Skip to content

Commit

Permalink
chore: change error message.
Browse files Browse the repository at this point in the history
Signed-off-by: zemyblue <[email protected]>
  • Loading branch information
zemyblue committed May 8, 2024
1 parent 0a92b50 commit 98370b3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/wasm_filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func wasmFilteredEncodeStargateMsg(unpakcer codectypes.AnyUnpacker) wasmkeeper.S
return func(sender sdk.AccAddress, msg *wasmvmtypes.StargateMsg) ([]sdk.Msg, error) {
for _, msgName := range deniedMsgInStargateMsg {
if strings.HasPrefix(msg.TypeURL, msgName) {
return nil, sdkerrors.Wrapf(wasmtypes.ErrUnsupportedForContract, "messages of the type in %s are not supported by Stargate", msgName)
return nil, sdkerrors.Wrapf(wasmtypes.ErrUnsupportedForContract, "%s is not supported by Stargate", msg.TypeURL)
}
}

Expand Down
7 changes: 6 additions & 1 deletion app/wasm_filter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ func TestFilteredStargateMsgEncoders(t *testing.T) {
output []sdk.Msg
// set if invalid
isError bool
errMsg string
}{
"stargate encoded bank msg": {
sender: addr2,
Expand Down Expand Up @@ -87,6 +88,7 @@ func TestFilteredStargateMsgEncoders(t *testing.T) {
},
},
isError: true,
errMsg: "Cannot unpack proto message with type URL: /cosmos.bank.v2.MsgSend: invalid CosmosMsg from the contract",
},
"stargate encoded filtered (fswap)": {
sender: addr1,
Expand All @@ -97,6 +99,7 @@ func TestFilteredStargateMsgEncoders(t *testing.T) {
},
},
isError: true,
errMsg: "/lbm.fswap.v1.MsgSwap is not supported by Stargate: unsupported for this contract",
},
"stargate encoded filtered (fbridge)": {
sender: addr1,
Expand All @@ -107,6 +110,7 @@ func TestFilteredStargateMsgEncoders(t *testing.T) {
},
},
isError: true,
errMsg: "/lbm.fbridge.v1.MsgTransfer is not supported by Stargate: unsupported for this contract",
},
}
encodingConfig := MakeEncodingConfig()
Expand All @@ -115,10 +119,11 @@ func TestFilteredStargateMsgEncoders(t *testing.T) {
t.Run(name, func(t *testing.T) {
var ctx sdk.Context
encoder := wasmkeeper.DefaultEncoders(encodingConfig.Marshaler, tc.transferPortSource)
encoder.Merge(filteredStargateMsgEncoders(encodingConfig.Marshaler))
encoder = encoder.Merge(filteredStargateMsgEncoders(encodingConfig.Marshaler))
res, err := encoder.Encode(ctx, tc.sender, tc.srcContractIBCPort, tc.srcMsg)
if tc.isError {
require.Error(t, err)
require.Equal(t, err.Error(), tc.errMsg)
} else {
require.NoError(t, err)
assert.Equal(t, tc.output, res)
Expand Down

0 comments on commit 98370b3

Please sign in to comment.