Description
openedon Jun 2, 2024
Summary
X/bank SendCoins
SendRestriction
should be applied before deducting of coins using subUnlockedCoins
Problem Definition
Why do we need this feature?
Currently, the coins are first deducted, and then we check the send restriction.
In the tx flow, is there is an error, then the tx is reverted.
In a module flow (that isn't in a tx, so begin/endblock call or whatever), the balances will indeed be deducted and then throw an error. This is why you need to run this in a cache context and only write it if it succeeds without an error. Ref
What problems may be addressed by introducing this feature?
Lack of standardisation with InputOutputCoins, we might need to change that as well but not a big issue for now.
What benefits does the SDK stand to gain by including this feature?
Safer usage of SendRestriction in SendCoins.
Proposed Feature
To move SendRestriction
before subUnlockedCoins
in SendCoins
of Send.go
in x/bank keeper