-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Enable/disable coin transfers by denom #6527
Changes from 28 commits
3c3a232
5cb0357
b1ea0e2
03ae118
fba1a1a
fe4844b
dbf96c3
d05321f
8568819
9308435
a76d751
42d8c08
fc3bd0e
ba1853c
db4646b
0ff3263
7ede620
1f753e6
f06e854
e11d1d1
7d63967
23494e8
d25c8f9
9c8918d
c7f1902
78b521b
9458c82
8778d26
eda215b
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 |
---|---|---|
|
@@ -24,8 +24,11 @@ type SendKeeper interface { | |
SetBalance(ctx sdk.Context, addr sdk.AccAddress, balance sdk.Coin) error | ||
SetBalances(ctx sdk.Context, addr sdk.AccAddress, balances sdk.Coins) error | ||
|
||
GetSendEnabled(ctx sdk.Context) bool | ||
SetSendEnabled(ctx sdk.Context, enabled bool) | ||
GetParams(ctx sdk.Context) types.Params | ||
SetParams(ctx sdk.Context, params types.Params) | ||
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. Why did we add |
||
|
||
SendEnabledCoin(ctx sdk.Context, coin sdk.Coin) bool | ||
SendEnabledCoins(ctx sdk.Context, coins ...sdk.Coin) error | ||
|
||
BlockedAddr(addr sdk.AccAddress) bool | ||
} | ||
|
@@ -60,6 +63,17 @@ func NewBaseSendKeeper( | |
} | ||
} | ||
|
||
// GetParams returns the total set of bank parameters. | ||
func (k BaseSendKeeper) GetParams(ctx sdk.Context) (params types.Params) { | ||
k.paramSpace.GetParamSet(ctx, ¶ms) | ||
return params | ||
} | ||
|
||
// SetParams sets the total set of bank parameters. | ||
func (k BaseSendKeeper) SetParams(ctx sdk.Context, params types.Params) { | ||
k.paramSpace.SetParamSet(ctx, ¶ms) | ||
} | ||
|
||
// InputOutputCoins performs multi-send functionality. It accepts a series of | ||
// inputs that correspond to a series of outputs. It returns an error if the | ||
// inputs and outputs don't lineup or if any single transfer of tokens fails. | ||
|
@@ -256,16 +270,21 @@ func (k BaseSendKeeper) SetBalance(ctx sdk.Context, addr sdk.AccAddress, balance | |
return nil | ||
} | ||
|
||
// GetSendEnabled returns the current SendEnabled | ||
func (k BaseSendKeeper) GetSendEnabled(ctx sdk.Context) bool { | ||
var enabled bool | ||
k.paramSpace.Get(ctx, types.ParamStoreKeySendEnabled, &enabled) | ||
return enabled | ||
// SendEnabledCoins checks the coins provide and returns an ErrSendDisabled if | ||
// any of the coins are not configured for sending. Returns nil if sending is enabled | ||
// for all provided coin | ||
func (k BaseSendKeeper) SendEnabledCoins(ctx sdk.Context, coins ...sdk.Coin) error { | ||
for _, coin := range coins { | ||
if !k.SendEnabledCoin(ctx, coin) { | ||
return sdkerrors.Wrapf(types.ErrSendDisabled, "%s transfers are currently disabled", coin.Denom) | ||
} | ||
} | ||
return nil | ||
} | ||
|
||
// SetSendEnabled sets the send enabled | ||
func (k BaseSendKeeper) SetSendEnabled(ctx sdk.Context, enabled bool) { | ||
k.paramSpace.Set(ctx, types.ParamStoreKeySendEnabled, &enabled) | ||
// SendEnabledCoin returns the current SendEnabled status of the provided coin's denom | ||
func (k BaseSendKeeper) SendEnabledCoin(ctx sdk.Context, coin sdk.Coin) bool { | ||
return k.GetParams(ctx).SendEnabledDenom(coin.Denom) | ||
} | ||
|
||
// BlockedAddr checks if a given address is restricted from | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,20 @@ order: 5 | |
|
||
The bank module contains the following parameters: | ||
|
||
| Key | Type | Example | | ||
|-------------|------|---------| | ||
| sendenabled | bool | true | | ||
| Key | Type | Example | | ||
|--------------------|---------------|------------------------------------| | ||
| SendEnabled | []SendEnabled | [{denom: "stake", enabled: true }] | | ||
| DefaultSendEnabled | bool | true | | ||
|
||
|
||
## SendEnabled | ||
|
||
The send enabled parameter is an array of SendEnabled entries mapping coin | ||
denominations to their send_enabled status. Entries in this list take | ||
precedence over the `DefaultSendEnabled` setting. | ||
|
||
## DefaultSendEnabled | ||
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. I'm not really convinced this is necessary or provides a cleaner UX. What is the drawback to just using |
||
|
||
The default send enabled value controls send transfer capability for all | ||
coin denominations unless specifically included in the array of `SendEnabled` | ||
parameters. |
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.
can you move this to
State Machine Breaking
? 🙏