@settlemint/dalp-sdk 3.1.18-main.33876465458 → 3.1.18-main.33879205297
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/auth.js +1 -1
- package/dist/{chunk-r5m5s5m8.js → chunk-cnz704t8.js} +1 -1
- package/dist/chunk-sk9nc2q3.js +10 -0
- package/dist/generated/api-types.d.ts +9 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +5 -1
- package/dist/reads-as-indexer-rebuild.d.ts +14 -0
- package/dist/wait-for-transaction.d.ts +16 -2
- package/dist/wait-for-transaction.js +21 -5
- package/package.json +1 -1
package/dist/auth.js
CHANGED
|
@@ -102,7 +102,7 @@ function createCookieStoreFetch2(cookieStore, fetchImpl = globalThis.fetch) {
|
|
|
102
102
|
// package.json
|
|
103
103
|
var package_default = {
|
|
104
104
|
name: "@settlemint/dalp-sdk",
|
|
105
|
-
version: "3.1.18-main.
|
|
105
|
+
version: "3.1.18-main.33879205297",
|
|
106
106
|
private: false,
|
|
107
107
|
description: "Fully typed SDK for the DALP tokenization platform API",
|
|
108
108
|
homepage: "https://settlemint.com",
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// src/reads-as-indexer-rebuild.ts
|
|
2
|
+
function readsAsIndexerRebuild2(status) {
|
|
3
|
+
if (status === null || typeof status !== "object") {
|
|
4
|
+
return false;
|
|
5
|
+
}
|
|
6
|
+
const rebuild = Reflect.get(status, "indexerRebuild");
|
|
7
|
+
return rebuild !== undefined && rebuild !== null;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export { readsAsIndexerRebuild2 };
|
|
@@ -1979,6 +1979,7 @@ export type BlockProgressStreamEventEncoded = string;
|
|
|
1979
1979
|
|
|
1980
1980
|
export type BlockchainMonitoringV2ReindexInput = {
|
|
1981
1981
|
readonly chainId: number;
|
|
1982
|
+
readonly force?: boolean;
|
|
1982
1983
|
};
|
|
1983
1984
|
|
|
1984
1985
|
export type BlockchainMonitoringV2ReindexOutput = {
|
|
@@ -7413,6 +7414,10 @@ export type EvmTransactionStatusOutput = {
|
|
|
7413
7414
|
};
|
|
7414
7415
|
readonly shortfall: string;
|
|
7415
7416
|
readonly recommendedTotal: string;
|
|
7417
|
+
} | null;
|
|
7418
|
+
readonly indexerRebuild?: {
|
|
7419
|
+
readonly chainId: number;
|
|
7420
|
+
readonly blockNumber: number;
|
|
7416
7421
|
} | null;
|
|
7417
7422
|
readonly createdAt: TimestampEncoded;
|
|
7418
7423
|
readonly updatedAt: TimestampEncoded;
|
|
@@ -33062,6 +33067,10 @@ export type transaction_statusStream_Response = {
|
|
|
33062
33067
|
};
|
|
33063
33068
|
readonly shortfall: string;
|
|
33064
33069
|
readonly recommendedTotal: string;
|
|
33070
|
+
} | null;
|
|
33071
|
+
readonly indexerRebuild?: {
|
|
33072
|
+
readonly chainId: number;
|
|
33073
|
+
readonly blockNumber: number;
|
|
33065
33074
|
} | null;
|
|
33066
33075
|
readonly createdAt: string;
|
|
33067
33076
|
readonly updatedAt: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -30,4 +30,6 @@ export type { CallOptions } from "./proxy/builder.ts";
|
|
|
30
30
|
export { decodeEventStream, RESERVED_STREAM_FAILURE_EVENT, STREAM_FAILED_ERROR_CODE } from "./proxy/sse.ts";
|
|
31
31
|
export { createDalpSdkConfigurationError, DalpSdkError } from "./errors/sdk-error.ts";
|
|
32
32
|
export { DalpApiError, findDalpSdkError, isDalpApiError, makeDalpApiError } from "./errors/api-error.ts";
|
|
33
|
+
export { readsAsIndexerRebuild } from "./reads-as-indexer-rebuild.ts";
|
|
34
|
+
export type { TransactionWaitFailureReason } from "./wait-for-transaction.ts";
|
|
33
35
|
export { SDK_USER_AGENT, SDK_VERSION } from "./version.ts";
|
package/dist/index.js
CHANGED
|
@@ -26,7 +26,10 @@ import {
|
|
|
26
26
|
createCookieStoreFetch2,
|
|
27
27
|
SDK_VERSION2,
|
|
28
28
|
SDK_USER_AGENT2
|
|
29
|
-
} from "./chunk-
|
|
29
|
+
} from "./chunk-cnz704t8.js";
|
|
30
|
+
import {
|
|
31
|
+
readsAsIndexerRebuild2
|
|
32
|
+
} from "./chunk-sk9nc2q3.js";
|
|
30
33
|
import {
|
|
31
34
|
createDalpClient2
|
|
32
35
|
} from "./chunk-v6zadx3z.js";
|
|
@@ -146,5 +149,6 @@ export {
|
|
|
146
149
|
isDalpApiError2 as isDalpApiError,
|
|
147
150
|
makeCookieStore2 as makeCookieStore,
|
|
148
151
|
makeDalpApiError2 as makeDalpApiError,
|
|
152
|
+
readsAsIndexerRebuild2 as readsAsIndexerRebuild,
|
|
149
153
|
secret2 as secret
|
|
150
154
|
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Whether a transaction status row says the platform is rebuilding its index
|
|
3
|
+
* of the chain the write landed on.
|
|
4
|
+
*
|
|
5
|
+
* A rebuild replays a chain's whole history, so a write that is already mined
|
|
6
|
+
* cannot be read back until the replay reaches its block. The queue state does
|
|
7
|
+
* not move while that runs, so `indexerRebuild`, published on the status route
|
|
8
|
+
* and its stream, is the only field that says the wait is on the replay rather
|
|
9
|
+
* than on the chain. The wire declares it absent or null when no rebuild runs.
|
|
10
|
+
*
|
|
11
|
+
* A rebuild takes hours, against minutes for a funding pause, so a caller that
|
|
12
|
+
* reads this must widen its own patience rather than report a timeout.
|
|
13
|
+
*/
|
|
14
|
+
export declare function readsAsIndexerRebuild(status: unknown): boolean;
|
|
@@ -17,6 +17,8 @@ export interface WaitForTransactionStatus {
|
|
|
17
17
|
readonly result?: WaitForTransactionResult;
|
|
18
18
|
/** The open funding ask a write parked by the funding gate is waiting on. */
|
|
19
19
|
readonly activeRequirement?: EvmTransactionStatusOutput["activeRequirement"];
|
|
20
|
+
/** The chain and block an index rebuild must reach before this write reads back. */
|
|
21
|
+
readonly indexerRebuild?: EvmTransactionStatusOutput["indexerRebuild"];
|
|
20
22
|
}
|
|
21
23
|
/** Kind-scoped terminal result from the generated transaction status contract. */
|
|
22
24
|
export type WaitForTransactionResult = NonNullable<EvmTransactionStatusOutput["result"]>;
|
|
@@ -37,11 +39,20 @@ export interface WaitForTransactionOptions {
|
|
|
37
39
|
* own time.
|
|
38
40
|
*/
|
|
39
41
|
readonly holdWhilePaused?: boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Whether the wait outlasts an index rebuild. True, the default, restarts the
|
|
44
|
+
* timeout on every status that reports a rebuild, so the wait ends only when
|
|
45
|
+
* the replay reaches the write's block or the platform fails the request.
|
|
46
|
+
* False ends the wait on the first such status with reason `indexer-rebuild`,
|
|
47
|
+
* for a caller that would rather come back later than hold a connection open
|
|
48
|
+
* for the hours a replay takes.
|
|
49
|
+
*/
|
|
50
|
+
readonly holdWhileRebuilding?: boolean;
|
|
40
51
|
readonly now?: () => number;
|
|
41
52
|
readonly sleep?: (milliseconds: number, signal?: AbortSignal) => Promise<void>;
|
|
42
53
|
readonly readStatus?: (transactionId: string, signal?: AbortSignal) => Promise<WaitForTransactionStatus>;
|
|
43
54
|
}
|
|
44
|
-
export type TransactionWaitFailureReason = "terminal-failure" | "timeout" | "aborted" | "funding-paused";
|
|
55
|
+
export type TransactionWaitFailureReason = "terminal-failure" | "timeout" | "aborted" | "funding-paused" | "indexer-rebuild";
|
|
45
56
|
export declare class DalpTransactionWaitError extends Error {
|
|
46
57
|
readonly code = "sdk.transaction.WAIT_FAILED";
|
|
47
58
|
readonly category: "operational";
|
|
@@ -61,7 +72,10 @@ export declare const isDalpTransactionWaitError: (error: unknown) => error is Da
|
|
|
61
72
|
* The timeout measures the platform's progress. A status that reports an
|
|
62
73
|
* open funding ask restarts it, so a write parked on an operator payment is
|
|
63
74
|
* never reported as a timeout and a resumed write gets its whole budget back.
|
|
64
|
-
*
|
|
75
|
+
* A status that reports an index rebuild restarts it for the same reason: the
|
|
76
|
+
* write is already on chain and the platform is replaying that chain's history
|
|
77
|
+
* before it can be read back. `holdWhilePaused: false` and
|
|
78
|
+
* `holdWhileRebuilding: false` end the wait on those statuses instead. The
|
|
65
79
|
* `elapsedMs` a timeout carries is the whole wait, pauses included.
|
|
66
80
|
*/
|
|
67
81
|
export declare function waitForTransaction(client: DalpClient, transactionId: string, options?: WaitForTransactionOptions): Promise<WaitForTransactionSuccess>;
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import {
|
|
2
|
+
readsAsIndexerRebuild2
|
|
3
|
+
} from "./chunk-sk9nc2q3.js";
|
|
1
4
|
import {
|
|
2
5
|
readsAsFundingPaused,
|
|
3
6
|
PAUSED_POLL_INTERVAL_MAX_MS
|
|
@@ -22,6 +25,9 @@ class DalpTransactionWaitError extends Error {
|
|
|
22
25
|
message = `Transaction ${transactionId} did not reach a terminal state within ${elapsedMs ?? 0}ms`;
|
|
23
26
|
} else if (reason === "funding-paused") {
|
|
24
27
|
message = `Transaction ${transactionId} is paused waiting for a gas funding payment`;
|
|
28
|
+
} else if (reason === "indexer-rebuild") {
|
|
29
|
+
const chainId = lastStatus?.indexerRebuild?.chainId;
|
|
30
|
+
message = `Transaction ${transactionId} is on chain, and the platform is still rebuilding its index of chain ${chainId ?? "unknown"} before the write can be read back`;
|
|
25
31
|
} else {
|
|
26
32
|
message = `Transaction status observation was aborted for transaction ${transactionId}`;
|
|
27
33
|
}
|
|
@@ -39,7 +45,7 @@ class DalpTransactionWaitError extends Error {
|
|
|
39
45
|
return this.lastStatus?.subStatus ?? null;
|
|
40
46
|
}
|
|
41
47
|
get retryable() {
|
|
42
|
-
return this.reason === "timeout" || this.reason === "funding-paused";
|
|
48
|
+
return this.reason === "timeout" || this.reason === "funding-paused" || this.reason === "indexer-rebuild";
|
|
43
49
|
}
|
|
44
50
|
}
|
|
45
51
|
var isDalpTransactionWaitError = (error) => error instanceof DalpTransactionWaitError;
|
|
@@ -70,6 +76,7 @@ async function waitForTransaction(client, transactionId, options = {}) {
|
|
|
70
76
|
const sleep = options.sleep ?? defaultSleep;
|
|
71
77
|
const readStatus = options.readStatus ?? routeStatusReader(client);
|
|
72
78
|
const holdWhilePaused = options.holdWhilePaused ?? true;
|
|
79
|
+
const holdWhileRebuilding = options.holdWhileRebuilding ?? true;
|
|
73
80
|
const waitStartedAt = now();
|
|
74
81
|
let budgetStartedAt = waitStartedAt;
|
|
75
82
|
let pollDelayMs = pollIntervalMs;
|
|
@@ -97,14 +104,23 @@ async function waitForTransaction(client, transactionId, options = {}) {
|
|
|
97
104
|
if (isWaitForTransactionSuccess(lastStatus)) {
|
|
98
105
|
return lastStatus;
|
|
99
106
|
}
|
|
107
|
+
let parkedBy;
|
|
108
|
+
let holdsThroughIt = false;
|
|
100
109
|
if (readsAsFundingPaused(lastStatus)) {
|
|
101
|
-
|
|
102
|
-
|
|
110
|
+
parkedBy = "funding-paused";
|
|
111
|
+
holdsThroughIt = holdWhilePaused;
|
|
112
|
+
} else if (readsAsIndexerRebuild2(lastStatus)) {
|
|
113
|
+
parkedBy = "indexer-rebuild";
|
|
114
|
+
holdsThroughIt = holdWhileRebuilding;
|
|
115
|
+
}
|
|
116
|
+
if (parkedBy === undefined) {
|
|
117
|
+
pollDelayMs = pollIntervalMs;
|
|
118
|
+
} else {
|
|
119
|
+
if (!holdsThroughIt) {
|
|
120
|
+
throw new DalpTransactionWaitError(transactionId, parkedBy, lastStatus, now() - waitStartedAt);
|
|
103
121
|
}
|
|
104
122
|
budgetStartedAt = now();
|
|
105
123
|
pollDelayMs = Math.min(pollDelayMs * 2, Math.max(pollIntervalMs, PAUSED_POLL_INTERVAL_MAX_MS));
|
|
106
|
-
} else {
|
|
107
|
-
pollDelayMs = pollIntervalMs;
|
|
108
124
|
}
|
|
109
125
|
try {
|
|
110
126
|
await sleep(Math.min(pollDelayMs, Math.max(0, timeoutMs - (now() - budgetStartedAt))), options.signal);
|
package/package.json
CHANGED