Skip to content

Commit 1ec4ddb

Browse files
authored
Merge pull request #16 from smartcontractkit/zp-1.6evm
Fix CI build errors for ccip-js package
2 parents 3791eb4 + 6fe0e62 commit 1ec4ddb

File tree

12 files changed

+55
-43
lines changed

12 files changed

+55
-43
lines changed

.github/workflows/publish.yaml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,17 @@ jobs:
1414
runs-on: ubuntu-latest
1515
environment: publish
1616
permissions:
17-
contents: read
17+
contents: read
1818
steps:
1919
- name: Checkout the repo
2020
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
2121
with:
2222
fetch-depth: 0
2323

24-
- name: Setup Node 18.x
24+
- name: Setup Node 20.x
2525
uses: actions/setup-node@v3
2626
with:
27-
node-version: 18.12
27+
node-version: 20.19
2828
always-auth: true
2929

3030
- name: Install PNPM
@@ -56,17 +56,17 @@ jobs:
5656
if: github.ref_name != 'main'
5757
runs-on: ubuntu-latest
5858
permissions:
59-
contents: read
59+
contents: read
6060
steps:
6161
- name: Checkout the repo
6262
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
6363
with:
6464
fetch-depth: 0
6565

66-
- name: Setup Node 18.x
66+
- name: Setup Node 20.x
6767
uses: actions/setup-node@v3
6868
with:
69-
node-version: 18.12
69+
node-version: 20.19
7070
always-auth: true
7171

7272
- name: Install PNPM
@@ -90,4 +90,4 @@ jobs:
9090
pnpm build-components
9191
cd packages/ccip-react-components
9292
pnpm publish --no-git-checks --access public --dry-run
93-
shell: bash
93+
shell: bash

packages/ccip-js/README.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -591,7 +591,7 @@ Retrieves the transaction receipt based on the transaction hash. Returns a promi
591591
getTransactionReceipt(options: { client: Viem.Client; hash: Viem.Hash }): Promise<Viem.TransactionReceipt>
592592
```
593593

594-
### Development
594+
### Development (For developing this CCIP-JS package locally)
595595

596596
#### Build
597597

@@ -600,14 +600,21 @@ pnpm i -w
600600
pnpm build-ccip-js
601601
```
602602

603+
Note that when the above `build-ccip-js` step is run, the contracts located in `./src/contracts` are compiled and ABIs and artifacts are emitted into the `../ccip-js/artifacts`
604+
folder. From there, the relevant ABI arrays must be manually moved to `./src/abi` , and just the ABI array is pasted into the corresponding file in `./src/abi`. However the files in `./artifacts-compile` contain objects with both the abi and the bytecode and are used in the unit test files with Viem's test clients.
605+
603606
#### Running tests
604607

605608
1. cd into `packages/ccip-js` and then run `pnpm install` OR from the project root you can run `pnpm i -w`
606609

