Skip to content

Commit 6fb75b5

Browse files
authored
add sdk-sui-ntt example (#22)
1 parent 5fd5ee8 commit 6fb75b5

6 files changed

Lines changed: 1291 additions & 940 deletions

File tree

package.json

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,18 @@
33
"typescript": "^5.5.4"
44
},
55
"dependencies": {
6-
"@wormhole-foundation/sdk": "3.0.4",
7-
"@wormhole-foundation/sdk-definitions-ntt": "^1.0.6",
8-
"@wormhole-foundation/sdk-evm-ntt": "^1.0.6",
9-
"@wormhole-foundation/sdk-route-ntt": "^1.0.6",
10-
"@wormhole-foundation/sdk-solana-ntt": "^1.0.6",
6+
"@wormhole-foundation/sdk": "3.4.1",
7+
"@wormhole-foundation/sdk-definitions-ntt": "2.0.0",
8+
"@wormhole-foundation/sdk-evm-ntt": "2.0.0",
9+
"@wormhole-foundation/sdk-route-ntt": "2.0.0",
10+
"@wormhole-foundation/sdk-solana-ntt": "2.0.0",
11+
"@wormhole-foundation/sdk-sui-ntt": "2.0.0",
1112
"dotenv": "^16.4.5",
1213
"rpc-websockets": "7.11.0"
1314
},
1415
"overrides": {
15-
"@wormhole-foundation/sdk": "3.0.4",
16-
"@wormhole-foundation/sdk-base": "3.0.4",
17-
"@wormhole-foundation/sdk-definitions": "3.0.4"
16+
"@wormhole-foundation/sdk": "3.4.1",
17+
"@wormhole-foundation/sdk-base": "3.4.1",
18+
"@wormhole-foundation/sdk-definitions": "3.4.1"
1819
}
1920
}

src/index-executor.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,12 @@ import {
77
} from "@wormhole-foundation/sdk";
88
import evm from "@wormhole-foundation/sdk/platforms/evm";
99
import solana from "@wormhole-foundation/sdk/platforms/solana";
10+
import sui from "@wormhole-foundation/sdk/platforms/sui";
1011

