@lifi/composer-sdk 0.4.1 → 0.5.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 +6 -3
- package/dist/authoring/FlowBuilderCore.cjs +1 -5
- package/dist/authoring/FlowBuilderCore.cjs.map +1 -1
- package/dist/authoring/FlowBuilderCore.d.cts +9 -7
- package/dist/authoring/FlowBuilderCore.d.ts +9 -7
- package/dist/authoring/FlowBuilderCore.js +2 -6
- package/dist/authoring/FlowBuilderCore.js.map +1 -1
- package/dist/authoring/handles.cjs +5 -2
- package/dist/authoring/handles.cjs.map +1 -1
- package/dist/authoring/handles.d.cts +25 -6
- package/dist/authoring/handles.d.ts +25 -6
- package/dist/authoring/handles.js +3 -1
- package/dist/authoring/handles.js.map +1 -1
- package/dist/authoring/raw.cjs +3 -0
- package/dist/authoring/raw.cjs.map +1 -1
- package/dist/authoring/raw.d.cts +33 -3
- package/dist/authoring/raw.d.ts +33 -3
- package/dist/authoring/raw.js +2 -0
- package/dist/authoring/raw.js.map +1 -1
- package/dist/authoring/signatureArgs.cjs.map +1 -1
- package/dist/authoring/signatureArgs.d.cts +16 -12
- package/dist/authoring/signatureArgs.d.ts +16 -12
- package/dist/authoring/signatureArgs.js.map +1 -1
- package/dist/client.cjs +70 -36
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.cts +33 -4
- package/dist/client.d.ts +33 -4
- package/dist/client.js +70 -36
- package/dist/client.js.map +1 -1
- package/dist/discovery.cjs.map +1 -1
- package/dist/discovery.d.cts +18 -2
- package/dist/discovery.d.ts +18 -2
- package/dist/generated/config.generated.cjs.map +1 -1
- package/dist/generated/config.generated.d.cts +21 -1
- package/dist/generated/config.generated.d.ts +21 -1
- package/dist/generated/operations.generated.cjs +6 -0
- package/dist/generated/operations.generated.cjs.map +1 -1
- package/dist/generated/operations.generated.d.cts +18 -2
- package/dist/generated/operations.generated.d.ts +18 -2
- package/dist/generated/operations.generated.js +6 -0
- package/dist/generated/operations.generated.js.map +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -6
- package/dist/index.d.ts +6 -6
- package/dist/index.js.map +1 -1
- package/dist/{raw-IxCF_bSS.d.ts → raw-BvRghN3r.d.ts} +3 -2
- package/dist/{raw-Dj_2rBSQ.d.cts → raw-s1rer8X3.d.cts} +3 -2
- package/dist/raw.cjs +2 -0
- package/dist/raw.cjs.map +1 -1
- package/dist/raw.d.cts +1 -1
- package/dist/raw.d.ts +1 -1
- package/dist/raw.js +2 -1
- package/dist/raw.js.map +1 -1
- package/dist/run/inputs.cjs +14 -15
- package/dist/run/inputs.cjs.map +1 -1
- package/dist/run/inputs.d.cts +8 -0
- package/dist/run/inputs.d.ts +8 -0
- package/dist/run/inputs.js +14 -15
- package/dist/run/inputs.js.map +1 -1
- package/dist/run/simulate.cjs +5 -0
- package/dist/run/simulate.cjs.map +1 -1
- package/dist/run/simulate.d.cts +5 -2
- package/dist/run/simulate.d.ts +5 -2
- package/dist/run/simulate.js +5 -0
- package/dist/run/simulate.js.map +1 -1
- package/dist/sdk.cjs +2 -0
- package/dist/sdk.cjs.map +1 -1
- package/dist/sdk.d.cts +28 -1
- package/dist/sdk.d.ts +28 -1
- package/dist/sdk.js +2 -0
- package/dist/sdk.js.map +1 -1
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.cts +18 -2
- package/dist/types.d.ts +18 -2
- package/package.json +3 -10
- package/src/authoring/FlowBuilderCore.ts +13 -15
- package/src/authoring/handles.ts +41 -5
- package/src/authoring/raw.ts +36 -2
- package/src/authoring/signatureArgs.ts +17 -13
- package/src/client.ts +133 -39
- package/src/discovery.ts +18 -1
- package/src/examples/flySwap.ts +167 -0
- package/src/examples/run.ts +29 -4
- package/src/examples/supportedChains.ts +122 -0
- package/src/generated/config.generated.ts +24 -0
- package/src/generated/operations.generated.ts +26 -0
- package/src/index.ts +10 -1
- package/src/raw.ts +1 -1
- package/src/run/inputs.ts +30 -11
- package/src/run/simulate.ts +14 -2
- package/src/sdk.ts +30 -0
- package/src/types.ts +20 -1
package/src/sdk.ts
CHANGED
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
type TypedFlow,
|
|
15
15
|
} from './authoring/FlowBuilderCore.js';
|
|
16
16
|
import { type ComposeClient, createComposeClient } from './client.js';
|
|
17
|
+
import type { ChainSummary } from './discovery.js';
|
|
17
18
|
import {
|
|
18
19
|
bindGeneratedOps,
|
|
19
20
|
type GeneratedOps,
|
|
@@ -109,6 +110,33 @@ export interface ComposeSdk {
|
|
|
109
110
|
chainId: number,
|
|
110
111
|
options: FlowOptions<T>,
|
|
111
112
|
) => FlowBuilder<T>;
|
|
113
|
+
/**
|
|
114
|
+
* Fetches the chains this Compose deployment supports, ascending by
|
|
115
|
+
* `chainId`. Thin pass-through to {@link ComposeClient.getChains}; see it
|
|
116
|
+
* for what "supported" means and for the caching caveat.
|
|
117
|
+
*
|
|
118
|
+
* Each entry pairs the `chainId` with a display `name`, so one call both
|
|
119
|
+
* gates a chain selector and labels it. Key on `chainId`; `name` is a
|
|
120
|
+
* deployment-maintained label that can change.
|
|
121
|
+
*
|
|
122
|
+
* Use it to fail fast before building a flow for a chain the server would
|
|
123
|
+
* reject.
|
|
124
|
+
*
|
|
125
|
+
* @returns The supported chains, ascending by `chainId`.
|
|
126
|
+
* @throws {@link ComposeError} on network or server errors.
|
|
127
|
+
*
|
|
128
|
+
* @example
|
|
129
|
+
* ```ts
|
|
130
|
+
* const chains = await sdk.getSupportedChains();
|
|
131
|
+
* if (!chains.some((c) => c.chainId === 8453)) {
|
|
132
|
+
* throw new Error('Base is not supported');
|
|
133
|
+
* }
|
|
134
|
+
* for (const { chainId, name } of chains) {
|
|
135
|
+
* console.log(`${name} (${chainId})`);
|
|
136
|
+
* }
|
|
137
|
+
* ```
|
|
138
|
+
*/
|
|
139
|
+
readonly getSupportedChains: () => Promise<readonly ChainSummary[]>;
|
|
112
140
|
/**
|
|
113
141
|
* Builds a raw compile request without sending it. Useful for inspecting the
|
|
114
142
|
* request payload or submitting it through a custom transport.
|
|
@@ -178,6 +206,7 @@ export const createComposeSdk = (options: ComposeSdkOptions): ComposeSdk => {
|
|
|
178
206
|
maxPriceImpactBps: run.maxPriceImpactBps,
|
|
179
207
|
sweepTo: run.sweepTo,
|
|
180
208
|
simulationPolicy: run.simulationPolicy,
|
|
209
|
+
simulateUserProgram: run.simulateUserProgram,
|
|
181
210
|
checkOnChainAllowances: run.checkOnChainAllowances,
|
|
182
211
|
}),
|
|
183
212
|
});
|
|
@@ -203,6 +232,7 @@ export const createComposeSdk = (options: ComposeSdkOptions): ComposeSdk => {
|
|
|
203
232
|
return {
|
|
204
233
|
client: composeClient,
|
|
205
234
|
flow,
|
|
235
|
+
getSupportedChains: composeClient.getChains,
|
|
206
236
|
request,
|
|
207
237
|
route: composeClient.route,
|
|
208
238
|
simulate: composeClient.simulate,
|
package/src/types.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Ref } from '@lifi/compose-spec';
|
|
1
|
+
import type { LiteralBinding, Ref } from '@lifi/compose-spec';
|
|
2
2
|
import {
|
|
3
3
|
InputSpec,
|
|
4
4
|
MaterialiserInput,
|
|
@@ -58,6 +58,25 @@ export interface TypedRef<T extends OutputKind = OutputKind> extends Ref {
|
|
|
58
58
|
readonly __outputKind?: T;
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
+
/**
|
|
62
|
+
* A literal bind value carrying a phantom type parameter.
|
|
63
|
+
*
|
|
64
|
+
* The wire format accepts a constant in a bind slot as
|
|
65
|
+
* `{ kind: <solType>, value: <string> }`, alongside `$ref` pointers. Use it
|
|
66
|
+
* for a value that must be baked into the flow document rather than supplied
|
|
67
|
+
* at run time — the destination of a flow the backend stores and re-runs
|
|
68
|
+
* later (a `continuation.settle` node's `continuationFlow`) has no run to
|
|
69
|
+
* take an input from.
|
|
70
|
+
*
|
|
71
|
+
* @typeParam T - The Solidity type of the literal (e.g. `'address'`).
|
|
72
|
+
*/
|
|
73
|
+
export interface TypedLiteral<
|
|
74
|
+
T extends SolType = SolType,
|
|
75
|
+
> extends LiteralBinding {
|
|
76
|
+
readonly kind: T;
|
|
77
|
+
readonly __outputKind?: T;
|
|
78
|
+
}
|
|
79
|
+
|
|
61
80
|
/**
|
|
62
81
|
* An input declaration in a flow schema.
|
|
63
82
|
* `Resource` values become resource inputs (token amounts);
|