@lifi/sdk 4.0.0-alpha.8 → 4.0.0-beta.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.
- 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/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 +53 -0
- package/dist/cjs/core/BaseStepExecutor.js.map +1 -1
- package/dist/cjs/core/StatusManager.d.ts +13 -12
- package/dist/cjs/core/StatusManager.js +55 -61
- 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.d.ts +4 -0
- package/dist/cjs/core/{processMessages.js → actionMessages.js} +25 -9
- package/dist/cjs/core/actionMessages.js.map +1 -0
- package/dist/cjs/core/execution.js +13 -1
- package/dist/cjs/core/execution.js.map +1 -1
- package/dist/cjs/core/prepareRestart.js +6 -6
- 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/tasks/helpers/waitForTransactionStatus.d.ts +4 -0
- package/dist/cjs/core/{waitForTransactionStatus.js → tasks/helpers/waitForTransactionStatus.js} +10 -8
- package/dist/cjs/core/tasks/helpers/waitForTransactionStatus.js.map +1 -0
- package/dist/cjs/core/utils.d.ts +6 -1
- package/dist/cjs/errors/SDKError.d.ts +3 -3
- package/dist/cjs/errors/SDKError.js +3 -3
- package/dist/cjs/errors/SDKError.js.map +1 -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/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 +21 -17
- 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/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 +53 -0
- package/dist/esm/core/BaseStepExecutor.js.map +1 -1
- package/dist/esm/core/StatusManager.d.ts +40 -39
- package/dist/esm/core/StatusManager.js +86 -92
- 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.d.ts +4 -0
- package/dist/esm/core/{processMessages.js → actionMessages.js} +24 -8
- package/dist/esm/core/actionMessages.js.map +1 -0
- package/dist/esm/core/execution.js +14 -3
- package/dist/esm/core/execution.js.map +1 -1
- package/dist/esm/core/prepareRestart.js +10 -9
- 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/tasks/helpers/waitForTransactionStatus.d.ts +4 -0
- package/dist/esm/core/{waitForTransactionStatus.js → tasks/helpers/waitForTransactionStatus.js} +9 -7
- package/dist/esm/core/tasks/helpers/waitForTransactionStatus.js.map +1 -0
- package/dist/esm/core/utils.d.ts +6 -1
- package/dist/esm/errors/SDKError.d.ts +3 -3
- package/dist/esm/errors/SDKError.js +4 -4
- package/dist/esm/errors/SDKError.js.map +1 -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/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 +25 -17
- 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 +40 -39
- 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 +5 -0
- package/dist/types/core/actionMessages.d.ts.map +1 -0
- 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/tasks/helpers/waitForTransactionStatus.d.ts +5 -0
- 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/SDKError.d.ts +3 -3
- package/dist/types/errors/SDKError.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 +25 -17
- 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/core/BaseStepExecutionTask.ts +9 -0
- package/src/core/BaseStepExecutor.ts +91 -2
- package/src/core/StatusManager.ts +108 -113
- package/src/core/TaskPipeline.ts +28 -0
- package/src/core/{processMessages.ts → actionMessages.ts} +32 -12
- package/src/core/execution.ts +17 -3
- package/src/core/prepareRestart.ts +12 -11
- 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} +11 -9
- package/src/errors/SDKError.ts +5 -5
- package/src/errors/constants.ts +1 -0
- package/src/errors/errors.ts +24 -0
- package/src/index.ts +27 -7
- package/src/types/core.ts +30 -25
- 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/processMessages.d.ts +0 -4
- package/dist/cjs/core/processMessages.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 -69
- package/dist/cjs/core/waitForDestinationChainTransaction.js.map +0 -1
- package/dist/cjs/core/waitForTransactionStatus.d.ts +0 -4
- package/dist/cjs/core/waitForTransactionStatus.js.map +0 -1
- package/dist/esm/core/checkBalance.js.map +0 -1
- package/dist/esm/core/processMessages.d.ts +0 -4
- package/dist/esm/core/processMessages.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 -71
- package/dist/esm/core/waitForDestinationChainTransaction.js.map +0 -1
- package/dist/esm/core/waitForTransactionStatus.d.ts +0 -4
- package/dist/esm/core/waitForTransactionStatus.js.map +0 -1
- package/dist/types/core/checkBalance.d.ts.map +0 -1
- package/dist/types/core/processMessages.d.ts +0 -5
- package/dist/types/core/processMessages.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 +0 -5
- package/dist/types/core/waitForTransactionStatus.d.ts.map +0 -1
- package/src/core/waitForDestinationChainTransaction.ts +0 -106
|
@@ -1,16 +1,13 @@
|
|
|
1
1
|
import type { ChainId, LiFiStep } from '@lifi/types';
|
|
2
|
-
import type { Execution,
|
|
3
|
-
type
|
|
2
|
+
import type { Execution, ExecutionAction, ExecutionActionStatus, ExecutionActionType, LiFiStepExtended } from '../types/core.js';
|
|
3
|
+
type ActionProps = {
|
|
4
4
|
step: LiFiStepExtended;
|
|
5
|
-
type:
|
|
6
|
-
chainId
|
|
7
|
-
status
|
|
8
|
-
startedAt?: number;
|
|
5
|
+
type: ExecutionActionType;
|
|
6
|
+
chainId: ChainId;
|
|
7
|
+
status: ExecutionActionStatus;
|
|
9
8
|
};
|
|
10
9
|
/**
|
|
11
|
-
* Manages status updates of a route and provides various functions for tracking
|
|
12
|
-
* @param {string} routeId The route dd this StatusManger belongs to.
|
|
13
|
-
* @returns {StatusManager} An instance of StatusManager.
|
|
10
|
+
* Manages status updates of a route and provides various functions for tracking actions.
|
|
14
11
|
*/
|
|
15
12
|
export declare class StatusManager {
|
|
16
13
|
private readonly routeId;
|
|
@@ -18,50 +15,54 @@ export declare class StatusManager {
|
|
|
18
15
|
constructor(routeId: string);
|
|
19
16
|
/**
|
|
20
17
|
* Initializes the execution object of a Step.
|
|
21
|
-
* @param step
|
|
22
|
-
* @returns The initialized execution object for this step
|
|
18
|
+
* @param step The current step in execution
|
|
19
|
+
* @returns The initialized execution object for this step
|
|
23
20
|
*/
|
|
24
|
-
|
|
21
|
+
initializeExecution: (step: LiFiStepExtended) => Execution;
|
|
25
22
|
/**
|
|
26
23
|
* Updates the execution object of a Step.
|
|
27
|
-
* @param step
|
|
28
|
-
* @param
|
|
29
|
-
* @param execution Optional. Information about received tokens
|
|
24
|
+
* @param step The current step in execution
|
|
25
|
+
* @param execution Partial execution data to merge
|
|
30
26
|
* @returns The step with the updated execution object
|
|
31
27
|
*/
|
|
32
|
-
updateExecution(step: LiFiStepExtended,
|
|
28
|
+
updateExecution(step: LiFiStepExtended, execution: Partial<Execution>): LiFiStep;
|
|
33
29
|
/**
|
|
34
|
-
* Finds
|
|
30
|
+
* Finds an action of the specified type in the step's execution
|
|
35
31
|
* @param step The step to search in
|
|
36
|
-
* @param type The
|
|
37
|
-
* @
|
|
38
|
-
* @returns The found process or undefined if not found
|
|
32
|
+
* @param type The action type to find
|
|
33
|
+
* @returns The found action or undefined if not found
|
|
39
34
|
*/
|
|
40
|
-
|
|
35
|
+
findAction(step: LiFiStepExtended, type: ExecutionActionType): ExecutionAction | undefined;
|
|
41
36
|
/**
|
|
42
|
-
* Create and push a new
|
|
43
|
-
*
|
|
44
|
-
* @param
|
|
45
|
-
* @param
|
|
46
|
-
* @param
|
|
47
|
-
* @
|
|
37
|
+
* Create and push a new action into the execution.
|
|
38
|
+
* Caller is responsible for ensuring an action of this type does not already exist.
|
|
39
|
+
* @param step The step that should contain the new action.
|
|
40
|
+
* @param type Type of the action.
|
|
41
|
+
* @param chainId Chain Id of the action.
|
|
42
|
+
* @param status The initial status for the new action.
|
|
43
|
+
* @returns The created action.
|
|
48
44
|
*/
|
|
49
|
-
|
|
45
|
+
createAction: ({ step, type, chainId, status, }: ActionProps) => ExecutionAction;
|
|
50
46
|
/**
|
|
51
|
-
*
|
|
52
|
-
* @param step The step
|
|
53
|
-
* @param type
|
|
54
|
-
* @param
|
|
55
|
-
* @param
|
|
56
|
-
* @returns The
|
|
47
|
+
* Find an existing action by type and update it, or create a new one if none exists.
|
|
48
|
+
* @param step The step that should contain the action.
|
|
49
|
+
* @param type Type of the action. Used to identify already existing actions.
|
|
50
|
+
* @param chainId Chain Id of the action (used when creating).
|
|
51
|
+
* @param status The status to set on the found or newly created action.
|
|
52
|
+
* @returns The updated or newly created action.
|
|
57
53
|
*/
|
|
58
|
-
|
|
54
|
+
initializeAction: ({ step, type, chainId, status, }: ActionProps) => ExecutionAction;
|
|
59
55
|
/**
|
|
60
|
-
*
|
|
61
|
-
* @param step The step where the
|
|
62
|
-
* @param type The
|
|
56
|
+
* Update an action object.
|
|
57
|
+
* @param step The step where the action should be updated
|
|
58
|
+
* @param type The action type to update
|
|
59
|
+
* @param status The status the action gets.
|
|
60
|
+
* @param [params] Additional parameters to append to the action.
|
|
61
|
+
* @returns The updated action
|
|
63
62
|
*/
|
|
64
|
-
|
|
63
|
+
updateAction: (step: LiFiStepExtended, type: ExecutionActionType, status: ExecutionActionStatus, params?: Partial<ExecutionAction & {
|
|
64
|
+
signedAt?: number;
|
|
65
|
+
}>) => ExecutionAction;
|
|
65
66
|
updateStepInRoute: (step: LiFiStep) => LiFiStep;
|
|
66
67
|
allowUpdates(value: boolean): void;
|
|
67
68
|
}
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
+
import { getActionMessage } from './actionMessages.js';
|
|
1
2
|
import { executionState } from './executionState.js';
|
|
2
|
-
import { getProcessMessage } from './processMessages.js';
|
|
3
3
|
/**
|
|
4
|
-
* Manages status updates of a route and provides various functions for tracking
|
|
5
|
-
* @param {string} routeId The route dd this StatusManger belongs to.
|
|
6
|
-
* @returns {StatusManager} An instance of StatusManager.
|
|
4
|
+
* Manages status updates of a route and provides various functions for tracking actions.
|
|
7
5
|
*/
|
|
8
6
|
export class StatusManager {
|
|
9
7
|
routeId;
|
|
@@ -13,15 +11,15 @@ export class StatusManager {
|
|
|
13
11
|
}
|
|
14
12
|
/**
|
|
15
13
|
* Initializes the execution object of a Step.
|
|
16
|
-
* @param step
|
|
17
|
-
* @returns The initialized execution object for this step
|
|
14
|
+
* @param step The current step in execution
|
|
15
|
+
* @returns The initialized execution object for this step
|
|
18
16
|
*/
|
|
19
|
-
|
|
17
|
+
initializeExecution = (step) => {
|
|
20
18
|
if (!step.execution) {
|
|
21
19
|
step.execution = {
|
|
22
|
-
status: 'PENDING',
|
|
23
|
-
process: [],
|
|
24
20
|
startedAt: Date.now(),
|
|
21
|
+
status: 'PENDING',
|
|
22
|
+
actions: [],
|
|
25
23
|
};
|
|
26
24
|
this.updateStepInRoute(step);
|
|
27
25
|
}
|
|
@@ -29,144 +27,140 @@ export class StatusManager {
|
|
|
29
27
|
if (step.execution.status === 'FAILED') {
|
|
30
28
|
step.execution.startedAt = Date.now();
|
|
31
29
|
step.execution.status = 'PENDING';
|
|
30
|
+
step.execution.signedAt = undefined;
|
|
31
|
+
step.execution.lastActionType = undefined;
|
|
32
|
+
step.execution.error = undefined;
|
|
32
33
|
this.updateStepInRoute(step);
|
|
33
34
|
}
|
|
34
35
|
return step.execution;
|
|
35
36
|
};
|
|
36
37
|
/**
|
|
37
38
|
* Updates the execution object of a Step.
|
|
38
|
-
* @param step
|
|
39
|
-
* @param
|
|
40
|
-
* @param execution Optional. Information about received tokens
|
|
39
|
+
* @param step The current step in execution
|
|
40
|
+
* @param execution Partial execution data to merge
|
|
41
41
|
* @returns The step with the updated execution object
|
|
42
42
|
*/
|
|
43
|
-
updateExecution(step,
|
|
43
|
+
updateExecution(step, execution) {
|
|
44
44
|
if (!step.execution) {
|
|
45
45
|
throw Error("Can't update empty execution.");
|
|
46
46
|
}
|
|
47
|
-
step.execution
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}
|
|
51
|
-
if (execution) {
|
|
52
|
-
step.execution = {
|
|
53
|
-
...step.execution,
|
|
54
|
-
...execution,
|
|
55
|
-
};
|
|
56
|
-
}
|
|
47
|
+
step.execution = {
|
|
48
|
+
...step.execution,
|
|
49
|
+
...execution,
|
|
50
|
+
};
|
|
57
51
|
this.updateStepInRoute(step);
|
|
58
52
|
return step;
|
|
59
53
|
}
|
|
60
54
|
/**
|
|
61
|
-
* Finds
|
|
55
|
+
* Finds an action of the specified type in the step's execution
|
|
62
56
|
* @param step The step to search in
|
|
63
|
-
* @param type The
|
|
64
|
-
* @
|
|
65
|
-
* @returns The found process or undefined if not found
|
|
57
|
+
* @param type The action type to find
|
|
58
|
+
* @returns The found action or undefined if not found
|
|
66
59
|
*/
|
|
67
|
-
|
|
68
|
-
if (!step.execution?.
|
|
60
|
+
findAction(step, type) {
|
|
61
|
+
if (!step.execution?.actions) {
|
|
69
62
|
throw new Error("Execution hasn't been initialized.");
|
|
70
63
|
}
|
|
71
|
-
const
|
|
72
|
-
|
|
73
|
-
process.status = status;
|
|
74
|
-
this.updateStepInRoute(step);
|
|
75
|
-
}
|
|
76
|
-
return process;
|
|
64
|
+
const action = step.execution.actions.find((p) => p.type === type);
|
|
65
|
+
return action;
|
|
77
66
|
}
|
|
78
67
|
/**
|
|
79
|
-
* Create and push a new
|
|
80
|
-
*
|
|
81
|
-
* @param
|
|
82
|
-
* @param
|
|
83
|
-
* @param
|
|
84
|
-
* @
|
|
68
|
+
* Create and push a new action into the execution.
|
|
69
|
+
* Caller is responsible for ensuring an action of this type does not already exist.
|
|
70
|
+
* @param step The step that should contain the new action.
|
|
71
|
+
* @param type Type of the action.
|
|
72
|
+
* @param chainId Chain Id of the action.
|
|
73
|
+
* @param status The initial status for the new action.
|
|
74
|
+
* @returns The created action.
|
|
85
75
|
*/
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
return process;
|
|
76
|
+
createAction = ({ step, type, chainId, status, }) => {
|
|
77
|
+
if (!step.execution) {
|
|
78
|
+
throw new Error("Execution hasn't been initialized.");
|
|
90
79
|
}
|
|
91
|
-
const
|
|
92
|
-
type
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
chainId: chainId,
|
|
80
|
+
const newAction = {
|
|
81
|
+
type,
|
|
82
|
+
message: getActionMessage(type, status),
|
|
83
|
+
status,
|
|
84
|
+
chainId,
|
|
97
85
|
};
|
|
98
|
-
step.execution.
|
|
86
|
+
step.execution.actions.push(newAction);
|
|
87
|
+
step.execution.lastActionType = type;
|
|
99
88
|
this.updateStepInRoute(step);
|
|
100
|
-
return
|
|
89
|
+
return newAction;
|
|
101
90
|
};
|
|
102
91
|
/**
|
|
103
|
-
*
|
|
104
|
-
* @param step The step
|
|
105
|
-
* @param type
|
|
106
|
-
* @param
|
|
107
|
-
* @param
|
|
108
|
-
* @returns The
|
|
92
|
+
* Find an existing action by type and update it, or create a new one if none exists.
|
|
93
|
+
* @param step The step that should contain the action.
|
|
94
|
+
* @param type Type of the action. Used to identify already existing actions.
|
|
95
|
+
* @param chainId Chain Id of the action (used when creating).
|
|
96
|
+
* @param status The status to set on the found or newly created action.
|
|
97
|
+
* @returns The updated or newly created action.
|
|
109
98
|
*/
|
|
110
|
-
|
|
99
|
+
initializeAction = ({ step, type, chainId, status, }) => {
|
|
100
|
+
const action = this.findAction(step, type);
|
|
101
|
+
if (action) {
|
|
102
|
+
return this.updateAction(step, type, status, {
|
|
103
|
+
error: undefined,
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
return this.createAction({ step, type, chainId, status });
|
|
107
|
+
};
|
|
108
|
+
/**
|
|
109
|
+
* Update an action object.
|
|
110
|
+
* @param step The step where the action should be updated
|
|
111
|
+
* @param type The action type to update
|
|
112
|
+
* @param status The status the action gets.
|
|
113
|
+
* @param [params] Additional parameters to append to the action.
|
|
114
|
+
* @returns The updated action
|
|
115
|
+
*/
|
|
116
|
+
updateAction = (step, type, status, params) => {
|
|
111
117
|
if (!step.execution) {
|
|
112
118
|
throw new Error("Can't update an empty step execution.");
|
|
113
119
|
}
|
|
114
|
-
const
|
|
115
|
-
if (!
|
|
116
|
-
throw new Error("Can't find
|
|
120
|
+
const currentAction = this.findAction(step, type);
|
|
121
|
+
if (!currentAction) {
|
|
122
|
+
throw new Error("Can't find an action for the given type.");
|
|
117
123
|
}
|
|
118
124
|
switch (status) {
|
|
119
125
|
case 'CANCELLED':
|
|
120
|
-
currentProcess.doneAt = Date.now();
|
|
121
126
|
break;
|
|
122
127
|
case 'FAILED':
|
|
123
|
-
currentProcess.doneAt = Date.now();
|
|
124
128
|
step.execution.status = 'FAILED';
|
|
129
|
+
if (params?.error) {
|
|
130
|
+
step.execution.error = params.error;
|
|
131
|
+
}
|
|
125
132
|
break;
|
|
126
133
|
case 'DONE':
|
|
127
|
-
currentProcess.doneAt = Date.now();
|
|
128
134
|
break;
|
|
129
135
|
case 'PENDING':
|
|
130
136
|
step.execution.status = 'PENDING';
|
|
131
|
-
|
|
137
|
+
if (params?.signedAt) {
|
|
138
|
+
step.execution.signedAt = params.signedAt;
|
|
139
|
+
}
|
|
132
140
|
break;
|
|
133
141
|
case 'RESET_REQUIRED':
|
|
134
142
|
case 'MESSAGE_REQUIRED':
|
|
135
143
|
case 'ACTION_REQUIRED':
|
|
136
144
|
step.execution.status = 'ACTION_REQUIRED';
|
|
137
|
-
currentProcess.actionRequiredAt = Date.now();
|
|
138
145
|
break;
|
|
139
146
|
default:
|
|
140
147
|
break;
|
|
141
148
|
}
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
149
|
+
step.execution.lastActionType = type;
|
|
150
|
+
currentAction.status = status;
|
|
151
|
+
currentAction.message = getActionMessage(type, status);
|
|
152
|
+
// set extra parameters or overwrite the standard params set in the switch statement
|
|
145
153
|
if (params) {
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
}
|
|
154
|
+
const { signedAt: _signedAt, ...rest } = params;
|
|
155
|
+
Object.assign(currentAction, rest);
|
|
149
156
|
}
|
|
150
|
-
// Sort
|
|
151
|
-
step.execution.
|
|
152
|
-
...step.execution.
|
|
153
|
-
...step.execution.
|
|
157
|
+
// Sort actions, the ones with DONE status go first
|
|
158
|
+
step.execution.actions = [
|
|
159
|
+
...step.execution.actions.filter((action) => action.status === 'DONE'),
|
|
160
|
+
...step.execution.actions.filter((action) => action.status !== 'DONE'),
|
|
154
161
|
];
|
|
155
162
|
this.updateStepInRoute(step); // updates the step in the route
|
|
156
|
-
return
|
|
157
|
-
};
|
|
158
|
-
/**
|
|
159
|
-
* Remove a process from the execution
|
|
160
|
-
* @param step The step where the process should be removed from
|
|
161
|
-
* @param type The process type to remove
|
|
162
|
-
*/
|
|
163
|
-
removeProcess = (step, type) => {
|
|
164
|
-
if (!step.execution) {
|
|
165
|
-
throw new Error("Execution hasn't been initialized.");
|
|
166
|
-
}
|
|
167
|
-
const index = step.execution.process.findIndex((p) => p.type === type);
|
|
168
|
-
step.execution.process.splice(index, 1);
|
|
169
|
-
this.updateStepInRoute(step);
|
|
163
|
+
return currentAction;
|
|
170
164
|
};
|
|
171
165
|
updateStepInRoute = (step) => {
|
|
172
166
|
if (!this.shouldUpdate) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StatusManager.js","sourceRoot":"","sources":["../../../src/core/StatusManager.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"StatusManager.js","sourceRoot":"","sources":["../../../src/core/StatusManager.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAA;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AASpD;;GAEG;AACH,MAAM,OAAO,aAAa;IACP,OAAO,CAAQ;IACxB,YAAY,GAAG,IAAI,CAAA;IAE3B,YAAY,OAAe;QACzB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;IACxB,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C,CAAA;QACpD,CAAC;QAED,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,SAAS,CAAC,EAAE,GAAG,IAAI,EAAE,CAAA;QAEzE,IAAI,CAAC,gBAAgB,EAAE,eAAe,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;QACpD,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,SAAS,CAAC,CAAA;IACpC,CAAC,CAAA;IAED,YAAY,CAAC,KAAc;QACzB,IAAI,CAAC,YAAY,GAAG,KAAK,CAAA;IAC3B,CAAC;CACF"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { StepExecutorContext, TaskResult } from '../types/execution.js';
|
|
2
|
+
import type { BaseStepExecutionTask } from './BaseStepExecutionTask.js';
|
|
3
|
+
export declare class TaskPipeline {
|
|
4
|
+
private readonly tasks;
|
|
5
|
+
constructor(tasks: BaseStepExecutionTask[]);
|
|
6
|
+
run(context: StepExecutorContext): Promise<TaskResult>;
|
|
7
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export class TaskPipeline {
|
|
2
|
+
tasks;
|
|
3
|
+
constructor(tasks) {
|
|
4
|
+
this.tasks = tasks;
|
|
5
|
+
}
|
|
6
|
+
async run(context) {
|
|
7
|
+
for (const task of this.tasks) {
|
|
8
|
+
const shouldRun = await task.shouldRun(context);
|
|
9
|
+
if (!shouldRun) {
|
|
10
|
+
continue;
|
|
11
|
+
}
|
|
12
|
+
const result = await task.run(context);
|
|
13
|
+
if (result.status === 'PAUSED') {
|
|
14
|
+
return { status: 'PAUSED' };
|
|
15
|
+
}
|
|
16
|
+
if (result.context && typeof result.context === 'object') {
|
|
17
|
+
Object.assign(context, result.context);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return { status: 'COMPLETED' };
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=TaskPipeline.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TaskPipeline.js","sourceRoot":"","sources":["../../../src/core/TaskPipeline.ts"],"names":[],"mappings":"AAGA,MAAM,OAAO,YAAY;IACN,KAAK,CAAyB;IAE/C,YAAY,KAA8B;QACxC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;IACpB,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,OAA4B;QACpC,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;YAC9B,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAA;YAC/C,IAAI,CAAC,SAAS,EAAE,CAAC;gBACf,SAAQ;YACV,CAAC;YACD,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,CAAA;YACtC,IAAI,MAAM,CAAC,MAAM,KAAK,QAAQ,EAAE,CAAC;gBAC/B,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAA;YAC7B,CAAC;YACD,IAAI,MAAM,CAAC,OAAO,IAAI,OAAO,MAAM,CAAC,OAAO,KAAK,QAAQ,EAAE,CAAC;gBACzD,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,OAAO,CAAC,CAAA;YACxC,CAAC;QACH,CAAC;QAED,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,CAAA;IAChC,CAAC;CACF"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { StatusMessage, Substatus } from '@lifi/types';
|
|
2
|
+
import type { ExecutionActionStatus, ExecutionActionType } from '../types/core.js';
|
|
3
|
+
export declare function getActionMessage(type: ExecutionActionType, status: ExecutionActionStatus): string | undefined;
|
|
4
|
+
export declare function getSubstatusMessage(status: StatusMessage, substatus?: Substatus): string | undefined;
|
|
@@ -1,9 +1,18 @@
|
|
|
1
|
-
const
|
|
2
|
-
|
|
1
|
+
const actionMessages = {
|
|
2
|
+
CHECK_ALLOWANCE: {
|
|
3
|
+
STARTED: 'Checking token allowance',
|
|
4
|
+
PENDING: 'Waiting for token allowance check',
|
|
5
|
+
DONE: 'Token allowance checked',
|
|
6
|
+
},
|
|
7
|
+
RESET_ALLOWANCE: {
|
|
8
|
+
STARTED: 'Resetting token allowance',
|
|
9
|
+
RESET_REQUIRED: 'Resetting token allowance',
|
|
10
|
+
PENDING: 'Waiting for token allowance reset',
|
|
11
|
+
DONE: 'Token allowance reset',
|
|
12
|
+
},
|
|
13
|
+
SET_ALLOWANCE: {
|
|
3
14
|
STARTED: 'Setting token allowance',
|
|
4
15
|
ACTION_REQUIRED: 'Set token allowance',
|
|
5
|
-
RESET_REQUIRED: 'Resetting token allowance',
|
|
6
|
-
MESSAGE_REQUIRED: 'Sign token allowance message',
|
|
7
16
|
PENDING: 'Waiting for token allowance',
|
|
8
17
|
DONE: 'Token allowance set',
|
|
9
18
|
},
|
|
@@ -22,6 +31,7 @@ const processMessages = {
|
|
|
22
31
|
DONE: 'Bridge transaction confirmed',
|
|
23
32
|
},
|
|
24
33
|
RECEIVING_CHAIN: {
|
|
34
|
+
STARTED: 'Waiting for destination chain',
|
|
25
35
|
PENDING: 'Waiting for destination chain',
|
|
26
36
|
DONE: 'Bridge completed',
|
|
27
37
|
},
|
|
@@ -31,6 +41,12 @@ const processMessages = {
|
|
|
31
41
|
PENDING: 'Waiting for permit message',
|
|
32
42
|
DONE: 'Permit message signed',
|
|
33
43
|
},
|
|
44
|
+
NATIVE_PERMIT: {
|
|
45
|
+
STARTED: 'Preparing transaction',
|
|
46
|
+
ACTION_REQUIRED: 'Sign permit message',
|
|
47
|
+
PENDING: 'Waiting for permit message',
|
|
48
|
+
DONE: 'Permit message signed',
|
|
49
|
+
},
|
|
34
50
|
};
|
|
35
51
|
const substatusMessages = {
|
|
36
52
|
PENDING: {
|
|
@@ -49,9 +65,9 @@ const substatusMessages = {
|
|
|
49
65
|
INVALID: {},
|
|
50
66
|
NOT_FOUND: {},
|
|
51
67
|
};
|
|
52
|
-
export function
|
|
53
|
-
const
|
|
54
|
-
return
|
|
68
|
+
export function getActionMessage(type, status) {
|
|
69
|
+
const actionMessage = actionMessages[type][status];
|
|
70
|
+
return actionMessage;
|
|
55
71
|
}
|
|
56
72
|
export function getSubstatusMessage(status, substatus) {
|
|
57
73
|
if (!substatus) {
|
|
@@ -60,4 +76,4 @@ export function getSubstatusMessage(status, substatus) {
|
|
|
60
76
|
const message = substatusMessages[status][substatus];
|
|
61
77
|
return message;
|
|
62
78
|
}
|
|
63
|
-
//# sourceMappingURL=
|
|
79
|
+
//# sourceMappingURL=actionMessages.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"actionMessages.js","sourceRoot":"","sources":["../../../src/core/actionMessages.ts"],"names":[],"mappings":"AAMA,MAAM,cAAc,GAGhB;IACF,eAAe,EAAE;QACf,OAAO,EAAE,0BAA0B;QACnC,OAAO,EAAE,mCAAmC;QAC5C,IAAI,EAAE,yBAAyB;KAChC;IACD,eAAe,EAAE;QACf,OAAO,EAAE,2BAA2B;QACpC,cAAc,EAAE,2BAA2B;QAC3C,OAAO,EAAE,mCAAmC;QAC5C,IAAI,EAAE,uBAAuB;KAC9B;IACD,aAAa,EAAE;QACb,OAAO,EAAE,yBAAyB;QAClC,eAAe,EAAE,qBAAqB;QACtC,OAAO,EAAE,6BAA6B;QACtC,IAAI,EAAE,qBAAqB;KAC5B;IACD,IAAI,EAAE;QACJ,OAAO,EAAE,4BAA4B;QACrC,eAAe,EAAE,uBAAuB;QACxC,gBAAgB,EAAE,mBAAmB;QACrC,OAAO,EAAE,8BAA8B;QACvC,IAAI,EAAE,gBAAgB;KACvB;IACD,WAAW,EAAE;QACX,OAAO,EAAE,8BAA8B;QACvC,eAAe,EAAE,yBAAyB;QAC1C,gBAAgB,EAAE,qBAAqB;QACvC,OAAO,EAAE,gCAAgC;QACzC,IAAI,EAAE,8BAA8B;KACrC;IACD,eAAe,EAAE;QACf,OAAO,EAAE,+BAA+B;QACxC,OAAO,EAAE,+BAA+B;QACxC,IAAI,EAAE,kBAAkB;KACzB;IACD,MAAM,EAAE;QACN,OAAO,EAAE,uBAAuB;QAChC,eAAe,EAAE,qBAAqB;QACtC,OAAO,EAAE,4BAA4B;QACrC,IAAI,EAAE,uBAAuB;KAC9B;IACD,aAAa,EAAE;QACb,OAAO,EAAE,uBAAuB;QAChC,eAAe,EAAE,qBAAqB;QACtC,OAAO,EAAE,4BAA4B;QACrC,IAAI,EAAE,uBAAuB;KAC9B;CACF,CAAA;AAED,MAAM,iBAAiB,GAGnB;IACF,OAAO,EAAE;QACP,oBAAoB,EAAE,kDAAkD;QACxE,mBAAmB,EAAE,+CAA+C;QACpE,aAAa,EACX,mFAAmF;QACrF,yBAAyB,EACvB,kHAAkH;QACpH,4BAA4B,EAC1B,4GAA4G;KAC/G;IACD,IAAI,EAAE;QACJ,OAAO,EACL,uEAAuE;QACzE,QAAQ,EAAE,iDAAiD;QAC3D,SAAS,EAAE,2BAA2B;KACvC;IACD,MAAM,EAAE,EAAE;IACV,OAAO,EAAE,EAAE;IACX,SAAS,EAAE,EAAE;CACd,CAAA;AAED,MAAM,UAAU,gBAAgB,CAC9B,IAAyB,EACzB,MAA6B;IAE7B,MAAM,aAAa,GAAG,cAAc,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAA;IAClD,OAAO,aAAa,CAAA;AACtB,CAAC;AAED,MAAM,UAAU,mBAAmB,CACjC,MAAqB,EACrB,SAAqB;IAErB,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,OAAM;IACR,CAAC;IACD,MAAM,OAAO,GAAG,iBAAiB,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,CAAA;IACpD,OAAO,OAAO,CAAA;AAChB,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { LiFiErrorCode } from '../errors/constants.js';
|
|
2
|
-
import { ProviderError } from '../errors/errors.js';
|
|
2
|
+
import { ExecuteStepRetryError, ProviderError } from '../errors/errors.js';
|
|
3
3
|
import { executionState } from './executionState.js';
|
|
4
4
|
import { prepareRestart } from './prepareRestart.js';
|
|
5
5
|
/**
|
|
@@ -64,7 +64,6 @@ const executeSteps = async (client, route) => {
|
|
|
64
64
|
const step = route.steps[index];
|
|
65
65
|
const previousStep = route.steps[index - 1];
|
|
66
66
|
// Check if the step is already done
|
|
67
|
-
//
|
|
68
67
|
if (step.execution?.status === 'DONE') {
|
|
69
68
|
continue;
|
|
70
69
|
}
|
|
@@ -94,7 +93,19 @@ const executeSteps = async (client, route) => {
|
|
|
94
93
|
if (execution.executionOptions) {
|
|
95
94
|
updateRouteExecution(route, execution.executionOptions);
|
|
96
95
|
}
|
|
97
|
-
|
|
96
|
+
let executedStep;
|
|
97
|
+
try {
|
|
98
|
+
executedStep = await stepExecutor.executeStep(client, step);
|
|
99
|
+
}
|
|
100
|
+
catch (e) {
|
|
101
|
+
if (e instanceof ExecuteStepRetryError) {
|
|
102
|
+
step.execution = undefined;
|
|
103
|
+
executedStep = await stepExecutor.executeStep(client, step, e.retryParams);
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
throw e;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
98
109
|
// We may reach this point if user interaction isn't allowed. We want to stop execution until we resume it
|
|
99
110
|
if (executedStep.execution?.status !== 'DONE') {
|
|
100
111
|
stopRouteExecution(route);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"execution.js","sourceRoot":"","sources":["../../../src/core/execution.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAA;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;
|
|
1
|
+
{"version":3,"file":"execution.js","sourceRoot":"","sources":["../../../src/core/execution.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAA;AACtD,OAAO,EAAE,qBAAqB,EA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AAS,GAAG,cAAc,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,CAAA;IAC9C,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,OAAO,KAAK,CAAA;IACd,CAAC;IAED,KAAK,MAAM,QAAQ,IAAI,SAAS,CAAC,SAAS,EAAE,CAAC;QAC3C,QAAQ,CAAC,cAAc,CAAC;YACtB,gBAAgB,EAAE,KAAK;YACvB,YAAY,EAAE,KAAK;YACnB,cAAc,EAAE,KAAK;SACtB,CAAC,CAAA;IACJ,CAAC;IACD,cAAc,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAA;IAC/B,OAAO,SAAS,CAAC,KAAK,CAAA;AACxB,CAAC,CAAA;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,GAAoB,EAAE;IACnD,OAAO,MAAM,CAAC,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC;SACvC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,EAAE,KAAK,CAAC;SAC1B,MAAM,CAAC,OAAO,CAAoB,CAAA;AACvC,CAAC,CAAA;AAED;;;;GAIG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,OAAe,EAA6B,EAAE;IAC3E,OAAO,cAAc,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,KAAK,CAAA;AAC3C,CAAC,CAAA"}
|
|
@@ -2,19 +2,20 @@ export const prepareRestart = (route) => {
|
|
|
2
2
|
for (let index = 0; index < route.steps.length; index++) {
|
|
3
3
|
const step = route.steps[index];
|
|
4
4
|
if (step.execution) {
|
|
5
|
-
// Find the index of the last
|
|
6
|
-
const lastValidIndex = step.execution.
|
|
7
|
-
!!
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
// Keep all processes up to the one with tx hash
|
|
5
|
+
// Find the index of the last action that has tx hash, taskId, or signed messages
|
|
6
|
+
const lastValidIndex = step.execution.actions.findLastIndex((action) => ['SWAP', 'CROSS_CHAIN', 'RECEIVING_CHAIN'].includes(action.type) &&
|
|
7
|
+
(!!action.txHash || !!action.taskId) &&
|
|
8
|
+
action.status !== 'FAILED');
|
|
9
|
+
// Keep all actions up to the one with tx hash
|
|
11
10
|
if (lastValidIndex >= 0) {
|
|
12
|
-
step.execution.
|
|
11
|
+
step.execution.actions = step.execution.actions.slice(0, lastValidIndex + 1);
|
|
13
12
|
}
|
|
14
13
|
else {
|
|
15
|
-
// If no tx hash exists, reset the
|
|
16
|
-
step.execution.
|
|
14
|
+
// If no tx hash exists, reset the actions array
|
|
15
|
+
step.execution.actions = [];
|
|
17
16
|
}
|
|
17
|
+
// Reset the last action type
|
|
18
|
+
step.execution.lastActionType = undefined;
|
|
18
19
|
}
|
|
19
20
|
step.transactionRequest = undefined;
|
|
20
21
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prepareRestart.js","sourceRoot":"","sources":["../../../src/core/prepareRestart.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,KAAoB,EAAE,EAAE;IACrD,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,CAAC;QACxD,MAAM,IAAI,GAAG,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;QAC/B,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;YACnB,
|
|
1
|
+
{"version":3,"file":"prepareRestart.js","sourceRoot":"","sources":["../../../src/core/prepareRestart.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,KAAoB,EAAE,EAAE;IACrD,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,CAAC;QACxD,MAAM,IAAI,GAAG,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;QAC/B,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;YACnB,iFAAiF;YACjF,MAAM,cAAc,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,aAAa,CACzD,CAAC,MAAM,EAAE,EAAE,CACT,CAAC,MAAM,EAAE,aAAa,EAAE,iBAAiB,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC;gBAChE,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,IAAI,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC;gBACpC,MAAM,CAAC,MAAM,KAAK,QAAQ,CAC7B,CAAA;YAED,8CAA8C;YAC9C,IAAI,cAAc,IAAI,CAAC,EAAE,CAAC;gBACxB,IAAI,CAAC,SAAS,CAAC,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,KAAK,CACnD,CAAC,EACD,cAAc,GAAG,CAAC,CACnB,CAAA;YACH,CAAC;iBAAM,CAAC;gBACN,gDAAgD;gBAChD,IAAI,CAAC,SAAS,CAAC,OAAO,GAAG,EAAE,CAAA;YAC7B,CAAC;YACD,6BAA6B;YAC7B,IAAI,CAAC,SAAS,CAAC,cAAc,GAAG,SAAS,CAAA;QAC3C,CAAC;QACD,IAAI,CAAC,kBAAkB,GAAG,SAAS,CAAA;IACrC,CAAC;AACH,CAAC,CAAA"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export interface SDKStorage {
|
|
2
|
+
get(key: string): string | null | Promise<string | null>;
|
|
3
|
+
set(key: string, value: string): void | Promise<void>;
|
|
4
|
+
remove(key: string): void | Promise<void>;
|
|
5
|
+
}
|
|
6
|
+
export declare class LocalStorageAdapter implements SDKStorage {
|
|
7
|
+
get(key: string): string | null;
|
|
8
|
+
set(key: string, value: string): void;
|
|
9
|
+
remove(key: string): void;
|
|
10
|
+
}
|
|
11
|
+
export declare class InMemoryStorage implements SDKStorage {
|
|
12
|
+
private store;
|
|
13
|
+
get(key: string): string | null;
|
|
14
|
+
set(key: string, value: string): void;
|
|
15
|
+
remove(key: string): void;
|
|
16
|
+
}
|
|
17
|
+
export declare function createDefaultStorage(): SDKStorage;
|