From c481a679af73b1370937b76a1744755b7ed4f6c7 Mon Sep 17 00:00:00 2001 From: skosito Date: Wed, 6 Mar 2024 20:59:59 +0100 Subject: [PATCH] Rename usdt occurrences --- cmd/zetae2e/README.md | 12 +++---- cmd/zetae2e/config/config.go | 4 +-- cmd/zetae2e/config/contracts.go | 24 ++++++------- cmd/zetae2e/config/example.yml | 4 +-- cmd/zetae2e/config/local.yml | 4 +-- cmd/zetae2e/local/admin.go | 4 +-- cmd/zetae2e/local/bitcoin.go | 4 +-- cmd/zetae2e/local/erc20.go | 4 +-- cmd/zetae2e/local/local.go | 2 +- cmd/zetae2e/stress.go | 4 +-- e2e/README.md | 4 +-- e2e/config/config.go | 6 ++-- e2e/e2etests/e2etests.go | 4 +-- e2e/e2etests/test_crosschain_swap.go | 22 ++++++------ e2e/e2etests/test_erc20_multiple_deposits.go | 10 +++--- e2e/e2etests/test_erc20_multiple_withdraws.go | 12 +++---- e2e/e2etests/test_erc20_refund.go | 25 +++++++------ e2e/e2etests/test_erc20_withdraw.go | 8 ++--- e2e/e2etests/test_pause_zrc20.go | 12 +++---- e2e/e2etests/test_zrc20_swap.go | 16 ++++----- e2e/runner/accounting.go | 14 ++++---- e2e/runner/balances.go | 5 ++- e2e/runner/evm.go | 36 +++++++++---------- e2e/runner/runner.go | 20 +++++------ e2e/runner/setup_evm.go | 24 ++++++------- e2e/runner/setup_zeta.go | 10 +++--- e2e/txserver/zeta_tx_server.go | 26 +++++++------- 27 files changed, 158 insertions(+), 162 deletions(-) diff --git a/cmd/zetae2e/README.md b/cmd/zetae2e/README.md index c296d44057..135f8b0494 100644 --- a/cmd/zetae2e/README.md +++ b/cmd/zetae2e/README.md @@ -43,7 +43,7 @@ contracts: zevm: system_contract: "0xEdf1c3275d13489aCdC6cD6eD246E72458B8795B" eth_zrc20: "0x13A0c5930C028511Dc02665E7285134B6d11A5f4" - usdt_zrc20: "0x0cbe0dF132a6c6B4a2974Fa1b7Fb953CF0Cc798a" + zrc20: "0x0cbe0dF132a6c6B4a2974Fa1b7Fb953CF0Cc798a" btc_zrc20: "0x65a45c57636f9BcCeD4fe193A602008578BcA90b" uniswap_factory: "0x9fd96203f7b22bCF72d9DCb40ff98302376cE09c" uniswap_router: "0x2ca7d64A7EFE2D62A725E2B35Cf7230D6677FfEe" @@ -51,7 +51,7 @@ contracts: zeta_eth: "0x0000c304d2934c00db1d51995b9f6996affd17c0" connector_eth: "0x00005e3125aba53c5652f9f0ce1a4cf91d8b15ea" custody: "0x000047f11c6e42293f433c82473532e869ce4ec5" - usdt: "0x07865c6e87b9f70255377e024ace6630c1eaa37f" + erc20: "0x07865c6e87b9f70255377e024ace6630c1eaa37f" ``` ### Bitcoin setup @@ -126,9 +126,7 @@ contracts: One of the tests can be commented out in case only a deposit or a withdrawal is to be tested. Testing an ERC20 ZRC20 from an EVM chain -Testing ZRC20 requires the same config as for the gas tokens, but must include the `usdt` field that contains the address of the ERC20 on the evm chain and `usdt_zrc20` on ZetaChain. - -It is currently named USDT because it was the defacto ERC20 tested in local tests, this field will be renamed into a more generic name in the future +Testing ZRC20 requires the same config as for the gas tokens, but must include the `erc20` field that contains the address of the ERC20 on the evm chain and `zrc20` on ZetaChain. ```go zeta_chain_id @@ -142,9 +140,9 @@ rpcs: zetacore_rpc contracts: zevm: - usdt_zrc20 + zrc20 evm: - usdt + erc20 ``` ### Testing a ZRC20 from a Bitcoin chain diff --git a/cmd/zetae2e/config/config.go b/cmd/zetae2e/config/config.go index 2d0cd3fed0..b69f90032b 100644 --- a/cmd/zetae2e/config/config.go +++ b/cmd/zetae2e/config/config.go @@ -92,11 +92,11 @@ func ExportContractsFromRunner(r *runner.E2ERunner, conf config.Config) config.C conf.Contracts.EVM.ZetaEthAddress = r.ZetaEthAddr.Hex() conf.Contracts.EVM.ConnectorEthAddr = r.ConnectorEthAddr.Hex() conf.Contracts.EVM.CustodyAddr = r.ERC20CustodyAddr.Hex() - conf.Contracts.EVM.USDT = r.USDTERC20Addr.Hex() + conf.Contracts.EVM.ERC20 = r.ERC20Addr.Hex() conf.Contracts.ZEVM.SystemContractAddr = r.SystemContractAddr.Hex() conf.Contracts.ZEVM.ETHZRC20Addr = r.ETHZRC20Addr.Hex() - conf.Contracts.ZEVM.USDTZRC20Addr = r.USDTZRC20Addr.Hex() + conf.Contracts.ZEVM.ZRC20Addr = r.ZRC20Addr.Hex() conf.Contracts.ZEVM.BTCZRC20Addr = r.BTCZRC20Addr.Hex() conf.Contracts.ZEVM.UniswapFactoryAddr = r.UniswapV2FactoryAddr.Hex() conf.Contracts.ZEVM.UniswapRouterAddr = r.UniswapV2RouterAddr.Hex() diff --git a/cmd/zetae2e/config/contracts.go b/cmd/zetae2e/config/contracts.go index 837e646bb3..ee34089e30 100644 --- a/cmd/zetae2e/config/contracts.go +++ b/cmd/zetae2e/config/contracts.go @@ -55,12 +55,12 @@ func setContractsFromConfig(r *runner.E2ERunner, conf config.Config) error { return err } } - if c := conf.Contracts.EVM.USDT; c != "" { + if c := conf.Contracts.EVM.ERC20; c != "" { if !ethcommon.IsHexAddress(c) { - return fmt.Errorf("invalid USDT: %s", c) + return fmt.Errorf("invalid ERC20: %s", c) } - r.USDTERC20Addr = ethcommon.HexToAddress(c) - r.USDTERC20, err = erc20.NewERC20(r.USDTERC20Addr, r.GoerliClient) + r.ERC20Addr = ethcommon.HexToAddress(c) + r.ERC20, err = erc20.NewERC20(r.ERC20Addr, r.GoerliClient) if err != nil { return err } @@ -87,12 +87,12 @@ func setContractsFromConfig(r *runner.E2ERunner, conf config.Config) error { return err } } - if c := conf.Contracts.ZEVM.USDTZRC20Addr; c != "" { + if c := conf.Contracts.ZEVM.ZRC20Addr; c != "" { if !ethcommon.IsHexAddress(c) { - return fmt.Errorf("invalid USDTZRC20Addr: %s", c) + return fmt.Errorf("invalid ZRC20Addr: %s", c) } - r.USDTZRC20Addr = ethcommon.HexToAddress(c) - r.USDTZRC20, err = zrc20.NewZRC20(r.USDTZRC20Addr, r.ZevmClient) + r.ZRC20Addr = ethcommon.HexToAddress(c) + r.ZRC20, err = zrc20.NewZRC20(r.ZRC20Addr, r.ZevmClient) if err != nil { return err } @@ -107,12 +107,12 @@ func setContractsFromConfig(r *runner.E2ERunner, conf config.Config) error { return err } } - if c := conf.Contracts.ZEVM.USDTZRC20Addr; c != "" { + if c := conf.Contracts.ZEVM.ZRC20Addr; c != "" { if !ethcommon.IsHexAddress(c) { - return fmt.Errorf("invalid USDTZRC20Addr: %s", c) + return fmt.Errorf("invalid ZRC20Addr: %s", c) } - r.USDTZRC20Addr = ethcommon.HexToAddress(c) - r.USDTZRC20, err = zrc20.NewZRC20(r.USDTZRC20Addr, r.ZevmClient) + r.ZRC20Addr = ethcommon.HexToAddress(c) + r.ZRC20, err = zrc20.NewZRC20(r.ZRC20Addr, r.ZevmClient) if err != nil { return err } diff --git a/cmd/zetae2e/config/example.yml b/cmd/zetae2e/config/example.yml index 4381834a7f..41316a6074 100644 --- a/cmd/zetae2e/config/example.yml +++ b/cmd/zetae2e/config/example.yml @@ -18,7 +18,7 @@ contracts: zevm: system_contract: "0xEdf1c3275d13489aCdC6cD6eD246E72458B8795B" eth_zrc20: "0x13A0c5930C028511Dc02665E7285134B6d11A5f4" - usdt_zrc20: "0x0cbe0dF132a6c6B4a2974Fa1b7Fb953CF0Cc798a" + zrc20: "0x0cbe0dF132a6c6B4a2974Fa1b7Fb953CF0Cc798a" btc_zrc20: "0x65a45c57636f9BcCeD4fe193A602008578BcA90b" uniswap_factory: "0x9fd96203f7b22bCF72d9DCb40ff98302376cE09c" uniswap_router: "0x2ca7d64A7EFE2D62A725E2B35Cf7230D6677FfEe" @@ -26,5 +26,5 @@ contracts: zeta_eth: "0x0000c304d2934c00db1d51995b9f6996affd17c0" connector_eth: "0x00005e3125aba53c5652f9f0ce1a4cf91d8b15ea" custody: "0x000047f11c6e42293f433c82473532e869ce4ec5" - usdt: "0x07865c6e87b9f70255377e024ace6630c1eaa37f" + erc20: "0x07865c6e87b9f70255377e024ace6630c1eaa37f" diff --git a/cmd/zetae2e/config/local.yml b/cmd/zetae2e/config/local.yml index 5c02747766..70196cc31c 100644 --- a/cmd/zetae2e/config/local.yml +++ b/cmd/zetae2e/config/local.yml @@ -18,7 +18,7 @@ contracts: zevm: system_contract: "0x91d18e54DAf4F677cB28167158d6dd21F6aB3921" eth_zrc20: "0x13A0c5930C028511Dc02665E7285134B6d11A5f4" - usdt_zrc20: "0x48f80608B672DC30DC7e3dbBd0343c5F02C738Eb" + zrc20: "0x48f80608B672DC30DC7e3dbBd0343c5F02C738Eb" btc_zrc20: "0xd97B1de3619ed2c6BEb3860147E30cA8A7dC9891" uniswap_factory: "0x9fd96203f7b22bCF72d9DCb40ff98302376cE09c" uniswap_router: "0x2ca7d64A7EFE2D62A725E2B35Cf7230D6677FfEe" @@ -28,4 +28,4 @@ contracts: zeta_eth: "0x733aB8b06DDDEf27Eaa72294B0d7c9cEF7f12db9" connector_eth: "0xD28D6A0b8189305551a0A8bd247a6ECa9CE781Ca" custody: "0xff3135df4F2775f4091b81f4c7B6359CfA07862a" - usdt: "0xbD1e64A22B9F92D9Ce81aA9B4b0fFacd80215564" \ No newline at end of file + erc20: "0xbD1e64A22B9F92D9Ce81aA9B4b0fFacd80215564" \ No newline at end of file diff --git a/cmd/zetae2e/local/admin.go b/cmd/zetae2e/local/admin.go index 7db44c4453..3ea161687b 100644 --- a/cmd/zetae2e/local/admin.go +++ b/cmd/zetae2e/local/admin.go @@ -48,9 +48,9 @@ func adminTestRoutine( // funding the account txZetaSend := deployerRunner.SendZetaOnEvm(UserAdminAddress, 1000) - txUSDTSend := deployerRunner.SendUSDTOnEvm(UserAdminAddress, 1000) + txERC20Send := deployerRunner.SendERC20OnEvm(UserAdminAddress, 1000) adminRunner.WaitForTxReceiptOnEvm(txZetaSend) - adminRunner.WaitForTxReceiptOnEvm(txUSDTSend) + adminRunner.WaitForTxReceiptOnEvm(txERC20Send) // depositing the necessary tokens on ZetaChain txZetaDeposit := adminRunner.DepositZeta() diff --git a/cmd/zetae2e/local/bitcoin.go b/cmd/zetae2e/local/bitcoin.go index 6da863d26a..9340e18d58 100644 --- a/cmd/zetae2e/local/bitcoin.go +++ b/cmd/zetae2e/local/bitcoin.go @@ -48,8 +48,8 @@ func bitcoinTestRoutine( startTime := time.Now() // funding the account - txUSDTSend := deployerRunner.SendUSDTOnEvm(UserBitcoinAddress, 1000) - bitcoinRunner.WaitForTxReceiptOnEvm(txUSDTSend) + txERC20Send := deployerRunner.SendERC20OnEvm(UserBitcoinAddress, 1000) + bitcoinRunner.WaitForTxReceiptOnEvm(txERC20Send) // depositing the necessary tokens on ZetaChain txEtherDeposit := bitcoinRunner.DepositEther(false) diff --git a/cmd/zetae2e/local/erc20.go b/cmd/zetae2e/local/erc20.go index c8eb63163f..c0e9030583 100644 --- a/cmd/zetae2e/local/erc20.go +++ b/cmd/zetae2e/local/erc20.go @@ -47,8 +47,8 @@ func erc20TestRoutine( startTime := time.Now() // funding the account - txUSDTSend := deployerRunner.SendUSDTOnEvm(UserERC20Address, 10) - erc20Runner.WaitForTxReceiptOnEvm(txUSDTSend) + txERC20Send := deployerRunner.SendERC20OnEvm(UserERC20Address, 10) + erc20Runner.WaitForTxReceiptOnEvm(txERC20Send) // depositing the necessary tokens on ZetaChain txEtherDeposit := erc20Runner.DepositEther(false) diff --git a/cmd/zetae2e/local/local.go b/cmd/zetae2e/local/local.go index 4e4ab4c8f5..37a2235c4e 100644 --- a/cmd/zetae2e/local/local.go +++ b/cmd/zetae2e/local/local.go @@ -205,7 +205,7 @@ func localE2ETest(cmd *cobra.Command, _ []string) { startTime := time.Now() deployerRunner.SetupEVM(contractsDeployed) deployerRunner.SetZEVMContracts() - deployerRunner.MintUSDTOnEvm(10000) + deployerRunner.MintERC20OnEvm(10000) logger.Print("✅ setup completed in %s", time.Since(startTime)) } diff --git a/cmd/zetae2e/stress.go b/cmd/zetae2e/stress.go index 86703ef94b..7af2f5b18b 100644 --- a/cmd/zetae2e/stress.go +++ b/cmd/zetae2e/stress.go @@ -219,13 +219,13 @@ func StressTest(cmd *cobra.Command, _ []string) { fmt.Println(" 2. Display Network metrics to monitor performance [Num Pending outbound tx], [Num Trackers]") e2eTest.WG.Add(2) - go WithdrawCCtx(e2eTest) // Withdraw USDT from ZEVM to EVM - goerli + go WithdrawCCtx(e2eTest) // Withdraw from ZEVM to EVM - goerli go EchoNetworkMetrics(e2eTest) // Display Network metrics periodically to monitor performance e2eTest.WG.Wait() } -// WithdrawCCtx withdraw USDT from ZEVM to EVM +// WithdrawCCtx withdraw ETHZRC20 from ZEVM to EVM func WithdrawCCtx(runner *runner.E2ERunner) { ticker := time.NewTicker(time.Millisecond * time.Duration(stressTestArgs.txnInterval)) for { diff --git a/e2e/README.md b/e2e/README.md index 882f73c100..f7d43ddf08 100644 --- a/e2e/README.md +++ b/e2e/README.md @@ -36,7 +36,7 @@ A config YAML file can be provided to the E2E test tool via the `--config` flag. **EVM Contracts** - `ZetaEthAddress`: Address of Zeta token contract on EVM chain. - `ConnectorEthAddr`: Address of a connector contract on EVM chain. -- `USDT`: Address of the USDT token contract on EVM chain. +- `ERC20`: Address of the ERC20 token contract on EVM chain. ### Config Example @@ -51,7 +51,7 @@ contracts: evm: zeta_eth: "0x..." connector_eth: "0x..." - usdt: "0x..." + erc20: "0x..." zeta_chain_id: "zetachain-1" ``` diff --git a/e2e/config/config.go b/e2e/config/config.go index 5eebd5fc68..af0648a111 100644 --- a/e2e/config/config.go +++ b/e2e/config/config.go @@ -54,14 +54,14 @@ type EVM struct { ZetaEthAddress string `yaml:"zeta_eth"` ConnectorEthAddr string `yaml:"connector_eth"` CustodyAddr string `yaml:"custody"` - USDT string `yaml:"usdt"` + ERC20 string `yaml:"erc20"` } // ZEVM contains the addresses of predeployed contracts on the zEVM chain type ZEVM struct { SystemContractAddr string `yaml:"system_contract"` ETHZRC20Addr string `yaml:"eth_zrc20"` - USDTZRC20Addr string `yaml:"usdt_zrc20"` + ZRC20Addr string `yaml:"zrc20"` BTCZRC20Addr string `yaml:"btc_zrc20"` UniswapFactoryAddr string `yaml:"uniswap_factory"` UniswapRouterAddr string `yaml:"uniswap_router"` @@ -92,7 +92,7 @@ func DefaultConfig() Config { ZetaChainID: "athens_101-1", Contracts: Contracts{ EVM: EVM{ - USDT: "0xff3135df4F2775f4091b81f4c7B6359CfA07862a", + ERC20: "0xff3135df4F2775f4091b81f4c7B6359CfA07862a", }, }, } diff --git a/e2e/e2etests/e2etests.go b/e2e/e2etests/e2etests.go index 37fc744502..2eae2733d6 100644 --- a/e2e/e2etests/e2etests.go +++ b/e2e/e2etests/e2etests.go @@ -67,7 +67,7 @@ var AllE2ETests = []runner.E2ETest{ ), runner.NewE2ETest( TestMultipleERC20DepositName, - "deposit USDT ERC20 into ZEVM in multiple deposits", + "deposit ERC20 into ZEVM in multiple deposits", []runner.ArgDefinition{ runner.ArgDefinition{Description: "amount", DefaultValue: "1000000000"}, runner.ArgDefinition{Description: "count", DefaultValue: "3"}, @@ -125,7 +125,7 @@ var AllE2ETests = []runner.E2ETest{ ), runner.NewE2ETest( TestZRC20SwapName, - "swap ZRC20 USDT for ZRC20 ETH", + "swap ZRC20 token for ZRC20 ETH", []runner.ArgDefinition{}, TestZRC20Swap, ), diff --git a/e2e/e2etests/test_crosschain_swap.go b/e2e/e2etests/test_crosschain_swap.go index 66eedc2d31..dcd16bfc7a 100644 --- a/e2e/e2etests/test_crosschain_swap.go +++ b/e2e/e2etests/test_crosschain_swap.go @@ -19,11 +19,11 @@ func TestCrosschainSwap(r *runner.E2ERunner, _ []string) { // https://github.com/zeta-chain/node-private/issues/88 // it is kept as is for now to be consistent with the old implementation // if the tx fails due to already initialized, it will be ignored - _, err := r.UniswapV2Factory.CreatePair(r.ZevmAuth, r.USDTZRC20Addr, r.BTCZRC20Addr) + _, err := r.UniswapV2Factory.CreatePair(r.ZevmAuth, r.ZRC20Addr, r.BTCZRC20Addr) if err != nil { r.Logger.Print("ℹ️create pair error") } - txUSDTApprove, err := r.USDTZRC20.Approve(r.ZevmAuth, r.UniswapV2RouterAddr, big.NewInt(1e18)) + txApprove, err := r.ZRC20.Approve(r.ZevmAuth, r.UniswapV2RouterAddr, big.NewInt(1e18)) if err != nil { panic(err) } @@ -42,8 +42,8 @@ func TestCrosschainSwap(r *runner.E2ERunner, _ []string) { panic(err) } - if receipt := utils.MustWaitForTxReceipt(r.Ctx, r.ZevmClient, txUSDTApprove, r.Logger, r.ReceiptTimeout); receipt.Status != 1 { - panic("usdt approve failed") + if receipt := utils.MustWaitForTxReceipt(r.Ctx, r.ZevmClient, txApprove, r.Logger, r.ReceiptTimeout); receipt.Status != 1 { + panic("zrc20 approve failed") } if receipt := utils.MustWaitForTxReceipt(r.Ctx, r.ZevmClient, txBTCApprove, r.Logger, r.ReceiptTimeout); receipt.Status != 1 { panic("btc approve failed") @@ -55,10 +55,10 @@ func TestCrosschainSwap(r *runner.E2ERunner, _ []string) { panic("BTC ZRC20 transfer failed") } - // Add 100 USDT liq and 0.001 BTC + // Add 100 zrc20 token liq and 0.001 BTC txAddLiquidity, err := r.UniswapV2Router.AddLiquidity( r.ZevmAuth, - r.USDTZRC20Addr, + r.ZRC20Addr, r.BTCZRC20Addr, big.NewInt(1e8), big.NewInt(1e8), @@ -87,8 +87,8 @@ func TestCrosschainSwap(r *runner.E2ERunner, _ []string) { r.Logger.Info("memobytes(%d) %x", len(memobytes), memobytes) msg = append(msg, memobytes...) - r.Logger.Info("***** First test: USDT -> BTC") - // Should deposit USDT for swap, swap for BTC and withdraw BTC + r.Logger.Info("***** First test: ERC20 -> BTC") + // Should deposit ERC20 for swap, swap for BTC and withdraw BTC txHash := r.DepositERC20WithAmountAndMessage(r.DeployerAddress, big.NewInt(8e7), msg) cctx1 := utils.WaitCctxMinedByInTxHash(r.Ctx, txHash.Hex(), r.CctxClient, r.Logger, r.CctxTimeout) @@ -118,14 +118,14 @@ func TestCrosschainSwap(r *runner.E2ERunner, _ []string) { r.Logger.Info("cctx2 outbound tx hash %s", cctx2.GetCurrentOutTxParam().OutboundTxHash) - r.Logger.Info("******* Second test: BTC -> USDT") + r.Logger.Info("******* Second test: BTC -> ZRC20") utxos, err := r.BtcRPCClient.ListUnspent() if err != nil { panic(err) } r.Logger.Info("#utxos %d", len(utxos)) - r.Logger.Info("memo address %s", r.USDTZRC20Addr) - memo, err := r.ZEVMSwapApp.EncodeMemo(&bind.CallOpts{}, r.USDTZRC20Addr, r.DeployerAddress.Bytes()) + r.Logger.Info("memo address %s", r.ZRC20Addr) + memo, err := r.ZEVMSwapApp.EncodeMemo(&bind.CallOpts{}, r.ZRC20Addr, r.DeployerAddress.Bytes()) if err != nil { panic(err) } diff --git a/e2e/e2etests/test_erc20_multiple_deposits.go b/e2e/e2etests/test_erc20_multiple_deposits.go index 053e3f596a..021b2d7868 100644 --- a/e2e/e2etests/test_erc20_multiple_deposits.go +++ b/e2e/e2etests/test_erc20_multiple_deposits.go @@ -26,7 +26,7 @@ func TestMultipleERC20Deposit(r *runner.E2ERunner, args []string) { panic("Invalid number of deposits specified for TestMultipleERC20Deposit.") } - initialBal, err := r.USDTZRC20.BalanceOf(&bind.CallOpts{}, r.DeployerAddress) + initialBal, err := r.ZRC20.BalanceOf(&bind.CallOpts{}, r.DeployerAddress) if err != nil { panic(err) } @@ -37,7 +37,7 @@ func TestMultipleERC20Deposit(r *runner.E2ERunner, args []string) { } // check new balance is increased by amount * count - bal, err := r.USDTZRC20.BalanceOf(&bind.CallOpts{}, r.DeployerAddress) + bal, err := r.ZRC20.BalanceOf(&bind.CallOpts{}, r.DeployerAddress) if err != nil { panic(err) } @@ -58,7 +58,7 @@ func MultipleDeposits(r *runner.E2ERunner, amount, count *big.Int) ethcommon.Has fullAmount := big.NewInt(0).Mul(amount, count) // approve - tx, err := r.USDTERC20.Approve(r.GoerliAuth, depositorAddr, fullAmount) + tx, err := r.ERC20.Approve(r.GoerliAuth, depositorAddr, fullAmount) if err != nil { panic(err) } @@ -66,10 +66,10 @@ func MultipleDeposits(r *runner.E2ERunner, amount, count *big.Int) ethcommon.Has if receipt.Status == 0 { panic("approve failed") } - r.Logger.Info("USDT Approve receipt tx hash: %s", tx.Hash().Hex()) + r.Logger.Info("ERC20 Approve receipt tx hash: %s", tx.Hash().Hex()) // deposit - tx, err = depositor.RunDeposits(r.GoerliAuth, r.DeployerAddress.Bytes(), r.USDTERC20Addr, amount, []byte{}, count) + tx, err = depositor.RunDeposits(r.GoerliAuth, r.DeployerAddress.Bytes(), r.ERC20Addr, amount, []byte{}, count) if err != nil { panic(err) } diff --git a/e2e/e2etests/test_erc20_multiple_withdraws.go b/e2e/e2etests/test_erc20_multiple_withdraws.go index 0d3a69ef8e..ee0c86f348 100644 --- a/e2e/e2etests/test_erc20_multiple_withdraws.go +++ b/e2e/e2etests/test_erc20_multiple_withdraws.go @@ -39,7 +39,7 @@ func TestMultipleWithdraws(r *runner.E2ERunner, args []string) { } // approve - tx, err := r.USDTZRC20.Approve(r.ZevmAuth, withdrawerAddr, approvedAmount) + tx, err := r.ZRC20.Approve(r.ZevmAuth, withdrawerAddr, approvedAmount) if err != nil { panic(err) } @@ -47,7 +47,7 @@ func TestMultipleWithdraws(r *runner.E2ERunner, args []string) { if receipt.Status == 0 { panic("approve failed") } - r.Logger.Info("USDT ZRC20 approve receipt: status %d", receipt.Status) + r.Logger.Info("ZRC20 approve receipt: status %d", receipt.Status) // approve gas token tx, err = r.ETHZRC20.Approve(r.ZevmAuth, withdrawerAddr, approvedAmount) @@ -61,21 +61,21 @@ func TestMultipleWithdraws(r *runner.E2ERunner, args []string) { r.Logger.Info("eth zrc20 approve receipt: status %d", receipt.Status) // check the balance - bal, err := r.USDTZRC20.BalanceOf(&bind.CallOpts{}, r.DeployerAddress) + bal, err := r.ZRC20.BalanceOf(&bind.CallOpts{}, r.DeployerAddress) if err != nil { panic(err) } - r.Logger.Info("balance of deployer on USDT ZRC20: %d", bal) + r.Logger.Info("balance of deployer on ZRC20: %d", bal) if bal.Int64() < totalWithdrawal.Int64() { - panic("not enough USDT ZRC20 balance!") + panic("not enough ZRC20 balance!") } // withdraw tx, err = withdrawer.RunWithdraws( r.ZevmAuth, r.DeployerAddress.Bytes(), - r.USDTZRC20Addr, + r.ZRC20Addr, withdrawalAmount, numberOfWithdrawals, ) diff --git a/e2e/e2etests/test_erc20_refund.go b/e2e/e2etests/test_erc20_refund.go index 9a725d5997..c5d5961365 100644 --- a/e2e/e2etests/test_erc20_refund.go +++ b/e2e/e2etests/test_erc20_refund.go @@ -15,7 +15,7 @@ import ( func TestERC20DepositAndCallRefund(r *runner.E2ERunner, _ []string) { // Get the initial balance of the deployer - initialBal, err := r.USDTZRC20.BalanceOf(&bind.CallOpts{}, r.DeployerAddress) + initialBal, err := r.ZRC20.BalanceOf(&bind.CallOpts{}, r.DeployerAddress) if err != nil { panic(err) } @@ -25,7 +25,7 @@ func TestERC20DepositAndCallRefund(r *runner.E2ERunner, _ []string) { amount := big.NewInt(1e4) // send the deposit - inTxHash, err := sendInvalidUSDTDeposit(r, amount) + inTxHash, err := sendInvalidERC20Deposit(r, amount) if err != nil { panic(err) } @@ -52,7 +52,7 @@ func TestERC20DepositAndCallRefund(r *runner.E2ERunner, _ []string) { } // Check that the erc20 in the aborted cctx was refunded on ZetaChain - newBalance, err := r.USDTZRC20.BalanceOf(&bind.CallOpts{}, r.DeployerAddress) + newBalance, err := r.ZRC20.BalanceOf(&bind.CallOpts{}, r.DeployerAddress) if err != nil { panic(err) } @@ -72,14 +72,14 @@ func TestERC20DepositAndCallRefund(r *runner.E2ERunner, _ []string) { } r.Logger.Info("Liquidity pool created") - goerliBalance, err := r.USDTERC20.BalanceOf(&bind.CallOpts{}, r.DeployerAddress) + goerliBalance, err := r.ERC20.BalanceOf(&bind.CallOpts{}, r.DeployerAddress) if err != nil { panic(err) } // send the deposit amount = big.NewInt(1e7) - inTxHash, err = sendInvalidUSDTDeposit(r, amount) + inTxHash, err = sendInvalidERC20Deposit(r, amount) if err != nil { panic(err) } @@ -108,7 +108,7 @@ func TestERC20DepositAndCallRefund(r *runner.E2ERunner, _ []string) { } // check that the erc20 in the reverted cctx was refunded on Goerli - goerliBalanceAfterRefund, err := r.USDTERC20.BalanceOf(&bind.CallOpts{}, r.DeployerAddress) + goerliBalanceAfterRefund, err := r.ERC20.BalanceOf(&bind.CallOpts{}, r.DeployerAddress) if err != nil { panic(err) } @@ -140,7 +140,7 @@ func createZetaERC20LiquidityPool(r *runner.E2ERunner) error { txHash := r.DepositERC20WithAmountAndMessage(r.DeployerAddress, amount, []byte{}) utils.WaitCctxMinedByInTxHash(r.Ctx, txHash.Hex(), r.CctxClient, r.Logger, r.CctxTimeout) - tx, err := r.USDTZRC20.Approve(r.ZevmAuth, r.UniswapV2RouterAddr, big.NewInt(1e10)) + tx, err := r.ZRC20.Approve(r.ZevmAuth, r.UniswapV2RouterAddr, big.NewInt(1e10)) if err != nil { return err } @@ -153,7 +153,7 @@ func createZetaERC20LiquidityPool(r *runner.E2ERunner) error { r.ZevmAuth.Value = big.NewInt(1e10) tx, err = r.UniswapV2Router.AddLiquidityETH( r.ZevmAuth, - r.USDTZRC20Addr, + r.ZRC20Addr, amount, big.NewInt(0), big.NewInt(0), @@ -172,19 +172,18 @@ func createZetaERC20LiquidityPool(r *runner.E2ERunner) error { return nil } -func sendInvalidUSDTDeposit(r *runner.E2ERunner, amount *big.Int) (string, error) { - USDT := r.USDTERC20 - tx, err := USDT.Approve(r.GoerliAuth, r.ERC20CustodyAddr, amount) +func sendInvalidERC20Deposit(r *runner.E2ERunner, amount *big.Int) (string, error) { + tx, err := r.ERC20.Approve(r.GoerliAuth, r.ERC20CustodyAddr, amount) if err != nil { return "", err } receipt := utils.MustWaitForTxReceipt(r.Ctx, r.GoerliClient, tx, r.Logger, r.ReceiptTimeout) - r.Logger.Info("USDT Approve receipt tx hash: %s", tx.Hash().Hex()) + r.Logger.Info("ERC20 Approve receipt tx hash: %s", tx.Hash().Hex()) tx, err = r.ERC20Custody.Deposit( r.GoerliAuth, r.DeployerAddress.Bytes(), - r.USDTERC20Addr, + r.ERC20Addr, amount, []byte("this is an invalid msg that will cause the contract to revert"), ) diff --git a/e2e/e2etests/test_erc20_withdraw.go b/e2e/e2etests/test_erc20_withdraw.go index 5817a269bf..cd9b258ce5 100644 --- a/e2e/e2etests/test_erc20_withdraw.go +++ b/e2e/e2etests/test_erc20_withdraw.go @@ -25,7 +25,7 @@ func TestERC20Withdraw(r *runner.E2ERunner, args []string) { } // approve - tx, err := r.ETHZRC20.Approve(r.ZevmAuth, r.USDTZRC20Addr, approvedAmount) + tx, err := r.ETHZRC20.Approve(r.ZevmAuth, r.ZRC20Addr, approvedAmount) if err != nil { panic(err) } @@ -36,14 +36,14 @@ func TestERC20Withdraw(r *runner.E2ERunner, args []string) { r.Logger.Info("eth zrc20 approve receipt: status %d", receipt.Status) // withdraw - tx, err = r.USDTZRC20.Withdraw(r.ZevmAuth, r.DeployerAddress.Bytes(), withdrawalAmount) + tx, err = r.ZRC20.Withdraw(r.ZevmAuth, r.DeployerAddress.Bytes(), withdrawalAmount) if err != nil { panic(err) } receipt = utils.MustWaitForTxReceipt(r.Ctx, r.ZevmClient, tx, r.Logger, r.ReceiptTimeout) r.Logger.Info("Receipt txhash %s status %d", receipt.TxHash, receipt.Status) for _, log := range receipt.Logs { - event, err := r.USDTZRC20.ParseWithdrawal(*log) + event, err := r.ZRC20.ParseWithdrawal(*log) if err != nil { continue } @@ -74,7 +74,7 @@ func verifyTransferAmountFromCCTX(r *runner.E2ERunner, cctx *crosschaintypes.Cro } r.Logger.Info("Receipt txhash %s status %d", receipt.TxHash, receipt.Status) for _, log := range receipt.Logs { - event, err := r.USDTERC20.ParseTransfer(*log) + event, err := r.ERC20.ParseTransfer(*log) if err != nil { continue } diff --git a/e2e/e2etests/test_pause_zrc20.go b/e2e/e2etests/test_pause_zrc20.go index e357e622e5..54925037b2 100644 --- a/e2e/e2etests/test_pause_zrc20.go +++ b/e2e/e2etests/test_pause_zrc20.go @@ -28,7 +28,7 @@ func TestPauseZRC20(r *runner.E2ERunner, _ []string) { if receipt.Status == 0 { panic("Vault approval should succeed") } - tx, err = r.USDTZRC20.Approve(r.ZevmAuth, vaultAddr, big.NewInt(1e18)) + tx, err = r.ZRC20.Approve(r.ZevmAuth, vaultAddr, big.NewInt(1e18)) if err != nil { panic(err) } @@ -93,23 +93,23 @@ func TestPauseZRC20(r *runner.E2ERunner, _ []string) { } r.Logger.Info("Operations all failed") - // Check we can still interact with USDT ZRC20 + // Check we can still interact with ZRC20 r.Logger.Info("Check other ZRC20 can still be operated") - tx, err = r.USDTZRC20.Transfer(r.ZevmAuth, sample.EthAddress(), big.NewInt(1e3)) + tx, err = r.ZRC20.Transfer(r.ZevmAuth, sample.EthAddress(), big.NewInt(1e3)) if err != nil { panic(err) } receipt = utils.MustWaitForTxReceipt(r.Ctx, r.ZevmClient, tx, r.Logger, r.ReceiptTimeout) if receipt.Status == 0 { - panic("USDT transfer should succeed") + panic("ZERC20 transfer should succeed") } - tx, err = vaultContract.Deposit(r.ZevmAuth, r.USDTZRC20Addr, big.NewInt(1e3)) + tx, err = vaultContract.Deposit(r.ZevmAuth, r.ZRC20Addr, big.NewInt(1e3)) if err != nil { panic(err) } receipt = utils.MustWaitForTxReceipt(r.Ctx, r.ZevmClient, tx, r.Logger, r.ReceiptTimeout) if receipt.Status == 0 { - panic("USDT vault deposit should succeed") + panic("ZRC20 vault deposit should succeed") } // Check deposit revert when paused diff --git a/e2e/e2etests/test_zrc20_swap.go b/e2e/e2etests/test_zrc20_swap.go index 9e02b650e7..b74feb3a6e 100644 --- a/e2e/e2etests/test_zrc20_swap.go +++ b/e2e/e2etests/test_zrc20_swap.go @@ -15,25 +15,25 @@ func TestZRC20Swap(r *runner.E2ERunner, _ []string) { // https://github.com/zeta-chain/node-private/issues/88 // it is kept as is for now to be consistent with the old implementation // if the tx fails due to already initialized, it will be ignored - tx, err := r.UniswapV2Factory.CreatePair(r.ZevmAuth, r.USDTZRC20Addr, r.ETHZRC20Addr) + tx, err := r.UniswapV2Factory.CreatePair(r.ZevmAuth, r.ZRC20Addr, r.ETHZRC20Addr) if err != nil { r.Logger.Print("ℹ️create pair error") } else { utils.MustWaitForTxReceipt(r.Ctx, r.ZevmClient, tx, r.Logger, r.ReceiptTimeout) } - usdtEthPair, err := r.UniswapV2Factory.GetPair(&bind.CallOpts{}, r.USDTZRC20Addr, r.ETHZRC20Addr) + zrc20EthPair, err := r.UniswapV2Factory.GetPair(&bind.CallOpts{}, r.ZRC20Addr, r.ETHZRC20Addr) if err != nil { panic(err) } - r.Logger.Info("USDT-ETH pair receipt pair addr %s", usdtEthPair.Hex()) + r.Logger.Info("ZRC20-ETH pair receipt pair addr %s", zrc20EthPair.Hex()) - tx, err = r.USDTZRC20.Approve(r.ZevmAuth, r.UniswapV2RouterAddr, big.NewInt(1e18)) + tx, err = r.ZRC20.Approve(r.ZevmAuth, r.UniswapV2RouterAddr, big.NewInt(1e18)) if err != nil { panic(err) } receipt := utils.MustWaitForTxReceipt(r.Ctx, r.ZevmClient, tx, r.Logger, r.ReceiptTimeout) - r.Logger.Info("USDT ZRC20 approval receipt txhash %s status %d", receipt.TxHash, receipt.Status) + r.Logger.Info("ZRC20 approval receipt txhash %s status %d", receipt.TxHash, receipt.Status) tx, err = r.ETHZRC20.Approve(r.ZevmAuth, r.UniswapV2RouterAddr, big.NewInt(1e18)) if err != nil { @@ -51,7 +51,7 @@ func TestZRC20Swap(r *runner.E2ERunner, _ []string) { r.ZevmAuth.GasLimit = 400000 tx, err = r.UniswapV2Router.AddLiquidity( r.ZevmAuth, - r.USDTZRC20Addr, + r.ZRC20Addr, r.ETHZRC20Addr, big.NewInt(90000), big.NewInt(1000), @@ -75,7 +75,7 @@ func TestZRC20Swap(r *runner.E2ERunner, _ []string) { r.ZevmAuth, big.NewInt(1000), ethOutAmout, - []ethcommon.Address{r.USDTZRC20Addr, r.ETHZRC20Addr}, + []ethcommon.Address{r.ZRC20Addr, r.ETHZRC20Addr}, r.DeployerAddress, big.NewInt(time.Now().Add(10*time.Minute).Unix()), ) @@ -83,7 +83,7 @@ func TestZRC20Swap(r *runner.E2ERunner, _ []string) { panic(err) } receipt = utils.MustWaitForTxReceipt(r.Ctx, r.ZevmClient, tx, r.Logger, r.ReceiptTimeout) - r.Logger.Info("Swap USDT for ETH ZRC20 %s status %d", receipt.TxHash, receipt.Status) + r.Logger.Info("Swap ZRC20 token for ETH ZRC20 %s status %d", receipt.TxHash, receipt.Status) balETHAfter, err := r.ETHZRC20.BalanceOf(&bind.CallOpts{}, r.DeployerAddress) if err != nil { diff --git a/e2e/runner/accounting.go b/e2e/runner/accounting.go index 495a881bc6..21dc436b28 100644 --- a/e2e/runner/accounting.go +++ b/e2e/runner/accounting.go @@ -24,7 +24,7 @@ func (runner *E2ERunner) CheckZRC20ReserveAndSupply() error { if err := runner.checkEthTSSBalance(); err != nil { return err } - if err := runner.checkUsdtTSSBalance(); err != nil { + if err := runner.checkZRC20TSSBalance(); err != nil { return err } return runner.checkZetaTSSBalance() @@ -80,19 +80,19 @@ func (runner *E2ERunner) CheckBtcTSSBalance() error { return nil } -func (runner *E2ERunner) checkUsdtTSSBalance() error { - usdtBal, err := runner.USDTERC20.BalanceOf(&bind.CallOpts{}, runner.ERC20CustodyAddr) +func (runner *E2ERunner) checkZRC20TSSBalance() error { + erc20Balance, err := runner.ERC20.BalanceOf(&bind.CallOpts{}, runner.ERC20CustodyAddr) if err != nil { return err } - zrc20Supply, err := runner.USDTZRC20.TotalSupply(&bind.CallOpts{}) + zrc20Supply, err := runner.ZRC20.TotalSupply(&bind.CallOpts{}) if err != nil { return err } - if usdtBal.Cmp(zrc20Supply) < 0 { - return fmt.Errorf("USDT: TSS balance (%d) < ZRC20 TotalSupply (%d) ", usdtBal, zrc20Supply) + if erc20Balance.Cmp(zrc20Supply) < 0 { + return fmt.Errorf("ERC20: TSS balance (%d) < ZRC20 TotalSupply (%d) ", erc20Balance, zrc20Supply) } - runner.Logger.Info("USDT: TSS balance (%d) >= ZRC20 TotalSupply (%d)", usdtBal, zrc20Supply) + runner.Logger.Info("ERC20: TSS balance (%d) >= ZRC20 TotalSupply (%d)", erc20Balance, zrc20Supply) return nil } diff --git a/e2e/runner/balances.go b/e2e/runner/balances.go index 3147a60eda..ab9ca4515d 100644 --- a/e2e/runner/balances.go +++ b/e2e/runner/balances.go @@ -44,7 +44,7 @@ func (runner *E2ERunner) GetAccountBalances(skipBTC bool) (AccountBalances, erro if err != nil { return AccountBalances{}, err } - zetaErc20, err := runner.USDTZRC20.BalanceOf(&bind.CallOpts{}, runner.DeployerAddress) + zetaErc20, err := runner.ZRC20.BalanceOf(&bind.CallOpts{}, runner.DeployerAddress) if err != nil { return AccountBalances{}, err } @@ -62,7 +62,7 @@ func (runner *E2ERunner) GetAccountBalances(skipBTC bool) (AccountBalances, erro if err != nil { return AccountBalances{}, err } - evmErc20, err := runner.USDTERC20.BalanceOf(&bind.CallOpts{}, runner.DeployerAddress) + evmErc20, err := runner.ERC20.BalanceOf(&bind.CallOpts{}, runner.DeployerAddress) if err != nil { return AccountBalances{}, err } @@ -117,7 +117,6 @@ func (runner *E2ERunner) GetBitcoinBalance() (string, error) { } // PrintAccountBalances shows the account balances of the accounts used in the E2E test -// Note: USDT is mentioned as erc20 here because we want to show the balance of any erc20 contract func (runner *E2ERunner) PrintAccountBalances(balances AccountBalances) { runner.Logger.Print(" ---💰 Account info %s ---", runner.DeployerAddress.Hex()) diff --git a/e2e/runner/evm.go b/e2e/runner/evm.go index 47035e61f3..8dbc61062a 100644 --- a/e2e/runner/evm.go +++ b/e2e/runner/evm.go @@ -28,17 +28,17 @@ func (runner *E2ERunner) WaitForTxReceiptOnEvm(tx *ethtypes.Transaction) { } } -// MintUSDTOnEvm mints USDT on EVM -// amountUSDT is a multiple of 1e18 -func (runner *E2ERunner) MintUSDTOnEvm(amountUSDT int64) { +// MintERC20OnEvm mints ERC20 on EVM +// amount is a multiple of 1e18 +func (runner *E2ERunner) MintERC20OnEvm(amountERC20 int64) { defer func() { runner.Unlock() }() runner.Lock() - amount := big.NewInt(0).Mul(big.NewInt(1e18), big.NewInt(amountUSDT)) + amount := big.NewInt(0).Mul(big.NewInt(1e18), big.NewInt(amountERC20)) - tx, err := runner.USDTERC20.Mint(runner.GoerliAuth, amount) + tx, err := runner.ERC20.Mint(runner.GoerliAuth, amount) if err != nil { panic(err) } @@ -49,20 +49,20 @@ func (runner *E2ERunner) MintUSDTOnEvm(amountUSDT int64) { runner.Logger.Info("Mint receipt tx hash: %s", tx.Hash().Hex()) } -// SendUSDTOnEvm sends USDT to an address on EVM -// this allows the USDT contract deployer to funds other accounts on EVM -// amountUSDT is a multiple of 1e18 -func (runner *E2ERunner) SendUSDTOnEvm(address ethcommon.Address, amountUSDT int64) *ethtypes.Transaction { - // the deployer might be sending USDT in different goroutines +// SendERC20OnEvm sends ERC20 to an address on EVM +// this allows the ERC20 contract deployer to funds other accounts on EVM +// amountERC20 is a multiple of 1e18 +func (runner *E2ERunner) SendERC20OnEvm(address ethcommon.Address, amountERC20 int64) *ethtypes.Transaction { + // the deployer might be sending ERC20 in different goroutines defer func() { runner.Unlock() }() runner.Lock() - amount := big.NewInt(0).Mul(big.NewInt(1e18), big.NewInt(amountUSDT)) + amount := big.NewInt(0).Mul(big.NewInt(1e18), big.NewInt(amountERC20)) // transfer - tx, err := runner.USDTERC20.Transfer(runner.GoerliAuth, address, amount) + tx, err := runner.ERC20.Transfer(runner.GoerliAuth, address, amount) if err != nil { panic(err) } @@ -76,8 +76,8 @@ func (runner *E2ERunner) DepositERC20() ethcommon.Hash { } func (runner *E2ERunner) DepositERC20WithAmountAndMessage(to ethcommon.Address, amount *big.Int, msg []byte) ethcommon.Hash { - // reset allowance, necessary for USDT - tx, err := runner.USDTERC20.Approve(runner.GoerliAuth, runner.ERC20CustodyAddr, big.NewInt(0)) + // reset allowance, necessary for ERC20 + tx, err := runner.ERC20.Approve(runner.GoerliAuth, runner.ERC20CustodyAddr, big.NewInt(0)) if err != nil { panic(err) } @@ -85,9 +85,9 @@ func (runner *E2ERunner) DepositERC20WithAmountAndMessage(to ethcommon.Address, if receipt.Status == 0 { panic("approve failed") } - runner.Logger.Info("USDT Approve receipt tx hash: %s", tx.Hash().Hex()) + runner.Logger.Info("ERC20 Approve receipt tx hash: %s", tx.Hash().Hex()) - tx, err = runner.USDTERC20.Approve(runner.GoerliAuth, runner.ERC20CustodyAddr, amount) + tx, err = runner.ERC20.Approve(runner.GoerliAuth, runner.ERC20CustodyAddr, amount) if err != nil { panic(err) } @@ -95,9 +95,9 @@ func (runner *E2ERunner) DepositERC20WithAmountAndMessage(to ethcommon.Address, if receipt.Status == 0 { panic("approve failed") } - runner.Logger.Info("USDT Approve receipt tx hash: %s", tx.Hash().Hex()) + runner.Logger.Info("ERC20 Approve receipt tx hash: %s", tx.Hash().Hex()) - tx, err = runner.ERC20Custody.Deposit(runner.GoerliAuth, to.Bytes(), runner.USDTERC20Addr, amount, msg) + tx, err = runner.ERC20Custody.Deposit(runner.GoerliAuth, to.Bytes(), runner.ERC20Addr, amount, msg) runner.Logger.Print("TX: %v", tx) if err != nil { panic(err) diff --git a/e2e/runner/runner.go b/e2e/runner/runner.go index 13536430df..52dd6c509a 100644 --- a/e2e/runner/runner.go +++ b/e2e/runner/runner.go @@ -72,10 +72,10 @@ type E2ERunner struct { ConnectorEth *zetaconnectoreth.ZetaConnectorEth ERC20CustodyAddr ethcommon.Address ERC20Custody *erc20custody.ERC20Custody - USDTERC20Addr ethcommon.Address - USDTERC20 *erc20.ERC20 - USDTZRC20Addr ethcommon.Address - USDTZRC20 *zrc20.ZRC20 + ERC20Addr ethcommon.Address + ERC20 *erc20.ERC20 + ZRC20Addr ethcommon.Address + ZRC20 *zrc20.ZRC20 ETHZRC20Addr ethcommon.Address ETHZRC20 *zrc20.ZRC20 BTCZRC20Addr ethcommon.Address @@ -358,8 +358,8 @@ func (runner *E2ERunner) CopyAddressesFrom(other *E2ERunner) (err error) { runner.ZetaEthAddr = other.ZetaEthAddr runner.ConnectorEthAddr = other.ConnectorEthAddr runner.ERC20CustodyAddr = other.ERC20CustodyAddr - runner.USDTERC20Addr = other.USDTERC20Addr - runner.USDTZRC20Addr = other.USDTZRC20Addr + runner.ERC20Addr = other.ERC20Addr + runner.ZRC20Addr = other.ZRC20Addr runner.ETHZRC20Addr = other.ETHZRC20Addr runner.BTCZRC20Addr = other.BTCZRC20Addr runner.UniswapV2FactoryAddr = other.UniswapV2FactoryAddr @@ -384,11 +384,11 @@ func (runner *E2ERunner) CopyAddressesFrom(other *E2ERunner) (err error) { if err != nil { return err } - runner.USDTERC20, err = erc20.NewERC20(runner.USDTERC20Addr, runner.GoerliClient) + runner.ERC20, err = erc20.NewERC20(runner.ERC20Addr, runner.GoerliClient) if err != nil { return err } - runner.USDTZRC20, err = zrc20.NewZRC20(runner.USDTZRC20Addr, runner.ZevmClient) + runner.ZRC20, err = zrc20.NewZRC20(runner.ZRC20Addr, runner.ZevmClient) if err != nil { return err } @@ -450,7 +450,7 @@ func (runner *E2ERunner) PrintContractAddresses() { runner.Logger.Print(" --- 📜zEVM contracts ---") runner.Logger.Print("SystemContract: %s", runner.SystemContractAddr.Hex()) runner.Logger.Print("ETHZRC20: %s", runner.ETHZRC20Addr.Hex()) - runner.Logger.Print("USDTZRC20: %s", runner.USDTZRC20Addr.Hex()) + runner.Logger.Print("ZRC20: %s", runner.ZRC20Addr.Hex()) runner.Logger.Print("BTCZRC20: %s", runner.BTCZRC20Addr.Hex()) runner.Logger.Print("UniswapFactory: %s", runner.UniswapV2FactoryAddr.Hex()) runner.Logger.Print("UniswapRouter: %s", runner.UniswapV2RouterAddr.Hex()) @@ -466,5 +466,5 @@ func (runner *E2ERunner) PrintContractAddresses() { runner.Logger.Print("ZetaEth: %s", runner.ZetaEthAddr.Hex()) runner.Logger.Print("ConnectorEth: %s", runner.ConnectorEthAddr.Hex()) runner.Logger.Print("ERC20Custody: %s", runner.ERC20CustodyAddr.Hex()) - runner.Logger.Print("USDTERC20: %s", runner.USDTERC20Addr.Hex()) + runner.Logger.Print("ERC20: %s", runner.ERC20Addr.Hex()) } diff --git a/e2e/runner/setup_evm.go b/e2e/runner/setup_evm.go index 0911b83f9b..f5105a8972 100644 --- a/e2e/runner/setup_evm.go +++ b/e2e/runner/setup_evm.go @@ -58,7 +58,7 @@ func (runner *E2ERunner) SetupEVM(contractsDeployed bool) { } conf := config.DefaultConfig() - runner.Logger.InfoLoud("Deploy ZetaETH ConnectorETH ERC20Custody USDT\n") + runner.Logger.InfoLoud("Deploy ZetaETH ConnectorETH ERC20Custody ERC20\n") // donate to the TSS address to avoid account errors because deploying gas token ZRC20 will automatically mint // gas token on ZetaChain to initialize the pool @@ -117,14 +117,14 @@ func (runner *E2ERunner) SetupEVM(contractsDeployed bool) { runner.ERC20Custody = ERC20Custody runner.Logger.Info("ERC20Custody contract address: %s, tx hash: %s", erc20CustodyAddr.Hex(), txCustody.Hash().Hex()) - runner.Logger.Info("Deploying USDT contract") - usdtAddr, txUSDT, usdt, err := erc20.DeployERC20(runner.GoerliAuth, runner.GoerliClient, "USDT", "USDT", 6) + runner.Logger.Info("Deploying ERC20 contract") + erc20Addr, txERC20, erc20, err := erc20.DeployERC20(runner.GoerliAuth, runner.GoerliClient, "TESTERC20", "TESTERC20", 6) if err != nil { panic(err) } - runner.USDTERC20 = usdt - runner.USDTERC20Addr = usdtAddr - runner.Logger.Info("USDT contract address: %s, tx hash: %s", usdtAddr.Hex(), txUSDT.Hash().Hex()) + runner.ERC20 = erc20 + runner.ERC20Addr = erc20Addr + runner.Logger.Info("ERC20 contract address: %s, tx hash: %s", erc20Addr.Hex(), txERC20.Hash().Hex()) // deploy TestDApp contract appAddr, txApp, _, err := testdapp.DeployTestDApp(runner.GoerliAuth, runner.GoerliClient, runner.ConnectorEthAddr, runner.ZetaEthAddr) @@ -147,8 +147,8 @@ func (runner *E2ERunner) SetupEVM(contractsDeployed bool) { if receipt := utils.MustWaitForTxReceipt(runner.Ctx, runner.GoerliClient, txCustody, runner.Logger, runner.ReceiptTimeout); receipt.Status != 1 { panic("ERC20Custody deployment failed") } - if receipt := utils.MustWaitForTxReceipt(runner.Ctx, runner.GoerliClient, txUSDT, runner.Logger, runner.ReceiptTimeout); receipt.Status != 1 { - panic("USDT deployment failed") + if receipt := utils.MustWaitForTxReceipt(runner.Ctx, runner.GoerliClient, txERC20, runner.Logger, runner.ReceiptTimeout); receipt.Status != 1 { + panic("ERC20 deployment failed") } receipt := utils.MustWaitForTxReceipt(runner.Ctx, runner.GoerliClient, txApp, runner.Logger, runner.ReceiptTimeout) if receipt.Status != 1 { @@ -156,13 +156,13 @@ func (runner *E2ERunner) SetupEVM(contractsDeployed bool) { } // initialize custody contract - runner.Logger.Info("Whitelist USDT") - txWhitelist, err := ERC20Custody.Whitelist(runner.GoerliAuth, usdtAddr) + runner.Logger.Info("Whitelist ERC20") + txWhitelist, err := ERC20Custody.Whitelist(runner.GoerliAuth, erc20Addr) if err != nil { panic(err) } if receipt := utils.MustWaitForTxReceipt(runner.Ctx, runner.GoerliClient, txWhitelist, runner.Logger, runner.ReceiptTimeout); receipt.Status != 1 { - panic("USDT whitelist failed") + panic("ERC20 whitelist failed") } runner.Logger.Info("Set TSS address") @@ -171,7 +171,7 @@ func (runner *E2ERunner) SetupEVM(contractsDeployed bool) { panic(err) } if receipt := utils.MustWaitForTxReceipt(runner.Ctx, runner.GoerliClient, txCustody, runner.Logger, runner.ReceiptTimeout); receipt.Status != 1 { - panic("USDT update TSS address failed") + panic("ERC20 update TSS address failed") } runner.Logger.Info("TSS set receipt tx hash: %s", txCustody.Hash().Hex()) diff --git a/e2e/runner/setup_zeta.go b/e2e/runner/setup_zeta.go index 6cfc6890a0..08315217f2 100644 --- a/e2e/runner/setup_zeta.go +++ b/e2e/runner/setup_zeta.go @@ -70,17 +70,17 @@ func (runner *E2ERunner) SetZEVMContracts() { }() // deploy system contracts and ZRC20 contracts on ZetaChain - uniswapV2FactoryAddr, uniswapV2RouterAddr, zevmConnectorAddr, wzetaAddr, usdtZRC20Addr, err := runner.ZetaTxServer.DeploySystemContractsAndZRC20( + uniswapV2FactoryAddr, uniswapV2RouterAddr, zevmConnectorAddr, wzetaAddr, zrc20Addr, err := runner.ZetaTxServer.DeploySystemContractsAndZRC20( utils2.FungibleAdminName, - runner.USDTERC20Addr.Hex(), + runner.ERC20Addr.Hex(), ) if err != nil { panic(err) } - // Set USDTZRC20Addr - runner.USDTZRC20Addr = ethcommon.HexToAddress(usdtZRC20Addr) - runner.USDTZRC20, err = zrc20.NewZRC20(runner.USDTZRC20Addr, runner.ZevmClient) + // Set ZRC20Addr + runner.ZRC20Addr = ethcommon.HexToAddress(zrc20Addr) + runner.ZRC20, err = zrc20.NewZRC20(runner.ZRC20Addr, runner.ZevmClient) if err != nil { panic(err) } diff --git a/e2e/txserver/zeta_tx_server.go b/e2e/txserver/zeta_tx_server.go index 5ab36c514a..022ba5cc61 100644 --- a/e2e/txserver/zeta_tx_server.go +++ b/e2e/txserver/zeta_tx_server.go @@ -172,8 +172,8 @@ func (zts ZetaTxServer) BroadcastTx(account string, msg sdktypes.Msg) (*sdktypes } // DeploySystemContractsAndZRC20 deploys the system contracts and ZRC20 contracts -// returns the addresses of uniswap factory, router and usdt zrc20 -func (zts ZetaTxServer) DeploySystemContractsAndZRC20(account, usdtERC20Addr string) (string, string, string, string, string, error) { +// returns the addresses of uniswap factory, router and zrc20 token +func (zts ZetaTxServer) DeploySystemContractsAndZRC20(account, erc20Addr string) (string, string, string, string, string, error) { // retrieve account acc, err := zts.clientCtx.Keyring.Key(account) if err != nil { @@ -253,30 +253,30 @@ func (zts ZetaTxServer) DeploySystemContractsAndZRC20(account, usdtERC20Addr str return "", "", "", "", "", fmt.Errorf("failed to deploy btc zrc20: %s", err.Error()) } - // deploy usdt zrc20 + // deploy zrc20 token res, err = zts.BroadcastTx(account, fungibletypes.NewMsgDeployFungibleCoinZRC20( addr.String(), - usdtERC20Addr, + erc20Addr, common.GoerliLocalnetChain().ChainId, 6, - "USDT", - "USDT", + "TestToken", + "TEST", common.CoinType_ERC20, 100000, )) if err != nil { - return "", "", "", "", "", fmt.Errorf("failed to deploy usdt zrc20: %s", err.Error()) + return "", "", "", "", "", fmt.Errorf("failed to deploy test token zrc20: %s", err.Error()) } - // fetch the usdt zrc20 contract address and remove the quotes - usdtZRC20Addr, err := fetchAttribute(res, "Contract") + // fetch the zrc20 contract address and remove the quotes + zrc20Addr, err := fetchAttribute(res, "Contract") if err != nil { - return "", "", "", "", "", fmt.Errorf("failed to fetch usdt zrc20 contract address: %s", err.Error()) + return "", "", "", "", "", fmt.Errorf("failed to fetch zrc20 contract address: %s", err.Error()) } - if !ethcommon.IsHexAddress(usdtZRC20Addr) { - return "", "", "", "", "", fmt.Errorf("invalid address in event: %s", usdtZRC20Addr) + if !ethcommon.IsHexAddress(zrc20Addr) { + return "", "", "", "", "", fmt.Errorf("invalid address in event: %s", zrc20Addr) } - return uniswapV2FactoryAddr, uniswapV2RouterAddr, zevmConnectorAddr, wzetaAddr, usdtZRC20Addr, nil + return uniswapV2FactoryAddr, uniswapV2RouterAddr, zevmConnectorAddr, wzetaAddr, zrc20Addr, nil } // newCodec returns the codec for msg server