607610
2. open a new terminal window and run `foundryup` followed by `anvil` - requires that you've [installed Foundry Anvil](https://book.getfoundry.sh/anvil/).
608611
<b?>Note:</b> that Anvil is only needed for the integrations tests inside `./test` which uses the [Chainlink Local](https://github.com/smartcontractkit/chainlink-local) simulator. Actual testnet and mainnet behavior may differ from time to time and passing these tests does not guarantee testnet or mainnet behavior.
609612

610-
3. Back in the first terminal, inside, `packages/ccip-js` run `pnpm t:int` or `pnpm t:uint`. Note some tests are flaky - this is under investigation. You can choose to run just the mocked test or the testnet integration tests using `pnpm jest <<name of test file>>`.
613+
3. Back in the first terminal, inside, `packages/ccip-js` run `export PRIVATE_KEY=xxxxxx` to set your private key and then run `pnpm t:int` or `pnpm t:uint`.
614+
615+
Note some tests are flaky - this is under investigation. You can choose to run just the mocked test or the testnet integration tests using `pnpm jest <<name of test file>>`.
616+
617+
Note further that we have set a 180000ms (3 mins) timeout on the jest config. This can cause the testnet integration test to "hang" for the entire duration.
611618

612619
### Contributing
613620

packages/ccip-js/hardhat.config.cjs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
require("@nomicfoundation/hardhat-toolbox");
2-
require("@nomicfoundation/hardhat-ethers");
3-
require("@nomicfoundation/hardhat-viem");
1+
require('@nomicfoundation/hardhat-toolbox')
2+
require('@nomicfoundation/hardhat-ethers')
3+
require('@nomicfoundation/hardhat-viem')
44

5-
require("chai");
6-
require("mocha");
7-
require("ethers");
5+
require('chai')
6+
require('mocha')
7+
require('ethers')
88
/** @type import('hardhat/config').HardhatUserConfig */
99
module.exports = {
10-
solidity: "0.8.24",
10+
solidity: '0.8.24',
1111
solc: {
12-
version: "0.8.24",
12+
version: '0.8.24',
1313
},
1414
paths: {
15-
sources: "src/contracts",
16-
tests: "./test",
17-
cache: "./cache",
18-
artifacts: "./artifacts",
15+
sources: 'src/contracts',
16+
tests: './test',
17+
cache: './cache',
18+
artifacts: './artifacts',
1919
},
20-
};
20+
}

packages/ccip-js/jest.config.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
/** @type {import('ts-jest').JestConfigWithTsJest} **/
22
export default {
3-
testEnvironment: 'node',
4-
transform: {
5-
'^.+.tsx?$': ['ts-jest', {}],
6-
},
7-
workerThreads: true,
8-
};
3+
testEnvironment: 'node',
4+
transform: {
5+
'^.+.tsx?$': ['ts-jest', {}],
6+
},
7+
workerThreads: true,
8+
testTimeout: 180000,
9+
}

