@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.
- package/dist/cjs/core/BaseStepExecutor.d.ts +4 -1
- package/dist/cjs/core/BaseStepExecutor.js +35 -6
- package/dist/cjs/core/BaseStepExecutor.js.map +1 -1
- package/dist/cjs/core/StatusManager.js +8 -1
- package/dist/cjs/core/StatusManager.js.map +1 -1
- package/dist/cjs/core/TaskPipeline.js +9 -28
- package/dist/cjs/core/TaskPipeline.js.map +1 -1
- package/dist/cjs/core/utils.d.ts +5 -1
- package/dist/cjs/index.d.ts +1 -1
- package/dist/cjs/index.js +2 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/core.d.ts +10 -6
- package/dist/cjs/types/execution.d.ts +1 -4
- package/dist/cjs/utils/waitForResult.d.ts +1 -1
- package/dist/cjs/utils/waitForResult.js +6 -2
- package/dist/cjs/utils/waitForResult.js.map +1 -1
- package/dist/cjs/utils/withDedupe.d.ts +5 -0
- package/dist/cjs/utils/withDedupe.js +2 -0
- package/dist/cjs/utils/withDedupe.js.map +1 -1
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/core/BaseStepExecutor.d.ts +4 -1
- package/dist/esm/core/BaseStepExecutor.js +35 -6
- package/dist/esm/core/BaseStepExecutor.js.map +1 -1
- package/dist/esm/core/StatusManager.js +8 -1
- package/dist/esm/core/StatusManager.js.map +1 -1
- package/dist/esm/core/TaskPipeline.js +9 -28
- package/dist/esm/core/TaskPipeline.js.map +1 -1
- package/dist/esm/core/utils.d.ts +5 -1
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/core.d.ts +10 -6
- package/dist/esm/types/execution.d.ts +1 -4
- package/dist/esm/utils/waitForResult.d.ts +2 -2
- package/dist/esm/utils/waitForResult.js +7 -3
- package/dist/esm/utils/waitForResult.js.map +1 -1
- package/dist/esm/utils/withDedupe.d.ts +10 -0
- package/dist/esm/utils/withDedupe.js +1 -1
- package/dist/esm/utils/withDedupe.js.map +1 -1
- package/dist/esm/version.d.ts +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/types/core/BaseStepExecutor.d.ts +4 -1
- package/dist/types/core/BaseStepExecutor.d.ts.map +1 -1
- package/dist/types/core/StatusManager.d.ts.map +1 -1
- package/dist/types/core/TaskPipeline.d.ts.map +1 -1
- package/dist/types/core/utils.d.ts +5 -1
- package/dist/types/core/utils.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/types/core.d.ts +10 -6
- package/dist/types/types/core.d.ts.map +1 -1
- package/dist/types/types/execution.d.ts +1 -4
- package/dist/types/types/execution.d.ts.map +1 -1
- package/dist/types/utils/waitForResult.d.ts +2 -2
- package/dist/types/utils/waitForResult.d.ts.map +1 -1
- package/dist/types/utils/withDedupe.d.ts +10 -0
- package/dist/types/utils/withDedupe.d.ts.map +1 -1
- package/dist/types/version.d.ts +1 -1
- package/package.json +2 -2
- package/src/core/BaseStepExecutor.ts +46 -7
- package/src/core/StatusManager.ts +8 -1
- package/src/core/TaskPipeline.ts +10 -29
- package/src/index.ts +1 -1
- package/src/types/core.ts +4 -2
- package/src/types/execution.ts +0 -8
- package/src/utils/waitForResult.ts +9 -4
- package/src/utils/withDedupe.ts +1 -1
- 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'
|
package/src/types/execution.ts
CHANGED
|
@@ -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,
|
|
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(
|
|
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(
|
|
39
|
+
await sleep(getInterval(polls))
|
|
40
|
+
polls++
|
|
36
41
|
}
|
|
37
42
|
}
|
|
38
43
|
|
package/src/utils/withDedupe.ts
CHANGED
package/src/version.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export const name = '@lifi/sdk'
|
|
2
|
-
export const version = '4.0.0-alpha.
|
|
2
|
+
export const version = '4.0.0-alpha.19'
|