The bank module provides these exported keeper interfaces that can be
passed to other modules that read or update account balances. Modules
should use the least-permissive interface that provides the functionality they
require.
Best practices dictate careful review of bank module code to ensure that
permissions are limited in the way that you expect.
The x/bank module accepts a map of addresses that are considered blocklisted
from directly and explicitly receiving funds through means such as MsgSend and
MsgMultiSend and direct API calls like SendCoinsFromModuleToAccount.
Typically, these addresses are module accounts. If these addresses receive funds
outside the expected rules of the state machine, invariants are likely to be
broken and could result in a halted network.
By providing the x/bank module with a blocklisted set of addresses, an error occurs for the operation if a user or client attempts to directly or indirectly send funds to a blocklisted account, for example, by using IBC(opens new window).
The base keeper provides full-permission access: the ability to arbitrary modify any account's balance and mint or burn coins.
Restricted permission to mint per module could be achieved by using baseKeeper with WithMintCoinsRestriction to give specific restrictions to mint (e.g. only minting certain denom).
Copy
// Keeper defines a module interface that facilitates the transfer of coins// between accounts.type Keeper interface{
SendKeeper
WithMintCoinsRestriction(NewRestrictionFn BankMintingRestrictionFn) BaseKeeper
InitGenesis(sdk.Context,*types.GenesisState)ExportGenesis(sdk.Context)*types.GenesisState
GetSupply(ctx sdk.Context, denom string) sdk.Coin
GetPaginatedTotalSupply(ctx sdk.Context, pagination *query.PageRequest)(sdk.Coins,*query.PageResponse,error)IterateTotalSupply(ctx sdk.Context, cb func(sdk.Coin)bool)GetDenomMetaData(ctx sdk.Context, denom string)(types.Metadata,bool)SetDenomMetaData(ctx sdk.Context, denomMetaData types.Metadata)IterateAllDenomMetaData(ctx sdk.Context, cb func(types.Metadata)bool)SendCoinsFromModuleToAccount(ctx sdk.Context, senderModule string, recipientAddr sdk.AccAddress, amt sdk.Coins)errorSendCoinsFromModuleToModule(ctx sdk.Context, senderModule, recipientModule string, amt sdk.Coins)errorSendCoinsFromAccountToModule(ctx sdk.Context, senderAddr sdk.AccAddress, recipientModule string, amt sdk.Coins)errorDelegateCoinsFromAccountToModule(ctx sdk.Context, senderAddr sdk.AccAddress, recipientModule string, amt sdk.Coins)errorUndelegateCoinsFromModuleToAccount(ctx sdk.Context, senderModule string, recipientAddr sdk.AccAddress, amt sdk.Coins)errorMintCoins(ctx sdk.Context, moduleName string, amt sdk.Coins)errorBurnCoins(ctx sdk.Context, moduleName string, amt sdk.Coins)errorDelegateCoins(ctx sdk.Context, delegatorAddr, moduleAccAddr sdk.AccAddress, amt sdk.Coins)errorUndelegateCoins(ctx sdk.Context, moduleAccAddr, delegatorAddr sdk.AccAddress, amt sdk.Coins)error
types.QueryServer
}
The send keeper provides access to account balances and the ability to transfer coins between
accounts. The send keeper does not alter the total supply (mint or burn coins).
Copy
// SendKeeper defines a module interface that facilitates the transfer of coins// between accounts without the possibility of creating coins.type SendKeeper interface{
ViewKeeper
InputOutputCoins(ctx sdk.Context, inputs []types.Input, outputs []types.Output)errorSendCoins(ctx sdk.Context, fromAddr sdk.AccAddress, toAddr sdk.AccAddress, amt sdk.Coins)errorGetParams(ctx sdk.Context) types.Params
SetParams(ctx sdk.Context, params types.Params)IsSendEnabledCoin(ctx sdk.Context, coin sdk.Coin)boolIsSendEnabledCoins(ctx sdk.Context, coins ...sdk.Coin)errorBlockedAddr(addr sdk.AccAddress)bool}
The view keeper provides read-only access to account balances. The view keeper does not have balance alteration functionality. All balance lookups are O(1).