From da0ff2b7bb30502d0a07889dd791ef608cf85ee7 Mon Sep 17 00:00:00 2001 From: fx0x55 <80245546+fx0x55@users.noreply.github.com> Date: Fri, 10 Jan 2025 21:28:21 +0800 Subject: [PATCH] refactor(x/crosschain): fix type registration for claim and confirm any --- app/interface_registry.json | 6 ------ x/crosschain/types/codec.go | 14 -------------- x/crosschain/types/msgs.go | 12 ++++++++---- 3 files changed, 8 insertions(+), 24 deletions(-) diff --git a/app/interface_registry.json b/app/interface_registry.json index 3b7b150f..260fab1f 100644 --- a/app/interface_registry.json +++ b/app/interface_registry.json @@ -424,10 +424,7 @@ "/fx.gravity.crosschain.v1.MsgAddDelegate", "/fx.gravity.crosschain.v1.MsgAddOracleDeposit", "/fx.gravity.crosschain.v1.MsgBondedOracle", - "/fx.gravity.crosschain.v1.MsgBridgeCallClaim", "/fx.gravity.crosschain.v1.MsgBridgeCallConfirm", - "/fx.gravity.crosschain.v1.MsgBridgeCallResultClaim", - "/fx.gravity.crosschain.v1.MsgBridgeTokenClaim", "/fx.gravity.crosschain.v1.MsgCancelSendToExternal", "/fx.gravity.crosschain.v1.MsgClaim", "/fx.gravity.crosschain.v1.MsgConfirm", @@ -435,12 +432,9 @@ "/fx.gravity.crosschain.v1.MsgEditBridger", "/fx.gravity.crosschain.v1.MsgIncreaseBridgeFee", "/fx.gravity.crosschain.v1.MsgOracleSetConfirm", - "/fx.gravity.crosschain.v1.MsgOracleSetUpdatedClaim", "/fx.gravity.crosschain.v1.MsgReDelegate", "/fx.gravity.crosschain.v1.MsgRequestBatch", "/fx.gravity.crosschain.v1.MsgSendToExternal", - "/fx.gravity.crosschain.v1.MsgSendToExternalClaim", - "/fx.gravity.crosschain.v1.MsgSendToFxClaim", "/fx.gravity.crosschain.v1.MsgSetOrchestratorAddress", "/fx.gravity.crosschain.v1.MsgUnbondedOracle", "/fx.gravity.crosschain.v1.MsgUpdateChainOracles", diff --git a/x/crosschain/types/codec.go b/x/crosschain/types/codec.go index e3ea1799..e5b558f6 100644 --- a/x/crosschain/types/codec.go +++ b/x/crosschain/types/codec.go @@ -22,32 +22,18 @@ func RegisterInterfaces(registry types.InterfaceRegistry) { &MsgEditBridger{}, &MsgWithdrawReward{}, - &MsgOracleSetConfirm{}, - &MsgSendToExternal{}, &MsgCancelSendToExternal{}, &MsgIncreaseBridgeFee{}, &MsgRequestBatch{}, - &MsgConfirmBatch{}, - - &MsgBridgeCallConfirm{}, &MsgUpdateParams{}, &MsgUpdateChainOracles{}, &MsgClaim{}, - &MsgSendToExternalClaim{}, - &MsgSendToFxClaim{}, - &MsgBridgeCallClaim{}, - &MsgBridgeTokenClaim{}, - &MsgOracleSetUpdatedClaim{}, - &MsgBridgeCallResultClaim{}, &MsgConfirm{}, - &MsgConfirmBatch{}, - &MsgOracleSetConfirm{}, - &MsgBridgeCallConfirm{}, ) registry.RegisterImplementations( diff --git a/x/crosschain/types/msgs.go b/x/crosschain/types/msgs.go index 8e1cb26f..f547017b 100644 --- a/x/crosschain/types/msgs.go +++ b/x/crosschain/types/msgs.go @@ -9,7 +9,6 @@ import ( codectypes "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - sdktx "github.com/cosmos/cosmos-sdk/types/tx" "github.com/cosmos/gogoproto/proto" "github.com/ethereum/go-ethereum/common" @@ -73,7 +72,10 @@ var ( _ sdk.Msg = &MsgConfirm{} ) -var _ codectypes.UnpackInterfacesMessage = &MsgClaim{} +var ( + _ codectypes.UnpackInterfacesMessage = &MsgClaim{} + _ codectypes.UnpackInterfacesMessage = &MsgConfirm{} +) func (m *MsgBondedOracle) ValidateBasic() (err error) { if !fxtypes.IsSupportChain(m.ChainName) { @@ -318,7 +320,8 @@ func (m *MsgClaim) GetSigners() []sdk.AccAddress { // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces func (m MsgClaim) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { - return sdktx.UnpackInterfaces(unpacker, []*codectypes.Any{m.Claim}) + var externalClaim ExternalClaim + return unpacker.UnpackAny(m.Claim, &externalClaim) } func (m *MsgSendToFxClaim) GetType() ClaimType { @@ -695,5 +698,6 @@ func (m *MsgUpdateChainOracles) ValidateBasic() error { // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces func (m MsgConfirm) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { - return sdktx.UnpackInterfaces(unpacker, []*codectypes.Any{m.Confirm}) + var confirm Confirm + return unpacker.UnpackAny(m.Confirm, &confirm) }