diff --git a/.github/workflows/md-link-checker-config.json b/.github/workflows/md-link-checker-config.json index fa7f2bde39..e70d47c119 100644 --- a/.github/workflows/md-link-checker-config.json +++ b/.github/workflows/md-link-checker-config.json @@ -17,6 +17,9 @@ }, { "pattern": "^index.md" + }, + { + "pattern": "^https://docs.starport.network" } ], "replacementPatterns": [ diff --git a/docs/docs/02-guide/04-blog/00-express.md b/docs/docs/02-guide/04-blog/00-express.md index e2cb2fc142..c7932c17b2 100644 --- a/docs/docs/02-guide/04-blog/00-express.md +++ b/docs/docs/02-guide/04-blog/00-express.md @@ -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 @@ -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 @@ -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' ``` @@ -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 @@ -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! \ No newline at end of file +and get ready to dive deeper into the world of blockchains with Ignite! diff --git a/docs/docs/02-guide/04-blog/03-create.md b/docs/docs/02-guide/04-blog/03-create.md index 5e0ea9209e..f5ef40183e 100644 --- a/docs/docs/02-guide/04-blog/03-create.md +++ b/docs/docs/02-guide/04-blog/03-create.md @@ -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) @@ -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 { @@ -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) @@ -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. \ No newline at end of file +logic for handling "create post" messages and adding posts to the blockchain. diff --git a/docs/docs/02-guide/04-blog/04-update.md b/docs/docs/02-guide/04-blog/04-update.md index 7be1ca80bc..462837b81d 100644 --- a/docs/docs/02-guide/04-blog/04-update.md +++ b/docs/docs/02-guide/04-blog/04-update.md @@ -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 @@ -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) } @@ -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" ) @@ -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 @@ -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. \ No newline at end of file +blockchain processes a message requesting an update to a post. diff --git a/docs/docs/02-guide/04-blog/05-delete.md b/docs/docs/02-guide/04-blog/05-delete.md index 4bef35b8de..1fe784ec2a 100644 --- a/docs/docs/02-guide/04-blog/05-delete.md +++ b/docs/docs/02-guide/04-blog/05-delete.md @@ -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)) } ``` @@ -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" ) @@ -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 @@ -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 @@ -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. \ No newline at end of file +respectively. diff --git a/docs/docs/02-guide/04-blog/07-list.md b/docs/docs/02-guide/04-blog/07-list.md index 268a3349a5..919149bc64 100644 --- a/docs/docs/02-guide/04-blog/07-list.md +++ b/docs/docs/02-guide/04-blog/07-list.md @@ -22,25 +22,24 @@ import ( "blog/x/blog/types" - "github.com/cosmos/cosmos-sdk/store/prefix" + "cosmossdk.io/store/prefix" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/runtime" "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 @@ -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` @@ -94,4 +91,4 @@ Run the command to generate Go files from proto: ``` ignite generate proto-go -``` \ No newline at end of file +``` diff --git a/docs/docs/02-guide/04-blog/08-play.md b/docs/docs/02-guide/04-blog/08-play.md index abda90113f..e41f02678e 100644 --- a/docs/docs/02-guide/04-blog/08-play.md +++ b/docs/docs/02-guide/04-blog/08-play.md @@ -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 @@ -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 @@ -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 ``` ``` @@ -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 ``` ``` @@ -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' -``` \ No newline at end of file +``` diff --git a/docs/docs/02-guide/05-loan/02-bank.md b/docs/docs/02-guide/05-loan/02-bank.md index 440c806e79..bdc2c726ca 100644 --- a/docs/docs/02-guide/05-loan/02-bank.md +++ b/docs/docs/02-guide/05-loan/02-bank.md @@ -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 } -``` \ No newline at end of file +``` diff --git a/docs/docs/02-guide/05-loan/03-request.md b/docs/docs/02-guide/05-loan/03-request.md index a68aed6845..d540ab557c 100644 --- a/docs/docs/02-guide/05-loan/03-request.md +++ b/docs/docs/02-guide/05-loan/03-request.md @@ -76,6 +76,7 @@ import ( // highlight-next-line "strconv" + errorsmod "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" ) @@ -83,33 +84,33 @@ import ( func (msg *MsgRequestLoan) ValidateBasic() error { _, err := sdk.AccAddressFromBech32(msg.Creator) if err != nil { - return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid creator address (%s)", err) + return errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, "invalid creator address (%s)", err) } // highlight-start amount, _ := sdk.ParseCoinsNormalized(msg.Amount) if !amount.IsValid() { - return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "amount is not a valid Coins object") + return errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "amount is not a valid Coins object") } if amount.Empty() { - return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "amount is empty") + return errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "amount is empty") } fee, _ := sdk.ParseCoinsNormalized(msg.Fee) if !fee.IsValid() { - return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "fee is not a valid Coins object") + return errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "fee is not a valid Coins object") } deadline, err := strconv.ParseInt(msg.Deadline, 10, 64) if err != nil { - return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "deadline is not an integer") + return errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "deadline is not an integer") } if deadline <= 0 { - return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "deadline should be a positive integer") + return errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "deadline should be a positive integer") } collateral, _ := sdk.ParseCoinsNormalized(msg.Collateral) if !collateral.IsValid() { - return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "collateral is not a valid Coins object") + return errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "collateral is not a valid Coins object") } if collateral.Empty() { - return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "collateral is empty") + return errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "collateral is empty") } // highlight-end return nil diff --git a/docs/docs/02-guide/05-loan/04-approve.md b/docs/docs/02-guide/05-loan/04-approve.md index 4fb75acf66..d1ff0d5d5d 100644 --- a/docs/docs/02-guide/05-loan/04-approve.md +++ b/docs/docs/02-guide/05-loan/04-approve.md @@ -21,6 +21,7 @@ package keeper import ( "context" + errorsmod "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" @@ -31,16 +32,16 @@ func (k msgServer) ApproveLoan(goCtx context.Context, msg *types.MsgApproveLoan) ctx := sdk.UnwrapSDKContext(goCtx) loan, found := k.GetLoan(ctx, msg.Id) if !found { - return nil, sdkerrors.Wrapf(sdkerrors.ErrKeyNotFound, "key %d doesn't exist", msg.Id) + return nil, errorsmod.Wrapf(sdkerrors.ErrKeyNotFound, "key %d doesn't exist", msg.Id) } if loan.State != "requested" { - return nil, sdkerrors.Wrapf(types.ErrWrongLoanState, "%v", loan.State) + return nil, errorsmod.Wrapf(types.ErrWrongLoanState, "%v", loan.State) } lender, _ := sdk.AccAddressFromBech32(msg.Creator) borrower, _ := sdk.AccAddressFromBech32(loan.Borrower) amount, err := sdk.ParseCoinsNormalized(loan.Amount) if err != nil { - return nil, sdkerrors.Wrap(types.ErrWrongLoanState, "Cannot parse coins in loan amount") + return nil, errorsmod.Wrap(types.ErrWrongLoanState, "Cannot parse coins in loan amount") } err = k.bankKeeper.SendCoins(ctx, lender, borrower, amount) if err != nil { @@ -94,4 +95,4 @@ import ( var ( ErrWrongLoanState = sdkerrors.Register(ModuleName, 2, "wrong loan state") ) -``` \ No newline at end of file +``` diff --git a/docs/docs/02-guide/05-loan/05-repay.md b/docs/docs/02-guide/05-loan/05-repay.md index 72150f695f..232327d349 100644 --- a/docs/docs/02-guide/05-loan/05-repay.md +++ b/docs/docs/02-guide/05-loan/05-repay.md @@ -25,6 +25,7 @@ package keeper import ( "context" + errorsmod "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" @@ -35,15 +36,15 @@ func (k msgServer) RepayLoan(goCtx context.Context, msg *types.MsgRepayLoan) (*t ctx := sdk.UnwrapSDKContext(goCtx) loan, found := k.GetLoan(ctx, msg.Id) if !found { - return nil, sdkerrors.Wrapf(sdkerrors.ErrKeyNotFound, "key %d doesn't exist", msg.Id) + return nil, errorsmod.Wrapf(sdkerrors.ErrKeyNotFound, "key %d doesn't exist", msg.Id) } if loan.State != "approved" { - return nil, sdkerrors.Wrapf(types.ErrWrongLoanState, "%v", loan.State) + return nil, errorsmod.Wrapf(types.ErrWrongLoanState, "%v", loan.State) } lender, _ := sdk.AccAddressFromBech32(loan.Lender) borrower, _ := sdk.AccAddressFromBech32(loan.Borrower) if msg.Creator != loan.Borrower { - return nil, sdkerrors.Wrap(sdkerrors.ErrUnauthorized, "Cannot repay: not the borrower") + return nil, errorsmod.Wrap(sdkerrors.ErrUnauthorized, "Cannot repay: not the borrower") } amount, _ := sdk.ParseCoinsNormalized(loan.Amount) fee, _ := sdk.ParseCoinsNormalized(loan.Fee) diff --git a/docs/docs/02-guide/05-loan/06-liquidate.md b/docs/docs/02-guide/05-loan/06-liquidate.md index 8d49058b76..419cc740b1 100644 --- a/docs/docs/02-guide/05-loan/06-liquidate.md +++ b/docs/docs/02-guide/05-loan/06-liquidate.md @@ -23,6 +23,7 @@ import ( "context" "strconv" + errorsmod "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" @@ -33,13 +34,13 @@ func (k msgServer) LiquidateLoan(goCtx context.Context, msg *types.MsgLiquidateL ctx := sdk.UnwrapSDKContext(goCtx) loan, found := k.GetLoan(ctx, msg.Id) if !found { - return nil, sdkerrors.Wrapf(sdkerrors.ErrKeyNotFound, "key %d doesn't exist", msg.Id) + return nil, errorsmod.Wrapf(sdkerrors.ErrKeyNotFound, "key %d doesn't exist", msg.Id) } if loan.Lender != msg.Creator { - return nil, sdkerrors.Wrap(sdkerrors.ErrUnauthorized, "Cannot liquidate: not the lender") + return nil, errorsmod.Wrap(sdkerrors.ErrUnauthorized, "Cannot liquidate: not the lender") } if loan.State != "approved" { - return nil, sdkerrors.Wrapf(types.ErrWrongLoanState, "%v", loan.State) + return nil, errorsmod.Wrapf(types.ErrWrongLoanState, "%v", loan.State) } lender, _ := sdk.AccAddressFromBech32(loan.Lender) collateral, _ := sdk.ParseCoinsNormalized(loan.Collateral) @@ -48,7 +49,7 @@ func (k msgServer) LiquidateLoan(goCtx context.Context, msg *types.MsgLiquidateL panic(err) } if ctx.BlockHeight() < deadline { - return nil, sdkerrors.Wrap(types.ErrDeadline, "Cannot liquidate before deadline") + return nil, errorsmod.Wrap(types.ErrDeadline, "Cannot liquidate before deadline") } err = k.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, lender, collateral) if err != nil { @@ -62,15 +63,15 @@ func (k msgServer) LiquidateLoan(goCtx context.Context, msg *types.MsgLiquidateL `LiquidateLoan` takes in a context and a `types.MsgLiquidateLoan` message as input and returns a types.MsgLiquidateLoanResponse message and an error as output. -The function first retrieves a loan using the `GetLoan` method and the `Id` field of the input message. If the loan is not found, it returns an error using the `sdkerrors.Wrap` function and the `sdkerrors.ErrKeyNotFound` error code. +The function first retrieves a loan using the `GetLoan` method and the `Id` field of the input message. If the loan is not found, it returns an error using the `errorsmod.Wrap` function and the `sdkerrors.ErrKeyNotFound` error code. -Next, the function checks that the `Creator` field of the input message is the same as the `Lender` field of the loan. If they are not the same, it returns an error using the `sdkerrors.Wrap` function and the `sdkerrors.ErrUnauthorized` error code. +Next, the function checks that the `Creator` field of the input message is the same as the `Lender` field of the loan. If they are not the same, it returns an error using the `errorsmod.Wrap` function and the `sdkerrors.ErrUnauthorized` error code. -The function then checks that the State field of the loan is equal to "approved". If it is not, it returns an error using the `sdkerrors.Wrapf` function and the `types.ErrWrongLoanState` error code. +The function then checks that the State field of the loan is equal to "approved". If it is not, it returns an error using the `errorsmod.Wrapf` function and the `types.ErrWrongLoanState` error code. The function then converts the Lender field of the loan to an address using the `sdk.AccAddressFromBech32` function and the `Collateral` field to coins using the `sdk.ParseCoinsNormalized` function. It also converts the `Deadline` field to an integer using the `strconv.ParseInt` function. If this function returns an error, it panics. -Finally, the function checks that the current block height is greater than or equal to the deadline. If it is not, it returns an error using the `sdkerrors.Wrap` function and the `types.ErrDeadline` error code. If all checks pass, the function uses the `bankKeeper.SendCoinsFromModuleToAccount` method to transfer the collateral from the module account to the lender's account and updates the `State` field of the loan to `"liquidated"`. It then stores the updated loan using the `SetLoan` method and returns a `types.MsgLiquidateLoanResponse` message with no error. +Finally, the function checks that the current block height is greater than or equal to the deadline. If it is not, it returns an error using the `errorsmod.Wrap` function and the `types.ErrDeadline` error code. If all checks pass, the function uses the `bankKeeper.SendCoinsFromModuleToAccount` method to transfer the collateral from the module account to the lender's account and updates the `State` field of the loan to `"liquidated"`. It then stores the updated loan using the `SetLoan` method and returns a `types.MsgLiquidateLoanResponse` message with no error. ## Register a custom error diff --git a/docs/docs/02-guide/05-loan/07-cancel.md b/docs/docs/02-guide/05-loan/07-cancel.md index 3997072a92..9415fe6ada 100644 --- a/docs/docs/02-guide/05-loan/07-cancel.md +++ b/docs/docs/02-guide/05-loan/07-cancel.md @@ -15,6 +15,7 @@ package keeper import ( "context" + errorsmod "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" @@ -25,13 +26,13 @@ func (k msgServer) CancelLoan(goCtx context.Context, msg *types.MsgCancelLoan) ( ctx := sdk.UnwrapSDKContext(goCtx) loan, found := k.GetLoan(ctx, msg.Id) if !found { - return nil, sdkerrors.Wrapf(sdkerrors.ErrKeyNotFound, "key %d doesn't exist", msg.Id) + return nil, errorsmod.Wrapf(sdkerrors.ErrKeyNotFound, "key %d doesn't exist", msg.Id) } if loan.Borrower != msg.Creator { - return nil, sdkerrors.Wrap(sdkerrors.ErrUnauthorized, "Cannot cancel: not the borrower") + return nil, errorsmod.Wrap(sdkerrors.ErrUnauthorized, "Cannot cancel: not the borrower") } if loan.State != "requested" { - return nil, sdkerrors.Wrapf(types.ErrWrongLoanState, "%v", loan.State) + return nil, errorsmod.Wrapf(types.ErrWrongLoanState, "%v", loan.State) } borrower, _ := sdk.AccAddressFromBech32(loan.Borrower) collateral, _ := sdk.ParseCoinsNormalized(loan.Collateral) @@ -53,16 +54,16 @@ The function begins by using the `sdk.UnwrapSDKContext` method to get the `sdk.Context` from the `context.Context` object. It then uses the `GetLoan` method of the `msgServer` type to retrieve a loan identified by the `Id` field of the `msg` argument. If the loan is not found, the function returns an error -using the `sdk.ErrKeyNotFound` error wrapped with the `sdk.Wrap` method. +using the `sdk.ErrKeyNotFound` error wrapped with the `errorsmod.Wrap` method. Next, the function checks if the `Creator` field of the msg argument is the same as the `Borrower` field of the loan. If they are not the same, the function returns an error using the `sdk.ErrUnauthorized` error wrapped with the -`sdk.Wrap` method. +`errorsmod.Wrap` method. The function then checks if the `State` field of the loan is equal to the string `"requested"`. If it is not, the function returns an error using the -types.`ErrWrongLoanState` error wrapped with the `sdk.Wrapf` method. +types.`ErrWrongLoanState` error wrapped with the `errorsmod.Wrapf` method. If the loan has the correct state and the creator of the message is the borrower of the loan, the function proceeds to send the collateral coins held in the @@ -70,4 +71,4 @@ of the loan, the function proceeds to send the collateral coins held in the `SendCoinsFromModuleToAccount` method of the `bankKeeper`. The function then updates the State field of the loan to the string "cancelled" and sets the updated loan using the `SetLoan` method. Finally, the function returns a -`types.MsgCancelLoanResponse` object and a nil error. \ No newline at end of file +`types.MsgCancelLoanResponse` object and a nil error. diff --git a/docs/docs/02-guide/05-loan/08-play.md b/docs/docs/02-guide/05-loan/08-play.md index eb715b0512..40ab5aabf7 100644 --- a/docs/docs/02-guide/05-loan/08-play.md +++ b/docs/docs/02-guide/05-loan/08-play.md @@ -41,7 +41,7 @@ Request a loan of `1000token` with `100token` as a fee and `1000foocoin` as a collateral from Alice's account. The deadline is set to `500` blocks: ``` -loand tx loan request-loan 1000token 100token 1000foocoin 500 --from alice +loand tx loan request-loan 1000token 100token 1000foocoin 500 --from alice --chain-id loan ``` ``` @@ -65,7 +65,7 @@ Please be aware that the addresses displayed in your terminal window (such as th Approve the loan from Bob's account: ``` -loand tx loan approve-loan 0 --from bob +loand tx loan approve-loan 0 --from bob --chain-id loan ``` ``` @@ -132,7 +132,7 @@ balances: Repay the loan from Alice's account: ``` -loand tx loan repay-loan 0 --from alice +loand tx loan repay-loan 0 --from alice --chain-id loan ``` ``` @@ -204,7 +204,7 @@ deadline is set to a very small value, so that the loan can be quickly liquidated in the next step: ``` -loand tx loan request-loan 1000token 100token 1000foocoin 20 --from alice +loand tx loan request-loan 1000token 100token 1000foocoin 20 --from alice --chain-id loan ``` ``` @@ -238,13 +238,13 @@ Loan: Approve the loan from Bob's account: ``` -loand tx loan approve-loan 1 --from bob +loand tx loan approve-loan 1 --from bob --chain-id loan ``` Liquidate the loan from Bob's account: ``` -loand tx loan liquidate-loan 1 --from bob +loand tx loan liquidate-loan 1 --from bob --chain-id loan ``` ``` diff --git a/docs/docs/02-guide/06-ibc.md b/docs/docs/02-guide/06-ibc.md index 9f1973adc5..8ee4c89037 100644 --- a/docs/docs/02-guide/06-ibc.md +++ b/docs/docs/02-guide/06-ibc.md @@ -288,7 +288,7 @@ Finally, the Ignite CLI-generated AppendPost function returns the ID of the new appended post. You can return this value to the source chain through acknowledgment. -Append the type instance as `PostID` on receiving the packet: +Append the type instance as `PostId` on receiving the packet: - The context `ctx` is an [immutable data structure](https://docs.cosmos.network/main/core/context#go-context-package) @@ -333,7 +333,7 @@ func (k Keeper) OnRecvIbcPostPacket(ctx sdk.Context, packet channeltypes.Packet, }, ) - packetAck.PostID = strconv.FormatUint(id, 10) + packetAck.PostId = strconv.FormatUint(id, 10) return packetAck, nil } @@ -375,7 +375,7 @@ func (k Keeper) OnAcknowledgementIbcPostPacket(ctx sdk.Context, packet channelty ctx, types.SentPost{ Creator: data.Creator, - PostID: packetAck.PostID, + PostId: packetAck.PostId, Title: data.Title, Chain: packet.DestinationPort + "-" + packet.DestinationChannel, }, diff --git a/docs/docs/06-migration/v0.24.0.md b/docs/docs/06-migration/v0.24.0.md index bcf1b85185..7b803cce85 100644 --- a/docs/docs/06-migration/v0.24.0.md +++ b/docs/docs/06-migration/v0.24.0.md @@ -241,7 +241,7 @@ package module_name func (im IBCModule) OnChanOpenInit( /*...*/ ) (string, error) { //... - return "", sdkerrors.Wrapf(porttypes.ErrInvalidPort, "invalid port: %s, expected %s", portID, boundPort) + return "", errorsmod.Wrapf(porttypes.ErrInvalidPort, "invalid port: %s, expected %s", portID, boundPort) //... } ``` @@ -259,8 +259,8 @@ package module_name func (im IBCModule) OnRecvPacket( /*...*/ ) { //... if err := modulePacketData.Unmarshal(modulePacket.GetData()); err != nil { - // return channeltypes.NewErrorAcknowledgement(sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "cannot unmarshal packet data: %s", err.Error()).Error()) - return channeltypes.NewErrorAcknowledgement(sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "cannot unmarshal packet data: %s", err.Error())) + // return channeltypes.NewErrorAcknowledgement(errorsmod.Wrapf(sdkerrors.ErrUnknownRequest, "cannot unmarshal packet data: %s", err.Error()).Error()) + return channeltypes.NewErrorAcknowledgement(errorsmod.Wrapf(sdkerrors.ErrUnknownRequest, "cannot unmarshal packet data: %s", err.Error())) } // ... diff --git a/docs/docs/06-migration/v0.26.0.md b/docs/docs/06-migration/v0.26.0.md index 8dae447d15..de3576dbe8 100644 --- a/docs/docs/06-migration/v0.26.0.md +++ b/docs/docs/06-migration/v0.26.0.md @@ -165,7 +165,7 @@ func (k Keeper) ChanCloseInit(ctx sdk.Context, portID, channelID string) error { capName := host.ChannelCapabilityPath(portID, channelID) chanCap, ok := k.scopedKeeper.GetCapability(ctx, capName) if !ok { - return sdkerrors.Wrapf(channeltypes.ErrChannelCapabilityNotFound, "could not retrieve channel capability at: %s", capName) + return errorsmod.Wrapf(channeltypes.ErrChannelCapabilityNotFound, "could not retrieve channel capability at: %s", capName) } return k.channelKeeper.ChanCloseInit(ctx, portID, channelID, chanCap) } diff --git a/docs/versioned_docs/version-v0.27.2/02-guide/02-getting-started.md b/docs/versioned_docs/version-v0.27.2/02-guide/02-getting-started.md index d1d8c7c161..df3ff4464d 100644 --- a/docs/versioned_docs/version-v0.27.2/02-guide/02-getting-started.md +++ b/docs/versioned_docs/version-v0.27.2/02-guide/02-getting-started.md @@ -29,8 +29,8 @@ following command: ignite scaffold chain example ``` -The [`ignite scaffold chain`](../references/cli#ignite-scaffold-chain) command will create a -new blockchain in a new directory `example`. +The [`ignite scaffold chain`](/references/cli#ignite-scaffold-chain) command +will create a new blockchain in a new directory `example`. The new blockchain is built using the Cosmos SDK framework and imports several standard modules to provide a range of functionality. These modules include @@ -132,7 +132,7 @@ To start a blockchain node in development, you can run the following command: ignite chain serve ``` -The [`ignite chain serve`](../references/cli#ignite-scaffold-chain) command is used to start +The [`ignite chain serve`](/references/cli#ignite-scaffold-chain) command is used to start a blockchain node in development mode. It first compiles and installs the binary using the `ignite chain build` command, then initializes the blockchain's data directory for a single validator using the `ignite chain init` command. After diff --git a/docs/versioned_docs/version-v0.27.2/02-guide/06-ibc.md b/docs/versioned_docs/version-v0.27.2/02-guide/06-ibc.md index 83efb4f760..13d4d6fce4 100644 --- a/docs/versioned_docs/version-v0.27.2/02-guide/06-ibc.md +++ b/docs/versioned_docs/version-v0.27.2/02-guide/06-ibc.md @@ -291,7 +291,7 @@ acknowledgment. Append the type instance as `PostID` on receiving the packet: - The context `ctx` is an [immutable data - structure](https://docs.cosmos.network/main/core/context.html#go-context-package) + structure](https://docs.cosmos.network/main/learn/advanced/context#go-context-package) that has header data from the transaction. See [how the context is initiated](https://github.com/cosmos/cosmos-sdk/blob/main/types/context.go#L71) - The identifier format that you defined earlier diff --git a/docs/versioned_docs/version-v0.27.2/02-guide/10-simapp.md b/docs/versioned_docs/version-v0.27.2/02-guide/10-simapp.md index fd2dcea96f..4bd38bf1b1 100644 --- a/docs/versioned_docs/version-v0.27.2/02-guide/10-simapp.md +++ b/docs/versioned_docs/version-v0.27.2/02-guide/10-simapp.md @@ -14,8 +14,7 @@ simulation methods for each scaffolded message. ## Module simulation Every new module that is scaffolded with Ignite CLI implements the Cosmos SDK -[Module -Simulation](https://docs.cosmos.network/main/building-modules/simulator.html). +[Module Simulation](https://docs.cosmos.network/main/learn/advanced/simulation). - Each new message creates a file with the simulation methods required for the tests. @@ -105,7 +104,7 @@ according to call the function. ## Invariants Simulating a chain can help you prevent [chain invariants -errors](https://docs.cosmos.network/main/building-modules/invariants.html). An +errors](https://docs.cosmos.network/main/build/building-modules/invariants). An invariant is a function called by the chain to check if something broke, invalidating the chain data. To create a new invariant and check the chain integrity, you must create a method to validate the invariants and register all diff --git a/docs/versioned_docs/version-v0.27.2/03-clients/02-typescript.md b/docs/versioned_docs/version-v0.27.2/03-clients/02-typescript.md index 3c8d29e81d..c770f5c338 100644 --- a/docs/versioned_docs/version-v0.27.2/03-clients/02-typescript.md +++ b/docs/versioned_docs/version-v0.27.2/03-clients/02-typescript.md @@ -8,7 +8,7 @@ Ignite offers powerful functionality for generating client-side code for your blockchain. Think of this as a one-click client SDK generation tailored specifically for your blockchain. -See [`ignite generate ts-client --help`](../references/cli#ignite-generate-ts-client) learn +See [`ignite generate ts-client --help`](/references/cli#ignite-generate-ts-client) learn more on how to use TypeScript code generation. ## Starting a node diff --git a/docs/versioned_docs/version-v0.27.2/06-migration/v0.19.2.md b/docs/versioned_docs/version-v0.27.2/06-migration/v0.19.2.md index 5bd63a73c1..aa141809bf 100644 --- a/docs/versioned_docs/version-v0.27.2/06-migration/v0.19.2.md +++ b/docs/versioned_docs/version-v0.27.2/06-migration/v0.19.2.md @@ -14,7 +14,7 @@ official Ignite CLI repo which introduces breaking changes. To migrate your chain that was scaffolded with Ignite CLI versions lower than v0.19.2: 1. IBC upgrade: Use - the [IBC migration documents](https://github.com/cosmos/ibc-go/blob/main/docs/migrations/v1-to-v2.md) + the [IBC migration documents](https://github.com/cosmos/ibc-go/blob/main/docs/docs/05-migrations/03-v1-to-v2.md) 2. In your chain's `go.mod` file, remove `tendermint/spm` and add the v0.19.2 version of `tendermint/starport`. If your chain uses these packages, change the import paths as shown: diff --git a/docs/versioned_docs/version-v0.27.2/06-migration/v0.26.0.md b/docs/versioned_docs/version-v0.27.2/06-migration/v0.26.0.md index f8895aabf1..e19dd53601 100644 --- a/docs/versioned_docs/version-v0.27.2/06-migration/v0.26.0.md +++ b/docs/versioned_docs/version-v0.27.2/06-migration/v0.26.0.md @@ -17,15 +17,14 @@ their tooling to the latest version. Chains that are newly scaffolded with Ignite CLI `v0.26.0` now use `ibc-go/v6` for ibc functionality. It is not necessary, but recommended to upgrade to the newest version of `ibc-go`. Most migrations can be done by following the -`ibc-go` [migration guide](https://github.com/cosmos/ibc-go/blob/main/docs/migrations/v5-to-v6.md), but there are some +`ibc-go` [migration guide](https://github.com/cosmos/ibc-go/blob/main/docs/docs/05-migrations/07-v5-to-v6.md), but there are some specific changes that will need to be followed for Ignite scaffolded chains. ### Removing `cosmosibckeeper` -Ignite CLI `v0.26.0` has deprecated [pkg/cosmosibckeeper](https://github.com/ignite/cli/tree/main/ignite/pkg/cosmosibckeeper). -This package contained interfaces for ibc-related keepers. Newly scaffolded chains now include the interface files in their -`./x/{moduleName}/types` directory in a new `expected_ibc_keeper.go` file. To migrate, create the following file for -each module: +Ignite CLI `v0.26.0` has deprecated `pkg/cosmosibckeeper`. This package contained interfaces for ibc-related keepers. +Newly scaffolded chains now include the interface files in their `./x/{moduleName}/types` directory in a new `expected_ibc_keeper.go` +file. To migrate, create the following file for each module: ```go title="x/{moduleName}/types/expected_ibc_keeper.go" package types @@ -215,7 +214,7 @@ func (k Keeper) Logger(ctx sdk.Context) log.Logger { ### Remaining migration -After all uses of `cosmosibckeeper` have been removed, you can follow any remaining steps in the`ibc-go`[migration guide](https://github.com/cosmos/ibc-go/blob/main/docs/migrations/v5-to-v6.md). +After all uses of `cosmosibckeeper` have been removed, you can follow any remaining steps in the`ibc-go`[migration guide](https://github.com/cosmos/ibc-go/blob/main/docs/docs/05-migrations/07-v5-to-v6.md). ## Scaffolded Release Workflow