-
Notifications
You must be signed in to change notification settings - Fork 4.1k
feat!: public setbalance #25771
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
base: feat/krakatoa
Are you sure you want to change the base?
feat!: public setbalance #25771
Changes from all commits
c8b6ea7
63fe75f
ee40fc4
2923500
e4d121c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -330,7 +330,7 @@ func (k BaseSendKeeper) subUnlockedCoins(ctx context.Context, addr sdk.AccAddres | |
|
|
||
| newBalance := balance.Sub(coin) | ||
|
|
||
| if err := k.setBalance(ctx, addr, newBalance); err != nil { | ||
| if err := k.SetBalance(ctx, addr, newBalance); err != nil { | ||
| return err | ||
| } | ||
| } | ||
|
|
@@ -353,7 +353,7 @@ func (k BaseSendKeeper) addCoins(ctx context.Context, addr sdk.AccAddress, amt s | |
| balance := k.GetBalance(ctx, addr, coin.Denom) | ||
| newBalance := balance.Add(coin) | ||
|
|
||
| err := k.setBalance(ctx, addr, newBalance) | ||
| err := k.SetBalance(ctx, addr, newBalance) | ||
| if err != nil { | ||
| return err | ||
| } | ||
|
|
@@ -368,8 +368,8 @@ func (k BaseSendKeeper) addCoins(ctx context.Context, addr sdk.AccAddress, amt s | |
| return nil | ||
| } | ||
|
|
||
| // setBalance sets the coin balance for an account by address. | ||
| func (k BaseSendKeeper) setBalance(ctx context.Context, addr sdk.AccAddress, balance sdk.Coin) error { | ||
| // SetBalance sets the coin balance for an account by address. | ||
| func (k BaseSendKeeper) SetBalance(ctx context.Context, addr sdk.AccAddress, balance sdk.Coin) error { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Compare
Especially the first one, it seems can become a security vulnerability easily if the caller is not careful. |
||
| if !balance.IsValid() { | ||
| return errorsmod.Wrap(sdkerrors.ErrInvalidCoins, balance.String()) | ||
| } | ||
|
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this feels like a dangerous method to include in the base interface
i'm (fairly) certain all of these methods here are fool proof, but SetBalance is not. for example, Mint/BurnCoins handles updating the supply for you. SetBalance can be misused and put the state out of whack.
would it make more sense to have an UnsafeBank or SudoBank-esque interface?