@@ -20,6 +20,7 @@ import {
2020 calculateRelayHashUint8Array ,
2121 getFillRelayDelegatePda ,
2222 getSpokePoolProgram ,
23+ intToU8Array32 ,
2324 loadFillRelayParams ,
2425 sendTransactionWithLookupTable ,
2526} from "../../src/svm/web3-v1" ;
@@ -40,10 +41,10 @@ const argv = yargs(hideBin(process.argv))
4041 . option ( "exclusiveRelayer" , { type : "string" , demandOption : false , describe : "Exclusive relayer public key" } )
4142 . option ( "inputToken" , { type : "string" , demandOption : true , describe : "Input token public key" } )
4243 . option ( "outputToken" , { type : "string" , demandOption : true , describe : "Output token public key" } )
43- . option ( "inputAmount" , { type : "number " , demandOption : true , describe : "Input amount" } )
44+ . option ( "inputAmount" , { type : "string " , demandOption : true , describe : "Input amount" } )
4445 . option ( "outputAmount" , { type : "number" , demandOption : true , describe : "Output amount" } )
4546 . option ( "originChainId" , { type : "string" , demandOption : true , describe : "Origin chain ID" } )
46- . option ( "depositId" , { type : "array " , demandOption : true , describe : "Deposit ID" } )
47+ . option ( "depositId" , { type : "string " , demandOption : true , describe : "Deposit ID" } )
4748 . option ( "fillDeadline" , { type : "number" , demandOption : false , describe : "Fill deadline" } )
4849 . option ( "exclusivityDeadline" , { type : "number" , demandOption : false , describe : "Exclusivity deadline" } )
4950 . option ( "repaymentChain" , { type : "number" , demandOption : false , description : "Repayment chain ID" } )
@@ -58,10 +59,10 @@ async function fillRelayToRandom(): Promise<void> {
5859 const exclusiveRelayer = new PublicKey ( resolvedArgv . exclusiveRelayer || PublicKey . default . toString ( ) ) ;
5960 const inputToken = new PublicKey ( resolvedArgv . inputToken ) ;
6061 const outputToken = new PublicKey ( resolvedArgv . outputToken ) ;
61- const inputAmount = new BN ( resolvedArgv . inputAmount ) ;
62+ const inputAmount = intToU8Array32 ( new BN ( resolvedArgv . inputAmount ) ) ;
6263 const outputAmount = new BN ( resolvedArgv . outputAmount ) ;
6364 const originChainId = new BN ( resolvedArgv . originChainId ) ;
64- const depositId = ( resolvedArgv . depositId as number [ ] ) . map ( ( id ) => id ) ; // Ensure depositId is an array of BN
65+ const depositId = intToU8Array32 ( new BN ( resolvedArgv . depositId ) ) ;
6566 const fillDeadline = resolvedArgv . fillDeadline || Math . floor ( Date . now ( ) / 1000 ) + 60 ; // Current time + 1 minute
6667 const exclusivityDeadline = resolvedArgv . exclusivityDeadline || Math . floor ( Date . now ( ) / 1000 ) + 30 ; // Current time + 30 seconds
6768 const repaymentChain = new BN ( resolvedArgv . repaymentChain || 1 ) ;
@@ -171,11 +172,17 @@ async function fillRelayToRandom(): Promise<void> {
171172 } ) )
172173 ) ;
173174
174- // Delegate state PDA to pull relayer tokens.
175+ // Delegate to pull relayer tokens.
176+ const delegatePda = getFillRelayDelegatePda (
177+ relayHashUint8Array ,
178+ repaymentChain ,
179+ repaymentAddress ,
180+ program . programId
181+ ) . pda ;
175182 const approveInstruction = await createApproveCheckedInstruction (
176183 relayerTokenAccount ,
177184 outputToken ,
178- statePda ,
185+ delegatePda ,
179186 signer . publicKey ,
180187 BigInt ( relayData . outputAmount . toString ( ) ) ,
181188 tokenDecimals ,
@@ -199,7 +206,7 @@ async function fillRelayToRandom(): Promise<void> {
199206 const fillAccounts = {
200207 state : statePda ,
201208 signer : signer . publicKey ,
202- delegate : getFillRelayDelegatePda ( relayHashUint8Array , repaymentChain , repaymentAddress , program . programId ) . pda ,
209+ delegate : delegatePda ,
203210 instructionParams,
204211 mint : outputToken ,
205212 relayerTokenAccount,
0 commit comments