@lifi/composer-sdk 0.8.1 → 0.10.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.
Files changed (161) hide show
  1. package/README.md +4 -3
  2. package/dist/_virtual/_rolldown/runtime.cjs +33 -0
  3. package/dist/_virtual/_rolldown/runtime.js +13 -0
  4. package/dist/authoring/FlowBuilderCore.cjs +102 -120
  5. package/dist/authoring/FlowBuilderCore.cjs.map +1 -1
  6. package/dist/authoring/FlowBuilderCore.d.cts +58 -61
  7. package/dist/authoring/FlowBuilderCore.d.ts +58 -61
  8. package/dist/authoring/FlowBuilderCore.js +99 -97
  9. package/dist/authoring/FlowBuilderCore.js.map +1 -1
  10. package/dist/authoring/handles.cjs +25 -40
  11. package/dist/authoring/handles.cjs.map +1 -1
  12. package/dist/authoring/handles.d.cts +33 -34
  13. package/dist/authoring/handles.d.ts +33 -34
  14. package/dist/authoring/handles.js +21 -13
  15. package/dist/authoring/handles.js.map +1 -1
  16. package/dist/authoring/raw.cjs +85 -44
  17. package/dist/authoring/raw.cjs.map +1 -1
  18. package/dist/authoring/raw.d.cts +8 -8
  19. package/dist/authoring/raw.d.ts +8 -8
  20. package/dist/authoring/raw.js +83 -19
  21. package/dist/authoring/raw.js.map +1 -1
  22. package/dist/authoring/signatureArgs.cjs +81 -103
  23. package/dist/authoring/signatureArgs.cjs.map +1 -1
  24. package/dist/authoring/signatureArgs.d.cts +63 -64
  25. package/dist/authoring/signatureArgs.d.ts +63 -64
  26. package/dist/authoring/signatureArgs.js +76 -75
  27. package/dist/authoring/signatureArgs.js.map +1 -1
  28. package/dist/client.cjs +172 -220
  29. package/dist/client.cjs.map +1 -1
  30. package/dist/client.d.cts +131 -131
  31. package/dist/client.d.ts +131 -131
  32. package/dist/client.js +165 -198
  33. package/dist/client.js.map +1 -1
  34. package/dist/discovery.cjs +0 -17
  35. package/dist/discovery.d.cts +57 -56
  36. package/dist/discovery.d.ts +57 -56
  37. package/dist/discovery.js +1 -1
  38. package/dist/errors.cjs +211 -159
  39. package/dist/errors.cjs.map +1 -1
  40. package/dist/errors.d.cts +84 -84
  41. package/dist/errors.d.ts +84 -84
  42. package/dist/errors.js +201 -120
  43. package/dist/errors.js.map +1 -1
  44. package/dist/generated/config.generated.cjs +0 -17
  45. package/dist/generated/config.generated.d.cts +804 -936
  46. package/dist/generated/config.generated.d.ts +804 -936
  47. package/dist/generated/config.generated.js +1 -1
  48. package/dist/generated/guards.generated.cjs +25 -35
  49. package/dist/generated/guards.generated.cjs.map +1 -1
  50. package/dist/generated/guards.generated.d.cts +20 -4
  51. package/dist/generated/guards.generated.d.ts +20 -4
  52. package/dist/generated/guards.generated.js +19 -11
  53. package/dist/generated/guards.generated.js.map +1 -1
  54. package/dist/generated/materialisers.generated.cjs +25 -35
  55. package/dist/generated/materialisers.generated.cjs.map +1 -1
  56. package/dist/generated/materialisers.generated.d.cts +17 -4
  57. package/dist/generated/materialisers.generated.d.ts +17 -4
  58. package/dist/generated/materialisers.generated.js +19 -11
  59. package/dist/generated/materialisers.generated.js.map +1 -1
  60. package/dist/generated/operations.generated.cjs +236 -277
  61. package/dist/generated/operations.generated.cjs.map +1 -1
  62. package/dist/generated/operations.generated.d.cts +719 -708
  63. package/dist/generated/operations.generated.d.ts +719 -708
  64. package/dist/generated/operations.generated.js +235 -256
  65. package/dist/generated/operations.generated.js.map +1 -1
  66. package/dist/generated/preconditions.generated.cjs +25 -35
  67. package/dist/generated/preconditions.generated.cjs.map +1 -1
  68. package/dist/generated/preconditions.generated.d.cts +17 -4
  69. package/dist/generated/preconditions.generated.d.ts +17 -4
  70. package/dist/generated/preconditions.generated.js +19 -11
  71. package/dist/generated/preconditions.generated.js.map +1 -1
  72. package/dist/index.cjs +131 -97
  73. package/dist/index.cjs.map +1 -1
  74. package/dist/index.d.cts +29 -43
  75. package/dist/index.d.ts +29 -43
  76. package/dist/index.js +96 -45
  77. package/dist/index.js.map +1 -1
  78. package/dist/outputs.cjs +11 -32
  79. package/dist/outputs.cjs.map +1 -1
  80. package/dist/outputs.d.cts +5 -5
  81. package/dist/outputs.d.ts +5 -5
  82. package/dist/outputs.js +10 -8
  83. package/dist/outputs.js.map +1 -1
  84. package/dist/raw.cjs +21 -33
  85. package/dist/raw.cjs.map +1 -1
  86. package/dist/raw.d.cts +8 -4
  87. package/dist/raw.d.ts +8 -4
  88. package/dist/raw.js +12 -7
  89. package/dist/raw.js.map +1 -1
  90. package/dist/reachability.cjs +82 -112
  91. package/dist/reachability.cjs.map +1 -1
  92. package/dist/reachability.d.cts +33 -59
  93. package/dist/reachability.d.ts +33 -59
  94. package/dist/reachability.js +81 -88
  95. package/dist/reachability.js.map +1 -1
  96. package/dist/resources.cjs +47 -32
  97. package/dist/resources.cjs.map +1 -1
  98. package/dist/resources.d.cts +50 -3
  99. package/dist/resources.d.ts +50 -3
  100. package/dist/resources.js +42 -9
  101. package/dist/resources.js.map +1 -1
  102. package/dist/responseSchemas.cjs +99 -111
  103. package/dist/responseSchemas.cjs.map +1 -1
  104. package/dist/responseSchemas.d.cts +34 -34
  105. package/dist/responseSchemas.d.ts +34 -34
  106. package/dist/responseSchemas.js +85 -66
  107. package/dist/responseSchemas.js.map +1 -1
  108. package/dist/routeAmount.cjs +61 -31
  109. package/dist/routeAmount.cjs.map +1 -1
  110. package/dist/routeAmount.d.cts +52 -2
  111. package/dist/routeAmount.d.ts +52 -2
  112. package/dist/routeAmount.js +56 -8
  113. package/dist/routeAmount.js.map +1 -1
  114. package/dist/run/inputs.cjs +56 -48
  115. package/dist/run/inputs.cjs.map +1 -1
  116. package/dist/run/inputs.d.cts +70 -74
  117. package/dist/run/inputs.d.ts +70 -74
  118. package/dist/run/inputs.js +54 -23
  119. package/dist/run/inputs.js.map +1 -1
  120. package/dist/run/simulate.cjs +38 -43
  121. package/dist/run/simulate.cjs.map +1 -1
  122. package/dist/run/simulate.d.cts +36 -36
  123. package/dist/run/simulate.d.ts +36 -36
  124. package/dist/run/simulate.js +37 -19
  125. package/dist/run/simulate.js.map +1 -1
  126. package/dist/sdk.cjs +55 -66
  127. package/dist/sdk.cjs.map +1 -1
  128. package/dist/sdk.d.cts +108 -111
  129. package/dist/sdk.d.ts +108 -111
  130. package/dist/sdk.js +52 -44
  131. package/dist/sdk.js.map +1 -1
  132. package/dist/types.cjs +0 -17
  133. package/dist/types.d.cts +22 -22
  134. package/dist/types.d.ts +22 -22
  135. package/dist/types.js +1 -1
  136. package/package.json +5 -5
  137. package/src/client.ts +2 -2
  138. package/src/examples/aaveClaimRewards.ts +2 -1
  139. package/src/examples/emitCustomEvent.ts +1 -2
  140. package/src/examples/run.ts +1 -1
  141. package/src/examples/transferTokens.ts +21 -17
  142. package/src/generated/config.generated.ts +20 -9
  143. package/src/generated/operations.generated.ts +28 -5
  144. package/dist/discovery.cjs.map +0 -1
  145. package/dist/discovery.js.map +0 -1
  146. package/dist/generated/config.generated.cjs.map +0 -1
  147. package/dist/generated/config.generated.js.map +0 -1
  148. package/dist/guards.generated-CDCgYGZo.d.cts +0 -24
  149. package/dist/guards.generated-CdYcs4h0.d.ts +0 -24
  150. package/dist/materialisers.generated-BMkBQgWZ.d.ts +0 -24
  151. package/dist/materialisers.generated-BWq5oePO.d.cts +0 -24
  152. package/dist/preconditions.generated-DblS13Wq.d.cts +0 -24
  153. package/dist/preconditions.generated-U7YpVh30.d.ts +0 -24
  154. package/dist/raw-BvRghN3r.d.ts +0 -20
  155. package/dist/raw-s1rer8X3.d.cts +0 -20
  156. package/dist/resources-BKlFxjo8.d.cts +0 -56
  157. package/dist/resources-CYis1_DS.d.ts +0 -56
  158. package/dist/routeAmount-DdbJYJyM.d.cts +0 -55
  159. package/dist/routeAmount-DdbJYJyM.d.ts +0 -55
  160. package/dist/types.cjs.map +0 -1
  161. package/dist/types.js.map +0 -1
