@piprail/sdk 1.13.0 → 1.14.0

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.
Files changed (30) hide show
  1. package/CHAINS.md +3 -2
  2. package/CHANGELOG.md +49 -0
  3. package/ERRORS.md +2 -1
  4. package/README.md +19 -2
  5. package/STANDARDS.md +2 -0
  6. package/dist/{algorand-WGVF4KTU.js → algorand-7EUZYL2Z.js} +1 -1
  7. package/dist/{algorand-MXUSKX46.cjs → algorand-OIHGJN5S.cjs} +17 -17
  8. package/dist/{aptos-LPBLSEIQ.js → aptos-CDEYDDM5.js} +1 -1
  9. package/dist/{aptos-YT7SXWPF.cjs → aptos-WDWZOU25.cjs} +16 -16
  10. package/dist/{chunk-MDLZJGLY.cjs → chunk-FTKVCP6K.cjs} +24 -13
  11. package/dist/{chunk-SVMGHASK.js → chunk-H3A4KWLJ.js} +12 -1
  12. package/dist/index.cjs +399 -145
  13. package/dist/index.d.cts +209 -31
  14. package/dist/index.d.ts +209 -31
  15. package/dist/index.js +308 -54
  16. package/dist/{near-K6BDBABG.js → near-DT6LRIKB.js} +1 -1
  17. package/dist/{near-7ZDNISUX.cjs → near-FUH3VAXT.cjs} +19 -19
  18. package/dist/{solana-S3UFI3FE.js → solana-3TRYD4QB.js} +1 -1
  19. package/dist/{solana-PU7N2M64.cjs → solana-QUVXPKBZ.cjs} +14 -14
  20. package/dist/{stellar-VDQOFQEO.cjs → stellar-APZEBFAD.cjs} +21 -21
  21. package/dist/{stellar-Q5PO23SC.js → stellar-IK3UML6O.js} +1 -1
  22. package/dist/{sui-FKSMLKRF.cjs → sui-L7BQNJWO.cjs} +17 -17
  23. package/dist/{sui-WOXRKJXS.js → sui-VSE63WQM.js} +1 -1
  24. package/dist/{ton-VK6KRJHP.cjs → ton-5DLKKOFE.cjs} +14 -14
  25. package/dist/{ton-WPTXGLVK.js → ton-QHGQLJX2.js} +1 -1
  26. package/dist/{tron-6GXBXTR4.js → tron-2N2GA62O.js} +1 -1
  27. package/dist/{tron-WLOF5OUV.cjs → tron-HHIT6WKY.cjs} +24 -24
  28. package/dist/{xrpl-HEAPEXAM.js → xrpl-2GZMDYW5.js} +1 -1
  29. package/dist/{xrpl-CMNI25BV.cjs → xrpl-USEG4AHX.cjs} +21 -21
  30. package/package.json +1 -1
package/CHAINS.md CHANGED
@@ -13,7 +13,7 @@ read those sections before you ship them.
13
13
 
14
14
  | Chain(s) | Pay in native coin? | Built-in stablecoins | Receiver needs setup? | Wallet input |
15
15
  |---|:--:|---|---|---|
