From ff317c52b1fbf538d04f38c81d79e1b5864d5bfb Mon Sep 17 00:00:00 2001 From: Andres Aiello Date: Mon, 5 Feb 2024 12:19:18 -0300 Subject: [PATCH] feat: update zetachain multichainvalue --- .../multi-chain-value/MultiChainValue.sol | 10 ++- .../zeta-app-contracts/data/addresses.json | 19 +++-- .../scripts/multi-chain-value/find-errors.ts | 75 +++++++++++++++++++ 3 files changed, 94 insertions(+), 10 deletions(-) create mode 100644 packages/zeta-app-contracts/scripts/multi-chain-value/find-errors.ts diff --git a/packages/zeta-app-contracts/contracts/multi-chain-value/MultiChainValue.sol b/packages/zeta-app-contracts/contracts/multi-chain-value/MultiChainValue.sol index d2f319f7..6387dd8a 100644 --- a/packages/zeta-app-contracts/contracts/multi-chain-value/MultiChainValue.sol +++ b/packages/zeta-app-contracts/contracts/multi-chain-value/MultiChainValue.sol @@ -94,7 +94,7 @@ contract MultiChainValue is ZetaInteractor, MultiChainValueErrors { destinationChainId: destinationChainId, destinationAddress: destinationAddress, destinationGasLimit: 300000, - message: abi.encode(msg.sender), + message: abi.encode(), zetaValueAndGas: zetaValueAndGas, zetaParams: abi.encode("") }) @@ -102,10 +102,12 @@ contract MultiChainValue is ZetaInteractor, MultiChainValueErrors { } function onZetaRevert(ZetaInterfaces.ZetaRevert calldata zetaRevert) external isValidRevertCall(zetaRevert) { - address messageFrom = abi.decode(zetaRevert.message, (address)); - bool success1 = ZetaEth(zetaToken).approve(address(this), zetaRevert.remainingZetaValue); - bool success2 = ZetaEth(zetaToken).transferFrom(address(this), messageFrom, zetaRevert.remainingZetaValue); + bool success2 = ZetaEth(zetaToken).transferFrom( + address(this), + zetaRevert.zetaTxSenderAddress, + zetaRevert.remainingZetaValue + ); if (!(success1 && success2)) revert ErrorTransferringZeta(); } } diff --git a/packages/zeta-app-contracts/data/addresses.json b/packages/zeta-app-contracts/data/addresses.json index eba55858..98f5f234 100644 --- a/packages/zeta-app-contracts/data/addresses.json +++ b/packages/zeta-app-contracts/data/addresses.json @@ -8,13 +8,13 @@ }, "bsc_mainnet": { "multiChainSwap": "", - "multiChainValue": "0x33e5fCFfe910B99DB46c259804fCA1317EA0Aa89", + "multiChainValue": "0x358E2cfC0E16444Ba7D3164Bbeeb6bEA7472c559", "zetaTokenConsumerUniV2": "", "zetaTokenConsumerUniV3": "" }, "bsc_testnet": { "multiChainSwap": "0x8BD7144Ddb59c9Fa3Dcf809998521E9cAD946fa1", - "multiChainValue": "0x064516547ECd3b2D1709e1b2798Aae92b1C8a84C", + "multiChainValue": "0xF9Eeb1E5360eb8da591956053FaE7CFD85100C08", "zetaTokenConsumerUniV2": "", "zetaTokenConsumerUniV3": "" }, @@ -26,13 +26,13 @@ }, "eth_mainnet": { "multiChainSwap": "", - "multiChainValue": "0x910966E1C0Bc9FD74f499723c19Ff9799fE258a5", + "multiChainValue": "0xfd6DD5119a4B8eFC3F23EA31924C8Bc961f4005e", "zetaTokenConsumerUniV2": "", "zetaTokenConsumerUniV3": "" }, "goerli_testnet": { "multiChainSwap": "0x323745f16C93e56a98012970c28788498d8B3a14", - "multiChainValue": "0x14BeC0E4A8e7bF7A02Af54Ad81a57a9fcA4D37Fd", + "multiChainValue": "0x667e4C493d40015256BDC89E3ba750B2F90359E1", "zetaTokenConsumerUniV2": "", "zetaTokenConsumerUniV3": "" }, @@ -44,12 +44,19 @@ }, "zeta_testnet": { "multiChainSwap": "", - "multiChainValue": "0x36Cfb6dCd6926dFb749dc8E4b28efc73f3e6FAe3", + "multiChainValue": "0x51886eC8E70e9331916fE44f1a10B641100094Fc", + "zetaTokenConsumerUniV2": "", + "zetaTokenConsumerUniV3": "" + }, + "zeta_mainnet": { + "multiChainSwap": "", + "multiChainValue": "0x113d1e0fA690746b6Bd86CaDCEA712f22CFEAc05", "zetaTokenConsumerUniV2": "", "zetaTokenConsumerUniV3": "" } }, "zevm": { - "zeta_testnet": {} + "zeta_testnet": {}, + "zeta_mainnet": {} } } \ No newline at end of file diff --git a/packages/zeta-app-contracts/scripts/multi-chain-value/find-errors.ts b/packages/zeta-app-contracts/scripts/multi-chain-value/find-errors.ts new file mode 100644 index 00000000..5db2a2fc --- /dev/null +++ b/packages/zeta-app-contracts/scripts/multi-chain-value/find-errors.ts @@ -0,0 +1,75 @@ +import { ContractReceipt, ContractTransaction, Transaction } from "ethers"; +import { ethers, network } from "hardhat"; + +// Specify the address you're interested in +const ADDRESS = "0x70e967acFcC17c3941E87562161406d41676FD83"; +let API_KEY = ""; +let API_ENDPOINT = ""; +let START_BLOCK = 0; +let END_BLOCK = 0; + +if (network.name === "bsc_mainnet") { + API_KEY = "C1Z6YAZ48NZF6FYM85JT4J9JUCESQEDNRQ"; + API_ENDPOINT = "api.bscscan.com"; + START_BLOCK = 35741686; + END_BLOCK = 35844713; +} else if (network.name === "eth_mainnet") { + API_KEY = "57A2HPCSSKRT16YHXKU6B6P2HXF36WA3BD"; + API_ENDPOINT = "api.etherscan.io"; + START_BLOCK = 19080591; + END_BLOCK = 19157698; +} else { + throw new Error("Unsupported network"); +} + +// Function to check if a transaction involves the specified address +const isTransactionOfInterest = (tx: any, address: string) => { + return tx.from.toLowerCase() === address.toLowerCase() || tx.to.toLowerCase() === address.toLowerCase(); +}; + +// Main function to iterate over the block range and find transactions +const findTransactionsInRange = async () => { + let totalTx = 0; + let totalErrorTx = 0; + for (let i = START_BLOCK; i < END_BLOCK; i++) { + // console.log(`Fetching block ${i} to ${END_BLOCK}...`); + const API_URL = `https://${API_ENDPOINT}/api?module=account&action=txlist&address=${ADDRESS}&startblock=${i}&endblock=${END_BLOCK}&sort=asc&apikey=${API_KEY}`; + + try { + const call = await fetch(API_URL); + const response = await call.json(); + const result = response.result; + const firstBlock = result[0].blockNumber; + const lastBlock = result[result.length - 1].blockNumber; + console.log(`Fetched block ${firstBlock} to ${lastBlock}...`); + + const filteredTx = result.filter((tx: any) => isTransactionOfInterest(tx, ADDRESS)); + const nonSuccesssfulTx = filteredTx.filter((tx: any) => tx.isError === "1" || tx.txreceipt_status !== "1"); + + totalTx += filteredTx.length; + totalErrorTx += nonSuccesssfulTx.length; + for (const tx of nonSuccesssfulTx) { + console.log(tx.hash); + } + if (result.length > 9000) { + i = parseInt(result[result.length - 1].blockNumber) - 1; + } + if (lastBlock >= END_BLOCK) { + break; + } + } catch (e) { + console.log(`Error fetching block ${i}`, e); + } + } + console.log(`total tx: ${totalTx} / Errors: ${totalErrorTx}`); +}; + +// Call the main function +const main = async () => { + await findTransactionsInRange(); +}; + +main().catch((error) => { + console.error(error); + process.exit(1); +});