@lifi/sdk 4.0.0-alpha.17 → 4.0.0-alpha.19

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 (69) hide show
  1. package/dist/cjs/core/BaseStepExecutor.d.ts +4 -1
  2. package/dist/cjs/core/BaseStepExecutor.js +35 -6
  3. package/dist/cjs/core/BaseStepExecutor.js.map +1 -1
  4. package/dist/cjs/core/StatusManager.js +8 -1
  5. package/dist/cjs/core/StatusManager.js.map +1 -1
  6. package/dist/cjs/core/TaskPipeline.js +9 -28
  7. package/dist/cjs/core/TaskPipeline.js.map +1 -1
  8. package/dist/cjs/core/utils.d.ts +5 -1
  9. package/dist/cjs/index.d.ts +1 -1
  10. package/dist/cjs/index.js +2 -1
  11. package/dist/cjs/index.js.map +1 -1
  12. package/dist/cjs/types/core.d.ts +10 -6
  13. package/dist/cjs/types/execution.d.ts +1 -4
  14. package/dist/cjs/utils/waitForResult.d.ts +1 -1
  15. package/dist/cjs/utils/waitForResult.js +6 -2
  16. package/dist/cjs/utils/waitForResult.js.map +1 -1
  17. package/dist/cjs/utils/withDedupe.d.ts +5 -0
  18. package/dist/cjs/utils/withDedupe.js +2 -0
  19. package/dist/cjs/utils/withDedupe.js.map +1 -1
  20. package/dist/cjs/version.d.ts +1 -1
  21. package/dist/cjs/version.js +1 -1
  22. package/dist/esm/core/BaseStepExecutor.d.ts +4 -1
  23. package/dist/esm/core/BaseStepExecutor.js +35 -6
  24. package/dist/esm/core/BaseStepExecutor.js.map +1 -1
  25. package/dist/esm/core/StatusManager.js +8 -1
  26. package/dist/esm/core/StatusManager.js.map +1 -1
  27. package/dist/esm/core/TaskPipeline.js +9 -28
  28. package/dist/esm/core/TaskPipeline.js.map +1 -1
  29. package/dist/esm/core/utils.d.ts +5 -1
  30. package/dist/esm/index.d.ts +1 -1
  31. package/dist/esm/index.js +1 -1
  32. package/dist/esm/index.js.map +1 -1
  33. package/dist/esm/types/core.d.ts +10 -6
  34. package/dist/esm/types/execution.d.ts +1 -4
  35. package/dist/esm/utils/waitForResult.d.ts +2 -2
  36. package/dist/esm/utils/waitForResult.js +7 -3
  37. package/dist/esm/utils/waitForResult.js.map +1 -1
  38. package/dist/esm/utils/withDedupe.d.ts +10 -0
  39. package/dist/esm/utils/withDedupe.js +1 -1
  40. package/dist/esm/utils/withDedupe.js.map +1 -1
  41. package/dist/esm/version.d.ts +1 -1
  42. package/dist/esm/version.js +1 -1
  43. package/dist/types/core/BaseStepExecutor.d.ts +4 -1
  44. package/dist/types/core/BaseStepExecutor.d.ts.map +1 -1
  45. package/dist/types/core/StatusManager.d.ts.map +1 -1
  46. package/dist/types/core/TaskPipeline.d.ts.map +1 -1
  47. package/dist/types/core/utils.d.ts +5 -1
  48. package/dist/types/core/utils.d.ts.map +1 -1
  49. package/dist/types/index.d.ts +1 -1
  50. package/dist/types/index.d.ts.map +1 -1
  51. package/dist/types/types/core.d.ts +10 -6
  52. package/dist/types/types/core.d.ts.map +1 -1
  53. package/dist/types/types/execution.d.ts +1 -4
  54. package/dist/types/types/execution.d.ts.map +1 -1
  55. package/dist/types/utils/waitForResult.d.ts +2 -2
  56. package/dist/types/utils/waitForResult.d.ts.map +1 -1
  57. package/dist/types/utils/withDedupe.d.ts +10 -0
  58. package/dist/types/utils/withDedupe.d.ts.map +1 -1
  59. package/dist/types/version.d.ts +1 -1
  60. package/package.json +2 -2
  61. package/src/core/BaseStepExecutor.ts +46 -7
  62. package/src/core/StatusManager.ts +8 -1
  63. package/src/core/TaskPipeline.ts +10 -29
  64. package/src/index.ts +1 -1
  65. package/src/types/core.ts +4 -2
  66. package/src/types/execution.ts +0 -8
  67. package/src/utils/waitForResult.ts +9 -4
  68. package/src/utils/withDedupe.ts +1 -1
  69. package/src/version.ts +1 -1
package/src/index.ts CHANGED
@@ -109,4 +109,4 @@ export { isHex } from './utils/isHex.js'
109
109
  export { parseUnits } from './utils/parseUnits.js'
110
110
  export { sleep } from './utils/sleep.js'
