Skip to content

Commit ef90fee

Browse files
committed
add custody addresses where necessary
1 parent c3b3c7b commit ef90fee

File tree

2 files changed

+29
-10
lines changed

2 files changed

+29
-10
lines changed

sdk/examples/src/index.ts

+19-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import {
22
TransactionId,
33
Wormhole,
4+
amount,
45
signSendWait,
56
} from "@wormhole-foundation/sdk";
67
import evm from "@wormhole-foundation/sdk/platforms/evm";
@@ -13,9 +14,15 @@ import "@wormhole-foundation/sdk-solana-ntt";
1314
import { TEST_NTT_SPL22_TOKENS, TEST_NTT_TOKENS } from "./consts.js";
1415
import { getSigner } from "./helpers.js";
1516

17+
const TOKEN_CONTRACTS = TEST_NTT_TOKENS;
18+
//const TOKEN_CONTRACTS = TEST_NTT_SPL22_TOKENS;
19+
1620
// Recover an in-flight transfer by setting txids here from output of previous run
1721
const recoverTxids: TransactionId[] = [
1822
//{ chain: "Solana", txid: "hZXRs9TEvMWnSAzcgmrEuHsq1C5rbcompy63vkJ2SrXv4a7u6ZBEaJAkBMXKAfScCooDNhN36Jt4PMcDhN8yGjP", },
23+
// Unused adn staged
24+
// {chain "Sepolia", txid: "0x9f2b1a8124f8377d77deb5c85f165c290669587b494c598beacea60a4d9a00fd"}
25+
// {chain "Sepolia", txid: "0x1aff02ed4bf9d51a424626187e3e331304229fc0d422b7abfe8025452b166180"}
1926
];
2027

2128
(async function () {
@@ -27,14 +34,18 @@ const recoverTxids: TransactionId[] = [
2734
const dstSigner = await getSigner(dst);
2835

2936
const srcNtt = await src.getProtocol("Ntt", {
30-
ntt: TEST_NTT_SPL22_TOKENS[src.chain],
37+
ntt: TOKEN_CONTRACTS[src.chain],
3138
});
3239
const dstNtt = await dst.getProtocol("Ntt", {
33-
ntt: TEST_NTT_SPL22_TOKENS[dst.chain],
40+
ntt: TOKEN_CONTRACTS[dst.chain],
3441
});
3542

43+
const amt = amount.units(
44+
amount.parse("0.01", await srcNtt.getTokenDecimals())
45+
);
46+
3647
const xfer = () =>
37-
srcNtt.transfer(srcSigner.address.address, 1_000n, dstSigner.address, {
48+
srcNtt.transfer(srcSigner.address.address, amt, dstSigner.address, {
3849
queue: false,
3950
automatic: false,
4051
gasDropoff: 0n,
@@ -47,7 +58,11 @@ const recoverTxids: TransactionId[] = [
4758
: recoverTxids;
4859
console.log("Source txs", txids);
4960

50-
const vaa = await wh.getVaa(txids[0]!.txid, "Ntt:WormholeTransfer");
61+
const vaa = await wh.getVaa(
62+
txids[0]!.txid,
63+
"Ntt:WormholeTransfer",
64+
25 * 60 * 1000
65+
);
5166
console.log(vaa);
5267

5368
const dstTxids = await signSendWait(

solana/ts/lib/ntt.ts

+10-6
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,7 @@ export namespace NTT {
366366
): Promise<TransactionInstruction> {
367367
pdas = pdas ?? NTT.pdas(program.programId);
368368

369+
const custody = await custodyAccountAddress(pdas, config);
369370
const recipientChain = toChain(args.transferArgs.recipientChain.id);
370371
const transferIx = await program.methods
371372
.transferBurn(args.transferArgs)
@@ -378,8 +379,8 @@ export namespace NTT {
378379
tokenProgram: config.tokenProgram,
379380
outboxItem: args.outboxItem,
380381
outboxRateLimit: pdas.outboxRateLimitAccount(),
381-
custody: await custodyAccountAddress(pdas, config),
382382
systemProgram: SystemProgram.programId,
383+
custody,
383384
},
384385
peer: pdas.peerAccount(recipientChain),
385386
inboxRateLimit: pdas.inboxRateLimitAccount(recipientChain),
@@ -448,10 +449,10 @@ export namespace NTT {
448449
pdas = pdas ?? NTT.pdas(program.programId);
449450

450451
const chain = toChain(args.transferArgs.recipientChain.id);
451-
452+
const custody = await custodyAccountAddress(pdas, config);
452453
const transferIx = await program.methods
453454
.transferLock(args.transferArgs)
454-
.accounts({
455+
.accountsStrict({
455456
common: {
456457
payer: args.payer,
457458
config: { config: pdas.configAccount() },
@@ -460,14 +461,16 @@ export namespace NTT {
460461
tokenProgram: config.tokenProgram,
461462
outboxItem: args.outboxItem,
462463
outboxRateLimit: pdas.outboxRateLimitAccount(),
463-
custody: await custodyAccountAddress(pdas, config),
464+
custody,
465+
systemProgram: SystemProgram.programId,
464466
},
465467
peer: pdas.peerAccount(chain),
466468
inboxRateLimit: pdas.inboxRateLimitAccount(chain),
467469
sessionAuthority: pdas.sessionAuthority(
468470
args.fromAuthority,
469471
args.transferArgs
470472
),
473+
custody,
471474
})
472475
.instruction();
473476

@@ -647,6 +650,7 @@ export namespace NTT {
647650
.recipientAddress;
648651

649652
pdas = pdas ?? NTT.pdas(program.programId);
653+
const custody = await custodyAccountAddress(pdas, config);
650654

651655
const transferIx = await program.methods
652656
.releaseInboundUnlock({
@@ -666,9 +670,9 @@ export namespace NTT {
666670
mint: config.mint,
667671
tokenAuthority: pdas.tokenAuthority(),
668672
tokenProgram: config.tokenProgram,
669-
custody: await custodyAccountAddress(pdas, config),
673+
custody,
670674
},
671-
custody: "",
675+
custody,
672676
})
673677
.instruction();
674678

0 commit comments

Comments
 (0)