Skip to content

Commit 089b192

Browse files
committed
Updated config mechanism: externalized configuration elements from the ccip-react-components package.
1 parent 7df5e9c commit 089b192

35 files changed

+2732
-320
lines changed

.github/workflows/publish.yaml

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# NOTE: See "prepublishOnly" script in package.json
2+
# NPM_TOKEN will only be populated in the context of the `publish` GH environment, see L14
3+
14
name: Publish to NPM
25

36
on:
@@ -34,14 +37,14 @@ jobs:
3437
run: |
3538
pnpm build-ccip-js
3639
cd packages/ccip-js
37-
pnpm config set //registry.npmjs.org/:_authToken ${{ secrets.NPM_CCIP_JAVASCRIPT_SDK }}
40+
pnpm config set //registry.npmjs.org/:_authToken ${{ secrets.NPM_CCIP_JS }}
3841
pnpm publish --no-git-checks --access public
3942
shell: bash
4043

4144
- name: Publish ccip-react-components to NPM
4245
run: |
4346
pnpm build-components
4447
cd packages/ccip-react-components
45-
pnpm config set //registry.npmjs.org/:_authToken ${{ secrets.NPM_CCIP_JAVASCRIPT_SDK }}
48+
pnpm config set //registry.npmjs.org/:_authToken ${{ secrets.NPM_CCIP_REACT_COMPONENTS }}
4649
pnpm publish --no-git-checks --access public
47-
shell: bash
50+
shell: bash

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ dist/
88
.env
99
*.tsbuildinfo
1010
bin
11+
.codegpt

examples/nextjs/components/client-only.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
"use client";
1+
'use client';
22

3-
import React, { useState, useEffect } from "react";
3+
import React, { useState, useEffect } from 'react';
44

55
type ClientOnlyProps = {
66
children: React.ReactNode;
@@ -14,7 +14,7 @@ export function ClientOnly({ children, fallback }: ClientOnlyProps) {
1414
setHasMounted(true);
1515
}, []);
1616

17-
if (!hasMounted) return <>{fallback}</> ?? null;
17+
if (!hasMounted) return fallback ? <>{fallback}</> : null;
1818

1919
return <>{children}</>;
2020
}

examples/nextjs/components/default-widget.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
import '@chainlink/ccip-react-components/dist/style.css';
44
import { CCIPWidget } from '@chainlink/ccip-react-components';
55

6-
import { tokensList } from '@/config/tokensList';
76
import { config } from '@/config';
7+
import { networkConfig } from '@/config/networkConfig';
88

99
export function DefaultWidget() {
10-
return <CCIPWidget config={config} tokensList={tokensList} />;
10+
return <CCIPWidget config={config} networkConfig={networkConfig} />;
1111
}

examples/nextjs/components/drawer-widget.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import '@chainlink/ccip-react-components/dist/style.css';
44
import { TDrawer, CCIPWidget } from '@chainlink/ccip-react-components';
55

66
import { useRef } from 'react';
7-
import { tokensList } from '@/config/tokensList';
87
import { config } from '@/config';
8+
import { networkConfig } from '@/config/networkConfig';
99

