From f14256a877b9c5b75611705035367dc00bdb4ea2 Mon Sep 17 00:00:00 2001 From: waynebruce0x Date: Tue, 24 Dec 2024 09:33:29 +0000 Subject: [PATCH] cronos zk bridge --- projects/cronos-zk/index.js | 31 +++++++++++++++++++++++++++++++ projects/txBridge/index.js | 31 +++++++++++++++++++++++-------- 2 files changed, 54 insertions(+), 8 deletions(-) create mode 100644 projects/cronos-zk/index.js diff --git a/projects/cronos-zk/index.js b/projects/cronos-zk/index.js new file mode 100644 index 000000000000..8de3a066146f --- /dev/null +++ b/projects/cronos-zk/index.js @@ -0,0 +1,31 @@ +const { sumTokens2 } = require("../helper/unwrapLPs"); + +const target = "0xD7f9f54194C633F36CCD5F3da84ad4a1c38cB2cB" +const gasQuery = '0x0000000000000000000000000000000000000001' +const gasAddress = '0x0000000000000000000000000000000000000000' +const chainId = 388 + +module.exports = { + ethereum: { + tvl: async (api) => { + const totalBalances = await sumTokens2({ + api, + owner: target, + fetchCoValentTokens: true, + }) + const balances = await api.multiCall({ + calls: [gasQuery, ...Object.keys(totalBalances)].map(token => ({ + target, params: [chainId, token.substring(token.indexOf(':') + 1)] + })), + abi: { "inputs": [{ "internalType": "uint256", "name": "chainId", "type": "uint256" }, { "internalType": "address", "name": "l1Token", "type": "address" }], "name": "chainBalance", "outputs": [{ "internalType": "uint256", "name": "balance", "type": "uint256" }], "stateMutability": "view", "type": "function" }, + permitFailure: true, + withMetadata: true + }) + api._balances._balances = {} + balances.map(call => { + const token = call.input.params[1] + api.add(token == gasQuery ? gasAddress : token, call.output) + }) + } + }, +}; diff --git a/projects/txBridge/index.js b/projects/txBridge/index.js index 3c27fe98449b..bdb3b6df1dae 100644 --- a/projects/txBridge/index.js +++ b/projects/txBridge/index.js @@ -1,16 +1,31 @@ const { sumTokens2 } = require("../helper/unwrapLPs"); +const target = "0xD7f9f54194C633F36CCD5F3da84ad4a1c38cB2cB" +const gasQuery = '0x0000000000000000000000000000000000000001' +const gasAddress = '0x0000000000000000000000000000000000000000' +const chainId = 324 + module.exports = { ethereum: { - tvl: (api) => - sumTokens2({ + tvl: async (api) => { + const totalBalances = await sumTokens2({ api, - owners: [ - "0x32400084C286CF3E17e7B677ea9583e60a000324", - "0x57891966931Eb4Bb6FB81430E6cE0A03AAbDe063", - "0xD7f9f54194C633F36CCD5F3da84ad4a1c38cB2cB" - ], + owner: target, fetchCoValentTokens: true, - }), + }) + const balances = await api.multiCall({ + calls: [gasQuery, ...Object.keys(totalBalances)].map(token => ({ + target, params: [chainId, token.substring(token.indexOf(':') + 1)] + })), + abi: { "inputs": [{ "internalType": "uint256", "name": "chainId", "type": "uint256" }, { "internalType": "address", "name": "l1Token", "type": "address" }], "name": "chainBalance", "outputs": [{ "internalType": "uint256", "name": "balance", "type": "uint256" }], "stateMutability": "view", "type": "function" }, + permitFailure: true, + withMetadata: true + }) + api._balances._balances = {} + balances.map(call => { + const token = call.input.params[1] + api.add(token == gasQuery ? gasAddress : token, call.output) + }) + } }, };