@lifi/sdk 4.0.0-alpha.9 → 4.0.0-beta.1
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/actions/getQuote.js +2 -1
- package/dist/cjs/actions/getQuote.js.map +1 -1
- package/dist/cjs/actions/getRelayedTransactionStatus.js +1 -1
- package/dist/cjs/actions/getRelayedTransactionStatus.js.map +1 -1
- package/dist/cjs/actions/getRelayerQuote.js +2 -1
- package/dist/cjs/actions/getRelayerQuote.js.map +1 -1
- package/dist/cjs/actions/getStepTransaction.js +18 -1
- package/dist/cjs/actions/getStepTransaction.js.map +1 -1
- package/dist/cjs/actions/getTokens.js +1 -1
- package/dist/cjs/actions/getTokens.js.map +1 -1
- package/dist/cjs/core/BaseStepExecutionTask.d.ts +5 -0
- package/dist/cjs/core/BaseStepExecutionTask.js +10 -0
- package/dist/cjs/core/BaseStepExecutionTask.js.map +1 -0
- package/dist/cjs/core/BaseStepExecutor.d.ts +10 -3
- package/dist/cjs/core/BaseStepExecutor.js +51 -0
- package/dist/cjs/core/BaseStepExecutor.js.map +1 -1
- package/dist/cjs/core/StatusManager.d.ts +12 -10
- package/dist/cjs/core/StatusManager.js +32 -33
- package/dist/cjs/core/StatusManager.js.map +1 -1
- package/dist/cjs/core/TaskPipeline.d.ts +7 -0
- package/dist/cjs/core/TaskPipeline.js +27 -0
- package/dist/cjs/core/TaskPipeline.js.map +1 -0
- package/dist/cjs/core/actionMessages.js +19 -3
- package/dist/cjs/core/actionMessages.js.map +1 -1
- package/dist/cjs/core/execution.js +13 -1
- package/dist/cjs/core/execution.js.map +1 -1
- package/dist/cjs/core/prepareRestart.js +2 -3
- package/dist/cjs/core/prepareRestart.js.map +1 -1
- package/dist/cjs/core/storage.d.ts +17 -0
- package/dist/cjs/core/storage.js +36 -0
- package/dist/cjs/core/storage.js.map +1 -0
- package/dist/cjs/core/tasks/CheckBalanceTask.d.ts +5 -0
- package/dist/cjs/core/tasks/CheckBalanceTask.js +26 -0
- package/dist/cjs/core/tasks/CheckBalanceTask.js.map +1 -0
- package/dist/cjs/core/tasks/PrepareTransactionTask.d.ts +5 -0
- package/dist/cjs/core/tasks/PrepareTransactionTask.js +36 -0
- package/dist/cjs/core/tasks/PrepareTransactionTask.js.map +1 -0
- package/dist/cjs/core/tasks/WaitForTransactionStatusTask.d.ts +8 -0
- package/dist/cjs/core/tasks/WaitForTransactionStatusTask.js +73 -0
- package/dist/cjs/core/tasks/WaitForTransactionStatusTask.js.map +1 -0
- package/dist/cjs/core/{checkBalance.d.ts → tasks/helpers/checkBalance.d.ts} +1 -1
- package/dist/cjs/core/{checkBalance.js → tasks/helpers/checkBalance.js} +4 -4
- package/dist/cjs/core/tasks/helpers/checkBalance.js.map +1 -0
- package/dist/cjs/core/tasks/helpers/getTransactionRequestData.d.ts +2 -0
- package/dist/cjs/core/tasks/helpers/getTransactionRequestData.js +30 -0
- package/dist/cjs/core/tasks/helpers/getTransactionRequestData.js.map +1 -0
- package/dist/cjs/core/{stepComparison.d.ts → tasks/helpers/stepComparison.d.ts} +2 -2
- package/dist/cjs/core/{stepComparison.js → tasks/helpers/stepComparison.js} +3 -3
- package/dist/cjs/core/tasks/helpers/stepComparison.js.map +1 -0
- package/dist/cjs/core/{waitForTransactionStatus.d.ts → tasks/helpers/waitForTransactionStatus.d.ts} +2 -2
- package/dist/cjs/core/{waitForTransactionStatus.js → tasks/helpers/waitForTransactionStatus.js} +7 -5
- package/dist/cjs/core/tasks/helpers/waitForTransactionStatus.js.map +1 -0
- package/dist/cjs/core/utils.d.ts +6 -1
- package/dist/cjs/errors/constants.d.ts +2 -1
- package/dist/cjs/errors/constants.js +1 -0
- package/dist/cjs/errors/constants.js.map +1 -1
- package/dist/cjs/errors/errors.d.ts +5 -0
- package/dist/cjs/errors/errors.js +9 -1
- package/dist/cjs/errors/errors.js.map +1 -1
- package/dist/cjs/errors/httpError.js +3 -3
- package/dist/cjs/errors/httpError.js.map +1 -1
- package/dist/cjs/index.d.ts +15 -6
- package/dist/cjs/index.js +26 -7
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/core.d.ts +14 -6
- package/dist/cjs/types/execution.d.ts +22 -0
- package/dist/cjs/types/execution.js +3 -0
- package/dist/cjs/types/execution.js.map +1 -0
- 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/cjs/version.js.map +1 -1
- package/dist/esm/actions/getQuote.js +2 -1
- package/dist/esm/actions/getQuote.js.map +1 -1
- package/dist/esm/actions/getRelayedTransactionStatus.js +1 -1
- package/dist/esm/actions/getRelayedTransactionStatus.js.map +1 -1
- package/dist/esm/actions/getRelayerQuote.js +2 -1
- package/dist/esm/actions/getRelayerQuote.js.map +1 -1
- package/dist/esm/actions/getStepTransaction.js +18 -1
- package/dist/esm/actions/getStepTransaction.js.map +1 -1
- package/dist/esm/actions/getTokens.js +1 -1
- package/dist/esm/actions/getTokens.js.map +1 -1
- package/dist/esm/core/BaseStepExecutionTask.d.ts +5 -0
- package/dist/esm/core/BaseStepExecutionTask.js +6 -0
- package/dist/esm/core/BaseStepExecutionTask.js.map +1 -0
- package/dist/esm/core/BaseStepExecutor.d.ts +10 -3
- package/dist/esm/core/BaseStepExecutor.js +52 -0
- package/dist/esm/core/BaseStepExecutor.js.map +1 -1
- package/dist/esm/core/StatusManager.d.ts +29 -27
- package/dist/esm/core/StatusManager.js +49 -50
- package/dist/esm/core/StatusManager.js.map +1 -1
- package/dist/esm/core/TaskPipeline.d.ts +7 -0
- package/dist/esm/core/TaskPipeline.js +23 -0
- package/dist/esm/core/TaskPipeline.js.map +1 -0
- package/dist/esm/core/actionMessages.js +19 -3
- package/dist/esm/core/actionMessages.js.map +1 -1
- package/dist/esm/core/execution.js +14 -3
- package/dist/esm/core/execution.js.map +1 -1
- package/dist/esm/core/prepareRestart.js +2 -3
- package/dist/esm/core/prepareRestart.js.map +1 -1
- package/dist/esm/core/storage.d.ts +17 -0
- package/dist/esm/core/storage.js +30 -0
- package/dist/esm/core/storage.js.map +1 -0
- package/dist/esm/core/tasks/CheckBalanceTask.d.ts +5 -0
- package/dist/esm/core/tasks/CheckBalanceTask.js +22 -0
- package/dist/esm/core/tasks/CheckBalanceTask.js.map +1 -0
- package/dist/esm/core/tasks/PrepareTransactionTask.d.ts +5 -0
- package/dist/esm/core/tasks/PrepareTransactionTask.js +32 -0
- package/dist/esm/core/tasks/PrepareTransactionTask.js.map +1 -0
- package/dist/esm/core/tasks/WaitForTransactionStatusTask.d.ts +8 -0
- package/dist/esm/core/tasks/WaitForTransactionStatusTask.js +74 -0
- package/dist/esm/core/tasks/WaitForTransactionStatusTask.js.map +1 -0
- package/dist/esm/core/{checkBalance.d.ts → tasks/helpers/checkBalance.d.ts} +1 -1
- package/dist/esm/core/{checkBalance.js → tasks/helpers/checkBalance.js} +4 -4
- package/dist/esm/core/tasks/helpers/checkBalance.js.map +1 -0
- package/dist/esm/core/tasks/helpers/getTransactionRequestData.d.ts +2 -0
- package/dist/esm/core/tasks/helpers/getTransactionRequestData.js +26 -0
- package/dist/esm/core/tasks/helpers/getTransactionRequestData.js.map +1 -0
- package/dist/esm/core/{stepComparison.d.ts → tasks/helpers/stepComparison.d.ts} +2 -2
- package/dist/esm/core/{stepComparison.js → tasks/helpers/stepComparison.js} +3 -3
- package/dist/esm/core/tasks/helpers/stepComparison.js.map +1 -0
- package/dist/esm/core/{waitForTransactionStatus.d.ts → tasks/helpers/waitForTransactionStatus.d.ts} +2 -2
- package/dist/esm/core/{waitForTransactionStatus.js → tasks/helpers/waitForTransactionStatus.js} +7 -5
- package/dist/esm/core/tasks/helpers/waitForTransactionStatus.js.map +1 -0
- package/dist/esm/core/utils.d.ts +6 -1
- package/dist/esm/errors/constants.d.ts +2 -1
- package/dist/esm/errors/constants.js +1 -0
- package/dist/esm/errors/constants.js.map +1 -1
- package/dist/esm/errors/errors.d.ts +10 -0
- package/dist/esm/errors/errors.js +12 -0
- package/dist/esm/errors/errors.js.map +1 -1
- package/dist/esm/errors/httpError.js +3 -3
- package/dist/esm/errors/httpError.js.map +1 -1
- package/dist/esm/index.d.ts +15 -6
- package/dist/esm/index.js +12 -5
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/core.d.ts +18 -6
- package/dist/esm/types/execution.d.ts +23 -0
- package/dist/esm/types/execution.js +2 -0
- package/dist/esm/types/execution.js.map +1 -0
- 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/esm/version.js.map +1 -1
- package/dist/types/actions/getRelayerQuote.d.ts.map +1 -1
- package/dist/types/actions/getStepTransaction.d.ts.map +1 -1
- package/dist/types/core/BaseStepExecutionTask.d.ts +6 -0
- package/dist/types/core/BaseStepExecutionTask.d.ts.map +1 -0
- package/dist/types/core/BaseStepExecutor.d.ts +10 -3
- package/dist/types/core/BaseStepExecutor.d.ts.map +1 -1
- package/dist/types/core/StatusManager.d.ts +29 -27
- package/dist/types/core/StatusManager.d.ts.map +1 -1
- package/dist/types/core/TaskPipeline.d.ts +8 -0
- package/dist/types/core/TaskPipeline.d.ts.map +1 -0
- package/dist/types/core/actionMessages.d.ts.map +1 -1
- package/dist/types/core/execution.d.ts.map +1 -1
- package/dist/types/core/prepareRestart.d.ts.map +1 -1
- package/dist/types/core/storage.d.ts +18 -0
- package/dist/types/core/storage.d.ts.map +1 -0
- package/dist/types/core/tasks/CheckBalanceTask.d.ts +6 -0
- package/dist/types/core/tasks/CheckBalanceTask.d.ts.map +1 -0
- package/dist/types/core/tasks/PrepareTransactionTask.d.ts +6 -0
- package/dist/types/core/tasks/PrepareTransactionTask.d.ts.map +1 -0
- package/dist/types/core/tasks/WaitForTransactionStatusTask.d.ts +9 -0
- package/dist/types/core/tasks/WaitForTransactionStatusTask.d.ts.map +1 -0
- package/dist/types/core/{checkBalance.d.ts → tasks/helpers/checkBalance.d.ts} +1 -1
- package/dist/types/core/tasks/helpers/checkBalance.d.ts.map +1 -0
- package/dist/types/core/tasks/helpers/getTransactionRequestData.d.ts +3 -0
- package/dist/types/core/tasks/helpers/getTransactionRequestData.d.ts.map +1 -0
- package/dist/types/core/{stepComparison.d.ts → tasks/helpers/stepComparison.d.ts} +2 -2
- package/dist/types/core/tasks/helpers/stepComparison.d.ts.map +1 -0
- package/dist/types/core/{waitForTransactionStatus.d.ts → tasks/helpers/waitForTransactionStatus.d.ts} +2 -2
- package/dist/types/core/tasks/helpers/waitForTransactionStatus.d.ts.map +1 -0
- package/dist/types/core/utils.d.ts +6 -1
- package/dist/types/core/utils.d.ts.map +1 -1
- package/dist/types/errors/constants.d.ts +2 -1
- package/dist/types/errors/constants.d.ts.map +1 -1
- package/dist/types/errors/errors.d.ts +10 -0
- package/dist/types/errors/errors.d.ts.map +1 -1
- package/dist/types/index.d.ts +15 -6
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/types/core.d.ts +18 -6
- package/dist/types/types/core.d.ts.map +1 -1
- package/dist/types/types/execution.d.ts +24 -0
- package/dist/types/types/execution.d.ts.map +1 -0
- 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/dist/types/version.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/actions/getQuote.ts +4 -1
- package/src/actions/getRelayedTransactionStatus.ts +1 -1
- package/src/actions/getRelayerQuote.ts +4 -1
- package/src/actions/getStepTransaction.ts +27 -11
- package/src/actions/getTokens.ts +4 -2
- package/src/core/BaseStepExecutionTask.ts +9 -0
- package/src/core/BaseStepExecutor.ts +90 -2
- package/src/core/StatusManager.ts +62 -61
- package/src/core/TaskPipeline.ts +28 -0
- package/src/core/actionMessages.ts +20 -3
- package/src/core/execution.ts +17 -3
- package/src/core/prepareRestart.ts +2 -3
- package/src/core/storage.ts +42 -0
- package/src/core/tasks/CheckBalanceTask.ts +29 -0
- package/src/core/tasks/PrepareTransactionTask.ts +62 -0
- package/src/core/tasks/WaitForTransactionStatusTask.ts +114 -0
- package/src/core/{checkBalance.ts → tasks/helpers/checkBalance.ts} +5 -5
- package/src/core/tasks/helpers/getTransactionRequestData.ts +47 -0
- package/src/core/{stepComparison.ts → tasks/helpers/stepComparison.ts} +5 -5
- package/src/core/{waitForTransactionStatus.ts → tasks/helpers/waitForTransactionStatus.ts} +9 -7
- package/src/errors/constants.ts +1 -0
- package/src/errors/errors.ts +24 -0
- package/src/errors/httpError.ts +3 -3
- package/src/index.ts +24 -4
- package/src/types/core.ts +22 -13
- package/src/types/execution.ts +32 -0
- package/src/utils/waitForResult.ts +9 -4
- package/src/utils/withDedupe.ts +1 -1
- package/src/version.ts +1 -1
- package/dist/cjs/core/checkBalance.js.map +0 -1
- package/dist/cjs/core/stepComparison.js.map +0 -1
- package/dist/cjs/core/waitForDestinationChainTransaction.d.ts +0 -4
- package/dist/cjs/core/waitForDestinationChainTransaction.js +0 -71
- package/dist/cjs/core/waitForDestinationChainTransaction.js.map +0 -1
- package/dist/cjs/core/waitForTransactionStatus.js.map +0 -1
- package/dist/esm/core/checkBalance.js.map +0 -1
- package/dist/esm/core/stepComparison.js.map +0 -1
- package/dist/esm/core/waitForDestinationChainTransaction.d.ts +0 -4
- package/dist/esm/core/waitForDestinationChainTransaction.js +0 -74
- package/dist/esm/core/waitForDestinationChainTransaction.js.map +0 -1
- package/dist/esm/core/waitForTransactionStatus.js.map +0 -1
- package/dist/types/core/checkBalance.d.ts.map +0 -1
- package/dist/types/core/stepComparison.d.ts.map +0 -1
- package/dist/types/core/waitForDestinationChainTransaction.d.ts +0 -5
- package/dist/types/core/waitForDestinationChainTransaction.d.ts.map +0 -1
- package/dist/types/core/waitForTransactionStatus.d.ts.map +0 -1
- package/src/core/waitForDestinationChainTransaction.ts +0 -112
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { ExtendedChain } from '@lifi/types';
|
|
2
|
+
import type { StatusManager } from '../core/StatusManager.js';
|
|
3
|
+
import type { ExecuteStepRetryParams, ExecutionOptions, LiFiStepExtended, SDKClient } from './core.js';
|
|
4
|
+
export interface StepExecutorBaseContext {
|
|
5
|
+
statusManager: StatusManager;
|
|
6
|
+
executionOptions?: ExecutionOptions;
|
|
7
|
+
fromChain: ExtendedChain;
|
|
8
|
+
toChain: ExtendedChain;
|
|
9
|
+
isBridgeExecution: boolean;
|
|
10
|
+
client: SDKClient;
|
|
11
|
+
step: LiFiStepExtended;
|
|
12
|
+
allowUserInteraction: boolean;
|
|
13
|
+
retryParams?: ExecuteStepRetryParams;
|
|
14
|
+
}
|
|
15
|
+
export interface StepExecutorContext extends StepExecutorBaseContext {
|
|
16
|
+
pollingIntervalMs?: number;
|
|
17
|
+
}
|
|
18
|
+
export interface TaskResult<TContext = Record<string, unknown>> {
|
|
19
|
+
status: TaskStatus;
|
|
20
|
+
/** Optional: data produced for downstream tasks. Pipeline merges into the executor context. */
|
|
21
|
+
context?: TContext;
|
|
22
|
+
}
|
|
23
|
+
export type TaskStatus = 'COMPLETED' | 'PAUSED';
|
|
24
|
+
//# sourceMappingURL=execution.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"execution.d.ts","sourceRoot":"","sources":["../../../src/types/execution.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAChD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAA;AAC7D,OAAO,KAAK,EACV,sBAAsB,EACtB,gBAAgB,EAChB,gBAAgB,EAChB,SAAS,EACV,MAAM,WAAW,CAAA;AAElB,MAAM,WAAW,uBAAuB;IACtC,aAAa,EAAE,aAAa,CAAA;IAC5B,gBAAgB,CAAC,EAAE,gBAAgB,CAAA;IACnC,SAAS,EAAE,aAAa,CAAA;IACxB,OAAO,EAAE,aAAa,CAAA;IACtB,iBAAiB,EAAE,OAAO,CAAA;IAC1B,MAAM,EAAE,SAAS,CAAA;IACjB,IAAI,EAAE,gBAAgB,CAAA;IACtB,oBAAoB,EAAE,OAAO,CAAA;IAC7B,WAAW,CAAC,EAAE,sBAAsB,CAAA;CACrC;AAED,MAAM,WAAW,mBAAoB,SAAQ,uBAAuB;IAClE,iBAAiB,CAAC,EAAE,MAAM,CAAA;CAC3B;AAED,MAAM,WAAW,UAAU,CAAC,QAAQ,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAC5D,MAAM,EAAE,UAAU,CAAA;IAClB,+FAA+F;IAC/F,OAAO,CAAC,EAAE,QAAQ,CAAA;CACnB;AAED,MAAM,MAAM,UAAU,GAAG,WAAW,GAAG,QAAQ,CAAA"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Repeatedly calls a given asynchronous function until it resolves with a value
|
|
3
3
|
* @param fn The function that should be repeated
|
|
4
|
-
* @param interval The timeout in milliseconds between retries,
|
|
4
|
+
* @param interval The timeout in milliseconds between retries, or a function that receives the current poll count and returns the interval. Defaults to 5000
|
|
5
5
|
* @param maxRetries Maximum number of retries before throwing an error, defaults to 3
|
|
6
6
|
* @param shouldRetry Optional predicate to determine if an error should trigger a retry
|
|
7
7
|
* @returns The result of the fn function
|
|
8
8
|
* @throws Error if maximum retries is reached, if function keeps returning undefined, or if shouldRetry returns false
|
|
9
9
|
*/
|
|
10
|
-
export declare const waitForResult: <T>(fn: () => Promise<T | undefined>, interval?: number, maxRetries?: number, shouldRetry?: (count: number, error: unknown) => boolean) => Promise<T>;
|
|
10
|
+
export declare const waitForResult: <T>(fn: () => Promise<T | undefined>, interval?: number | ((poll: number) => number), maxRetries?: number, shouldRetry?: (count: number, error: unknown) => boolean) => Promise<T>;
|
|
11
11
|
//# sourceMappingURL=waitForResult.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"waitForResult.d.ts","sourceRoot":"","sources":["../../../src/utils/waitForResult.ts"],"names":[],"mappings":"AAEA;;;;;;;;GAQG;AACH,eAAO,MAAM,aAAa,GAAU,CAAC,EACnC,IAAI,MAAM,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC,EAChC,
|
|
1
|
+
{"version":3,"file":"waitForResult.d.ts","sourceRoot":"","sources":["../../../src/utils/waitForResult.ts"],"names":[],"mappings":"AAEA;;;;;;;;GAQG;AACH,eAAO,MAAM,aAAa,GAAU,CAAC,EACnC,IAAI,MAAM,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC,EAChC,WAAU,MAAM,GAAG,CAAC,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAAQ,EACpD,mBAAc,EACd,cAAa,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,KAAK,OAAoB,KACnE,OAAO,CAAC,CAAC,CA4BX,CAAA"}
|
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Map with a LRU (Least recently used) policy.
|
|
3
|
+
*
|
|
4
|
+
* https://en.wikipedia.org/wiki/Cache_replacement_policies#LRU
|
|
5
|
+
*/
|
|
6
|
+
export declare class LruMap<value = unknown> extends Map<string, value> {
|
|
7
|
+
maxSize: number;
|
|
8
|
+
constructor(size: number);
|
|
9
|
+
set(key: string, value: value): this;
|
|
10
|
+
}
|
|
1
11
|
type WithDedupeOptions = {
|
|
2
12
|
enabled?: boolean | undefined;
|
|
3
13
|
id?: string | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"withDedupe.d.ts","sourceRoot":"","sources":["../../../src/utils/withDedupe.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"withDedupe.d.ts","sourceRoot":"","sources":["../../../src/utils/withDedupe.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,qBAAa,MAAM,CAAC,KAAK,GAAG,OAAO,CAAE,SAAQ,GAAG,CAAC,MAAM,EAAE,KAAK,CAAC;IAC7D,OAAO,EAAE,MAAM,CAAA;gBAEH,IAAI,EAAE,MAAM;IAKf,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK;CAOvC;AAKD,KAAK,iBAAiB,GAAG;IACvB,OAAO,CAAC,EAAE,OAAO,GAAG,SAAS,CAAA;IAC7B,EAAE,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CACxB,CAAA;AAED,uCAAuC;AACvC,wBAAgB,UAAU,CAAC,CAAC,EAC1B,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EACpB,EAAE,OAAc,EAAE,EAAE,EAAE,EAAE,iBAAiB,GACxC,OAAO,CAAC,CAAC,CAAC,CAUZ"}
|
package/dist/types/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,IAAI,cAAc,CAAA;AAC/B,eAAO,MAAM,OAAO,
|
|
1
|
+
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,IAAI,cAAc,CAAA;AAC/B,eAAO,MAAM,OAAO,iBAAiB,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lifi/sdk",
|
|
3
|
-
"version": "4.0.0-
|
|
3
|
+
"version": "4.0.0-beta.1",
|
|
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": "^17.
|
|
31
|
+
"@lifi/types": "^17.67.1"
|
|
32
32
|
},
|
|
33
33
|
"publishConfig": {
|
|
34
34
|
"access": "public"
|
package/src/actions/getQuote.ts
CHANGED
|
@@ -85,7 +85,10 @@ export async function getQuote(
|
|
|
85
85
|
params.preferExchanges ??= client.config.routeOptions?.exchanges?.prefer
|
|
86
86
|
|
|
87
87
|
for (const key of Object.keys(params)) {
|
|
88
|
-
if (
|
|
88
|
+
if (
|
|
89
|
+
params[key as keyof QuoteRequest] === undefined ||
|
|
90
|
+
params[key as keyof QuoteRequest] === null
|
|
91
|
+
) {
|
|
89
92
|
delete params[key as keyof QuoteRequest]
|
|
90
93
|
}
|
|
91
94
|
}
|
|
@@ -39,7 +39,7 @@ export const getRelayedTransactionStatus = async (
|
|
|
39
39
|
|
|
40
40
|
const decodedTaskId = decodeTaskId(taskId)
|
|
41
41
|
// Temporary solution during the transition between status endpoints
|
|
42
|
-
if (decodedTaskId.length
|
|
42
|
+
if (decodedTaskId.length >= 3) {
|
|
43
43
|
return (await getStatus(
|
|
44
44
|
client,
|
|
45
45
|
params,
|
|
@@ -56,7 +56,10 @@ export const getRelayerQuote = async (
|
|
|
56
56
|
params.preferExchanges ??= client.config.routeOptions?.exchanges?.prefer
|
|
57
57
|
|
|
58
58
|
for (const key of Object.keys(params)) {
|
|
59
|
-
if (
|
|
59
|
+
if (
|
|
60
|
+
params[key as keyof QuoteRequest] === undefined ||
|
|
61
|
+
params[key as keyof QuoteRequest] === null
|
|
62
|
+
) {
|
|
60
63
|
delete params[key as keyof QuoteRequest]
|
|
61
64
|
}
|
|
62
65
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { LiFiStep, RequestOptions, SignedLiFiStep } from '@lifi/types'
|
|
2
|
+
import { ChainId } from '@lifi/types'
|
|
2
3
|
import type { SDKClient } from '../types/core.js'
|
|
3
4
|
import { isStep } from '../utils/isStep.js'
|
|
4
5
|
import { request } from '../utils/request.js'
|
|
@@ -21,16 +22,31 @@ export const getStepTransaction = async (
|
|
|
21
22
|
console.warn('SDK Validation: Invalid Step', step)
|
|
22
23
|
}
|
|
23
24
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
25
|
+
const { config } = client
|
|
26
|
+
|
|
27
|
+
let requestUrl = `${config.apiUrl}/advanced/stepTransaction`
|
|
28
|
+
const jitoBundle = config.routeOptions?.jitoBundle
|
|
29
|
+
const svmSponsor = config.routeOptions?.svmSponsor
|
|
30
|
+
|
|
31
|
+
if (step.action.fromChainId === ChainId.SOL) {
|
|
32
|
+
const queryParams = new URLSearchParams()
|
|
33
|
+
if (jitoBundle) {
|
|
34
|
+
queryParams.set('jitoBundle', jitoBundle.toString())
|
|
35
|
+
}
|
|
36
|
+
if (svmSponsor) {
|
|
37
|
+
queryParams.set('svmSponsor', svmSponsor)
|
|
34
38
|
}
|
|
35
|
-
|
|
39
|
+
if (queryParams.size > 0) {
|
|
40
|
+
requestUrl = `${requestUrl}?${queryParams}`
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return await request<LiFiStep>(config, requestUrl, {
|
|
45
|
+
method: 'POST',
|
|
46
|
+
headers: {
|
|
47
|
+
'Content-Type': 'application/json',
|
|
48
|
+
},
|
|
49
|
+
body: JSON.stringify(step),
|
|
50
|
+
signal: options?.signal,
|
|
51
|
+
})
|
|
36
52
|
}
|
package/src/actions/getTokens.ts
CHANGED
|
@@ -40,11 +40,13 @@ export async function getTokens(
|
|
|
40
40
|
const urlSearchParams = new URLSearchParams(
|
|
41
41
|
params as Record<string, string>
|
|
42
42
|
).toString()
|
|
43
|
-
const
|
|
43
|
+
const _isExtended = params?.extended === true
|
|
44
44
|
const response = await withDedupe(
|
|
45
45
|
() =>
|
|
46
46
|
request<
|
|
47
|
-
typeof
|
|
47
|
+
typeof _isExtended extends true
|
|
48
|
+
? TokensExtendedResponse
|
|
49
|
+
: TokensResponse
|
|
48
50
|
>(client.config, `${client.config.apiUrl}/tokens?${urlSearchParams}`, {
|
|
49
51
|
signal: options?.signal,
|
|
50
52
|
}),
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { StepExecutorContext, TaskResult } from '../types/execution.js'
|
|
2
|
+
|
|
3
|
+
export abstract class BaseStepExecutionTask {
|
|
4
|
+
shouldRun(_context: StepExecutorContext): Promise<boolean> {
|
|
5
|
+
return Promise.resolve(true)
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
abstract run(context: StepExecutorContext): Promise<TaskResult>
|
|
9
|
+
}
|
|
@@ -1,12 +1,21 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { ExecuteStepRetryError } from '../errors/errors.js'
|
|
2
|
+
import type { SDKError } from '../errors/SDKError.js'
|
|
2
3
|
import type {
|
|
4
|
+
ExecuteStepRetryParams,
|
|
5
|
+
ExecutionAction,
|
|
3
6
|
ExecutionOptions,
|
|
4
7
|
InteractionSettings,
|
|
8
|
+
LiFiStepExtended,
|
|
5
9
|
SDKClient,
|
|
6
10
|
StepExecutor,
|
|
7
11
|
StepExecutorOptions,
|
|
8
12
|
} from '../types/core.js'
|
|
13
|
+
import type {
|
|
14
|
+
StepExecutorBaseContext,
|
|
15
|
+
StepExecutorContext,
|
|
16
|
+
} from '../types/execution.js'
|
|
9
17
|
import { StatusManager } from './StatusManager.js'
|
|
18
|
+
import type { TaskPipeline } from './TaskPipeline.js'
|
|
10
19
|
|
|
11
20
|
// Please be careful when changing the defaults as it may break the behavior (e.g., background execution)
|
|
12
21
|
const defaultInteractionSettings = {
|
|
@@ -37,5 +46,84 @@ export abstract class BaseStepExecutor implements StepExecutor {
|
|
|
37
46
|
this.allowExecution = interactionSettings.allowExecution
|
|
38
47
|
}
|
|
39
48
|
|
|
40
|
-
|
|
49
|
+
private createBaseContext = async (
|
|
50
|
+
client: SDKClient,
|
|
51
|
+
step: LiFiStepExtended,
|
|
52
|
+
retryParams?: ExecuteStepRetryParams
|
|
53
|
+
): Promise<StepExecutorBaseContext> => {
|
|
54
|
+
const fromChain = await client.getChainById(step.action.fromChainId)
|
|
55
|
+
const toChain = await client.getChainById(step.action.toChainId)
|
|
56
|
+
|
|
57
|
+
const isBridgeExecution = fromChain.id !== toChain.id
|
|
58
|
+
|
|
59
|
+
return {
|
|
60
|
+
client,
|
|
61
|
+
step,
|
|
62
|
+
fromChain,
|
|
63
|
+
toChain,
|
|
64
|
+
isBridgeExecution,
|
|
65
|
+
retryParams,
|
|
66
|
+
statusManager: this.statusManager,
|
|
67
|
+
executionOptions: this.executionOptions,
|
|
68
|
+
allowUserInteraction: this.allowUserInteraction,
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
abstract createContext(
|
|
73
|
+
baseContext: StepExecutorBaseContext
|
|
74
|
+
): Promise<StepExecutorContext>
|
|
75
|
+
|
|
76
|
+
abstract createPipeline(context: StepExecutorContext): TaskPipeline
|
|
77
|
+
|
|
78
|
+
abstract parseErrors(
|
|
79
|
+
error: Error,
|
|
80
|
+
step?: LiFiStepExtended,
|
|
81
|
+
action?: ExecutionAction,
|
|
82
|
+
retryParams?: ExecuteStepRetryParams
|
|
83
|
+
): Promise<SDKError | ExecuteStepRetryError>
|
|
84
|
+
|
|
85
|
+
executeStep = async (
|
|
86
|
+
client: SDKClient,
|
|
87
|
+
step: LiFiStepExtended,
|
|
88
|
+
retryParams?: ExecuteStepRetryParams
|
|
89
|
+
): Promise<LiFiStepExtended> => {
|
|
90
|
+
try {
|
|
91
|
+
step.execution = this.statusManager.initializeExecution(step)
|
|
92
|
+
|
|
93
|
+
const baseContext = await this.createBaseContext(
|
|
94
|
+
client,
|
|
95
|
+
step,
|
|
96
|
+
retryParams
|
|
97
|
+
)
|
|
98
|
+
const context = await this.createContext(baseContext)
|
|
99
|
+
const pipeline = this.createPipeline(context)
|
|
100
|
+
|
|
101
|
+
await pipeline.run(context)
|
|
102
|
+
|
|
103
|
+
return step
|
|
104
|
+
} catch (error: any) {
|
|
105
|
+
// Derive failing action from last in execution.actions
|
|
106
|
+
const action = step.execution?.actions?.at(-1)
|
|
107
|
+
const parsed = await this.parseErrors(error, step, action, retryParams)
|
|
108
|
+
if (!(parsed instanceof ExecuteStepRetryError)) {
|
|
109
|
+
if (action) {
|
|
110
|
+
this.statusManager.updateAction(step, action.type, 'FAILED', {
|
|
111
|
+
error: {
|
|
112
|
+
message: parsed.cause?.message,
|
|
113
|
+
code: parsed.code,
|
|
114
|
+
},
|
|
115
|
+
})
|
|
116
|
+
} else {
|
|
117
|
+
this.statusManager.updateExecution(step, {
|
|
118
|
+
status: 'FAILED',
|
|
119
|
+
error: {
|
|
120
|
+
message: parsed.cause?.message,
|
|
121
|
+
code: parsed.code,
|
|
122
|
+
},
|
|
123
|
+
})
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
throw parsed
|
|
127
|
+
}
|
|
128
|
+
}
|
|
41
129
|
}
|
|
@@ -4,23 +4,20 @@ import type {
|
|
|
4
4
|
ExecutionAction,
|
|
5
5
|
ExecutionActionStatus,
|
|
6
6
|
ExecutionActionType,
|
|
7
|
-
ExecutionStatus,
|
|
8
7
|
LiFiStepExtended,
|
|
9
8
|
} from '../types/core.js'
|
|
10
9
|
import { getActionMessage } from './actionMessages.js'
|
|
11
10
|
import { executionState } from './executionState.js'
|
|
12
11
|
|
|
13
|
-
type
|
|
12
|
+
type ActionProps = {
|
|
14
13
|
step: LiFiStepExtended
|
|
15
14
|
type: ExecutionActionType
|
|
16
|
-
chainId
|
|
17
|
-
status
|
|
15
|
+
chainId: ChainId
|
|
16
|
+
status: ExecutionActionStatus
|
|
18
17
|
}
|
|
19
18
|
|
|
20
19
|
/**
|
|
21
|
-
* Manages status updates of a route and provides various functions for tracking actions
|
|
22
|
-
* @param {string} routeId The route dd this StatusManger belongs to.
|
|
23
|
-
* @returns {StatusManager} An instance of StatusManager.
|
|
20
|
+
* Manages status updates of a route and provides various functions for tracking actions.
|
|
24
21
|
*/
|
|
25
22
|
export class StatusManager {
|
|
26
23
|
private readonly routeId: string
|
|
@@ -32,10 +29,10 @@ export class StatusManager {
|
|
|
32
29
|
|
|
33
30
|
/**
|
|
34
31
|
* Initializes the execution object of a Step.
|
|
35
|
-
* @param step
|
|
36
|
-
* @returns The initialized execution object for this step
|
|
32
|
+
* @param step The current step in execution
|
|
33
|
+
* @returns The initialized execution object for this step
|
|
37
34
|
*/
|
|
38
|
-
|
|
35
|
+
initializeExecution = (step: LiFiStepExtended): Execution => {
|
|
39
36
|
if (!step.execution) {
|
|
40
37
|
step.execution = {
|
|
41
38
|
startedAt: Date.now(),
|
|
@@ -50,6 +47,7 @@ export class StatusManager {
|
|
|
50
47
|
step.execution.startedAt = Date.now()
|
|
51
48
|
step.execution.status = 'PENDING'
|
|
52
49
|
step.execution.signedAt = undefined
|
|
50
|
+
step.execution.error = undefined
|
|
53
51
|
this.updateStepInRoute(step)
|
|
54
52
|
}
|
|
55
53
|
|
|
@@ -58,25 +56,20 @@ export class StatusManager {
|
|
|
58
56
|
|
|
59
57
|
/**
|
|
60
58
|
* Updates the execution object of a Step.
|
|
61
|
-
* @param step
|
|
62
|
-
* @param
|
|
63
|
-
* @param execution Optional. Information about received tokens
|
|
59
|
+
* @param step The current step in execution
|
|
60
|
+
* @param execution Partial execution data to merge
|
|
64
61
|
* @returns The step with the updated execution object
|
|
65
62
|
*/
|
|
66
63
|
updateExecution(
|
|
67
64
|
step: LiFiStepExtended,
|
|
68
|
-
|
|
69
|
-
execution?: Partial<Execution>
|
|
65
|
+
execution: Partial<Execution>
|
|
70
66
|
): LiFiStep {
|
|
71
67
|
if (!step.execution) {
|
|
72
68
|
throw Error("Can't update empty execution.")
|
|
73
69
|
}
|
|
74
|
-
step.execution
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
...step.execution,
|
|
78
|
-
...execution,
|
|
79
|
-
}
|
|
70
|
+
step.execution = {
|
|
71
|
+
...step.execution,
|
|
72
|
+
...execution,
|
|
80
73
|
}
|
|
81
74
|
this.updateStepInRoute(step)
|
|
82
75
|
return step
|
|
@@ -86,13 +79,11 @@ export class StatusManager {
|
|
|
86
79
|
* Finds an action of the specified type in the step's execution
|
|
87
80
|
* @param step The step to search in
|
|
88
81
|
* @param type The action type to find
|
|
89
|
-
* @param status Optional status to update the action with if found
|
|
90
82
|
* @returns The found action or undefined if not found
|
|
91
83
|
*/
|
|
92
84
|
findAction(
|
|
93
85
|
step: LiFiStepExtended,
|
|
94
|
-
type: ExecutionActionType
|
|
95
|
-
status?: ExecutionActionStatus
|
|
86
|
+
type: ExecutionActionType
|
|
96
87
|
): ExecutionAction | undefined {
|
|
97
88
|
if (!step.execution?.actions) {
|
|
98
89
|
throw new Error("Execution hasn't been initialized.")
|
|
@@ -100,46 +91,65 @@ export class StatusManager {
|
|
|
100
91
|
|
|
101
92
|
const action = step.execution.actions.find((p) => p.type === type)
|
|
102
93
|
|
|
103
|
-
if (action && status && action.status !== status) {
|
|
104
|
-
action.status = status
|
|
105
|
-
this.updateStepInRoute(step)
|
|
106
|
-
}
|
|
107
|
-
|
|
108
94
|
return action
|
|
109
95
|
}
|
|
110
96
|
|
|
111
97
|
/**
|
|
112
98
|
* Create and push a new action into the execution.
|
|
99
|
+
* Caller is responsible for ensuring an action of this type does not already exist.
|
|
113
100
|
* @param step The step that should contain the new action.
|
|
114
|
-
* @param type Type of the action.
|
|
101
|
+
* @param type Type of the action.
|
|
115
102
|
* @param chainId Chain Id of the action.
|
|
116
|
-
* @param status
|
|
117
|
-
* @returns
|
|
103
|
+
* @param status The initial status for the new action.
|
|
104
|
+
* @returns The created action.
|
|
118
105
|
*/
|
|
119
|
-
|
|
106
|
+
createAction = ({
|
|
120
107
|
step,
|
|
121
108
|
type,
|
|
122
109
|
chainId,
|
|
123
110
|
status,
|
|
124
|
-
}:
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
if (action) {
|
|
128
|
-
return action
|
|
111
|
+
}: ActionProps): ExecutionAction => {
|
|
112
|
+
if (!step.execution) {
|
|
113
|
+
throw new Error("Execution hasn't been initialized.")
|
|
129
114
|
}
|
|
130
115
|
|
|
131
116
|
const newAction: ExecutionAction = {
|
|
132
|
-
type
|
|
133
|
-
message: getActionMessage(type, status
|
|
134
|
-
status
|
|
135
|
-
chainId
|
|
117
|
+
type,
|
|
118
|
+
message: getActionMessage(type, status),
|
|
119
|
+
status,
|
|
120
|
+
chainId,
|
|
136
121
|
}
|
|
137
122
|
|
|
138
|
-
step.execution
|
|
123
|
+
step.execution.actions.push(newAction)
|
|
139
124
|
this.updateStepInRoute(step)
|
|
140
125
|
return newAction
|
|
141
126
|
}
|
|
142
127
|
|
|
128
|
+
/**
|
|
129
|
+
* Find an existing action by type and update it, or create a new one if none exists.
|
|
130
|
+
* @param step The step that should contain the action.
|
|
131
|
+
* @param type Type of the action. Used to identify already existing actions.
|
|
132
|
+
* @param chainId Chain Id of the action (used when creating).
|
|
133
|
+
* @param status The status to set on the found or newly created action.
|
|
134
|
+
* @returns The updated or newly created action.
|
|
135
|
+
*/
|
|
136
|
+
initializeAction = ({
|
|
137
|
+
step,
|
|
138
|
+
type,
|
|
139
|
+
chainId,
|
|
140
|
+
status,
|
|
141
|
+
}: ActionProps): ExecutionAction => {
|
|
142
|
+
const action = this.findAction(step, type)
|
|
143
|
+
|
|
144
|
+
if (action) {
|
|
145
|
+
return this.updateAction(step, type, status, {
|
|
146
|
+
error: undefined,
|
|
147
|
+
})
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
return this.createAction({ step, type, chainId, status })
|
|
151
|
+
}
|
|
152
|
+
|
|
143
153
|
/**
|
|
144
154
|
* Update an action object.
|
|
145
155
|
* @param step The step where the action should be updated
|
|
@@ -152,7 +162,7 @@ export class StatusManager {
|
|
|
152
162
|
step: LiFiStepExtended,
|
|
153
163
|
type: ExecutionActionType,
|
|
154
164
|
status: ExecutionActionStatus,
|
|
155
|
-
params?: Partial<ExecutionAction>
|
|
165
|
+
params?: Partial<ExecutionAction & { signedAt?: number }>
|
|
156
166
|
): ExecutionAction => {
|
|
157
167
|
if (!step.execution) {
|
|
158
168
|
throw new Error("Can't update an empty step execution.")
|
|
@@ -168,11 +178,17 @@ export class StatusManager {
|
|
|
168
178
|
break
|
|
169
179
|
case 'FAILED':
|
|
170
180
|
step.execution.status = 'FAILED'
|
|
181
|
+
if (params?.error) {
|
|
182
|
+
step.execution.error = params.error
|
|
183
|
+
}
|
|
171
184
|
break
|
|
172
185
|
case 'DONE':
|
|
173
186
|
break
|
|
174
187
|
case 'PENDING':
|
|
175
188
|
step.execution.status = 'PENDING'
|
|
189
|
+
if (params?.signedAt) {
|
|
190
|
+
step.execution.signedAt = params.signedAt
|
|
191
|
+
}
|
|
176
192
|
break
|
|
177
193
|
case 'RESET_REQUIRED':
|
|
178
194
|
case 'MESSAGE_REQUIRED':
|
|
@@ -187,9 +203,8 @@ export class StatusManager {
|
|
|
187
203
|
currentAction.message = getActionMessage(type, status)
|
|
188
204
|
// set extra parameters or overwrite the standard params set in the switch statement
|
|
189
205
|
if (params) {
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
}
|
|
206
|
+
const { signedAt: _signedAt, ...rest } = params
|
|
207
|
+
Object.assign(currentAction, rest)
|
|
193
208
|
}
|
|
194
209
|
// Sort actions, the ones with DONE status go first
|
|
195
210
|
step.execution.actions = [
|
|
@@ -200,20 +215,6 @@ export class StatusManager {
|
|
|
200
215
|
return currentAction
|
|
201
216
|
}
|
|
202
217
|
|
|
203
|
-
/**
|
|
204
|
-
* Remove an action from the execution
|
|
205
|
-
* @param step The step where the action should be removed from
|
|
206
|
-
* @param type The action type to remove
|
|
207
|
-
*/
|
|
208
|
-
removeAction = (step: LiFiStepExtended, type: ExecutionActionType): void => {
|
|
209
|
-
if (!step.execution) {
|
|
210
|
-
throw new Error("Execution hasn't been initialized.")
|
|
211
|
-
}
|
|
212
|
-
const index = step.execution.actions.findIndex((p) => p.type === type)
|
|
213
|
-
step.execution.actions.splice(index, 1)
|
|
214
|
-
this.updateStepInRoute(step)
|
|
215
|
-
}
|
|
216
|
-
|
|
217
218
|
updateStepInRoute = (step: LiFiStep): LiFiStep => {
|
|
218
219
|
if (!this.shouldUpdate) {
|
|
219
220
|
return step
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { StepExecutorContext, TaskResult } from '../types/execution.js'
|
|
2
|
+
import type { BaseStepExecutionTask } from './BaseStepExecutionTask.js'
|
|
3
|
+
|
|
4
|
+
export class TaskPipeline {
|
|
5
|
+
private readonly tasks: BaseStepExecutionTask[]
|
|
6
|
+
|
|
7
|
+
constructor(tasks: BaseStepExecutionTask[]) {
|
|
8
|
+
this.tasks = tasks
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
async run(context: StepExecutorContext): Promise<TaskResult> {
|
|
12
|
+
for (const task of this.tasks) {
|
|
13
|
+
const shouldRun = await task.shouldRun(context)
|
|
14
|
+
if (!shouldRun) {
|
|
15
|
+
continue
|
|
16
|
+
}
|
|
17
|
+
const result = await task.run(context)
|
|
18
|
+
if (result.status === 'PAUSED') {
|
|
19
|
+
return { status: 'PAUSED' }
|
|
20
|
+
}
|
|
21
|
+
if (result.context && typeof result.context === 'object') {
|
|
22
|
+
Object.assign(context, result.context)
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return { status: 'COMPLETED' }
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -8,11 +8,20 @@ const actionMessages: Record<
|
|
|
8
8
|
ExecutionActionType,
|
|
9
9
|
Partial<Record<ExecutionActionStatus, string>>
|
|
10
10
|
> = {
|
|
11
|
-
|
|
11
|
+
CHECK_ALLOWANCE: {
|
|
12
|
+
STARTED: 'Checking token allowance',
|
|
13
|
+
PENDING: 'Waiting for token allowance check',
|
|
14
|
+
DONE: 'Token allowance checked',
|
|
15
|
+
},
|
|
16
|
+
RESET_ALLOWANCE: {
|
|
17
|
+
STARTED: 'Resetting token allowance',
|
|
18
|
+
RESET_REQUIRED: 'Resetting token allowance',
|
|
19
|
+
PENDING: 'Waiting for token allowance reset',
|
|
20
|
+
DONE: 'Token allowance reset',
|
|
21
|
+
},
|
|
22
|
+
SET_ALLOWANCE: {
|
|
12
23
|
STARTED: 'Setting token allowance',
|
|
13
24
|
ACTION_REQUIRED: 'Set token allowance',
|
|
14
|
-
RESET_REQUIRED: 'Resetting token allowance',
|
|
15
|
-
MESSAGE_REQUIRED: 'Sign token allowance message',
|
|
16
25
|
PENDING: 'Waiting for token allowance',
|
|
17
26
|
DONE: 'Token allowance set',
|
|
18
27
|
},
|
|
@@ -31,6 +40,7 @@ const actionMessages: Record<
|
|
|
31
40
|
DONE: 'Bridge transaction confirmed',
|
|
32
41
|
},
|
|
33
42
|
RECEIVING_CHAIN: {
|
|
43
|
+
STARTED: 'Waiting for destination chain',
|
|
34
44
|
PENDING: 'Waiting for destination chain',
|
|
35
45
|
DONE: 'Bridge completed',
|
|
36
46
|
},
|
|
@@ -40,7 +50,14 @@ const actionMessages: Record<
|
|
|
40
50
|
PENDING: 'Waiting for permit message',
|
|
41
51
|
DONE: 'Permit message signed',
|
|
42
52
|
},
|
|
53
|
+
NATIVE_PERMIT: {
|
|
54
|
+
STARTED: 'Preparing transaction',
|
|
55
|
+
ACTION_REQUIRED: 'Sign permit message',
|
|
56
|
+
PENDING: 'Waiting for permit message',
|
|
57
|
+
DONE: 'Permit message signed',
|
|
58
|
+
},
|
|
43
59
|
}
|
|
60
|
+
|
|
44
61
|
const substatusMessages: Record<
|
|
45
62
|
StatusMessage,
|
|
46
63
|
Partial<Record<Substatus, string>>
|