From 7fb4bfa125466e0704ea9c4f1c26bf57733ff494 Mon Sep 17 00:00:00 2001 From: Zubin Pratap Date: Mon, 28 Apr 2025 15:42:41 +1000 Subject: [PATCH 1/8] Update package.json scripts and README for improved testing instructions - Removed the pretest script and updated test commands in package.json. - Revised README to clarify the use of `foundryup` for running Anvil and updated test execution instructions. - Enhanced error handling in integration test to handle undefined block numbers. --- packages/ccip-js/README.md | 7 +++---- packages/ccip-js/package.json | 2 -- packages/ccip-js/test/integration-testnet.test.ts | 2 +- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/packages/ccip-js/README.md b/packages/ccip-js/README.md index 6f6bd94..e7856ae 100644 --- a/packages/ccip-js/README.md +++ b/packages/ccip-js/README.md @@ -594,11 +594,10 @@ pnpm build-ccip-js 1. cd into `packages/ccip-js` and then run `pnpm install` OR from the project root you can run `pnpm i -w` -2. open a new terminal window and run `anvil` - requires that you've [installed Foundry Anvil](https://book.getfoundry.sh/anvil/). +2. open a new terminal window and run `foundryup` followed by `anvil` - requires that you've [installed Foundry Anvil](https://book.getfoundry.sh/anvil/). + Note: that Anvil is only needed for the tests inside `./test/integration-mocked.test.ts` 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. -3. Back in the first terminal, inside, `packages/ccip-js` run `pnpm test` - -Note: that Anvil is only needed for the tests inside `./test/integration-mocked.test.ts` 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. +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. ### Contributing diff --git a/packages/ccip-js/package.json b/packages/ccip-js/package.json index 25abd6a..882dd58 100644 --- a/packages/ccip-js/package.json +++ b/packages/ccip-js/package.json @@ -14,10 +14,8 @@ "build": "tsc && hardhat compile", "lint": "eslint 'src/**/*.{ts,js}'", "format": "prettier --write 'src/**/*.{ts,js,json,md}'", - "pretest": "anvil --block-time 2", "t:int": "jest --coverage -u --testMatch=\"**/integration-*.test.ts\" --detectOpenHandles", "t:unit": "jest --coverage -u -t=\"Unit\"", - "test": "jest --coverage", "test:hh": "hardhat test" }, "devDependencies": { diff --git a/packages/ccip-js/test/integration-testnet.test.ts b/packages/ccip-js/test/integration-testnet.test.ts index f1605ca..a2eb141 100644 --- a/packages/ccip-js/test/integration-testnet.test.ts +++ b/packages/ccip-js/test/integration-testnet.test.ts @@ -278,7 +278,7 @@ describe('Integration: Fuji -> Sepolia', () => { client: sepoliaClient, // from the destination chain sourceChainSelector: FUJI_CHAIN_SELECTOR, destinationRouterAddress: SEPOLIA_ROUTER_ADDRESS, - fromBlockNumber: ccipSend_txReceipt.blockNumber, + fromBlockNumber: ccipSend_txReceipt.blockNumber ? ccipSend_txReceipt.blockNumber : undefined, messageId: _messageId, }) From dc81adfe6c1574cc96d73d723b0e8f5c73a6b168 Mon Sep 17 00:00:00 2001 From: Zubin Pratap Date: Mon, 28 Apr 2025 17:38:08 +1000 Subject: [PATCH 2/8] Undo prettier tab width change. Update README and refactor for new Event Names and updated FeeQuoter. Update pnpm-lock.yaml and package dependencies; introduce FeeQuoter contract - Upgraded lockfile version to 9.0 and updated TypeScript dependencies in pnpm-lock.yaml. - Added new FeeQuoter contract and corresponding ABI for fee management. - Refactored references from PriceRegistry to FeeQuoter in various components and tests. - Updated documentation to reflect changes in function names and parameters related to fee handling. --- .gitignore | 2 +- examples/nextjs/components/ccip.tsx | 301 +- packages/ccip-js/.eslintrc.json | 22 +- packages/ccip-js/README.md | 26 +- .../artifacts-compile/EVM2EVMOnRamp.json | 3700 +-- .../ccip-js/artifacts-compile/FeeQuoter.json | 605 + .../artifacts-compile/PriceRegistry.json | 605 - packages/ccip-js/package.json | 12 +- .../{PriceRegistry.json => FeeQuoter.json} | 0 packages/ccip-js/src/abi/OffRamp.json | 4 +- packages/ccip-js/src/abi/OnRamp.json | 10 +- packages/ccip-js/src/api.ts | 125 +- .../{PriceRegistry.sol => FeeQuoter.sol} | 20 +- packages/ccip-js/test/helpers/config.ts | 256 +- packages/ccip-js/test/helpers/constants.ts | 9 +- packages/ccip-js/test/helpers/contracts.ts | 99 +- packages/ccip-js/test/helpers/types.ts | 103 +- .../ccip-js/test/integration-mocked.test.ts | 136 +- .../ccip-js/test/integration-testnet.test.ts | 4 +- packages/ccip-js/test/unit.test.ts | 26 +- .../lib/components/RateLimit.tsx | 20 +- pnpm-lock.yaml | 19849 +++++++++------- 22 files changed, 14344 insertions(+), 11590 deletions(-) create mode 100644 packages/ccip-js/artifacts-compile/FeeQuoter.json delete mode 100644 packages/ccip-js/artifacts-compile/PriceRegistry.json rename packages/ccip-js/src/abi/{PriceRegistry.json => FeeQuoter.json} (100%) rename packages/ccip-js/src/contracts/{PriceRegistry.sol => FeeQuoter.sol} (96%) diff --git a/.gitignore b/.gitignore index 1715450..3589ad7 100644 --- a/.gitignore +++ b/.gitignore @@ -5,7 +5,7 @@ node_modules/ dist/ # misc -.env +*.env *.tsbuildinfo bin .codegpt diff --git a/examples/nextjs/components/ccip.tsx b/examples/nextjs/components/ccip.tsx index a2dff92..3dc939d 100644 --- a/examples/nextjs/components/ccip.tsx +++ b/examples/nextjs/components/ccip.tsx @@ -1,18 +1,7 @@ -'use client'; +"use client"; -import { - createClient, - IERC20ABI, - RateLimiterState, - TransferStatus, -} from '@chainlink/ccip-js'; -import { - useConnect, - useAccount, - useSwitchChain, - usePublicClient, - useWalletClient, -} from 'wagmi'; +import { createClient, IERC20ABI, RateLimiterState, TransferStatus } from "@chainlink/ccip-js"; +import { useConnect, useAccount, useSwitchChain, usePublicClient, useWalletClient } from "wagmi"; import { Address, encodeAbiParameters, @@ -23,8 +12,8 @@ import { PublicClient, TransactionReceipt, WalletClient, -} from 'viem'; -import { useState } from 'react'; +} from "viem"; +import { useState } from "react"; const ccipClient = createClient(); @@ -40,9 +29,9 @@ export function CCIP() { - + - + @@ -63,18 +52,8 @@ export function CCIP() { function ConnectWallet() { const { chain, address } = useAccount(); - const { - connectors, - connect, - isError: isConnectError, - error: connectError, - } = useConnect(); - const { - chains, - switchChain, - error: switchError, - isError: isSwitchError, - } = useSwitchChain(); + const { connectors, connect, isError: isConnectError, error: connectError } = useConnect(); + const { chains, switchChain, error: switchError, isError: isSwitchError } = useSwitchChain(); const [chainId, setChainId] = useState(`${chain?.id}`); @@ -82,7 +61,7 @@ function ConnectWallet() {

Connect Wallet:

- {connectors.map((connector) => ( + {connectors.map(connector => ( - {isSwitchError && ( -

{switchError.message}

- )} + {isSwitchError &&

{switchError.message}

} )}
@@ -192,16 +169,11 @@ function ApproveRouter({ walletClient }: { walletClient: WalletClient }) { ); } -function TransferTokensAndMessage({ - walletClient, -}: { - walletClient: WalletClient; -}) { +function TransferTokensAndMessage({ walletClient }: { walletClient: WalletClient }) { const [routerAddress, setRouterAddress] = useState(); const [tokenAddress, setTokenAddress] = useState(); const [amount, setAmount] = useState(); - const [destinationChainSelector, setDestinationChainSelector] = - useState(); + const [destinationChainSelector, setDestinationChainSelector] = useState(); const [destinationAccount, setDestinationAccount] = useState(); const [data, setData] = useState(); const [messageId, setMessageId] = useState(); @@ -229,9 +201,7 @@ function TransferTokensAndMessage({ />
- + - setData( - encodeAbiParameters( - [{ type: 'string', name: 'data' }], - [target.value] - ) - ) - } + onChange={({ target }) => setData(encodeAbiParameters([{ type: "string", name: "data" }], [target.value]))} />
@@ -279,13 +242,7 @@ function TransferTokensAndMessage({
@@ -322,8 +277,7 @@ function TransferTokensAndMessage({ function SendCCIPMessage({ walletClient }: { walletClient: WalletClient }) { const [routerAddress, setRouterAddress] = useState(); - const [destinationChainSelector, setDestinationChainSelector] = - useState(); + const [destinationChainSelector, setDestinationChainSelector] = useState(); const [destinationAccount, setDestinationAccount] = useState(); const [data, setData] = useState(); const [messageId, setMessageId] = useState(); @@ -343,9 +297,7 @@ function SendCCIPMessage({ walletClient }: { walletClient: WalletClient }) {
- + - setData( - encodeAbiParameters( - [{ type: 'string', name: 'data' }], - [target.value] - ) - ) - } + onChange={({ target }) => setData(encodeAbiParameters([{ type: "string", name: "data" }], [target.value]))} />