@toon-protocol/client 0.23.0 → 0.24.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/dist/index.d.ts +73 -1
- package/dist/index.js +440 -255
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1194,6 +1194,35 @@ interface ConnectorIdentity {
|
|
|
1194
1194
|
/** The normalized client-edge base URL this identity was read from. */
|
|
1195
1195
|
endpoint: string;
|
|
1196
1196
|
}
|
|
1197
|
+
/**
|
|
1198
|
+
* The channel-opening facts a settling connector carries in its x402
|
|
1199
|
+
* greeting (connector #617): everything a buyer needs to OPEN a channel
|
|
1200
|
+
* with the node, learned by ASKING (ADR 0022) rather than from a
|
|
1201
|
+
* kind:10032 announce the Rust fleet never makes.
|
|
1202
|
+
*/
|
|
1203
|
+
interface ConnectorSettlementTerms {
|
|
1204
|
+
/** `evm:<chainId>` — the chain the node's settlement backend runs on. */
|
|
1205
|
+
chain: string;
|
|
1206
|
+
/** The on-chain counterparty a buyer opens a channel WITH. */
|
|
1207
|
+
settlementAddress: string;
|
|
1208
|
+
/** The stable TokenNetworkRegistry factory address. */
|
|
1209
|
+
tokenNetworkRegistry: string;
|
|
1210
|
+
/** The resolved TokenNetwork — the EIP-712 verifyingContract. */
|
|
1211
|
+
tokenNetwork: string;
|
|
1212
|
+
tokenAddress: string;
|
|
1213
|
+
/** Informational; claims are already in base units. */
|
|
1214
|
+
decimals: number;
|
|
1215
|
+
}
|
|
1216
|
+
/**
|
|
1217
|
+
* A route's terms as the x402 greeting states them: the price, plus (from a
|
|
1218
|
+
* settling node) the channel-opening facts. `settlement` is absent exactly
|
|
1219
|
+
* when the node has no settlement backend — the wire's own shape.
|
|
1220
|
+
*/
|
|
1221
|
+
interface ConnectorRouteTerms {
|
|
1222
|
+
destination: string;
|
|
1223
|
+
price: string;
|
|
1224
|
+
settlement?: ConnectorSettlementTerms;
|
|
1225
|
+
}
|
|
1197
1226
|
/** What a locally-terminated route costs, as reported by `GET /ilp/routes/price`. */
|
|
1198
1227
|
interface ConnectorRoutePrice {
|
|
1199
1228
|
/** The ILP destination that was asked about (echoed by the connector). */
|
|
@@ -1223,7 +1252,11 @@ type ConnectorEdgeErrorCode =
|
|
|
1223
1252
|
/** `GET /ilp/routes/price` answered 2xx with a body that is not the documented object. */
|
|
1224
1253
|
| 'ROUTE_PRICE_MALFORMED'
|
|
1225
1254
|
/** A destination that cannot be put in a query string was asked about. */
|
|
1226
|
-
| 'INVALID_DESTINATION'
|
|
1255
|
+
| 'INVALID_DESTINATION'
|
|
1256
|
+
/** A 402 greeting whose body is not the documented x402 shape (or whose
|
|
1257
|
+
* optional `settlement` facts are present but malformed — refused rather
|
|
1258
|
+
* than silently dropped, since they would be opened AGAINST). */
|
|
1259
|
+
| 'TERMS_MALFORMED';
|
|
1227
1260
|
/**
|
|
1228
1261
|
* A refusal to carry a connector's answer forward. Distinct from
|
|
1229
1262
|
* {@link NetworkError} (which this module throws for a transport failure), so
|
|
@@ -1319,6 +1352,19 @@ declare class ConnectorEdgeClient {
|
|
|
1319
1352
|
getRoutePrice(endpoint: string, destination: string, options?: {
|
|
1320
1353
|
forceRefresh?: boolean;
|
|
1321
1354
|
}): Promise<ConnectorRoutePrice | null>;
|
|
1355
|
+
/**
|
|
1356
|
+
* Ask a route for its full x402 terms — the greeting a claimless PREPARE
|
|
1357
|
+
* is answered with (client-edge-spec.md §1.4) — including, from a settling
|
|
1358
|
+
* node, the channel-opening facts (connector #617).
|
|
1359
|
+
*
|
|
1360
|
+
* This is a real `POST /ilp` carrying a minimal PREPARE with no claim
|
|
1361
|
+
* header. It is free by the wire's own contract: an unpaid request to a
|
|
1362
|
+
* priced route is answered with terms instead of performed, and nothing
|
|
1363
|
+
* is charged for asking. `null` when the connector does not price the
|
|
1364
|
+
* destination (the request would be routed or refused, not greeted) —
|
|
1365
|
+
* mapped from anything other than a 402 answer.
|
|
1366
|
+
*/
|
|
1367
|
+
getRouteTerms(endpoint: string, destination: string): Promise<ConnectorRouteTerms | null>;
|
|
1322
1368
|
/**
|
|
1323
1369
|
* Drop a cached route price — one (endpoint, destination)'s, every
|
|
1324
1370
|
* destination's at one endpoint when `destination` is omitted, or all of
|
|
@@ -2252,6 +2298,32 @@ declare class ToonClient {
|
|
|
2252
2298
|
* Convention: destination "g.toon.peer1" → peerId "peer1" (last segment).
|
|
2253
2299
|
* Falls back to first known peer if no match.
|
|
2254
2300
|
*/
|
|
2301
|
+
/**
|
|
2302
|
+
* The peer id a claim for `destination` accounts under. Normally
|
|
2303
|
+
* `resolvePeerId` — but where that throws `PEER_NOT_FOUND` (an empty
|
|
2304
|
+
* negotiation map: nothing announced, nothing registered), the
|
|
2305
|
+
* destination itself is the key, so the announce-less greeting bootstrap
|
|
2306
|
+
* (connector #617) has a stable identity to remember its synthesized
|
|
2307
|
+
* negotiation under.
|
|
2308
|
+
*/
|
|
2309
|
+
private peerIdForClaim;
|
|
2310
|
+
/**
|
|
2311
|
+
* The announce-less channel bootstrap (connector #617): when nothing has
|
|
2312
|
+
* negotiated with this destination's peer — no kind:10032 announce, no
|
|
2313
|
+
* connector-admin registration — ask the route itself. A settling
|
|
2314
|
+
* connector's x402 greeting carries the channel-opening facts, and ADR
|
|
2315
|
+
* 0022 makes the greeting the ONLY place the Rust fleet will ever state
|
|
2316
|
+
* them. Synthesizes a {@link PeerNegotiation} from those facts, remembers
|
|
2317
|
+
* it, and returns it; `undefined` when there is no edge to ask, the
|
|
2318
|
+
* greeting carries no settlement facts, or the chain is not one this
|
|
2319
|
+
* client opens channels on (EVM only today — Solana/Mina channel opening
|
|
2320
|
+
* still needs announce-shaped metadata).
|
|
2321
|
+
*
|
|
2322
|
+
* Never throws: this is a fallback on a path that already has a precise
|
|
2323
|
+
* error (`PEER_NOT_NEGOTIATED`), and a transport failure while ASKING
|
|
2324
|
+
* must not mask it.
|
|
2325
|
+
*/
|
|
2326
|
+
private negotiateFromGreeting;
|
|
2255
2327
|
private resolvePeerId;
|
|
2256
2328
|
/**
|
|
2257
2329
|
* Extracts chain context (chainId + tokenNetworkAddress) from a chain key like 'evm:base:421614'.
|