@across-protocol/sdk 4.3.40 → 4.3.42
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/dist/cjs/arch/svm/BlockUtils.d.ts +2 -2
- package/dist/cjs/arch/svm/BlockUtils.js +3 -3
- package/dist/cjs/arch/svm/BlockUtils.js.map +1 -1
- package/dist/cjs/arch/svm/SpokeUtils.d.ts +3 -3
- package/dist/cjs/arch/svm/SpokeUtils.js +16 -13
- package/dist/cjs/arch/svm/SpokeUtils.js.map +1 -1
- package/dist/cjs/arch/svm/utils.d.ts +2 -2
- package/dist/cjs/arch/svm/utils.js +5 -4
- package/dist/cjs/arch/svm/utils.js.map +1 -1
- package/dist/cjs/clients/BaseAbstractClient.js +4 -2
- package/dist/cjs/clients/BaseAbstractClient.js.map +1 -1
- package/dist/cjs/clients/BundleDataClient/BundleDataClient.js +1 -1
- package/dist/cjs/clients/BundleDataClient/BundleDataClient.js.map +1 -1
- package/dist/cjs/clients/SpokePoolClient/SVMSpokePoolClient.js +3 -2
- package/dist/cjs/clients/SpokePoolClient/SVMSpokePoolClient.js.map +1 -1
- package/dist/esm/arch/svm/BlockUtils.d.ts +2 -2
- package/dist/esm/arch/svm/BlockUtils.js +3 -3
- package/dist/esm/arch/svm/BlockUtils.js.map +1 -1
- package/dist/esm/arch/svm/SpokeUtils.d.ts +3 -3
- package/dist/esm/arch/svm/SpokeUtils.js +16 -13
- package/dist/esm/arch/svm/SpokeUtils.js.map +1 -1
- package/dist/esm/arch/svm/utils.d.ts +2 -2
- package/dist/esm/arch/svm/utils.js +5 -4
- package/dist/esm/arch/svm/utils.js.map +1 -1
- package/dist/esm/clients/BaseAbstractClient.js +4 -2
- package/dist/esm/clients/BaseAbstractClient.js.map +1 -1
- package/dist/esm/clients/BundleDataClient/BundleDataClient.js +1 -1
- package/dist/esm/clients/BundleDataClient/BundleDataClient.js.map +1 -1
- package/dist/esm/clients/SpokePoolClient/SVMSpokePoolClient.js +3 -2
- package/dist/esm/clients/SpokePoolClient/SVMSpokePoolClient.js.map +1 -1
- package/dist/types/arch/svm/BlockUtils.d.ts +2 -2
- package/dist/types/arch/svm/BlockUtils.d.ts.map +1 -1
- package/dist/types/arch/svm/SpokeUtils.d.ts +3 -3
- package/dist/types/arch/svm/SpokeUtils.d.ts.map +1 -1
- package/dist/types/arch/svm/utils.d.ts +2 -2
- package/dist/types/arch/svm/utils.d.ts.map +1 -1
- package/dist/types/clients/BaseAbstractClient.d.ts.map +1 -1
- package/dist/types/clients/SpokePoolClient/SVMSpokePoolClient.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/arch/svm/BlockUtils.ts +3 -3
- package/src/arch/svm/SpokeUtils.ts +18 -15
- package/src/arch/svm/utils.ts +5 -4
- package/src/clients/BaseAbstractClient.ts +2 -1
- package/src/clients/BundleDataClient/BundleDataClient.ts +2 -2
- package/src/clients/SpokePoolClient/SVMSpokePoolClient.ts +2 -1
|
@@ -89,21 +89,21 @@ type ProtoFill = Omit<RelayData, "recipient" | "outputToken"> & {
|
|
|
89
89
|
outputToken: SvmAddress;
|
|
90
90
|
};
|
|
91
91
|
|
|
92
|
-
export function getSlot(provider: SVMProvider, commitment: Commitment, logger
|
|
92
|
+
export function getSlot(provider: SVMProvider, commitment: Commitment, logger?: winston.Logger): Promise<bigint> {
|
|
93
93
|
return _callGetSlotWithRetry(provider, commitment, logger);
|
|
94
94
|
}
|
|
95
95
|
|
|
96
96
|
async function _callGetSlotWithRetry(
|
|
97
97
|
provider: SVMProvider,
|
|
98
98
|
commitment: Commitment,
|
|
99
|
-
logger
|
|
99
|
+
logger?: winston.Logger
|
|
100
100
|
): Promise<bigint> {
|
|
101
101
|
try {
|
|
102
102
|
return await provider.getSlot({ commitment }).send();
|
|
103
103
|
} catch (err) {
|
|
104
104
|
if (isSolanaError(err)) {
|
|
105
105
|
const { __code: code } = err.context;
|
|
106
|
-
logger
|
|
106
|
+
logger?.debug({
|
|
107
107
|
at: "_getSlotWithRetry",
|
|
108
108
|
message: "Caught error from getSlot()",
|
|
109
109
|
code,
|
|
@@ -122,8 +122,8 @@ async function _callGetSlotWithRetry(
|
|
|
122
122
|
export function getTimestampForSlot(
|
|
123
123
|
provider: SVMProvider,
|
|
124
124
|
slotNumber: bigint,
|
|
125
|
-
|
|
126
|
-
|
|
125
|
+
maxRetries = 2,
|
|
126
|
+
logger?: winston.Logger
|
|
127
127
|
): Promise<number | undefined> {
|
|
128
128
|
return _callGetTimestampForSlotWithRetry(provider, slotNumber, 0, maxRetries, logger);
|
|
129
129
|
}
|
|
@@ -133,7 +133,7 @@ async function _callGetTimestampForSlotWithRetry(
|
|
|
133
133
|
slotNumber: bigint,
|
|
134
134
|
retryAttempt: number,
|
|
135
135
|
maxRetries: number,
|
|
136
|
-
logger
|
|
136
|
+
logger?: winston.Logger
|
|
137
137
|
): Promise<number | undefined> {
|
|
138
138
|
// @note: getBlockTime receives a slot number, not a block number.
|
|
139
139
|
let _timestamp: bigint;
|
|
@@ -159,7 +159,7 @@ async function _callGetTimestampForSlotWithRetry(
|
|
|
159
159
|
if (retryAttempt >= maxRetries) {
|
|
160
160
|
throw new Error(`Timeout on SVM getBlockTime() for slot ${slot} after ${retryAttempt} retry attempts`);
|
|
161
161
|
}
|
|
162
|
-
logger
|
|
162
|
+
logger?.debug({
|
|
163
163
|
at: "getTimestampForSlot",
|
|
164
164
|
message: `Retrying getBlockTime() after ${delaySeconds} seconds for retry attempt #${retryAttempt}`,
|
|
165
165
|
slot,
|
|
@@ -172,7 +172,7 @@ async function _callGetTimestampForSlotWithRetry(
|
|
|
172
172
|
}
|
|
173
173
|
|
|
174
174
|
default:
|
|
175
|
-
logger
|
|
175
|
+
logger?.debug({
|
|
176
176
|
at: "getTimestampForSlot",
|
|
177
177
|
message: "Caught error from getBlockTime()",
|
|
178
178
|
errorCode: code,
|
|
@@ -253,7 +253,8 @@ export async function findDeposit(
|
|
|
253
253
|
}
|
|
254
254
|
|
|
255
255
|
const provider = eventClient.getRpc();
|
|
256
|
-
const
|
|
256
|
+
const opts = undefined;
|
|
257
|
+
const { slot: currentSlot } = await getNearestSlotTime(provider, opts, logger);
|
|
257
258
|
|
|
258
259
|
// If no slot is provided, use the current slot
|
|
259
260
|
// If a slot is provided, ensure it's not in the future
|
|
@@ -325,7 +326,7 @@ export async function relayFillStatus(
|
|
|
325
326
|
const commitment = "confirmed";
|
|
326
327
|
const [fillStatusAccount, { slot: currentSlot, timestamp }] = await Promise.all([
|
|
327
328
|
fetchEncodedAccount(provider, fillStatusPda, { commitment }),
|
|
328
|
-
getNearestSlotTime(provider,
|
|
329
|
+
getNearestSlotTime(provider, { commitment }, logger),
|
|
329
330
|
]);
|
|
330
331
|
toSlot = currentSlot;
|
|
331
332
|
|
|
@@ -407,7 +408,8 @@ export async function fillStatusArray(
|
|
|
407
408
|
const missingResults: { index: number; fillStatus: FillStatus }[] = [];
|
|
408
409
|
|
|
409
410
|
// Determine the toSlot to use for event reconstruction
|
|
410
|
-
const
|
|
411
|
+
const opts = undefined;
|
|
412
|
+
const toSlot = atHeight ? BigInt(atHeight) : (await getNearestSlotTime(provider, opts, logger)).slot;
|
|
411
413
|
|
|
412
414
|
// @note: This path is mostly used for deposits past their fill deadline.
|
|
413
415
|
// If it becomes a bottleneck, consider returning an "Unknown" status that can be handled downstream.
|
|
@@ -445,12 +447,13 @@ export async function findFillEvent(
|
|
|
445
447
|
relayData: RelayData,
|
|
446
448
|
destinationChainId: number,
|
|
447
449
|
svmEventsClient: SvmCpiEventsClient,
|
|
448
|
-
logger: winston.Logger,
|
|
449
450
|
fromSlot: number,
|
|
450
|
-
toSlot?: number
|
|
451
|
+
toSlot?: number,
|
|
452
|
+
logger?: winston.Logger
|
|
451
453
|
): Promise<FillWithBlock | undefined> {
|
|
452
454
|
assert(chainIsSvm(destinationChainId), "Destination chain must be an SVM chain");
|
|
453
|
-
|
|
455
|
+
const opts = undefined;
|
|
456
|
+
toSlot ??= Number((await getNearestSlotTime(svmEventsClient.getRpc(), opts, logger)).slot);
|
|
454
457
|
|
|
455
458
|
// Get fillStatus PDA using relayData
|
|
456
459
|
const programId = svmEventsClient.getProgramAddress();
|
|
@@ -931,7 +934,7 @@ async function fetchBatchFillStatusFromPdaAccounts(
|
|
|
931
934
|
|
|
932
935
|
const [pdaAccounts, { timestamp }] = await Promise.all([
|
|
933
936
|
Promise.all(chunk(fillStatusPdas, chunkSize).map((chunk) => fetchEncodedAccounts(provider, chunk, { commitment }))),
|
|
934
|
-
getNearestSlotTime(provider,
|
|
937
|
+
getNearestSlotTime(provider, { commitment }, logger),
|
|
935
938
|
]);
|
|
936
939
|
|
|
937
940
|
const fillStatuses = pdaAccounts.flat().map((account, index) => {
|
package/src/arch/svm/utils.ts
CHANGED
|
@@ -68,14 +68,15 @@ export function toAddress(address: SdkAddress): Address<string> {
|
|
|
68
68
|
*/
|
|
69
69
|
export async function getNearestSlotTime(
|
|
70
70
|
provider: SVMProvider,
|
|
71
|
-
|
|
72
|
-
|
|
71
|
+
opts: { slot: bigint } | { commitment: Commitment } = { commitment: "confirmed" },
|
|
72
|
+
logger?: winston.Logger
|
|
73
73
|
): Promise<{ slot: bigint; timestamp: number }> {
|
|
74
74
|
let timestamp: number | undefined;
|
|
75
75
|
let slot = "slot" in opts ? opts.slot : await getSlot(provider, opts.commitment, logger);
|
|
76
|
+
const maxRetries = undefined; // Inherit defaults
|
|
76
77
|
|
|
77
78
|
do {
|
|
78
|
-
timestamp = await getTimestampForSlot(provider, slot, logger);
|
|
79
|
+
timestamp = await getTimestampForSlot(provider, slot, maxRetries, logger);
|
|
79
80
|
} while (!isDefined(timestamp) && --slot);
|
|
80
81
|
assert(isDefined(timestamp), `Unable to resolve block time for SVM slot ${slot}`);
|
|
81
82
|
|
|
@@ -94,7 +95,7 @@ export async function getLatestFinalizedSlotWithBlock(
|
|
|
94
95
|
maxLookback = 1000
|
|
95
96
|
): Promise<number> {
|
|
96
97
|
const opts = { maxSupportedTransactionVersion: 0, transactionDetails: "none", rewards: false } as const;
|
|
97
|
-
const { slot: finalizedSlot } = await getNearestSlotTime(provider,
|
|
98
|
+
const { slot: finalizedSlot } = await getNearestSlotTime(provider, { commitment: "finalized" }, logger);
|
|
98
99
|
const endSlot = biMin(maxSlot, finalizedSlot);
|
|
99
100
|
|
|
100
101
|
let slot = endSlot;
|
|
@@ -89,7 +89,8 @@ export abstract class BaseAbstractClient {
|
|
|
89
89
|
throw new Error(`Invalid event search config from (${from}) > to (${to})`);
|
|
90
90
|
}
|
|
91
91
|
} else {
|
|
92
|
-
const
|
|
92
|
+
const opts = undefined; // Inherit defaults
|
|
93
|
+
const { slot } = await getNearestSlotTime(provider, opts, logger);
|
|
93
94
|
to = Number(slot);
|
|
94
95
|
if (to < from) {
|
|
95
96
|
return UpdateFailureReason.AlreadyUpdated;
|
|
@@ -1651,9 +1651,9 @@ export class BundleDataClient {
|
|
|
1651
1651
|
deposit,
|
|
1652
1652
|
spokePoolClient.chainId,
|
|
1653
1653
|
spokePoolClient.svmEventsClient,
|
|
1654
|
-
spokePoolClient.logger,
|
|
1655
1654
|
spokePoolClient.deploymentBlock,
|
|
1656
|
-
spokePoolClient.latestHeightSearched
|
|
1655
|
+
spokePoolClient.latestHeightSearched,
|
|
1656
|
+
spokePoolClient.logger
|
|
1657
1657
|
);
|
|
1658
1658
|
} else if (isEVMSpokePoolClient(spokePoolClient)) {
|
|
1659
1659
|
return await findEvmFillEvent(
|
|
@@ -194,8 +194,9 @@ export class SVMSpokePoolClient extends SpokePoolClient {
|
|
|
194
194
|
*/
|
|
195
195
|
public override async getTimestampForBlock(slot: number): Promise<number> {
|
|
196
196
|
let _slot = BigInt(slot);
|
|
197
|
+
const maxRetries = undefined; // Inherit defaults
|
|
197
198
|
do {
|
|
198
|
-
const timestamp = await getTimestampForSlot(this.svmEventsClient.getRpc(), _slot, this.logger);
|
|
199
|
+
const timestamp = await getTimestampForSlot(this.svmEventsClient.getRpc(), _slot, maxRetries, this.logger);
|
|
199
200
|
if (isDefined(timestamp)) {
|
|
200
201
|
return timestamp;
|
|
201
202
|
}
|