@lifi/sdk 4.10.0 → 4.12.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 (140) hide show
  1. package/CHANGELOG.md +39 -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 +107 -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/getStepStatusRequest.d.ts +10 -0
  24. package/dist/cjs/core/tasks/helpers/getStepStatusRequest.js +20 -0
  25. package/dist/cjs/core/tasks/helpers/getStepStatusRequest.js.map +1 -0
  26. package/dist/cjs/core/tasks/helpers/isKnownToStatusApi.d.ts +21 -0
  27. package/dist/cjs/core/tasks/helpers/isKnownToStatusApi.js +44 -0
  28. package/dist/cjs/core/tasks/helpers/isKnownToStatusApi.js.map +1 -0
  29. package/dist/cjs/core/tasks/helpers/waitForTransactionStatus.d.ts +22 -1
  30. package/dist/cjs/core/tasks/helpers/waitForTransactionStatus.js +76 -17
  31. package/dist/cjs/core/tasks/helpers/waitForTransactionStatus.js.map +1 -1
  32. package/dist/cjs/core/transactionState.d.ts +123 -0
  33. package/dist/cjs/core/transactionState.js +167 -0
  34. package/dist/cjs/core/transactionState.js.map +1 -0
  35. package/dist/cjs/errors/constants.d.ts +2 -1
  36. package/dist/cjs/errors/constants.js +1 -0
  37. package/dist/cjs/errors/constants.js.map +1 -1
  38. package/dist/cjs/errors/errors.d.ts +13 -2
  39. package/dist/cjs/errors/errors.js +5 -2
  40. package/dist/cjs/errors/errors.js.map +1 -1
  41. package/dist/cjs/index.d.ts +5 -2
  42. package/dist/cjs/index.js +14 -0
  43. package/dist/cjs/types/core.d.ts +56 -3
  44. package/dist/cjs/types/execution.d.ts +8 -0
  45. package/dist/cjs/utils/checkPackageUpdates.js +1 -1
  46. package/dist/cjs/utils/waitForResult.d.ts +3 -1
  47. package/dist/cjs/utils/waitForResult.js +15 -10
  48. package/dist/cjs/utils/waitForResult.js.map +1 -1
  49. package/dist/cjs/version.d.ts +1 -1
  50. package/dist/cjs/version.js +1 -1
  51. package/dist/cjs/version.js.map +1 -1
  52. package/dist/esm/actions/getRoutes.d.ts.map +1 -1
  53. package/dist/esm/actions/index.d.ts.map +1 -1
  54. package/dist/esm/client/createClient.d.ts.map +1 -1
  55. package/dist/esm/client/createClient.js +6 -4
  56. package/dist/esm/client/createClient.js.map +1 -1
  57. package/dist/esm/client/findProvider.d.ts +10 -0
  58. package/dist/esm/client/findProvider.d.ts.map +1 -0
  59. package/dist/esm/client/findProvider.js +10 -0
  60. package/dist/esm/client/findProvider.js.map +1 -0
  61. package/dist/esm/core/BaseStepExecutor.d.ts +1 -1
  62. package/dist/esm/core/BaseStepExecutor.d.ts.map +1 -1
  63. package/dist/esm/core/BaseStepExecutor.js +22 -10
  64. package/dist/esm/core/BaseStepExecutor.js.map +1 -1
  65. package/dist/esm/core/StatusManager.d.ts +10 -0
  66. package/dist/esm/core/StatusManager.d.ts.map +1 -1
  67. package/dist/esm/core/StatusManager.js +107 -3
  68. package/dist/esm/core/StatusManager.js.map +1 -1
  69. package/dist/esm/core/execution.d.ts.map +1 -1
  70. package/dist/esm/core/execution.js +30 -14
  71. package/dist/esm/core/execution.js.map +1 -1
  72. package/dist/esm/core/executionState.d.ts +34 -2
  73. package/dist/esm/core/executionState.d.ts.map +1 -1
  74. package/dist/esm/core/executionState.js +44 -1
  75. package/dist/esm/core/executionState.js.map +1 -1
  76. package/dist/esm/core/prepareRestart.d.ts.map +1 -1
  77. package/dist/esm/core/prepareRestart.js +14 -6
  78. package/dist/esm/core/prepareRestart.js.map +1 -1
  79. package/dist/esm/core/tasks/WaitForTransactionStatusTask.d.ts.map +1 -1
  80. package/dist/esm/core/tasks/WaitForTransactionStatusTask.js +4 -2
  81. package/dist/esm/core/tasks/WaitForTransactionStatusTask.js.map +1 -1
  82. package/dist/esm/core/tasks/helpers/getStepStatusRequest.d.ts +10 -0
  83. package/dist/esm/core/tasks/helpers/getStepStatusRequest.d.ts.map +1 -0
  84. package/dist/esm/core/tasks/helpers/getStepStatusRequest.js +19 -0
  85. package/dist/esm/core/tasks/helpers/getStepStatusRequest.js.map +1 -0
  86. package/dist/esm/core/tasks/helpers/isKnownToStatusApi.d.ts +21 -0
  87. package/dist/esm/core/tasks/helpers/isKnownToStatusApi.d.ts.map +1 -0
  88. package/dist/esm/core/tasks/helpers/isKnownToStatusApi.js +43 -0
  89. package/dist/esm/core/tasks/helpers/isKnownToStatusApi.js.map +1 -0
  90. package/dist/esm/core/tasks/helpers/waitForTransactionStatus.d.ts +22 -1
  91. package/dist/esm/core/tasks/helpers/waitForTransactionStatus.d.ts.map +1 -1
  92. package/dist/esm/core/tasks/helpers/waitForTransactionStatus.js +76 -18
  93. package/dist/esm/core/tasks/helpers/waitForTransactionStatus.js.map +1 -1
  94. package/dist/esm/core/transactionState.d.ts +123 -0
  95. package/dist/esm/core/transactionState.d.ts.map +1 -0
  96. package/dist/esm/core/transactionState.js +155 -0
  97. package/dist/esm/core/transactionState.js.map +1 -0
  98. package/dist/esm/errors/constants.d.ts +2 -1
  99. package/dist/esm/errors/constants.d.ts.map +1 -1
  100. package/dist/esm/errors/constants.js +1 -0
  101. package/dist/esm/errors/constants.js.map +1 -1
  102. package/dist/esm/errors/errors.d.ts +13 -2
  103. package/dist/esm/errors/errors.d.ts.map +1 -1
  104. package/dist/esm/errors/errors.js +5 -2
  105. package/dist/esm/errors/errors.js.map +1 -1
  106. package/dist/esm/index.d.ts +5 -2
  107. package/dist/esm/index.js +4 -1
  108. package/dist/esm/types/actions.d.ts.map +1 -1
  109. package/dist/esm/types/core.d.ts +56 -3
  110. package/dist/esm/types/core.d.ts.map +1 -1
  111. package/dist/esm/types/execution.d.ts +8 -0
  112. package/dist/esm/types/execution.d.ts.map +1 -1
  113. package/dist/esm/utils/checkPackageUpdates.js +1 -1
  114. package/dist/esm/utils/waitForResult.d.ts +3 -1
  115. package/dist/esm/utils/waitForResult.d.ts.map +1 -1
  116. package/dist/esm/utils/waitForResult.js +15 -10
  117. package/dist/esm/utils/waitForResult.js.map +1 -1
  118. package/dist/esm/version.d.ts +1 -1
  119. package/dist/esm/version.js +1 -1
  120. package/dist/esm/version.js.map +1 -1
  121. package/package.json +2 -2
  122. package/src/client/createClient.ts +12 -4
  123. package/src/client/findProvider.ts +21 -0
  124. package/src/core/BaseStepExecutor.ts +40 -6
  125. package/src/core/StatusManager.ts +214 -2
  126. package/src/core/execution.ts +69 -20
  127. package/src/core/executionState.ts +84 -1
  128. package/src/core/prepareRestart.ts +29 -13
  129. package/src/core/tasks/WaitForTransactionStatusTask.ts +10 -1
  130. package/src/core/tasks/helpers/getStepStatusRequest.ts +20 -0
  131. package/src/core/tasks/helpers/isKnownToStatusApi.ts +57 -0
  132. package/src/core/tasks/helpers/waitForTransactionStatus.ts +128 -17
  133. package/src/core/transactionState.ts +200 -0
  134. package/src/errors/constants.ts +1 -0
  135. package/src/errors/errors.ts +21 -2
  136. package/src/index.ts +14 -0
  137. package/src/types/core.ts +57 -3
  138. package/src/types/execution.ts +8 -0
  139. package/src/utils/waitForResult.ts +16 -6
  140. package/src/version.ts +1 -1
