Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add TS linting check in CI #350

Merged
merged 11 commits into from
Oct 28, 2024
6 changes: 6 additions & 0 deletions .changeset/small-singers-attend.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@fuel-bridge/solidity-contracts': patch
'@fuel-bridge/test-utils': patch
---

ts linting for test packages
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
**/typechain/
docker/l1-chain/hardhat
dist
**/exports/
2 changes: 1 addition & 1 deletion packages/integration-tests/tests/bridge_erc20.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
36 changes: 13 additions & 23 deletions packages/integration-tests/tests/bridge_mainnet_tokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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({
Expand Down Expand Up @@ -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;
Expand All @@ -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];
Expand Down Expand Up @@ -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;
});
Expand All @@ -315,15 +305,15 @@ 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,
FUEL_MESSAGE_TIMEOUT_MS
);
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()],
Expand Down
2 changes: 1 addition & 1 deletion packages/integration-tests/tests/bridge_proxy.ts
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
9 changes: 5 additions & 4 deletions packages/integration-tests/tests/transfer_eth.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { TestEnvironment } from '@fuel-bridge/test-utils';
import {
TestEnvironment,
setupEnvironment,
fuels_parseEther,
createRelayMessageParams,
Expand All @@ -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,
Expand Down Expand Up @@ -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()}`);
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { HardhatRuntimeEnvironment } from 'hardhat/types';
import type { DeployFunction } from 'hardhat-deploy/dist/types';

import {
USDT_ADDRESS,
USDC_ADDRESS,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
@@ -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';

Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -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', {
Expand Down
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -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', {
Expand Down
Original file line number Diff line number Diff line change
@@ -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',
Expand Down
Original file line number Diff line number Diff line change
@@ -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',
Expand Down
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -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,
Expand Down
Loading
Loading