@across-protocol/contracts 3.0.17 → 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.d.ts +1 -0
- package/dist/scripts/svm/addressToPublicKey.js +20 -0
- package/dist/scripts/svm/bridgeLiabilityToHubPool.d.ts +25 -0
- package/dist/scripts/svm/bridgeLiabilityToHubPool.js +221 -0
- package/dist/scripts/svm/closeRelayerPdas.js +8 -9
- package/dist/scripts/svm/enableRoute.js +7 -1
- package/dist/scripts/svm/executeRebalanceToHubPool.d.ts +29 -0
- package/dist/scripts/svm/executeRebalanceToHubPool.js +345 -0
- package/dist/scripts/svm/executeRebalanceToSpokePool.d.ts +1 -0
- package/dist/scripts/svm/executeRebalanceToSpokePool.js +240 -0
- package/dist/scripts/svm/fakeFillWithRandomDistribution.js +6 -7
- package/dist/scripts/svm/initialize.js +2 -2
- package/dist/scripts/svm/proposeRebalanceToHubPool.d.ts +27 -0
- package/dist/scripts/svm/proposeRebalanceToHubPool.js +117 -0
- package/dist/scripts/svm/proposeRebalanceToSpokePool.d.ts +1 -0
- package/dist/scripts/svm/proposeRebalanceToSpokePool.js +97 -0
- package/dist/scripts/svm/publicKeyToAddress.d.ts +1 -0
- package/dist/scripts/svm/publicKeyToAddress.js +20 -0
- package/dist/scripts/svm/queryDeposits.js +3 -2
- package/dist/scripts/svm/queryFills.js +12 -14
- package/dist/scripts/svm/queryRoute.js +7 -1
- package/dist/scripts/svm/queryState.js +1 -0
- package/dist/scripts/svm/remoteHubPoolPauseDeposits.d.ts +1 -0
- package/dist/scripts/svm/remoteHubPoolPauseDeposits.js +191 -0
- package/dist/scripts/svm/remoteHubPoolSetDepositRoute.js +16 -29
- package/dist/scripts/svm/remotePauseDeposits.js +21 -27
- package/dist/scripts/svm/simpleDeposit.js +7 -1
- package/dist/scripts/svm/simpleFakeRelayerRepayment.js +3 -3
- package/dist/scripts/svm/simpleFill.js +6 -6
- package/dist/scripts/svm/utils/constants.d.ts +4 -0
- package/dist/scripts/svm/utils/constants.js +8 -1
- package/dist/scripts/svm/utils/helpers.d.ts +33 -0
- package/dist/scripts/svm/utils/helpers.js +60 -1
- package/dist/scripts/svm/utils/poolRebalanceTree.d.ts +22 -0
- package/dist/scripts/svm/utils/poolRebalanceTree.js +20 -0
- 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/target/types/svm_spoke.d.ts +47 -42
- package/dist/tasks/enableL1TokenAcrossEcosystem.js +3 -33
- package/dist/tasks/types.d.ts +2 -0
- package/dist/tasks/types.js +2 -0
- package/dist/tasks/utils.d.ts +12 -0
- package/dist/tasks/utils.js +34 -0
- package/dist/test/svm/MulticallHandler.js +2 -2
- package/dist/test/svm/SvmSpoke.Bundle.js +59 -60
- package/dist/test/svm/SvmSpoke.Deposit.js +23 -31
- package/dist/test/svm/SvmSpoke.Fill.AcrossPlus.js +16 -18
- package/dist/test/svm/SvmSpoke.Fill.js +38 -40
- package/dist/test/svm/SvmSpoke.HandleReceiveMessage.js +2 -2
- package/dist/test/svm/SvmSpoke.Ownership.js +11 -17
- package/dist/test/svm/SvmSpoke.RefundClaims.js +12 -11
- package/dist/test/svm/SvmSpoke.Routes.js +11 -7
- package/dist/test/svm/SvmSpoke.SlowFill.AcrossPlus.js +72 -16
- package/dist/test/svm/SvmSpoke.SlowFill.js +33 -28
- package/dist/test/svm/SvmSpoke.TokenBridge.js +15 -17
- package/dist/test/svm/SvmSpoke.common.d.ts +1 -49
- package/dist/test/svm/SvmSpoke.common.js +6 -5
- package/dist/test/svm/cctpHelpers.js +2 -2
- package/dist/test/svm/utils.d.ts +5 -67
- package/dist/test/svm/utils.js +10 -220
- 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 -50
- package/dist/src/SvmUtils.js +0 -415
|
@@ -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);
|
|
@@ -144,11 +144,9 @@ describe("svm_spoke.bundle", () => {
|
|
|
144
144
|
.relayRootBundle(relayerRefundRootArray, slowRelayRootArray)
|
|
145
145
|
.accounts(relayRootBundleAccounts)
|
|
146
146
|
.rpc();
|
|
147
|
-
// Wait for event processing
|
|
148
|
-
await new Promise((resolve) => setTimeout(resolve, 1000));
|
|
149
147
|
// Check for the emitted event
|
|
150
|
-
|
|
151
|
-
const event = events.find((event) => event.name === "relayedRootBundle")
|
|
148
|
+
let events = await (0, svm_1.readEventsUntilFound)(connection, tx, [program]);
|
|
149
|
+
const event = events.find((event) => event.name === "relayedRootBundle")?.data;
|
|
152
150
|
chai_1.assert.isTrue(event.rootBundleId.toString() === rootBundleId.toString(), "Root bundle ID should match");
|
|
153
151
|
chai_1.assert.isTrue(event.relayerRefundRoot.toString() === relayerRefundRootArray.toString(), "Relayer refund root should match");
|
|
154
152
|
chai_1.assert.isTrue(event.slowRelayRoot.toString() === slowRelayRootArray.toString(), "Slow relay root should match");
|
|
@@ -166,7 +164,7 @@ describe("svm_spoke.bundle", () => {
|
|
|
166
164
|
refundAddresses: [relayerA.publicKey, relayerB.publicKey],
|
|
167
165
|
refundAmounts: [relayerARefund, relayerBRefund],
|
|
168
166
|
});
|
|
169
|
-
const merkleTree = new
|
|
167
|
+
const merkleTree = new utils_1.MerkleTree(relayerRefundLeaves, svm_1.relayerRefundHashFn);
|
|
170
168
|
const root = merkleTree.getRoot();
|
|
171
169
|
const proof = merkleTree.getProof(relayerRefundLeaves[0]);
|
|
172
170
|
const leaf = relayerRefundLeaves[0];
|
|
@@ -199,16 +197,15 @@ describe("svm_spoke.bundle", () => {
|
|
|
199
197
|
program: program.programId,
|
|
200
198
|
};
|
|
201
199
|
const proofAsNumbers = proof.map((p) => Array.from(p));
|
|
202
|
-
await (0,
|
|
203
|
-
await program.methods
|
|
200
|
+
await (0, svm_1.loadExecuteRelayerRefundLeafParams)(program, owner, stateAccountData.rootBundleId, leaf, proofAsNumbers);
|
|
201
|
+
const tx = await program.methods
|
|
204
202
|
.executeRelayerRefundLeaf()
|
|
205
203
|
.accounts(executeRelayerRefundLeafAccounts)
|
|
206
204
|
.remainingAccounts(remainingAccounts)
|
|
207
205
|
.rpc();
|
|
208
206
|
// Verify the ExecutedRelayerRefundRoot event
|
|
209
|
-
|
|
210
|
-
let
|
|
211
|
-
let event = events.find((event) => event.name === "executedRelayerRefundRoot").data;
|
|
207
|
+
let events = await (0, svm_1.readEventsUntilFound)(connection, tx, [program]);
|
|
208
|
+
let event = events.find((event) => event.name === "executedRelayerRefundRoot")?.data;
|
|
212
209
|
// Remove the expectedValues object and use direct assertions
|
|
213
210
|
assertSE(event.amountToReturn, relayerRefundLeaves[0].amountToReturn, "amountToReturn should match");
|
|
214
211
|
assertSE(event.chainId, chainId, "chainId should match");
|
|
@@ -221,6 +218,12 @@ describe("svm_spoke.bundle", () => {
|
|
|
221
218
|
assertSE(event.refundAddresses[1], relayerB.publicKey, "Relayer B address should match");
|
|
222
219
|
chai_1.assert.isFalse(event.deferredRefunds, "deferredRefunds should be false");
|
|
223
220
|
assertSE(event.caller, owner, "caller should match");
|
|
221
|
+
event = events.find((event) => event.name === "tokensBridged")?.data;
|
|
222
|
+
assertSE(event.amountToReturn, relayerRefundLeaves[0].amountToReturn, "amountToReturn should match");
|
|
223
|
+
assertSE(event.chainId, chainId, "chainId should match");
|
|
224
|
+
assertSE(event.leafId, leaf.leafId, "leafId should match");
|
|
225
|
+
assertSE(event.l2TokenAddress, mint, "l2TokenAddress should match");
|
|
226
|
+
assertSE(event.caller, owner, "caller should match");
|
|
224
227
|
const fVaultBal = (await connection.getTokenAccountBalance(vault)).value.amount;
|
|
225
228
|
const fRelayerABal = (await connection.getTokenAccountBalance(relayerTA)).value.amount;
|
|
226
229
|
const fRelayerBBal = (await connection.getTokenAccountBalance(relayerTB)).value.amount;
|
|
@@ -241,7 +244,7 @@ describe("svm_spoke.bundle", () => {
|
|
|
241
244
|
systemProgram: anchor_1.web3.SystemProgram.programId,
|
|
242
245
|
program: program.programId,
|
|
243
246
|
};
|
|
244
|
-
await (0,
|
|
247
|
+
await (0, svm_1.loadExecuteRelayerRefundLeafParams)(program, owner, stateAccountData.rootBundleId, leaf, proofAsNumbers);
|
|
245
248
|
await program.methods
|
|
246
249
|
.executeRelayerRefundLeaf()
|
|
247
250
|
.accounts(executeRelayerRefundLeafAccounts)
|
|
@@ -257,14 +260,14 @@ describe("svm_spoke.bundle", () => {
|
|
|
257
260
|
const solanaDistributions = 50;
|
|
258
261
|
const evmDistributions = 50;
|
|
259
262
|
const solanaLeafNumber = 13;
|
|
260
|
-
const { relayerRefundLeaves, merkleTree } = (0,
|
|
263
|
+
const { relayerRefundLeaves, merkleTree } = (0, utils_2.buildRelayerRefundMerkleTree)({
|
|
261
264
|
totalEvmDistributions: evmDistributions,
|
|
262
265
|
totalSolanaDistributions: solanaDistributions,
|
|
263
266
|
mixLeaves: false,
|
|
264
267
|
chainId: chainId.toNumber(),
|
|
265
268
|
mint,
|
|
266
269
|
svmRelayers: [relayerA.publicKey, relayerB.publicKey],
|
|
267
|
-
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())],
|
|
268
271
|
});
|
|
269
272
|
const invalidRelayerRefundLeaf = {
|
|
270
273
|
isSolana: true,
|
|
@@ -273,7 +276,7 @@ describe("svm_spoke.bundle", () => {
|
|
|
273
276
|
amountToReturn: new anchor_1.BN(0),
|
|
274
277
|
mintPublicKey: mint,
|
|
275
278
|
refundAddresses: [relayerA.publicKey, relayerB.publicKey],
|
|
276
|
-
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())],
|
|
277
280
|
};
|
|
278
281
|
const root = merkleTree.getRoot();
|
|
279
282
|
const proof = merkleTree.getProof(relayerRefundLeaves[solanaLeafNumber]);
|
|
@@ -313,7 +316,7 @@ describe("svm_spoke.bundle", () => {
|
|
|
313
316
|
{ pubkey: web3_js_1.Keypair.generate().publicKey, isWritable: true, isSigner: false },
|
|
314
317
|
];
|
|
315
318
|
// Verify valid leaf
|
|
316
|
-
await (0,
|
|
319
|
+
await (0, svm_1.loadExecuteRelayerRefundLeafParams)(program, owner, stateAccountData.rootBundleId, leaf, proofAsNumbers);
|
|
317
320
|
await program.methods
|
|
318
321
|
.executeRelayerRefundLeaf()
|
|
319
322
|
.accounts(executeRelayerRefundLeafAccounts)
|
|
@@ -336,7 +339,7 @@ describe("svm_spoke.bundle", () => {
|
|
|
336
339
|
systemProgram: anchor_1.web3.SystemProgram.programId,
|
|
337
340
|
program: program.programId,
|
|
338
341
|
};
|
|
339
|
-
await (0,
|
|
342
|
+
await (0, svm_1.loadExecuteRelayerRefundLeafParams)(program, owner, stateAccountData.rootBundleId, leaf, proofAsNumbers);
|
|
340
343
|
await program.methods
|
|
341
344
|
.executeRelayerRefundLeaf()
|
|
342
345
|
.accounts(executeRelayerRefundLeafAccounts)
|
|
@@ -362,7 +365,7 @@ describe("svm_spoke.bundle", () => {
|
|
|
362
365
|
systemProgram: anchor_1.web3.SystemProgram.programId,
|
|
363
366
|
program: program.programId,
|
|
364
367
|
};
|
|
365
|
-
await (0,
|
|
368
|
+
await (0, svm_1.loadExecuteRelayerRefundLeafParams)(program, owner, stateAccountData.rootBundleId, invalidRelayerRefundLeaf, proofAsNumbers);
|
|
366
369
|
await program.methods
|
|
367
370
|
.executeRelayerRefundLeaf()
|
|
368
371
|
.accounts(executeRelayerRefundLeafAccounts)
|
|
@@ -377,14 +380,14 @@ describe("svm_spoke.bundle", () => {
|
|
|
377
380
|
it("Test Merkle Proof Verification with Mixed Solana and EVM Leaves", async () => {
|
|
378
381
|
const evmDistributions = 5;
|
|
379
382
|
const solanaDistributions = 5;
|
|
380
|
-
const { relayerRefundLeaves, merkleTree } = (0,
|
|
383
|
+
const { relayerRefundLeaves, merkleTree } = (0, utils_2.buildRelayerRefundMerkleTree)({
|
|
381
384
|
totalEvmDistributions: evmDistributions,
|
|
382
385
|
totalSolanaDistributions: solanaDistributions,
|
|
383
386
|
mixLeaves: true,
|
|
384
387
|
chainId: chainId.toNumber(),
|
|
385
388
|
mint,
|
|
386
389
|
svmRelayers: [relayerA.publicKey, relayerB.publicKey],
|
|
387
|
-
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())],
|
|
388
391
|
});
|
|
389
392
|
const root = merkleTree.getRoot();
|
|
390
393
|
let stateAccountData = await program.account.state.fetch(state);
|
|
@@ -422,7 +425,7 @@ describe("svm_spoke.bundle", () => {
|
|
|
422
425
|
systemProgram: anchor_1.web3.SystemProgram.programId,
|
|
423
426
|
program: program.programId,
|
|
424
427
|
};
|
|
425
|
-
await (0,
|
|
428
|
+
await (0, svm_1.loadExecuteRelayerRefundLeafParams)(program, owner, stateAccountData.rootBundleId, leaf, proofAsNumbers);
|
|
426
429
|
await program.methods
|
|
427
430
|
.executeRelayerRefundLeaf()
|
|
428
431
|
.accounts(executeRelayerRefundLeafAccounts)
|
|
@@ -449,14 +452,14 @@ describe("svm_spoke.bundle", () => {
|
|
|
449
452
|
it("Test Merkle Proof Verification with Sorted Solana and EVM Leaves", async () => {
|
|
450
453
|
const evmDistributions = 5;
|
|
451
454
|
const solanaDistributions = 5;
|
|
452
|
-
const { relayerRefundLeaves, merkleTree } = (0,
|
|
455
|
+
const { relayerRefundLeaves, merkleTree } = (0, utils_2.buildRelayerRefundMerkleTree)({
|
|
453
456
|
totalEvmDistributions: evmDistributions,
|
|
454
457
|
totalSolanaDistributions: solanaDistributions,
|
|
455
458
|
mixLeaves: false,
|
|
456
459
|
chainId: chainId.toNumber(),
|
|
457
460
|
mint,
|
|
458
461
|
svmRelayers: [relayerA.publicKey, relayerB.publicKey],
|
|
459
|
-
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())],
|
|
460
463
|
});
|
|
461
464
|
const root = merkleTree.getRoot();
|
|
462
465
|
let stateAccountData = await program.account.state.fetch(state);
|
|
@@ -494,7 +497,7 @@ describe("svm_spoke.bundle", () => {
|
|
|
494
497
|
systemProgram: anchor_1.web3.SystemProgram.programId,
|
|
495
498
|
program: program.programId,
|
|
496
499
|
};
|
|
497
|
-
await (0,
|
|
500
|
+
await (0, svm_1.loadExecuteRelayerRefundLeafParams)(program, owner, stateAccountData.rootBundleId, leaf, proofAsNumbers);
|
|
498
501
|
await program.methods
|
|
499
502
|
.executeRelayerRefundLeaf()
|
|
500
503
|
.accounts(executeRelayerRefundLeafAccounts)
|
|
@@ -532,7 +535,7 @@ describe("svm_spoke.bundle", () => {
|
|
|
532
535
|
refundAddresses: [relayerA.publicKey, relayerB.publicKey],
|
|
533
536
|
refundAmounts: [relayerARefund, relayerBRefund],
|
|
534
537
|
});
|
|
535
|
-
const merkleTree = new
|
|
538
|
+
const merkleTree = new utils_1.MerkleTree(relayerRefundLeaves, svm_1.relayerRefundHashFn);
|
|
536
539
|
const root = merkleTree.getRoot();
|
|
537
540
|
const proof = merkleTree.getProof(relayerRefundLeaves[0]);
|
|
538
541
|
const leaf = relayerRefundLeaves[0];
|
|
@@ -562,7 +565,7 @@ describe("svm_spoke.bundle", () => {
|
|
|
562
565
|
systemProgram: anchor_1.web3.SystemProgram.programId,
|
|
563
566
|
program: program.programId,
|
|
564
567
|
};
|
|
565
|
-
await (0,
|
|
568
|
+
await (0, svm_1.loadExecuteRelayerRefundLeafParams)(program, owner, stateAccountData.rootBundleId, leaf, proofAsNumbers);
|
|
566
569
|
await program.methods
|
|
567
570
|
.executeRelayerRefundLeaf()
|
|
568
571
|
.accounts(executeRelayerRefundLeafAccounts)
|
|
@@ -586,7 +589,7 @@ describe("svm_spoke.bundle", () => {
|
|
|
586
589
|
refundAddresses: [relayerA.publicKey, relayerB.publicKey],
|
|
587
590
|
refundAmounts: [relayerARefund, relayerBRefund],
|
|
588
591
|
});
|
|
589
|
-
const merkleTree = new
|
|
592
|
+
const merkleTree = new utils_1.MerkleTree(relayerRefundLeaves, svm_1.relayerRefundHashFn);
|
|
590
593
|
const root = merkleTree.getRoot();
|
|
591
594
|
const proof = merkleTree.getProof(relayerRefundLeaves[0]);
|
|
592
595
|
const leaf = relayerRefundLeaves[0];
|
|
@@ -616,7 +619,7 @@ describe("svm_spoke.bundle", () => {
|
|
|
616
619
|
systemProgram: anchor_1.web3.SystemProgram.programId,
|
|
617
620
|
program: program.programId,
|
|
618
621
|
};
|
|
619
|
-
await (0,
|
|
622
|
+
await (0, svm_1.loadExecuteRelayerRefundLeafParams)(program, owner, stateAccountData.rootBundleId, leaf, proofAsNumbers);
|
|
620
623
|
await program.methods
|
|
621
624
|
.executeRelayerRefundLeaf()
|
|
622
625
|
.accounts(executeRelayerRefundLeafAccounts)
|
|
@@ -642,7 +645,7 @@ describe("svm_spoke.bundle", () => {
|
|
|
642
645
|
refundAmounts: [relayerRefundAmount],
|
|
643
646
|
});
|
|
644
647
|
}
|
|
645
|
-
const merkleTree = new
|
|
648
|
+
const merkleTree = new utils_1.MerkleTree(relayerRefundLeaves, svm_1.relayerRefundHashFn);
|
|
646
649
|
const root = merkleTree.getRoot();
|
|
647
650
|
const proof = relayerRefundLeaves.map((leaf) => merkleTree.getProof(leaf).map((p) => Array.from(p)));
|
|
648
651
|
let stateAccountData = await program.account.state.fetch(state);
|
|
@@ -670,7 +673,7 @@ describe("svm_spoke.bundle", () => {
|
|
|
670
673
|
systemProgram: anchor_1.web3.SystemProgram.programId,
|
|
671
674
|
program: program.programId,
|
|
672
675
|
};
|
|
673
|
-
await (0,
|
|
676
|
+
await (0, svm_1.loadExecuteRelayerRefundLeafParams)(program, owner, stateAccountData.rootBundleId, relayerRefundLeaves[i], proof[i]);
|
|
674
677
|
await program.methods
|
|
675
678
|
.executeRelayerRefundLeaf()
|
|
676
679
|
.accounts(executeRelayerRefundLeafAccounts)
|
|
@@ -696,7 +699,7 @@ describe("svm_spoke.bundle", () => {
|
|
|
696
699
|
systemProgram: anchor_1.web3.SystemProgram.programId,
|
|
697
700
|
program: program.programId,
|
|
698
701
|
};
|
|
699
|
-
await (0,
|
|
702
|
+
await (0, svm_1.loadExecuteRelayerRefundLeafParams)(program, owner, stateAccountData.rootBundleId, relayerRefundLeaves[i], proof[i]);
|
|
700
703
|
await program.methods
|
|
701
704
|
.executeRelayerRefundLeaf()
|
|
702
705
|
.accounts(executeRelayerRefundLeafAccounts)
|
|
@@ -822,9 +825,9 @@ describe("svm_spoke.bundle", () => {
|
|
|
822
825
|
await program.methods.initializeClaimAccount(mint, tokenOwner).rpc();
|
|
823
826
|
refundAccounts.push(claimAccount);
|
|
824
827
|
}
|
|
825
|
-
refundAmounts.push(new anchor_1.BN((0,
|
|
828
|
+
refundAmounts.push(new anchor_1.BN((0, utils_2.randomBigInt)(2).toString()));
|
|
826
829
|
}
|
|
827
|
-
const { relayerRefundLeaves, merkleTree } = (0,
|
|
830
|
+
const { relayerRefundLeaves, merkleTree } = (0, utils_2.buildRelayerRefundMerkleTree)({
|
|
828
831
|
totalEvmDistributions: evmDistributions,
|
|
829
832
|
totalSolanaDistributions: testConfig.solanaDistributions,
|
|
830
833
|
mixLeaves: false,
|
|
@@ -876,7 +879,7 @@ describe("svm_spoke.bundle", () => {
|
|
|
876
879
|
])
|
|
877
880
|
: [];
|
|
878
881
|
// Build the instruction to execute relayer refund leaf and write its instruction args to the data account.
|
|
879
|
-
await (0,
|
|
882
|
+
await (0, svm_1.loadExecuteRelayerRefundLeafParams)(program, owner, stateAccountData.rootBundleId, leaf, proofAsNumbers);
|
|
880
883
|
const executeInstruction = !testConfig.deferredRefunds
|
|
881
884
|
? await program.methods
|
|
882
885
|
.executeRelayerRefundLeaf()
|
|
@@ -901,7 +904,7 @@ describe("svm_spoke.bundle", () => {
|
|
|
901
904
|
// Add relay refund leaf execution instruction.
|
|
902
905
|
instructions.push(executeInstruction);
|
|
903
906
|
// Execute using ALT.
|
|
904
|
-
await (0,
|
|
907
|
+
await (0, svm_1.sendTransactionWithLookupTable)(connection, instructions, anchor.AnchorProvider.env().wallet.payer);
|
|
905
908
|
// Verify all refund account balances (either token or claim accounts).
|
|
906
909
|
await new Promise((resolve) => setTimeout(resolve, 1000)); // Make sure account balances have been synced.
|
|
907
910
|
const refundBalances = await Promise.all(refundAccounts.map(async (account) => {
|
|
@@ -946,7 +949,7 @@ describe("svm_spoke.bundle", () => {
|
|
|
946
949
|
refundAddresses: [],
|
|
947
950
|
refundAmounts: [],
|
|
948
951
|
});
|
|
949
|
-
const merkleTree = new
|
|
952
|
+
const merkleTree = new utils_1.MerkleTree(relayerRefundLeaves, svm_1.relayerRefundHashFn);
|
|
950
953
|
const root = merkleTree.getRoot();
|
|
951
954
|
const proof = merkleTree.getProof(relayerRefundLeaves[0]);
|
|
952
955
|
const leaf = relayerRefundLeaves[0];
|
|
@@ -970,7 +973,7 @@ describe("svm_spoke.bundle", () => {
|
|
|
970
973
|
systemProgram: anchor_1.web3.SystemProgram.programId,
|
|
971
974
|
program: program.programId,
|
|
972
975
|
};
|
|
973
|
-
await (0,
|
|
976
|
+
await (0, svm_1.loadExecuteRelayerRefundLeafParams)(program, owner, stateAccountData.rootBundleId, leaf, proofAsNumbers);
|
|
974
977
|
await program.methods.executeRelayerRefundLeaf().accounts(executeRelayerRefundLeafAccounts).rpc();
|
|
975
978
|
};
|
|
976
979
|
const zeroAmountToReturn = new anchor_1.BN(0);
|
|
@@ -1003,7 +1006,7 @@ describe("svm_spoke.bundle", () => {
|
|
|
1003
1006
|
refundAmounts: [relayerRefundAmount],
|
|
1004
1007
|
});
|
|
1005
1008
|
}
|
|
1006
|
-
const merkleTree = new
|
|
1009
|
+
const merkleTree = new utils_1.MerkleTree(relayerRefundLeaves, svm_1.relayerRefundHashFn);
|
|
1007
1010
|
const root = merkleTree.getRoot();
|
|
1008
1011
|
const proof = relayerRefundLeaves.map((leaf) => merkleTree.getProof(leaf).map((p) => Array.from(p)));
|
|
1009
1012
|
let stateAccountData = await program.account.state.fetch(state);
|
|
@@ -1031,7 +1034,7 @@ describe("svm_spoke.bundle", () => {
|
|
|
1031
1034
|
systemProgram: anchor_1.web3.SystemProgram.programId,
|
|
1032
1035
|
program: program.programId,
|
|
1033
1036
|
};
|
|
1034
|
-
await (0,
|
|
1037
|
+
await (0, svm_1.loadExecuteRelayerRefundLeafParams)(program, owner, stateAccountData.rootBundleId, relayerRefundLeaves[i], proof[i]);
|
|
1035
1038
|
await program.methods
|
|
1036
1039
|
.executeRelayerRefundLeaf()
|
|
1037
1040
|
.accounts(executeRelayerRefundLeafAccounts)
|
|
@@ -1057,7 +1060,7 @@ describe("svm_spoke.bundle", () => {
|
|
|
1057
1060
|
refundAddresses: [relayerA.publicKey, relayerB.publicKey],
|
|
1058
1061
|
refundAmounts: [relayerARefund],
|
|
1059
1062
|
});
|
|
1060
|
-
const merkleTree = new
|
|
1063
|
+
const merkleTree = new utils_1.MerkleTree(relayerRefundLeaves, svm_1.relayerRefundHashFn);
|
|
1061
1064
|
const root = merkleTree.getRoot();
|
|
1062
1065
|
const proof = merkleTree.getProof(relayerRefundLeaves[0]);
|
|
1063
1066
|
const leaf = relayerRefundLeaves[0];
|
|
@@ -1087,7 +1090,7 @@ describe("svm_spoke.bundle", () => {
|
|
|
1087
1090
|
program: program.programId,
|
|
1088
1091
|
};
|
|
1089
1092
|
const proofAsNumbers = proof.map((p) => Array.from(p));
|
|
1090
|
-
await (0,
|
|
1093
|
+
await (0, svm_1.loadExecuteRelayerRefundLeafParams)(program, owner, stateAccountData.rootBundleId, leaf, proofAsNumbers);
|
|
1091
1094
|
// Mismatched refund amount and account length should fail.
|
|
1092
1095
|
try {
|
|
1093
1096
|
await program.methods
|
|
@@ -1131,7 +1134,7 @@ describe("svm_spoke.bundle", () => {
|
|
|
1131
1134
|
refundAddresses: [relayerA.publicKey, relayerB.publicKey],
|
|
1132
1135
|
refundAmounts: [relayerARefund, relayerBRefund],
|
|
1133
1136
|
});
|
|
1134
|
-
const merkleTree = new
|
|
1137
|
+
const merkleTree = new utils_1.MerkleTree(relayerRefundLeaves, svm_1.relayerRefundHashFn);
|
|
1135
1138
|
const root = merkleTree.getRoot();
|
|
1136
1139
|
const proof = merkleTree.getProof(relayerRefundLeaves[0]);
|
|
1137
1140
|
const leaf = relayerRefundLeaves[0];
|
|
@@ -1162,7 +1165,7 @@ describe("svm_spoke.bundle", () => {
|
|
|
1162
1165
|
program: program.programId,
|
|
1163
1166
|
};
|
|
1164
1167
|
const proofAsNumbers = proof.map((p) => Array.from(p));
|
|
1165
|
-
await (0,
|
|
1168
|
+
await (0, svm_1.loadExecuteRelayerRefundLeafParams)(program, owner, stateAccountData.rootBundleId, leaf, proofAsNumbers);
|
|
1166
1169
|
if (!testConfig.deferredRefunds) {
|
|
1167
1170
|
return await program.methods
|
|
1168
1171
|
.executeRelayerRefundLeaf()
|
|
@@ -1180,16 +1183,14 @@ describe("svm_spoke.bundle", () => {
|
|
|
1180
1183
|
};
|
|
1181
1184
|
it("No deferred refunds in all Token Accounts", async () => {
|
|
1182
1185
|
const tx = await executeRelayerRefundLeaf({ deferredRefunds: false });
|
|
1183
|
-
|
|
1184
|
-
const
|
|
1185
|
-
const event = events.find((event) => event.name === "executedRelayerRefundRoot").data;
|
|
1186
|
+
const events = await (0, svm_1.readEventsUntilFound)(connection, tx, [program]);
|
|
1187
|
+
const event = events.find((event) => event.name === "executedRelayerRefundRoot")?.data;
|
|
1186
1188
|
chai_1.assert.isFalse(event.deferredRefunds, "deferredRefunds should be false");
|
|
1187
1189
|
});
|
|
1188
1190
|
it("Deferred refunds in all Claim Accounts", async () => {
|
|
1189
1191
|
const tx = await executeRelayerRefundLeaf({ deferredRefunds: true });
|
|
1190
|
-
|
|
1191
|
-
const
|
|
1192
|
-
const event = events.find((event) => event.name === "executedRelayerRefundRoot").data;
|
|
1192
|
+
const events = await (0, svm_1.readEventsUntilFound)(connection, tx, [program]);
|
|
1193
|
+
const event = events.find((event) => event.name === "executedRelayerRefundRoot")?.data;
|
|
1193
1194
|
chai_1.assert.isTrue(event.deferredRefunds, "deferredRefunds should be true");
|
|
1194
1195
|
});
|
|
1195
1196
|
});
|
|
@@ -1207,7 +1208,7 @@ describe("svm_spoke.bundle", () => {
|
|
|
1207
1208
|
refundAddresses: [relayerA.publicKey],
|
|
1208
1209
|
refundAmounts: [relayerARefund],
|
|
1209
1210
|
});
|
|
1210
|
-
const merkleTree = new
|
|
1211
|
+
const merkleTree = new utils_1.MerkleTree(relayerRefundLeaves, svm_1.relayerRefundHashFn);
|
|
1211
1212
|
const root = merkleTree.getRoot();
|
|
1212
1213
|
const proof = merkleTree.getProof(relayerRefundLeaves[0]);
|
|
1213
1214
|
const leaf = relayerRefundLeaves[0];
|
|
@@ -1233,7 +1234,7 @@ describe("svm_spoke.bundle", () => {
|
|
|
1233
1234
|
program: program.programId,
|
|
1234
1235
|
};
|
|
1235
1236
|
const proofAsNumbers = proof.map((p) => Array.from(p));
|
|
1236
|
-
await (0,
|
|
1237
|
+
await (0, svm_1.loadExecuteRelayerRefundLeafParams)(program, owner, stateAccountData.rootBundleId, leaf, proofAsNumbers);
|
|
1237
1238
|
// Leaf execution should fail due to insufficient balance.
|
|
1238
1239
|
try {
|
|
1239
1240
|
await program.methods
|
|
@@ -1281,7 +1282,7 @@ describe("svm_spoke.bundle", () => {
|
|
|
1281
1282
|
]);
|
|
1282
1283
|
return ethers_1.ethers.utils.keccak256(contentToHash);
|
|
1283
1284
|
};
|
|
1284
|
-
const merkleTree = new
|
|
1285
|
+
const merkleTree = new utils_1.MerkleTree(relayerRefundLeaves, customRelayerRefundHashFn);
|
|
1285
1286
|
const root = merkleTree.getRoot();
|
|
1286
1287
|
const proof = merkleTree.getProof(relayerRefundLeaves[0]);
|
|
1287
1288
|
const leaf = relayerRefundLeaves[0];
|
|
@@ -1311,7 +1312,7 @@ describe("svm_spoke.bundle", () => {
|
|
|
1311
1312
|
program: program.programId,
|
|
1312
1313
|
};
|
|
1313
1314
|
const proofAsNumbers = proof.map((p) => Array.from(p));
|
|
1314
|
-
await (0,
|
|
1315
|
+
await (0, svm_1.loadExecuteRelayerRefundLeafParams)(program, owner, stateAccountData.rootBundleId, leaf, proofAsNumbers);
|
|
1315
1316
|
try {
|
|
1316
1317
|
await program.methods
|
|
1317
1318
|
.executeRelayerRefundLeaf()
|
|
@@ -1321,7 +1322,6 @@ describe("svm_spoke.bundle", () => {
|
|
|
1321
1322
|
chai_1.assert.fail("Leaf verification should fail without leading 64 bytes");
|
|
1322
1323
|
}
|
|
1323
1324
|
catch (err) {
|
|
1324
|
-
console.log("err", err);
|
|
1325
1325
|
chai_1.assert.include(err.toString(), "Invalid Merkle proof", "Expected merkle verification to fail");
|
|
1326
1326
|
}
|
|
1327
1327
|
});
|
|
@@ -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()
|
|
@@ -1399,7 +1399,6 @@ describe("svm_spoke.bundle", () => {
|
|
|
1399
1399
|
chai_1.assert.fail("Leaf verification should fail without leading 64 bytes");
|
|
1400
1400
|
}
|
|
1401
1401
|
catch (err) {
|
|
1402
|
-
console.log("err", err);
|
|
1403
1402
|
chai_1.assert.include(err.toString(), "Invalid Merkle proof", "Expected merkle verification to fail");
|
|
1404
1403
|
}
|
|
1405
1404
|
});
|
|
@@ -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
|
|
@@ -85,7 +85,8 @@ describe("svm_spoke.deposit", () => {
|
|
|
85
85
|
.accounts(calledDepositAccounts)
|
|
86
86
|
.instruction();
|
|
87
87
|
const depositTx = new web3_js_1.Transaction().add(approveIx, depositIx);
|
|
88
|
-
await (0, web3_js_1.sendAndConfirmTransaction)(connection, depositTx, [payer, depositor]);
|
|
88
|
+
const tx = await (0, web3_js_1.sendAndConfirmTransaction)(connection, depositTx, [payer, depositor]);
|
|
89
|
+
return tx;
|
|
89
90
|
};
|
|
90
91
|
beforeEach(async () => {
|
|
91
92
|
({ state, seed } = await initializeState());
|
|
@@ -122,22 +123,20 @@ describe("svm_spoke.deposit", () => {
|
|
|
122
123
|
depositData.inputAmount = depositData.inputAmount.add(new anchor_1.BN(69));
|
|
123
124
|
// Execute the first deposit_v3 call
|
|
124
125
|
let depositDataValues = Object.values(depositData);
|
|
125
|
-
await approvedDepositV3(depositDataValues);
|
|
126
|
-
|
|
127
|
-
let events = await (0, utils_1.readProgramEvents)(connection, program);
|
|
126
|
+
const tx = await approvedDepositV3(depositDataValues);
|
|
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.
|
|
133
133
|
assertSE(event[key], value, `${key} should match`);
|
|
134
134
|
}
|
|
135
135
|
// Execute the second deposit_v3 call
|
|
136
|
-
await approvedDepositV3(depositDataValues);
|
|
137
|
-
await
|
|
138
|
-
events = await (0, utils_1.readProgramEvents)(connection, program);
|
|
136
|
+
const tx2 = await approvedDepositV3(depositDataValues);
|
|
137
|
+
events = await (0, svm_1.readEventsUntilFound)(connection, tx2, [program]);
|
|
139
138
|
event = events[0].data; // 0th event is the latest event.
|
|
140
|
-
const expectedValues2 = { ...expectedValues1, depositId: (0,
|
|
139
|
+
const expectedValues2 = { ...expectedValues1, depositId: (0, svm_1.intToU8Array32)(2) }; // Verify the event props emitted match the depositData.
|
|
141
140
|
for (let [key, value] of Object.entries(expectedValues2)) {
|
|
142
141
|
if (key === "exclusivityParameter")
|
|
143
142
|
key = "exclusivityDeadline"; // the prop and the event names differ on this key.
|
|
@@ -286,7 +285,6 @@ describe("svm_spoke.deposit", () => {
|
|
|
286
285
|
program: program.programId,
|
|
287
286
|
};
|
|
288
287
|
await program.methods.setEnableRoute(inputToken, fakeRouteChainId, true).accounts(fakeSetEnableRouteAccounts).rpc();
|
|
289
|
-
await new Promise((resolve) => setTimeout(resolve, 2000));
|
|
290
288
|
const fakeDepositAccounts = {
|
|
291
289
|
state: fakeState.state,
|
|
292
290
|
route: fakeRoutePda,
|
|
@@ -302,13 +300,12 @@ describe("svm_spoke.deposit", () => {
|
|
|
302
300
|
...depositData,
|
|
303
301
|
destinationChainId: fakeRouteChainId,
|
|
304
302
|
});
|
|
305
|
-
await approvedDepositV3(depositDataValues, fakeDepositAccounts);
|
|
306
|
-
|
|
307
|
-
let events = await (0, utils_1.readProgramEvents)(connection, program);
|
|
303
|
+
const tx = await approvedDepositV3(depositDataValues, fakeDepositAccounts);
|
|
304
|
+
let events = await (0, svm_1.readEventsUntilFound)(connection, tx, [program]);
|
|
308
305
|
let event = events[0].data; // 0th event is the latest event.
|
|
309
306
|
const expectedValues = {
|
|
310
307
|
...{ ...depositData, destinationChainId: fakeRouteChainId },
|
|
311
|
-
depositId: (0,
|
|
308
|
+
depositId: (0, svm_1.intToU8Array32)(1),
|
|
312
309
|
}; // Verify the event props emitted match the depositData.
|
|
313
310
|
for (let [key, value] of Object.entries(expectedValues)) {
|
|
314
311
|
if (key === "exclusivityParameter")
|
|
@@ -346,9 +343,8 @@ describe("svm_spoke.deposit", () => {
|
|
|
346
343
|
.accounts(depositAccounts)
|
|
347
344
|
.instruction();
|
|
348
345
|
const depositTx = new web3_js_1.Transaction().add(approveIx, depositIx);
|
|
349
|
-
await (0, web3_js_1.sendAndConfirmTransaction)(connection, depositTx, [payer, depositor]);
|
|
350
|
-
|
|
351
|
-
const events = await (0, utils_1.readProgramEvents)(connection, program);
|
|
346
|
+
const tx = await (0, web3_js_1.sendAndConfirmTransaction)(connection, depositTx, [payer, depositor]);
|
|
347
|
+
const events = await (0, svm_1.readEventsUntilFound)(connection, tx, [program]);
|
|
352
348
|
const event = events[0].data; // 0th event is the latest event.
|
|
353
349
|
// Verify the event props emitted match the expected values
|
|
354
350
|
const currentTime = await getCurrentTime(program, state);
|
|
@@ -356,7 +352,7 @@ describe("svm_spoke.deposit", () => {
|
|
|
356
352
|
...depositData,
|
|
357
353
|
quoteTimestamp: currentTime,
|
|
358
354
|
fillDeadline: currentTime + fillDeadlineOffset,
|
|
359
|
-
depositId: (0,
|
|
355
|
+
depositId: (0, svm_1.intToU8Array32)(1),
|
|
360
356
|
};
|
|
361
357
|
for (let [key, value] of Object.entries(expectedValues)) {
|
|
362
358
|
if (key === "exclusivityParameter")
|
|
@@ -407,9 +403,8 @@ describe("svm_spoke.deposit", () => {
|
|
|
407
403
|
depositData.exclusiveRelayer = depositor.publicKey;
|
|
408
404
|
depositData.exclusivityParameter = maxExclusivityOffsetSeconds;
|
|
409
405
|
const depositDataValues = Object.values(depositData);
|
|
410
|
-
await approvedDepositV3(depositDataValues);
|
|
411
|
-
|
|
412
|
-
const events = await (0, utils_1.readProgramEvents)(connection, program);
|
|
406
|
+
const tx = await approvedDepositV3(depositDataValues);
|
|
407
|
+
const events = await (0, svm_1.readEventsUntilFound)(connection, tx, [program]);
|
|
413
408
|
const event = events[0].data; // 0th event is the latest event
|
|
414
409
|
assertSE(event.exclusivityDeadline, currentTime.add(maxExclusivityOffsetSeconds), "exclusivityDeadline should be current time + offset");
|
|
415
410
|
});
|
|
@@ -420,9 +415,8 @@ describe("svm_spoke.deposit", () => {
|
|
|
420
415
|
depositData.exclusiveRelayer = depositor.publicKey;
|
|
421
416
|
depositData.exclusivityParameter = exclusivityDeadlineTimestamp;
|
|
422
417
|
const depositDataValues = Object.values(depositData);
|
|
423
|
-
await approvedDepositV3(depositDataValues);
|
|
424
|
-
|
|
425
|
-
const events = await (0, utils_1.readProgramEvents)(connection, program);
|
|
418
|
+
const tx = await approvedDepositV3(depositDataValues);
|
|
419
|
+
const events = await (0, svm_1.readEventsUntilFound)(connection, tx, [program]);
|
|
426
420
|
const event = events[0].data; // 0th event is the latest event;
|
|
427
421
|
assertSE(event.exclusivityDeadline, exclusivityDeadlineTimestamp, "exclusivityDeadline should be passed in time");
|
|
428
422
|
});
|
|
@@ -433,9 +427,8 @@ describe("svm_spoke.deposit", () => {
|
|
|
433
427
|
depositData.exclusiveRelayer = depositor.publicKey;
|
|
434
428
|
depositData.exclusivityParameter = zeroExclusivity;
|
|
435
429
|
const depositDataValues = Object.values(depositData);
|
|
436
|
-
await approvedDepositV3(depositDataValues);
|
|
437
|
-
|
|
438
|
-
const events = await (0, utils_1.readProgramEvents)(connection, program);
|
|
430
|
+
const tx = await approvedDepositV3(depositDataValues);
|
|
431
|
+
const events = await (0, svm_1.readEventsUntilFound)(connection, tx, [program]);
|
|
439
432
|
const event = events[0].data; // 0th event is the latest event;
|
|
440
433
|
assertSE(event.exclusivityDeadline, zeroExclusivity, "Exclusivity deadline should always be 0");
|
|
441
434
|
});
|
|
@@ -462,11 +455,10 @@ describe("svm_spoke.deposit", () => {
|
|
|
462
455
|
.accounts(depositAccounts) // Assuming depositAccounts is already set up correctly
|
|
463
456
|
.instruction();
|
|
464
457
|
const unsafeDepositTx = new web3_js_1.Transaction().add(approveIx, unsafeDepositIx);
|
|
465
|
-
await (0, web3_js_1.sendAndConfirmTransaction)(connection, unsafeDepositTx, [payer, depositor]);
|
|
458
|
+
const tx = await (0, web3_js_1.sendAndConfirmTransaction)(connection, unsafeDepositTx, [payer, depositor]);
|
|
466
459
|
// Wait for a short period to ensure the event is emitted
|
|
467
|
-
await new Promise((resolve) => setTimeout(resolve, 500));
|
|
468
460
|
// Read and verify the event
|
|
469
|
-
const events = await (0,
|
|
461
|
+
const events = await (0, svm_1.readEventsUntilFound)(connection, tx, [program]);
|
|
470
462
|
const event = events[0].data; // Assuming the latest event is the one we want
|
|
471
463
|
const expectedValues = { ...depositData, depositId: expectedDepositIdArray };
|
|
472
464
|
for (let [key, value] of Object.entries(expectedValues)) {
|