mppx 0.17.1 → 0.17.4
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/CHANGELOG.md +65 -0
- package/dist/Errors.d.ts +94 -0
- package/dist/Errors.js +83 -0
- package/dist/Store.d.ts +413 -0
- package/dist/Store.js +837 -0
- package/dist/cli/cli.js +141 -136
- package/dist/cli/internal.js +28 -6
- package/dist/cli/plugins/index.js +16 -11
- package/dist/cli/sessions/Manager.js +12 -1
- package/dist/cli/utils.d.ts +2 -0
- package/dist/cli/utils.js +6 -0
- package/dist/cli/validate/challenge.d.ts +4 -0
- package/dist/cli/validate/challenge.js +9 -6
- package/dist/client/Mppx.d.ts +1 -1
- package/dist/client/Mppx.js +7 -3
- package/dist/client/internal/Fetch.d.ts +1 -1
- package/dist/client/internal/Fetch.js +9 -0
- package/dist/client/internal/MethodResponse.d.ts +8 -0
- package/dist/client/internal/MethodResponse.js +9 -0
- package/dist/client/internal/ProofRealm.d.ts +3 -3
- package/dist/client/internal/ProofRealm.js +4 -4
- package/dist/client/internal/protocols/Mcp.d.ts +4 -0
- package/dist/client/internal/protocols/Mcp.js +27 -14
- package/dist/cloudflare/ChannelStore.d.ts +97 -0
- package/dist/cloudflare/ChannelStore.js +304 -0
- package/dist/cloudflare/Channels.d.ts +92 -0
- package/dist/cloudflare/Channels.js +325 -0
- package/dist/cloudflare/index.d.ts +5 -0
- package/dist/cloudflare/index.js +5 -0
- package/dist/identity/Client.js +7 -1
- package/dist/internal/sse.d.ts +21 -0
- package/dist/internal/sse.js +82 -0
- package/dist/internal/version.d.ts +2 -2
- package/dist/internal/version.js +1 -1
- package/dist/mcp/client/McpClient.d.ts +2 -2
- package/dist/mcp/client/McpClient.js +5 -2
- package/dist/proxy/Proxy.d.ts +2 -0
- package/dist/proxy/Proxy.js +31 -6
- package/dist/proxy/internal/Replay.js +1 -1
- package/dist/server/Mppx.js +5 -4
- package/dist/server/Transport.js +1 -1
- package/dist/server/internal/html/config.d.ts +7 -1
- package/dist/server/internal/html/config.js +4 -0
- package/dist/stripe/internal/types.d.ts +82 -6
- package/dist/stripe/server/Charge.js +1 -2
- package/dist/stripe/server/Methods.d.ts +2 -0
- package/dist/stripe/server/Methods.js +2 -1
- package/dist/stripe/server/internal/html.gen.js +1 -1
- package/dist/stripe/server/internal/record-payment.d.ts +49 -0
- package/dist/stripe/server/internal/record-payment.js +75 -18
- package/dist/tempo/Methods.d.ts +8 -0
- package/dist/tempo/Methods.js +18 -2
- package/dist/tempo/client/Charge.d.ts +32 -1
- package/dist/tempo/client/Charge.js +201 -3
- package/dist/tempo/client/Methods.d.ts +16 -0
- package/dist/tempo/internal/fee-payer.d.ts +64 -14
- package/dist/tempo/internal/fee-payer.js +231 -20
- package/dist/tempo/internal/zone.d.ts +79 -0
- package/dist/tempo/internal/zone.js +133 -0
- package/dist/tempo/legacy/session/Chain.js +2 -0
- package/dist/tempo/server/Charge.d.ts +7 -3
- package/dist/tempo/server/Charge.js +100 -6
- package/dist/tempo/server/Methods.d.ts +40 -0
- package/dist/tempo/server/Subscription.js +1 -0
- package/dist/tempo/server/internal/html.gen.js +1 -1
- package/dist/tempo/server/internal/transport.d.ts +6 -0
- package/dist/tempo/server/internal/transport.js +21 -21
- package/dist/tempo/session/client/ChannelStore.d.ts +2 -0
- package/dist/tempo/session/client/CredentialState.js +2 -0
- package/dist/tempo/session/client/Session.d.ts +11 -1
- package/dist/tempo/session/client/Session.js +39 -6
- package/dist/tempo/session/client/SessionManager.d.ts +1 -1
- package/dist/tempo/session/client/SessionManager.js +8 -4
- package/dist/tempo/session/client/Transports.d.ts +2 -0
- package/dist/tempo/session/client/Transports.js +4 -1
- package/dist/tempo/session/precompile/Chain.js +1 -0
- package/dist/tempo/session/server/ChannelStore.d.ts +14 -0
- package/dist/tempo/session/server/ChannelStore.js +10 -3
- package/dist/tempo/session/server/CredentialVerification.js +1 -1
- package/dist/tempo/session/server/MeteredStream.d.ts +4 -0
- package/dist/tempo/session/server/MeteredStream.js +6 -1
- package/dist/tempo/session/server/Sse.d.ts +59 -0
- package/dist/tempo/session/server/Sse.js +175 -10
- package/dist/validation/core.js +2 -0
- package/dist/zod.d.ts +2 -1
- package/dist/zod.js +1 -1
- package/package.json +5 -3
- package/dist/stripe/server/internal/html/types.d.ts +0 -2
- package/dist/stripe/server/internal/html/types.js +0 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,70 @@
|
|
|
1
1
|
# mppx
|
|
2
2
|
|
|
3
|
+
## 0.17.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- fa22d95: Fixed `ChannelStore` replacing the immediate send that a close request written during a failed queue send scheduled with the 60-second retry, and resending failed settlements forever when `minUnsettledAmount` is `0n` and the deposit is under 10 raw units: the threshold is now at least 1.
|
|
8
|
+
- 3e44f83: Fixed `ChannelStore` giving up on a channel during the server's cooperative-close marker, which left a payer close request merged into it unsent, and spending watchdog attempts on alarms set for a close marker that a failed close then cleared. `ChannelStore` now rejects non-finite or negative `retryMs`, `staleAfterMs` and `watchdogMs` and a `maxAttempts` that is not a positive integer.
|
|
9
|
+
- d11a756: Added `mppx/cloudflare`: a `ChannelStore` Durable Object that stores Tempo session channels and sends them to a settlement queue by amount or staleness, with a watchdog; `channels()`, the store and reusable-channel lookup for `tempo.session()`; and `settle()`, the queue consumer that settles them on-chain.
|
|
10
|
+
- 48d97fa: Fixed `mppx/cloudflare` settlement and channel lookup: a payer close request stamped at or before the server's own cooperative-close marker is now sent to the settlement queue once that marker can no longer land, with an alarm at the marker's end; and a lookup add skips a channel that no longer resumes, while a full lookup entry drops closed channels before an open one.
|
|
11
|
+
- b964dc4: Fixed `mppx/cloudflare` settlement and channel lookup: the server's own cooperative-close marker (recorded in the new `pendingCloseAt` channel field) no longer queues an immediate settlement, and `settle()` waits while that close may still land; a new payer close request after an earlier one cleared is sent at once; and each lookup entry keeps up to 8 of the payer's open channels, so closing one leaves the others findable.
|
|
12
|
+
- 8e812d3: Fixed `mppx/cloudflare`'s `channels()` lookup returning a channel opened with another operator for a challenge without one, which mppx verifies against the zero operator, and losing a matching channel behind eight newer ones with other operators: lookup entries are now keyed by operator too (`mppx:session-lookup:v3`), so channels written before resume again after their next write. Fixed `ChannelStore` replacing the immediate send that a close request written during a queue send scheduled with a later watchdog alarm.
|
|
13
|
+
- 7255375: Fixed `mppx/cloudflare` so `channels()` skips a channel opened with another operator than the challenge's, `settle()` renews its settlement lease while a settlement runs, and `ChannelStore` resends a closing channel within 2 minutes so every attempt fits in the escrow's close grace period.
|
|
14
|
+
- 4adc283: Fixed follow-ups in `Store.durableObject` replay shards and `mppx/cloudflare`. Replay shards kept their claims in a table named `mppx_replay_claims`, so the shard alarm no longer clears a subclass's own `replay_claims` table. `ChannelStore` sent a channel to the settlement queue at once on a close request or a threshold's worth of new vouchers, instead of waiting for the watchdog after a failed job. `channels()` no longer let a delayed lookup write for a closed channel replace the entry of a channel the payer can still resume, and its lookup skipped entries whose channel had closed.
|
|
15
|
+
- a9b2cbc: Added `onWrite` and `alarm` hooks to `Store.DurableObjectStore`: a subclass sees every applied write with its previous and next values in one storage transaction with the write (so the hook's own writes commit with it, and a hook that throws rolls it back), and can schedule and handle alarms through the protected `storage`, `state` and `env`.
|
|
16
|
+
- 0968d3f: Renamed `Store.DurableObjectStore`'s store operations to `storeGet`, `storePut`, `storeDelete`, `storeSwap` and `storeClaim`, so Workers RPC reaches them on Workers whose Durable Object stubs keep the legacy `get`, `put` and `delete` methods, and `fetch` no longer calls a subclass's own methods of those names. `Store.DurableObjectStore.rpc()` now keeps a subclass's static members.
|
|
17
|
+
|
|
18
|
+
Fixed `DurableObjectStore.isReplayShard()` to match a replay shard's whole object name, so an ordinary key that starts with `mppx:replay:` is not taken for a shard, and the base `alarm()` clears claims only in an object that holds them.
|
|
19
|
+
|
|
20
|
+
- 5ebce56: Added `DurableObjectStore.isReplayShard()`, so a subclass skips its own work (in `alarm`, handlers or its constructor, by the object's name) in the replay shards of `Store.durableObject`'s `replayShards`, which are objects of the same class, and documented that values stored at a key don't block its sharded replay claims.
|
|
21
|
+
- 56e0c8c: Added `replayShards` and `replayShardVersion` options to `Store.durableObject`: replay claims spread over a fixed number of SQLite-backed shard objects, each claimed with one SQL statement and cleared by an alarm once expired, instead of one Durable Object per claimed key.
|
|
22
|
+
- c776057: Added `transport: 'rpc'` and `encoding: 'native'` options to `Store.durableObject`: the store calls the object's methods over Workers RPC (with a class from `Store.DurableObjectStore.rpc(DurableObject)`), and native encoding stores structured-clone values, so bigints stay intact and values a Durable Object wrote with `storage.put` read back.
|
|
23
|
+
- 2f96b5b: Improved the internal SSE parser's throughput on line-dense `text/event-stream` bodies by scanning with `indexOf` instead of a global RegExp.
|
|
24
|
+
- 94d1e36: Fixed `Store.DurableObjectStore`'s native compare-and-swap treating a length-tracking view of a resizable `ArrayBuffer` as equal to a fixed-length one.
|
|
25
|
+
- 5ba7bf5: Fixed `Store.durableObject` native compare-and-swap to compare object keys, map entries and set members in order, compare sparse arrays by their own elements instead of scanning to their length, and tell resizable `ArrayBuffer`s apart.
|
|
26
|
+
- fa22d95: Changed `Store.DurableObjectStore`'s native encoding to reject views of resizable `ArrayBuffer`s, as it rejects other values it cannot compare, instead of probing their length tracking with a copy of the whole buffer resized to its maximum on every compare-and-swap.
|
|
27
|
+
- 8e2f7fe: Fixed `tempo.charge` with `waitForConfirmation: false` to throw `Errors.BroadcastOutcomeUnknownError` with the transaction hash after an ambiguous broadcast failure, instead of the raw RPC error. `stripe.recordPayment` now returns the PaymentIntent's Stripe status as `paymentIntentStatus`.
|
|
28
|
+
- ca6cc56: Fixed `Store.durableObject` storing a key named like a replay shard (`mppx:replay:v<version>:<shard>`) in that shard's object, where `DurableObjectStore.isReplayShard()` then reported it as a shard. Such keys, and keys starting with `mppx:key:`, now live in an object named `mppx:key:<key>`, so values stored at them before are no longer found.
|
|
29
|
+
- d631e07: Fixed `Store.DurableObjectStore.rpc()` throwing when a subclass shadows a static member or method that an ancestor made non-configurable.
|
|
30
|
+
- ed12b58: Added `Errors.BroadcastOutcomeUnknownError`, which `tempo.charge` now throws with the transaction hash and `validBefore` when an ambiguous broadcast leaves no receipt, instead of rethrowing the RPC error (still its `cause`). Added `stripe.recordPayment` to record a settled payment as a Stripe PaymentIntent, idempotent per transaction hash.
|
|
31
|
+
- f54a1c9: Added `Errors.PaymentSimulationError`, which wraps a failed fee-sponsored preflight simulation with its `phase` (`sender` or `sponsored`), `sender`, `feePayer` and `paymentToken`, so callers can tell a payer's insufficient balance from a sponsor's. Fixed the sponsored simulation dropping a zero `maxPriorityFeePerGas`, which broke a hosted fee payer's signature.
|
|
32
|
+
- a89d5f5: Added Zone payments to the `tempo` charge method. A server lists the Zones it accepts with `zones: [3, 7]`, or accepts any Zone with `zones: true`. A client pays from a Zone balance with `zone`: it withdraws to the recipient with a challenge-bound memo, waits for the withdrawal to settle on Tempo, and sends a `zone` credential with the settlement transaction hash, which the server verifies.
|
|
33
|
+
|
|
34
|
+
If the wait fails, the client throws `Errors.ZoneSettlementPendingError` and resumes the same withdrawal when the challenge is retried.
|
|
35
|
+
|
|
36
|
+
- 3f60dcc: Fixed `mppx validate` and paid CLI retries rejecting every mppx server's retry Challenge as changed: the comparison now ignores the per-issuance `_mppx_nonce` and `_mppx_identity` in `opaque`. The malformed-Credential probe now sends the `-H` headers and puts the Credential in the header the server's Challenge names.
|
|
37
|
+
- 64d852c: Fixed `mppx validate` error-handling hints to name the Credential header the server's Challenge uses instead of always `Authorization`.
|
|
38
|
+
- 9ba2807: Fixed Zone ID validation to reject IDs that alias another Zone's portal address.
|
|
39
|
+
|
|
40
|
+
## 0.17.3
|
|
41
|
+
|
|
42
|
+
### Patch Changes
|
|
43
|
+
|
|
44
|
+
- f8852c3: Removed the `eventsource-parser` dependency. The MCP client protocol now reads the first event of a `text/event-stream` response with a small internal SSE parser.
|
|
45
|
+
|
|
46
|
+
## 0.17.2
|
|
47
|
+
|
|
48
|
+
### Patch Changes
|
|
49
|
+
|
|
50
|
+
- 247dc02: Rendered nested problem-details fields (such as `details`) as JSON in the CLI's Payment Rejected output instead of `[object Object]`.
|
|
51
|
+
- d87c8bb: Removed `@stripe/stripe-js` from `dependencies`. The Stripe HTML payment page bundles Stripe.js at build time, and the Stripe Elements option types in `stripe.charge`'s `html.elements` are now inlined, so the published types no longer import `@stripe/stripe-js`.
|
|
52
|
+
- a384733: Added `Store.durableObject()` and `Store.DurableObjectStore`, an atomic store backed by Cloudflare Durable Objects (one object per key, compare-and-swap with jittered retries), for running `tempo.session()` and replay protection on Cloudflare Workers.
|
|
53
|
+
- adaeef7: Fixed Tempo and Stripe server bundles always including their HTML payment page: the page now loads with a dynamic `import()` the first time it is rendered, and `html.content` also accepts an async loader.
|
|
54
|
+
- 2060c5f: Bound automatic session signatures and stored channel reuse to the authorized HTTP origin. Applied `trustedTempoProofRealms` to session challenges and forwarded manager pins. Added `session({ origin })` for direct credentials that will be reused over HTTP; originless stored channels must be explicitly migrated or closed rather than silently rebound. Use separate channel stores per HTTP origin because each payment scope retains a single channel.
|
|
55
|
+
|
|
56
|
+
Preserved request swap policies for automatic session top-ups and payment suppression through identity wrappers. Kept MCP adapter approval and payer selection authoritative when global payment fetch is installed. Limited proxy request bodies, including free routes, to 10 MiB by default with a configurable `maxRequestBodySize`.
|
|
57
|
+
|
|
58
|
+
Required explicit origin trust for remote snapshot recovery and rejected opaque origins. Preserved explicit CLI closing of legacy channels through validated origin migration. Returned payment challenges before buffering unpaid uploads and rejected oversized tee branches without waiting for sibling cancellation.
|
|
59
|
+
|
|
60
|
+
- 55a7b62: Credited prepaid SSE items that failed before delivery when their spend remained unsettled. Added an idempotent merchant reconciliation hook for declined or uncertain credits, preserving settled funds and delivered-item charges.
|
|
61
|
+
|
|
62
|
+
Automatic prepaid credits are opt-in with `sse: { autoCreditPrepaid: true, onRefundRequired }`; existing merchant refund handlers remain unchanged. Delivery obligations persist in channel state before a managed stream starts, with bounded records and idempotent credit retries. Refund jobs distinguish uncertain writes from definite failures and expose only finalized captured funds as externally refundable. HTTP close receipts accept spend reduced by credits while retaining authorization and scope validation.
|
|
63
|
+
|
|
64
|
+
- 7a18dac: Fixed sponsored preflight simulation billing the sender's fee token. Tempo nodes recover the fee payer of an `eth_call` only from `feePayerSignature` and ignore a bare `feePayer` address, so the final simulation charged the sender, and payments failed with "insufficient fee token balance" when the sponsor picked a fee token the sender did not hold. The simulation now carries the sponsor's signature: hosted sponsors return it from `eth_fillTransaction` (`fillHostedFeePayerTransaction` now returns `feePayerSignature`), and local fee-payer accounts sign a simulation-only copy with the new `signFeePayerSimulation`, only after the sender simulation passes. The sender simulation now runs at the transaction's exact gas limit with zero fee fields and the fields that set its intrinsic gas, so a transaction whose gas is too low is rejected before broadcast without needing a sender fee balance. The local simulation-only copy adds up to `sponsoredSimulationGasBuffer` (10,000) gas, because a sponsored `eth_call` charges more gas than the mined transaction uses, clamped to the fee payer policy's `maxGas` and `maxTotalFee` (`sponsoredSimulationGas`). When the sponsored simulation runs without the full buffer (hosted signatures, or clamped padding), a failure that is only out of gas no longer rejects the payment; fee balance errors and reverts still do.
|
|
65
|
+
- a4d7a8e: Added `Store.sql()`, an atomic store on SQL databases (single-statement compare-and-swap, no transactions needed, and replay claims in one statement), with `Store.postgres()` for `pg`, Neon, Vercel Postgres, Supabase and PGlite, `Store.sqlite()` for `node:sqlite`, `better-sqlite3` and `bun:sqlite`, and `Store.d1()` for Cloudflare D1.
|
|
66
|
+
- 8be5d55: Fixed esbuild bundles including all of `zod/mini` by importing it as a namespace in `mppx`'s zod helpers, so unused validators tree-shake.
|
|
67
|
+
|
|
3
68
|
## 0.17.1
|
|
4
69
|
|
|
5
70
|
### Patch Changes
|
package/dist/Errors.d.ts
CHANGED
|
@@ -196,6 +196,100 @@ export declare namespace PaymentOutcomeUnknownError {
|
|
|
196
196
|
transactionHash?: string | undefined;
|
|
197
197
|
};
|
|
198
198
|
}
|
|
199
|
+
/**
|
|
200
|
+
* A server broadcast a payment transaction, the broadcast failed in a way that does not say whether
|
|
201
|
+
* the node accepted it, and no receipt appeared before settlement stopped polling. The transaction
|
|
202
|
+
* may still be included until `validBefore`.
|
|
203
|
+
*
|
|
204
|
+
* Settle it by looking up the receipt for `transactionHash`: once `validBefore` has passed, the
|
|
205
|
+
* transaction can no longer be included, so one lookup after it is final. This is not a
|
|
206
|
+
* `PaymentError`: HTTP handlers still answer with a generic 500 `InternalPaymentError`, whose
|
|
207
|
+
* `cause` is this error.
|
|
208
|
+
*/
|
|
209
|
+
export declare class BroadcastOutcomeUnknownError extends Error {
|
|
210
|
+
readonly name = "BroadcastOutcomeUnknownError";
|
|
211
|
+
/** Hash of the broadcast transaction, as it will appear on chain if it is included. */
|
|
212
|
+
readonly transactionHash: `0x${string}`;
|
|
213
|
+
/** Unix time in seconds after which the transaction can no longer be included, when it expires. */
|
|
214
|
+
readonly validBefore: number | undefined;
|
|
215
|
+
constructor(options: BroadcastOutcomeUnknownError.Options);
|
|
216
|
+
}
|
|
217
|
+
export declare namespace BroadcastOutcomeUnknownError {
|
|
218
|
+
type Options = {
|
|
219
|
+
/** The broadcast error that left the outcome unknown. */
|
|
220
|
+
cause?: unknown;
|
|
221
|
+
/** Hash of the broadcast transaction. */
|
|
222
|
+
transactionHash: `0x${string}`;
|
|
223
|
+
/** Unix time in seconds after which the transaction can no longer be included. */
|
|
224
|
+
validBefore?: number | undefined;
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* A pre-broadcast simulation of a fee-sponsored payment failed, so the payment was not broadcast.
|
|
229
|
+
*
|
|
230
|
+
* `phase` says which simulation failed: `sender` runs the sender's calls before sponsorship, and
|
|
231
|
+
* `sponsored` runs the final envelope billed to `feePayer`. Callers use it, with `sender`,
|
|
232
|
+
* `feePayer` and `paymentToken`, to tell a payer's insufficient balance from a sponsor's without
|
|
233
|
+
* matching node messages. The node's error is the `cause`. This is not a `PaymentError`: HTTP
|
|
234
|
+
* handlers still answer with a generic 500 `InternalPaymentError`, whose `cause` is this error.
|
|
235
|
+
*/
|
|
236
|
+
export declare class PaymentSimulationError extends Error {
|
|
237
|
+
readonly name = "PaymentSimulationError";
|
|
238
|
+
/** Fee payer the sponsored simulation billed. Set only in the `sponsored` phase. */
|
|
239
|
+
readonly feePayer: `0x${string}` | undefined;
|
|
240
|
+
/** TIP-20 token of a single `transfer` or `transferWithMemo` call, when the transaction is one. */
|
|
241
|
+
readonly paymentToken: `0x${string}` | undefined;
|
|
242
|
+
/** Simulation that failed. */
|
|
243
|
+
readonly phase: PaymentSimulationError.Phase;
|
|
244
|
+
/** Sender of the simulated transaction. */
|
|
245
|
+
readonly sender: `0x${string}` | undefined;
|
|
246
|
+
constructor(options: PaymentSimulationError.Options);
|
|
247
|
+
}
|
|
248
|
+
export declare namespace PaymentSimulationError {
|
|
249
|
+
/** `sender`: the sender's calls before sponsorship. `sponsored`: the final sponsored envelope. */
|
|
250
|
+
type Phase = 'sender' | 'sponsored';
|
|
251
|
+
type Options = {
|
|
252
|
+
/** The simulation error. */
|
|
253
|
+
cause?: unknown;
|
|
254
|
+
/** Fee payer of the sponsored simulation. */
|
|
255
|
+
feePayer?: `0x${string}` | undefined;
|
|
256
|
+
/** TIP-20 token of a single transfer call. */
|
|
257
|
+
paymentToken?: `0x${string}` | undefined;
|
|
258
|
+
/** Simulation that failed. */
|
|
259
|
+
phase: Phase;
|
|
260
|
+
/** Sender of the simulated transaction. */
|
|
261
|
+
sender?: `0x${string}` | undefined;
|
|
262
|
+
};
|
|
263
|
+
}
|
|
264
|
+
/**
|
|
265
|
+
* A client withdrew from a Zone to pay a challenge, but the withdrawal did not settle on Tempo
|
|
266
|
+
* before the client stopped waiting. The withdrawal cannot be undone and may still settle.
|
|
267
|
+
*
|
|
268
|
+
* Retry the same challenge with the same `tempo.charge` client to resume waiting without
|
|
269
|
+
* withdrawing again, or find the settlement with `senderTag` on the Zone's portal.
|
|
270
|
+
*/
|
|
271
|
+
export declare class ZoneSettlementPendingError extends Error {
|
|
272
|
+
readonly name = "ZoneSettlementPendingError";
|
|
273
|
+
/** ID of the challenge the withdrawal pays. */
|
|
274
|
+
readonly challengeId: string;
|
|
275
|
+
/** Sender tag of the withdrawal, as the portal's `WithdrawalProcessed` event carries it. */
|
|
276
|
+
readonly senderTag: `0x${string}`;
|
|
277
|
+
/** ID of the Zone the withdrawal left. */
|
|
278
|
+
readonly zoneId: number;
|
|
279
|
+
constructor(options: ZoneSettlementPendingError.Options);
|
|
280
|
+
}
|
|
281
|
+
export declare namespace ZoneSettlementPendingError {
|
|
282
|
+
type Options = {
|
|
283
|
+
/** The error that ended the wait. */
|
|
284
|
+
cause?: unknown;
|
|
285
|
+
/** ID of the challenge the withdrawal pays. */
|
|
286
|
+
challengeId: string;
|
|
287
|
+
/** Sender tag of the withdrawal. */
|
|
288
|
+
senderTag: `0x${string}`;
|
|
289
|
+
/** ID of the Zone the withdrawal left. */
|
|
290
|
+
zoneId: number;
|
|
291
|
+
};
|
|
292
|
+
}
|
|
199
293
|
/**
|
|
200
294
|
* No credential was provided but payment is required.
|
|
201
295
|
*/
|
package/dist/Errors.js
CHANGED
|
@@ -160,6 +160,89 @@ export class PaymentOutcomeUnknownError extends PaymentError {
|
|
|
160
160
|
this.transactionHash = transactionHash;
|
|
161
161
|
}
|
|
162
162
|
}
|
|
163
|
+
/**
|
|
164
|
+
* A server broadcast a payment transaction, the broadcast failed in a way that does not say whether
|
|
165
|
+
* the node accepted it, and no receipt appeared before settlement stopped polling. The transaction
|
|
166
|
+
* may still be included until `validBefore`.
|
|
167
|
+
*
|
|
168
|
+
* Settle it by looking up the receipt for `transactionHash`: once `validBefore` has passed, the
|
|
169
|
+
* transaction can no longer be included, so one lookup after it is final. This is not a
|
|
170
|
+
* `PaymentError`: HTTP handlers still answer with a generic 500 `InternalPaymentError`, whose
|
|
171
|
+
* `cause` is this error.
|
|
172
|
+
*/
|
|
173
|
+
export class BroadcastOutcomeUnknownError extends Error {
|
|
174
|
+
name = 'BroadcastOutcomeUnknownError';
|
|
175
|
+
/** Hash of the broadcast transaction, as it will appear on chain if it is included. */
|
|
176
|
+
transactionHash;
|
|
177
|
+
/** Unix time in seconds after which the transaction can no longer be included, when it expires. */
|
|
178
|
+
validBefore;
|
|
179
|
+
constructor(options) {
|
|
180
|
+
const { cause, transactionHash, validBefore } = options;
|
|
181
|
+
super(`Broadcast outcome is unknown for transaction ${transactionHash}. Look up its receipt before retrying.`);
|
|
182
|
+
this.transactionHash = transactionHash;
|
|
183
|
+
this.validBefore = validBefore;
|
|
184
|
+
// Defined manually (non-enumerable, like native `cause`) so consumers on pre-ES2022 libs still typecheck.
|
|
185
|
+
if (cause !== undefined)
|
|
186
|
+
Object.defineProperty(this, 'cause', { configurable: true, value: cause, writable: true });
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* A pre-broadcast simulation of a fee-sponsored payment failed, so the payment was not broadcast.
|
|
191
|
+
*
|
|
192
|
+
* `phase` says which simulation failed: `sender` runs the sender's calls before sponsorship, and
|
|
193
|
+
* `sponsored` runs the final envelope billed to `feePayer`. Callers use it, with `sender`,
|
|
194
|
+
* `feePayer` and `paymentToken`, to tell a payer's insufficient balance from a sponsor's without
|
|
195
|
+
* matching node messages. The node's error is the `cause`. This is not a `PaymentError`: HTTP
|
|
196
|
+
* handlers still answer with a generic 500 `InternalPaymentError`, whose `cause` is this error.
|
|
197
|
+
*/
|
|
198
|
+
export class PaymentSimulationError extends Error {
|
|
199
|
+
name = 'PaymentSimulationError';
|
|
200
|
+
/** Fee payer the sponsored simulation billed. Set only in the `sponsored` phase. */
|
|
201
|
+
feePayer;
|
|
202
|
+
/** TIP-20 token of a single `transfer` or `transferWithMemo` call, when the transaction is one. */
|
|
203
|
+
paymentToken;
|
|
204
|
+
/** Simulation that failed. */
|
|
205
|
+
phase;
|
|
206
|
+
/** Sender of the simulated transaction. */
|
|
207
|
+
sender;
|
|
208
|
+
constructor(options) {
|
|
209
|
+
const { cause, feePayer, paymentToken, phase, sender } = options;
|
|
210
|
+
super('Payment simulation failed');
|
|
211
|
+
this.feePayer = feePayer;
|
|
212
|
+
this.paymentToken = paymentToken;
|
|
213
|
+
this.phase = phase;
|
|
214
|
+
this.sender = sender;
|
|
215
|
+
// Defined manually (non-enumerable, like native `cause`) so consumers on pre-ES2022 libs still typecheck.
|
|
216
|
+
if (cause !== undefined)
|
|
217
|
+
Object.defineProperty(this, 'cause', { configurable: true, value: cause, writable: true });
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* A client withdrew from a Zone to pay a challenge, but the withdrawal did not settle on Tempo
|
|
222
|
+
* before the client stopped waiting. The withdrawal cannot be undone and may still settle.
|
|
223
|
+
*
|
|
224
|
+
* Retry the same challenge with the same `tempo.charge` client to resume waiting without
|
|
225
|
+
* withdrawing again, or find the settlement with `senderTag` on the Zone's portal.
|
|
226
|
+
*/
|
|
227
|
+
export class ZoneSettlementPendingError extends Error {
|
|
228
|
+
name = 'ZoneSettlementPendingError';
|
|
229
|
+
/** ID of the challenge the withdrawal pays. */
|
|
230
|
+
challengeId;
|
|
231
|
+
/** Sender tag of the withdrawal, as the portal's `WithdrawalProcessed` event carries it. */
|
|
232
|
+
senderTag;
|
|
233
|
+
/** ID of the Zone the withdrawal left. */
|
|
234
|
+
zoneId;
|
|
235
|
+
constructor(options) {
|
|
236
|
+
const { cause, challengeId, senderTag, zoneId } = options;
|
|
237
|
+
super(`Zone ${zoneId} withdrawal ${senderTag} for challenge "${challengeId}" has not settled on Tempo yet. Retry the challenge to resume waiting instead of paying again.`);
|
|
238
|
+
this.challengeId = challengeId;
|
|
239
|
+
this.senderTag = senderTag;
|
|
240
|
+
this.zoneId = zoneId;
|
|
241
|
+
// Defined manually (non-enumerable, like native `cause`) so consumers on pre-ES2022 libs still typecheck.
|
|
242
|
+
if (cause !== undefined)
|
|
243
|
+
Object.defineProperty(this, 'cause', { configurable: true, value: cause, writable: true });
|
|
244
|
+
}
|
|
245
|
+
}
|
|
163
246
|
/**
|
|
164
247
|
* No credential was provided but payment is required.
|
|
165
248
|
*/
|