Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: cosmos-sdk v0.50.x #3659

Merged
merged 147 commits into from
Nov 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
147 commits
Select commit Hold shift + click to select a range
7417c15
update go.sum
Sep 15, 2023
046a47b
Merge remote-tracking branch 'origin/main' into feat/sdk-v0.50
Sep 18, 2023
7356681
cosmos-sdk v0.50 imports
Sep 18, 2023
855c8bb
changes imports and update sdk
Sep 18, 2023
bd4ea39
fix vet issues
Sep 18, 2023
994660b
fix unused imports
Sep 19, 2023
6b9956b
bump ibc
Sep 19, 2023
be9288d
Merge branch 'main' into feat/sdk-v0.50
Pantani Sep 19, 2023
91df772
add changelog
Sep 19, 2023
61fbfb4
update mocks
Sep 19, 2023
fa9a1af
rollback some test changes
Sep 19, 2023
cb22273
fix go version for the git workflows
Sep 19, 2023
5e1afdd
fix wront tx result for abci tx
Sep 19, 2023
d07c286
Merge branch 'main' into feat/sdk-v0.50
Pantani Sep 20, 2023
f564ad0
fix wrong test case
Sep 20, 2023
d4e2507
remove some legacy methods and add module import blank to the `app_co…
Sep 22, 2023
736a2b2
Merge remote-tracking branch 'origin/main' into feat/sdk-v0.50
Sep 26, 2023
811f0bb
remove legacy amino and fix genesis commands
Sep 26, 2023
c0322ec
fix module orders
Sep 26, 2023
b454808
remove unused modules and commands
Sep 26, 2023
7945ea9
fix module imports
Sep 26, 2023
a8047bd
use statstore instead key and memory store
Sep 26, 2023
dfe6ad9
fix missing runtime import for test keepers
Sep 26, 2023
cb5e1df
remove typo
Sep 26, 2023
199a2cb
fix missing imports
Sep 26, 2023
e52af75
add msg signer option to the tx proto messages
Sep 26, 2023
70f5e86
Merge remote-tracking branch 'origin/main' into feat/sdk-v0.50
Sep 27, 2023
2bdb1c4
add release branch to trigger tests
Sep 27, 2023
b31dc57
remove invalid test case
Sep 27, 2023
f54c916
fix typo
Sep 27, 2023
eb8ef34
Merge branch 'main' into feat/sdk-v0.50
Pantani Sep 27, 2023
ba0ce77
fix missing create mesage option for single messages scaffold
Sep 27, 2023
8da1c2a
Initialized with Ignite CLI
Sep 27, 2023
1e6267d
remove unused files
Sep 27, 2023
c2b960e
`--events` flag was moved to `--query` into `query tx` command
Sep 29, 2023
7fd3d54
refactor: v0.50 store app wiring (#3672)
julienrbrt Sep 29, 2023
a71496c
refactor: remove unecessary boilerplate in module (#3673)
julienrbrt Sep 29, 2023
46629bf
refactor: simplify app.go (#3675)
julienrbrt Sep 29, 2023
fec7f91
fix simulation types
Sep 29, 2023
07bc4a9
fix query txs params
Sep 29, 2023
5213a3d
remove some empty lines
Sep 29, 2023
0862f96
Merge branch 'main' into feat/sdk-v0.50
Pantani Sep 29, 2023
1d8f9b5
Merge branch 'main' into feat/sdk-v0.50
Pantani Sep 29, 2023
c14da74
refactor: remove unecessary boilerplate (#3676)
julienrbrt Sep 29, 2023
274d536
update go.mod.plush
Sep 29, 2023
41638ec
rollback go.mod changes
Sep 29, 2023
8bb73b3
fix module discovery to use the keepers
Oct 4, 2023
7a2e2f6
Merge branch 'main' into feat/sdk-v0.50
Pantani Oct 4, 2023
17b4391
bump sdk and ibc
Oct 4, 2023
8fe304d
find module per keeper
Oct 4, 2023
9c052cb
Merge branch 'main' into feat/sdk-v0.50
Pantani Oct 4, 2023
52683bc
check blank imports
Oct 4, 2023
41cb37f
remove unused test data
Oct 4, 2023
bddf8e8
remove old support methods and move module pkg to module folder
Oct 5, 2023
e2f0ba9
fix the module scaffold to find the module folder
Oct 5, 2023
fc2629e
add more test case and blank imports
Oct 5, 2023
d1568ea
use basepath instead roothopath
Oct 5, 2023
ff0a6ef
add pre blockers
Oct 5, 2023
a334cb2
fix cmd root_v2
Oct 5, 2023
18c8448
change ProvideClientContext to a pointer
Oct 5, 2023
591d05c
Merge branch 'main' into feat/sdk-v0.50
Pantani Oct 5, 2023
513c86e
remove unused unit tests and fix others
Oct 5, 2023
f0c7030
bump cosmos-sdk and run make format
Oct 5, 2023
2f81bd6
fix root.go
julienrbrt Oct 5, 2023
da17f3d
fix wrong tx swagger generation
Oct 6, 2023
564da66
fix ibc module import
Oct 6, 2023
b5096e9
fix unit tests
Oct 8, 2023
a652d8e
fix app config for the unit tests
Oct 9, 2023
1726b4b
return ModuleCDC for ibc modules
Oct 9, 2023
b12e007
fix capability keeper without app wiring
Oct 9, 2023
ec693fa
cleanup root.go and app.go
Oct 10, 2023
b0a975e
rollback txConfigOpts
Oct 10, 2023
fd478f0
use keepers injections as optional
Oct 10, 2023
7a2b776
Merge remote-tracking branch 'origin/main' into feat/sdk-v0.50
Oct 10, 2023
3e13181
fix error handler assign for sim tests
Oct 10, 2023
9c5c487
fix root sdk config call
Oct 10, 2023
ba1f45b
skip lint cache
Oct 10, 2023
4fb1a51
fix unit tests for app.go discovery
Oct 10, 2023
5ba6f96
fix test data
Oct 10, 2023
dc601a0
add mmising interface methods for some tests
Oct 10, 2023
79389f5
fix cosmosanalystis find implementation methods
Oct 11, 2023
9227d7c
fix ibc keepers for the testutil pkg
Oct 11, 2023
ff67023
fix expected keepers injection conflict
Oct 11, 2023
bc59139
remove unused expected keepers interfsces
Oct 11, 2023
31fc570
fix capability keeper nullpointer for unit tests
Oct 11, 2023
3ead9fe
fix module_ibc.go scaffolder
Oct 11, 2023
a42c8be
rollback sdk context
Oct 11, 2023
c1b6206
add creator options for packet msgs
Oct 11, 2023
443cd90
bump cosmos-sdk
Oct 11, 2023
58db6e3
fix unhandled error
Oct 11, 2023
73831a0
Merge remote-tracking branch 'origin/main' into feat/sdk-v0.50
Oct 12, 2023
bf11343
Merge branch 'main' into feat/sdk-v0.50
Pantani Oct 12, 2023
588e7d0
Merge branch 'main' into feat/sdk-v0.50
Pantani Oct 12, 2023
5d481af
Merge branch 'main' into feat/sdk-v0.50
Pantani Oct 13, 2023
9384106
Merge branch 'main' into feat/sdk-v0.50
Pantani Oct 16, 2023
3bd59c0
Merge branch 'main' into feat/sdk-v0.50
Pantani Oct 16, 2023
8b5f007
Merge branch 'main' into feat/sdk-v0.50
Pantani Oct 16, 2023
34d807c
Merge branch 'main' into feat/sdk-v0.50
Pantani Oct 18, 2023
1c10b12
rollback lint version and improve app module comments
Oct 18, 2023
98bc8d6
Merge branch 'main' into feat/sdk-v0.50
Pantani Oct 18, 2023
5403dcc
Merge branch 'main' into feat/sdk-v0.50
jeronimoalbi Oct 19, 2023
3a8f232
move appconfig inject to app.go
Oct 19, 2023
e22e20b
fix default test config
Oct 19, 2023
d2eabb5
Merge branch 'main' into feat/sdk-v0.50
Pantani Oct 19, 2023
25c93f5
increase chain test timeout for integration
Oct 19, 2023
f525f64
Merge remote-tracking branch 'origin/main' into feat/sdk-v0.50
Oct 19, 2023
82355e8
Merge branch 'main' into feat/sdk-v0.50
Pantani Oct 19, 2023
3629651
Merge branch 'main' into feat/sdk-v0.50
Pantani Oct 24, 2023
edc0c11
Merge remote-tracking branch 'origin/main' into feat/sdk-v0.50
Oct 24, 2023
367b87b
remove unused `go.sum` files
Oct 24, 2023
cbec276
Merge remote-tracking branch 'origin/main' into feat/sdk-v0.50
Oct 31, 2023
0ade246
Merge remote-tracking branch 'origin/main' into feat/sdk-v0.50
Nov 6, 2023
d1bab5e
Merge branch 'main' into feat/sdk-v0.50
Pantani Nov 6, 2023
8f3f478
Merge branch 'main' into feat/sdk-v0.50
Pantani Nov 6, 2023
a757c69
Merge branch 'main' into feat/sdk-v0.50
Pantani Nov 6, 2023
51cfa45
Merge branch 'main' into feat/sdk-v0.50
Pantani Nov 6, 2023
d6024ff
Merge branch 'main' into feat/sdk-v0.50
Pantani Nov 6, 2023
85f7c92
Merge remote-tracking branch 'origin/main' into feat/sdk-v0.50
Nov 7, 2023
d4ba712
bump cosmos-sdk and ibc
Nov 7, 2023
34b5a86
Merge branch 'main' into feat/sdk-v0.50
Pantani Nov 8, 2023
aeb2432
fix network tests
Nov 8, 2023
d3d1001
add generic clenaup for the network config
Nov 9, 2023
3a1051e
add cfg addresses manually
Nov 9, 2023
1e85559
avoid override config ports
Nov 9, 2023
8950b0b
Merge branch 'main' into feat/sdk-v0.50
Pantani Nov 9, 2023
89ecddd
add chain id and log format to tx integration test
Nov 9, 2023
7144225
add tx output
Nov 9, 2023
5275618
add json output for key query
Nov 9, 2023
8665f19
bump ibc/capability and sdk/client
Nov 9, 2023
3a8e27d
bum go dependencies
Nov 9, 2023
29a53de
rollback not linux support dependency
Nov 9, 2023
07dbd3c
Merge remote-tracking branch 'origin/main' into feat/sdk-v0.50
Nov 11, 2023
5a321b2
bump ibc
Nov 11, 2023
336121c
regenerate mocks
Nov 11, 2023
c7e38c6
docs: update tutorials to work with SDK `v0.50` (#3705)
jeronimoalbi Nov 11, 2023
bad0da8
Merge branch 'main' into feat/sdk-v0.50
Pantani Nov 11, 2023
2631b49
Merge remote-tracking branch 'origin/main' into feat/sdk-v0.50
Nov 11, 2023
d01e2e4
Merge branch 'main' into feat/sdk-v0.50
Pantani Nov 12, 2023
c0297e5
Merge remote-tracking branch 'origin/main' into feat/sdk-v0.50
Nov 14, 2023
c0c8f9f
Merge branch 'main' into feat/sdk-v0.50
Pantani Nov 14, 2023
c6983d3
Merge remote-tracking branch 'origin/main' into feat/sdk-v0.50
Nov 14, 2023
c2f5783
Merge branch 'main' into feat/sdk-v0.50
Pantani Nov 15, 2023
cb556cf
Merge remote-tracking branch 'origin/main' into feat/sdk-v0.50
Nov 17, 2023
77b36b7
bum chain ibc
Nov 17, 2023
6c6533c
fix: fix ibc registration in 0.50 (#3758)
julienrbrt Nov 17, 2023
fac8ad6
register capability module and fix genesis order
Nov 17, 2023
b8a87cd
ibc params register
Nov 20, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading