-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: move exec compat msg to core, regen
- Loading branch information
1 parent
53b8980
commit 7fadcee
Showing
4 changed files
with
744 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,48 @@ | ||
package types | ||
|
||
import ( | ||
wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types" | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" | ||
) | ||
|
||
const RouterKey = ModuleName | ||
|
||
func (msg MsgExecuteContractCompat) Route() string { | ||
return RouterKey | ||
} | ||
|
||
func (msg MsgExecuteContractCompat) Type() string { | ||
return "executeCompat" | ||
} | ||
|
||
func (msg MsgExecuteContractCompat) ValidateBasic() error { | ||
if _, err := sdk.AccAddressFromBech32(msg.Sender); err != nil { | ||
return sdkerrors.Wrap(err, "sender") | ||
} | ||
if _, err := sdk.AccAddressFromBech32(msg.Contract); err != nil { | ||
return sdkerrors.Wrap(err, "contract") | ||
} | ||
|
||
if !msg.Funds.IsValid() { | ||
return sdkerrors.Wrap(sdkerrors.ErrInvalidCoins, "sentFunds") | ||
} | ||
|
||
rawMsg := wasmtypes.RawContractMessage(msg.Msg) | ||
if err := rawMsg.ValidateBasic(); err != nil { | ||
return sdkerrors.Wrap(err, "payload msg") | ||
} | ||
return nil | ||
} | ||
|
||
func (msg MsgExecuteContractCompat) GetSignBytes() []byte { | ||
return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&msg)) | ||
} | ||
|
||
func (msg MsgExecuteContractCompat) GetSigners() []sdk.AccAddress { | ||
senderAddr, err := sdk.AccAddressFromBech32(msg.Sender) | ||
if err != nil { // should never happen as valid basic rejects invalid addresses | ||
panic(err.Error()) | ||
} | ||
return []sdk.AccAddress{senderAddr} | ||
} |
Oops, something went wrong.