From 6315bbb5f2c3dc76c0e304895f53cbe278561347 Mon Sep 17 00:00:00 2001 From: Viraz Malhotra Date: Mon, 28 Oct 2024 14:43:32 +0530 Subject: [PATCH] feat: add TS linting check in CI (#350) - fixes existing ts linting errors - closes #346 --------- Co-authored-by: Mad <46090742+DefiCake@users.noreply.github.com> --- .changeset/small-singers-attend.md | 6 ++++ .eslintignore | 1 + .../integration-tests/tests/bridge_erc20.ts | 2 +- .../tests/bridge_mainnet_tokens.ts | 36 +++++++------------ .../integration-tests/tests/bridge_proxy.ts | 2 +- .../integration-tests/tests/transfer_eth.ts | 9 ++--- .../008.set_canonical_token_bytecode.ts | 1 + .../mainnet/002.fuel_message_portal_v3.ts | 3 +- .../deploy/mainnet/009.gateway_add_usdc.ts | 2 +- .../mainnet/010.gateway_rate_limit_usdc.ts | 2 +- .../mainnet/012.portal_transfer_ownership.ts | 7 ++-- .../013.chain_state_transfer_ownership.ts | 7 ++-- .../mainnet/014.gateway_transfer_ownership.ts | 7 ++-- .../mainnet/015.relinquish_ownership.ts | 5 +-- .../deploy/mainnet/016.gateway_upgrade.ts | 13 ++++--- .../deploy/mainnet/017.portal_upgrade.ts | 12 +++++-- .../deploy/mainnet/018.rate_limit_proposal.ts | 11 +++--- .../deploy/mainnet/019.pausers_proposal.ts | 11 +++--- .../upgradeTest/prepareUpgrade.chain_state.ts | 11 ++++-- .../prepareUpgrade.erc20_gateway_v4.ts | 11 ++++-- .../prepareUpgrade.fuel_message_portal_v3.ts | 11 ++++-- .../scripts/hardhat/depositETH.ts | 1 + .../scripts/hardhat/depositMetadata.ts | 3 +- .../scripts/hardhat/depositToken.ts | 3 +- .../scripts/hardhat/eventFilter.ts | 4 +-- .../scripts/hardhat/resetERC20RateLimit.ts | 1 + .../scripts/hardhat/resetETHRateLimit.ts | 1 + .../hardhat/utils/requireConfirmation.ts | 1 - .../scripts/hardhat/verifyDeployment.ts | 14 ++++---- .../hardhat/verifyMainnetDeployment.ts | 12 ++++--- .../scripts/hardhat/withdrawalBlacklist.ts | 1 + .../scripts/hardhat/withdrawalPause.ts | 1 + .../scripts/hardhat/withdrawalResume.ts | 1 + .../scripts/hardhat/withdrawalWhitelist.ts | 1 + .../behaviors/erc20GatewayV4.behavior.test.ts | 6 ++-- .../test/erc20GatewayV4.test.ts | 1 - .../test/erc721Gateway.test.ts | 1 - .../test/messagesIncomingV3.test.ts | 3 +- .../test/messagesOutgoingV2.test.ts | 1 - packages/solidity-contracts/test/upgrade.ts | 1 - .../test/utils/deployProxy.ts | 2 +- .../test-utils/src/scripts/check-balances.ts | 3 +- .../test-utils/src/scripts/check-nonce.ts | 5 +-- .../src/scripts/check-proxy-data.ts | 4 +-- .../test-utils/src/scripts/deploy-bridge.ts | 13 +++---- .../test-utils/src/scripts/deposit-to-coin.ts | 5 +-- .../test-utils/src/scripts/relay-deposit.ts | 13 ++++--- .../test-utils/src/scripts/relay-metadata.ts | 10 +++--- .../src/scripts/transfer-bridge-ownership.ts | 9 ++--- .../src/scripts/upgrade-bridge-kms.ts | 13 +++---- .../test-utils/src/scripts/upgrade-bridge.ts | 12 ++++--- .../src/scripts/verify-asset-metadata.ts | 17 +++++---- .../test-utils/src/scripts/withdraw-init.ts | 28 +++++---------- .../src/utils/fuels/waitForBlock.ts | 2 +- .../src/utils/fuels/waitForMessage.ts | 9 ++--- packages/test-utils/src/utils/setup.ts | 2 +- scripts/check.sh | 2 ++ 57 files changed, 203 insertions(+), 173 deletions(-) create mode 100644 .changeset/small-singers-attend.md diff --git a/.changeset/small-singers-attend.md b/.changeset/small-singers-attend.md new file mode 100644 index 00000000..8c51c65c --- /dev/null +++ b/.changeset/small-singers-attend.md @@ -0,0 +1,6 @@ +--- +'@fuel-bridge/solidity-contracts': patch +'@fuel-bridge/test-utils': patch +--- + +ts linting for test packages diff --git a/.eslintignore b/.eslintignore index 5ebbe234..b03558b7 100644 --- a/.eslintignore +++ b/.eslintignore @@ -4,3 +4,4 @@ **/typechain/ docker/l1-chain/hardhat dist +**/exports/ diff --git a/packages/integration-tests/tests/bridge_erc20.ts b/packages/integration-tests/tests/bridge_erc20.ts index ee0d7096..c3b4015d 100644 --- a/packages/integration-tests/tests/bridge_erc20.ts +++ b/packages/integration-tests/tests/bridge_erc20.ts @@ -642,7 +642,7 @@ describe('Bridging ERC20 tokens', async function () { it('Rate limit parameters are updated when current withdrawn amount is more than the new limit & set a new higher limit', async () => { const deployer = await env.eth.deployer; - let newRateLimit = '5'; + const newRateLimit = '5'; let withdrawnAmountBeforeReset = await env.eth.fuelERC20Gateway.currentPeriodAmount( diff --git a/packages/integration-tests/tests/bridge_mainnet_tokens.ts b/packages/integration-tests/tests/bridge_mainnet_tokens.ts index 4c569bb1..593c9973 100644 --- a/packages/integration-tests/tests/bridge_mainnet_tokens.ts +++ b/packages/integration-tests/tests/bridge_mainnet_tokens.ts @@ -2,19 +2,19 @@ import type { BridgeFungibleToken } from '@fuel-bridge/fungible-token'; import { RATE_LIMIT_AMOUNT, RATE_LIMIT_DURATION, + USDT_ADDRESS, + USDC_ADDRESS, + WBTC_ADDRESS, + WETH_ADDRESS, } from '@fuel-bridge/solidity-contracts/protocol/constants'; -import { +import type { CustomToken, CustomTokenWETH, +} from '@fuel-bridge/solidity-contracts/typechain'; +import { CustomToken__factory, CustomTokenWETH__factory, } from '@fuel-bridge/solidity-contracts/typechain'; -import { - USDT_ADDRESS, - USDC_ADDRESS, - WBTC_ADDRESS, - WETH_ADDRESS, -} from '@fuel-bridge/solidity-contracts/protocol/constants'; import type { TestEnvironment } from '@fuel-bridge/test-utils'; import { setupEnvironment, @@ -89,8 +89,7 @@ describe('Bridge mainnet tokens', function () { fuel_AssetId ); - let transactionRequest; - transactionRequest = await fuel_bridge.functions + const transactionRequest = await fuel_bridge.functions .withdraw(paddedAddress) .addContracts([fuel_bridge, fuel_bridgeImpl]) .txParams({ @@ -232,7 +231,6 @@ describe('Bridge mainnet tokens', function () { const NUM_TOKENS = 100000000000000000000n; let ethereumTokenSender: Signer; let ethereumTokenSenderAddress: string; - let ethereumTokenSenderBalance: bigint; let fuelTokenReceiver: FuelWallet; let fuelTokenReceiverAddress: string; let fuelTokenReceiverBalance: BN; @@ -247,20 +245,12 @@ describe('Bridge mainnet tokens', function () { await weth_testToken .connect(ethereumTokenSender) .deposit({ value: NUM_TOKENS }); - - ethereumTokenSenderBalance = await weth_testToken.balanceOf( - ethereumTokenSenderAddress - ); } else { const mintAmount = BigInt(NUM_TOKENS) / 10n ** (18n - decimals[index]); await customToken .mint(ethereumTokenSender, mintAmount) .then((tx) => tx.wait()); - - ethereumTokenSenderBalance = await customToken.balanceOf( - ethereumTokenSenderAddress - ); } fuelTokenReceiver = env.fuel.signers[0]; @@ -302,10 +292,10 @@ describe('Bridge mainnet tokens', function () { fuelTokenMessageNonce = new BN(event.args.nonce.toString()); - let newSenderBalance; - // check that the sender balance has decreased by the expected amount - newSenderBalance = await token.balanceOf(ethereumTokenSenderAddress); + const newSenderBalance = await token.balanceOf( + ethereumTokenSenderAddress + ); expect(newSenderBalance === 0n).to.be.true; }); @@ -315,7 +305,7 @@ describe('Bridge mainnet tokens', function () { this.timeout(FUEL_MESSAGE_TIMEOUT_MS); // relay the message ourselves - let message = await waitForMessage( + const message = await waitForMessage( env.fuel.provider, fuelTokenMessageReceiver, fuelTokenMessageNonce, @@ -323,7 +313,7 @@ describe('Bridge mainnet tokens', function () { ); expect(message).to.not.be.null; - let tx = await relayCommonMessage(env.fuel.deployer, message, { + const tx = await relayCommonMessage(env.fuel.deployer, message, { gasLimit: 30000000, maturity: undefined, contractIds: [fuel_bridgeImpl.id.toHexString()], diff --git a/packages/integration-tests/tests/bridge_proxy.ts b/packages/integration-tests/tests/bridge_proxy.ts index 16ad23cb..ec184fbf 100644 --- a/packages/integration-tests/tests/bridge_proxy.ts +++ b/packages/integration-tests/tests/bridge_proxy.ts @@ -1,8 +1,8 @@ +import type { Proxy } from '@fuel-bridge/fungible-token'; import type { TestEnvironment } from '@fuel-bridge/test-utils'; import { setupEnvironment, getOrDeployL2Bridge } from '@fuel-bridge/test-utils'; import chai from 'chai'; import type { Contract, FuelError } from 'fuels'; -import { Proxy } from '@fuel-bridge/fungible-token'; const { expect } = chai; diff --git a/packages/integration-tests/tests/transfer_eth.ts b/packages/integration-tests/tests/transfer_eth.ts index ba28203f..2ef61397 100644 --- a/packages/integration-tests/tests/transfer_eth.ts +++ b/packages/integration-tests/tests/transfer_eth.ts @@ -1,5 +1,5 @@ +import type { TestEnvironment } from '@fuel-bridge/test-utils'; import { - TestEnvironment, setupEnvironment, fuels_parseEther, createRelayMessageParams, @@ -14,9 +14,8 @@ import { hardhatSkipTime, } from '@fuel-bridge/test-utils'; import chai from 'chai'; -import type { Signer } from 'ethers'; import { parseEther } from 'ethers'; -import type { JsonRpcProvider } from 'ethers'; +import type { Signer, JsonRpcProvider } from 'ethers'; import { Address, BN, padFirst12BytesOfEvmAddress } from 'fuels'; import type { AbstractAddress, @@ -264,6 +263,8 @@ describe('Transferring ETH', async function () { // withdraw ETH back to the base chain const blocksPerCommitInterval = await env.eth.fuelChainState.BLOCKS_PER_COMMIT_INTERVAL(); + + // eslint-disable-next-line no-constant-condition while (true) { const currentBlock = await env.fuel.provider.getBlockNumber(); debug(`Current block ${currentBlock.toString()}`); @@ -349,7 +350,7 @@ describe('Transferring ETH', async function () { }); describe('ETH Withdrawls based on rate limit updates', async () => { - let NUM_ETH = '9'; + const NUM_ETH = '9'; const largeRateLimit = `30`; let fuelETHSender: FuelWallet; let ethereumETHReceiver: Signer; diff --git a/packages/solidity-contracts/deploy/hardhat/008.set_canonical_token_bytecode.ts b/packages/solidity-contracts/deploy/hardhat/008.set_canonical_token_bytecode.ts index 698cf33d..f7ec8ccb 100644 --- a/packages/solidity-contracts/deploy/hardhat/008.set_canonical_token_bytecode.ts +++ b/packages/solidity-contracts/deploy/hardhat/008.set_canonical_token_bytecode.ts @@ -1,5 +1,6 @@ import type { HardhatRuntimeEnvironment } from 'hardhat/types'; import type { DeployFunction } from 'hardhat-deploy/dist/types'; + import { USDT_ADDRESS, USDC_ADDRESS, diff --git a/packages/solidity-contracts/deploy/mainnet/002.fuel_message_portal_v3.ts b/packages/solidity-contracts/deploy/mainnet/002.fuel_message_portal_v3.ts index 67703d8f..b29acdac 100644 --- a/packages/solidity-contracts/deploy/mainnet/002.fuel_message_portal_v3.ts +++ b/packages/solidity-contracts/deploy/mainnet/002.fuel_message_portal_v3.ts @@ -2,12 +2,11 @@ import { MaxUint256 } from 'ethers'; import type { HardhatRuntimeEnvironment } from 'hardhat/types'; import type { DeployFunction } from 'hardhat-deploy/dist/types'; -import { FuelMessagePortalV3__factory as FuelMessagePortal } from '../../typechain'; - import { RATE_LIMIT_AMOUNT, RATE_LIMIT_DURATION, } from '../../protocol/constants'; +import { FuelMessagePortalV3__factory as FuelMessagePortal } from '../../typechain'; const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { const { diff --git a/packages/solidity-contracts/deploy/mainnet/009.gateway_add_usdc.ts b/packages/solidity-contracts/deploy/mainnet/009.gateway_add_usdc.ts index f4111bcb..81922248 100644 --- a/packages/solidity-contracts/deploy/mainnet/009.gateway_add_usdc.ts +++ b/packages/solidity-contracts/deploy/mainnet/009.gateway_add_usdc.ts @@ -1,6 +1,6 @@ +import { parseUnits } from 'ethers'; import type { HardhatRuntimeEnvironment } from 'hardhat/types'; import type { DeployFunction } from 'hardhat-deploy/dist/types'; -import { parseUnits } from 'ethers'; const USDC_ADDRESS = '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48'; diff --git a/packages/solidity-contracts/deploy/mainnet/010.gateway_rate_limit_usdc.ts b/packages/solidity-contracts/deploy/mainnet/010.gateway_rate_limit_usdc.ts index 7e3fa4b0..39c22bae 100644 --- a/packages/solidity-contracts/deploy/mainnet/010.gateway_rate_limit_usdc.ts +++ b/packages/solidity-contracts/deploy/mainnet/010.gateway_rate_limit_usdc.ts @@ -1,6 +1,6 @@ +import { parseUnits } from 'ethers'; import type { HardhatRuntimeEnvironment } from 'hardhat/types'; import type { DeployFunction } from 'hardhat-deploy/dist/types'; -import { parseUnits } from 'ethers'; const USDC_ADDRESS = '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48'; const ONE_WEEK_IN_SECONDS = 3600 * 24 * 7; diff --git a/packages/solidity-contracts/deploy/mainnet/012.portal_transfer_ownership.ts b/packages/solidity-contracts/deploy/mainnet/012.portal_transfer_ownership.ts index b44a386a..322409ea 100644 --- a/packages/solidity-contracts/deploy/mainnet/012.portal_transfer_ownership.ts +++ b/packages/solidity-contracts/deploy/mainnet/012.portal_transfer_ownership.ts @@ -1,8 +1,9 @@ import { ZeroHash as DEFAULT_ADMIN_ROLE } from 'ethers'; -import { DeployFunction } from 'hardhat-deploy/dist/types'; -import { HardhatRuntimeEnvironment } from 'hardhat/types'; -import { FuelMessagePortalV3__factory } from '../../typechain'; +import type { HardhatRuntimeEnvironment } from 'hardhat/types'; +import type { DeployFunction } from 'hardhat-deploy/dist/types'; + import { MAINNET_MULTISIG_ADDRESS } from '../../protocol/constants'; +import { FuelMessagePortalV3__factory } from '../../typechain'; const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { const { ethers, deployments } = hre; diff --git a/packages/solidity-contracts/deploy/mainnet/013.chain_state_transfer_ownership.ts b/packages/solidity-contracts/deploy/mainnet/013.chain_state_transfer_ownership.ts index a00fb9da..12ac2896 100644 --- a/packages/solidity-contracts/deploy/mainnet/013.chain_state_transfer_ownership.ts +++ b/packages/solidity-contracts/deploy/mainnet/013.chain_state_transfer_ownership.ts @@ -1,8 +1,9 @@ import { ZeroHash as DEFAULT_ADMIN_ROLE } from 'ethers'; -import { DeployFunction } from 'hardhat-deploy/dist/types'; -import { HardhatRuntimeEnvironment } from 'hardhat/types'; -import { FuelChainState__factory } from '../../typechain'; +import type { HardhatRuntimeEnvironment } from 'hardhat/types'; +import type { DeployFunction } from 'hardhat-deploy/dist/types'; + import { MAINNET_MULTISIG_ADDRESS } from '../../protocol/constants'; +import { FuelChainState__factory } from '../../typechain'; const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { const { ethers, deployments } = hre; diff --git a/packages/solidity-contracts/deploy/mainnet/014.gateway_transfer_ownership.ts b/packages/solidity-contracts/deploy/mainnet/014.gateway_transfer_ownership.ts index 2aa02169..0cdc3be2 100644 --- a/packages/solidity-contracts/deploy/mainnet/014.gateway_transfer_ownership.ts +++ b/packages/solidity-contracts/deploy/mainnet/014.gateway_transfer_ownership.ts @@ -1,8 +1,9 @@ import { ZeroHash as DEFAULT_ADMIN_ROLE } from 'ethers'; -import { DeployFunction } from 'hardhat-deploy/dist/types'; -import { HardhatRuntimeEnvironment } from 'hardhat/types'; -import { FuelERC20GatewayV4__factory } from '../../typechain'; +import type { HardhatRuntimeEnvironment } from 'hardhat/types'; +import type { DeployFunction } from 'hardhat-deploy/dist/types'; + import { MAINNET_MULTISIG_ADDRESS } from '../../protocol/constants'; +import { FuelERC20GatewayV4__factory } from '../../typechain'; const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { const { ethers, deployments } = hre; diff --git a/packages/solidity-contracts/deploy/mainnet/015.relinquish_ownership.ts b/packages/solidity-contracts/deploy/mainnet/015.relinquish_ownership.ts index ee54a211..290929f7 100644 --- a/packages/solidity-contracts/deploy/mainnet/015.relinquish_ownership.ts +++ b/packages/solidity-contracts/deploy/mainnet/015.relinquish_ownership.ts @@ -1,6 +1,7 @@ import { ZeroHash as DEFAULT_ADMIN_ROLE } from 'ethers'; -import { DeployFunction } from 'hardhat-deploy/dist/types'; -import { HardhatRuntimeEnvironment } from 'hardhat/types'; +import type { HardhatRuntimeEnvironment } from 'hardhat/types'; +import type { DeployFunction } from 'hardhat-deploy/dist/types'; + import { FuelChainState__factory, FuelERC20GatewayV4__factory, diff --git a/packages/solidity-contracts/deploy/mainnet/016.gateway_upgrade.ts b/packages/solidity-contracts/deploy/mainnet/016.gateway_upgrade.ts index 48735ef4..f5b2a4c5 100644 --- a/packages/solidity-contracts/deploy/mainnet/016.gateway_upgrade.ts +++ b/packages/solidity-contracts/deploy/mainnet/016.gateway_upgrade.ts @@ -1,14 +1,14 @@ -import { TransactionResponse } from 'ethers'; +import { password } from '@inquirer/prompts'; +import type { TransactionResponse } from 'ethers'; import type { HardhatRuntimeEnvironment } from 'hardhat/types'; import type { DeployFunction } from 'hardhat-deploy/dist/types'; import { FuelERC20GatewayV4__factory } from '../../typechain'; -import { password } from '@inquirer/prompts'; const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { const { ethers, - upgrades: { prepareUpgrade, upgradeProxy, erc1967 }, + upgrades: { prepareUpgrade }, deployments: { get, save }, } = hre; @@ -22,7 +22,12 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { getTxResponse: true, })) as TransactionResponse; const receipt = await tx.wait(); - const implementation = receipt?.contractAddress!; + const implementation = receipt?.contractAddress ?? ''; + + if (implementation === '') + throw new Error( + `Upgrade proposal failed for FuelERC20GatewayV4 proxy (${address})` + ); console.log(`Proposed FuelERC20GatewayV4 upgrade to ${implementation}`); await save('FuelERC20GatewayV4', { diff --git a/packages/solidity-contracts/deploy/mainnet/017.portal_upgrade.ts b/packages/solidity-contracts/deploy/mainnet/017.portal_upgrade.ts index dc5e59a0..4d78f3ea 100644 --- a/packages/solidity-contracts/deploy/mainnet/017.portal_upgrade.ts +++ b/packages/solidity-contracts/deploy/mainnet/017.portal_upgrade.ts @@ -1,9 +1,10 @@ -import { TransactionResponse, parseEther } from 'ethers'; +import { password } from '@inquirer/prompts'; +import type { TransactionResponse } from 'ethers'; +import { parseEther } from 'ethers'; import type { HardhatRuntimeEnvironment } from 'hardhat/types'; import type { DeployFunction } from 'hardhat-deploy/dist/types'; import { FuelMessagePortalV3__factory as FuelMessagePortal } from '../../typechain'; -import { password } from '@inquirer/prompts'; const RATE_LIMIT_DURATION = 3600 * 24 * 7; @@ -30,7 +31,12 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { })) as TransactionResponse; const receipt = await tx.wait(); - const implementation = receipt?.contractAddress!; + const implementation = receipt?.contractAddress ?? ''; + + if (implementation === '') + throw new Error( + `Upgrade proposal failed for FuelMessagePortal proxy (${address})` + ); console.log('Proposed FuelMessagePortal upgrade to', implementation); await save('FuelMessagePortal', { diff --git a/packages/solidity-contracts/deploy/mainnet/018.rate_limit_proposal.ts b/packages/solidity-contracts/deploy/mainnet/018.rate_limit_proposal.ts index 475baa3d..6a83e608 100644 --- a/packages/solidity-contracts/deploy/mainnet/018.rate_limit_proposal.ts +++ b/packages/solidity-contracts/deploy/mainnet/018.rate_limit_proposal.ts @@ -1,16 +1,15 @@ +import { password } from '@inquirer/prompts'; +import SafeApiKit from '@safe-global/api-kit'; +import SafeProtocolKit from '@safe-global/protocol-kit'; +import type { MetaTransactionData } from '@safe-global/safe-core-sdk-types'; import type { HardhatRuntimeEnvironment, HttpNetworkConfig, } from 'hardhat/types'; import type { DeployFunction } from 'hardhat-deploy/dist/types'; -import SafeProtocolKit from '@safe-global/protocol-kit'; -import SafeApiKit from '@safe-global/api-kit'; -import { MetaTransactionData } from '@safe-global/safe-core-sdk-types'; - -import { password } from '@inquirer/prompts'; -import { FuelERC20GatewayV4__factory } from '../../typechain'; import { MAINNET_MULTISIG_ADDRESS } from '../../protocol/constants'; +import { FuelERC20GatewayV4__factory } from '../../typechain'; const MAINNET_TOKENS = [ '0x4041381e947CFD3D483d67a25C6aa9Dc924250c5', diff --git a/packages/solidity-contracts/deploy/mainnet/019.pausers_proposal.ts b/packages/solidity-contracts/deploy/mainnet/019.pausers_proposal.ts index a4b06d66..543acf2c 100644 --- a/packages/solidity-contracts/deploy/mainnet/019.pausers_proposal.ts +++ b/packages/solidity-contracts/deploy/mainnet/019.pausers_proposal.ts @@ -1,16 +1,15 @@ +import { password } from '@inquirer/prompts'; +import SafeApiKit from '@safe-global/api-kit'; +import SafeProtocolKit from '@safe-global/protocol-kit'; +import type { MetaTransactionData } from '@safe-global/safe-core-sdk-types'; import type { HardhatRuntimeEnvironment, HttpNetworkConfig, } from 'hardhat/types'; import type { DeployFunction } from 'hardhat-deploy/dist/types'; -import SafeProtocolKit from '@safe-global/protocol-kit'; -import SafeApiKit from '@safe-global/api-kit'; -import { MetaTransactionData } from '@safe-global/safe-core-sdk-types'; - -import { password } from '@inquirer/prompts'; -import { FuelMessagePortalV3__factory } from '../../typechain'; import { MAINNET_MULTISIG_ADDRESS } from '../../protocol/constants'; +import { FuelMessagePortalV3__factory } from '../../typechain'; const PAUSERS = [ '0x958470a2ADe72b7a01A2e160F3286767b9623Ad7', diff --git a/packages/solidity-contracts/deploy/upgradeTest/prepareUpgrade.chain_state.ts b/packages/solidity-contracts/deploy/upgradeTest/prepareUpgrade.chain_state.ts index cd337908..d96a398d 100644 --- a/packages/solidity-contracts/deploy/upgradeTest/prepareUpgrade.chain_state.ts +++ b/packages/solidity-contracts/deploy/upgradeTest/prepareUpgrade.chain_state.ts @@ -1,8 +1,8 @@ +import type { TransactionResponse } from 'ethers'; import type { HardhatRuntimeEnvironment } from 'hardhat/types'; import type { DeployFunction } from 'hardhat-deploy/dist/types'; import { FuelChainState__factory as FuelChainState } from '../../typechain'; -import { TransactionResponse } from 'ethers'; const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { const { @@ -25,10 +25,17 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { response.hash ); + const implementation = receipt?.contractAddress ?? ''; + + if (implementation === '') + throw new Error( + `Upgrade proposal failed for FuelChainState proxy (${contractDeployment.address})` + ); + await save('FuelChainState', { address: contractDeployment.address, abi: [...FuelChainState.abi], - implementation: receipt?.contractAddress!, + implementation, transactionHash: response.hash, linkedData: { constructorArgs: contractDeployment.linkedData.constructorArgs, diff --git a/packages/solidity-contracts/deploy/upgradeTest/prepareUpgrade.erc20_gateway_v4.ts b/packages/solidity-contracts/deploy/upgradeTest/prepareUpgrade.erc20_gateway_v4.ts index cbca06dc..a6cf4f88 100644 --- a/packages/solidity-contracts/deploy/upgradeTest/prepareUpgrade.erc20_gateway_v4.ts +++ b/packages/solidity-contracts/deploy/upgradeTest/prepareUpgrade.erc20_gateway_v4.ts @@ -1,8 +1,8 @@ +import type { TransactionResponse } from 'ethers'; import type { HardhatRuntimeEnvironment } from 'hardhat/types'; import type { DeployFunction } from 'hardhat-deploy/dist/types'; import { FuelERC20GatewayV4__factory as FuelERC20Gateway } from '../../typechain'; -import { TransactionResponse } from 'ethers'; const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { const { @@ -25,10 +25,17 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { response.hash ); + const implementation = receipt?.contractAddress ?? ''; + + if (implementation === '') + throw new Error( + `Upgrade proposal failed for FuelERC20GatewayV4 proxy (${contractDeployment.address})` + ); + await save('FuelERC20GatewayV4', { address: contractDeployment.address, abi: [...FuelERC20Gateway.abi], - implementation: receipt?.contractAddress!, + implementation, transactionHash: response.hash, linkedData: { factory: 'FuelERC20GatewayV4', diff --git a/packages/solidity-contracts/deploy/upgradeTest/prepareUpgrade.fuel_message_portal_v3.ts b/packages/solidity-contracts/deploy/upgradeTest/prepareUpgrade.fuel_message_portal_v3.ts index ab67e57e..cb5eed0a 100644 --- a/packages/solidity-contracts/deploy/upgradeTest/prepareUpgrade.fuel_message_portal_v3.ts +++ b/packages/solidity-contracts/deploy/upgradeTest/prepareUpgrade.fuel_message_portal_v3.ts @@ -1,8 +1,8 @@ +import type { TransactionResponse } from 'ethers'; import type { HardhatRuntimeEnvironment } from 'hardhat/types'; import type { DeployFunction } from 'hardhat-deploy/dist/types'; import { FuelMessagePortalV3__factory as FuelMessagePortal } from '../../typechain'; -import { TransactionResponse } from 'ethers'; const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { const { @@ -25,10 +25,17 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { response.hash ); + const implementation = receipt?.contractAddress ?? ''; + + if (implementation === '') + throw new Error( + `Upgrade proposal failed for FuelMessagePortalV3 proxy (${contractDeployment.address})` + ); + await save('FuelMessagePortalV3', { address: contractDeployment.address, abi: [...FuelMessagePortal.abi], - implementation: receipt?.contractAddress!, + implementation, transactionHash: response.hash, linkedData: { factory: 'FuelMessagePortalV3', diff --git a/packages/solidity-contracts/scripts/hardhat/depositETH.ts b/packages/solidity-contracts/scripts/hardhat/depositETH.ts index 8daf4b5e..64a780e8 100644 --- a/packages/solidity-contracts/scripts/hardhat/depositETH.ts +++ b/packages/solidity-contracts/scripts/hardhat/depositETH.ts @@ -2,6 +2,7 @@ import { Wallet, parseEther } from 'ethers'; import type { Signer } from 'ethers'; import { isB256, isBech32, toB256 } from 'fuels'; import { task } from 'hardhat/config'; + import { enterPrivateKey } from './utils'; task('depositETH', 'deposits ETH to Fuel') diff --git a/packages/solidity-contracts/scripts/hardhat/depositMetadata.ts b/packages/solidity-contracts/scripts/hardhat/depositMetadata.ts index 551ebf6e..2d1d6546 100644 --- a/packages/solidity-contracts/scripts/hardhat/depositMetadata.ts +++ b/packages/solidity-contracts/scripts/hardhat/depositMetadata.ts @@ -1,6 +1,7 @@ import { Wallet, hexlify, toBeHex, zeroPadValue } from 'ethers'; import type { Signer } from 'ethers'; import { task } from 'hardhat/config'; + import { enterPrivateKey } from './utils'; task('depositMetadata', 'relays metadata of a token to Fuel') @@ -43,7 +44,7 @@ task('depositMetadata', 'relays metadata of a token to Fuel') const [message] = await portal.queryFilter( portal.filters.MessageSent, - receipt?.blockNumber!, + receipt?.blockNumber, receipt?.blockNumber ); diff --git a/packages/solidity-contracts/scripts/hardhat/depositToken.ts b/packages/solidity-contracts/scripts/hardhat/depositToken.ts index b5a61238..04d6ff05 100644 --- a/packages/solidity-contracts/scripts/hardhat/depositToken.ts +++ b/packages/solidity-contracts/scripts/hardhat/depositToken.ts @@ -1,7 +1,8 @@ -import { Wallet, parseEther, parseUnits } from 'ethers'; +import { Wallet, parseUnits } from 'ethers'; import type { Signer } from 'ethers'; import { isB256, isBech32, toB256 } from 'fuels'; import { task } from 'hardhat/config'; + import { enterPrivateKey } from './utils'; task('depositToken', 'deposits a token to Fuel') diff --git a/packages/solidity-contracts/scripts/hardhat/eventFilter.ts b/packages/solidity-contracts/scripts/hardhat/eventFilter.ts index bf0c4e9b..7669ed8e 100644 --- a/packages/solidity-contracts/scripts/hardhat/eventFilter.ts +++ b/packages/solidity-contracts/scripts/hardhat/eventFilter.ts @@ -1,6 +1,6 @@ -import { task } from 'hardhat/config'; -import { HardhatRuntimeEnvironment } from 'hardhat/types'; import { writeFileSync } from 'fs'; +import { task } from 'hardhat/config'; +import type { HardhatRuntimeEnvironment } from 'hardhat/types'; task( 'grant-role-event-filter', diff --git a/packages/solidity-contracts/scripts/hardhat/resetERC20RateLimit.ts b/packages/solidity-contracts/scripts/hardhat/resetERC20RateLimit.ts index 75f1c237..353e974f 100644 --- a/packages/solidity-contracts/scripts/hardhat/resetERC20RateLimit.ts +++ b/packages/solidity-contracts/scripts/hardhat/resetERC20RateLimit.ts @@ -1,6 +1,7 @@ import { Wallet, parseUnits } from 'ethers'; import type { Signer } from 'ethers'; import { task } from 'hardhat/config'; + import { enterPrivateKey } from './utils'; task('resetERC20RateLimit', 'sets/resets erc20 token rate limit') diff --git a/packages/solidity-contracts/scripts/hardhat/resetETHRateLimit.ts b/packages/solidity-contracts/scripts/hardhat/resetETHRateLimit.ts index ced862f4..385ed11c 100644 --- a/packages/solidity-contracts/scripts/hardhat/resetETHRateLimit.ts +++ b/packages/solidity-contracts/scripts/hardhat/resetETHRateLimit.ts @@ -1,6 +1,7 @@ import { Wallet, parseEther } from 'ethers'; import type { Signer } from 'ethers'; import { task } from 'hardhat/config'; + import { enterPrivateKey } from './utils'; task('resetETHRateLimit', 'resets eth rate limit') diff --git a/packages/solidity-contracts/scripts/hardhat/utils/requireConfirmation.ts b/packages/solidity-contracts/scripts/hardhat/utils/requireConfirmation.ts index 8d03b9c7..1f3f781d 100644 --- a/packages/solidity-contracts/scripts/hardhat/utils/requireConfirmation.ts +++ b/packages/solidity-contracts/scripts/hardhat/utils/requireConfirmation.ts @@ -1,4 +1,3 @@ -import inquirer from 'inquirer'; import { confirm } from '@inquirer/prompts'; export async function requireConfirmation() { diff --git a/packages/solidity-contracts/scripts/hardhat/verifyDeployment.ts b/packages/solidity-contracts/scripts/hardhat/verifyDeployment.ts index ded15647..3341fa01 100644 --- a/packages/solidity-contracts/scripts/hardhat/verifyDeployment.ts +++ b/packages/solidity-contracts/scripts/hardhat/verifyDeployment.ts @@ -1,8 +1,7 @@ -import { task } from 'hardhat/config'; -import { HardhatRuntimeEnvironment } from 'hardhat/types'; -import { config as dotEnvConfig } from 'dotenv'; -import { ContractFactory } from 'ethers'; +import type { ContractFactory } from 'ethers'; import { writeFileSync } from 'fs'; +import { task } from 'hardhat/config'; +import type { HardhatRuntimeEnvironment } from 'hardhat/types'; task('verify-deployment', 'Verifies proxy upgrades').setAction( async (taskArgs: any, hre: HardhatRuntimeEnvironment): Promise => { @@ -66,9 +65,10 @@ task('verify-deployment', 'Verifies proxy upgrades').setAction( deployment.transactionHash! )!; - const receipt = await ethers.provider.getTransactionReceipt( - fetchedDeploymentTx?.hash! - ); + const txHash = fetchedDeploymentTx?.hash ?? ''; + if (txHash === '') throw new Error('Transaction hash not found'); + + const receipt = await ethers.provider.getTransactionReceipt(txHash); // checking for null/undefined value too if ( diff --git a/packages/solidity-contracts/scripts/hardhat/verifyMainnetDeployment.ts b/packages/solidity-contracts/scripts/hardhat/verifyMainnetDeployment.ts index b60594ed..11e14e19 100644 --- a/packages/solidity-contracts/scripts/hardhat/verifyMainnetDeployment.ts +++ b/packages/solidity-contracts/scripts/hardhat/verifyMainnetDeployment.ts @@ -1,6 +1,7 @@ +import type { ContractFactory } from 'ethers'; +import { isAddress } from 'ethers'; import { task } from 'hardhat/config'; -import { HardhatRuntimeEnvironment } from 'hardhat/types'; -import { ContractFactory, isAddress } from 'ethers'; +import type { HardhatRuntimeEnvironment } from 'hardhat/types'; task( 'verify-mainnet-deployments', @@ -78,9 +79,10 @@ task( deployment.transactionHash! )!; - const receipt = await ethers.provider.getTransactionReceipt( - fetchedDeploymentTx?.hash! - ); + const txHash = fetchedDeploymentTx?.hash ?? ''; + if (txHash === '') throw new Error('Transaction hash not found'); + + const receipt = await ethers.provider.getTransactionReceipt(txHash); // checking for null/undefined value too if ( diff --git a/packages/solidity-contracts/scripts/hardhat/withdrawalBlacklist.ts b/packages/solidity-contracts/scripts/hardhat/withdrawalBlacklist.ts index 745f354f..4e369750 100644 --- a/packages/solidity-contracts/scripts/hardhat/withdrawalBlacklist.ts +++ b/packages/solidity-contracts/scripts/hardhat/withdrawalBlacklist.ts @@ -1,6 +1,7 @@ import { Wallet, getBytes } from 'ethers'; import type { Signer } from 'ethers'; import { task } from 'hardhat/config'; + import { enterPrivateKey } from './utils'; task('withdrawalBlacklist', 'blacklists a l2 -> l1 message') diff --git a/packages/solidity-contracts/scripts/hardhat/withdrawalPause.ts b/packages/solidity-contracts/scripts/hardhat/withdrawalPause.ts index 072bddac..afff262d 100644 --- a/packages/solidity-contracts/scripts/hardhat/withdrawalPause.ts +++ b/packages/solidity-contracts/scripts/hardhat/withdrawalPause.ts @@ -1,6 +1,7 @@ import { Wallet } from 'ethers'; import type { Signer } from 'ethers'; import { task } from 'hardhat/config'; + import { enterPrivateKey } from './utils'; task('withdrawalPause', 'pauses all l2 > l1 messages') diff --git a/packages/solidity-contracts/scripts/hardhat/withdrawalResume.ts b/packages/solidity-contracts/scripts/hardhat/withdrawalResume.ts index a6e74938..007f802b 100644 --- a/packages/solidity-contracts/scripts/hardhat/withdrawalResume.ts +++ b/packages/solidity-contracts/scripts/hardhat/withdrawalResume.ts @@ -1,6 +1,7 @@ import { Wallet } from 'ethers'; import type { Signer } from 'ethers'; import { task } from 'hardhat/config'; + import { enterPrivateKey } from './utils'; task('withdrawalResume', 'unpauses l2 > l1 messages') diff --git a/packages/solidity-contracts/scripts/hardhat/withdrawalWhitelist.ts b/packages/solidity-contracts/scripts/hardhat/withdrawalWhitelist.ts index 3032daad..f21b576d 100644 --- a/packages/solidity-contracts/scripts/hardhat/withdrawalWhitelist.ts +++ b/packages/solidity-contracts/scripts/hardhat/withdrawalWhitelist.ts @@ -1,6 +1,7 @@ import { Wallet, getBytes } from 'ethers'; import type { Signer } from 'ethers'; import { task } from 'hardhat/config'; + import { enterPrivateKey } from './utils'; task('withdrawalWhitelist', 'removes blacklist from a l2 > l1 message') diff --git a/packages/solidity-contracts/test/behaviors/erc20GatewayV4.behavior.test.ts b/packages/solidity-contracts/test/behaviors/erc20GatewayV4.behavior.test.ts index 0cc6dab8..678f35d2 100644 --- a/packages/solidity-contracts/test/behaviors/erc20GatewayV4.behavior.test.ts +++ b/packages/solidity-contracts/test/behaviors/erc20GatewayV4.behavior.test.ts @@ -24,7 +24,6 @@ import { randomAddress, randomBytes32 } from '../../protocol/utils'; import { CustomToken__factory, NoDecimalsToken__factory, - MockPermitToken, } from '../../typechain'; import type { MockFuelMessagePortal, @@ -32,6 +31,7 @@ import type { Token, CustomToken, NoDecimalsToken, + MockPermitToken, } from '../../typechain'; import { impersonateAccount } from '../utils/impersonateAccount'; @@ -1262,7 +1262,7 @@ export function behavesLikeErc20GatewayV4(fixture: () => Promise) { it('emits event when rate limit is set', async () => { const { erc20Gateway, - signers: [deployer, user], + signers: [deployer], } = env; const rateLimitAmount = @@ -1557,7 +1557,7 @@ export function behavesLikeErc20GatewayV4(fixture: () => Promise) { RATE_LIMIT_DURATION * 2, ]); - let rateLimitAmount = + const rateLimitAmount = RATE_LIMIT_AMOUNT / 10 ** (STANDARD_TOKEN_DECIMALS - decimals); await erc20Gateway diff --git a/packages/solidity-contracts/test/erc20GatewayV4.test.ts b/packages/solidity-contracts/test/erc20GatewayV4.test.ts index d0400ebe..f590c0e7 100644 --- a/packages/solidity-contracts/test/erc20GatewayV4.test.ts +++ b/packages/solidity-contracts/test/erc20GatewayV4.test.ts @@ -1,7 +1,6 @@ import { zeroPadValue } from 'ethers'; import hre, { deployments } from 'hardhat'; -import { RATE_LIMIT_AMOUNT, RATE_LIMIT_DURATION } from '../protocol/constants'; import { randomBytes32 } from '../protocol/utils'; import { FuelERC20GatewayV4__factory, diff --git a/packages/solidity-contracts/test/erc721Gateway.test.ts b/packages/solidity-contracts/test/erc721Gateway.test.ts index 1b6f2725..c9de32d8 100644 --- a/packages/solidity-contracts/test/erc721Gateway.test.ts +++ b/packages/solidity-contracts/test/erc721Gateway.test.ts @@ -32,7 +32,6 @@ import { TIME_TO_FINALIZE, COMMIT_COOLDOWN, } from './utils'; - import { createBlock } from './utils/createBlock'; const { expect } = chai; diff --git a/packages/solidity-contracts/test/messagesIncomingV3.test.ts b/packages/solidity-contracts/test/messagesIncomingV3.test.ts index 21ef22d2..52349568 100644 --- a/packages/solidity-contracts/test/messagesIncomingV3.test.ts +++ b/packages/solidity-contracts/test/messagesIncomingV3.test.ts @@ -17,6 +17,7 @@ import { computeBlockId, generateBlockHeaderLite, } from '../protocol/blockHeader'; +import { RATE_LIMIT_AMOUNT, RATE_LIMIT_DURATION } from '../protocol/constants'; import Message, { computeMessageId } from '../protocol/message'; import { randomBytes32, tai64Time } from '../protocol/utils'; import type { @@ -37,8 +38,6 @@ import { getLeafIndexKey, } from './utils/merkle'; -import { RATE_LIMIT_AMOUNT, RATE_LIMIT_DURATION } from '../protocol/constants'; - const ETH_DECIMALS = 18n; const FUEL_BASE_ASSET_DECIMALS = 9n; const BASE_ASSET_CONVERSION = 10n ** (ETH_DECIMALS - FUEL_BASE_ASSET_DECIMALS); diff --git a/packages/solidity-contracts/test/messagesOutgoingV2.test.ts b/packages/solidity-contracts/test/messagesOutgoingV2.test.ts index 8384d442..ded0ff36 100644 --- a/packages/solidity-contracts/test/messagesOutgoingV2.test.ts +++ b/packages/solidity-contracts/test/messagesOutgoingV2.test.ts @@ -24,7 +24,6 @@ import { COMMIT_COOLDOWN, TIME_TO_FINALIZE, } from './utils'; - import { addressToB256 } from './utils/addressConversion'; const { expect } = chai; diff --git a/packages/solidity-contracts/test/upgrade.ts b/packages/solidity-contracts/test/upgrade.ts index 927354d0..048d807f 100644 --- a/packages/solidity-contracts/test/upgrade.ts +++ b/packages/solidity-contracts/test/upgrade.ts @@ -5,7 +5,6 @@ import type { DeployedContractAddresses, HarnessObject, } from '../protocol/harness'; - import { setupFuel, upgradeFuel } from '../protocol/harness'; import type { UpgradeableTester } from '../typechain'; diff --git a/packages/solidity-contracts/test/utils/deployProxy.ts b/packages/solidity-contracts/test/utils/deployProxy.ts index 4de1e741..2aaefc21 100644 --- a/packages/solidity-contracts/test/utils/deployProxy.ts +++ b/packages/solidity-contracts/test/utils/deployProxy.ts @@ -7,7 +7,7 @@ import type { Signer, } from 'ethers'; -interface ConstructorWithStatic extends Function { +interface ConstructorWithStatic { new (signer: Signer): T; // Instance type connect: (address: string, runner?: ContractRunner | null) => K; } diff --git a/packages/test-utils/src/scripts/check-balances.ts b/packages/test-utils/src/scripts/check-balances.ts index 25919ff0..e04df958 100644 --- a/packages/test-utils/src/scripts/check-balances.ts +++ b/packages/test-utils/src/scripts/check-balances.ts @@ -5,7 +5,8 @@ import { password } from '@inquirer/prompts'; import { Provider, WalletUnlocked } from 'fuels'; -let { L2_ADDRESS, L2_RPC } = process.env; +let { L2_ADDRESS } = process.env; +const { L2_RPC } = process.env; const main = async () => { const provider = await Provider.create(L2_RPC, { resourceCacheTTL: -1 }); diff --git a/packages/test-utils/src/scripts/check-nonce.ts b/packages/test-utils/src/scripts/check-nonce.ts index 3cb78f12..c6a8175a 100644 --- a/packages/test-utils/src/scripts/check-nonce.ts +++ b/packages/test-utils/src/scripts/check-nonce.ts @@ -2,9 +2,10 @@ * This is a stand-alone script that looks for a message nonce */ -import { BN, Message, Provider } from 'fuels'; +import type { Message } from 'fuels'; +import { BN, Provider } from 'fuels'; -let { L2_RPC, L2_MESSAGE_NONCE } = process.env; +const { L2_RPC, L2_MESSAGE_NONCE } = process.env; const main = async () => { if (!L2_MESSAGE_NONCE) { diff --git a/packages/test-utils/src/scripts/check-proxy-data.ts b/packages/test-utils/src/scripts/check-proxy-data.ts index 727d709b..eb6cc5e5 100644 --- a/packages/test-utils/src/scripts/check-proxy-data.ts +++ b/packages/test-utils/src/scripts/check-proxy-data.ts @@ -4,11 +4,9 @@ */ import { Proxy } from '@fuel-bridge/fungible-token'; - import { Provider } from 'fuels'; -let { L2_RPC, L2_BRIDGE_ID } = process.env; -const L1_LLAMA_RPC = 'https://eth.llamarpc.com'; +const { L2_RPC, L2_BRIDGE_ID } = process.env; const main = async () => { const fuel_provider = await Provider.create(L2_RPC, { resourceCacheTTL: -1 }); diff --git a/packages/test-utils/src/scripts/deploy-bridge.ts b/packages/test-utils/src/scripts/deploy-bridge.ts index e7bb6e68..80f7e2a3 100644 --- a/packages/test-utils/src/scripts/deploy-bridge.ts +++ b/packages/test-utils/src/scripts/deploy-bridge.ts @@ -8,17 +8,12 @@ import { BridgeFungibleTokenFactory, ProxyFactory, } from '@fuel-bridge/fungible-token'; - -import { - DeployContractResult, - Provider, - Wallet, - WalletUnlocked, - ZeroBytes32, -} from 'fuels'; import { password } from '@inquirer/prompts'; +import type { DeployContractResult, WalletUnlocked } from 'fuels'; +import { Provider, Wallet, ZeroBytes32 } from 'fuels'; -let { L1_TOKEN_GATEWAY, L2_SIGNER, L2_RPC } = process.env; +let { L2_SIGNER } = process.env; +const { L1_TOKEN_GATEWAY, L2_RPC } = process.env; // This helper avoids an exception in the case that the contract // was already deployed, and returns the contract instead diff --git a/packages/test-utils/src/scripts/deposit-to-coin.ts b/packages/test-utils/src/scripts/deposit-to-coin.ts index 8ad1b84c..d7d9f2fd 100644 --- a/packages/test-utils/src/scripts/deposit-to-coin.ts +++ b/packages/test-utils/src/scripts/deposit-to-coin.ts @@ -3,10 +3,11 @@ * to convert a message coin into a coin utxo */ -import { Provider, TransactionStatus, Wallet } from 'fuels'; import { password } from '@inquirer/prompts'; +import { Provider, TransactionStatus, Wallet } from 'fuels'; -let { L2_SIGNER, L2_RPC } = process.env; +let { L2_SIGNER } = process.env; +const { L2_RPC } = process.env; const main = async () => { if (!L2_RPC) { diff --git a/packages/test-utils/src/scripts/relay-deposit.ts b/packages/test-utils/src/scripts/relay-deposit.ts index 7c8e4ac3..dd087dee 100644 --- a/packages/test-utils/src/scripts/relay-deposit.ts +++ b/packages/test-utils/src/scripts/relay-deposit.ts @@ -4,9 +4,8 @@ */ import { Proxy } from '@fuel-bridge/fungible-token'; - import { contractMessagePredicate } from '@fuel-bridge/message-predicates'; - +import { password } from '@inquirer/prompts'; import { Account, BN, @@ -16,7 +15,7 @@ import { getPredicateRoot, hexlify, } from 'fuels'; -import { password } from '@inquirer/prompts'; + import { FUEL_MESSAGE_TIMEOUT_MS, debug, @@ -26,7 +25,9 @@ import { const TOKEN_RECIPIENT_DATA_OFFSET = 160; -let { L2_SIGNER, L2_RPC, L2_BRIDGE_ID, L2_MESSAGE_NONCE, L2_TOKEN_RECEIVER } = +let { L2_SIGNER } = process.env; + +const { L2_RPC, L2_BRIDGE_ID, L2_MESSAGE_NONCE, L2_TOKEN_RECEIVER } = process.env; const main = async () => { @@ -45,7 +46,7 @@ const main = async () => { console.log('\t> Balance: ', (await wallet.getBalance()).toString()); debug('Detecting if the bridge is a proxy...'); - let implementation_id: string | null = await proxy.functions + const implementation_id: string | null = await proxy.functions .proxy_target() .dryRun() .then((result) => { @@ -63,7 +64,9 @@ const main = async () => { let endCursor: string | undefined; if (L2_MESSAGE_NONCE) nonce = new BN(L2_MESSAGE_NONCE); + else + // eslint-disable-next-line no-constant-condition while (true) { const response = await provider.getMessages(predicateRoot, { after: endCursor, diff --git a/packages/test-utils/src/scripts/relay-metadata.ts b/packages/test-utils/src/scripts/relay-metadata.ts index 28ebce29..92a38ec3 100644 --- a/packages/test-utils/src/scripts/relay-metadata.ts +++ b/packages/test-utils/src/scripts/relay-metadata.ts @@ -4,9 +4,8 @@ */ import { Proxy } from '@fuel-bridge/fungible-token'; - import { contractMessagePredicate } from '@fuel-bridge/message-predicates'; - +import { password } from '@inquirer/prompts'; import { Account, BN, @@ -15,7 +14,7 @@ import { Wallet, getPredicateRoot, } from 'fuels'; -import { password } from '@inquirer/prompts'; + import { FUEL_MESSAGE_TIMEOUT_MS, debug, @@ -23,7 +22,8 @@ import { waitForMessage, } from '../utils'; -let { L2_SIGNER, L2_RPC, L2_BRIDGE_ID, L2_MESSAGE_NONCE } = process.env; +let { L2_SIGNER } = process.env; +const { L2_RPC, L2_BRIDGE_ID, L2_MESSAGE_NONCE } = process.env; const main = async () => { if (!L2_RPC) { @@ -51,7 +51,7 @@ const main = async () => { console.log('\t> Balance: ', (await wallet.getBalance()).toString()); debug('Detecting if the bridge is a proxy...'); - let implementation_id: string | null = await proxy.functions + const implementation_id: string | null = await proxy.functions .proxy_target() .dryRun() .then((result) => { diff --git a/packages/test-utils/src/scripts/transfer-bridge-ownership.ts b/packages/test-utils/src/scripts/transfer-bridge-ownership.ts index b6668be9..c5767fe1 100644 --- a/packages/test-utils/src/scripts/transfer-bridge-ownership.ts +++ b/packages/test-utils/src/scripts/transfer-bridge-ownership.ts @@ -4,12 +4,13 @@ */ import { Proxy } from '@fuel-bridge/fungible-token'; - -import { Provider, Wallet } from 'fuels'; import { password } from '@inquirer/prompts'; +import { Provider, Wallet } from 'fuels'; + import { debug } from '../utils'; -let { L2_SIGNER, L2_RPC, L2_BRIDGE_ID, L2_NEW_OWNER } = process.env; +let { L2_SIGNER } = process.env; +const { L2_RPC, L2_BRIDGE_ID, L2_NEW_OWNER } = process.env; const main = async () => { const provider = await Provider.create(L2_RPC, { resourceCacheTTL: -1 }); @@ -27,7 +28,7 @@ const main = async () => { console.log('\t> Balance: ', (await wallet.getBalance()).toString()); debug('Detecting if the bridge is a proxy...'); - let owner: string | null = await proxy.functions + const owner: string | null = await proxy.functions ._proxy_owner() .dryRun() .then((result) => { diff --git a/packages/test-utils/src/scripts/upgrade-bridge-kms.ts b/packages/test-utils/src/scripts/upgrade-bridge-kms.ts index a64b2a87..4be5a128 100644 --- a/packages/test-utils/src/scripts/upgrade-bridge-kms.ts +++ b/packages/test-utils/src/scripts/upgrade-bridge-kms.ts @@ -8,13 +8,14 @@ import { BridgeFungibleToken, } from '@fuel-bridge/fungible-token'; import { KMSAccount } from '@fuels/kms-account'; - -import { Provider, TransactionStatus, getRandomB256 } from 'fuels'; import { password } from '@inquirer/prompts'; +import { Provider, TransactionStatus, getRandomB256 } from 'fuels'; + import { debug } from '../utils'; -let { L1_TOKEN_GATEWAY, L2_SIGNER, L2_RPC, L2_BRIDGE_ID, KMS_KEY_ID } = - process.env; +let { L2_SIGNER } = process.env; + +const { L2_RPC, L2_BRIDGE_ID, KMS_KEY_ID, L1_TOKEN_GATEWAY } = process.env; const main = async () => { const provider = await Provider.create(L2_RPC!, { resourceCacheTTL: -1 }); @@ -32,7 +33,7 @@ const main = async () => { console.log('\t> Balance: ', (await kms_wallet.getBalance()).toString()); debug('Detecting if the bridge is a proxy: implementation'); - let current_implementation: string = await proxy.functions + const current_implementation: string = await proxy.functions .proxy_target() .dryRun() .then((result) => { @@ -50,7 +51,7 @@ const main = async () => { debug(`Current implementation at ${current_implementation}`); debug('Detecting if the bridge is a proxy: owner'); - let owner: string | null = await proxy.functions + const owner: string | null = await proxy.functions ._proxy_owner() .dryRun() .then((result) => { diff --git a/packages/test-utils/src/scripts/upgrade-bridge.ts b/packages/test-utils/src/scripts/upgrade-bridge.ts index 1c528b37..383a0cff 100644 --- a/packages/test-utils/src/scripts/upgrade-bridge.ts +++ b/packages/test-utils/src/scripts/upgrade-bridge.ts @@ -7,12 +7,14 @@ import { BridgeFungibleTokenFactory, BridgeFungibleToken, } from '@fuel-bridge/fungible-token'; - -import { Provider, TransactionStatus, Wallet, ZeroBytes32 } from 'fuels'; import { password } from '@inquirer/prompts'; +import { Provider, TransactionStatus, Wallet, ZeroBytes32 } from 'fuels'; + import { debug } from '../utils'; -let { L1_TOKEN_GATEWAY, L2_SIGNER, L2_RPC, L2_BRIDGE_ID } = process.env; +let { L2_SIGNER } = process.env; + +const { L2_RPC, L2_BRIDGE_ID, L1_TOKEN_GATEWAY } = process.env; const main = async () => { const provider = await Provider.create(L2_RPC!, { resourceCacheTTL: -1 }); @@ -28,7 +30,7 @@ const main = async () => { console.log('\t> Balance: ', (await wallet.getBalance()).toString()); debug('Detecting if the bridge is a proxy: implementation'); - let current_implementation: string = await proxy.functions + const current_implementation: string = await proxy.functions .proxy_target() .dryRun() .then((result) => { @@ -46,7 +48,7 @@ const main = async () => { debug(`Current implementation at ${current_implementation}`); debug('Detecting if the bridge is a proxy: owner'); - let owner: string | null = await proxy.functions + const owner: string | null = await proxy.functions ._proxy_owner() .dryRun() .then((result) => { diff --git a/packages/test-utils/src/scripts/verify-asset-metadata.ts b/packages/test-utils/src/scripts/verify-asset-metadata.ts index edd5f8d8..e5d98866 100644 --- a/packages/test-utils/src/scripts/verify-asset-metadata.ts +++ b/packages/test-utils/src/scripts/verify-asset-metadata.ts @@ -5,14 +5,17 @@ */ import { BridgeFungibleToken, Proxy } from '@fuel-bridge/fungible-token'; +import { IERC20Metadata__factory } from '@fuel-bridge/solidity-contracts/typechain'; +import { JsonRpcProvider, isAddress } from 'ethers'; +import type { FuelError } from 'fuels'; +import { Provider, isB256 } from 'fuels'; -import { FuelError, Provider, isB256 } from 'fuels'; import { debug, getTokenId } from '../utils'; -import { JsonRpcProvider, isAddress } from 'ethers'; -import { IERC20Metadata__factory } from '@fuel-bridge/solidity-contracts/typechain'; -let { L1_RPC, L2_RPC, L2_BRIDGE_ID, L2_ASSET_ID, L1_TOKEN_ADDRESS } = - process.env; +let { L2_ASSET_ID } = process.env; + +const { L1_RPC, L2_RPC, L2_BRIDGE_ID, L1_TOKEN_ADDRESS } = process.env; + const L1_LLAMA_RPC = 'https://eth.llamarpc.com'; const main = async () => { const fuel_provider = await Provider.create(L2_RPC, { resourceCacheTTL: -1 }); @@ -31,7 +34,7 @@ const main = async () => { console.log('\t> Checking asset metadata...'); debug('Detecting if the bridge is a proxy...'); - let implementation_id: string | null = await proxy.functions + await proxy.functions .proxy_target() .dryRun() .then((result) => { @@ -64,7 +67,7 @@ const main = async () => { return; } - let l1_token_address = '0x' + (call_result.value as string).slice(-40); + const l1_token_address = '0x' + (call_result.value as string).slice(-40); console.log('l1_token_address', `${l1_token_address}`); const fuel_symbol = (await bridge.functions.symbol(asset).dryRun()).value; diff --git a/packages/test-utils/src/scripts/withdraw-init.ts b/packages/test-utils/src/scripts/withdraw-init.ts index bec5fa42..20467015 100644 --- a/packages/test-utils/src/scripts/withdraw-init.ts +++ b/packages/test-utils/src/scripts/withdraw-init.ts @@ -4,27 +4,17 @@ */ import { BridgeFungibleToken, Proxy } from '@fuel-bridge/fungible-token'; - -import { - AbstractContract, - BN, - Provider, - TransactionStatus, - Wallet, - isB256, -} from 'fuels'; -import { isAddress, parseUnits } from 'ethers'; import { password } from '@inquirer/prompts'; +import { isAddress, parseUnits } from 'ethers'; +import type { AbstractContract } from 'fuels'; +import { BN, Provider, TransactionStatus, Wallet, isB256 } from 'fuels'; + import { debug, eth_address_to_b256 } from '../utils'; -let { - L2_SIGNER, - L2_RPC, - L2_BRIDGE_ID, - L2_ASSET_ID, - AMOUNT, - L1_TOKEN_RECEIVER, -} = process.env; +let { L2_SIGNER } = process.env; + +const { L2_ASSET_ID, L2_RPC, L2_BRIDGE_ID, AMOUNT, L1_TOKEN_RECEIVER } = + process.env; const main = async () => { const provider = await Provider.create(L2_RPC, { resourceCacheTTL: -1 }); @@ -52,7 +42,7 @@ const main = async () => { console.log('\t> Balance: ', (await wallet.getBalance()).toString()); debug('Detecting if the bridge is a proxy...'); - let implementation_id: string | null = await proxy.functions + const implementation_id: string | null = await proxy.functions .proxy_target() .dryRun() .then((result) => { diff --git a/packages/test-utils/src/utils/fuels/waitForBlock.ts b/packages/test-utils/src/utils/fuels/waitForBlock.ts index bb45c449..a720402a 100644 --- a/packages/test-utils/src/utils/fuels/waitForBlock.ts +++ b/packages/test-utils/src/utils/fuels/waitForBlock.ts @@ -1,4 +1,4 @@ -import { type Provider as FuelProvider, type BigNumberish, BN } from 'fuels'; +import { type Provider as FuelProvider, type BigNumberish } from 'fuels'; export async function waitForBlock( blockNumber: BigNumberish, diff --git a/packages/test-utils/src/utils/fuels/waitForMessage.ts b/packages/test-utils/src/utils/fuels/waitForMessage.ts index 6bf987e1..99b5af04 100644 --- a/packages/test-utils/src/utils/fuels/waitForMessage.ts +++ b/packages/test-utils/src/utils/fuels/waitForMessage.ts @@ -1,12 +1,7 @@ /// @dev The Fuel testing utils. /// A set of useful helper methods for the integration test environment. -import { - type Provider as FuelProvider, - type Message, - BN, - AbstractAddress, - hexlify, -} from 'fuels'; +import type { BN, AbstractAddress } from 'fuels'; +import { type Provider as FuelProvider, type Message, hexlify } from 'fuels'; import { FUEL_MESSAGE_POLL_MS } from '../constants'; import { delay } from '../delay'; diff --git a/packages/test-utils/src/utils/setup.ts b/packages/test-utils/src/utils/setup.ts index 7ce57778..35640936 100644 --- a/packages/test-utils/src/utils/setup.ts +++ b/packages/test-utils/src/utils/setup.ts @@ -13,7 +13,7 @@ import { FuelERC721Gateway__factory, } from '@fuel-bridge/solidity-contracts/typechain'; import * as dotenv from 'dotenv'; -import type { Signer as EthSigner, Provider as EthProvider } from 'ethers'; +import type { Signer as EthSigner } from 'ethers'; import { JsonRpcProvider, ethers, diff --git a/scripts/check.sh b/scripts/check.sh index 5dc1fd71..f2f4be9b 100644 --- a/scripts/check.sh +++ b/scripts/check.sh @@ -5,3 +5,5 @@ cargo fmt --check pnpm forc build --release cargo clippy --all-features --all-targets -- -D warnings pnpm prettier:check +pnpm lint:check +