package/dist/esm/index.js CHANGED
@@ -29,9 +29,11 @@ import { patchContractCalls } from "./actions/patchContractCalls.js";
29
29
  import { relayTransaction } from "./actions/relayTransaction.js";
30
30
  import { actions } from "./actions/index.js";
31
31
  import { checkPackageUpdates } from "./utils/checkPackageUpdates.js";
32
+ import { findProvider } from "./client/findProvider.js";
32
33
  import { createClient } from "./client/createClient.js";
33
34
  import { getActionMessage, getSubstatusMessage } from "./core/actionMessages.js";
34
35
  import { BaseStepExecutionTask } from "./core/BaseStepExecutionTask.js";
36
+ 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";
35
37
  import { StatusManager } from "./core/StatusManager.js";
36
38
  import { BaseStepExecutor } from "./core/BaseStepExecutor.js";
37
39
  import { executeRoute, getActiveRoute, getActiveRoutes, resumeRoute, stopRouteExecution, updateRouteExecution } from "./core/execution.js";
@@ -42,6 +44,7 @@ import { withTimeout } from "./utils/withTimeout.js";
42
44
  import { checkBalance } from "./core/tasks/helpers/checkBalance.js";
43
45
  import { CheckBalanceTask } from "./core/tasks/CheckBalanceTask.js";
44
46
  import { getTransactionRequestData } from "./core/tasks/helpers/getTransactionRequestData.js";
47
+ import { isKnownToStatusApi } from "./core/tasks/helpers/isKnownToStatusApi.js";
45
48
  import { stepComparison } from "./core/tasks/helpers/stepComparison.js";
46
49
  import { PrepareTransactionTask } from "./core/tasks/PrepareTransactionTask.js";
47
50
  import { waitForResult } from "./utils/waitForResult.js";
@@ -51,4 +54,4 @@ import { fetchTxErrorDetails } from "./utils/fetchTxErrorDetails.js";
51
54
  import { isHex } from "./utils/isHex.js";
52
55
  import { parseUnits } from "./utils/parseUnits.js";
53
56
  export * from "@lifi/types";
54
- export { BalanceError, BaseError, BaseStepExecutionTask, BaseStepExecutor, CheckBalanceTask, ErrorMessage, ErrorName, ExecuteStepRetryError, HTTPError, InMemoryStorage, LiFiErrorCode, LocalStorageAdapter, LruMap, PrepareTransactionTask, ProviderError, RPCError, SDKError, ServerError, StatusManager, TaskPipeline, TransactionError, UnknownError, 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 };
57
+ export { BalanceError, BaseError, BaseStepExecutionTask, BaseStepExecutor, CLEARED_TRANSACTION_FIELDS, CLOCK_SKEW_MARGIN_MS, CheckBalanceTask, DROPPED_FALLBACK_AGE_MS, ErrorMessage, ErrorName, ExecuteStepRetryError, HTTPError, InMemoryStorage, LiFiErrorCode, LocalStorageAdapter, LruMap, MAX_RESEND_AGE_MS, PrepareTransactionTask, ProviderError, RPCError, SDKError, ServerError, StatusManager, TaskPipeline, TransactionError, UnknownError, 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 };
@@ -1 +1 @@
1
- {"version":3,"file":"actions.d.ts","names":[],"sources":["../../../src/types/actions.ts"],"mappings":";;YASY,2BAA2B;EACrC;;;;;;KAOG;EACH;EACA;EACA;;YAGU,gBAAgB,KAAK,8BAC/B;EACE,UAAU;;IAER;;;;;;YAOM,mBAAmB,WAAW;EACxC,QAAQ,SAAS;;YAGP,yBAAyB;YAEzB,uBAAuB,KAAK;EACtC;;YAGU,eAAe,yBAAyB"}
1
+ {"version":3,"file":"actions.d.ts","names":["RoutesRequestBase","QuoteRequestBase"],"sources":["../../../src/types/actions.ts"],"mappings":";;YASY,2BAA2B;EACrC;;;;;;KAOG;EACH;EACA;EACA;;YAGU,gBAAgB,KAAKA,8BAC/B;EACE,UAAUA;;IAER;;;;;;YAOM,mBAAmB,WAAW;EACxC,QAAQ,SAAS;;YAGP,yBAAyBC;YAEzB,uBAAuB,KAAKA;EACtC;;YAGU,eAAe,yBAAyB"}
@@ -67,7 +67,18 @@ export type RPCUrlsConfig = Partial<Record<ChainId, string[] | RPCUrlsByRole>>;
67
67
  export type RPCUrls = Partial<Record<ChainId, string[]>>;
