Skip to content

Commit 52ee33a

Browse files
committed
fix: across plus
Signed-off-by: Pablo Maldonado <[email protected]>
1 parent 8756179 commit 52ee33a

File tree

3 files changed

+20
-16
lines changed

3 files changed

+20
-16
lines changed

test/svm/SvmSpoke.Fill.AcrossPlus.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import {
3333
import { MulticallHandler } from "../../target/types/multicall_handler";
3434
import { common } from "./SvmSpoke.common";
3535
import { FillDataParams, FillDataValues } from "../../src/types/svm";
36+
import { getDelegatePdaFillRelay } from "./utils";
3637
const { provider, connection, program, owner, chainId, seedBalance } = common;
3738
const { initializeState, assertSE } = common;
3839

@@ -49,7 +50,8 @@ describe("svm_spoke.fill.across_plus", () => {
4950
finalRecipientATA: PublicKey,
5051
state: PublicKey,
5152
mint: PublicKey,
52-
relayerATA: PublicKey;
53+
relayerATA: PublicKey,
54+
seed: BN;
5355

5456
const relayAmount = 500000;
5557
const mintDecimals = 6;
@@ -66,6 +68,7 @@ describe("svm_spoke.fill.across_plus", () => {
6668

6769
accounts = {
6870
state,
71+
delegate: getDelegatePdaFillRelay(relayHashUint8Array, seed, program.programId),
6972
signer: relayer.publicKey,
7073
instructionParams: program.programId,
7174
mint: mint,
@@ -79,11 +82,14 @@ describe("svm_spoke.fill.across_plus", () => {
7982
}
8083

8184
async function createApproveAndFillIx(multicallHandlerCoder: MulticallHandlerCoder, bufferParams = false) {
85+
const relayHashUint8Array = calculateRelayHashUint8Array(relayData, chainId);
86+
const relayHash = Array.from(relayHashUint8Array);
87+
8288
// Delegate state PDA to pull relayer tokens.
8389
const approveIx = await createApproveCheckedInstruction(
8490
accounts.relayerTokenAccount,
8591
accounts.mint,
86-
accounts.state,
92+
getDelegatePdaFillRelay(relayHashUint8Array, seed, program.programId),
8793
accounts.signer,
8894
BigInt(relayAmount),
8995
mintDecimals
@@ -94,8 +100,6 @@ describe("svm_spoke.fill.across_plus", () => {
94100
...multicallHandlerCoder.compiledKeyMetas,
95101
];
96102

97-
const relayHash = Array.from(calculateRelayHashUint8Array(relayData, chainId));
98-
99103
// Prepare fill instruction.
100104
const fillV3RelayValues: FillDataValues = [relayHash, relayData, new BN(1), relayer.publicKey];
101105
if (bufferParams) {
@@ -133,7 +137,7 @@ describe("svm_spoke.fill.across_plus", () => {
133137
finalRecipient = Keypair.generate().publicKey;
134138
finalRecipientATA = (await getOrCreateAssociatedTokenAccount(connection, payer, mint, finalRecipient)).address;
135139

136-
({ state } = await initializeState());
140+
({ state, seed } = await initializeState());
137141

138142
const initialRelayData = {
139143
depositor: finalRecipient,

test/svm/SvmSpoke.Fill.ts

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ describe("svm_spoke.fill", () => {
7575

7676
accounts = {
7777
state,
78-
delegate: getDelegatePda(relayHashUint8Array, seed),
78+
delegate: getDelegatePdaFillRelay(relayHashUint8Array, seed, program.programId),
7979
signer: relayer.publicKey,
8080
instructionParams: program.programId,
8181
mint: mint,
@@ -89,13 +89,6 @@ describe("svm_spoke.fill", () => {
8989
};
9090
}
9191

92-
const getDelegatePda = (relayHash: Uint8Array, stateSeed: BN) => {
93-
return PublicKey.findProgramAddressSync(
94-
[Buffer.from("delegate"), stateSeed.toArrayLike(Buffer, "le", 8), relayHash],
95-
program.programId
96-
)[0];
97-
};
98-
9992
const approvedFillRelay = async (
10093
fillDataValues: FillDataValues,
10194
calledFillAccounts: FillAccounts = accounts,
@@ -106,7 +99,7 @@ describe("svm_spoke.fill", () => {
10699
const approveIx = await createApproveCheckedInstruction(
107100
calledFillAccounts.relayerTokenAccount,
108101
calledFillAccounts.mint,
109-
getDelegatePda(relayHash, seed),
102+
getDelegatePdaFillRelay(relayHash, seed, program.programId),
110103
calledFillAccounts.signer,
111104
BigInt(fillDataValues[1].outputAmount.toString()),
112105
tokenDecimals,
@@ -466,7 +459,7 @@ describe("svm_spoke.fill", () => {
466459
const approveInstruction = await createApproveCheckedInstruction(
467460
accounts.relayerTokenAccount,
468461
accounts.mint,
469-
getDelegatePda(relayHashUint8Array, seed),
462+
getDelegatePdaFillRelay(relayHashUint8Array, seed, program.programId),
470463
accounts.signer,
471464
BigInt(newRelayData.outputAmount.toString()),
472465
tokenDecimals,
@@ -527,7 +520,7 @@ describe("svm_spoke.fill", () => {
527520
const approveInstruction = await createApproveCheckedInstruction(
528521
accounts.relayerTokenAccount,
529522
accounts.mint,
530-
getDelegatePda(relayHashUint8Array, seed),
523+
getDelegatePdaFillRelay(relayHashUint8Array, seed, program.programId),
531524
accounts.signer,
532525
BigInt(totalFillAmount.toString()),
533526
tokenDecimals,

test/svm/utils.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,3 +211,10 @@ export const generateKeyPairSignerWithSol = async (rpcClient: RpcClient, putativ
211211
});
212212
return signer;
213213
};
214+
215+
export const getDelegatePdaFillRelay = (relayHash: Uint8Array, stateSeed: BN, programId: PublicKey) => {
216+
return PublicKey.findProgramAddressSync(
217+
[Buffer.from("delegate"), stateSeed.toArrayLike(Buffer, "le", 8), relayHash],
218+
programId
219+
)[0];
220+
};

0 commit comments

Comments
 (0)