@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,57 +1,57 @@
1
- import { SimulationRevert, SimulateResult } from '@lifi/compose-spec';
2
-
1
+ import { SimulateResult, SimulationRevert } from "@lifi/compose-spec";
2
+ //#region src/responseSchemas.d.ts
3
3
  /**
4
4
  * Parses a `POST /simulate` body into a {@link SimulateResult}. Returns `null`
5
5
  * when the body does not match the `ok`/`revert`/`error` union, letting the
6
6
  * caller raise a transport-level error.
7
7
  */
8
- declare const parseSimulateResult: (body: unknown) => SimulateResult | null;
8
+ export declare const parseSimulateResult: (body: unknown) => SimulateResult | null;
9
9
  /**
10
10
  * The validated members of an HTTP 206 partial compile envelope. `data` is
11
11
  * verified to be an object at runtime but left `unknown` here — compose-spec
12
12
  * owns its full shape (`ComposeCompilePartialData`) as a hand-authored type, so
13
13
  * the caller narrows it in one step. `error` is fully validated.
14
14
  */
15
- interface CompilePartialEnvelope {
16
- readonly data: unknown;
17
- readonly error: {
18
- readonly kind: string;
19
- readonly message: string;
20
- };
15
+ export interface CompilePartialEnvelope {
16
+ readonly data: unknown;
17
+ readonly error: {
18
+ readonly kind: string;
19
+ readonly message: string;
20
+ };
21
21
  }
22
22
  /** Parses an HTTP 206 partial compile envelope; `null` when it does not match. */
23
- declare const parseCompilePartialEnvelope: (body: unknown) => CompilePartialEnvelope | null;
23
+ export declare const parseCompilePartialEnvelope: (body: unknown) => CompilePartialEnvelope | null;
24
24
  /**
25
25
  * A single prepared-op failure inside a `preparation_error` envelope. `kind` is
26
26
  * kept as `string` here — the narrowing to `GenericComposeErrorKind` happens in
27
27
  * `errorFromHttpResponse`, where the value is lifted onto `ComposeError`.
28
28
  */
29
- interface ServerFailedPreparedOp {
30
- readonly callId: string;
31
- readonly op: string;
32
- readonly kind: string;
33
- readonly message: string;
29
+ export interface ServerFailedPreparedOp {
30
+ readonly callId: string;
31
+ readonly op: string;
32
+ readonly kind: string;
33
+ readonly message: string;
34
+ readonly path?: string;
35
+ readonly port?: string;
36
+ readonly fix?: string;
37
+ }
38
+ /** Error envelope returned on non-2xx responses. */
39
+ export interface ServerErrorBody {
40
+ readonly error?: {
41
+ readonly kind?: string;
42
+ readonly message?: string;
34
43
  readonly path?: string;
35
44
  readonly port?: string;
36
45
  readonly fix?: string;
37
- }
38
- /** Error envelope returned on non-2xx responses. */
39
- interface ServerErrorBody {
40
- readonly error?: {
41
- readonly kind?: string;
42
- readonly message?: string;
43
- readonly path?: string;
44
- readonly port?: string;
45
- readonly fix?: string;
46
- readonly sdkVersion?: string;
47
- readonly serverVersion?: string;
48
- readonly minimumSdkVersion?: string;
49
- readonly details?: SimulationRevert;
50
- readonly failedOps?: readonly ServerFailedPreparedOp[];
51
- readonly succeededOps?: readonly string[];
52
- };
46
+ readonly sdkVersion?: string;
47
+ readonly serverVersion?: string;
48
+ readonly minimumSdkVersion?: string;
49
+ readonly details?: SimulationRevert;
50
+ readonly failedOps?: readonly ServerFailedPreparedOp[];
51
+ readonly succeededOps?: readonly string[];
52
+ };
53
53
  }
54
54
  /** Validates an already-parsed error envelope; `null` when it does not match. */
55
- declare const parseServerErrorBody: (json: unknown) => ServerErrorBody | null;
56
-
57
- export { type CompilePartialEnvelope, type ServerErrorBody, type ServerFailedPreparedOp, parseCompilePartialEnvelope, parseServerErrorBody, parseSimulateResult };
55
+ export declare const parseServerErrorBody: (json: unknown) => ServerErrorBody | null;
56
+ //#endregion
57
+ //# sourceMappingURL=responseSchemas.d.ts.map
@@ -1,90 +1,109 @@
1
1
  import z from "zod";
2
+ //#region src/responseSchemas.ts
3
+ /**
4
+ * Zod-backed parsers for Compose API response bodies.
5
+ *
6
+ * Server responses are untrusted input crossing into the SDK, so the shapes the
7
+ * client reads back are validated here rather than asserted with `as` casts. The
8
+ * schemas are module-private (the package builds with `--isolatedDeclarations`,
9
+ * which forbids exporting un-annotated complex values); the public surface is
10
+ * the typed `parse*` helpers, whose explicit return types double as the contract.
11
+ *
12
+ * The simulate union is the one response the SDK fully owns and parses itself
13
+ * (it is un-enveloped, unlike `/compose`), so it gets a complete schema kept in
14
+ * lockstep with the canonical `SimulateResult` in `@lifi/compose-spec` by the
15
+ * compile-time assertion below — the same anchoring `@lifi/api-schemas` uses for
16
+ * its server-side simulate schema, so the two cannot silently drift.
17
+ */
2
18
  const balanceEntrySchema = z.object({
3
- token: z.string(),
4
- owner: z.string(),
5
- amount: z.string()
19
+ token: z.string(),
20
+ owner: z.string(),
21
+ amount: z.string()
6
22
  });
7
23
  const simulateOkSchema = z.object({
8
- status: z.literal("ok"),
9
- block: z.number(),
10
- timestamp: z.number(),
11
- balancesBefore: z.array(balanceEntrySchema),
12
- balancesAfter: z.array(balanceEntrySchema),
13
- deltas: z.array(balanceEntrySchema),
14
- gasUsed: z.string()
24
+ status: z.literal("ok"),
25
+ block: z.number(),
26
+ timestamp: z.number(),
27
+ balancesBefore: z.array(balanceEntrySchema),
28
+ balancesAfter: z.array(balanceEntrySchema),
29
+ deltas: z.array(balanceEntrySchema),
30
+ gasUsed: z.string()
15
31
  });
16
32
  const simulateRevertDecodeResultSchema = z.object({
17
- errorCandidates: z.array(
18
- z.object({
19
- decodedErrorSignature: z.string(),
20
- decodedParams: z.array(z.string())
21
- })
22
- ).optional(),
23
- error: z.string().optional()
33
+ errorCandidates: z.array(z.object({
34
+ decodedErrorSignature: z.string(),
35
+ decodedParams: z.array(z.string())
36
+ })).optional(),
37
+ error: z.string().optional()
24
38
  });
25
39
  const simulateRevertSchema = z.object({
26
- status: z.literal("revert"),
27
- block: z.number(),
28
- timestamp: z.number(),
29
- revertReason: z.string().optional(),
30
- code: z.number().optional(),
31
- rawErrorBytes: z.string().optional(),
32
- decodeResult: simulateRevertDecodeResultSchema.optional()
40
+ status: z.literal("revert"),
41
+ block: z.number(),
42
+ timestamp: z.number(),
43
+ revertReason: z.string().optional(),
44
+ code: z.number().optional(),
45
+ rawErrorBytes: z.string().optional(),
46
+ decodeResult: simulateRevertDecodeResultSchema.optional()
33
47
  });
34
48
  const simulateSetupErrorSchema = z.object({
35
- status: z.literal("error"),
36
- message: z.string()
49
+ status: z.literal("error"),
50
+ message: z.string()
37
51
  });
38
52
  const simulateResultSchema = z.discriminatedUnion("status", [
39
- simulateOkSchema,
40
- simulateRevertSchema,
41
- simulateSetupErrorSchema
53
+ simulateOkSchema,
54
+ simulateRevertSchema,
55
+ simulateSetupErrorSchema
42
56
  ]);
57
+ /**
58
+ * Parses a `POST /simulate` body into a {@link SimulateResult}. Returns `null`
59
+ * when the body does not match the `ok`/`revert`/`error` union, letting the
60
+ * caller raise a transport-level error.
61
+ */
43
62
  const parseSimulateResult = (body) => {
44
- const parsed = simulateResultSchema.safeParse(body);
45
- if (!parsed.success) return null;
46
- const result = parsed.data;
47
- return result;
63
+ const parsed = simulateResultSchema.safeParse(body);
64
+ if (!parsed.success) return null;
65
+ return parsed.data;
48
66
  };
49
67
  const compilePartialEnvelopeSchema = z.object({
50
- data: z.record(z.string(), z.unknown()),
51
- error: z.object({ kind: z.string(), message: z.string() })
68
+ data: z.record(z.string(), z.unknown()),
69
+ error: z.object({
70
+ kind: z.string(),
71
+ message: z.string()
72
+ })
52
73
  });
74
+ /** Parses an HTTP 206 partial compile envelope; `null` when it does not match. */
53
75
  const parseCompilePartialEnvelope = (body) => {
54
- const parsed = compilePartialEnvelopeSchema.safeParse(body);
55
- return parsed.success ? parsed.data : null;
76
+ const parsed = compilePartialEnvelopeSchema.safeParse(body);
77
+ return parsed.success ? parsed.data : null;
56
78
  };
57
79
  const failedPreparedOpSchema = z.object({
58
- callId: z.string(),
59
- op: z.string(),
60
- kind: z.string(),
61
- message: z.string(),
62
- path: z.string().optional(),
63
- port: z.string().optional(),
64
- fix: z.string().optional()
65
- });
66
- const serverErrorBodySchema = z.object({
67
- error: z.object({
68
- kind: z.string().optional(),
69
- message: z.string().optional(),
70
- path: z.string().optional(),
71
- port: z.string().optional(),
72
- fix: z.string().optional(),
73
- sdkVersion: z.string().optional(),
74
- serverVersion: z.string().optional(),
75
- minimumSdkVersion: z.string().optional(),
76
- details: z.custom().optional(),
77
- failedOps: z.array(failedPreparedOpSchema).readonly().optional(),
78
- succeededOps: z.array(z.string()).readonly().optional()
79
- }).optional()
80
+ callId: z.string(),
81
+ op: z.string(),
82
+ kind: z.string(),
83
+ message: z.string(),
84
+ path: z.string().optional(),
85
+ port: z.string().optional(),
86
+ fix: z.string().optional()
80
87
  });
88
+ const serverErrorBodySchema = z.object({ error: z.object({
89
+ kind: z.string().optional(),
90
+ message: z.string().optional(),
91
+ path: z.string().optional(),
92
+ port: z.string().optional(),
93
+ fix: z.string().optional(),
94
+ sdkVersion: z.string().optional(),
95
+ serverVersion: z.string().optional(),
96
+ minimumSdkVersion: z.string().optional(),
97
+ details: z.custom().optional(),
98
+ failedOps: z.array(failedPreparedOpSchema).readonly().optional(),
99
+ succeededOps: z.array(z.string()).readonly().optional()
100
+ }).optional() });
101
+ /** Validates an already-parsed error envelope; `null` when it does not match. */
81
102
  const parseServerErrorBody = (json) => {
82
- const parsed = serverErrorBodySchema.safeParse(json);
83
- return parsed.success ? parsed.data : null;
84
- };
85
- export {
86
- parseCompilePartialEnvelope,
87
- parseServerErrorBody,
88
- parseSimulateResult
103
+ const parsed = serverErrorBodySchema.safeParse(json);
104
+ return parsed.success ? parsed.data : null;
89
105
  };
106
+ //#endregion
107
+ export { parseCompilePartialEnvelope, parseServerErrorBody, parseSimulateResult };
108
+
90
109
  //# sourceMappingURL=responseSchemas.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/responseSchemas.ts"],"sourcesContent":["import type { SimulateResult, SimulationRevert } from '@lifi/compose-spec';\nimport z from 'zod';\n\n/**\n * Zod-backed parsers for Compose API response bodies.\n *\n * Server responses are untrusted input crossing into the SDK, so the shapes the\n * client reads back are validated here rather than asserted with `as` casts. The\n * schemas are module-private (the package builds with `--isolatedDeclarations`,\n * which forbids exporting un-annotated complex values); the public surface is\n * the typed `parse*` helpers, whose explicit return types double as the contract.\n *\n * The simulate union is the one response the SDK fully owns and parses itself\n * (it is un-enveloped, unlike `/compose`), so it gets a complete schema kept in\n * lockstep with the canonical `SimulateResult` in `@lifi/compose-spec` by the\n * compile-time assertion below — the same anchoring `@lifi/api-schemas` uses for\n * its server-side simulate schema, so the two cannot silently drift.\n */\n\nconst balanceEntrySchema = z.object({\n token: z.string(),\n owner: z.string(),\n amount: z.string(),\n});\n\nconst simulateOkSchema = z.object({\n status: z.literal('ok'),\n block: z.number(),\n timestamp: z.number(),\n balancesBefore: z.array(balanceEntrySchema),\n balancesAfter: z.array(balanceEntrySchema),\n deltas: z.array(balanceEntrySchema),\n gasUsed: z.string(),\n});\n\nconst simulateRevertDecodeResultSchema = z.object({\n errorCandidates: z\n .array(\n z.object({\n decodedErrorSignature: z.string(),\n decodedParams: z.array(z.string()),\n }),\n )\n .optional(),\n error: z.string().optional(),\n});\n\nconst simulateRevertSchema = z.object({\n status: z.literal('revert'),\n block: z.number(),\n timestamp: z.number(),\n revertReason: z.string().optional(),\n code: z.number().optional(),\n rawErrorBytes: z.string().optional(),\n decodeResult: simulateRevertDecodeResultSchema.optional(),\n});\n\nconst simulateSetupErrorSchema = z.object({\n status: z.literal('error'),\n message: z.string(),\n});\n\nconst simulateResultSchema = z.discriminatedUnion('status', [\n simulateOkSchema,\n simulateRevertSchema,\n simulateSetupErrorSchema,\n]);\n\n// The type the schema actually parses out. Kept private (referencing it from an\n// exported declaration would break `--isolatedDeclarations`) and pinned to the\n// canonical `SimulateResult` inside `parseSimulateResult` below.\ntype SimulateResultWire = z.infer<typeof simulateResultSchema>;\n\n/**\n * Parses a `POST /simulate` body into a {@link SimulateResult}. Returns `null`\n * when the body does not match the `ok`/`revert`/`error` union, letting the\n * caller raise a transport-level error.\n */\nexport const parseSimulateResult = (body: unknown): SimulateResult | null => {\n const parsed = simulateResultSchema.safeParse(body);\n if (!parsed.success) return null;\n // Pin the schema to the canonical contract in both directions, so it cannot\n // silently drift (mirroring the conformance assertion `@lifi/api-schemas` runs\n // on its server-side simulate schema). Assigning the inferred wire value to a\n // `SimulateResult` checks wire→spec; `satisfies SimulateResultWire` checks\n // spec→wire. A missing or mistyped field on either side fails to compile.\n const result: SimulateResult = parsed.data;\n return result satisfies SimulateResultWire;\n};\n\n/**\n * The validated members of an HTTP 206 partial compile envelope. `data` is\n * verified to be an object at runtime but left `unknown` here — compose-spec\n * owns its full shape (`ComposeCompilePartialData`) as a hand-authored type, so\n * the caller narrows it in one step. `error` is fully validated.\n */\nexport interface CompilePartialEnvelope {\n readonly data: unknown;\n readonly error: { readonly kind: string; readonly message: string };\n}\n\nconst compilePartialEnvelopeSchema = z.object({\n data: z.record(z.string(), z.unknown()),\n error: z.object({ kind: z.string(), message: z.string() }),\n});\n\n/** Parses an HTTP 206 partial compile envelope; `null` when it does not match. */\nexport const parseCompilePartialEnvelope = (\n body: unknown,\n): CompilePartialEnvelope | null => {\n const parsed = compilePartialEnvelopeSchema.safeParse(body);\n return parsed.success ? parsed.data : null;\n};\n\n/**\n * A single prepared-op failure inside a `preparation_error` envelope. `kind` is\n * kept as `string` here — the narrowing to `GenericComposeErrorKind` happens in\n * `errorFromHttpResponse`, where the value is lifted onto `ComposeError`.\n */\nexport interface ServerFailedPreparedOp {\n readonly callId: string;\n readonly op: string;\n readonly kind: string;\n readonly message: string;\n readonly path?: string;\n readonly port?: string;\n readonly fix?: string;\n}\n\n/** Error envelope returned on non-2xx responses. */\nexport interface ServerErrorBody {\n readonly error?: {\n readonly kind?: string;\n readonly message?: string;\n readonly path?: string;\n readonly port?: string;\n readonly fix?: string;\n readonly sdkVersion?: string;\n readonly serverVersion?: string;\n readonly minimumSdkVersion?: string;\n readonly details?: SimulationRevert;\n readonly failedOps?: readonly ServerFailedPreparedOp[];\n readonly succeededOps?: readonly string[];\n };\n}\n\nconst failedPreparedOpSchema = z.object({\n callId: z.string(),\n op: z.string(),\n kind: z.string(),\n message: z.string(),\n path: z.string().optional(),\n port: z.string().optional(),\n fix: z.string().optional(),\n});\n\n// `details` is passed through (`z.custom`) rather than parsed: the SDK does not\n// own the `SimulationRevert` schema and forwards the field verbatim onto\n// `ComposeError`.\n//\n// `failedOps`/`succeededOps` are optional here because every error kind shares\n// this envelope; they are only populated for `preparation_error` (422). Zod\n// strips undeclared keys, so omitting them would silently drop them — which is\n// also why `port` and `fix`, set on every author-caused `validation_error`,\n// have to be declared here to reach the caller.\nconst serverErrorBodySchema = z.object({\n error: z\n .object({\n kind: z.string().optional(),\n message: z.string().optional(),\n path: z.string().optional(),\n port: z.string().optional(),\n fix: z.string().optional(),\n sdkVersion: z.string().optional(),\n serverVersion: z.string().optional(),\n minimumSdkVersion: z.string().optional(),\n details: z.custom<SimulationRevert>().optional(),\n failedOps: z.array(failedPreparedOpSchema).readonly().optional(),\n succeededOps: z.array(z.string()).readonly().optional(),\n })\n .optional(),\n});\n\n/** Validates an already-parsed error envelope; `null` when it does not match. */\nexport const parseServerErrorBody = (json: unknown): ServerErrorBody | null => {\n const parsed = serverErrorBodySchema.safeParse(json);\n return parsed.success ? parsed.data : null;\n};\n"],"mappings":"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","names":[]}
1
+ {"version":3,"file":"responseSchemas.js","names":[],"sources":["../src/responseSchemas.ts"],"sourcesContent":["import type { SimulateResult, SimulationRevert } from '@lifi/compose-spec';\nimport z from 'zod';\n\n/**\n * Zod-backed parsers for Compose API response bodies.\n *\n * Server responses are untrusted input crossing into the SDK, so the shapes the\n * client reads back are validated here rather than asserted with `as` casts. The\n * schemas are module-private (the package builds with `--isolatedDeclarations`,\n * which forbids exporting un-annotated complex values); the public surface is\n * the typed `parse*` helpers, whose explicit return types double as the contract.\n *\n * The simulate union is the one response the SDK fully owns and parses itself\n * (it is un-enveloped, unlike `/compose`), so it gets a complete schema kept in\n * lockstep with the canonical `SimulateResult` in `@lifi/compose-spec` by the\n * compile-time assertion below — the same anchoring `@lifi/api-schemas` uses for\n * its server-side simulate schema, so the two cannot silently drift.\n */\n\nconst balanceEntrySchema = z.object({\n token: z.string(),\n owner: z.string(),\n amount: z.string(),\n});\n\nconst simulateOkSchema = z.object({\n status: z.literal('ok'),\n block: z.number(),\n timestamp: z.number(),\n balancesBefore: z.array(balanceEntrySchema),\n balancesAfter: z.array(balanceEntrySchema),\n deltas: z.array(balanceEntrySchema),\n gasUsed: z.string(),\n});\n\nconst simulateRevertDecodeResultSchema = z.object({\n errorCandidates: z\n .array(\n z.object({\n decodedErrorSignature: z.string(),\n decodedParams: z.array(z.string()),\n }),\n )\n .optional(),\n error: z.string().optional(),\n});\n\nconst simulateRevertSchema = z.object({\n status: z.literal('revert'),\n block: z.number(),\n timestamp: z.number(),\n revertReason: z.string().optional(),\n code: z.number().optional(),\n rawErrorBytes: z.string().optional(),\n decodeResult: simulateRevertDecodeResultSchema.optional(),\n});\n\nconst simulateSetupErrorSchema = z.object({\n status: z.literal('error'),\n message: z.string(),\n});\n\nconst simulateResultSchema = z.discriminatedUnion('status', [\n simulateOkSchema,\n simulateRevertSchema,\n simulateSetupErrorSchema,\n]);\n\n// The type the schema actually parses out. Kept private (referencing it from an\n// exported declaration would break `--isolatedDeclarations`) and pinned to the\n// canonical `SimulateResult` inside `parseSimulateResult` below.\ntype SimulateResultWire = z.infer<typeof simulateResultSchema>;\n\n/**\n * Parses a `POST /simulate` body into a {@link SimulateResult}. Returns `null`\n * when the body does not match the `ok`/`revert`/`error` union, letting the\n * caller raise a transport-level error.\n */\nexport const parseSimulateResult = (body: unknown): SimulateResult | null => {\n const parsed = simulateResultSchema.safeParse(body);\n if (!parsed.success) return null;\n // Pin the schema to the canonical contract in both directions, so it cannot\n // silently drift (mirroring the conformance assertion `@lifi/api-schemas` runs\n // on its server-side simulate schema). Assigning the inferred wire value to a\n // `SimulateResult` checks wire→spec; `satisfies SimulateResultWire` checks\n // spec→wire. A missing or mistyped field on either side fails to compile.\n const result: SimulateResult = parsed.data;\n return result satisfies SimulateResultWire;\n};\n\n/**\n * The validated members of an HTTP 206 partial compile envelope. `data` is\n * verified to be an object at runtime but left `unknown` here — compose-spec\n * owns its full shape (`ComposeCompilePartialData`) as a hand-authored type, so\n * the caller narrows it in one step. `error` is fully validated.\n */\nexport interface CompilePartialEnvelope {\n readonly data: unknown;\n readonly error: { readonly kind: string; readonly message: string };\n}\n\nconst compilePartialEnvelopeSchema = z.object({\n data: z.record(z.string(), z.unknown()),\n error: z.object({ kind: z.string(), message: z.string() }),\n});\n\n/** Parses an HTTP 206 partial compile envelope; `null` when it does not match. */\nexport const parseCompilePartialEnvelope = (\n body: unknown,\n): CompilePartialEnvelope | null => {\n const parsed = compilePartialEnvelopeSchema.safeParse(body);\n return parsed.success ? parsed.data : null;\n};\n\n/**\n * A single prepared-op failure inside a `preparation_error` envelope. `kind` is\n * kept as `string` here — the narrowing to `GenericComposeErrorKind` happens in\n * `errorFromHttpResponse`, where the value is lifted onto `ComposeError`.\n */\nexport interface ServerFailedPreparedOp {\n readonly callId: string;\n readonly op: string;\n readonly kind: string;\n readonly message: string;\n readonly path?: string;\n readonly port?: string;\n readonly fix?: string;\n}\n\n/** Error envelope returned on non-2xx responses. */\nexport interface ServerErrorBody {\n readonly error?: {\n readonly kind?: string;\n readonly message?: string;\n readonly path?: string;\n readonly port?: string;\n readonly fix?: string;\n readonly sdkVersion?: string;\n readonly serverVersion?: string;\n readonly minimumSdkVersion?: string;\n readonly details?: SimulationRevert;\n readonly failedOps?: readonly ServerFailedPreparedOp[];\n readonly succeededOps?: readonly string[];\n };\n}\n\nconst failedPreparedOpSchema = z.object({\n callId: z.string(),\n op: z.string(),\n kind: z.string(),\n message: z.string(),\n path: z.string().optional(),\n port: z.string().optional(),\n fix: z.string().optional(),\n});\n\n// `details` is passed through (`z.custom`) rather than parsed: the SDK does not\n// own the `SimulationRevert` schema and forwards the field verbatim onto\n// `ComposeError`.\n//\n// `failedOps`/`succeededOps` are optional here because every error kind shares\n// this envelope; they are only populated for `preparation_error` (422). Zod\n// strips undeclared keys, so omitting them would silently drop them — which is\n// also why `port` and `fix`, set on every author-caused `validation_error`,\n// have to be declared here to reach the caller.\nconst serverErrorBodySchema = z.object({\n error: z\n .object({\n kind: z.string().optional(),\n message: z.string().optional(),\n path: z.string().optional(),\n port: z.string().optional(),\n fix: z.string().optional(),\n sdkVersion: z.string().optional(),\n serverVersion: z.string().optional(),\n minimumSdkVersion: z.string().optional(),\n details: z.custom<SimulationRevert>().optional(),\n failedOps: z.array(failedPreparedOpSchema).readonly().optional(),\n succeededOps: z.array(z.string()).readonly().optional(),\n })\n .optional(),\n});\n\n/** Validates an already-parsed error envelope; `null` when it does not match. */\nexport const parseServerErrorBody = (json: unknown): ServerErrorBody | null => {\n const parsed = serverErrorBodySchema.safeParse(json);\n return parsed.success ? parsed.data : null;\n};\n"],"mappings":"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"}
@@ -1,38 +1,68 @@
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, all2) => {
7
- for (var name in all2)
8
- __defProp(target, name, { get: all2[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 routeAmount_exports = {};
20
- __export(routeAmount_exports, {
21
- all: () => all,
22
- exact: () => exact
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ //#region src/routeAmount.ts
3
+ var routeAmount_exports = /* @__PURE__ */ require("./_virtual/_rolldown/runtime.cjs").__exportAll({
4
+ all: () => all,
5
+ exact: () => exact
23
6
  });
24
- module.exports = __toCommonJS(routeAmount_exports);
7
+ /**
8
+ * Spend an exact amount of the route's `fromToken`.
9
+ *
10
+ * @param amount - Amount in the token's smallest unit. `bigint` is serialised
11
+ * to a decimal string when the request is sent.
12
+ * @returns The `EXACT` member of the route amount union.
13
+ *
14
+ * @example
15
+ * ```ts
16
+ * const result = await sdk.route({
17
+ * chainId: 1,
18
+ * fromToken: NATIVE_ETH,
19
+ * toToken: WETH,
20
+ * amount: routeAmount.exact(10n ** 17n), // 0.1 ETH, wrapped
21
+ * signer: OWNER,
22
+ * });
23
+ * ```
24
+ */
25
25
  const exact = (amount) => ({
26
- type: "EXACT",
27
- amount
26
+ type: "EXACT",
27
+ amount
28
28
  });
29
+ /**
30
+ * Spend the signer's entire `fromToken` balance, resolved on-chain at execution
31
+ * time.
32
+ *
33
+ * Not supported when `fromToken` is the chain's native sentinel — the server
34
+ * rejects it. A gas coin is sent via `msg.value`, so there is no on-chain
35
+ * balance to sweep; use {@link exact} for native inputs.
36
+ *
37
+ * @param simAmount - A realistic estimate of that balance, in the token's
38
+ * smallest unit. The server quotes and simulates against this value, so it
39
+ * shapes the returned quote and preconditions — but the amount actually moved
40
+ * is whatever the balance turns out to be.
41
+ * @returns The `ALL` member of the route amount union.
42
+ *
43
+ * @example
44
+ * ```ts
45
+ * const result = await sdk.route({
46
+ * chainId: 1,
47
+ * fromToken: USDC,
48
+ * toToken: A_ETH_USDC,
49
+ * amount: routeAmount.all(1_000_000n), // estimate: ~1 USDC on hand
50
+ * signer: OWNER,
51
+ * });
52
+ * ```
53
+ */
29
54
  const all = (simAmount) => ({
30
- type: "ALL",
31
- simAmount
55
+ type: "ALL",
56
+ simAmount
32
57
  });
33
- // Annotate the CommonJS export names for ESM import in node:
34
- 0 && (module.exports = {
35
- all,
36
- exact
58
+ //#endregion
59
+ exports.all = all;
60
+ exports.exact = exact;
61
+ Object.defineProperty(exports, "routeAmount_exports", {
62
+ enumerable: true,
63
+ get: function() {
64
+ return routeAmount_exports;
65
+ }
37
66
  });
67
+
38
68
  //# sourceMappingURL=routeAmount.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/routeAmount.ts"],"sourcesContent":["import type { RouteAmountAll, RouteAmountExact } from '@lifi/compose-spec';\n\n// Constructors for the `amount` member of a `ComposeRouteRequest`. The wire\n// union is discriminated by `type` and — deliberately, because the two variants\n// mean different things — names its payload field differently in each variant:\n// `amount` is the sum actually moved, `simAmount` is only a quoting stand-in for\n// a balance resolved on-chain. These helpers keep call sites from having to\n// remember which name goes with which discriminant.\n\n/**\n * Spend an exact amount of the route's `fromToken`.\n *\n * @param amount - Amount in the token's smallest unit. `bigint` is serialised\n * to a decimal string when the request is sent.\n * @returns The `EXACT` member of the route amount union.\n *\n * @example\n * ```ts\n * const result = await sdk.route({\n * chainId: 1,\n * fromToken: NATIVE_ETH,\n * toToken: WETH,\n * amount: routeAmount.exact(10n ** 17n), // 0.1 ETH, wrapped\n * signer: OWNER,\n * });\n * ```\n */\nexport const exact = (amount: bigint | string): RouteAmountExact => ({\n type: 'EXACT',\n amount,\n});\n\n/**\n * Spend the signer's entire `fromToken` balance, resolved on-chain at execution\n * time.\n *\n * Not supported when `fromToken` is the chain's native sentinel — the server\n * rejects it. A gas coin is sent via `msg.value`, so there is no on-chain\n * balance to sweep; use {@link exact} for native inputs.\n *\n * @param simAmount - A realistic estimate of that balance, in the token's\n * smallest unit. The server quotes and simulates against this value, so it\n * shapes the returned quote and preconditions — but the amount actually moved\n * is whatever the balance turns out to be.\n * @returns The `ALL` member of the route amount union.\n *\n * @example\n * ```ts\n * const result = await sdk.route({\n * chainId: 1,\n * fromToken: USDC,\n * toToken: A_ETH_USDC,\n * amount: routeAmount.all(1_000_000n), // estimate: ~1 USDC on hand\n * signer: OWNER,\n * });\n * ```\n */\nexport const all = (simAmount: bigint | string): RouteAmountAll => ({\n type: 'ALL',\n simAmount,\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA2BO,MAAM,QAAQ,CAAC,YAA+C;AAAA,EACnE,MAAM;AAAA,EACN;AACF;AA2BO,MAAM,MAAM,CAAC,eAAgD;AAAA,EAClE,MAAM;AAAA,EACN;AACF;","names":[]}
1
+ {"version":3,"file":"routeAmount.cjs","names":[],"sources":["../src/routeAmount.ts"],"sourcesContent":["import type { RouteAmountAll, RouteAmountExact } from '@lifi/compose-spec';\n\n// Constructors for the `amount` member of a `ComposeRouteRequest`. The wire\n// union is discriminated by `type` and — deliberately, because the two variants\n// mean different things — names its payload field differently in each variant:\n// `amount` is the sum actually moved, `simAmount` is only a quoting stand-in for\n// a balance resolved on-chain. These helpers keep call sites from having to\n// remember which name goes with which discriminant.\n\n/**\n * Spend an exact amount of the route's `fromToken`.\n *\n * @param amount - Amount in the token's smallest unit. `bigint` is serialised\n * to a decimal string when the request is sent.\n * @returns The `EXACT` member of the route amount union.\n *\n * @example\n * ```ts\n * const result = await sdk.route({\n * chainId: 1,\n * fromToken: NATIVE_ETH,\n * toToken: WETH,\n * amount: routeAmount.exact(10n ** 17n), // 0.1 ETH, wrapped\n * signer: OWNER,\n * });\n * ```\n */\nexport const exact = (amount: bigint | string): RouteAmountExact => ({\n type: 'EXACT',\n amount,\n});\n\n/**\n * Spend the signer's entire `fromToken` balance, resolved on-chain at execution\n * time.\n *\n * Not supported when `fromToken` is the chain's native sentinel — the server\n * rejects it. A gas coin is sent via `msg.value`, so there is no on-chain\n * balance to sweep; use {@link exact} for native inputs.\n *\n * @param simAmount - A realistic estimate of that balance, in the token's\n * smallest unit. The server quotes and simulates against this value, so it\n * shapes the returned quote and preconditions — but the amount actually moved\n * is whatever the balance turns out to be.\n * @returns The `ALL` member of the route amount union.\n *\n * @example\n * ```ts\n * const result = await sdk.route({\n * chainId: 1,\n * fromToken: USDC,\n * toToken: A_ETH_USDC,\n * amount: routeAmount.all(1_000_000n), // estimate: ~1 USDC on hand\n * signer: OWNER,\n * });\n * ```\n */\nexport const all = (simAmount: bigint | string): RouteAmountAll => ({\n type: 'ALL',\n simAmount,\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AA2BA,MAAa,SAAS,YAA+C;CACnE,MAAM;CACN;AACF;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BA,MAAa,OAAO,eAAgD;CAClE,MAAM;CACN;AACF"}
@@ -1,2 +1,52 @@
1
- import '@lifi/compose-spec';
2
- export { a as all, e as exact } from './routeAmount-DdbJYJyM.cjs';
1
+ import { RouteAmountAll, RouteAmountExact } from "@lifi/compose-spec";
2
+ declare namespace routeAmount_d_exports {
3
+ export { all, exact };
4
+ }
5
+ /**
6
+ * Spend an exact amount of the route's `fromToken`.
7
+ *
8
+ * @param amount - Amount in the token's smallest unit. `bigint` is serialised
9
+ * to a decimal string when the request is sent.
10
+ * @returns The `EXACT` member of the route amount union.
11
+ *
12
+ * @example
13
+ * ```ts
14
+ * const result = await sdk.route({
15
+ * chainId: 1,
16
+ * fromToken: NATIVE_ETH,
17
+ * toToken: WETH,
18
+ * amount: routeAmount.exact(10n ** 17n), // 0.1 ETH, wrapped
19
+ * signer: OWNER,
20
+ * });
21
+ * ```
22
+ */
23
+ export declare const exact: (amount: bigint | string) => RouteAmountExact;
24
+ /**
25
+ * Spend the signer's entire `fromToken` balance, resolved on-chain at execution
26
+ * time.
27
+ *
28
+ * Not supported when `fromToken` is the chain's native sentinel — the server
29
+ * rejects it. A gas coin is sent via `msg.value`, so there is no on-chain
30
+ * balance to sweep; use {@link exact} for native inputs.
31
+ *
32
+ * @param simAmount - A realistic estimate of that balance, in the token's
33
+ * smallest unit. The server quotes and simulates against this value, so it
34
+ * shapes the returned quote and preconditions — but the amount actually moved
35
+ * is whatever the balance turns out to be.
36
+ * @returns The `ALL` member of the route amount union.
37
+ *
38
+ * @example
39
+ * ```ts
40
+ * const result = await sdk.route({
41
+ * chainId: 1,
42
+ * fromToken: USDC,
43
+ * toToken: A_ETH_USDC,
44
+ * amount: routeAmount.all(1_000_000n), // estimate: ~1 USDC on hand
45
+ * signer: OWNER,
46
+ * });
47
+ * ```
48
+ */
49
+ export declare const all: (simAmount: bigint | string) => RouteAmountAll;
50
+ //#endregion
51
+ export { routeAmount_d_exports };
52
+ //# sourceMappingURL=routeAmount.d.cts.map
@@ -1,2 +1,52 @@
1
- import '@lifi/compose-spec';
2
- export { a as all, e as exact } from './routeAmount-DdbJYJyM.js';
1
+ import { RouteAmountAll, RouteAmountExact } from "@lifi/compose-spec";
2
+ declare namespace routeAmount_d_exports {
3
+ export { all, exact };
4
+ }
5
+ /**
6
+ * Spend an exact amount of the route's `fromToken`.
7
+ *
8
+ * @param amount - Amount in the token's smallest unit. `bigint` is serialised
9
+ * to a decimal string when the request is sent.
10
+ * @returns The `EXACT` member of the route amount union.
11
+ *
12
+ * @example
13
+ * ```ts
14
+ * const result = await sdk.route({
15
+ * chainId: 1,
16
+ * fromToken: NATIVE_ETH,
17
+ * toToken: WETH,
18
+ * amount: routeAmount.exact(10n ** 17n), // 0.1 ETH, wrapped
19
+ * signer: OWNER,
20
+ * });
21
+ * ```
22
+ */
23
+ export declare const exact: (amount: bigint | string) => RouteAmountExact;
24
+ /**
25
+ * Spend the signer's entire `fromToken` balance, resolved on-chain at execution
26
+ * time.
27
+ *
28
+ * Not supported when `fromToken` is the chain's native sentinel — the server
29
+ * rejects it. A gas coin is sent via `msg.value`, so there is no on-chain
30
+ * balance to sweep; use {@link exact} for native inputs.
31
+ *
32
+ * @param simAmount - A realistic estimate of that balance, in the token's
33
+ * smallest unit. The server quotes and simulates against this value, so it
34
+ * shapes the returned quote and preconditions — but the amount actually moved
35
+ * is whatever the balance turns out to be.
36
+ * @returns The `ALL` member of the route amount union.
37
+ *
38
+ * @example
39
+ * ```ts
40
+ * const result = await sdk.route({
41
+ * chainId: 1,
42
+ * fromToken: USDC,
43
+ * toToken: A_ETH_USDC,
44
+ * amount: routeAmount.all(1_000_000n), // estimate: ~1 USDC on hand
45
+ * signer: OWNER,
46
+ * });
47
+ * ```
48
+ */
49
+ export declare const all: (simAmount: bigint | string) => RouteAmountAll;
50
+ //#endregion
51
+ export { routeAmount_d_exports };
52
+ //# sourceMappingURL=routeAmount.d.ts.map
@@ -1,13 +1,61 @@
1
+ import { __exportAll } from "./_virtual/_rolldown/runtime.js";
2
+ //#region src/routeAmount.ts
3
+ var routeAmount_exports = /* @__PURE__ */ __exportAll({
4
+ all: () => all,
5
+ exact: () => exact
6
+ });
7
+ /**
8
+ * Spend an exact amount of the route's `fromToken`.
9
+ *
10
+ * @param amount - Amount in the token's smallest unit. `bigint` is serialised
11
+ * to a decimal string when the request is sent.
12
+ * @returns The `EXACT` member of the route amount union.
13
+ *
14
+ * @example
15
+ * ```ts
16
+ * const result = await sdk.route({
17
+ * chainId: 1,
18
+ * fromToken: NATIVE_ETH,
19
+ * toToken: WETH,
20
+ * amount: routeAmount.exact(10n ** 17n), // 0.1 ETH, wrapped
21
+ * signer: OWNER,
22
+ * });
23
+ * ```
24
+ */
1
25
  const exact = (amount) => ({
2
- type: "EXACT",
3
- amount
26
+ type: "EXACT",
27
+ amount
4
28
  });
29
+ /**
30
+ * Spend the signer's entire `fromToken` balance, resolved on-chain at execution
31
+ * time.
32
+ *
33
+ * Not supported when `fromToken` is the chain's native sentinel — the server
34
+ * rejects it. A gas coin is sent via `msg.value`, so there is no on-chain
35
+ * balance to sweep; use {@link exact} for native inputs.
36
+ *
37
+ * @param simAmount - A realistic estimate of that balance, in the token's
38
+ * smallest unit. The server quotes and simulates against this value, so it
39
+ * shapes the returned quote and preconditions — but the amount actually moved
40
+ * is whatever the balance turns out to be.
41
+ * @returns The `ALL` member of the route amount union.
42
+ *
43
+ * @example
44
+ * ```ts
45
+ * const result = await sdk.route({
46
+ * chainId: 1,
47
+ * fromToken: USDC,
48
+ * toToken: A_ETH_USDC,
49
+ * amount: routeAmount.all(1_000_000n), // estimate: ~1 USDC on hand
50
+ * signer: OWNER,
51
+ * });
52
+ * ```
53
+ */
5
54
  const all = (simAmount) => ({
6
- type: "ALL",
7
- simAmount
55
+ type: "ALL",
56
+ simAmount
8
57
  });
9
- export {
10
- all,
11
- exact
12
- };
58
+ //#endregion
59
+ export { all, exact, routeAmount_exports };
60
+
13
61
  //# sourceMappingURL=routeAmount.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/routeAmount.ts"],"sourcesContent":["import type { RouteAmountAll, RouteAmountExact } from '@lifi/compose-spec';\n\n// Constructors for the `amount` member of a `ComposeRouteRequest`. The wire\n// union is discriminated by `type` and — deliberately, because the two variants\n// mean different things — names its payload field differently in each variant:\n// `amount` is the sum actually moved, `simAmount` is only a quoting stand-in for\n// a balance resolved on-chain. These helpers keep call sites from having to\n// remember which name goes with which discriminant.\n\n/**\n * Spend an exact amount of the route's `fromToken`.\n *\n * @param amount - Amount in the token's smallest unit. `bigint` is serialised\n * to a decimal string when the request is sent.\n * @returns The `EXACT` member of the route amount union.\n *\n * @example\n * ```ts\n * const result = await sdk.route({\n * chainId: 1,\n * fromToken: NATIVE_ETH,\n * toToken: WETH,\n * amount: routeAmount.exact(10n ** 17n), // 0.1 ETH, wrapped\n * signer: OWNER,\n * });\n * ```\n */\nexport const exact = (amount: bigint | string): RouteAmountExact => ({\n type: 'EXACT',\n amount,\n});\n\n/**\n * Spend the signer's entire `fromToken` balance, resolved on-chain at execution\n * time.\n *\n * Not supported when `fromToken` is the chain's native sentinel — the server\n * rejects it. A gas coin is sent via `msg.value`, so there is no on-chain\n * balance to sweep; use {@link exact} for native inputs.\n *\n * @param simAmount - A realistic estimate of that balance, in the token's\n * smallest unit. The server quotes and simulates against this value, so it\n * shapes the returned quote and preconditions — but the amount actually moved\n * is whatever the balance turns out to be.\n * @returns The `ALL` member of the route amount union.\n *\n * @example\n * ```ts\n * const result = await sdk.route({\n * chainId: 1,\n * fromToken: USDC,\n * toToken: A_ETH_USDC,\n * amount: routeAmount.all(1_000_000n), // estimate: ~1 USDC on hand\n * signer: OWNER,\n * });\n * ```\n */\nexport const all = (simAmount: bigint | string): RouteAmountAll => ({\n type: 'ALL',\n simAmount,\n});\n"],"mappings":"AA2BO,MAAM,QAAQ,CAAC,YAA+C;AAAA,EACnE,MAAM;AAAA,EACN;AACF;AA2BO,MAAM,MAAM,CAAC,eAAgD;AAAA,EAClE,MAAM;AAAA,EACN;AACF;","names":[]}
1
+ {"version":3,"file":"routeAmount.js","names":[],"sources":["../src/routeAmount.ts"],"sourcesContent":["import type { RouteAmountAll, RouteAmountExact } from '@lifi/compose-spec';\n\n// Constructors for the `amount` member of a `ComposeRouteRequest`. The wire\n// union is discriminated by `type` and — deliberately, because the two variants\n// mean different things — names its payload field differently in each variant:\n// `amount` is the sum actually moved, `simAmount` is only a quoting stand-in for\n// a balance resolved on-chain. These helpers keep call sites from having to\n// remember which name goes with which discriminant.\n\n/**\n * Spend an exact amount of the route's `fromToken`.\n *\n * @param amount - Amount in the token's smallest unit. `bigint` is serialised\n * to a decimal string when the request is sent.\n * @returns The `EXACT` member of the route amount union.\n *\n * @example\n * ```ts\n * const result = await sdk.route({\n * chainId: 1,\n * fromToken: NATIVE_ETH,\n * toToken: WETH,\n * amount: routeAmount.exact(10n ** 17n), // 0.1 ETH, wrapped\n * signer: OWNER,\n * });\n * ```\n */\nexport const exact = (amount: bigint | string): RouteAmountExact => ({\n type: 'EXACT',\n amount,\n});\n\n/**\n * Spend the signer's entire `fromToken` balance, resolved on-chain at execution\n * time.\n *\n * Not supported when `fromToken` is the chain's native sentinel — the server\n * rejects it. A gas coin is sent via `msg.value`, so there is no on-chain\n * balance to sweep; use {@link exact} for native inputs.\n *\n * @param simAmount - A realistic estimate of that balance, in the token's\n * smallest unit. The server quotes and simulates against this value, so it\n * shapes the returned quote and preconditions — but the amount actually moved\n * is whatever the balance turns out to be.\n * @returns The `ALL` member of the route amount union.\n *\n * @example\n * ```ts\n * const result = await sdk.route({\n * chainId: 1,\n * fromToken: USDC,\n * toToken: A_ETH_USDC,\n * amount: routeAmount.all(1_000_000n), // estimate: ~1 USDC on hand\n * signer: OWNER,\n * });\n * ```\n */\nexport const all = (simAmount: bigint | string): RouteAmountAll => ({\n type: 'ALL',\n simAmount,\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AA2BA,MAAa,SAAS,YAA+C;CACnE,MAAM;CACN;AACF;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BA,MAAa,OAAO,eAAgD;CAClE,MAAM;CACN;AACF"}