68
68
  export interface SDKProvider {
69
69
  readonly type: ChainType;
70
- isAddress(address: string): boolean;
70
+ /**
71
+ * The chains this provider serves. Omit it to serve every chain of `type`
72
+ * that no other provider lists.
73
+ */
74
+ readonly chainIds?: readonly ChainId[];
75
+ /**
76
+ * Validates a wallet address. With `chainId`, a provider whose chains use
77
+ * different address formats accepts only that chain's format and refuses a
78
+ * chain it does not know. Never forward `chainId` to a library function whose
79
+ * second parameter means something else.
80
+ */
81
+ isAddress(address: string, chainId?: ChainId): boolean;
71
82
  /**
72
83
  * Validates a token identifier, which several ecosystems shape unlike a
73
84
  * wallet address. A provider that omits the method has no token address
@@ -81,7 +92,7 @@ export interface SDKProvider {
81
92
  export interface SDKClient {
82
93
  config: SDKBaseConfig;
83
94
  providers: SDKProvider[];
84
- getProvider(type: ChainType): SDKProvider | undefined;
95
+ getProvider(type: ChainType, chainId?: ChainId): SDKProvider | undefined;
85
96
  setProviders(providers: SDKProvider[]): void;
86
97
  setChains(chains: ExtendedChain[]): void;
87
98
  getChains(): Promise<ExtendedChain[]>;
@@ -121,7 +132,11 @@ export interface StepExecutor {
121
132
  allowUserInteraction: boolean;
122
133
  allowExecution: boolean;
123
134
  setInteraction(settings?: InteractionSettings): void;
124
- executeStep(client: SDKClient, step: LiFiStepExtended, retryParams?: ExecuteStepRetryParams): Promise<LiFiStepExtended>;
135
+ /**
136
+ * @param signal Aborts when the execution stops. Only waits that start
137
+ * after the broadcast may use it (`StepExecutorBaseContext.signal`).
138
+ */
139
+ executeStep(client: SDKClient, step: LiFiStepExtended, retryParams?: ExecuteStepRetryParams, signal?: AbortSignal): Promise<LiFiStepExtended>;
125
140
  }
