Skip to content

Commit 6b8b45c

Browse files
committed
fix: propagate funds validation errors
The validation functions on the `tx` type masquerade the root error message for the `Funds` validation. Having the original error helps to save time when debugging the cause for a failed tx. One example is if someone sends multiple funds to a contract execution without sorting the denoms, which is one of the validations in the `Coins.Validate` method. With the error propagation, the developer can quickly determine why the tx failed.
1 parent e0da419 commit 6b8b45c

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

x/wasm/types/tx.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,8 @@ func (msg MsgInstantiateContract) ValidateBasic() error {
103103
return errorsmod.Wrap(err, "label")
104104
}
105105

106-
if !msg.Funds.IsValid() {
107-
return sdkerrors.ErrInvalidCoins
106+
if err := msg.Funds.Validate(); err != nil {
107+
return errorsmod.Wrap(err, "funds")
108108
}
109109

110110
if len(msg.Admin) != 0 {
@@ -142,8 +142,8 @@ func (msg MsgExecuteContract) ValidateBasic() error {
142142
return errorsmod.Wrap(err, "contract")
143143
}
144144

145-
if !msg.Funds.IsValid() {
146-
return errorsmod.Wrap(sdkerrors.ErrInvalidCoins, "sentFunds")
145+
if err := msg.Funds.Validate(); err != nil {
146+
return errorsmod.Wrap(err, "funds")
147147
}
148148
if err := msg.Msg.ValidateBasic(); err != nil {
149149
return errorsmod.Wrap(err, "payload msg")
@@ -336,8 +336,8 @@ func (msg MsgInstantiateContract2) ValidateBasic() error {
336336
return errorsmod.Wrap(err, "label")
337337
}
338338

339-
if !msg.Funds.IsValid() {
340-
return sdkerrors.ErrInvalidCoins
339+
if err := msg.Funds.Validate(); err != nil {
340+
return errorsmod.Wrap(err, "funds")
341341
}
342342

343343
if len(msg.Admin) != 0 {
@@ -537,8 +537,8 @@ func (msg MsgStoreAndInstantiateContract) ValidateBasic() error {
537537
return errorsmod.Wrap(err, "label")
538538
}
539539

540-
if !msg.Funds.IsValid() {
541-
return sdkerrors.ErrInvalidCoins
540+
if err := msg.Funds.Validate(); err != nil {
541+
return errorsmod.Wrap(err, "funds")
542542
}
543543

544544
if len(msg.Admin) != 0 {

0 commit comments

Comments
 (0)