-
Notifications
You must be signed in to change notification settings - Fork 634
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
chore: update math package #8857
Conversation
Important Notice This PR modifies an in-repo Go module. It is one of:
The dependent Go modules, especially the root one, will have to be Please follow the instructions below:
Please let us know if you need any help. |
WalkthroughThe changes in the pull request primarily focus on enhancing the Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant CustomMessenger
participant TokenFactoryKeeper
participant BankKeeper
Client->>CustomMessenger: Request to mint tokens
CustomMessenger->>TokenFactoryKeeper: PerformMint check
TokenFactoryKeeper->>CustomMessenger: Validate recipient address
alt If recipient is a module account
CustomMessenger-->>Client: Error: Cannot mint to module account
else
CustomMessenger->>BankKeeper: Mint tokens
BankKeeper-->>CustomMessenger: Tokens minted successfully
CustomMessenger-->>Client: Success: Tokens minted
end
📜 Recent review detailsConfiguration used: CodeRabbit UI ⛔ Files ignored due to path filters (2)
📒 Files selected for processing (1)
🔇 Additional comments (1)wasmbinding/message_plugin.go (1)
Consider adding module account check before minting While the added validation prevents sending minted tokens to module accounts, the current implementation performs the check after minting but before transfer. This could lead to tokens being minted and stuck in the contract address if the recipient is a module account. Consider moving the module account check before the mint operation to prevent unnecessary state changes: func PerformMint(f *tokenfactorykeeper.Keeper, b *bankkeeper.BaseKeeper, ctx sdk.Context, contractAddr sdk.AccAddress, mint *bindings.MintTokens) error {
if mint == nil {
return wasmvmtypes.InvalidRequest{Err: "mint token null mint"}
}
rcpt, err := parseAddress(mint.MintToAddress)
if err != nil {
return err
}
+ if f.IsModuleAcc(ctx, rcpt) {
+ return tokenfactorytypes.ErrMintToModuleAccount
+ }
coin := sdk.Coin{Denom: mint.Denom, Amount: mint.Amount}
sdkMsg := tokenfactorytypes.NewMsgMint(contractAddr.String(), coin)
if err = sdkMsg.ValidateBasic(); err != nil {
return err
}
// Mint through token factory / message server
msgServer := tokenfactorykeeper.NewMsgServerImpl(*f)
_, err = msgServer.Mint(ctx, sdkMsg)
if err != nil {
return errorsmod.Wrap(err, "minting coins from message")
}
- if f.IsModuleAcc(ctx, rcpt) {
- return tokenfactorytypes.ErrMintToModuleAccount
- }
err = b.SendCoins(ctx, contractAddr, rcpt, sdk.NewCoins(coin))
if err != nil {
return errorsmod.Wrap(err, "sending newly minted coins from message")
}
return nil
} Let's verify if there are any existing module account checks in other token factory implementations: ✅ Verification successfulLet me analyze the search results. The key findings from the codebase search are:
This confirms that the review comment's suggestion to move the module account check before minting is consistent with the existing patterns in the codebase. Consider moving module account check before minting to maintain consistency The module account check should be performed before minting to:
func PerformMint(f *tokenfactorykeeper.Keeper, b *bankkeeper.BaseKeeper, ctx sdk.Context, contractAddr sdk.AccAddress, mint *bindings.MintTokens) error {
if mint == nil {
return wasmvmtypes.InvalidRequest{Err: "mint token null mint"}
}
rcpt, err := parseAddress(mint.MintToAddress)
if err != nil {
return err
}
+ if f.IsModuleAcc(ctx, rcpt) {
+ return tokenfactorytypes.ErrMintToModuleAccount
+ }
coin := sdk.Coin{Denom: mint.Denom, Amount: mint.Amount}
sdkMsg := tokenfactorytypes.NewMsgMint(contractAddr.String(), coin)
if err = sdkMsg.ValidateBasic(); err != nil {
return err
}
// Mint through token factory / message server
msgServer := tokenfactorykeeper.NewMsgServerImpl(*f)
_, err = msgServer.Mint(ctx, sdkMsg)
if err != nil {
return errorsmod.Wrap(err, "minting coins from message")
}
- if f.IsModuleAcc(ctx, rcpt) {
- return tokenfactorytypes.ErrMintToModuleAccount
- }
err = b.SendCoins(ctx, contractAddr, rcpt, sdk.NewCoins(coin))
if err != nil {
return errorsmod.Wrap(err, "sending newly minted coins from message")
}
return nil
} 🏁 Scripts executedThe following scripts were executed for the analysis: Script: #!/bin/bash
# Search for similar module account validation patterns in token factory implementations
rg -A 2 "IsModuleAcc|ModuleAccount"
Length of output: 114465 Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
What is the purpose of the change
Updating math in osmosis math package