@across-protocol/contracts 3.0.18 → 3.0.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/artifacts/build-info/9cb910e5bb5dd730cd01af84a0fb0466.json +1 -0
- package/artifacts/contracts/Ink_SpokePool.sol/Ink_SpokePool.dbg.json +4 -0
- package/artifacts/contracts/Ink_SpokePool.sol/Ink_SpokePool.json +2316 -0
- package/contracts/Ink_SpokePool.sol +72 -0
- package/dist/deploy/consts.js +8 -2
- package/dist/deployments/deployments.json +7 -1
- package/dist/hardhat.config.js +17 -0
- package/dist/scripts/svm/addressToPublicKey.js +2 -2
- package/dist/scripts/svm/bridgeLiabilityToHubPool.d.ts +1 -4
- package/dist/scripts/svm/bridgeLiabilityToHubPool.js +5 -15
- package/dist/scripts/svm/closeRelayerPdas.js +3 -3
- package/dist/scripts/svm/executeRebalanceToHubPool.d.ts +1 -4
- package/dist/scripts/svm/executeRebalanceToHubPool.js +6 -16
- package/dist/scripts/svm/executeRebalanceToSpokePool.js +14 -27
- package/dist/scripts/svm/fakeFillWithRandomDistribution.js +6 -7
- package/dist/scripts/svm/initialize.js +2 -2
- package/dist/scripts/svm/proposeRebalanceToSpokePool.js +11 -15
- package/dist/scripts/svm/publicKeyToAddress.js +2 -2
- package/dist/scripts/svm/queryDeposits.js +2 -2
- package/dist/scripts/svm/queryFills.js +10 -11
- package/dist/scripts/svm/remoteHubPoolPauseDeposits.js +10 -24
- package/dist/scripts/svm/remoteHubPoolSetDepositRoute.js +16 -29
- package/dist/scripts/svm/remotePauseDeposits.js +21 -27
- package/dist/scripts/svm/simpleFakeRelayerRepayment.js +3 -3
- package/dist/scripts/svm/simpleFill.js +3 -4
- package/dist/scripts/svm/utils/helpers.d.ts +3 -1
- package/dist/scripts/svm/utils/helpers.js +13 -3
- package/dist/src/svm/coders.d.ts +37 -0
- package/dist/src/svm/coders.js +250 -0
- package/dist/src/svm/conversionUtils.d.ts +22 -0
- package/dist/src/svm/conversionUtils.js +73 -0
- package/dist/src/svm/index.d.ts +6 -0
- package/dist/src/svm/index.js +22 -0
- package/dist/src/svm/instructionParamsUtils.d.ts +31 -0
- package/dist/src/svm/instructionParamsUtils.js +128 -0
- package/dist/src/svm/relayHashUtils.d.ts +30 -0
- package/dist/src/svm/relayHashUtils.js +209 -0
- package/dist/src/svm/solanaProgramUtils.d.ts +38 -0
- package/dist/src/svm/solanaProgramUtils.js +147 -0
- package/dist/src/svm/transactionUtils.d.ts +8 -0
- package/dist/src/svm/transactionUtils.js +55 -0
- package/dist/src/types/svm.d.ts +118 -0
- package/dist/src/types/svm.js +2 -0
- package/dist/test/svm/MulticallHandler.js +2 -2
- package/dist/test/svm/SvmSpoke.Bundle.js +48 -48
- package/dist/test/svm/SvmSpoke.Deposit.js +13 -13
- package/dist/test/svm/SvmSpoke.Fill.AcrossPlus.js +15 -17
- package/dist/test/svm/SvmSpoke.Fill.js +29 -30
- package/dist/test/svm/SvmSpoke.HandleReceiveMessage.js +2 -2
- package/dist/test/svm/SvmSpoke.Ownership.js +6 -6
- package/dist/test/svm/SvmSpoke.RefundClaims.js +5 -5
- package/dist/test/svm/SvmSpoke.Routes.js +3 -3
- package/dist/test/svm/SvmSpoke.SlowFill.AcrossPlus.js +19 -20
- package/dist/test/svm/SvmSpoke.SlowFill.js +18 -18
- package/dist/test/svm/SvmSpoke.TokenBridge.js +13 -13
- package/dist/test/svm/SvmSpoke.common.d.ts +1 -49
- package/dist/test/svm/SvmSpoke.common.js +4 -4
- package/dist/test/svm/cctpHelpers.js +2 -2
- package/dist/test/svm/utils.d.ts +5 -66
- package/dist/test/svm/utils.js +10 -226
- package/dist/typechain/contracts/Ink_SpokePool.d.ts +1251 -0
- package/dist/typechain/contracts/Ink_SpokePool.js +2 -0
- package/dist/typechain/contracts/index.d.ts +1 -0
- package/dist/typechain/factories/contracts/Ink_SpokePool__factory.d.ts +1833 -0
- package/dist/typechain/factories/contracts/Ink_SpokePool__factory.js +2347 -0
- package/dist/typechain/factories/contracts/index.d.ts +1 -0
- package/dist/typechain/factories/contracts/index.js +3 -1
- package/dist/typechain/hardhat.d.ts +9 -0
- package/dist/typechain/index.d.ts +2 -0
- package/dist/typechain/index.js +5 -3
- package/package.json +2 -2
- package/dist/src/SvmUtils.d.ts +0 -72
- package/dist/src/SvmUtils.js +0 -496
|
@@ -29,11 +29,11 @@ const spl_token_1 = require("@solana/spl-token");
|
|
|
29
29
|
const web3_js_1 = require("@solana/web3.js");
|
|
30
30
|
const chai_1 = require("chai");
|
|
31
31
|
const crypto = __importStar(require("crypto"));
|
|
32
|
-
const SvmSpoke_common_1 = require("./SvmSpoke.common");
|
|
33
|
-
const utils_1 = require("./utils");
|
|
34
|
-
const utils_2 = require("../../utils");
|
|
35
|
-
const SvmUtils_1 = require("../../src/SvmUtils");
|
|
36
32
|
const ethers_1 = require("ethers");
|
|
33
|
+
const svm_1 = require("../../src/svm");
|
|
34
|
+
const utils_1 = require("../../utils");
|
|
35
|
+
const SvmSpoke_common_1 = require("./SvmSpoke.common");
|
|
36
|
+
const utils_2 = require("./utils");
|
|
37
37
|
const { provider, program, owner, initializeState, connection, chainId, assertSE } = SvmSpoke_common_1.common;
|
|
38
38
|
describe("svm_spoke.bundle", () => {
|
|
39
39
|
anchor.setProvider(provider);
|
|
@@ -145,7 +145,7 @@ describe("svm_spoke.bundle", () => {
|
|
|
145
145
|
.accounts(relayRootBundleAccounts)
|
|
146
146
|
.rpc();
|
|
147
147
|
// Check for the emitted event
|
|
148
|
-
let events = await (0,
|
|
148
|
+
let events = await (0, svm_1.readEventsUntilFound)(connection, tx, [program]);
|
|
149
149
|
const event = events.find((event) => event.name === "relayedRootBundle")?.data;
|
|
150
150
|
chai_1.assert.isTrue(event.rootBundleId.toString() === rootBundleId.toString(), "Root bundle ID should match");
|
|
151
151
|
chai_1.assert.isTrue(event.relayerRefundRoot.toString() === relayerRefundRootArray.toString(), "Relayer refund root should match");
|
|
@@ -164,7 +164,7 @@ describe("svm_spoke.bundle", () => {
|
|
|
164
164
|
refundAddresses: [relayerA.publicKey, relayerB.publicKey],
|
|
165
165
|
refundAmounts: [relayerARefund, relayerBRefund],
|
|
166
166
|
});
|
|
167
|
-
const merkleTree = new
|
|
167
|
+
const merkleTree = new utils_1.MerkleTree(relayerRefundLeaves, svm_1.relayerRefundHashFn);
|
|
168
168
|
const root = merkleTree.getRoot();
|
|
169
169
|
const proof = merkleTree.getProof(relayerRefundLeaves[0]);
|
|
170
170
|
const leaf = relayerRefundLeaves[0];
|
|
@@ -197,14 +197,14 @@ describe("svm_spoke.bundle", () => {
|
|
|
197
197
|
program: program.programId,
|
|
198
198
|
};
|
|
199
199
|
const proofAsNumbers = proof.map((p) => Array.from(p));
|
|
200
|
-
await (0,
|
|
200
|
+
await (0, svm_1.loadExecuteRelayerRefundLeafParams)(program, owner, stateAccountData.rootBundleId, leaf, proofAsNumbers);
|
|
201
201
|
const tx = await program.methods
|
|
202
202
|
.executeRelayerRefundLeaf()
|
|
203
203
|
.accounts(executeRelayerRefundLeafAccounts)
|
|
204
204
|
.remainingAccounts(remainingAccounts)
|
|
205
205
|
.rpc();
|
|
206
206
|
// Verify the ExecutedRelayerRefundRoot event
|
|
207
|
-
let events = await (0,
|
|
207
|
+
let events = await (0, svm_1.readEventsUntilFound)(connection, tx, [program]);
|
|
208
208
|
let event = events.find((event) => event.name === "executedRelayerRefundRoot")?.data;
|
|
209
209
|
// Remove the expectedValues object and use direct assertions
|
|
210
210
|
assertSE(event.amountToReturn, relayerRefundLeaves[0].amountToReturn, "amountToReturn should match");
|
|
@@ -244,7 +244,7 @@ describe("svm_spoke.bundle", () => {
|
|
|
244
244
|
systemProgram: anchor_1.web3.SystemProgram.programId,
|
|
245
245
|
program: program.programId,
|
|
246
246
|
};
|
|
247
|
-
await (0,
|
|
247
|
+
await (0, svm_1.loadExecuteRelayerRefundLeafParams)(program, owner, stateAccountData.rootBundleId, leaf, proofAsNumbers);
|
|
248
248
|
await program.methods
|
|
249
249
|
.executeRelayerRefundLeaf()
|
|
250
250
|
.accounts(executeRelayerRefundLeafAccounts)
|
|
@@ -260,14 +260,14 @@ describe("svm_spoke.bundle", () => {
|
|
|
260
260
|
const solanaDistributions = 50;
|
|
261
261
|
const evmDistributions = 50;
|
|
262
262
|
const solanaLeafNumber = 13;
|
|
263
|
-
const { relayerRefundLeaves, merkleTree } = (0,
|
|
263
|
+
const { relayerRefundLeaves, merkleTree } = (0, utils_2.buildRelayerRefundMerkleTree)({
|
|
264
264
|
totalEvmDistributions: evmDistributions,
|
|
265
265
|
totalSolanaDistributions: solanaDistributions,
|
|
266
266
|
mixLeaves: false,
|
|
267
267
|
chainId: chainId.toNumber(),
|
|
268
268
|
mint,
|
|
269
269
|
svmRelayers: [relayerA.publicKey, relayerB.publicKey],
|
|
270
|
-
svmRefundAmounts: [new anchor_1.BN((0,
|
|
270
|
+
svmRefundAmounts: [new anchor_1.BN((0, utils_2.randomBigInt)(2).toString()), new anchor_1.BN((0, utils_2.randomBigInt)(2).toString())],
|
|
271
271
|
});
|
|
272
272
|
const invalidRelayerRefundLeaf = {
|
|
273
273
|
isSolana: true,
|
|
@@ -276,7 +276,7 @@ describe("svm_spoke.bundle", () => {
|
|
|
276
276
|
amountToReturn: new anchor_1.BN(0),
|
|
277
277
|
mintPublicKey: mint,
|
|
278
278
|
refundAddresses: [relayerA.publicKey, relayerB.publicKey],
|
|
279
|
-
refundAmounts: [new anchor_1.BN((0,
|
|
279
|
+
refundAmounts: [new anchor_1.BN((0, utils_2.randomBigInt)(2).toString()), new anchor_1.BN((0, utils_2.randomBigInt)(2).toString())],
|
|
280
280
|
};
|
|
281
281
|
const root = merkleTree.getRoot();
|
|
282
282
|
const proof = merkleTree.getProof(relayerRefundLeaves[solanaLeafNumber]);
|
|
@@ -316,7 +316,7 @@ describe("svm_spoke.bundle", () => {
|
|
|
316
316
|
{ pubkey: web3_js_1.Keypair.generate().publicKey, isWritable: true, isSigner: false },
|
|
317
317
|
];
|
|
318
318
|
// Verify valid leaf
|
|
319
|
-
await (0,
|
|
319
|
+
await (0, svm_1.loadExecuteRelayerRefundLeafParams)(program, owner, stateAccountData.rootBundleId, leaf, proofAsNumbers);
|
|
320
320
|
await program.methods
|
|
321
321
|
.executeRelayerRefundLeaf()
|
|
322
322
|
.accounts(executeRelayerRefundLeafAccounts)
|
|
@@ -339,7 +339,7 @@ describe("svm_spoke.bundle", () => {
|
|
|
339
339
|
systemProgram: anchor_1.web3.SystemProgram.programId,
|
|
340
340
|
program: program.programId,
|
|
341
341
|
};
|
|
342
|
-
await (0,
|
|
342
|
+
await (0, svm_1.loadExecuteRelayerRefundLeafParams)(program, owner, stateAccountData.rootBundleId, leaf, proofAsNumbers);
|
|
343
343
|
await program.methods
|
|
344
344
|
.executeRelayerRefundLeaf()
|
|
345
345
|
.accounts(executeRelayerRefundLeafAccounts)
|
|
@@ -365,7 +365,7 @@ describe("svm_spoke.bundle", () => {
|
|
|
365
365
|
systemProgram: anchor_1.web3.SystemProgram.programId,
|
|
366
366
|
program: program.programId,
|
|
367
367
|
};
|
|
368
|
-
await (0,
|
|
368
|
+
await (0, svm_1.loadExecuteRelayerRefundLeafParams)(program, owner, stateAccountData.rootBundleId, invalidRelayerRefundLeaf, proofAsNumbers);
|
|
369
369
|
await program.methods
|
|
370
370
|
.executeRelayerRefundLeaf()
|
|
371
371
|
.accounts(executeRelayerRefundLeafAccounts)
|
|
@@ -380,14 +380,14 @@ describe("svm_spoke.bundle", () => {
|
|
|
380
380
|
it("Test Merkle Proof Verification with Mixed Solana and EVM Leaves", async () => {
|
|
381
381
|
const evmDistributions = 5;
|
|
382
382
|
const solanaDistributions = 5;
|
|
383
|
-
const { relayerRefundLeaves, merkleTree } = (0,
|
|
383
|
+
const { relayerRefundLeaves, merkleTree } = (0, utils_2.buildRelayerRefundMerkleTree)({
|
|
384
384
|
totalEvmDistributions: evmDistributions,
|
|
385
385
|
totalSolanaDistributions: solanaDistributions,
|
|
386
386
|
mixLeaves: true,
|
|
387
387
|
chainId: chainId.toNumber(),
|
|
388
388
|
mint,
|
|
389
389
|
svmRelayers: [relayerA.publicKey, relayerB.publicKey],
|
|
390
|
-
svmRefundAmounts: [new anchor_1.BN((0,
|
|
390
|
+
svmRefundAmounts: [new anchor_1.BN((0, utils_2.randomBigInt)(2).toString()), new anchor_1.BN((0, utils_2.randomBigInt)(2).toString())],
|
|
391
391
|
});
|
|
392
392
|
const root = merkleTree.getRoot();
|
|
393
393
|
let stateAccountData = await program.account.state.fetch(state);
|
|
@@ -425,7 +425,7 @@ describe("svm_spoke.bundle", () => {
|
|
|
425
425
|
systemProgram: anchor_1.web3.SystemProgram.programId,
|
|
426
426
|
program: program.programId,
|
|
427
427
|
};
|
|
428
|
-
await (0,
|
|
428
|
+
await (0, svm_1.loadExecuteRelayerRefundLeafParams)(program, owner, stateAccountData.rootBundleId, leaf, proofAsNumbers);
|
|
429
429
|
await program.methods
|
|
430
430
|
.executeRelayerRefundLeaf()
|
|
431
431
|
.accounts(executeRelayerRefundLeafAccounts)
|
|
@@ -452,14 +452,14 @@ describe("svm_spoke.bundle", () => {
|
|
|
452
452
|
it("Test Merkle Proof Verification with Sorted Solana and EVM Leaves", async () => {
|
|
453
453
|
const evmDistributions = 5;
|
|
454
454
|
const solanaDistributions = 5;
|
|
455
|
-
const { relayerRefundLeaves, merkleTree } = (0,
|
|
455
|
+
const { relayerRefundLeaves, merkleTree } = (0, utils_2.buildRelayerRefundMerkleTree)({
|
|
456
456
|
totalEvmDistributions: evmDistributions,
|
|
457
457
|
totalSolanaDistributions: solanaDistributions,
|
|
458
458
|
mixLeaves: false,
|
|
459
459
|
chainId: chainId.toNumber(),
|
|
460
460
|
mint,
|
|
461
461
|
svmRelayers: [relayerA.publicKey, relayerB.publicKey],
|
|
462
|
-
svmRefundAmounts: [new anchor_1.BN((0,
|
|
462
|
+
svmRefundAmounts: [new anchor_1.BN((0, utils_2.randomBigInt)(2).toString()), new anchor_1.BN((0, utils_2.randomBigInt)(2).toString())],
|
|
463
463
|
});
|
|
464
464
|
const root = merkleTree.getRoot();
|
|
465
465
|
let stateAccountData = await program.account.state.fetch(state);
|
|
@@ -497,7 +497,7 @@ describe("svm_spoke.bundle", () => {
|
|
|
497
497
|
systemProgram: anchor_1.web3.SystemProgram.programId,
|
|
498
498
|
program: program.programId,
|
|
499
499
|
};
|
|
500
|
-
await (0,
|
|
500
|
+
await (0, svm_1.loadExecuteRelayerRefundLeafParams)(program, owner, stateAccountData.rootBundleId, leaf, proofAsNumbers);
|
|
501
501
|
await program.methods
|
|
502
502
|
.executeRelayerRefundLeaf()
|
|
503
503
|
.accounts(executeRelayerRefundLeafAccounts)
|
|
@@ -535,7 +535,7 @@ describe("svm_spoke.bundle", () => {
|
|
|
535
535
|
refundAddresses: [relayerA.publicKey, relayerB.publicKey],
|
|
536
536
|
refundAmounts: [relayerARefund, relayerBRefund],
|
|
537
537
|
});
|
|
538
|
-
const merkleTree = new
|
|
538
|
+
const merkleTree = new utils_1.MerkleTree(relayerRefundLeaves, svm_1.relayerRefundHashFn);
|
|
539
539
|
const root = merkleTree.getRoot();
|
|
540
540
|
const proof = merkleTree.getProof(relayerRefundLeaves[0]);
|
|
541
541
|
const leaf = relayerRefundLeaves[0];
|
|
@@ -565,7 +565,7 @@ describe("svm_spoke.bundle", () => {
|
|
|
565
565
|
systemProgram: anchor_1.web3.SystemProgram.programId,
|
|
566
566
|
program: program.programId,
|
|
567
567
|
};
|
|
568
|
-
await (0,
|
|
568
|
+
await (0, svm_1.loadExecuteRelayerRefundLeafParams)(program, owner, stateAccountData.rootBundleId, leaf, proofAsNumbers);
|
|
569
569
|
await program.methods
|
|
570
570
|
.executeRelayerRefundLeaf()
|
|
571
571
|
.accounts(executeRelayerRefundLeafAccounts)
|
|
@@ -589,7 +589,7 @@ describe("svm_spoke.bundle", () => {
|
|
|
589
589
|
refundAddresses: [relayerA.publicKey, relayerB.publicKey],
|
|
590
590
|
refundAmounts: [relayerARefund, relayerBRefund],
|
|
591
591
|
});
|
|
592
|
-
const merkleTree = new
|
|
592
|
+
const merkleTree = new utils_1.MerkleTree(relayerRefundLeaves, svm_1.relayerRefundHashFn);
|
|
593
593
|
const root = merkleTree.getRoot();
|
|
594
594
|
const proof = merkleTree.getProof(relayerRefundLeaves[0]);
|
|
595
595
|
const leaf = relayerRefundLeaves[0];
|
|
@@ -619,7 +619,7 @@ describe("svm_spoke.bundle", () => {
|
|
|
619
619
|
systemProgram: anchor_1.web3.SystemProgram.programId,
|
|
620
620
|
program: program.programId,
|
|
621
621
|
};
|
|
622
|
-
await (0,
|
|
622
|
+
await (0, svm_1.loadExecuteRelayerRefundLeafParams)(program, owner, stateAccountData.rootBundleId, leaf, proofAsNumbers);
|
|
623
623
|
await program.methods
|
|
624
624
|
.executeRelayerRefundLeaf()
|
|
625
625
|
.accounts(executeRelayerRefundLeafAccounts)
|
|
@@ -645,7 +645,7 @@ describe("svm_spoke.bundle", () => {
|
|
|
645
645
|
refundAmounts: [relayerRefundAmount],
|
|
646
646
|
});
|
|
647
647
|
}
|
|
648
|
-
const merkleTree = new
|
|
648
|
+
const merkleTree = new utils_1.MerkleTree(relayerRefundLeaves, svm_1.relayerRefundHashFn);
|
|
649
649
|
const root = merkleTree.getRoot();
|
|
650
650
|
const proof = relayerRefundLeaves.map((leaf) => merkleTree.getProof(leaf).map((p) => Array.from(p)));
|
|
651
651
|
let stateAccountData = await program.account.state.fetch(state);
|
|
@@ -673,7 +673,7 @@ describe("svm_spoke.bundle", () => {
|
|
|
673
673
|
systemProgram: anchor_1.web3.SystemProgram.programId,
|
|
674
674
|
program: program.programId,
|
|
675
675
|
};
|
|
676
|
-
await (0,
|
|
676
|
+
await (0, svm_1.loadExecuteRelayerRefundLeafParams)(program, owner, stateAccountData.rootBundleId, relayerRefundLeaves[i], proof[i]);
|
|
677
677
|
await program.methods
|
|
678
678
|
.executeRelayerRefundLeaf()
|
|
679
679
|
.accounts(executeRelayerRefundLeafAccounts)
|
|
@@ -699,7 +699,7 @@ describe("svm_spoke.bundle", () => {
|
|
|
699
699
|
systemProgram: anchor_1.web3.SystemProgram.programId,
|
|
700
700
|
program: program.programId,
|
|
701
701
|
};
|
|
702
|
-
await (0,
|
|
702
|
+
await (0, svm_1.loadExecuteRelayerRefundLeafParams)(program, owner, stateAccountData.rootBundleId, relayerRefundLeaves[i], proof[i]);
|
|
703
703
|
await program.methods
|
|
704
704
|
.executeRelayerRefundLeaf()
|
|
705
705
|
.accounts(executeRelayerRefundLeafAccounts)
|
|
@@ -825,9 +825,9 @@ describe("svm_spoke.bundle", () => {
|
|
|
825
825
|
await program.methods.initializeClaimAccount(mint, tokenOwner).rpc();
|
|
826
826
|
refundAccounts.push(claimAccount);
|
|
827
827
|
}
|
|
828
|
-
refundAmounts.push(new anchor_1.BN((0,
|
|
828
|
+
refundAmounts.push(new anchor_1.BN((0, utils_2.randomBigInt)(2).toString()));
|
|
829
829
|
}
|
|
830
|
-
const { relayerRefundLeaves, merkleTree } = (0,
|
|
830
|
+
const { relayerRefundLeaves, merkleTree } = (0, utils_2.buildRelayerRefundMerkleTree)({
|
|
831
831
|
totalEvmDistributions: evmDistributions,
|
|
832
832
|
totalSolanaDistributions: testConfig.solanaDistributions,
|
|
833
833
|
mixLeaves: false,
|
|
@@ -879,7 +879,7 @@ describe("svm_spoke.bundle", () => {
|
|
|
879
879
|
])
|
|
880
880
|
: [];
|
|
881
881
|
// Build the instruction to execute relayer refund leaf and write its instruction args to the data account.
|
|
882
|
-
await (0,
|
|
882
|
+
await (0, svm_1.loadExecuteRelayerRefundLeafParams)(program, owner, stateAccountData.rootBundleId, leaf, proofAsNumbers);
|
|
883
883
|
const executeInstruction = !testConfig.deferredRefunds
|
|
884
884
|
? await program.methods
|
|
885
885
|
.executeRelayerRefundLeaf()
|
|
@@ -904,7 +904,7 @@ describe("svm_spoke.bundle", () => {
|
|
|
904
904
|
// Add relay refund leaf execution instruction.
|
|
905
905
|
instructions.push(executeInstruction);
|
|
906
906
|
// Execute using ALT.
|
|
907
|
-
await (0,
|
|
907
|
+
await (0, svm_1.sendTransactionWithLookupTable)(connection, instructions, anchor.AnchorProvider.env().wallet.payer);
|
|
908
908
|
// Verify all refund account balances (either token or claim accounts).
|
|
909
909
|
await new Promise((resolve) => setTimeout(resolve, 1000)); // Make sure account balances have been synced.
|
|
910
910
|
const refundBalances = await Promise.all(refundAccounts.map(async (account) => {
|
|
@@ -949,7 +949,7 @@ describe("svm_spoke.bundle", () => {
|
|
|
949
949
|
refundAddresses: [],
|
|
950
950
|
refundAmounts: [],
|
|
951
951
|
});
|
|
952
|
-
const merkleTree = new
|
|
952
|
+
const merkleTree = new utils_1.MerkleTree(relayerRefundLeaves, svm_1.relayerRefundHashFn);
|
|
953
953
|
const root = merkleTree.getRoot();
|
|
954
954
|
const proof = merkleTree.getProof(relayerRefundLeaves[0]);
|
|
955
955
|
const leaf = relayerRefundLeaves[0];
|
|
@@ -973,7 +973,7 @@ describe("svm_spoke.bundle", () => {
|
|
|
973
973
|
systemProgram: anchor_1.web3.SystemProgram.programId,
|
|
974
974
|
program: program.programId,
|
|
975
975
|
};
|
|
976
|
-
await (0,
|
|
976
|
+
await (0, svm_1.loadExecuteRelayerRefundLeafParams)(program, owner, stateAccountData.rootBundleId, leaf, proofAsNumbers);
|
|
977
977
|
await program.methods.executeRelayerRefundLeaf().accounts(executeRelayerRefundLeafAccounts).rpc();
|
|
978
978
|
};
|
|
979
979
|
const zeroAmountToReturn = new anchor_1.BN(0);
|
|
@@ -1006,7 +1006,7 @@ describe("svm_spoke.bundle", () => {
|
|
|
1006
1006
|
refundAmounts: [relayerRefundAmount],
|
|
1007
1007
|
});
|
|
1008
1008
|
}
|
|
1009
|
-
const merkleTree = new
|
|
1009
|
+
const merkleTree = new utils_1.MerkleTree(relayerRefundLeaves, svm_1.relayerRefundHashFn);
|
|
1010
1010
|
const root = merkleTree.getRoot();
|
|
1011
1011
|
const proof = relayerRefundLeaves.map((leaf) => merkleTree.getProof(leaf).map((p) => Array.from(p)));
|
|
1012
1012
|
let stateAccountData = await program.account.state.fetch(state);
|
|
@@ -1034,7 +1034,7 @@ describe("svm_spoke.bundle", () => {
|
|
|
1034
1034
|
systemProgram: anchor_1.web3.SystemProgram.programId,
|
|
1035
1035
|
program: program.programId,
|
|
1036
1036
|
};
|
|
1037
|
-
await (0,
|
|
1037
|
+
await (0, svm_1.loadExecuteRelayerRefundLeafParams)(program, owner, stateAccountData.rootBundleId, relayerRefundLeaves[i], proof[i]);
|
|
1038
1038
|
await program.methods
|
|
1039
1039
|
.executeRelayerRefundLeaf()
|
|
1040
1040
|
.accounts(executeRelayerRefundLeafAccounts)
|
|
@@ -1060,7 +1060,7 @@ describe("svm_spoke.bundle", () => {
|
|
|
1060
1060
|
refundAddresses: [relayerA.publicKey, relayerB.publicKey],
|
|
1061
1061
|
refundAmounts: [relayerARefund],
|
|
1062
1062
|
});
|
|
1063
|
-
const merkleTree = new
|
|
1063
|
+
const merkleTree = new utils_1.MerkleTree(relayerRefundLeaves, svm_1.relayerRefundHashFn);
|
|
1064
1064
|
const root = merkleTree.getRoot();
|
|
1065
1065
|
const proof = merkleTree.getProof(relayerRefundLeaves[0]);
|
|
1066
1066
|
const leaf = relayerRefundLeaves[0];
|
|
@@ -1090,7 +1090,7 @@ describe("svm_spoke.bundle", () => {
|
|
|
1090
1090
|
program: program.programId,
|
|
1091
1091
|
};
|
|
1092
1092
|
const proofAsNumbers = proof.map((p) => Array.from(p));
|
|
1093
|
-
await (0,
|
|
1093
|
+
await (0, svm_1.loadExecuteRelayerRefundLeafParams)(program, owner, stateAccountData.rootBundleId, leaf, proofAsNumbers);
|
|
1094
1094
|
// Mismatched refund amount and account length should fail.
|
|
1095
1095
|
try {
|
|
1096
1096
|
await program.methods
|
|
@@ -1134,7 +1134,7 @@ describe("svm_spoke.bundle", () => {
|
|
|
1134
1134
|
refundAddresses: [relayerA.publicKey, relayerB.publicKey],
|
|
1135
1135
|
refundAmounts: [relayerARefund, relayerBRefund],
|
|
1136
1136
|
});
|
|
1137
|
-
const merkleTree = new
|
|
1137
|
+
const merkleTree = new utils_1.MerkleTree(relayerRefundLeaves, svm_1.relayerRefundHashFn);
|
|
1138
1138
|
const root = merkleTree.getRoot();
|
|
1139
1139
|
const proof = merkleTree.getProof(relayerRefundLeaves[0]);
|
|
1140
1140
|
const leaf = relayerRefundLeaves[0];
|
|
@@ -1165,7 +1165,7 @@ describe("svm_spoke.bundle", () => {
|
|
|
1165
1165
|
program: program.programId,
|
|
1166
1166
|
};
|
|
1167
1167
|
const proofAsNumbers = proof.map((p) => Array.from(p));
|
|
1168
|
-
await (0,
|
|
1168
|
+
await (0, svm_1.loadExecuteRelayerRefundLeafParams)(program, owner, stateAccountData.rootBundleId, leaf, proofAsNumbers);
|
|
1169
1169
|
if (!testConfig.deferredRefunds) {
|
|
1170
1170
|
return await program.methods
|
|
1171
1171
|
.executeRelayerRefundLeaf()
|
|
@@ -1183,13 +1183,13 @@ describe("svm_spoke.bundle", () => {
|
|
|
1183
1183
|
};
|
|
1184
1184
|
it("No deferred refunds in all Token Accounts", async () => {
|
|
1185
1185
|
const tx = await executeRelayerRefundLeaf({ deferredRefunds: false });
|
|
1186
|
-
const events = await (0,
|
|
1186
|
+
const events = await (0, svm_1.readEventsUntilFound)(connection, tx, [program]);
|
|
1187
1187
|
const event = events.find((event) => event.name === "executedRelayerRefundRoot")?.data;
|
|
1188
1188
|
chai_1.assert.isFalse(event.deferredRefunds, "deferredRefunds should be false");
|
|
1189
1189
|
});
|
|
1190
1190
|
it("Deferred refunds in all Claim Accounts", async () => {
|
|
1191
1191
|
const tx = await executeRelayerRefundLeaf({ deferredRefunds: true });
|
|
1192
|
-
const events = await (0,
|
|
1192
|
+
const events = await (0, svm_1.readEventsUntilFound)(connection, tx, [program]);
|
|
1193
1193
|
const event = events.find((event) => event.name === "executedRelayerRefundRoot")?.data;
|
|
1194
1194
|
chai_1.assert.isTrue(event.deferredRefunds, "deferredRefunds should be true");
|
|
1195
1195
|
});
|
|
@@ -1208,7 +1208,7 @@ describe("svm_spoke.bundle", () => {
|
|
|
1208
1208
|
refundAddresses: [relayerA.publicKey],
|
|
1209
1209
|
refundAmounts: [relayerARefund],
|
|
1210
1210
|
});
|
|
1211
|
-
const merkleTree = new
|
|
1211
|
+
const merkleTree = new utils_1.MerkleTree(relayerRefundLeaves, svm_1.relayerRefundHashFn);
|
|
1212
1212
|
const root = merkleTree.getRoot();
|
|
1213
1213
|
const proof = merkleTree.getProof(relayerRefundLeaves[0]);
|
|
1214
1214
|
const leaf = relayerRefundLeaves[0];
|
|
@@ -1234,7 +1234,7 @@ describe("svm_spoke.bundle", () => {
|
|
|
1234
1234
|
program: program.programId,
|
|
1235
1235
|
};
|
|
1236
1236
|
const proofAsNumbers = proof.map((p) => Array.from(p));
|
|
1237
|
-
await (0,
|
|
1237
|
+
await (0, svm_1.loadExecuteRelayerRefundLeafParams)(program, owner, stateAccountData.rootBundleId, leaf, proofAsNumbers);
|
|
1238
1238
|
// Leaf execution should fail due to insufficient balance.
|
|
1239
1239
|
try {
|
|
1240
1240
|
await program.methods
|
|
@@ -1282,7 +1282,7 @@ describe("svm_spoke.bundle", () => {
|
|
|
1282
1282
|
]);
|
|
1283
1283
|
return ethers_1.ethers.utils.keccak256(contentToHash);
|
|
1284
1284
|
};
|
|
1285
|
-
const merkleTree = new
|
|
1285
|
+
const merkleTree = new utils_1.MerkleTree(relayerRefundLeaves, customRelayerRefundHashFn);
|
|
1286
1286
|
const root = merkleTree.getRoot();
|
|
1287
1287
|
const proof = merkleTree.getProof(relayerRefundLeaves[0]);
|
|
1288
1288
|
const leaf = relayerRefundLeaves[0];
|
|
@@ -1312,7 +1312,7 @@ describe("svm_spoke.bundle", () => {
|
|
|
1312
1312
|
program: program.programId,
|
|
1313
1313
|
};
|
|
1314
1314
|
const proofAsNumbers = proof.map((p) => Array.from(p));
|
|
1315
|
-
await (0,
|
|
1315
|
+
await (0, svm_1.loadExecuteRelayerRefundLeafParams)(program, owner, stateAccountData.rootBundleId, leaf, proofAsNumbers);
|
|
1316
1316
|
try {
|
|
1317
1317
|
await program.methods
|
|
1318
1318
|
.executeRelayerRefundLeaf()
|
|
@@ -1359,7 +1359,7 @@ describe("svm_spoke.bundle", () => {
|
|
|
1359
1359
|
]);
|
|
1360
1360
|
return ethers_1.ethers.utils.keccak256(contentToHash);
|
|
1361
1361
|
};
|
|
1362
|
-
const merkleTree = new
|
|
1362
|
+
const merkleTree = new utils_1.MerkleTree(relayerRefundLeaves, customRelayerRefundHashFn);
|
|
1363
1363
|
const root = merkleTree.getRoot();
|
|
1364
1364
|
const proof = merkleTree.getProof(relayerRefundLeaves[0]);
|
|
1365
1365
|
const leaf = relayerRefundLeaves[0];
|
|
@@ -1389,7 +1389,7 @@ describe("svm_spoke.bundle", () => {
|
|
|
1389
1389
|
program: program.programId,
|
|
1390
1390
|
};
|
|
1391
1391
|
const proofAsNumbers = proof.map((p) => Array.from(p));
|
|
1392
|
-
await (0,
|
|
1392
|
+
await (0, svm_1.loadExecuteRelayerRefundLeafParams)(program, owner, stateAccountData.rootBundleId, leaf, proofAsNumbers);
|
|
1393
1393
|
try {
|
|
1394
1394
|
await program.methods
|
|
1395
1395
|
.executeRelayerRefundLeaf()
|
|
@@ -29,7 +29,7 @@ const ethers_1 = require("ethers");
|
|
|
29
29
|
const spl_token_1 = require("@solana/spl-token");
|
|
30
30
|
const web3_js_1 = require("@solana/web3.js");
|
|
31
31
|
const SvmSpoke_common_1 = require("./SvmSpoke.common");
|
|
32
|
-
const
|
|
32
|
+
const svm_1 = require("../../src/svm");
|
|
33
33
|
const { provider, connection, program, owner, seedBalance, initializeState, depositData } = SvmSpoke_common_1.common;
|
|
34
34
|
const { createRoutePda, getVaultAta, assertSE, assert, getCurrentTime, depositQuoteTimeBuffer, fillDeadlineBuffer } = SvmSpoke_common_1.common;
|
|
35
35
|
const maxExclusivityOffsetSeconds = new anchor_1.BN(365 * 24 * 60 * 60); // 1 year in seconds
|
|
@@ -124,9 +124,9 @@ describe("svm_spoke.deposit", () => {
|
|
|
124
124
|
// Execute the first deposit_v3 call
|
|
125
125
|
let depositDataValues = Object.values(depositData);
|
|
126
126
|
const tx = await approvedDepositV3(depositDataValues);
|
|
127
|
-
let events = await (0,
|
|
127
|
+
let events = await (0, svm_1.readEventsUntilFound)(connection, tx, [program]);
|
|
128
128
|
let event = events[0].data; // 0th event is the latest event
|
|
129
|
-
const expectedValues1 = { ...depositData, depositId: (0,
|
|
129
|
+
const expectedValues1 = { ...depositData, depositId: (0, svm_1.intToU8Array32)(1) }; // Verify the event props emitted match the depositData.
|
|
130
130
|
for (let [key, value] of Object.entries(expectedValues1)) {
|
|
131
131
|
if (key === "exclusivityParameter")
|
|
132
132
|
key = "exclusivityDeadline"; // the prop and the event names differ on this key.
|
|
@@ -134,9 +134,9 @@ describe("svm_spoke.deposit", () => {
|
|
|
134
134
|
}
|
|
135
135
|
// Execute the second deposit_v3 call
|
|
136
136
|
const tx2 = await approvedDepositV3(depositDataValues);
|
|
137
|
-
events = await (0,
|
|
137
|
+
events = await (0, svm_1.readEventsUntilFound)(connection, tx2, [program]);
|
|
138
138
|
event = events[0].data; // 0th event is the latest event.
|
|
139
|
-
const expectedValues2 = { ...expectedValues1, depositId: (0,
|
|
139
|
+
const expectedValues2 = { ...expectedValues1, depositId: (0, svm_1.intToU8Array32)(2) }; // Verify the event props emitted match the depositData.
|
|
140
140
|
for (let [key, value] of Object.entries(expectedValues2)) {
|
|
141
141
|
if (key === "exclusivityParameter")
|
|
142
142
|
key = "exclusivityDeadline"; // the prop and the event names differ on this key.
|
|
@@ -301,11 +301,11 @@ describe("svm_spoke.deposit", () => {
|
|
|
301
301
|
destinationChainId: fakeRouteChainId,
|
|
302
302
|
});
|
|
303
303
|
const tx = await approvedDepositV3(depositDataValues, fakeDepositAccounts);
|
|
304
|
-
let events = await (0,
|
|
304
|
+
let events = await (0, svm_1.readEventsUntilFound)(connection, tx, [program]);
|
|
305
305
|
let event = events[0].data; // 0th event is the latest event.
|
|
306
306
|
const expectedValues = {
|
|
307
307
|
...{ ...depositData, destinationChainId: fakeRouteChainId },
|
|
308
|
-
depositId: (0,
|
|
308
|
+
depositId: (0, svm_1.intToU8Array32)(1),
|
|
309
309
|
}; // Verify the event props emitted match the depositData.
|
|
310
310
|
for (let [key, value] of Object.entries(expectedValues)) {
|
|
311
311
|
if (key === "exclusivityParameter")
|
|
@@ -344,7 +344,7 @@ describe("svm_spoke.deposit", () => {
|
|
|
344
344
|
.instruction();
|
|
345
345
|
const depositTx = new web3_js_1.Transaction().add(approveIx, depositIx);
|
|
346
346
|
const tx = await (0, web3_js_1.sendAndConfirmTransaction)(connection, depositTx, [payer, depositor]);
|
|
347
|
-
const events = await (0,
|
|
347
|
+
const events = await (0, svm_1.readEventsUntilFound)(connection, tx, [program]);
|
|
348
348
|
const event = events[0].data; // 0th event is the latest event.
|
|
349
349
|
// Verify the event props emitted match the expected values
|
|
350
350
|
const currentTime = await getCurrentTime(program, state);
|
|
@@ -352,7 +352,7 @@ describe("svm_spoke.deposit", () => {
|
|
|
352
352
|
...depositData,
|
|
353
353
|
quoteTimestamp: currentTime,
|
|
354
354
|
fillDeadline: currentTime + fillDeadlineOffset,
|
|
355
|
-
depositId: (0,
|
|
355
|
+
depositId: (0, svm_1.intToU8Array32)(1),
|
|
356
356
|
};
|
|
357
357
|
for (let [key, value] of Object.entries(expectedValues)) {
|
|
358
358
|
if (key === "exclusivityParameter")
|
|
@@ -404,7 +404,7 @@ describe("svm_spoke.deposit", () => {
|
|
|
404
404
|
depositData.exclusivityParameter = maxExclusivityOffsetSeconds;
|
|
405
405
|
const depositDataValues = Object.values(depositData);
|
|
406
406
|
const tx = await approvedDepositV3(depositDataValues);
|
|
407
|
-
const events = await (0,
|
|
407
|
+
const events = await (0, svm_1.readEventsUntilFound)(connection, tx, [program]);
|
|
408
408
|
const event = events[0].data; // 0th event is the latest event
|
|
409
409
|
assertSE(event.exclusivityDeadline, currentTime.add(maxExclusivityOffsetSeconds), "exclusivityDeadline should be current time + offset");
|
|
410
410
|
});
|
|
@@ -416,7 +416,7 @@ describe("svm_spoke.deposit", () => {
|
|
|
416
416
|
depositData.exclusivityParameter = exclusivityDeadlineTimestamp;
|
|
417
417
|
const depositDataValues = Object.values(depositData);
|
|
418
418
|
const tx = await approvedDepositV3(depositDataValues);
|
|
419
|
-
const events = await (0,
|
|
419
|
+
const events = await (0, svm_1.readEventsUntilFound)(connection, tx, [program]);
|
|
420
420
|
const event = events[0].data; // 0th event is the latest event;
|
|
421
421
|
assertSE(event.exclusivityDeadline, exclusivityDeadlineTimestamp, "exclusivityDeadline should be passed in time");
|
|
422
422
|
});
|
|
@@ -428,7 +428,7 @@ describe("svm_spoke.deposit", () => {
|
|
|
428
428
|
depositData.exclusivityParameter = zeroExclusivity;
|
|
429
429
|
const depositDataValues = Object.values(depositData);
|
|
430
430
|
const tx = await approvedDepositV3(depositDataValues);
|
|
431
|
-
const events = await (0,
|
|
431
|
+
const events = await (0, svm_1.readEventsUntilFound)(connection, tx, [program]);
|
|
432
432
|
const event = events[0].data; // 0th event is the latest event;
|
|
433
433
|
assertSE(event.exclusivityDeadline, zeroExclusivity, "Exclusivity deadline should always be 0");
|
|
434
434
|
});
|
|
@@ -458,7 +458,7 @@ describe("svm_spoke.deposit", () => {
|
|
|
458
458
|
const tx = await (0, web3_js_1.sendAndConfirmTransaction)(connection, unsafeDepositTx, [payer, depositor]);
|
|
459
459
|
// Wait for a short period to ensure the event is emitted
|
|
460
460
|
// Read and verify the event
|
|
461
|
-
const events = await (0,
|
|
461
|
+
const events = await (0, svm_1.readEventsUntilFound)(connection, tx, [program]);
|
|
462
462
|
const event = events[0].data; // Assuming the latest event is the one we want
|
|
463
463
|
const expectedValues = { ...depositData, depositId: expectedDepositIdArray };
|
|
464
464
|
for (let [key, value] of Object.entries(expectedValues)) {
|
|
@@ -27,10 +27,8 @@ const anchor = __importStar(require("@coral-xyz/anchor"));
|
|
|
27
27
|
const anchor_1 = require("@coral-xyz/anchor");
|
|
28
28
|
const spl_token_1 = require("@solana/spl-token");
|
|
29
29
|
const web3_js_1 = require("@solana/web3.js");
|
|
30
|
-
const
|
|
31
|
-
const SvmUtils_1 = require("../../src/SvmUtils");
|
|
30
|
+
const svm_1 = require("../../src/svm");
|
|
32
31
|
const SvmSpoke_common_1 = require("./SvmSpoke.common");
|
|
33
|
-
const utils_2 = require("./utils");
|
|
34
32
|
const { provider, connection, program, owner, chainId, seedBalance } = SvmSpoke_common_1.common;
|
|
35
33
|
const { initializeState, assertSE } = SvmSpoke_common_1.common;
|
|
36
34
|
describe("svm_spoke.fill.across_plus", () => {
|
|
@@ -45,7 +43,7 @@ describe("svm_spoke.fill.across_plus", () => {
|
|
|
45
43
|
let accounts; // Store accounts to simplify contract interactions.
|
|
46
44
|
function updateRelayData(newRelayData) {
|
|
47
45
|
relayData = newRelayData;
|
|
48
|
-
const relayHashUint8Array = (0,
|
|
46
|
+
const relayHashUint8Array = (0, svm_1.calculateRelayHashUint8Array)(relayData, chainId);
|
|
49
47
|
const [fillStatusPDA] = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("fills"), relayHashUint8Array], program.programId);
|
|
50
48
|
accounts = {
|
|
51
49
|
state,
|
|
@@ -67,11 +65,11 @@ describe("svm_spoke.fill.across_plus", () => {
|
|
|
67
65
|
{ pubkey: handlerProgram.programId, isSigner: false, isWritable: false },
|
|
68
66
|
...multicallHandlerCoder.compiledKeyMetas,
|
|
69
67
|
];
|
|
70
|
-
const relayHash = Array.from((0,
|
|
68
|
+
const relayHash = Array.from((0, svm_1.calculateRelayHashUint8Array)(relayData, chainId));
|
|
71
69
|
// Prepare fill instruction.
|
|
72
70
|
const fillV3RelayValues = [relayHash, relayData, new anchor_1.BN(1), relayer.publicKey];
|
|
73
71
|
if (bufferParams) {
|
|
74
|
-
await (0,
|
|
72
|
+
await (0, svm_1.loadFillV3RelayParams)(program, relayer, fillV3RelayValues[1], fillV3RelayValues[2], fillV3RelayValues[3]);
|
|
75
73
|
[accounts.instructionParams] = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("instruction_params"), relayer.publicKey.toBuffer()], program.programId);
|
|
76
74
|
}
|
|
77
75
|
const fillV3RelayParams = bufferParams
|
|
@@ -105,7 +103,7 @@ describe("svm_spoke.fill.across_plus", () => {
|
|
|
105
103
|
inputAmount: new anchor_1.BN(relayAmount),
|
|
106
104
|
outputAmount: new anchor_1.BN(relayAmount),
|
|
107
105
|
originChainId: new anchor_1.BN(1),
|
|
108
|
-
depositId: (0,
|
|
106
|
+
depositId: (0, svm_1.intToU8Array32)(Math.floor(Math.random() * 1000000)), // force that we always have a new deposit id.
|
|
109
107
|
fillDeadline: new anchor_1.BN(Math.floor(Date.now() / 1000) + 60), // 1 minute from now
|
|
110
108
|
exclusivityDeadline: new anchor_1.BN(Math.floor(Date.now() / 1000) + 30), // 30 seconds from now
|
|
111
109
|
message: Buffer.from(""), // Will be populated in the tests below.
|
|
@@ -116,9 +114,9 @@ describe("svm_spoke.fill.across_plus", () => {
|
|
|
116
114
|
const iRelayerBal = (await (0, spl_token_1.getAccount)(connection, relayerATA)).amount;
|
|
117
115
|
// Construct ix to transfer all tokens from handler to the final recipient.
|
|
118
116
|
const transferIx = (0, spl_token_1.createTransferCheckedInstruction)(handlerATA, mint, finalRecipientATA, handlerSigner, relayData.outputAmount, mintDecimals);
|
|
119
|
-
const multicallHandlerCoder = new
|
|
117
|
+
const multicallHandlerCoder = new svm_1.MulticallHandlerCoder([transferIx]);
|
|
120
118
|
const handlerMessage = multicallHandlerCoder.encode();
|
|
121
|
-
const message = new
|
|
119
|
+
const message = new svm_1.AcrossPlusMessageCoder({
|
|
122
120
|
handler: handlerProgram.programId,
|
|
123
121
|
readOnlyLen: multicallHandlerCoder.readOnlyLen,
|
|
124
122
|
valueAmount: new anchor_1.BN(0),
|
|
@@ -153,9 +151,9 @@ describe("svm_spoke.fill.across_plus", () => {
|
|
|
153
151
|
const transferInstruction = (0, spl_token_1.createTransferCheckedInstruction)(handlerATA, mint, recipientATA, handlerSigner, distributionAmount, mintDecimals);
|
|
154
152
|
transferInstructions.push(transferInstruction);
|
|
155
153
|
}
|
|
156
|
-
const multicallHandlerCoder = new
|
|
154
|
+
const multicallHandlerCoder = new svm_1.MulticallHandlerCoder(transferInstructions);
|
|
157
155
|
const handlerMessage = multicallHandlerCoder.encode();
|
|
158
|
-
const message = new
|
|
156
|
+
const message = new svm_1.AcrossPlusMessageCoder({
|
|
159
157
|
handler: handlerProgram.programId,
|
|
160
158
|
readOnlyLen: multicallHandlerCoder.readOnlyLen,
|
|
161
159
|
valueAmount: new anchor_1.BN(0),
|
|
@@ -174,7 +172,7 @@ describe("svm_spoke.fill.across_plus", () => {
|
|
|
174
172
|
const { approveIx, fillIx } = await createApproveAndFillIx(multicallHandlerCoder, bufferParams);
|
|
175
173
|
// Fill using the ALT.
|
|
176
174
|
const computeBudgetIx = web3_js_1.ComputeBudgetProgram.setComputeUnitLimit({ units: 1_400_000 });
|
|
177
|
-
await (0,
|
|
175
|
+
await (0, svm_1.sendTransactionWithLookupTable)(connection, [computeBudgetIx, approveIx, fillIx], relayer);
|
|
178
176
|
// Verify relayer's balance after the fill
|
|
179
177
|
await new Promise((resolve) => setTimeout(resolve, 500)); // Make sure token transfers get processed.
|
|
180
178
|
const fRelayerBal = (await (0, spl_token_1.getAccount)(connection, relayerATA)).amount;
|
|
@@ -200,9 +198,9 @@ describe("svm_spoke.fill.across_plus", () => {
|
|
|
200
198
|
it("Sends lamports from the relayer to value recipient", async () => {
|
|
201
199
|
const valueAmount = new anchor_1.BN(1_000_000_000);
|
|
202
200
|
const valueRecipient = web3_js_1.Keypair.generate().publicKey;
|
|
203
|
-
const multicallHandlerCoder = new
|
|
201
|
+
const multicallHandlerCoder = new svm_1.MulticallHandlerCoder([], valueRecipient);
|
|
204
202
|
const handlerMessage = multicallHandlerCoder.encode();
|
|
205
|
-
const message = new
|
|
203
|
+
const message = new svm_1.AcrossPlusMessageCoder({
|
|
206
204
|
handler: handlerProgram.programId,
|
|
207
205
|
readOnlyLen: multicallHandlerCoder.readOnlyLen,
|
|
208
206
|
valueAmount,
|
|
@@ -232,9 +230,9 @@ describe("svm_spoke.fill.across_plus", () => {
|
|
|
232
230
|
// Construct ix to transfer all tokens from handler to the recipient ATA.
|
|
233
231
|
const transferInstruction = (0, spl_token_1.createTransferCheckedInstruction)(handlerATA, mint, anotherRecipientATA, handlerSigner, relayData.outputAmount, mintDecimals);
|
|
234
232
|
// Encode both instructions with handler PDA as the payer for ATA initialization.
|
|
235
|
-
const multicallHandlerCoder = new
|
|
233
|
+
const multicallHandlerCoder = new svm_1.MulticallHandlerCoder([createTokenAccountInstruction, transferInstruction], handlerSigner);
|
|
236
234
|
const handlerMessage = multicallHandlerCoder.encode();
|
|
237
|
-
const message = new
|
|
235
|
+
const message = new svm_1.AcrossPlusMessageCoder({
|
|
238
236
|
handler: handlerProgram.programId,
|
|
239
237
|
readOnlyLen: multicallHandlerCoder.readOnlyLen,
|
|
240
238
|
valueAmount: new anchor_1.BN(valueAmount), // Must exactly cover ATA creation.
|
|
@@ -248,7 +246,7 @@ describe("svm_spoke.fill.across_plus", () => {
|
|
|
248
246
|
// Prepare approval and fill instructions as we will need to use Address Lookup Table (ALT).
|
|
249
247
|
const { approveIx, fillIx } = await createApproveAndFillIx(multicallHandlerCoder);
|
|
250
248
|
// Fill using the ALT.
|
|
251
|
-
await (0,
|
|
249
|
+
await (0, svm_1.sendTransactionWithLookupTable)(connection, [approveIx, fillIx], relayer);
|
|
252
250
|
// Verify recipient's balance after the fill
|
|
253
251
|
await new Promise((resolve) => setTimeout(resolve, 500)); // Make sure token transfer gets processed.
|
|
254
252
|
const anotherRecipientAccount = await (0, spl_token_1.getAccount)(connection, anotherRecipientATA);
|