@piprail/sdk 2.16.2 → 3.0.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 +343 -0
- package/README.md +1 -0
- package/dist/{algorand-25FMBCT3.js → algorand-HL57PQHE.js} +157 -2
- package/dist/{algorand-Q3TUQLPK.cjs → algorand-W776EEM2.cjs} +205 -50
- package/dist/{aptos-VBJONBFY.cjs → aptos-5QBXJ6NV.cjs} +255 -39
- package/dist/{aptos-SBV6SGDP.js → aptos-H5VLH2QL.js} +217 -1
- package/dist/{chunk-QONQSZHJ.cjs → chunk-6XTNI2OQ.cjs} +44 -44
- package/dist/{chunk-OXEFPLZA.cjs → chunk-6ZRAIQXF.cjs} +4 -4
- package/dist/chunk-GVCGUSTE.js +30 -0
- package/dist/{chunk-V2IJ5HUW.cjs → chunk-MZAJQYM3.cjs} +1 -0
- package/dist/chunk-MZXVXC3C.cjs +30 -0
- package/dist/{chunk-2CX7XRZK.js → chunk-TZDVZCTC.js} +1 -0
- package/dist/{chunk-C52H5TYB.js → chunk-YXBQKBDH.js} +2 -2
- package/dist/index.cjs +2929 -1444
- package/dist/index.d.cts +625 -13
- package/dist/index.d.ts +625 -13
- package/dist/index.js +2506 -1021
- package/dist/{near-OLKCMTBI.js → near-5X2CQGML.js} +197 -1
- package/dist/{near-5LTTDU6G.cjs → near-XSQXEIHT.cjs} +242 -46
- package/dist/{solana-AI2G7V33.cjs → solana-EBV6PUCU.cjs} +211 -52
- package/dist/{solana-HTKDRTD3.js → solana-O6Q6QILH.js} +167 -8
- package/dist/{stellar-E2KWEV2E.cjs → stellar-5C7FQLPS.cjs} +191 -29
- package/dist/{stellar-EUFZLX6J.js → stellar-YF5LOJEM.js} +163 -1
- package/dist/{sui-KCIITCYH.js → sui-JFQSDNSZ.js} +165 -3
- package/dist/{sui-Q3NJOJZS.cjs → sui-WIZEAO7E.cjs} +185 -23
- package/dist/{ton-J7TQWRN4.cjs → ton-AGTKLQA5.cjs} +264 -22
- package/dist/{ton-WH2JVQOO.js → ton-OZKFNRLT.js} +244 -2
- package/dist/{tron-FXBXDNEY.js → tron-HG3IOOCG.js} +283 -1
- package/dist/{tron-HIPMOX7S.cjs → tron-S4WX7OHY.cjs} +323 -41
- package/dist/{xrpl-RUOB37QH.js → xrpl-GOVHMYYK.js} +222 -5
- package/dist/{xrpl-SVVS445B.cjs → xrpl-YS3IXPLV.cjs} +273 -56
- package/package.json +12 -2
- package/dist/{chunk-QU25LSVS.js → chunk-5GRBEMCA.js} +44 -44
package/dist/index.d.ts
CHANGED
|
@@ -1574,7 +1574,9 @@ declare const CHAINS: {
|
|
|
1574
1574
|
authorizationList?: undefined;
|
|
1575
1575
|
mint?: undefined;
|
|
1576
1576
|
isSystemTx?: undefined;
|
|
1577
|
-
sourceHash
|
|
1577
|
+
sourceHash
|
|
1578
|
+
/** Native coin metadata. Defaults to 18-decimal ETH. */
|
|
1579
|
+
? /** Native coin metadata. Defaults to 18-decimal ETH. */: undefined;
|
|
1578
1580
|
} | {
|
|
1579
1581
|
blockHash: `0x${string}` | null;
|
|
1580
1582
|
blockNumber: bigint | null;
|
|
@@ -2505,7 +2507,9 @@ declare const CHAINS: {
|
|
|
2505
2507
|
yParity: number;
|
|
2506
2508
|
l1BatchNumber: bigint | null;
|
|
2507
2509
|
l1BatchTxIndex: bigint | null;
|
|
2508
|
-
gasPrice
|
|
2510
|
+
gasPrice
|
|
2511
|
+
/** Known tokens on this chain (empty for unknown custom chains). */
|
|
2512
|
+
? /** Known tokens on this chain (empty for unknown custom chains). */: undefined | undefined;
|
|
2509
2513
|
maxFeePerBlobGas?: undefined | undefined;
|
|
2510
2514
|
maxFeePerGas: bigint;
|
|
2511
2515
|
maxPriorityFeePerGas: bigint;
|
|
@@ -3294,15 +3298,7 @@ declare const CHAINS: {
|
|
|
3294
3298
|
maxPriorityFeePerGas: bigint;
|
|
3295
3299
|
isSystemTx?: undefined | undefined;
|
|
3296
3300
|
mint?: undefined | undefined;
|
|
3297
|
-
sourceHash
|
|
3298
|
-
/**
|
|
3299
|
-
* Normalise a `ChainInput` (+ optional rpc override) into the
|
|
3300
|
-
* `{ chain, chainId, rpcUrl, tokens }` the wallet and verifier need.
|
|
3301
|
-
*/
|
|
3302
|
-
? /**
|
|
3303
|
-
* Normalise a `ChainInput` (+ optional rpc override) into the
|
|
3304
|
-
* `{ chain, chainId, rpcUrl, tokens }` the wallet and verifier need.
|
|
3305
|
-
*/: undefined | undefined;
|
|
3301
|
+
sourceHash?: undefined | undefined;
|
|
3306
3302
|
} | {
|
|
3307
3303
|
blockHash: `0x${string}` | null;
|
|
3308
3304
|
blockNumber: bigint | null;
|
|
@@ -3680,6 +3676,74 @@ declare const CHAINS: {
|
|
|
3680
3676
|
};
|
|
3681
3677
|
};
|
|
3682
3678
|
};
|
|
3679
|
+
/**
|
|
3680
|
+
* Robinhood Chain — Arbitrum Orbit L2 for tokenized equities, mainnet since 2026-07-01.
|
|
3681
|
+
* viem ships no preset for it (it is not in chainid.network either), so the chain is
|
|
3682
|
+
* defined inline from the values Robinhood publishes.
|
|
3683
|
+
*
|
|
3684
|
+
* ONE stablecoin on purpose: USDG, the Paxos-issued Global Dollar, which is the asset the
|
|
3685
|
+
* chain's own markets quote against. Circle does NOT issue native USDC here (verified
|
|
3686
|
+
* against Circle's contract list 2026-09-08), so no USDC/USDT preset ships — a bridged
|
|
3687
|
+
* one would break the "issuer-native only" token rule.
|
|
3688
|
+
*/
|
|
3689
|
+
robinhood: {
|
|
3690
|
+
chain: {
|
|
3691
|
+
blockExplorers: {
|
|
3692
|
+
readonly default: {
|
|
3693
|
+
readonly name: "Blockscout";
|
|
3694
|
+
readonly url: "https://robinhoodchain.blockscout.com";
|
|
3695
|
+
};
|
|
3696
|
+
};
|
|
3697
|
+
blockTime?: number | undefined | undefined;
|
|
3698
|
+
contracts?: {
|
|
3699
|
+
[x: string]: viem.ChainContract | {
|
|
3700
|
+
[sourceId: number]: viem.ChainContract | undefined;
|
|
3701
|
+
} | undefined;
|
|
3702
|
+
ensRegistry?: viem.ChainContract | undefined;
|
|
3703
|
+
ensUniversalResolver?: viem.ChainContract | undefined;
|
|
3704
|
+
multicall3?: viem.ChainContract | undefined;
|
|
3705
|
+
erc6492Verifier?: viem.ChainContract | undefined;
|
|
3706
|
+
} | undefined;
|
|
3707
|
+
ensTlds?: readonly string[] | undefined;
|
|
3708
|
+
id: 4663;
|
|
3709
|
+
name: "Robinhood Chain";
|
|
3710
|
+
nativeCurrency: {
|
|
3711
|
+
readonly name: "Ether";
|
|
3712
|
+
readonly symbol: "ETH";
|
|
3713
|
+
readonly decimals: 18;
|
|
3714
|
+
};
|
|
3715
|
+
experimental_preconfirmationTime?: number | undefined | undefined;
|
|
3716
|
+
rpcUrls: {
|
|
3717
|
+
readonly default: {
|
|
3718
|
+
readonly http: readonly ["https://rpc.mainnet.chain.robinhood.com"];
|
|
3719
|
+
};
|
|
3720
|
+
};
|
|
3721
|
+
sourceId?: number | undefined | undefined;
|
|
3722
|
+
testnet?: boolean | undefined | undefined;
|
|
3723
|
+
custom?: Record<string, unknown> | undefined;
|
|
3724
|
+
extendSchema?: Record<string, unknown> | undefined;
|
|
3725
|
+
fees?: viem.ChainFees<undefined> | undefined;
|
|
3726
|
+
formatters?: undefined;
|
|
3727
|
+
prepareTransactionRequest?: ((args: viem.PrepareTransactionRequestParameters, options: {
|
|
3728
|
+
client: viem.Client;
|
|
3729
|
+
phase: "beforeFillTransaction" | "beforeFillParameters" | "afterFillParameters";
|
|
3730
|
+
}) => Promise<viem.PrepareTransactionRequestParameters>) | [fn: ((args: viem.PrepareTransactionRequestParameters, options: {
|
|
3731
|
+
client: viem.Client;
|
|
3732
|
+
phase: "beforeFillTransaction" | "beforeFillParameters" | "afterFillParameters";
|
|
3733
|
+
}) => Promise<viem.PrepareTransactionRequestParameters>) | undefined, options: {
|
|
3734
|
+
runAt: readonly ("beforeFillTransaction" | "beforeFillParameters" | "afterFillParameters")[];
|
|
3735
|
+
}] | undefined;
|
|
3736
|
+
serializers?: viem.ChainSerializers<undefined, viem.TransactionSerializable> | undefined;
|
|
3737
|
+
verifyHash?: ((client: viem.Client, parameters: viem.VerifyHashActionParameters) => Promise<viem.VerifyHashActionReturnType>) | undefined;
|
|
3738
|
+
};
|
|
3739
|
+
tokens: {
|
|
3740
|
+
USDG: {
|
|
3741
|
+
address: "0x5fc5360D0400a0Fd4f2af552ADD042D716F1d168";
|
|
3742
|
+
decimals: number;
|
|
3743
|
+
symbol: string;
|
|
3744
|
+
};
|
|
3745
|
+
};
|
|
3746
|
+
};
|
|
3683
3747
|
};
|
|
3684
3748
|
/** A built-in EVM chain name. */
|
|
3685
3749
|
type ChainName = keyof typeof CHAINS;
|
|
@@ -3710,6 +3774,232 @@ interface ResolvedChain {
|
|
|
3710
3774
|
*/
|
|
3711
3775
|
declare function resolveChain(input: ChainInput, rpcUrlOverride?: string): ResolvedChain;
|
|
3712
3776
|
|
|
3777
|
+
/**
|
|
3778
|
+
* Swap — the OPTIONAL, opt-in helper for "I hold the wrong token".
|
|
3779
|
+
*
|
|
3780
|
+
* PROTOCOL LAYER — pure types + pure helpers, ZERO chain libraries (STANDARDS §1).
|
|
3781
|
+
* The work happens in the drivers, behind two OPTIONAL contract methods
|
|
3782
|
+
* (`quoteSwap?` / `swap?` on {@link ResolvedNetwork}), so a family that can't swap
|
|
3783
|
+
* simply doesn't implement them and nothing about it changes.
|
|
3784
|
+
*
|
|
3785
|
+
* ── WHY THIS EXISTS ────────────────────────────────────────────────────────────
|
|
3786
|
+
* A 402 names a token. A wallet holds what it holds. Today, holding XLM when the
|
|
3787
|
+
* invoice wants USDC is a dead end: `planPayment()` reports INSUFFICIENT_TOKEN and
|
|
3788
|
+
* stops. This turns that dead end into a suggestion the caller may act on — or
|
|
3789
|
+
* ignore entirely.
|
|
3790
|
+
*
|
|
3791
|
+
* ── IT IS NOT ON BY DEFAULT, AND IT NEVER WILL BE ──────────────────────────────
|
|
3792
|
+
* Nothing here runs unless you call it. `fetch()` never swaps. `planPayment()`
|
|
3793
|
+
* never swaps. There is no `autoSwap` flag, deliberately: moving one asset into
|
|
3794
|
+
* another is a priced, irreversible act, and it is not something a payment library
|
|
3795
|
+
* should ever do on your behalf because it noticed you were short. You ask, or it
|
|
3796
|
+
* doesn't happen. (STANDARDS §0: opt-in, defaults unchanged.)
|
|
3797
|
+
*
|
|
3798
|
+
* ── 🔴 PIPRAIL DOES NOT PRICE ANYTHING ─────────────────────────────────────────
|
|
3799
|
+
* STANDARDS §7 forbids a price oracle, and a swap rate IS a price. So every
|
|
3800
|
+
* {@link SwapQuote} carries a {@link SwapQuoteSource} naming WHO said it. PipRail
|
|
3801
|
+
* relays a rate; it never asserts one. Read `quote.source` before you trust a
|
|
3802
|
+
* number, exactly as you would read which facilitator settled a payment.
|
|
3803
|
+
*
|
|
3804
|
+
* Two tiers ship today, and the type system keeps them apart.
|
|
3805
|
+
*
|
|
3806
|
+
* **Tier 1, `kind: 'protocol'`** — the ledger itself swaps, so there is no third party
|
|
3807
|
+
* at all:
|
|
3808
|
+
*
|
|
3809
|
+
* - **Stellar** — a `PathPaymentStrictReceive` to your own account. One atomic
|
|
3810
|
+
* operation, routed by the **Stellar SDEX** across its order books and liquidity pools.
|
|
3811
|
+
* - **XRPL** — a cross-currency `Payment` to your own address (the ledger permits
|
|
3812
|
+
* `Account == Destination` precisely for currency conversion), routed by the
|
|
3813
|
+
* **XRPL DEX + AMM** across the order books and AMM pools, auto-bridging through XRP
|
|
3814
|
+
* when that is cheaper.
|
|
3815
|
+
*
|
|
3816
|
+
* Both are protocol primitives: no third-party contract, no router to approve, no
|
|
3817
|
+
* solver, no relayer, no API key, and no integrator fee, because there is nowhere to
|
|
3818
|
+
* put one. The funds never leave the user's own account.
|
|
3819
|
+
*
|
|
3820
|
+
* **Tier 2, `kind: 'provider'`** — a named third-party router, used because those
|
|
3821
|
+
* chains have no protocol-level swap:
|
|
3822
|
+
*
|
|
3823
|
+
* - **Solana** via **Jupiter**, verified keyless with `platformFee: null`.
|
|
3824
|
+
* - **EVM** (9 live-probed chains) via **KyberSwap**, verified keyless, no integrator fee.
|
|
3825
|
+
* - **Sui** via **Aftermath**, which returns a complete signable transaction block.
|
|
3826
|
+
* - **NEAR** via **Ref Finance**, chosen over Intents because Intents re-adds a facilitator.
|
|
3827
|
+
* - **Algorand** via **Vestige**, whose unsigned group names only you as a signer.
|
|
3828
|
+
* - **Aptos** via **Hyperion**, which publishes no API at all: the quote and the swap are
|
|
3829
|
+
* both Move calls straight to the router contract.
|
|
3830
|
+
* - **TON** via **STON.fi**, whose `reverse_swap` simulation fixes the ask side; the request
|
|
3831
|
+
* is padded so the router's on-chain floor is at least the invoice.
|
|
3832
|
+
* - **Tron** via **SunSwap V2**, also called contract-to-contract with no API.
|
|
3833
|
+
*
|
|
3834
|
+
* The first five were adopted only after a plain server-side request returned HTTP 200 with
|
|
3835
|
+
* no key. The last three need no request at all, because they are read straight off the
|
|
3836
|
+
* chain. 0x, 1inch, Odos, OpenOcean, Squid, Rango and thirdweb Bridge all failed that bar
|
|
3837
|
+
* and were rejected. PipRail never sets a platform or integrator fee field on any provider,
|
|
3838
|
+
* so it takes nothing on top, ever.
|
|
3839
|
+
*
|
|
3840
|
+
* ⭐ **Three of them are exact-output natively.** Hyperion, STON.fi and SunSwap V2 take the
|
|
3841
|
+
* invoice amount as the OUTPUT and cap the input on-chain, which is the exact shape of an
|
|
3842
|
+
* x402 quote. Every other route prices an exact input, so the amount is probed and scaled.
|
|
3843
|
+
*/
|
|
3844
|
+
|
|
3845
|
+
/**
|
|
3846
|
+
* WHO produced a rate. PipRail never asserts a price of its own, so this is
|
|
3847
|
+
* REQUIRED on every quote — there is no anonymous number in this module.
|
|
3848
|
+
*
|
|
3849
|
+
* - `'protocol'` — the chain's own DEX decided it (Stellar SDEX, XRPL order books
|
|
3850
|
+
* + AMM). No company is involved and no fee is taken by anyone but the pool.
|
|
3851
|
+
* - `'provider'` — a named third party quoted it. Judge it as you would a
|
|
3852
|
+
* facilitator: it can be down, it can be wrong, and it may take a cut.
|
|
3853
|
+
*/
|
|
3854
|
+
interface SwapQuoteSource {
|
|
3855
|
+
kind: 'protocol' | 'provider';
|
|
3856
|
+
/** Human name, e.g. `'Stellar SDEX'`, `'XRPL DEX + AMM'`. */
|
|
3857
|
+
name: string;
|
|
3858
|
+
/** Anything the caller should know before trusting the rate (pool fees, caveats). */
|
|
3859
|
+
note?: string;
|
|
3860
|
+
}
|
|
3861
|
+
/** One side of a swap, in both machine and human units. */
|
|
3862
|
+
interface SwapSide {
|
|
3863
|
+
/** Driver-native asset id (`'native'`, `'USDC:GA5Z…'`, an XRPL `CODE.issuer`). */
|
|
3864
|
+
asset: string;
|
|
3865
|
+
symbol: string;
|
|
3866
|
+
decimals: number;
|
|
3867
|
+
/** Base units. */
|
|
3868
|
+
amount: string;
|
|
3869
|
+
/** Human units, for display and for an LLM to reason about. */
|
|
3870
|
+
amountFormatted: string;
|
|
3871
|
+
}
|
|
3872
|
+
/** What you want swapped. Shaped for the x402 case: an invoice names an exact price. */
|
|
3873
|
+
interface SwapRequest {
|
|
3874
|
+
/** The token you HOLD and are willing to spend. */
|
|
3875
|
+
from: TokenInput;
|
|
3876
|
+
/** The token you NEED. */
|
|
3877
|
+
to: TokenInput;
|
|
3878
|
+
/**
|
|
3879
|
+
* How much of `to` you need, in human units (e.g. `'0.50'`). Exact-output, because
|
|
3880
|
+
* that is the shape of an invoice: the amount owed is fixed and the cost floats.
|
|
3881
|
+
*/
|
|
3882
|
+
wantAmount: string;
|
|
3883
|
+
/**
|
|
3884
|
+
* Slippage tolerance in basis points, applied to the INPUT side as a hard on-chain
|
|
3885
|
+
* cap (Stellar `sendMax`, XRPL `SendMax`). Default {@link DEFAULT_SLIPPAGE_BPS}.
|
|
3886
|
+
* The cap is enforced by the validators, not by this library: if the market moves
|
|
3887
|
+
* past it the transaction fails rather than overspending.
|
|
3888
|
+
*/
|
|
3889
|
+
slippageBps?: number;
|
|
3890
|
+
}
|
|
3891
|
+
/**
|
|
3892
|
+
* ── AGENT MODE: who is answerable for this wallet ───────────────────────────────────
|
|
3893
|
+
*
|
|
3894
|
+
* The capability an AI agent gets used to depend on which PACKAGE it imported: a model
|
|
3895
|
+
* driving `@piprail/mcp` could never swap, while the same wallet driven through the SDK
|
|
3896
|
+
* could. That is the wrong axis. Whether an agent may move its own funds between
|
|
3897
|
+
* denominations is a question about AUTHORITY, not transport.
|
|
3898
|
+
*
|
|
3899
|
+
* So it is declared, once, by whoever provisions the key:
|
|
3900
|
+
*
|
|
3901
|
+
* - `'supervised'` — a human approves each payment at the moment of spend. The human is
|
|
3902
|
+
* the policy. (MCP: `PIPRAIL_CONFIRM=1`.)
|
|
3903
|
+
* - `'budgeted'` — **the default.** The `policy` IS the consent: the agent runs free
|
|
3904
|
+
* inside caps it cannot exceed, with no per-payment prompt. Swapping is withheld,
|
|
3905
|
+
* because every cap counts PAYMENTS and a swap is not one.
|
|
3906
|
+
* - `'sovereign'` — the agent owns the wallet and answers for it. Swapping is unlocked,
|
|
3907
|
+
* governed by {@link SwapPolicy} rather than by the payment caps.
|
|
3908
|
+
*
|
|
3909
|
+
* 🔴 **A model can never set its own mode.** It is read at construction from the
|
|
3910
|
+
* environment the operator controls, exactly as an agent cannot grant itself broader
|
|
3911
|
+
* permissions in its host. `client.mode()` reads it back; nothing writes it.
|
|
3912
|
+
*
|
|
3913
|
+
* 🔴 **Sovereign does not mean unguarded.** It means guarded by the RIGHT instrument.
|
|
3914
|
+
* A payment cap cannot bound a swap, so sovereignty ships with `swapPolicy` instead:
|
|
3915
|
+
* a ceiling on what one swap may spend and on the slippage it may accept. Unlocking the
|
|
3916
|
+
* capability without that would repeat the exact mistake the withholding avoided.
|
|
3917
|
+
*
|
|
3918
|
+
* Defaults are unchanged (STANDARDS §0): omit `mode` and everything behaves byte-for-byte
|
|
3919
|
+
* as before, with the same eight tools.
|
|
3920
|
+
*/
|
|
3921
|
+
type AgentMode = 'supervised' | 'budgeted' | 'sovereign';
|
|
3922
|
+
/** The default. Named, so the fallback is never an unexplained string literal. */
|
|
3923
|
+
declare const DEFAULT_AGENT_MODE: AgentMode;
|
|
3924
|
+
/** Every valid mode, for validation and for surfaces that enumerate them. */
|
|
3925
|
+
declare const AGENT_MODES: readonly AgentMode[];
|
|
3926
|
+
/**
|
|
3927
|
+
* Guardrails for SWAPPING, the instrument the payment policy cannot be.
|
|
3928
|
+
*
|
|
3929
|
+
* A payment cap counts money leaving for a merchant. A swap moves your own funds between
|
|
3930
|
+
* denominations, so it passes every such cap untouched: a loop of USDC → SOL → USDC bleeds
|
|
3931
|
+
* the pool fee each time while the ledger records no spend at all. These bound the two
|
|
3932
|
+
* things that actually leak value on that path.
|
|
3933
|
+
*/
|
|
3934
|
+
interface SwapPolicy {
|
|
3935
|
+
/**
|
|
3936
|
+
* The most one swap may SPEND, in human units of the token being sold (e.g. `'25.00'`).
|
|
3937
|
+
* Compared against the quote's on-chain ceiling (`maxSpend`), never the estimate, so a
|
|
3938
|
+
* route that moves against you cannot slip past it.
|
|
3939
|
+
*/
|
|
3940
|
+
maxPerSwap?: string;
|
|
3941
|
+
/**
|
|
3942
|
+
* The worst slippage this agent may accept, in basis points. Caps the tolerance a
|
|
3943
|
+
* caller (or a model) may ask for; a request above it is refused rather than clamped,
|
|
3944
|
+
* because silently tightening a number somebody chose is its own surprise.
|
|
3945
|
+
*/
|
|
3946
|
+
maxSlippageBps?: number;
|
|
3947
|
+
/**
|
|
3948
|
+
* Optional allowlist of token symbols this agent may swap into. Omit for no restriction.
|
|
3949
|
+
* Useful for "may consolidate into USDC, may not take a position in anything else".
|
|
3950
|
+
*/
|
|
3951
|
+
allowTo?: readonly string[];
|
|
3952
|
+
}
|
|
3953
|
+
/** A priced, executable swap. Read `source` before trusting `maxSpend`. */
|
|
3954
|
+
interface SwapQuote {
|
|
3955
|
+
/** 🔴 WHO said this rate. Never absent. */
|
|
3956
|
+
source: SwapQuoteSource;
|
|
3957
|
+
network: Caip2;
|
|
3958
|
+
/** What you'd spend at the quoted rate. */
|
|
3959
|
+
from: SwapSide;
|
|
3960
|
+
/** What you'd receive — exactly `wantAmount`, since these rails are exact-output. */
|
|
3961
|
+
to: SwapSide;
|
|
3962
|
+
/** The most you can possibly spend, base units. Enforced ON-CHAIN, not here. */
|
|
3963
|
+
maxSpend: string;
|
|
3964
|
+
maxSpendFormatted: string;
|
|
3965
|
+
slippageBps: number;
|
|
3966
|
+
/**
|
|
3967
|
+
* Opaque routing data the driver needs to execute (a Stellar path, an XRPL
|
|
3968
|
+
* `Paths` array). Treat it as a token: pass it back, never interpret it.
|
|
3969
|
+
*/
|
|
3970
|
+
route: unknown;
|
|
3971
|
+
}
|
|
3972
|
+
/** Proof that a swap settled. */
|
|
3973
|
+
interface SwapReceipt {
|
|
3974
|
+
/** Tx hash / ledger ref, the same shape a payment receipt uses. */
|
|
3975
|
+
transaction: string;
|
|
3976
|
+
network: Caip2;
|
|
3977
|
+
source: SwapQuoteSource;
|
|
3978
|
+
/** What actually left the wallet, when the chain reports it; else the quote. */
|
|
3979
|
+
from: SwapSide;
|
|
3980
|
+
to: SwapSide;
|
|
3981
|
+
}
|
|
3982
|
+
/** Default slippage tolerance: 0.5%. Conservative, and overridable per request. */
|
|
3983
|
+
declare const DEFAULT_SLIPPAGE_BPS = 50;
|
|
3984
|
+
/** Basis-point ceiling. 10% — past this, a "swap" is a donation to an arbitrageur. */
|
|
3985
|
+
declare const MAX_SLIPPAGE_BPS = 1000;
|
|
3986
|
+
/**
|
|
3987
|
+
* Validate and default a slippage setting. Pure. Throws {@link RangeError} rather
|
|
3988
|
+
* than a `PipRailError` because this is a programming mistake in the caller's own
|
|
3989
|
+
* arguments, not a payment condition — see ERRORS.md §1.
|
|
3990
|
+
*/
|
|
3991
|
+
declare function resolveSlippageBps(bps: number | undefined): number;
|
|
3992
|
+
/**
|
|
3993
|
+
* Apply a slippage tolerance to an input amount, rounding UP so the on-chain cap is
|
|
3994
|
+
* never tighter than asked for. Pure integer maths — no floats anywhere near money.
|
|
3995
|
+
*/
|
|
3996
|
+
declare function applySlippage(amount: bigint, bps: number): bigint;
|
|
3997
|
+
/**
|
|
3998
|
+
* One human sentence describing a quote, for a log line or an LLM. Always names the
|
|
3999
|
+
* source, so the "who priced this?" question is answered wherever the quote is shown.
|
|
4000
|
+
*/
|
|
4001
|
+
declare function summarizeSwap(q: SwapQuote): string;
|
|
4002
|
+
|
|
3713
4003
|
/**
|
|
3714
4004
|
* The PaymentDriver contract. Every chain-family section (EVM, Solana, …)
|
|
3715
4005
|
* implements this and nothing else; the protocol layer (server/client/x402)
|
|
@@ -3968,6 +4258,20 @@ interface ResolvedNetwork {
|
|
|
3968
4258
|
assertValidPayTo(payTo: string): void;
|
|
3969
4259
|
/** Validate + wrap the user's wallet config for this family. */
|
|
3970
4260
|
bindWallet(wallet: unknown): WalletHandle;
|
|
4261
|
+
/**
|
|
4262
|
+
* The bound wallet's OWN address, in this family's canonical form — the answer to
|
|
4263
|
+
* "where do I get paid?".
|
|
4264
|
+
*
|
|
4265
|
+
* Every driver already derives this internally for {@link ResolvedNetwork.balanceOf};
|
|
4266
|
+
* exposing it is what lets a wallet holder RECEIVE rather than only spend. An agent
|
|
4267
|
+
* handed a key it never chose has no other way to learn its own address, so without
|
|
4268
|
+
* this it can pay for things but can never be paid for anything.
|
|
4269
|
+
*
|
|
4270
|
+
* Async only because TON must build the wallet contract before it has an address;
|
|
4271
|
+
* every other family derives it synchronously from the key. Pure — derives from the
|
|
4272
|
+
* key material, reads no RPC, moves nothing.
|
|
4273
|
+
*/
|
|
4274
|
+
addressOf(wallet: WalletHandle): Promise<string>;
|
|
3971
4275
|
/** Broadcast payment for `accept`; return the proof ref (tx hash / signature). */
|
|
3972
4276
|
send(wallet: WalletHandle, accept: X402AcceptEntry): Promise<string>;
|
|
3973
4277
|
/** Wait until `ref` reaches minConfirmations (or finality). */
|
|
@@ -4202,6 +4506,42 @@ interface ResolvedNetwork {
|
|
|
4202
4506
|
accept: X402UptoAcceptEntry;
|
|
4203
4507
|
settleAmount: bigint;
|
|
4204
4508
|
}): Promise<VerifyResult>;
|
|
4509
|
+
/**
|
|
4510
|
+
* Price a same-chain swap — "I hold the wrong token". READ-ONLY: no funds move,
|
|
4511
|
+
* nothing is signed.
|
|
4512
|
+
*
|
|
4513
|
+
* OPTIONAL, like every method above it: a family that can't swap omits both this
|
|
4514
|
+
* and {@link ResolvedNetwork.swap}, and the client reports that honestly instead
|
|
4515
|
+
* of pretending. Implemented today where swapping is a PROTOCOL PRIMITIVE —
|
|
4516
|
+
* Stellar path payments and the XRPL DEX/AMM — so no third party, no API key and
|
|
4517
|
+
* no extra dependency is involved.
|
|
4518
|
+
*
|
|
4519
|
+
* NEVER THROWS for a read problem (same posture as `estimateCost`/`balanceOf`):
|
|
4520
|
+
* returns `null` when this pair can't be routed, the market has no liquidity, or
|
|
4521
|
+
* the RPC read failed. `null` means "no quote", never "no funds".
|
|
4522
|
+
*
|
|
4523
|
+
* 🔴 The returned rate is NOT PipRail's opinion — `quote.source` names who
|
|
4524
|
+
* produced it (STANDARDS §7: no price oracle, ever).
|
|
4525
|
+
*/
|
|
4526
|
+
quoteSwap?(input: {
|
|
4527
|
+
from: ResolvedToken;
|
|
4528
|
+
to: ResolvedToken;
|
|
4529
|
+
/** Exact output wanted, base units. */
|
|
4530
|
+
wantAmount: bigint;
|
|
4531
|
+
slippageBps: number;
|
|
4532
|
+
/** The wallet that would swap — the driver derives its own address from it. */
|
|
4533
|
+
wallet: WalletHandle;
|
|
4534
|
+
}): Promise<SwapQuote | null>;
|
|
4535
|
+
/**
|
|
4536
|
+
* Execute a swap the caller has already seen and accepted. Signs and broadcasts
|
|
4537
|
+
* one transaction from the user's OWN wallet; the funds never leave their account
|
|
4538
|
+
* (both rails today are a self-transfer that changes denomination).
|
|
4539
|
+
*
|
|
4540
|
+
* Throws {@link InsufficientFundsError} when the wallet can't cover `maxSpend`,
|
|
4541
|
+
* per ERRORS.md §5. The slippage cap rides ON-CHAIN inside the transaction, so a
|
|
4542
|
+
* market that moves past it fails the transaction rather than overspending.
|
|
4543
|
+
*/
|
|
4544
|
+
swap?(wallet: WalletHandle, quote: SwapQuote): Promise<SwapReceipt>;
|
|
4205
4545
|
}
|
|
4206
4546
|
interface ResolveOptions {
|
|
4207
4547
|
/** The developer-supplied `chain` selector. */
|
|
@@ -5392,6 +5732,18 @@ interface PipRailClientOptions {
|
|
|
5392
5732
|
* (unguarded) default. See {@link PaymentPolicy}.
|
|
5393
5733
|
*/
|
|
5394
5734
|
policy?: PaymentPolicy;
|
|
5735
|
+
/**
|
|
5736
|
+
* Who is answerable for this wallet. Default `'budgeted'`, which is byte-identical to
|
|
5737
|
+
* every release before modes existed. Set `'sovereign'` only when the agent OWNS these
|
|
5738
|
+
* funds: it unlocks the swap tools for a model, governed by {@link swapPolicy}. A model
|
|
5739
|
+
* can never set this for itself. See {@link AgentMode}.
|
|
5740
|
+
*/
|
|
5741
|
+
mode?: AgentMode;
|
|
5742
|
+
/**
|
|
5743
|
+
* Guardrails for swapping, used in `'sovereign'` mode. A payment cap counts money going
|
|
5744
|
+
* to a merchant and cannot bound a swap, so this bounds it instead. See {@link SwapPolicy}.
|
|
5745
|
+
*/
|
|
5746
|
+
swapPolicy?: SwapPolicy;
|
|
5395
5747
|
/**
|
|
5396
5748
|
* Final approval hook, called with the {@link PipRailQuote} after the policy
|
|
5397
5749
|
* passes but before paying. Return `false` (or a rejected promise resolving
|
|
@@ -5399,6 +5751,21 @@ interface PipRailClientOptions {
|
|
|
5399
5751
|
* funds move. Use for human-in-the-loop or custom per-payment logic.
|
|
5400
5752
|
*/
|
|
5401
5753
|
onBeforePay?: (quote: PipRailQuote) => boolean | Promise<boolean>;
|
|
5754
|
+
/**
|
|
5755
|
+
* Approve (or refuse) a SWAP before anything is signed — the swap-side twin of
|
|
5756
|
+
* {@link PipRailClientOptions.onBeforePay}.
|
|
5757
|
+
*
|
|
5758
|
+
* It exists because `onBeforePay` genuinely does not cover swaps: a swap is not a payment,
|
|
5759
|
+
* which is the whole reason `swapPolicy` bounds it instead. But an operator who wired an
|
|
5760
|
+
* approver did not mean "ask me before payments and let value move silently any other way",
|
|
5761
|
+
* and a supervised sovereign agent could swap its whole balance without the human seeing one
|
|
5762
|
+
* prompt. Same fail-safe contract as `onBeforePay`: `false` or a throw refuses, and the
|
|
5763
|
+
* refusal arrives as a {@link PaymentDeclinedError} with `reasonCode: 'APPROVAL'`.
|
|
5764
|
+
*
|
|
5765
|
+
* `@piprail/mcp` wires this alongside `onBeforePay` whenever confirmation is on, so an
|
|
5766
|
+
* operator gets it without asking.
|
|
5767
|
+
*/
|
|
5768
|
+
onBeforeSwap?: (quote: SwapQuote) => boolean | Promise<boolean>;
|
|
5402
5769
|
/**
|
|
5403
5770
|
* After paying, how many times to re-send the request with proof before
|
|
5404
5771
|
* giving up. Default 3, with a short backoff between attempts — this
|
|
@@ -5581,6 +5948,41 @@ interface PayingClient {
|
|
|
5581
5948
|
/** The CONFIGURED spend policy, read back (so an agent can self-check its whole leash
|
|
5582
5949
|
* without hitting a decline). `undefined` when no policy is set. */
|
|
5583
5950
|
policy(): PaymentPolicy | undefined;
|
|
5951
|
+
/** Who is answerable for this wallet. Absent means the default, `'budgeted'`. */
|
|
5952
|
+
mode?(): AgentMode;
|
|
5953
|
+
/** May a MODEL swap on this wallet? True only in `'sovereign'` mode. */
|
|
5954
|
+
canAgentSwap?(): boolean;
|
|
5955
|
+
/** Price a same-chain swap, read-only. Never throws for a read problem. */
|
|
5956
|
+
quoteSwap?(req: SwapRequest): Promise<SwapQuote | null>;
|
|
5957
|
+
/** Execute a quoted swap. Governed by `swapPolicy`, not by the payment caps. */
|
|
5958
|
+
swap?(quote: SwapQuote): Promise<SwapReceipt>;
|
|
5959
|
+
/** This wallet's own address — where it gets paid. `paymentTools()` defaults a
|
|
5960
|
+
* sold offer's `payTo` to it, so an agent never has to be told its own address. */
|
|
5961
|
+
address?(): Promise<string>;
|
|
5962
|
+
/** May a MODEL sell on this wallet — price offers and collect for them? Sovereign only. */
|
|
5963
|
+
canAgentSell?(): boolean;
|
|
5964
|
+
/** The chain this client is configured for — the default an offer is priced on. */
|
|
5965
|
+
chain?(): ChainSelector;
|
|
5966
|
+
/** What this wallet HOLDS, per asset — the balance sheet, distinct from the budget leash. */
|
|
5967
|
+
balanceOf?(assets?: readonly string[]): Promise<WalletAssetBalance[]>;
|
|
5968
|
+
}
|
|
5969
|
+
/**
|
|
5970
|
+
* One asset's holding, as {@link PipRailClient.balanceOf} reports it. A `null` amount means the
|
|
5971
|
+
* read was UNAVAILABLE, never zero: an agent has to tell "I hold nothing" apart from "I could
|
|
5972
|
+
* not find out", because acting on the second as if it were the first looks exactly like having
|
|
5973
|
+
* been drained.
|
|
5974
|
+
*/
|
|
5975
|
+
interface WalletAssetBalance {
|
|
5976
|
+
/** The symbol as the chain resolved it, or as asked for when the chain does not ship it. */
|
|
5977
|
+
symbol: string;
|
|
5978
|
+
/** The on-chain asset id, or `null` when this chain has no such token. */
|
|
5979
|
+
asset: string | null;
|
|
5980
|
+
decimals: number | null;
|
|
5981
|
+
/** False when this chain does not ship this symbol. Reported, never guessed at. */
|
|
5982
|
+
known: boolean;
|
|
5983
|
+
/** Base units, or `null` when the read was unavailable. */
|
|
5984
|
+
amount: string | null;
|
|
5985
|
+
amountFormatted: string | null;
|
|
5584
5986
|
}
|
|
5585
5987
|
/**
|
|
5586
5988
|
* The verdict from {@link PipRailClient.verifyReceipt} — a {@link PipRailReceipt}
|
|
@@ -5744,10 +6146,79 @@ declare class PipRailClient {
|
|
|
5744
6146
|
* count, cumulative spend per token, cumulative spend per denomination (the
|
|
5745
6147
|
* cross-token grand total), and the individual records. */
|
|
5746
6148
|
spent(): SpendSummary;
|
|
6149
|
+
/**
|
|
6150
|
+
* Each mode must be able to KEEP its promise, checked once at construction.
|
|
6151
|
+
*
|
|
6152
|
+
* `'supervised'` means a human approves each payment, and the only thing that can pause a
|
|
6153
|
+
* payment for a human is `onBeforePay`. Without it the mode was a label: the client happily
|
|
6154
|
+
* paid without asking anyone, while the name, the docs and the operator's mental model all
|
|
6155
|
+
* said otherwise. A safety control that silently does nothing is worse than an absent one,
|
|
6156
|
+
* because the operator has already stopped worrying about it.
|
|
6157
|
+
*
|
|
6158
|
+
* The mirror of the sovereign rule, which refuses to unlock swapping without a ceiling. Both
|
|
6159
|
+
* fail at CONSTRUCTION rather than at the first payment, so the mistake surfaces while
|
|
6160
|
+
* somebody is reading their own config instead of mid-spend.
|
|
6161
|
+
*/
|
|
6162
|
+
private assertModeIsHonest;
|
|
5747
6163
|
/** The CONFIGURED spend policy, read back unchanged — so an agent can self-check
|
|
5748
6164
|
* its WHOLE leash (caps, allowlists, time, denom + count limits) without hitting a
|
|
5749
6165
|
* decline. `undefined` when no policy is set. Pure; never throws. */
|
|
5750
6166
|
policy(): PaymentPolicy | undefined;
|
|
6167
|
+
/**
|
|
6168
|
+
* Who is answerable for this wallet: `'supervised'`, `'budgeted'` (default) or
|
|
6169
|
+
* `'sovereign'`. READ-ONLY on purpose. A model asks what authority it has; it can
|
|
6170
|
+
* never grant itself more, exactly as an agent cannot widen its own permissions in
|
|
6171
|
+
* its host. Set once at construction by whoever provisioned the key.
|
|
6172
|
+
*/
|
|
6173
|
+
mode(): AgentMode;
|
|
6174
|
+
/** The configured swap guardrails, read back unchanged. `undefined` when none is set. */
|
|
6175
|
+
swapPolicy(): SwapPolicy | undefined;
|
|
6176
|
+
/**
|
|
6177
|
+
* This wallet's OWN address — where it gets paid.
|
|
6178
|
+
*
|
|
6179
|
+
* The receiving half of a wallet, and the one thing an agent handed a key cannot work
|
|
6180
|
+
* out for itself: the key is set by whoever provisioned it, so without this the agent
|
|
6181
|
+
* can spend but can never tell a buyer where to send anything. `sell` defaults its
|
|
6182
|
+
* `payTo` to exactly this.
|
|
6183
|
+
*
|
|
6184
|
+
* Derived from the key, not the network — no RPC read, nothing moved. Throws
|
|
6185
|
+
* {@link WalletRequiredError} on a read-only client (no wallet, no address).
|
|
6186
|
+
*/
|
|
6187
|
+
/** The chain this client is configured for, exactly as it was given. A sold offer
|
|
6188
|
+
* defaults to it, so an agent prices on the chain it actually holds funds on. */
|
|
6189
|
+
chain(): ChainSelector;
|
|
6190
|
+
/**
|
|
6191
|
+
* What this wallet actually HOLDS, per asset — the balance sheet, not the leash.
|
|
6192
|
+
*
|
|
6193
|
+
* `budget()` answers "how much of my allowance is left", a different question and the only
|
|
6194
|
+
* one an agent could previously ask. An agent that OWNS a wallet has to answer "what do I
|
|
6195
|
+
* have?" before it can decide anything: whether to sell, whether to swap, whether it needs
|
|
6196
|
+
* topping up and in which denomination.
|
|
6197
|
+
*
|
|
6198
|
+
* RPC-read-only and never throws for a read problem: an asset whose read was unavailable
|
|
6199
|
+
* comes back `null` (unknown), never `0`, because a rate-limited read that reads as "broke"
|
|
6200
|
+
* would make an agent behave as though it had been drained. A symbol this chain does not ship
|
|
6201
|
+
* is reported as unknown rather than guessed at.
|
|
6202
|
+
*/
|
|
6203
|
+
balanceOf(assets?: readonly string[]): Promise<WalletAssetBalance[]>;
|
|
6204
|
+
address(): Promise<string>;
|
|
6205
|
+
/**
|
|
6206
|
+
* May a model SELL on this wallet — price its own offers and collect payment for them?
|
|
6207
|
+
* True only in `'sovereign'` mode, the same authority test as {@link canAgentSwap}:
|
|
6208
|
+
* earning is the other half of owning a wallet, and an agent that answers for its own
|
|
6209
|
+
* balance answers for how that balance is filled.
|
|
6210
|
+
*
|
|
6211
|
+
* Taking money is not the risk that gates this. Committing to DELIVER something is, and
|
|
6212
|
+
* so is publishing an address as an open invitation to pay it — neither is a supervised
|
|
6213
|
+
* agent's call to make alone.
|
|
6214
|
+
*/
|
|
6215
|
+
canAgentSell(): boolean;
|
|
6216
|
+
/**
|
|
6217
|
+
* May a model move this wallet's own funds between denominations? True only in
|
|
6218
|
+
* `'sovereign'` mode. The payment tools consult this, so the answer lives in ONE place
|
|
6219
|
+
* rather than being re-derived by every surface that asks.
|
|
6220
|
+
*/
|
|
6221
|
+
canAgentSwap(): boolean;
|
|
5751
6222
|
/**
|
|
5752
6223
|
* Read-only budget + time leash for a Mode-A (headless) agent — the policy IS
|
|
5753
6224
|
* the consent, and this is how the agent SEES what's left of it before paying.
|
|
@@ -5807,6 +6278,43 @@ declare class PipRailClient {
|
|
|
5807
6278
|
* resource is trivially "affordable"). No funds move.
|
|
5808
6279
|
*/
|
|
5809
6280
|
canAfford(url: string, init?: RequestInit): Promise<boolean>;
|
|
6281
|
+
/**
|
|
6282
|
+
* Price a same-chain swap — "I hold the wrong token". READ-ONLY: no funds move,
|
|
6283
|
+
* nothing is signed, nothing is committed to.
|
|
6284
|
+
*
|
|
6285
|
+
* ⚠️ **This is a convenience, not part of paying.** Nothing calls it for you.
|
|
6286
|
+
* `fetch()` never swaps, `planPayment()` never swaps, and there is deliberately no
|
|
6287
|
+
* `autoSwap` option: converting one asset into another is a priced, irreversible
|
|
6288
|
+
* act, and a payment library should not do that on your behalf because it noticed
|
|
6289
|
+
* you were short. If you would rather bridge or swap somewhere else entirely, or
|
|
6290
|
+
* just top the wallet up by hand, that is a perfectly good answer and this method
|
|
6291
|
+
* costs you nothing by existing.
|
|
6292
|
+
*
|
|
6293
|
+
* 🔴 **The rate is not PipRail's.** Read `quote.source` — it names who produced the
|
|
6294
|
+
* number. Today both implementations are `kind: 'protocol'`, meaning the chain's
|
|
6295
|
+
* own order books priced it and no company is involved.
|
|
6296
|
+
*
|
|
6297
|
+
* Returns `null` — never throws — when this chain has no swap support, the pair
|
|
6298
|
+
* can't be routed, there's no liquidity, or a read failed. `null` means "no quote",
|
|
6299
|
+
* never "no funds".
|
|
6300
|
+
*/
|
|
6301
|
+
quoteSwap(req: SwapRequest): Promise<SwapQuote | null>;
|
|
6302
|
+
/**
|
|
6303
|
+
* Execute a swap you have already quoted and chosen to accept. Signs from your own
|
|
6304
|
+
* wallet (one transaction, or two where a token must be approved first); on every route
|
|
6305
|
+
* the funds never leave your account, they just change denomination.
|
|
6306
|
+
*
|
|
6307
|
+
* Pass the {@link SwapQuote} from {@link quoteSwap} unmodified — it carries the
|
|
6308
|
+
* route and the on-chain slippage cap. Re-quote rather than reusing an old one: a
|
|
6309
|
+
* stale route is how you get a worse price than you were shown.
|
|
6310
|
+
*
|
|
6311
|
+
* Throws {@link WalletRequiredError} without a wallet, {@link UnsupportedNetworkError}
|
|
6312
|
+
* when the chain has no swap support, and {@link InsufficientFundsError} when the
|
|
6313
|
+
* wallet can't cover it (which includes the market moving past your slippage cap —
|
|
6314
|
+
* nothing is swapped in that case, though chains that charge for a reverted
|
|
6315
|
+
* transaction, such as EVM, Aptos and Tron, still take the gas).
|
|
6316
|
+
*/
|
|
6317
|
+
swap(quote: SwapQuote): Promise<SwapReceipt>;
|
|
5810
6318
|
/**
|
|
5811
6319
|
* Find payable resources on the OPEN x402 indexes — WITHOUT paying. Reads the
|
|
5812
6320
|
* free indexes (CDP Bazaar + 402 Index by default), merges + dedupes them, and
|
|
@@ -6214,6 +6722,19 @@ declare class MultiChainPayer implements PayingClient {
|
|
|
6214
6722
|
/** The CONFIGURED spend policy (the shared policy `fromWallets` applies to every chain;
|
|
6215
6723
|
* the first client's for the explicit constructor). `undefined` when none is set. */
|
|
6216
6724
|
policy(): PaymentPolicy | undefined;
|
|
6725
|
+
mode(): AgentMode;
|
|
6726
|
+
canAgentSwap(): boolean;
|
|
6727
|
+
canAgentSell(): boolean;
|
|
6728
|
+
address(): Promise<string>;
|
|
6729
|
+
chain(): ChainSelector;
|
|
6730
|
+
/**
|
|
6731
|
+
* Holdings across EVERY chain this payer owns, not just the primary. A multi-chain agent's
|
|
6732
|
+
* balance sheet is the union: reporting only the first chain would tell it it was broke while
|
|
6733
|
+
* it held funds one client along, which is exactly the wrong answer to "what do I have?".
|
|
6734
|
+
*/
|
|
6735
|
+
balanceOf(assets?: readonly string[]): Promise<WalletAssetBalance[]>;
|
|
6736
|
+
quoteSwap(req: SwapRequest): Promise<SwapQuote | null>;
|
|
6737
|
+
swap(quote: SwapQuote): Promise<SwapReceipt>;
|
|
6217
6738
|
}
|
|
6218
6739
|
|
|
6219
6740
|
/**
|
|
@@ -6320,7 +6841,7 @@ declare function describeChallenge(challenge: X402Challenge): string;
|
|
|
6320
6841
|
* literally, so a wrong name or order actively misleads. A test pins the load-
|
|
6321
6842
|
* bearing phrases.
|
|
6322
6843
|
*/
|
|
6323
|
-
declare const PIPRAIL_AGENT_GUIDE = "# Paying with PipRail \u2014 the agent contract\n\nYou can pay for x402 \"402 Payment Required\" resources autonomously. Money moves\nstraight from your wallet to the server; PipRail custodies nothing. Follow this.\n\n## Landing cold \u2014 read the self-description\nEvery PipRail 402 self-describes. Read challenge.extensions.piprail for { name, what, pay[]\n(each rail's how-to-pay), sdk.install, mcp, docs } \u2014 never guess what an endpoint is. If your\ntooling can't pay a rail (e.g. a stock x402 client can't pay the onchain-proof scheme), the\nblock says how: install @piprail/sdk (npm i @piprail/sdk) or run the MCP (npx -y @piprail/mcp)\nand pay with the tools below.\n\n## The loop: quote \u2192 plan \u2192 pay\n1. piprail_quote_payment(url) \u2014 PRICE it. Returns the amount, token, chain, and\n whether it is within your spend policy. No funds move. Use it to decide if a\n resource is worth buying.\n2. piprail_plan_payment(url) \u2014 can I afford it NOW? Reads your balance, native gas,\n and recipient-readiness across every rail, and returns { payable, best,\n fundingHint, session? }. If payable is false, do NOT attempt the payment \u2014\n fundingHint says exactly what to fix.\n3. piprail_pay_request(url, method?, body?) \u2014 PAY (only if the plan was payable)\n and return the result.\nAlways plan before you pay so you never commit to a payment you cannot finish.\n\n## Gasless \u2014 the exact rail (zero gas for you)\nA 402 may offer up to three rails; you don't choose per payment \u2014 the client does, automatically:\n- onchain-proof (PipRail's default): you broadcast the payment yourself and pay the network gas\n (the native coin \u2014 ETH/SOL/\u2026). Works on every chain.\n- exact (the ratified x402 rail, opt-in): you only SIGN; the server \u2014 or a facilitator it chose\n (e.g. PayAI) \u2014 broadcasts it, so you pay ZERO gas (you need only the token, no native coin). It\n works on EVM, Solana, Algorand, Aptos + NEAR, and the on-chain method (EIP-3009 / Permit2 / SVM /\n Algorand fee-pooled group / Aptos fee-payer / NEAR SignedDelegateAction) is picked automatically.\n XRPL also supports exact (native XRP), with ONE difference that matters to your budget: there the\n PAYER pays the network fee, because on the XRP Ledger the fee lives inside the signed transaction.\n So keep a little XRP for fees on that chain \u2014 everywhere else exact means you need no native coin.\n- upto (the metered/variable x402 rail, opt-in, EVM): the amount you see is a MAXIMUM \u2014 you sign\n a ceiling, the server meters real usage and settles the ACTUAL (<= the max). BUDGET AGAINST THE MAX:\n the plan/policy treat the ceiling as the spend (a server may charge up to it), so a payable plan\n means the MAX fits your budget; the settled actual is recorded for reconciliation.\nWhen the exact scheme is enabled AND balance-aware routing is on, paying picks the cheapest\nsettleable rail \u2014 i.e. the gasless exact one. Nothing changes in your loop: quote \u2192 plan \u2192 pay is\nidentical. The exact/upto schemes are OPT-IN by the operator (MCP: PIPRAIL_SCHEMES=onchain-proof,exact,upto);\nyou can't enable them yourself, but you can report when a 402 needs one (see UNSUPPORTED_SCHEME below).\n\n## Reading a refusal \u2014 never crash, never double-spend\nA failed pay returns a STRUCTURED object, never a thrown error you must catch:\n { ok:false, code, reason, explain, ref?, reasonCode?, declined? }\nBranch on `code` (always reliable). Key cases:\n- declined:true with reasonCode:'SESSION_EXPIRED' \u2014 your time budget is over. This\n is TERMINAL: STOP. Do not retry ANY payment this process; it cannot be undone\n without a restart / a longer TTL.\n- declined:true with reasonCode:'APPROVAL' \u2014 a human (or hook) declined this\n payment. Terminal for this pay: do NOT auto-retry \u2014 they said no, or no one\n answered.\n- declined:true with reasonCode:'OUTSIDE_WINDOW' \u2014 your rolling rate-limit is\n exhausted. Wait for it to free, then retry; do not raise the amount.\n- declined:true with reasonCode:'POLICY' or 'BUDGET' \u2014 a spend cap or allowlist\n refused it. Don't retry the same payment; pick a cheaper/allowed one.\n- code:'INSUFFICIENT_FUNDS' \u2014 top up the wallet (token and/or native gas), retry.\n- code:'PAYMENT_TIMEOUT' / 'MAX_RETRIES_EXCEEDED' / 'CONFIRMATION_TIMEOUT' \u2014 the\n payment may ALREADY be on-chain. Recover using the proof on `.ref` (re-verify\n or re-submit it); never re-pay \u2014 a fresh payment would double-spend. On a gasless\n exact rail `.ref` is the authorization NONCE, not a tx hash: re-present the SAME\n signed authorization, never sign a fresh one (that would risk a double-spend).\n- code:'NO_COMPATIBLE_ACCEPT' / 'UNSUPPORTED_SCHEME' \u2014 the 402 isn't payable on\n your chain/scheme; `explain` says whether it's the wrong chain or a scheme to enable.\n If it's a standard x402 server offering an exact rail, that's a config fix the operator makes\n once (enable the exact scheme); report it, don't retry the same call blindly.\n\n## Knowing your leash \u2014 call piprail_budget\npiprail_budget tells you how much budget and time you have left: per (network,\nasset) remaining, the cross-token GRAND TOTAL per denomination (e.g. how much\nUSD you can still spend across every stablecoin and chain), the payment-count\nleash, the session time envelope, your spend so far, and the configured policy\nread back. Read-only; moves no funds. Use it in Mode A to self-check before paying.\n\n## Two modes\n- Mode A (headless, default): you run FREE inside a pre-set budget + time\n envelope. The policy IS the consent \u2014 there is no per-payment prompt. Stay\n inside it; piprail_budget shows what's left.\n- Mode B (supervised): the host may ask a human to approve each payment. A\n decline/cancel/timeout comes back as declined:true (reasonCode:'APPROVAL') \u2014\n do NOT retry it as if it were a transient error.\n\n## Hard facts\n- Per-payment + per-(network, asset) caps always apply. A cross-token GRAND TOTAL per\n denomination (maxTotalPerDenom, e.g. \"$20 across every USD stablecoin + chain\") is\n OPTIONAL \u2014 it sums tokens declared as one unit, each 1:1; it is NOT a price oracle and\n never prices a volatile native coin. Payment-COUNT caps (maxPayments / per-window) also\n span every chain + token.\n- The time envelope lives IN-MEMORY for THIS process (resets on restart). The money + count\n totals also reset on restart UNLESS a durable spend store is configured \u2014 then they resume.\n- A refusal arrives as declined:true with a reasonCode; 'BUDGET' covers the lifetime, denom,\n and count caps; 'OUTSIDE_WINDOW' covers both the rolling money and rolling count windows.\n";
|
|
6844
|
+
declare const PIPRAIL_AGENT_GUIDE = "# Paying with PipRail \u2014 the agent contract\n\nYou can pay for x402 \"402 Payment Required\" resources autonomously. Money moves\nstraight from your wallet to the server; PipRail custodies nothing. Follow this.\n\n## Your tools, and which ones act\nYou always have these eight tools. Six are READ-ONLY and safe to call freely, two change\nsomething, and only ONE spends. In 'sovereign' mode you also hold the swap and seller tools\ndescribed later, so count your OWN list rather than trusting this number:\n- piprail_guide \u2014 this contract. Re-read it if you lose the thread. Read-only.\n- piprail_discover \u2014 find payable resources on the OPEN indexes (a phone book of x402 APIs),\n without paying. Read-only.\n- piprail_quote_payment \u2014 the price of one URL. Read-only.\n- piprail_plan_payment \u2014 can I afford it NOW, on this wallet. Read-only.\n- piprail_budget \u2014 how much budget and time is left. Read-only.\n- piprail_verify_receipt \u2014 re-check a receipt against the chain. Read-only.\n- \uD83D\uDD36 piprail_register \u2014 PUBLISHES a resource you run to a public index. It writes to the\n outside world and cannot be un-published by you, so only call it when asked to list\n something. It moves no money.\n- \uD83D\uDD34 piprail_pay_request \u2014 the ONLY tool that spends. Everything else is safe to explore with.\n\n## Landing cold \u2014 read the self-description\nEvery PipRail 402 self-describes. Read challenge.extensions.piprail for { name, what, pay[]\n(each rail's how-to-pay), sdk.install, mcp, docs } \u2014 never guess what an endpoint is. If your\ntooling can't pay a rail (e.g. a stock x402 client can't pay the onchain-proof scheme), the\nblock says how: install @piprail/sdk (npm i @piprail/sdk) or run the MCP (npx -y @piprail/mcp)\nand pay with the tools below.\n\n## The loop: quote \u2192 plan \u2192 pay\n1. piprail_quote_payment(url) \u2014 PRICE it. Returns the amount, token, chain, and\n whether it is within your spend policy. No funds move. Use it to decide if a\n resource is worth buying.\n2. piprail_plan_payment(url) \u2014 can I afford it NOW? Reads your balance, native gas,\n and recipient-readiness across every rail, and returns { payable, best,\n fundingHint, session? }. If payable is false, do NOT attempt the payment \u2014\n fundingHint says exactly what to fix.\n3. piprail_pay_request(url, method?, body?) \u2014 PAY (only if the plan was payable)\n and return the result.\nAlways plan before you pay so you never commit to a payment you cannot finish.\n\n## Gasless \u2014 the exact rail (zero gas for you)\nA 402 may offer up to three rails; you don't choose per payment \u2014 the client does, automatically:\n- onchain-proof (PipRail's default): you broadcast the payment yourself and pay the network gas\n (the native coin \u2014 ETH/SOL/\u2026). Works on every chain.\n- exact (the ratified x402 rail, opt-in): you only SIGN; the server \u2014 or a facilitator it chose\n (e.g. PayAI) \u2014 broadcasts it, so you pay ZERO gas (you need only the token, no native coin). It\n works on EVM, Solana, Algorand, Aptos + NEAR, and the on-chain method (EIP-3009 / Permit2 / SVM /\n Algorand fee-pooled group / Aptos fee-payer / NEAR SignedDelegateAction) is picked automatically.\n XRPL also supports exact (native XRP), with ONE difference that matters to your budget: there the\n PAYER pays the network fee, because on the XRP Ledger the fee lives inside the signed transaction.\n So keep a little XRP for fees on that chain \u2014 everywhere else exact means you need no native coin.\n- upto (the metered/variable x402 rail, opt-in, EVM): the amount you see is a MAXIMUM \u2014 you sign\n a ceiling, the server meters real usage and settles the ACTUAL (<= the max). BUDGET AGAINST THE MAX:\n the plan/policy treat the ceiling as the spend (a server may charge up to it), so a payable plan\n means the MAX fits your budget; the settled actual is recorded for reconciliation.\nWhen the exact scheme is enabled AND balance-aware routing is on, paying picks the cheapest\nsettleable rail \u2014 i.e. the gasless exact one. Nothing changes in your loop: quote \u2192 plan \u2192 pay is\nidentical. The exact/upto schemes are OPT-IN by the operator (MCP: PIPRAIL_SCHEMES=onchain-proof,exact,upto);\nyou can't enable them yourself, but you can report when a 402 needs one (see UNSUPPORTED_SCHEME below).\n\n## Reading a refusal \u2014 never crash, never double-spend\nA failed pay returns a STRUCTURED object, never a thrown error you must catch:\n { ok:false, code, reason, explain, ref?, reasonCode?, declined? }\nBranch on `code` (always reliable). Key cases:\n- declined:true with reasonCode:'SESSION_EXPIRED' \u2014 your time budget is over. This\n is TERMINAL: STOP. Do not retry ANY payment this process; it cannot be undone\n without a restart / a longer TTL.\n- declined:true with reasonCode:'APPROVAL' \u2014 a human (or hook) declined this\n payment. Terminal for this pay: do NOT auto-retry \u2014 they said no, or no one\n answered.\n- declined:true with reasonCode:'OUTSIDE_WINDOW' \u2014 your rolling rate-limit is\n exhausted. Wait for it to free, then retry; do not raise the amount.\n- declined:true with reasonCode:'POLICY' or 'BUDGET' \u2014 a spend cap or allowlist\n refused it. Don't retry the same payment; pick a cheaper/allowed one.\n- code:'INSUFFICIENT_FUNDS' \u2014 top up the wallet (token and/or native gas), retry.\n- code:'PAYMENT_TIMEOUT' / 'MAX_RETRIES_EXCEEDED' / 'CONFIRMATION_TIMEOUT' \u2014 the\n payment may ALREADY be on-chain. Recover using the proof on `.ref` (re-verify\n or re-submit it); never re-pay \u2014 a fresh payment would double-spend. On a gasless\n exact rail `.ref` is the authorization NONCE, not a tx hash: re-present the SAME\n signed authorization, never sign a fresh one (that would risk a double-spend).\n- code:'NO_COMPATIBLE_ACCEPT' / 'UNSUPPORTED_SCHEME' \u2014 the 402 isn't payable on\n your chain/scheme; `explain` says whether it's the wrong chain or a scheme to enable.\n If it's a standard x402 server offering an exact rail, that's a config fix the operator makes\n once (enable the exact scheme); report it, don't retry the same call blindly.\n\n## Finding work to buy \u2014 piprail_discover\nYou do not have to be handed a URL. piprail_discover reads the open x402 indexes and returns\nresources with their advertised rails, which you can feed straight into quote \u2192 plan \u2192 pay.\nIt never throws: an index that is down simply contributes nothing, so an empty list means\n\"nothing found\", never \"something broke\". These are third-party directories, not a PipRail\nregistry \u2014 treat a listing as a claim, and let quote/plan tell you what is really true.\n\n## Proving a payment settled \u2014 piprail_verify_receipt\nA receipt is a claim until it is checked. piprail_verify_receipt re-reads the transaction from\nthe chain and tells you whether the funds provably moved, to the right recipient, for the right\namount. Use it when you must be SURE (before delivering something costly, or when reconciling),\nand after any timeout where the payment may already be on-chain. Read-only, and it moves nothing.\n\n## Who else is in the path \u2014 nobody who holds your money\nOn the gasless exact rail a FACILITATOR may broadcast your signed authorization (PayAI, Ultravioleta\nDAO and others). You never choose one and never need an account with one: the operator configures it,\nand it is a courier, not a custodian. It cannot change the amount or the recipient, because those are\ninside what you signed. If one is down the payment fails cleanly; it cannot take your funds.\n\n## Getting PAID \u2014 only if you hold piprail_sell\nIf piprail_sell is in your tool list you are in 'sovereign' mode and the wallet is yours to\nEARN with, not only to spend from. Three tools, mirroring the buying loop:\n- piprail_sell \u2014 price something and get a `challenge` to hand a buyer. Mirrors quote.\n- piprail_collect \u2014 verify a proof a buyer sent you. Mirrors pay.\n- piprail_earnings \u2014 what you have actually been paid. Mirrors piprail_budget.\n- piprail_wallet \u2014 what you HOLD, and the address you get paid at. Read-only.\n\nKnow the difference between your two numbers: piprail_budget is your spend LEASH (how much of\nyour allowance is left), piprail_wallet is what you actually OWN. Check piprail_wallet before\ndeciding to sell, to swap, or to ask to be topped up, and hand out its `address` to anyone who\nneeds to send you funds. A null amount there means the read FAILED, not that you are broke:\nretry before you act on it.\n\nThe loop: piprail_sell \u2192 give the buyer the `challenge` \u2192 they send back a proof \u2192\npiprail_collect \u2192 and ONLY on paid:true, deliver.\n\nA proof belongs to ONE offer. If a buyer hands you a settlement that was really payment for a\ndifferent offer, piprail_collect returns paid:false with code 'wrong_offer', even when the two\ncost the same and pay the same address. Do not \"helpfully\" retry it against another offerId: that\nis the exact move the check exists to stop.\n\n\uD83D\uDD34 COLLECT IS THE ONLY PROOF YOU WERE PAID. A buyer saying they paid, a real-looking tx hash,\nand a settled payment are three different things, and only piprail_collect tells them apart.\nDeliver nothing before it returns paid:true. It reads the chain; a claim is not evidence, and\na confident buyer is not evidence. One proof is one sale: collecting the same proof twice\nreturns paid:false, which is a REPLAY and not a second payment, so never treat it as one.\n\nYou need no web server and no open port: a challenge is just data, so carry it to the buyer\nover whatever you already speak. Receiving needs NO KEY at all, only your address, so the\nearning side cannot spend and cannot be drained even if the machine you run on is taken.\npiprail_sell defaults `payTo` to your OWN address; set it to someone else's only if you\ngenuinely mean to be paid elsewhere, and NEVER to an address a buyer supplies.\n\nTwo things to check on an offer. If its schemes are onchain-proof only, most agent-buyers\nCANNOT pay it and your listing will simply stay silent, so read any warnings piprail_sell\nreturns. And offers live in memory for this session: a restart clears them, so re-price\nanything you still intend to sell. To let strangers find an offer, call piprail_register.\n\n## Wrong token? Check your MODE before you answer\nWrong token on the RIGHT chain? What you may do depends on the mode your operator set, and\nYOUR TOOL LIST IS THE TRUTH \u2014 LOOK AT IT, never claim a capability it does not show:\n- no piprail_swap \u21D2 'budgeted' or 'supervised'. You CANNOT swap. Top up, pay from another\n chain you hold funds on, tell the human, or skip it. fundingHint names what is missing.\n Never offer \"I could swap for you\".\n- piprail_swap present \u21D2 'sovereign': this wallet is yours and you answer for it. Price with\n piprail_quote_swap, read who priced it, then piprail_swap.\n\n\uD83D\uDD34 You cannot change your own mode \u2014 whoever provisioned this wallet set it, exactly as you\ncannot widen your own permissions in your host. Never ask for it.\n\nWHY the default withholds it: YOUR SPEND POLICY DOES NOT GOVERN SWAPS. Every cap you have\nlimits PAYING A MERCHANT; a swap moves your own funds between denominations and passes all\nof them untouched, so an agent looping between tokens can bleed a wallet through fees and\nslippage without tripping one budget check. Sovereign mode bounds it with a SEPARATE\ninstrument (a ceiling per swap and on slippage), so a refusal there is your swapPolicy, not\nyour budget.\n\nTrue in EVERY mode: a swap is SAME-CHAIN only and can never move funds between chains, and\nPipRail prices nothing itself, so every quote NAMES the venue that priced it \u2014 read\n`source` before you trust a number. docs.piprail.com/making-payments/swapping/\n\n## Knowing your leash \u2014 call piprail_budget\npiprail_budget tells you how much budget and time you have left: per (network,\nasset) remaining, the cross-token GRAND TOTAL per denomination (e.g. how much\nUSD you can still spend across every stablecoin and chain), the payment-count\nleash, the session time envelope, your spend so far, and the configured policy\nread back. Read-only; moves no funds. Use it in Mode A to self-check before paying.\n\n## Two modes of CONSENT \u2014 a different axis from the mode above\nYour 'supervised'/'budgeted'/'sovereign' mode says what you may DO. This says how each\npayment is agreed. Both are in force at once, so read them together:\n- Mode A (headless \u2014 how 'budgeted' and 'sovereign' behave): you run FREE inside a pre-set\n budget + time envelope. The policy IS the consent, and there is no per-payment prompt.\n Stay inside it; piprail_budget shows what's left.\n- Mode B (supervised \u2014 how the 'supervised' mode behaves): the host may ask a human to\n approve each payment. A decline/cancel/timeout comes back as declined:true\n (reasonCode:'APPROVAL') \u2014 do NOT retry it as if it were a transient error.\n\n## Hard facts\n- Per-payment + per-(network, asset) caps always apply. A cross-token GRAND TOTAL per\n denomination (maxTotalPerDenom, e.g. \"$20 across every USD stablecoin + chain\") is\n OPTIONAL \u2014 it sums tokens declared as one unit, each 1:1; it is NOT a price oracle and\n never prices a volatile native coin. Payment-COUNT caps (maxPayments / per-window) also\n span every chain + token.\n- The time envelope lives IN-MEMORY for THIS process (resets on restart). The money + count\n totals also reset on restart UNLESS a durable spend store is configured \u2014 then they resume.\n- A refusal arrives as declined:true with a reasonCode; 'BUDGET' covers the lifetime, denom,\n and count caps; 'OUTSIDE_WINDOW' covers both the rolling money and rolling count windows.\n";
|
|
6324
6845
|
/** Returns {@link PIPRAIL_AGENT_GUIDE} (a parity accessor for callers that prefer a function). */
|
|
6325
6846
|
declare function agentGuide(): string;
|
|
6326
6847
|
|
|
@@ -7396,6 +7917,85 @@ declare function toWorker(gate: PaymentGate, serve: Serve): {
|
|
|
7396
7917
|
*/
|
|
7397
7918
|
declare function proxyTo(origin: string): Serve;
|
|
7398
7919
|
|
|
7920
|
+
/**
|
|
7921
|
+
* Swap coverage — the honest, chain-agnostic DATA map of what can swap where, who
|
|
7922
|
+
* routes it, and the real mainnet transaction that proves each one works.
|
|
7923
|
+
*
|
|
7924
|
+
* PURE DATA: imports only the `Caip2` type from `x402.ts` — zero chain libraries
|
|
7925
|
+
* (protocol layer, STANDARDS §1). Deliberately the same shape as `facilitators.ts`,
|
|
7926
|
+
* because it is the same problem: an optional third party the user opts into, which
|
|
7927
|
+
* must be named openly and must never be advertised beyond what we have proven.
|
|
7928
|
+
*
|
|
7929
|
+
* ── THE ADMISSION RULE (this is the whole point) ──────────────────────────────
|
|
7930
|
+
* An entry earns its place ONLY after a real mainnet swap settled through it and the
|
|
7931
|
+
* transaction was read back from a public node. Never seed from a documentation page,
|
|
7932
|
+
* a coverage table, or a successful quote. A quote proves routing; only a transaction
|
|
7933
|
+
* proves settlement.
|
|
7934
|
+
*
|
|
7935
|
+
* This rule exists because the facilitator registry learned it the hard way: it grew
|
|
7936
|
+
* from `/supported` reads, nothing ever re-checked an entry, and on 2026-08-28 two of
|
|
7937
|
+
* eleven seeded facilitators turned out to be dead hosts the SDK was still handing to
|
|
7938
|
+
* callers. Same failure mode, same guard.
|
|
7939
|
+
*
|
|
7940
|
+
* ── TWO TIERS, AND THE DIFFERENCE MATTERS ─────────────────────────────────────
|
|
7941
|
+
* `kind: 'protocol'` — the LEDGER ITSELF swaps. No third party exists to trust, no API
|
|
7942
|
+
* key, no extra dependency, and no integrator fee is even expressible.
|
|
7943
|
+
* `kind: 'provider'` — a named third-party router. Open and keyless, but you are
|
|
7944
|
+
* trusting its contracts and its routing API as well as the chain.
|
|
7945
|
+
*
|
|
7946
|
+
* Never blur them in any surface that renders this data.
|
|
7947
|
+
*/
|
|
7948
|
+
|
|
7949
|
+
/** A real mainnet swap, verified by reading the transaction back from a public node. */
|
|
7950
|
+
interface SwapProof {
|
|
7951
|
+
network: Caip2;
|
|
7952
|
+
/** Full transaction hash / digest. */
|
|
7953
|
+
tx: string;
|
|
7954
|
+
/** ISO date the swap settled. */
|
|
7955
|
+
date: string;
|
|
7956
|
+
/** Human summary, e.g. `'0.2652 XLM → 0.05 USDC'`. */
|
|
7957
|
+
summary: string;
|
|
7958
|
+
/** What this particular proof covers that the others do not. */
|
|
7959
|
+
covers?: string;
|
|
7960
|
+
}
|
|
7961
|
+
/** One route that can swap, and the evidence that it does. */
|
|
7962
|
+
interface SwapProviderEntry {
|
|
7963
|
+
/** Stable slug. Also the logo filename in `site/public/swaps/<id>.<ext>`. */
|
|
7964
|
+
id: string;
|
|
7965
|
+
name: string;
|
|
7966
|
+
/** `'protocol'` = the ledger swaps, no third party. `'provider'` = a named router. */
|
|
7967
|
+
kind: 'protocol' | 'provider';
|
|
7968
|
+
/** Homepage, or the protocol's own documentation for a `'protocol'` entry. */
|
|
7969
|
+
url: string;
|
|
7970
|
+
/** Networks this route covers, every one of them live-probed. */
|
|
7971
|
+
networks: readonly Caip2[];
|
|
7972
|
+
/** True when it needs NO API key. Every shipped entry is keyless; this is asserted. */
|
|
7973
|
+
keyless: boolean;
|
|
7974
|
+
/** What the route costs, stated plainly. PipRail adds nothing on top, ever. */
|
|
7975
|
+
fee: string;
|
|
7976
|
+
/** How the swap actually happens, one line. */
|
|
7977
|
+
mechanism: string;
|
|
7978
|
+
/**
|
|
7979
|
+
* Set ONLY when the route ships without a mainnet proof, naming the reason. Every other
|
|
7980
|
+
* entry carries real transaction hashes; this makes the exception impossible to miss
|
|
7981
|
+
* rather than letting an empty `proofs` array pass for evidence.
|
|
7982
|
+
*/
|
|
7983
|
+
unproven?: string;
|
|
7984
|
+
/** Real mainnet proofs. An entry with none must not ship. */
|
|
7985
|
+
proofs: readonly SwapProof[];
|
|
7986
|
+
}
|
|
7987
|
+
/**
|
|
7988
|
+
* 🔴 THE SOURCE OF TRUTH. The website data and the docs table are derived from this;
|
|
7989
|
+
* nothing below is allowed a hand-maintained second copy (see `npm run sync`).
|
|
7990
|
+
*/
|
|
7991
|
+
declare const SWAP_PROVIDERS: readonly SwapProviderEntry[];
|
|
7992
|
+
/** Every route that can swap on `network`, or an empty array when none is known. */
|
|
7993
|
+
declare function swapProvidersFor(network: Caip2): readonly SwapProviderEntry[];
|
|
7994
|
+
/** Can PipRail swap on this network at all? */
|
|
7995
|
+
declare function canSwapOn(network: Caip2): boolean;
|
|
7996
|
+
/** Every network with a proven swap route, deduped and sorted for stable rendering. */
|
|
7997
|
+
declare function swappableNetworks(): readonly Caip2[];
|
|
7998
|
+
|
|
7399
7999
|
/**
|
|
7400
8000
|
* Mode-B settlement: delegate a standard `exact` payment to a THIRD-PARTY x402
|
|
7401
8001
|
* facilitator the MERCHANT chooses (Coinbase CDP, x402.org, or any). PipRail hosts
|
|
@@ -7477,6 +8077,18 @@ interface SettleViaFacilitatorInput extends FacilitatorConfig {
|
|
|
7477
8077
|
};
|
|
7478
8078
|
/** authorization.from, for the receipt's `payer`. */
|
|
7479
8079
|
payerHint?: string;
|
|
8080
|
+
/**
|
|
8081
|
+
* The gated resource, from the merchant's own trusted config (never the client echo).
|
|
8082
|
+
* x402 v2 facilitators may require it at the request root — Ultravioleta DAO refuses a
|
|
8083
|
+
* v2 body without it (`data did not match any variant of untagged enum VerifyRequestEnvelope`),
|
|
8084
|
+
* which silently blocked every non-EVM rail it settles. Omitted fields fall back to a
|
|
8085
|
+
* neutral placeholder rather than being dropped, because the field is required, not optional.
|
|
8086
|
+
*/
|
|
8087
|
+
resource?: {
|
|
8088
|
+
url?: string;
|
|
8089
|
+
description?: string;
|
|
8090
|
+
mimeType?: string;
|
|
8091
|
+
};
|
|
7480
8092
|
}
|
|
7481
8093
|
/**
|
|
7482
8094
|
* Verify-then-settle a standard `exact` payment through a third-party facilitator.
|
|
@@ -8568,4 +9180,4 @@ interface McpPaymentTool {
|
|
|
8568
9180
|
*/
|
|
8569
9181
|
declare function createMcpPaymentTool(options: McpPaymentToolOptions): McpPaymentTool;
|
|
8570
9182
|
|
|
8571
|
-
export { type A2AArtifact, type A2AExtensionDeclaration, type A2AMessage, type A2AMetadata, type A2APart, type A2APaymentHandler, type A2APaymentHandlerOptions, type A2APaymentStatus, type A2ATask, type A2ATaskRecord, type A2ATaskState, type A2ATaskStore, A2A_ERROR_KEY, A2A_EXTENSIONS_HEADER, A2A_PAYLOAD_KEY, A2A_RECEIPTS_KEY, A2A_REQUIRED_KEY, A2A_STATUS_KEY, A2A_X402_EXTENSION_URI_V01, A2A_X402_EXTENSION_URI_V02, type AcceptOption, AddressId, type AgentTool, type AlgorandToken, type AptosToken, AssetId, BRAND, BUILTIN_DENOMS, type BazaarExtension, type BuildExactParams, CHAINS, Caip2, type ChainFamily, type ChainInput, type ChainName, type ChainPreset, type ChainSelector, type ChallengeTriage, type ChallengeVerdict, type ConfirmInfo, ConfirmationTimeoutError, type CostEstimate, type CountStatus, DENOM_PRECISION, DIRECTORY_INFO, type DeclineReasonCode, type DeliverAttempt, type DeliverReceiptOptions, type DeliverResult, type DenomRemaining, type DirectoryInfo, type DiscoverOptions, type DiscoveredRail, type DiscoveredResource, type DiscoveryDescriptor, type DiscoverySigner, type DiscoverySort, type DiscoverySource, type DomainClaim, type DomainVerification, EIP3009_TYPES, EXACT_NETWORK_SLUGS, type EvmToken, type ExactAccept, type ExactAuthorization, ExactPaymentPayloadAny, type ExactRailOption, type ExpressLikeMiddleware, type ExpressLikeNext, type ExpressLikeRequest, type ExpressLikeResponse, type FacilitatorConfig, type FacilitatorPaymentRequirements, type FacilitatorSupportedKind, type FailedPayment, GENERATOR, type GateSelfTest, InsufficientFundsError, InvalidConfigError, InvalidEnvelopeError, KNOWN_FACILITATORS, type KnownFacilitator, type ListingVisibility, MCP_PAYMENT_META_KEY, MCP_PAYMENT_RESPONSE_META_KEY, type ManifestInput, MaxRetriesExceededError, type McpContentBlock, type McpPaymentMeta, type McpPaymentTool, type McpPaymentToolOptions, type McpToolCallParams, type McpToolResult, MissingDriverError, MultiChainPayer, type MultiChainPayerOptions, type NearToken, NoCompatibleAcceptError, NonReplayableBodyError, type OpenApiDocument, type OpenApiOperation, PERMIT2_ADDRESS, PERMIT2_PROXY_CHAIN_IDS, PERMIT2_UPTO_WITNESS_TYPES, PERMIT2_WITNESS_TYPES, PIPRAIL_AGENT_GUIDE, POWERED_BY, PaidReceipt, type PayBlocker, type PayOption, type PayWarning, type PayingClient, PaymentDeclinedError, type PaymentDriver, type PaymentGate, type PaymentIntent, type PaymentPlan, type PaymentPolicy, type PaymentRail, type PaymentScheme, PaymentTimeoutError, type PaywallOptions, Permit2UptoPaymentPayload, PipRailClient, type PipRailClientOptions, type PipRailCostQuote, PipRailError, type PipRailEvent, type PipRailQuote, PipRailReceipt, type PolicyDecision, type PolicyDenyCode, REGISTER_ATTRIBUTION, type ReceiptInput, type ReceiptOption, type ReceiptVerification, RecipientNotReadyError, type RecipientReason, type RegisterInput, type RegisterOptions, type RegisterOutcome, type RequirePaymentOptions, type ResolveOptions, type ResolvedChain, type ResolvedNetwork, type ResolvedToken, type ResourceDescription, type SearchOpenIndexesOptions, type SelfDescribeEndpoint, type SelfDescribeRail, type SelfDescription, type Serve, type SessionBudget, SettleOutcome, type SettleViaFacilitatorInput, SettlementError, SignedReceipt, type SolanaToken, SpendLedger, SpendRecord, type SpendRemaining, SpendStore, SpendSummary, type StellarToken, type SuiToken, type TipJarOptions, type TokenInfo, type TokenInput, type TonToken, type ToolAnnotations, type TronToken, UPTO_PROXY_CHAIN_IDS, UnknownTokenError, UnsupportedNetworkError, UnsupportedSchemeError, type UptoRailOption, VERIFY_CODE_TO_A2A_ERROR, VerifyErrorCode, type VerifyPaymentResult, VerifyResult, type WalletBalance, type WalletHandle, type WalletInput, WalletRequiredError, type WellKnownX402, type WellKnownX402Item, type WellKnownX402Manifest, WrongChainError, WrongFamilyError, X402AcceptEntry, X402AnyAccept, X402Challenge, type X402DnsRecord, X402ExactAcceptEntry, type X402InvalidBody, X402Receipt, X402UptoAcceptEntry, X402_EXACT_PERMIT2_PROXY, X402_UPTO_PERMIT2_PROXY, type XrplToken, agentGuide, appendAttribution, appendKeywords, buildBazaarExtension, buildEndpointInfo, buildExactAuthorization, buildMcpPaymentMeta, buildOpenApi, buildSelfDescription, buildWellKnownX402, buildWellKnownX402Manifest, buildX402DnsTxt, chainIdForExactNetwork, claim402IndexDomain, classifyChallenge, createA2APaymentHandler, createMcpPaymentTool, createPaymentGate, createPaywall, createTipJar, decorateOutcome, deliverReceipt, denomOf, describeChallenge, discoveryHeaders, eip3009Abi, encodeXPaymentHeader, evaluatePolicy, explainDecline, facilitatorCoverage, fetchAcross, firstKeylessFacilitator, formatSpendReport, fromA2APaymentPayload, fromA2APaymentRequired, fromMcpPayment, fromMcpPaymentRequired, fromMcpPaymentResponse, getDirectoryInfo, isMcpPaymentRequired, isPermit2ProxyChain, isUptoProxyChain, knownFacilitatorsFor, normalizeNetwork, parseExactRequirements, parseFacilitatorSupported, paymentTools, planAcross, proxyTo, rankResources, readExactDomain, register402Index, registerDriver, registerX402Scan, renderLandingPage, requirePayment, resolveChain, scoreResource, searchOpenIndexes, settleViaFacilitator, summarizePlan, toA2AErrorCode, toA2APaymentFailed, toA2APaymentReceipts, toA2APaymentRequired, toFetchHandler, toInsufficientFundsError, toInvalidBody, toMcpPaymentRequired, toMcpPaymentResponse, toWorker, verify402IndexDomain };
|
|
9183
|
+
export { type A2AArtifact, type A2AExtensionDeclaration, type A2AMessage, type A2AMetadata, type A2APart, type A2APaymentHandler, type A2APaymentHandlerOptions, type A2APaymentStatus, type A2ATask, type A2ATaskRecord, type A2ATaskState, type A2ATaskStore, A2A_ERROR_KEY, A2A_EXTENSIONS_HEADER, A2A_PAYLOAD_KEY, A2A_RECEIPTS_KEY, A2A_REQUIRED_KEY, A2A_STATUS_KEY, A2A_X402_EXTENSION_URI_V01, A2A_X402_EXTENSION_URI_V02, AGENT_MODES, type AcceptOption, AddressId, type AgentMode, type AgentTool, type AlgorandToken, type AptosToken, AssetId, BRAND, BUILTIN_DENOMS, type BazaarExtension, type BuildExactParams, CHAINS, Caip2, type ChainFamily, type ChainInput, type ChainName, type ChainPreset, type ChainSelector, type ChallengeTriage, type ChallengeVerdict, type ConfirmInfo, ConfirmationTimeoutError, type CostEstimate, type CountStatus, DEFAULT_AGENT_MODE, DEFAULT_SLIPPAGE_BPS, DENOM_PRECISION, DIRECTORY_INFO, type DeclineReasonCode, type DeliverAttempt, type DeliverReceiptOptions, type DeliverResult, type DenomRemaining, type DirectoryInfo, type DiscoverOptions, type DiscoveredRail, type DiscoveredResource, type DiscoveryDescriptor, type DiscoverySigner, type DiscoverySort, type DiscoverySource, type DomainClaim, type DomainVerification, EIP3009_TYPES, EXACT_NETWORK_SLUGS, type EvmToken, type ExactAccept, type ExactAuthorization, ExactPaymentPayloadAny, type ExactRailOption, type ExpressLikeMiddleware, type ExpressLikeNext, type ExpressLikeRequest, type ExpressLikeResponse, type FacilitatorConfig, type FacilitatorPaymentRequirements, type FacilitatorSupportedKind, type FailedPayment, GENERATOR, type GateSelfTest, InsufficientFundsError, InvalidConfigError, InvalidEnvelopeError, KNOWN_FACILITATORS, type KnownFacilitator, type ListingVisibility, MAX_SLIPPAGE_BPS, MCP_PAYMENT_META_KEY, MCP_PAYMENT_RESPONSE_META_KEY, type ManifestInput, MaxRetriesExceededError, type McpContentBlock, type McpPaymentMeta, type McpPaymentTool, type McpPaymentToolOptions, type McpToolCallParams, type McpToolResult, MissingDriverError, MultiChainPayer, type MultiChainPayerOptions, type NearToken, NoCompatibleAcceptError, NonReplayableBodyError, type OpenApiDocument, type OpenApiOperation, PERMIT2_ADDRESS, PERMIT2_PROXY_CHAIN_IDS, PERMIT2_UPTO_WITNESS_TYPES, PERMIT2_WITNESS_TYPES, PIPRAIL_AGENT_GUIDE, POWERED_BY, PaidReceipt, type PayBlocker, type PayOption, type PayWarning, type PayingClient, PaymentDeclinedError, type PaymentDriver, type PaymentGate, type PaymentIntent, type PaymentPlan, type PaymentPolicy, type PaymentRail, type PaymentScheme, PaymentTimeoutError, type PaywallOptions, Permit2UptoPaymentPayload, PipRailClient, type PipRailClientOptions, type PipRailCostQuote, PipRailError, type PipRailEvent, type PipRailQuote, PipRailReceipt, type PolicyDecision, type PolicyDenyCode, REGISTER_ATTRIBUTION, type ReceiptInput, type ReceiptOption, type ReceiptVerification, RecipientNotReadyError, type RecipientReason, type RegisterInput, type RegisterOptions, type RegisterOutcome, type RequirePaymentOptions, type ResolveOptions, type ResolvedChain, type ResolvedNetwork, type ResolvedToken, type ResourceDescription, SWAP_PROVIDERS, type SearchOpenIndexesOptions, type SelfDescribeEndpoint, type SelfDescribeRail, type SelfDescription, type Serve, type SessionBudget, SettleOutcome, type SettleViaFacilitatorInput, SettlementError, SignedReceipt, type SolanaToken, SpendLedger, SpendRecord, type SpendRemaining, SpendStore, SpendSummary, type StellarToken, type SuiToken, type SwapPolicy, type SwapProof, type SwapProviderEntry, type SwapQuote, type SwapQuoteSource, type SwapReceipt, type SwapRequest, type SwapSide, type TipJarOptions, type TokenInfo, type TokenInput, type TonToken, type ToolAnnotations, type TronToken, UPTO_PROXY_CHAIN_IDS, UnknownTokenError, UnsupportedNetworkError, UnsupportedSchemeError, type UptoRailOption, VERIFY_CODE_TO_A2A_ERROR, VerifyErrorCode, type VerifyPaymentResult, VerifyResult, type WalletBalance, type WalletHandle, type WalletInput, WalletRequiredError, type WellKnownX402, type WellKnownX402Item, type WellKnownX402Manifest, WrongChainError, WrongFamilyError, X402AcceptEntry, X402AnyAccept, X402Challenge, type X402DnsRecord, X402ExactAcceptEntry, type X402InvalidBody, X402Receipt, X402UptoAcceptEntry, X402_EXACT_PERMIT2_PROXY, X402_UPTO_PERMIT2_PROXY, type XrplToken, agentGuide, appendAttribution, appendKeywords, applySlippage, buildBazaarExtension, buildEndpointInfo, buildExactAuthorization, buildMcpPaymentMeta, buildOpenApi, buildSelfDescription, buildWellKnownX402, buildWellKnownX402Manifest, buildX402DnsTxt, canSwapOn, chainIdForExactNetwork, claim402IndexDomain, classifyChallenge, createA2APaymentHandler, createMcpPaymentTool, createPaymentGate, createPaywall, createTipJar, decorateOutcome, deliverReceipt, denomOf, describeChallenge, discoveryHeaders, eip3009Abi, encodeXPaymentHeader, evaluatePolicy, explainDecline, facilitatorCoverage, fetchAcross, firstKeylessFacilitator, formatSpendReport, fromA2APaymentPayload, fromA2APaymentRequired, fromMcpPayment, fromMcpPaymentRequired, fromMcpPaymentResponse, getDirectoryInfo, isMcpPaymentRequired, isPermit2ProxyChain, isUptoProxyChain, knownFacilitatorsFor, normalizeNetwork, parseExactRequirements, parseFacilitatorSupported, paymentTools, planAcross, proxyTo, rankResources, readExactDomain, register402Index, registerDriver, registerX402Scan, renderLandingPage, requirePayment, resolveChain, resolveSlippageBps, scoreResource, searchOpenIndexes, settleViaFacilitator, summarizePlan, summarizeSwap, swapProvidersFor, swappableNetworks, toA2AErrorCode, toA2APaymentFailed, toA2APaymentReceipts, toA2APaymentRequired, toFetchHandler, toInsufficientFundsError, toInvalidBody, toMcpPaymentRequired, toMcpPaymentResponse, toWorker, verify402IndexDomain };
|