@@ -1,53 +1,61 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var inputs_exports = {};
20
- __export(inputs_exports, {
21
- buildRun: () => buildRun,
22
- materialiser: () => materialiser
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
- kind,
27
- ...config
24
+ kind,
25
+ ...config
28
26
  });
29
- const pickDefined = (obj) => Object.fromEntries(
30
- Object.entries(obj).filter(([, value]) => value !== void 0)
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
- inputs: run.inputs,
34
- signer: run.signer,
35
- ...pickDefined({
36
- // An empty precondition list is the same as none, so drop it too.
37
- preconditions: run.preconditions?.length ? run.preconditions : void 0,
38
- assumptions: run.assumptions,
39
- referrer: run.referrer,
40
- integratorFeeBps: run.integratorFeeBps,
41
- maxPriceImpactBps: run.maxPriceImpactBps,
42
- sweepTo: run.sweepTo,
43
- simulationPolicy: run.simulationPolicy,
44
- simulateUserProgram: run.simulateUserProgram,
45
- checkOnChainAllowances: run.checkOnChainAllowances
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
@@ -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":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA0FO,MAAM,eAAe,CAC1B,MACA,SAAkC,CAAC,OACZ;AAAA,EACvB;AAAA,EACA,GAAG;AACL;AAUA,MAAM,cAAc,CAClB,QAEA,OAAO;AAAA,EACL,OAAO,QAAQ,GAAG,EAAE,OAAO,CAAC,CAAC,EAAE,KAAK,MAAM,UAAU,MAAS;AAC/D;AAQK,MAAM,WAAW,CAAC,SAYN;AAAA,EACjB,QAAQ,IAAI;AAAA,EACZ,QAAQ,IAAI;AAAA,EACZ,GAAG,YAAY;AAAA;AAAA,IAEb,eAAe,IAAI,eAAe,SAAS,IAAI,gBAAgB;AAAA,IAC/D,aAAa,IAAI;AAAA,IACjB,UAAU,IAAI;AAAA,IACd,kBAAkB,IAAI;AAAA,IACtB,mBAAmB,IAAI;AAAA,IACvB,SAAS,IAAI;AAAA,IACb,kBAAkB,IAAI;AAAA,IACtB,qBAAqB,IAAI;AAAA,IACzB,wBAAwB,IAAI;AAAA,EAC9B,CAAC;AACH;","names":[]}
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"}
@@ -1,67 +1,63 @@
1
- import { Precondition, SweepTo, SimulationPolicy, MaterialiserInput, InputSpec, ComposeRun } from '@lifi/compose-spec';
2
- import { InputSchema, InputSpecOf, Address } from '../types.cjs';
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
- * 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: {
15
- readonly [K in keyof T]: InputSpecOf<T[K]>;
16
- };
17
- /** Optional preconditions that must hold before the flow executes (e.g. minimum balances). */
18
- readonly preconditions?: readonly Precondition[];
19
- /** The `0x`-prefixed address of the transaction signer. */
20
- readonly signer: Address;
21
- /**
22
- * Optional assumed token amounts for resource inputs, keyed by input name.
23
- * When a materialiser resolves amounts at execution time rather than upfront,
24
- * assumptions let the compiler plan routes using estimated values. The keys
25
- * must match the input names declared in the flow schema.
26
- */
27
- readonly assumptions?: {
28
- readonly [K in keyof T]?: bigint;
29
- };
30
- /** Optional integrator referrer identifier. */
31
- readonly referrer?: string;
32
- /**
33
- * Optional integrator fee in basis points (1bp = 0.01%, max `9000` = 90%).
34
- * A non-zero value requires the request to be authenticated with an
35
- * integration-scoped API key — the integration is derived from the key, not
36
- * this field. Defaults to `0` (no fee) when omitted.
37
- */
38
- readonly integratorFeeBps?: number;
39
- /** Maximum acceptable price impact in basis points (e.g. `300` = 3%). */
40
- readonly maxPriceImpactBps?: number;
41
- /**
42
- * Destination for sweeping all proxy-held terminal resources after execution.
43
- * Pass a literal `0x`-prefixed address or `{ $ref: "context.sender" }` to
44
- * send remaining tokens to the signer.
45
- */
46
- readonly sweepTo?: SweepTo;
47
- /**
48
- * Controls behavior when simulation detects a revert.
49
- * `'strict'` (default) returns an error; `'allow-revert'` returns a partial
50
- * result with the transaction and revert diagnostics.
51
- */
52
- readonly simulationPolicy?: SimulationPolicy;
53
- /**
54
- * When `true`, the server also simulates the final user-facing transaction
55
- * after the structured simulation succeeds; reverts honour
56
- * `simulationPolicy`. On success the result is echoed back on the response as
57
- * `userProgramSimulation`. Defaults to `false`.
58
- */
59
- readonly simulateUserProgram?: boolean;
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
- inputs: Record<string, InputSpec>;
95
- preconditions?: readonly Precondition[];
96
- signer: string;
97
- assumptions?: Record<string, bigint>;
98
- referrer?: string;
99
- integratorFeeBps?: number;
100
- maxPriceImpactBps?: number;
101
- sweepTo?: SweepTo;
102
- simulationPolicy?: SimulationPolicy;
103
- simulateUserProgram?: boolean;
104
- checkOnChainAllowances?: boolean;
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
- export { type ComposeRunInput, buildRun, materialiser };
102
+ //#endregion
103
+ //# sourceMappingURL=inputs.d.cts.map
@@ -1,67 +1,63 @@
1
- import { Precondition, SweepTo, SimulationPolicy, MaterialiserInput, InputSpec, ComposeRun } from '@lifi/compose-spec';
2
- import { InputSchema, InputSpecOf, Address } from '../types.js';
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
- * 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: {
15
- readonly [K in keyof T]: InputSpecOf<T[K]>;
16
- };
17
- /** Optional preconditions that must hold before the flow executes (e.g. minimum balances). */
18
- readonly preconditions?: readonly Precondition[];
19
- /** The `0x`-prefixed address of the transaction signer. */
20
- readonly signer: Address;
21
- /**
22
- * Optional assumed token amounts for resource inputs, keyed by input name.
23
- * When a materialiser resolves amounts at execution time rather than upfront,
24
- * assumptions let the compiler plan routes using estimated values. The keys
25
- * must match the input names declared in the flow schema.
26
- */
27
- readonly assumptions?: {
28
- readonly [K in keyof T]?: bigint;
29
- };
30
- /** Optional integrator referrer identifier. */
31
- readonly referrer?: string;
32
- /**
33
- * Optional integrator fee in basis points (1bp = 0.01%, max `9000` = 90%).
34
- * A non-zero value requires the request to be authenticated with an
35
- * integration-scoped API key — the integration is derived from the key, not
36
- * this field. Defaults to `0` (no fee) when omitted.
37
- */
38
- readonly integratorFeeBps?: number;
39
- /** Maximum acceptable price impact in basis points (e.g. `300` = 3%). */
40
- readonly maxPriceImpactBps?: number;
41
- /**
42
- * Destination for sweeping all proxy-held terminal resources after execution.
43
- * Pass a literal `0x`-prefixed address or `{ $ref: "context.sender" }` to
44
- * send remaining tokens to the signer.
45
- */
46
- readonly sweepTo?: SweepTo;
47
- /**
48
- * Controls behavior when simulation detects a revert.
49
- * `'strict'` (default) returns an error; `'allow-revert'` returns a partial
50
- * result with the transaction and revert diagnostics.
51
- */
52
- readonly simulationPolicy?: SimulationPolicy;
53
- /**
54
- * When `true`, the server also simulates the final user-facing transaction
55
- * after the structured simulation succeeds; reverts honour
56
- * `simulationPolicy`. On success the result is echoed back on the response as
57
- * `userProgramSimulation`. Defaults to `false`.
58
- */
59
- readonly simulateUserProgram?: boolean;
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
- inputs: Record<string, InputSpec>;
95
- preconditions?: readonly Precondition[];
96
- signer: string;
97
- assumptions?: Record<string, bigint>;
98
- referrer?: string;
99
- integratorFeeBps?: number;
100
- maxPriceImpactBps?: number;
101
- sweepTo?: SweepTo;
102
- simulationPolicy?: SimulationPolicy;
103
- simulateUserProgram?: boolean;
104
- checkOnChainAllowances?: boolean;
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
- export { type ComposeRunInput, buildRun, materialiser };
102
+ //#endregion
103
+ //# sourceMappingURL=inputs.d.ts.map
@@ -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
- kind,
3
- ...config
23
+ kind,
24
+ ...config
4
25
  });