111
111
  export { waitForResult } from './utils/waitForResult.js'
112
- export { withDedupe } from './utils/withDedupe.js'
112
+ export { LruMap, withDedupe } from './utils/withDedupe.js'
package/src/types/core.ts CHANGED
@@ -202,7 +202,6 @@ export interface ExecutionOptions {
202
202
  getContractCalls?: GetContractCallsHook
203
203
  adjustZeroOutputFromPreviousStep?: boolean
204
204
  executeInBackground?: boolean
205
- disableMessageSigning?: boolean
206
205
  /**
207
206
  * @deprecated
208
207
  */
@@ -238,12 +237,13 @@ export type ExecutionAction = {
238
237
  substatus?: Substatus
239
238
  substatusMessage?: string
240
239
  chainId?: number
241
- error?: { code: string | number; message: string; htmlMessage?: string }
242
240
  txHash?: string
243
241
  txLink?: string
244
242
  taskId?: string
245
243
  txType?: TransactionMethodType
246
244
  txHex?: string
245
+ // Errors occured during the action execution (within tasks)
246
+ error?: { code: string | number; message: string; htmlMessage?: string }
247
247
  }
248
248
 
249
249
  export interface Execution {
@@ -259,6 +259,8 @@ export interface Execution {
259
259
  gasCosts?: GasCost[]
260
260
  internalTxLink?: string
261
261
  externalTxLink?: string
262
+ // Errors occured outside of actions (e.g. during context creation)
263
+ error?: { code: string | number; message: string; htmlMessage?: string }
262
264
  }
263
265
 
264
266
  export type TransactionMethodType = 'standard' | 'relayed' | 'batched'
@@ -1,10 +1,7 @@
1
1
  import type { ExtendedChain } from '@lifi/types'
2
2
  import type { StatusManager } from '../core/StatusManager.js'
3
- import type { ExecuteStepRetryError } from '../errors/errors.js'
4
- import type { SDKError } from '../errors/SDKError.js'
5
3
  import type {
6
4
  ExecuteStepRetryParams,
7
- ExecutionAction,
8
5
  ExecutionOptions,
9
6
  LiFiStepExtended,
10
7
  SDKClient,
@@ -24,11 +21,6 @@ export interface StepExecutorBaseContext {
24
21
 
25
22
  export interface StepExecutorContext extends StepExecutorBaseContext {
26
23
  pollingIntervalMs?: number
27
- parseErrors: (
28
- error: Error,
29
- step?: LiFiStepExtended,
30
- action?: ExecutionAction
31
- ) => Promise<SDKError | ExecuteStepRetryError>
32
24
  }
33
25
 
34
26
  export interface TaskResult<TContext = Record<string, unknown>> {
@@ -3,7 +3,7 @@ import { sleep } from './sleep.js'
3
3
  /**
4
4
  * Repeatedly calls a given asynchronous function until it resolves with a value
5
5
  * @param fn The function that should be repeated
6
- * @param interval The timeout in milliseconds between retries, defaults to 5000
6
+ * @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
7
  * @param maxRetries Maximum number of retries before throwing an error, defaults to 3
8
8
  * @param shouldRetry Optional predicate to determine if an error should trigger a retry
9
9
  * @returns The result of the fn function
@@ -11,18 +11,22 @@ import { sleep } from './sleep.js'
11
11
  */
12
12
  export const waitForResult = async <T>(
13
13
  fn: () => Promise<T | undefined>,
14
- interval = 5000,
14
+ interval: number | ((poll: number) => number) = 5000,
15
15
  maxRetries = 3,
16
16
  shouldRetry: (count: number, error: unknown) => boolean = () => true
17
17
  ): Promise<T> => {
18
18
  let result: T | undefined
19
19
  let attempts = 0
20
+ let polls = 0
21
+
22
+ const getInterval = typeof interval === 'function' ? interval : () => interval
20
23
 
21
24
  while (!result) {
22
25
  try {
23
26
  result = await fn()
24
27
  if (!result) {
25
- await sleep(interval)
28
+ await sleep(getInterval(polls))
29
+ polls++
26
30
  }
27
31
  } catch (error) {
28
32
  if (!shouldRetry(attempts, error)) {
@@ -32,7 +36,8 @@ export const waitForResult = async <T>(
32
36
  if (attempts === maxRetries) {
33
37
  throw error
34
38
  }
35
- await sleep(interval)
39
+ await sleep(getInterval(polls))
40
+ polls++
36
41
  }
37
42
  }
38
43
 
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * https://en.wikipedia.org/wiki/Cache_replacement_policies#LRU
5
5
  */
6
- class LruMap<value = unknown> extends Map<string, value> {
6
+ export class LruMap<value = unknown> extends Map<string, value> {
7
7
  maxSize: number
8
8
 
9
9
  constructor(size: number) {
package/src/version.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  export const name = '@lifi/sdk'
2
- export const version = '4.0.0-alpha.17'
2
+ export const version = '4.0.0-alpha.19'