Skip to content

Enable/disable coin transfers by denom #6518

@denalimarsh

Description

@denalimarsh

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:

  1. Update the bank module's SendKeeper interface
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)
}
  1. 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.
  1. Update bank module handler functions handleMsgSend and handleMsgMultiSend to 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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions