@lifi/composer-sdk 0.4.1 → 0.5.0

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