Skip to content

Commit 4885598

Browse files
authored
Added Unichain CCTP support (#3265)
* Added Unichain CCTP support * change ETH token icons for unichain * bump sdk for unichain chain native id * unichain chain order * change explorer url * remove space * change explorer name * checkForeignAssets script fix * checkForeignAssets script fix * bump sdk for higher eta
1 parent fd262f9 commit 4885598

19 files changed

+360
-205
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ See [`chains.ts`](https://github.com/wormhole-foundation/wormhole-sdk-ts/blob/ma
158158
| Xlayer | Xlayer |
159159
| Mantle | Mantle |
160160
| Worldchain | Worldchain |
161+
| Unichain | Unichain |
161162

162163
### RPC Endpoints (`rpcs`):
163164

wormhole-connect/package-lock.json

+180-178
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

wormhole-connect/package.json

+18-18
Original file line numberDiff line numberDiff line change
@@ -39,16 +39,16 @@
3939
"@solana/spl-token": "^0.3.9",
4040
"@solana/wallet-adapter-wallets": "^0.19.25",
4141
"@solana/web3.js": "^1.95.8",
42-
"@wormhole-foundation/sdk": "1.5.2",
43-
"@wormhole-foundation/sdk-definitions": "1.5.2",
42+
"@wormhole-foundation/sdk": "1.6.1-beta.3",
43+
"@wormhole-foundation/sdk-definitions": "1.6.1-beta.3",
4444
"@wormhole-foundation/sdk-definitions-ntt": "^0.6.1",
4545
"@wormhole-foundation/sdk-evm-ntt": "^0.6.1",
4646
"@wormhole-foundation/sdk-icons": "^1.0.0",
4747
"@wormhole-foundation/sdk-route-ntt": "^0.6.1",
4848
"@wormhole-foundation/sdk-solana-ntt": "^0.6.1",
4949
"@xlabs-libs/wallet-aggregator-aptos": "^1.0.0-alpha.2",
50-
"@xlabs-libs/wallet-aggregator-core": "^0.0.1-alpha.22",
51-
"@xlabs-libs/wallet-aggregator-evm": "^0.0.2-alpha.5",
50+
"@xlabs-libs/wallet-aggregator-core": "^0.0.1-alpha.23",
51+
"@xlabs-libs/wallet-aggregator-evm": "^0.0.2-alpha.6",
5252
"@xlabs-libs/wallet-aggregator-solana": "^0.0.1-alpha.15",
5353
"@xlabs-libs/wallet-aggregator-sui": "^0.0.1-alpha.11",
5454
"axios": "1.4.0",
@@ -167,28 +167,28 @@
167167
"axios": "1.4.0"
168168
},
169169
"@mayanfinance/wormhole-sdk-route": {
170-
"@wormhole-foundation/sdk-connect": "1.5.2",
171-
"@wormhole-foundation/sdk-evm": "1.5.2",
172-
"@wormhole-foundation/sdk-solana": "1.5.2"
170+
"@wormhole-foundation/sdk-connect": "1.6.1-beta.3",
171+
"@wormhole-foundation/sdk-evm": "1.6.1-beta.3",
172+
"@wormhole-foundation/sdk-solana": "1.6.1-beta.3"
173173
},
174174
"@wormhole-foundation/sdk-definitions-ntt": {
175-
"@wormhole-foundation/sdk-base": "1.5.2",
176-
"@wormhole-foundation/sdk-definitions": "1.5.2"
175+
"@wormhole-foundation/sdk-base": "1.6.1-beta.3",
176+
"@wormhole-foundation/sdk-definitions": "1.6.1-beta.3"
177177
},
178178
"@wormhole-foundation/sdk-evm-ntt": {
179-
"@wormhole-foundation/sdk-base": "1.5.2",
180-
"@wormhole-foundation/sdk-definitions": "1.5.2",
181-
"@wormhole-foundation/sdk-evm": "1.5.2",
182-
"@wormhole-foundation/sdk-evm-core": "1.5.2"
179+
"@wormhole-foundation/sdk-base": "1.6.1-beta.3",
180+
"@wormhole-foundation/sdk-definitions": "1.6.1-beta.3",
181+
"@wormhole-foundation/sdk-evm": "1.6.1-beta.3",
182+
"@wormhole-foundation/sdk-evm-core": "1.6.1-beta.3"
183183
},
184184
"@wormhole-foundation/sdk-route-ntt": {
185-
"@wormhole-foundation/sdk-connect": "1.5.2"
185+
"@wormhole-foundation/sdk-connect": "1.6.1-beta.3"
186186
},
187187
"@wormhole-foundation/sdk-solana-ntt": {
188-
"@wormhole-foundation/sdk-base": "1.5.2",
189-
"@wormhole-foundation/sdk-definitions": "1.5.2",
190-
"@wormhole-foundation/sdk-solana": "1.5.2",
191-
"@wormhole-foundation/sdk-solana-core": "1.5.2"
188+
"@wormhole-foundation/sdk-base": "1.6.1-beta.3",
189+
"@wormhole-foundation/sdk-definitions": "1.6.1-beta.3",
190+
"@wormhole-foundation/sdk-solana": "1.6.1-beta.3",
191+
"@wormhole-foundation/sdk-solana-core": "1.6.1-beta.3"
192192
},
193193
"@wormhole-foundation/wormhole-connect": {
194194
"aptos": "1.5.2"

wormhole-connect/scripts/checkForeignAssetsConfig.ts

+10-2
Original file line numberDiff line numberDiff line change
@@ -62,19 +62,27 @@ const checkEnvConfig = async (
6262

6363
for (const { tokenId } of tokensConfig) {
6464
const nativeChain = wh.getChain(tokenId.chain);
65-
const nativeTb = await nativeChain.getTokenBridge();
65+
const nativeTb = await nativeChain.getTokenBridge().catch((_) => undefined);
66+
if (!nativeTb) continue;
67+
6668
let universalAddress: UniversalAddress | null = null;
6769
if (tokenId.address !== 'native') {
6870
universalAddress = await nativeTb.getTokenUniversalAddress(
6971
toNative(nativeChain.chain, tokenId.address),
7072
);
7173
}
74+
7275
await Promise.all(
7376
Object.keys(chainsConfig).map((unTypedChain) => {
7477
return (async () => {
7578
const chain = unTypedChain as Chain;
7679
const context = wh.getChain(chain);
77-
const tb = await context.getTokenBridge();
80+
const tb = await context.getTokenBridge().catch((_) => undefined);
81+
if (!tb) {
82+
// Some chains don't have token bridge deployed
83+
console.log(`No token bridge for ${chain}`);
84+
return;
85+
}
7886

7987
const configForeignAddress =
8088
wrappedTokens[tokenId.chain]?.[tokenId.address]?.[chain];

wormhole-connect/src/config/constants.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,13 @@ export const CHAIN_ORDER: Chain[] = [
1616
'Sui',
1717
'Bsc',
1818
'Optimism',
19+
'Unichain',
1920
'Fantom',
2021
'Polygon',
2122
'Avalanche',
22-
'Osmosis',
2323
'Celo',
2424
'Moonbeam',
2525
'Klaytn',
26-
'Injective',
27-
'Kujira',
2826
'Scroll',
2927
'Evmos',
3028
'Mantle',

wormhole-connect/src/config/mainnet/chains.ts

+11
Original file line numberDiff line numberDiff line change
@@ -209,4 +209,15 @@ export const MAINNET_CHAINS: ChainsConfig = {
209209
icon: 'Worldchain',
210210
symbol: 'WORLD',
211211
},
212+
Unichain: {
213+
...chains.Unichain!,
214+
displayName: 'Unichain',
215+
sdkName: 'Unichain',
216+
explorerUrl: 'https://uniscan.xyz/',
217+
explorerName: 'Uniscan',
218+
chainId: 130,
219+
icon: 'Unichain',
220+
symbol: 'UNI',
221+
wrappedGasToken: '0x4200000000000000000000000000000000000006',
222+
},
212223
};

wormhole-connect/src/config/mainnet/rpcs.ts

+2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ const {
1919
REACT_APP_XLAYER_RPC,
2020
REACT_APP_MANTLE_RPC,
2121
REACT_APP_WORLDCHAIN_RPC,
22+
REACT_APP_UNICHAIN_RPC,
2223
} = import.meta.env;
2324

2425
export const MAINNET_RPC_MAPPING = {
@@ -41,4 +42,5 @@ export const MAINNET_RPC_MAPPING = {
4142
...populateRpcField('Xlayer', REACT_APP_XLAYER_RPC),
4243
...populateRpcField('Mantle', REACT_APP_MANTLE_RPC),
4344
...populateRpcField('Worldchain', REACT_APP_WORLDCHAIN_RPC),
45+
...populateRpcField('Unichain', REACT_APP_UNICHAIN_RPC),
4446
};

wormhole-connect/src/config/mainnet/tokens.ts

+27
Original file line numberDiff line numberDiff line change
@@ -611,4 +611,31 @@ export const MAINNET_TOKENS: TokenConfig[] = [
611611
decimals: 18,
612612
icon: TokenIcon.WORLDCHAIN,
613613
},
614+
{
615+
symbol: 'ETH',
616+
tokenId: {
617+
chain: 'Unichain',
618+
address: 'native',
619+
},
620+
decimals: 18,
621+
icon: TokenIcon.ETH,
622+
},
623+
{
624+
symbol: 'WETH',
625+
tokenId: {
626+
chain: 'Unichain',
627+
address: '0x4200000000000000000000000000000000000006',
628+
},
629+
decimals: 18,
630+
icon: TokenIcon.ETH,
631+
},
632+
{
633+
symbol: 'USDC',
634+
tokenId: {
635+
chain: 'Unichain',
636+
address: '0x078D782b760474a361dDA0AF3839290b0EF57AD6',
637+
},
638+
decimals: 6,
639+
icon: TokenIcon.USDC,
640+
},
614641
];

wormhole-connect/src/config/testnet/chains.ts

+11
Original file line numberDiff line numberDiff line change
@@ -198,4 +198,15 @@ export const TESTNET_CHAINS: ChainsConfig = {
198198
sdkName: 'Worldchain',
199199
symbol: 'WORLD',
200200
},
201+
Unichain: {
202+
...chains.Unichain!,
203+
displayName: 'Unichain',
204+
explorerUrl: 'https://unichain-sepolia.blockscout.com/',
205+
explorerName: 'Unichain Explorer',
206+
chainId: 1301,
207+
icon: 'Unichain',
208+
symbol: 'UNI',
209+
sdkName: 'Unichain',
210+
wrappedGasToken: '0x4200000000000000000000000000000000000006',
211+
},
201212
};

wormhole-connect/src/config/testnet/rpcs.ts

+2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ const {
1818
REACT_APP_XLAYER_TESTNET_RPC,
1919
REACT_APP_MANTLE_TESTNET_RPC,
2020
REACT_APP_WORLDCHAIN_TESTNET_RPC,
21+
REACT_APP_UNICHAIN_TESTNET_RPC,
2122
} = import.meta.env;
2223

2324
export const TESTNET_RPC_MAPPING = {
@@ -39,4 +40,5 @@ export const TESTNET_RPC_MAPPING = {
3940
...populateRpcField('Xlayer', REACT_APP_XLAYER_TESTNET_RPC),
4041
...populateRpcField('Mantle', REACT_APP_MANTLE_TESTNET_RPC),
4142
...populateRpcField('Worldchain', REACT_APP_WORLDCHAIN_TESTNET_RPC),
43+
...populateRpcField('Unichain', REACT_APP_UNICHAIN_TESTNET_RPC),
4244
};

wormhole-connect/src/config/testnet/tokens.ts

+27
Original file line numberDiff line numberDiff line change
@@ -307,4 +307,31 @@ export const TESTNET_TOKENS: TokenConfig[] = [
307307
decimals: 18,
308308
icon: TokenIcon.WORLDCHAIN,
309309
},
310+
{
311+
symbol: 'ETH',
312+
tokenId: {
313+
chain: 'Unichain',
314+
address: 'native',
315+
},
316+
decimals: 18,
317+
icon: TokenIcon.ETH,
318+
},
319+
{
320+
symbol: 'WETH',
321+
tokenId: {
322+
chain: 'Unichain',
323+
address: '0x4200000000000000000000000000000000000006',
324+
},
325+
decimals: 18,
326+
icon: TokenIcon.ETH,
327+
},
328+
{
329+
symbol: 'USDC',
330+
tokenId: {
331+
chain: 'Unichain',
332+
address: '0x31d0220469e10c4E71834a79b1f276d740d3768F',
333+
},
334+
decimals: 6,
335+
icon: TokenIcon.USDC,
336+
},
310337
];

wormhole-connect/src/config/types.ts

+1
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ export enum TokenIcon {
6464
'XLAYER',
6565
'MANTLE',
6666
'WORLDCHAIN',
67+
'UNICHAIN',
6768
}
6869

6970
// Used in bridging components

wormhole-connect/src/env.d.ts

+2
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ interface ImportMetaEnv {
2727
REACT_APP_XLAYER_RPC: string;
2828
REACT_APP_MANTLE_RPC: string;
2929
REACT_APP_WORLDCHAIN_RPC: string;
30+
REACT_APP_UNICHAIN_RPC: string;
3031

3132
// testnet
3233
REACT_APP_SEPOLIA_RPC: string;
@@ -47,6 +48,7 @@ interface ImportMetaEnv {
4748
REACT_APP_XLAYER_TESTNET_RPC: string;
4849
REACT_APP_MANTLE_TESTNET_RPC: string;
4950
REACT_APP_WORLDCHAIN_TESTNET_RPC: string;
51+
REACT_APP_UNICHAIN_TESTNET_RPC: string;
5052

5153
// devnet
5254
REACT_APP_ETHEREUM_DEVNET_RPC: string;

wormhole-connect/src/icons/ChainIcons.tsx

+2
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import MANTLE from './Chains/MANTLE';
2525
import XLAYER from './Chains/XLAYER';
2626
import OSMO from './Chains/OSMO';
2727
import WORLD from './Chains/WORLD';
28+
import UNI from './Chains/UNI';
2829

2930
const useStyles = makeStyles<{ size: number }>()((theme, { size }) => ({
3031
container: {
@@ -63,6 +64,7 @@ const iconMap: { [key in Chain]?: React.JSX.Element } = {
6364
Mantle: MANTLE(),
6465
Osmosis: OSMO(),
6566
Worldchain: WORLD(),
67+
Unichain: UNI(),
6668
};
6769

6870
function isBuiltinChainIcon(icon?: Chain | string): icon is Chain {
+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import React from 'react';
2+
3+
function UNI() {
4+
return (
5+
<svg
6+
width="37"
7+
height="36"
8+
viewBox="0 0 37 36"
9+
fill="none"
10+
xmlns="http://www.w3.org/2000/svg"
11+
>
12+
<g clipPath="url(#clip0_952_10579)">
13+
<path
14+
d="M30.3597 0H6.49976C3.18605 0 0.499756 2.68629 0.499756 6V30C0.499756 33.3137 3.18605 36 6.49976 36H30.3597C33.6734 36 36.3597 33.3137 36.3597 30V6C36.3597 2.68629 33.6734 0 30.3597 0Z"
15+
fill="url(#paint0_radial_952_10579)"
16+
/>
17+
<path
18+
d="M33.3037 17.7159C25.2415 17.7159 18.7127 11.155 18.7127 3.06787H18.1467V17.7159H3.55566V18.2841C11.6179 18.2841 18.1467 24.8449 18.1467 32.9321H18.7127V18.2841H33.3037V17.7159Z"
19+
fill="white"
20+
/>
21+
</g>
22+
<defs>
23+
<radialGradient
24+
id="paint0_radial_952_10579"
25+
cx="0"
26+
cy="0"
27+
r="1"
28+
gradientUnits="userSpaceOnUse"
29+
gradientTransform="translate(18.4297 18) rotate(90) scale(18 17.93)"
30+
>
31+
<stop stopColor="#FC74FE" />
32+
<stop offset="1" stopColor="#F50DB4" />
33+
</radialGradient>
34+
<clipPath id="clip0_952_10579">
35+
<rect
36+
width="36"
37+
height="36"
38+
fill="white"
39+
transform="translate(0.429688)"
40+
/>
41+
</clipPath>
42+
</defs>
43+
</svg>
44+
);
45+
}
46+
47+
export default UNI;

wormhole-connect/src/icons/TokenIcons.tsx

+2
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ import NTT from './Tokens/NTT';
3939
import SCROLL from './Tokens/SCROLL';
4040
import BLAST from './Tokens/BLAST';
4141
import WORLD from './Tokens/WORLD';
42+
import UNI from './Chains/UNI';
4243

4344
const useStyles = makeStyles<{ size: number }>()((theme, { size }) => ({
4445
container: {
@@ -103,6 +104,7 @@ const iconMap: { [key in TokenIcon]: React.JSX.Element } = {
103104
/>
104105
),
105106
[TokenIcon.WORLDCHAIN]: WORLD(),
107+
[TokenIcon.UNICHAIN]: UNI(),
106108
};
107109

108110
function isBuiltinTokenIcon(icon?: TokenIcon | string): icon is TokenIcon {

wormhole-connect/src/routes/sdkv2/route.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@ import { SDKv2Signer } from './signer';
1616

1717
import { amount as sdkAmount } from '@wormhole-foundation/sdk';
1818
import config, { getWormholeContextV2 } from 'config';
19-
import {
20-
sleep,
21-
} from 'utils';
19+
import { sleep } from 'utils';
2220
import { isFrankensteinToken } from 'utils';
2321
import { TransferWallet } from 'utils/wallet';
2422

@@ -356,7 +354,9 @@ export class SDKv2Route {
356354
if (
357355
['ETH', 'WETH'].includes(symbol) &&
358356
nativeChain === 'Ethereum' &&
359-
(['Scroll', 'Blast', 'Xlayer', 'Mantle'] as Chain[]).includes(toChain)
357+
(['Scroll', 'Blast', 'Xlayer', 'Mantle', 'Unichain'] as Chain[]).includes(
358+
toChain,
359+
)
360360
) {
361361
return true;
362362
}

wormhole-connect/src/sdklegacy/config/MAINNET.ts

+6
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,11 @@ const MAINNET: { [chain in Chain]?: ChainConfig } = {
9292
id: 37,
9393
context: Context.ETH,
9494
},
95+
Unichain: {
96+
key: 'Unichain',
97+
id: 44,
98+
context: Context.ETH,
99+
},
95100
Worldchain: {
96101
key: 'Worldchain',
97102
id: 45,
@@ -131,6 +136,7 @@ const MAINNET_CONFIG: WormholeConfig = {
131136
Xlayer: 'https://rpc.xlayer.tech',
132137
Mantle: 'https://rpc.mantle.xyz',
133138
Worldchain: 'https://worldchain-mainnet.g.alchemy.com/public',
139+
Unichain: 'https://mainnet.unichain.org',
134140
},
135141
chains: MAINNET,
136142
};

0 commit comments

Comments
 (0)