@lifi/composer-sdk 0.7.1 → 0.9.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/README.md +5 -2
- package/dist/_virtual/_rolldown/runtime.cjs +33 -0
- package/dist/_virtual/_rolldown/runtime.js +13 -0
- package/dist/authoring/FlowBuilderCore.cjs +102 -120
- package/dist/authoring/FlowBuilderCore.cjs.map +1 -1
- package/dist/authoring/FlowBuilderCore.d.cts +58 -61
- package/dist/authoring/FlowBuilderCore.d.ts +58 -61
- package/dist/authoring/FlowBuilderCore.js +99 -97
- package/dist/authoring/FlowBuilderCore.js.map +1 -1
- package/dist/authoring/handles.cjs +25 -40
- package/dist/authoring/handles.cjs.map +1 -1
- package/dist/authoring/handles.d.cts +33 -34
- package/dist/authoring/handles.d.ts +33 -34
- package/dist/authoring/handles.js +21 -13
- package/dist/authoring/handles.js.map +1 -1
- package/dist/authoring/raw.cjs +85 -44
- package/dist/authoring/raw.cjs.map +1 -1
- package/dist/authoring/raw.d.cts +8 -8
- package/dist/authoring/raw.d.ts +8 -8
- package/dist/authoring/raw.js +83 -19
- package/dist/authoring/raw.js.map +1 -1
- package/dist/authoring/signatureArgs.cjs +81 -103
- package/dist/authoring/signatureArgs.cjs.map +1 -1
- package/dist/authoring/signatureArgs.d.cts +63 -64
- package/dist/authoring/signatureArgs.d.ts +63 -64
- package/dist/authoring/signatureArgs.js +76 -75
- package/dist/authoring/signatureArgs.js.map +1 -1
- package/dist/client.cjs +172 -220
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.cts +131 -131
- package/dist/client.d.ts +131 -131
- package/dist/client.js +165 -198
- package/dist/client.js.map +1 -1
- package/dist/discovery.cjs +0 -17
- package/dist/discovery.d.cts +57 -56
- package/dist/discovery.d.ts +57 -56
- package/dist/discovery.js +1 -1
- package/dist/errors.cjs +211 -159
- package/dist/errors.cjs.map +1 -1
- package/dist/errors.d.cts +84 -84
- package/dist/errors.d.ts +84 -84
- package/dist/errors.js +201 -120
- package/dist/errors.js.map +1 -1
- package/dist/generated/config.generated.cjs +0 -17
- package/dist/generated/config.generated.d.cts +805 -895
- package/dist/generated/config.generated.d.ts +805 -895
- package/dist/generated/config.generated.js +1 -1
- package/dist/generated/guards.generated.cjs +27 -31
- package/dist/generated/guards.generated.cjs.map +1 -1
- package/dist/generated/guards.generated.d.cts +20 -4
- package/dist/generated/guards.generated.d.ts +20 -4
- package/dist/generated/guards.generated.js +21 -8
- package/dist/generated/guards.generated.js.map +1 -1
- package/dist/generated/materialisers.generated.cjs +25 -35
- package/dist/generated/materialisers.generated.cjs.map +1 -1
- package/dist/generated/materialisers.generated.d.cts +17 -4
- package/dist/generated/materialisers.generated.d.ts +17 -4
- package/dist/generated/materialisers.generated.js +19 -11
- package/dist/generated/materialisers.generated.js.map +1 -1
- package/dist/generated/operations.generated.cjs +236 -250
- package/dist/generated/operations.generated.cjs.map +1 -1
- package/dist/generated/operations.generated.d.cts +740 -657
- package/dist/generated/operations.generated.d.ts +740 -657
- package/dist/generated/operations.generated.js +235 -229
- package/dist/generated/operations.generated.js.map +1 -1
- package/dist/generated/preconditions.generated.cjs +25 -35
- package/dist/generated/preconditions.generated.cjs.map +1 -1
- package/dist/generated/preconditions.generated.d.cts +17 -4
- package/dist/generated/preconditions.generated.d.ts +17 -4
- package/dist/generated/preconditions.generated.js +19 -11
- package/dist/generated/preconditions.generated.js.map +1 -1
- package/dist/index.cjs +131 -97
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +29 -43
- package/dist/index.d.ts +29 -43
- package/dist/index.js +96 -45
- package/dist/index.js.map +1 -1
- package/dist/outputs.cjs +11 -32
- package/dist/outputs.cjs.map +1 -1
- package/dist/outputs.d.cts +5 -5
- package/dist/outputs.d.ts +5 -5
- package/dist/outputs.js +10 -8
- package/dist/outputs.js.map +1 -1
- package/dist/raw.cjs +21 -33
- package/dist/raw.cjs.map +1 -1
- package/dist/raw.d.cts +8 -4
- package/dist/raw.d.ts +8 -4
- package/dist/raw.js +12 -7
- package/dist/raw.js.map +1 -1
- package/dist/reachability.cjs +82 -112
- package/dist/reachability.cjs.map +1 -1
- package/dist/reachability.d.cts +33 -59
- package/dist/reachability.d.ts +33 -59
- package/dist/reachability.js +81 -88
- package/dist/reachability.js.map +1 -1
- package/dist/resources.cjs +47 -32
- package/dist/resources.cjs.map +1 -1
- package/dist/resources.d.cts +50 -3
- package/dist/resources.d.ts +50 -3
- package/dist/resources.js +42 -9
- package/dist/resources.js.map +1 -1
- package/dist/responseSchemas.cjs +99 -111
- package/dist/responseSchemas.cjs.map +1 -1
- package/dist/responseSchemas.d.cts +34 -34
- package/dist/responseSchemas.d.ts +34 -34
- package/dist/responseSchemas.js +85 -66
- package/dist/responseSchemas.js.map +1 -1
- package/dist/routeAmount.cjs +61 -31
- package/dist/routeAmount.cjs.map +1 -1
- package/dist/routeAmount.d.cts +52 -2
- package/dist/routeAmount.d.ts +52 -2
- package/dist/routeAmount.js +56 -8
- package/dist/routeAmount.js.map +1 -1
- package/dist/run/inputs.cjs +56 -48
- package/dist/run/inputs.cjs.map +1 -1
- package/dist/run/inputs.d.cts +70 -74
- package/dist/run/inputs.d.ts +70 -74
- package/dist/run/inputs.js +54 -23
- package/dist/run/inputs.js.map +1 -1
- package/dist/run/simulate.cjs +38 -43
- package/dist/run/simulate.cjs.map +1 -1
- package/dist/run/simulate.d.cts +36 -36
- package/dist/run/simulate.d.ts +36 -36
- package/dist/run/simulate.js +37 -19
- package/dist/run/simulate.js.map +1 -1
- package/dist/sdk.cjs +55 -66
- package/dist/sdk.cjs.map +1 -1
- package/dist/sdk.d.cts +108 -111
- package/dist/sdk.d.ts +108 -111
- package/dist/sdk.js +52 -44
- package/dist/sdk.js.map +1 -1
- package/dist/types.cjs +0 -17
- package/dist/types.d.cts +22 -22
- package/dist/types.d.ts +22 -22
- package/dist/types.js +1 -1
- package/package.json +4 -4
- package/src/client.ts +2 -2
- package/src/examples/aaveClaimRewards.ts +2 -1
- package/src/examples/emitCustomEvent.ts +1 -2
- package/src/examples/run.ts +14 -1
- package/src/examples/transferTokens.ts +21 -17
- package/src/examples/uniswapV2AddLiquidity.ts +106 -0
- package/src/examples/uniswapV3Mint.ts +95 -0
- package/src/generated/config.generated.ts +102 -47
- package/src/generated/guards.generated.ts +9 -0
- package/src/generated/operations.generated.ts +161 -5
- package/src/index.ts +0 -3
- package/dist/discovery.cjs.map +0 -1
- package/dist/discovery.js.map +0 -1
- package/dist/generated/config.generated.cjs.map +0 -1
- package/dist/generated/config.generated.js.map +0 -1
- package/dist/guards.generated-BPLFwe7y.d.ts +0 -19
- package/dist/guards.generated-M3VAIevI.d.cts +0 -19
- package/dist/materialisers.generated-BMkBQgWZ.d.ts +0 -24
- package/dist/materialisers.generated-BWq5oePO.d.cts +0 -24
- package/dist/preconditions.generated-DblS13Wq.d.cts +0 -24
- package/dist/preconditions.generated-U7YpVh30.d.ts +0 -24
- package/dist/raw-BvRghN3r.d.ts +0 -20
- package/dist/raw-s1rer8X3.d.cts +0 -20
- package/dist/resources-BKlFxjo8.d.cts +0 -56
- package/dist/resources-CYis1_DS.d.ts +0 -56
- package/dist/routeAmount-DdbJYJyM.d.cts +0 -55
- package/dist/routeAmount-DdbJYJyM.d.ts +0 -55
- package/dist/types.cjs.map +0 -1
- package/dist/types.js.map +0 -1
package/dist/client.d.cts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import { ChainSummary, GetZapPacksOptions, ZapPackOverview } from "./discovery.cjs";
|
|
2
|
+
import { ComposeCompileRequest, ComposeCompileResult, ComposeManifest, ComposeRouteRequest, SimulateRequest, SimulateResult } from "@lifi/compose-spec";
|
|
3
|
+
//#region src/client.d.ts
|
|
4
4
|
/**
|
|
5
5
|
* Configuration for creating a low-level Compose API client.
|
|
6
6
|
*/
|
|
7
|
-
interface ComposeClientOptions {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
7
|
+
export interface ComposeClientOptions {
|
|
8
|
+
/** Base URL of the Compose API. */
|
|
9
|
+
readonly baseUrl: string;
|
|
10
|
+
/** Optional custom `fetch` implementation. Defaults to `globalThis.fetch`. */
|
|
11
|
+
readonly fetch?: typeof globalThis.fetch;
|
|
12
|
+
/** LI.FI API key, sent as the `x-lifi-api-key` header on every request. Required — the Compose API rejects unauthenticated requests. */
|
|
13
|
+
readonly apiKey: string;
|
|
14
14
|
}
|
|
15
15
|
/**
|
|
16
16
|
* Low-level HTTP client for the Compose API.
|
|
@@ -21,123 +21,123 @@ interface ComposeClientOptions {
|
|
|
21
21
|
* build via `sdk.request()` then submit via `client.compile()` with custom
|
|
22
22
|
* retry logic or request inspection.
|
|
23
23
|
*/
|
|
24
|
-
interface ComposeClient {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
24
|
+
export interface ComposeClient {
|
|
25
|
+
/**
|
|
26
|
+
* Fetches the server's operation manifest describing all supported operations,
|
|
27
|
+
* guards, materialisers, and preconditions.
|
|
28
|
+
* @returns The manifest document.
|
|
29
|
+
* @throws {@link ComposeError} on network, validation, or server errors.
|
|
30
|
+
*/
|
|
31
|
+
readonly getManifest: () => Promise<ComposeManifest>;
|
|
32
|
+
/**
|
|
33
|
+
* Fetches the chains the Compose API supports, ascending by `chainId`.
|
|
34
|
+
*
|
|
35
|
+
* A chain is listed once the server confirms the VM contract is deployed on
|
|
36
|
+
* it — the same condition {@link compile}, {@link route} and
|
|
37
|
+
* {@link simulate} validate against. A chain absent from this list is
|
|
38
|
+
* rejected outright by those endpoints.
|
|
39
|
+
*
|
|
40
|
+
* The converse does not hold: a listed chain can still have no routing edge
|
|
41
|
+
* for a given token pair, which {@link route} reports as `no_route_error`.
|
|
42
|
+
* Use {@link getZapPacks} to enumerate the pairs that do route.
|
|
43
|
+
*
|
|
44
|
+
* Each entry carries a display `name` alongside its `chainId`. The name is a
|
|
45
|
+
* deployment-maintained label — render it, but key on `chainId`.
|
|
46
|
+
*
|
|
47
|
+
* The list tracks the server's chain registry, which refreshes periodically.
|
|
48
|
+
* Results are not cached by the SDK; callers should cache as appropriate.
|
|
49
|
+
*
|
|
50
|
+
* @returns The supported chains, ascending by `chainId`.
|
|
51
|
+
* @throws {@link ComposeError} on network or server errors.
|
|
52
|
+
*/
|
|
53
|
+
readonly getChains: () => Promise<readonly ChainSummary[]>;
|
|
54
|
+
/**
|
|
55
|
+
* Submits a compile request and returns the result.
|
|
56
|
+
*
|
|
57
|
+
* When the caller passes `simulationPolicy: 'allow-revert'` and the transaction
|
|
58
|
+
* reverts in simulation, the server responds with HTTP 206 and the SDK returns a
|
|
59
|
+
* partial result (`status: 'partial'`) instead of throwing. The partial result
|
|
60
|
+
* includes the transaction (without `gasLimit`) and revert diagnostics.
|
|
61
|
+
*
|
|
62
|
+
* @param request - The full compile request including flow and run inputs.
|
|
63
|
+
* @returns A discriminated result: `status: 'success'` or `status: 'partial'`.
|
|
64
|
+
* @throws {@link ComposeError} on network, validation, or server errors.
|
|
65
|
+
*/
|
|
66
|
+
readonly compile: (request: ComposeCompileRequest) => Promise<ComposeCompileResult>;
|
|
67
|
+
/**
|
|
68
|
+
* Compiles a token pair into a submit-ready transaction via
|
|
69
|
+
* `POST /compose/route`.
|
|
70
|
+
*
|
|
71
|
+
* A convenience path that skips flow authoring: the server builds a one-node
|
|
72
|
+
* zap flow with a `directDeposit` input from the `fromToken` / `toToken`
|
|
73
|
+
* pair and runs it through the same pipeline as {@link compile}. The
|
|
74
|
+
* response is therefore the same discriminated result — HTTP 206 under
|
|
75
|
+
* `simulationPolicy: 'allow-revert'` yields `status: 'partial'` rather than
|
|
76
|
+
* throwing, exactly as it does for {@link compile}.
|
|
77
|
+
*
|
|
78
|
+
* The server plans a short chain of catalog edges for the pair (a position
|
|
79
|
+
* entry or exit, a wrap or unwrap, a mint or burn), optionally opened by a
|
|
80
|
+
* `lifi.swap`. {@link getZapPacks} lists the single edges; the pairs the
|
|
81
|
+
* planner connects are their closure up to the hop budget, which
|
|
82
|
+
* {@link buildReachability} computes locally. A pair the planner cannot
|
|
83
|
+
* connect is rejected with `kind: 'no_route_error'`.
|
|
84
|
+
*
|
|
85
|
+
* Only synchronous edges are considered unless the request sets
|
|
86
|
+
* `allowAsyncRoutes: true`, so by default every terminal output comes back
|
|
87
|
+
* `delivery.when: 'now'` and a pair reachable only after settlement is a
|
|
88
|
+
* `no_route_error`. Opting in adds the `lifi.zapAsync` fallback, which still
|
|
89
|
+
* loses to a synchronous edge when the pair has one; read
|
|
90
|
+
* `outputs[*].delivery.when` to see which representation you got.
|
|
91
|
+
*
|
|
92
|
+
* Use {@link compile} for what the server does not author for you: several
|
|
93
|
+
* chained operations, splits, explicit preconditions, or per-op guards.
|
|
94
|
+
*
|
|
95
|
+
* `bigint` amounts in `amount` are serialised to decimal strings
|
|
96
|
+
* automatically.
|
|
97
|
+
*
|
|
98
|
+
* @param request - The from/to token pair, amount, signer, and route options.
|
|
99
|
+
* @returns A discriminated result: `status: 'success'` or `status: 'partial'`.
|
|
100
|
+
* @throws {@link ComposeError} on network, validation, or server errors —
|
|
101
|
+
* including `NOT_FOUND` (HTTP 404) when the planner cannot connect the pair.
|
|
102
|
+
*/
|
|
103
|
+
readonly route: (request: ComposeRouteRequest) => Promise<ComposeCompileResult>;
|
|
104
|
+
/**
|
|
105
|
+
* Fetches the available routing edges grouped by protocol.
|
|
106
|
+
*
|
|
107
|
+
* The edge catalog is dynamic — it reflects the current state of the
|
|
108
|
+
* backend's routing snapshot (protocols, chains, token blacklists).
|
|
109
|
+
* Results are not cached by the SDK; callers should cache as appropriate.
|
|
110
|
+
*
|
|
111
|
+
* @param options - Optional filter to restrict results to specific protocols.
|
|
112
|
+
* @returns An array of {@link ZapPackOverview} objects, one per protocol.
|
|
113
|
+
* @throws {@link ComposeError} on network or server errors (503 when the
|
|
114
|
+
* routing catalog is not yet initialized).
|
|
115
|
+
*/
|
|
116
|
+
readonly getZapPacks: (options?: GetZapPacksOptions) => Promise<readonly ZapPackOverview[]>;
|
|
117
|
+
/**
|
|
118
|
+
* Simulates a raw, pre-encoded transaction against `POST /simulate` and
|
|
119
|
+
* reports how the watched balances change and how much inner-call gas it
|
|
120
|
+
* burns.
|
|
121
|
+
*
|
|
122
|
+
* The result is a discriminated union on `status`:
|
|
123
|
+
* - `'ok'` — the simulation ran successfully; `deltas`/`gasUsed` are populated.
|
|
124
|
+
* - `'revert'` — the simulation ran but the transaction reverted on-chain. A
|
|
125
|
+
* revert is a *successful simulation*, not a transport error, so it is
|
|
126
|
+
* returned (HTTP 200) rather than thrown — mirroring how {@link compile}
|
|
127
|
+
* returns `status: 'partial'` on a simulated revert.
|
|
128
|
+
* - `'error'` — the request was well-formed but the simulation could not be
|
|
129
|
+
* set up or run (HTTP 422); `message` is intentionally generic.
|
|
130
|
+
*
|
|
131
|
+
* `bigint` amounts in the request (`value`, requirement `balance`/`allowance`)
|
|
132
|
+
* are serialised to decimal strings automatically.
|
|
133
|
+
*
|
|
134
|
+
* @param request - The raw transaction plus funding `requirements` and the
|
|
135
|
+
* `trackedBalances` to watch.
|
|
136
|
+
* @returns A {@link SimulateResult} (`ok` / `revert` / `error`).
|
|
137
|
+
* @throws {@link ComposeError} on network failures, HTTP 400 (malformed
|
|
138
|
+
* input), 401/403 (auth), 404, 429, and 5xx.
|
|
139
|
+
*/
|
|
140
|
+
readonly simulate: (request: SimulateRequest) => Promise<SimulateResult>;
|
|
141
141
|
}
|
|
142
142
|
/**
|
|
143
143
|
* `JSON.stringify` replacer that renders `bigint` amounts as decimal strings.
|
|
@@ -146,13 +146,13 @@ interface ComposeClient {
|
|
|
146
146
|
* no JSON representation, so every payload this client sends goes through it.
|
|
147
147
|
* Exported so the example harness prints a request exactly as it is sent.
|
|
148
148
|
*/
|
|
149
|
-
declare const bigintReplacer: (_key: string, value: unknown) => unknown;
|
|
149
|
+
export declare const bigintReplacer: (_key: string, value: unknown) => unknown;
|
|
150
150
|
/**
|
|
151
151
|
* Creates a low-level Compose API client.
|
|
152
152
|
*
|
|
153
153
|
* @param options - Client configuration including the API base URL.
|
|
154
154
|
* @returns A {@link ComposeClient} instance.
|
|
155
155
|
*/
|
|
156
|
-
declare const createComposeClient: (options: ComposeClientOptions) => ComposeClient;
|
|
157
|
-
|
|
158
|
-
|
|
156
|
+
export declare const createComposeClient: (options: ComposeClientOptions) => ComposeClient;
|
|
157
|
+
//#endregion
|
|
158
|
+
//# sourceMappingURL=client.d.cts.map
|
package/dist/client.d.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import { ChainSummary, GetZapPacksOptions, ZapPackOverview } from "./discovery.js";
|
|
2
|
+
import { ComposeCompileRequest, ComposeCompileResult, ComposeManifest, ComposeRouteRequest, SimulateRequest, SimulateResult } from "@lifi/compose-spec";
|
|
3
|
+
//#region src/client.d.ts
|
|
4
4
|
/**
|
|
5
5
|
* Configuration for creating a low-level Compose API client.
|
|
6
6
|
*/
|
|
7
|
-
interface ComposeClientOptions {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
7
|
+
export interface ComposeClientOptions {
|
|
8
|
+
/** Base URL of the Compose API. */
|
|
9
|
+
readonly baseUrl: string;
|
|
10
|
+
/** Optional custom `fetch` implementation. Defaults to `globalThis.fetch`. */
|
|
11
|
+
readonly fetch?: typeof globalThis.fetch;
|
|
12
|
+
/** LI.FI API key, sent as the `x-lifi-api-key` header on every request. Required — the Compose API rejects unauthenticated requests. */
|
|
13
|
+
readonly apiKey: string;
|
|
14
14
|
}
|
|
15
15
|
/**
|
|
16
16
|
* Low-level HTTP client for the Compose API.
|
|
@@ -21,123 +21,123 @@ interface ComposeClientOptions {
|
|
|
21
21
|
* build via `sdk.request()` then submit via `client.compile()` with custom
|
|
22
22
|
* retry logic or request inspection.
|
|
23
23
|
*/
|
|
24
|
-
interface ComposeClient {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
24
|
+
export interface ComposeClient {
|
|
25
|
+
/**
|
|
26
|
+
* Fetches the server's operation manifest describing all supported operations,
|
|
27
|
+
* guards, materialisers, and preconditions.
|
|
28
|
+
* @returns The manifest document.
|
|
29
|
+
* @throws {@link ComposeError} on network, validation, or server errors.
|
|
30
|
+
*/
|
|
31
|
+
readonly getManifest: () => Promise<ComposeManifest>;
|
|
32
|
+
/**
|
|
33
|
+
* Fetches the chains the Compose API supports, ascending by `chainId`.
|
|
34
|
+
*
|
|
35
|
+
* A chain is listed once the server confirms the VM contract is deployed on
|
|
36
|
+
* it — the same condition {@link compile}, {@link route} and
|
|
37
|
+
* {@link simulate} validate against. A chain absent from this list is
|
|
38
|
+
* rejected outright by those endpoints.
|
|
39
|
+
*
|
|
40
|
+
* The converse does not hold: a listed chain can still have no routing edge
|
|
41
|
+
* for a given token pair, which {@link route} reports as `no_route_error`.
|
|
42
|
+
* Use {@link getZapPacks} to enumerate the pairs that do route.
|
|
43
|
+
*
|
|
44
|
+
* Each entry carries a display `name` alongside its `chainId`. The name is a
|
|
45
|
+
* deployment-maintained label — render it, but key on `chainId`.
|
|
46
|
+
*
|
|
47
|
+
* The list tracks the server's chain registry, which refreshes periodically.
|
|
48
|
+
* Results are not cached by the SDK; callers should cache as appropriate.
|
|
49
|
+
*
|
|
50
|
+
* @returns The supported chains, ascending by `chainId`.
|
|
51
|
+
* @throws {@link ComposeError} on network or server errors.
|
|
52
|
+
*/
|
|
53
|
+
readonly getChains: () => Promise<readonly ChainSummary[]>;
|
|
54
|
+
/**
|
|
55
|
+
* Submits a compile request and returns the result.
|
|
56
|
+
*
|
|
57
|
+
* When the caller passes `simulationPolicy: 'allow-revert'` and the transaction
|
|
58
|
+
* reverts in simulation, the server responds with HTTP 206 and the SDK returns a
|
|
59
|
+
* partial result (`status: 'partial'`) instead of throwing. The partial result
|
|
60
|
+
* includes the transaction (without `gasLimit`) and revert diagnostics.
|
|
61
|
+
*
|
|
62
|
+
* @param request - The full compile request including flow and run inputs.
|
|
63
|
+
* @returns A discriminated result: `status: 'success'` or `status: 'partial'`.
|
|
64
|
+
* @throws {@link ComposeError} on network, validation, or server errors.
|
|
65
|
+
*/
|
|
66
|
+
readonly compile: (request: ComposeCompileRequest) => Promise<ComposeCompileResult>;
|
|
67
|
+
/**
|
|
68
|
+
* Compiles a token pair into a submit-ready transaction via
|
|
69
|
+
* `POST /compose/route`.
|
|
70
|
+
*
|
|
71
|
+
* A convenience path that skips flow authoring: the server builds a one-node
|
|
72
|
+
* zap flow with a `directDeposit` input from the `fromToken` / `toToken`
|
|
73
|
+
* pair and runs it through the same pipeline as {@link compile}. The
|
|
74
|
+
* response is therefore the same discriminated result — HTTP 206 under
|
|
75
|
+
* `simulationPolicy: 'allow-revert'` yields `status: 'partial'` rather than
|
|
76
|
+
* throwing, exactly as it does for {@link compile}.
|
|
77
|
+
*
|
|
78
|
+
* The server plans a short chain of catalog edges for the pair (a position
|
|
79
|
+
* entry or exit, a wrap or unwrap, a mint or burn), optionally opened by a
|
|
80
|
+
* `lifi.swap`. {@link getZapPacks} lists the single edges; the pairs the
|
|
81
|
+
* planner connects are their closure up to the hop budget, which
|
|
82
|
+
* {@link buildReachability} computes locally. A pair the planner cannot
|
|
83
|
+
* connect is rejected with `kind: 'no_route_error'`.
|
|
84
|
+
*
|
|
85
|
+
* Only synchronous edges are considered unless the request sets
|
|
86
|
+
* `allowAsyncRoutes: true`, so by default every terminal output comes back
|
|
87
|
+
* `delivery.when: 'now'` and a pair reachable only after settlement is a
|
|
88
|
+
* `no_route_error`. Opting in adds the `lifi.zapAsync` fallback, which still
|
|
89
|
+
* loses to a synchronous edge when the pair has one; read
|
|
90
|
+
* `outputs[*].delivery.when` to see which representation you got.
|
|
91
|
+
*
|
|
92
|
+
* Use {@link compile} for what the server does not author for you: several
|
|
93
|
+
* chained operations, splits, explicit preconditions, or per-op guards.
|
|
94
|
+
*
|
|
95
|
+
* `bigint` amounts in `amount` are serialised to decimal strings
|
|
96
|
+
* automatically.
|
|
97
|
+
*
|
|
98
|
+
* @param request - The from/to token pair, amount, signer, and route options.
|
|
99
|
+
* @returns A discriminated result: `status: 'success'` or `status: 'partial'`.
|
|
100
|
+
* @throws {@link ComposeError} on network, validation, or server errors —
|
|
101
|
+
* including `NOT_FOUND` (HTTP 404) when the planner cannot connect the pair.
|
|
102
|
+
*/
|
|
103
|
+
readonly route: (request: ComposeRouteRequest) => Promise<ComposeCompileResult>;
|
|
104
|
+
/**
|
|
105
|
+
* Fetches the available routing edges grouped by protocol.
|
|
106
|
+
*
|
|
107
|
+
* The edge catalog is dynamic — it reflects the current state of the
|
|
108
|
+
* backend's routing snapshot (protocols, chains, token blacklists).
|
|
109
|
+
* Results are not cached by the SDK; callers should cache as appropriate.
|
|
110
|
+
*
|
|
111
|
+
* @param options - Optional filter to restrict results to specific protocols.
|
|
112
|
+
* @returns An array of {@link ZapPackOverview} objects, one per protocol.
|
|
113
|
+
* @throws {@link ComposeError} on network or server errors (503 when the
|
|
114
|
+
* routing catalog is not yet initialized).
|
|
115
|
+
*/
|
|
116
|
+
readonly getZapPacks: (options?: GetZapPacksOptions) => Promise<readonly ZapPackOverview[]>;
|
|
117
|
+
/**
|
|
118
|
+
* Simulates a raw, pre-encoded transaction against `POST /simulate` and
|
|
119
|
+
* reports how the watched balances change and how much inner-call gas it
|
|
120
|
+
* burns.
|
|
121
|
+
*
|
|
122
|
+
* The result is a discriminated union on `status`:
|
|
123
|
+
* - `'ok'` — the simulation ran successfully; `deltas`/`gasUsed` are populated.
|
|
124
|
+
* - `'revert'` — the simulation ran but the transaction reverted on-chain. A
|
|
125
|
+
* revert is a *successful simulation*, not a transport error, so it is
|
|
126
|
+
* returned (HTTP 200) rather than thrown — mirroring how {@link compile}
|
|
127
|
+
* returns `status: 'partial'` on a simulated revert.
|
|
128
|
+
* - `'error'` — the request was well-formed but the simulation could not be
|
|
129
|
+
* set up or run (HTTP 422); `message` is intentionally generic.
|
|
130
|
+
*
|
|
131
|
+
* `bigint` amounts in the request (`value`, requirement `balance`/`allowance`)
|
|
132
|
+
* are serialised to decimal strings automatically.
|
|
133
|
+
*
|
|
134
|
+
* @param request - The raw transaction plus funding `requirements` and the
|
|
135
|
+
* `trackedBalances` to watch.
|
|
136
|
+
* @returns A {@link SimulateResult} (`ok` / `revert` / `error`).
|
|
137
|
+
* @throws {@link ComposeError} on network failures, HTTP 400 (malformed
|
|
138
|
+
* input), 401/403 (auth), 404, 429, and 5xx.
|
|
139
|
+
*/
|
|
140
|
+
readonly simulate: (request: SimulateRequest) => Promise<SimulateResult>;
|
|
141
141
|
}
|
|
142
142
|
/**
|
|
143
143
|
* `JSON.stringify` replacer that renders `bigint` amounts as decimal strings.
|
|
@@ -146,13 +146,13 @@ interface ComposeClient {
|
|
|
146
146
|
* no JSON representation, so every payload this client sends goes through it.
|
|
147
147
|
* Exported so the example harness prints a request exactly as it is sent.
|
|
148
148
|
*/
|
|
149
|
-
declare const bigintReplacer: (_key: string, value: unknown) => unknown;
|
|
149
|
+
export declare const bigintReplacer: (_key: string, value: unknown) => unknown;
|
|
150
150
|
/**
|
|
151
151
|
* Creates a low-level Compose API client.
|
|
152
152
|
*
|
|
153
153
|
* @param options - Client configuration including the API base URL.
|
|
154
154
|
* @returns A {@link ComposeClient} instance.
|
|
155
155
|
*/
|
|
156
|
-
declare const createComposeClient: (options: ComposeClientOptions) => ComposeClient;
|
|
157
|
-
|
|
158
|
-
|
|
156
|
+
export declare const createComposeClient: (options: ComposeClientOptions) => ComposeClient;
|
|
157
|
+
//#endregion
|
|
158
|
+
//# sourceMappingURL=client.d.ts.map
|