@lifi/composer-sdk 0.8.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 +3 -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 +804 -936
- package/dist/generated/config.generated.d.ts +804 -936
- package/dist/generated/config.generated.js +1 -1
- package/dist/generated/guards.generated.cjs +25 -35
- 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 +19 -11
- 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 -277
- package/dist/generated/operations.generated.cjs.map +1 -1
- package/dist/generated/operations.generated.d.cts +719 -708
- package/dist/generated/operations.generated.d.ts +719 -708
- package/dist/generated/operations.generated.js +235 -256
- 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 +1 -1
- package/src/examples/transferTokens.ts +21 -17
- package/src/generated/config.generated.ts +20 -9
- package/src/generated/operations.generated.ts +28 -5
- 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-CDCgYGZo.d.cts +0 -24
- package/dist/guards.generated-CdYcs4h0.d.ts +0 -24
- 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/run/inputs.cjs
CHANGED
|
@@ -1,53 +1,61 @@
|
|
|
1
|
-
"
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
});
|
|
24
|
-
module.exports = __toCommonJS(inputs_exports);
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
//#region src/run/inputs.ts
|
|
3
|
+
/**
|
|
4
|
+
* Creates an untyped materialiser input spec. This is a low-level escape hatch
|
|
5
|
+
* for materialiser kinds not yet covered by the generated helpers.
|
|
6
|
+
*
|
|
7
|
+
* Prefer the typed helpers in the `materialisers` namespace (e.g.
|
|
8
|
+
* `materialisers.balanceOf()`, `materialisers.directDeposit()`) which provide
|
|
9
|
+
* compile-time config validation.
|
|
10
|
+
*
|
|
11
|
+
* @param kind - The materialiser type (e.g. `"balanceOf"`, `"directDeposit"`).
|
|
12
|
+
* @param config - Optional materialiser-specific configuration.
|
|
13
|
+
* @returns A {@link MaterialiserInput} for use in {@link ComposeRunInput.inputs}.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```ts
|
|
17
|
+
* const run = {
|
|
18
|
+
* inputs: { token: materialiser('customKind', { myParam: '0x...' }) },
|
|
19
|
+
* signer: '0x...',
|
|
20
|
+
* };
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
25
23
|
const materialiser = (kind, config = {}) => ({
|
|
26
|
-
|
|
27
|
-
|
|
24
|
+
kind,
|
|
25
|
+
...config
|
|
28
26
|
});
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
27
|
+
/**
|
|
28
|
+
* Drops the keys whose value is `undefined`, so optional fields are omitted
|
|
29
|
+
* from the wire payload rather than serialized as `null`.
|
|
30
|
+
*
|
|
31
|
+
* A local copy of `pickDefined` from `@lifi/utils`: this package is published
|
|
32
|
+
* to npm and `@lifi/utils` is a private workspace package, so it cannot be a
|
|
33
|
+
* runtime dependency here.
|
|
34
|
+
*/
|
|
35
|
+
const pickDefined = (obj) => Object.fromEntries(Object.entries(obj).filter(([, value]) => value !== void 0));
|
|
36
|
+
/**
|
|
37
|
+
* Assembles a {@link ComposeRun} object from individual parameters.
|
|
38
|
+
* Used internally by the SDK; prefer {@link ComposeRunInput} for external use.
|
|
39
|
+
*
|
|
40
|
+
* @internal
|
|
41
|
+
*/
|
|
32
42
|
const buildRun = (run) => ({
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
})
|
|
47
|
-
});
|
|
48
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
49
|
-
0 && (module.exports = {
|
|
50
|
-
buildRun,
|
|
51
|
-
materialiser
|
|
43
|
+
inputs: run.inputs,
|
|
44
|
+
signer: run.signer,
|
|
45
|
+
...pickDefined({
|
|
46
|
+
preconditions: run.preconditions?.length ? run.preconditions : void 0,
|
|
47
|
+
assumptions: run.assumptions,
|
|
48
|
+
referrer: run.referrer,
|
|
49
|
+
integratorFeeBps: run.integratorFeeBps,
|
|
50
|
+
maxPriceImpactBps: run.maxPriceImpactBps,
|
|
51
|
+
sweepTo: run.sweepTo,
|
|
52
|
+
simulationPolicy: run.simulationPolicy,
|
|
53
|
+
simulateUserProgram: run.simulateUserProgram,
|
|
54
|
+
checkOnChainAllowances: run.checkOnChainAllowances
|
|
55
|
+
})
|
|
52
56
|
});
|
|
57
|
+
//#endregion
|
|
58
|
+
exports.buildRun = buildRun;
|
|
59
|
+
exports.materialiser = materialiser;
|
|
60
|
+
|
|
53
61
|
//# sourceMappingURL=inputs.cjs.map
|
package/dist/run/inputs.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/run/inputs.ts"],"sourcesContent":["import type {\n ComposeRun,\n InputSpec,\n MaterialiserInput,\n Precondition,\n SimulationPolicy,\n SweepTo,\n} from '@lifi/compose-spec';\n\nimport type { Address, InputSchema, InputSpecOf } from '../types.js';\n\n/**\n * Runtime inputs for compiling a flow. Passed to `builder.compile()` or `sdk.request()`.\n *\n * @typeParam T - The flow's input schema, used to type-check `inputs` and `assumptions`.\n */\nexport interface ComposeRunInput<T extends InputSchema = InputSchema> {\n /**\n * Concrete values for each declared flow input. Resource inputs accept a\n * materialiser or a literal integer amount; scalar inputs accept the matching type.\n */\n readonly inputs: { readonly [K in keyof T]: InputSpecOf<T[K]> };\n /** Optional preconditions that must hold before the flow executes (e.g. minimum balances). */\n readonly preconditions?: readonly Precondition[];\n /** The `0x`-prefixed address of the transaction signer. */\n readonly signer: Address;\n /**\n * Optional assumed token amounts for resource inputs, keyed by input name.\n * When a materialiser resolves amounts at execution time rather than upfront,\n * assumptions let the compiler plan routes using estimated values. The keys\n * must match the input names declared in the flow schema.\n */\n readonly assumptions?: { readonly [K in keyof T]?: bigint };\n /** Optional integrator referrer identifier. */\n readonly referrer?: string;\n /**\n * Optional integrator fee in basis points (1bp = 0.01%, max `9000` = 90%).\n * A non-zero value requires the request to be authenticated with an\n * integration-scoped API key — the integration is derived from the key, not\n * this field. Defaults to `0` (no fee) when omitted.\n */\n readonly integratorFeeBps?: number;\n /** Maximum acceptable price impact in basis points (e.g. `300` = 3%). */\n readonly maxPriceImpactBps?: number;\n /**\n * Destination for sweeping all proxy-held terminal resources after execution.\n * Pass a literal `0x`-prefixed address or `{ $ref: \"context.sender\" }` to\n * send remaining tokens to the signer.\n */\n readonly sweepTo?: SweepTo;\n /**\n * Controls behavior when simulation detects a revert.\n * `'strict'` (default) returns an error; `'allow-revert'` returns a partial\n * result with the transaction and revert diagnostics.\n */\n readonly simulationPolicy?: SimulationPolicy;\n /**\n * When `true`, the server also simulates the final user-facing transaction\n * after the structured simulation succeeds; reverts honour\n * `simulationPolicy`. On success the result is echoed back on the response as\n * `userProgramSimulation`. Defaults to `false`.\n */\n readonly simulateUserProgram?: boolean;\n /**\n * When `true`, the server checks on-chain ERC-20 allowances and omits\n * approvals that are already sufficient. Defaults to `false`.\n */\n readonly checkOnChainAllowances?: boolean;\n}\n\n/**\n * Creates an untyped materialiser input spec. This is a low-level escape hatch\n * for materialiser kinds not yet covered by the generated helpers.\n *\n * Prefer the typed helpers in the `materialisers` namespace (e.g.\n * `materialisers.balanceOf()`, `materialisers.directDeposit()`) which provide\n * compile-time config validation.\n *\n * @param kind - The materialiser type (e.g. `\"balanceOf\"`, `\"directDeposit\"`).\n * @param config - Optional materialiser-specific configuration.\n * @returns A {@link MaterialiserInput} for use in {@link ComposeRunInput.inputs}.\n *\n * @example\n * ```ts\n * const run = {\n * inputs: { token: materialiser('customKind', { myParam: '0x...' }) },\n * signer: '0x...',\n * };\n * ```\n */\nexport const materialiser = (\n kind: string,\n config: Record<string, unknown> = {},\n): MaterialiserInput => ({\n kind,\n ...config,\n});\n\n/**\n * Drops the keys whose value is `undefined`, so optional fields are omitted\n * from the wire payload rather than serialized as `null`.\n *\n * A local copy of `pickDefined` from `@lifi/utils`: this package is published\n * to npm and `@lifi/utils` is a private workspace package, so it cannot be a\n * runtime dependency here.\n */\nconst pickDefined = <S extends Record<string, unknown>>(\n obj: S,\n): Partial<{ [K in keyof S]: Exclude<S[K], undefined> }> =>\n Object.fromEntries(\n Object.entries(obj).filter(([, value]) => value !== undefined),\n ) as Partial<{ [K in keyof S]: Exclude<S[K], undefined> }>;\n\n/**\n * Assembles a {@link ComposeRun} object from individual parameters.\n * Used internally by the SDK; prefer {@link ComposeRunInput} for external use.\n *\n * @internal\n */\nexport const buildRun = (run: {\n inputs: Record<string, InputSpec>;\n preconditions?: readonly Precondition[];\n signer: string;\n assumptions?: Record<string, bigint>;\n referrer?: string;\n integratorFeeBps?: number;\n maxPriceImpactBps?: number;\n sweepTo?: SweepTo;\n simulationPolicy?: SimulationPolicy;\n simulateUserProgram?: boolean;\n checkOnChainAllowances?: boolean;\n}): ComposeRun => ({\n inputs: run.inputs,\n signer: run.signer,\n ...pickDefined({\n // An empty precondition list is the same as none, so drop it too.\n preconditions: run.preconditions?.length ? run.preconditions : undefined,\n assumptions: run.assumptions,\n referrer: run.referrer,\n integratorFeeBps: run.integratorFeeBps,\n maxPriceImpactBps: run.maxPriceImpactBps,\n sweepTo: run.sweepTo,\n simulationPolicy: run.simulationPolicy,\n simulateUserProgram: run.simulateUserProgram,\n checkOnChainAllowances: run.checkOnChainAllowances,\n }),\n});\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"inputs.cjs","names":[],"sources":["../../src/run/inputs.ts"],"sourcesContent":["import type {\n ComposeRun,\n InputSpec,\n MaterialiserInput,\n Precondition,\n SimulationPolicy,\n SweepTo,\n} from '@lifi/compose-spec';\n\nimport type { Address, InputSchema, InputSpecOf } from '../types.js';\n\n/**\n * Runtime inputs for compiling a flow. Passed to `builder.compile()` or `sdk.request()`.\n *\n * @typeParam T - The flow's input schema, used to type-check `inputs` and `assumptions`.\n */\nexport interface ComposeRunInput<T extends InputSchema = InputSchema> {\n /**\n * Concrete values for each declared flow input. Resource inputs accept a\n * materialiser or a literal integer amount; scalar inputs accept the matching type.\n */\n readonly inputs: { readonly [K in keyof T]: InputSpecOf<T[K]> };\n /** Optional preconditions that must hold before the flow executes (e.g. minimum balances). */\n readonly preconditions?: readonly Precondition[];\n /** The `0x`-prefixed address of the transaction signer. */\n readonly signer: Address;\n /**\n * Optional assumed token amounts for resource inputs, keyed by input name.\n * When a materialiser resolves amounts at execution time rather than upfront,\n * assumptions let the compiler plan routes using estimated values. The keys\n * must match the input names declared in the flow schema.\n */\n readonly assumptions?: { readonly [K in keyof T]?: bigint };\n /** Optional integrator referrer identifier. */\n readonly referrer?: string;\n /**\n * Optional integrator fee in basis points (1bp = 0.01%, max `9000` = 90%).\n * A non-zero value requires the request to be authenticated with an\n * integration-scoped API key — the integration is derived from the key, not\n * this field. Defaults to `0` (no fee) when omitted.\n */\n readonly integratorFeeBps?: number;\n /** Maximum acceptable price impact in basis points (e.g. `300` = 3%). */\n readonly maxPriceImpactBps?: number;\n /**\n * Destination for sweeping all proxy-held terminal resources after execution.\n * Pass a literal `0x`-prefixed address or `{ $ref: \"context.sender\" }` to\n * send remaining tokens to the signer.\n */\n readonly sweepTo?: SweepTo;\n /**\n * Controls behavior when simulation detects a revert.\n * `'strict'` (default) returns an error; `'allow-revert'` returns a partial\n * result with the transaction and revert diagnostics.\n */\n readonly simulationPolicy?: SimulationPolicy;\n /**\n * When `true`, the server also simulates the final user-facing transaction\n * after the structured simulation succeeds; reverts honour\n * `simulationPolicy`. On success the result is echoed back on the response as\n * `userProgramSimulation`. Defaults to `false`.\n */\n readonly simulateUserProgram?: boolean;\n /**\n * When `true`, the server checks on-chain ERC-20 allowances and omits\n * approvals that are already sufficient. Defaults to `false`.\n */\n readonly checkOnChainAllowances?: boolean;\n}\n\n/**\n * Creates an untyped materialiser input spec. This is a low-level escape hatch\n * for materialiser kinds not yet covered by the generated helpers.\n *\n * Prefer the typed helpers in the `materialisers` namespace (e.g.\n * `materialisers.balanceOf()`, `materialisers.directDeposit()`) which provide\n * compile-time config validation.\n *\n * @param kind - The materialiser type (e.g. `\"balanceOf\"`, `\"directDeposit\"`).\n * @param config - Optional materialiser-specific configuration.\n * @returns A {@link MaterialiserInput} for use in {@link ComposeRunInput.inputs}.\n *\n * @example\n * ```ts\n * const run = {\n * inputs: { token: materialiser('customKind', { myParam: '0x...' }) },\n * signer: '0x...',\n * };\n * ```\n */\nexport const materialiser = (\n kind: string,\n config: Record<string, unknown> = {},\n): MaterialiserInput => ({\n kind,\n ...config,\n});\n\n/**\n * Drops the keys whose value is `undefined`, so optional fields are omitted\n * from the wire payload rather than serialized as `null`.\n *\n * A local copy of `pickDefined` from `@lifi/utils`: this package is published\n * to npm and `@lifi/utils` is a private workspace package, so it cannot be a\n * runtime dependency here.\n */\nconst pickDefined = <S extends Record<string, unknown>>(\n obj: S,\n): Partial<{ [K in keyof S]: Exclude<S[K], undefined> }> =>\n Object.fromEntries(\n Object.entries(obj).filter(([, value]) => value !== undefined),\n ) as Partial<{ [K in keyof S]: Exclude<S[K], undefined> }>;\n\n/**\n * Assembles a {@link ComposeRun} object from individual parameters.\n * Used internally by the SDK; prefer {@link ComposeRunInput} for external use.\n *\n * @internal\n */\nexport const buildRun = (run: {\n inputs: Record<string, InputSpec>;\n preconditions?: readonly Precondition[];\n signer: string;\n assumptions?: Record<string, bigint>;\n referrer?: string;\n integratorFeeBps?: number;\n maxPriceImpactBps?: number;\n sweepTo?: SweepTo;\n simulationPolicy?: SimulationPolicy;\n simulateUserProgram?: boolean;\n checkOnChainAllowances?: boolean;\n}): ComposeRun => ({\n inputs: run.inputs,\n signer: run.signer,\n ...pickDefined({\n // An empty precondition list is the same as none, so drop it too.\n preconditions: run.preconditions?.length ? run.preconditions : undefined,\n assumptions: run.assumptions,\n referrer: run.referrer,\n integratorFeeBps: run.integratorFeeBps,\n maxPriceImpactBps: run.maxPriceImpactBps,\n sweepTo: run.sweepTo,\n simulationPolicy: run.simulationPolicy,\n simulateUserProgram: run.simulateUserProgram,\n checkOnChainAllowances: run.checkOnChainAllowances,\n }),\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AA0FA,MAAa,gBACX,MACA,SAAkC,CAAC,OACZ;CACvB;CACA,GAAG;AACL;;;;;;;;;AAUA,MAAM,eACJ,QAEA,OAAO,YACL,OAAO,QAAQ,GAAG,CAAC,CAAC,QAAQ,GAAG,WAAW,UAAU,KAAA,CAAS,CAC/D;;;;;;;AAQF,MAAa,YAAY,SAYN;CACjB,QAAQ,IAAI;CACZ,QAAQ,IAAI;CACZ,GAAG,YAAY;EAEb,eAAe,IAAI,eAAe,SAAS,IAAI,gBAAgB,KAAA;EAC/D,aAAa,IAAI;EACjB,UAAU,IAAI;EACd,kBAAkB,IAAI;EACtB,mBAAmB,IAAI;EACvB,SAAS,IAAI;EACb,kBAAkB,IAAI;EACtB,qBAAqB,IAAI;EACzB,wBAAwB,IAAI;CAC9B,CAAC;AACH"}
|
package/dist/run/inputs.d.cts
CHANGED
|
@@ -1,67 +1,63 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import { Address, InputSchema, InputSpecOf } from "../types.cjs";
|
|
2
|
+
import { ComposeRun, InputSpec, MaterialiserInput, Precondition, SimulationPolicy, SweepTo } from "@lifi/compose-spec";
|
|
3
|
+
//#region src/run/inputs.d.ts
|
|
4
4
|
/**
|
|
5
5
|
* Runtime inputs for compiling a flow. Passed to `builder.compile()` or `sdk.request()`.
|
|
6
6
|
*
|
|
7
7
|
* @typeParam T - The flow's input schema, used to type-check `inputs` and `assumptions`.
|
|
8
8
|
*/
|
|
9
|
-
interface ComposeRunInput<T extends InputSchema = InputSchema> {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
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
|
-
* When `true`, the server checks on-chain ERC-20 allowances and omits
|
|
62
|
-
* approvals that are already sufficient. Defaults to `false`.
|
|
63
|
-
*/
|
|
64
|
-
readonly checkOnChainAllowances?: boolean;
|
|
9
|
+
export interface ComposeRunInput<T extends InputSchema = InputSchema> {
|
|
10
|
+
/**
|
|
11
|
+
* Concrete values for each declared flow input. Resource inputs accept a
|
|
12
|
+
* materialiser or a literal integer amount; scalar inputs accept the matching type.
|
|
13
|
+
*/
|
|
14
|
+
readonly inputs: { readonly [K in keyof T]: InputSpecOf<T[K]>; };
|
|
15
|
+
/** Optional preconditions that must hold before the flow executes (e.g. minimum balances). */
|
|
16
|
+
readonly preconditions?: readonly Precondition[];
|
|
17
|
+
/** The `0x`-prefixed address of the transaction signer. */
|
|
18
|
+
readonly signer: Address;
|
|
19
|
+
/**
|
|
20
|
+
* Optional assumed token amounts for resource inputs, keyed by input name.
|
|
21
|
+
* When a materialiser resolves amounts at execution time rather than upfront,
|
|
22
|
+
* assumptions let the compiler plan routes using estimated values. The keys
|
|
23
|
+
* must match the input names declared in the flow schema.
|
|
24
|
+
*/
|
|
25
|
+
readonly assumptions?: { readonly [K in keyof T]?: bigint; };
|
|
26
|
+
/** Optional integrator referrer identifier. */
|
|
27
|
+
readonly referrer?: string;
|
|
28
|
+
/**
|
|
29
|
+
* Optional integrator fee in basis points (1bp = 0.01%, max `9000` = 90%).
|
|
30
|
+
* A non-zero value requires the request to be authenticated with an
|
|
31
|
+
* integration-scoped API key — the integration is derived from the key, not
|
|
32
|
+
* this field. Defaults to `0` (no fee) when omitted.
|
|
33
|
+
*/
|
|
34
|
+
readonly integratorFeeBps?: number;
|
|
35
|
+
/** Maximum acceptable price impact in basis points (e.g. `300` = 3%). */
|
|
36
|
+
readonly maxPriceImpactBps?: number;
|
|
37
|
+
/**
|
|
38
|
+
* Destination for sweeping all proxy-held terminal resources after execution.
|
|
39
|
+
* Pass a literal `0x`-prefixed address or `{ $ref: "context.sender" }` to
|
|
40
|
+
* send remaining tokens to the signer.
|
|
41
|
+
*/
|
|
42
|
+
readonly sweepTo?: SweepTo;
|
|
43
|
+
/**
|
|
44
|
+
* Controls behavior when simulation detects a revert.
|
|
45
|
+
* `'strict'` (default) returns an error; `'allow-revert'` returns a partial
|
|
46
|
+
* result with the transaction and revert diagnostics.
|
|
47
|
+
*/
|
|
48
|
+
readonly simulationPolicy?: SimulationPolicy;
|
|
49
|
+
/**
|
|
50
|
+
* When `true`, the server also simulates the final user-facing transaction
|
|
51
|
+
* after the structured simulation succeeds; reverts honour
|
|
52
|
+
* `simulationPolicy`. On success the result is echoed back on the response as
|
|
53
|
+
* `userProgramSimulation`. Defaults to `false`.
|
|
54
|
+
*/
|
|
55
|
+
readonly simulateUserProgram?: boolean;
|
|
56
|
+
/**
|
|
57
|
+
* When `true`, the server checks on-chain ERC-20 allowances and omits
|
|
58
|
+
* approvals that are already sufficient. Defaults to `false`.
|
|
59
|
+
*/
|
|
60
|
+
readonly checkOnChainAllowances?: boolean;
|
|
65
61
|
}
|
|
66
62
|
/**
|
|
67
63
|
* Creates an untyped materialiser input spec. This is a low-level escape hatch
|
|
@@ -83,25 +79,25 @@ interface ComposeRunInput<T extends InputSchema = InputSchema> {
|
|
|
83
79
|
* };
|
|
84
80
|
* ```
|
|
85
81
|
*/
|
|
86
|
-
declare const materialiser: (kind: string, config?: Record<string, unknown>) => MaterialiserInput;
|
|
82
|
+
export declare const materialiser: (kind: string, config?: Record<string, unknown>) => MaterialiserInput;
|
|
87
83
|
/**
|
|
88
84
|
* Assembles a {@link ComposeRun} object from individual parameters.
|
|
89
85
|
* Used internally by the SDK; prefer {@link ComposeRunInput} for external use.
|
|
90
86
|
*
|
|
91
87
|
* @internal
|
|
92
88
|
*/
|
|
93
|
-
declare const buildRun: (run: {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
89
|
+
export declare const buildRun: (run: {
|
|
90
|
+
inputs: Record<string, InputSpec>;
|
|
91
|
+
preconditions?: readonly Precondition[];
|
|
92
|
+
signer: string;
|
|
93
|
+
assumptions?: Record<string, bigint>;
|
|
94
|
+
referrer?: string;
|
|
95
|
+
integratorFeeBps?: number;
|
|
96
|
+
maxPriceImpactBps?: number;
|
|
97
|
+
sweepTo?: SweepTo;
|
|
98
|
+
simulationPolicy?: SimulationPolicy;
|
|
99
|
+
simulateUserProgram?: boolean;
|
|
100
|
+
checkOnChainAllowances?: boolean;
|
|
105
101
|
}) => ComposeRun;
|
|
106
|
-
|
|
107
|
-
|
|
102
|
+
//#endregion
|
|
103
|
+
//# sourceMappingURL=inputs.d.cts.map
|
package/dist/run/inputs.d.ts
CHANGED
|
@@ -1,67 +1,63 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import { Address, InputSchema, InputSpecOf } from "../types.js";
|
|
2
|
+
import { ComposeRun, InputSpec, MaterialiserInput, Precondition, SimulationPolicy, SweepTo } from "@lifi/compose-spec";
|
|
3
|
+
//#region src/run/inputs.d.ts
|
|
4
4
|
/**
|
|
5
5
|
* Runtime inputs for compiling a flow. Passed to `builder.compile()` or `sdk.request()`.
|
|
6
6
|
*
|
|
7
7
|
* @typeParam T - The flow's input schema, used to type-check `inputs` and `assumptions`.
|
|
8
8
|
*/
|
|
9
|
-
interface ComposeRunInput<T extends InputSchema = InputSchema> {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
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
|
-
* When `true`, the server checks on-chain ERC-20 allowances and omits
|
|
62
|
-
* approvals that are already sufficient. Defaults to `false`.
|
|
63
|
-
*/
|
|
64
|
-
readonly checkOnChainAllowances?: boolean;
|
|
9
|
+
export interface ComposeRunInput<T extends InputSchema = InputSchema> {
|
|
10
|
+
/**
|
|
11
|
+
* Concrete values for each declared flow input. Resource inputs accept a
|
|
12
|
+
* materialiser or a literal integer amount; scalar inputs accept the matching type.
|
|
13
|
+
*/
|
|
14
|
+
readonly inputs: { readonly [K in keyof T]: InputSpecOf<T[K]>; };
|
|
15
|
+
/** Optional preconditions that must hold before the flow executes (e.g. minimum balances). */
|
|
16
|
+
readonly preconditions?: readonly Precondition[];
|
|
17
|
+
/** The `0x`-prefixed address of the transaction signer. */
|
|
18
|
+
readonly signer: Address;
|
|
19
|
+
/**
|
|
20
|
+
* Optional assumed token amounts for resource inputs, keyed by input name.
|
|
21
|
+
* When a materialiser resolves amounts at execution time rather than upfront,
|
|
22
|
+
* assumptions let the compiler plan routes using estimated values. The keys
|
|
23
|
+
* must match the input names declared in the flow schema.
|
|
24
|
+
*/
|
|
25
|
+
readonly assumptions?: { readonly [K in keyof T]?: bigint; };
|
|
26
|
+
/** Optional integrator referrer identifier. */
|
|
27
|
+
readonly referrer?: string;
|
|
28
|
+
/**
|
|
29
|
+
* Optional integrator fee in basis points (1bp = 0.01%, max `9000` = 90%).
|
|
30
|
+
* A non-zero value requires the request to be authenticated with an
|
|
31
|
+
* integration-scoped API key — the integration is derived from the key, not
|
|
32
|
+
* this field. Defaults to `0` (no fee) when omitted.
|
|
33
|
+
*/
|
|
34
|
+
readonly integratorFeeBps?: number;
|
|
35
|
+
/** Maximum acceptable price impact in basis points (e.g. `300` = 3%). */
|
|
36
|
+
readonly maxPriceImpactBps?: number;
|
|
37
|
+
/**
|
|
38
|
+
* Destination for sweeping all proxy-held terminal resources after execution.
|
|
39
|
+
* Pass a literal `0x`-prefixed address or `{ $ref: "context.sender" }` to
|
|
40
|
+
* send remaining tokens to the signer.
|
|
41
|
+
*/
|
|
42
|
+
readonly sweepTo?: SweepTo;
|
|
43
|
+
/**
|
|
44
|
+
* Controls behavior when simulation detects a revert.
|
|
45
|
+
* `'strict'` (default) returns an error; `'allow-revert'` returns a partial
|
|
46
|
+
* result with the transaction and revert diagnostics.
|
|
47
|
+
*/
|
|
48
|
+
readonly simulationPolicy?: SimulationPolicy;
|
|
49
|
+
/**
|
|
50
|
+
* When `true`, the server also simulates the final user-facing transaction
|
|
51
|
+
* after the structured simulation succeeds; reverts honour
|
|
52
|
+
* `simulationPolicy`. On success the result is echoed back on the response as
|
|
53
|
+
* `userProgramSimulation`. Defaults to `false`.
|
|
54
|
+
*/
|
|
55
|
+
readonly simulateUserProgram?: boolean;
|
|
56
|
+
/**
|
|
57
|
+
* When `true`, the server checks on-chain ERC-20 allowances and omits
|
|
58
|
+
* approvals that are already sufficient. Defaults to `false`.
|
|
59
|
+
*/
|
|
60
|
+
readonly checkOnChainAllowances?: boolean;
|
|
65
61
|
}
|
|
66
62
|
/**
|
|
67
63
|
* Creates an untyped materialiser input spec. This is a low-level escape hatch
|
|
@@ -83,25 +79,25 @@ interface ComposeRunInput<T extends InputSchema = InputSchema> {
|
|
|
83
79
|
* };
|
|
84
80
|
* ```
|
|
85
81
|
*/
|
|
86
|
-
declare const materialiser: (kind: string, config?: Record<string, unknown>) => MaterialiserInput;
|
|
82
|
+
export declare const materialiser: (kind: string, config?: Record<string, unknown>) => MaterialiserInput;
|
|
87
83
|
/**
|
|
88
84
|
* Assembles a {@link ComposeRun} object from individual parameters.
|
|
89
85
|
* Used internally by the SDK; prefer {@link ComposeRunInput} for external use.
|
|
90
86
|
*
|
|
91
87
|
* @internal
|
|
92
88
|
*/
|
|
93
|
-
declare const buildRun: (run: {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
89
|
+
export declare const buildRun: (run: {
|
|
90
|
+
inputs: Record<string, InputSpec>;
|
|
91
|
+
preconditions?: readonly Precondition[];
|
|
92
|
+
signer: string;
|
|
93
|
+
assumptions?: Record<string, bigint>;
|
|
94
|
+
referrer?: string;
|
|
95
|
+
integratorFeeBps?: number;
|
|
96
|
+
maxPriceImpactBps?: number;
|
|
97
|
+
sweepTo?: SweepTo;
|
|
98
|
+
simulationPolicy?: SimulationPolicy;
|
|
99
|
+
simulateUserProgram?: boolean;
|
|
100
|
+
checkOnChainAllowances?: boolean;
|
|
105
101
|
}) => ComposeRun;
|
|
106
|
-
|
|
107
|
-
|
|
102
|
+
//#endregion
|
|
103
|
+
//# sourceMappingURL=inputs.d.ts.map
|
package/dist/run/inputs.js
CHANGED
|
@@ -1,28 +1,59 @@
|
|
|
1
|
+
//#region src/run/inputs.ts
|
|
2
|
+
/**
|
|
3
|
+
* Creates an untyped materialiser input spec. This is a low-level escape hatch
|
|
4
|
+
* for materialiser kinds not yet covered by the generated helpers.
|
|
5
|
+
*
|
|
6
|
+
* Prefer the typed helpers in the `materialisers` namespace (e.g.
|
|
7
|
+
* `materialisers.balanceOf()`, `materialisers.directDeposit()`) which provide
|
|
8
|
+
* compile-time config validation.
|
|
9
|
+
*
|
|
10
|
+
* @param kind - The materialiser type (e.g. `"balanceOf"`, `"directDeposit"`).
|
|
11
|
+
* @param config - Optional materialiser-specific configuration.
|
|
12
|
+
* @returns A {@link MaterialiserInput} for use in {@link ComposeRunInput.inputs}.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```ts
|
|
16
|
+
* const run = {
|
|
17
|
+
* inputs: { token: materialiser('customKind', { myParam: '0x...' }) },
|
|
18
|
+
* signer: '0x...',
|
|
19
|
+
* };
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
1
22
|
const materialiser = (kind, config = {}) => ({
|
|
2
|
-
|
|
3
|
-
|
|
23
|
+
kind,
|
|
24
|
+
...config
|
|
4
25
|
});
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
26
|
+
/**
|
|
27
|
+
* Drops the keys whose value is `undefined`, so optional fields are omitted
|
|
28
|
+
* from the wire payload rather than serialized as `null`.
|
|
29
|
+
*
|
|
30
|
+
* A local copy of `pickDefined` from `@lifi/utils`: this package is published
|
|
31
|
+
* to npm and `@lifi/utils` is a private workspace package, so it cannot be a
|
|
32
|
+
* runtime dependency here.
|
|
33
|
+
*/
|
|
34
|
+
const pickDefined = (obj) => Object.fromEntries(Object.entries(obj).filter(([, value]) => value !== void 0));
|
|
35
|
+
/**
|
|
36
|
+
* Assembles a {@link ComposeRun} object from individual parameters.
|
|
37
|
+
* Used internally by the SDK; prefer {@link ComposeRunInput} for external use.
|
|
38
|
+
*
|
|
39
|
+
* @internal
|
|
40
|
+
*/
|
|
8
41
|
const buildRun = (run) => ({
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
})
|
|
42
|
+
inputs: run.inputs,
|
|
43
|
+
signer: run.signer,
|
|
44
|
+
...pickDefined({
|
|
45
|
+
preconditions: run.preconditions?.length ? run.preconditions : void 0,
|
|
46
|
+
assumptions: run.assumptions,
|
|
47
|
+
referrer: run.referrer,
|
|
48
|
+
integratorFeeBps: run.integratorFeeBps,
|
|
49
|
+
maxPriceImpactBps: run.maxPriceImpactBps,
|
|
50
|
+
sweepTo: run.sweepTo,
|
|
51
|
+
simulationPolicy: run.simulationPolicy,
|
|
52
|
+
simulateUserProgram: run.simulateUserProgram,
|
|
53
|
+
checkOnChainAllowances: run.checkOnChainAllowances
|
|
54
|
+
})
|
|
23
55
|
});
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
};
|
|
56
|
+
//#endregion
|
|
57
|
+
export { buildRun, materialiser };
|
|
58
|
+
|
|
28
59
|
//# sourceMappingURL=inputs.js.map
|
package/dist/run/inputs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/run/inputs.ts"],"sourcesContent":["import type {\n ComposeRun,\n InputSpec,\n MaterialiserInput,\n Precondition,\n SimulationPolicy,\n SweepTo,\n} from '@lifi/compose-spec';\n\nimport type { Address, InputSchema, InputSpecOf } from '../types.js';\n\n/**\n * Runtime inputs for compiling a flow. Passed to `builder.compile()` or `sdk.request()`.\n *\n * @typeParam T - The flow's input schema, used to type-check `inputs` and `assumptions`.\n */\nexport interface ComposeRunInput<T extends InputSchema = InputSchema> {\n /**\n * Concrete values for each declared flow input. Resource inputs accept a\n * materialiser or a literal integer amount; scalar inputs accept the matching type.\n */\n readonly inputs: { readonly [K in keyof T]: InputSpecOf<T[K]> };\n /** Optional preconditions that must hold before the flow executes (e.g. minimum balances). */\n readonly preconditions?: readonly Precondition[];\n /** The `0x`-prefixed address of the transaction signer. */\n readonly signer: Address;\n /**\n * Optional assumed token amounts for resource inputs, keyed by input name.\n * When a materialiser resolves amounts at execution time rather than upfront,\n * assumptions let the compiler plan routes using estimated values. The keys\n * must match the input names declared in the flow schema.\n */\n readonly assumptions?: { readonly [K in keyof T]?: bigint };\n /** Optional integrator referrer identifier. */\n readonly referrer?: string;\n /**\n * Optional integrator fee in basis points (1bp = 0.01%, max `9000` = 90%).\n * A non-zero value requires the request to be authenticated with an\n * integration-scoped API key — the integration is derived from the key, not\n * this field. Defaults to `0` (no fee) when omitted.\n */\n readonly integratorFeeBps?: number;\n /** Maximum acceptable price impact in basis points (e.g. `300` = 3%). */\n readonly maxPriceImpactBps?: number;\n /**\n * Destination for sweeping all proxy-held terminal resources after execution.\n * Pass a literal `0x`-prefixed address or `{ $ref: \"context.sender\" }` to\n * send remaining tokens to the signer.\n */\n readonly sweepTo?: SweepTo;\n /**\n * Controls behavior when simulation detects a revert.\n * `'strict'` (default) returns an error; `'allow-revert'` returns a partial\n * result with the transaction and revert diagnostics.\n */\n readonly simulationPolicy?: SimulationPolicy;\n /**\n * When `true`, the server also simulates the final user-facing transaction\n * after the structured simulation succeeds; reverts honour\n * `simulationPolicy`. On success the result is echoed back on the response as\n * `userProgramSimulation`. Defaults to `false`.\n */\n readonly simulateUserProgram?: boolean;\n /**\n * When `true`, the server checks on-chain ERC-20 allowances and omits\n * approvals that are already sufficient. Defaults to `false`.\n */\n readonly checkOnChainAllowances?: boolean;\n}\n\n/**\n * Creates an untyped materialiser input spec. This is a low-level escape hatch\n * for materialiser kinds not yet covered by the generated helpers.\n *\n * Prefer the typed helpers in the `materialisers` namespace (e.g.\n * `materialisers.balanceOf()`, `materialisers.directDeposit()`) which provide\n * compile-time config validation.\n *\n * @param kind - The materialiser type (e.g. `\"balanceOf\"`, `\"directDeposit\"`).\n * @param config - Optional materialiser-specific configuration.\n * @returns A {@link MaterialiserInput} for use in {@link ComposeRunInput.inputs}.\n *\n * @example\n * ```ts\n * const run = {\n * inputs: { token: materialiser('customKind', { myParam: '0x...' }) },\n * signer: '0x...',\n * };\n * ```\n */\nexport const materialiser = (\n kind: string,\n config: Record<string, unknown> = {},\n): MaterialiserInput => ({\n kind,\n ...config,\n});\n\n/**\n * Drops the keys whose value is `undefined`, so optional fields are omitted\n * from the wire payload rather than serialized as `null`.\n *\n * A local copy of `pickDefined` from `@lifi/utils`: this package is published\n * to npm and `@lifi/utils` is a private workspace package, so it cannot be a\n * runtime dependency here.\n */\nconst pickDefined = <S extends Record<string, unknown>>(\n obj: S,\n): Partial<{ [K in keyof S]: Exclude<S[K], undefined> }> =>\n Object.fromEntries(\n Object.entries(obj).filter(([, value]) => value !== undefined),\n ) as Partial<{ [K in keyof S]: Exclude<S[K], undefined> }>;\n\n/**\n * Assembles a {@link ComposeRun} object from individual parameters.\n * Used internally by the SDK; prefer {@link ComposeRunInput} for external use.\n *\n * @internal\n */\nexport const buildRun = (run: {\n inputs: Record<string, InputSpec>;\n preconditions?: readonly Precondition[];\n signer: string;\n assumptions?: Record<string, bigint>;\n referrer?: string;\n integratorFeeBps?: number;\n maxPriceImpactBps?: number;\n sweepTo?: SweepTo;\n simulationPolicy?: SimulationPolicy;\n simulateUserProgram?: boolean;\n checkOnChainAllowances?: boolean;\n}): ComposeRun => ({\n inputs: run.inputs,\n signer: run.signer,\n ...pickDefined({\n // An empty precondition list is the same as none, so drop it too.\n preconditions: run.preconditions?.length ? run.preconditions : undefined,\n assumptions: run.assumptions,\n referrer: run.referrer,\n integratorFeeBps: run.integratorFeeBps,\n maxPriceImpactBps: run.maxPriceImpactBps,\n sweepTo: run.sweepTo,\n simulationPolicy: run.simulationPolicy,\n simulateUserProgram: run.simulateUserProgram,\n checkOnChainAllowances: run.checkOnChainAllowances,\n }),\n});\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"inputs.js","names":[],"sources":["../../src/run/inputs.ts"],"sourcesContent":["import type {\n ComposeRun,\n InputSpec,\n MaterialiserInput,\n Precondition,\n SimulationPolicy,\n SweepTo,\n} from '@lifi/compose-spec';\n\nimport type { Address, InputSchema, InputSpecOf } from '../types.js';\n\n/**\n * Runtime inputs for compiling a flow. Passed to `builder.compile()` or `sdk.request()`.\n *\n * @typeParam T - The flow's input schema, used to type-check `inputs` and `assumptions`.\n */\nexport interface ComposeRunInput<T extends InputSchema = InputSchema> {\n /**\n * Concrete values for each declared flow input. Resource inputs accept a\n * materialiser or a literal integer amount; scalar inputs accept the matching type.\n */\n readonly inputs: { readonly [K in keyof T]: InputSpecOf<T[K]> };\n /** Optional preconditions that must hold before the flow executes (e.g. minimum balances). */\n readonly preconditions?: readonly Precondition[];\n /** The `0x`-prefixed address of the transaction signer. */\n readonly signer: Address;\n /**\n * Optional assumed token amounts for resource inputs, keyed by input name.\n * When a materialiser resolves amounts at execution time rather than upfront,\n * assumptions let the compiler plan routes using estimated values. The keys\n * must match the input names declared in the flow schema.\n */\n readonly assumptions?: { readonly [K in keyof T]?: bigint };\n /** Optional integrator referrer identifier. */\n readonly referrer?: string;\n /**\n * Optional integrator fee in basis points (1bp = 0.01%, max `9000` = 90%).\n * A non-zero value requires the request to be authenticated with an\n * integration-scoped API key — the integration is derived from the key, not\n * this field. Defaults to `0` (no fee) when omitted.\n */\n readonly integratorFeeBps?: number;\n /** Maximum acceptable price impact in basis points (e.g. `300` = 3%). */\n readonly maxPriceImpactBps?: number;\n /**\n * Destination for sweeping all proxy-held terminal resources after execution.\n * Pass a literal `0x`-prefixed address or `{ $ref: \"context.sender\" }` to\n * send remaining tokens to the signer.\n */\n readonly sweepTo?: SweepTo;\n /**\n * Controls behavior when simulation detects a revert.\n * `'strict'` (default) returns an error; `'allow-revert'` returns a partial\n * result with the transaction and revert diagnostics.\n */\n readonly simulationPolicy?: SimulationPolicy;\n /**\n * When `true`, the server also simulates the final user-facing transaction\n * after the structured simulation succeeds; reverts honour\n * `simulationPolicy`. On success the result is echoed back on the response as\n * `userProgramSimulation`. Defaults to `false`.\n */\n readonly simulateUserProgram?: boolean;\n /**\n * When `true`, the server checks on-chain ERC-20 allowances and omits\n * approvals that are already sufficient. Defaults to `false`.\n */\n readonly checkOnChainAllowances?: boolean;\n}\n\n/**\n * Creates an untyped materialiser input spec. This is a low-level escape hatch\n * for materialiser kinds not yet covered by the generated helpers.\n *\n * Prefer the typed helpers in the `materialisers` namespace (e.g.\n * `materialisers.balanceOf()`, `materialisers.directDeposit()`) which provide\n * compile-time config validation.\n *\n * @param kind - The materialiser type (e.g. `\"balanceOf\"`, `\"directDeposit\"`).\n * @param config - Optional materialiser-specific configuration.\n * @returns A {@link MaterialiserInput} for use in {@link ComposeRunInput.inputs}.\n *\n * @example\n * ```ts\n * const run = {\n * inputs: { token: materialiser('customKind', { myParam: '0x...' }) },\n * signer: '0x...',\n * };\n * ```\n */\nexport const materialiser = (\n kind: string,\n config: Record<string, unknown> = {},\n): MaterialiserInput => ({\n kind,\n ...config,\n});\n\n/**\n * Drops the keys whose value is `undefined`, so optional fields are omitted\n * from the wire payload rather than serialized as `null`.\n *\n * A local copy of `pickDefined` from `@lifi/utils`: this package is published\n * to npm and `@lifi/utils` is a private workspace package, so it cannot be a\n * runtime dependency here.\n */\nconst pickDefined = <S extends Record<string, unknown>>(\n obj: S,\n): Partial<{ [K in keyof S]: Exclude<S[K], undefined> }> =>\n Object.fromEntries(\n Object.entries(obj).filter(([, value]) => value !== undefined),\n ) as Partial<{ [K in keyof S]: Exclude<S[K], undefined> }>;\n\n/**\n * Assembles a {@link ComposeRun} object from individual parameters.\n * Used internally by the SDK; prefer {@link ComposeRunInput} for external use.\n *\n * @internal\n */\nexport const buildRun = (run: {\n inputs: Record<string, InputSpec>;\n preconditions?: readonly Precondition[];\n signer: string;\n assumptions?: Record<string, bigint>;\n referrer?: string;\n integratorFeeBps?: number;\n maxPriceImpactBps?: number;\n sweepTo?: SweepTo;\n simulationPolicy?: SimulationPolicy;\n simulateUserProgram?: boolean;\n checkOnChainAllowances?: boolean;\n}): ComposeRun => ({\n inputs: run.inputs,\n signer: run.signer,\n ...pickDefined({\n // An empty precondition list is the same as none, so drop it too.\n preconditions: run.preconditions?.length ? run.preconditions : undefined,\n assumptions: run.assumptions,\n referrer: run.referrer,\n integratorFeeBps: run.integratorFeeBps,\n maxPriceImpactBps: run.maxPriceImpactBps,\n sweepTo: run.sweepTo,\n simulationPolicy: run.simulationPolicy,\n simulateUserProgram: run.simulateUserProgram,\n checkOnChainAllowances: run.checkOnChainAllowances,\n }),\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA0FA,MAAa,gBACX,MACA,SAAkC,CAAC,OACZ;CACvB;CACA,GAAG;AACL;;;;;;;;;AAUA,MAAM,eACJ,QAEA,OAAO,YACL,OAAO,QAAQ,GAAG,CAAC,CAAC,QAAQ,GAAG,WAAW,UAAU,KAAA,CAAS,CAC/D;;;;;;;AAQF,MAAa,YAAY,SAYN;CACjB,QAAQ,IAAI;CACZ,QAAQ,IAAI;CACZ,GAAG,YAAY;EAEb,eAAe,IAAI,eAAe,SAAS,IAAI,gBAAgB,KAAA;EAC/D,aAAa,IAAI;EACjB,UAAU,IAAI;EACd,kBAAkB,IAAI;EACtB,mBAAmB,IAAI;EACvB,SAAS,IAAI;EACb,kBAAkB,IAAI;EACtB,qBAAqB,IAAI;EACzB,wBAAwB,IAAI;CAC9B,CAAC;AACH"}
|