1010
export function DrawerWidget() {
1111
const drawerRef = useRef<TDrawer>(null);
@@ -23,7 +23,7 @@ export function DrawerWidget() {
2323
</button>
2424
<CCIPWidget
2525
config={{ ...config, variant: 'drawer' }}
26-
tokensList={tokensList}
26+
networkConfig={networkConfig}
2727
ref={drawerRef}
2828
/>
2929
</>

examples/nextjs/config/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,5 @@ export const config: Config = {
2525
},
2626
shape: { radius: 4 },
2727
},
28+
showFaucet: true,
2829
};
+153
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
import {
2+
AddressMap,
3+
NetworkConfig,
4+
Token,
5+
} from '@chainlink/ccip-react-components';
6+
import {
7+
arbitrumSepolia,
8+
avalancheFuji,
9+
baseSepolia,
10+
bscTestnet,
11+
optimismSepolia,
12+
polygonAmoy,
13+
sepolia,
14+
} from 'viem/chains';
15+
16+
const tokensList: Token[] = [
17+
{
18+
symbol: 'CCIP-BnM',
19+
address: {
20+
[arbitrumSepolia.id]: '0xA8C0c11bf64AF62CDCA6f93D3769B88BdD7cb93D',
21+
[avalancheFuji.id]: '0xD21341536c5cF5EB1bcb58f6723cE26e8D8E90e4',
22+
[baseSepolia.id]: '0x88A2d74F47a237a62e7A51cdDa67270CE381555e',
23+
[bscTestnet.id]: '0xbFA2ACd33ED6EEc0ed3Cc06bF1ac38d22b36B9e9',
24+
[optimismSepolia.id]: '0x8aF4204e30565DF93352fE8E1De78925F6664dA7',
25+
[polygonAmoy.id]: '0xcab0EF91Bee323d1A617c0a027eE753aFd6997E4',
26+
[sepolia.id]: '0xFd57b4ddBf88a4e07fF4e34C487b99af2Fe82a05',
27+
},
28+
logoURL:
29+
'https://smartcontract.imgix.net/tokens/ccip-bnm.webp?auto=compress%2Cformat',
30+
tags: ['chainlink', 'default'],
31+
},
32+
{
33+
symbol: 'CCIP-LnM',
34+
address: {
35+
[arbitrumSepolia.id]: '0x139E99f0ab4084E14e6bb7DacA289a91a2d92927',
36+
[avalancheFuji.id]: '0x70F5c5C40b873EA597776DA2C21929A8282A3b35',
37+
[baseSepolia.id]: '0xA98FA8A008371b9408195e52734b1768c0d1Cb5c',
38+
[bscTestnet.id]: '0x79a4Fc27f69323660f5Bfc12dEe21c3cC14f5901',
39+
[optimismSepolia.id]: '0x044a6B4b561af69D2319A2f4be5Ec327a6975D0a',
40+
[polygonAmoy.id]: '0x3d357fb52253e86c8Ee0f80F5FfE438fD9503FF2',
41+
[sepolia.id]: '0x466D489b6d36E7E3b824ef491C225F5830E81cC1',
42+
},
43+
logoURL:
44+
'https://smartcontract.imgix.net/tokens/ccip-lnm.webp?auto=compress%2Cformat',
45+
tags: ['chainlink', 'default'],
46+
},
47+
{
48+
symbol: 'GHO',
49+
address: {
50+
[arbitrumSepolia.id]: '0xb13Cfa6f8B2Eed2C37fB00fF0c1A59807C585810',
51+
[avalancheFuji.id]: '0x9c04928Cc678776eC1C1C0E46ecC03a5F47A7723',
52+
[baseSepolia.id]: '0x7CFa3f3d1cded0Da930881c609D4Dbf0012c14Bb',
53+
[bscTestnet.id]: undefined,
54+
[optimismSepolia.id]: undefined,
55+
[polygonAmoy.id]: undefined,
56+
[sepolia.id]: '0xc4bF5CbDaBE595361438F8c6a187bDc330539c60',
57+
},
58+
logoURL:
59+
'https://smartcontract.imgix.net/tokens/gho.webp?auto=compress%2Cformat',
60+
tags: ['stablecoin', 'default'],
61+
},
62+
{
63+
symbol: 'USDC',
64+
address: {
65+
[arbitrumSepolia.id]: '0x75faf114eafb1BDbe2F0316DF893fd58CE46AA4d',
66+
[avalancheFuji.id]: '0x5425890298aed601595a70AB815c96711a31Bc65',
67+
[baseSepolia.id]: '0x036CbD53842c5426634e7929541eC2318f3dCF7e',
68+
[bscTestnet.id]: undefined,
69+
[optimismSepolia.id]: '0x5fd84259d66Cd46123540766Be93DFE6D43130D7',
70+
[polygonAmoy.id]: '0x41E94Eb019C0762f9Bfcf9Fb1E58725BfB0e7582',
71+
[sepolia.id]: '0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238',
72+
},
73+
logoURL:
74+
'https://smartcontract.imgix.net/tokens/usdc.webp?auto=compress%2Cformat',
75+
tags: ['stablecoin', 'default'],
76+
},
77+
];
78+
79+
const chains = [
80+
{
81+
chain: arbitrumSepolia,
82+
logoURL:
83+
'https://d2f70xi62kby8n.cloudfront.net/bridge/icons/networks/arbitrum.svg?auto=compress%2Cformat',
84+
},
85+
{
86+
chain: avalancheFuji,
87+
logoURL:
88+
'https://d2f70xi62kby8n.cloudfront.net/bridge/icons/networks/avalanche.svg?auto=compress%2Cformat',
89+
},
90+
{
91+
chain: baseSepolia,
92+
logoURL:
93+
'https://d2f70xi62kby8n.cloudfront.net/bridge/icons/networks/base.svg?auto=compress%2Cformat',
94+
},
95+
{
96+
chain: bscTestnet,
97+
logoURL:
98+
'https://d2f70xi62kby8n.cloudfront.net/bridge/icons/networks/bsc.svg?auto=compress%2Cformat',
99+
},
100+
{
101+
chain: sepolia,
102+
logoURL:
103+
'https://d2f70xi62kby8n.cloudfront.net/bridge/icons/networks/ethereum.svg?auto=compress%2Cformat',
104+
},
105+
{
106+
chain: optimismSepolia,
107+
logoURL:
108+
'https://d2f70xi62kby8n.cloudfront.net/bridge/icons/networks/optimism.svg?auto=compress%2Cformat',
109+
},
110+
{
111+
chain: polygonAmoy,
112+
logoURL:
113+
'https://d2f70xi62kby8n.cloudfront.net/bridge/icons/networks/polygon.svg?auto=compress%2Cformat',
114+
},
115+
];
116+
117+
const linkContracts: AddressMap = {
118+
[arbitrumSepolia.id]: '0xb1D4538B4571d411F07960EF2838Ce337FE1E80E',
119+
[avalancheFuji.id]: '0x0b9d5D9136855f6FEc3c0993feE6E9CE8a297846',
120+
[baseSepolia.id]: '0xE4aB69C077896252FAFBD49EFD26B5D171A32410',
121+
[bscTestnet.id]: '0x84b9B910527Ad5C03A9Ca831909E21e236EA7b06',
122+
[sepolia.id]: '0x779877A7B0D9E8603169DdbD7836e478b4624789',
123+
[optimismSepolia.id]: '0xE4aB69C077896252FAFBD49EFD26B5D171A32410',
124+
[polygonAmoy.id]: '0x0Fd9e8d3aF1aaee056EB9e802c3A762a667b1904',
125+
};
126+
127+
const routerAddresses: AddressMap = {
128+
[arbitrumSepolia.id]: '0x2a9C5afB0d0e4BAb2BCdaE109EC4b0c4Be15a165',
129+
[avalancheFuji.id]: '0xF694E193200268f9a4868e4Aa017A0118C9a8177',
130+
[baseSepolia.id]: '0xD3b06cEbF099CE7DA4AcCf578aaebFDBd6e88a93',
131+
[bscTestnet.id]: '0xE1053aE1857476f36A3C62580FF9b016E8EE8F6f',
132+
[sepolia.id]: '0x0BF3dE8c5D3e8A2B34D2BEeB17ABfCeBaf363A59',
133+
[optimismSepolia.id]: '0x114a20a10b43d4115e5aeef7345a1a71d2a60c57',
134+
[polygonAmoy.id]: '0x9C32fCB86BF0f4a1A8921a9Fe46de3198bb884B2',
135+
};
136+
137+
const chainSelectors = {
138+
[arbitrumSepolia.id]: '3478487238524512106',
139+
[avalancheFuji.id]: '14767482510784806043',
140+
[baseSepolia.id]: '10344971235874465080',
141+
[bscTestnet.id]: '13264668187771770619',
142+
[sepolia.id]: '16015286601757825753',
143+
[optimismSepolia.id]: '5224473277236331295',
144+
[polygonAmoy.id]: '16281711391670634445',
145+
};
146+
147+
export const networkConfig: NetworkConfig = {
148+
chains,
149+
linkContracts,
150+
routerAddresses,
151+
chainSelectors,
152+
tokensList,
153+
};

examples/nextjs/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
"lint": "next lint"
1414
},
1515
"dependencies": {
16-
"@chainlink/ccip-js": "0.2.1",
17-
"@chainlink/ccip-react-components": "0.2.1",
16+
"@chainlink/ccip-js": "^0.2.1",
17+
"@chainlink/ccip-react-components": "^0.2.1",
1818
"@tanstack/react-query": "^5.37.1",
1919
"next": "14.2.3",
2020
"react": "18",

0 commit comments

Comments
 (0)