@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
|
@@ -27,10 +27,9 @@ 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 utils_1 = require("./utils");
|
|
30
|
+
const svm_1 = require("../../src/svm");
|
|
32
31
|
const SvmSpoke_common_1 = require("./SvmSpoke.common");
|
|
33
|
-
const
|
|
32
|
+
const utils_1 = require("./utils");
|
|
34
33
|
const { provider, connection, program, owner, chainId, seedBalance } = SvmSpoke_common_1.common;
|
|
35
34
|
const { recipient, initializeState, setCurrentTime, assertSE, assert } = SvmSpoke_common_1.common;
|
|
36
35
|
describe("svm_spoke.fill", () => {
|
|
@@ -38,7 +37,7 @@ describe("svm_spoke.fill", () => {
|
|
|
38
37
|
const payer = anchor.AnchorProvider.env().wallet.payer;
|
|
39
38
|
const relayer = web3_js_1.Keypair.generate();
|
|
40
39
|
const otherRelayer = web3_js_1.Keypair.generate();
|
|
41
|
-
const { encodedMessage, fillRemainingAccounts } = (0,
|
|
40
|
+
const { encodedMessage, fillRemainingAccounts } = (0, utils_1.testAcrossPlusMessage)();
|
|
42
41
|
const tokenDecimals = 6;
|
|
43
42
|
let state, mint, relayerTA, recipientTA, otherRelayerTA, tokenProgram;
|
|
44
43
|
const relayAmount = 500000;
|
|
@@ -46,7 +45,7 @@ describe("svm_spoke.fill", () => {
|
|
|
46
45
|
let accounts; // Store accounts to simplify contract interactions.
|
|
47
46
|
function updateRelayData(newRelayData) {
|
|
48
47
|
relayData = newRelayData;
|
|
49
|
-
const relayHashUint8Array = (0,
|
|
48
|
+
const relayHashUint8Array = (0, svm_1.calculateRelayHashUint8Array)(relayData, chainId);
|
|
50
49
|
const [fillStatusPDA] = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("fills"), relayHashUint8Array], program.programId);
|
|
51
50
|
accounts = {
|
|
52
51
|
state,
|
|
@@ -100,7 +99,7 @@ describe("svm_spoke.fill", () => {
|
|
|
100
99
|
inputAmount: new anchor_1.BN(relayAmount),
|
|
101
100
|
outputAmount: new anchor_1.BN(relayAmount),
|
|
102
101
|
originChainId: new anchor_1.BN(1),
|
|
103
|
-
depositId: (0,
|
|
102
|
+
depositId: (0, svm_1.intToU8Array32)(Math.floor(Math.random() * 1000000)), // force that we always have a new deposit id.
|
|
104
103
|
fillDeadline: Math.floor(Date.now() / 1000) + 60, // 1 minute from now
|
|
105
104
|
exclusivityDeadline: Math.floor(Date.now() / 1000) + 30, // 30 seconds from now
|
|
106
105
|
message: encodedMessage,
|
|
@@ -114,7 +113,7 @@ describe("svm_spoke.fill", () => {
|
|
|
114
113
|
// Verify relayer's balance before the fill
|
|
115
114
|
let relayerAccount = await (0, spl_token_1.getAccount)(connection, relayerTA);
|
|
116
115
|
assertSE(relayerAccount.amount, seedBalance, "Relayer's balance should be equal to seed balance before the fill");
|
|
117
|
-
const relayHash = Array.from((0,
|
|
116
|
+
const relayHash = Array.from((0, svm_1.calculateRelayHashUint8Array)(relayData, chainId));
|
|
118
117
|
await approvedFillV3Relay([relayHash, relayData, new anchor_1.BN(1), relayer.publicKey]);
|
|
119
118
|
// Verify relayer's balance after the fill
|
|
120
119
|
relayerAccount = await (0, spl_token_1.getAccount)(connection, relayerTA);
|
|
@@ -124,23 +123,23 @@ describe("svm_spoke.fill", () => {
|
|
|
124
123
|
assertSE(recipientAccount.amount, relayAmount, "Recipient's balance should be increased by the relay amount");
|
|
125
124
|
});
|
|
126
125
|
it("Verifies FilledV3Relay event after filling a relay", async () => {
|
|
127
|
-
const relayHash = Array.from((0,
|
|
126
|
+
const relayHash = Array.from((0, svm_1.calculateRelayHashUint8Array)(relayData, chainId));
|
|
128
127
|
const tx = await approvedFillV3Relay([relayHash, relayData, new anchor_1.BN(420), otherRelayer.publicKey]);
|
|
129
128
|
// Fetch and verify the FilledV3Relay event
|
|
130
|
-
const events = await (0,
|
|
129
|
+
const events = await (0, svm_1.readEventsUntilFound)(connection, tx, [program]);
|
|
131
130
|
const event = events.find((event) => event.name === "filledV3Relay")?.data;
|
|
132
131
|
assert.isNotNull(event, "FilledV3Relay event should be emitted");
|
|
133
132
|
// Verify that the event data matches the relay data.
|
|
134
133
|
Object.entries(relayData).forEach(([key, value]) => {
|
|
135
134
|
if (key === "message") {
|
|
136
|
-
assertSE(event.messageHash, (0,
|
|
135
|
+
assertSE(event.messageHash, (0, svm_1.hashNonEmptyMessage)(value), `MessageHash should match`);
|
|
137
136
|
}
|
|
138
137
|
else
|
|
139
138
|
assertSE(event[key], value, `${key.charAt(0).toUpperCase() + key.slice(1)} should match`);
|
|
140
139
|
});
|
|
141
140
|
// RelayExecutionInfo should match.
|
|
142
141
|
assertSE(event.relayExecutionInfo.updatedRecipient, relayData.recipient, "UpdatedRecipient should match");
|
|
143
|
-
assertSE(event.relayExecutionInfo.updatedMessageHash, (0,
|
|
142
|
+
assertSE(event.relayExecutionInfo.updatedMessageHash, (0, svm_1.hashNonEmptyMessage)(relayData.message), "UpdatedMessageHash should match");
|
|
144
143
|
assertSE(event.relayExecutionInfo.updatedOutputAmount, relayData.outputAmount, "UpdatedOutputAmount should match");
|
|
145
144
|
assert.equal(JSON.stringify(event.relayExecutionInfo.fillType), `{"fastFill":{}}`, "FillType should be FastFill");
|
|
146
145
|
// These props below are not part of relayData.
|
|
@@ -149,7 +148,7 @@ describe("svm_spoke.fill", () => {
|
|
|
149
148
|
});
|
|
150
149
|
it("Fails to fill a V3 relay after the fill deadline", async () => {
|
|
151
150
|
updateRelayData({ ...relayData, fillDeadline: Math.floor(Date.now() / 1000) - 69 }); // 69 seconds ago
|
|
152
|
-
const relayHash = Array.from((0,
|
|
151
|
+
const relayHash = Array.from((0, svm_1.calculateRelayHashUint8Array)(relayData, chainId));
|
|
153
152
|
try {
|
|
154
153
|
await approvedFillV3Relay([relayHash, relayData, new anchor_1.BN(1), relayer.publicKey]);
|
|
155
154
|
assert.fail("Fill should have failed due to fill deadline passed");
|
|
@@ -161,7 +160,7 @@ describe("svm_spoke.fill", () => {
|
|
|
161
160
|
it("Fails to fill a V3 relay by non-exclusive relayer before exclusivity deadline", async () => {
|
|
162
161
|
accounts.signer = otherRelayer.publicKey;
|
|
163
162
|
accounts.relayerTokenAccount = otherRelayerTA;
|
|
164
|
-
const relayHash = Array.from((0,
|
|
163
|
+
const relayHash = Array.from((0, svm_1.calculateRelayHashUint8Array)(relayData, chainId));
|
|
165
164
|
try {
|
|
166
165
|
await approvedFillV3Relay([relayHash, relayData, new anchor_1.BN(1), relayer.publicKey], undefined, otherRelayer);
|
|
167
166
|
assert.fail("Fill should have failed due to non-exclusive relayer before exclusivity deadline");
|
|
@@ -176,7 +175,7 @@ describe("svm_spoke.fill", () => {
|
|
|
176
175
|
accounts.relayerTokenAccount = otherRelayerTA;
|
|
177
176
|
const recipientAccountBefore = await (0, spl_token_1.getAccount)(connection, recipientTA);
|
|
178
177
|
const relayerAccountBefore = await (0, spl_token_1.getAccount)(connection, otherRelayerTA);
|
|
179
|
-
const relayHash = Array.from((0,
|
|
178
|
+
const relayHash = Array.from((0, svm_1.calculateRelayHashUint8Array)(relayData, chainId));
|
|
180
179
|
await approvedFillV3Relay([relayHash, relayData, new anchor_1.BN(1), relayer.publicKey], undefined, otherRelayer);
|
|
181
180
|
// Verify relayer's balance after the fill
|
|
182
181
|
const relayerAccountAfter = await (0, spl_token_1.getAccount)(connection, otherRelayerTA);
|
|
@@ -186,7 +185,7 @@ describe("svm_spoke.fill", () => {
|
|
|
186
185
|
assertSE(recipientAccountAfter.amount, BigInt(recipientAccountBefore.amount) + BigInt(relayAmount), "Recipient's balance should be increased by the relay amount");
|
|
187
186
|
});
|
|
188
187
|
it("Fails to fill a V3 relay with the same deposit data multiple times", async () => {
|
|
189
|
-
const relayHash = Array.from((0,
|
|
188
|
+
const relayHash = Array.from((0, svm_1.calculateRelayHashUint8Array)(relayData, chainId));
|
|
190
189
|
// First fill attempt
|
|
191
190
|
await approvedFillV3Relay([relayHash, relayData, new anchor_1.BN(1), relayer.publicKey]);
|
|
192
191
|
// Second fill attempt with the same data
|
|
@@ -199,7 +198,7 @@ describe("svm_spoke.fill", () => {
|
|
|
199
198
|
}
|
|
200
199
|
});
|
|
201
200
|
it("Closes the fill PDA after the fill", async () => {
|
|
202
|
-
const relayHash = Array.from((0,
|
|
201
|
+
const relayHash = Array.from((0, svm_1.calculateRelayHashUint8Array)(relayData, chainId));
|
|
203
202
|
const closeFillPdaAccounts = {
|
|
204
203
|
state,
|
|
205
204
|
signer: relayer.publicKey,
|
|
@@ -228,7 +227,7 @@ describe("svm_spoke.fill", () => {
|
|
|
228
227
|
assert.isNull(fillStatusAccountAfter, "Fill PDA should be closed after closing");
|
|
229
228
|
});
|
|
230
229
|
it("Fetches FillStatusAccount before and after fillV3Relay", async () => {
|
|
231
|
-
const relayHash = (0,
|
|
230
|
+
const relayHash = (0, svm_1.calculateRelayHashUint8Array)(relayData, chainId);
|
|
232
231
|
const [fillStatusPDA] = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("fills"), relayHash], program.programId);
|
|
233
232
|
// Fetch FillStatusAccount before fillV3Relay
|
|
234
233
|
let fillStatusAccount = await program.account.fillStatusAccount.fetchNullable(fillStatusPDA);
|
|
@@ -248,7 +247,7 @@ describe("svm_spoke.fill", () => {
|
|
|
248
247
|
const stateAccountData = await program.account.state.fetch(state);
|
|
249
248
|
assert.isTrue(stateAccountData.pausedFills, "Fills should be paused");
|
|
250
249
|
// Try to fill the relay. This should fail because fills are paused.
|
|
251
|
-
const relayHash = Array.from((0,
|
|
250
|
+
const relayHash = Array.from((0, svm_1.calculateRelayHashUint8Array)(relayData, chainId));
|
|
252
251
|
try {
|
|
253
252
|
await approvedFillV3Relay([relayHash, relayData, new anchor_1.BN(1), relayer.publicKey]);
|
|
254
253
|
assert.fail("Should not be able to fill relay when fills are paused");
|
|
@@ -258,7 +257,7 @@ describe("svm_spoke.fill", () => {
|
|
|
258
257
|
}
|
|
259
258
|
});
|
|
260
259
|
it("Fails to fill a relay to wrong recipient token account", async () => {
|
|
261
|
-
const relayHash = (0,
|
|
260
|
+
const relayHash = (0, svm_1.calculateRelayHashUint8Array)(relayData, chainId);
|
|
262
261
|
// Create new accounts as derived from wrong recipient.
|
|
263
262
|
const wrongRecipient = web3_js_1.Keypair.generate().publicKey;
|
|
264
263
|
const wrongRecipientTA = (await (0, spl_token_1.getOrCreateAssociatedTokenAccount)(connection, payer, mint, wrongRecipient)).address;
|
|
@@ -276,7 +275,7 @@ describe("svm_spoke.fill", () => {
|
|
|
276
275
|
}
|
|
277
276
|
});
|
|
278
277
|
it("Fails to fill a relay for mint inconsistent output_token", async () => {
|
|
279
|
-
const relayHash = (0,
|
|
278
|
+
const relayHash = (0, svm_1.calculateRelayHashUint8Array)(relayData, chainId);
|
|
280
279
|
// Create and fund new accounts as derived from wrong mint account.
|
|
281
280
|
const wrongMint = await (0, spl_token_1.createMint)(connection, payer, owner, owner, tokenDecimals);
|
|
282
281
|
const wrongRecipientTA = (await (0, spl_token_1.getOrCreateAssociatedTokenAccount)(connection, payer, wrongMint, recipient)).address;
|
|
@@ -302,7 +301,7 @@ describe("svm_spoke.fill", () => {
|
|
|
302
301
|
accounts.recipientTokenAccount = relayerTA;
|
|
303
302
|
// Store relayer's balance before the fill
|
|
304
303
|
const iRelayerBalance = (await (0, spl_token_1.getAccount)(connection, relayerTA)).amount;
|
|
305
|
-
const relayHash = Array.from((0,
|
|
304
|
+
const relayHash = Array.from((0, svm_1.calculateRelayHashUint8Array)(relayData, chainId));
|
|
306
305
|
// No need for approval in self-relay.
|
|
307
306
|
const txSignature = await program.methods
|
|
308
307
|
.fillV3Relay(relayHash, relayData, new anchor_1.BN(1), relayer.publicKey)
|
|
@@ -334,7 +333,7 @@ describe("svm_spoke.fill", () => {
|
|
|
334
333
|
const iRecipientBal = (await (0, spl_token_1.getAccount)(connection, recipientTA)).amount;
|
|
335
334
|
// Fill relay from custom relayer token account
|
|
336
335
|
accounts.relayerTokenAccount = customRelayerTA;
|
|
337
|
-
const relayHash = Array.from((0,
|
|
336
|
+
const relayHash = Array.from((0, svm_1.calculateRelayHashUint8Array)(relayData, chainId));
|
|
338
337
|
await approvedFillV3Relay([relayHash, relayData, new anchor_1.BN(1), relayer.publicKey]);
|
|
339
338
|
// Verify balances after the fill
|
|
340
339
|
const fRelayerBal = (await (0, spl_token_1.getAccount)(connection, customRelayerTA)).amount;
|
|
@@ -350,11 +349,11 @@ describe("svm_spoke.fill", () => {
|
|
|
350
349
|
const newRelayData = {
|
|
351
350
|
...relayData,
|
|
352
351
|
recipient: newRecipient,
|
|
353
|
-
depositId: (0,
|
|
352
|
+
depositId: (0, svm_1.intToU8Array32)(Math.floor(Math.random() * 1000000)),
|
|
354
353
|
};
|
|
355
354
|
updateRelayData(newRelayData);
|
|
356
355
|
accounts.recipientTokenAccount = newRecipientATA;
|
|
357
|
-
const relayHash = Array.from((0,
|
|
356
|
+
const relayHash = Array.from((0, svm_1.calculateRelayHashUint8Array)(newRelayData, chainId));
|
|
358
357
|
try {
|
|
359
358
|
await approvedFillV3Relay([relayHash, newRelayData, new anchor_1.BN(1), relayer.publicKey]);
|
|
360
359
|
assert.fail("Fill should have failed due to missing ATA");
|
|
@@ -409,12 +408,12 @@ describe("svm_spoke.fill", () => {
|
|
|
409
408
|
const newRelayData = {
|
|
410
409
|
...relayData,
|
|
411
410
|
recipient: recipientAuthorities[i],
|
|
412
|
-
depositId: (0,
|
|
411
|
+
depositId: (0, svm_1.intToU8Array32)(Math.floor(Math.random() * 1000000)),
|
|
413
412
|
};
|
|
414
413
|
totalFillAmount = totalFillAmount.add(newRelayData.outputAmount);
|
|
415
414
|
updateRelayData(newRelayData);
|
|
416
415
|
accounts.recipientTokenAccount = recipientAssociatedTokens[i];
|
|
417
|
-
const relayHash = Array.from((0,
|
|
416
|
+
const relayHash = Array.from((0, svm_1.calculateRelayHashUint8Array)(newRelayData, chainId));
|
|
418
417
|
const fillInstruction = await program.methods
|
|
419
418
|
.fillV3Relay(relayHash, newRelayData, new anchor_1.BN(1), relayer.publicKey)
|
|
420
419
|
.accounts(accounts)
|
|
@@ -424,7 +423,7 @@ describe("svm_spoke.fill", () => {
|
|
|
424
423
|
}
|
|
425
424
|
const approveInstruction = await (0, spl_token_1.createApproveCheckedInstruction)(accounts.relayerTokenAccount, accounts.mint, accounts.state, accounts.signer, BigInt(totalFillAmount.toString()), tokenDecimals, undefined, tokenProgram);
|
|
426
425
|
// Fill using the ALT.
|
|
427
|
-
await (0,
|
|
426
|
+
await (0, svm_1.sendTransactionWithLookupTable)(connection, [createTokenAccountsInstruction, approveInstruction, ...fillInstructions], relayer);
|
|
428
427
|
// Verify balances after the fill
|
|
429
428
|
await new Promise((resolve) => setTimeout(resolve, 500)); // Wait for tx processing
|
|
430
429
|
const fRelayerBal = (await (0, spl_token_1.getAccount)(connection, relayerTA)).amount;
|
|
@@ -454,7 +453,7 @@ describe("svm_spoke.fill", () => {
|
|
|
454
453
|
// Verify relayer's balance before the fill
|
|
455
454
|
let relayerAccount = await (0, spl_token_1.getAccount)(connection, relayerTA, undefined, tokenProgram);
|
|
456
455
|
assertSE(relayerAccount.amount, seedBalance, "Relayer's balance should be equal to seed balance before the fill");
|
|
457
|
-
const relayHash = Array.from((0,
|
|
456
|
+
const relayHash = Array.from((0, svm_1.calculateRelayHashUint8Array)(relayData, chainId));
|
|
458
457
|
await approvedFillV3Relay([relayHash, relayData, new anchor_1.BN(1), relayer.publicKey]);
|
|
459
458
|
// Verify relayer's balance after the fill
|
|
460
459
|
relayerAccount = await (0, spl_token_1.getAccount)(connection, relayerTA, undefined, tokenProgram);
|
|
@@ -465,10 +464,10 @@ describe("svm_spoke.fill", () => {
|
|
|
465
464
|
});
|
|
466
465
|
it("Emits zeroed hash for empty message", async () => {
|
|
467
466
|
updateRelayData({ ...relayData, message: Buffer.alloc(0) });
|
|
468
|
-
const relayHash = Array.from((0,
|
|
467
|
+
const relayHash = Array.from((0, svm_1.calculateRelayHashUint8Array)(relayData, chainId));
|
|
469
468
|
const tx = await approvedFillV3Relay([relayHash, relayData, new anchor_1.BN(420), otherRelayer.publicKey]);
|
|
470
469
|
// Fetch and verify the FilledV3Relay event
|
|
471
|
-
const events = await (0,
|
|
470
|
+
const events = await (0, svm_1.readEventsUntilFound)(connection, tx, [program]);
|
|
472
471
|
const event = events.find((event) => event.name === "filledV3Relay")?.data;
|
|
473
472
|
assert.isNotNull(event, "FilledV3Relay event should be emitted");
|
|
474
473
|
// Verify that the event data has zeroed message hash.
|
|
@@ -30,7 +30,7 @@ const spl_token_1 = require("@solana/spl-token");
|
|
|
30
30
|
const web3_js_1 = require("@solana/web3.js");
|
|
31
31
|
const chai_1 = require("chai");
|
|
32
32
|
const ethers_1 = require("ethers");
|
|
33
|
-
const
|
|
33
|
+
const svm_1 = require("../../src/svm");
|
|
34
34
|
const cctpHelpers_1 = require("./cctpHelpers");
|
|
35
35
|
const SvmSpoke_common_1 = require("./SvmSpoke.common");
|
|
36
36
|
const { createRoutePda, getVaultAta, initializeState, crossDomainAdmin, remoteDomain, localDomain } = SvmSpoke_common_1.common;
|
|
@@ -262,7 +262,7 @@ describe("svm_spoke.handle_receive_message", () => {
|
|
|
262
262
|
});
|
|
263
263
|
it("Sets cross-domain admin remotely", async () => {
|
|
264
264
|
const newCrossDomainAdminAddress = ethers_1.ethers.Wallet.createRandom().address;
|
|
265
|
-
const newCrossDomainAdminPubkey = (0,
|
|
265
|
+
const newCrossDomainAdminPubkey = (0, svm_1.evmAddressToPublicKey)(newCrossDomainAdminAddress);
|
|
266
266
|
let calldata = ethereumIface.encodeFunctionData("setCrossDomainAdmin", [newCrossDomainAdminAddress]);
|
|
267
267
|
let messageBody = Buffer.from(calldata.slice(2), "hex");
|
|
268
268
|
let message = (0, cctpHelpers_1.encodeMessageHeader)({
|
|
@@ -28,7 +28,7 @@ const anchor_1 = require("@coral-xyz/anchor");
|
|
|
28
28
|
const web3_js_1 = require("@solana/web3.js");
|
|
29
29
|
const chai_1 = require("chai");
|
|
30
30
|
const SvmSpoke_common_1 = require("./SvmSpoke.common");
|
|
31
|
-
const
|
|
31
|
+
const svm_1 = require("../../src/svm");
|
|
32
32
|
const { provider, program, owner, initializeState, crossDomainAdmin, assertSE } = SvmSpoke_common_1.common;
|
|
33
33
|
describe("svm_spoke.ownership", () => {
|
|
34
34
|
anchor.setProvider(provider);
|
|
@@ -67,7 +67,7 @@ describe("svm_spoke.ownership", () => {
|
|
|
67
67
|
let stateAccountData = await program.account.state.fetch(state);
|
|
68
68
|
chai_1.assert.isTrue(stateAccountData.pausedDeposits, "Deposits should be paused");
|
|
69
69
|
// Verify the PausedDeposits event
|
|
70
|
-
let events = await (0,
|
|
70
|
+
let events = await (0, svm_1.readEventsUntilFound)(provider.connection, tx, [program]);
|
|
71
71
|
let pausedDepositEvents = events.filter((event) => event.name === "pausedDeposits");
|
|
72
72
|
chai_1.assert.isTrue(pausedDepositEvents[0].data.isPaused, "PausedDeposits event should indicate deposits are paused");
|
|
73
73
|
// Unpause deposits as owner
|
|
@@ -76,7 +76,7 @@ describe("svm_spoke.ownership", () => {
|
|
|
76
76
|
stateAccountData = await program.account.state.fetch(state);
|
|
77
77
|
chai_1.assert.isFalse(stateAccountData.pausedDeposits, "Deposits should not be paused");
|
|
78
78
|
// Verify the PausedDeposits event
|
|
79
|
-
events = await (0,
|
|
79
|
+
events = await (0, svm_1.readEventsUntilFound)(provider.connection, tx2, [program]);
|
|
80
80
|
pausedDepositEvents = events.filter((event) => event.name === "pausedDeposits");
|
|
81
81
|
chai_1.assert.isFalse(pausedDepositEvents[0].data.isPaused, "PausedDeposits event should indicate deposits are unpaused");
|
|
82
82
|
// Try to pause deposits as non-owner
|
|
@@ -98,7 +98,7 @@ describe("svm_spoke.ownership", () => {
|
|
|
98
98
|
let stateAccountData = await program.account.state.fetch(state);
|
|
99
99
|
chai_1.assert.isTrue(stateAccountData.pausedFills, "Fills should be paused");
|
|
100
100
|
// Verify the PausedFills event
|
|
101
|
-
let events = await (0,
|
|
101
|
+
let events = await (0, svm_1.readEventsUntilFound)(provider.connection, tx, [program]);
|
|
102
102
|
let pausedFillEvents = events.filter((event) => event.name === "pausedFills");
|
|
103
103
|
chai_1.assert.isTrue(pausedFillEvents[0].data.isPaused, "PausedFills event should indicate fills are paused");
|
|
104
104
|
// Unpause fills as owner
|
|
@@ -107,7 +107,7 @@ describe("svm_spoke.ownership", () => {
|
|
|
107
107
|
stateAccountData = await program.account.state.fetch(state);
|
|
108
108
|
chai_1.assert.isFalse(stateAccountData.pausedFills, "Fills should not be paused");
|
|
109
109
|
// Verify the PausedFills event
|
|
110
|
-
events = await (0,
|
|
110
|
+
events = await (0, svm_1.readEventsUntilFound)(provider.connection, tx2, [program]);
|
|
111
111
|
pausedFillEvents = events.filter((event) => event.name === "pausedFills");
|
|
112
112
|
chai_1.assert.isFalse(pausedFillEvents[0].data.isPaused, "PausedFills event should indicate fills are unpaused");
|
|
113
113
|
// Try to pause fills as non-owner
|
|
@@ -152,7 +152,7 @@ describe("svm_spoke.ownership", () => {
|
|
|
152
152
|
let stateAccountData = await program.account.state.fetch(state);
|
|
153
153
|
chai_1.assert.equal(stateAccountData.crossDomainAdmin.toString(), newCrossDomainAdmin.publicKey.toString(), "Cross-domain admin should be set");
|
|
154
154
|
// Verify the SetXDomainAdmin event
|
|
155
|
-
let events = await (0,
|
|
155
|
+
let events = await (0, svm_1.readEventsUntilFound)(provider.connection, tx, [program]);
|
|
156
156
|
let setXDomainAdminEvents = events.filter((event) => event.name === "setXDomainAdmin");
|
|
157
157
|
chai_1.assert.equal(setXDomainAdminEvents[0].data.newAdmin.toString(), newCrossDomainAdmin.publicKey.toString(), "SetXDomainAdmin event should indicate the new admin");
|
|
158
158
|
// Try to set cross-domain admin as non-owner
|
|
@@ -30,7 +30,7 @@ const chai_1 = require("chai");
|
|
|
30
30
|
const SvmSpoke_common_1 = require("./SvmSpoke.common");
|
|
31
31
|
const MerkleTree_1 = require("@uma/common/dist/MerkleTree");
|
|
32
32
|
const spl_token_1 = require("@solana/spl-token");
|
|
33
|
-
const
|
|
33
|
+
const svm_1 = require("../../src/svm");
|
|
34
34
|
const { provider, program, owner, initializeState, connection, chainId, assertSE } = SvmSpoke_common_1.common;
|
|
35
35
|
describe("svm_spoke.refund_claims", () => {
|
|
36
36
|
anchor.setProvider(provider);
|
|
@@ -69,7 +69,7 @@ describe("svm_spoke.refund_claims", () => {
|
|
|
69
69
|
refundAddresses: [relayer.publicKey],
|
|
70
70
|
refundAmounts: [relayerRefund],
|
|
71
71
|
});
|
|
72
|
-
const merkleTree = new MerkleTree_1.MerkleTree(relayerRefundLeaves,
|
|
72
|
+
const merkleTree = new MerkleTree_1.MerkleTree(relayerRefundLeaves, svm_1.relayerRefundHashFn);
|
|
73
73
|
const root = merkleTree.getRoot();
|
|
74
74
|
const proof = merkleTree.getProof(relayerRefundLeaves[0]);
|
|
75
75
|
const leaf = relayerRefundLeaves[0];
|
|
@@ -99,7 +99,7 @@ describe("svm_spoke.refund_claims", () => {
|
|
|
99
99
|
program: program.programId,
|
|
100
100
|
};
|
|
101
101
|
const proofAsNumbers = proof.map((p) => Array.from(p));
|
|
102
|
-
await (0,
|
|
102
|
+
await (0, svm_1.loadExecuteRelayerRefundLeafParams)(program, owner, stateAccountData.rootBundleId, leaf, proofAsNumbers);
|
|
103
103
|
await program.methods
|
|
104
104
|
.executeRelayerRefundLeafDeferred()
|
|
105
105
|
.accounts(executeRelayerRefundLeafAccounts)
|
|
@@ -152,7 +152,7 @@ describe("svm_spoke.refund_claims", () => {
|
|
|
152
152
|
assertSE(BigInt(iVaultBal) - BigInt(fVaultBal), relayerRefund, "Vault balance");
|
|
153
153
|
assertSE(BigInt(fRelayerBal) - BigInt(iRelayerBal), relayerRefund, "Relayer balance");
|
|
154
154
|
// Verify the ClaimedRelayerRefund event
|
|
155
|
-
const events = await (0,
|
|
155
|
+
const events = await (0, svm_1.readEventsUntilFound)(connection, tx, [program]);
|
|
156
156
|
const event = events.find((event) => event.name === "claimedRelayerRefund")?.data;
|
|
157
157
|
assertSE(event.l2TokenAddress, mint, "l2TokenAddress should match");
|
|
158
158
|
assertSE(event.claimAmount, relayerRefund, "Relayer refund amount should match");
|
|
@@ -309,7 +309,7 @@ describe("svm_spoke.refund_claims", () => {
|
|
|
309
309
|
assertSE(BigInt(iVaultBal) - BigInt(fVaultBal), relayerRefund, "Vault balance");
|
|
310
310
|
assertSE(BigInt(fRelayerBal) - BigInt(iRelayerBal), relayerRefund, "Relayer balance");
|
|
311
311
|
// Verify the ClaimedRelayerRefund event
|
|
312
|
-
const events = await (0,
|
|
312
|
+
const events = await (0, svm_1.readEventsUntilFound)(connection, tx, [program]);
|
|
313
313
|
const event = events.find((event) => event.name === "claimedRelayerRefund")?.data;
|
|
314
314
|
assertSE(event.l2TokenAddress, mint, "l2TokenAddress should match");
|
|
315
315
|
assertSE(event.claimAmount, relayerRefund, "Relayer refund amount should match");
|
|
@@ -29,7 +29,7 @@ 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 SvmSpoke_common_1 = require("./SvmSpoke.common");
|
|
32
|
-
const
|
|
32
|
+
const svm_1 = require("../../src/svm");
|
|
33
33
|
const { provider, program, owner, initializeState, createRoutePda, getVaultAta } = SvmSpoke_common_1.common;
|
|
34
34
|
describe("svm_spoke.routes", () => {
|
|
35
35
|
anchor.setProvider(provider);
|
|
@@ -68,7 +68,7 @@ describe("svm_spoke.routes", () => {
|
|
|
68
68
|
let routeAccount = await program.account.route.fetch(routePda);
|
|
69
69
|
chai_1.assert.isTrue(routeAccount.enabled, "Route should be enabled");
|
|
70
70
|
// Verify the enabledDepositRoute event
|
|
71
|
-
let events = await (0,
|
|
71
|
+
let events = await (0, svm_1.readEventsUntilFound)(provider.connection, tx, [program]);
|
|
72
72
|
let event = events[0].data;
|
|
73
73
|
chai_1.assert.strictEqual(event.originToken.toString(), tokenMint.toString(), "originToken event match");
|
|
74
74
|
chai_1.assert.strictEqual(event.destinationChainId.toString(), routeChainId.toString(), "destinationChainId should match");
|
|
@@ -82,7 +82,7 @@ describe("svm_spoke.routes", () => {
|
|
|
82
82
|
routeAccount = await program.account.route.fetch(routePda);
|
|
83
83
|
chai_1.assert.isFalse(routeAccount.enabled, "Route should be disabled");
|
|
84
84
|
// Verify the enabledDepositRoute event
|
|
85
|
-
events = await (0,
|
|
85
|
+
events = await (0, svm_1.readEventsUntilFound)(provider.connection, tx2, [program]);
|
|
86
86
|
event = events[0].data; // take most recent event, index 0.
|
|
87
87
|
chai_1.assert.strictEqual(event.originToken.toString(), tokenMint.toString(), "originToken event match");
|
|
88
88
|
chai_1.assert.strictEqual(event.destinationChainId.toString(), routeChainId.toString(), "destinationChainId should match");
|
|
@@ -29,9 +29,8 @@ const anchor_1 = require("@coral-xyz/anchor");
|
|
|
29
29
|
const spl_token_1 = require("@solana/spl-token");
|
|
30
30
|
const web3_js_1 = require("@solana/web3.js");
|
|
31
31
|
const MerkleTree_1 = require("@uma/common/dist/MerkleTree");
|
|
32
|
-
const
|
|
32
|
+
const svm_1 = require("../../src/svm");
|
|
33
33
|
const SvmSpoke_common_1 = require("./SvmSpoke.common");
|
|
34
|
-
const utils_1 = require("./utils");
|
|
35
34
|
const { provider, connection, program, owner, chainId, setCurrentTime } = SvmSpoke_common_1.common;
|
|
36
35
|
const { initializeState, assertSE, assert } = SvmSpoke_common_1.common;
|
|
37
36
|
describe("svm_spoke.slow_fill.across_plus", () => {
|
|
@@ -48,7 +47,7 @@ describe("svm_spoke.slow_fill.across_plus", () => {
|
|
|
48
47
|
const seedBalance = 10_000_000_000;
|
|
49
48
|
async function updateRelayData(newRelayData) {
|
|
50
49
|
relayData = newRelayData;
|
|
51
|
-
const relayHashUint8Array = (0,
|
|
50
|
+
const relayHashUint8Array = (0, svm_1.calculateRelayHashUint8Array)(relayData, chainId);
|
|
52
51
|
const [fillStatusPDA] = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("fills"), relayHashUint8Array], program.programId);
|
|
53
52
|
// Accounts for requestingSlowFill.
|
|
54
53
|
requestAccounts = {
|
|
@@ -75,7 +74,7 @@ describe("svm_spoke.slow_fill.across_plus", () => {
|
|
|
75
74
|
updatedOutputAmount: relayData.outputAmount,
|
|
76
75
|
});
|
|
77
76
|
}
|
|
78
|
-
const merkleTree = new MerkleTree_1.MerkleTree(slowRelayLeafs,
|
|
77
|
+
const merkleTree = new MerkleTree_1.MerkleTree(slowRelayLeafs, svm_1.slowFillHashFn);
|
|
79
78
|
const slowRelayRoot = merkleTree.getRoot();
|
|
80
79
|
const proof = merkleTree.getProof(slowRelayLeafs[0]);
|
|
81
80
|
const leaf = slowRelayLeafs[0];
|
|
@@ -93,7 +92,7 @@ describe("svm_spoke.slow_fill.across_plus", () => {
|
|
|
93
92
|
.accounts(relayRootBundleAccounts)
|
|
94
93
|
.rpc();
|
|
95
94
|
const proofAsNumbers = proof.map((p) => Array.from(p));
|
|
96
|
-
const relayHash = (0,
|
|
95
|
+
const relayHash = (0, svm_1.calculateRelayHashUint8Array)(slowRelayLeaf.relayData, chainId);
|
|
97
96
|
return { relayHash, leaf, rootBundleId, proofAsNumbers, rootBundle };
|
|
98
97
|
};
|
|
99
98
|
const createSlowFillIx = async (multicallHandlerCoder, bufferParams = false) => {
|
|
@@ -102,7 +101,7 @@ describe("svm_spoke.slow_fill.across_plus", () => {
|
|
|
102
101
|
const requestV3SlowFillValues = [Array.from(relayHash), leaf.relayData];
|
|
103
102
|
let loadRequestParamsInstructions = [];
|
|
104
103
|
if (bufferParams) {
|
|
105
|
-
loadRequestParamsInstructions = await (0,
|
|
104
|
+
loadRequestParamsInstructions = await (0, svm_1.loadRequestV3SlowFillParams)(program, relayer, requestV3SlowFillValues[1]);
|
|
106
105
|
[requestAccounts.instructionParams] = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("instruction_params"), relayer.publicKey.toBuffer()], program.programId);
|
|
107
106
|
}
|
|
108
107
|
const requestV3SlowFillParams = bufferParams
|
|
@@ -136,7 +135,7 @@ describe("svm_spoke.slow_fill.across_plus", () => {
|
|
|
136
135
|
];
|
|
137
136
|
let loadExecuteParamsInstructions = [];
|
|
138
137
|
if (bufferParams) {
|
|
139
|
-
loadExecuteParamsInstructions = await (0,
|
|
138
|
+
loadExecuteParamsInstructions = await (0, svm_1.loadExecuteV3SlowRelayLeafParams)(program, relayer, executeV3SlowRelayLeafValues[1], executeV3SlowRelayLeafValues[2], executeV3SlowRelayLeafValues[3]);
|
|
140
139
|
[requestAccounts.instructionParams] = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("instruction_params"), relayer.publicKey.toBuffer()], program.programId);
|
|
141
140
|
}
|
|
142
141
|
const executeV3SlowRelayLeafParams = bufferParams
|
|
@@ -171,7 +170,7 @@ describe("svm_spoke.slow_fill.across_plus", () => {
|
|
|
171
170
|
inputAmount: new anchor_1.BN(relayAmount),
|
|
172
171
|
outputAmount: new anchor_1.BN(relayAmount),
|
|
173
172
|
originChainId: new anchor_1.BN(1),
|
|
174
|
-
depositId: (0,
|
|
173
|
+
depositId: (0, svm_1.intToU8Array32)(Math.floor(Math.random() * 1000000)), // Unique ID for each test.
|
|
175
174
|
fillDeadline: Math.floor(Date.now() / 1000) + 60, // 1 minute from now
|
|
176
175
|
exclusivityDeadline: Math.floor(Date.now() / 1000) - 30, // Note we set time in past to avoid exclusivity deadline
|
|
177
176
|
message: Buffer.from(""), // Will be populated in the tests below.
|
|
@@ -182,9 +181,9 @@ describe("svm_spoke.slow_fill.across_plus", () => {
|
|
|
182
181
|
const iVaultBal = (await (0, spl_token_1.getAccount)(connection, vault)).amount;
|
|
183
182
|
// Construct ix to transfer all tokens from handler to the final recipient.
|
|
184
183
|
const transferIx = (0, spl_token_1.createTransferCheckedInstruction)(handlerATA, mint, finalRecipientATA, handlerSigner, relayData.outputAmount.toNumber(), tokenDecimals);
|
|
185
|
-
const multicallHandlerCoder = new
|
|
184
|
+
const multicallHandlerCoder = new svm_1.MulticallHandlerCoder([transferIx]);
|
|
186
185
|
const handlerMessage = multicallHandlerCoder.encode();
|
|
187
|
-
const message = new
|
|
186
|
+
const message = new svm_1.AcrossPlusMessageCoder({
|
|
188
187
|
handler: handlerProgram.programId,
|
|
189
188
|
readOnlyLen: multicallHandlerCoder.readOnlyLen,
|
|
190
189
|
valueAmount: new anchor_1.BN(0),
|
|
@@ -220,9 +219,9 @@ describe("svm_spoke.slow_fill.across_plus", () => {
|
|
|
220
219
|
const transferInstruction = (0, spl_token_1.createTransferCheckedInstruction)(handlerATA, mint, recipientATA, handlerSigner, distributionAmount, tokenDecimals);
|
|
221
220
|
transferInstructions.push(transferInstruction);
|
|
222
221
|
}
|
|
223
|
-
const multicallHandlerCoder = new
|
|
222
|
+
const multicallHandlerCoder = new svm_1.MulticallHandlerCoder(transferInstructions);
|
|
224
223
|
const handlerMessage = multicallHandlerCoder.encode();
|
|
225
|
-
const message = new
|
|
224
|
+
const message = new svm_1.AcrossPlusMessageCoder({
|
|
226
225
|
handler: handlerProgram.programId,
|
|
227
226
|
readOnlyLen: multicallHandlerCoder.readOnlyLen,
|
|
228
227
|
valueAmount: new anchor_1.BN(0),
|
|
@@ -247,14 +246,14 @@ describe("svm_spoke.slow_fill.across_plus", () => {
|
|
|
247
246
|
await (0, web3_js_1.sendAndConfirmTransaction)(program.provider.connection, new web3_js_1.Transaction().add(loadRequestParamsInstructions[i]), [relayer]);
|
|
248
247
|
}
|
|
249
248
|
}
|
|
250
|
-
await (0,
|
|
249
|
+
await (0, svm_1.sendTransactionWithLookupTable)(connection, [computeBudgetIx, requestIx], relayer);
|
|
251
250
|
await new Promise((resolve) => setTimeout(resolve, 1000)); // Make sure request tx gets processed.
|
|
252
251
|
if (bufferParams) {
|
|
253
252
|
for (let i = 0; i < loadExecuteParamsInstructions.length; i += 1) {
|
|
254
253
|
await (0, web3_js_1.sendAndConfirmTransaction)(program.provider.connection, new web3_js_1.Transaction().add(loadExecuteParamsInstructions[i]), [relayer]);
|
|
255
254
|
}
|
|
256
255
|
}
|
|
257
|
-
await (0,
|
|
256
|
+
await (0, svm_1.sendTransactionWithLookupTable)(connection, [computeBudgetIx, executeIx], relayer);
|
|
258
257
|
// Verify vault's balance after the fill
|
|
259
258
|
await new Promise((resolve) => setTimeout(resolve, 1000)); // Make sure token transfers get processed.
|
|
260
259
|
const fVaultBal = (await (0, spl_token_1.getAccount)(connection, vault)).amount;
|
|
@@ -280,9 +279,9 @@ describe("svm_spoke.slow_fill.across_plus", () => {
|
|
|
280
279
|
it("Can recover and close fill status PDA from event data", async () => {
|
|
281
280
|
// Construct ix to transfer all tokens from handler to the final recipient.
|
|
282
281
|
const transferIx = (0, spl_token_1.createTransferCheckedInstruction)(handlerATA, mint, finalRecipientATA, handlerSigner, relayData.outputAmount.toNumber(), tokenDecimals);
|
|
283
|
-
const multicallHandlerCoder = new
|
|
282
|
+
const multicallHandlerCoder = new svm_1.MulticallHandlerCoder([transferIx]);
|
|
284
283
|
const handlerMessage = multicallHandlerCoder.encode();
|
|
285
|
-
const message = new
|
|
284
|
+
const message = new svm_1.AcrossPlusMessageCoder({
|
|
286
285
|
handler: handlerProgram.programId,
|
|
287
286
|
readOnlyLen: multicallHandlerCoder.readOnlyLen,
|
|
288
287
|
valueAmount: new anchor_1.BN(0),
|
|
@@ -300,12 +299,12 @@ describe("svm_spoke.slow_fill.across_plus", () => {
|
|
|
300
299
|
for (let i = 0; i < loadRequestParamsInstructions.length; i += 1) {
|
|
301
300
|
await (0, web3_js_1.sendAndConfirmTransaction)(program.provider.connection, new web3_js_1.Transaction().add(loadRequestParamsInstructions[i]), [relayer]);
|
|
302
301
|
}
|
|
303
|
-
await (0,
|
|
302
|
+
await (0, svm_1.sendTransactionWithLookupTable)(connection, [requestIx], relayer);
|
|
304
303
|
await new Promise((resolve) => setTimeout(resolve, 1000)); // Make sure request tx gets processed.
|
|
305
304
|
for (let i = 0; i < loadExecuteParamsInstructions.length; i += 1) {
|
|
306
305
|
await (0, web3_js_1.sendAndConfirmTransaction)(program.provider.connection, new web3_js_1.Transaction().add(loadExecuteParamsInstructions[i]), [relayer]);
|
|
307
306
|
}
|
|
308
|
-
const { txSignature } = await (0,
|
|
307
|
+
const { txSignature } = await (0, svm_1.sendTransactionWithLookupTable)(connection, [executeIx], relayer);
|
|
309
308
|
await connection.confirmTransaction(txSignature, "confirmed");
|
|
310
309
|
await connection.getTransaction(txSignature, {
|
|
311
310
|
commitment: "confirmed",
|
|
@@ -313,11 +312,11 @@ describe("svm_spoke.slow_fill.across_plus", () => {
|
|
|
313
312
|
});
|
|
314
313
|
// We don't close ALT here as that would require ~4 minutes between deactivation and closing, but we demonstrate
|
|
315
314
|
// being able to close the fill status PDA using only event data.
|
|
316
|
-
const events = await (0,
|
|
315
|
+
const events = await (0, svm_1.readEventsUntilFound)(connection, txSignature, [program]);
|
|
317
316
|
const eventData = events.find((event) => event.name === "filledV3Relay")?.data;
|
|
318
317
|
assert.isNotNull(eventData, "FilledV3Relay event should be emitted");
|
|
319
318
|
// Recover relay hash and derived fill status from event data.
|
|
320
|
-
const relayHashUint8Array = (0,
|
|
319
|
+
const relayHashUint8Array = (0, svm_1.calculateRelayEventHashUint8Array)(eventData, chainId);
|
|
321
320
|
const [fillStatusPDA] = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("fills"), relayHashUint8Array], program.programId);
|
|
322
321
|
const fillStatusAccount = await program.account.fillStatusAccount.fetch(fillStatusPDA);
|
|
323
322
|
assert.isTrue("filled" in fillStatusAccount.status, "Fill status account should be marked as filled");
|