Skip to content

Commit

Permalink
fix(golang): complete ledger support for MsgWallet{Spend}Action
Browse files Browse the repository at this point in the history
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
  • Loading branch information
dckc committed Jul 29, 2022
1 parent c8c610a commit a62f6b1
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
2 changes: 2 additions & 0 deletions golang/cosmos/x/swingset/types/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 22 additions & 0 deletions golang/cosmos/x/swingset/types/msgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit a62f6b1

Please sign in to comment.