Skip to content

Commit f14256a

Browse files
committed
cronos zk bridge
1 parent a20e090 commit f14256a

File tree

2 files changed

+54
-8
lines changed

2 files changed

+54
-8
lines changed

projects/cronos-zk/index.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
const { sumTokens2 } = require("../helper/unwrapLPs");
2+
3+
const target = "0xD7f9f54194C633F36CCD5F3da84ad4a1c38cB2cB"
4+
const gasQuery = '0x0000000000000000000000000000000000000001'
5+
const gasAddress = '0x0000000000000000000000000000000000000000'
6+
const chainId = 388
7+
8+
module.exports = {
9+
ethereum: {
10+
tvl: async (api) => {
11+
const totalBalances = await sumTokens2({
12+
api,
13+
owner: target,
14+
fetchCoValentTokens: true,
15+
})
16+
const balances = await api.multiCall({
17+
calls: [gasQuery, ...Object.keys(totalBalances)].map(token => ({
18+
target, params: [chainId, token.substring(token.indexOf(':') + 1)]
19+
})),
20+
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" },
21+
permitFailure: true,
22+
withMetadata: true
23+
})
24+
api._balances._balances = {}
25+
balances.map(call => {
26+
const token = call.input.params[1]
27+
api.add(token == gasQuery ? gasAddress : token, call.output)
28+
})
29+
}
30+
},
31+
};

projects/txBridge/index.js

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,31 @@
11
const { sumTokens2 } = require("../helper/unwrapLPs");
22

3+
const target = "0xD7f9f54194C633F36CCD5F3da84ad4a1c38cB2cB"
4+
const gasQuery = '0x0000000000000000000000000000000000000001'
5+
const gasAddress = '0x0000000000000000000000000000000000000000'
6+
const chainId = 324
7+
38
module.exports = {
49
ethereum: {
5-
tvl: (api) =>
6-
sumTokens2({
10+
tvl: async (api) => {
11+
const totalBalances = await sumTokens2({
712
api,
8-
owners: [
9-
"0x32400084C286CF3E17e7B677ea9583e60a000324",
10-
"0x57891966931Eb4Bb6FB81430E6cE0A03AAbDe063",
11-
"0xD7f9f54194C633F36CCD5F3da84ad4a1c38cB2cB"
12-
],
13+
owner: target,
1314
fetchCoValentTokens: true,
14-
}),
15+
})
16+
const balances = await api.multiCall({
17+
calls: [gasQuery, ...Object.keys(totalBalances)].map(token => ({
18+
target, params: [chainId, token.substring(token.indexOf(':') + 1)]
19+
})),
20+
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" },
21+
permitFailure: true,
22+
withMetadata: true
23+
})
24+
api._balances._balances = {}
25+
balances.map(call => {
26+
const token = call.input.params[1]
27+
api.add(token == gasQuery ? gasAddress : token, call.output)
28+
})
29+
}
1530
},
1631
};

0 commit comments

Comments
 (0)