1112
// register protocol implementations
1213
import "@wormhole-foundation/sdk-evm-ntt";
1314
import "@wormhole-foundation/sdk-solana-ntt";
15+
import "@wormhole-foundation/sdk-sui-ntt";
1416
import { NttExecutorRoute, nttExecutorRoute } from "@wormhole-foundation/sdk-route-ntt";
1517
import { TEST_NTT_TOKENS } from "./utils/const";
1618
import { getSigner, convertToExecutorConfig } from "./utils/helpers";
@@ -20,10 +22,10 @@ import { routes } from "@wormhole-foundation/sdk";
2022
(async function () {
2123
// TODO: change to "Mainnet" for mainnet
2224
const network = "Testnet";
23-
const wh = new Wormhole(network, [solana.Platform, evm.Platform], {
25+
const wh = new Wormhole(network, [solana.Platform, evm.Platform, sui.Platform], {
2426
// optional way to use private RPCs, especially recommended for mainnet
2527
// "chains": {
26-
// "Monad": {
28+
// "Sui": {
2729
// "rpc": "http://127.0.0.1:8546"
2830
// },
2931
// "Solana": {
@@ -32,10 +34,10 @@ import { routes } from "@wormhole-foundation/sdk";
3234
// }
3335
});
3436
const src = wh.getChain("Solana");
35-
const dst = wh.getChain("Monad");
37+
const dst = wh.getChain("Sui");
3638
const srcSigner = await getSigner(src);
3739
// TODO: change destination address
38-
const dstAddress: ChainAddress = Wormhole.chainAddress("Monad","0x5e8C54C443E8c42ccA73Fa9399C8D61C94aD9f36");
40+
const dstAddress: ChainAddress = Wormhole.chainAddress("Sui","0xa43");
3941
console.log("Source signer address:", srcSigner.address.address);
4042

4143
const srcNtt = await src.getProtocol("Ntt", {
@@ -70,7 +72,7 @@ import { routes } from "@wormhole-foundation/sdk";
7072
});
7173

7274
//TODO: change to token amount that should be transferred
73-
const amtString = "0.07";
75+
const amtString = "1.7";
7476
const amt = amount.units(
7577
amount.parse(amtString, await srcNtt.getTokenDecimals())
7678
);

src/index.ts

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,28 +6,30 @@ import {
66
} from "@wormhole-foundation/sdk";
77
import evm from "@wormhole-foundation/sdk/platforms/evm";
88
import solana from "@wormhole-foundation/sdk/platforms/solana";
9+
import sui from "@wormhole-foundation/sdk/platforms/sui";
910

1011
// register protocol implementations
1112
import "@wormhole-foundation/sdk-evm-ntt";
1213
import "@wormhole-foundation/sdk-solana-ntt";
14+
import "@wormhole-foundation/sdk-sui-ntt";
1315
import { TEST_NTT_TOKENS } from "./utils/const";
1416
import { getSigner } from "./utils/helpers";
1517

1618

1719
(async function () {
18-
const wh = new Wormhole("Testnet", [solana.Platform, evm.Platform], {
20+
const wh = new Wormhole("Testnet", [solana.Platform, evm.Platform, sui.Platform], {
1921
// optional way to use private RPCs, especially recommended for mainnet
20-
"chains": {
21-
"Monad": {
22-
"rpc": "http://127.0.0.1:8546"
23-
},
24-
"Solana": {
25-
"rpc": "http://127.0.0.1:8899"
26-
}
27-
}
22+
// "chains": {
23+
// "Sui": {
24+
// "rpc": "http://127.0.0.1:8546"
25+
// },
26+
// "Solana": {
27+
// "rpc": "http://127.0.0.1:8899"
28+
// }
29+
// }
2830
});
2931
const src = wh.getChain("Solana");
30-
const dst = wh.getChain("Monad");
32+
const dst = wh.getChain("Sui");
3133

3234
const srcSigner = await getSigner(src);
3335
const dstSigner = await getSigner(dst);
@@ -41,7 +43,7 @@ import {
4143

4244
//TODO: change to token amount that should be transferred
4345
const amt = amount.units(
44-
amount.parse("1.1", await srcNtt.getTokenDecimals())
46+
amount.parse("1.32", await srcNtt.getTokenDecimals())
4547
);
4648

4749
const xfer = () =>

src/utils/const.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,20 @@ export const DEVNET_SOL_PRIVATE_KEY = encoding.b58.encode(
1313
export const DEVNET_ETH_PRIVATE_KEY =
1414
"0x4f3edf983ac636a65a842ce7c78d9aa706d3b113bce9c46f30d7d21715b23b1d"; // Ganache default private key
1515

16+
export const TESTNET_SUI_MNEMONIC = "";
17+
1618
export const TEST_NTT_TOKENS: NttContracts = {
1719
Solana: {
18-
token: "7xKXtg2CW87d97TXJSDpbD5jBkheTqA83TZRuJosgAsU",
19-
manager: "9WzDXwBbmkg8ZTbNMqUxvQRAyrZzDsGYdLVL9zYtAWWM",
20+
token: "ANRdVy8fvhiJqXccFPpZijty5jQqkBp5Xjw4NXL1CsU1",
21+
manager: "nasiB9hbB1s5ZWXAR54fjr3Y4HVTTzJMXNPAuedggQA",
2022
transceiver: {
21-
wormhole: "3vJjDYwPKkhBykQU1BkJAnCrMp9U4qZn9hFMbvQJCyU3",
23+
wormhole: "Ba8FkdiKmNuGiwiZ6PVzkyR7uE2kMGV1aAYUh3XReLuA",
2224
},
2325
quoter: "Nqd6XqA8LbsCuG8MLWWuP865NV6jR1MbXeKxD4HLKDJ"
2426
},
25-
Monad: {
26-
token: "0x8f3Cf7ad23Cd3CaDbD9735AFf958023239c6A063",
27-
manager: "0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174",
28-
transceiver: { wormhole: "0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619" },
27+
Sui: {
28+
token: "0x84a63e6b60767903c32b403fa6817fee6983470429e63bcf6da78a69ff00e4be::my_coin::MY_COIN",
29+
manager: "0x8eb275808fe2f03ba24c9033de6322653262d3a360ee48541be6d6a072414306",
30+
transceiver: { wormhole: "0x0540541acbd520955b0150b97c77e6c8b4ab3847fe8768b75551adcc3c5098ec" },
2931
},
3032
};

src/utils/helpers.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ import {
1111

1212
import evm from "@wormhole-foundation/sdk/platforms/evm";
1313
import solana from "@wormhole-foundation/sdk/platforms/solana";
14-
import { NttContracts, DEVNET_SOL_PRIVATE_KEY, DEVNET_ETH_PRIVATE_KEY, TEST_NTT_TOKENS} from "./const";
14+
import sui from "@wormhole-foundation/sdk/platforms/sui";
15+
import { NttContracts, DEVNET_SOL_PRIVATE_KEY, DEVNET_ETH_PRIVATE_KEY, TEST_NTT_TOKENS, TESTNET_SUI_MNEMONIC} from "./const";
1516
import { NttExecutorRoute, NttRoute } from "@wormhole-foundation/sdk-route-ntt";
1617

1718
export interface SignerStuff<N extends Network, C extends Chain> {
@@ -42,6 +43,12 @@ import { NttExecutorRoute, NttRoute } from "@wormhole-foundation/sdk-route-ntt";
4243
getEnv("ETH_PRIVATE_KEY", DEVNET_ETH_PRIVATE_KEY)
4344
);
4445
break;
46+
case "Sui":
47+
signer = await sui.getSigner(
48+
await chain.getRpc(),
49+
getEnv("SUI_MNEMONIC", TESTNET_SUI_MNEMONIC)
50+
);
51+
break;
4552
default:
4653
throw new Error("Unrecognized platform: " + platform);
4754
}

0 commit comments

Comments
 (0)