16
- | **EVM** (Ethereum, Base, Arbitrum, Optimism, Polygon, BNB, Avalanche, Mantle, Sonic, Linea, Scroll, Celo, zkSync, Unichain, World Chain, Sei, Injective, HyperEVM, Monad, Kaia, + any EVM chain) | ✅ ETH/BNB/POL/… | USDC (all **except Kaia**) · USDT (all **except Base, World Chain, Sei, HyperEVM, Monad**) | No | `{ privateKey }` |
16
+ | **EVM** (Ethereum, Base, Arbitrum, Optimism, Polygon, BNB, Avalanche, Mantle, Sonic, Linea, Scroll, Celo, zkSync, Unichain, World Chain, Sei, Injective, HyperEVM, Monad, Kaia, + any EVM chain) | ✅ ETH/BNB/POL/… | USDC (all **except Kaia**) · USDT (all **except Base, World Chain, Sei, HyperEVM, Monad**) · **EURC** (Ethereum, Base, Avalanche) | No | `{ privateKey }` |
17
17
  | **Solana** | ✅ SOL | USDC · USDT | No (payer creates the recipient's token account) | `{ secretKey }` |
18
18
  | **Sui** | ✅ SUI | USDC (no USDT) | No | `{ privateKey }` (`suiprivkey1…`) |
19
19
  | **Aptos** | ✅ APT | USDC · USDT | No (primary FA store auto-creates) | `{ privateKey }` (`ed25519-priv-0x…`) |
@@ -44,8 +44,9 @@ read those sections before you ship them.
44
44
  ## Chains with no caveats
45
45
 
46
46
  ### EVM — Ethereum, Base, Arbitrum, Optimism, Polygon, BNB, Avalanche, …
47
- - **Pay in:** native coin (`'native'`), `'USDC'`, `'USDT'`, or a custom `{ address, decimals }`.
47
+ - **Pay in:** native coin (`'native'`), `'USDC'`, `'USDT'`, `'EURC'` (where issued), or a custom `{ address, decimals }`.
48
48
  - **USDT gap:** built in on every preset **except Base, World Chain, Sei, HyperEVM, and Monad** (USDC only there). **Kaia** is the inverse — **USD₮ only** (no Circle-native USDC on Kaia).
49
+ - **EURC:** Circle's euro stablecoin is built in on **Ethereum, Base, and Avalanche** (EIP-3009, 6-dp, addresses verified on-chain). Its EIP-712 domain name differs per deployment (`"Euro Coin"` on Ethereum/Avalanche, `"EURC"` on Base) — the SDK reads it on-chain, so `exact` payments are correct everywhere. Like USDC, it's `exact`-payable.
49
50
  - **Decimals:** on **BNB Chain**, Binance-Peg USDC/USDT are **18 decimals**, not 6 (the SDK handles it; don't hardcode 6).
50
51
  - **Stablecoin provenance — issuer-native vs bridged (every shipped address verified on-chain 2026-06-08, incl. bridge markers).** Every address is the correct, canonical, 1:1-redeemable dollar token on its chain; what varies is *who issues it*. You request it as `'USDC'` / `'USDT'` either way — provenance matters only if you specifically require issuer-native settlement.
51
52
  - **USDC** is **Circle-native** on every preset **except** **BNB** (Binance-Peg, 18-dp), **Mantle** (OP canonical-bridge), and **Scroll** (Bridged-USDC-Standard) — the last two are backed 1:1 by Circle USDC on Ethereum but are **not** Circle-issued on that chain (absent from Circle's native-USDC list).
package/CHANGELOG.md CHANGED
@@ -4,6 +4,53 @@ All notable changes to `@piprail/sdk` are documented here. The format
4
4
  follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/) and the
5
5
  versions follow [Semantic Versioning](https://semver.org/).
6
6
 
7
+ ## [1.14.0] — 2026-06-10
8
+
9
+ ### Added — pay the standard `exact` rail (opt-in, EVM + EIP-3009)
10
+ - **`PipRailClient` can now PAY standard x402 `exact` rails**, not just PipRail's native
11
+ `onchain-proof` — so an agent can transact with ANY standard v2 x402 server (the dominant
12
+ `exact`-on-Base-via-CDP web), while PipRail's own gates stay backendless. **Opt-in** via a new
13
+ `schemes` option (default `['onchain-proof']` — the zero-config path is byte-identical):
14
+ `new PipRailClient({ chain: 'base', wallet, schemes: ['onchain-proof', 'exact'] })`, with a per-call
15
+ override `fetch(url, { schemes: ['exact'] })`. EVM + EIP-3009 only (USDC/EURC); silently ignored on
16
+ non-EVM chains, for USDT/native, or for a token the SDK can't price (those keep `onchain-proof`).
17
+ - The buyer signs an EIP-3009 authorization with **its own** wallet and the server / merchant-chosen
18
+ facilitator broadcasts it — the buyer pays ~0 gas and PipRail hosts/settles nothing. `quote()`,
19
+ `planPayment()`, `estimateCost()`, `canAfford()`, `autoRoute`, and `planAcross()` are now truthful
20
+ across both schemes (an exact rail is priced gasless: `cost.fee === '0'`, never an `INSUFFICIENT_GAS`
21
+ blocker). The EIP-712 domain is **re-derived on-chain** (`name()`/`version()`), never trusted from
22
+ the server's `extra`. The same `policy` + `onBeforePay` gate it BEFORE any signature.
23
+ **Verify against your target facilitator before production.**
24
+ - **EURC is now a built-in EVM preset token** on Ethereum, Base, and Avalanche (on-chain-verified;
25
+ EIP-3009, 6 decimals) — so the `exact` buyer recognises it and the "USDC/EURC" coverage is real, not
26
+ aspirational. (Its EIP-712 domain name differs per deployment — `"Euro Coin"` on Ethereum/Avalanche,
27
+ `"EURC"` on Base — which the buyer re-derives on-chain; the symbol is display-only.)
28
+ - `X402ExactAcceptEntry.extra.name`/`version` are now OPTIONAL (the exact-EVM scheme only requires
29
+ `assetTransferMethod`) — matching the spec; the buyer ignores them (it re-derives on-chain), the gate
30
+ still populates them from its own on-chain read. The `payment-settled` event now also carries the
31
+ conformant `settle?: SettleOutcome` (a third-party facilitator's lean SettleResponse, when there's no
32
+ rich receipt).
33
+ - New exports: `buildExactSignatureHeader`, `parseSettleResponse` (+ the `SettleOutcome` type), the
34
+ `PaymentScheme` type, and the `UnsupportedSchemeError` (`code: 'UNSUPPORTED_SCHEME'`). New driver SPI
35
+ method `payExact?` (optional, EVM-only). `@piprail/mcp` adds the `PIPRAIL_SCHEMES` env (unset ⇒ the
36
+ SDK default, so the MCP's zero-config posture is unchanged).
37
+
38
+ ### Changed (additive — minor, but type-affecting)
39
+ - `PayOption.accept` and the `payment-required` event's `accept` are now `X402AnyAccept` (was
40
+ `X402AcceptEntry`). A consumer that reads `accept.extra.nonce`/`minConfirmations` without a `scheme`
41
+ guard should narrow on `accept.scheme === 'onchain-proof'` first.
42
+ - The buyer emits **v2 only** for `exact` (`PAYMENT-SIGNATURE` + the `accepted`-envelope). v1-only
43
+ servers (which never parse as a v2 challenge here) are out of scope for this milestone.
44
+
45
+ ## [1.13.1] — 2026-06-10
46
+
47
+ ### Fixed
48
+ - **`register()` visibility is now accurate for a verified domain.** 402 Index returns a structured
49
+ `service.status` — a register from a domain you've verified comes back `'active'`, so the outcome now
50
+ reports `visibility:'live'` instead of the conservative `'pending-review'` default (`decorateOutcome`
51
+ honours a visibility the adapter already set). The `detail` already surfaced 402 Index's own message;
52
+ now `visibility` and `detail` agree.
53
+
7
54
  ## [1.13.0] — 2026-06-10
8
55
 
9
56
  ### Added — gate `discovery` option (one flag → x402scan-listable)
@@ -615,6 +662,8 @@ straight into your wallet. The API is small and self-contained.
615
662
  to your wallet; PipRail never holds funds.
616
663
  - `viem ^2.21` is a peer dependency. Node 20+ or a modern browser.
617
664
 
665
+ [1.14.0]: https://www.npmjs.com/package/@piprail/sdk
666
+ [1.13.1]: https://www.npmjs.com/package/@piprail/sdk
618
667
  [1.13.0]: https://www.npmjs.com/package/@piprail/sdk
619
668
  [1.12.0]: https://www.npmjs.com/package/@piprail/sdk
620
669
  [1.11.0]: https://www.npmjs.com/package/@piprail/sdk
package/ERRORS.md CHANGED
@@ -56,7 +56,8 @@ Base class [`PipRailError`](src/errors.ts) (abstract; `.name` = the subclass nam
56
56
  | `MAX_RETRIES_EXCEEDED` | `MaxRetriesExceededError` | server kept returning 402 after broadcast — **message embeds the last server `error — detail`, and carries `.ref`** | client |
57
57
  | `PAYMENT_DECLINED` | `PaymentDeclinedError` | the client refused to pay BEFORE any send — over the spend `policy` (amount/total/chain/token/host), or an `onBeforePay` hook returned false / threw | client |
58
58
  | `INVALID_ENVELOPE` | `InvalidEnvelopeError` | a 402 had no parseable x402 challenge | client |
59
- | `NO_COMPATIBLE_ACCEPT` | `NoCompatibleAcceptError` | the challenge offered no `accepts[]` entry for the client's network | client |
59
+ | `NO_COMPATIBLE_ACCEPT` | `NoCompatibleAcceptError` | the challenge offered no `accepts[]` entry the client can pay on its network + enabled `schemes` (message names the enabled schemes) | client |
60
+ | `UNSUPPORTED_SCHEME` | `UnsupportedSchemeError` | asked to pay a scheme the bound family/asset/signer can't settle, with no fallback: `exact` on a non-EVM family, a non-EIP-3009 token (USDT/native/plain ERC-20), or a contract / EIP-1271 / EIP-7702 signer | client / EVM `exact` (`payExact`) |
60
61
  | `NON_REPLAYABLE_BODY` | `NonReplayableBodyError` | `init.body` isn't replayable (e.g. a one-shot stream) | client |
61
62
  | `MISSING_DRIVER` | `MissingDriverError` | a family's **optional peer deps aren't installed** (the lazy `import()` failed) — message names the exact `npm install` and sets `{ cause }` | registry loaders |
62
63
  | `UNSUPPORTED_NETWORK` | `UnsupportedNetworkError` | no driver for the family, or the driver's `resolve()` returned `null` (unrecognised `chain`) | registry |
package/README.md CHANGED
@@ -59,6 +59,22 @@ exact: { settle: { facilitator: 'https://x402.org/facilitator' } }
59
59
 
60
60
  EVM + EIP-3009 tokens only (USDC, EURC — not USDT, not native; those stay `onchain-proof`). Omit `exact` and the gate is byte-identical to today. Proven end-to-end: a real `@x402/fetch` reference client settles against a PipRail gate on Base mainnet.
61
61
 
62
+ ### Pay *any* x402 server — the `exact` rail, buyer side
63
+
64
+ The mirror image: let your **`PipRailClient` pay** standard x402 servers (the dominant `exact`-on-Base-via-CDP web), not just PipRail's own gates. Opt in with `schemes` — default `['onchain-proof']`, so the zero-config client is byte-identical:
65
+
66
+ ```ts
67
+ const client = new PipRailClient({
68
+ chain: 'base',
69
+ wallet: { privateKey: process.env.AGENT_KEY },
70
+ schemes: ['onchain-proof', 'exact'], // also pay standard exact rails
71
+ })
72
+ await client.fetch('https://api.somevendor.com/paid') // pays whichever rail it offers
73
+ // or per call: client.fetch(url, { schemes: ['exact'] })
74
+ ```
75
+
76
+ On an `exact` rail the client signs an EIP-3009 authorization with **its own** wallet and the server / merchant-chosen facilitator broadcasts it — so the **buyer pays ~0 gas** and PipRail hosts/settles nothing. The EIP-712 token domain is **re-derived on-chain** (never trusted from the challenge), the same `policy` + `onBeforePay` gate it **before any signature**, and `quote()`/`planPayment()`/`estimateCost()` are truthful across both schemes (an exact rail prices gasless). EVM + EIP-3009 only (USDC/EURC); silently ignored on non-EVM chains, for USDT/native, or for a token the SDK can't price — those stay `onchain-proof`. **Verify against your target facilitator before production.**
77
+
62
78
  ## Built for agents — spend safely
63
79
 
64
80
  A funded key loose on the internet needs guardrails. Opt in to a `policy` and the client refuses anything outside it **before any on-chain send** — plus learn a price without paying it, approve each payment, and read back exactly what you spent. All opt-in, all local, no backend; omit it and the client behaves exactly as before.
@@ -253,7 +269,8 @@ For an LLM/MCP these are two more tools — **`piprail_discover`** (find) and **
253
269
 
254
270
  > **Two honest caveats.** The open indexes assume the mainstream `exact` scheme, so to be *usefully*
255
271
  > listed also offer a standard `exact` USDC rail on Base/Solana (`discover()` results are
256
- > cross-scheme; `fetch()` pays only PipRail `onchain-proof` rails directly). And **x402scan indexes
272
+ > cross-scheme; `fetch()` pays PipRail `onchain-proof` rails by default, and standard `exact` rails too
273
+ > once you opt in with `schemes: ['onchain-proof', 'exact']` — EVM/EIP-3009). And **x402scan indexes
257
274
  > Base/Solana only** — 402 Index has no such limit, so it's the default register target. There is no
258
275
  > single ratified discovery standard yet; OpenAPI-first is an emerging multi-vendor convention.
259
276
 
@@ -758,7 +775,7 @@ Methods: `fetch` · `get` · `post` (return the gated `Response` after settlemen
758
775
 
759
776
  **Bring your own chain family:** the SDK is built on a tiny `PaymentDriver` contract — `resolve(chain)` returns a bound network with `resolveToken` / `describeAsset` / `assertValidPayTo` / `bindWallet` / `send` / `confirm` / `estimateCost` / `balanceOf` / `recipientReady` / `verify`. Register your own with `registerDriver(...)`; the protocol layer never changes (see [Architecture](#architecture-under-the-hood)).
760
777
 
761
- **Universal x402 (experimental):** building blocks to pay servers on the mainstream x402 `exact` scheme (EIP-3009 + facilitator) `parseExactRequirements`, `buildExactAuthorization`, `encodeXPaymentHeader`. EVM-only; validate against your target facilitator before production.
778
+ **Universal x402 (`exact` scheme):** the supported way to pay any standard x402 server is `new PipRailClient({ …, schemes: ['onchain-proof', 'exact'] })` (see [Pay *any* x402 server](#pay-any-x402-server--the-exact-rail-buyer-side)) — the client signs the EIP-3009 authorization on-chain-derived-domain and the server/facilitator settles. The low-level codecs `parseExactRequirements` / `buildExactAuthorization` (`@deprecated` — trusts the server-supplied domain, local-key only) / `encodeXPaymentHeader` remain for hand-rolled or v1 clients. EVM + EIP-3009 only; validate against your target facilitator before production.
762
779
 
763
780
  ## Requirements
764
781
 
package/STANDARDS.md CHANGED
@@ -109,6 +109,8 @@ npm test # full Vitest suite
109
109
  npm run build # tsup build succeeds
110
110
  # lazy-chunk invariant — the EVM bundle pulls in no non-EVM chain lib:
111
111
  grep -E "from ?['\"]@(solana|ton|stellar)" dist/index.js # → expect NO matches
112
+ # viem-free protocol layer — the chain-agnostic core never imports a chain SDK:
113
+ grep -lE "from ['\"]viem" src/client.ts src/x402.ts src/policy.ts src/ledger.ts src/server.ts src/agent.ts # → expect NO matches
112
114
  ```
113
115
 
114
116
  `prepublishOnly` runs build + test + both typechecks. Never ship with any of these red.
@@ -7,7 +7,7 @@ import {
7
7
  nativeCost,
8
8
  rejectForeignToken,
9
9
  toInsufficientFundsError
10
- } from "./chunk-SVMGHASK.js";
10
+ } from "./chunk-H3A4KWLJ.js";
11
11
 
12
12
  // src/drivers/algorand/index.ts
13
13
  import algosdk2 from "algosdk";
@@ -7,7 +7,7 @@
7
7
 
8
8
 
9
9
 
10
- var _chunkMDLZJGLYcjs = require('./chunk-MDLZJGLY.cjs');
10
+ var _chunkFTKVCP6Kcjs = require('./chunk-FTKVCP6K.cjs');
11
11
 
12
12
  // src/drivers/algorand/index.ts
13
13
  var _algosdk = require('algosdk'); var _algosdk2 = _interopRequireDefault(_algosdk);
@@ -55,13 +55,13 @@ async function payAlgorand(params) {
55
55
  } catch (err) {
56
56
  const mapped = mapAlgorandError(err, accept.payTo);
57
57
  if (mapped) throw mapped;
58
- throw _nullishCoalesce(_chunkMDLZJGLYcjs.toInsufficientFundsError.call(void 0, err), () => ( err));
58
+ throw _nullishCoalesce(_chunkFTKVCP6Kcjs.toInsufficientFundsError.call(void 0, err), () => ( err));
59
59
  }
60
60
  }
61
61
  function mapAlgorandError(err, payTo) {
62
62
  const m = err instanceof Error ? err.message : String(err);
63
63
  if (/must optin/i.test(m) || /missing from/i.test(m) && m.includes(payTo)) {
64
- return new (0, _chunkMDLZJGLYcjs.RecipientNotReadyError)(
64
+ return new (0, _chunkFTKVCP6Kcjs.RecipientNotReadyError)(
65
65
  `Algorand recipient ${payTo} hasn't opted into this asset \u2014 it must opt in (a 0-amount asset transfer to itself) before it can receive. (Algorand: ${firstLine(m)})`,
66
66
  { cause: err }
67
67
  );
@@ -69,7 +69,7 @@ function mapAlgorandError(err, payTo) {
69
69
  if (/overspend|below min|min(imum)? balance|tried to spend|balance \d+ below|asset \d+ missing from|insufficient|underflow/i.test(
70
70
  m
71
71
  )) {
72
- return new (0, _chunkMDLZJGLYcjs.InsufficientFundsError)(
72
+ return new (0, _chunkFTKVCP6Kcjs.InsufficientFundsError)(
73
73
  `Algorand payment failed: the sender can't cover it \u2014 token balance, ALGO for fees, the 0.1-ALGO minimum balance, or a missing asset opt-in on the sender. (Algorand: ${firstLine(m)})`,
74
74
  { cause: err }
75
75
  );
@@ -157,22 +157,22 @@ function rpcFailed(nonce) {
157
157
 
158
158
  function assertAlgorandWallet(wallet, network) {
159
159
  if (typeof wallet !== "object" || wallet === null) {
160
- throw new (0, _chunkMDLZJGLYcjs.WrongFamilyError)(
160
+ throw new (0, _chunkFTKVCP6Kcjs.WrongFamilyError)(
161
161
  `chain ${network} is Algorand; wallet must be { mnemonic } (25 words) or { account }.`
162
162
  );
163
163
  }
164
164
  if ("privateKey" in wallet || "walletClient" in wallet) {
165
- throw new (0, _chunkMDLZJGLYcjs.WrongFamilyError)(
165
+ throw new (0, _chunkFTKVCP6Kcjs.WrongFamilyError)(
166
166
  `chain ${network} is Algorand; an EVM/Aptos wallet can't be used \u2014 pass { mnemonic } (25 words) or { account }.`
167
167
  );
168
168
  }
169
169
  if ("secretKey" in wallet || "signer" in wallet || "secret" in wallet || "keypair" in wallet || "keyPair" in wallet || "seed" in wallet || "accountId" in wallet) {
170
- throw new (0, _chunkMDLZJGLYcjs.WrongFamilyError)(
170
+ throw new (0, _chunkFTKVCP6Kcjs.WrongFamilyError)(
171
171
  `chain ${network} is Algorand; that looks like another family's wallet \u2014 pass { mnemonic } (25 words) or { account }.`
172
172
  );
173
173
  }
174
174
  if (!("mnemonic" in wallet) && !("account" in wallet)) {
175
- throw new (0, _chunkMDLZJGLYcjs.WrongFamilyError)(
175
+ throw new (0, _chunkFTKVCP6Kcjs.WrongFamilyError)(
176
176
  `chain ${network} is Algorand; wallet must be { mnemonic } (25 words) or { account }.`
177
177
  );
178
178
  }
@@ -187,13 +187,13 @@ function resolveAlgorandWallet(config) {
187
187
  const { addr, sk } = _algosdk2.default.mnemonicToSecretKey(config.mnemonic);
188
188
  return { addr: addr.toString(), sk };
189
189
  } catch (cause) {
190
- throw new (0, _chunkMDLZJGLYcjs.WrongFamilyError)(
190
+ throw new (0, _chunkFTKVCP6Kcjs.WrongFamilyError)(
191
191
  "Algorand wallet { mnemonic } is not a valid 25-word Algorand mnemonic.",
192
192
  { cause }
193
193
  );
194
194
  }
195
195
  }
196
- throw new (0, _chunkMDLZJGLYcjs.WrongFamilyError)("Algorand wallet needs { mnemonic } (25 words) or { account }.");
196
+ throw new (0, _chunkFTKVCP6Kcjs.WrongFamilyError)("Algorand wallet needs { mnemonic } (25 words) or { account }.");
197
197
  }
198
198
 
199
199
  // src/drivers/algorand/index.ts
@@ -248,16 +248,16 @@ function makeAlgorandNetwork(preset, algodUrl) {
248
248
  const info = preset.tokens[token.toUpperCase()];
249
249
  if (!info) {
250
250
  const known = Object.keys(preset.tokens).join(", ") || "(none built in)";
251
- throw new (0, _chunkMDLZJGLYcjs.UnknownTokenError)(
251
+ throw new (0, _chunkFTKVCP6Kcjs.UnknownTokenError)(
252
252
  `token "${token}" isn't built in for Algorand (known: ${known}). Pass { assetId, decimals } for a custom ASA, or use 'native'.`
253
253
  );
254
254
  }
255
255
  return { asset: algorandAssetId(info.assetId), decimals: info.decimals, symbol: info.symbol };
256
256
  }
257
- _chunkMDLZJGLYcjs.rejectForeignToken.call(void 0, token, "algorand", network);
257
+ _chunkFTKVCP6Kcjs.rejectForeignToken.call(void 0, token, "algorand", network);
258
258
  const t = token;
259
259
  if (typeof t.assetId !== "number" || typeof t.decimals !== "number") {
260
- throw new (0, _chunkMDLZJGLYcjs.WrongFamilyError)(
260
+ throw new (0, _chunkFTKVCP6Kcjs.WrongFamilyError)(
261
261
  `chain ${network} is Algorand; a custom token must be { assetId, decimals }.`
262
262
  );
263
263
  }
@@ -278,12 +278,12 @@ function makeAlgorandNetwork(preset, algodUrl) {
278
278
  },
279
279
  assertValidPayTo(payTo) {
280
280
  if (payTo.startsWith("0x")) {
281
- throw new (0, _chunkMDLZJGLYcjs.WrongFamilyError)(
281
+ throw new (0, _chunkFTKVCP6Kcjs.WrongFamilyError)(
282
282
  `chain ${network} is Algorand, but payTo "${payTo}" looks like an EVM address.`
283
283
  );
284
284
  }
285
285
  if (!_algosdk2.default.isValidAddress(payTo)) {
286
- throw new (0, _chunkMDLZJGLYcjs.WrongFamilyError)(
286
+ throw new (0, _chunkFTKVCP6Kcjs.WrongFamilyError)(
287
287
  `chain ${network} is Algorand, but payTo "${payTo}" is not a valid Algorand address.`
288
288
  );
289
289
  }
@@ -300,13 +300,13 @@ function makeAlgorandNetwork(preset, algodUrl) {
300
300
  const info = await _algosdk2.default.waitForConfirmation(algod, ref, 10);
301
301
  return { height: String(_nullishCoalesce(info.confirmedRound, () => ( 0))) };
302
302
  } catch (err) {
303
- throw new (0, _chunkMDLZJGLYcjs.ConfirmationTimeoutError)(`Algorand tx ${ref} did not confirm in time.`, {
303
+ throw new (0, _chunkFTKVCP6Kcjs.ConfirmationTimeoutError)(`Algorand tx ${ref} did not confirm in time.`, {
304
304
  cause: err
305
305
  });
306
306
  }
307
307
  },
308
308
  async estimateCost() {
309
- return _chunkMDLZJGLYcjs.nativeCost.call(void 0, {
309
+ return _chunkFTKVCP6Kcjs.nativeCost.call(void 0, {
310
310
  symbol: ALGO_SYMBOL,
311
311
  decimals: ALGO_DECIMALS,
312
312
  fee: 1000n,
@@ -6,7 +6,7 @@ import {
6
6
  nativeCost,
7
7
  rejectForeignToken,
8
8
  toInsufficientFundsError
9
- } from "./chunk-SVMGHASK.js";
9
+ } from "./chunk-H3A4KWLJ.js";
10
10
 
11
11
  // src/drivers/aptos/index.ts
12
12
  import { Aptos, AptosConfig, Network, AccountAddress } from "@aptos-labs/ts-sdk";
@@ -6,7 +6,7 @@
6
6
 
7
7
 
8
8
 
9
- var _chunkMDLZJGLYcjs = require('./chunk-MDLZJGLY.cjs');
9
+ var _chunkFTKVCP6Kcjs = require('./chunk-FTKVCP6K.cjs');
10
10
 
11
11
  // src/drivers/aptos/index.ts
12
12
  var _tssdk = require('@aptos-labs/ts-sdk');
@@ -55,14 +55,14 @@ async function payAptos(params) {
55
55
  const res = await client.signSubmit({ signer, transaction });
56
56
  return res.hash;
57
57
  } catch (err) {
58
- if (err instanceof _chunkMDLZJGLYcjs.InsufficientFundsError) throw err;
58
+ if (err instanceof _chunkFTKVCP6Kcjs.InsufficientFundsError) throw err;
59
59
  if (isAptosAffordability(err)) {
60
- throw new (0, _chunkMDLZJGLYcjs.InsufficientFundsError)(
60
+ throw new (0, _chunkFTKVCP6Kcjs.InsufficientFundsError)(
61
61
  err instanceof Error ? err.message : "Insufficient APT/token balance for the payment.",
62
62
  { cause: err }
63
63
  );
64
64
  }
65
- throw _nullishCoalesce(_chunkMDLZJGLYcjs.toInsufficientFundsError.call(void 0, err), () => ( err));
65
+ throw _nullishCoalesce(_chunkFTKVCP6Kcjs.toInsufficientFundsError.call(void 0, err), () => ( err));
66
66
  }
67
67
  }
68
68
  function isAptosAffordability(err) {
@@ -146,22 +146,22 @@ function txNotFound(hash) {
146
146
 
147
147
  function assertAptosWallet(wallet, network) {
148
148
  if (typeof wallet !== "object" || wallet === null) {
149
- throw new (0, _chunkMDLZJGLYcjs.WrongFamilyError)(
149
+ throw new (0, _chunkFTKVCP6Kcjs.WrongFamilyError)(
150
150
  `chain ${network} is Aptos; wallet must be { privateKey } (ed25519-priv-0x\u2026) or { account }.`
151
151
  );
152
152
  }
153
153
  if ("walletClient" in wallet) {
154
- throw new (0, _chunkMDLZJGLYcjs.WrongFamilyError)(
154
+ throw new (0, _chunkFTKVCP6Kcjs.WrongFamilyError)(
155
155
  `chain ${network} is Aptos; a viem { walletClient } can't be used \u2014 pass { privateKey } (ed25519-priv-0x\u2026) or { account }.`
156
156
  );
157
157
  }
158
158
  if ("secretKey" in wallet || "signer" in wallet || "mnemonic" in wallet || "keypair" in wallet || "keyPair" in wallet || "secret" in wallet || "seed" in wallet || "accountId" in wallet) {
159
- throw new (0, _chunkMDLZJGLYcjs.WrongFamilyError)(
159
+ throw new (0, _chunkFTKVCP6Kcjs.WrongFamilyError)(
160
160
  `chain ${network} is Aptos; that looks like another family's wallet \u2014 pass { privateKey } (ed25519-priv-0x\u2026) or { account }.`
161
161
  );
162
162
  }
163
163
  if (!("privateKey" in wallet) && !("account" in wallet)) {
164
- throw new (0, _chunkMDLZJGLYcjs.WrongFamilyError)(
164
+ throw new (0, _chunkFTKVCP6Kcjs.WrongFamilyError)(
165
165
  `chain ${network} is Aptos; wallet must be { privateKey } (ed25519-priv-0x\u2026) or { account }.`
166
166
  );
167
167
  }
@@ -173,13 +173,13 @@ function resolveAptosAccount(config) {
173
173
  try {
174
174
  return _tssdk.Account.fromPrivateKey({ privateKey: new (0, _tssdk.Ed25519PrivateKey)(config.privateKey) });
175
175
  } catch (cause) {
176
- throw new (0, _chunkMDLZJGLYcjs.WrongFamilyError)(
176
+ throw new (0, _chunkFTKVCP6Kcjs.WrongFamilyError)(
177
177
  "Aptos wallet { privateKey } is not a valid ed25519 secret (ed25519-priv-0x\u2026 or 0x\u2026 hex).",
178
178
  { cause }
179
179
  );
180
180
  }
181
181
  }
182
- throw new (0, _chunkMDLZJGLYcjs.WrongFamilyError)("Aptos wallet needs { privateKey } (ed25519-priv-0x\u2026) or { account }.");
182
+ throw new (0, _chunkFTKVCP6Kcjs.WrongFamilyError)("Aptos wallet needs { privateKey } (ed25519-priv-0x\u2026) or { account }.");
183
183
  }
184
184
 
185
185
  // src/drivers/aptos/index.ts
@@ -251,16 +251,16 @@ function makeAptosNetwork(preset, rpcUrl) {
251
251
  const info = preset.tokens[token.toUpperCase()];
252
252
  if (!info) {
253
253
  const known = Object.keys(preset.tokens).join(", ") || "(none built in)";
254
- throw new (0, _chunkMDLZJGLYcjs.UnknownTokenError)(
254
+ throw new (0, _chunkFTKVCP6Kcjs.UnknownTokenError)(
255
255
  `token "${token}" isn't built in for Aptos (known: ${known}). Pass { metadata, decimals } for a custom Fungible Asset, or use 'native'.`
256
256
  );
257
257
  }
258
258
  return { asset: info.metadata, decimals: info.decimals, symbol: info.symbol };
259
259
  }
260
- _chunkMDLZJGLYcjs.rejectForeignToken.call(void 0, token, "aptos", network);
260
+ _chunkFTKVCP6Kcjs.rejectForeignToken.call(void 0, token, "aptos", network);
261
261
  const t = token;
262
262
  if (!t.metadata || typeof t.decimals !== "number") {
263
- throw new (0, _chunkMDLZJGLYcjs.WrongFamilyError)(
263
+ throw new (0, _chunkFTKVCP6Kcjs.WrongFamilyError)(
264
264
  `chain ${network} is Aptos; a custom token must be { metadata, decimals }.`
265
265
  );
266
266
  }
@@ -287,7 +287,7 @@ function makeAptosNetwork(preset, rpcUrl) {
287
287
  valid = false;
288
288
  }
289
289
  if (!valid || evmLike) {
290
- throw new (0, _chunkMDLZJGLYcjs.WrongFamilyError)(
290
+ throw new (0, _chunkFTKVCP6Kcjs.WrongFamilyError)(
291
291
  `chain ${network} is Aptos, but payTo "${payTo}" is not a valid Aptos address (0x + 32 bytes).`
292
292
  );
293
293
  }
@@ -309,11 +309,11 @@ function makeAptosNetwork(preset, rpcUrl) {
309
309
  const tx = await aptos.waitForTransaction({ transactionHash: ref });
310
310
  return { height: String(_nullishCoalesce(tx.version, () => ( "0"))) };
311
311
  } catch (err) {
312
- throw new (0, _chunkMDLZJGLYcjs.ConfirmationTimeoutError)(`Aptos tx ${ref} did not finalize in time.`, { cause: err });
312
+ throw new (0, _chunkFTKVCP6Kcjs.ConfirmationTimeoutError)(`Aptos tx ${ref} did not finalize in time.`, { cause: err });
313
313
  }
314
314
  },
315
315
  async estimateCost() {
316
- return _chunkMDLZJGLYcjs.nativeCost.call(void 0, {
316
+ return _chunkFTKVCP6Kcjs.nativeCost.call(void 0, {
317
317
  symbol: APT_SYMBOL,
318
318
  decimals: APT_DECIMALS,
319
319
  fee: 100000n,
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class; var _class2; var _class3; var _class4; var _class5; var _class6; var _class7; var _class8; var _class9; var _class10; var _class11; var _class12; var _class13; var _class14; var _class15;// src/errors.ts
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class; var _class2; var _class3; var _class4; var _class5; var _class6; var _class7; var _class8; var _class9; var _class10; var _class11; var _class12; var _class13; var _class14; var _class15; var _class16;// src/errors.ts
2
2
  var PipRailError = class extends Error {
3
3
  constructor(message, options) {
4
4
  super(message, options);
@@ -37,7 +37,14 @@ var PaymentTimeoutError = (_class4 = class extends PipRailError {
37
37
  }, _class4);
38
38
  var MaxRetriesExceededError = (_class5 = class extends PipRailError {
39
39
  __init5() {this.code = "MAX_RETRIES_EXCEEDED"}
40
- /** The already-broadcast proof ref — recover with it, don't re-pay. */
40
+ /**
41
+ * The proof ref — recover with it, don't re-pay. Its meaning depends on the
42
+ * scheme: for `onchain-proof` it's the already-broadcast transaction ref
43
+ * (re-verify or re-submit it). For a standard `exact` rail it's the EIP-3009
44
+ * authorization NONCE (a `0x…` 32-byte value, NOT a tx hash) — re-PRESENT the
45
+ * same signed authorization, never re-sign a fresh nonce; check the token's
46
+ * `authorizationState(from, nonce)` before assuming it didn't settle.
47
+ */
41
48
 
42
49
  constructor(message, options) {
43
50
  super(message, options);_class5.prototype.__init5.call(this);;
@@ -59,21 +66,24 @@ var InvalidEnvelopeError = (_class9 = class extends PipRailError {constructor(..
59
66
  var NoCompatibleAcceptError = (_class10 = class extends PipRailError {constructor(...args8) { super(...args8); _class10.prototype.__init10.call(this); }
60
67
  __init10() {this.code = "NO_COMPATIBLE_ACCEPT"}
61
68
  }, _class10);
62
- var NonReplayableBodyError = (_class11 = class extends PipRailError {constructor(...args9) { super(...args9); _class11.prototype.__init11.call(this); }
63
- __init11() {this.code = "NON_REPLAYABLE_BODY"}
69
+ var UnsupportedSchemeError = (_class11 = class extends PipRailError {constructor(...args9) { super(...args9); _class11.prototype.__init11.call(this); }
70
+ __init11() {this.code = "UNSUPPORTED_SCHEME"}
64
71
  }, _class11);
65
- var WrongFamilyError = (_class12 = class extends PipRailError {constructor(...args10) { super(...args10); _class12.prototype.__init12.call(this); }
66
- __init12() {this.code = "WRONG_FAMILY"}
72
+ var NonReplayableBodyError = (_class12 = class extends PipRailError {constructor(...args10) { super(...args10); _class12.prototype.__init12.call(this); }
73
+ __init12() {this.code = "NON_REPLAYABLE_BODY"}
67
74
  }, _class12);
68
- var UnknownTokenError = (_class13 = class extends PipRailError {constructor(...args11) { super(...args11); _class13.prototype.__init13.call(this); }
69
- __init13() {this.code = "UNKNOWN_TOKEN"}
75
+ var WrongFamilyError = (_class13 = class extends PipRailError {constructor(...args11) { super(...args11); _class13.prototype.__init13.call(this); }
76
+ __init13() {this.code = "WRONG_FAMILY"}
70
77
  }, _class13);
71
- var MissingDriverError = (_class14 = class extends PipRailError {constructor(...args12) { super(...args12); _class14.prototype.__init14.call(this); }
72
- __init14() {this.code = "MISSING_DRIVER"}
78
+ var UnknownTokenError = (_class14 = class extends PipRailError {constructor(...args12) { super(...args12); _class14.prototype.__init14.call(this); }
79
+ __init14() {this.code = "UNKNOWN_TOKEN"}
73
80
  }, _class14);
74
- var UnsupportedNetworkError = (_class15 = class extends PipRailError {constructor(...args13) { super(...args13); _class15.prototype.__init15.call(this); }
75
- __init15() {this.code = "UNSUPPORTED_NETWORK"}
81
+ var MissingDriverError = (_class15 = class extends PipRailError {constructor(...args13) { super(...args13); _class15.prototype.__init15.call(this); }
82
+ __init15() {this.code = "MISSING_DRIVER"}
76
83
  }, _class15);
84
+ var UnsupportedNetworkError = (_class16 = class extends PipRailError {constructor(...args14) { super(...args14); _class16.prototype.__init16.call(this); }
85
+ __init16() {this.code = "UNSUPPORTED_NETWORK"}
86
+ }, _class16);
77
87
 
78
88
  // src/drivers/shared.ts
79
89
  var FAMILY_LABEL = {
@@ -178,4 +188,5 @@ function nativeCost(opts) {
178
188
 
179
189
 
180
190
 
181
- exports.PipRailError = PipRailError; exports.InsufficientFundsError = InsufficientFundsError; exports.RecipientNotReadyError = RecipientNotReadyError; exports.toInsufficientFundsError = toInsufficientFundsError; exports.WrongChainError = WrongChainError; exports.PaymentTimeoutError = PaymentTimeoutError; exports.MaxRetriesExceededError = MaxRetriesExceededError; exports.PaymentDeclinedError = PaymentDeclinedError; exports.ConfirmationTimeoutError = ConfirmationTimeoutError; exports.SettlementError = SettlementError; exports.InvalidEnvelopeError = InvalidEnvelopeError; exports.NoCompatibleAcceptError = NoCompatibleAcceptError; exports.NonReplayableBodyError = NonReplayableBodyError; exports.WrongFamilyError = WrongFamilyError; exports.UnknownTokenError = UnknownTokenError; exports.MissingDriverError = MissingDriverError; exports.UnsupportedNetworkError = UnsupportedNetworkError; exports.rejectForeignToken = rejectForeignToken; exports.parseUnits = parseUnits; exports.floorUnits = floorUnits; exports.formatUnits = formatUnits; exports.nativeCost = nativeCost;
191
+
192
+ exports.PipRailError = PipRailError; exports.InsufficientFundsError = InsufficientFundsError; exports.RecipientNotReadyError = RecipientNotReadyError; exports.toInsufficientFundsError = toInsufficientFundsError; exports.WrongChainError = WrongChainError; exports.PaymentTimeoutError = PaymentTimeoutError; exports.MaxRetriesExceededError = MaxRetriesExceededError; exports.PaymentDeclinedError = PaymentDeclinedError; exports.ConfirmationTimeoutError = ConfirmationTimeoutError; exports.SettlementError = SettlementError; exports.InvalidEnvelopeError = InvalidEnvelopeError; exports.NoCompatibleAcceptError = NoCompatibleAcceptError; exports.UnsupportedSchemeError = UnsupportedSchemeError; exports.NonReplayableBodyError = NonReplayableBodyError; exports.WrongFamilyError = WrongFamilyError; exports.UnknownTokenError = UnknownTokenError; exports.MissingDriverError = MissingDriverError; exports.UnsupportedNetworkError = UnsupportedNetworkError; exports.rejectForeignToken = rejectForeignToken; exports.parseUnits = parseUnits; exports.floorUnits = floorUnits; exports.formatUnits = formatUnits; exports.nativeCost = nativeCost;
@@ -37,7 +37,14 @@ var PaymentTimeoutError = class extends PipRailError {
37
37
  };
38
38
  var MaxRetriesExceededError = class extends PipRailError {
39
39
  code = "MAX_RETRIES_EXCEEDED";
40
- /** The already-broadcast proof ref — recover with it, don't re-pay. */
40
+ /**
41
+ * The proof ref — recover with it, don't re-pay. Its meaning depends on the
42
+ * scheme: for `onchain-proof` it's the already-broadcast transaction ref
43
+ * (re-verify or re-submit it). For a standard `exact` rail it's the EIP-3009
44
+ * authorization NONCE (a `0x…` 32-byte value, NOT a tx hash) — re-PRESENT the
45
+ * same signed authorization, never re-sign a fresh nonce; check the token's
46
+ * `authorizationState(from, nonce)` before assuming it didn't settle.
47
+ */
41
48
  ref;
42
49
  constructor(message, options) {
43
50
  super(message, options);
@@ -59,6 +66,9 @@ var InvalidEnvelopeError = class extends PipRailError {
59
66
  var NoCompatibleAcceptError = class extends PipRailError {
60
67
  code = "NO_COMPATIBLE_ACCEPT";
61
68
  };
69
+ var UnsupportedSchemeError = class extends PipRailError {
70
+ code = "UNSUPPORTED_SCHEME";
71
+ };
62
72
  var NonReplayableBodyError = class extends PipRailError {
63
73
  code = "NON_REPLAYABLE_BODY";
64
74
  };
@@ -168,6 +178,7 @@ export {
168
178
  SettlementError,
169
179
  InvalidEnvelopeError,
170
180
  NoCompatibleAcceptError,
181
+ UnsupportedSchemeError,
171
182
  NonReplayableBodyError,
172
183
  WrongFamilyError,
173
184
  UnknownTokenError,