5
- const pickDefined = (obj) => Object.fromEntries(
6
- Object.entries(obj).filter(([, value]) => value !== void 0)
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
- inputs: run.inputs,
10
- signer: run.signer,
11
- ...pickDefined({
12
- // An empty precondition list is the same as none, so drop it too.
13
- preconditions: run.preconditions?.length ? run.preconditions : void 0,
14
- assumptions: run.assumptions,
15
- referrer: run.referrer,
16
- integratorFeeBps: run.integratorFeeBps,
17
- maxPriceImpactBps: run.maxPriceImpactBps,
18
- sweepTo: run.sweepTo,
19
- simulationPolicy: run.simulationPolicy,
20
- simulateUserProgram: run.simulateUserProgram,
21
- checkOnChainAllowances: run.checkOnChainAllowances
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
- export {
25
- buildRun,
26
- materialiser
27
- };
56
+ //#endregion
57
+ export { buildRun, materialiser };
58
+
28
59
  //# sourceMappingURL=inputs.js.map
@@ -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":"AA0FO,MAAM,eAAe,CAC1B,MACA,SAAkC,CAAC,OACZ;AAAA,EACvB;AAAA,EACA,GAAG;AACL;AAUA,MAAM,cAAc,CAClB,QAEA,OAAO;AAAA,EACL,OAAO,QAAQ,GAAG,EAAE,OAAO,CAAC,CAAC,EAAE,KAAK,MAAM,UAAU,MAAS;AAC/D;AAQK,MAAM,WAAW,CAAC,SAYN;AAAA,EACjB,QAAQ,IAAI;AAAA,EACZ,QAAQ,IAAI;AAAA,EACZ,GAAG,YAAY;AAAA;AAAA,IAEb,eAAe,IAAI,eAAe,SAAS,IAAI,gBAAgB;AAAA,IAC/D,aAAa,IAAI;AAAA,IACjB,UAAU,IAAI;AAAA,IACd,kBAAkB,IAAI;AAAA,IACtB,mBAAmB,IAAI;AAAA,IACvB,SAAS,IAAI;AAAA,IACb,kBAAkB,IAAI;AAAA,IACtB,qBAAqB,IAAI;AAAA,IACzB,wBAAwB,IAAI;AAAA,EAC9B,CAAC;AACH;","names":[]}
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"}