Skip to content

Commit 8d3a680

Browse files
authored
Sui CCTP support (#718)
1 parent b44cd1a commit 8d3a680

File tree

16 files changed

+435
-8
lines changed

16 files changed

+435
-8
lines changed

core/base/src/constants/circle.ts

+4
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ const usdcContracts = [[
1919
["Solana", "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"],
2020
["Base", "0x833589fcd6edb6e08f4c7c32d4f71b54bda02913"],
2121
["Polygon", "0x3c499c542cef5e3811e1192ce70d8cc03d5c3359"],
22+
["Sui", "0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7::usdc::USDC"],
2223
]], [
2324
"Testnet", [
2425
["Sepolia", "0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238"],
@@ -28,6 +29,7 @@ const usdcContracts = [[
2829
["Solana", "4zMMC9srt5Ri5X14GAgXhaHii3GnPAEERYPJgZJDncDU"],
2930
["BaseSepolia", "0x036CbD53842c5426634e7929541eC2318f3dCF7e"],
3031
["Polygon", "0x9999f7fea5938fd3b1e26a12c3f2fb024e194f97"],
32+
["Sui", "0xa1ec7fc00a6f40db9693ad1415d0c193ad3906494428cf252621037bd7117e29::usdc::USDC"],
3133
]],
3234
] as const satisfies MapLevel<Network, MapLevel<Chain, string>>;
3335
export const usdcContract = constMap(usdcContracts);
@@ -43,6 +45,7 @@ const circleDomains = [[
4345
["Solana", 5],
4446
["Base", 6],
4547
["Polygon", 7],
48+
["Sui", 8],
4649
]], [
4750
"Testnet", [
4851
["Sepolia", 0],
@@ -52,6 +55,7 @@ const circleDomains = [[
5255
["Solana", 5],
5356
["BaseSepolia", 6],
5457
["Polygon", 7],
58+
["Sui", 8],
5559
]],
5660
] as const satisfies MapLevel<Network, MapLevel<Chain, number>>;
5761

core/base/src/constants/contracts/circle.ts

+12
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,12 @@ export const circleContracts = [[
5353
messageTransmitter: "0xF3be9355363857F3e001be68856A2f96b4C39Ba9",
5454
wormholeRelayer: "0x4cb69FaE7e7Af841e44E1A1c30Af640739378bb2",
5555
wormhole: "0x0FF28217dCc90372345954563486528aa865cDd6",
56+
}], [
57+
"Sui", {
58+
tokenMessenger: "0x410d70c8baad60f310f45c13b9656ecbfed46fdf970e051f0cac42891a848856",
59+
messageTransmitter: "0x34c884874be4cb4b84e79fa280d7b041f186f4d1ef08be1dc74b20e94376951a",
60+
wormholeRelayer: "",
61+
wormhole: "",
5662
}],
5763
]], [
5864
"Testnet", [[
@@ -97,6 +103,12 @@ export const circleContracts = [[
97103
messageTransmitter: "0xe09A679F56207EF33F5b9d8fb4499Ec00792eA73",
98104
wormholeRelayer: "0x4cb69FaE7e7Af841e44E1A1c30Af640739378bb2",
99105
wormhole: "0x2703483B1a5a7c577e8680de9Df8Be03c6f30e3c",
106+
}], [
107+
"Sui", {
108+
tokenMessenger: "0x4e16078afc5ebfc244a8107ded4044970df5d84db384e7194b7fc444090683fd",
109+
messageTransmitter: "0x4741a96a5903c80613f2d013492a47741cf10c6246ea38a724d354a09895cf8f",
110+
wormholeRelayer: "",
111+
wormhole: "",
100112
}],
101113
]],
102114
] as const satisfies MapLevels<[Network, Chain, CircleContracts]>;

examples/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,4 @@
5353
"dependencies": {
5454
"@wormhole-foundation/sdk": "0.12.0"
5555
}
56-
}
56+
}

examples/src/cctp.ts

+17-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import type { Network, Signer, TransactionId, Wormhole } from "@wormhole-foundation/sdk";
2-
import { CircleTransfer, amount, wormhole } from "@wormhole-foundation/sdk";
2+
import { CircleTransfer, TransferState, amount, wormhole } from "@wormhole-foundation/sdk";
33
import evm from "@wormhole-foundation/sdk/evm";
44
import solana from "@wormhole-foundation/sdk/solana";
5+
import sui from "@wormhole-foundation/sdk/sui";
56
import type { SignerStuff } from "./helpers/index.js";
67
import { getSigner } from "./helpers/index.js";
78

