@piprail/sdk 2.8.0 → 2.10.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.
- package/CHANGELOG.md +124 -0
- package/README.md +7 -4
- package/dist/{algorand-WJL6VRXW.js → algorand-AA3WXKW4.js} +1 -1
- package/dist/{algorand-EKD34T4Q.cjs → algorand-FCEECDG6.cjs} +32 -32
- package/dist/{aptos-CVHLVMAF.cjs → aptos-GHJPO6JJ.cjs} +31 -31
- package/dist/{aptos-WMPFEASY.js → aptos-LY67Q6QF.js} +1 -1
- package/dist/chunk-3SBTJKAG.js +92 -0
- package/dist/chunk-CQQI5IJX.cjs +92 -0
- package/dist/{chunk-VPENSVOI.cjs → chunk-MWBT7MCE.cjs} +7 -3
- package/dist/chunk-O4UQOZ4Z.cjs +14 -0
- package/dist/{chunk-W3HOMXOF.js → chunk-SC2ZYDHD.js} +6 -2
- package/dist/chunk-SK3CB7UA.js +14 -0
- package/dist/index.cjs +2247 -425
- package/dist/index.d.cts +3094 -2583
- package/dist/index.d.ts +3094 -2583
- package/dist/index.js +1937 -115
- package/dist/ledger-OQos-tmj.d.cts +925 -0
- package/dist/ledger-OQos-tmj.d.ts +925 -0
- package/dist/{near-NYFMX2KA.cjs → near-6KAQVVG2.cjs} +26 -26
- package/dist/{near-QV4IOZNX.js → near-FZBUICCS.js} +1 -1
- package/dist/node.cjs +38 -0
- package/dist/node.d.cts +16 -0
- package/dist/node.d.ts +16 -0
- package/dist/node.js +38 -0
- package/dist/receipt-NNEID77X.js +14 -0
- package/dist/receipt-QCDPMWNF.cjs +14 -0
- package/dist/{solana-Z34OWXMO.js → solana-ELUWO6N5.js} +1 -1
- package/dist/{solana-L342QCSV.cjs → solana-MYF4HBO4.cjs} +32 -32
- package/dist/{stellar-PWC4LETJ.js → stellar-ASP2THL2.js} +2 -2
- package/dist/{stellar-YEXRVR3W.cjs → stellar-CRWBSX4E.cjs} +21 -21
- package/dist/{sui-VEOGHBYE.js → sui-FZIKZNVI.js} +14 -4
- package/dist/{sui-EFRSCDWN.cjs → sui-Y4RLKKE2.cjs} +29 -19
- package/dist/{ton-N7KSPSAR.js → ton-7GKCTC5H.js} +1 -1
- package/dist/{ton-LZKJWYHV.cjs → ton-AOR3EURW.cjs} +16 -16
- package/dist/{tron-WKDUQVZR.js → tron-BMCWN5SS.js} +8 -2
- package/dist/{tron-DQU4WTGQ.cjs → tron-OMXB6EW2.cjs} +31 -25
- package/dist/{xrpl-6B4IYRWI.js → xrpl-DD7TJL5L.js} +1 -1
- package/dist/{xrpl-K3U3SBF4.cjs → xrpl-Y6SQNYLC.cjs} +20 -20
- package/package.json +11 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,130 @@ 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
|
+
## [2.10.0] — 2026-06-20 — x402 parity: verifiable receipts · the `upto` metered rail · A2A transport
|
|
8
|
+
|
|
9
|
+
Four ratified-x402 capabilities, all **additive and opt-in** — omit the new options and the 402, the
|
|
10
|
+
200, and the pay path are byte-identical to 2.9.0.
|
|
11
|
+
|
|
12
|
+
- **feat(receipts): verifiable receipts — chain-grounded (no key) + optional EIP-712 attestation.**
|
|
13
|
+
`receipts: true` on a gate emits a self-contained `PipRailReceipt` on every settled payment, in a
|
|
14
|
+
byte-compatible `extensions['offer-receipt'].info` block. **Anyone** re-verifies it against the chain
|
|
15
|
+
with only an RPC: `PipRailClient.verifyReceipt(receipt)` re-reads the settlement tx and re-derives
|
|
16
|
+
`payTo`/`asset`/`payer`, **ignoring the receipt's claims** (never throws; `amount` is a verified lower
|
|
17
|
+
bound; `payer` genuinely re-derived). `client.lastReceipt()` captures it after a paid `fetch`. The new
|
|
18
|
+
additive wire field is `X402Receipt.nonce?` (required to re-verify the five memo-bound families:
|
|
19
|
+
Stellar/XRPL/NEAR/Algorand/TON). **Tier 2 (EVM-only):** `receipts: { attest: { wallet } }` also signs
|
|
20
|
+
the official x402 offer-receipt EIP-712 `RECEIPT_TYPES` with the merchant's existing `payTo` wallet —
|
|
21
|
+
attesting the one thing the chain can't (that the resource was *served*); verify with
|
|
22
|
+
`PipRailClient.verifyAttestation`. `includeTxHash` defaults **true** (PipRail-default verifiability — a
|
|
23
|
+
deliberate, documented divergence from the reference privacy-default; flip to `false` for the §5.3
|
|
24
|
+
empty-string privacy path). New exports: `buildReceiptExtension`, `parseReceiptExtension`,
|
|
25
|
+
`PipRailReceipt`, `SignedReceipt`, `ReceiptInput`, `ReceiptOption`, `ReceiptVerification`.
|
|
26
|
+
- **feat(upto): the ratified `upto` (metered / variable-amount) rail — EVM-Permit2, self-settle.** The
|
|
27
|
+
buyer signs a Permit2 authorization for a **maximum**; the merchant serves, meters, then self-settles
|
|
28
|
+
the **actual** (`≤ max`) from its own relayer through the on-chain `x402UptoPermit2Proxy` — backendless,
|
|
29
|
+
no fee. Opt in with `upto: { relayer, settleAmount }` and meter inside `settleAmount` on a direct
|
|
30
|
+
`gate.verify()` call (`requirePayment` throws for `upto` — it settles before the handler serves). A
|
|
31
|
+
zero charge settles nothing on-chain. New `X402UptoAcceptEntry` / `Permit2UptoAuthorization` types +
|
|
32
|
+
`parseUptoPaymentHeader` / `buildUptoSignatureHeader` codecs.
|
|
33
|
+
- **feat(transport): A2A — `gate.verifyObject()` + the A2A seller handler.** `gate.verifyObject(payload)`
|
|
34
|
+
verifies a raw-JSON payment object (not just a base64 HTTP header), and `createA2APaymentHandler(gate)`
|
|
35
|
+
maps a gate onto Google's A2A JSON-RPC Task/Message metadata — **sharing one replay set with HTTP**.
|
|
36
|
+
Backendless, zero `@a2a` dependency. The parser cores `parseSignatureObject`/`parseExactObject` are now
|
|
37
|
+
exported. *(The A2A buyer, AP2 carriage, and the live-Google-interop emit-version finalization trail.)*
|
|
38
|
+
- **feat(agent/mcp): an 8th tool — `piprail_verify_receipt`** (read-only, key-less) re-verifies a receipt
|
|
39
|
+
against the chain; `piprail_pay_request` now surfaces the `verifiableReceipt`.
|
|
40
|
+
- **fix:** a batch of correctness hardening from an adversarial multi-agent audit — require the replay
|
|
41
|
+
store's `isUsed`/`markUsed` as a pair (a lone one silently disabled double-spend protection); the read
|
|
42
|
+
methods (`planPayment`/`canAfford`/`estimateCost`) degrade instead of throwing on a malformed accept;
|
|
43
|
+
Sui coin pagination; Stellar custom-asset decimals; Tron native safe-integer; and more.
|
|
44
|
+
- **fix:** a second adversarial multi-agent conformance pass (vs the cloned x402 spec) hardened the new
|
|
45
|
+
surfaces — **upto cumulative caps are now merchant-proof:** the budget debits the authorized **MAX**
|
|
46
|
+
(a merchant that under-reports its settled `amount` can no longer loosen `maxTotal`/`maxTotalPerDenom`/
|
|
47
|
+
`windowTotal`); the metered actual is surfaced on `SpendRecord.settledBase`. The `upto` driver now
|
|
48
|
+
enforces **strict** `permitted.amount === advertised max` at verify time (an over-permit is rejected —
|
|
49
|
+
x402 `scheme_upto_evm` §Phase 3). `describe()` now projects the upto rail's mandatory
|
|
50
|
+
`extra.facilitatorAddress` (+ the exact rail's EIP-712 domain) so a discovered rail is reconstructable.
|
|
51
|
+
A2A conformance: a rejected proof re-challenges as `payment-rejected` (the spec status that pairs with
|
|
52
|
+
the retryable `input-required`, not the terminal `payment-failed`) carrying a failure receipt with
|
|
53
|
+
`network` + `transaction:''`. The agent guide + `paymentTools` JSDoc now document the upto rail and the
|
|
54
|
+
8th tool.
|
|
55
|
+
- **fix:** a third verification pass (regression-focused) caught two **doc copy-paste bugs** that would
|
|
56
|
+
brick a user's code — the `upto` seller + Tier-2 receipt examples used the pre-v2 `{ privateKey }`
|
|
57
|
+
wallet field (which throws `WrongFamilyError`) instead of the unified `{ key }`. Also: the A2A
|
|
58
|
+
terminal-`failed` receipt now carries the attempted `network`; the A2A `fulfill` doc/example returns a
|
|
59
|
+
structurally valid artifact (`{ name, parts }`); the MCP config docs + registry `server.json` now list
|
|
60
|
+
`upto`; and a **regression test** locks the merchant-proof cumulative leash (a sequence of
|
|
61
|
+
under-reporting `upto` payments is refused by `maxTotal`/`maxTotalPerDenom`/`windowTotal`).
|
|
62
|
+
- **fix:** a fourth, end-to-end pass (every flow traced hop-by-hop + a clean-room standards sign-off,
|
|
63
|
+
which came back **CONFORMANT on all four wire formats**, and a live MCP-pays-the-`upto`-rail proof)
|
|
64
|
+
found only doc-accuracy gaps + one low edge case: A2A failure receipts now attribute `network` from
|
|
65
|
+
the buyer's submitted payload (covering multi-network gates + v1-flat exact payloads), and the whole
|
|
66
|
+
docs-site is updated to the **8-tool** surface (the new `piprail_verify_receipt`) with the 2.10.0
|
|
67
|
+
receipts/upto/A2A APIs documented in the reference. No SDK behavior change beyond the A2A edge fix.
|
|
68
|
+
|
|
69
|
+
## [2.9.0] — 2026-06-19 — Cross-token grand total · payment-count caps · durable budget · richer spend observability
|
|
70
|
+
|
|
71
|
+
Spend controls grow up — a single budget across every token and chain, caps on the *number* of
|
|
72
|
+
payments, a budget that can survive a restart, and first-class decline/threshold events. Everything
|
|
73
|
+
is **additive and opt-in**: omit the new fields and behaviour is byte-identical to 2.8.0.
|
|
74
|
+
|
|
75
|
+
- **feat(policy): `maxTotalPerDenom` — the cross-token GRAND TOTAL.** Cap "$20 total across every
|
|
76
|
+
stablecoin and chain, full stop" with one number: `policy: { maxTotalPerDenom: { USD: '20.00', EUR: '5.00' } }`.
|
|
77
|
+
The SDK sums the human value of every token of that denomination (USDC/USDT/USD1/FDUSD/RLUSD → `USD`,
|
|
78
|
+
EURC → `EUR`; extend via `denomFor`) and refuses the payment that would breach it
|
|
79
|
+
(`reasonCode: 'BUDGET'`). **Not a price oracle** — PipRail still reads no market and never prices a
|
|
80
|
+
volatile coin; it's a user-declared unit-of-account sum (each token counted 1:1), and native/unknown
|
|
81
|
+
tokens are never in a bucket. Coexists with the per-asset `maxTotal`; the stricter cap wins. Exported
|
|
82
|
+
helpers: `denomOf`, `BUILTIN_DENOMS`, `DENOM_PRECISION`.
|
|
83
|
+
- **feat(policy): payment-COUNT caps.** `maxPayments` (lifetime) and `maxPaymentsPerWindow`
|
|
84
|
+
(+ `windowSeconds`) cap the *number* of payments across every chain + token — a rate limit that
|
|
85
|
+
needs no oracle. (`windowSeconds` is now the shared width for the money window AND the count window.)
|
|
86
|
+
- **feat(client): durable budget via a pluggable `spendStore`.** Pass `spendStore` and the spend
|
|
87
|
+
ledger hydrates at construction + persists every settle, so `maxTotal` / `maxTotalPerDenom` / the
|
|
88
|
+
count caps **survive a restart** — with no PipRail backend (you own the store, like the gate's
|
|
89
|
+
replay set). Ships `memorySpendStore` (from `@piprail/sdk`) and **`fileSpendStore(path)` from the new
|
|
90
|
+
`@piprail/sdk/node` entry** (a one-line local JSONL log; kept out of the browser bundle). `SpendLedger`
|
|
91
|
+
is now exported so several single-chain clients can SHARE one — `MultiChainPayer.fromWallets` does this
|
|
92
|
+
for you, making the grand total + count caps span every chain as ONE budget (also `spendStore` on its options).
|
|
93
|
+
- **feat(client): richer spend observability.** New constructor option `onSpend(record, budget)` —
|
|
94
|
+
the ergonomic "log my spend locally" hook, fired after each settle. Two new additive `PipRailEvent`
|
|
95
|
+
kinds: **`payment-declined`** (the rich decline — typed `reasonCode`, fine `PolicyDenyCode`, the quote,
|
|
96
|
+
and a budget snapshot; `payment-failed` still fires too for back-compat) and **`budget-threshold`**
|
|
97
|
+
(an early warning the first time spend crosses `policy.warnAtFraction` of any cap).
|
|
98
|
+
- **feat(client): budget surface extended (additive).** `client.budget()` now also returns
|
|
99
|
+
`byDenom: DenomRemaining[]` (the grand-total leash, previewable *before* any spend) and
|
|
100
|
+
`counts: CountStatus`; new reads `client.denomRemaining()`, `client.countStatus()`, and
|
|
101
|
+
`client.policy()` (the configured leash read back, also on `MultiChainPayer` + the `PayingClient`
|
|
102
|
+
interface). `client.spent()` / `SpendSummary` gains `byDenom: SpendDenomTotal[]`; `SpendRecord` now
|
|
103
|
+
carries `decimals` + `denom`. `formatSpendReport` appends the grand total when present.
|
|
104
|
+
- **New deny codes** on `PolicyDenyCode`: `MAX_TOTAL_DENOM`, `MAX_PAYMENTS`, `WINDOW_COUNT` (the
|
|
105
|
+
coarse `DeclineReasonCode` set is unchanged — they map to `BUDGET` / `BUDGET` / `OUTSIDE_WINDOW`).
|
|
106
|
+
- **New package entry `@piprail/sdk/node`** (`exports["./node"]`) for the Node-only `fileSpendStore`;
|
|
107
|
+
the core `@piprail/sdk` bundle stays browser-safe (no static `node:fs`).
|
|
108
|
+
- **Hardened against an adversarial review** (38-agent fuzz of the new surface). Fixes shipped
|
|
109
|
+
before release — see [Internals & hardening](https://docs.piprail.com/spend-controls/internals/):
|
|
110
|
+
- **OOM/DoS:** an absurd server-stated `decimals` (e.g. `1e9`) is rejected by a new `MAX_DECIMALS`
|
|
111
|
+
(100) bound at the envelope + the `assertValidDecimals` chokepoint (no multi-GB string).
|
|
112
|
+
- **Grand-total bypass (fund safety):** a token labelled `USDC` with `decimals` in `(24, 100]`
|
|
113
|
+
once **escaped** `maxTotalPerDenom`. `DENOM_PRECISION` is now pinned to `MAX_DECIMALS` and the
|
|
114
|
+
denom check **fails closed** (refuses an unscalable capped token, never skips it).
|
|
115
|
+
- **Strictest-cap-wins:** case-variant / whitespace / duplicate denomination keys (`{ USD, usd }`,
|
|
116
|
+
`" USD "`, a repeated CSV denom) now enforce the SMALLEST cap, never silently relax the leash.
|
|
117
|
+
- **Native never bucketed:** a native coin can't be summed into a USD/EUR total even if its symbol
|
|
118
|
+
matches a stablecoin.
|
|
119
|
+
- **Poisoned-store crash-safety:** the ledger validates + skips un-tallyable hydrated records
|
|
120
|
+
(non-numeric/negative `amountBase`, out-of-range `decimals`), so a corrupt store line can't crash
|
|
121
|
+
construction or make `budget()`/`spent()`/`summary()` throw; an unparseable `at` fails closed.
|
|
122
|
+
- **Loud validation:** `expiresAt` (must be a representable epoch-ms), a non-plain-object
|
|
123
|
+
`maxTotalPerDenom`, and a non-string `denomFor` value are all rejected at construction (the last
|
|
124
|
+
would otherwise throw at PAY time, after settlement).
|
|
125
|
+
- **Poisoned `denom` (final-pass fix):** a hydrated store record with a non-string `denom` is
|
|
126
|
+
coerced to "no denomination" (it still tallies per-asset) rather than throwing
|
|
127
|
+
`denom.toUpperCase()` out of construction/reads — completing the crash-safety guarantee.
|
|
128
|
+
- **`budget-threshold` dedup is ledger-scoped:** on a shared cross-chain ledger
|
|
129
|
+
(`MultiChainPayer.fromWallets`) a threshold now fires ONCE for the whole budget, not once per chain.
|
|
130
|
+
|
|
7
131
|
## [2.8.0] — 2026-06-19 — Solana exact SPL-Memo conformance · TON canonical CAIP-2 (`tvm:-239`) · Toncoin→Gram
|
|
8
132
|
|
|
9
133
|
- **chore(ton): native coin symbol `TON` → `GRAM` (Toncoin → Gram rebrand).** A TON community
|
package/README.md
CHANGED
|
@@ -53,7 +53,9 @@ const payer = MultiChainPayer.fromWallets({
|
|
|
53
53
|
solana: { key: process.env.SOLANA_KEY },
|
|
54
54
|
xrpl: { key: process.env.XRPL_SEED },
|
|
55
55
|
},
|
|
56
|
-
|
|
56
|
+
// ONE budget across every chain: $20 total + at most 100 payments. `maxTotalPerDenom`
|
|
57
|
+
// sums every USD stablecoin on every chain (not a price oracle — a 1:1 unit sum).
|
|
58
|
+
policy: { maxAmount: '1.00', maxTotalPerDenom: { USD: '20.00' }, maxPayments: 100 },
|
|
57
59
|
})
|
|
58
60
|
|
|
59
61
|
await payer.planPayment(url) // read-only: every chain ranked, payable-first in your listed order
|
|
@@ -61,7 +63,7 @@ const res = await payer.get(url) // pays on the first chain that can settle —
|
|
|
61
63
|
```
|
|
62
64
|
|
|
63
65
|
Built on `planAcross` / `fetchAcross` (the same composable primitives, for when you
|
|
64
|
-
already hold an array of clients). See [`examples/multi-chain`](../examples/multi-chain).
|
|
66
|
+
already hold an array of clients). See [`examples/basics/multi-chain`](../examples/basics/multi-chain).
|
|
65
67
|
|
|
66
68
|
The same app can **take** payments and **make** them. → [Making payments](https://docs.piprail.com/making-payments/piprail-client/)
|
|
67
69
|
|
|
@@ -72,9 +74,10 @@ The same app can **take** payments and **make** them. → [Making payments](http
|
|
|
72
74
|
| | |
|
|
73
75
|
|---|---|
|
|
74
76
|
| **[Getting started](https://docs.piprail.com/getting-started/introduction/)** | Install · quickstart · how it works |
|
|
75
|
-
| **[Accepting payments](https://docs.piprail.com/accepting-payments/require-payment-and-gate/)** | `requirePayment` · `createPaymentGate` · the `exact` rail |
|
|
77
|
+
| **[Accepting payments](https://docs.piprail.com/accepting-payments/require-payment-and-gate/)** | `requirePayment` · `createPaymentGate` · the `exact` rail · the `upto` metered rail |
|
|
76
78
|
| **[Making payments](https://docs.piprail.com/making-payments/piprail-client/)** | `PipRailClient` · `quote` · `estimateCost` · `planPayment` · auto-route · `MultiChainPayer` |
|
|
77
|
-
| **[
|
|
79
|
+
| **[Verifiable receipts](https://docs.piprail.com/accepting-payments/verifiable-receipts/)** | Chain-grounded, anyone-verifiable receipts (no key) · optional EIP-712 attestation |
|
|
80
|
+
| **[Spend controls](https://docs.piprail.com/spend-controls/payment-policy/)** | Per-token + cross-token grand total · payment-count caps · time envelope · durable budget · the spend ledger |
|
|
78
81
|
| **[Agent toolkit](https://docs.piprail.com/agent-toolkit/payment-tools/)** | `paymentTools` · the agent guide · NL renderers |
|
|
79
82
|
| **[Discovery](https://docs.piprail.com/discovery/discover-and-register/)** | Find & be found on the open x402 indexes ($0, no backend) |
|
|
80
83
|
| **[Chains & tokens](https://docs.piprail.com/chains/overview/)** | Every chain, per-family setup & caveats |
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
|
|
13
|
-
var
|
|
13
|
+
var _chunkMWBT7MCEcjs = require('./chunk-MWBT7MCE.cjs');
|
|
14
14
|
|
|
15
15
|
// src/drivers/algorand/index.ts
|
|
16
16
|
var _algosdk = require('algosdk'); var _algosdk2 = _interopRequireDefault(_algosdk);
|
|
@@ -58,13 +58,13 @@ async function payAlgorand(params) {
|
|
|
58
58
|
} catch (err) {
|
|
59
59
|
const mapped = mapAlgorandError(err, accept.payTo);
|
|
60
60
|
if (mapped) throw mapped;
|
|
61
|
-
throw _nullishCoalesce(
|
|
61
|
+
throw _nullishCoalesce(_chunkMWBT7MCEcjs.toInsufficientFundsError.call(void 0, err), () => ( err));
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
64
|
function mapAlgorandError(err, payTo) {
|
|
65
65
|
const m = err instanceof Error ? err.message : String(err);
|
|
66
66
|
if (/must optin/i.test(m) || /missing from/i.test(m) && m.includes(payTo)) {
|
|
67
|
-
return new (0,
|
|
67
|
+
return new (0, _chunkMWBT7MCEcjs.RecipientNotReadyError)(
|
|
68
68
|
`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)})`,
|
|
69
69
|
{ cause: err }
|
|
70
70
|
);
|
|
@@ -72,7 +72,7 @@ function mapAlgorandError(err, payTo) {
|
|
|
72
72
|
if (/overspend|below min|min(imum)? balance|tried to spend|balance \d+ below|asset \d+ missing from|insufficient|underflow/i.test(
|
|
73
73
|
m
|
|
74
74
|
)) {
|
|
75
|
-
return new (0,
|
|
75
|
+
return new (0, _chunkMWBT7MCEcjs.InsufficientFundsError)(
|
|
76
76
|
`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)})`,
|
|
77
77
|
{ cause: err }
|
|
78
78
|
);
|
|
@@ -99,33 +99,33 @@ function isSet(addr) {
|
|
|
99
99
|
function randomNote() {
|
|
100
100
|
const g = globalThis.crypto;
|
|
101
101
|
if (!_optionalChain([g, 'optionalAccess', _ => _.getRandomValues])) {
|
|
102
|
-
throw new (0,
|
|
102
|
+
throw new (0, _chunkMWBT7MCEcjs.UnsupportedSchemeError)("Algorand exact: no Web Crypto CSPRNG available to generate a unique note.");
|
|
103
103
|
}
|
|
104
104
|
return g.getRandomValues(new Uint8Array(32));
|
|
105
105
|
}
|
|
106
106
|
async function payExactAlgorand(input) {
|
|
107
107
|
const { suggestedParams, sk, sender, accept } = input;
|
|
108
108
|
if (accept.asset === "native") {
|
|
109
|
-
throw new (0,
|
|
109
|
+
throw new (0, _chunkMWBT7MCEcjs.UnsupportedSchemeError)(
|
|
110
110
|
"Algorand exact is ASA-only (an asset transfer); native ALGO is not exact-payable. Pay via onchain-proof."
|
|
111
111
|
);
|
|
112
112
|
}
|
|
113
113
|
const feePayer = accept.extra.feePayer;
|
|
114
114
|
if (!feePayer) {
|
|
115
|
-
throw new (0,
|
|
115
|
+
throw new (0, _chunkMWBT7MCEcjs.UnsupportedSchemeError)("Algorand exact rail must advertise extra.feePayer (the fee sponsor address).");
|
|
116
116
|
}
|
|
117
117
|
const assetId = parseAlgorandAssetId(accept.asset);
|
|
118
118
|
if (assetId === null) {
|
|
119
|
-
throw new (0,
|
|
119
|
+
throw new (0, _chunkMWBT7MCEcjs.UnsupportedSchemeError)(`Algorand exact rail asset "${accept.asset}" must be a numeric ASA id.`);
|
|
120
120
|
}
|
|
121
121
|
if (!_algosdk2.default.isValidAddress(feePayer)) {
|
|
122
|
-
throw new (0,
|
|
122
|
+
throw new (0, _chunkMWBT7MCEcjs.UnsupportedSchemeError)(`Algorand exact: extra.feePayer "${feePayer}" is not a valid Algorand address.`);
|
|
123
123
|
}
|
|
124
124
|
if (!_algosdk2.default.isValidAddress(accept.payTo)) {
|
|
125
|
-
throw new (0,
|
|
125
|
+
throw new (0, _chunkMWBT7MCEcjs.UnsupportedSchemeError)(`Algorand exact: payTo "${accept.payTo}" is not a valid Algorand address.`);
|
|
126
126
|
}
|
|
127
127
|
if (feePayer === sender) {
|
|
128
|
-
throw new (0,
|
|
128
|
+
throw new (0, _chunkMWBT7MCEcjs.UnsupportedSchemeError)(
|
|
129
129
|
"Algorand exact: the fee payer must differ from the payer \u2014 the buyer must pay ZERO ALGO (the sponsor pays the pooled fee)."
|
|
130
130
|
);
|
|
131
131
|
}
|
|
@@ -172,13 +172,13 @@ function decodeElement(bytes) {
|
|
|
172
172
|
async function verifyAndSettleExactAlgorand(input) {
|
|
173
173
|
const { client, feePayerSk, feePayerAddr, payload, accept } = input;
|
|
174
174
|
const railFeePayer = accept.extra.feePayer;
|
|
175
|
-
if (!railFeePayer) throw new (0,
|
|
175
|
+
if (!railFeePayer) throw new (0, _chunkMWBT7MCEcjs.SettlementError)("Algorand exact: rail is missing extra.feePayer.");
|
|
176
176
|
if (railFeePayer !== feePayerAddr) {
|
|
177
|
-
throw new (0,
|
|
177
|
+
throw new (0, _chunkMWBT7MCEcjs.SettlementError)("Algorand exact: the gate relayer address does not match the rail extra.feePayer \u2014 misconfigured rail.");
|
|
178
178
|
}
|
|
179
179
|
const assetId = parseAlgorandAssetId(accept.asset);
|
|
180
|
-
if (assetId === null) throw new (0,
|
|
181
|
-
if (!_algosdk2.default.isValidAddress(accept.payTo)) throw new (0,
|
|
180
|
+
if (assetId === null) throw new (0, _chunkMWBT7MCEcjs.SettlementError)(`Algorand exact: rail asset "${accept.asset}" is not a numeric ASA id.`);
|
|
181
|
+
if (!_algosdk2.default.isValidAddress(accept.payTo)) throw new (0, _chunkMWBT7MCEcjs.SettlementError)(`Algorand exact: rail payTo "${accept.payTo}" is invalid.`);
|
|
182
182
|
const { paymentIndex, paymentGroup } = payload;
|
|
183
183
|
if (paymentGroup.length !== GROUP_SIZE) {
|
|
184
184
|
return fail("signature_invalid", `Algorand exact expects a ${GROUP_SIZE}-transaction group (payment + fee), got ${paymentGroup.length}.`);
|
|
@@ -244,7 +244,7 @@ async function verifyAndSettleExactAlgorand(input) {
|
|
|
244
244
|
try {
|
|
245
245
|
feeSigned = fee.signTxn(feePayerSk);
|
|
246
246
|
} catch (err) {
|
|
247
|
-
throw new (0,
|
|
247
|
+
throw new (0, _chunkMWBT7MCEcjs.SettlementError)(`Algorand exact settle: the gate could not sign the fee transaction (${shorten(err instanceof Error ? err.message : String(err))}).`, { cause: err });
|
|
248
248
|
}
|
|
249
249
|
const signedGroup = elements.map((el, i) => i === paymentIndex ? payElement.raw : feeSigned);
|
|
250
250
|
try {
|
|
@@ -266,7 +266,7 @@ async function verifyAndSettleExactAlgorand(input) {
|
|
|
266
266
|
if (/signature|sig|auth|malformed/i.test(m)) return fail("signature_invalid", `Settle rejected \u2014 bad signature: ${shorten(m)}.`);
|
|
267
267
|
if (/already in ledger|already committed|duplicate/i.test(m)) return fail("tx_already_used", `This payment was already settled: ${shorten(m)}.`);
|
|
268
268
|
if (/\bround\b|expired|lifetime|stale|validity/i.test(m)) return fail("payment_expired", `Settle rejected \u2014 validity window expired: ${shorten(m)}.`);
|
|
269
|
-
throw new (0,
|
|
269
|
+
throw new (0, _chunkMWBT7MCEcjs.SettlementError)(
|
|
270
270
|
`Algorand exact settle: the group failed to submit (${shorten(m)}). The buyer's signed transaction is still valid \u2014 fund/fix the fee payer (${railFeePayer}) and the buyer can re-present it.`,
|
|
271
271
|
{ cause: err }
|
|
272
272
|
);
|
|
@@ -275,10 +275,10 @@ async function verifyAndSettleExactAlgorand(input) {
|
|
|
275
275
|
try {
|
|
276
276
|
round = await client.waitForConfirmation(buyerTxid);
|
|
277
277
|
} catch (err) {
|
|
278
|
-
throw new (0,
|
|
278
|
+
throw new (0, _chunkMWBT7MCEcjs.SettlementError)(`Algorand exact settle: submitted ${buyerTxid} but confirmation read failed (${shorten(err instanceof Error ? err.message : String(err))}). It likely landed \u2014 re-verify before re-presenting; do NOT re-pay.`, { cause: err });
|
|
279
279
|
}
|
|
280
280
|
if (round === null) {
|
|
281
|
-
throw new (0,
|
|
281
|
+
throw new (0, _chunkMWBT7MCEcjs.SettlementError)(`Algorand exact settle: submitted ${buyerTxid} but it did not confirm in time. It likely landed \u2014 re-verify before re-presenting; do NOT re-pay.`);
|
|
282
282
|
}
|
|
283
283
|
return {
|
|
284
284
|
ok: true,
|
|
@@ -373,13 +373,13 @@ function rpcFailed(nonce) {
|
|
|
373
373
|
|
|
374
374
|
function assertAlgorandWallet(wallet, network) {
|
|
375
375
|
if (typeof wallet !== "object" || wallet === null) {
|
|
376
|
-
throw new (0,
|
|
376
|
+
throw new (0, _chunkMWBT7MCEcjs.WrongFamilyError)(
|
|
377
377
|
`chain ${network} is Algorand; wallet must be { key } (25-word mnemonic) or { account }.`
|
|
378
378
|
);
|
|
379
379
|
}
|
|
380
|
-
|
|
380
|
+
_chunkMWBT7MCEcjs.assertNoLegacyWalletKey.call(void 0, wallet, "Algorand");
|
|
381
381
|
if (!("key" in wallet) && !("account" in wallet)) {
|
|
382
|
-
throw new (0,
|
|
382
|
+
throw new (0, _chunkMWBT7MCEcjs.WrongFamilyError)(
|
|
383
383
|
`chain ${network} is Algorand; wallet must be { key } (25-word mnemonic) or { account }.`
|
|
384
384
|
);
|
|
385
385
|
}
|
|
@@ -394,13 +394,13 @@ function resolveAlgorandWallet(config) {
|
|
|
394
394
|
const { addr, sk } = _algosdk2.default.mnemonicToSecretKey(config.key);
|
|
395
395
|
return { addr: addr.toString(), sk };
|
|
396
396
|
} catch (cause) {
|
|
397
|
-
throw new (0,
|
|
397
|
+
throw new (0, _chunkMWBT7MCEcjs.WrongFamilyError)(
|
|
398
398
|
"Algorand wallet { key } is not a valid 25-word Algorand mnemonic.",
|
|
399
399
|
{ cause }
|
|
400
400
|
);
|
|
401
401
|
}
|
|
402
402
|
}
|
|
403
|
-
throw new (0,
|
|
403
|
+
throw new (0, _chunkMWBT7MCEcjs.WrongFamilyError)("Algorand wallet needs { key } (25-word mnemonic) or { account }.");
|
|
404
404
|
}
|
|
405
405
|
|
|
406
406
|
// src/drivers/algorand/index.ts
|
|
@@ -471,16 +471,16 @@ function makeAlgorandNetwork(preset, algodUrl) {
|
|
|
471
471
|
const info = preset.tokens[token.toUpperCase()];
|
|
472
472
|
if (!info) {
|
|
473
473
|
const known = Object.keys(preset.tokens).join(", ") || "(none built in)";
|
|
474
|
-
throw new (0,
|
|
474
|
+
throw new (0, _chunkMWBT7MCEcjs.UnknownTokenError)(
|
|
475
475
|
`token "${token}" isn't built in for Algorand (known: ${known}). Pass { assetId, decimals } for a custom ASA, or use 'native'.`
|
|
476
476
|
);
|
|
477
477
|
}
|
|
478
478
|
return { asset: algorandAssetId(info.assetId), decimals: info.decimals, symbol: info.symbol };
|
|
479
479
|
}
|
|
480
|
-
|
|
480
|
+
_chunkMWBT7MCEcjs.rejectForeignToken.call(void 0, token, "algorand", network);
|
|
481
481
|
const t = token;
|
|
482
482
|
if (typeof t.assetId !== "number" || typeof t.decimals !== "number") {
|
|
483
|
-
throw new (0,
|
|
483
|
+
throw new (0, _chunkMWBT7MCEcjs.WrongFamilyError)(
|
|
484
484
|
`chain ${network} is Algorand; a custom token must be { assetId, decimals }.`
|
|
485
485
|
);
|
|
486
486
|
}
|
|
@@ -501,12 +501,12 @@ function makeAlgorandNetwork(preset, algodUrl) {
|
|
|
501
501
|
},
|
|
502
502
|
assertValidPayTo(payTo) {
|
|
503
503
|
if (payTo.startsWith("0x")) {
|
|
504
|
-
throw new (0,
|
|
504
|
+
throw new (0, _chunkMWBT7MCEcjs.WrongFamilyError)(
|
|
505
505
|
`chain ${network} is Algorand, but payTo "${payTo}" looks like an EVM address.`
|
|
506
506
|
);
|
|
507
507
|
}
|
|
508
508
|
if (!_algosdk2.default.isValidAddress(payTo)) {
|
|
509
|
-
throw new (0,
|
|
509
|
+
throw new (0, _chunkMWBT7MCEcjs.WrongFamilyError)(
|
|
510
510
|
`chain ${network} is Algorand, but payTo "${payTo}" is not a valid Algorand address.`
|
|
511
511
|
);
|
|
512
512
|
}
|
|
@@ -523,14 +523,14 @@ function makeAlgorandNetwork(preset, algodUrl) {
|
|
|
523
523
|
const info = await _algosdk2.default.waitForConfirmation(algod, ref, 10);
|
|
524
524
|
return { height: String(_nullishCoalesce(info.confirmedRound, () => ( 0))) };
|
|
525
525
|
} catch (err) {
|
|
526
|
-
throw new (0,
|
|
526
|
+
throw new (0, _chunkMWBT7MCEcjs.ConfirmationTimeoutError)(`Algorand tx ${ref} did not confirm in time.`, {
|
|
527
527
|
cause: err
|
|
528
528
|
});
|
|
529
529
|
}
|
|
530
530
|
},
|
|
531
531
|
async estimateCost(accept) {
|
|
532
532
|
if (accept.scheme === "exact") {
|
|
533
|
-
return
|
|
533
|
+
return _chunkMWBT7MCEcjs.nativeCost.call(void 0, {
|
|
534
534
|
symbol: ALGO_SYMBOL,
|
|
535
535
|
decimals: ALGO_DECIMALS,
|
|
536
536
|
fee: 0n,
|
|
@@ -538,7 +538,7 @@ function makeAlgorandNetwork(preset, algodUrl) {
|
|
|
538
538
|
detail: "gasless \u2014 the fee payer (facilitator/relayer) pools the group fee; the buyer pays 0 ALGO"
|
|
539
539
|
});
|
|
540
540
|
}
|
|
541
|
-
return
|
|
541
|
+
return _chunkMWBT7MCEcjs.nativeCost.call(void 0, {
|
|
542
542
|
symbol: ALGO_SYMBOL,
|
|
543
543
|
decimals: ALGO_DECIMALS,
|
|
544
544
|
fee: 1000n,
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
|
|
12
|
-
var
|
|
12
|
+
var _chunkMWBT7MCEcjs = require('./chunk-MWBT7MCE.cjs');
|
|
13
13
|
|
|
14
14
|
// src/drivers/aptos/index.ts
|
|
15
15
|
var _tssdk = require('@aptos-labs/ts-sdk');
|
|
@@ -58,14 +58,14 @@ async function payAptos(params) {
|
|
|
58
58
|
const res = await client.signSubmit({ signer, transaction });
|
|
59
59
|
return res.hash;
|
|
60
60
|
} catch (err) {
|
|
61
|
-
if (err instanceof
|
|
61
|
+
if (err instanceof _chunkMWBT7MCEcjs.InsufficientFundsError) throw err;
|
|
62
62
|
if (isAptosAffordability(err)) {
|
|
63
|
-
throw new (0,
|
|
63
|
+
throw new (0, _chunkMWBT7MCEcjs.InsufficientFundsError)(
|
|
64
64
|
err instanceof Error ? err.message : "Insufficient APT/token balance for the payment.",
|
|
65
65
|
{ cause: err }
|
|
66
66
|
);
|
|
67
67
|
}
|
|
68
|
-
throw _nullishCoalesce(
|
|
68
|
+
throw _nullishCoalesce(_chunkMWBT7MCEcjs.toInsufficientFundsError.call(void 0, err), () => ( err));
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
71
|
function isAptosAffordability(err) {
|
|
@@ -103,24 +103,24 @@ function parseAddr(addr) {
|
|
|
103
103
|
async function payExactAptos(input) {
|
|
104
104
|
const { client, sender, accept } = input;
|
|
105
105
|
if (accept.asset === "native") {
|
|
106
|
-
throw new (0,
|
|
106
|
+
throw new (0, _chunkMWBT7MCEcjs.UnsupportedSchemeError)(
|
|
107
107
|
"Aptos exact is Fungible-Asset only (a primary_fungible_store transfer); native APT is not exact-payable. Pay via onchain-proof."
|
|
108
108
|
);
|
|
109
109
|
}
|
|
110
110
|
const feePayer = accept.extra.feePayer;
|
|
111
111
|
if (!feePayer) {
|
|
112
|
-
throw new (0,
|
|
112
|
+
throw new (0, _chunkMWBT7MCEcjs.UnsupportedSchemeError)("Aptos exact rail must advertise extra.feePayer (the gas sponsor address).");
|
|
113
113
|
}
|
|
114
114
|
const feePayerAddr = parseAddr(feePayer);
|
|
115
|
-
if (!feePayerAddr) throw new (0,
|
|
115
|
+
if (!feePayerAddr) throw new (0, _chunkMWBT7MCEcjs.UnsupportedSchemeError)(`Aptos exact: extra.feePayer "${feePayer}" is not a valid Aptos address.`);
|
|
116
116
|
const payToAddr = parseAddr(accept.payTo);
|
|
117
|
-
if (!payToAddr) throw new (0,
|
|
117
|
+
if (!payToAddr) throw new (0, _chunkMWBT7MCEcjs.UnsupportedSchemeError)(`Aptos exact: payTo "${accept.payTo}" is not a valid Aptos address.`);
|
|
118
118
|
const metadataAddr = parseAddr(accept.asset);
|
|
119
|
-
if (!metadataAddr) throw new (0,
|
|
119
|
+
if (!metadataAddr) throw new (0, _chunkMWBT7MCEcjs.UnsupportedSchemeError)(`Aptos exact: asset "${accept.asset}" is not a valid FA metadata address.`);
|
|
120
120
|
const senderAddr = parseAddr(sender);
|
|
121
|
-
if (!senderAddr) throw new (0,
|
|
121
|
+
if (!senderAddr) throw new (0, _chunkMWBT7MCEcjs.UnsupportedSchemeError)(`Aptos exact: payer "${sender}" is not a valid Aptos address.`);
|
|
122
122
|
if (feePayerAddr.equals(senderAddr)) {
|
|
123
|
-
throw new (0,
|
|
123
|
+
throw new (0, _chunkMWBT7MCEcjs.UnsupportedSchemeError)(
|
|
124
124
|
"Aptos exact: the fee payer must differ from the payer \u2014 the buyer must pay ZERO APT (the sponsor pays gas)."
|
|
125
125
|
);
|
|
126
126
|
}
|
|
@@ -158,16 +158,16 @@ function argBytes(arg) {
|
|
|
158
158
|
async function verifyAndSettleExactAptos(input) {
|
|
159
159
|
const { client, feePayerAddr, payload, accept } = input;
|
|
160
160
|
const railFeePayer = accept.extra.feePayer;
|
|
161
|
-
if (!railFeePayer) throw new (0,
|
|
161
|
+
if (!railFeePayer) throw new (0, _chunkMWBT7MCEcjs.SettlementError)("Aptos exact: rail is missing extra.feePayer.");
|
|
162
162
|
if (railFeePayer !== feePayerAddr) {
|
|
163
|
-
throw new (0,
|
|
163
|
+
throw new (0, _chunkMWBT7MCEcjs.SettlementError)("Aptos exact: the gate relayer address does not match the rail extra.feePayer \u2014 misconfigured rail.");
|
|
164
164
|
}
|
|
165
|
-
if (accept.asset === "native") throw new (0,
|
|
165
|
+
if (accept.asset === "native") throw new (0, _chunkMWBT7MCEcjs.SettlementError)("Aptos exact: native APT is not exact-payable (misconfigured rail).");
|
|
166
166
|
const railFeePayerAddr = parseAddr(railFeePayer);
|
|
167
167
|
const railPayTo = parseAddr(accept.payTo);
|
|
168
168
|
const railMetadata = parseAddr(accept.asset);
|
|
169
169
|
if (!railFeePayerAddr || !railPayTo || !railMetadata) {
|
|
170
|
-
throw new (0,
|
|
170
|
+
throw new (0, _chunkMWBT7MCEcjs.SettlementError)("Aptos exact: rail feePayer/payTo/asset is not a valid Aptos address (misconfigured rail).");
|
|
171
171
|
}
|
|
172
172
|
let tx;
|
|
173
173
|
let senderAuth;
|
|
@@ -241,7 +241,7 @@ async function verifyAndSettleExactAptos(input) {
|
|
|
241
241
|
try {
|
|
242
242
|
feePayerAuth = client.signAsFeePayer({ transaction: tx });
|
|
243
243
|
} catch (err) {
|
|
244
|
-
throw new (0,
|
|
244
|
+
throw new (0, _chunkMWBT7MCEcjs.SettlementError)(`Aptos exact settle: the gate could not sign as fee payer (${shorten(err instanceof Error ? err.message : String(err))}).`, { cause: err });
|
|
245
245
|
}
|
|
246
246
|
if (senderAuth instanceof _tssdk.AccountAuthenticatorEd25519) {
|
|
247
247
|
try {
|
|
@@ -264,7 +264,7 @@ async function verifyAndSettleExactAptos(input) {
|
|
|
264
264
|
if (/signature|invalid.*auth|INVALID_SIGNATURE/i.test(m)) return fail("signature_invalid", `Settle rejected \u2014 bad signature: ${shorten(m)}.`);
|
|
265
265
|
if (/SEQUENCE_NUMBER_TOO_OLD|already.*(committed|ledger)|duplicate/i.test(m)) return fail("tx_already_used", `This payment was already settled: ${shorten(m)}.`);
|
|
266
266
|
if (/EXPIRED|expired|TOO_NEW/i.test(m)) return fail("payment_expired", `Settle rejected \u2014 expired/stale: ${shorten(m)}.`);
|
|
267
|
-
throw new (0,
|
|
267
|
+
throw new (0, _chunkMWBT7MCEcjs.SettlementError)(
|
|
268
268
|
`Aptos exact settle: the transaction failed to submit (${shorten(m)}). The buyer's signed transaction is still valid \u2014 fund/fix the fee payer (${railFeePayer}) and the buyer can re-present it.`,
|
|
269
269
|
{ cause: err }
|
|
270
270
|
);
|
|
@@ -273,10 +273,10 @@ async function verifyAndSettleExactAptos(input) {
|
|
|
273
273
|
try {
|
|
274
274
|
confirmed = await client.waitForConfirmation(hash);
|
|
275
275
|
} catch (err) {
|
|
276
|
-
throw new (0,
|
|
276
|
+
throw new (0, _chunkMWBT7MCEcjs.SettlementError)(`Aptos exact settle: submitted ${hash} but confirmation read failed (${shorten(err instanceof Error ? err.message : String(err))}). It likely landed \u2014 re-verify before re-presenting; do NOT re-pay.`, { cause: err });
|
|
277
277
|
}
|
|
278
278
|
if (confirmed === null) {
|
|
279
|
-
throw new (0,
|
|
279
|
+
throw new (0, _chunkMWBT7MCEcjs.SettlementError)(`Aptos exact settle: submitted ${hash} but it did not confirm in time. It likely landed \u2014 re-verify before re-presenting; do NOT re-pay.`);
|
|
280
280
|
}
|
|
281
281
|
if (!confirmed.success) {
|
|
282
282
|
return fail("tx_reverted", `Settle tx ${hash} reverted on-chain (a post-simulate race).`);
|
|
@@ -371,13 +371,13 @@ function txNotFound(hash) {
|
|
|
371
371
|
|
|
372
372
|
function assertAptosWallet(wallet, network) {
|
|
373
373
|
if (typeof wallet !== "object" || wallet === null) {
|
|
374
|
-
throw new (0,
|
|
374
|
+
throw new (0, _chunkMWBT7MCEcjs.WrongFamilyError)(
|
|
375
375
|
`chain ${network} is Aptos; wallet must be { key } (ed25519-priv-0x\u2026) or { account }.`
|
|
376
376
|
);
|
|
377
377
|
}
|
|
378
|
-
|
|
378
|
+
_chunkMWBT7MCEcjs.assertNoLegacyWalletKey.call(void 0, wallet, "Aptos");
|
|
379
379
|
if (!("key" in wallet) && !("account" in wallet)) {
|
|
380
|
-
throw new (0,
|
|
380
|
+
throw new (0, _chunkMWBT7MCEcjs.WrongFamilyError)(
|
|
381
381
|
`chain ${network} is Aptos; wallet must be { key } (ed25519-priv-0x\u2026) or { account }.`
|
|
382
382
|
);
|
|
383
383
|
}
|
|
@@ -389,13 +389,13 @@ function resolveAptosAccount(config) {
|
|
|
389
389
|
try {
|
|
390
390
|
return _tssdk.Account.fromPrivateKey({ privateKey: new (0, _tssdk.Ed25519PrivateKey)(config.key) });
|
|
391
391
|
} catch (cause) {
|
|
392
|
-
throw new (0,
|
|
392
|
+
throw new (0, _chunkMWBT7MCEcjs.WrongFamilyError)(
|
|
393
393
|
"Aptos wallet { key } is not a valid ed25519 secret (ed25519-priv-0x\u2026 or 0x\u2026 hex).",
|
|
394
394
|
{ cause }
|
|
395
395
|
);
|
|
396
396
|
}
|
|
397
397
|
}
|
|
398
|
-
throw new (0,
|
|
398
|
+
throw new (0, _chunkMWBT7MCEcjs.WrongFamilyError)("Aptos wallet needs { key } (ed25519-priv-0x\u2026) or { account }.");
|
|
399
399
|
}
|
|
400
400
|
|
|
401
401
|
// src/drivers/aptos/index.ts
|
|
@@ -467,16 +467,16 @@ function makeAptosNetwork(preset, rpcUrl) {
|
|
|
467
467
|
const info = preset.tokens[token.toUpperCase()];
|
|
468
468
|
if (!info) {
|
|
469
469
|
const known = Object.keys(preset.tokens).join(", ") || "(none built in)";
|
|
470
|
-
throw new (0,
|
|
470
|
+
throw new (0, _chunkMWBT7MCEcjs.UnknownTokenError)(
|
|
471
471
|
`token "${token}" isn't built in for Aptos (known: ${known}). Pass { metadata, decimals } for a custom Fungible Asset, or use 'native'.`
|
|
472
472
|
);
|
|
473
473
|
}
|
|
474
474
|
return { asset: info.metadata, decimals: info.decimals, symbol: info.symbol };
|
|
475
475
|
}
|
|
476
|
-
|
|
476
|
+
_chunkMWBT7MCEcjs.rejectForeignToken.call(void 0, token, "aptos", network);
|
|
477
477
|
const t = token;
|
|
478
478
|
if (!t.metadata || typeof t.decimals !== "number") {
|
|
479
|
-
throw new (0,
|
|
479
|
+
throw new (0, _chunkMWBT7MCEcjs.WrongFamilyError)(
|
|
480
480
|
`chain ${network} is Aptos; a custom token must be { metadata, decimals }.`
|
|
481
481
|
);
|
|
482
482
|
}
|
|
@@ -503,7 +503,7 @@ function makeAptosNetwork(preset, rpcUrl) {
|
|
|
503
503
|
valid = false;
|
|
504
504
|
}
|
|
505
505
|
if (!valid || evmLike) {
|
|
506
|
-
throw new (0,
|
|
506
|
+
throw new (0, _chunkMWBT7MCEcjs.WrongFamilyError)(
|
|
507
507
|
`chain ${network} is Aptos, but payTo "${payTo}" is not a valid Aptos address (0x + 32 bytes).`
|
|
508
508
|
);
|
|
509
509
|
}
|
|
@@ -525,12 +525,12 @@ function makeAptosNetwork(preset, rpcUrl) {
|
|
|
525
525
|
const tx = await aptos.waitForTransaction({ transactionHash: ref });
|
|
526
526
|
return { height: String(_nullishCoalesce(tx.version, () => ( "0"))) };
|
|
527
527
|
} catch (err) {
|
|
528
|
-
throw new (0,
|
|
528
|
+
throw new (0, _chunkMWBT7MCEcjs.ConfirmationTimeoutError)(`Aptos tx ${ref} did not finalize in time.`, { cause: err });
|
|
529
529
|
}
|
|
530
530
|
},
|
|
531
531
|
async estimateCost(accept) {
|
|
532
532
|
if (accept.scheme === "exact") {
|
|
533
|
-
return
|
|
533
|
+
return _chunkMWBT7MCEcjs.nativeCost.call(void 0, {
|
|
534
534
|
symbol: APT_SYMBOL,
|
|
535
535
|
decimals: APT_DECIMALS,
|
|
536
536
|
fee: 0n,
|
|
@@ -538,7 +538,7 @@ function makeAptosNetwork(preset, rpcUrl) {
|
|
|
538
538
|
detail: "gasless \u2014 the fee payer (facilitator/relayer) sponsors gas; the buyer pays 0 APT"
|
|
539
539
|
});
|
|
540
540
|
}
|
|
541
|
-
return
|
|
541
|
+
return _chunkMWBT7MCEcjs.nativeCost.call(void 0, {
|
|
542
542
|
symbol: APT_SYMBOL,
|
|
543
543
|
decimals: APT_DECIMALS,
|
|
544
544
|
fee: 100000n,
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
nativeCost,
|
|
10
10
|
rejectForeignToken,
|
|
11
11
|
toInsufficientFundsError
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-SC2ZYDHD.js";
|
|
13
13
|
|
|
14
14
|
// src/drivers/aptos/index.ts
|
|
15
15
|
import { Aptos, AptosConfig, Network, AccountAddress as AccountAddress2 } from "@aptos-labs/ts-sdk";
|