From 48e53924e8c1fe9559b05a14331af5d3e8c5f32e Mon Sep 17 00:00:00 2001 From: Tanmay Date: Wed, 4 Dec 2024 17:53:33 -0500 Subject: [PATCH] update operation whitelist erc20 to not try whitelisting duplicate assets --- x/crosschain/genesis.go | 3 --- x/crosschain/simulation/operation_whitelist_erc20.go | 11 +++++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/x/crosschain/genesis.go b/x/crosschain/genesis.go index 17ecf9bc07..aa96120198 100644 --- a/x/crosschain/genesis.go +++ b/x/crosschain/genesis.go @@ -1,11 +1,8 @@ package crosschain import ( - "fmt" - sdkmath "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/zeta-chain/node/pkg/coin" "github.com/zeta-chain/node/x/crosschain/keeper" "github.com/zeta-chain/node/x/crosschain/types" diff --git a/x/crosschain/simulation/operation_whitelist_erc20.go b/x/crosschain/simulation/operation_whitelist_erc20.go index efa5b894d1..a0fade8955 100644 --- a/x/crosschain/simulation/operation_whitelist_erc20.go +++ b/x/crosschain/simulation/operation_whitelist_erc20.go @@ -87,6 +87,17 @@ func SimulateMsgWhitelistERC20(k keeper.Keeper) simtypes.Operation { ), nil, nil } + foreignCoins := k.GetFungibleKeeper().GetAllForeignCoins(ctx) + for _, fCoin := range foreignCoins { + if fCoin.Asset == tokenAddress && fCoin.ForeignChainId == randomChain.ChainId { + return simtypes.NoOpMsg( + types.ModuleName, + types.TypeMsgWhitelistERC20, + "ERC20 already whitelisted", + ), nil, nil + } + } + gasLimit := r.Int63n(1000000000) + 1 nameLength := r.Intn(97) + 3 msg := types.MsgWhitelistERC20{