Skip to content

Commit a6aa75e

Browse files
authored
chore: Remove unused code (#2794)
1 parent 47ab750 commit a6aa75e

File tree

2 files changed

+3
-46
lines changed

2 files changed

+3
-46
lines changed

scripts/refillUsdcToSpecificChain.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import {
88
CHAIN_IDs,
99
TOKEN_SYMBOLS_MAP,
1010
createFormatFunction,
11-
formatUnits,
1211
toBNWei,
1312
ERC20,
1413
Contract,
@@ -198,7 +197,7 @@ async function run(): Promise<void> {
198197
chainName: sourceChainName,
199198
chainId: sourceChainId,
200199
balance: balanceFormatted,
201-
threshold: formatUnits(MIN_BALANCE_THRESHOLD_USDC, sourceUsdcTokenInfo.decimals),
200+
threshold: MIN_BALANCE_THRESHOLD_USDC_DECIMAL,
202201
});
203202

204203
// Construct transaction to send entire balance to destination chain
@@ -239,7 +238,7 @@ async function run(): Promise<void> {
239238
chainName: sourceChainName,
240239
chainId: sourceChainId,
241240
balance: balanceFormatted,
242-
threshold: formatUnits(MIN_BALANCE_THRESHOLD_USDC, sourceUsdcTokenInfo.decimals),
241+
threshold: MIN_BALANCE_THRESHOLD_USDC_DECIMAL,
243242
});
244243
}
245244
} catch (error) {

src/clients/bridges/utils.ts

Lines changed: 1 addition & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,5 @@
1-
import { Contract } from "ethers";
21
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";
173

184
/**
195
* @notice This function is designed to be used in L2 chain adapters when identifying "finalized" cross
@@ -116,31 +102,3 @@ export async function setL2TokenAllowanceInCache(
116102
const key = getL2AllowanceCacheKey(l2ChainId, l2Token, userAddress, contractAddress);
117103
await redis?.set(key, allowance.toString());
118104
}
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

Comments
 (0)