From 0b7b94b7c3a43a9214b1daa22b8ff0017b0285f8 Mon Sep 17 00:00:00 2001 From: Aleksa Colovic Date: Wed, 3 Dec 2025 15:27:40 +0100 Subject: [PATCH] chore: Remove unused code --- scripts/refillUsdcToSpecificChain.ts | 5 ++-- src/clients/bridges/utils.ts | 44 +--------------------------- 2 files changed, 3 insertions(+), 46 deletions(-) diff --git a/scripts/refillUsdcToSpecificChain.ts b/scripts/refillUsdcToSpecificChain.ts index 3b63ecc380..197e7f5de5 100644 --- a/scripts/refillUsdcToSpecificChain.ts +++ b/scripts/refillUsdcToSpecificChain.ts @@ -8,7 +8,6 @@ import { CHAIN_IDs, TOKEN_SYMBOLS_MAP, createFormatFunction, - formatUnits, toBNWei, ERC20, Contract, @@ -198,7 +197,7 @@ async function run(): Promise { chainName: sourceChainName, chainId: sourceChainId, balance: balanceFormatted, - threshold: formatUnits(MIN_BALANCE_THRESHOLD_USDC, sourceUsdcTokenInfo.decimals), + threshold: MIN_BALANCE_THRESHOLD_USDC_DECIMAL, }); // Construct transaction to send entire balance to destination chain @@ -239,7 +238,7 @@ async function run(): Promise { chainName: sourceChainName, chainId: sourceChainId, balance: balanceFormatted, - threshold: formatUnits(MIN_BALANCE_THRESHOLD_USDC, sourceUsdcTokenInfo.decimals), + threshold: MIN_BALANCE_THRESHOLD_USDC_DECIMAL, }); } } catch (error) { diff --git a/src/clients/bridges/utils.ts b/src/clients/bridges/utils.ts index 97df9ed6c4..982999c5f9 100644 --- a/src/clients/bridges/utils.ts +++ b/src/clients/bridges/utils.ts @@ -1,19 +1,5 @@ -import { Contract } from "ethers"; import { Log } from "../../interfaces"; -import { TOKEN_APPROVALS_TO_FIRST_ZERO } from "../../common"; -import { - BigNumber, - MAX_SAFE_ALLOWANCE, - blockExplorerLink, - bnZero, - getNetworkName, - getRedisCache, - runTransaction, - toBN, - winston, - mapAsync, - EvmAddress, -} from "../../utils"; +import { BigNumber, getRedisCache, toBN, EvmAddress } from "../../utils"; /** * @notice This function is designed to be used in L2 chain adapters when identifying "finalized" cross @@ -116,31 +102,3 @@ export async function setL2TokenAllowanceInCache( const key = getL2AllowanceCacheKey(l2ChainId, l2Token, userAddress, contractAddress); await redis?.set(key, allowance.toString()); } - -// @TODO: It looks like this function is not used anywhere. We have similar function in adapter/utils.ts. Delete this? -export async function approveTokens( - tokens: { token: Contract; bridge: EvmAddress }[], - chainId: number, - hubChainId: number, - logger: winston.Logger -): Promise { - const approvalMarkdwn = await mapAsync(tokens, async ({ token: l1Token, bridge }) => { - const txs = []; - if (TOKEN_APPROVALS_TO_FIRST_ZERO[hubChainId]?.includes(l1Token.address)) { - txs.push(await runTransaction(logger, l1Token, "approve", [bridge.toNative(), bnZero])); - } - txs.push(await runTransaction(logger, l1Token, "approve", [bridge.toNative(), MAX_SAFE_ALLOWANCE])); - const receipts = await Promise.all(txs.map((tx) => tx.wait())); - const hubNetwork = getNetworkName(hubChainId); - const spokeNetwork = getNetworkName(chainId); - let internalMrkdwn = - ` - Approved canonical ${spokeNetwork} token bridge ${blockExplorerLink(bridge.toNative(), hubChainId)} ` + - `to spend ${await l1Token.symbol()} ${blockExplorerLink(l1Token.address, hubChainId)} on ${hubNetwork}.` + - `tx: ${blockExplorerLink(receipts[receipts.length - 1].txnRef, hubChainId)}`; - if (receipts.length > 1) { - internalMrkdwn += ` tx (to zero approval first): ${blockExplorerLink(receipts[0].txnRef, hubChainId)}`; - } - return internalMrkdwn; - }); - return ["*Approval transactions:*", ...approvalMarkdwn].join("\n"); -}