From 486c70cd7d664e3d17b9e4ec6139239ac2d24e50 Mon Sep 17 00:00:00 2001 From: zakir <80246097+zakir-code@users.noreply.github.com> Date: Mon, 30 Oct 2023 17:48:26 +0800 Subject: [PATCH 1/4] feat: disable eth module --- app/keepers/keepers.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/keepers/keepers.go b/app/keepers/keepers.go index ec640feb6..23f031915 100644 --- a/app/keepers/keepers.go +++ b/app/keepers/keepers.go @@ -431,7 +431,7 @@ func NewAppKeeper( AddRoute(bsctypes.ModuleName, crosschainkeeper.NewModuleHandler(appKeepers.BscKeeper)). AddRoute(polygontypes.ModuleName, crosschainkeeper.NewModuleHandler(appKeepers.PolygonKeeper)). AddRoute(avalanchetypes.ModuleName, crosschainkeeper.NewModuleHandler(appKeepers.AvalancheKeeper)). - AddRoute(ethtypes.ModuleName, crosschainkeeper.NewModuleHandler(appKeepers.EthKeeper)). + //AddRoute(ethtypes.ModuleName, crosschainkeeper.NewModuleHandler(appKeepers.EthKeeper)). AddRoute(arbitrumtypes.ModuleName, crosschainkeeper.NewModuleHandler(appKeepers.ArbitrumKeeper)). AddRoute(optimismtypes.ModuleName, crosschainkeeper.NewModuleHandler(appKeepers.OptimismKeeper)). AddRoute(trontypes.ModuleName, tronkeeper.NewModuleHandler(appKeepers.TronKeeper)) From 734ce5bd6da88147da72d4546078941581556f57 Mon Sep 17 00:00:00 2001 From: zakir <80246097+zakir-code@users.noreply.github.com> Date: Tue, 31 Oct 2023 09:54:08 +0800 Subject: [PATCH 2/4] chore: replace with MustAccAddressFromBech32 --- x/crosschain/client/cli/query.go | 2 +- x/crosschain/keeper/attestation.go | 5 +- x/crosschain/keeper/genesis.go | 5 +- x/crosschain/keeper/oracle.go | 5 +- x/crosschain/types/msgs.go | 132 ++++------------------ x/crosschain/types/types.go | 13 +-- x/erc20/types/msg.go | 9 +- x/gravity/types/msgs.go | 78 +++---------- x/ibc/applications/transfer/types/msgs.go | 6 +- x/migrate/keeper/genesis.go | 7 +- x/migrate/types/msg.go | 6 +- x/staking/keeper/genesis.go | 10 +- x/staking/types/msg.go | 12 +- 13 files changed, 52 insertions(+), 238 deletions(-) diff --git a/x/crosschain/client/cli/query.go b/x/crosschain/client/cli/query.go index a3499cbb2..4f62d8597 100644 --- a/x/crosschain/client/cli/query.go +++ b/x/crosschain/client/cli/query.go @@ -541,7 +541,7 @@ func CmdGetPendingSendToExternal(chainName string) *cobra.Command { addr, err := sdk.AccAddressFromBech32(args[0]) if err != nil { - return nil + return err } res, err := queryClient.GetPendingSendToExternal(cmd.Context(), &types.QueryPendingSendToExternalRequest{ ChainName: chainName, diff --git a/x/crosschain/keeper/attestation.go b/x/crosschain/keeper/attestation.go index 128157f1a..a4d9f4c5d 100644 --- a/x/crosschain/keeper/attestation.go +++ b/x/crosschain/keeper/attestation.go @@ -69,10 +69,7 @@ func (k Keeper) TryAttestation(ctx sdk.Context, att *types.Attestation, claim ty attestationPower := sdkmath.NewInt(0) for _, oracleStr := range att.Votes { - oracleAddr, err := sdk.AccAddressFromBech32(oracleStr) - if err != nil { - panic(fmt.Errorf("invalid oracle address %s", err.Error())) - } + oracleAddr := sdk.MustAccAddressFromBech32(oracleStr) oracle, found := k.GetOracle(ctx, oracleAddr) if !found { k.Logger(ctx).Error("TryAttestation", "not found oracle", oracleAddr.String(), "claimEventNonce", diff --git a/x/crosschain/keeper/genesis.go b/x/crosschain/keeper/genesis.go index 87cad23f8..78fda2a50 100644 --- a/x/crosschain/keeper/genesis.go +++ b/x/crosschain/keeper/genesis.go @@ -123,10 +123,7 @@ func InitGenesis(ctx sdk.Context, k Keeper, state *types.GenesisState) { // while all attestations have already been cleaned up we can do this instead and // not carry around every validators event nonce counter forever. for _, vote := range att.Votes { - oracle, err := sdk.AccAddressFromBech32(vote) - if err != nil { - panic(err) - } + oracle := sdk.MustAccAddressFromBech32(vote) last := k.GetLastEventNonceByOracle(ctx, oracle) if claim.GetEventNonce() > last { // 0x23 diff --git a/x/crosschain/keeper/oracle.go b/x/crosschain/keeper/oracle.go index 3c77e5621..d44416382 100644 --- a/x/crosschain/keeper/oracle.go +++ b/x/crosschain/keeper/oracle.go @@ -183,10 +183,7 @@ func (k Keeper) GetAllOracles(ctx sdk.Context, isOnline bool) (oracles types.Ora } func (k Keeper) SlashOracle(ctx sdk.Context, oracleAddrStr string) { - oracleAddr, err := sdk.AccAddressFromBech32(oracleAddrStr) - if err != nil { - panic(err) - } + oracleAddr := sdk.MustAccAddressFromBech32(oracleAddrStr) oracle, found := k.GetOracle(ctx, oracleAddr) if !found { panic(types.ErrNoFoundOracle) diff --git a/x/crosschain/types/msgs.go b/x/crosschain/types/msgs.go index ad47259d4..736425bca 100644 --- a/x/crosschain/types/msgs.go +++ b/x/crosschain/types/msgs.go @@ -166,11 +166,7 @@ func (m *MsgBondedOracle) GetSignBytes() []byte { } func (m *MsgBondedOracle) GetSigners() []sdk.AccAddress { - acc, err := sdk.AccAddressFromBech32(m.OracleAddress) - if err != nil { - panic(err) - } - return []sdk.AccAddress{acc} + return []sdk.AccAddress{sdk.MustAccAddressFromBech32(m.OracleAddress)} } // MsgAddDelegate @@ -197,11 +193,7 @@ func (m *MsgAddDelegate) GetSignBytes() []byte { } func (m *MsgAddDelegate) GetSigners() []sdk.AccAddress { - acc, err := sdk.AccAddressFromBech32(m.OracleAddress) - if err != nil { - panic(err) - } - return []sdk.AccAddress{acc} + return []sdk.AccAddress{sdk.MustAccAddressFromBech32(m.OracleAddress)} } // MsgReDelegate @@ -228,11 +220,7 @@ func (m *MsgReDelegate) GetSignBytes() []byte { } func (m *MsgReDelegate) GetSigners() []sdk.AccAddress { - acc, err := sdk.AccAddressFromBech32(m.OracleAddress) - if err != nil { - panic(err) - } - return []sdk.AccAddress{acc} + return []sdk.AccAddress{sdk.MustAccAddressFromBech32(m.OracleAddress)} } // MsgEditBridger @@ -257,11 +245,7 @@ func (m *MsgEditBridger) GetSignBytes() []byte { } func (m *MsgEditBridger) GetSigners() []sdk.AccAddress { - acc, err := sdk.AccAddressFromBech32(m.OracleAddress) - if err != nil { - panic(err) - } - return []sdk.AccAddress{acc} + return []sdk.AccAddress{sdk.MustAccAddressFromBech32(m.OracleAddress)} } // MsgWithdrawReward @@ -286,11 +270,7 @@ func (m *MsgWithdrawReward) GetSignBytes() []byte { } func (m *MsgWithdrawReward) GetSigners() []sdk.AccAddress { - acc, err := sdk.AccAddressFromBech32(m.OracleAddress) - if err != nil { - panic(err) - } - return []sdk.AccAddress{acc} + return []sdk.AccAddress{sdk.MustAccAddressFromBech32(m.OracleAddress)} } // MsgUnbondedOracle @@ -315,11 +295,7 @@ func (m *MsgUnbondedOracle) GetSignBytes() []byte { } func (m *MsgUnbondedOracle) GetSigners() []sdk.AccAddress { - acc, err := sdk.AccAddressFromBech32(m.OracleAddress) - if err != nil { - panic(err) - } - return []sdk.AccAddress{acc} + return []sdk.AccAddress{sdk.MustAccAddressFromBech32(m.OracleAddress)} } // MsgOracleSetConfirm @@ -349,11 +325,7 @@ func (m *MsgOracleSetConfirm) GetSignBytes() []byte { // GetSigners defines whose signature is required func (m *MsgOracleSetConfirm) GetSigners() []sdk.AccAddress { - acc, err := sdk.AccAddressFromBech32(m.BridgerAddress) - if err != nil { - panic(err) - } - return []sdk.AccAddress{acc} + return []sdk.AccAddress{sdk.MustAccAddressFromBech32(m.BridgerAddress)} } // MsgSendToExternal @@ -384,11 +356,7 @@ func (m *MsgSendToExternal) GetSignBytes() []byte { // GetSigners defines whose signature is required func (m *MsgSendToExternal) GetSigners() []sdk.AccAddress { - acc, err := sdk.AccAddressFromBech32(m.Sender) - if err != nil { - panic(err) - } - return []sdk.AccAddress{acc} + return []sdk.AccAddress{sdk.MustAccAddressFromBech32(m.Sender)} } // MsgRequestBatch @@ -418,11 +386,7 @@ func (m *MsgRequestBatch) GetSignBytes() []byte { // GetSigners defines whose signature is required func (m *MsgRequestBatch) GetSigners() []sdk.AccAddress { - acc, err := sdk.AccAddressFromBech32(m.Sender) - if err != nil { - panic(err) - } - return []sdk.AccAddress{acc} + return []sdk.AccAddress{sdk.MustAccAddressFromBech32(m.Sender)} } // MsgConfirmBatch @@ -452,11 +416,7 @@ func (m *MsgConfirmBatch) GetSignBytes() []byte { // GetSigners defines whose signature is required func (m *MsgConfirmBatch) GetSigners() []sdk.AccAddress { - acc, err := sdk.AccAddressFromBech32(m.BridgerAddress) - if err != nil { - panic(err) - } - return []sdk.AccAddress{acc} + return []sdk.AccAddress{sdk.MustAccAddressFromBech32(m.BridgerAddress)} } // MsgCancelSendToExternal @@ -486,11 +446,7 @@ func (m *MsgCancelSendToExternal) GetSignBytes() []byte { // GetSigners defines whose signature is required func (m *MsgCancelSendToExternal) GetSigners() []sdk.AccAddress { - acc, err := sdk.AccAddressFromBech32(m.Sender) - if err != nil { - panic(err) - } - return []sdk.AccAddress{acc} + return []sdk.AccAddress{sdk.MustAccAddressFromBech32(m.Sender)} } // MsgIncreaseBridgeFee @@ -520,11 +476,7 @@ func (m *MsgIncreaseBridgeFee) GetSignBytes() []byte { // GetSigners defines whose signature is required func (m *MsgIncreaseBridgeFee) GetSigners() []sdk.AccAddress { - acc, err := sdk.AccAddressFromBech32(m.Sender) - if err != nil { - panic(err) - } - return []sdk.AccAddress{acc} + return []sdk.AccAddress{sdk.MustAccAddressFromBech32(m.Sender)} } // ExternalClaim represents a claim on ethereum state @@ -588,20 +540,12 @@ func (m *MsgSendToFxClaim) GetSignBytes() []byte { } func (m *MsgSendToFxClaim) GetClaimer() sdk.AccAddress { - val, err := sdk.AccAddressFromBech32(m.BridgerAddress) - if err != nil { - panic(err) - } - return val + return sdk.MustAccAddressFromBech32(m.BridgerAddress) } // GetSigners defines whose signature is required func (m *MsgSendToFxClaim) GetSigners() []sdk.AccAddress { - acc, err := sdk.AccAddressFromBech32(m.BridgerAddress) - if err != nil { - panic(err) - } - return []sdk.AccAddress{acc} + return []sdk.AccAddress{sdk.MustAccAddressFromBech32(m.BridgerAddress)} } // Type should return the action @@ -647,20 +591,12 @@ func (m *MsgSendToExternalClaim) GetSignBytes() []byte { } func (m *MsgSendToExternalClaim) GetClaimer() sdk.AccAddress { - val, err := sdk.AccAddressFromBech32(m.BridgerAddress) - if err != nil { - panic(fmt.Sprintf("invalid address %s", m.BridgerAddress)) - } - return val + return sdk.MustAccAddressFromBech32(m.BridgerAddress) } // GetSigners defines whose signature is required func (m *MsgSendToExternalClaim) GetSigners() []sdk.AccAddress { - acc, err := sdk.AccAddressFromBech32(m.BridgerAddress) - if err != nil { - panic(err) - } - return []sdk.AccAddress{acc} + return []sdk.AccAddress{sdk.MustAccAddressFromBech32(m.BridgerAddress)} } // Route should return the name of the module @@ -691,19 +627,11 @@ func (m *MsgBridgeTokenClaim) GetSignBytes() []byte { } func (m *MsgBridgeTokenClaim) GetSigners() []sdk.AccAddress { - acc, err := sdk.AccAddressFromBech32(m.BridgerAddress) - if err != nil { - panic(err) - } - return []sdk.AccAddress{acc} + return []sdk.AccAddress{sdk.MustAccAddressFromBech32(m.BridgerAddress)} } func (m *MsgBridgeTokenClaim) GetClaimer() sdk.AccAddress { - val, err := sdk.AccAddressFromBech32(m.BridgerAddress) - if err != nil { - panic(fmt.Sprintf("invalid address %s", m.BridgerAddress)) - } - return val + return sdk.MustAccAddressFromBech32(m.BridgerAddress) } func (m *MsgBridgeTokenClaim) GetType() ClaimType { @@ -740,20 +668,12 @@ func (m *MsgOracleSetUpdatedClaim) GetSignBytes() []byte { } func (m *MsgOracleSetUpdatedClaim) GetClaimer() sdk.AccAddress { - val, err := sdk.AccAddressFromBech32(m.BridgerAddress) - if err != nil { - panic(fmt.Sprintf("invalid address %s", m.BridgerAddress)) - } - return val + return sdk.MustAccAddressFromBech32(m.BridgerAddress) } // GetSigners defines whose signature is required func (m *MsgOracleSetUpdatedClaim) GetSigners() []sdk.AccAddress { - acc, err := sdk.AccAddressFromBech32(m.BridgerAddress) - if err != nil { - panic(err) - } - return []sdk.AccAddress{acc} + return []sdk.AccAddress{sdk.MustAccAddressFromBech32(m.BridgerAddress)} } // Type should return the action @@ -773,11 +693,7 @@ func (m *MsgSetOrchestratorAddress) ValidateBasic() (err error) { } func (m *MsgSetOrchestratorAddress) GetSigners() []sdk.AccAddress { - acc, err := sdk.AccAddressFromBech32(m.BridgerAddress) - if err != nil { - panic(err) - } - return []sdk.AccAddress{acc} + return []sdk.AccAddress{sdk.MustAccAddressFromBech32(m.BridgerAddress)} } func (m *MsgAddOracleDeposit) ValidateBasic() (err error) { @@ -785,11 +701,7 @@ func (m *MsgAddOracleDeposit) ValidateBasic() (err error) { } func (m *MsgAddOracleDeposit) GetSigners() []sdk.AccAddress { - acc, err := sdk.AccAddressFromBech32(m.OracleAddress) - if err != nil { - panic(err) - } - return []sdk.AccAddress{acc} + return []sdk.AccAddress{sdk.MustAccAddressFromBech32(m.OracleAddress)} } // Route returns the MsgUpdateParams message route. diff --git a/x/crosschain/types/types.go b/x/crosschain/types/types.go index efa13c3ed..1e9cffe25 100644 --- a/x/crosschain/types/types.go +++ b/x/crosschain/types/types.go @@ -321,20 +321,11 @@ func (m *OutgoingTxBatch) GetCheckpoint(gravityIDString string) ([]byte, error) // --- Oracle(S) --- // func (m *Oracle) GetOracle() sdk.AccAddress { - // oracle address can't be empty - addr, err := sdk.AccAddressFromBech32(m.OracleAddress) - if err != nil { - panic(err) - } - return addr + return sdk.MustAccAddressFromBech32(m.OracleAddress) } func (m *Oracle) GetBridger() sdk.AccAddress { - addr, err := sdk.AccAddressFromBech32(m.BridgerAddress) - if err != nil { - panic(err) - } - return addr + return sdk.MustAccAddressFromBech32(m.BridgerAddress) } func (m *Oracle) GetValidator() sdk.ValAddress { diff --git a/x/erc20/types/msg.go b/x/erc20/types/msg.go index 47a0dbf01..b3e41cf5c 100644 --- a/x/erc20/types/msg.go +++ b/x/erc20/types/msg.go @@ -77,8 +77,7 @@ func (m *MsgConvertCoin) GetSignBytes() []byte { // GetSigners defines whose signature is required func (m *MsgConvertCoin) GetSigners() []sdk.AccAddress { - addr := sdk.MustAccAddressFromBech32(m.Sender) - return []sdk.AccAddress{addr} + return []sdk.AccAddress{sdk.MustAccAddressFromBech32(m.Sender)} } // NewMsgConvertERC20 creates a new instance of MsgConvertERC20 @@ -121,8 +120,7 @@ func (m *MsgConvertERC20) GetSignBytes() []byte { // GetSigners defines whose signature is required func (m *MsgConvertERC20) GetSigners() []sdk.AccAddress { - addr := common.HexToAddress(m.Sender) - return []sdk.AccAddress{addr.Bytes()} + return []sdk.AccAddress{common.HexToAddress(m.Sender).Bytes()} } func NewMsgConvertDenom(sender, receiver sdk.AccAddress, coin sdk.Coin, target string) *MsgConvertDenom { @@ -161,8 +159,7 @@ func (m *MsgConvertDenom) GetSignBytes() []byte { // GetSigners defines whose signature is required func (m *MsgConvertDenom) GetSigners() []sdk.AccAddress { - addr := sdk.MustAccAddressFromBech32(m.Sender) - return []sdk.AccAddress{addr} + return []sdk.AccAddress{sdk.MustAccAddressFromBech32(m.Sender)} } // Route returns the MsgUpdateParams message route. diff --git a/x/gravity/types/msgs.go b/x/gravity/types/msgs.go index e38a9afde..633deccd4 100644 --- a/x/gravity/types/msgs.go +++ b/x/gravity/types/msgs.go @@ -105,11 +105,7 @@ func (m *MsgValsetConfirm) GetSignBytes() []byte { // GetSigners defines whose signature is required func (m *MsgValsetConfirm) GetSigners() []sdk.AccAddress { - acc, err := sdk.AccAddressFromBech32(m.Orchestrator) - if err != nil { - panic(err) - } - return []sdk.AccAddress{acc} + return []sdk.AccAddress{sdk.MustAccAddressFromBech32(m.Orchestrator)} } // Route should return the name of the module @@ -146,11 +142,7 @@ func (m *MsgSendToEth) GetSignBytes() []byte { // GetSigners defines whose signature is required func (m *MsgSendToEth) GetSigners() []sdk.AccAddress { - acc, err := sdk.AccAddressFromBech32(m.Sender) - if err != nil { - panic(err) - } - return []sdk.AccAddress{acc} + return []sdk.AccAddress{sdk.MustAccAddressFromBech32(m.Sender)} } // Route should return the name of the module @@ -186,11 +178,7 @@ func (m *MsgRequestBatch) GetSignBytes() []byte { // GetSigners defines whose signature is required func (m *MsgRequestBatch) GetSigners() []sdk.AccAddress { - acc, err := sdk.AccAddressFromBech32(m.Sender) - if err != nil { - panic(err) - } - return []sdk.AccAddress{acc} + return []sdk.AccAddress{sdk.MustAccAddressFromBech32(m.Sender)} } // Route should return the name of the module @@ -226,11 +214,7 @@ func (m *MsgConfirmBatch) GetSignBytes() []byte { // GetSigners defines whose signature is required func (m *MsgConfirmBatch) GetSigners() []sdk.AccAddress { - acc, err := sdk.AccAddressFromBech32(m.Orchestrator) - if err != nil { - panic(err) - } - return []sdk.AccAddress{acc} + return []sdk.AccAddress{sdk.MustAccAddressFromBech32(m.Orchestrator)} } // Route should return the name of the module @@ -257,11 +241,7 @@ func (m *MsgCancelSendToEth) GetSignBytes() []byte { // GetSigners defines whose signature is required func (m *MsgCancelSendToEth) GetSigners() []sdk.AccAddress { - acc, err := sdk.AccAddressFromBech32(m.Sender) - if err != nil { - panic(err) - } - return []sdk.AccAddress{acc} + return []sdk.AccAddress{sdk.MustAccAddressFromBech32(m.Sender)} } // Deprecated: EthereumClaim represents a claim on ethereum state @@ -339,20 +319,12 @@ func (m *MsgDepositClaim) GetSignBytes() []byte { } func (m *MsgDepositClaim) GetClaimer() sdk.AccAddress { - val, err := sdk.AccAddressFromBech32(m.Orchestrator) - if err != nil { - panic(err) - } - return val + return sdk.MustAccAddressFromBech32(m.Orchestrator) } // GetSigners defines whose signature is required func (m *MsgDepositClaim) GetSigners() []sdk.AccAddress { - acc, err := sdk.AccAddressFromBech32(m.Orchestrator) - if err != nil { - panic(err) - } - return []sdk.AccAddress{acc} + return []sdk.AccAddress{sdk.MustAccAddressFromBech32(m.Orchestrator)} } // Type should return the action @@ -404,20 +376,12 @@ func (m *MsgWithdrawClaim) GetSignBytes() []byte { } func (m *MsgWithdrawClaim) GetClaimer() sdk.AccAddress { - val, err := sdk.AccAddressFromBech32(m.Orchestrator) - if err != nil { - panic(err) - } - return val + return sdk.MustAccAddressFromBech32(m.Orchestrator) } // GetSigners defines whose signature is required func (m *MsgWithdrawClaim) GetSigners() []sdk.AccAddress { - acc, err := sdk.AccAddressFromBech32(m.Orchestrator) - if err != nil { - panic(err) - } - return []sdk.AccAddress{acc} + return []sdk.AccAddress{sdk.MustAccAddressFromBech32(m.Orchestrator)} } // Route should return the name of the module @@ -459,19 +423,11 @@ func (m *MsgFxOriginatedTokenClaim) GetSignBytes() []byte { } func (m *MsgFxOriginatedTokenClaim) GetSigners() []sdk.AccAddress { - acc, err := sdk.AccAddressFromBech32(m.Orchestrator) - if err != nil { - panic(err) - } - return []sdk.AccAddress{acc} + return []sdk.AccAddress{sdk.MustAccAddressFromBech32(m.Orchestrator)} } func (m *MsgFxOriginatedTokenClaim) GetClaimer() sdk.AccAddress { - val, err := sdk.AccAddressFromBech32(m.Orchestrator) - if err != nil { - panic(err) - } - return val + return sdk.MustAccAddressFromBech32(m.Orchestrator) } func (m *MsgFxOriginatedTokenClaim) GetType() ClaimType { @@ -519,20 +475,12 @@ func (m *MsgValsetUpdatedClaim) GetSignBytes() []byte { } func (m *MsgValsetUpdatedClaim) GetClaimer() sdk.AccAddress { - val, err := sdk.AccAddressFromBech32(m.Orchestrator) - if err != nil { - panic(err) - } - return val + return sdk.MustAccAddressFromBech32(m.Orchestrator) } // GetSigners defines whose signature is required func (m *MsgValsetUpdatedClaim) GetSigners() []sdk.AccAddress { - acc, err := sdk.AccAddressFromBech32(m.Orchestrator) - if err != nil { - panic(err) - } - return []sdk.AccAddress{acc} + return []sdk.AccAddress{sdk.MustAccAddressFromBech32(m.Orchestrator)} } // Type should return the action diff --git a/x/ibc/applications/transfer/types/msgs.go b/x/ibc/applications/transfer/types/msgs.go index f4cbf8591..a28eac85c 100644 --- a/x/ibc/applications/transfer/types/msgs.go +++ b/x/ibc/applications/transfer/types/msgs.go @@ -88,9 +88,5 @@ func (msg MsgTransfer) GetSignBytes() []byte { // GetSigners implements sdk.Msg func (msg MsgTransfer) GetSigners() []sdk.AccAddress { - valAddr, err := sdk.AccAddressFromBech32(msg.Sender) - if err != nil { - panic(err) - } - return []sdk.AccAddress{valAddr} + return []sdk.AccAddress{sdk.MustAccAddressFromBech32(msg.Sender)} } diff --git a/x/migrate/keeper/genesis.go b/x/migrate/keeper/genesis.go index ed118c31f..0c8c90dca 100644 --- a/x/migrate/keeper/genesis.go +++ b/x/migrate/keeper/genesis.go @@ -11,11 +11,8 @@ import ( // InitGenesis import module genesis func (k Keeper) InitGenesis(ctx sdk.Context, state types.GenesisState) { for _, record := range state.MigrateRecords { - fromAddr, err := sdk.AccAddressFromBech32(record.From) - if err != nil { - panic(err) - } - if err = fxtypes.ValidateEthereumAddress(record.To); err != nil { + fromAddr := sdk.MustAccAddressFromBech32(record.From) + if err := fxtypes.ValidateEthereumAddress(record.To); err != nil { panic(err) } k.SetMigrateRecord(ctx, fromAddr, common.HexToAddress(record.To)) diff --git a/x/migrate/types/msg.go b/x/migrate/types/msg.go index 6a2708577..2bd2cca31 100644 --- a/x/migrate/types/msg.go +++ b/x/migrate/types/msg.go @@ -74,11 +74,7 @@ func (m *MsgMigrateAccount) GetSignBytes() []byte { // GetSigners defines whose signature is required func (m *MsgMigrateAccount) GetSigners() []sdk.AccAddress { - acc, err := sdk.AccAddressFromBech32(m.From) - if err != nil { - panic(err) - } - return []sdk.AccAddress{acc} + return []sdk.AccAddress{sdk.MustAccAddressFromBech32(m.From)} } func MigrateAccountSignatureHash(from, to []byte) []byte { diff --git a/x/staking/keeper/genesis.go b/x/staking/keeper/genesis.go index 46bfd234e..a584fe12b 100644 --- a/x/staking/keeper/genesis.go +++ b/x/staking/keeper/genesis.go @@ -18,14 +18,8 @@ func (k Keeper) InitGenesis(ctx sdk.Context, data *types.GenesisState) (res []ab if err != nil { panic(err) } - ownerAddr, err := sdk.AccAddressFromBech32(allowance.OwnerAddress) - if err != nil { - panic(err) - } - spenderAddr, err := sdk.AccAddressFromBech32(allowance.SpenderAddress) - if err != nil { - panic(err) - } + ownerAddr := sdk.MustAccAddressFromBech32(allowance.OwnerAddress) + spenderAddr := sdk.MustAccAddressFromBech32(allowance.SpenderAddress) if allowance.Allowance.IsNegative() { panic("allowance must be positive") } diff --git a/x/staking/types/msg.go b/x/staking/types/msg.go index 3539b64c7..903e785c2 100644 --- a/x/staking/types/msg.go +++ b/x/staking/types/msg.go @@ -84,11 +84,7 @@ func (m *MsgGrantPrivilege) GetSignBytes() []byte { } func (m *MsgGrantPrivilege) GetSigners() []sdk.AccAddress { - acc, err := sdk.AccAddressFromBech32(m.FromAddress) - if err != nil { - panic(err) - } - return []sdk.AccAddress{acc} + return []sdk.AccAddress{sdk.MustAccAddressFromBech32(m.FromAddress)} } // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces @@ -163,11 +159,7 @@ func (m *MsgEditConsensusPubKey) GetSignBytes() []byte { } func (m *MsgEditConsensusPubKey) GetSigners() []sdk.AccAddress { - acc, err := sdk.AccAddressFromBech32(m.From) - if err != nil { - panic(err) - } - return []sdk.AccAddress{acc} + return []sdk.AccAddress{sdk.MustAccAddressFromBech32(m.From)} } // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces From 87071a39783b883eff15d5da49ff65bb19edf988 Mon Sep 17 00:00:00 2001 From: zakir <80246097+zakir-code@users.noreply.github.com> Date: Tue, 31 Oct 2023 10:34:55 +0800 Subject: [PATCH 3/4] Update app/keepers/keepers.go --- app/keepers/keepers.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/keepers/keepers.go b/app/keepers/keepers.go index 23f031915..ec640feb6 100644 --- a/app/keepers/keepers.go +++ b/app/keepers/keepers.go @@ -431,7 +431,7 @@ func NewAppKeeper( AddRoute(bsctypes.ModuleName, crosschainkeeper.NewModuleHandler(appKeepers.BscKeeper)). AddRoute(polygontypes.ModuleName, crosschainkeeper.NewModuleHandler(appKeepers.PolygonKeeper)). AddRoute(avalanchetypes.ModuleName, crosschainkeeper.NewModuleHandler(appKeepers.AvalancheKeeper)). - //AddRoute(ethtypes.ModuleName, crosschainkeeper.NewModuleHandler(appKeepers.EthKeeper)). + AddRoute(ethtypes.ModuleName, crosschainkeeper.NewModuleHandler(appKeepers.EthKeeper)). AddRoute(arbitrumtypes.ModuleName, crosschainkeeper.NewModuleHandler(appKeepers.ArbitrumKeeper)). AddRoute(optimismtypes.ModuleName, crosschainkeeper.NewModuleHandler(appKeepers.OptimismKeeper)). AddRoute(trontypes.ModuleName, tronkeeper.NewModuleHandler(appKeepers.TronKeeper)) From 8c6306367b57bc710260fc84fa8d90cebc8adaad Mon Sep 17 00:00:00 2001 From: zakir <80246097+zakir-code@users.noreply.github.com> Date: Tue, 31 Oct 2023 10:47:58 +0800 Subject: [PATCH 4/4] fix err --- x/crosschain/keeper/attestation.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x/crosschain/keeper/attestation.go b/x/crosschain/keeper/attestation.go index a4d9f4c5d..e940ebfce 100644 --- a/x/crosschain/keeper/attestation.go +++ b/x/crosschain/keeper/attestation.go @@ -96,7 +96,7 @@ func (k Keeper) TryAttestation(ctx sdk.Context, att *types.Attestation, claim ty att.Observed = true k.SetAttestation(ctx, claim.GetEventNonce(), claim.ClaimHash(), att) - err = k.processAttestation(ctx, claim) + err := k.processAttestation(ctx, claim) ctx.EventManager().EmitEvent(sdk.NewEvent( types.EventTypeContractEvent, sdk.NewAttribute(sdk.AttributeKeyModule, k.moduleName),