@@ -4,26 +4,26 @@ import * as anchor from "@coral-xyz/anchor";
44import { AnchorProvider , BN } from "@coral-xyz/anchor" ;
55import {
66 ASSOCIATED_TOKEN_PROGRAM_ID ,
7- NATIVE_MINT ,
8- TOKEN_PROGRAM_ID ,
97 createApproveCheckedInstruction ,
108 createAssociatedTokenAccountIdempotentInstruction ,
119 createCloseAccountInstruction ,
1210 createSyncNativeInstruction ,
1311 getAssociatedTokenAddressSync ,
1412 getMinimumBalanceForRentExemptAccount ,
1513 getMint ,
14+ NATIVE_MINT ,
15+ TOKEN_PROGRAM_ID ,
1616} from "@solana/spl-token" ;
1717import {
1818 PublicKey ,
19- Transaction ,
2019 sendAndConfirmTransaction ,
21- TransactionInstruction ,
2220 SystemProgram ,
21+ Transaction ,
22+ TransactionInstruction ,
2323} from "@solana/web3.js" ;
2424import yargs from "yargs" ;
2525import { hideBin } from "yargs/helpers" ;
26- import { getSpokePoolProgram , SOLANA_SPOKE_STATE_SEED } from "../../src/svm/web3-v1" ;
26+ import { getDepositPda , getDepositSeedHash , getSpokePoolProgram , SOLANA_SPOKE_STATE_SEED } from "../../src/svm/web3-v1" ;
2727
2828// Set up the provider
2929const provider = AnchorProvider . env ( ) ;
@@ -125,20 +125,49 @@ async function nativeDeposit(): Promise<void> {
125125 ? [ ]
126126 : [ createCloseAccountInstruction ( userTokenAccount , signer . publicKey , signer . publicKey ) ] ;
127127
128+ const depositData : Parameters < typeof getDepositSeedHash > [ 0 ] = {
129+ depositor : signer . publicKey ,
130+ recipient,
131+ inputToken,
132+ outputToken,
133+ inputAmount,
134+ outputAmount,
135+ destinationChainId,
136+ exclusiveRelayer,
137+ quoteTimestamp : new BN ( quoteTimestamp ) ,
138+ fillDeadline : new BN ( fillDeadline ) ,
139+ exclusivityParameter : new BN ( exclusivityDeadline ) ,
140+ message,
141+ } ;
142+ const delegatePda = getDepositPda ( depositData , program . programId ) ;
143+
128144 // Delegate state PDA to pull depositor tokens.
129145 const approveIx = await createApproveCheckedInstruction (
130146 userTokenAccount ,
131147 inputToken ,
132- statePda ,
148+ delegatePda ,
133149 signer . publicKey ,
134150 BigInt ( inputAmount . toString ( ) ) ,
135151 tokenDecimals ,
136152 undefined ,
137153 TOKEN_PROGRAM_ID
138154 ) ;
139155
140- const depositIx = await (
141- program . methods . deposit (
156+ const depositAccounts = {
157+ state : statePda ,
158+ delegate : delegatePda ,
159+ signer : signer . publicKey ,
160+ depositorTokenAccount : userTokenAccount ,
161+ vault : vault ,
162+ mint : inputToken ,
163+ tokenProgram : TOKEN_PROGRAM_ID ,
164+ associatedTokenProgram : ASSOCIATED_TOKEN_PROGRAM_ID ,
165+ systemProgram : SystemProgram . programId ,
166+ program : programId ,
167+ } ;
168+
169+ const depositIx = await program . methods
170+ . deposit (
142171 signer . publicKey ,
143172 recipient ,
144173 inputToken ,
@@ -151,16 +180,8 @@ async function nativeDeposit(): Promise<void> {
151180 fillDeadline ,
152181 exclusivityDeadline ,
153182 message
154- ) as any
155- )
156- . accounts ( {
157- state : statePda ,
158- signer : signer . publicKey ,
159- userTokenAccount,
160- vault : vault ,
161- tokenProgram : TOKEN_PROGRAM_ID ,
162- mint : inputToken ,
163- } )
183+ )
184+ . accounts ( depositAccounts )
164185 . instruction ( ) ;
165186
166187 // Create the deposit transaction
0 commit comments