Skip to content

Commit

Permalink
feat: cosmos-sdk v0.50.x (#3659)
Browse files Browse the repository at this point in the history
* update go.sum

* cosmos-sdk v0.50 imports

* changes imports and update sdk

* fix vet issues

* fix unused imports

* bump ibc

* add changelog

* update mocks

* rollback some test changes

* fix go version for the git workflows

* fix wront tx result for abci tx

* fix wrong test case

* remove some legacy methods and add module import blank to the `app_config.go`

* remove legacy amino and fix genesis commands

* fix module orders

* remove unused modules and commands

* fix module imports

* use statstore instead key and memory store

* fix missing runtime import for test keepers

* remove typo

* fix missing imports

* add msg signer option to the tx proto messages

* add release branch to trigger tests

* remove invalid test case

* fix typo

* fix missing create mesage option for single messages scaffold

* Initialized with Ignite CLI

* remove unused files

* `--events` flag was moved to `--query` into `query tx` command

* refactor: v0.50 store app wiring (#3672)

* refactor: v0.50 store app wiring

* updates

* updates

---------

Co-authored-by: Danilo Pantani <[email protected]>

* refactor: remove unecessary boilerplate in module (#3673)

* refactor: remove unecessary boilerplate in module

* updates

---------

Co-authored-by: Danilo Pantani <[email protected]>

* refactor: simplify app.go (#3675)

* refactor: simplify app.go

* updates

---------

Co-authored-by: Danilo Pantani <[email protected]>

* fix simulation types

* fix query txs params

* remove some empty lines

* refactor: remove unecessary boilerplate (#3676)

Co-authored-by: Danilo Pantani <[email protected]>

* update go.mod.plush

* rollback go.mod changes

* fix module discovery to use the keepers

* bump sdk and ibc

* find module per keeper

* check blank imports

* remove unused test data

* remove old support methods and move module pkg to module folder

* fix the module scaffold to find the module folder

* add more test case and blank imports

* use basepath instead roothopath

* add pre blockers

* fix cmd root_v2

* change ProvideClientContext to a pointer

* remove unused unit tests and fix others

* bump cosmos-sdk and run make format

* fix root.go

* fix wrong tx swagger generation

* fix ibc module import

* fix unit tests

* fix app config for the unit tests

* return ModuleCDC for ibc modules

* fix capability keeper without app wiring

* cleanup root.go and app.go

* rollback txConfigOpts

* use keepers injections as optional

* fix error handler assign for sim tests

* fix root sdk config call

* skip lint cache

* fix unit tests for app.go discovery

* fix test data

* add mmising interface methods for some tests

* fix cosmosanalystis find implementation methods

* fix ibc keepers for the testutil pkg

* fix expected keepers injection conflict

* remove unused expected keepers interfsces

* fix capability keeper nullpointer for unit tests

* fix module_ibc.go scaffolder

* rollback sdk context

* add creator options for packet msgs

* bump cosmos-sdk

* fix unhandled error

* rollback lint version and improve app module comments

* move appconfig inject to app.go

* fix default test config

* increase chain test timeout for integration

* remove unused `go.sum` files

* bump cosmos-sdk and ibc

* fix network tests

* add generic clenaup for the network config

* add cfg addresses manually

* avoid override config ports

* add chain id and log format to tx integration test

* add tx output

* add json output for key query

* bump ibc/capability and sdk/client

* bum go dependencies

* rollback not linux support dependency

* bump ibc

* regenerate mocks

* docs: update tutorials to work with SDK `v0.50` (#3705)

* chore: add `--chain-id` flag to blog commands

* chore: use `cosmossdk.io/store`

* chore: change blog tutorial to use the store service

* chore: use `cosmossdk.io/errors`

* chore: change "PostID" to "PostId"

* chore: add missing import to code snippet

* fix: correct expected keepers interface args

* chore: add `--chain-id` flag to loan commands

* ci: fix broken links

* ci: fix broken references

* ci: fix broken reference

* chore: fix typo

---------

Co-authored-by: Danilo Pantani <[email protected]>

* bum chain ibc

* fix: fix ibc registration in 0.50 (#3758)

* fix: fix ibc registration in 0.59

* updates

* nit

---------

Co-authored-by: Danilo Pantani <[email protected]>

* register capability module and fix genesis order

* ibc params register

---------

Co-authored-by: Pantani <Pantani>
Co-authored-by: Developer Experience team at Ignite <[email protected]>
Co-authored-by: Julien Robert <[email protected]>
Co-authored-by: Jerónimo Albi <[email protected]>
  • Loading branch information
4 people authored Nov 20, 2023
1 parent 2b53b25 commit 561d77b
Show file tree
Hide file tree
Showing 218 changed files with 4,813 additions and 6,742 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/md-link-checker-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
},
{
"pattern": "^index.md"
},
{
"pattern": "^https://docs.starport.network"
}
],
"replacementPatterns": [
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/md-link-checker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ on:
- "**.*.md"
branches:
- main
- release/*

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/test-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on:
- '**.md'
branches:
- main
- release/*

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ on:
- '**.md'
branches:
- main
- release/*

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
Expand Down
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
- [#3476](https://github.com/ignite/cli/pull/3476) Use `buf.build` binary to code generate from proto files
- [#3614](https://github.com/ignite/cli/pull/3614) feat: use DefaultBaseappOptions for app.New method
- [#3536](https://github.com/ignite/cli/pull/3536) Change app.go to v2 and add AppWiring feature
- [#3659](https://github.com/ignite/cli/pull/3659) cosmos-sdk `v0.50.x`
- [#3670](https://github.com/ignite/cli/pull/3670) Remove nodetime binaries
- [#3724](https://github.com/ignite/cli/pull/3724) Add or vendor proto packages from Go dependencies
- [#3715](https://github.com/ignite/cli/pull/3715) Add test suite for the cli tests
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/02-guide/03-hello/01-scaffolding.md
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ to the list of available commands, allowing users to call it from the
command-line interface (CLI).

```go title="x/hello/client/cli/query.go"
func GetQueryCmd(queryRoute string) *cobra.Command {
func GetQueryCmd() *cobra.Command {
cmd := &cobra.Command{
Use: types.ModuleName,
Short: fmt.Sprintf("Querying commands for the %s module", types.ModuleName),
Expand Down
10 changes: 5 additions & 5 deletions docs/docs/02-guide/04-blog/00-express.md
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ While `ignite chain serve` is running in one terminal window, open another
terminal and use the chain's binary to create a new blog post on the blockchain:

```
blogd tx blog create-post 'Hello, World!' 'This is a blog post' --from alice
blogd tx blog create-post 'Hello, World!' 'This is a blog post' --from alice --chain-id blog
```

When using the `--from` flag to specify the account that will be used to sign a
Expand Down Expand Up @@ -220,7 +220,7 @@ transaction will be broadcasted to the blockchain and the blog post will be
updated with the new body content.

```
blogd tx blog update-post 0 'Hello, World!' 'This is a blog post from Alice' --from alice
blogd tx blog update-post 0 'Hello, World!' 'This is a blog post from Alice' --from alice --chain-id blog
```

Now that we have updated the blog post with new content, let's query the
Expand Down Expand Up @@ -263,7 +263,7 @@ example of how the blockchain can enforce rules and permissions, and it shows
that only authorized users are able to make changes to the blockchain.

```
blogd tx blog delete-post 0 --from bob
blogd tx blog delete-post 0 --from bob --chain-id blog
raw_log: 'failed to execute message; message index: 0: incorrect owner: unauthorized'
```
Expand All @@ -273,7 +273,7 @@ account. Since Alice is the author of the blog post, she should be authorized to
delete it.

```
blogd tx blog delete-post 0 --from alice
blogd tx blog delete-post 0 --from alice --chain-id blog
```

To check whether the blog post has been successfully deleted by Alice, we can
Expand Down Expand Up @@ -306,4 +306,4 @@ some of the code ourselves, we can gain a deeper understanding of how Ignite
works and how it can be used to create applications on a blockchain. This will
help us learn more about the capabilities of Ignite CLI and how it can be used
to build robust and powerful applications. Keep an eye out for these tutorials
and get ready to dive deeper into the world of blockchains with Ignite!
and get ready to dive deeper into the world of blockchains with Ignite!
14 changes: 9 additions & 5 deletions docs/docs/02-guide/04-blog/03-create.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,16 @@ import (

"blog/x/blog/types"

"github.com/cosmos/cosmos-sdk/store/prefix"
"cosmossdk.io/store/prefix"
"github.com/cosmos/cosmos-sdk/runtime"
sdk "github.com/cosmos/cosmos-sdk/types"
)

func (k Keeper) AppendPost(ctx sdk.Context, post types.Post) uint64 {
count := k.GetPostCount(ctx)
post.Id = count
store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.PostKey))
storeAdapter := runtime.KVStoreAdapter(k.storeService.OpenKVStore(ctx))
store := prefix.NewStore(storeAdapter, types.KeyPrefix(types.PostKey))
appendedValue := k.cdc.MustMarshal(&post)
store.Set(GetPostIDBytes(post.Id), appendedValue)
k.SetPostCount(ctx, count+1)
Expand Down Expand Up @@ -126,7 +128,8 @@ In the file `post.go`, let's define the `GetPostCount` function as follows:

```go title="x/blog/keeper/post.go"
func (k Keeper) GetPostCount(ctx sdk.Context) uint64 {
store := prefix.NewStore(ctx.KVStore(k.storeKey), []byte{})
storeAdapter := runtime.KVStoreAdapter(k.storeService.OpenKVStore(ctx))
store := prefix.NewStore(storeAdapter, []byte{})
byteKey := types.KeyPrefix(types.PostCountKey)
bz := store.Get(byteKey)
if bz == nil {
Expand Down Expand Up @@ -209,7 +212,8 @@ in the database.

```go title="x/blog/keeper/post.go"
func (k Keeper) SetPostCount(ctx sdk.Context, count uint64) {
store := prefix.NewStore(ctx.KVStore(k.storeKey), []byte{})
storeAdapter := runtime.KVStoreAdapter(k.storeService.OpenKVStore(ctx))
store := prefix.NewStore(storeAdapter, []byte{})
byteKey := types.KeyPrefix(types.PostCountKey)
bz := make([]byte, 8)
binary.BigEndian.PutUint64(bz, count)
Expand Down Expand Up @@ -316,4 +320,4 @@ then returns a `MsgCreatePostResponse` object containing the ID of the newly
created post.

By implementing these methods, you have successfully implemented the necessary
logic for handling "create post" messages and adding posts to the blockchain.
logic for handling "create post" messages and adding posts to the blockchain.
13 changes: 8 additions & 5 deletions docs/docs/02-guide/04-blog/04-update.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ Implement the `GetPost` keeper method in `post.go`:

```go title="x/blog/keeper/post.go"
func (k Keeper) GetPost(ctx sdk.Context, id uint64) (val types.Post, found bool) {
store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.PostKey))
storeAdapter := runtime.KVStoreAdapter(k.storeService.OpenKVStore(ctx))
store := prefix.NewStore(storeAdapter, types.KeyPrefix(types.PostKey))
b := store.Get(GetPostIDBytes(id))
if b == nil {
return val, false
Expand Down Expand Up @@ -48,7 +49,8 @@ Implement the `SetPost` keeper method in `post.go`:

```go title="x/blog/keeper/post.go"
func (k Keeper) SetPost(ctx sdk.Context, post types.Post) {
store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.PostKey))
storeAdapter := runtime.KVStoreAdapter(k.storeService.OpenKVStore(ctx))
store := prefix.NewStore(storeAdapter, types.KeyPrefix(types.PostKey))
b := k.cdc.MustMarshal(&post)
store.Set(GetPostIDBytes(post.Id), b)
}
Expand Down Expand Up @@ -78,6 +80,7 @@ import (

"blog/x/blog/types"

errorsmod "cosmossdk.io/errors"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
)
Expand All @@ -92,10 +95,10 @@ func (k msgServer) UpdatePost(goCtx context.Context, msg *types.MsgUpdatePost) (
}
val, found := k.GetPost(ctx, msg.Id)
if !found {
return nil, sdkerrors.Wrap(sdkerrors.ErrKeyNotFound, fmt.Sprintf("key %d doesn't exist", msg.Id))
return nil, errorsmod.Wrap(sdkerrors.ErrKeyNotFound, fmt.Sprintf("key %d doesn't exist", msg.Id))
}
if msg.Creator != val.Creator {
return nil, sdkerrors.Wrap(sdkerrors.ErrUnauthorized, "incorrect owner")
return nil, errorsmod.Wrap(sdkerrors.ErrUnauthorized, "incorrect owner")
}
k.SetPost(ctx, post)
return &types.MsgUpdatePostResponse{}, nil
Expand Down Expand Up @@ -124,4 +127,4 @@ can be useful for correcting mistakes or updating the content of a post as new
information becomes available.

Finally, you implemented the `UpdatePost` method, which is called whenever the
blockchain processes a message requesting an update to a post.
blockchain processes a message requesting an update to a post.
12 changes: 7 additions & 5 deletions docs/docs/02-guide/04-blog/05-delete.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ message.

```go title="x/blog/keeper/post.go"
func (k Keeper) RemovePost(ctx sdk.Context, id uint64) {
store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.PostKey))
storeAdapter := runtime.KVStoreAdapter(k.storeService.OpenKVStore(ctx))
store := prefix.NewStore(storeAdapter, types.KeyPrefix(types.PostKey))
store.Delete(GetPostIDBytes(id))
}
```
Expand All @@ -32,6 +33,7 @@ import (

"blog/x/blog/types"

errorsmod "cosmossdk.io/errors"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
)
Expand All @@ -40,10 +42,10 @@ func (k msgServer) DeletePost(goCtx context.Context, msg *types.MsgDeletePost) (
ctx := sdk.UnwrapSDKContext(goCtx)
val, found := k.GetPost(ctx, msg.Id)
if !found {
return nil, sdkerrors.Wrap(sdkerrors.ErrKeyNotFound, fmt.Sprintf("key %d doesn't exist", msg.Id))
return nil, errorsmod.Wrap(sdkerrors.ErrKeyNotFound, fmt.Sprintf("key %d doesn't exist", msg.Id))
}
if msg.Creator != val.Creator {
return nil, sdkerrors.Wrap(sdkerrors.ErrUnauthorized, "incorrect owner")
return nil, errorsmod.Wrap(sdkerrors.ErrUnauthorized, "incorrect owner")
}
k.RemovePost(ctx, msg.Id)
return &types.MsgDeletePostResponse{}, nil
Expand All @@ -57,7 +59,7 @@ a pointer to a message of type `*types.MsgDeletePostResponse` and an `error`.
Inside the function, the context is unwrapped using the `sdk.UnwrapSDKContext`
function and the value of the post with the ID specified in the message is
retrieved using the `GetPost` function. If the post is not found, an error is
returned using the `sdkerrors.Wrap` function. If the creator of the message does
returned using the `errorsmod.Wrap` function. If the creator of the message does
not match the creator of the post, another error is returned. If both of these
checks pass, the `RemovePost` function is called with the context and the ID of
the post to delete the post. Finally, the function returns a response message
Expand All @@ -71,4 +73,4 @@ requester is the creator of the post before deleting it.
Congratulations on completing the implementation of the `RemovePost` and
`DeletePost` methods in the keeper package! These methods provide functionality
for removing a post from a store and handling a request to delete a post,
respectively.
respectively.
31 changes: 14 additions & 17 deletions docs/docs/02-guide/04-blog/07-list.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,25 +22,24 @@ import (

"blog/x/blog/types"

"github.com/cosmos/cosmos-sdk/store/prefix"
"cosmossdk.io/store/prefix"
"github.com/cosmos/cosmos-sdk/runtime"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/query"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
)

func (k Keeper) ListPost(goCtx context.Context, req *types.QueryListPostRequest) (*types.QueryListPostResponse, error) {
func (k Keeper) ListPost(ctx context.Context, req *types.QueryListPostRequest) (*types.QueryListPostResponse, error) {
if req == nil {
return nil, status.Error(codes.InvalidArgument, "invalid request")
}

var posts []types.Post
ctx := sdk.UnwrapSDKContext(goCtx)

store := ctx.KVStore(k.storeKey)
postStore := prefix.NewStore(store, types.KeyPrefix(types.PostKey))
storeAdapter := runtime.KVStoreAdapter(k.storeService.OpenKVStore(ctx))
store := prefix.NewStore(storeAdapter, types.KeyPrefix(types.PostKey))

pageRes, err := query.Paginate(postStore, req.Pagination, func(key []byte, value []byte) error {
var posts []types.Post
pageRes, err := query.Paginate(store, req.Pagination, func(key []byte, value []byte) error {
var post types.Post
if err := k.cdc.Unmarshal(value, &post); err != nil {
return err
Expand All @@ -63,14 +62,12 @@ func (k Keeper) ListPost(goCtx context.Context, req *types.QueryListPostRequest)
`QueryListPostResponse` and an error.

The function first checks if the request object is `nil` and returns an error
with a `InvalidArgument` code if it is. It then initializes an empty slice of
`Post` objects and unwraps the context object.

It retrieves a key-value store from the context using the `storeKey` field of
the keeper struct and creates a new store using a prefix of the `PostKey`. It
then calls the `Paginate` function from the `query` package on the store and the
pagination information in the request object. The function passed as an argument
to Paginate iterates over the key-value pairs in the store and unmarshals the
with a `InvalidArgument` code if it is.

It creates a new store using a prefix of the `PostKey` and then calls the
`Paginate` function from the `query` package on the store and the pagination
information in the request object. The function passed as an argument to
Paginate iterates over the key-value pairs in the store and unmarshals the
values into `Post` objects, which are then appended to the `posts` slice.

If an error occurs during pagination, the function returns an `Internal error`
Expand All @@ -94,4 +91,4 @@ Run the command to generate Go files from proto:

```
ignite generate proto-go
```
```
12 changes: 6 additions & 6 deletions docs/docs/02-guide/04-blog/08-play.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
## Create a blog post by Alice

```
blogd tx blog create-post hello world --from alice
blogd tx blog create-post hello world --from alice --chain-id blog
```

## Show a blog post
Expand All @@ -23,7 +23,7 @@ post:
## Create a blog post by Bob
```
blogd tx blog create-post foo bar --from bob
blogd tx blog create-post foo bar --from bob --chain-id blog
```

## List all blog posts with pagination
Expand All @@ -50,7 +50,7 @@ post:
## Update a blog post
```
blogd tx blog update-post hello cosmos 0 --from alice
blogd tx blog update-post hello cosmos 0 --from alice --chain-id blog
```

```
Expand All @@ -68,7 +68,7 @@ post:
## Delete a blog post
```
blogd tx blog delete-post 0 --from alice
blogd tx blog delete-post 0 --from alice --chain-id blog
```

```
Expand All @@ -89,9 +89,9 @@ post:
## Delete a blog post unsuccessfully
```
blogd tx blog delete-post 1 --from alice
blogd tx blog delete-post 1 --from alice --chain-id blog
```

```yml
raw_log: 'failed to execute message; message index: 0: incorrect owner: unauthorized'
```
```
8 changes: 4 additions & 4 deletions docs/docs/02-guide/05-loan/02-bank.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ import (
type BankKeeper interface {
SpendableCoins(ctx sdk.Context, addr sdk.AccAddress) sdk.Coins
// highlight-start
SendCoins(ctx sdk.Context, fromAddr sdk.AccAddress, toAddr sdk.AccAddress, amt sdk.Coins) error
SendCoinsFromAccountToModule(ctx sdk.Context, senderAddr sdk.AccAddress, recipientModule string, amt sdk.Coins) error
SendCoinsFromModuleToAccount(ctx sdk.Context, senderModule string, recipientAddr sdk.AccAddress, amt sdk.Coins) error
SendCoins(ctx context.Context, fromAddr sdk.AccAddress, toAddr sdk.AccAddress, amt sdk.Coins) error
SendCoinsFromAccountToModule(ctx context.Context, senderAddr sdk.AccAddress, recipientModule string, amt sdk.Coins) error
SendCoinsFromModuleToAccount(ctx context.Context, senderModule string, recipientAddr sdk.AccAddress, amt sdk.Coins) error
// highlight-end
}
```
```
Loading

0 comments on commit 561d77b

Please sign in to comment.