Skip to content

Commit

Permalink
fix: does not support fswap and fbridge amino bug
Browse files Browse the repository at this point in the history
  • Loading branch information
zemyblue committed May 11, 2024
1 parent 97570b2 commit 99a4c6a
Show file tree
Hide file tree
Showing 3 changed files with 146 additions and 0 deletions.
1 change: 1 addition & 0 deletions x/fbridge/types/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ var (
)

func init() {
RegisterLegacyAminoCodec(Amino)
cryptocodec.RegisterCrypto(Amino)
codec.RegisterEvidences(Amino)
sdk.RegisterLegacyAminoCodec(Amino)
Expand Down
110 changes: 110 additions & 0 deletions x/fbridge/types/msgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,96 +32,206 @@ func (m MsgTransfer) GetSigners() []sdk.AccAddress {
return []sdk.AccAddress{sdk.MustAccAddressFromBech32(m.Sender)}
}

// GetSignBytes implements the LegacyMsg.GetSignBytes method.
func (m MsgTransfer) GetSignBytes() []byte {
return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m))
}

// Type implements the LegacyMsg.Type method.
func (m MsgTransfer) Type() string {
return sdk.MsgTypeURL(&m)
}

// Route implements the LegacyMsg.Route method.
func (m MsgTransfer) Route() string {
return sdk.MsgTypeURL(&m)
}

func (m MsgProvision) ValidateBasic() error { return nil }

func (m MsgProvision) GetSigners() []sdk.AccAddress {
return []sdk.AccAddress{sdk.MustAccAddressFromBech32(m.From)}
}

// GetSignBytes implements the LegacyMsg.GetSignBytes method.
func (m MsgProvision) GetSignBytes() []byte {
return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m))
}

// Type implements the LegacyMsg.Type method.
func (m MsgProvision) Type() string {
return sdk.MsgTypeURL(&m)
}

// Route implements the LegacyMsg.Route method.
func (m MsgProvision) Route() string {
return sdk.MsgTypeURL(&m)
}

func (m MsgHoldTransfer) ValidateBasic() error { return nil }

func (m MsgHoldTransfer) GetSigners() []sdk.AccAddress {
return []sdk.AccAddress{sdk.MustAccAddressFromBech32(m.From)}
}

// GetSignBytes implements the LegacyMsg.GetSignBytes method.
func (m MsgHoldTransfer) GetSignBytes() []byte {
return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m))
}

// Type implements the LegacyMsg.Type method.
func (m MsgHoldTransfer) Type() string {
return sdk.MsgTypeURL(&m)
}

// Route implements the LegacyMsg.Route method.
func (m MsgHoldTransfer) Route() string {
return sdk.MsgTypeURL(&m)
}

func (m MsgReleaseTransfer) ValidateBasic() error { return nil }

func (m MsgReleaseTransfer) GetSigners() []sdk.AccAddress {
return []sdk.AccAddress{sdk.MustAccAddressFromBech32(m.From)}
}

// GetSignBytes implements the LegacyMsg.GetSignBytes method.
func (m MsgReleaseTransfer) GetSignBytes() []byte {
return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m))
}

// Type implements the LegacyMsg.Type method.
func (m MsgReleaseTransfer) Type() string {
return sdk.MsgTypeURL(&m)
}

// Route implements the LegacyMsg.Route method.
func (m MsgReleaseTransfer) Route() string {
return sdk.MsgTypeURL(&m)
}

func (m MsgRemoveProvision) ValidateBasic() error { return nil }

func (m MsgRemoveProvision) GetSigners() []sdk.AccAddress {
return []sdk.AccAddress{sdk.MustAccAddressFromBech32(m.From)}
}

// GetSignBytes implements the LegacyMsg.GetSignBytes method.
func (m MsgRemoveProvision) GetSignBytes() []byte {
return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m))
}

// Type implements the LegacyMsg.Type method.
func (m MsgRemoveProvision) Type() string {
return sdk.MsgTypeURL(&m)
}

// Route implements the LegacyMsg.Route method.
func (m MsgRemoveProvision) Route() string {
return sdk.MsgTypeURL(&m)
}

func (m MsgClaimBatch) ValidateBasic() error { return nil }

func (m MsgClaimBatch) GetSigners() []sdk.AccAddress {
return []sdk.AccAddress{sdk.MustAccAddressFromBech32(m.From)}
}

// GetSignBytes implements the LegacyMsg.GetSignBytes method.
func (m MsgClaimBatch) GetSignBytes() []byte {
return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m))
}

// Type implements the LegacyMsg.Type method.
func (m MsgClaimBatch) Type() string {
return sdk.MsgTypeURL(&m)
}

// Route implements the LegacyMsg.Route method.
func (m MsgClaimBatch) Route() string {
return sdk.MsgTypeURL(&m)
}

func (m MsgClaim) ValidateBasic() error { return nil }

func (m MsgClaim) GetSigners() []sdk.AccAddress {
return []sdk.AccAddress{sdk.MustAccAddressFromBech32(m.From)}
}

