@lifi/sdk 4.9.0 → 4.11.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 (185) hide show
  1. package/CHANGELOG.md +50 -0
  2. package/README.md +9 -0
  3. package/dist/cjs/client/createClient.js +6 -4
  4. package/dist/cjs/client/createClient.js.map +1 -1
  5. package/dist/cjs/client/findProvider.d.ts +10 -0
  6. package/dist/cjs/client/findProvider.js +11 -0
  7. package/dist/cjs/client/findProvider.js.map +1 -0
  8. package/dist/cjs/core/BaseStepExecutor.d.ts +1 -1
  9. package/dist/cjs/core/BaseStepExecutor.js +21 -9
  10. package/dist/cjs/core/BaseStepExecutor.js.map +1 -1
  11. package/dist/cjs/core/StatusManager.d.ts +10 -0
  12. package/dist/cjs/core/StatusManager.js +105 -3
  13. package/dist/cjs/core/StatusManager.js.map +1 -1
  14. package/dist/cjs/core/execution.js +30 -14
  15. package/dist/cjs/core/execution.js.map +1 -1
  16. package/dist/cjs/core/executionState.d.ts +34 -2
  17. package/dist/cjs/core/executionState.js +44 -1
  18. package/dist/cjs/core/executionState.js.map +1 -1
  19. package/dist/cjs/core/prepareRestart.js +14 -6
  20. package/dist/cjs/core/prepareRestart.js.map +1 -1
  21. package/dist/cjs/core/tasks/WaitForTransactionStatusTask.js +4 -2
  22. package/dist/cjs/core/tasks/WaitForTransactionStatusTask.js.map +1 -1
  23. package/dist/cjs/core/tasks/helpers/checkBalance.js +6 -3
  24. package/dist/cjs/core/tasks/helpers/checkBalance.js.map +1 -1
  25. package/dist/cjs/core/tasks/helpers/getStepStatusRequest.d.ts +10 -0
  26. package/dist/cjs/core/tasks/helpers/getStepStatusRequest.js +20 -0
  27. package/dist/cjs/core/tasks/helpers/getStepStatusRequest.js.map +1 -0
  28. package/dist/cjs/core/tasks/helpers/isKnownToStatusApi.d.ts +21 -0
  29. package/dist/cjs/core/tasks/helpers/isKnownToStatusApi.js +44 -0
  30. package/dist/cjs/core/tasks/helpers/isKnownToStatusApi.js.map +1 -0
  31. package/dist/cjs/core/tasks/helpers/waitForTransactionStatus.d.ts +22 -1
  32. package/dist/cjs/core/tasks/helpers/waitForTransactionStatus.js +76 -17
  33. package/dist/cjs/core/tasks/helpers/waitForTransactionStatus.js.map +1 -1
  34. package/dist/cjs/core/transactionState.d.ts +121 -0
  35. package/dist/cjs/core/transactionState.js +164 -0
  36. package/dist/cjs/core/transactionState.js.map +1 -0
  37. package/dist/cjs/errors/errors.d.ts +13 -2
  38. package/dist/cjs/errors/errors.js +5 -2
  39. package/dist/cjs/errors/errors.js.map +1 -1
  40. package/dist/cjs/index.d.ts +7 -3
  41. package/dist/cjs/index.js +16 -1
  42. package/dist/cjs/types/core.d.ts +49 -3
  43. package/dist/cjs/types/execution.d.ts +8 -0
  44. package/dist/cjs/utils/abort.d.ts +6 -0
  45. package/dist/cjs/utils/abort.js +10 -0
  46. package/dist/cjs/utils/abort.js.map +1 -0
  47. package/dist/cjs/utils/checkPackageUpdates.js +1 -1
  48. package/dist/cjs/utils/formatUnits.js +1 -0
  49. package/dist/cjs/utils/formatUnits.js.map +1 -1
  50. package/dist/cjs/utils/lru.d.ts +14 -0
  51. package/dist/cjs/utils/lru.js +35 -0
  52. package/dist/cjs/utils/lru.js.map +1 -0
  53. package/dist/cjs/utils/parseUnits.js +30 -16
  54. package/dist/cjs/utils/parseUnits.js.map +1 -1
  55. package/dist/cjs/utils/sleep.d.ts +7 -1
  56. package/dist/cjs/utils/sleep.js +22 -3
  57. package/dist/cjs/utils/sleep.js.map +1 -1
  58. package/dist/cjs/utils/waitForResult.d.ts +7 -5
  59. package/dist/cjs/utils/waitForResult.js +19 -14
  60. package/dist/cjs/utils/waitForResult.js.map +1 -1
  61. package/dist/cjs/utils/withDedupe.d.ts +0 -10
  62. package/dist/cjs/utils/withDedupe.js +4 -23
  63. package/dist/cjs/utils/withDedupe.js.map +1 -1
  64. package/dist/cjs/utils/withTimeout.js +6 -2
  65. package/dist/cjs/utils/withTimeout.js.map +1 -1
  66. package/dist/cjs/version.d.ts +1 -1
  67. package/dist/cjs/version.js +1 -1
  68. package/dist/cjs/version.js.map +1 -1
  69. package/dist/esm/actions/getRoutes.d.ts.map +1 -1
  70. package/dist/esm/actions/index.d.ts.map +1 -1
  71. package/dist/esm/client/createClient.d.ts.map +1 -1
  72. package/dist/esm/client/createClient.js +6 -4
  73. package/dist/esm/client/createClient.js.map +1 -1
  74. package/dist/esm/client/findProvider.d.ts +10 -0
  75. package/dist/esm/client/findProvider.d.ts.map +1 -0
  76. package/dist/esm/client/findProvider.js +10 -0
  77. package/dist/esm/client/findProvider.js.map +1 -0
  78. package/dist/esm/core/BaseStepExecutor.d.ts +1 -1
  79. package/dist/esm/core/BaseStepExecutor.d.ts.map +1 -1
  80. package/dist/esm/core/BaseStepExecutor.js +22 -10
  81. package/dist/esm/core/BaseStepExecutor.js.map +1 -1
  82. package/dist/esm/core/StatusManager.d.ts +10 -0
  83. package/dist/esm/core/StatusManager.d.ts.map +1 -1
  84. package/dist/esm/core/StatusManager.js +105 -3
  85. package/dist/esm/core/StatusManager.js.map +1 -1
  86. package/dist/esm/core/execution.d.ts.map +1 -1
  87. package/dist/esm/core/execution.js +30 -14
  88. package/dist/esm/core/execution.js.map +1 -1
  89. package/dist/esm/core/executionState.d.ts +34 -2
  90. package/dist/esm/core/executionState.d.ts.map +1 -1
  91. package/dist/esm/core/executionState.js +44 -1
  92. package/dist/esm/core/executionState.js.map +1 -1
  93. package/dist/esm/core/prepareRestart.d.ts.map +1 -1
  94. package/dist/esm/core/prepareRestart.js +14 -6
  95. package/dist/esm/core/prepareRestart.js.map +1 -1
  96. package/dist/esm/core/tasks/WaitForTransactionStatusTask.d.ts.map +1 -1
  97. package/dist/esm/core/tasks/WaitForTransactionStatusTask.js +4 -2
  98. package/dist/esm/core/tasks/WaitForTransactionStatusTask.js.map +1 -1
  99. package/dist/esm/core/tasks/helpers/checkBalance.js +6 -3
  100. package/dist/esm/core/tasks/helpers/checkBalance.js.map +1 -1
  101. package/dist/esm/core/tasks/helpers/getStepStatusRequest.d.ts +10 -0
  102. package/dist/esm/core/tasks/helpers/getStepStatusRequest.d.ts.map +1 -0
  103. package/dist/esm/core/tasks/helpers/getStepStatusRequest.js +19 -0
  104. package/dist/esm/core/tasks/helpers/getStepStatusRequest.js.map +1 -0
  105. package/dist/esm/core/tasks/helpers/isKnownToStatusApi.d.ts +21 -0
  106. package/dist/esm/core/tasks/helpers/isKnownToStatusApi.d.ts.map +1 -0
  107. package/dist/esm/core/tasks/helpers/isKnownToStatusApi.js +43 -0
  108. package/dist/esm/core/tasks/helpers/isKnownToStatusApi.js.map +1 -0
  109. package/dist/esm/core/tasks/helpers/waitForTransactionStatus.d.ts +22 -1
  110. package/dist/esm/core/tasks/helpers/waitForTransactionStatus.d.ts.map +1 -1
  111. package/dist/esm/core/tasks/helpers/waitForTransactionStatus.js +76 -18
  112. package/dist/esm/core/tasks/helpers/waitForTransactionStatus.js.map +1 -1
  113. package/dist/esm/core/transactionState.d.ts +121 -0
  114. package/dist/esm/core/transactionState.d.ts.map +1 -0
  115. package/dist/esm/core/transactionState.js +152 -0
  116. package/dist/esm/core/transactionState.js.map +1 -0
  117. package/dist/esm/errors/errors.d.ts +13 -2
  118. package/dist/esm/errors/errors.d.ts.map +1 -1
  119. package/dist/esm/errors/errors.js +5 -2
  120. package/dist/esm/errors/errors.js.map +1 -1
  121. package/dist/esm/index.d.ts +7 -3
  122. package/dist/esm/index.js +6 -2
  123. package/dist/esm/types/actions.d.ts.map +1 -1
  124. package/dist/esm/types/core.d.ts +49 -3
  125. package/dist/esm/types/core.d.ts.map +1 -1
  126. package/dist/esm/types/execution.d.ts +8 -0
  127. package/dist/esm/types/execution.d.ts.map +1 -1
  128. package/dist/esm/utils/abort.d.ts +6 -0
  129. package/dist/esm/utils/abort.d.ts.map +1 -0
  130. package/dist/esm/utils/abort.js +8 -0
  131. package/dist/esm/utils/abort.js.map +1 -0
  132. package/dist/esm/utils/checkPackageUpdates.js +1 -1
  133. package/dist/esm/utils/formatUnits.js +1 -0
  134. package/dist/esm/utils/formatUnits.js.map +1 -1
  135. package/dist/esm/utils/lru.d.ts +14 -0
  136. package/dist/esm/utils/lru.d.ts.map +1 -0
  137. package/dist/esm/utils/lru.js +34 -0
  138. package/dist/esm/utils/lru.js.map +1 -0
  139. package/dist/esm/utils/parseUnits.js +30 -16
  140. package/dist/esm/utils/parseUnits.js.map +1 -1
  141. package/dist/esm/utils/sleep.d.ts +7 -1
  142. package/dist/esm/utils/sleep.d.ts.map +1 -1
  143. package/dist/esm/utils/sleep.js +22 -3
  144. package/dist/esm/utils/sleep.js.map +1 -1
  145. package/dist/esm/utils/waitForResult.d.ts +7 -5
  146. package/dist/esm/utils/waitForResult.d.ts.map +1 -1
  147. package/dist/esm/utils/waitForResult.js +19 -14
  148. package/dist/esm/utils/waitForResult.js.map +1 -1
  149. package/dist/esm/utils/withDedupe.d.ts +0 -10
  150. package/dist/esm/utils/withDedupe.d.ts.map +1 -1
  151. package/dist/esm/utils/withDedupe.js +5 -22
  152. package/dist/esm/utils/withDedupe.js.map +1 -1
  153. package/dist/esm/utils/withTimeout.d.ts.map +1 -1
  154. package/dist/esm/utils/withTimeout.js +6 -2
  155. package/dist/esm/utils/withTimeout.js.map +1 -1
  156. package/dist/esm/version.d.ts +1 -1
  157. package/dist/esm/version.js +1 -1
  158. package/dist/esm/version.js.map +1 -1
  159. package/package.json +2 -2
  160. package/src/client/createClient.ts +12 -4
  161. package/src/client/findProvider.ts +21 -0
  162. package/src/core/BaseStepExecutor.ts +40 -6
  163. package/src/core/StatusManager.ts +211 -2
  164. package/src/core/execution.ts +69 -20
  165. package/src/core/executionState.ts +84 -1
  166. package/src/core/prepareRestart.ts +29 -13
  167. package/src/core/tasks/WaitForTransactionStatusTask.ts +10 -1
  168. package/src/core/tasks/helpers/checkBalance.ts +11 -3
  169. package/src/core/tasks/helpers/getStepStatusRequest.ts +20 -0
  170. package/src/core/tasks/helpers/isKnownToStatusApi.ts +57 -0
  171. package/src/core/tasks/helpers/waitForTransactionStatus.ts +128 -17
  172. package/src/core/transactionState.ts +194 -0
  173. package/src/errors/errors.ts +21 -2
  174. package/src/index.ts +16 -1
  175. package/src/types/core.ts +50 -3
  176. package/src/types/execution.ts +8 -0
  177. package/src/utils/abort.ts +10 -0
  178. package/src/utils/formatUnits.ts +6 -0
  179. package/src/utils/lru.ts +38 -0
  180. package/src/utils/parseUnits.ts +53 -20
  181. package/src/utils/sleep.ts +27 -3
  182. package/src/utils/waitForResult.ts +20 -10
  183. package/src/utils/withDedupe.ts +4 -28
  184. package/src/utils/withTimeout.ts +7 -2
  185. package/src/version.ts +1 -1