126
141
  export interface RouteExecutionData {
127
142
  route: Route;
@@ -151,6 +166,18 @@ export type TransactionParameters = {
151
166
  maxPriorityFeePerGas?: bigint;
152
167
  };
153
168
  export type RouteExecutionDictionary = Partial<Record<string, Promise<Route>>>;
169
+ /**
170
+ * Called on every update of the route. It receives the SDK's working copy of
171
+ * the route: the same object on every call of one execution, which the SDK
172
+ * keeps changing after the hook returns. Copy or serialize it before you
173
+ * store it.
174
+ *
175
+ * After `stopRouteExecution` it can still be called, but only to deliver the
176
+ * transaction data (`txHash`, `txHex`, `taskId`, `callCount`, `txFinal`) of a
177
+ * task that was still running at the stop, for example in an open wallet
178
+ * prompt. Store that data, so a resume waits for that transaction instead of
179
+ * signing again. If you deleted the route, ignore the call.
180
+ */
154
181
  export type UpdateRouteHook = (updatedRoute: RouteExtended) => void;
155
182
  export interface TransactionRequestParameters extends TransactionParameters {
156
183
  requestType: "approve" | "transaction";
@@ -193,6 +220,11 @@ export interface GetContractCallsResult {
193
220
  export type GetContractCallsHook = (params: ContractCallParams) => Promise<GetContractCallsResult>;
194
221
  export interface ExecutionOptions {
195
222
  acceptExchangeRateUpdateHook?: AcceptExchangeRateUpdateHook;
223
+ /**
224
+ * Receives the route on every update, and after `stopRouteExecution` the
225
+ * late transaction data of a task that was still running. See
226
+ * {@link UpdateRouteHook}.
227
+ */
196
228
  updateRouteHook?: UpdateRouteHook;
197
229
  updateTransactionRequestHook?: TransactionRequestUpdateHook;
198
230
  getContractCalls?: GetContractCallsHook;
@@ -213,7 +245,28 @@ export type ExecutionAction = {
213
245
  txLink?: string;
214
246
  taskId?: string;
215
247
  txType?: TransactionMethodType;
248
+ /**
249
+ * The number of calls of a batched (EIP-5792) transaction. Set with
250
+ * `taskId` when `txType` is `batched`. The batched wait reads it after a
251
+ * reload, when the calls are gone.
252
+ */
253
+ callCount?: number;
254
+ /**
255
+ * Provider-specific serialized signed transaction (hex, XDR, base64 or JSON).
256
+ * Present while the transaction may still need to be (re)sent or looked up.
257
+ * Stellar keeps it, and Bitcoin keeps it unless every node refuses its first
258
+ * send; Solana, Tron and Sui clear it when no longer needed.
259
+ */
216
260
  txHex?: string;
261
+ /**
262
+ * Set together with status `FAILED` when the outcome of this action's
263
+ * transaction is known and final (failed or reverted on chain or at the
264
+ * relayer, cancelled (also by a wallet that removed it before it sent it),
265
+ * replaced, or dropped with proof).
266
+ * A FAILED action without this flag has an unknown outcome and is re-checked
267
+ * on resume instead of being signed again.
268
+ */
269
+ txFinal?: boolean;
217
270
  error?: {
218
271
  code: string | number;
219
272
  message: string;
@@ -1 +1 @@
1
- {"version":3,"file":"core.d.ts","names":[],"sources":["../../../src/types/core.ts"],"mappings":";;;;YAmBY,sBACV,SAAS,wBACN,sBAAsB,QAAQ;iBAElB;EACf;EACA;EACA;EACA;EACA,eAAe;EACf,mBAAmB;EACnB,SAAS;EACT;EACA;EACA;EACA;EACA;EACA,qBAAqB;EACrB,UAAU;;iBAGK,kBACP,QAAQ,KAAK;EACrB;;;;;;EAMA,UAAU;EACV,YAAY;;;;;iBAMG;;;;;EAKf;;;;;;;;;;EAUA;;;;;;;;;EASA;;;;;;YAOU,gBAAgB,QAAQ,OAAO,oBAAoB;;YAGnD,UAAU,QAAQ,OAAO;iBAEpB;WACN,MAAM;EACf,UAAU;;;;;;EAMV,gBAAgB;EAChB,eACE,cACA,QAAQ,WACR,UAAU,SACV,QAAQ,UACP;EACH,gBAAgB,SAAS,sBAAsB,QAAQ;EACvD,WACE,QAAQ,WACR,uBACA,QAAQ,UACP,QAAQ;;iBAGI;EACf,QAAQ;EACR,WAAW;EACX,YAAY,MAAM,YAAY;EAC9B,aAAa,WAAW;EACxB,UAAU,QAAQ;EAClB,aAAa,QAAQ;EACrB,aAAa,SAAS,UAAU,QAAQ;EACxC,cAAc,QAAQ;EACtB,oBAAoB,SAAS,UAAU;;;;;;;;EAQvC,0BAA0B,SAAS,UAAU;;;;;;EAM7C,2BAA2B,SAAS,UAAU;;iBAG/B;EACf;EACA,mBAAmB;;iBAGJ;EACf;EACA;EACA;;;;;;YAOU,yBAAyB;iBAEpB;EACf;EACA;EACA,eAAe,WAAW;EAC1B,YACE,QAAQ,WACR,MAAM,kBACN,cAAc,yBACb,QAAQ;;iBAGI;EACf,OAAO;EACP,WAAW;EACX,mBAAmB;;YAGT,+BAA+B,QACzC,eAAe;iBAGA,sBAAsB,KAAK;EAC1C,OAAO;;iBAGQ,yBAAyB;EACxC,YAAY;;YAGF,eAAe;EACzB,YAAY;;YAGF;EACV;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;YAGU,2BAA2B,QAAQ,eAAe,QAAQ;YAE1D,mBAAmB,cAAc;iBAE5B,qCAAqC;EACpD;;YAGU,gCACV,kBAAkB,iCACf,QAAQ;iBAEI;EACf,SAAS;EACT;EACA;EACA;EACA;;YAGU,4BACV,QAAQ,mCACL;iBAEY;EACf,SAAS;EACT;EACA;;YAGU,gCACV,QAAQ,6BACL;iBAEY;EACf;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;iBAGe;EACf;EACA;;iBAGe;EACf,eAAe;EACf;EACA,eAAe;;YAGL,wBACV,QAAQ,uBACL,QAAQ;iBAEI;EACf,+BAA+B;EAC/B,kBAAkB;EAClB,+BAA+B;EAC/B,mBAAmB;EACnB;EACA;;YAGU;YAEA;YAUA;YAUA;EACV,MAAM;EACN,QAAQ;EACR;EACA,YAAY;EACZ;EACA;EACA;EACA;EACA;EACA,SAAS;EACT;EAEA;IAAU;IAAuB;IAAiB;;;iBAGnC;EACf;EACA;EACA,QAAQ;EACR,SAAS,MAAM;EACf;EACA;EACA,UAAU;EACV,WAAW;EACX,WAAW;EACX;EACA;EAEA;IAAU;IAAuB;IAAiB;;;YAGxC"}
1
+ {"version":3,"file":"core.d.ts","names":[],"sources":["../../../src/types/core.ts"],"mappings":";;;;YAmBY,sBACV,SAAS,wBACN,sBAAsB,QAAQ;iBAElB;EACf;EACA;EACA;EACA;EACA,eAAe;EACf,mBAAmB;EACnB,SAAS;EACT;EACA;EACA;EACA;EACA;EACA,qBAAqB;EACrB,UAAU;;iBAGK,kBACP,QAAQ,KAAK;EACrB;;;;;;EAMA,UAAU;EACV,YAAY;;;;;iBAMG;;;;;EAKf;;;;;;;;;;EAUA;;;;;;;;;EASA;;;;;;YAOU,gBAAgB,QAAQ,OAAO,oBAAoB;;YAGnD,UAAU,QAAQ,OAAO;iBAEpB;WACN,MAAM;;;;;WAKN,oBAAoB;;;;;;;EAO7B,UAAU,iBAAiB,UAAU;;;;;;EAMrC,gBAAgB;EAChB,eACE,cACA,QAAQ,WACR,UAAU,SACV,QAAQ,UACP;EACH,gBAAgB,SAAS,sBAAsB,QAAQ;EACvD,WACE,QAAQ,WACR,uBACA,QAAQ,UACP,QAAQ;;iBAGI;EACf,QAAQ;EACR,WAAW;EACX,YAAY,MAAM,WAAW,UAAU,UAAU;EACjD,aAAa,WAAW;EACxB,UAAU,QAAQ;EAClB,aAAa,QAAQ;EACrB,aAAa,SAAS,UAAU,QAAQ;EACxC,cAAc,QAAQ;EACtB,oBAAoB,SAAS,UAAU;;;;;;;;EAQvC,0BAA0B,SAAS,UAAU;;;;;;EAM7C,2BAA2B,SAAS,UAAU;;iBAG/B;EACf;EACA,mBAAmB;;iBAGJ;EACf;EACA;EACA;;;;;;YAOU,yBAAyB;iBAEpB;EACf;EACA;EACA,eAAe,WAAW;;;;;EAK1B,YACE,QAAQ,WACR,MAAM,kBACN,cAAc,wBACd,SAAS,cACR,QAAQ;;iBAGI;EACf,OAAO;EACP,WAAW;EACX,mBAAmB;;YAGT,+BAA+B,QACzC,eAAe;iBAGA,sBAAsB,KAAK;EAC1C,OAAO;;iBAGQ,yBAAyB;EACxC,YAAY;;YAGF,eAAe;EACzB,YAAY;;YAGF;EACV;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;YAGU,2BAA2B,QAAQ,eAAe,QAAQ;;;;;;;;;;;;;YAc1D,mBAAmB,cAAc;iBAE5B,qCAAqC;EACpD;;YAGU,gCACV,kBAAkB,iCACf,QAAQ;iBAEI;EACf,SAAS;EACT;EACA;EACA;EACA;;YAGU,4BACV,QAAQ,mCACL;iBAEY;EACf,SAAS;EACT;EACA;;YAGU,gCACV,QAAQ,6BACL;iBAEY;EACf;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;iBAGe;EACf;EACA;;iBAGe;EACf,eAAe;EACf;EACA,eAAe;;YAGL,wBACV,QAAQ,uBACL,QAAQ;iBAEI;EACf,+BAA+B;;;;;;EAM/B,kBAAkB;EAClB,+BAA+B;EAC/B,mBAAmB;EACnB;EACA;;YAGU;YAEA;YAUA;YAUA;EACV,MAAM;EACN,QAAQ;EACR;EACA,YAAY;EACZ;EACA;EACA;EACA;EACA;EACA,SAAS;;;;;;EAMT;;;;;;;EAOA;;;;;;;;;EASA;EAEA;IAAU;IAAuB;IAAiB;;;iBAGnC;EACf;EACA;EACA,QAAQ;EACR,SAAS,MAAM;EACf;EACA;EACA,UAAU;EACV,WAAW;EACX,WAAW;EACX;EACA;EAEA;IAAU;IAAuB;IAAiB;;;YAGxC"}
@@ -12,6 +12,14 @@ export interface StepExecutorBaseContext {
12
12
  step: LiFiStepExtended;
13
13
  allowUserInteraction: boolean;
14
14
  retryParams?: ExecuteStepRetryParams;
15
+ /**
16
+ * Aborts when `stopRouteExecution` stops the execution. Give it only to a
17
+ * wait that starts after the transaction is broadcast, such as the
18
+ * `/status` poll. Never give it to a sign, send or wallet call: a stopped
19
+ * run must finish those, so its late transaction data still reaches the
20
+ * stored route and a resume does not sign again.
21
+ */
22
+ signal?: AbortSignal;
15
23
  }
16
24
  export interface StepExecutorContext extends StepExecutorBaseContext {
17
25
  pollingIntervalMs?: number;
@@ -1 +1 @@
1
- {"version":3,"file":"execution.d.ts","names":[],"sources":["../../../src/types/execution.ts"],"mappings":";;;;iBASiB;EACf,eAAe;EACf,mBAAmB;EACnB,WAAW;EACX,SAAS;EACT;EACA,QAAQ;EACR,MAAM;EACN;EACA,cAAc;;iBAGC,4BAA4B;EAC3C;;iBAGe,WAAW,WAAW;EACrC,QAAQ;;EAER,UAAU;;YAGA"}
1
+ {"version":3,"file":"execution.d.ts","names":[],"sources":["../../../src/types/execution.ts"],"mappings":";;;;iBASiB;EACf,eAAe;EACf,mBAAmB;EACnB,WAAW;EACX,SAAS;EACT;EACA,QAAQ;EACR,MAAM;EACN;EACA,cAAc;;;;;;;;EAQd,SAAS;;iBAGM,4BAA4B;EAC3C;;iBAGe,WAAW,WAAW;EACrC,QAAQ;;EAER,UAAU;;YAGA"}
@@ -4,7 +4,7 @@ const checkPackageUpdates = async (packageName, packageVersion) => {
4
4
  try {
5
5
  const pkgName = packageName ?? "@lifi/sdk";
6
6
  const latestVersion = (await (await fetch(`https://registry.npmjs.org/${pkgName}/latest`)).json()).version;
7
- const currentVersion = packageVersion ?? "4.10.0";
7
+ const currentVersion = packageVersion ?? "4.12.0";
8
8
  if (latestVersion > currentVersion) console.warn(`${pkgName}: new package version is available. Please update as soon as possible to enjoy the newest features. Current version: ${currentVersion}. Latest version: ${latestVersion}.`);
9
9
  } catch (_error) {}
10
10
  };
@@ -5,9 +5,11 @@
5
5
  * @param interval The timeout in milliseconds between retries, or a function that receives the current poll count and returns the interval. Defaults to 5000
6
6
  * @param maxRetries Maximum number of calls that throw before the error is rethrown, defaults to 3
7
7
  * @param shouldRetry Optional predicate to determine if an error should trigger a retry
8
+ * @param signal Optional signal that ends the wait: no call starts after it aborts, and the sleep between calls ends at once
8
9
  * @returns The result of the fn function
9
10
  * @throws The error of fn if maximum retries is reached, or if shouldRetry returns false
11
+ * @throws The abort reason of `signal` once it aborts
10
12
  */
11
- export declare const waitForResult: <T>(fn: () => Promise<T | undefined>, interval?: number | ((poll: number) => number), maxRetries?: number, shouldRetry?: (count: number, error: unknown) => boolean) => Promise<T>;
13
+ export declare const waitForResult: <T>(fn: () => Promise<T | undefined>, interval?: number | ((poll: number) => number), maxRetries?: number, shouldRetry?: (count: number, error: unknown) => boolean, signal?: AbortSignal) => Promise<T>;
12
14
  //#endregion
13
15
  //# sourceMappingURL=waitForResult.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"waitForResult.d.ts","names":[],"sources":["../../../src/utils/waitForResult.ts"],"mappings":";;;;;;;;;;qBAWa,gBAAuB,GAClC,UAAU,QAAQ,gBAClB,sBAAqB,0BACrB,qBACA,eAAc,eAAe,+BAC5B,QAAQ"}
1
+ {"version":3,"file":"waitForResult.d.ts","names":[],"sources":["../../../src/utils/waitForResult.ts"],"mappings":";;;;;;;;;;;;qBAca,gBAAuB,GAClC,UAAU,QAAQ,gBAClB,sBAAqB,0BACrB,qBACA,eAAc,eAAe,4BAC7B,SAAS,gBACR,QAAQ"}
@@ -1,3 +1,4 @@
1
+ import { getAbortError } from "./abort.js";
1
2
  import { sleep } from "./sleep.js";
2
3
  //#region src/utils/waitForResult.ts
3
4
  /**
@@ -6,26 +7,30 @@ import { sleep } from "./sleep.js";
6
7
  * @param interval The timeout in milliseconds between retries, or a function that receives the current poll count and returns the interval. Defaults to 5000
7
8
  * @param maxRetries Maximum number of calls that throw before the error is rethrown, defaults to 3
8
9
  * @param shouldRetry Optional predicate to determine if an error should trigger a retry
10
+ * @param signal Optional signal that ends the wait: no call starts after it aborts, and the sleep between calls ends at once
9
11
  * @returns The result of the fn function
10
12
  * @throws The error of fn if maximum retries is reached, or if shouldRetry returns false
13
+ * @throws The abort reason of `signal` once it aborts
11
14
  */
12
- const waitForResult = async (fn, interval = 5e3, maxRetries = 3, shouldRetry = () => true) => {
15
+ const waitForResult = async (fn, interval = 5e3, maxRetries = 3, shouldRetry = () => true, signal) => {
13
16
  let result;
14
17
  let attempts = 0;
15
18
  let polls = 0;
16
19
  const getInterval = typeof interval === "function" ? interval : () => interval;
17
- while (!result) try {
18
- result = await fn();
20
+ while (!result) {
21
+ if (signal?.aborted) throw getAbortError(signal);
22
+ try {
23
+ result = await fn();
24
+ } catch (error) {
25
+ if (signal?.aborted) throw getAbortError(signal);
26
+ if (!shouldRetry(attempts, error)) throw error;
27
+ attempts++;
28
+ if (attempts === maxRetries) throw error;
29
+ }
19
30
  if (!result) {
20
- await sleep(getInterval(polls));
31
+ await sleep(getInterval(polls), { signal });
21
32
  polls++;
22
33
  }
23
- } catch (error) {
24
- if (!shouldRetry(attempts, error)) throw error;
25
- attempts++;
26
- if (attempts === maxRetries) throw error;
27
- await sleep(getInterval(polls));
28
- polls++;
29
34
  }
30
35
  return result;
31
36
  };
@@ -1 +1 @@
1
- {"version":3,"file":"waitForResult.js","names":[],"sources":["../../../src/utils/waitForResult.ts"],"sourcesContent":["import { sleep } from './sleep.js'\n\n/**\n * Repeatedly calls a given asynchronous function until it resolves with a truthy value\n * @param fn The function that should be repeated. A falsy result means \"no result yet\" and polls again, with no limit on the number of polls\n * @param interval The timeout in milliseconds between retries, or a function that receives the current poll count and returns the interval. Defaults to 5000\n * @param maxRetries Maximum number of calls that throw before the error is rethrown, defaults to 3\n * @param shouldRetry Optional predicate to determine if an error should trigger a retry\n * @returns The result of the fn function\n * @throws The error of fn if maximum retries is reached, or if shouldRetry returns false\n */\nexport const waitForResult = async <T>(\n fn: () => Promise<T | undefined>,\n interval: number | ((poll: number) => number) = 5000,\n maxRetries = 3,\n shouldRetry: (count: number, error: unknown) => boolean = () => true\n): Promise<T> => {\n let result: T | undefined\n let attempts = 0\n let polls = 0\n\n const getInterval = typeof interval === 'function' ? interval : () => interval\n\n while (!result) {\n try {\n result = await fn()\n if (!result) {\n await sleep(getInterval(polls))\n polls++\n }\n } catch (error) {\n if (!shouldRetry(attempts, error)) {\n throw error\n }\n attempts++\n if (attempts === maxRetries) {\n throw error\n }\n await sleep(getInterval(polls))\n polls++\n }\n }\n\n return result\n}\n"],"mappings":";;;;;;;;;;;AAWA,MAAa,gBAAgB,OAC3B,IACA,WAAgD,KAChD,aAAa,GACb,oBAAgE,SACjD;CACf,IAAI;CACJ,IAAI,WAAW;CACf,IAAI,QAAQ;CAEZ,MAAM,cAAc,OAAO,aAAa,aAAa,iBAAiB;CAEtE,OAAO,CAAC,QACN,IAAI;EACF,SAAS,MAAM,GAAG;EAClB,IAAI,CAAC,QAAQ;GACX,MAAM,MAAM,YAAY,KAAK,CAAC;GAC9B;EACF;CACF,SAAS,OAAO;EACd,IAAI,CAAC,YAAY,UAAU,KAAK,GAC9B,MAAM;EAER;EACA,IAAI,aAAa,YACf,MAAM;EAER,MAAM,MAAM,YAAY,KAAK,CAAC;EAC9B;CACF;CAGF,OAAO;AACT"}
1
+ {"version":3,"file":"waitForResult.js","names":[],"sources":["../../../src/utils/waitForResult.ts"],"sourcesContent":["import { getAbortError } from './abort.js'\nimport { sleep } from './sleep.js'\n\n/**\n * Repeatedly calls a given asynchronous function until it resolves with a truthy value\n * @param fn The function that should be repeated. A falsy result means \"no result yet\" and polls again, with no limit on the number of polls\n * @param interval The timeout in milliseconds between retries, or a function that receives the current poll count and returns the interval. Defaults to 5000\n * @param maxRetries Maximum number of calls that throw before the error is rethrown, defaults to 3\n * @param shouldRetry Optional predicate to determine if an error should trigger a retry\n * @param signal Optional signal that ends the wait: no call starts after it aborts, and the sleep between calls ends at once\n * @returns The result of the fn function\n * @throws The error of fn if maximum retries is reached, or if shouldRetry returns false\n * @throws The abort reason of `signal` once it aborts\n */\nexport const waitForResult = async <T>(\n fn: () => Promise<T | undefined>,\n interval: number | ((poll: number) => number) = 5000,\n maxRetries = 3,\n shouldRetry: (count: number, error: unknown) => boolean = () => true,\n signal?: AbortSignal\n): Promise<T> => {\n let result: T | undefined\n let attempts = 0\n let polls = 0\n\n const getInterval = typeof interval === 'function' ? interval : () => interval\n\n while (!result) {\n if (signal?.aborted) {\n throw getAbortError(signal)\n }\n try {\n result = await fn()\n } catch (error) {\n // An error of a call that the abort cut short is not a reason to retry.\n if (signal?.aborted) {\n throw getAbortError(signal)\n }\n if (!shouldRetry(attempts, error)) {\n throw error\n }\n attempts++\n if (attempts === maxRetries) {\n throw error\n }\n }\n if (!result) {\n // Rejects at once, also when the signal aborted during the call.\n await sleep(getInterval(polls), { signal })\n polls++\n }\n }\n\n return result\n}\n"],"mappings":";;;;;;;;;;;;;;AAcA,MAAa,gBAAgB,OAC3B,IACA,WAAgD,KAChD,aAAa,GACb,oBAAgE,MAChE,WACe;CACf,IAAI;CACJ,IAAI,WAAW;CACf,IAAI,QAAQ;CAEZ,MAAM,cAAc,OAAO,aAAa,aAAa,iBAAiB;CAEtE,OAAO,CAAC,QAAQ;EACd,IAAI,QAAQ,SACV,MAAM,cAAc,MAAM;EAE5B,IAAI;GACF,SAAS,MAAM,GAAG;EACpB,SAAS,OAAO;GAEd,IAAI,QAAQ,SACV,MAAM,cAAc,MAAM;GAE5B,IAAI,CAAC,YAAY,UAAU,KAAK,GAC9B,MAAM;GAER;GACA,IAAI,aAAa,YACf,MAAM;EAEV;EACA,IAAI,CAAC,QAAQ;GAEX,MAAM,MAAM,YAAY,KAAK,GAAG,EAAE,OAAO,CAAC;GAC1C;EACF;CACF;CAEA,OAAO;AACT"}
@@ -1,5 +1,5 @@
1
1
  //#region src/version.d.ts
2
2
  export declare const name = "@lifi/sdk";
3
- export declare const version = "4.10.0";
3
+ export declare const version = "4.12.0";
4
4
  //#endregion
5
5
  //# sourceMappingURL=version.d.ts.map
@@ -1,6 +1,6 @@
1
1
  //#region src/version.ts
2
2
  const name = "@lifi/sdk";
3
- const version = "4.10.0";
3
+ const version = "4.12.0";
4
4
  //#endregion
5
5
  export { name, version };
6
6
 
@@ -1 +1 @@
1
- {"version":3,"file":"version.js","names":[],"sources":["../../src/version.ts"],"sourcesContent":["export const name = '@lifi/sdk'\nexport const version = '4.10.0'\n"],"mappings":";AAAA,MAAa,OAAO;AACpB,MAAa,UAAU"}
1
+ {"version":3,"file":"version.js","names":[],"sources":["../../src/version.ts"],"sourcesContent":["export const name = '@lifi/sdk'\nexport const version = '4.12.0'\n"],"mappings":";AAAA,MAAa,OAAO;AACpB,MAAa,UAAU"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lifi/sdk",
3
- "version": "4.10.0",
3
+ "version": "4.12.0",
4
4
  "description": "LI.FI SDK for Any-to-Any Cross-Chain-Swap",
5
5
  "homepage": "https://github.com/lifinance/sdk",
6
6
  "bugs": {
@@ -28,7 +28,7 @@
28
28
  "./package.json": "./package.json"
29
29
  },
30
30
  "dependencies": {
31
- "@lifi/types": "^18.12.1"
31
+ "@lifi/types": "^18.13.0"
32
32
  },
33
33
  "publishConfig": {
34
34
  "access": "public"
@@ -8,8 +8,16 @@ import type {
8
8
  } from '../types/core.js'
9
9
  import { checkPackageUpdates } from '../utils/checkPackageUpdates.js'
10
10
  import { name, version } from '../version.js'
11
+ import { findProvider } from './findProvider.js'
11
12
  import { getClientStorage } from './getClientStorage.js'
12
13
 
14
+ // A provider replaces only one that serves the same chains. A provider that
15
+ // lists no chains keeps the bare type, so even an empty list stays apart.
16
+ const providerScope = (provider: SDKProvider): string =>
17
+ provider.chainIds
18
+ ? `${provider.type}:${[...provider.chainIds].sort().join(',')}`
19
+ : provider.type
20
+
13
21
  export function createClient(options: SDKConfig): SDKClient {
14
22
  if (!options.integrator) {
15
23
  throw new Error(
@@ -68,15 +76,15 @@ export function createClient(options: SDKConfig): SDKClient {
68
76
  get providers() {
69
77
  return _providers
70
78
  },
71
- getProvider(type: ChainType) {
72
- return this.providers.find((provider) => provider.type === type)
79
+ getProvider(type: ChainType, chainId?: ChainId) {
80
+ return findProvider(this.providers, type, chainId)
73
81
  },
74
82
  setProviders(newProviders: SDKProvider[]) {
75
83
  const providerMap = new Map(
76
- this.providers.map((provider) => [provider.type, provider])
84
+ this.providers.map((provider) => [providerScope(provider), provider])
77
85
  )
78
86
  for (const provider of newProviders) {
79
- providerMap.set(provider.type, provider)
87
+ providerMap.set(providerScope(provider), provider)
80
88
  }
81
89
  _providers = Array.from(providerMap.values())
82
90
  },
@@ -0,0 +1,21 @@
1
+ import type { ChainId, ChainType } from '@lifi/types'
2
+ import type { SDKProvider } from '../types/core.js'
3
+
4
+ /**
5
+ * The provider that serves a chain: the one that lists `chainId` in its
6
+ * `chainIds`, otherwise the provider of `chainType` that lists no chains.
7
+ */
8
+ export const findProvider = <T extends Pick<SDKProvider, 'type' | 'chainIds'>>(
9
+ providers: readonly T[],
10
+ chainType: ChainType,
11
+ chainId?: ChainId
12
+ ): T | undefined =>
13
+ (chainId === undefined
14
+ ? undefined
15
+ : providers.find(
16
+ (provider) =>
17
+ provider.type === chainType && provider.chainIds?.includes(chainId)
18
+ )) ??
19
+ providers.find(
20
+ (provider) => provider.type === chainType && !provider.chainIds
21
+ )
@@ -1,5 +1,6 @@
1
- import { ExecuteStepRetryError } from '../errors/errors.js'
2
- import type { SDKError } from '../errors/SDKError.js'
1
+ import { BaseError } from '../errors/baseError.js'
2
+ import { ExecuteStepRetryError, UnknownError } from '../errors/errors.js'
3
+ import { SDKError } from '../errors/SDKError.js'
3
4
  import type {
4
5
  ExecuteStepRetryParams,
5
6
  ExecutionAction,
@@ -16,6 +17,11 @@ import type {
16
17
  } from '../types/execution.js'
17
18
  import { StatusManager } from './StatusManager.js'
18
19
  import type { TaskPipeline } from './TaskPipeline.js'
20
+ import {
21
+ hasStepOpenTransaction,
22
+ isFinalTransactionError,
23
+ transactionConflictError,
24
+ } from './transactionState.js'
19
25
 
20
26
  // Please be careful when changing the defaults as it may break the behavior (e.g., background execution)
21
27
  const defaultInteractionSettings = {
@@ -49,7 +55,8 @@ export abstract class BaseStepExecutor implements StepExecutor {
49
55
  private createBaseContext = async (
50
56
  client: SDKClient,
51
57
  step: LiFiStepExtended,
52
- retryParams?: ExecuteStepRetryParams
58
+ retryParams?: ExecuteStepRetryParams,
59
+ signal?: AbortSignal
53
60
  ): Promise<StepExecutorBaseContext> => {
54
61
  const fromChain = await client.getChainById(step.action.fromChainId)
55
62
  const toChain = await client.getChainById(step.action.toChainId)
@@ -66,6 +73,7 @@ export abstract class BaseStepExecutor implements StepExecutor {
66
73
  statusManager: this.statusManager,
67
74
  executionOptions: this.executionOptions,
68
75
  allowUserInteraction: this.allowUserInteraction,
76
+ signal,
69
77
  }
70
78
  }
71
79
 
@@ -85,7 +93,8 @@ export abstract class BaseStepExecutor implements StepExecutor {
85
93
  executeStep = async (
86
94
  client: SDKClient,
87
95
  step: LiFiStepExtended,
88
- retryParams?: ExecuteStepRetryParams
96
+ retryParams?: ExecuteStepRetryParams,
97
+ signal?: AbortSignal
89
98
  ): Promise<LiFiStepExtended> => {
90
99
  try {
91
100
  step.execution = this.statusManager.initializeExecution(step)
@@ -93,7 +102,8 @@ export abstract class BaseStepExecutor implements StepExecutor {
93
102
  const baseContext = await this.createBaseContext(
94
103
  client,
95
104
  step,
96
- retryParams
105
+ retryParams,
106
+ signal
97
107
  )
98
108
  const context = await this.createContext(baseContext)
99
109
  const pipeline = this.createPipeline(context)
@@ -104,7 +114,30 @@ export abstract class BaseStepExecutor implements StepExecutor {
104
114
  } catch (error: any) {
105
115
  // Derive failing action from last in execution.actions
106
116
  const action = step.execution?.actions?.at(-1)
107
- const parsed = await this.parseErrors(error, step, action, retryParams)
117
+ // Read before parsing: parsers may rebuild the error and drop the marker.
118
+ let isFinal = isFinalTransactionError(error)
119
+ let parsed = await this.parseErrors(error, step, action, retryParams)
120
+ if (
121
+ parsed instanceof ExecuteStepRetryError &&
122
+ hasStepOpenTransaction(step)
123
+ ) {
124
+ // A retry runs the step again on an empty execution, which would erase
125
+ // the hash of a transaction that may still land. Fail with the original
126
+ // error instead, and keep the outcome unknown so a resume re-checks it.
127
+ // A BaseError keeps its code, so the widget shows its text. A replay
128
+ // that a task asked for has no error of its own: it fails as a sign
129
+ // task fails for the same state (`TransactionConflict`).
130
+ parsed = new SDKError(
131
+ error instanceof ExecuteStepRetryError
132
+ ? transactionConflictError()
133
+ : error instanceof BaseError
134
+ ? error
135
+ : new UnknownError(error?.message || parsed.message, error),
136
+ step,
137
+ action
138
+ )
139
+ isFinal = false
140
+ }
108
141
  if (!(parsed instanceof ExecuteStepRetryError)) {
109
142
  if (action) {
110
143
  this.statusManager.updateAction(step, action.type, 'FAILED', {
@@ -112,6 +145,7 @@ export abstract class BaseStepExecutor implements StepExecutor {
112
145
  message: parsed.cause?.message,
113
146
  code: parsed.code,
114
147
  },
148
+ ...(isFinal && { txFinal: true }),
115
149
  })
116
150
  } else {
117
151
  this.statusManager.updateExecution(step, {