@@ -16,19 +17,19 @@ AutoRelayer takes a 0.1usdc fee when xfering to any chain beside goerli, which i
1617
(async function () {
1718
// init Wormhole object, passing config for which network
1819
// to use (e.g. Mainnet/Testnet) and what Platforms to support
19-
const wh = await wormhole("Testnet", [evm, solana]);
20+
const wh = await wormhole("Testnet", [evm, solana, sui]);
2021

2122
// Grab chain Contexts
2223
const sendChain = wh.getChain("Avalanche");
23-
const rcvChain = wh.getChain("Solana");
24+
const rcvChain = wh.getChain("Sui");
2425

2526
// Get signer from local key but anything that implements
2627
// Signer interface (e.g. wrapper around web wallet) should work
2728
const source = await getSigner(sendChain);
2829
const destination = await getSigner(rcvChain);
2930

3031
// 6 decimals for USDC (except for bsc, so check decimals before using this)
31-
const amt = amount.units(amount.parse("0.2", 6));
32+
const amt = amount.units(amount.parse("0.01", 6));
3233

3334
// Choose whether or not to have the attestation delivered for you
3435
const automatic = false;
@@ -105,6 +106,18 @@ async function cctpTransfer<N extends Network>(
105106
console.log("Completing Transfer");
106107
const dstTxids = await xfer.completeTransfer(dst.signer);
107108
console.log(`Completed Transfer: `, dstTxids);
109+
110+
console.log("Tracking Transfer Progress");
111+
let receipt = CircleTransfer.getReceipt(xfer);
112+
113+
for await (receipt of CircleTransfer.track(wh, receipt)) {
114+
console.log("Receipt State:", receipt.state);
115+
if (receipt.state === TransferState.DestinationFinalized) {
116+
console.log("Transfer Confirmed Complete");
117+
break;
118+
}
119+
}
120+
108121
// EXAMPLE_CCTP_TRANSFER
109122
}
110123

package-lock.json

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

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
"platforms/sui",
5959
"platforms/sui/protocols/core",
6060
"platforms/sui/protocols/tokenBridge",
61+
"platforms/sui/protocols/cctp",
6162
"platforms/aptos",
6263
"platforms/aptos/protocols/core",
6364
"platforms/aptos/protocols/tokenBridge",
@@ -67,4 +68,4 @@
6768
"unreleased": [
6869
"tokenRegistry"
6970
]
70-
}
71+
}

platforms/evm/protocols/cctp/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -80,4 +80,4 @@
8080
}
8181
}
8282
}
83-
}
83+
}
+75
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
{
2+
"name": "@wormhole-foundation/sdk-sui-cctp",
3+
"version": "0.12.0",
4+
"repository": {
5+
"type": "git",
6+
"url": "git+https://github.com/wormhole-foundation/wormhole-sdk-ts.git"
7+
},
8+
"bugs": {
9+
"url": "https://github.com/wormhole-foundation/wormhole-sdk-ts/issues"
10+
},
11+
"homepage": "https://github.com/wormhole-foundation/wormhole-sdk-ts#readme",
12+
"directories": {
13+
"test": "tests"
14+
},
15+
"license": "Apache-2.0",
16+
"main": "./dist/cjs/index.js",
17+
"types": "./dist/cjs/index.d.ts",
18+
"module": "./dist/esm/index.js",
19+
"description": "SDK for Sui chains, used in conjunction with @wormhole-foundation/sdk",
20+
"files": [
21+
"dist/esm",
22+
"dist/cjs"
23+
],
24+
"keywords": [
25+
"wormhole",
26+
"sdk",
27+
"typescript",
28+
"connect",
29+
"sui"
30+
],
31+
"engines": {
32+
"node": ">=16"
33+
},
34+
"sideEffects": [
35+
"./dist/cjs/index.js",
36+
"./dist/esm/index.js"
37+
],
38+
"scripts": {
39+
"build:cjs": "tsc -p ./tsconfig.cjs.json && echo '{\"type\":\"commonjs\"}' > dist/cjs/package.json",
40+
"build:esm": "tsc -p ./tsconfig.esm.json",
41+
"build": "npm run build:esm && npm run build:cjs",
42+
"rebuild": "npm run clean && npm run build",
43+
"clean": "rm -rf ./dist && rm -rf ./.turbo",
44+
"lint": "npm run prettier && eslint --fix ./src --ext .ts",
45+
"prettier": "prettier --write ./src"
46+
},
47+
"dependencies": {
48+
"@mysten/sui.js": "^0.50.1",
49+
"@wormhole-foundation/sdk-connect": "0.12.0",
50+
"@wormhole-foundation/sdk-sui": "0.12.0"
51+
},
52+
"type": "module",
53+
"exports": {
54+
".": {
55+
"react-native": {
56+
"import": "./dist/esm/index.js",
57+
"require": "./dist/cjs/index.js",
58+
"types": "./dist/cjs/index.d.ts",
59+
"default": "./dist/cjs/index.js"
60+
},
61+
"import": {
62+
"types": "./dist/esm/index.d.ts",
63+
"default": "./dist/esm/index.js"
64+
},
65+
"require": {
66+
"types": "./dist/cjs/index.d.ts",
67+
"default": "./dist/cjs/index.js"
68+
},
69+
"default": {
70+
"types": "./dist/cjs/index.d.ts",
71+
"default": "./dist/cjs/index.js"
72+
}
73+
}
74+
}
75+
}

0 commit comments

Comments
 (0)