packages/ccip-js/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"lint": "eslint 'src/**/*.{ts,js}'",
1616
"format": "prettier --write 'src/**/*.{ts,js,json,md}'",
1717
"t:int": "jest --coverage -u --testMatch=\"**/integration-testnet.test.ts\" --detectOpenHandles",
18-
"t:unit": "jest --coverage -u -t=\"Unit\"",
18+
"t:unit": "jest --coverage -u --testMatch=\"**/unit.test.ts\" ",
1919
"test:hh": "hardhat test"
2020
},
2121
"devDependencies": {

packages/ccip-js/src/api.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ import OnRampABI from './abi/OnRamp.json'
1414
import OnRampABI_1_6 from './abi/OnRamp_1_6.json'
1515
import IERC20ABI from './abi/IERC20Metadata.json'
1616
import TokenPoolABI from './abi/TokenPool.json'
17-
import PriceRegistryABI from './abi/PriceRegistry.json'
18-
import FeeQuoterABI from './abi/FeeQuoter.json'
1917
import TokenAdminRegistryABI from './abi/TokenAdminRegistry.json'
2018
import { TRANSFER_STATUS_FROM_BLOCK_SHIFT, ExecutionStateChangedABI } from './config'
2119
import { parseAbi } from 'viem'

packages/ccip-js/src/contracts/FeeQuoter.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {EnumerableSet} from '@openzeppelin/contracts/utils/structs/EnumerableSet
1111

1212
/// @notice The FeeQuoter contract responsibility is to store the current gas price in USD for a given destination chain,
1313
/// and the price of a token in USD allowing the owner or priceUpdater to update this value.
14-
contract FeeQuoter is IFeeQuoter, OwnerIsCreator {
14+
abstract contract FeeQuoter is IFeeQuoter, OwnerIsCreator {
1515
using EnumerableSet for EnumerableSet.AddressSet;
1616
using USDPriceWith18Decimals for uint224;
1717

@@ -124,7 +124,7 @@ contract FeeQuoter is IFeeQuoter, OwnerIsCreator {
124124
return (_getValidatedTokenPrice(feeToken), gasPrice.value);
125125
}
126126

127-
/// @inheritdoc IFeeQuoter
127+
128128
/// @dev this function assumed that no more than 1e59 dollar, is sent as payment.
129129
/// If more is sent, the multiplication of feeTokenAmount and feeTokenValue will overflow.
130130
/// Since there isn't even close to 1e59 dollars in the world economy this is safe.

packages/ccip-js/test/helpers/constants.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { Address, Hash, Hex, TransactionReceipt } from 'viem'
22
import { privateKeyToAccount } from 'viem/accounts'
33
import dotenv from 'dotenv'
4+
45
import bridgeJson from '../../artifacts-compile/BridgeToken.json'
56
import onRampJson from '../../artifacts-compile/EVM2EVMOnRamp.json'
67
import routerJson from '../../artifacts-compile/Router.json'
@@ -15,7 +16,8 @@ if (process.env.PRIVATE_KEY?.slice(0, 2) !== '0x') {
1516
process.env.PRIVATE_KEY = `0x${process.env.PRIVATE_KEY}`
1617
}
1718

18-
export const DEFAULT_ANVIL_PRIVATE_KEY = '0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80'
19+
export const DEFAULT_ANVIL_PRIVATE_KEY =
20+
'0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80' as Hex
1921
export const account = privateKeyToAccount(DEFAULT_ANVIL_PRIVATE_KEY)
2022

2123
// bridge token contract

packages/ccip-js/test/helpers/contracts.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { formatEther, getContract, type Address, type Hex } from 'viem'
1+
import { getContract, type Address, type Hex } from 'viem'
22
import {
33
account,
44
bridgeTokenAbi,

packages/ccip-js/test/integration-testnet.test.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { jest, expect, it, beforeAll, describe, afterAll } from '@jest/globals'
1+
import { expect, it, afterAll, beforeAll, describe } from '@jest/globals'
22
import * as CCIP from '../src/api'
33
import * as Viem from 'viem'
44
import { sepolia, avalancheFuji } from 'viem/chains'
@@ -18,23 +18,23 @@ const LINK_TOKEN_FUJI = '0x0b9d5D9136855f6FEc3c0993feE6E9CE8a297846'
1818
// 6m to match https://viem.sh/docs/actions/public/waitForTransactionReceipt.html#timeout-optional,
1919
// which is called in approveRouter()
2020
// TODO @zeuslawyer: https://prajjwaldimri.medium.com/why-is-my-jest-runner-not-closing-bc4f6632c959 - tests are passing but jest is not closing. Viem transport issue? why?
21-
const TIMEOUT = 180 * 1000 // 3m
21+
// currently timeout set to 180000ms in jest.config.js
2222

2323
if (!SEPOLIA_RPC_URL) {
2424
throw new Error('SEPOLIA_RPC_URL must be set')
2525
}
2626
if (!AVALANCHE_FUJI_RPC_URL) {
2727
throw new Error('AVALANCHE_FUJI_RPC_URL must be set')
2828
}
29-
const privateKey = process.env.PRIVATE_KEY as `0x${string}`
29+
30+
const privateKey = process.env.PRIVATE_KEY as Viem.Hex
3031

3132
if (privateKey === DEFAULT_ANVIL_PRIVATE_KEY) {
3233
throw new Error(
3334
"Developer's PRIVATE_KEY for Ethereum Sepolia and Avalanche Fuji must be set for integration testing on",
3435
)
3536
}
3637

37-
jest.setTimeout(TIMEOUT)
3838
describe('Integration: Fuji -> Sepolia', () => {
3939
let avalancheFujiClient: Viem.WalletClient
4040
let sepoliaClient: Viem.WalletClient
@@ -290,4 +290,8 @@ describe('Integration: Fuji -> Sepolia', () => {
290290
expect(ccipSend_txReceipt.to!.toLowerCase()).toEqual(AVALANCHE_FUJI_CCIP_ROUTER_ADDRESS.toLowerCase())
291291
})
292292
})
293+
294+
afterAll(async () => {
295+
console.info('✅ | Testnet Integration tests passed. Waiting for timeout...')
296+
})
293297
})

0 commit comments

Comments
 (0)