@@ -24,12 +24,6 @@ import {
24
24
import { SolanaWormholeCore } from "@wormhole-foundation/sdk-solana-core" ;
25
25
import * as fs from "fs" ;
26
26
27
- import {
28
- PublicKey ,
29
- SystemProgram ,
30
- Transaction ,
31
- sendAndConfirmTransaction ,
32
- } from "@solana/web3.js" ;
33
27
import { DummyTransferHook } from "../ts/idl/1_0_0/ts/dummy_transfer_hook.js" ;
34
28
import { getTransceiverProgram , IdlVersion , NTT } from "../ts/index.js" ;
35
29
import { derivePda } from "../ts/lib/utils.js" ;
@@ -41,9 +35,9 @@ const VERSION: IdlVersion = "3.0.0";
41
35
const GUARDIAN_KEY =
42
36
"cfb12303a19cde580bb4dd771639b0d26bc68353645571a8cff516ab2ee113a0" ;
43
37
const CORE_BRIDGE_ADDRESS = contracts . coreBridge ( "Mainnet" , "Solana" ) ;
44
- const NTT_ADDRESS : PublicKey =
38
+ const NTT_ADDRESS : anchor . web3 . PublicKey =
45
39
anchor . workspace . ExampleNativeTokenTransfers . programId ;
46
- const WH_TRANSCEIVER_ADDRESS : PublicKey =
40
+ const WH_TRANSCEIVER_ADDRESS : anchor . web3 . PublicKey =
47
41
anchor . workspace . NttTransceiver . programId ;
48
42
49
43
async function signSendWait (
@@ -102,12 +96,12 @@ const mint = anchor.web3.Keypair.generate();
102
96
const dummyTransferHook = anchor . workspace
103
97
. DummyTransferHook as anchor . Program < DummyTransferHook > ;
104
98
105
- const [ extraAccountMetaListPDA ] = PublicKey . findProgramAddressSync (
99
+ const [ extraAccountMetaListPDA ] = anchor . web3 . PublicKey . findProgramAddressSync (
106
100
[ Buffer . from ( "extra-account-metas" ) , mint . publicKey . toBuffer ( ) ] ,
107
101
dummyTransferHook . programId
108
102
) ;
109
103
110
- const [ counterPDA ] = PublicKey . findProgramAddressSync (
104
+ const [ counterPDA ] = anchor . web3 . PublicKey . findProgramAddressSync (
111
105
[ Buffer . from ( "counter" ) ] ,
112
106
dummyTransferHook . programId
113
107
) ;
@@ -135,6 +129,7 @@ describe("example-native-token-transfers", () => {
135
129
let ntt : SolanaNtt < "Devnet" , "Solana" > ;
136
130
let signer : Signer ;
137
131
let sender : AccountAddress < "Solana" > ;
132
+ let multisig : anchor . web3 . PublicKey ;
138
133
let tokenAddress : string ;
139
134
140
135
beforeAll ( async ( ) => {
@@ -150,8 +145,8 @@ describe("example-native-token-transfers", () => {
150
145
mintLen
151
146
) ;
152
147
153
- const transaction = new Transaction ( ) . add (
154
- SystemProgram . createAccount ( {
148
+ const transaction = new anchor . web3 . Transaction ( ) . add (
149
+ anchor . web3 . SystemProgram . createAccount ( {
155
150
fromPubkey : payer . publicKey ,
156
151
newAccountPubkey : mint . publicKey ,
157
152
space : mintLen ,
@@ -178,9 +173,14 @@ describe("example-native-token-transfers", () => {
178
173
transaction . feePayer = payer . publicKey ;
179
174
transaction . recentBlockhash = blockhash ;
180
175
181
- await sendAndConfirmTransaction ( connection , transaction , [ payer , mint ] , {
182
- commitment : "confirmed" ,
183
- } ) ;
176
+ await anchor . web3 . sendAndConfirmTransaction (
177
+ connection ,
178
+ transaction ,
179
+ [ payer , mint ] ,
180
+ {
181
+ commitment : "confirmed" ,
182
+ }
183
+ ) ;
184
184
185
185
tokenAccount = await spl . createAssociatedTokenAccount (
186
186
connection ,
@@ -231,13 +231,22 @@ describe("example-native-token-transfers", () => {
231
231
describe ( "Burning" , ( ) => {
232
232
beforeAll ( async ( ) => {
233
233
try {
234
+ multisig = await spl . createMultisig (
235
+ connection ,
236
+ payer ,
237
+ [ owner . publicKey , ntt . pdas . tokenAuthority ( ) ] ,
238
+ 1 ,
239
+ anchor . web3 . Keypair . generate ( ) ,
240
+ undefined ,
241
+ TOKEN_PROGRAM
242
+ ) ;
234
243
await spl . setAuthority (
235
244
connection ,
236
245
payer ,
237
246
mint . publicKey ,
238
247
owner ,
239
248
spl . AuthorityType . MintTokens ,
240
- ntt . pdas . tokenAuthority ( ) ,
249
+ multisig ,
241
250
[ ] ,
242
251
undefined ,
243
252
TOKEN_PROGRAM
@@ -248,6 +257,7 @@ describe("example-native-token-transfers", () => {
248
257
mint : mint . publicKey ,
249
258
outboundLimit : 1000000n ,
250
259
mode : "burning" ,
260
+ multisig,
251
261
} ) ;
252
262
await signSendWait ( ctx , initTxs , signer ) ;
253
263
@@ -285,21 +295,26 @@ describe("example-native-token-transfers", () => {
285
295
extraAccountMetaList : extraAccountMetaListPDA ,
286
296
tokenProgram : TOKEN_PROGRAM ,
287
297
associatedTokenProgram : spl . ASSOCIATED_TOKEN_PROGRAM_ID ,
288
- systemProgram : SystemProgram . programId ,
298
+ systemProgram : anchor . web3 . SystemProgram . programId ,
289
299
} )
290
300
. instruction ( ) ;
291
301
292
- const transaction = new Transaction ( ) . add (
302
+ const transaction = new anchor . web3 . Transaction ( ) . add (
293
303
initializeExtraAccountMetaListInstruction
294
304
) ;
295
305
transaction . feePayer = payer . publicKey ;
296
306
const { blockhash } = await connection . getLatestBlockhash ( ) ;
297
307
transaction . recentBlockhash = blockhash ;
298
308
299
309
transaction . sign ( payer ) ;
300
- await sendAndConfirmTransaction ( connection , transaction , [ payer ] , {
301
- commitment : "confirmed" ,
302
- } ) ;
310
+ await anchor . web3 . sendAndConfirmTransaction (
311
+ connection ,
312
+ transaction ,
313
+ [ payer ] ,
314
+ {
315
+ commitment : "confirmed" ,
316
+ }
317
+ ) ;
303
318
} ) ;
304
319
305
320
test ( "Can send tokens" , async ( ) => {
@@ -391,7 +406,7 @@ describe("example-native-token-transfers", () => {
391
406
const published = emitter . publishMessage ( 0 , serialized , 200 ) ;
392
407
const rawVaa = guardians . addSignatures ( published , [ 0 ] ) ;
393
408
const vaa = deserialize ( "Ntt:WormholeTransfer" , serialize ( rawVaa ) ) ;
394
- const redeemTxs = ntt . redeem ( [ vaa ] , sender ) ;
409
+ const redeemTxs = ntt . redeem ( [ vaa ] , sender , multisig ) ;
395
410
try {
396
411
await signSendWait ( ctx , redeemTxs , signer ) ;
397
412
} catch ( e ) {
@@ -401,6 +416,32 @@ describe("example-native-token-transfers", () => {
401
416
402
417
expect ( ( await counterValue ( ) ) . toString ( ) ) . toEqual ( "2" ) ;
403
418
} ) ;
419
+
420
+ it ( "Can mint independently" , async ( ) => {
421
+ const dest = await spl . getOrCreateAssociatedTokenAccount (
422
+ connection ,
423
+ payer ,
424
+ mint . publicKey ,
425
+ anchor . web3 . Keypair . generate ( ) . publicKey ,
426
+ false ,
427
+ undefined ,
428
+ undefined ,
429
+ TOKEN_PROGRAM
430
+ ) ;
431
+ await spl . mintTo (
432
+ connection ,
433
+ payer ,
434
+ mint . publicKey ,
435
+ dest . address ,
436
+ multisig ,
437
+ 1 ,
438
+ [ owner ] ,
439
+ undefined ,
440
+ TOKEN_PROGRAM
441
+ ) ;
442
+ const balance = await connection . getTokenAccountBalance ( dest . address ) ;
443
+ expect ( balance . value . amount . toString ( ) ) . toBe ( "1" ) ;
444
+ } ) ;
404
445
} ) ;
405
446
406
447
describe ( "Static Checks" , ( ) => {
0 commit comments