-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Closed
Description
Summary
Enable/disable coin transfers by denom.
Problem Definition
Transfers of a specific token type cannot be paused/unpaused without disabling all transfers in the bank module. Some token implementations on other chains allow for fine-grain control of an individual token by the designated owner. The feature acts as a safeguard in potential attack scenarios and can increase trust in the system in a variety of situations. The authority to enable/disable transfers of a specific coin type could be vested in a trusted coin owner or subject to governance depending on the use case.
Proposal
Replace the global SendEnabled parameter with a per coin one indexed by denom:
- Update the bank module's
SendKeeperinterface
type SendKeeper interface {
// Current:
GetSendEnabled(ctx sdk.Context) bool
SetSendEnabled(ctx sdk.Context, enabled bool)
// Proposed:
GetSendEnabled(ctx sdk.Context, string denom) bool
SetSendEnabled(ctx sdk.Context, string denom, enabled bool)
}- Update bank module's params to include
SendEnabledParams
ParamStoreKeySendEnabledParams = []byte("sendenabledparams")
type Params struct {
SendEnabledParams SendEnabledParams `json:"send_enabled_params" yaml:"send_enabled_params"`
}
func ParamKeyTable() paramtypes.KeyTable {
return paramtypes.NewKeyTable(
paramtypes.NewParamSetPair(ParamStoreKeySendEnabledParams, SendEnabledParams{}, validateSendEnabledParams),
)
}
type SendEnabledParams struct {
SendEnabled bool `json:"send_enabled,omitempty" yaml:"send_enabled,omitempty"`
}
// ...validateSendEnabledParams(), DefaultSendEnabledParams(), etc.- Update bank module handler functions
handleMsgSendandhandleMsgMultiSendto reject attempted transfers that include a disabled coin
for _, a := range msg.Amount {
if !k.GetSendEnabled(ctx, a.Denom) {
return nil, sdkerrors.Wrapf(sdkerrors.ErrSendDisabled, "%s transfers are currently disabled", a.Denom)
}
}For Admin Use
- Not duplicate issue
- Appropriate labels applied
- Appropriate contributors tagged
- Contributor assigned/self-assigned
Reactions are currently unavailable