// GetSignBytes implements the LegacyMsg.GetSignBytes method.
func (m MsgClaim) GetSignBytes() []byte {
return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m))
}

// Type implements the LegacyMsg.Type method.
func (m MsgClaim) Type() string {
return sdk.MsgTypeURL(&m)
}

// Route implements the LegacyMsg.Route method.
func (m MsgClaim) Route() string {
return sdk.MsgTypeURL(&m)
}

func (m MsgSuggestRole) ValidateBasic() error { return nil }

func (m MsgSuggestRole) GetSigners() []sdk.AccAddress {
return []sdk.AccAddress{sdk.MustAccAddressFromBech32(m.From)}
}

// GetSignBytes implements the LegacyMsg.GetSignBytes method.
func (m MsgSuggestRole) GetSignBytes() []byte {
return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m))
}

// Type implements the LegacyMsg.Type method.
func (m MsgSuggestRole) Type() string {
return sdk.MsgTypeURL(&m)
}

// Route implements the LegacyMsg.Route method.
func (m MsgSuggestRole) Route() string {
return sdk.MsgTypeURL(&m)
}

func (m MsgAddVoteForRole) ValidateBasic() error { return nil }

func (m MsgAddVoteForRole) GetSigners() []sdk.AccAddress {
return []sdk.AccAddress{sdk.MustAccAddressFromBech32(m.From)}
}

// GetSignBytes implements the LegacyMsg.GetSignBytes method.
func (m MsgAddVoteForRole) GetSignBytes() []byte {
return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m))
}

// Type implements the LegacyMsg.Type method.
func (m MsgAddVoteForRole) Type() string {
return sdk.MsgTypeURL(&m)
}

// Route implements the LegacyMsg.Route method.
func (m MsgAddVoteForRole) Route() string {
return sdk.MsgTypeURL(&m)
}

func (m MsgSetBridgeStatus) ValidateBasic() error { return nil }

func (m MsgSetBridgeStatus) GetSigners() []sdk.AccAddress {
return []sdk.AccAddress{sdk.MustAccAddressFromBech32(m.Guardian)}
}

// GetSignBytes implements the LegacyMsg.GetSignBytes method.
func (m MsgSetBridgeStatus) GetSignBytes() []byte {
return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m))
}

// Type implements the LegacyMsg.Type method.
func (m MsgSetBridgeStatus) Type() string {
return sdk.MsgTypeURL(&m)
}

// Route implements the LegacyMsg.Route method.
func (m MsgSetBridgeStatus) Route() string {
return sdk.MsgTypeURL(&m)
}
35 changes: 35 additions & 0 deletions x/fswap/types/msgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package types
import (
sdk "github.com/Finschia/finschia-sdk/types"
sdkerrors "github.com/Finschia/finschia-sdk/types/errors"
"github.com/Finschia/finschia-sdk/x/foundation/codec"
)

var (
Expand Down Expand Up @@ -47,6 +48,20 @@ func (m *MsgSwap) GetSignBytes() []byte {
return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(m))
}

// Type implements the LegacyMsg.Type method.
func (m *MsgSwap) Type() string {
return sdk.MsgTypeURL(m)
}

// Route implements the LegacyMsg.Route method.
func (m *MsgSwap) Route() string {
return sdk.MsgTypeURL(m)
}

func (m *MsgSwap) GetSignerBytes() []byte {
return sdk.MustSortJSON(codec.ModuleCdc.MustMarshalJSON(m))
}

// ValidateBasic Implements Msg.
func (m *MsgSwapAll) ValidateBasic() error {
_, err := sdk.AccAddressFromBech32(m.FromAddress)
Expand Down Expand Up @@ -74,6 +89,16 @@ func (m *MsgSwapAll) GetSigners() []sdk.AccAddress {
return []sdk.AccAddress{from}
}

// Type implements the LegacyMsg.Type method.
func (m *MsgSwapAll) Type() string {
return sdk.MsgTypeURL(m)
}

// Route implements the LegacyMsg.Route method.
func (m *MsgSwapAll) Route() string {
return sdk.MsgTypeURL(m)
}

// GetSignBytes implements the LegacyMsg.GetSignBytes method.
func (m *MsgSwapAll) GetSignBytes() []byte {
return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(m))
Expand Down Expand Up @@ -102,6 +127,16 @@ func (m *MsgSetSwap) GetSigners() []sdk.AccAddress {
return []sdk.AccAddress{signer}
}

// Type implements the LegacyMsg.Type method.
func (m *MsgSetSwap) Type() string {
return sdk.MsgTypeURL(m)
}

// Route implements the LegacyMsg.Route method.
func (m *MsgSetSwap) Route() string {
return sdk.MsgTypeURL(m)
}

// GetSignBytes implements the LegacyMsg.GetSignBytes method.
func (m *MsgSetSwap) GetSignBytes() []byte {
return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(m))
Expand Down

0 comments on commit 99a4c6a

Please sign in to comment.