|
1 | | -import { Contract } from "ethers"; |
2 | 1 | import { Log } from "../../interfaces"; |
3 | | -import { TOKEN_APPROVALS_TO_FIRST_ZERO } from "../../common"; |
4 | | -import { |
5 | | - BigNumber, |
6 | | - MAX_SAFE_ALLOWANCE, |
7 | | - blockExplorerLink, |
8 | | - bnZero, |
9 | | - getNetworkName, |
10 | | - getRedisCache, |
11 | | - runTransaction, |
12 | | - toBN, |
13 | | - winston, |
14 | | - mapAsync, |
15 | | - EvmAddress, |
16 | | -} from "../../utils"; |
| 2 | +import { BigNumber, getRedisCache, toBN, EvmAddress } from "../../utils"; |
17 | 3 |
|
18 | 4 | /** |
19 | 5 | * @notice This function is designed to be used in L2 chain adapters when identifying "finalized" cross |
@@ -116,31 +102,3 @@ export async function setL2TokenAllowanceInCache( |
116 | 102 | const key = getL2AllowanceCacheKey(l2ChainId, l2Token, userAddress, contractAddress); |
117 | 103 | await redis?.set(key, allowance.toString()); |
118 | 104 | } |
119 | | - |
120 | | -// @TODO: It looks like this function is not used anywhere. We have similar function in adapter/utils.ts. Delete this? |
121 | | -export async function approveTokens( |
122 | | - tokens: { token: Contract; bridge: EvmAddress }[], |
123 | | - chainId: number, |
124 | | - hubChainId: number, |
125 | | - logger: winston.Logger |
126 | | -): Promise<string> { |
127 | | - const approvalMarkdwn = await mapAsync(tokens, async ({ token: l1Token, bridge }) => { |
128 | | - const txs = []; |
129 | | - if (TOKEN_APPROVALS_TO_FIRST_ZERO[hubChainId]?.includes(l1Token.address)) { |
130 | | - txs.push(await runTransaction(logger, l1Token, "approve", [bridge.toNative(), bnZero])); |
131 | | - } |
132 | | - txs.push(await runTransaction(logger, l1Token, "approve", [bridge.toNative(), MAX_SAFE_ALLOWANCE])); |
133 | | - const receipts = await Promise.all(txs.map((tx) => tx.wait())); |
134 | | - const hubNetwork = getNetworkName(hubChainId); |
135 | | - const spokeNetwork = getNetworkName(chainId); |
136 | | - let internalMrkdwn = |
137 | | - ` - Approved canonical ${spokeNetwork} token bridge ${blockExplorerLink(bridge.toNative(), hubChainId)} ` + |
138 | | - `to spend ${await l1Token.symbol()} ${blockExplorerLink(l1Token.address, hubChainId)} on ${hubNetwork}.` + |
139 | | - `tx: ${blockExplorerLink(receipts[receipts.length - 1].txnRef, hubChainId)}`; |
140 | | - if (receipts.length > 1) { |
141 | | - internalMrkdwn += ` tx (to zero approval first): ${blockExplorerLink(receipts[0].txnRef, hubChainId)}`; |
142 | | - } |
143 | | - return internalMrkdwn; |
144 | | - }); |
145 | | - return ["*Approval transactions:*", ...approvalMarkdwn].join("\n"); |
146 | | -} |
0 commit comments