From a62f6b1561e06ba3a0cfe4be9cf2615f49099334 Mon Sep 17 00:00:00 2001 From: Dan Connolly Date: Thu, 14 Jul 2022 23:25:01 -0500 Subject: [PATCH] fix(golang): complete ledger support for MsgWallet{Spend}Action refs #3628 register amino codec for WalletAction, SpendAction ... and MsgWalletSpendAction by filling in LegacyMsg methods. This avoids: panic: expected *legacytx.LegacyMsg when using amino JSON --- golang/cosmos/x/swingset/types/codec.go | 2 ++ golang/cosmos/x/swingset/types/msgs.go | 22 ++++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/golang/cosmos/x/swingset/types/codec.go b/golang/cosmos/x/swingset/types/codec.go index 4f47d63f391..0c1433bfeab 100644 --- a/golang/cosmos/x/swingset/types/codec.go +++ b/golang/cosmos/x/swingset/types/codec.go @@ -31,6 +31,8 @@ func init() { func RegisterCodec(cdc *codec.LegacyAmino) { cdc.RegisterConcrete(&MsgDeliverInbound{}, ModuleName+"/DeliverInbound", nil) cdc.RegisterConcrete(&MsgProvision{}, ModuleName+"/Provision", nil) + cdc.RegisterConcrete(&MsgWalletAction{}, ModuleName+"/WalletAction", nil) + cdc.RegisterConcrete(&MsgWalletSpendAction{}, ModuleName+"/WalletSpendAction", nil) } // RegisterInterfaces registers the x/swingset interfaces types with the interface registry diff --git a/golang/cosmos/x/swingset/types/msgs.go b/golang/cosmos/x/swingset/types/msgs.go index 276e54acbe0..4003b2cff8b 100644 --- a/golang/cosmos/x/swingset/types/msgs.go +++ b/golang/cosmos/x/swingset/types/msgs.go @@ -104,6 +104,28 @@ func (msg MsgWalletAction) GetSigners() []sdk.AccAddress { return []sdk.AccAddress{msg.Owner} } +// GetSignBytes encodes the message for signing +func (msg MsgWalletAction) GetSignBytes() []byte { + return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&msg)) +} + +// GetSignBytes encodes the message for signing +func (msg MsgWalletSpendAction) GetSignBytes() []byte { + return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&msg)) +} + +// Route should return the name of the module +func (msg MsgWalletAction) Route() string { return RouterKey } + +// Type should return the action +func (msg MsgWalletAction) Type() string { return "wallet_action" } + +// Route should return the name of the module +func (msg MsgWalletSpendAction) Route() string { return RouterKey } + +// Type should return the action +func (msg MsgWalletSpendAction) Type() string { return "wallet_spend_action" } + // ValidateBasic runs stateless checks on the message func (msg MsgWalletAction) ValidateBasic() error { if msg.Owner.Empty() {