@@ -1,20 +1,23 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_errors_errors = require("../../../errors/errors.js");
3
+ const require_utils_abort = require("../../../utils/abort.js");
3
4
  const require_actions_getStatus = require("../../../actions/getStatus.js");
4
5
  const require_core_actionMessages = require("../../actionMessages.js");
6
+ const require_core_tasks_helpers_getStepStatusRequest = require("./getStepStatusRequest.js");
5
7
  const require_utils_waitForResult = require("../../../utils/waitForResult.js");
6
8
  //#region src/core/tasks/helpers/waitForTransactionStatus.ts
9
+ /** @internal The running poll per transaction hash. Exported for tests. */
7
10
  const TRANSACTION_HASH_OBSERVERS = {};
8
- async function waitForTransactionStatus(client, statusManager, txHash, step, actionType, interval = 5e3) {
9
- const _getStatus = () => {
10
- return require_actions_getStatus.getStatus(client, {
11
- fromChain: step.action.fromChainId,
12
- fromAddress: step.action.fromAddress,
13
- toChain: step.action.toChainId,
14
- txHash,
15
- ...step.tool !== "custom" && { bridge: step.tool },
16
- ...step.transactionId && { transactionId: step.transactionId }
17
- }).then((statusResponse) => {
11
+ /**
12
+ * Waits for the final status of `txHash`. Callers that wait for the same hash
13
+ * share one poll. A caller whose `signal` aborts leaves at once with the abort
14
+ * reason; the poll itself ends only when every caller with a signal has left
15
+ * and no caller without a signal joined it.
16
+ */
17
+ async function waitForTransactionStatus(client, statusManager, txHash, step, actionType, interval = 5e3, signal) {
18
+ if (signal?.aborted) throw require_utils_abort.getAbortError(signal);
19
+ const _getStatus = (pollSignal) => {
20
+ return require_actions_getStatus.getStatus(client, require_core_tasks_helpers_getStepStatusRequest.getStepStatusRequest(step, txHash), { signal: pollSignal }).then((statusResponse) => {
18
21
  switch (statusResponse.status) {
19
22
  case "DONE": return statusResponse;
20
23
  case "PENDING": {
@@ -33,18 +36,74 @@ async function waitForTransactionStatus(client, statusManager, txHash, step, act
33
36
  if (process.env.NODE_ENV === "development") console.debug("Fetching status from backend failed.", e);
34
37
  });
35
38
  };
36
- let status = TRANSACTION_HASH_OBSERVERS[txHash];
37
- if (!status) {
38
- status = require_utils_waitForResult.waitForResult(_getStatus, interval).finally(() => {
39
- delete TRANSACTION_HASH_OBSERVERS[txHash];
40
- });
41
- TRANSACTION_HASH_OBSERVERS[txHash] = status;
39
+ let poll = TRANSACTION_HASH_OBSERVERS[txHash];
40
+ if (!poll) {
41
+ const controller = new AbortController();
42
+ const promise = require_utils_waitForResult.waitForResult(() => _getStatus(controller.signal), interval, void 0, void 0, controller.signal).finally(() => removePoll(txHash, promise));
43
+ poll = {
44
+ promise,
45
+ controller,
46
+ pinned: false
47
+ };
48
+ TRANSACTION_HASH_OBSERVERS[txHash] = poll;
42
49
  }
43
- const resolvedStatus = await status;
50
+ const resolvedStatus = await joinPoll(txHash, poll, signal);
44
51
  if (!("receiving" in resolvedStatus)) throw new require_errors_errors.ServerError("Status doesn't contain destination chain information.");
45
52
  return resolvedStatus;
46
53
  }
54
+ function joinPoll(txHash, poll, signal) {
55
+ if (!signal) {
56
+ poll.pinned = true;
57
+ return poll.promise;
58
+ }
59
+ const waiters = poll.waiters ?? subscribe(poll);
60
+ return new Promise((resolve, reject) => {
61
+ const waiter = {
62
+ resolve: (status) => {
63
+ signal.removeEventListener("abort", leave);
64
+ resolve(status);
65
+ },
66
+ reject: (error) => {
67
+ signal.removeEventListener("abort", leave);
68
+ reject(error);
69
+ }
70
+ };
71
+ const leave = () => {
72
+ signal.removeEventListener("abort", leave);
73
+ waiters.delete(waiter);
74
+ const reason = require_utils_abort.getAbortError(signal);
75
+ reject(reason);
76
+ if (!poll.pinned && waiters.size === 0) {
77
+ removePoll(txHash, poll.promise);
78
+ poll.controller.abort(reason);
79
+ }
80
+ };
81
+ waiters.add(waiter);
82
+ signal.addEventListener("abort", leave, { once: true });
83
+ if (signal.aborted) leave();
84
+ });
85
+ }
86
+ /**
87
+ * Hands the result to the callers with a signal, through one reaction per
88
+ * poll, so a caller that leaves holds nothing here. It also handles the
89
+ * rejection of a poll that every caller left.
90
+ */
91
+ function subscribe(poll) {
92
+ const waiters = /* @__PURE__ */ new Set();
93
+ poll.waiters = waiters;
94
+ poll.promise.then((status) => {
95
+ for (const waiter of waiters) waiter.resolve(status);
96
+ }, (error) => {
97
+ for (const waiter of waiters) waiter.reject(error);
98
+ });
99
+ return waiters;
100
+ }
101
+ /** Drops the entry for `txHash` only while it still holds this poll. */
102
+ function removePoll(txHash, promise) {
103
+ if (TRANSACTION_HASH_OBSERVERS[txHash]?.promise === promise) delete TRANSACTION_HASH_OBSERVERS[txHash];
104
+ }
47
105
  //#endregion
106
+ exports.TRANSACTION_HASH_OBSERVERS = TRANSACTION_HASH_OBSERVERS;
48
107
  exports.waitForTransactionStatus = waitForTransactionStatus;
49
108
 
50
109
  //# sourceMappingURL=waitForTransactionStatus.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"waitForTransactionStatus.js","names":["getStatus","getSubstatusMessage","waitForResult","ServerError"],"sources":["../../../../../src/core/tasks/helpers/waitForTransactionStatus.ts"],"sourcesContent":["import type { FullStatusData, LiFiStep, StatusResponse } from '@lifi/types'\nimport { getStatus } from '../../../actions/getStatus.js'\nimport { ServerError } from '../../../errors/errors.js'\nimport type { ExecutionActionType, SDKClient } from '../../../types/core.js'\nimport { waitForResult } from '../../../utils/waitForResult.js'\nimport { getSubstatusMessage } from '../../actionMessages.js'\nimport type { StatusManager } from '../../StatusManager.js'\n\nconst TRANSACTION_HASH_OBSERVERS: Record<string, Promise<StatusResponse>> = {}\n\nexport async function waitForTransactionStatus(\n client: SDKClient,\n statusManager: StatusManager,\n txHash: string,\n step: LiFiStep,\n actionType: ExecutionActionType,\n interval = 5_000\n): Promise<StatusResponse> {\n const _getStatus = (): Promise<StatusResponse | undefined> => {\n return getStatus(client, {\n fromChain: step.action.fromChainId,\n fromAddress: step.action.fromAddress,\n toChain: step.action.toChainId,\n txHash,\n ...(step.tool !== 'custom' && { bridge: step.tool }),\n ...(step.transactionId && { transactionId: step.transactionId }),\n })\n .then((statusResponse) => {\n switch (statusResponse.status) {\n case 'DONE':\n return statusResponse\n case 'PENDING': {\n const pendingStatus = statusResponse as FullStatusData\n statusManager?.updateAction(step, actionType, 'PENDING', {\n substatus: statusResponse.substatus,\n substatusMessage:\n statusResponse.substatusMessage ||\n getSubstatusMessage(\n statusResponse.status,\n statusResponse.substatus\n ),\n // Most bridges implement no `getExplorerLink`, so fall back to\n // the LI.FI explorer rather than leave the user with no link.\n txLink:\n pendingStatus.bridgeExplorerLink ??\n pendingStatus.lifiExplorerLink,\n })\n return undefined\n }\n case 'NOT_FOUND':\n return undefined\n default:\n return Promise.reject()\n }\n })\n .catch((e) => {\n if (process.env.NODE_ENV === 'development') {\n console.debug('Fetching status from backend failed.', e)\n }\n return undefined\n })\n }\n\n let status = TRANSACTION_HASH_OBSERVERS[txHash]\n\n if (!status) {\n status = waitForResult(_getStatus, interval).finally(() => {\n delete TRANSACTION_HASH_OBSERVERS[txHash]\n })\n TRANSACTION_HASH_OBSERVERS[txHash] = status\n }\n\n const resolvedStatus = await status\n\n if (!('receiving' in resolvedStatus)) {\n throw new ServerError(\n \"Status doesn't contain destination chain information.\"\n )\n }\n\n return resolvedStatus\n}\n"],"mappings":";;;;;;AAQA,MAAM,6BAAsE,CAAC;AAE7E,eAAsB,yBACpB,QACA,eACA,QACA,MACA,YACA,WAAW,KACc;CACzB,MAAM,mBAAwD;EAC5D,OAAOA,0BAAAA,UAAU,QAAQ;GACvB,WAAW,KAAK,OAAO;GACvB,aAAa,KAAK,OAAO;GACzB,SAAS,KAAK,OAAO;GACrB;GACA,GAAI,KAAK,SAAS,YAAY,EAAE,QAAQ,KAAK,KAAK;GAClD,GAAI,KAAK,iBAAiB,EAAE,eAAe,KAAK,cAAc;EAChE,CAAC,CAAC,CACC,MAAM,mBAAmB;GACxB,QAAQ,eAAe,QAAvB;IACE,KAAK,QACH,OAAO;IACT,KAAK,WAAW;KACd,MAAM,gBAAgB;KACtB,eAAe,aAAa,MAAM,YAAY,WAAW;MACvD,WAAW,eAAe;MAC1B,kBACE,eAAe,oBACfC,4BAAAA,oBACE,eAAe,QACf,eAAe,SACjB;MAGF,QACE,cAAc,sBACd,cAAc;KAClB,CAAC;KACD;IACF;IACA,KAAK,aACH;IACF,SACE,OAAO,QAAQ,OAAO;GAC1B;EACF,CAAC,CAAC,CACD,OAAO,MAAM;GACZ,IAAI,QAAQ,IAAI,aAAa,eAC3B,QAAQ,MAAM,wCAAwC,CAAC;EAG3D,CAAC;CACL;CAEA,IAAI,SAAS,2BAA2B;CAExC,IAAI,CAAC,QAAQ;EACX,SAASC,4BAAAA,cAAc,YAAY,QAAQ,CAAC,CAAC,cAAc;GACzD,OAAO,2BAA2B;EACpC,CAAC;EACD,2BAA2B,UAAU;CACvC;CAEA,MAAM,iBAAiB,MAAM;CAE7B,IAAI,EAAE,eAAe,iBACnB,MAAM,IAAIC,sBAAAA,YACR,uDACF;CAGF,OAAO;AACT"}
1
+ {"version":3,"file":"waitForTransactionStatus.js","names":["getAbortError","getStatus","getStepStatusRequest","getSubstatusMessage","waitForResult","ServerError"],"sources":["../../../../../src/core/tasks/helpers/waitForTransactionStatus.ts"],"sourcesContent":["import type { FullStatusData, LiFiStep, StatusResponse } from '@lifi/types'\nimport { getStatus } from '../../../actions/getStatus.js'\nimport { ServerError } from '../../../errors/errors.js'\nimport type { ExecutionActionType, SDKClient } from '../../../types/core.js'\nimport { getAbortError } from '../../../utils/abort.js'\nimport { waitForResult } from '../../../utils/waitForResult.js'\nimport { getSubstatusMessage } from '../../actionMessages.js'\nimport type { StatusManager } from '../../StatusManager.js'\nimport { getStepStatusRequest } from './getStepStatusRequest.js'\n\ntype Waiter = {\n resolve: (status: StatusResponse) => void\n reject: (error: unknown) => void\n}\n\n/** The `/status` poll of one transaction hash, shared by all its callers. */\ntype StatusPoll = {\n promise: Promise<StatusResponse>\n controller: AbortController\n /** Callers with a signal that still wait, once the first one joined. */\n waiters?: Set<Waiter>\n /** A caller without a signal joined, so the poll runs until it settles. */\n pinned: boolean\n}\n\n/** @internal The running poll per transaction hash. Exported for tests. */\nexport const TRANSACTION_HASH_OBSERVERS: Partial<Record<string, StatusPoll>> =\n {}\n\n/**\n * Waits for the final status of `txHash`. Callers that wait for the same hash\n * share one poll. A caller whose `signal` aborts leaves at once with the abort\n * reason; the poll itself ends only when every caller with a signal has left\n * and no caller without a signal joined it.\n */\nexport async function waitForTransactionStatus(\n client: SDKClient,\n statusManager: StatusManager,\n txHash: string,\n step: LiFiStep,\n actionType: ExecutionActionType,\n interval = 5_000,\n signal?: AbortSignal\n): Promise<StatusResponse> {\n if (signal?.aborted) {\n throw getAbortError(signal)\n }\n\n const _getStatus = (\n pollSignal: AbortSignal\n ): Promise<StatusResponse | undefined> => {\n return getStatus(client, getStepStatusRequest(step, txHash), {\n signal: pollSignal,\n })\n .then((statusResponse) => {\n switch (statusResponse.status) {\n case 'DONE':\n return statusResponse\n case 'PENDING': {\n const pendingStatus = statusResponse as FullStatusData\n statusManager?.updateAction(step, actionType, 'PENDING', {\n substatus: statusResponse.substatus,\n substatusMessage:\n statusResponse.substatusMessage ||\n getSubstatusMessage(\n statusResponse.status,\n statusResponse.substatus\n ),\n // Most bridges implement no `getExplorerLink`, so fall back to\n // the LI.FI explorer rather than leave the user with no link.\n txLink:\n pendingStatus.bridgeExplorerLink ??\n pendingStatus.lifiExplorerLink,\n })\n return undefined\n }\n case 'NOT_FOUND':\n return undefined\n default:\n return Promise.reject()\n }\n })\n .catch((e) => {\n if (process.env.NODE_ENV === 'development') {\n console.debug('Fetching status from backend failed.', e)\n }\n return undefined\n })\n }\n\n let poll = TRANSACTION_HASH_OBSERVERS[txHash]\n\n if (!poll) {\n const controller = new AbortController()\n const promise: Promise<StatusResponse> = waitForResult(\n () => _getStatus(controller.signal),\n interval,\n undefined,\n undefined,\n controller.signal\n ).finally(() => removePoll(txHash, promise))\n poll = { promise, controller, pinned: false }\n TRANSACTION_HASH_OBSERVERS[txHash] = poll\n }\n\n const resolvedStatus = await joinPoll(txHash, poll, signal)\n\n if (!('receiving' in resolvedStatus)) {\n throw new ServerError(\n \"Status doesn't contain destination chain information.\"\n )\n }\n\n return resolvedStatus\n}\n\nfunction joinPoll(\n txHash: string,\n poll: StatusPoll,\n signal: AbortSignal | undefined\n): Promise<StatusResponse> {\n if (!signal) {\n poll.pinned = true\n return poll.promise\n }\n const waiters = poll.waiters ?? subscribe(poll)\n return new Promise<StatusResponse>((resolve, reject) => {\n // Stop listening before settling, so a later abort cannot reach the poll.\n const waiter: Waiter = {\n resolve: (status) => {\n signal.removeEventListener('abort', leave)\n resolve(status)\n },\n reject: (error) => {\n signal.removeEventListener('abort', leave)\n reject(error)\n },\n }\n const leave = (): void => {\n // `leave` can run without the event, so the listener is not always gone.\n signal.removeEventListener('abort', leave)\n waiters.delete(waiter)\n const reason = getAbortError(signal)\n reject(reason)\n if (!poll.pinned && waiters.size === 0) {\n // A caller arriving now must start a new poll, not join this one.\n removePoll(txHash, poll.promise)\n poll.controller.abort(reason)\n }\n }\n waiters.add(waiter)\n signal.addEventListener('abort', leave, { once: true })\n // Defensive; this branch does not run today. The check at the top of\n // `waitForTransactionStatus` throws for an aborted signal, and no await\n // runs between that check and this one. An aborted signal fires no more\n // abort event, so without the branch a caller that joins with an aborted\n // signal would not leave: it would wait, and keep the poll running,\n // until the poll settles.\n if (signal.aborted) {\n leave()\n }\n })\n}\n\n/**\n * Hands the result to the callers with a signal, through one reaction per\n * poll, so a caller that leaves holds nothing here. It also handles the\n * rejection of a poll that every caller left.\n */\nfunction subscribe(poll: StatusPoll): Set<Waiter> {\n const waiters = new Set<Waiter>()\n poll.waiters = waiters\n poll.promise.then(\n (status) => {\n for (const waiter of waiters) {\n waiter.resolve(status)\n }\n },\n (error: unknown) => {\n for (const waiter of waiters) {\n waiter.reject(error)\n }\n }\n )\n return waiters\n}\n\n/** Drops the entry for `txHash` only while it still holds this poll. */\nfunction removePoll(txHash: string, promise: Promise<StatusResponse>): void {\n if (TRANSACTION_HASH_OBSERVERS[txHash]?.promise === promise) {\n delete TRANSACTION_HASH_OBSERVERS[txHash]\n }\n}\n"],"mappings":";;;;;;;;;AA0BA,MAAa,6BACX,CAAC;;;;;;;AAQH,eAAsB,yBACpB,QACA,eACA,QACA,MACA,YACA,WAAW,KACX,QACyB;CACzB,IAAI,QAAQ,SACV,MAAMA,oBAAAA,cAAc,MAAM;CAG5B,MAAM,cACJ,eACwC;EACxC,OAAOC,0BAAAA,UAAU,QAAQC,gDAAAA,qBAAqB,MAAM,MAAM,GAAG,EAC3D,QAAQ,WACV,CAAC,CAAC,CACC,MAAM,mBAAmB;GACxB,QAAQ,eAAe,QAAvB;IACE,KAAK,QACH,OAAO;IACT,KAAK,WAAW;KACd,MAAM,gBAAgB;KACtB,eAAe,aAAa,MAAM,YAAY,WAAW;MACvD,WAAW,eAAe;MAC1B,kBACE,eAAe,oBACfC,4BAAAA,oBACE,eAAe,QACf,eAAe,SACjB;MAGF,QACE,cAAc,sBACd,cAAc;KAClB,CAAC;KACD;IACF;IACA,KAAK,aACH;IACF,SACE,OAAO,QAAQ,OAAO;GAC1B;EACF,CAAC,CAAC,CACD,OAAO,MAAM;GACZ,IAAI,QAAQ,IAAI,aAAa,eAC3B,QAAQ,MAAM,wCAAwC,CAAC;EAG3D,CAAC;CACL;CAEA,IAAI,OAAO,2BAA2B;CAEtC,IAAI,CAAC,MAAM;EACT,MAAM,aAAa,IAAI,gBAAgB;EACvC,MAAM,UAAmCC,4BAAAA,oBACjC,WAAW,WAAW,MAAM,GAClC,UACA,KAAA,GACA,KAAA,GACA,WAAW,MACb,CAAC,CAAC,cAAc,WAAW,QAAQ,OAAO,CAAC;EAC3C,OAAO;GAAE;GAAS;GAAY,QAAQ;EAAM;EAC5C,2BAA2B,UAAU;CACvC;CAEA,MAAM,iBAAiB,MAAM,SAAS,QAAQ,MAAM,MAAM;CAE1D,IAAI,EAAE,eAAe,iBACnB,MAAM,IAAIC,sBAAAA,YACR,uDACF;CAGF,OAAO;AACT;AAEA,SAAS,SACP,QACA,MACA,QACyB;CACzB,IAAI,CAAC,QAAQ;EACX,KAAK,SAAS;EACd,OAAO,KAAK;CACd;CACA,MAAM,UAAU,KAAK,WAAW,UAAU,IAAI;CAC9C,OAAO,IAAI,SAAyB,SAAS,WAAW;EAEtD,MAAM,SAAiB;GACrB,UAAU,WAAW;IACnB,OAAO,oBAAoB,SAAS,KAAK;IACzC,QAAQ,MAAM;GAChB;GACA,SAAS,UAAU;IACjB,OAAO,oBAAoB,SAAS,KAAK;IACzC,OAAO,KAAK;GACd;EACF;EACA,MAAM,cAAoB;GAExB,OAAO,oBAAoB,SAAS,KAAK;GACzC,QAAQ,OAAO,MAAM;GACrB,MAAM,SAASL,oBAAAA,cAAc,MAAM;GACnC,OAAO,MAAM;GACb,IAAI,CAAC,KAAK,UAAU,QAAQ,SAAS,GAAG;IAEtC,WAAW,QAAQ,KAAK,OAAO;IAC/B,KAAK,WAAW,MAAM,MAAM;GAC9B;EACF;EACA,QAAQ,IAAI,MAAM;EAClB,OAAO,iBAAiB,SAAS,OAAO,EAAE,MAAM,KAAK,CAAC;EAOtD,IAAI,OAAO,SACT,MAAM;CAEV,CAAC;AACH;;;;;;AAOA,SAAS,UAAU,MAA+B;CAChD,MAAM,0BAAU,IAAI,IAAY;CAChC,KAAK,UAAU;CACf,KAAK,QAAQ,MACV,WAAW;EACV,KAAK,MAAM,UAAU,SACnB,OAAO,QAAQ,MAAM;CAEzB,IACC,UAAmB;EAClB,KAAK,MAAM,UAAU,SACnB,OAAO,OAAO,KAAK;CAEvB,CACF;CACA,OAAO;AACT;;AAGA,SAAS,WAAW,QAAgB,SAAwC;CAC1E,IAAI,2BAA2B,OAAO,EAAE,YAAY,SAClD,OAAO,2BAA2B;AAEtC"}
@@ -0,0 +1,121 @@
1
+ import { ExecutionAction, ExecutionActionType, LiFiStepExtended } from "../types/core.js";
2
+ import { TransactionError } from "../errors/errors.js";
3
+ //#region src/core/transactionState.d.ts
4
+ /**
5
+ * Action types that carry the step's own transaction.
6
+ *
7
+ * @internal
8
+ */
9
+ export declare const TRANSACTION_ACTION_TYPES: readonly ExecutionActionType[];
10
+ /**
11
+ * Stored bytes on a chain without its own expiry (Sui, Solana with a durable
12
+ * nonce, Bitcoin) are resent only this long after signing. Past it, a page
13
+ * load could otherwise execute a swap on a quote the user no longer expects.
14
+ *
15
+ * @internal
16
+ */
17
+ export declare const MAX_RESEND_AGE_MS = 12e4;
18
+ /**
19
+ * Without an expiry verdict, a signature younger than this is never declared
20
+ * dropped. Solana blockhashes and Tron transactions expire well before it.
21
+ *
22
+ * @internal
23
+ */
24
+ export declare const DROPPED_FALLBACK_AGE_MS = 3e5;
25
+ /**
26
+ * Subtracted from `execution.signedAt` (the device clock) when it anchors a
27
+ * history-coverage check, so a device clock that runs fast cannot make a node
28
+ * look like it covers the signing time when it does not.
29
+ *
30
+ * @internal
31
+ */
32
+ export declare const CLOCK_SKEW_MARGIN_MS = 6e5;
33
+ /**
34
+ * Fields a sign task clears before it writes a new transaction's data, and
35
+ * that re-initializing a final-failed action clears. `taskId` is included: a
36
+ * stale relayed or batched task id would otherwise keep the action open.
37
+ *
38
+ * @internal
39
+ */
40
+ export declare const CLEARED_TRANSACTION_FIELDS: Readonly<Pick<ExecutionAction, "txHash" | "txLink" | "txHex" | "txFinal" | "taskId">>;
41
+ /**
42
+ * True when the action has a transaction to follow, landed or not: a hash, a
43
+ * task id or stored signed bytes, unless the action FAILED with a final
44
+ * outcome. Every resume decision uses this one predicate, so the pipeline
45
+ * selector and the pre-sign guard can never disagree.
46
+ *
47
+ * Resume rules for providers. A step never signs or sends a second
48
+ * transaction while an earlier one can still land:
49
+ * 1. Pick the first task with this predicate: open and DONE, the status
50
+ * wait; open, the provider's wait task; otherwise the first task.
51
+ * 2. In the sign task, call `assertNoOpenTransaction` at the start, right
52
+ * before each wallet call and, where the SDK sends, right after the
53
+ * wallet returns. Write the new data with `CLEARED_TRANSACTION_FIELDS`
54
+ * and `signedAt`.
55
+ * 3. From the last check, nothing awaits until the send or, where the SDK
56
+ * sends signed bytes, until they are stored as `txHex`, before the first
57
+ * send. Clear `txHex` only when the outcome is known, no node can still
58
+ * hold the bytes, or they no longer decode.
59
+ * 4. A resume never signs. It looks the transaction up and resends the
60
+ * stored bytes only while `isResendAllowed` (or the chain's own expiry)
61
+ * allows it; otherwise it only waits.
62
+ * 5. Mark an error final only on a verdict about the transaction: failed
63
+ * or reverted (on chain or at the relayer), cancelled, replaced, or
64
+ * dropped with proof. Dropped needs all three: the transaction can no
65
+ * longer land, a node that covers its window reports it absent (in the
66
+ * same response where the chain allows it), and `isKnownToStatusApi` is
67
+ * false. In doubt, throw without the marker and keep the fields.
68
+ * 6. Give `context.signal` only to waits that start after the broadcast. On
69
+ * abort, return `PAUSED` and write nothing.
70
+ */
71
+ export declare function hasOpenTransaction(action?: ExecutionAction): boolean;
72
+ /**
73
+ * True when any SWAP / CROSS_CHAIN action of the step has an open transaction.
74
+ *
75
+ * @internal
76
+ */
77
+ export declare function hasStepOpenTransaction(step: LiFiStepExtended): boolean;
78
+ /**
79
+ * Walks the error and its `cause` chain. Parsers may rebuild errors, so the
80
+ * marker is read from the original error. A property check instead of
81
+ * `instanceof` keeps it working across duplicated installs.
82
+ *
83
+ * @internal
84
+ */
85
+ export declare function isFinalTransactionError(error: unknown): boolean;
86
+ /**
87
+ * The error of a step that would sign a second transaction while its first
88
+ * one may still land.
89
+ *
90
+ * @internal
91
+ */
92
+ export declare function transactionConflictError(): TransactionError;
93
+ /**
94
+ * Called first in every sign task. With correct pipeline selectors it never
95
+ * throws; it stops a second signature if a selector ever routes an open
96
+ * transaction back to signing. Every sign task calls it again on the freshly
97
+ * found action right before its wallet call: a late write of an older run can
98
+ * merge a transaction into the action during the awaits in between. A sign
99
+ * task that sends the transaction itself calls it once more after the wallet
100
+ * returns, before it writes or sends anything: the merge can also land while
101
+ * the prompt is open.
102
+ *
103
+ * @internal
104
+ */
105
+ export declare function assertNoOpenTransaction(action?: ExecutionAction): void;
106
+ /**
107
+ * Unknown signing time never allows a resend. Nor does a signing time in the
108
+ * future: a device clock that ran ahead at signing and was corrected later
109
+ * would otherwise stretch the cap by the clock error.
110
+ *
111
+ * @internal
112
+ */
113
+ export declare function isResendAllowed(signedAt: number | undefined, now?: number): boolean;
114
+ /**
115
+ * Unknown signing time never allows a drop.
116
+ *
117
+ * @internal
118
+ */
119
+ export declare function isOldEnoughToDrop(signedAt: number | undefined, now?: number): boolean;
120
+ //#endregion
121
+ //# sourceMappingURL=transactionState.d.ts.map
@@ -0,0 +1,164 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ require("../errors/constants.js");
3
+ const require_errors_errors = require("../errors/errors.js");
4
+ //#region src/core/transactionState.ts
5
+ /**
6
+ * Action types that carry the step's own transaction.
7
+ *
8
+ * @internal
9
+ */
10
+ const TRANSACTION_ACTION_TYPES = ["SWAP", "CROSS_CHAIN"];
11
+ /**
12
+ * Stored bytes on a chain without its own expiry (Sui, Solana with a durable
13
+ * nonce, Bitcoin) are resent only this long after signing. Past it, a page
14
+ * load could otherwise execute a swap on a quote the user no longer expects.
15
+ *
16
+ * @internal
17
+ */
18
+ const MAX_RESEND_AGE_MS = 12e4;
19
+ /**
20
+ * Without an expiry verdict, a signature younger than this is never declared
21
+ * dropped. Solana blockhashes and Tron transactions expire well before it.
22
+ *
23
+ * @internal
24
+ */
25
+ const DROPPED_FALLBACK_AGE_MS = 3e5;
26
+ /**
27
+ * Subtracted from `execution.signedAt` (the device clock) when it anchors a
28
+ * history-coverage check, so a device clock that runs fast cannot make a node
29
+ * look like it covers the signing time when it does not.
30
+ *
31
+ * @internal
32
+ */
33
+ const CLOCK_SKEW_MARGIN_MS = 6e5;
34
+ /**
35
+ * Fields a sign task clears before it writes a new transaction's data, and
36
+ * that re-initializing a final-failed action clears. `taskId` is included: a
37
+ * stale relayed or batched task id would otherwise keep the action open.
38
+ *
39
+ * @internal
40
+ */
41
+ const CLEARED_TRANSACTION_FIELDS = Object.freeze({
42
+ txHash: void 0,
43
+ txLink: void 0,
44
+ txHex: void 0,
45
+ txFinal: void 0,
46
+ taskId: void 0
47
+ });
48
+ /**
49
+ * True when the action has a transaction to follow, landed or not: a hash, a
50
+ * task id or stored signed bytes, unless the action FAILED with a final
51
+ * outcome. Every resume decision uses this one predicate, so the pipeline
52
+ * selector and the pre-sign guard can never disagree.
53
+ *
54
+ * Resume rules for providers. A step never signs or sends a second
55
+ * transaction while an earlier one can still land:
56
+ * 1. Pick the first task with this predicate: open and DONE, the status
57
+ * wait; open, the provider's wait task; otherwise the first task.
58
+ * 2. In the sign task, call `assertNoOpenTransaction` at the start, right
59
+ * before each wallet call and, where the SDK sends, right after the
60
+ * wallet returns. Write the new data with `CLEARED_TRANSACTION_FIELDS`
61
+ * and `signedAt`.
62
+ * 3. From the last check, nothing awaits until the send or, where the SDK
63
+ * sends signed bytes, until they are stored as `txHex`, before the first
64
+ * send. Clear `txHex` only when the outcome is known, no node can still
65
+ * hold the bytes, or they no longer decode.
66
+ * 4. A resume never signs. It looks the transaction up and resends the
67
+ * stored bytes only while `isResendAllowed` (or the chain's own expiry)
68
+ * allows it; otherwise it only waits.
69
+ * 5. Mark an error final only on a verdict about the transaction: failed
70
+ * or reverted (on chain or at the relayer), cancelled, replaced, or
71
+ * dropped with proof. Dropped needs all three: the transaction can no
72
+ * longer land, a node that covers its window reports it absent (in the
73
+ * same response where the chain allows it), and `isKnownToStatusApi` is
74
+ * false. In doubt, throw without the marker and keep the fields.
75
+ * 6. Give `context.signal` only to waits that start after the broadcast. On
76
+ * abort, return `PAUSED` and write nothing.
77
+ */
78
+ function hasOpenTransaction(action) {
79
+ if (!action) return false;
80
+ if (!(action.txHash || action.taskId || action.txHex)) return false;
81
+ return !(action.status === "FAILED" && action.txFinal === true);
82
+ }
83
+ /**
84
+ * True when any SWAP / CROSS_CHAIN action of the step has an open transaction.
85
+ *
86
+ * @internal
87
+ */
88
+ function hasStepOpenTransaction(step) {
89
+ return !!step.execution?.actions?.some((action) => TRANSACTION_ACTION_TYPES.includes(action.type) && hasOpenTransaction(action));
90
+ }
91
+ /**
92
+ * Walks the error and its `cause` chain. Parsers may rebuild errors, so the
93
+ * marker is read from the original error. A property check instead of
94
+ * `instanceof` keeps it working across duplicated installs.
95
+ *
96
+ * @internal
97
+ */
98
+ function isFinalTransactionError(error) {
99
+ const seen = /* @__PURE__ */ new Set();
100
+ let current = error;
101
+ while (current && typeof current === "object" && !seen.has(current)) {
102
+ seen.add(current);
103
+ if (current.final === true) return true;
104
+ current = current.cause;
105
+ }
106
+ return false;
107
+ }
108
+ /**
109
+ * The error of a step that would sign a second transaction while its first
110
+ * one may still land.
111
+ *
112
+ * @internal
113
+ */
114
+ function transactionConflictError() {
115
+ return new require_errors_errors.TransactionError(1020, "A transaction for this step was already signed and may still land. Resume the route to wait for it instead of signing a new one.");
116
+ }
117
+ /**
118
+ * Called first in every sign task. With correct pipeline selectors it never
119
+ * throws; it stops a second signature if a selector ever routes an open
120
+ * transaction back to signing. Every sign task calls it again on the freshly
121
+ * found action right before its wallet call: a late write of an older run can
122
+ * merge a transaction into the action during the awaits in between. A sign
123
+ * task that sends the transaction itself calls it once more after the wallet
124
+ * returns, before it writes or sends anything: the merge can also land while
125
+ * the prompt is open.
126
+ *
127
+ * @internal
128
+ */
129
+ function assertNoOpenTransaction(action) {
130
+ if (hasOpenTransaction(action)) throw transactionConflictError();
131
+ }
132
+ /**
133
+ * Unknown signing time never allows a resend. Nor does a signing time in the
134
+ * future: a device clock that ran ahead at signing and was corrected later
135
+ * would otherwise stretch the cap by the clock error.
136
+ *
137
+ * @internal
138
+ */
139
+ function isResendAllowed(signedAt, now = Date.now()) {
140
+ return signedAt !== void 0 && now >= signedAt && now - signedAt < 12e4;
141
+ }
142
+ /**
143
+ * Unknown signing time never allows a drop.
144
+ *
145
+ * @internal
146
+ */
147
+ function isOldEnoughToDrop(signedAt, now = Date.now()) {
148
+ return signedAt !== void 0 && now - signedAt > 3e5;
149
+ }
150
+ //#endregion
151
+ exports.CLEARED_TRANSACTION_FIELDS = CLEARED_TRANSACTION_FIELDS;
152
+ exports.CLOCK_SKEW_MARGIN_MS = CLOCK_SKEW_MARGIN_MS;
153
+ exports.DROPPED_FALLBACK_AGE_MS = DROPPED_FALLBACK_AGE_MS;
154
+ exports.MAX_RESEND_AGE_MS = MAX_RESEND_AGE_MS;
155
+ exports.TRANSACTION_ACTION_TYPES = TRANSACTION_ACTION_TYPES;
156
+ exports.assertNoOpenTransaction = assertNoOpenTransaction;
157
+ exports.hasOpenTransaction = hasOpenTransaction;
158
+ exports.hasStepOpenTransaction = hasStepOpenTransaction;
159
+ exports.isFinalTransactionError = isFinalTransactionError;
160
+ exports.isOldEnoughToDrop = isOldEnoughToDrop;
161
+ exports.isResendAllowed = isResendAllowed;
162
+ exports.transactionConflictError = transactionConflictError;
163
+
164
+ //# sourceMappingURL=transactionState.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transactionState.js","names":["TransactionError"],"sources":["../../../src/core/transactionState.ts"],"sourcesContent":["import { LiFiErrorCode } from '../errors/constants.js'\nimport { TransactionError } from '../errors/errors.js'\nimport type {\n ExecutionAction,\n ExecutionActionType,\n LiFiStepExtended,\n} from '../types/core.js'\n\n/**\n * Action types that carry the step's own transaction.\n *\n * @internal\n */\nexport const TRANSACTION_ACTION_TYPES: readonly ExecutionActionType[] = [\n 'SWAP',\n 'CROSS_CHAIN',\n]\n\n/**\n * Stored bytes on a chain without its own expiry (Sui, Solana with a durable\n * nonce, Bitcoin) are resent only this long after signing. Past it, a page\n * load could otherwise execute a swap on a quote the user no longer expects.\n *\n * @internal\n */\nexport const MAX_RESEND_AGE_MS = 120_000\n\n/**\n * Without an expiry verdict, a signature younger than this is never declared\n * dropped. Solana blockhashes and Tron transactions expire well before it.\n *\n * @internal\n */\nexport const DROPPED_FALLBACK_AGE_MS = 300_000\n\n/**\n * Subtracted from `execution.signedAt` (the device clock) when it anchors a\n * history-coverage check, so a device clock that runs fast cannot make a node\n * look like it covers the signing time when it does not.\n *\n * @internal\n */\nexport const CLOCK_SKEW_MARGIN_MS = 600_000\n\n/**\n * Fields a sign task clears before it writes a new transaction's data, and\n * that re-initializing a final-failed action clears. `taskId` is included: a\n * stale relayed or batched task id would otherwise keep the action open.\n *\n * @internal\n */\nexport const CLEARED_TRANSACTION_FIELDS: Readonly<\n Pick<ExecutionAction, 'txHash' | 'txLink' | 'txHex' | 'txFinal' | 'taskId'>\n> = Object.freeze({\n txHash: undefined,\n txLink: undefined,\n txHex: undefined,\n txFinal: undefined,\n taskId: undefined,\n})\n\n/**\n * True when the action has a transaction to follow, landed or not: a hash, a\n * task id or stored signed bytes, unless the action FAILED with a final\n * outcome. Every resume decision uses this one predicate, so the pipeline\n * selector and the pre-sign guard can never disagree.\n *\n * Resume rules for providers. A step never signs or sends a second\n * transaction while an earlier one can still land:\n * 1. Pick the first task with this predicate: open and DONE, the status\n * wait; open, the provider's wait task; otherwise the first task.\n * 2. In the sign task, call `assertNoOpenTransaction` at the start, right\n * before each wallet call and, where the SDK sends, right after the\n * wallet returns. Write the new data with `CLEARED_TRANSACTION_FIELDS`\n * and `signedAt`.\n * 3. From the last check, nothing awaits until the send or, where the SDK\n * sends signed bytes, until they are stored as `txHex`, before the first\n * send. Clear `txHex` only when the outcome is known, no node can still\n * hold the bytes, or they no longer decode.\n * 4. A resume never signs. It looks the transaction up and resends the\n * stored bytes only while `isResendAllowed` (or the chain's own expiry)\n * allows it; otherwise it only waits.\n * 5. Mark an error final only on a verdict about the transaction: failed\n * or reverted (on chain or at the relayer), cancelled, replaced, or\n * dropped with proof. Dropped needs all three: the transaction can no\n * longer land, a node that covers its window reports it absent (in the\n * same response where the chain allows it), and `isKnownToStatusApi` is\n * false. In doubt, throw without the marker and keep the fields.\n * 6. Give `context.signal` only to waits that start after the broadcast. On\n * abort, return `PAUSED` and write nothing.\n */\nexport function hasOpenTransaction(action?: ExecutionAction): boolean {\n if (!action) {\n return false\n }\n if (!(action.txHash || action.taskId || action.txHex)) {\n return false\n }\n return !(action.status === 'FAILED' && action.txFinal === true)\n}\n\n/**\n * True when any SWAP / CROSS_CHAIN action of the step has an open transaction.\n *\n * @internal\n */\nexport function hasStepOpenTransaction(step: LiFiStepExtended): boolean {\n return !!step.execution?.actions?.some(\n (action) =>\n TRANSACTION_ACTION_TYPES.includes(action.type) &&\n hasOpenTransaction(action)\n )\n}\n\n/**\n * Walks the error and its `cause` chain. Parsers may rebuild errors, so the\n * marker is read from the original error. A property check instead of\n * `instanceof` keeps it working across duplicated installs.\n *\n * @internal\n */\nexport function isFinalTransactionError(error: unknown): boolean {\n const seen = new Set<unknown>()\n let current: unknown = error\n while (current && typeof current === 'object' && !seen.has(current)) {\n seen.add(current)\n if ((current as { final?: unknown }).final === true) {\n return true\n }\n current = (current as { cause?: unknown }).cause\n }\n return false\n}\n\n/**\n * The error of a step that would sign a second transaction while its first\n * one may still land.\n *\n * @internal\n */\nexport function transactionConflictError(): TransactionError {\n return new TransactionError(\n LiFiErrorCode.TransactionConflict,\n 'A transaction for this step was already signed and may still land. Resume the route to wait for it instead of signing a new one.'\n )\n}\n\n/**\n * Called first in every sign task. With correct pipeline selectors it never\n * throws; it stops a second signature if a selector ever routes an open\n * transaction back to signing. Every sign task calls it again on the freshly\n * found action right before its wallet call: a late write of an older run can\n * merge a transaction into the action during the awaits in between. A sign\n * task that sends the transaction itself calls it once more after the wallet\n * returns, before it writes or sends anything: the merge can also land while\n * the prompt is open.\n *\n * @internal\n */\nexport function assertNoOpenTransaction(action?: ExecutionAction): void {\n if (hasOpenTransaction(action)) {\n throw transactionConflictError()\n }\n}\n\n/**\n * Unknown signing time never allows a resend. Nor does a signing time in the\n * future: a device clock that ran ahead at signing and was corrected later\n * would otherwise stretch the cap by the clock error.\n *\n * @internal\n */\nexport function isResendAllowed(\n signedAt: number | undefined,\n now: number = Date.now()\n): boolean {\n return (\n signedAt !== undefined &&\n now >= signedAt &&\n now - signedAt < MAX_RESEND_AGE_MS\n )\n}\n\n/**\n * Unknown signing time never allows a drop.\n *\n * @internal\n */\nexport function isOldEnoughToDrop(\n signedAt: number | undefined,\n now: number = Date.now()\n): boolean {\n return signedAt !== undefined && now - signedAt > DROPPED_FALLBACK_AGE_MS\n}\n"],"mappings":";;;;;;;;;AAaA,MAAa,2BAA2D,CACtE,QACA,aACF;;;;;;;;AASA,MAAa,oBAAoB;;;;;;;AAQjC,MAAa,0BAA0B;;;;;;;;AASvC,MAAa,uBAAuB;;;;;;;;AASpC,MAAa,6BAET,OAAO,OAAO;CAChB,QAAQ,KAAA;CACR,QAAQ,KAAA;CACR,OAAO,KAAA;CACP,SAAS,KAAA;CACT,QAAQ,KAAA;AACV,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgCD,SAAgB,mBAAmB,QAAmC;CACpE,IAAI,CAAC,QACH,OAAO;CAET,IAAI,EAAE,OAAO,UAAU,OAAO,UAAU,OAAO,QAC7C,OAAO;CAET,OAAO,EAAE,OAAO,WAAW,YAAY,OAAO,YAAY;AAC5D;;;;;;AAOA,SAAgB,uBAAuB,MAAiC;CACtE,OAAO,CAAC,CAAC,KAAK,WAAW,SAAS,MAC/B,WACC,yBAAyB,SAAS,OAAO,IAAI,KAC7C,mBAAmB,MAAM,CAC7B;AACF;;;;;;;;AASA,SAAgB,wBAAwB,OAAyB;CAC/D,MAAM,uBAAO,IAAI,IAAa;CAC9B,IAAI,UAAmB;CACvB,OAAO,WAAW,OAAO,YAAY,YAAY,CAAC,KAAK,IAAI,OAAO,GAAG;EACnE,KAAK,IAAI,OAAO;EAChB,IAAK,QAAgC,UAAU,MAC7C,OAAO;EAET,UAAW,QAAgC;CAC7C;CACA,OAAO;AACT;;;;;;;AAQA,SAAgB,2BAA6C;CAC3D,OAAO,IAAIA,sBAAAA,iBAAAA,MAET,kIACF;AACF;;;;;;;;;;;;;AAcA,SAAgB,wBAAwB,QAAgC;CACtE,IAAI,mBAAmB,MAAM,GAC3B,MAAM,yBAAyB;AAEnC;;;;;;;;AASA,SAAgB,gBACd,UACA,MAAc,KAAK,IAAI,GACd;CACT,OACE,aAAa,KAAA,KACb,OAAO,YACP,MAAM,WAAA;AAEV;;;;;;AAOA,SAAgB,kBACd,UACA,MAAc,KAAK,IAAI,GACd;CACT,OAAO,aAAa,KAAA,KAAa,MAAM,WAAA;AACzC"}
@@ -8,8 +8,18 @@ export declare class RPCError extends BaseError {
8
8
  export declare class ProviderError extends BaseError {
9
9
  constructor(code: LiFiErrorCode, message: string, cause?: Error);
10
10
  }
11
+ export interface TransactionErrorOptions {
12
+ /**
13
+ * A definite verdict about the transaction (failed or reverted on chain or
14
+ * at the relayer, cancelled, replaced, or dropped with proof). The step
15
+ * executor then flags the failed action with `txFinal`, so a restart signs
16
+ * a new transaction.
17
+ */
18
+ final?: boolean;
19
+ }
11
20
  export declare class TransactionError extends BaseError {
12
- constructor(code: LiFiErrorCode, message: string, cause?: Error);
21
+ readonly final: boolean;
22
+ constructor(code: LiFiErrorCode, message: string, cause?: Error, options?: TransactionErrorOptions);
13
23
  }
14
24
  export declare class UnknownError extends BaseError {
15
25
  constructor(message: string, cause?: Error);
@@ -26,7 +36,8 @@ export declare class ValidationError extends BaseError {
26
36
  /**
27
37
  * Thrown by a step executor when executeStep should be retried with the given params
28
38
  * (e.g. wallet rejected 7702 upgrade → retry with atomicityNotReady).
29
- * The execution layer catches this and retries executeStep(client, step, retryParams).
39
+ * The execution layer catches this and retries executeStep(client, step, retryParams),
40
+ * unless the route was stopped or the step has an open transaction.
30
41
  */
31
42
  export declare class ExecuteStepRetryError extends BaseError {
32
43
  readonly retryParams: ExecuteStepRetryParams;
@@ -13,8 +13,10 @@ var ProviderError = class extends require_errors_baseError.BaseError {
13
13
  }
14
14
  };
15
15
  var TransactionError = class extends require_errors_baseError.BaseError {
16
- constructor(code, message, cause) {
16
+ final;
17
+ constructor(code, message, cause, options) {
17
18
  super("TransactionError", code, message, cause);
19
+ this.final = options?.final ?? false;
18
20
  }
19
21
  };
20
22
  var UnknownError = class extends require_errors_baseError.BaseError {
@@ -40,7 +42,8 @@ var ValidationError = class extends require_errors_baseError.BaseError {
40
42
  /**
41
43
  * Thrown by a step executor when executeStep should be retried with the given params
42
44
  * (e.g. wallet rejected 7702 upgrade → retry with atomicityNotReady).
43
- * The execution layer catches this and retries executeStep(client, step, retryParams).
45
+ * The execution layer catches this and retries executeStep(client, step, retryParams),
46
+ * unless the route was stopped or the step has an open transaction.
44
47
  */
45
48
  var ExecuteStepRetryError = class extends require_errors_baseError.BaseError {
46
49
  retryParams;
@@ -1 +1 @@
1
- {"version":3,"file":"errors.js","names":["BaseError"],"sources":["../../../src/errors/errors.ts"],"sourcesContent":["import type { ExecuteStepRetryParams } from '../types/core.js'\nimport { BaseError } from './baseError.js'\nimport { ErrorName, LiFiErrorCode } from './constants.js'\n\nexport class RPCError extends BaseError {\n constructor(code: LiFiErrorCode, message: string, cause?: Error) {\n super(ErrorName.RPCError, code, message, cause)\n }\n}\n\nexport class ProviderError extends BaseError {\n constructor(code: LiFiErrorCode, message: string, cause?: Error) {\n super(ErrorName.ProviderError, code, message, cause)\n }\n}\n\nexport class TransactionError extends BaseError {\n constructor(code: LiFiErrorCode, message: string, cause?: Error) {\n super(ErrorName.TransactionError, code, message, cause)\n }\n}\n\nexport class UnknownError extends BaseError {\n constructor(message: string, cause?: Error) {\n super(ErrorName.UnknownError, LiFiErrorCode.InternalError, message, cause)\n }\n}\n\nexport class BalanceError extends BaseError {\n constructor(message: string, cause?: Error) {\n super(ErrorName.BalanceError, LiFiErrorCode.BalanceError, message, cause)\n }\n}\n\nexport class ServerError extends BaseError {\n constructor(message: string) {\n super(ErrorName.ServerError, LiFiErrorCode.InternalError, message)\n }\n}\n\nexport class ValidationError extends BaseError {\n constructor(message: string) {\n super(ErrorName.ValidationError, LiFiErrorCode.ValidationError, message)\n }\n}\n\n/**\n * Thrown by a step executor when executeStep should be retried with the given params\n * (e.g. wallet rejected 7702 upgrade → retry with atomicityNotReady).\n * The execution layer catches this and retries executeStep(client, step, retryParams).\n */\nexport class ExecuteStepRetryError extends BaseError {\n readonly retryParams: ExecuteStepRetryParams\n\n constructor(\n message: string,\n retryParams: ExecuteStepRetryParams,\n cause?: Error\n ) {\n super(\n ErrorName.ExecuteStepRetryError,\n LiFiErrorCode.InternalError,\n message,\n cause\n )\n this.retryParams = retryParams\n }\n}\n"],"mappings":";;;;AAIA,IAAa,WAAb,cAA8BA,yBAAAA,UAAU;CACtC,YAAY,MAAqB,SAAiB,OAAe;EAC/D,MAAA,YAA0B,MAAM,SAAS,KAAK;CAChD;AACF;AAEA,IAAa,gBAAb,cAAmCA,yBAAAA,UAAU;CAC3C,YAAY,MAAqB,SAAiB,OAAe;EAC/D,MAAA,iBAA+B,MAAM,SAAS,KAAK;CACrD;AACF;AAEA,IAAa,mBAAb,cAAsCA,yBAAAA,UAAU;CAC9C,YAAY,MAAqB,SAAiB,OAAe;EAC/D,MAAA,oBAAkC,MAAM,SAAS,KAAK;CACxD;AACF;AAEA,IAAa,eAAb,cAAkCA,yBAAAA,UAAU;CAC1C,YAAY,SAAiB,OAAe;EAC1C,MAAA,gBAAA,KAA2D,SAAS,KAAK;CAC3E;AACF;AAEA,IAAa,eAAb,cAAkCA,yBAAAA,UAAU;CAC1C,YAAY,SAAiB,OAAe;EAC1C,MAAA,gBAAA,MAA0D,SAAS,KAAK;CAC1E;AACF;AAEA,IAAa,cAAb,cAAiCA,yBAAAA,UAAU;CACzC,YAAY,SAAiB;EAC3B,MAAA,eAAA,KAA0D,OAAO;CACnE;AACF;AAEA,IAAa,kBAAb,cAAqCA,yBAAAA,UAAU;CAC7C,YAAY,SAAiB;EAC3B,MAAA,mBAAA,MAAgE,OAAO;CACzE;AACF;;;;;;AAOA,IAAa,wBAAb,cAA2CA,yBAAAA,UAAU;CACnD;CAEA,YACE,SACA,aACA,OACA;EACA,MAAA,yBAAA,KAGE,SACA,KACF;EACA,KAAK,cAAc;CACrB;AACF"}
1
+ {"version":3,"file":"errors.js","names":["BaseError"],"sources":["../../../src/errors/errors.ts"],"sourcesContent":["import type { ExecuteStepRetryParams } from '../types/core.js'\nimport { BaseError } from './baseError.js'\nimport { ErrorName, LiFiErrorCode } from './constants.js'\n\nexport class RPCError extends BaseError {\n constructor(code: LiFiErrorCode, message: string, cause?: Error) {\n super(ErrorName.RPCError, code, message, cause)\n }\n}\n\nexport class ProviderError extends BaseError {\n constructor(code: LiFiErrorCode, message: string, cause?: Error) {\n super(ErrorName.ProviderError, code, message, cause)\n }\n}\n\nexport interface TransactionErrorOptions {\n /**\n * A definite verdict about the transaction (failed or reverted on chain or\n * at the relayer, cancelled, replaced, or dropped with proof). The step\n * executor then flags the failed action with `txFinal`, so a restart signs\n * a new transaction.\n */\n final?: boolean\n}\n\nexport class TransactionError extends BaseError {\n readonly final: boolean\n\n constructor(\n code: LiFiErrorCode,\n message: string,\n cause?: Error,\n options?: TransactionErrorOptions\n ) {\n super(ErrorName.TransactionError, code, message, cause)\n this.final = options?.final ?? false\n }\n}\n\nexport class UnknownError extends BaseError {\n constructor(message: string, cause?: Error) {\n super(ErrorName.UnknownError, LiFiErrorCode.InternalError, message, cause)\n }\n}\n\nexport class BalanceError extends BaseError {\n constructor(message: string, cause?: Error) {\n super(ErrorName.BalanceError, LiFiErrorCode.BalanceError, message, cause)\n }\n}\n\nexport class ServerError extends BaseError {\n constructor(message: string) {\n super(ErrorName.ServerError, LiFiErrorCode.InternalError, message)\n }\n}\n\nexport class ValidationError extends BaseError {\n constructor(message: string) {\n super(ErrorName.ValidationError, LiFiErrorCode.ValidationError, message)\n }\n}\n\n/**\n * Thrown by a step executor when executeStep should be retried with the given params\n * (e.g. wallet rejected 7702 upgrade → retry with atomicityNotReady).\n * The execution layer catches this and retries executeStep(client, step, retryParams),\n * unless the route was stopped or the step has an open transaction.\n */\nexport class ExecuteStepRetryError extends BaseError {\n readonly retryParams: ExecuteStepRetryParams\n\n constructor(\n message: string,\n retryParams: ExecuteStepRetryParams,\n cause?: Error\n ) {\n super(\n ErrorName.ExecuteStepRetryError,\n LiFiErrorCode.InternalError,\n message,\n cause\n )\n this.retryParams = retryParams\n }\n}\n"],"mappings":";;;;AAIA,IAAa,WAAb,cAA8BA,yBAAAA,UAAU;CACtC,YAAY,MAAqB,SAAiB,OAAe;EAC/D,MAAA,YAA0B,MAAM,SAAS,KAAK;CAChD;AACF;AAEA,IAAa,gBAAb,cAAmCA,yBAAAA,UAAU;CAC3C,YAAY,MAAqB,SAAiB,OAAe;EAC/D,MAAA,iBAA+B,MAAM,SAAS,KAAK;CACrD;AACF;AAYA,IAAa,mBAAb,cAAsCA,yBAAAA,UAAU;CAC9C;CAEA,YACE,MACA,SACA,OACA,SACA;EACA,MAAA,oBAAkC,MAAM,SAAS,KAAK;EACtD,KAAK,QAAQ,SAAS,SAAS;CACjC;AACF;AAEA,IAAa,eAAb,cAAkCA,yBAAAA,UAAU;CAC1C,YAAY,SAAiB,OAAe;EAC1C,MAAA,gBAAA,KAA2D,SAAS,KAAK;CAC3E;AACF;AAEA,IAAa,eAAb,cAAkCA,yBAAAA,UAAU;CAC1C,YAAY,SAAiB,OAAe;EAC1C,MAAA,gBAAA,MAA0D,SAAS,KAAK;CAC1E;AACF;AAEA,IAAa,cAAb,cAAiCA,yBAAAA,UAAU;CACzC,YAAY,SAAiB;EAC3B,MAAA,eAAA,KAA0D,OAAO;CACnE;AACF;AAEA,IAAa,kBAAb,cAAqCA,yBAAAA,UAAU;CAC7C,YAAY,SAAiB;EAC3B,MAAA,mBAAA,MAAgE,OAAO;CACzE;AACF;;;;;;;AAQA,IAAa,wBAAb,cAA2CA,yBAAAA,UAAU;CACnD;CAEA,YACE,SACA,aACA,OACA;EACA,MAAA,yBAAA,KAGE,SACA,KACF;EACA,KAAK,cAAc;CACrB;AACF"}
@@ -23,12 +23,13 @@ import { patchContractCalls } from "./actions/patchContractCalls.js";
23
23
  import { actions } from "./actions/index.js";
24
24
  import { relayTransaction } from "./actions/relayTransaction.js";
25
25
  import { createClient } from "./client/createClient.js";
26
+ import { findProvider } from "./client/findProvider.js";
26
27
  import { StatusManager } from "./core/StatusManager.js";
27
28
  import { StepExecutorBaseContext, StepExecutorContext, TaskResult, TaskStatus } from "./types/execution.js";
28
29
  import { BaseStepExecutionTask } from "./core/BaseStepExecutionTask.js";
29
30
  import { ErrorCode, ErrorMessage, ErrorName, LiFiErrorCode } from "./errors/constants.js";
30
31
  import { BaseError } from "./errors/baseError.js";
31
- import { BalanceError, ExecuteStepRetryError, ProviderError, RPCError, ServerError, TransactionError, UnknownError, ValidationError } from "./errors/errors.js";
32
+ import { BalanceError, ExecuteStepRetryError, ProviderError, RPCError, ServerError, TransactionError, TransactionErrorOptions, UnknownError, ValidationError } from "./errors/errors.js";
32
33
  import { SDKError } from "./errors/SDKError.js";
33
34
  import { TaskPipeline } from "./core/TaskPipeline.js";
34
35
  import { BaseStepExecutor } from "./core/BaseStepExecutor.js";
@@ -39,18 +40,21 @@ import { CheckBalanceTask } from "./core/tasks/CheckBalanceTask.js";
39
40
  import { PrepareTransactionTask } from "./core/tasks/PrepareTransactionTask.js";
40
41
  import { WaitForTransactionStatusTask } from "./core/tasks/WaitForTransactionStatusTask.js";
41
42
  import { getTransactionRequestData } from "./core/tasks/helpers/getTransactionRequestData.js";
43
+ import { isKnownToStatusApi } from "./core/tasks/helpers/isKnownToStatusApi.js";
42
44
  import { stepComparison } from "./core/tasks/helpers/stepComparison.js";
45
+ import { CLEARED_TRANSACTION_FIELDS, CLOCK_SKEW_MARGIN_MS, DROPPED_FALLBACK_AGE_MS, MAX_RESEND_AGE_MS, assertNoOpenTransaction, hasOpenTransaction, isFinalTransactionError, isOldEnoughToDrop, isResendAllowed } from "./core/transactionState.js";
43
46
  import { HTTPError } from "./errors/httpError.js";
44
47
  import { checkPackageUpdates } from "./utils/checkPackageUpdates.js";
45
48
  import { convertQuoteToRoute } from "./utils/convertQuoteToRoute.js";
46
49
  import { fetchTxErrorDetails } from "./utils/fetchTxErrorDetails.js";
47
50
  import { formatUnits } from "./utils/formatUnits.js";
48
51
  import { isHex } from "./utils/isHex.js";
52
+ import { LruMap } from "./utils/lru.js";
49
53
  import { parseUnits } from "./utils/parseUnits.js";
50
54
  import { sleep } from "./utils/sleep.js";
51
55
  import { waitForResult } from "./utils/waitForResult.js";
52
- import { LruMap, withDedupe } from "./utils/withDedupe.js";
56
+ import { withDedupe } from "./utils/withDedupe.js";
53
57
  import { withTimeout } from "./utils/withTimeout.js";
54
58
  import { name, version } from "./version.js";
55
59
  export * from "@lifi/types";
56
- export { type AcceptExchangeRateUpdateHook, type AcceptSlippageUpdateHook, type AcceptSlippageUpdateHookParams, BalanceError, BaseError, BaseStepExecutionTask, BaseStepExecutor, type CheckBalanceOptions, CheckBalanceTask, type ContractCallParams, type ContractTool, type ErrorCode, ErrorMessage, ErrorName, type ExchangeRateUpdateParams, ExecuteStepRetryError, type ExecuteStepRetryParams, type Execution, type ExecutionAction, type ExecutionActionStatus, type ExecutionActionType, type ExecutionOptions, type ExecutionStatus, type GetContractCallsHook, type GetContractCallsResult, type GetStatusRequestExtended, HTTPError, InMemoryStorage, type InteractionSettings, LiFiErrorCode, type LiFiStepExtended, type LiFiStepRequest, LocalStorageAdapter, LruMap, PrepareTransactionTask, ProviderError, type QuoteRequest, type QuoteRequestFromAmount, type QuoteRequestToAmount, RPCError, type RPCUrls, type RPCUrlsByRole, type RPCUrlsConfig, type RequestInterceptor, type RouteExecutionData, type RouteExecutionDataDictionary, type RouteExecutionDictionary, type RouteExtended, type SDKBaseConfig, type SDKClient, type SDKConfig, SDKError, type SDKProvider, type SDKStorage, ServerError, StatusManager, type StepExecutor, type StepExecutorBaseContext, type StepExecutorContext, type StepExecutorOptions, type StepExtended, TaskPipeline, type TaskResult, type TaskStatus, TransactionError, type TransactionMethodType, type TransactionParameters, type TransactionRequestParameters, type TransactionRequestUpdateHook, UnknownError, type UpdateRouteHook, ValidationError, WaitForTransactionStatusTask, actions, checkBalance, checkPackageUpdates, convertQuoteToRoute, createClient, createDefaultStorage, executeRoute, fetchTxErrorDetails, formatUnits, getActionMessage, getActiveRoute, getActiveRoutes, getChains, getConnections, getContractCallsQuote, getGasRecommendation, getNameServiceAddress, getQuote, getRelayedTransactionStatus, getRelayerQuote, getRoutes, getStatus, getStepTransaction, getSubstatusMessage, getToken, getTokenBalance, getTokenBalances, getTokenBalancesByChain, getTokens, getTools, getTransactionHistory, getTransactionRequestData, isHex, name, parseUnits, patchContractCalls, relayTransaction, resumeRoute, sleep, stepComparison, stopRouteExecution, updateRouteExecution, version, waitForResult, withDedupe, withTimeout };
60
+ export { type AcceptExchangeRateUpdateHook, type AcceptSlippageUpdateHook, type AcceptSlippageUpdateHookParams, BalanceError, BaseError, BaseStepExecutionTask, BaseStepExecutor, CLEARED_TRANSACTION_FIELDS, CLOCK_SKEW_MARGIN_MS, type CheckBalanceOptions, CheckBalanceTask, type ContractCallParams, type ContractTool, DROPPED_FALLBACK_AGE_MS, type ErrorCode, ErrorMessage, ErrorName, type ExchangeRateUpdateParams, ExecuteStepRetryError, type ExecuteStepRetryParams, type Execution, type ExecutionAction, type ExecutionActionStatus, type ExecutionActionType, type ExecutionOptions, type ExecutionStatus, type GetContractCallsHook, type GetContractCallsResult, type GetStatusRequestExtended, HTTPError, InMemoryStorage, type InteractionSettings, LiFiErrorCode, type LiFiStepExtended, type LiFiStepRequest, LocalStorageAdapter, LruMap, MAX_RESEND_AGE_MS, PrepareTransactionTask, ProviderError, type QuoteRequest, type QuoteRequestFromAmount, type QuoteRequestToAmount, RPCError, type RPCUrls, type RPCUrlsByRole, type RPCUrlsConfig, type RequestInterceptor, type RouteExecutionData, type RouteExecutionDataDictionary, type RouteExecutionDictionary, type RouteExtended, type SDKBaseConfig, type SDKClient, type SDKConfig, SDKError, type SDKProvider, type SDKStorage, ServerError, StatusManager, type StepExecutor, type StepExecutorBaseContext, type StepExecutorContext, type StepExecutorOptions, type StepExtended, TaskPipeline, type TaskResult, type TaskStatus, TransactionError, type TransactionErrorOptions, type TransactionMethodType, type TransactionParameters, type TransactionRequestParameters, type TransactionRequestUpdateHook, UnknownError, type UpdateRouteHook, ValidationError, WaitForTransactionStatusTask, actions, assertNoOpenTransaction, checkBalance, checkPackageUpdates, convertQuoteToRoute, createClient, createDefaultStorage, executeRoute, fetchTxErrorDetails, findProvider, formatUnits, getActionMessage, getActiveRoute, getActiveRoutes, getChains, getConnections, getContractCallsQuote, getGasRecommendation, getNameServiceAddress, getQuote, getRelayedTransactionStatus, getRelayerQuote, getRoutes, getStatus, getStepTransaction, getSubstatusMessage, getToken, getTokenBalance, getTokenBalances, getTokenBalancesByChain, getTokens, getTools, getTransactionHistory, getTransactionRequestData, hasOpenTransaction, isFinalTransactionError, isHex, isKnownToStatusApi, isOldEnoughToDrop, isResendAllowed, name, parseUnits, patchContractCalls, relayTransaction, resumeRoute, sleep, stepComparison, stopRouteExecution, updateRouteExecution, version, waitForResult, withDedupe, withTimeout };