Skip to content

Commit

Permalink
feat: update zetachain multichainvalue
Browse files Browse the repository at this point in the history
  • Loading branch information
andresaiello committed Feb 5, 2024
1 parent f79723b commit ff317c5
Show file tree
Hide file tree
Showing 3 changed files with 94 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,18 +94,20 @@ contract MultiChainValue is ZetaInteractor, MultiChainValueErrors {
destinationChainId: destinationChainId,
destinationAddress: destinationAddress,
destinationGasLimit: 300000,
message: abi.encode(msg.sender),
message: abi.encode(),
zetaValueAndGas: zetaValueAndGas,
zetaParams: abi.encode("")
})
);
}

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();
}
}
19 changes: 13 additions & 6 deletions packages/zeta-app-contracts/data/addresses.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
},
"bsc_mainnet": {
"multiChainSwap": "",
"multiChainValue": "0x33e5fCFfe910B99DB46c259804fCA1317EA0Aa89",
"multiChainValue": "0x358E2cfC0E16444Ba7D3164Bbeeb6bEA7472c559",
"zetaTokenConsumerUniV2": "",
"zetaTokenConsumerUniV3": ""
},
"bsc_testnet": {
"multiChainSwap": "0x8BD7144Ddb59c9Fa3Dcf809998521E9cAD946fa1",
"multiChainValue": "0x064516547ECd3b2D1709e1b2798Aae92b1C8a84C",
"multiChainValue": "0xF9Eeb1E5360eb8da591956053FaE7CFD85100C08",
"zetaTokenConsumerUniV2": "",
"zetaTokenConsumerUniV3": ""
},
Expand All @@ -26,13 +26,13 @@
},
"eth_mainnet": {
"multiChainSwap": "",
"multiChainValue": "0x910966E1C0Bc9FD74f499723c19Ff9799fE258a5",
"multiChainValue": "0xfd6DD5119a4B8eFC3F23EA31924C8Bc961f4005e",
"zetaTokenConsumerUniV2": "",
"zetaTokenConsumerUniV3": ""
},
"goerli_testnet": {
"multiChainSwap": "0x323745f16C93e56a98012970c28788498d8B3a14",
"multiChainValue": "0x14BeC0E4A8e7bF7A02Af54Ad81a57a9fcA4D37Fd",
"multiChainValue": "0x667e4C493d40015256BDC89E3ba750B2F90359E1",
"zetaTokenConsumerUniV2": "",
"zetaTokenConsumerUniV3": ""
},
Expand All @@ -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": {}
}
}
Original file line number Diff line number Diff line change
@@ -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);
});

0 comments on commit ff317c5

Please sign in to comment.