@settlemint/dalp-sdk 3.1.11-main.33723791073 → 3.1.11-main.33724992663

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 CHANGED
@@ -63,6 +63,15 @@ id and the status URL. That is not a failed write: the transaction is still on
63
63
  its way to a block, and resubmitting is a second transfer. `settlementTimeoutMs`
64
64
  sets the bound per client, and a call may override it.
65
65
 
66
+ A write the funding gate parks on an operator payment is stopped, not slow. The
67
+ status row carries the open ask as `activeRequirement`, and every read that
68
+ reports one restarts the bound, so the wait outlasts the pause and resolves
69
+ with the settled record once the ask is paid. When an ask lapses unpaid the
70
+ platform fails the request, and that failure is what the client reports. A
71
+ caller that cannot wait that long ends the wait through `signal`, and
72
+ `waitForTransaction` takes `holdWhilePaused: false` to end on the first parked
73
+ status with reason `funding-paused` instead.
74
+
66
75
  ### Conditional requests and ETags
67
76
 
68
77
  The client reuses a held body when the server answers a matching ETag with 304.
package/dist/auth.js CHANGED
@@ -2,7 +2,7 @@ import {
2
2
  SDK_USER_AGENT,
3
3
  createCookieStoreFetch,
4
4
  makeCookieStore
5
- } from "./chunk-tm3g9mh4.js";
5
+ } from "./chunk-g5ch7ns0.js";
6
6
  import {
7
7
  normalizeDalpBaseUrl,
8
8
  secret,
package/dist/bundler.js CHANGED
@@ -1,8 +1,9 @@
1
1
  import {
2
2
  createDalpClient
3
- } from "./chunk-wk8e0p9d.js";
3
+ } from "./chunk-vw4bccje.js";
4
4
  import"./chunk-f4t1bm86.js";
5
- import"./chunk-mrfkqrht.js";
5
+ import"./chunk-gpezyfx3.js";
6
+ import"./chunk-fjnq61hj.js";
6
7
  import"./chunk-0m709wz4.js";
7
8
  import"./chunk-h12fatty.js";
8
9
  import"./chunk-y0d2c7kp.js";
