@lifi/composer-sdk 0.0.1-alpha

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 (160) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +220 -0
  3. package/dist/authoring/FlowBuilderCore.cjs +115 -0
  4. package/dist/authoring/FlowBuilderCore.cjs.map +1 -0
  5. package/dist/authoring/FlowBuilderCore.d.cts +114 -0
  6. package/dist/authoring/FlowBuilderCore.d.ts +114 -0
  7. package/dist/authoring/FlowBuilderCore.js +91 -0
  8. package/dist/authoring/FlowBuilderCore.js.map +1 -0
  9. package/dist/authoring/handles.cjs +43 -0
  10. package/dist/authoring/handles.cjs.map +1 -0
  11. package/dist/authoring/handles.d.cts +61 -0
  12. package/dist/authoring/handles.d.ts +61 -0
  13. package/dist/authoring/handles.js +17 -0
  14. package/dist/authoring/handles.js.map +1 -0
  15. package/dist/authoring/raw.cjs +41 -0
  16. package/dist/authoring/raw.cjs.map +1 -0
  17. package/dist/authoring/raw.d.cts +47 -0
  18. package/dist/authoring/raw.d.ts +47 -0
  19. package/dist/authoring/raw.js +16 -0
  20. package/dist/authoring/raw.js.map +1 -0
  21. package/dist/authoring/signatureArgs.cjs +114 -0
  22. package/dist/authoring/signatureArgs.cjs.map +1 -0
  23. package/dist/authoring/signatureArgs.d.cts +146 -0
  24. package/dist/authoring/signatureArgs.d.ts +146 -0
  25. package/dist/authoring/signatureArgs.js +87 -0
  26. package/dist/authoring/signatureArgs.js.map +1 -0
  27. package/dist/client.cjs +140 -0
  28. package/dist/client.cjs.map +1 -0
  29. package/dist/client.d.cts +67 -0
  30. package/dist/client.d.ts +67 -0
  31. package/dist/client.js +116 -0
  32. package/dist/client.js.map +1 -0
  33. package/dist/discovery.cjs +17 -0
  34. package/dist/discovery.cjs.map +1 -0
  35. package/dist/discovery.d.cts +56 -0
  36. package/dist/discovery.d.ts +56 -0
  37. package/dist/discovery.js +1 -0
  38. package/dist/discovery.js.map +1 -0
  39. package/dist/errors.cjs +91 -0
  40. package/dist/errors.cjs.map +1 -0
  41. package/dist/errors.d.cts +77 -0
  42. package/dist/errors.d.ts +77 -0
  43. package/dist/errors.js +65 -0
  44. package/dist/errors.js.map +1 -0
  45. package/dist/generated/config.generated.cjs +17 -0
  46. package/dist/generated/config.generated.cjs.map +1 -0
  47. package/dist/generated/config.generated.d.cts +144 -0
  48. package/dist/generated/config.generated.d.ts +144 -0
  49. package/dist/generated/config.generated.js +1 -0
  50. package/dist/generated/config.generated.js.map +1 -0
  51. package/dist/generated/guards.generated.cjs +32 -0
  52. package/dist/generated/guards.generated.cjs.map +1 -0
  53. package/dist/generated/guards.generated.d.cts +4 -0
  54. package/dist/generated/guards.generated.d.ts +4 -0
  55. package/dist/generated/guards.generated.js +8 -0
  56. package/dist/generated/guards.generated.js.map +1 -0
  57. package/dist/generated/materialisers.generated.cjs +44 -0
  58. package/dist/generated/materialisers.generated.cjs.map +1 -0
  59. package/dist/generated/materialisers.generated.d.cts +4 -0
  60. package/dist/generated/materialisers.generated.d.ts +4 -0
  61. package/dist/generated/materialisers.generated.js +18 -0
  62. package/dist/generated/materialisers.generated.js.map +1 -0
  63. package/dist/generated/operations.generated.cjs +110 -0
  64. package/dist/generated/operations.generated.cjs.map +1 -0
  65. package/dist/generated/operations.generated.d.cts +337 -0
  66. package/dist/generated/operations.generated.d.ts +337 -0
  67. package/dist/generated/operations.generated.js +89 -0
  68. package/dist/generated/operations.generated.js.map +1 -0
  69. package/dist/generated/preconditions.generated.cjs +44 -0
  70. package/dist/generated/preconditions.generated.cjs.map +1 -0
  71. package/dist/generated/preconditions.generated.d.cts +4 -0
  72. package/dist/generated/preconditions.generated.d.ts +4 -0
  73. package/dist/generated/preconditions.generated.js +18 -0
  74. package/dist/generated/preconditions.generated.js.map +1 -0
  75. package/dist/guards.generated-DKKDKREA.d.ts +14 -0
  76. package/dist/guards.generated-hrQ1KPNv.d.cts +14 -0
  77. package/dist/index.cjs +76 -0
  78. package/dist/index.cjs.map +1 -0
  79. package/dist/index.d.cts +99 -0
  80. package/dist/index.d.ts +99 -0
  81. package/dist/index.js +30 -0
  82. package/dist/index.js.map +1 -0
  83. package/dist/materialisers.generated-BsA1uDW8.d.ts +24 -0
  84. package/dist/materialisers.generated-nMxTAaVi.d.cts +24 -0
  85. package/dist/preconditions.generated-DblS13Wq.d.cts +24 -0
  86. package/dist/preconditions.generated-U7YpVh30.d.ts +24 -0
  87. package/dist/raw-Dj_2rBSQ.d.cts +19 -0
  88. package/dist/raw-IxCF_bSS.d.ts +19 -0
  89. package/dist/raw.cjs +34 -0
  90. package/dist/raw.cjs.map +1 -0
  91. package/dist/raw.d.cts +4 -0
  92. package/dist/raw.d.ts +4 -0
  93. package/dist/raw.js +8 -0
  94. package/dist/raw.js.map +1 -0
  95. package/dist/resources-BKlFxjo8.d.cts +56 -0
  96. package/dist/resources-CYis1_DS.d.ts +56 -0
  97. package/dist/resources.cjs +39 -0
  98. package/dist/resources.cjs.map +1 -0
  99. package/dist/resources.d.cts +3 -0
  100. package/dist/resources.d.ts +3 -0
  101. package/dist/resources.js +14 -0
  102. package/dist/resources.js.map +1 -0
  103. package/dist/run/inputs.cjs +51 -0
  104. package/dist/run/inputs.cjs.map +1 -0
  105. package/dist/run/inputs.d.cts +91 -0
  106. package/dist/run/inputs.d.ts +91 -0
  107. package/dist/run/inputs.js +26 -0
  108. package/dist/run/inputs.js.map +1 -0
  109. package/dist/sdk.cjs +60 -0
  110. package/dist/sdk.cjs.map +1 -0
  111. package/dist/sdk.d.cts +112 -0
  112. package/dist/sdk.d.ts +112 -0
  113. package/dist/sdk.js +40 -0
  114. package/dist/sdk.js.map +1 -0
  115. package/dist/types.cjs +17 -0
  116. package/dist/types.cjs.map +1 -0
  117. package/dist/types.d.cts +74 -0
  118. package/dist/types.d.ts +74 -0
  119. package/dist/types.js +1 -0
  120. package/dist/types.js.map +1 -0
  121. package/package.json +81 -0
  122. package/src/authoring/FlowBuilderCore.ts +270 -0
  123. package/src/authoring/handles.ts +81 -0
  124. package/src/authoring/raw.ts +60 -0
  125. package/src/authoring/signatureArgs.ts +249 -0
  126. package/src/client.ts +230 -0
  127. package/src/discovery.ts +51 -0
  128. package/src/errors.ts +150 -0
  129. package/src/examples/approveAndDeposit.ts +84 -0
  130. package/src/examples/callContract.ts +199 -0
  131. package/src/examples/config.ts +9 -0
  132. package/src/examples/consolidateToEth.ts +94 -0
  133. package/src/examples/consolidateToUsdc.ts +95 -0
  134. package/src/examples/depositFromProxy.ts +87 -0
  135. package/src/examples/dustSweep.ts +66 -0
  136. package/src/examples/lifiSwap.ts +56 -0
  137. package/src/examples/lifiZap.ts +60 -0
  138. package/src/examples/rawCallWithArithmetic.ts +78 -0
  139. package/src/examples/readContractState.ts +77 -0
  140. package/src/examples/run.ts +168 -0
  141. package/src/examples/splitAndZap.ts +73 -0
  142. package/src/examples/splitWithArithmetic.ts +93 -0
  143. package/src/examples/swapAndZap.ts +72 -0
  144. package/src/examples/swapToRecipient.ts +109 -0
  145. package/src/examples/swapWithAllowRevert.ts +119 -0
  146. package/src/examples/swapWithBalanceCheck.ts +73 -0
  147. package/src/examples/swapWithOutputValidation.ts +125 -0
  148. package/src/examples/transferTokens.ts +123 -0
  149. package/src/examples/untypedOpWithTypedRef.ts +77 -0
  150. package/src/generated/config.generated.ts +174 -0
  151. package/src/generated/guards.generated.ts +14 -0
  152. package/src/generated/materialisers.generated.ts +44 -0
  153. package/src/generated/operations.generated.ts +568 -0
  154. package/src/generated/preconditions.generated.ts +43 -0
  155. package/src/index.ts +149 -0
  156. package/src/raw.ts +10 -0
  157. package/src/resources.ts +61 -0
  158. package/src/run/inputs.ts +117 -0
  159. package/src/sdk.ts +173 -0
  160. package/src/types.ts +101 -0
