@integraledger/profile-facilitator 0.5.0 → 0.6.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 +556 -0
- package/README.md +754 -111
- package/dist/core.d.ts +1 -1
- package/dist/core.js +683 -66
- package/dist/http.d.ts +19 -4
- package/dist/http.js +16 -6
- package/dist/module.d.ts +111 -24
- package/dist/module.js +39 -0
- package/dist/modules/algorand/index.js +1 -1
- package/dist/modules/aptos/index.js +1 -1
- package/dist/modules/cardano/index.js +1 -1
- package/dist/modules/casper/index.js +15 -3
- package/dist/modules/concordium/index.js +1 -1
- package/dist/modules/erc7710/index.d.ts +8 -5
- package/dist/modules/erc7710/index.js +1111 -34
- package/dist/modules/evm/escrow.d.ts +125 -0
- package/dist/modules/evm/escrow.js +619 -0
- package/dist/modules/evm/forms.d.ts +39 -11
- package/dist/modules/evm/forms.js +191 -25
- package/dist/modules/evm/index.d.ts +41 -6
- package/dist/modules/evm/index.js +1135 -20
- package/dist/modules/evm/node.d.ts +16 -1
- package/dist/modules/evm/node.js +181 -26
- package/dist/modules/evm/nonce-proof.d.ts +186 -0
- package/dist/modules/evm/nonce-proof.js +779 -0
- package/dist/modules/hedera/executor.js +1 -1
- package/dist/modules/hedera/index.js +1 -1
- package/dist/modules/lnbtc/index.js +3 -2
- package/dist/modules/near/index.js +1 -1
- package/dist/modules/polkadot/index.js +1 -1
- package/dist/modules/solana/index.d.ts +3 -0
- package/dist/modules/solana/index.js +119 -10
- package/dist/modules/solana/reader.d.ts +2 -1
- package/dist/modules/solana/reader.js +42 -4
- package/dist/modules/solana/upto-claim.d.ts +58 -0
- package/dist/modules/solana/upto-claim.js +269 -0
- package/dist/modules/starknet/index.js +9 -2
- package/dist/modules/stellar/index.d.ts +5 -0
- package/dist/modules/stellar/index.js +18 -8
- package/dist/modules/stellar/node.d.ts +7 -1
- package/dist/modules/stellar/node.js +51 -7
- package/dist/modules/sui/index.js +66 -20
- package/dist/modules/sui/node.d.ts +13 -0
- package/dist/modules/sui/node.js +60 -0
- package/dist/modules/ton/index.js +6 -2
- package/dist/modules/tron/index.js +1 -1
- package/dist/modules/xrpl/index.js +61 -12
- package/dist/modules/xrpl/node.d.ts +31 -2
- package/dist/modules/xrpl/node.js +88 -17
- package/dist/modules/xrpl/upto.js +106 -20
- package/dist/record.d.ts +52 -8
- package/dist/record.js +39 -5
- package/dist/wrapper.d.ts +7 -5
- package/dist/wrapper.js +7 -5
- package/package.json +4 -3
package/README.md
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
# @integraledger/profile-facilitator
|
|
2
2
|
|
|
3
|
-
The settler: an x402 facilitator
|
|
4
|
-
[`@integraledger/lcp`](https://www.npmjs.com/package/@integraledger/lcp) ships. A resource server
|
|
5
|
-
facilitator API, one HTTP surface: `GET /supported`, `POST /verify` and `POST /settle`. It checks
|
|
6
|
-
its pairing's profile and the requirements it answers, submits what the payer signed, records each
|
|
7
|
-
Postgres, and answers what the chain shows.
|
|
3
|
+
The settler: an x402 facilitator that holds each payment to its pairing's LCP profile (hence the package name), for
|
|
4
|
+
the x402 pairings that [`@integraledger/lcp`](https://www.npmjs.com/package/@integraledger/lcp) ships. A resource server
|
|
5
|
+
calls it over x402's facilitator API, one HTTP surface: `GET /supported`, `POST /verify` and `POST /settle`. It checks
|
|
6
|
+
each payment against its pairing's profile and the requirements it answers, submits what the payer signed, records each
|
|
7
|
+
payment once in Postgres, and answers what the chain shows.
|
|
8
|
+
|
|
9
|
+
This page is for the operator who runs it: at the end you can install it, configure each module with its keys, nodes
|
|
10
|
+
and database, put it behind TLS, and read every answer it gives.
|
|
8
11
|
|
|
9
12
|
## What it is
|
|
10
13
|
|
|
@@ -28,7 +31,9 @@ settler adds three things:
|
|
|
28
31
|
- **The record**: one row per payment in Postgres, keyed as its profile names the payment (the single-use value its
|
|
29
32
|
signer signed, or its transaction id), so that one payment is submitted once and answered success once, across
|
|
30
33
|
every process that shares the database.
|
|
31
|
-
- **lcp's read of the chain**, which decides whether a payment the class did not answer success for is final
|
|
34
|
+
- **lcp's read of the chain**, which decides whether a payment the class did not answer success for is final, and
|
|
35
|
+
makes final a payment an EVM class answered success for on one receipt at the head: the success is given at once,
|
|
36
|
+
and the row stays open, naming its transaction, until a read shows the payment on the finalized chain.
|
|
32
37
|
|
|
33
38
|
```mermaid
|
|
34
39
|
sequenceDiagram
|
|
@@ -57,13 +62,14 @@ or legal logic beyond that.
|
|
|
57
62
|
## Install
|
|
58
63
|
|
|
59
64
|
```sh
|
|
60
|
-
npm install @integraledger/profile-facilitator @integraledger/lcp
|
|
65
|
+
npm install @integraledger/profile-facilitator @integraledger/lcp@~0.7.0
|
|
61
66
|
```
|
|
62
67
|
|
|
63
|
-
It needs Node.js `>=24.22.1`, Postgres
|
|
64
|
-
reads. It is ESM only. `@integraledger/lcp` is its peer dependency
|
|
65
|
-
key takes it as the signer object of x402's class for that
|
|
66
|
-
release the settler's classes are pinned to
|
|
68
|
+
It needs Node.js `>=24.22.1`, Postgres 11 or later ([The database](#the-database)), and, for each network it serves,
|
|
69
|
+
the node its module reads. It is ESM only. `@integraledger/lcp` is its peer dependency, at `~0.7.0`: install it with
|
|
70
|
+
the settler ([Versions](#versions)). A module that holds a key takes it as the signer object of x402's class for that
|
|
71
|
+
chain; make it with that chain's x402 package at 2.31.0, the release the settler's classes are pinned to
|
|
72
|
+
(`@x402/evm`, `@x402/svm`, `@x402/avm`, and so on).
|
|
67
73
|
|
|
68
74
|
Two packages in its dependency tree have install scripts that it runs without: `protobufjs` (through `@hiero-ledger/sdk`
|
|
69
75
|
and `@concordium/web-sdk`) and `secp256k1` (through `@x402/near`). This repository installs with both denied, and runs
|
|
@@ -138,7 +144,7 @@ await settler.close();
|
|
|
138
144
|
"extra": {
|
|
139
145
|
"assetTransferMethod": "lcp-assets-remark",
|
|
140
146
|
"key": "none",
|
|
141
|
-
"acceptsZero":
|
|
147
|
+
"acceptsZero": [],
|
|
142
148
|
"pairings": [
|
|
143
149
|
"x402/exact/polkadot/lcp-assets-remark"
|
|
144
150
|
]
|
|
@@ -151,7 +157,7 @@ await settler.close();
|
|
|
151
157
|
"extra": {
|
|
152
158
|
"assetTransferMethod": "lcp-trc20-memo",
|
|
153
159
|
"key": "none",
|
|
154
|
-
"acceptsZero":
|
|
160
|
+
"acceptsZero": [],
|
|
155
161
|
"pairings": [
|
|
156
162
|
"x402/exact/tron/lcp-trc20-memo"
|
|
157
163
|
]
|
|
@@ -168,10 +174,11 @@ await settler.close();
|
|
|
168
174
|
|
|
169
175
|
## Run it as a service
|
|
170
176
|
|
|
171
|
-
The package exports one function that starts the server; it has no command-line entry.
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
177
|
+
The package exports one function that starts the server; it has no command-line entry. It reads no environment variable
|
|
178
|
+
and no file: every setting is a member of the configuration, and the variable names in these samples are the samples'
|
|
179
|
+
own. A service is a short module that reads its configuration, makes the signer objects its keyed modules take, and
|
|
180
|
+
stops cleanly on a signal. This one serves x402's `exact` scheme on Base Sepolia through the `evm` module, whose key,
|
|
181
|
+
the seller's gas key, sends each transaction and pays its gas:
|
|
175
182
|
|
|
176
183
|
```ts no-check title="settler.ts"
|
|
177
184
|
import { serveProfileFacilitator } from "@integraledger/profile-facilitator";
|
|
@@ -188,15 +195,26 @@ if (credential === undefined || gasKey === undefined) throw new Error("set SETTL
|
|
|
188
195
|
// The seller's gas key, as x402's EVM classes take it.
|
|
189
196
|
const account = privateKeyToAccount(gasKey);
|
|
190
197
|
const client = createWalletClient({ account, chain: baseSepolia, transport: http(rpc) }).extend(publicActions);
|
|
191
|
-
const signer = toFacilitatorEvmSigner(
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
198
|
+
const signer = toFacilitatorEvmSigner(
|
|
199
|
+
{
|
|
200
|
+
address: account.address,
|
|
201
|
+
getCode: (a) => client.getCode(a),
|
|
202
|
+
readContract: (a) => client.readContract({ ...a, args: a.args ?? [] } as never),
|
|
203
|
+
verifyTypedData: (a) => client.verifyTypedData(a as never),
|
|
204
|
+
writeContract: (a) => client.writeContract({ ...a, args: a.args ?? [] } as never),
|
|
205
|
+
sendTransaction: (a) => client.sendTransaction(a as never),
|
|
206
|
+
waitForTransactionReceipt: (a) => client.waitForTransactionReceipt(a) as never,
|
|
207
|
+
simulateCalls: (a) => client.simulateCalls(a as never) as never,
|
|
208
|
+
},
|
|
209
|
+
// Below settleWaitMs, so /settle answers settlement_pending instead of waiting up to x402's default 180 s.
|
|
210
|
+
{ confirmationTimeoutMs: 25_000 },
|
|
211
|
+
);
|
|
212
|
+
// For auth-capture, the key also signs without sending, and sends what it signed, so that the settler names each
|
|
213
|
+
// escrow call before it is sent.
|
|
214
|
+
Object.assign(signer, {
|
|
215
|
+
signTransaction: async (r: { to: Hex; data: Hex; gas?: bigint; nonce?: number }) =>
|
|
216
|
+
client.signTransaction((await client.prepareTransactionRequest({ ...r })) as never),
|
|
217
|
+
sendRawTransaction: (r: { serializedTransaction: Hex }) => client.sendRawTransaction(r as never),
|
|
200
218
|
});
|
|
201
219
|
|
|
202
220
|
const listen = process.env.LISTEN ?? "127.0.0.1:4021";
|
|
@@ -233,7 +251,7 @@ Run it with `node settler.ts`: Node.js 26 runs TypeScript directly. Every call m
|
|
|
233
251
|
"network": "eip155:84532",
|
|
234
252
|
"extra": {
|
|
235
253
|
"key": "relayer",
|
|
236
|
-
"acceptsZero":
|
|
254
|
+
"acceptsZero": ["x402/exact/eip155/eip3009"],
|
|
237
255
|
"pairings": ["x402/exact/eip155/eip3009", "x402/exact/eip155/permit2"],
|
|
238
256
|
"feeBudget": true
|
|
239
257
|
}
|
|
@@ -246,7 +264,8 @@ Run it with `node settler.ts`: Node.js 26 runs TypeScript directly. Every call m
|
|
|
246
264
|
|
|
247
265
|
`close()` stops accepting requests, closes open connections, closes what each module opened (the Polkadot nodes'
|
|
248
266
|
connections among them), stops the sweep and closes the Postgres pool. If the settler cannot start, it closes what it
|
|
249
|
-
opened and rejects with the error that stopped it, such as the listen's `EADDRINUSE` or a configuration it refuses
|
|
267
|
+
opened and rejects with the error that stopped it, such as the listen's `EADDRINUSE` or a configuration it refuses
|
|
268
|
+
([What stops the start](#what-stops-the-start)).
|
|
250
269
|
|
|
251
270
|
## Configuration
|
|
252
271
|
|
|
@@ -258,38 +277,58 @@ the deployment starts, named for the module. A module whose member is absent is
|
|
|
258
277
|
| Member | Type | Meaning |
|
|
259
278
|
|---|---|---|
|
|
260
279
|
| `listen` | `string` | `"host:port"`; an IPv6 host may be written in brackets. |
|
|
261
|
-
| `store` | `{ url: string }` | The Postgres connection string. Postgres holds the record, the fee count and the modules' durable state; the settler creates its tables at start where they do not exist. |
|
|
280
|
+
| `store` | `{ url: string }` | The Postgres connection string. Postgres holds the record, the fee count and the modules' durable state; the settler creates its tables at start where they do not exist ([The database](#the-database)). |
|
|
262
281
|
| `settleWaitMs` | `number` | How long `/settle` waits for the chain before it answers `settlement_pending`. A value that is not a positive finite number means 30 000. |
|
|
263
282
|
| `credential` | `string`, optional | The credential every call must present as `Authorization: Bearer <credential>`; required where a configured module holds a key ([The credential](#the-credential)). Its characters are those RFC 6750 admits in a bearer token: letters, digits and `-._~+/`, then any `=`. |
|
|
264
283
|
| `feeBudgets` | `{ network, amount, periodSeconds }[]`, optional | At most one per network, each on a network a configured module serves ([The fee budget](#the-fee-budget)). `amount` is in the smallest unit of the network's fee asset, a `bigint` or its decimal digits, and positive; `periodSeconds` is a positive whole number. |
|
|
265
284
|
| `operatorLog` | `(entry, cause?) => void`, optional | Receives every entry for the operator ([Bounds and logs](#bounds-and-logs)). The default writes one JSON line per entry on standard error. |
|
|
266
285
|
|
|
286
|
+
### The database
|
|
287
|
+
|
|
288
|
+
The settler needs Postgres 11 or later: nothing it runs is newer than `hashtextextended`, which Postgres 11 added. Its
|
|
289
|
+
tests run on Postgres 18. At every start it runs `CREATE TABLE IF NOT EXISTS` and `CREATE INDEX IF NOT EXISTS` for its
|
|
290
|
+
three tables and two indexes ([Storage](#storage)), so the role in `store.url` needs `CREATE` on the schema they live
|
|
291
|
+
in and owns them. From Postgres 15, the schema `public` grants `CREATE` to no role but its owner by default: grant it,
|
|
292
|
+
or create a schema named for the role and owned by it, which Postgres's default `search_path` (`"$user", public`) puts
|
|
293
|
+
first. The role then reads and writes only those tables, and takes transaction-level advisory locks. Each process holds
|
|
294
|
+
at most 10 connections.
|
|
295
|
+
|
|
296
|
+
Every settler process that may settle the same payments uses the same database: the record is what keeps one payment
|
|
297
|
+
submitted once and answered success once. Do not truncate or replace its tables while payments they hold can still
|
|
298
|
+
land, and back them up as you back up payment records.
|
|
299
|
+
|
|
267
300
|
### The modules
|
|
268
301
|
|
|
269
302
|
Each module's member lists the networks it serves. Its keys reach it inside that member, as the signer objects its
|
|
270
|
-
classes take; the settler reads no key material of its own.
|
|
271
|
-
names
|
|
272
|
-
|
|
273
|
-
| Member | Chain | Scheme: pairings | `extra.key` | `extra.acceptsZero` | Facilitator |
|
|
274
|
-
|
|
275
|
-
| `algorand` | Algorand | `exact`: `x402/exact/algorand` | `fee-payer` | `
|
|
276
|
-
| `aptos` | Aptos | `exact`: `x402/exact/aptos` | `fee-payer`, or `none` with `sponsor: false` | `
|
|
277
|
-
| `cardano` | Cardano | `exact`: `x402/exact/cardano
|
|
278
|
-
| `casper` | Casper | `exact`: `x402/exact/casper` | `relayer` | `
|
|
279
|
-
| `concordium` | Concordium | `exact`: `x402/exact/ccd` | `fee-payer` | `
|
|
280
|
-
| `evm` | EVM | `exact`: `x402/exact/eip155/eip3009
|
|
281
|
-
| `erc7710` | EVM | `exact` with `erc7710`: `x402/exact/eip155/erc7710
|
|
282
|
-
| `hedera` | Hedera | `exact`: `x402/exact/hedera` | `fee-payer` | `
|
|
283
|
-
| `lnbtc` | Lightning | `exact`: `x402/exact/lnbtc/payment-hash` | `none` | `
|
|
284
|
-
| `near` | NEAR | `exact`: `x402/exact/near` | `relayer` | `
|
|
285
|
-
| `polkadot` | Polkadot Asset Hub | `exact`: `x402/exact/polkadot/lcp-assets-remark` | `none` | `
|
|
286
|
-
| `solana` | Solana | `exact`: `x402/exact/solana
|
|
287
|
-
| `starknet` | Starknet | `exact`: `x402/exact/starknet` | `relayer` | `
|
|
288
|
-
| `stellar` | Stellar | `exact` with `lcp-precondition`: `x402/exact/stellar/precondition` | `relayer` | `
|
|
289
|
-
| `sui` | Sui | `exact`: `x402/exact/sui` | `none` | `
|
|
290
|
-
| `ton` | TON | `exact`: `x402/exact/tvm` | `relayer` | `
|
|
291
|
-
| `tron` | Tron | `exact`: `x402/exact/tron/lcp-trc20-memo` | `none` | `
|
|
292
|
-
| `xrpl` | XRP Ledger | `exact`: `x402/exact/xrpl
|
|
303
|
+
classes take; the settler reads no key material of its own. A network is the CAIP-2 id lcp's type for the chain
|
|
304
|
+
names, and the table gives the ones each module takes.
|
|
305
|
+
|
|
306
|
+
| Member | Chain | Networks | Scheme: pairings (`confirmed`) | `extra.key` | `extra.acceptsZero` | Facilitator |
|
|
307
|
+
|---|---|---|---|---|---|---|
|
|
308
|
+
| `algorand` | Algorand | `algorand:wGHE2Pwdvd7S12BL5FaOP20EGYesN73k` (mainnet), `algorand:SGO1GKSzyE7IEPItTxCByw9x8FmnrCDe` (testnet), the two `@x402/avm`'s class takes | `exact`: `x402/exact/algorand` (yes) | `fee-payer` | `x402/exact/algorand` | `@x402/avm`'s class; the settler's own path for a rekeyed payer signing with one key and a Falcon-key payer |
|
|
309
|
+
| `aptos` | Aptos | `aptos:1`, `aptos:2`, the two `@x402/aptos`'s class takes | `exact`: `x402/exact/aptos` (yes) | `fee-payer`, or `none` with `sponsor: false` | `[]` | `@x402/aptos`'s class |
|
|
310
|
+
| `cardano` | Cardano | `cardano:mainnet`, `cardano:preprod`, `cardano:preview` | `exact`: `x402/exact/cardano` (yes), `x402/exact/cardano/lock` (yes) | `none` | `[]` | `@x402/cardano`'s class |
|
|
311
|
+
| `casper` | Casper | `casper:casper-test` | `exact`: `x402/exact/casper` (no) | `relayer` | `[]` | `@x402/casper`'s class |
|
|
312
|
+
| `concordium` | Concordium | `ccd:<genesis hash prefix>` | `exact`: `x402/exact/ccd` (no) | `fee-payer` | `x402/exact/ccd` | `@x402/concordium`'s class |
|
|
313
|
+
| `evm` | EVM | `eip155:<chain id>` | `exact`: `x402/exact/eip155/eip3009` (yes), `x402/exact/eip155/permit2` (yes); `upto`: `x402/upto/eip155/permit2` (yes); `auth-capture`: `x402/auth-capture/eip155/eip3009` (yes), `x402/auth-capture/eip155/permit2` (yes); `batch-settlement`: `x402/batch-settlement/eip155` (yes) | `relayer` | `x402/exact/eip155/eip3009` on `exact`; `[]` on the others | `@x402/evm`'s classes |
|
|
314
|
+
| `erc7710` | EVM | `eip155:<chain id>`, where `evm` registers `exact` | `exact` with `erc7710`: `x402/exact/eip155/erc7710` (yes), `x402/exact/eip155/erc7710-salt` (yes) | `relayer` | `[]` | the settler's own, behind the `evm` module's `exact` |
|
|
315
|
+
| `hedera` | Hedera | `hedera:mainnet`, `hedera:testnet`, the two `@x402/hedera`'s class takes | `exact`: `x402/exact/hedera` (yes) | `fee-payer` | `[]` | `@x402/hedera`'s class |
|
|
316
|
+
| `lnbtc` | Lightning | `lnbtc:000000000019d6689c085ae165831e93`, `lnbtc:000000000933ea01ad0ee984209779ba` | `exact`: `x402/exact/lnbtc/payment-hash` (yes) | `none` | `[]` | the settler's own |
|
|
317
|
+
| `near` | NEAR | `near:mainnet`, `near:testnet` | `exact`: `x402/exact/near` (yes) | `relayer` | `[]` | `@x402/near`'s class |
|
|
318
|
+
| `polkadot` | Polkadot Asset Hub | `polkadot:68d56f15f85d3136970ec16946040bc1`, `polkadot:67f9723393ef76214df0118c34bbbd3d` | `exact`: `x402/exact/polkadot/lcp-assets-remark` (yes) | `none` | `[]` | the settler's own |
|
|
319
|
+
| `solana` | Solana | `solana:<genesis hash prefix>`; `upto` and `batch-settlement` not on `solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp` | `exact`: `x402/exact/solana` (yes); `upto`: `x402/upto/solana` (no); `batch-settlement`: `x402/batch-settlement/solana` (no) | `fee-payer` | `x402/exact/solana` on `exact`; `[]` on the others | `@x402/svm`'s classes |
|
|
320
|
+
| `starknet` | Starknet | `starknet:SN_MAIN`, `starknet:SN_SEPOLIA` | `exact`: `x402/exact/starknet` (yes) | `relayer` | `x402/exact/starknet` on `starknet:SN_SEPOLIA`; `[]` on `starknet:SN_MAIN` | the settler's own |
|
|
321
|
+
| `stellar` | Stellar | `stellar:pubnet`, `stellar:testnet` | `exact` with `lcp-precondition`: `x402/exact/stellar/precondition` (yes) | `relayer` | `x402/exact/stellar/precondition` | the settler's own |
|
|
322
|
+
| `sui` | Sui | `sui:mainnet`, `sui:testnet`, `sui:devnet` | `exact`: `x402/exact/sui` (yes) | `none` | `x402/exact/sui` | the settler's own |
|
|
323
|
+
| `ton` | TON | `tvm:-239`, `tvm:-3` | `exact`: `x402/exact/tvm` (yes) | `relayer` | `x402/exact/tvm` | `@x402/tvm`'s class |
|
|
324
|
+
| `tron` | Tron | `tron:<chain id in decimal>` | `exact`: `x402/exact/tron/lcp-trc20-memo` (yes) | `none` | `[]` | the settler's own |
|
|
325
|
+
| `xrpl` | XRP Ledger | `xrpl:<NetworkID>` | `exact`: `x402/exact/xrpl` (yes); `upto`: `x402/upto/xrpl` (yes) | `none` | `[]` | `@x402/xrpl`'s class for a payer signing with one key; the settler's own for a multisigned payer and for `upto` |
|
|
326
|
+
|
|
327
|
+
`confirmed` is lcp's registry's: whether something outside lcp has shown the form as its profile defines it
|
|
328
|
+
([the pairing registry](https://github.com/IntegraLedger/integra-protocol/blob/main/docs/reference/pairings.md)). The
|
|
329
|
+
settler serves the forms marked `no` as their profiles define them, but no recorded run outside lcp has yet shown one.
|
|
330
|
+
The `casper` and `concordium` modules serve only such forms: run them on a test network, and do not offer those forms
|
|
331
|
+
to buyers until the registry says `yes`.
|
|
293
332
|
|
|
294
333
|
Each member, one entry per network unless it says otherwise:
|
|
295
334
|
|
|
@@ -309,11 +348,11 @@ Each member, one entry per network unless it says otherwise:
|
|
|
309
348
|
names one of the key's addresses.
|
|
310
349
|
- **`cardano`**: `network`; `signer`, the chain-query object `@x402/cardano`'s class takes over the seller's provider (a
|
|
311
350
|
provider's project id is its configuration, not a key); `reader`, lcp's `CardanoReader` over the seller's indexer. The
|
|
312
|
-
class broadcasts the transaction the buyer signed, whose fee the buyer pays.
|
|
313
|
-
alone: over Koios alone it sees none, so an option it settles there
|
|
314
|
-
`{ "l1Confirmations": 0 }`, and an option that states none, whose default asks
|
|
315
|
-
|
|
316
|
-
|
|
351
|
+
class broadcasts the transaction the buyer signed, whose fee the buyer pays. `@x402/cardano` 2.31.0 reads a
|
|
352
|
+
transaction's confirmations from Blockfrost alone: over Koios alone it sees none, so an option it settles there
|
|
353
|
+
states `extra.confirmationPolicy` as `{ "l1Confirmations": 0 }`, and an option that states none, whose default asks
|
|
354
|
+
one confirmation, is refused at `/verify`. A provider with a Blockfrost project serves an option that asks
|
|
355
|
+
confirmations. `/settle` answers success where the class does, and
|
|
317
356
|
otherwise once lcp's read through `reader` shows the transaction final, at the ledger's security parameter of
|
|
318
357
|
confirmations (2160 on mainnet and Preprod, some 12 hours); until then it answers `settlement_pending` naming the
|
|
319
358
|
transaction. Over Koios alone the class's settle gives no success, so a payment is answered at that mark. Its guard
|
|
@@ -340,20 +379,323 @@ Each member, one entry per network unless it says otherwise:
|
|
|
340
379
|
`reader`, lcp's `CcdReader` over the seller's node. The record names each payment by the digest of what its sender
|
|
341
380
|
signed, so a payment is never sent twice.
|
|
342
381
|
- **`evm`**: `network`; `rpc`, the seller's JSON-RPC endpoint, which lcp's reads and the fee's read go through; `signer`,
|
|
343
|
-
the seller's gas key (`FacilitatorEvmSigner`, made with `toFacilitatorEvmSigner` over the same node
|
|
382
|
+
the seller's gas key (`FacilitatorEvmSigner`, made with `toFacilitatorEvmSigner` over the same node; for
|
|
383
|
+
`auth-capture` also `signTransaction` and `sendRawTransaction`, `EvmSender`, as the example composes them); `schemes`,
|
|
344
384
|
optional, the schemes registered (`exact`, `upto`, `auth-capture`, `batch-settlement`; all four where absent);
|
|
345
385
|
`eip6492AllowedFactories`, optional, the ERC-6492 factories `exact` and `batch-settlement` may call to deploy a payer's
|
|
346
386
|
wallet (none where absent); `authCapture`, optional, `auth-capture`'s own configuration, passed to its class
|
|
347
387
|
unchanged. Before the class is asked, `exact` refuses an option that pays several payees (a non-empty
|
|
348
388
|
`extra.splits`) and Circle's batched option (`extra.name` `GatewayWalletBatched`, or an `extra.verifyingContract`
|
|
349
|
-
other than the asset), which no published EVM class settles.
|
|
389
|
+
other than the asset), which no published EVM class settles. An EIP-3009 authorization that has already landed, by
|
|
390
|
+
whatever route, is answered at `/verify` as the class answers it where the record holds no row for it: within its
|
|
391
|
+
validity window, `invalid_exact_evm_nonce_already_used`. At `/settle`, `upto` settles the amount its requirements
|
|
392
|
+
state, the charge: requirements that are the option the payment accepted in every member but an `amount` at or below
|
|
393
|
+
the accepted one are held as that option, and the class checks the permit against the accepted maximum, as its own
|
|
394
|
+
settle does; any other requirements are refused `invalid_payload`. Where another transaction
|
|
395
|
+
of the gas key took the nonce of a settle's transaction, viem's `waitForTransactionReceipt` answers that
|
|
396
|
+
transaction's receipt. A settle of `exact` (Permit2 or EIP-3009), `upto` or a `batch-settlement` claim takes it as
|
|
397
|
+
its own only where the node shows that transaction, by its hash, as the same call (the same contract and call data)
|
|
398
|
+
of the same account at the same nonce: the transaction sent, signed again at another fee, which executed this
|
|
399
|
+
payment, and which the answer names. Any other receipt executed nothing of this payment, and the settle is answered
|
|
400
|
+
`settlement_pending` naming its own transaction; so is a settle whose receipt names no transaction (x402's own
|
|
401
|
+
receipt type, a status and logs), unless the node shows the receipt of the transaction waited for. Where the gas key
|
|
402
|
+
gives `signTransaction` and `sendRawTransaction`, as the example composes them, each call of these classes is signed
|
|
403
|
+
before it is sent, so that its account, nonce and call are known whatever the node later shows of it; with a key that
|
|
404
|
+
does not, they are learnt from the node's answer by the transaction's hash, and of a transaction the node never showed
|
|
405
|
+
only the account and nonce are known, once viem answers the receipt of the transaction that took its nonce: any
|
|
406
|
+
transaction a finalized block shows there then lets it go. The transaction `exact` and `upto` keep as a pending settlement, and wait for again on a repeat
|
|
407
|
+
instead of sending, is let go only where one finalized block, read by its hash, shows a different transaction of the
|
|
408
|
+
gas key at its nonce that did not execute its call (another call, or the same call reverted), searched from the node's head as it was signed, so that a node that
|
|
409
|
+
keeps recent state only can show it; the repeat then checks the payment again and sends the same signed
|
|
410
|
+
authorization, which the token or Permit2 executes once. Where that block shows the same call there, executed, nothing is let
|
|
411
|
+
go, and lcp's read answers the payment. Where no finalized block shows it, a repeat waits for the transaction the
|
|
412
|
+
class keeps. The module's own node calls hold a settle at most two seconds before the class's wait for a receipt (the
|
|
413
|
+
proof, on a repeat of a pending settlement; one that takes longer goes on beside the wait, and the next repeat has
|
|
414
|
+
its answer) and at most two seconds after a wait that ended with a receipt that does not name the transaction waited
|
|
415
|
+
for; a wait that ends with the transaction's own receipt, or with none, is held by none. A `batch-settlement` deposit
|
|
416
|
+
whose transaction the node dropped while another transaction of the gas key took its nonce stays `settlement_pending`
|
|
417
|
+
on every repeat, and nothing is sent for it again: the settler gives a deposit's repeat back to no class. `exact`'s `extra.acceptsZero` names
|
|
418
|
+
`x402/exact/eip155/eip3009` alone, and every other kind's is `[]`. On Base Sepolia, USDC's EIP-3009
|
|
419
|
+
`transferWithAuthorization` of 0 succeeds, emitting `AuthorizationUsed` and a `Transfer` of 0 (`eth_simulateV1` at
|
|
420
|
+
block 61198157); at block 61194449, x402's `exact` and `upto` Permit2 proxies revert `InvalidAmount` and the
|
|
421
|
+
commerce-payments escrow's `authorize` reverts `ZeroAmount`; batch settlement's facilitator requires a deposit above
|
|
422
|
+
0. The later messages of the two multi-step schemes, which a resource server sends after the payment opened, go to
|
|
423
|
+
the class as x402's own code sends them: `auth-capture`'s `capture`, `void` and `refund` (x402's lifecycle manager,
|
|
424
|
+
and the hold's own payload the resource server stamps `capture` after its handler or `void` on cancel), and
|
|
425
|
+
`batch-settlement`'s `claim`, `settle` and `refund` (x402's channel manager, whose requirements are its own, at
|
|
426
|
+
amount `"0"`). The class checks each (the receiver authorizer's signature, or its own where `authCapture` delegates
|
|
427
|
+
that authorizer to it; the escrow's or the channel's state), and the escrow or the channel contract bounds what it
|
|
428
|
+
moves by what the opening funded. An escrow message is its own row, keyed by the message its receiver authorizer signs,
|
|
429
|
+
every member it signs and nothing else (the typed-data domain: its name and version, the chain id and the
|
|
430
|
+
`captureAuthorizer`; the payment's hash as the chain id, the escrow and the twelve members of `PaymentInfo` it
|
|
431
|
+
commits to; its type; for a capture its amount, fee receiver, fee and the escrow amounts it expects; for a refund its
|
|
432
|
+
amount, the deployment's refund collector and the amounts it expects), each number as `BigInt` reads it, as the
|
|
433
|
+
class and viem's encoder read it. The void of the payment's remainder a capture may carry is another message the
|
|
434
|
+
receiver authorizer signs, over the payment's hash alone, which the escrow's event of the capture does not show: a
|
|
435
|
+
capture with it and the same capture without it are one row and one body. That message is also
|
|
436
|
+
the row's body (`Instrumented.body`): one message, its numbers spelt in any way `BigInt` reads, or signed again by a
|
|
437
|
+
receiver authorizer whose signatures differ each time, is one row and one body, sent once, and another signature
|
|
438
|
+
over it goes to the class's check, which judges the signature; a message with any other signed member, its fee terms
|
|
439
|
+
among them, is another row. A channel's refund is keyed by the digest of its payload.
|
|
440
|
+
A channel's `refund` is admitted as a later message by its payload's type alone, whoever sends it, the buyer's own
|
|
441
|
+
refund request too (x402's client `refundChannel` sends it under the route's own option, and x402's resource server
|
|
442
|
+
has it verified before it adds the receiver authorizer's signatures and settles): lcp's option filter, lcp's channel
|
|
443
|
+
read and the zero-amount rule are not applied to it. The record (a repeat is answered from its row), what the kind
|
|
444
|
+
declares and the fee budget still hold it, and the class makes the payment's own checks, its `verify` at `/verify`
|
|
445
|
+
and its `settle` at `/settle`. The class settles a refund only with the receiver authorizer's signature, and the
|
|
446
|
+
settler holds no receiver authorizer key. Where `authCapture` delegates the receiver authorizer to the class
|
|
447
|
+
(`authorizerSigner`, `resolveCallerIdentity`), nothing the settler passes authenticates the caller: the context the
|
|
448
|
+
class gives `resolveCallerIdentity` holds the payment, its requirements and x402's facilitator context, in which the
|
|
449
|
+
settler registers no extension. A resolver that identifies the caller by an extension finds none, and the class
|
|
450
|
+
refuses each call it would sign (`invalid_auth_capture_evm_unauthenticated_authorizer_request`); one that derives an
|
|
451
|
+
identity from the payment or its requirements, which the caller writes, makes holding the settler's credential the
|
|
452
|
+
whole authority for a void or a refund the class signs as that authorizer.
|
|
453
|
+
A channel's `claim` and `settle` are not recorded: the manager sends the same settle in every round, and the
|
|
454
|
+
contract claims only above the channel's recorded total and settles only what is claimed and unpaid, to the
|
|
455
|
+
channel's receiver. At `/settle` of a `claim`, `settle` or `refund`, which the batch class's `verify` does not take
|
|
456
|
+
under the manager's requirements, the class's `settle` makes the check, simulating the call before it sends; at
|
|
457
|
+
`/verify` the class's `verify` answers them, as without the settler. An escrow refund for the default `delegated`
|
|
458
|
+
operator is funded by the operator's own address, the seller's gas key: the class refuses it unless `authCapture`
|
|
459
|
+
sets `refundFunding`. An escrow message is read from the escrow itself, by the hash its `getHash` gives the
|
|
460
|
+
message's `PaymentInfo`, since the escrow takes a second identical capture or refund while enough is capturable or
|
|
461
|
+
refundable (a second void reverts). The gas key signs each auth-capture call, the hold's among them, before it is sent
|
|
462
|
+
(`EvmSender`; the settler does not start where `auth-capture` is registered with a key without it): the signed bytes of a capture's, void's or refund's calls are kept in the settler's database until the class answers the message success or the read shows it final, and deleted then; and the transaction is named in the message's
|
|
463
|
+
row by one write that holds only while no later settle has taken the claim (each take of a claim gets the next
|
|
464
|
+
fencing number); where it does not hold, nothing is sent. A repeat's read and its `settlement_pending` answer start
|
|
465
|
+
from the transaction the row names once its sends and namings are done. A repeat reads the transaction the row names first (where
|
|
466
|
+
it replaced another at its nonce, whichever of them the node shows a receipt for):
|
|
467
|
+
reverted, the message is final, `invalid_transaction_state` naming it; executed with the escrow's event of the
|
|
468
|
+
message, settled; held by the node (shown by its hash with no block), `settlement_pending` naming it. One the node
|
|
469
|
+
shows in a block while it answers no receipt for it (a node that dropped old receipts) is not held. Where the node
|
|
470
|
+
shows it, or another signed for the message at its nonce, in a block, and one finalized block shows the gas key's
|
|
471
|
+
transaction at that nonce to be one of them, and the events of the block that holds it, read by that block's hash,
|
|
472
|
+
hold the escrow's event of the message by it, settled, naming it. Before that read, where the network's fee budget
|
|
473
|
+
is not spent, a repeat that passes the
|
|
474
|
+
class's checks (for the void of a capture's remainder, the class's check of that void) treats each transaction the row names, as the `erc7710` module treats a redemption: where the node
|
|
475
|
+
shows one of them by its hash unmined and underpriced, and shows none signed after it at their nonce, its fee cap
|
|
476
|
+
below the base fee of the node's latest block, or its tip (for one priced by `gasPrice` alone, that price less the
|
|
477
|
+
base fee) below the tip the node suggests (`eth_maxPriorityFeePerGas`) a whole settle wait after the last at that
|
|
478
|
+
nonce was signed, the repeat replaces it by the same call at the same nonce, the tip the larger of the tip it offers
|
|
479
|
+
(for one priced by `gasPrice` alone, that price) raised by an eighth and the node's suggestion, the fee cap the
|
|
480
|
+
larger of its own raised by an eighth and twice the base fee and the tip, naming the replacement in the row before
|
|
481
|
+
it is sent, and sending nothing where that naming fails. A replacement whose send fails and that the node does not
|
|
482
|
+
show by its hash is judged only once the node shows it: the row names again the one the node holds, which a later repeat replaces again (on the
|
|
483
|
+
tip alone, a whole settle wait after that replacement was signed). Where the node shows none of the transactions
|
|
484
|
+
signed at a nonce, its `pending` count shows no transaction of the key at that nonce (none held, none mined), and
|
|
485
|
+
the fee cap of the last one signed there is below the base fee of the node's latest block, so that the node would
|
|
486
|
+
refuse its same bytes for their price, the repeat signs the same call again at that nonce with a replacement's fees,
|
|
487
|
+
names it in the row, and sends it. No replacement is signed whose own bound (its gas limit times its fee cap) is
|
|
488
|
+
above the network's whole fee budget, where it has one: the transaction signed before stays the last at its nonce.
|
|
489
|
+
Repeats alone never raise the fees again. Either can land, and the nonce lets one. Nothing else is sent before the read. Then the `pending` transaction count of the gas key's addresses is read, then one block is fixed for the payment's
|
|
490
|
+
`paymentState` and the key's mined count. Where the amounts are still those the message expects (for a void, an
|
|
491
|
+
amount still capturable) and nothing of the key is unmined, a repeat of the identical message, the lifecycle
|
|
492
|
+
manager's own included, goes to the class again once its checks pass again. Before its call is sent, every
|
|
493
|
+
transaction signed for the message is judged. One the settler marked, when it signed it, as not yet named, and that
|
|
494
|
+
the row does not name, was never given to the node (another settle took the claim before its naming, or a stop came
|
|
495
|
+
between the two; the mark is deleted once the naming holds, before its only send that is not a repeat), so it can
|
|
496
|
+
never land and is passed over. One the node shows mined or holds stops the send (another call, a
|
|
497
|
+
capture's before the void that releases its remainder, does not). One the node does not show is no fact about the
|
|
498
|
+
chain: the block the node names `finalized` is read by its hash (EIP-1898) for the gas key's transaction count and
|
|
499
|
+
the escrow's `paymentState` there. Where the count has not passed its nonce, its same signed bytes are sent again,
|
|
500
|
+
and no other (nothing, where the node's `pending` count shows a transaction at that nonce). Where the count has
|
|
501
|
+
passed its nonce and the escrow's amounts there are still those the message expects, it can never execute: the
|
|
502
|
+
escrow's pair of amounts falls strictly with every call that executes, so a pair once left never returns, though the
|
|
503
|
+
escrow itself executes the same capture or refund call twice. Only where every other transaction signed for the
|
|
504
|
+
message is shown so is the call signed at a new nonce: a first send that never reached the node lands on the repeat once
|
|
505
|
+
another transaction of the key at its nonce is finalized. Where the amounts no longer stand, the escrow's events for the
|
|
506
|
+
payment after the block read just before the claim (asked for 2,000 blocks at a time) are replayed from the amounts at
|
|
507
|
+
that block, which are those at the fixed block with the events since undone: this message's event, settled; else the
|
|
508
|
+
event after which the message can never be taken as signed, `invalid_transaction_state` naming it. Where the amounts
|
|
509
|
+
at that block were already past the message, `invalid_transaction_state` naming nothing (`before-position`), once
|
|
510
|
+
that block is finalized. The escrow executes a call whatever amounts its message expects, so neither refusal is
|
|
511
|
+
given while a transaction the settler signed for the message's call may have executed it, or still may: each is
|
|
512
|
+
given only where one finalized block, read by its hash, shows of every such transaction that its nonce is not taken
|
|
513
|
+
there while the amounts there let no call of the message execute any more (nothing capturable for a void, less
|
|
514
|
+
capturable than a capture's amount, less capturable and refundable together than a refund's), or that its nonce is
|
|
515
|
+
taken and what took it is another transaction of the key, or one signed at that nonce that reverted. Where the
|
|
516
|
+
finalized chain shows one of them executed with the message's event, settled, naming it; otherwise
|
|
517
|
+
`settlement_pending` naming the row's transaction. A lookup that finds nothing decides neither. Where
|
|
518
|
+
no block was read before the claim, or the replay settles nothing, `settlement_pending` (`search-incomplete`), which
|
|
519
|
+
is not final. Each final answer is given at the `finalized` block, and one that rests on a transaction's receipt only where that
|
|
520
|
+
receipt's block, named by its hash, is shown on the finalized chain (an ancestor of the finalized block, from that
|
|
521
|
+
block's own hash: by EIP-2935's history contract, in at most 1,024 hops of 8,190 blocks, each read at the block the
|
|
522
|
+
last one showed, a proof's hops going on from the lowest block an earlier proof showed; then, below the lowest block it shows (where the node does not hold the state the next hop reads, or
|
|
523
|
+
the contract answers no hash, as for a block from before its activation), or on a node without it, by reading headers
|
|
524
|
+
by their parents' hashes, at most 1,024 per proof, each proof walking on from the lowest block an earlier one or the
|
|
525
|
+
contract showed, which the module's state keeps, one per 1,024 blocks of the chain; a block deeper than that becomes final over as many
|
|
526
|
+
repeats as the walk takes, and is `settlement_pending` until then; a kept block is used only where the node's own block at its number is that block: one the node does not hold is dropped, and where the node holds another block there, as after a network whose history was replaced, every kept block of the network is dropped; a proof that goes on from a kept block rests on the node's answer by number, so it assumes the node gives one view of the chain: an endpoint answering from backends on different chains can show a block of a replaced history as final); before it, `settlement_pending` naming the
|
|
527
|
+
transaction. So the first answer to a send the escrow reverted is `settlement_pending` naming it while its block is
|
|
528
|
+
above the finalized one, and `invalid_transaction_state` naming it once that block is finalized; only where the
|
|
529
|
+
block is already finalized when the send's answer is read is the first answer the class's own
|
|
530
|
+
(`invalid_auth_capture_evm_transaction_reverted`). The class's own store of a settlement it waited for in vain keeps
|
|
531
|
+
nothing here, in place of any `authCapture.pendingSettlementStore`, so a repeat is decided by the record and the
|
|
532
|
+
read. A capture that releases its remainder (a `voidAuthorizerSignature` that is not empty beside the capture's
|
|
533
|
+
signature, or, for a receiver authorizer the class signs for, `voidRemainder` true) is answered success only once
|
|
534
|
+
its void is mined, or the escrow reverted it, as the class sends that void once its capture settled: where the class
|
|
535
|
+
answers the capture a success and the node holds the void unmined, the answer is `settlement_pending` naming the
|
|
536
|
+
capture and the row stays open until the void is mined, so that a void the node drops is sent again on a repeat;
|
|
537
|
+
where the node does not show the void, it is judged as above at once (its same signed bytes sent again, or nothing),
|
|
538
|
+
and where that fails, or the node cannot say whether it holds it (nothing more is then sent), the answer is
|
|
539
|
+
`settlement_pending` naming the capture; where the class's capture fails
|
|
540
|
+
after a send the escrow took (its answer lost), the void is sent at once; where the capture is read landed and
|
|
541
|
+
finalized, the remainder still capturable at the finalized block, and nothing of the key unmined, a repeat sends only
|
|
542
|
+
the void, its check the class's check of that void, made only where a transaction the claim itself named holds the
|
|
543
|
+
capture's event, and answers success naming the capture. A success the module gives for such a capture carries the
|
|
544
|
+
capture's own amount, never the void's; one the core gives from its read of the chain (a repeat once a void held
|
|
545
|
+
unmined is mined) carries no amount, as for any payment it answers from the read. A void the escrow reverted is not sent again, and the
|
|
546
|
+
capture is answered as landed. The void a capture's claim carries is recorded before anything is sent for it, so
|
|
547
|
+
that while it is due, whichever body of the row is presented next (the same capture without it among them) sends it,
|
|
548
|
+
and the row is not final before it. A capture with the void presented after the same capture without it was answered
|
|
549
|
+
is answered from that row, and its void is not sent. A transaction the settler names for an escrow message and
|
|
550
|
+
sends is answered `settlement_pending` naming it, whatever failure the class answers, until the read shows the
|
|
551
|
+
message final.
|
|
552
|
+
Limits: a node that does not answer reads at a block named by its hash (EIP-1898) never lets a message be signed at
|
|
553
|
+
a new nonce, so a first send that never reached it stays `settlement_pending`; a message whose own transaction never
|
|
554
|
+
reached a node, and whose expected amounts another sender's call left while the escrow would still execute it, stays
|
|
555
|
+
`settlement_pending` until another transaction of the gas key at its nonce is finalized; a node that holds neither
|
|
556
|
+
the receipt of an old transaction nor the events and state of its block (a node that keeps recent history only)
|
|
557
|
+
leaves a message that landed by it `settlement_pending`; and where the block read just before the claim could not be
|
|
558
|
+
read, the node's head is read again before the message's first signing and kept in the module's state, nothing
|
|
559
|
+
being signed where it cannot be read. A channel refund (`batch-settlement`'s `refund`) is read by its
|
|
560
|
+
receipt: one the finalized chain shows mined and reverted (its receipt's block, by its hash, shown on the finalized
|
|
561
|
+
chain) is answered `settlement_pending` naming it while its block is above the
|
|
562
|
+
finalized one, and final once that block is finalized, `invalid_transaction_state` naming it, by every repeat. One
|
|
563
|
+
the finalized chain shows mined and executed, whose own receipt in that block holds the channel contract's
|
|
564
|
+
`Refunded` for the channel its `channelConfig` names, is answered the same way while its block is above the finalized
|
|
565
|
+
one, and once it is finalized is the success, naming it, the row final, so that a refund whose first answer was lost
|
|
566
|
+
is answered once it is shown; any other refund not answered a success stays `settlement_pending`. The refund is sent by x402's class, once, for its
|
|
567
|
+
row: a repeat of the same refund payload sends nothing, and x402's channel manager signing the refund of the same
|
|
568
|
+
channel again, with a receiver authorizer that signs deterministically, makes the same payload, so a refund the chain
|
|
569
|
+
reverted is never sent again by the settler, whether or not the reason it reverted has passed. A refund signed over
|
|
570
|
+
other members is another row, sent once the class's own simulation of it passes.
|
|
350
571
|
- **`erc7710`**: `network`; `rpc`; `signer`, the seller's gas key, whose node must answer `eth_simulateV1`. The key
|
|
351
572
|
sends from its first address, so that address is the delegate the leaf delegation must name (or the reference
|
|
352
573
|
implementation's wildcard delegate), and the account the simulation runs from. It registers nothing of its own: on
|
|
353
574
|
each of its networks it is offered to the `evm` module's `exact` registration, which hands it every payment whose
|
|
354
575
|
option names `erc7710`. The settler does not start where the `evm` module does not register `exact` on such a
|
|
355
576
|
network. It simulates the redemption the payment names, then calls `redeemDelegations` on the delegation manager the
|
|
356
|
-
payload names, with one execution that transfers the option's amount to `payTo`.
|
|
577
|
+
payload names, with one execution that transfers the option's amount to `payTo`. The signer must also give
|
|
578
|
+
`signTransaction` (a transaction to `to` with `data`, signed and not sent, its nonce, gas and fees filled; with viem,
|
|
579
|
+
`signTransaction: async (r) => client.signTransaction(await client.prepareTransactionRequest(r))`) and
|
|
580
|
+
`sendRawTransaction` (viem's, `(r) => client.sendRawTransaction(r)`): the module signs the redemption first, keeps
|
|
581
|
+
the signed bytes in its state, and the record holds their hash before they are sent, since the level that signs no H
|
|
582
|
+
(`x402/exact/eip155/erc7710`) is found only by the transaction the record holds. A send that fails is read on by
|
|
583
|
+
that hash whatever the failure, a lost answer, a send that never reached the node or the node's JSON-RPC error alike,
|
|
584
|
+
since none shows that the node took nothing. A repeat that takes the claim sends the same bytes again where the
|
|
585
|
+
transaction count of the key that signed them, at the finalized block, has not passed their nonce, its pending count
|
|
586
|
+
is not above that nonce (the node holds no transaction of the key there), and no other sale's redemption under the same root delegator is in flight (the repeat then holds that mark, naming them),
|
|
587
|
+
so a send that never reached the node, or a stop before it, is made by the repeat; a nonce is taken once, so the
|
|
588
|
+
bytes land at most once. Where the node shows one of them by its hash unmined and underpriced, and shows none signed
|
|
589
|
+
after it at their nonce, its fee cap below the base fee of the node's latest block, or its tip (for one priced by
|
|
590
|
+
`gasPrice` alone, that price less the base fee) below the tip the node suggests (`eth_maxPriorityFeePerGas`) a whole
|
|
591
|
+
settle wait after the last at that nonce was signed, the repeat replaces it by the same call at the same nonce, the
|
|
592
|
+
tip the larger of the tip it offers (for one priced by `gasPrice` alone, that price) raised by an eighth and the
|
|
593
|
+
node's suggestion, the fee cap the larger of its own raised by an eighth and twice the base fee and the tip, naming
|
|
594
|
+
the replacement in the row before it is sent. A replacement whose send fails and that the node does not show by its
|
|
595
|
+
hash is judged only once the node shows it: the row names again the one the node holds, which a later repeat replaces again (on the
|
|
596
|
+
tip alone, a whole settle wait after that replacement was signed); where the node shows it later, the next repeat
|
|
597
|
+
of the sale names it in the row. A replacement the node refuses stays named, since it may have reached another node:
|
|
598
|
+
with a signer whose signatures differ each time (one that draws its own k), each refused repeat adds one name to the
|
|
599
|
+
row, for as long as the node refuses. Repeats alone never raise the fees again, only a base fee or a suggested tip that rises. The signer's
|
|
600
|
+
`signTransaction` must sign with the fee members the request names. Either can land, and the nonce lets one. The
|
|
601
|
+
same bytes are named in the row again before they are sent, and neither they nor a replacement is sent on a repeat
|
|
602
|
+
where the network's fee budget is spent ([the fee budget](#the-fee-budget)). A new
|
|
603
|
+
nonce is signed only where one finalized block shows that a different transaction took the nonce: the key's count,
|
|
604
|
+
read by the finalized block's hash (EIP-1898), has passed the nonce; the block in which it passed it, found by
|
|
605
|
+
halving the range from the block the node's head was when the redemption was signed, is read by its hash, the
|
|
606
|
+
count is above the nonce there and not at its parent, both read by hash; that block is an ancestor of the finalized
|
|
607
|
+
block, shown from the finalized block's hash through EIP-2935's history contract and, below the lowest block it
|
|
608
|
+
shows or on a node without it, by reading headers by their parents' hashes, at most 1,024 per proof, each proof
|
|
609
|
+
walking on from the lowest block an earlier one or the contract showed (a kept block used only where the node's
|
|
610
|
+
own block at its number is that block, as the `evm` module's passage states); and that block holds the key's transaction at the nonce,
|
|
611
|
+
whose hash is none of those signed at it. The row then stops naming the hash, nothing is sent on that
|
|
612
|
+
repeat, and the claim is answered `unexpected_settle_error`; the next repeat finds the row naming none and redeems
|
|
613
|
+
the sale by a new transaction. Where that block holds one of those signed at the nonce, it landed, and nothing is
|
|
614
|
+
sent again. The search for the block in which the count passed the nonce runs on the first repeat that finds the
|
|
615
|
+
count at the finalized block past it, and the module's state keeps what it found: the range it narrowed, and the
|
|
616
|
+
block itself once the counts by its hash show it, so that later repeats read no count there again and need only
|
|
617
|
+
the finalized block's state, headers and that block's transactions. A lookup by hash that finds nothing is no part
|
|
618
|
+
of the proof: where the node does not hold the finalized block, the block in which the count passed the nonce, or
|
|
619
|
+
the state the search reads, the ancestry is not yet shown, or a read fails, the row keeps naming the hash and
|
|
620
|
+
nothing is sent on that repeat. A block more than 1,024 blocks below the lowest block the history contract shows, or
|
|
621
|
+
below the finalized one on a node without it, is shown over as many repeats as the walk takes, once the block has
|
|
622
|
+
been found. The search reads the key's count at blocks from the one the node's head was when the redemption was
|
|
623
|
+
signed up to the finalized one, which a node that keeps the state of recent blocks only, as a pruning node does,
|
|
624
|
+
holds only for its last blocks. Where the node does not serve a count, the proof rests on what it does serve, never
|
|
625
|
+
on a lookup that found nothing: the search goes on above the blocks whose count it does not serve, and from the
|
|
626
|
+
node's latest block where it serves none at the finalized one, so that the block is found, and kept, while the node
|
|
627
|
+
holds its state, before it is final; a transaction signed at the nonce that the node shows mined names its block;
|
|
628
|
+
and the blocks above the one the node's head was at signing are read whole, at most 8 on a repeat and 256 in all,
|
|
629
|
+
for the key's transaction at the nonce. A block so found is read by its hash, holds the key's transaction at the
|
|
630
|
+
nonce, and is shown an ancestor of the finalized block as above, or through the history contract read at the node's
|
|
631
|
+
latest block, before anything rests on it; the counts by its hash and its parent's are read too and, where the node
|
|
632
|
+
serves them, never contradict it. Where none of these finds the block (no head was noted at signing, or the nonce
|
|
633
|
+
was taken more than 256 blocks above it, on a node that no longer holds that state), the redemption stays
|
|
634
|
+
`settlement_pending` and nothing more is sent for that sale, until a node that holds that state is the seller's
|
|
635
|
+
`rpc`; the proof's answer names the reads the node did not serve. The module's calls for these proofs are at most
|
|
636
|
+
four at once at an endpoint, and are spaced after it answers that it is asked too fast. On the
|
|
637
|
+
level that signs no H, a named redemption the node mined and reverted, its receipt's block, by
|
|
638
|
+
its hash, shown on the finalized chain below the finalized block's own hash, is final, `invalid_transaction_state` naming it: the module reads that receipt itself,
|
|
639
|
+
since lcp reads a reverted named transaction as pending (the profile, rule 8) and nothing else can show that sale
|
|
640
|
+
paid, and nothing named is sent again; above the finalized block it is `settlement_pending` naming it. On the salt
|
|
641
|
+
level such a redemption stays `settlement_pending` naming it, since lcp's search for H, never read whole, can still
|
|
642
|
+
meet another redemption carrying H. The seller can settle such a sale outside the settler by reading the chain for
|
|
643
|
+
a redemption that carries H, the reverted one the answer names or any other: the reference DelegationManager's
|
|
644
|
+
`RedeemedDelegation` logs with the payer as root delegator, a transaction that did not revert, whose delegation
|
|
645
|
+
carries H as its salt (the profile, rule 10). One transaction is one sale's payment, before its receipt and after
|
|
646
|
+
it: the module keeps, by the hash of each redemption it signs, the sale it was signed for, and where a signing gives
|
|
647
|
+
a sale the bytes of another sale's redemption (the level that signs no H gives two sales of one price the same call;
|
|
648
|
+
a signer answered by a node behind signs it at a nonce already taken, which is then the same transaction) nothing is
|
|
649
|
+
sent or named for that sale, and it is answered `unexpected_settle_error`; its repeat signs again, and is redeemed by
|
|
650
|
+
its own transaction once the signer is answered the key's next nonce. That record goes only once the key's
|
|
651
|
+
transaction count at the block the node names `finalized`, read by that block's hash, is above the redemption's
|
|
652
|
+
nonce; the module keeps that count as the key's floor, which never falls, and sends nothing signed below it. So the
|
|
653
|
+
records kept are one for each redemption signed at a nonce the finalized chain had not passed when the module last
|
|
654
|
+
sent a redemption, and one list of them for each key. Where several redemptions were signed at one nonce and the
|
|
655
|
+
node shows one of them mined, a repeat names that one in the row, so that the read is of the one that landed. A
|
|
656
|
+
redemption whose buyer never asks again does not hold back the other sales: where it never reached the node and the
|
|
657
|
+
next sale of the same price signs the same bytes, that sale's settle sends those bytes for the sale that owns them,
|
|
658
|
+
as that sale's own repeat would (their nonce still the key's next, the finalized chain not past it, the node holding
|
|
659
|
+
nothing there, under the mark, which passes to their sale), and is itself answered `unexpected_settle_error`, its
|
|
660
|
+
repeat redeemed by its own transaction; and where the node holds it unmined and underpriced, at the lowest unmined
|
|
661
|
+
nonce of the gas key or under the mark a later sale of the same root delegator waits on, that sale's settle or
|
|
662
|
+
repeat replaces it by the rule above, for the sale that owns it. Such a replacement is not in the other sale's row
|
|
663
|
+
when it is sent: it is kept, with the sale it is for, among those signed at its nonce, and that sale's next repeat
|
|
664
|
+
names it in its row before it judges any of them, and counts it against the fee budget then. Only a redemption the
|
|
665
|
+
key that signed it still signs for is replaced. One redemption
|
|
666
|
+
per sale: each sale through a delegation is its own row, keyed by the delegation and the H the payment echoes, and
|
|
667
|
+
the same sale presented again, in sequence or at once, is answered from its row. x402's ERC-7710 is one-time or
|
|
668
|
+
multi-use, its caveats the limit, so a second sale through a multi-use delegation is redeemed where its simulation
|
|
669
|
+
shows the transfer. On the level that signs no H the H is not signed, so whoever presents the payload chooses it:
|
|
670
|
+
what can be redeemed through one delegation, beyond what the delegator holds, is bounded by the caveats the
|
|
671
|
+
delegator signed, and by nothing else. One
|
|
672
|
+
redemption per root delegator (the payload's `delegator`, whose funds the transfer moves) is in flight at a time on
|
|
673
|
+
a network, whatever delegation it comes through: a second sale's settle waits, up to half the settle wait, until
|
|
674
|
+
the first's is mined or can never land, and only then simulates its own, so that two leaves under one root
|
|
675
|
+
delegation, or two delegations of one delegator, are simulated one after the other and a delegation with one use
|
|
676
|
+
left is sent once; where the wait ends first, nothing is sent and the answer is `unexpected_settle_error`. The
|
|
677
|
+
first's mark ends only on what the node shows, never on its age once it names a redemption: the redemption, or
|
|
678
|
+
another signed at its nonce (one it replaced, or its replacement), mined (a receipt, or the node's answer for its
|
|
679
|
+
hash naming a block), or, where the gas key signed it, the key's count at the node's latest block past that nonce;
|
|
680
|
+
one finalized block showing that it or another transaction took its nonce, or the signing key's count at the
|
|
681
|
+
finalized block, read by its hash, past its nonce; or, where the gas key signed it, the node's pending count showing
|
|
682
|
+
no transaction of the key at that nonce, which is still the key's next, and then the second sale's redemption is
|
|
683
|
+
signed at that same nonce, so that of the two one can land. Where the second sends nothing, the mark keeps naming
|
|
684
|
+
that nonce for the next sale, which is signed at it only where the node's pending count, read just before signing,
|
|
685
|
+
shows no transaction of the key held there, whichever scheme sent it. That mark ends once the nonce is taken: the
|
|
686
|
+
gas key's count at the node's latest block past it, or, for a key the settler no longer signs with, that key's count
|
|
687
|
+
at the finalized block past it; meanwhile a repeat of the sale whose redemption it names may still send, or replace,
|
|
688
|
+
those kept bytes at that nonce. So the module never signs at a nonce at which the node holds a transaction of the
|
|
689
|
+
gas key, other than its own replacement of the sale's own held redemption, and a pending count it could not read
|
|
690
|
+
signs nothing. A lookup by hash that finds nothing ends nothing: while the node's pending count shows a transaction
|
|
691
|
+
at that nonce, the second sale is sent nothing, however long the first waits unmined. A redemption signed by a key
|
|
692
|
+
the settler no longer signs with ends its mark only on a receipt, the node's answer naming its block, or a finalized
|
|
693
|
+
fact about that key's nonce. A mark whose settle named no redemption,
|
|
694
|
+
which therefore sent none, lapses after the settle wait; that settle then sends nothing, since it names its
|
|
695
|
+
redemption by swapping the mark it holds. A transaction is one
|
|
696
|
+
sale's: two sales of one price on the level that signs no H are one call, and signed at one nonce the same bytes,
|
|
697
|
+
so such a redemption is not sent for the second sale, answered `unexpected_settle_error`; its repeat, which is
|
|
698
|
+
submitted again since nothing of it was sent, redeems it by its own transaction once the key's nonce has moved on.
|
|
357
699
|
- **`hedera`**: `network`; `signer`, the seller's fee-payer account and its key (`FacilitatorHederaSigner`): the class
|
|
358
700
|
takes only a payment whose transaction id names an account it manages as `extra.feePayer`; `mirror`, the seller's
|
|
359
701
|
Mirror Node REST base URL, which lcp's read and the fee count use; `archival`, optional, true where it holds every
|
|
@@ -375,32 +717,95 @@ Each member, one entry per network unless it says otherwise:
|
|
|
375
717
|
pruning node discards the state of older blocks, and a block that holds the extrinsic and whose state is discarded
|
|
376
718
|
keeps the answer `settlement_pending`. The runtime metadata is loaded on the first payment for the network, and again
|
|
377
719
|
whenever the node's runtime version changes. A success names `<block hash>-<extrinsic index>`; a pending answer
|
|
378
|
-
names the extrinsic's hash.
|
|
720
|
+
names the extrinsic's hash. The kind's `extra.acceptsZero` is `[]`: lcp's option filter takes a positive amount only
|
|
721
|
+
(its profile's rule 1), and a `transfer_keep_alive` of 0, dry-run on Westend Asset Hub at block 19635446, dispatches
|
|
722
|
+
and emits no event.
|
|
379
723
|
- **`solana`**: `network`; `node`, the seller's JSON-RPC endpoint, one whose `getFirstAvailableBlock` is at or below the
|
|
380
724
|
slot at which each payment was issued; `signer`, the seller's fee payer (`FacilitatorSvmSigner`), which co-signs every
|
|
381
725
|
transaction the payer signed and, on the channel forms, pays the channel's rent; `transactionVersions`, optional, the
|
|
382
726
|
message versions the classes accept (their default `[0, 1]`). `upto` and `batch-settlement` need the payment-channels
|
|
383
727
|
program, which is deployed on devnet and testnet and not on mainnet: on Solana mainnet
|
|
384
728
|
(`solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp`) only `exact` is registered. Their channels are kept in the settler's
|
|
385
|
-
database.
|
|
729
|
+
database. `upto` is settled in the order x402's `upto` resource server sends it: `/verify` of the opening as the buyer
|
|
730
|
+
sent it, then `/settle` of its deposit before the resource server's handler runs and of its claim after, each
|
|
731
|
+
carrying the `type` (`deposit`, `claim`) that server adds. A claim needs the voucher of the option's
|
|
732
|
+
`extra.receiverAuthorizer`, which the module does not sign: the resource server signs it with its own key. A claim
|
|
733
|
+
is read from its channel: it has landed where a finalized transaction on the channel succeeded with the
|
|
734
|
+
payment-channels program's `settle_and_seal` of it and, for a positive amount, the ed25519 check of the claim's own
|
|
735
|
+
voucher signature, and it has not landed while the channel account reads `Open`. A claim landed by another route, a
|
|
736
|
+
transaction the settler did not name, that carries the presented claim's voucher signature is read as the body
|
|
737
|
+
presented only for a row the settler gave to the class at a `confirmed` slot below the slot the transaction landed
|
|
738
|
+
in, which the module keeps when it first gives the row to the class, and of those, for the first row read against
|
|
739
|
+
the transaction: the voucher covers the channel, the amount and the expiry and no other member of the body. So the
|
|
740
|
+
identical claim, given to the class before it landed by another route, is answered success where it is the first
|
|
741
|
+
such row read against the transaction; any other body carrying the same voucher, and a body first given at a
|
|
742
|
+
`confirmed` slot at or past the one the transaction landed in, is answered `invalid_transaction_state`. A body given
|
|
743
|
+
after the transaction landed but while `node`'s `confirmed` slot was still below it counts as given before: how wide
|
|
744
|
+
that window is depends on how far `node` lags the cluster. A transaction the settler named is decided by the row
|
|
745
|
+
that named it. Each transaction the class sends for a claim is kept in the claim's row, with its blockhash in the
|
|
746
|
+
module's state, before it is sent; it is not sent where either cannot be kept or another settle has taken the claim.
|
|
747
|
+
A transaction sent for a claim can no longer land where the node shows it landed and failed at `finalized`, or where
|
|
748
|
+
the node holds no status for it and its blockhash has ended: `isBlockhashValid` answers `false` at `finalized` at a
|
|
749
|
+
`finalized` slot at least 150 past the context slot of the first answer of `true` at `confirmed`, the rule of lcp's
|
|
750
|
+
`x402-upto-solana` profile. The module asks `node` for that first `true` just before the send, and at each read
|
|
751
|
+
until one comes. A node answers `false` at `finalized` for a blockhash its `finalized` bank does not hold yet as
|
|
752
|
+
well (a signer that builds on a `confirmed` blockhash, or a `node` behind the signer's node), so until such a `true`
|
|
753
|
+
is seen, and until the bound is passed, the claim stays `settlement_pending` naming the transaction, and nothing is
|
|
754
|
+
sent again. x402's `upto` class (`@x402/svm` 2.31.0) keeps each channel's claim in a window of its own process for
|
|
755
|
+
120 seconds from the settle that opened it, released only where that settle's simulation failed or it failed
|
|
756
|
+
outright: within the window, that process answers another settle of the channel `duplicate_settlement` and sends
|
|
757
|
+
nothing. So after a claim whose send never reached the node, the settler that sent it answers the repeats
|
|
758
|
+
`settlement_pending` naming that transaction until its blockhash has ended, then gives the claim to its class again,
|
|
759
|
+
which answers `duplicate_settlement`, sending nothing, until the window closes; another settler process on the same
|
|
760
|
+
database has a window of its own. A claim's voucher expires at the opening's time plus the route's
|
|
761
|
+
`maxTimeoutSeconds`, after which the class refuses it (`invalid_upto_svm_payload_expired`): where it expires inside
|
|
762
|
+
the window, that settler can no longer make the claim, and the channel stays open with nothing paid to the seller.
|
|
763
|
+
The settler enforces no floor on `maxTimeoutSeconds`. On a local validator (Agave 4.4.1), with one settler process
|
|
764
|
+
and a claim whose first send never reached the node, the claim was paid about 122 seconds after its first settle, at
|
|
765
|
+
blocks of about 125 ms and of about 420 ms alike, and the voucher counts from the opening: at blocks of about 420 ms,
|
|
766
|
+
a route of 150 seconds paid a claim made 16 seconds after the opening and did not pay one made 40 seconds after it,
|
|
767
|
+
and a route of 60 seconds was not paid. So, as guidance, give a Solana `upto` route at least about 125 seconds more
|
|
768
|
+
than the longest time from the opening to the claim: 150 seconds covers a claim made within about 25 seconds of the
|
|
769
|
+
opening, and the 300 that x402's resource server sets where the route names none (`@x402/core` 2.31.0,
|
|
770
|
+
`buildPaymentRequirements`) one made within about 175 seconds.
|
|
771
|
+
The read lists one page of the channel's signatures, the latest 1,000 at `finalized`: where more than 1,000
|
|
772
|
+
transactions name the channel's address after the claim's, which anyone can add, a landed claim reads not shown
|
|
773
|
+
(`search-incomplete`), and its repeats are never answered success. `batch-settlement`'s `claim`, `seal` and
|
|
774
|
+
`settle`, which x402's channel manager sends, go to the class's `settle`, which checks each before it sends anything
|
|
775
|
+
(the channel, its status, and the payer authorizer's voucher), each time they are sent: they are not recorded, and
|
|
776
|
+
the program moves nothing twice for them; the class's `verify`, which takes only what a buyer sends, answers them at
|
|
777
|
+
`/verify`.
|
|
386
778
|
- **`starknet`**: an object `{ networks }`, one entry per network: `network`; `rpc`, a JSON-RPC node (specification 0.9
|
|
387
779
|
or later) that serves `starknet_traceTransaction` and `starknet_simulateTransactions`; `executor`, an `address` and
|
|
388
780
|
its `signer`, the account the payer's outside execution names as its caller, stated as `extra.feePayer`, which
|
|
389
781
|
sends and pays for the transaction that executes it; `maxFee`, optional, the most one settlement's resource bounds
|
|
390
782
|
may pay, in fri; `skewMarginSeconds` (default 60) and `minSettleMarginSeconds` (default 30), optional, the scheme's
|
|
391
783
|
margins. x402 specifies Starknet and publishes no code for it, so the module is written to x402's scheme text and
|
|
392
|
-
lcp's profile.
|
|
784
|
+
lcp's profile. On `starknet:SN_SEPOLIA` the kind's `extra.acceptsZero` names `x402/exact/starknet`, and an option of
|
|
785
|
+
amount `"0"` is taken on STRK (`0x4718f5a0fc34cc1af16a1cdee98ffb20c31f5cd61d6ab07201858f4287c938d`) and USDC
|
|
786
|
+
(`0x53b40a647cedfca6ca84f542a0fe36736031905a9639a7f19a3c1e66bfd5080`), the tokens on which lcp's `starknetFloor`
|
|
787
|
+
answers 0 (its profile's rule 24): a `transfer` of 0 of each, simulated on Starknet Sepolia at block 18422698, emits a
|
|
788
|
+
`Transfer` of 0. lcp refuses `"0"` on any other token, `starknet/option-malformed`, which the module answers
|
|
789
|
+
`invalid_payment_requirements`. On `starknet:SN_MAIN` the list is `[]`.
|
|
393
790
|
- **`stellar`**: an object `{ networks }`: `network`; `rpc`, a Stellar RPC endpoint that holds the history the read
|
|
394
791
|
searches; `source`, the seller's funded account as a signer (`address` and `signTransaction`, such as x402's
|
|
395
792
|
`createEd25519Signer` of `@x402/stellar` or a SEP-43 wallet), the transaction's source, which pays its fee;
|
|
396
|
-
`maxTransactionFeeStroops`, optional (default 50,000)
|
|
397
|
-
100)
|
|
793
|
+
`maxTransactionFeeStroops`, optional (default 50,000); `inclusionFeeStroops`, optional (at least 100, default
|
|
794
|
+
100); and `eventsTimeoutMs`, optional, the most one `getEvents` call of the read may take (without it, each is bounded
|
|
795
|
+
by the read's deadline alone, since an RPC scans up to 10,000 ledgers per call). It serves the agreement form, the option whose `extra.assetTransferMethod` is `lcp-precondition`: the module
|
|
398
796
|
builds the transaction around the buyer's operation and preconditions, unchanged, signs it as its source, and carries
|
|
399
797
|
the buyer's payload signature with its own.
|
|
400
798
|
- **`sui`**: an object `{ networks }`: `network` (`sui:mainnet`, `sui:testnet` or `sui:devnet`); `graphql`, the seller's
|
|
401
799
|
GraphQL endpoint. It serves the path where the buyer pays gas and the gasless path (`extra.gasless`), and holds no
|
|
402
|
-
key. A transaction
|
|
403
|
-
|
|
800
|
+
key. A transaction already executed is refused at `/verify`, `invalid_transaction_state` (`sui/executed-by-payer`),
|
|
801
|
+
whoever presents it, since `isValid: true` tells the caller that a settle may follow; its `/settle` answers a failure
|
|
802
|
+
naming it. One not executed is refused `invalid_transaction`
|
|
803
|
+
(`sui/object-version-unavailable`) where the GraphQL endpoint shows an object it names at a version (its gas payment,
|
|
804
|
+
each owned or immutable input, each object it receives) at a later version, no longer live, or held under another
|
|
805
|
+
digest at that version: Sui's simulation answers success for it, and execution refuses it. The kind's `extra.acceptsZero` names `x402/exact/sui`: a
|
|
806
|
+
transfer of 0 executes where the buyer pays gas (Sui testnet transaction
|
|
807
|
+
`7EjfN1kqGng3phZjqgCzy8RRRXCP2Ybt7mikGgjBUwKA`, status `SUCCESS`, its only balance change the sender's gas), and at
|
|
808
|
+
0 the signed transfer must name the option's payee. lcp's option filter refuses 0 on the gasless path.
|
|
404
809
|
- **`ton`**: `network`; `signer`, the seller's highload-v3 wallet and its node (`FacilitatorTvmSigner`), which relays
|
|
405
810
|
the payer's W5 request in a message of its own and pays its gas; `reader`, lcp's `TvmReader` over the seller's TON
|
|
406
811
|
Center v3 index.
|
|
@@ -409,11 +814,84 @@ Each member, one entry per network unless it says otherwise:
|
|
|
409
814
|
pays every fee.
|
|
410
815
|
- **`xrpl`**: `network`; `node`, the seller's rippled or Clio JSON-RPC endpoint, holding the ledgers from each payment's
|
|
411
816
|
issue to the validated ledger; `waitMs`, optional, how long a settle waits for its transaction in a validated ledger
|
|
412
|
-
(default 30 000); `maxFeeDrops`, optional, the most fee a payment may sign (the class's default, 10 000).
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
817
|
+
(default 30 000); `maxFeeDrops`, optional, the most fee a payment may sign (the class's default, 10 000). The node may
|
|
818
|
+
answer in API version 1's members or version 2's (`tx` answers `tx` and `meta`, or `tx_blob` and `meta_blob`). lcp's
|
|
819
|
+
read searches the payer's history to the validated ledger `server_info` names. A `tx` answer in no validated ledger
|
|
820
|
+
and with no metadata, as rippled answers for a submission it refused and keeps (`tefPAST_SEQ`, `tefMAX_LEDGER`) or for
|
|
821
|
+
one no closed ledger holds yet, reads as not found, never as a search read whole: lcp's read then decides by the
|
|
822
|
+
payer's account. Both paths refuse a payment that names a `Delegate` or carries `Memos`, as x402's scheme requires.
|
|
823
|
+
The multisigned path checks the `Payment`'s `Destination`, `DestinationTag` and `Amount` against the requirements, the
|
|
824
|
+
tag by the class's rule (where the requirements name one, a 32-bit unsigned integer the `Payment` carries; where they
|
|
825
|
+
name none, any); `SendMax` by the class's rule (none on XRP; on an issued currency, required, of the `Amount`'s
|
|
826
|
+
currency and issuer and no less than it); no `Paths`, no `DeliverMin` and no partial-payment flag; the fee against
|
|
827
|
+
`maxFeeDrops`; and `LastLedgerSequence` by the class's rule (`verifyLedgerExpiry`): above the validated ledger,
|
|
828
|
+
else `invalid_exact_xrpl_payload_expired`, and at most the class's `getMaxLastLedgerSequence`, the validated ledger
|
|
829
|
+
plus the requirements' `maxTimeoutSeconds` divided by 5 and rounded up, plus 2, else
|
|
830
|
+
`invalid_exact_xrpl_payload_lastledgersequence_too_large`. Each signer is held to rippled's rule for its key: its
|
|
831
|
+
regular key, or its master key where that is not disabled; a signer list's
|
|
832
|
+
entry need not be a funded account, and one that is not signs with the key its address derives from. For `upto`, the
|
|
833
|
+
payer opens a payment channel to `payTo` and signs one claim off the ledger; at `/settle` the resource server adds
|
|
834
|
+
`settlementTransaction`, a `PaymentChannelClaim` its `payTo` key signed for the actual charge with `tfClose`, which
|
|
835
|
+
the module checks and submits unchanged; `/verify` refuses a payload that already carries one, and `/settle` refuses
|
|
836
|
+
one that carries none with `invalid_upto_xrpl_missing_settlement_transaction` at any charge, as the scheme requires.
|
|
837
|
+
A settle-time `amount` that is not a string of canonical drops (zero, or a positive decimal with no sign, space or leading zero,
|
|
838
|
+
below 10^17) is refused `invalid_payment_requirements` (`x402/option-malformed`) before anything is submitted. A
|
|
839
|
+
claim in a validated ledger with `tesSUCCESS` is a success only where its metadata shows the channel's `Balance` at or
|
|
840
|
+
above the charge: a claim on a channel that expired by the ledger it lands in closes it delivering nothing and still
|
|
841
|
+
answers `tesSUCCESS`. Metadata that shows no node of the channel does not show what the claim did, and is unreadable,
|
|
842
|
+
never a failure: `/settle` answers `settlement_pending` naming the claim, and a repeat reads it again. Against such
|
|
843
|
+
metadata a bare close is judged by the presented `amount`; a repeat whose `amount` is not canonical drops is
|
|
844
|
+
unreadable as well, answered `settlement_pending` naming the claim, and the row stays open. Nothing bounds that
|
|
845
|
+
state: a validated transaction's metadata does not change, so on a node that leaves the channel's node out, every
|
|
846
|
+
repeat of a claim that carries a `Balance`, and every repeat of a bare close at a charge above zero or one that is
|
|
847
|
+
not canonical drops, is answered `settlement_pending`, until an answer that shows the node, from another server or a
|
|
848
|
+
corrected one; a bare close repeated at a charge of `"0"` asks nothing, and is answered by the read. `/settle`
|
|
849
|
+
answers a claim short of the charge `transaction_failed`; a repeat of the payment, after that answer or after a lost
|
|
850
|
+
one, is answered `invalid_transaction_state` naming the claim, and the row is final. A repeat after a lost answer is
|
|
851
|
+
judged by the charge of the claim the record holds, the `Balance` it carries, whoever presents the payment next; one
|
|
852
|
+
that presents another claim is answered `invalid_transaction_state` naming the record's, and the row is left as it
|
|
853
|
+
was.
|
|
854
|
+
|
|
855
|
+
The `cardano`, `concordium` and `ton` modules take an lcp reader in `reader` rather than a node's URL, and lcp ships the
|
|
856
|
+
interface but no implementation: `CardanoReader` of `@integraledger/lcp/cardano`, `CcdReader` of
|
|
857
|
+
`@integraledger/lcp/ccd` and `TvmReader` of `@integraledger/lcp/tvm`, each documented member by member on its API page
|
|
858
|
+
([`cardano`](https://github.com/IntegraLedger/integra-protocol/blob/main/docs/reference/api/cardano.md),
|
|
859
|
+
[`ccd`](https://github.com/IntegraLedger/integra-protocol/blob/main/docs/reference/api/ccd.md),
|
|
860
|
+
[`tvm`](https://github.com/IntegraLedger/integra-protocol/blob/main/docs/reference/api/tvm.md)), with the calls each
|
|
861
|
+
makes in
|
|
862
|
+
[Rails: reading settlement](https://github.com/IntegraLedger/integra-protocol/blob/main/docs/guides/rails.md#reading-settlement).
|
|
863
|
+
Write one over your own indexer or node. Its `network` is the module's `network`: the module refuses to start where they
|
|
864
|
+
differ. Each call is read-only and bounded by your own timeout and byte limit, and rejects on any failure, with lcp's
|
|
865
|
+
`ReaderError` (`@integraledger/lcp/evm`) where the kind is known: a rejection reads as `unreadable`, never as absence.
|
|
866
|
+
An item the endpoint does not hold is answered only in the form the interface names for it (`null`, or
|
|
867
|
+
`{ notFound: true, ... }` with the point the interface asks for), and only where the endpoint answered in the form it
|
|
868
|
+
documents for a missing item. lcp makes no other call, so the endpoint, its credentials, its timeouts and its retries
|
|
869
|
+
are yours.
|
|
870
|
+
|
|
871
|
+
### What stops the start
|
|
872
|
+
|
|
873
|
+
`serveProfileFacilitator` rejects with the first of these it meets, in this order, having closed what it opened; each
|
|
874
|
+
message starts as shown:
|
|
875
|
+
|
|
876
|
+
| The configuration | The message |
|
|
877
|
+
|---|---|
|
|
878
|
+
| `listen` is not `host:port` | `listen must be "host:port"` |
|
|
879
|
+
| `credential` holds a character RFC 6750 does not admit | `credential must be a bearer token` |
|
|
880
|
+
| A fee budget whose amount is not a positive integer, or whose period is not a positive whole number of seconds | `the fee budget of <network>: its amount is not a positive integer`, `the fee budget of <network>: its period is not a positive number of seconds` |
|
|
881
|
+
| Two fee budgets on one network | `<network> has two fee budgets` |
|
|
882
|
+
| Postgres cannot be reached, or the tables cannot be created ([The database](#the-database)) | the driver's own error |
|
|
883
|
+
| A module's member it refuses, the modules taken in the order of their names | `casper on <network>: not served` (`casper:casper`), `casper on <network>: the signer reads`, `casper on <network>: the signer's speculative execution goes to`, `casper on <network>: the signer names the chain`; `the Cardano reader serves`; `the Concordium signer and reader must serve`; `lnbtc: <network> is not an lnbtc network`; `not a Starknet network`, `the executor's address is not an account address`; `not a Stellar network`, `the source account's address is not an account strkey`, `the fee ceiling must be positive, and the inclusion fee at least 100 stroops`; `not a Sui network`; `the TON reader serves` |
|
|
884
|
+
| An `evm` network registering `auth-capture` whose signer does not give `signTransaction` and `sendRawTransaction` | `evm on <network>: auth-capture needs a signer` |
|
|
885
|
+
| An `erc7710` signer that does not give `signTransaction` and `sendRawTransaction` | `erc7710 on <network>: the signer must give` |
|
|
886
|
+
| An `erc7710` network where the `evm` module does not register `exact` | `an own module is offered to exact on <network>, which no module registers` |
|
|
887
|
+
| A module's class that states `pairings`, `key`, `acceptsZero` or `feeBudget` in its `extra` | `<network>: a module's facilitator states` |
|
|
888
|
+
| Two registrations of one scheme on one network | `two registrations of <scheme> <network>` |
|
|
889
|
+
| Two modules behind one registration whose keys sign for different purposes | `<scheme> on <network>: its modules' keys sign for` |
|
|
890
|
+
| A fee budget on a network no module serves | `the fee budget of <network>: no module serves it` |
|
|
891
|
+
| A fee budget on a network where a keyed module neither counts nor shows its fees (`ton`, `concordium`) | `the fee budget of <network>: the <module> module's key pays fees it neither meters nor shows` |
|
|
892
|
+
| A keyed module, and no `credential` | `a module holds a key (<scheme> on <network>, ...): credential is required` |
|
|
893
|
+
|
|
894
|
+
Any other rejection is the error of a call the start makes, such as the listen's `EADDRINUSE`.
|
|
417
895
|
|
|
418
896
|
## Keys
|
|
419
897
|
|
|
@@ -439,6 +917,18 @@ settler would spend the seller's money on payments between other parties. A depl
|
|
|
439
917
|
in constant time, and answers a call without it `401` `{"error":"unauthorized"}` with `WWW-Authenticate: Bearer`,
|
|
440
918
|
before it reads the body, closing the connection. A keyless deployment may set one too, with the same effect.
|
|
441
919
|
|
|
920
|
+
## Security
|
|
921
|
+
|
|
922
|
+
The settler serves plain HTTP (`node:http`, no TLS option): the credential and every payment cross the network in clear
|
|
923
|
+
unless TLS is in front of it. Bind `listen` to loopback or a private interface and terminate TLS in a proxy before it,
|
|
924
|
+
or run the settler on the resource server's own host. The credential is its only gate: anyone who holds it can have a
|
|
925
|
+
keyed module pay fees for payments between other parties, without limit unless a fee budget caps them ([The fee
|
|
926
|
+
budget](#the-fee-budget)), so keep it as you keep the keys, and set a budget on each network whose fees a key pays (the
|
|
927
|
+
`ton` and `concordium` modules take none). The keys live in the operator's process, as the signer objects passed in; the
|
|
928
|
+
settler reads no key material itself, and names a node in an error by its origin alone. It does not check that H is the
|
|
929
|
+
one the resource server issued, nor that the resource server has not accepted it before ([What it is](#what-it-is)):
|
|
930
|
+
those checks are the resource server's.
|
|
931
|
+
|
|
442
932
|
## What `/supported` states
|
|
443
933
|
|
|
444
934
|
`GET /supported` answers `{kinds, extensions, signers}` as x402's facilitator class gives it. Each kind is
|
|
@@ -448,7 +938,7 @@ before it reads the body, closing the connection. A keyless deployment may set o
|
|
|
448
938
|
|---|---|
|
|
449
939
|
| `extra.pairings` | The lcp pairing ids the kind submits. A scheme on one network can hold several forms, so the scheme alone does not name them. |
|
|
450
940
|
| `extra.key` | `none`, `relayer` or `fee-payer` ([Keys](#keys)). |
|
|
451
|
-
| `extra.acceptsZero` |
|
|
941
|
+
| `extra.acceptsZero` | The pairings of `extra.pairings` the kind settles at an amount of zero; `[]` where none does. An option of amount zero whose pairing it does not name is refused `invalid_payment_requirements`. |
|
|
452
942
|
| `extra.feeBudget` | `true` on each kind of a network whose fee budget the operator set; absent otherwise. Neither the amount nor what remains is stated. |
|
|
453
943
|
| The class's own members | Kept unchanged, such as `assetTransferMethod` on Tron and Polkadot, `feePayer` where a fee payer co-signs, and `areFeesSponsored` on the XRP Ledger and Stellar. No module's class may state one of the four members above: the settler refuses one that does at start. |
|
|
454
944
|
|
|
@@ -515,47 +1005,99 @@ await settler.close();
|
|
|
515
1005
|
`unsupported_scheme`. Where an own module claims the payment (by a member of the option, or by what the payment
|
|
516
1006
|
holds), it goes to that module, else to the registration's class. On `lnbtc` the answer is `unsupported_scheme`.
|
|
517
1007
|
3. lcp's checks of the pairing, from the payment and its requirements alone. A refusal carries x402's reason and, on
|
|
518
|
-
the `algorand`, `aptos`, `hedera`, `solana`, `starknet` and `sui` modules, lcp's refusal code as
|
|
519
|
-
(on `starknet` and `sui`, the module's own code where its own check refused).
|
|
1008
|
+
the `algorand`, `aptos`, `casper`, `hedera`, `solana`, `starknet` and `sui` modules, lcp's refusal code as
|
|
1009
|
+
`invalidMessage` (on `starknet` and `sui`, the module's own code where its own check refused).
|
|
520
1010
|
4. The record: a payment it holds, claimed or final, is refused `invalid_transaction_state`, since `isValid: true`
|
|
521
|
-
tells the caller that a settle may follow.
|
|
522
|
-
|
|
523
|
-
|
|
1011
|
+
tells the caller that a settle may follow. A later message the record does not hold (a batch settlement's `claim`
|
|
1012
|
+
and `settle`, and `seal` on `solana`) is not looked up.
|
|
1013
|
+
5. What the kind declares: an amount of zero whose pairing `extra.acceptsZero` does not name, and a form outside the
|
|
1014
|
+
pairings of the module the payment goes to, are refused `invalid_payment_requirements`. A later message of a
|
|
1015
|
+
multi-step scheme (an escrow's capture, void or refund; a channel's claim, settle or refund) pays no option's
|
|
1016
|
+
amount, and the zero rule does not hold it.
|
|
524
1017
|
6. The fee budget, where the module's key pays the fee: a spent budget is refused `fee_budget_spent`.
|
|
525
1018
|
7. The class's verify, unchanged, with its own reasons.
|
|
526
1019
|
8. lcp's read of the chain: a payment the chain shows final (landed, or consumed by another act) is refused
|
|
527
1020
|
`invalid_transaction_state`. A read that fails goes to the operator log and leaves the class's answer.
|
|
528
1021
|
|
|
529
|
-
|
|
1022
|
+
Step 8 is not made for a later message the record does not hold, which the class's verify answers.
|
|
530
1023
|
The answer is `{isValid: true, payer}` or `{isValid: false, invalidReason, invalidMessage?, payer?}`.
|
|
531
1024
|
|
|
532
1025
|
### `/settle`
|
|
533
1026
|
|
|
534
1027
|
1. Steps 1 to 3 of `/verify`, with `errorMessage` for `invalidMessage`; `lnbtc` is served here.
|
|
535
|
-
2. The record
|
|
536
|
-
success. A claim
|
|
537
|
-
|
|
1028
|
+
2. The record: a final row is answered `invalid_transaction_state` naming the transaction it holds, never a second
|
|
1029
|
+
success. A batch settlement's `claim` and `settle` (and `seal` on `solana`), which carry no single-use value and
|
|
1030
|
+
which the channel contract or program makes inert on a repeat, are not recorded: what the kind declares, the fee
|
|
1031
|
+
budget, the class's check and its settle are made each time, and the answer is the class's; a refusal by its check
|
|
1032
|
+
is answered with its reason alone, with no `errorMessage`. Where the check leaves the request's wait no time, the
|
|
1033
|
+
settle is not made, and the answer is `unexpected_settle_error`.
|
|
538
1034
|
3. What the kind declares, as `/verify` checks it.
|
|
539
|
-
4.
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
1035
|
+
4. A claim the record holds that is not final, which another settle holds or whose hold has ended: it is answered as
|
|
1036
|
+
[the record](#the-record-and-what-a-repeat-answers) says, and no step below is made.
|
|
1037
|
+
5. The class's verify. On `evm` and `solana`, batch settlement's `claim` and `settle` (`seal` too on `solana`, and
|
|
1038
|
+
`refund` on `evm`), which x402's channel manager sends and the class's verify does not take under the manager's
|
|
1039
|
+
requirements, are checked by the class's settle before it sends anything. Where it refuses, lcp's read of the chain:
|
|
1040
|
+
a payment the chain shows landed, or whose value another act consumed, is stored final and answered
|
|
1041
|
+
`invalid_transaction_state` naming its transaction; otherwise the class's refusal is the answer, its reason and,
|
|
1042
|
+
where it gave one, its message as `errorMessage`; nothing is stored, and a repeat is checked again.
|
|
1043
|
+
6. Where the module's read searches from a position no x402 call carries (a ledger, a slot, a block), the chain's
|
|
543
1044
|
position, read just before the claim, which the row keeps for every later read.
|
|
544
|
-
|
|
1045
|
+
7. The claim: one conditional insert of the payment's row, held by this settle for `settleWaitMs`, so that of two
|
|
545
1046
|
settles of one payment only one submits.
|
|
546
|
-
|
|
1047
|
+
8. The fee budget, where the module's key pays the fee: a spent budget answers `fee_budget_spent`, sends nothing, and
|
|
547
1048
|
leaves the claim, not final.
|
|
548
|
-
|
|
549
|
-
answered `{success: true, transaction, network, payer}
|
|
1049
|
+
9. The class's settle, which submits what the payer signed. A success that names a transaction is stored final, then
|
|
1050
|
+
answered as the class gave it (on `evm` and `erc7710` it is stored open instead, as below), `{success: true, transaction, network, payer}` with any member the class adds (x402's
|
|
1051
|
+
Solana `upto` class adds `amount`). Anything else is classified by lcp's read: a payment the
|
|
550
1052
|
chain shows final is stored final and answered (success only where the read shows a transaction this settler sent,
|
|
551
1053
|
or the payment it presented, settled); one still live is answered `settlement_pending` naming the transaction sent,
|
|
552
|
-
or the class's own failure where it named no transaction or its failure consumed nothing.
|
|
1054
|
+
or the class's own failure where it named no transaction or its failure consumed nothing. Where the module named a
|
|
1055
|
+
transaction before sending it (`beforeSend`: Solana's `upto` claim, an escrow's capture, void or refund) and the
|
|
1056
|
+
class's answer names none, the answer is `settlement_pending` naming that transaction, unless the read shows it
|
|
1057
|
+
unable to land. The read is given the
|
|
1058
|
+
transaction the settler sent; on `stellar` it is made by that transaction, so that a second payment of the buyer
|
|
1059
|
+
under one H which this settler sent answers success once it lands, where the first act under H would be another
|
|
1060
|
+
payment. The `stellar` module keeps the transaction's hash in the row before it sends it, so that a settler that
|
|
1061
|
+
stops before the send's answer leaves the row naming it, and takes it back out where the node refuses the send.
|
|
1062
|
+
On `ton` the read is made by the request the payment presents, which the payer's signature names by its body hash
|
|
1063
|
+
before anything is sent, so that a second payment of the buyer under one H, at its own sequence number, is
|
|
1064
|
+
answered by its own run, never by the first payment's.
|
|
1065
|
+
On `evm`'s `exact` EIP-3009 payment the read is made by the authorization the payment presents, its use on the
|
|
1066
|
+
asset, so that a second payment of the buyer under one H on another EIP-3009 token, whose nonce H is unused there,
|
|
1067
|
+
never answers the payment presented.
|
|
553
1068
|
|
|
554
1069
|
A success is answered once, only by the settle whose write stored it: of two settles of one payment, only one answers
|
|
555
1070
|
success, and the other answers `invalid_transaction_state` naming the transaction, or `settlement_pending` where its
|
|
556
1071
|
wait ends first. A success that cannot be stored is answered `settlement_pending` naming its transaction, and a later
|
|
557
1072
|
`/settle` reads the chain again.
|
|
558
1073
|
|
|
1074
|
+
On `evm` and `erc7710` the class's success rests on one receipt at the chain's head, whose block a node on another
|
|
1075
|
+
fork can show and the chain then drop. That success is still answered at once, but the row is stored open, naming the
|
|
1076
|
+
transaction and holding the success given, and is made final only once lcp's read shows the payment on the finalized
|
|
1077
|
+
chain (a read made at once, for at most a second, or a later `/settle`'s). What a repeat is answered:
|
|
1078
|
+
|
|
1079
|
+
- **Between the receipt and finality:** `settlement_pending` naming the same transaction. Nothing is sent again while
|
|
1080
|
+
the read shows that transaction in a block above the finalized one.
|
|
1081
|
+
- **Once the finalized chain holds it:** the row is final, and every repeat is answered `invalid_transaction_state`
|
|
1082
|
+
naming that transaction, as for any final row. No second success is given for it.
|
|
1083
|
+
- **Where the transaction left the chain** (its block was dropped, another transaction of the gas key took its nonce):
|
|
1084
|
+
repeats are answered `settlement_pending` while the existing rules decide, on facts read at a finalized block, and
|
|
1085
|
+
the same signed payment is sent again where they allow it (`erc7710`: the repeat that retires the redemption is
|
|
1086
|
+
answered `unexpected_settle_error` naming none, and the next redeems the sale by a transaction of its own). If it then lands, the repeat that finds it is answered
|
|
1087
|
+
`success` naming the new transaction, with `extra.supersedes` naming the transaction of the success given before,
|
|
1088
|
+
and the operator log has `success-superseded`. If the read instead shows the payment can never land (its value
|
|
1089
|
+
consumed by another act, its validity passed), the answer is that final read's: `invalid_transaction_state` naming
|
|
1090
|
+
what the read shows, and the operator log has `success-withdrawn`. A success naming another transaction than one
|
|
1091
|
+
given before is never answered without `extra.supersedes`.
|
|
1092
|
+
- A row left open, because no repeat came, is dropped by the sweep once past its keep, as a final row is.
|
|
1093
|
+
|
|
1094
|
+
This does not close a fork that outlasts the backend's own finality: an endpoint whose backends follow different
|
|
1095
|
+
chains past their `finalized` blocks can still show a dropped transaction as final. The settler's finality is its
|
|
1096
|
+
endpoint's: it holds final what the endpoint shows on the chain at or below the block it names `finalized`, and reads no
|
|
1097
|
+
second source. An operator puts behind one endpoint only backends that agree on every block at or below their
|
|
1098
|
+
`finalized` ones; and on a chain whose `finalized` block its consensus does not make irreversible, a reorganisation
|
|
1099
|
+
below that block can leave a dropped payment final in the record. That risk is the operator's.
|
|
1100
|
+
|
|
559
1101
|
## The record, and what a repeat answers
|
|
560
1102
|
|
|
561
1103
|
The record is one row per payment, its **instrument**, within its network: the single-use value its signer signed (an
|
|
@@ -566,14 +1108,16 @@ that a copy signed again would change. An agreement and a payment of one payer u
|
|
|
566
1108
|
|
|
567
1109
|
A row is **final** once its answer can never change: a success; a failed result that consumed the single-use value; a
|
|
568
1110
|
value another act consumed; a validity that passed with the value unconsumed; or a payment that landed by another
|
|
569
|
-
route.
|
|
570
|
-
|
|
1111
|
+
route. Another body under a claim never makes its row final where the read shows that body failed, nor where it
|
|
1112
|
+
shows it settled and a settle gave the claim's body to the class. A refused submission, one that cannot have reached
|
|
1113
|
+
the node, and a failed result that consumed nothing leave the row a claim, which a repeat reads again. A claim is never
|
|
1114
|
+
removed.
|
|
571
1115
|
|
|
572
1116
|
| A repeated `/settle` finds | It answers |
|
|
573
1117
|
|---|---|
|
|
574
1118
|
| A final row | `invalid_transaction_state` naming the transaction the row holds. Never a second success, as x402's `exact` family requires: a consumed payment produces a settlement failure. |
|
|
575
|
-
| A claim another settle holds | It reads the row every second and sends nothing, until that settle answers or its hold ends; then the row's answer, or lcp's read. It answers `settlement_pending` naming the transaction where one is known, and `unexpected_settle_error` where none is known when its wait ends. |
|
|
576
|
-
| A claim whose hold has ended | It takes the claim and reads the chain. A payment the chain shows final is stored and answered. The identical signed payment is submitted again only where the pairing's `nonce` is `single-use` in lcp's registry, the row is not named by the digest of the signed payment
|
|
1119
|
+
| A claim another settle holds | It reads the row every second and sends nothing, until that settle answers or its hold ends; then the row's answer, or lcp's read, answered as for a claim whose hold has ended, except that it never takes the claim, sends nothing and ends no hold. It answers `settlement_pending` naming the transaction where one is known, and `unexpected_settle_error` where none is known when its wait ends. |
|
|
1120
|
+
| A claim whose hold has ended | It takes the claim, with the next fencing number, and reads the chain. A payment the chain shows final is stored and answered. It is a success where a settle holding the claim gave the body that claimed the row to the class's settle, this call presents that body, and the read shows it settled, whatever the class answered. A failure naming no transaction is the same answer whether or not the node took the send (its answer lost, a class that names nothing on any failure after its broadcast), and so is no answer (the settler stopped, or the class's settle outlasted the hold). So that body landing by another route after it was given to the class is answered success too. That success needs the read to show the presented body (`presented` `yes`) where it names none of the transactions the settler's submissions named: a read that answers `presented` `unshown`, as lcp's reads do where they cannot read every member of the landed act, never reaches it, and is answered `invalid_transaction_state` naming the transaction, the row made final. The identical signed payment is submitted again only where the body is the one that claimed the row, the class's verify passes again, and either the pairing's `nonce` is `single-use` in lcp's registry, the row is not named by the digest of the signed payment and the read shows the value unconsumed and its validity open (for the escrow's hold, also nothing of the gas key unmined: one that is may be the hold's own send); or the row is named by the digest of the signed payment, its module keeps each transaction in the row before sending it (Solana's `upto` claim), the read shows it not landed, and either no transaction was sent for it or the read shows the last one sent unable to land; or the module's read shows whether a message keyed by its digest landed (an escrow's capture, void or refund: the escrow's amounts still those it expects, and nothing of the gas key unmined); or its module names each transaction before sending it and keeps what it signed (`erc7710`), the row is named by the digest of the signed payment, and the row, as taken, names none. Before the read, unless the network's fee budget is spent, such a module sends again each transaction the row names where the chain could still take it, or replaces one the node holds unmined and underpriced at the same nonce, naming the replacement first, and takes out of the row one the chain shows can never land (a block read by its hash and shown an ancestor of the finalized block holds a different transaction at its nonce); that repeat sends nothing more, and the next finds the row naming none and submits it again. A lookup by hash that finds nothing takes nothing out of the row. A module that keeps each transaction in the row before sending it (these two, and `erc7710`) does so by one write that holds only while the row's fencing number is still the one its settle took the claim with; where it does not hold, nothing is sent, so a settle whose hold lapsed and was taken by another sends nothing after it. The settle's other writes to the claim hold on the same fencing number: it takes back a transaction it named and did not send, and ends its hold, only while the number is still its own, so it never removes the name another settle wrote for the same bytes or ends another settle's hold; a settle that watches a claim another holds ends no hold. A transaction sent for it that may still land is answered `settlement_pending` naming it, and nothing is sent again. Another body under the same instrument is answered `invalid_transaction_state`, naming the transaction the read found, and the row stays a claim: the settler never gave that body to the class, so it is not this settler's payment even where the read shows it settled, and a read that shows it failed (its own validity passed, or its value consumed) is of that body and never makes the row final. The body is the payload with its requirements, so the same payload under changed requirements is another body; where the payment's module states what makes two payments one body (`Instrumented.body`), that is the body, and another signature over it is given to the class, whose check judges the signature. Otherwise `settlement_pending` naming the transaction sent, or `unexpected_settle_error` where none is known. |
|
|
577
1121
|
| No row, and the store cannot be read | `settlement_pending` where the payment's transaction id is known before it is sent, else `unexpected_settle_error`: the settler cannot know whether it was sent. |
|
|
578
1122
|
|
|
579
1123
|
When the wait ends first, `/settle` answers `{success: false, errorReason: "settlement_pending", transaction}`; x402
|
|
@@ -592,6 +1136,13 @@ Where the count has reached the amount:
|
|
|
592
1136
|
|
|
593
1137
|
- `/verify` and `/settle` refuse a payment whose fee the module's key would pay, `fee_budget_spent`, before anything is
|
|
594
1138
|
sent. A payment whose payer pays the fee is never refused for it.
|
|
1139
|
+
- A repeat of a payment the record holds sends nothing before its read: no transaction its row names is sent again,
|
|
1140
|
+
and none is replaced at its nonce (`auth-capture`, `erc7710`). A repeat whose read shows the payment unsent (an
|
|
1141
|
+
`auth-capture` message whose amounts still stand, another form's unconsumed value, or a row that names none) is
|
|
1142
|
+
refused `fee_budget_spent`, naming nothing, as a first settle is, unless its row names a transaction an earlier
|
|
1143
|
+
settle gave to the class, which may still land: that repeat is `settlement_pending` naming it. Any other is answered
|
|
1144
|
+
from its read, which, as any repeat's, starts from the transaction the row names, `settlement_pending` while nothing
|
|
1145
|
+
final is shown.
|
|
595
1146
|
- Each kind of the network states `extra.feeBudget: true`, so that a resource server learns that the settler may refuse
|
|
596
1147
|
every payment on that network for a period.
|
|
597
1148
|
|
|
@@ -601,7 +1152,9 @@ data fee the network's GasPriceOracle (`getL1Fee`) gives. On Hedera it is the fe
|
|
|
601
1152
|
to five seconds after the settle answers; where the mirror shows none by then, the `maxFee` the payer signed. The
|
|
602
1153
|
`evm`, `solana`, `aptos` and `casper` modules count each transaction their key sends as it is sent, one their class
|
|
603
1154
|
does not name in its answer included: a payer's ERC-6492 wallet deployment on EVM, or a Solana or Casper transaction
|
|
604
|
-
whose send failed.
|
|
1155
|
+
whose send failed. A replacement at a nonce (`auth-capture`, `erc7710`) is counted as a transaction of its own, by its
|
|
1156
|
+
hash, at its whole bound and then at the fee it paid; the transaction it replaced keeps the count it had, its bound
|
|
1157
|
+
where the chain never shows it included. The same signed bytes sent again are the same transaction, counted once.
|
|
605
1158
|
|
|
606
1159
|
At start the settler refuses a budget on a network no configured module serves, and one on a network where a module
|
|
607
1160
|
whose key pays fees can neither show the fee of what it sent nor count it as it sends: the `ton` and `concordium`
|
|
@@ -610,7 +1163,8 @@ modules, whose classes and lcp's reads give no fee.
|
|
|
610
1163
|
Its stated costs:
|
|
611
1164
|
|
|
612
1165
|
- A transaction is counted once it is sent (`evm`, `solana`, `aptos`, `casper`) or once its settle answers (`algorand`,
|
|
613
|
-
`erc7710`, `hedera`, `near`),
|
|
1166
|
+
`erc7710`, `hedera`, `near`), and one an `auth-capture` or `erc7710` repeat names before it sends it once that
|
|
1167
|
+
repeat's sends are done, so settles that run at once on a nearly spent budget can each pass the check before the
|
|
614
1168
|
first is counted. The `starknet` and `stellar` modules count each send before it is made, one at a time per network.
|
|
615
1169
|
The `evm` module's count at the send is what its node shows then: a transaction the node does not show yet (the
|
|
616
1170
|
operator log's `fee-not-counted`, reason `not-shown`) is not counted until a later read shows it, when the class's
|
|
@@ -628,6 +1182,18 @@ Its stated costs:
|
|
|
628
1182
|
executor, and x402's specification of the method admits none by default.
|
|
629
1183
|
- **Solana's channel forms on mainnet.** `x402/upto/solana` and `x402/batch-settlement/solana` need the payment-channels
|
|
630
1184
|
program, which is not deployed on Solana mainnet; there only `exact` is registered.
|
|
1185
|
+
- **Solana batch settlement with server-signed vouchers.** x402's Solana batch server signs each voucher itself
|
|
1186
|
+
(`extra.voucherSigner` `"server"`, naming its `operator`), and does so by default once an operator is configured.
|
|
1187
|
+
`x402/batch-settlement/solana` is client-signed: the payer signs each voucher. The settler refuses a server-signed
|
|
1188
|
+
option `invalid_payment_requirements` (`x402/option-not-this-pairing`) at `/verify` and `/settle` of a deposit that
|
|
1189
|
+
opens a channel, and sends nothing for it. lcp's checks read only that opening: under a server-signed option, a
|
|
1190
|
+
voucher, a deposit into a channel already open, and the claim, seal, settle and refund the resource server sends,
|
|
1191
|
+
reach x402's class, as every later message does: the class's settle checks a claim, seal or settle before it
|
|
1192
|
+
sends.
|
|
1193
|
+
`/supported` names no voucher mode, and `@x402/svm` 2.31.0's server reads none at start-up: it checks the
|
|
1194
|
+
facilitator's `feePayer` and `receiverAuthorizer` only, so a server with an operator starts against the settler and
|
|
1195
|
+
then refuses every buyer at the first deposit. A seller with an operator sets `extra.voucherSigner` `"client"` on the
|
|
1196
|
+
route, which the stock server keeps: its deposit then passes lcp's checks at the settler and reaches x402's class.
|
|
631
1197
|
- **Casper mainnet.** x402's Casper scheme names `casper:casper`, but no token there has yet been shown to execute
|
|
632
1198
|
`transfer_with_authorization`, so the `casper` module does not start on it; it serves `casper:casper-test`.
|
|
633
1199
|
- **lcp's x402 pairings that another party settles.** `x402/exact/eip155/gateway-batched`, Circle's batched option,
|
|
@@ -640,7 +1206,7 @@ Its stated costs:
|
|
|
640
1206
|
|---|---|
|
|
641
1207
|
| `GET /supported` | `200` `{kinds, extensions, signers}`. |
|
|
642
1208
|
| `POST /verify` | `200` `{isValid: true, payer}` or `{isValid: false, invalidReason, invalidMessage?, payer?}`; `400` `{isValid: false, invalidReason: "invalid_payload"}` when the body is not JSON. |
|
|
643
|
-
| `POST /settle` | `200` `{success: true, transaction, network, payer}` or `{success: false, errorReason, errorMessage?, transaction, network}`; `400` with `errorReason` `invalid_payload` when the body is not JSON. |
|
|
1209
|
+
| `POST /settle` | `200` `{success: true, transaction, network, payer}` (with any member the class's success adds) or `{success: false, errorReason, errorMessage?, transaction, network}`; `400` with `errorReason` `invalid_payload` when the body is not JSON. |
|
|
644
1210
|
| A call without the credential, where one is configured | `401` `{error: "unauthorized"}` with `WWW-Authenticate: Bearer`, before the body is read; the connection is closed. |
|
|
645
1211
|
| A body over 132,096 bytes | `413`, and the connection is closed. |
|
|
646
1212
|
| Another method on a served path | `405` `{error}`. |
|
|
@@ -657,15 +1223,15 @@ x402 codec reads, and 1,024 bytes for the envelope.
|
|
|
657
1223
|
| `invalid_x402_version` | yes | yes | `x402Version` is not 2 in the request or the payload. |
|
|
658
1224
|
| `invalid_network` | yes | yes | No configured module serves the network. |
|
|
659
1225
|
| `unsupported_scheme` | yes | yes | No module registers the scheme on the network. On `lnbtc`, every `/verify`. |
|
|
660
|
-
| `invalid_payment_requirements` | yes | yes | The requirements are not ones the pairing's profile admits; an amount of zero
|
|
1226
|
+
| `invalid_payment_requirements` | yes | yes | The requirements are not ones the pairing's profile admits; an amount of zero whose pairing the kind's `extra.acceptsZero` does not name; a form outside the kind's pairings; an option the module refuses (each module's notes). |
|
|
661
1227
|
| `invalid_payload` | yes | yes | The payload does not match the profile or the requirements. |
|
|
662
1228
|
| `unsupported_permission` | yes | yes | Tron: the owner's permission does not accept the transaction's signatures. |
|
|
663
1229
|
| `invalid_transaction` | yes | yes | The node refuses the transaction in simulation or validation, in a module of the settler's own. |
|
|
664
|
-
| `invalid_transaction_state` | yes | yes | `/verify`: the record or the chain already holds the payment. `/settle`: a repeat of a final row, or a payment the chain shows failed, consumed by another act, lapsed or landed by another route; each names the transaction where one is known. |
|
|
1230
|
+
| `invalid_transaction_state` | yes | yes | `/verify`: the record or the chain already holds the payment. `/settle`: a repeat of a final row, or a payment the chain shows failed, consumed by another act, lapsed or landed by another route; each names the transaction where one is known. The one exception: where a settle holding the claim gave the body that claimed the row to the class's settle and this call presents that body, a transaction the settler sent shown landed and not read as another body, or the presented body shown landed (`presented` `yes`), is a success, whatever route it landed by (see *A claim whose hold has ended*). |
|
|
665
1231
|
| `fee_budget_spent` | yes | yes | The network's fee budget is spent, and the module's key would pay the fee. |
|
|
666
1232
|
| `settlement_pending` | no | yes | Submitted, or possibly submitted, and not yet final or not yet stored when the wait ended; `transaction` names it. |
|
|
667
1233
|
| `unexpected_verify_error` | yes | no | A node or the store could not be read. |
|
|
668
|
-
| `unexpected_settle_error` | no | yes | A node or the store could not be read before submission, the settle's wait ended before it, or the submission failed with nothing sent. |
|
|
1234
|
+
| `unexpected_settle_error` | no | yes | A node or the store could not be read before submission, the settle's wait ended before it, or the submission failed with nothing sent. `erc7710`, with nothing sent: where its signer could not sign the redemption; where its own state could not be written before the send; where its send failed and the node then shows the bytes can never land; on the repeat that retires a named redemption as unable to land; where the wait for another sale's redemption in flight under the same root delegator ends; and for a sale whose redemption is the same bytes as another sale's, or was signed at a nonce the finalized chain has passed. A repeat settles it. |
|
|
669
1235
|
|
|
670
1236
|
`unsupported_permission`, `invalid_transaction` and `fee_budget_spent` are the settler's own; the others are x402's. A
|
|
671
1237
|
published class's own reasons, such as `invalid_exact_evm_payload_signature`, pass unchanged.
|
|
@@ -691,6 +1257,8 @@ CREATE TABLE IF NOT EXISTS instrument (
|
|
|
691
1257
|
search jsonb,
|
|
692
1258
|
since jsonb,
|
|
693
1259
|
keep_until bigint,
|
|
1260
|
+
submitted boolean NOT NULL DEFAULT false,
|
|
1261
|
+
fence bigint NOT NULL DEFAULT 1,
|
|
694
1262
|
PRIMARY KEY (network, key)
|
|
695
1263
|
);
|
|
696
1264
|
CREATE INDEX IF NOT EXISTS instrument_final_keep ON instrument (keep_until) WHERE final AND keep_until IS NOT NULL;
|
|
@@ -714,21 +1282,41 @@ CREATE TABLE IF NOT EXISTS module_state (
|
|
|
714
1282
|
- `instrument` is the record: `key` is the instrument, its kind and parts as a JSON array. `held_until` is when the
|
|
715
1283
|
settle holding the claim may no longer send (0 once it answered); `answer` is the answer as first given, once
|
|
716
1284
|
`final`; `transaction` the transaction the row names; `sent` every transaction the settler's submissions for the
|
|
717
|
-
claim named, any of which can be the one that lands; `body` the SHA-256 of the body that claimed the row
|
|
718
|
-
|
|
719
|
-
|
|
1285
|
+
claim named, any of which can be the one that lands; `body` the SHA-256 of the body that claimed the row (what its
|
|
1286
|
+
module states makes two payments one body, else the payload with its requirements), the only body sent again and the
|
|
1287
|
+
only body a landed payment is this settler's for; `search` where the next read resumes;
|
|
1288
|
+
`since` the chain's position read just before the claim; `submitted` whether a settle holding the claim gave the
|
|
1289
|
+
claim's body to the class's settle, set before it sends; `fence` the claim's fencing number, 1 for the settle
|
|
1290
|
+
that claimed the row and one more each time a settle takes it again, the one number under which the holding settle
|
|
1291
|
+
names a transaction, takes one back or ends its hold; times are Unix milliseconds. A limit: the wait for the write
|
|
1292
|
+
that sets `submitted` ends at what is left before the call's deadline or at 5 seconds, counted from before the store
|
|
1293
|
+
hands the write a connection, while the statement's own bound starts once it is sent, so it can commit after the call
|
|
1294
|
+
answered
|
|
1295
|
+
`unexpected_settle_error` with nothing sent. The row is then marked though the class's settle was never
|
|
1296
|
+
called, and a later settle answers success where the claim's body is shown landed by another route.
|
|
720
1297
|
- `fee` is the fee count: one row per transaction a keyed module submitted on a network with a budget.
|
|
721
1298
|
- `module_state` is the modules' durable state, under each module's name: a class's pending settlements, Cardano's
|
|
722
|
-
broadcast guard, Solana's channels
|
|
1299
|
+
broadcast guard, Solana's channels, the `erc7710` module's signed redemptions (each removed once the finalized
|
|
1300
|
+
chain shows its receipt, by a later settle of the module that sends a redemption on that network, and kept
|
|
1301
|
+
otherwise, a settle that sends nothing included: one whose nonce another transaction took is kept after its
|
|
1302
|
+
retirement), the sale each was signed for (removed once the finalized chain has passed its nonce and shows what took
|
|
1303
|
+
it, or was read eight times without showing it), for each key on a network the list of those and the nonce below
|
|
1304
|
+
which it sends nothing, for each network the keys so listed (one the settler no longer signs with among them), and, for each root delegator on a network, the redemption in flight.
|
|
723
1305
|
- A sweep every minute drops the final rows kept 24 hours past their keep, and the fees older than the longest budget
|
|
724
1306
|
period. The pool holds at most 10 connections; acquiring one, each query and each statement are bounded by 5 seconds.
|
|
725
1307
|
|
|
726
1308
|
## Bounds and logs
|
|
727
1309
|
|
|
728
1310
|
- Each node call the settler makes itself has a timeout of at most 5 seconds and an answer of at most 4 MiB, except
|
|
729
|
-
Polkadot's block reads, bounded by the runtime's `System.BlockLength` (at most 4 of them at once in a process)
|
|
1311
|
+
Polkadot's block reads, bounded by the runtime's `System.BlockLength` (at most 4 of them at once in a process), and
|
|
1312
|
+
Stellar's `getEvents`, bounded by the read's deadline (or `eventsTimeoutMs`). A
|
|
730
1313
|
published class's calls are bounded by the class, and its settle takes no deadline: `settleWaitMs` bounds the
|
|
731
|
-
settler's own reads and store calls, and a class's settle runs on its own bounds.
|
|
1314
|
+
settler's own reads and store calls, and a class's settle runs on its own bounds. x402's EVM signer waits up to
|
|
1315
|
+
180 s for a receipt unless `toFacilitatorEvmSigner`'s `confirmationTimeoutMs` is set: set it below `settleWaitMs`,
|
|
1316
|
+
as the service above does, or a `/settle` can outlast its wait. Where it is not, a repeat made after the hold ends
|
|
1317
|
+
while the first settle still waits can submit the same signed `exact` payment again, at the key's next nonce:
|
|
1318
|
+
x402's class records a sent payment only once its wait ends. The second transaction reverts once the first lands, and
|
|
1319
|
+
its fee is spent.
|
|
732
1320
|
- `/settle`'s reads and submission end a second before `settleWaitMs` (a quarter of a shorter wait), the time kept for
|
|
733
1321
|
storing the answer. The server's request timeout is `settleWaitMs` plus 60 seconds.
|
|
734
1322
|
- An error names a node by its origin alone, since a URL's path or query can hold an API key.
|
|
@@ -739,14 +1327,69 @@ CREATE TABLE IF NOT EXISTS module_state (
|
|
|
739
1327
|
`operator-log-failed` entry. The core's entries are `verify-error`, `settle-error` and `request-error` (an error the
|
|
740
1328
|
handling threw); `read-failed` and `position-unread` (lcp's read, or the position before a claim, could not be made);
|
|
741
1329
|
`store-call-failed` (with the `call`), `store-connection-error` and `answer-not-stored`; `settle-deadline-passed`
|
|
742
|
-
(with `before`, the step not started); `claim-unread` (a held claim whose read told nothing); `
|
|
1330
|
+
(with `before`, the step not started); `claim-unread` (a held claim whose read told nothing); `refusal-withheld`
|
|
1331
|
+
(with the `reason` a repeat was not answered, its row naming a transaction that may still land); `success-not-stored`;
|
|
743
1332
|
and `fee-not-counted`. Each module adds its own, such as `node-call-failed` and `settlement-failed`. Every
|
|
744
1333
|
`unexpected_verify_error` and `unexpected_settle_error` has an entry that names why, written when it is first given.
|
|
745
1334
|
|
|
746
|
-
##
|
|
1335
|
+
## Versions
|
|
1336
|
+
|
|
1337
|
+
0.6.0 takes `@integraledger/lcp` `~0.7.0` as its peer dependency: install `@integraledger/lcp@~0.7.0` beside it. A
|
|
1338
|
+
later lcp minor release needs a settler release that names it. While both packages are 0.x, a minor release may change
|
|
1339
|
+
the configuration, the answers or the storage; [the CHANGELOG](./CHANGELOG.md) lists what each release changes. It
|
|
1340
|
+
needs Node.js 24.22.1 or later.
|
|
1341
|
+
|
|
1342
|
+
### Upgrading from 0.5.x
|
|
1343
|
+
|
|
1344
|
+
0.6.0 needs `@integraledger/lcp` `~0.7.0` (0.5.1 took `~0.6.3`). Its configuration members are those of 0.5.1, with two
|
|
1345
|
+
signers that must give more:
|
|
1346
|
+
|
|
1347
|
+
- **`evm`, where a network registers `auth-capture`,** as the default scheme list does: the `signer` gives
|
|
1348
|
+
`signTransaction` and `sendRawTransaction` beside `FacilitatorEvmSigner`. The settler does not start without them. A
|
|
1349
|
+
network that names `schemes` without `auth-capture` needs neither.
|
|
1350
|
+
- **`erc7710`:** the `signer` gives `signTransaction` and `sendRawTransaction`. The settler does not start without them.
|
|
1351
|
+
|
|
1352
|
+
**The database.** 0.6.0 does not serve a database 0.5.x made: its `instrument` table has two columns more, `submitted`
|
|
1353
|
+
and `fence`, which it creates only with the table. Start it on a database or a schema of its own, or drop the three
|
|
1354
|
+
tables first; it then knows no payment 0.5.x answered, and a repeated `/settle` of one is judged afresh, by the
|
|
1355
|
+
module's checks and lcp's read of the chain.
|
|
1356
|
+
|
|
1357
|
+
**The answers.** On `evm` and `erc7710` a success is given on the first receipt, at the head, and its row is final
|
|
1358
|
+
only once the finalized chain holds the payment. Until then a repeat is answered `settlement_pending` naming the
|
|
1359
|
+
transaction, and a later success that names another transaction carries `extra.supersedes`
|
|
1360
|
+
([The record, and what a repeat answers](#the-record-and-what-a-repeat-answers)). [The CHANGELOG](./CHANGELOG.md) lists every change.
|
|
1361
|
+
|
|
1362
|
+
### Upgrading from 0.4.0
|
|
1363
|
+
|
|
1364
|
+
0.4.0 served the `tron` and `polkadot` modules alone. 0.5.0 takes `listen`, `store`, `settleWaitMs`, `operatorLog`,
|
|
1365
|
+
`tron` and `polkadot` unchanged, and needs `@integraledger/lcp` `~0.6.0` (0.4.0 took `~0.5.0`) and Node.js 24.22.1.
|
|
1366
|
+
|
|
1367
|
+
0.4.0 kept its record in the table `settlement`. 0.5.0 creates `instrument`, `fee` and `module_state` beside it, never
|
|
1368
|
+
reads or writes `settlement`, and does not fill `instrument` from it, so it does not know the payments 0.4.0 answered.
|
|
1369
|
+
A repeated `/settle` of one of them is judged afresh, by the module's checks and lcp's read of the chain:
|
|
1370
|
+
|
|
1371
|
+
- **A payment 0.4.0 answered success is never answered success again.** On Tron, the module's checks refuse a
|
|
1372
|
+
transaction id the node holds in its blocks or pending pool, and an expiration already passed; on Polkadot, the node
|
|
1373
|
+
no longer answers the extrinsic valid once its nonce is used. The answer is `invalid_transaction_state` naming the
|
|
1374
|
+
transaction, stored, where lcp's read shows the payment final, and otherwise the check's refusal, with nothing stored.
|
|
1375
|
+
- **A payment 0.4.0 answered `settlement_pending` is answered the same way once its transaction is in a block, and so
|
|
1376
|
+
is never answered success by 0.5.0, though it landed.** The one exception is a Polkadot extrinsic still in the
|
|
1377
|
+
node's pool, not yet in a block, when the repeat arrives: it passes the checks, 0.5.0 claims it, the node refuses
|
|
1378
|
+
its submission as already seen, and 0.5.0 answers success once lcp's read shows it final.
|
|
1379
|
+
- **A payment 0.4.0 claimed and never sent** is new to 0.5.0, which settles it.
|
|
1380
|
+
|
|
1381
|
+
Neither rail lets one signed payment land twice: a Tron transaction id and a Polkadot account nonce are each used once.
|
|
1382
|
+
Before you switch, call `/settle` on 0.4.0 again for each payment it left pending, until each has a final answer (its
|
|
1383
|
+
rows in `settlement` whose `answer` is null or whose `answer->>'errorReason'` is `settlement_pending`), or read those
|
|
1384
|
+
payments with lcp's `status` after the switch. Do not run 0.4.0 and 0.5.0 at once for the same payments: each keeps its
|
|
1385
|
+
own record, so each can submit a payment and answer it success. `settlement` can be dropped once no payment it holds
|
|
1386
|
+
can still land.
|
|
1387
|
+
|
|
1388
|
+
## Tests (in a clone of this repository)
|
|
747
1389
|
|
|
748
|
-
The
|
|
749
|
-
|
|
1390
|
+
The package ships no tests: they run in a clone of [the repository](https://github.com/IntegraLedger/integra-protocol).
|
|
1391
|
+
They feed lcp's vectors for each module's pairings through the settler's `/verify` and `/settle`, against local node
|
|
1392
|
+
stubs that replay recorded node answers (`test/fixtures/tron-mainnet-answers.json`, Polkadot Asset Hub's runtime
|
|
750
1393
|
metadata in `test/fixtures/polkadot-asset-hub-2005000.json.gz`) or answers derived from the pairing's profile. They
|
|
751
1394
|
need Postgres: set `INTEGRA_DATABASE_URL` to a connection string whose user may create databases. Each test file makes
|
|
752
1395
|
and drops its own database, so test runs share one server. CI runs them against a Postgres 18 service.
|