Skip to content

Commit

Permalink
refactor: improve Stargate msg handling with denylist
Browse files Browse the repository at this point in the history
  • Loading branch information
da1suk8 committed Apr 26, 2024
1 parent 58714d1 commit 2047fe7
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions x/wasm/keeper/msg_dispatcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,14 @@ func (d MessageDispatcher) DispatchSubmessages(ctx sdk.Context, contractAddr sdk
var rsp []byte
for _, msg := range msgs {

// Prevent the use of fswap and fbridge module in Submessages
// Prevent the use of specific modules in Submessages
// https://github.com/Finschia/finschia-sdk/pull/1336, https://github.com/Finschia/finschia-sdk/pull/1340
if stargateMsg := msg.Msg.Stargate; stargateMsg != nil {
if strings.HasPrefix(stargateMsg.TypeURL, "/lbm.fswap.v1") {
return nil, sdkerrors.Wrap(types.ErrUnsupportedForContract, "fswap not supported by Stargate")
}
if strings.HasPrefix(stargateMsg.TypeURL, "/lbm.fbridge.v1") {
return nil, sdkerrors.Wrap(types.ErrUnsupportedForContract, "fbridge not supported by Stargate")
deniedModules := []string{"/lbm.fswap.v1", "/lbm.fbridge.v1"}
for _, moduleName := range deniedModules {
if strings.HasPrefix(stargateMsg.TypeURL, moduleName) {
return nil, sdkerrors.Wrap(types.ErrUnsupportedForContract, moduleName+" not supported by Stargate")
}
}
}

Expand Down

0 comments on commit 2047fe7

Please sign in to comment.