@@ -0,0 +1,11 @@
1
+ // src/reads-as-funding-paused.ts
2
+ function readsAsFundingPaused(status) {
3
+ if (status === null || typeof status !== "object") {
4
+ return false;
5
+ }
6
+ const requirement = Reflect.get(status, "activeRequirement");
7
+ return requirement !== undefined && requirement !== null;
8
+ }
9
+ var PAUSED_POLL_INTERVAL_MAX_MS = 30000;
10
+
11
+ export { readsAsFundingPaused, PAUSED_POLL_INTERVAL_MAX_MS };
@@ -102,7 +102,7 @@ function createCookieStoreFetch(cookieStore, fetchImpl = globalThis.fetch) {
102
102
  // package.json
103
103
  var package_default = {
104
104
  name: "@settlemint/dalp-sdk",
105
- version: "3.1.11-main.33723791073",
105
+ version: "3.1.11-main.33724992663",
106
106
  private: false,
107
107
  description: "Fully typed SDK for the DALP tokenization platform API",
108
108
  homepage: "https://settlemint.com",
@@ -1,3 +1,7 @@
1
+ import {
2
+ PAUSED_POLL_INTERVAL_MAX_MS,
3
+ readsAsFundingPaused
4
+ } from "./chunk-fjnq61hj.js";
1
5
  import {
2
6
  Secret,
3
7
  normalizeDalpBaseUrl,
@@ -749,13 +753,14 @@ async function resolveSettlement(transport, payload, options, now = Date.now, sl
749
753
  return payload;
750
754
  }
751
755
  const timeoutMs = options?.settlementTimeoutMs ?? transport.settlementTimeoutMs ?? DEFAULT_SETTLEMENT_TIMEOUT_MS;
752
- const deadline = now() + timeoutMs;
756
+ let deadline = now() + timeoutMs;
757
+ let pollIntervalMs = POLL_INTERVAL_MS;
753
758
  const statusUrl = handle.statusUrl.startsWith("http") ? handle.statusUrl : `${transport.baseUrl}${handle.statusUrl}`;
754
759
  for (;; ) {
755
760
  if (now() >= deadline) {
756
761
  throw new SettlementTimeoutError(handle.transactionId, handle.statusUrl, timeoutMs);
757
762
  }
758
- await sleep(POLL_INTERVAL_MS);
763
+ await sleep(pollIntervalMs);
759
764
  const response = await transport.fetch(statusUrl, {
760
765
  method: "GET",
761
766
  headers: callHeaders(transport, options),
@@ -771,6 +776,12 @@ async function resolveSettlement(transport, payload, options, now = Date.now, sl
771
776
  if (state !== undefined && FAILURE_STATES.has(state)) {
772
777
  throw new SettlementFailedError(handle.transactionId, state, readString2(body, "errorMessage"));
773
778
  }
779
+ if (readsAsFundingPaused(body)) {
780
+ deadline = now() + timeoutMs;
781
+ pollIntervalMs = Math.min(pollIntervalMs * 2, PAUSED_POLL_INTERVAL_MAX_MS);
782
+ } else {
783
+ pollIntervalMs = POLL_INTERVAL_MS;
784
+ }
774
785
  }
775
786
  }
776
787
 
@@ -8,7 +8,7 @@ import {
8
8
  createTransport,
9
9
  sendRequest,
10
10
  streamRequest
11
- } from "./chunk-mrfkqrht.js";
11
+ } from "./chunk-gpezyfx3.js";
12
12
  import {
13
13
  data
14
14
  } from "./chunk-0m709wz4.js";
package/dist/effect.js CHANGED
@@ -8,7 +8,8 @@ import {
8
8
  queryKeyFor,
9
9
  sendRequest,
10
10
  streamRequest
11
- } from "./chunk-mrfkqrht.js";
11
+ } from "./chunk-gpezyfx3.js";
12
+ import"./chunk-fjnq61hj.js";
12
13
  import {
13
14
  data
14
15
  } from "./chunk-0m709wz4.js";
package/dist/index.js CHANGED
@@ -3,10 +3,10 @@ import {
3
3
  SDK_VERSION,
4
4
  createCookieStoreFetch,
5
5
  makeCookieStore
6
- } from "./chunk-tm3g9mh4.js";
6
+ } from "./chunk-g5ch7ns0.js";
7
7
  import {
8
8
  createDalpClient
9
- } from "./chunk-wk8e0p9d.js";
9
+ } from "./chunk-vw4bccje.js";
10
10
  import"./chunk-f4t1bm86.js";
11
11
  import {
12
12
  DEFAULT_SETTLEMENT_TIMEOUT_MS,
@@ -17,7 +17,8 @@ import {
17
17
  findDalpSdkError,
18
18
  isDalpApiError,
19
19
  makeDalpApiError
20
- } from "./chunk-mrfkqrht.js";
20
+ } from "./chunk-gpezyfx3.js";
21
+ import"./chunk-fjnq61hj.js";
21
22
  import"./chunk-0m709wz4.js";
22
23
  import {
23
24
  SECRET_REDACTION_MARKER,
@@ -12,14 +12,30 @@
12
12
  * not a failed mutation, and reporting it as one would tell a caller their
13
13
  * write was rejected when it is still queued. `SettlementTimeoutError` carries
14
14
  * `transactionId` and `statusUrl` so the caller can resume the wait through
15
- * `./wait-for-transaction` or read the status route directly.
15
+ * `../wait-for-transaction` or read the status route directly.
16
+ *
17
+ * The bound measures the platform's progress, not the calendar. A write the
18
+ * funding gate has parked on an operator payment is stopped, not slow: the
19
+ * status row reports the open ask as `activeRequirement` on every read, and no
20
+ * progress is expected until the ask is paid. Every read that reports one
21
+ * restarts the bound, so a parked write is never reported as a timeout and a
22
+ * resumed write gets its whole budget back. What ends a pause is the payment
23
+ * arriving or the platform failing the request when the ask lapses, and both
24
+ * reach this loop as status. A caller that cannot wait that long ends the
25
+ * wait through its `signal`. While the write is parked the reads slow down,
26
+ * because the gate resumes it at its own cadence and the status route pays
27
+ * for every read.
16
28
  *
17
29
  * @module
18
30
  */
19
31
  import { DalpSdkError } from "../errors/sdk-error.ts";
20
32
  import type { CallOptions } from "./builder.ts";
21
33
  import { type Transport } from "./transport.ts";
22
- /** Default bound on how long the SDK follows a handle before giving it back. */
34
+ /**
35
+ * Default bound on how long the SDK follows a handle while the platform is
36
+ * making progress. Time the write spends parked on a funding ask does not
37
+ * count against it.
38
+ */
23
39
  export declare const DEFAULT_SETTLEMENT_TIMEOUT_MS = 120000;
24
40
  /** Raised when the wait runs out while the work is still queued. */
25
41
  export declare class SettlementTimeoutError extends DalpSdkError {
@@ -44,6 +60,8 @@ export declare function readHandle(payload: unknown): SettlementHandle | undefin
44
60
  *
45
61
  * Returns the settled payload the status route reports. Raises
46
62
  * {@link SettlementFailedError} on a terminal failure and
47
- * {@link SettlementTimeoutError} when the bound elapses first.
63
+ * {@link SettlementTimeoutError} when the bound elapses first. The bound
64
+ * restarts on every status read that reports an open funding ask, so it never
65
+ * elapses while the write is parked on a payment.
48
66
  */
49
67
  export declare function resolveSettlement(transport: Transport, payload: unknown, options: CallOptions | undefined, now?: () => number, sleep?: (ms: number) => Promise<void>): Promise<unknown>;
@@ -2,7 +2,8 @@ import {
2
2
  UI_SETTLEMENT_TIMEOUT_MS,
3
3
  canonicalize,
4
4
  queryKeyFor
5
- } from "./chunk-mrfkqrht.js";
5
+ } from "./chunk-gpezyfx3.js";
6
+ import"./chunk-fjnq61hj.js";
6
7
  import"./chunk-h12fatty.js";
7
8
  import"./chunk-y0d2c7kp.js";
8
9
  export {
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Whether a transaction status row says the write is parked on an operator's
3
+ * gas funding payment.
4
+ *
5
+ * The funding gate holds the queue state of a write it pauses, so `status`
6
+ * does not move while the operator is being asked for money. The open ask,
7
+ * published as `activeRequirement` on the status route and its stream, is the
8
+ * only field that says the write is waiting on a payment rather than on the
9
+ * chain. The wire declares it absent or null when there is no ask.
10
+ */
11
+ export declare function readsAsFundingPaused(status: unknown): boolean;
12
+ /**
13
+ * Longest gap between two status reads of a parked write.
14
+ *
15
+ * A write waiting on a payment moves at the funding gate's own cadence, which
16
+ * grows to minutes, so reading it faster than this learns nothing and costs
17
+ * the status route a request for every parked write on every second of a pause
18
+ * that can last a day.
19
+ */
20
+ export declare const PAUSED_POLL_INTERVAL_MAX_MS = 30000;
@@ -15,6 +15,8 @@ export interface WaitForTransactionStatus {
15
15
  readonly errorMessage: string | null;
16
16
  readonly contractError?: WaitForTransactionContractError | null;
17
17
  readonly result?: WaitForTransactionResult;
18
+ /** The open funding ask a write parked by the funding gate is waiting on. */
19
+ readonly activeRequirement?: EvmTransactionStatusOutput["activeRequirement"];
18
20
  }
19
21
  /** Kind-scoped terminal result from the generated transaction status contract. */
20
22
  export type WaitForTransactionResult = NonNullable<EvmTransactionStatusOutput["result"]>;
@@ -26,11 +28,20 @@ export interface WaitForTransactionOptions {
26
28
  readonly pollIntervalMs?: number;
27
29
  readonly signal?: AbortSignal;
28
30
  readonly onStatus?: (status: WaitForTransactionStatus) => void;
31
+ /**
32
+ * Whether the wait outlasts a funding pause. True, the default, restarts the
33
+ * timeout on every status that reports an open funding ask, so the wait ends
34
+ * only when the ask is paid or the platform fails the request. False ends
35
+ * the wait on the first such status with reason `funding-paused`, for a
36
+ * caller that shows the write as pending and lets the payment land on its
37
+ * own time.
38
+ */
39
+ readonly holdWhilePaused?: boolean;
29
40
  readonly now?: () => number;
30
41
  readonly sleep?: (milliseconds: number, signal?: AbortSignal) => Promise<void>;
31
42
  readonly readStatus?: (transactionId: string, signal?: AbortSignal) => Promise<WaitForTransactionStatus>;
32
43
  }
33
- export type TransactionWaitFailureReason = "terminal-failure" | "timeout" | "aborted";
44
+ export type TransactionWaitFailureReason = "terminal-failure" | "timeout" | "aborted" | "funding-paused";
34
45
  export declare class DalpTransactionWaitError extends Error {
35
46
  readonly code = "sdk.transaction.WAIT_FAILED";
36
47
  readonly category: "operational";
@@ -44,5 +55,13 @@ export declare class DalpTransactionWaitError extends Error {
44
55
  get retryable(): boolean;
45
56
  }
46
57
  export declare const isDalpTransactionWaitError: (error: unknown) => error is DalpTransactionWaitError;
47
- /** Poll transaction status until a terminal verdict, timeout, or abort. */
58
+ /**
59
+ * Poll transaction status until a terminal verdict, timeout, or abort.
60
+ *
61
+ * The timeout measures the platform's progress. A status that reports an
62
+ * open funding ask restarts it, so a write parked on an operator payment is
63
+ * never reported as a timeout and a resumed write gets its whole budget back.
64
+ * `holdWhilePaused: false` ends the wait on that status instead. The
65
+ * `elapsedMs` a timeout carries is the whole wait, pauses included.
66
+ */
48
67
  export declare function waitForTransaction(client: DalpClient, transactionId: string, options?: WaitForTransactionOptions): Promise<WaitForTransactionSuccess>;
@@ -1,3 +1,8 @@
1
+ import {
2
+ PAUSED_POLL_INTERVAL_MAX_MS,
3
+ readsAsFundingPaused
4
+ } from "./chunk-fjnq61hj.js";
5
+
1
6
  // src/wait-for-transaction.ts
2
7
  var failedStates = new Set(["FAILED", "DEAD_LETTER", "CANCELLED"]);
3
8
  var isWaitForTransactionSuccess = (status) => status.status === "COMPLETED";
@@ -15,6 +20,8 @@ class DalpTransactionWaitError extends Error {
15
20
  message = `Transaction ${transactionId} reached terminal state ${lastStatus?.status ?? "UNKNOWN"}`;
16
21
  } else if (reason === "timeout") {
17
22
  message = `Transaction ${transactionId} did not reach a terminal state within ${elapsedMs ?? 0}ms`;
23
+ } else if (reason === "funding-paused") {
24
+ message = `Transaction ${transactionId} is paused waiting for a gas funding payment`;
18
25
  } else {
19
26
  message = `Transaction status observation was aborted for transaction ${transactionId}`;
20
27
  }
@@ -32,7 +39,7 @@ class DalpTransactionWaitError extends Error {
32
39
  return this.lastStatus?.subStatus ?? null;
33
40
  }
34
41
  get retryable() {
35
- return this.reason === "timeout";
42
+ return this.reason === "timeout" || this.reason === "funding-paused";
36
43
  }
37
44
  }
38
45
  var isDalpTransactionWaitError = (error) => error instanceof DalpTransactionWaitError;
@@ -62,16 +69,18 @@ async function waitForTransaction(client, transactionId, options = {}) {
62
69
  const now = options.now ?? Date.now;
63
70
  const sleep = options.sleep ?? defaultSleep;
64
71
  const readStatus = options.readStatus ?? routeStatusReader(client);
65
- const startedAt = now();
72
+ const holdWhilePaused = options.holdWhilePaused ?? true;
73
+ const waitStartedAt = now();
74
+ let budgetStartedAt = waitStartedAt;
75
+ let pollDelayMs = pollIntervalMs;
66
76
  let lastStatus;
67
77
  const isAborted = () => options.signal?.aborted === true;
68
78
  while (true) {
69
79
  if (isAborted()) {
70
80
  throw new DalpTransactionWaitError(transactionId, "aborted", lastStatus);
71
81
  }
72
- const elapsed = now() - startedAt;
73
- if (elapsed >= timeoutMs) {
74
- throw new DalpTransactionWaitError(transactionId, "timeout", lastStatus, elapsed);
82
+ if (now() - budgetStartedAt >= timeoutMs) {
83
+ throw new DalpTransactionWaitError(transactionId, "timeout", lastStatus, now() - waitStartedAt);
75
84
  }
76
85
  try {
77
86
  lastStatus = await readStatus(transactionId, options.signal);
@@ -88,8 +97,17 @@ async function waitForTransaction(client, transactionId, options = {}) {
88
97
  if (isWaitForTransactionSuccess(lastStatus)) {
89
98
  return lastStatus;
90
99
  }
100
+ if (readsAsFundingPaused(lastStatus)) {
101
+ if (!holdWhilePaused) {
102
+ throw new DalpTransactionWaitError(transactionId, "funding-paused", lastStatus, now() - waitStartedAt);
103
+ }
104
+ budgetStartedAt = now();
105
+ pollDelayMs = Math.min(pollDelayMs * 2, Math.max(pollIntervalMs, PAUSED_POLL_INTERVAL_MAX_MS));
106
+ } else {
107
+ pollDelayMs = pollIntervalMs;
108
+ }
91
109
  try {
92
- await sleep(Math.min(pollIntervalMs, Math.max(0, timeoutMs - (now() - startedAt))), options.signal);
110
+ await sleep(Math.min(pollDelayMs, Math.max(0, timeoutMs - (now() - budgetStartedAt))), options.signal);
93
111
  } catch {
94
112
  throw new DalpTransactionWaitError(transactionId, "aborted", lastStatus);
95
113
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@settlemint/dalp-sdk",
3
- "version": "3.1.11-main.33723791073",
3
+ "version": "3.1.11-main.33724992663",
4
4
  "private": false,
5
5
  "description": "Fully typed SDK for the DALP tokenization platform API",
6
6
  "homepage": "https://settlemint.com",