@@ -0,0 +1,91 @@
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 errors_exports = {};
20
+ __export(errors_exports, {
21
+ ComposeError: () => ComposeError,
22
+ errorFromHttpResponse: () => errorFromHttpResponse,
23
+ isComposeError: () => isComposeError
24
+ });
25
+ module.exports = __toCommonJS(errors_exports);
26
+ class ComposeError extends Error {
27
+ name = "ComposeError";
28
+ /** Machine-readable error category. */
29
+ code;
30
+ /** HTTP status code, when the error originated from an HTTP response. */
31
+ status;
32
+ /** The request URL that produced the error. */
33
+ url;
34
+ /** Server-provided error kind for finer-grained classification. */
35
+ kind;
36
+ /** JSON-pointer path to the field that caused a validation error. */
37
+ path;
38
+ /**
39
+ * Simulation revert diagnostics attached to `simulation_revert` errors.
40
+ * Contains the raw error bytes and decoded error candidates when the
41
+ * backend can parse the revert reason.
42
+ */
43
+ details;
44
+ constructor(code, message, options) {
45
+ super(message, { cause: options?.cause });
46
+ this.code = code;
47
+ this.status = options?.status;
48
+ this.url = options?.url;
49
+ this.kind = options?.kind;
50
+ this.path = options?.path;
51
+ this.details = options?.details;
52
+ }
53
+ }
54
+ const isComposeError = (e) => e instanceof ComposeError || e instanceof Error && e.name === "ComposeError" && "code" in e;
55
+ const STATUS_TO_CODE = /* @__PURE__ */ new Map([
56
+ [400, "VALIDATION_ERROR"],
57
+ [401, "UNAUTHENTICATED"],
58
+ [403, "FORBIDDEN"],
59
+ [404, "NOT_FOUND"],
60
+ [422, "VALIDATION_ERROR"],
61
+ [429, "RATE_LIMITED"]
62
+ ]);
63
+ const tryParseErrorBody = (body) => {
64
+ try {
65
+ return JSON.parse(body);
66
+ } catch {
67
+ return null;
68
+ }
69
+ };
70
+ const errorFromHttpResponse = (status, body, url) => {
71
+ const parsed = tryParseErrorBody(body);
72
+ const serverError = parsed?.error;
73
+ return new ComposeError(
74
+ STATUS_TO_CODE.get(status) ?? (status >= 500 ? "SERVER_ERROR" : "UNKNOWN_ERROR"),
75
+ (serverError?.message ?? body) || `HTTP ${status}`,
76
+ {
77
+ status,
78
+ url,
79
+ kind: serverError?.kind,
80
+ path: serverError?.path,
81
+ details: serverError?.details
82
+ }
83
+ );
84
+ };
85
+ // Annotate the CommonJS export names for ESM import in node:
86
+ 0 && (module.exports = {
87
+ ComposeError,
88
+ errorFromHttpResponse,
89
+ isComposeError
90
+ });
91
+ //# sourceMappingURL=errors.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/errors.ts"],"sourcesContent":["import type { ComposeErrorKind, SimulationRevert } from '@lifi/compose-spec';\n\n/**\n * Machine-readable error codes returned by the SDK.\n *\n * - `NETWORK_ERROR` — The HTTP request failed (DNS, timeout, connection refused).\n * - `VALIDATION_ERROR` — The server rejected the request (HTTP 400/422).\n * - `UNAUTHENTICATED` — The request lacks valid authentication credentials (HTTP 401).\n * - `FORBIDDEN` — The server understood the request but refuses to authorise it (HTTP 403).\n * - `SERVER_ERROR` — The server returned a 5xx status.\n * - `RATE_LIMITED` — The server returned HTTP 429.\n * - `NOT_FOUND` — The requested resource does not exist (HTTP 404).\n * - `UNKNOWN_ERROR` — An unexpected error that doesn't fit other categories.\n */\nexport type ComposeErrorCode =\n | 'NETWORK_ERROR'\n | 'VALIDATION_ERROR'\n | 'UNAUTHENTICATED'\n | 'FORBIDDEN'\n | 'SERVER_ERROR'\n | 'RATE_LIMITED'\n | 'NOT_FOUND'\n | 'UNKNOWN_ERROR';\n\n/**\n * Error class for all failures originating from the Compose SDK or API.\n *\n * Includes structured metadata beyond the error message to support\n * programmatic error handling.\n *\n * @example\n * ```ts\n * try {\n * await builder.compile(run);\n * } catch (e) {\n * if (isComposeError(e) && e.code === 'VALIDATION_ERROR') {\n * console.error('Invalid request:', e.message, e.path);\n * }\n * }\n * ```\n */\nexport class ComposeError extends Error {\n override readonly name = 'ComposeError';\n /** Machine-readable error category. */\n readonly code: ComposeErrorCode;\n /** HTTP status code, when the error originated from an HTTP response. */\n readonly status?: number;\n /** The request URL that produced the error. */\n readonly url?: string;\n /** Server-provided error kind for finer-grained classification. */\n readonly kind?: ComposeErrorKind;\n /** JSON-pointer path to the field that caused a validation error. */\n readonly path?: string;\n /**\n * Simulation revert diagnostics attached to `simulation_revert` errors.\n * Contains the raw error bytes and decoded error candidates when the\n * backend can parse the revert reason.\n */\n readonly details?: SimulationRevert;\n\n constructor(\n code: ComposeErrorCode,\n message: string,\n options?: {\n status?: number;\n url?: string;\n cause?: unknown;\n kind?: ComposeErrorKind;\n path?: string;\n details?: SimulationRevert;\n },\n ) {\n super(message, { cause: options?.cause });\n this.code = code;\n this.status = options?.status;\n this.url = options?.url;\n this.kind = options?.kind;\n this.path = options?.path;\n this.details = options?.details;\n }\n}\n\n/**\n * Type guard that narrows an unknown error to {@link ComposeError}.\n * @param e - The value to check.\n * @returns `true` if `e` is an instance of `ComposeError`.\n */\nexport const isComposeError = (e: unknown): e is ComposeError =>\n e instanceof ComposeError ||\n (e instanceof Error && e.name === 'ComposeError' && 'code' in e);\n\nconst STATUS_TO_CODE: ReadonlyMap<number, ComposeErrorCode> = new Map<\n number,\n ComposeErrorCode\n>([\n [400, 'VALIDATION_ERROR'],\n [401, 'UNAUTHENTICATED'],\n [403, 'FORBIDDEN'],\n [404, 'NOT_FOUND'],\n [422, 'VALIDATION_ERROR'],\n [429, 'RATE_LIMITED'],\n]);\n\ninterface ServerErrorBody {\n readonly error?: {\n readonly kind?: string;\n readonly message?: string;\n readonly path?: string;\n readonly details?: SimulationRevert;\n };\n}\n\nconst tryParseErrorBody = (body: string): ServerErrorBody | null => {\n try {\n return JSON.parse(body) as ServerErrorBody;\n } catch {\n return null;\n }\n};\n\n/**\n * Constructs a {@link ComposeError} from an HTTP error response, extracting\n * structured error details from the response body when available.\n *\n * @param status - The HTTP status code.\n * @param body - The raw response body text.\n * @param url - The request URL that produced the error.\n * @returns A `ComposeError` with the appropriate error code and metadata.\n */\nexport const errorFromHttpResponse = (\n status: number,\n body: string,\n url: string,\n): ComposeError => {\n const parsed = tryParseErrorBody(body);\n const serverError = parsed?.error;\n\n return new ComposeError(\n STATUS_TO_CODE.get(status) ??\n (status >= 500 ? 'SERVER_ERROR' : 'UNKNOWN_ERROR'),\n (serverError?.message ?? body) || `HTTP ${status}`,\n {\n status,\n url,\n kind: serverError?.kind as ComposeErrorKind | undefined,\n path: serverError?.path,\n details: serverError?.details,\n },\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAyCO,MAAM,qBAAqB,MAAM;AAAA,EACpB,OAAO;AAAA;AAAA,EAEhB;AAAA;AAAA,EAEA;AAAA;AAAA,EAEA;AAAA;AAAA,EAEA;AAAA;AAAA,EAEA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA;AAAA,EAET,YACE,MACA,SACA,SAQA;AACA,UAAM,SAAS,EAAE,OAAO,SAAS,MAAM,CAAC;AACxC,SAAK,OAAO;AACZ,SAAK,SAAS,SAAS;AACvB,SAAK,MAAM,SAAS;AACpB,SAAK,OAAO,SAAS;AACrB,SAAK,OAAO,SAAS;AACrB,SAAK,UAAU,SAAS;AAAA,EAC1B;AACF;AAOO,MAAM,iBAAiB,CAAC,MAC7B,aAAa,gBACZ,aAAa,SAAS,EAAE,SAAS,kBAAkB,UAAU;AAEhE,MAAM,iBAAwD,oBAAI,IAGhE;AAAA,EACA,CAAC,KAAK,kBAAkB;AAAA,EACxB,CAAC,KAAK,iBAAiB;AAAA,EACvB,CAAC,KAAK,WAAW;AAAA,EACjB,CAAC,KAAK,WAAW;AAAA,EACjB,CAAC,KAAK,kBAAkB;AAAA,EACxB,CAAC,KAAK,cAAc;AACtB,CAAC;AAWD,MAAM,oBAAoB,CAAC,SAAyC;AAClE,MAAI;AACF,WAAO,KAAK,MAAM,IAAI;AAAA,EACxB,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AAWO,MAAM,wBAAwB,CACnC,QACA,MACA,QACiB;AACjB,QAAM,SAAS,kBAAkB,IAAI;AACrC,QAAM,cAAc,QAAQ;AAE5B,SAAO,IAAI;AAAA,IACT,eAAe,IAAI,MAAM,MACtB,UAAU,MAAM,iBAAiB;AAAA,KACnC,aAAa,WAAW,SAAS,QAAQ,MAAM;AAAA,IAChD;AAAA,MACE;AAAA,MACA;AAAA,MACA,MAAM,aAAa;AAAA,MACnB,MAAM,aAAa;AAAA,MACnB,SAAS,aAAa;AAAA,IACxB;AAAA,EACF;AACF;","names":[]}
@@ -0,0 +1,77 @@
1
+ import { ComposeErrorKind, SimulationRevert } from '@lifi/compose-spec';
2
+
3
+ /**
4
+ * Machine-readable error codes returned by the SDK.
5
+ *
6
+ * - `NETWORK_ERROR` — The HTTP request failed (DNS, timeout, connection refused).
7
+ * - `VALIDATION_ERROR` — The server rejected the request (HTTP 400/422).
8
+ * - `UNAUTHENTICATED` — The request lacks valid authentication credentials (HTTP 401).
9
+ * - `FORBIDDEN` — The server understood the request but refuses to authorise it (HTTP 403).
10
+ * - `SERVER_ERROR` — The server returned a 5xx status.
11
+ * - `RATE_LIMITED` — The server returned HTTP 429.
12
+ * - `NOT_FOUND` — The requested resource does not exist (HTTP 404).
13
+ * - `UNKNOWN_ERROR` — An unexpected error that doesn't fit other categories.
14
+ */
15
+ type ComposeErrorCode = 'NETWORK_ERROR' | 'VALIDATION_ERROR' | 'UNAUTHENTICATED' | 'FORBIDDEN' | 'SERVER_ERROR' | 'RATE_LIMITED' | 'NOT_FOUND' | 'UNKNOWN_ERROR';
16
+ /**
17
+ * Error class for all failures originating from the Compose SDK or API.
18
+ *
19
+ * Includes structured metadata beyond the error message to support
20
+ * programmatic error handling.
21
+ *
22
+ * @example
23
+ * ```ts
24
+ * try {
25
+ * await builder.compile(run);
26
+ * } catch (e) {
27
+ * if (isComposeError(e) && e.code === 'VALIDATION_ERROR') {
28
+ * console.error('Invalid request:', e.message, e.path);
29
+ * }
30
+ * }
31
+ * ```
32
+ */
33
+ declare class ComposeError extends Error {
34
+ readonly name = "ComposeError";
35
+ /** Machine-readable error category. */
36
+ readonly code: ComposeErrorCode;
37
+ /** HTTP status code, when the error originated from an HTTP response. */
38
+ readonly status?: number;
39
+ /** The request URL that produced the error. */
40
+ readonly url?: string;
41
+ /** Server-provided error kind for finer-grained classification. */
42
+ readonly kind?: ComposeErrorKind;
43
+ /** JSON-pointer path to the field that caused a validation error. */
44
+ readonly path?: string;
45
+ /**
46
+ * Simulation revert diagnostics attached to `simulation_revert` errors.
47
+ * Contains the raw error bytes and decoded error candidates when the
48
+ * backend can parse the revert reason.
49
+ */
50
+ readonly details?: SimulationRevert;
51
+ constructor(code: ComposeErrorCode, message: string, options?: {
52
+ status?: number;
53
+ url?: string;
54
+ cause?: unknown;
55
+ kind?: ComposeErrorKind;
56
+ path?: string;
57
+ details?: SimulationRevert;
58
+ });
59
+ }
60
+ /**
61
+ * Type guard that narrows an unknown error to {@link ComposeError}.
62
+ * @param e - The value to check.
63
+ * @returns `true` if `e` is an instance of `ComposeError`.
64
+ */
65
+ declare const isComposeError: (e: unknown) => e is ComposeError;
66
+ /**
67
+ * Constructs a {@link ComposeError} from an HTTP error response, extracting
68
+ * structured error details from the response body when available.
69
+ *
70
+ * @param status - The HTTP status code.
71
+ * @param body - The raw response body text.
72
+ * @param url - The request URL that produced the error.
73
+ * @returns A `ComposeError` with the appropriate error code and metadata.
74
+ */
75
+ declare const errorFromHttpResponse: (status: number, body: string, url: string) => ComposeError;
76
+
77
+ export { ComposeError, type ComposeErrorCode, errorFromHttpResponse, isComposeError };
@@ -0,0 +1,77 @@
1
+ import { ComposeErrorKind, SimulationRevert } from '@lifi/compose-spec';
2
+
3
+ /**
4
+ * Machine-readable error codes returned by the SDK.
5
+ *
6
+ * - `NETWORK_ERROR` — The HTTP request failed (DNS, timeout, connection refused).
7
+ * - `VALIDATION_ERROR` — The server rejected the request (HTTP 400/422).
8
+ * - `UNAUTHENTICATED` — The request lacks valid authentication credentials (HTTP 401).
9
+ * - `FORBIDDEN` — The server understood the request but refuses to authorise it (HTTP 403).
10
+ * - `SERVER_ERROR` — The server returned a 5xx status.
11
+ * - `RATE_LIMITED` — The server returned HTTP 429.
12
+ * - `NOT_FOUND` — The requested resource does not exist (HTTP 404).
13
+ * - `UNKNOWN_ERROR` — An unexpected error that doesn't fit other categories.
14
+ */
15
+ type ComposeErrorCode = 'NETWORK_ERROR' | 'VALIDATION_ERROR' | 'UNAUTHENTICATED' | 'FORBIDDEN' | 'SERVER_ERROR' | 'RATE_LIMITED' | 'NOT_FOUND' | 'UNKNOWN_ERROR';
16
+ /**
17
+ * Error class for all failures originating from the Compose SDK or API.
18
+ *
19
+ * Includes structured metadata beyond the error message to support
20
+ * programmatic error handling.
21
+ *
22
+ * @example
23
+ * ```ts
24
+ * try {
25
+ * await builder.compile(run);
26
+ * } catch (e) {
27
+ * if (isComposeError(e) && e.code === 'VALIDATION_ERROR') {
28
+ * console.error('Invalid request:', e.message, e.path);
29
+ * }
30
+ * }
31
+ * ```
32
+ */
33
+ declare class ComposeError extends Error {
34
+ readonly name = "ComposeError";
35
+ /** Machine-readable error category. */
36
+ readonly code: ComposeErrorCode;
37
+ /** HTTP status code, when the error originated from an HTTP response. */
38
+ readonly status?: number;
39
+ /** The request URL that produced the error. */
40
+ readonly url?: string;
41
+ /** Server-provided error kind for finer-grained classification. */
42
+ readonly kind?: ComposeErrorKind;
43
+ /** JSON-pointer path to the field that caused a validation error. */
44
+ readonly path?: string;
45
+ /**
46
+ * Simulation revert diagnostics attached to `simulation_revert` errors.
47
+ * Contains the raw error bytes and decoded error candidates when the
48
+ * backend can parse the revert reason.
49
+ */
50
+ readonly details?: SimulationRevert;
51
+ constructor(code: ComposeErrorCode, message: string, options?: {
52
+ status?: number;
53
+ url?: string;
54
+ cause?: unknown;
55
+ kind?: ComposeErrorKind;
56
+ path?: string;
57
+ details?: SimulationRevert;
58
+ });
59
+ }
60
+ /**
61
+ * Type guard that narrows an unknown error to {@link ComposeError}.
62
+ * @param e - The value to check.
63
+ * @returns `true` if `e` is an instance of `ComposeError`.
64
+ */
65
+ declare const isComposeError: (e: unknown) => e is ComposeError;
66
+ /**
67
+ * Constructs a {@link ComposeError} from an HTTP error response, extracting
68
+ * structured error details from the response body when available.
69
+ *
70
+ * @param status - The HTTP status code.
71
+ * @param body - The raw response body text.
72
+ * @param url - The request URL that produced the error.
73
+ * @returns A `ComposeError` with the appropriate error code and metadata.
74
+ */
75
+ declare const errorFromHttpResponse: (status: number, body: string, url: string) => ComposeError;
76
+
77
+ export { ComposeError, type ComposeErrorCode, errorFromHttpResponse, isComposeError };
package/dist/errors.js ADDED
@@ -0,0 +1,65 @@
1
+ class ComposeError extends Error {
2
+ name = "ComposeError";
3
+ /** Machine-readable error category. */
4
+ code;
5
+ /** HTTP status code, when the error originated from an HTTP response. */
6
+ status;
7
+ /** The request URL that produced the error. */
8
+ url;
9
+ /** Server-provided error kind for finer-grained classification. */
10
+ kind;
11
+ /** JSON-pointer path to the field that caused a validation error. */
12
+ path;
13
+ /**
14
+ * Simulation revert diagnostics attached to `simulation_revert` errors.
15
+ * Contains the raw error bytes and decoded error candidates when the
16
+ * backend can parse the revert reason.
17
+ */
18
+ details;
19
+ constructor(code, message, options) {
20
+ super(message, { cause: options?.cause });
21
+ this.code = code;
22
+ this.status = options?.status;
23
+ this.url = options?.url;
24
+ this.kind = options?.kind;
25
+ this.path = options?.path;
26
+ this.details = options?.details;
27
+ }
28
+ }
29
+ const isComposeError = (e) => e instanceof ComposeError || e instanceof Error && e.name === "ComposeError" && "code" in e;
30
+ const STATUS_TO_CODE = /* @__PURE__ */ new Map([
31
+ [400, "VALIDATION_ERROR"],
32
+ [401, "UNAUTHENTICATED"],
33
+ [403, "FORBIDDEN"],
34
+ [404, "NOT_FOUND"],
35
+ [422, "VALIDATION_ERROR"],
36
+ [429, "RATE_LIMITED"]
37
+ ]);
38
+ const tryParseErrorBody = (body) => {
39
+ try {
40
+ return JSON.parse(body);
41
+ } catch {
42
+ return null;
43
+ }
44
+ };
45
+ const errorFromHttpResponse = (status, body, url) => {
46
+ const parsed = tryParseErrorBody(body);
47
+ const serverError = parsed?.error;
48
+ return new ComposeError(
49
+ STATUS_TO_CODE.get(status) ?? (status >= 500 ? "SERVER_ERROR" : "UNKNOWN_ERROR"),
50
+ (serverError?.message ?? body) || `HTTP ${status}`,
51
+ {
52
+ status,
53
+ url,
54
+ kind: serverError?.kind,
55
+ path: serverError?.path,
56
+ details: serverError?.details
57
+ }
58
+ );
59
+ };
60
+ export {
61
+ ComposeError,
62
+ errorFromHttpResponse,
63
+ isComposeError
64
+ };
65
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/errors.ts"],"sourcesContent":["import type { ComposeErrorKind, SimulationRevert } from '@lifi/compose-spec';\n\n/**\n * Machine-readable error codes returned by the SDK.\n *\n * - `NETWORK_ERROR` — The HTTP request failed (DNS, timeout, connection refused).\n * - `VALIDATION_ERROR` — The server rejected the request (HTTP 400/422).\n * - `UNAUTHENTICATED` — The request lacks valid authentication credentials (HTTP 401).\n * - `FORBIDDEN` — The server understood the request but refuses to authorise it (HTTP 403).\n * - `SERVER_ERROR` — The server returned a 5xx status.\n * - `RATE_LIMITED` — The server returned HTTP 429.\n * - `NOT_FOUND` — The requested resource does not exist (HTTP 404).\n * - `UNKNOWN_ERROR` — An unexpected error that doesn't fit other categories.\n */\nexport type ComposeErrorCode =\n | 'NETWORK_ERROR'\n | 'VALIDATION_ERROR'\n | 'UNAUTHENTICATED'\n | 'FORBIDDEN'\n | 'SERVER_ERROR'\n | 'RATE_LIMITED'\n | 'NOT_FOUND'\n | 'UNKNOWN_ERROR';\n\n/**\n * Error class for all failures originating from the Compose SDK or API.\n *\n * Includes structured metadata beyond the error message to support\n * programmatic error handling.\n *\n * @example\n * ```ts\n * try {\n * await builder.compile(run);\n * } catch (e) {\n * if (isComposeError(e) && e.code === 'VALIDATION_ERROR') {\n * console.error('Invalid request:', e.message, e.path);\n * }\n * }\n * ```\n */\nexport class ComposeError extends Error {\n override readonly name = 'ComposeError';\n /** Machine-readable error category. */\n readonly code: ComposeErrorCode;\n /** HTTP status code, when the error originated from an HTTP response. */\n readonly status?: number;\n /** The request URL that produced the error. */\n readonly url?: string;\n /** Server-provided error kind for finer-grained classification. */\n readonly kind?: ComposeErrorKind;\n /** JSON-pointer path to the field that caused a validation error. */\n readonly path?: string;\n /**\n * Simulation revert diagnostics attached to `simulation_revert` errors.\n * Contains the raw error bytes and decoded error candidates when the\n * backend can parse the revert reason.\n */\n readonly details?: SimulationRevert;\n\n constructor(\n code: ComposeErrorCode,\n message: string,\n options?: {\n status?: number;\n url?: string;\n cause?: unknown;\n kind?: ComposeErrorKind;\n path?: string;\n details?: SimulationRevert;\n },\n ) {\n super(message, { cause: options?.cause });\n this.code = code;\n this.status = options?.status;\n this.url = options?.url;\n this.kind = options?.kind;\n this.path = options?.path;\n this.details = options?.details;\n }\n}\n\n/**\n * Type guard that narrows an unknown error to {@link ComposeError}.\n * @param e - The value to check.\n * @returns `true` if `e` is an instance of `ComposeError`.\n */\nexport const isComposeError = (e: unknown): e is ComposeError =>\n e instanceof ComposeError ||\n (e instanceof Error && e.name === 'ComposeError' && 'code' in e);\n\nconst STATUS_TO_CODE: ReadonlyMap<number, ComposeErrorCode> = new Map<\n number,\n ComposeErrorCode\n>([\n [400, 'VALIDATION_ERROR'],\n [401, 'UNAUTHENTICATED'],\n [403, 'FORBIDDEN'],\n [404, 'NOT_FOUND'],\n [422, 'VALIDATION_ERROR'],\n [429, 'RATE_LIMITED'],\n]);\n\ninterface ServerErrorBody {\n readonly error?: {\n readonly kind?: string;\n readonly message?: string;\n readonly path?: string;\n readonly details?: SimulationRevert;\n };\n}\n\nconst tryParseErrorBody = (body: string): ServerErrorBody | null => {\n try {\n return JSON.parse(body) as ServerErrorBody;\n } catch {\n return null;\n }\n};\n\n/**\n * Constructs a {@link ComposeError} from an HTTP error response, extracting\n * structured error details from the response body when available.\n *\n * @param status - The HTTP status code.\n * @param body - The raw response body text.\n * @param url - The request URL that produced the error.\n * @returns A `ComposeError` with the appropriate error code and metadata.\n */\nexport const errorFromHttpResponse = (\n status: number,\n body: string,\n url: string,\n): ComposeError => {\n const parsed = tryParseErrorBody(body);\n const serverError = parsed?.error;\n\n return new ComposeError(\n STATUS_TO_CODE.get(status) ??\n (status >= 500 ? 'SERVER_ERROR' : 'UNKNOWN_ERROR'),\n (serverError?.message ?? body) || `HTTP ${status}`,\n {\n status,\n url,\n kind: serverError?.kind as ComposeErrorKind | undefined,\n path: serverError?.path,\n details: serverError?.details,\n },\n );\n};\n"],"mappings":"AAyCO,MAAM,qBAAqB,MAAM;AAAA,EACpB,OAAO;AAAA;AAAA,EAEhB;AAAA;AAAA,EAEA;AAAA;AAAA,EAEA;AAAA;AAAA,EAEA;AAAA;AAAA,EAEA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA;AAAA,EAET,YACE,MACA,SACA,SAQA;AACA,UAAM,SAAS,EAAE,OAAO,SAAS,MAAM,CAAC;AACxC,SAAK,OAAO;AACZ,SAAK,SAAS,SAAS;AACvB,SAAK,MAAM,SAAS;AACpB,SAAK,OAAO,SAAS;AACrB,SAAK,OAAO,SAAS;AACrB,SAAK,UAAU,SAAS;AAAA,EAC1B;AACF;AAOO,MAAM,iBAAiB,CAAC,MAC7B,aAAa,gBACZ,aAAa,SAAS,EAAE,SAAS,kBAAkB,UAAU;AAEhE,MAAM,iBAAwD,oBAAI,IAGhE;AAAA,EACA,CAAC,KAAK,kBAAkB;AAAA,EACxB,CAAC,KAAK,iBAAiB;AAAA,EACvB,CAAC,KAAK,WAAW;AAAA,EACjB,CAAC,KAAK,WAAW;AAAA,EACjB,CAAC,KAAK,kBAAkB;AAAA,EACxB,CAAC,KAAK,cAAc;AACtB,CAAC;AAWD,MAAM,oBAAoB,CAAC,SAAyC;AAClE,MAAI;AACF,WAAO,KAAK,MAAM,IAAI;AAAA,EACxB,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AAWO,MAAM,wBAAwB,CACnC,QACA,MACA,QACiB;AACjB,QAAM,SAAS,kBAAkB,IAAI;AACrC,QAAM,cAAc,QAAQ;AAE5B,SAAO,IAAI;AAAA,IACT,eAAe,IAAI,MAAM,MACtB,UAAU,MAAM,iBAAiB;AAAA,KACnC,aAAa,WAAW,SAAS,QAAQ,MAAM;AAAA,IAChD;AAAA,MACE;AAAA,MACA;AAAA,MACA,MAAM,aAAa;AAAA,MACnB,MAAM,aAAa;AAAA,MACnB,SAAS,aAAa;AAAA,IACxB;AAAA,EACF;AACF;","names":[]}
@@ -0,0 +1,17 @@
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 __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
+ var config_generated_exports = {};
16
+ module.exports = __toCommonJS(config_generated_exports);
17
+ //# sourceMappingURL=config.generated.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/generated/config.generated.ts"],"sourcesContent":["// AUTO-GENERATED from manifest.json — do not edit by hand.\n// Regenerate with: yarn workspace @lifi/composer-sdk generate\n\nimport type { Address, IntegerStringInput } from '../types.js';\n\nexport interface CoreSplitConfig {\n bps: number;\n}\n\n/**\n * a positive number\n */\nexport type Positive = number;\n\nexport interface LifiSwapConfig {\n resourceOut:\n | {\n kind: 'native';\n chainId: Positive;\n }\n | {\n kind: 'erc20';\n token: Address;\n chainId: Positive;\n };\n slippage?: number;\n timing?: {\n swapStepTimingStrategies?: {\n strategy: 'minWaitTime';\n minWaitTimeMs: number;\n startingExpectedResults: number;\n reduceEveryMs: number;\n }[];\n routeTimingStrategies?: {\n strategy: 'minWaitTime';\n minWaitTimeMs: number;\n startingExpectedResults: number;\n reduceEveryMs: number;\n }[];\n };\n}\n\nexport interface LifiZapConfig {\n resourceOut:\n | {\n kind: 'native';\n chainId: Positive;\n }\n | {\n kind: 'erc20';\n token: Address;\n chainId: Positive;\n };\n}\n\nexport interface CoreBpsDownConfig {\n bps: number;\n}\n\nexport interface CoreBpsUpConfig {\n bps: number;\n}\n\nexport interface CoreApproveConfig {\n spender: Address;\n}\n\nexport interface CoreBalanceOfConfig {\n token: Address;\n owner?: Address;\n}\n\nexport interface CoreTransferConfig {\n amount?: IntegerStringInput;\n}\n\nexport interface CoreCallConfig {\n target: Address;\n functionSignature: string;\n callType?: 'Call' | 'ValueCall';\n args?: Unknown[];\n approvals?: {\n spender: Address;\n }[];\n}\nexport interface Unknown {\n [k: string]: unknown;\n}\n\nexport interface CoreStaticCallConfig {\n target: Address;\n functionSignature: string;\n args?: Unknown[];\n}\n\nexport interface CoreRawCallConfig {\n target: Address;\n calldata: string;\n callType?: 'Call' | 'StaticCall' | 'ValueCall' | 'DelegateCall';\n resultType?: string;\n}\n\nexport interface CoreInvokeConfig {\n target: Address;\n functionSignature: string;\n callType?: 'Call' | 'ValueCall';\n args?: Unknown[];\n}\n\nexport interface CoreAsResourceConfig {\n resource:\n | {\n kind: 'native';\n chainId: Positive;\n }\n | {\n kind: 'erc20';\n token: Address;\n chainId: Positive;\n };\n}\n\nexport interface CorePeekConfig {\n target: Address;\n functionSignature: string;\n args?: string[];\n}\n\n/**\n * a number between 0 and 10000\n */\nexport type Between010000 = number;\n\nexport interface SlippageGuardConfig {\n port: string;\n bps: Between010000;\n}\n\nexport interface BalanceOfMaterialiserConfig {\n owner: Address;\n}\n\nexport type DirectDepositMaterialiserConfig =\n | {\n amount: IntegerStringInput;\n allowNonExact?: false;\n }\n | {\n amount?: IntegerStringInput;\n allowNonExact: true;\n };\n\nexport interface CallMaterialiserConfig {\n target: Address;\n calldata: string;\n}\n\nexport interface Erc20BalancePreconditionConfig {\n wallet: Address;\n token: Address;\n balance: IntegerStringInput;\n}\n\nexport interface NativeBalancePreconditionConfig {\n wallet: Address;\n balance: IntegerStringInput;\n}\n\nexport interface Erc20AllowancePreconditionConfig {\n owner: Address;\n spender: Address;\n token: Address;\n allowance: IntegerStringInput;\n}\n"],"mappings":";;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
@@ -0,0 +1,144 @@
1
+ import { Address, IntegerStringInput } from '../types.cjs';
2
+ import '@lifi/compose-spec';
3
+
4
+ interface CoreSplitConfig {
5
+ bps: number;
6
+ }
7
+ /**
8
+ * a positive number
9
+ */
10
+ type Positive = number;
11
+ interface LifiSwapConfig {
12
+ resourceOut: {
13
+ kind: 'native';
14
+ chainId: Positive;
15
+ } | {
16
+ kind: 'erc20';
17
+ token: Address;
18
+ chainId: Positive;
19
+ };
20
+ slippage?: number;
21
+ timing?: {
22
+ swapStepTimingStrategies?: {
23
+ strategy: 'minWaitTime';
24
+ minWaitTimeMs: number;
25
+ startingExpectedResults: number;
26
+ reduceEveryMs: number;
27
+ }[];
28
+ routeTimingStrategies?: {
29
+ strategy: 'minWaitTime';
30
+ minWaitTimeMs: number;
31
+ startingExpectedResults: number;
32
+ reduceEveryMs: number;
33
+ }[];
34
+ };
35
+ }
36
+ interface LifiZapConfig {
37
+ resourceOut: {
38
+ kind: 'native';
39
+ chainId: Positive;
40
+ } | {
41
+ kind: 'erc20';
42
+ token: Address;
43
+ chainId: Positive;
44
+ };
45
+ }
46
+ interface CoreBpsDownConfig {
47
+ bps: number;
48
+ }
49
+ interface CoreBpsUpConfig {
50
+ bps: number;
51
+ }
52
+ interface CoreApproveConfig {
53
+ spender: Address;
54
+ }
55
+ interface CoreBalanceOfConfig {
56
+ token: Address;
57
+ owner?: Address;
58
+ }
59
+ interface CoreTransferConfig {
60
+ amount?: IntegerStringInput;
61
+ }
62
+ interface CoreCallConfig {
63
+ target: Address;
64
+ functionSignature: string;
65
+ callType?: 'Call' | 'ValueCall';
66
+ args?: Unknown[];
67
+ approvals?: {
68
+ spender: Address;
69
+ }[];
70
+ }
71
+ interface Unknown {
72
+ [k: string]: unknown;
73
+ }
74
+ interface CoreStaticCallConfig {
75
+ target: Address;
76
+ functionSignature: string;
77
+ args?: Unknown[];
78
+ }
79
+ interface CoreRawCallConfig {
80
+ target: Address;
81
+ calldata: string;
82
+ callType?: 'Call' | 'StaticCall' | 'ValueCall' | 'DelegateCall';
83
+ resultType?: string;
84
+ }
85
+ interface CoreInvokeConfig {
86
+ target: Address;
87
+ functionSignature: string;
88
+ callType?: 'Call' | 'ValueCall';
89
+ args?: Unknown[];
90
+ }
91
+ interface CoreAsResourceConfig {
92
+ resource: {
93
+ kind: 'native';
94
+ chainId: Positive;
95
+ } | {
96
+ kind: 'erc20';
97
+ token: Address;
98
+ chainId: Positive;
99
+ };
100
+ }
101
+ interface CorePeekConfig {
102
+ target: Address;
103
+ functionSignature: string;
104
+ args?: string[];
105
+ }
106
+ /**
107
+ * a number between 0 and 10000
108
+ */
109
+ type Between010000 = number;
110
+ interface SlippageGuardConfig {
111
+ port: string;
112
+ bps: Between010000;
113
+ }
114
+ interface BalanceOfMaterialiserConfig {
115
+ owner: Address;
116
+ }
117
+ type DirectDepositMaterialiserConfig = {
118
+ amount: IntegerStringInput;
119
+ allowNonExact?: false;
120
+ } | {
121
+ amount?: IntegerStringInput;
122
+ allowNonExact: true;
123
+ };
124
+ interface CallMaterialiserConfig {
125
+ target: Address;
126
+ calldata: string;
127
+ }
128
+ interface Erc20BalancePreconditionConfig {
129
+ wallet: Address;
130
+ token: Address;
131
+ balance: IntegerStringInput;
132
+ }
133
+ interface NativeBalancePreconditionConfig {
134
+ wallet: Address;
135
+ balance: IntegerStringInput;
136
+ }
137
+ interface Erc20AllowancePreconditionConfig {
138
+ owner: Address;
139
+ spender: Address;
140
+ token: Address;
141
+ allowance: IntegerStringInput;
142
+ }
143
+
144
+ export type { BalanceOfMaterialiserConfig, Between010000, CallMaterialiserConfig, CoreApproveConfig, CoreAsResourceConfig, CoreBalanceOfConfig, CoreBpsDownConfig, CoreBpsUpConfig, CoreCallConfig, CoreInvokeConfig, CorePeekConfig, CoreRawCallConfig, CoreSplitConfig, CoreStaticCallConfig, CoreTransferConfig, DirectDepositMaterialiserConfig, Erc20AllowancePreconditionConfig, Erc20BalancePreconditionConfig, LifiSwapConfig, LifiZapConfig, NativeBalancePreconditionConfig, Positive, SlippageGuardConfig, Unknown };
@@ -0,0 +1,144 @@
1
+ import { Address, IntegerStringInput } from '../types.js';
2
+ import '@lifi/compose-spec';
3
+
4
+ interface CoreSplitConfig {
5
+ bps: number;
6
+ }
7
+ /**
8
+ * a positive number
9
+ */
10
+ type Positive = number;
11
+ interface LifiSwapConfig {
12
+ resourceOut: {
13
+ kind: 'native';
14
+ chainId: Positive;
15
+ } | {
16
+ kind: 'erc20';
17
+ token: Address;
18
+ chainId: Positive;
19
+ };
20
+ slippage?: number;
21
+ timing?: {
22
+ swapStepTimingStrategies?: {
23
+ strategy: 'minWaitTime';
24
+ minWaitTimeMs: number;
25
+ startingExpectedResults: number;
26
+ reduceEveryMs: number;
27
+ }[];
28
+ routeTimingStrategies?: {
29
+ strategy: 'minWaitTime';
30
+ minWaitTimeMs: number;
31
+ startingExpectedResults: number;
32
+ reduceEveryMs: number;
33
+ }[];
34
+ };
35
+ }
36
+ interface LifiZapConfig {
37
+ resourceOut: {
38
+ kind: 'native';
39
+ chainId: Positive;
40
+ } | {
41
+ kind: 'erc20';
42
+ token: Address;
43
+ chainId: Positive;
44
+ };
45
+ }
46
+ interface CoreBpsDownConfig {
47
+ bps: number;
48
+ }
49
+ interface CoreBpsUpConfig {
50
+ bps: number;
51
+ }
52
+ interface CoreApproveConfig {
53
+ spender: Address;
54
+ }
55
+ interface CoreBalanceOfConfig {
56
+ token: Address;
57
+ owner?: Address;
58
+ }
59
+ interface CoreTransferConfig {
60
+ amount?: IntegerStringInput;
61
+ }
62
+ interface CoreCallConfig {
63
+ target: Address;
64
+ functionSignature: string;
65
+ callType?: 'Call' | 'ValueCall';
66
+ args?: Unknown[];
67
+ approvals?: {
68
+ spender: Address;
69
+ }[];
70
+ }
71
+ interface Unknown {
72
+ [k: string]: unknown;
73
+ }
74
+ interface CoreStaticCallConfig {
75
+ target: Address;
76
+ functionSignature: string;
77
+ args?: Unknown[];
78
+ }
79
+ interface CoreRawCallConfig {
80
+ target: Address;
81
+ calldata: string;
82
+ callType?: 'Call' | 'StaticCall' | 'ValueCall' | 'DelegateCall';
83
+ resultType?: string;
84
+ }
85
+ interface CoreInvokeConfig {
86
+ target: Address;
87
+ functionSignature: string;
88
+ callType?: 'Call' | 'ValueCall';
89
+ args?: Unknown[];
90
+ }
91
+ interface CoreAsResourceConfig {
92
+ resource: {
93
+ kind: 'native';
94
+ chainId: Positive;
95
+ } | {
96
+ kind: 'erc20';
97
+ token: Address;
98
+ chainId: Positive;
99
+ };
100
+ }
101
+ interface CorePeekConfig {
102
+ target: Address;
103
+ functionSignature: string;
104
+ args?: string[];
105
+ }
106
+ /**
107
+ * a number between 0 and 10000
108
+ */
109
+ type Between010000 = number;
110
+ interface SlippageGuardConfig {
111
+ port: string;
112
+ bps: Between010000;
113
+ }
114
+ interface BalanceOfMaterialiserConfig {
115
+ owner: Address;
116
+ }
117
+ type DirectDepositMaterialiserConfig = {
118
+ amount: IntegerStringInput;
119
+ allowNonExact?: false;
120
+ } | {
121
+ amount?: IntegerStringInput;
122
+ allowNonExact: true;
123
+ };
124
+ interface CallMaterialiserConfig {
125
+ target: Address;
126
+ calldata: string;
127
+ }
128
+ interface Erc20BalancePreconditionConfig {
129
+ wallet: Address;
130
+ token: Address;
131
+ balance: IntegerStringInput;
132
+ }
133
+ interface NativeBalancePreconditionConfig {
134
+ wallet: Address;
135
+ balance: IntegerStringInput;
136
+ }
137
+ interface Erc20AllowancePreconditionConfig {
138
+ owner: Address;
139
+ spender: Address;
140
+ token: Address;
141
+ allowance: IntegerStringInput;
142
+ }
143
+
144
+ export type { BalanceOfMaterialiserConfig, Between010000, CallMaterialiserConfig, CoreApproveConfig, CoreAsResourceConfig, CoreBalanceOfConfig, CoreBpsDownConfig, CoreBpsUpConfig, CoreCallConfig, CoreInvokeConfig, CorePeekConfig, CoreRawCallConfig, CoreSplitConfig, CoreStaticCallConfig, CoreTransferConfig, DirectDepositMaterialiserConfig, Erc20AllowancePreconditionConfig, Erc20BalancePreconditionConfig, LifiSwapConfig, LifiZapConfig, NativeBalancePreconditionConfig, Positive, SlippageGuardConfig, Unknown };
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=config.generated.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}