@lifi/sdk 4.0.0-alpha.8 → 4.0.0-alpha.9
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/StatusManager.d.ts +8 -9
- package/dist/cjs/core/StatusManager.js +32 -40
- package/dist/cjs/core/StatusManager.js.map +1 -1
- package/dist/cjs/core/actionMessages.d.ts +4 -0
- package/dist/cjs/core/{processMessages.js → actionMessages.js} +6 -6
- package/dist/cjs/core/actionMessages.js.map +1 -0
- package/dist/cjs/core/prepareRestart.js +6 -6
- package/dist/cjs/core/prepareRestart.js.map +1 -1
- package/dist/cjs/core/waitForDestinationChainTransaction.d.ts +2 -2
- package/dist/cjs/core/waitForDestinationChainTransaction.js +12 -10
- package/dist/cjs/core/waitForDestinationChainTransaction.js.map +1 -1
- package/dist/cjs/core/waitForTransactionStatus.d.ts +2 -2
- package/dist/cjs/core/waitForTransactionStatus.js +4 -4
- package/dist/cjs/core/waitForTransactionStatus.js.map +1 -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/index.d.ts +1 -1
- package/dist/cjs/types/core.d.ts +7 -12
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/core/StatusManager.d.ts +28 -29
- package/dist/esm/core/StatusManager.js +54 -62
- package/dist/esm/core/StatusManager.js.map +1 -1
- package/dist/esm/core/actionMessages.d.ts +4 -0
- package/dist/esm/core/{processMessages.js → actionMessages.js} +5 -5
- package/dist/esm/core/actionMessages.js.map +1 -0
- package/dist/esm/core/prepareRestart.js +9 -9
- package/dist/esm/core/prepareRestart.js.map +1 -1
- package/dist/esm/core/waitForDestinationChainTransaction.d.ts +2 -2
- package/dist/esm/core/waitForDestinationChainTransaction.js +14 -11
- package/dist/esm/core/waitForDestinationChainTransaction.js.map +1 -1
- package/dist/esm/core/waitForTransactionStatus.d.ts +2 -2
- package/dist/esm/core/waitForTransactionStatus.js +3 -3
- package/dist/esm/core/waitForTransactionStatus.js.map +1 -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/index.d.ts +1 -1
- package/dist/esm/types/core.d.ts +7 -12
- package/dist/esm/version.d.ts +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/types/core/StatusManager.d.ts +28 -29
- package/dist/types/core/StatusManager.d.ts.map +1 -1
- package/dist/types/core/actionMessages.d.ts +5 -0
- package/dist/types/core/actionMessages.d.ts.map +1 -0
- package/dist/types/core/waitForDestinationChainTransaction.d.ts +2 -2
- package/dist/types/core/waitForDestinationChainTransaction.d.ts.map +1 -1
- package/dist/types/core/waitForTransactionStatus.d.ts +2 -2
- package/dist/types/core/waitForTransactionStatus.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/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/types/core.d.ts +7 -12
- package/dist/types/types/core.d.ts.map +1 -1
- package/dist/types/version.d.ts +1 -1
- package/package.json +2 -2
- package/src/core/StatusManager.ts +68 -78
- package/src/core/{processMessages.ts → actionMessages.ts} +12 -9
- package/src/core/prepareRestart.ts +11 -11
- package/src/core/waitForDestinationChainTransaction.ts +19 -13
- package/src/core/waitForTransactionStatus.ts +4 -4
- package/src/errors/SDKError.ts +5 -5
- package/src/index.ts +3 -3
- package/src/types/core.ts +7 -12
- package/src/version.ts +1 -1
- package/dist/cjs/core/processMessages.d.ts +0 -4
- package/dist/cjs/core/processMessages.js.map +0 -1
- package/dist/esm/core/processMessages.d.ts +0 -4
- package/dist/esm/core/processMessages.js.map +0 -1
- package/dist/types/core/processMessages.d.ts +0 -5
- package/dist/types/core/processMessages.d.ts.map +0 -1
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import type { ChainId, LiFiStep } from '@lifi/types';
|
|
2
|
-
import type { Execution,
|
|
3
|
-
type
|
|
2
|
+
import type { Execution, ExecutionAction, ExecutionActionStatus, ExecutionActionType, ExecutionStatus, LiFiStepExtended } from '../types/core.js';
|
|
3
|
+
type FindOrCreateActionProps = {
|
|
4
4
|
step: LiFiStepExtended;
|
|
5
|
-
type:
|
|
5
|
+
type: ExecutionActionType;
|
|
6
6
|
chainId?: ChainId;
|
|
7
|
-
status?:
|
|
8
|
-
startedAt?: number;
|
|
7
|
+
status?: ExecutionActionStatus;
|
|
9
8
|
};
|
|
10
9
|
export declare class StatusManager {
|
|
11
10
|
private readonly routeId;
|
|
@@ -13,10 +12,10 @@ export declare class StatusManager {
|
|
|
13
12
|
constructor(routeId: string);
|
|
14
13
|
initExecutionObject: (step: LiFiStepExtended) => Execution;
|
|
15
14
|
updateExecution(step: LiFiStepExtended, status: ExecutionStatus, execution?: Partial<Execution>): LiFiStep;
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
15
|
+
findAction(step: LiFiStepExtended, type: ExecutionActionType, status?: ExecutionActionStatus): ExecutionAction | undefined;
|
|
16
|
+
findOrCreateAction: ({ step, type, chainId, status, }: FindOrCreateActionProps) => ExecutionAction;
|
|
17
|
+
updateAction: (step: LiFiStepExtended, type: ExecutionActionType, status: ExecutionActionStatus, params?: Partial<ExecutionAction>) => ExecutionAction;
|
|
18
|
+
removeAction: (step: LiFiStepExtended, type: ExecutionActionType) => void;
|
|
20
19
|
updateStepInRoute: (step: LiFiStep) => LiFiStep;
|
|
21
20
|
allowUpdates(value: boolean): void;
|
|
22
21
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.StatusManager = void 0;
|
|
4
|
+
const actionMessages_js_1 = require("./actionMessages.js");
|
|
4
5
|
const executionState_js_1 = require("./executionState.js");
|
|
5
|
-
const processMessages_js_1 = require("./processMessages.js");
|
|
6
6
|
class StatusManager {
|
|
7
7
|
routeId;
|
|
8
8
|
shouldUpdate = true;
|
|
@@ -12,15 +12,16 @@ class StatusManager {
|
|
|
12
12
|
initExecutionObject = (step) => {
|
|
13
13
|
if (!step.execution) {
|
|
14
14
|
step.execution = {
|
|
15
|
-
status: 'PENDING',
|
|
16
|
-
process: [],
|
|
17
15
|
startedAt: Date.now(),
|
|
16
|
+
status: 'PENDING',
|
|
17
|
+
actions: [],
|
|
18
18
|
};
|
|
19
19
|
this.updateStepInRoute(step);
|
|
20
20
|
}
|
|
21
21
|
if (step.execution.status === 'FAILED') {
|
|
22
22
|
step.execution.startedAt = Date.now();
|
|
23
23
|
step.execution.status = 'PENDING';
|
|
24
|
+
step.execution.signedAt = undefined;
|
|
24
25
|
this.updateStepInRoute(step);
|
|
25
26
|
}
|
|
26
27
|
return step.execution;
|
|
@@ -30,9 +31,6 @@ class StatusManager {
|
|
|
30
31
|
throw Error("Can't update empty execution.");
|
|
31
32
|
}
|
|
32
33
|
step.execution.status = status;
|
|
33
|
-
if (status === 'DONE') {
|
|
34
|
-
step.execution.doneAt = Date.now();
|
|
35
|
-
}
|
|
36
34
|
if (execution) {
|
|
37
35
|
step.execution = {
|
|
38
36
|
...step.execution,
|
|
@@ -42,85 +40,79 @@ class StatusManager {
|
|
|
42
40
|
this.updateStepInRoute(step);
|
|
43
41
|
return step;
|
|
44
42
|
}
|
|
45
|
-
|
|
46
|
-
if (!step.execution?.
|
|
43
|
+
findAction(step, type, status) {
|
|
44
|
+
if (!step.execution?.actions) {
|
|
47
45
|
throw new Error("Execution hasn't been initialized.");
|
|
48
46
|
}
|
|
49
|
-
const
|
|
50
|
-
if (
|
|
51
|
-
|
|
47
|
+
const action = step.execution.actions.find((p) => p.type === type);
|
|
48
|
+
if (action && status && action.status !== status) {
|
|
49
|
+
action.status = status;
|
|
52
50
|
this.updateStepInRoute(step);
|
|
53
51
|
}
|
|
54
|
-
return
|
|
52
|
+
return action;
|
|
55
53
|
}
|
|
56
|
-
|
|
57
|
-
const
|
|
58
|
-
if (
|
|
59
|
-
return
|
|
54
|
+
findOrCreateAction = ({ step, type, chainId, status, }) => {
|
|
55
|
+
const action = this.findAction(step, type, status);
|
|
56
|
+
if (action) {
|
|
57
|
+
return action;
|
|
60
58
|
}
|
|
61
|
-
const
|
|
59
|
+
const newAction = {
|
|
62
60
|
type: type,
|
|
63
|
-
|
|
64
|
-
message: (0, processMessages_js_1.getProcessMessage)(type, status ?? 'STARTED'),
|
|
61
|
+
message: (0, actionMessages_js_1.getActionMessage)(type, status ?? 'STARTED'),
|
|
65
62
|
status: status ?? 'STARTED',
|
|
66
63
|
chainId: chainId,
|
|
67
64
|
};
|
|
68
|
-
step.execution.
|
|
65
|
+
step.execution.actions.push(newAction);
|
|
69
66
|
this.updateStepInRoute(step);
|
|
70
|
-
return
|
|
67
|
+
return newAction;
|
|
71
68
|
};
|
|
72
|
-
|
|
69
|
+
updateAction = (step, type, status, params) => {
|
|
73
70
|
if (!step.execution) {
|
|
74
71
|
throw new Error("Can't update an empty step execution.");
|
|
75
72
|
}
|
|
76
|
-
const
|
|
77
|
-
if (!
|
|
78
|
-
throw new Error("Can't find
|
|
73
|
+
const currentAction = this.findAction(step, type);
|
|
74
|
+
if (!currentAction) {
|
|
75
|
+
throw new Error("Can't find an action for the given type.");
|
|
79
76
|
}
|
|
80
77
|
switch (status) {
|
|
81
78
|
case 'CANCELLED':
|
|
82
|
-
currentProcess.doneAt = Date.now();
|
|
83
79
|
break;
|
|
84
80
|
case 'FAILED':
|
|
85
|
-
currentProcess.doneAt = Date.now();
|
|
86
81
|
step.execution.status = 'FAILED';
|
|
87
82
|
break;
|
|
88
83
|
case 'DONE':
|
|
89
|
-
currentProcess.doneAt = Date.now();
|
|
90
84
|
break;
|
|
91
85
|
case 'PENDING':
|
|
92
86
|
step.execution.status = 'PENDING';
|
|
93
|
-
currentProcess.pendingAt = Date.now();
|
|
94
87
|
break;
|
|
95
88
|
case 'RESET_REQUIRED':
|
|
96
89
|
case 'MESSAGE_REQUIRED':
|
|
97
90
|
case 'ACTION_REQUIRED':
|
|
98
91
|
step.execution.status = 'ACTION_REQUIRED';
|
|
99
|
-
currentProcess.actionRequiredAt = Date.now();
|
|
100
92
|
break;
|
|
101
93
|
default:
|
|
102
94
|
break;
|
|
103
95
|
}
|
|
104
|
-
|
|
105
|
-
|
|
96
|
+
currentAction.status = status;
|
|
97
|
+
currentAction.message = (0, actionMessages_js_1.getActionMessage)(type, status);
|
|
106
98
|
if (params) {
|
|
107
99
|
for (const [key, value] of Object.entries(params)) {
|
|
108
|
-
|
|
100
|
+
currentAction[key] = value;
|
|
109
101
|
}
|
|
110
102
|
}
|
|
111
|
-
step.execution.
|
|
112
|
-
...step.execution.
|
|
113
|
-
...step.execution.
|
|
103
|
+
step.execution.actions = [
|
|
104
|
+
...step.execution.actions.filter((action) => action.status === 'DONE'),
|
|
105
|
+
...step.execution.actions.filter((action) => action.status !== 'DONE'),
|
|
114
106
|
];
|
|
115
107
|
this.updateStepInRoute(step);
|
|
116
|
-
return
|
|
108
|
+
return currentAction;
|
|
117
109
|
};
|
|
118
|
-
|
|
110
|
+
removeAction = (step, type) => {
|
|
119
111
|
if (!step.execution) {
|
|
120
112
|
throw new Error("Execution hasn't been initialized.");
|
|
121
113
|
}
|
|
122
|
-
const index = step.execution.
|
|
123
|
-
step.execution.
|
|
114
|
+
const index = step.execution.actions.findIndex((p) => p.type === type);
|
|
115
|
+
step.execution.actions.splice(index, 1);
|
|
124
116
|
this.updateStepInRoute(step);
|
|
125
117
|
};
|
|
126
118
|
updateStepInRoute = (step) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StatusManager.js","sourceRoot":"","sources":["../../../src/core/StatusManager.ts"],"names":[],"mappings":";;;AASA,
|
|
1
|
+
{"version":3,"file":"StatusManager.js","sourceRoot":"","sources":["../../../src/core/StatusManager.ts"],"names":[],"mappings":";;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AC,iCAAiC,CAAC,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;AA3ND,sCA2NC"}
|
|
@@ -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,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.getActionMessage = getActionMessage;
|
|
4
4
|
exports.getSubstatusMessage = getSubstatusMessage;
|
|
5
|
-
const
|
|
5
|
+
const actionMessages = {
|
|
6
6
|
TOKEN_ALLOWANCE: {
|
|
7
7
|
STARTED: 'Setting token allowance',
|
|
8
8
|
ACTION_REQUIRED: 'Set token allowance',
|
|
@@ -53,9 +53,9 @@ const substatusMessages = {
|
|
|
53
53
|
INVALID: {},
|
|
54
54
|
NOT_FOUND: {},
|
|
55
55
|
};
|
|
56
|
-
function
|
|
57
|
-
const
|
|
58
|
-
return
|
|
56
|
+
function getActionMessage(type, status) {
|
|
57
|
+
const actionMessage = actionMessages[type][status];
|
|
58
|
+
return actionMessage;
|
|
59
59
|
}
|
|
60
60
|
function getSubstatusMessage(status, substatus) {
|
|
61
61
|
if (!substatus) {
|
|
@@ -64,4 +64,4 @@ function getSubstatusMessage(status, substatus) {
|
|
|
64
64
|
const message = substatusMessages[status][substatus];
|
|
65
65
|
return message;
|
|
66
66
|
}
|
|
67
|
-
//# sourceMappingURL=
|
|
67
|
+
//# sourceMappingURL=actionMessages.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"actionMessages.js","sourceRoot":"","sources":["../../../src/core/actionMessages.ts"],"names":[],"mappings":";;AAoEA,4CAMC;AAED,kDASC;AA/ED,MAAM,cAAc,GAGhB;IACF,eAAe,EAAE;QACf,OAAO,EAAE,yBAAyB;QAClC,eAAe,EAAE,qBAAqB;QACtC,cAAc,EAAE,2BAA2B;QAC3C,gBAAgB,EAAE,8BAA8B;QAChD,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,IAAI,EAAE,kBAAkB;KACzB;IACD,MAAM,EAAE;QACN,OAAO,EAAE,uBAAuB;QAChC,eAAe,EAAE,qBAAqB;QACtC,OAAO,EAAE,4BAA4B;QACrC,IAAI,EAAE,uBAAuB;KAC9B;CACF,CAAA;AACD,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,SAAgB,gBAAgB,CAC9B,IAAyB,EACzB,MAA6B;IAE7B,MAAM,aAAa,GAAG,cAAc,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAA;IAClD,OAAO,aAAa,CAAA;AACtB,CAAC;AAED,SAAgB,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"}
|
|
@@ -5,15 +5,15 @@ const prepareRestart = (route) => {
|
|
|
5
5
|
for (let index = 0; index < route.steps.length; index++) {
|
|
6
6
|
const step = route.steps[index];
|
|
7
7
|
if (step.execution) {
|
|
8
|
-
const lastValidIndex = step.execution.
|
|
9
|
-
!!
|
|
10
|
-
!!
|
|
11
|
-
|
|
8
|
+
const lastValidIndex = step.execution.actions.findLastIndex((action) => (!!action.txHash ||
|
|
9
|
+
!!action.taskId ||
|
|
10
|
+
!!action.signedTypedData?.length) &&
|
|
11
|
+
action.status !== 'FAILED');
|
|
12
12
|
if (lastValidIndex >= 0) {
|
|
13
|
-
step.execution.
|
|
13
|
+
step.execution.actions = step.execution.actions.slice(0, lastValidIndex + 1);
|
|
14
14
|
}
|
|
15
15
|
else {
|
|
16
|
-
step.execution.
|
|
16
|
+
step.execution.actions = [];
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
19
|
step.transactionRequest = undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prepareRestart.js","sourceRoot":"","sources":["../../../src/core/prepareRestart.ts"],"names":[],"mappings":";;;AAEO,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;YAEnB,MAAM,cAAc,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,aAAa,CACzD,CAAC,
|
|
1
|
+
{"version":3,"file":"prepareRestart.js","sourceRoot":"","sources":["../../../src/core/prepareRestart.ts"],"names":[],"mappings":";;;AAEO,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;YAEnB,MAAM,cAAc,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,aAAa,CACzD,CAAC,MAAM,EAAE,EAAE,CACT,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM;gBACd,CAAC,CAAC,MAAM,CAAC,MAAM;gBACf,CAAC,CAAC,MAAM,CAAC,eAAe,EAAE,MAAM,CAAC;gBACnC,MAAM,CAAC,MAAM,KAAK,QAAQ,CAC7B,CAAA;YAGD,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;gBAEN,IAAI,CAAC,SAAS,CAAC,OAAO,GAAG,EAAE,CAAA;YAC7B,CAAC;QACH,CAAC;QACD,IAAI,CAAC,kBAAkB,GAAG,SAAS,CAAA;IACrC,CAAC;AACH,CAAC,CAAA;AA1BY,QAAA,cAAc,kBA0B1B"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { ExtendedChain } from '@lifi/types';
|
|
2
|
-
import type {
|
|
2
|
+
import type { ExecutionAction, LiFiStepExtended, SDKClient } from '../types/core.js';
|
|
3
3
|
import type { StatusManager } from './StatusManager.js';
|
|
4
|
-
export declare function waitForDestinationChainTransaction(client: SDKClient, step: LiFiStepExtended,
|
|
4
|
+
export declare function waitForDestinationChainTransaction(client: SDKClient, step: LiFiStepExtended, action: ExecutionAction, fromChain: ExtendedChain, toChain: ExtendedChain, statusManager: StatusManager, pollingInterval?: number): Promise<LiFiStepExtended>;
|
|
@@ -4,27 +4,30 @@ exports.waitForDestinationChainTransaction = waitForDestinationChainTransaction;
|
|
|
4
4
|
const constants_js_1 = require("../errors/constants.js");
|
|
5
5
|
const getTransactionMessage_js_1 = require("../utils/getTransactionMessage.js");
|
|
6
6
|
const waitForTransactionStatus_js_1 = require("./waitForTransactionStatus.js");
|
|
7
|
-
async function waitForDestinationChainTransaction(client, step,
|
|
8
|
-
const transactionHash =
|
|
9
|
-
let
|
|
7
|
+
async function waitForDestinationChainTransaction(client, step, action, fromChain, toChain, statusManager, pollingInterval) {
|
|
8
|
+
const transactionHash = action.txHash || action.taskId;
|
|
9
|
+
let actionType = action.type;
|
|
10
10
|
try {
|
|
11
11
|
if (!transactionHash) {
|
|
12
12
|
throw new Error('Transaction hash is undefined.');
|
|
13
13
|
}
|
|
14
14
|
const isBridgeExecution = fromChain.id !== toChain.id;
|
|
15
15
|
if (isBridgeExecution) {
|
|
16
|
-
const
|
|
16
|
+
const receivingChainAction = statusManager.findOrCreateAction({
|
|
17
17
|
step,
|
|
18
18
|
type: 'RECEIVING_CHAIN',
|
|
19
19
|
status: 'PENDING',
|
|
20
20
|
chainId: toChain.id,
|
|
21
|
-
startedAt: process.doneAt,
|
|
22
21
|
});
|
|
23
|
-
|
|
22
|
+
actionType = receivingChainAction.type;
|
|
24
23
|
}
|
|
25
|
-
|
|
24
|
+
step = statusManager.updateExecution(step, 'PENDING', {
|
|
25
|
+
signedAt: Date.now(),
|
|
26
|
+
});
|
|
27
|
+
const statusResponse = (await (0, waitForTransactionStatus_js_1.waitForTransactionStatus)(client, statusManager, transactionHash, step, actionType, pollingInterval));
|
|
26
28
|
const statusReceiving = statusResponse.receiving;
|
|
27
|
-
statusManager.
|
|
29
|
+
statusManager.updateAction(step, actionType, 'DONE', {
|
|
30
|
+
chainId: statusReceiving?.chainId || toChain.id,
|
|
28
31
|
substatus: statusResponse.substatus,
|
|
29
32
|
substatusMessage: statusResponse.substatusMessage,
|
|
30
33
|
txHash: statusReceiving?.txHash,
|
|
@@ -55,14 +58,13 @@ async function waitForDestinationChainTransaction(client, step, process, fromCha
|
|
|
55
58
|
}
|
|
56
59
|
catch (e) {
|
|
57
60
|
const htmlMessage = await (0, getTransactionMessage_js_1.getTransactionFailedMessage)(client, step, `${toChain.metamask.blockExplorerUrls[0]}tx/${transactionHash}`);
|
|
58
|
-
statusManager.
|
|
61
|
+
statusManager.updateAction(step, actionType, 'FAILED', {
|
|
59
62
|
error: {
|
|
60
63
|
code: constants_js_1.LiFiErrorCode.TransactionFailed,
|
|
61
64
|
message: 'Failed while waiting for status of destination chain transaction.',
|
|
62
65
|
htmlMessage,
|
|
63
66
|
},
|
|
64
67
|
});
|
|
65
|
-
statusManager.updateExecution(step, 'FAILED');
|
|
66
68
|
throw e;
|
|
67
69
|
}
|
|
68
70
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"waitForDestinationChainTransaction.js","sourceRoot":"","sources":["../../../src/core/waitForDestinationChainTransaction.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"waitForDestinationChainTransaction.js","sourceRoot":"","sources":["../../../src/core/waitForDestinationChainTransaction.ts"],"names":[],"mappings":";;AAeA,gFAgGC;AA1GD,yDAAsD;AAMtD,gFAA+E;AAE/E,+EAAwE;AAEjE,KAAK,UAAU,kCAAkC,CACtD,MAAiB,EACjB,IAAsB,EACtB,MAAuB,EACvB,SAAwB,EACxB,OAAsB,EACtB,aAA4B,EAC5B,eAAwB;IAIxB,MAAM,eAAe,GAAG,MAAM,CAAC,MAAM,IAAI,MAAM,CAAC,MAAM,CAAA;IACtD,IAAI,UAAU,GAAG,MAAM,CAAC,IAAI,CAAA;IAC5B,IAAI,CAAC;QAEH,IAAI,CAAC,eAAe,EAAE,CAAC;YACrB,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAA;QACnD,CAAC;QAED,MAAM,iBAAiB,GAAG,SAAS,CAAC,EAAE,KAAK,OAAO,CAAC,EAAE,CAAA;QACrD,IAAI,iBAAiB,EAAE,CAAC;YACtB,MAAM,oBAAoB,GAAG,aAAa,CAAC,kBAAkB,CAAC;gBAC5D,IAAI;gBACJ,IAAI,EAAE,iBAAiB;gBACvB,MAAM,EAAE,SAAS;gBACjB,OAAO,EAAE,OAAO,CAAC,EAAE;aACpB,CAAC,CAAA;YACF,UAAU,GAAG,oBAAoB,CAAC,IAAI,CAAA;QACxC,CAAC;QAED,IAAI,GAAG,aAAa,CAAC,eAAe,CAAC,IAAI,EAAE,SAAS,EAAE;YACpD,QAAQ,EAAE,IAAI,CAAC,GAAG,EAAE;SACrB,CAAC,CAAA;QAEF,MAAM,cAAc,GAAG,CAAC,MAAM,IAAA,sDAAwB,EACpD,MAAM,EACN,aAAa,EACb,eAAe,EACf,IAAI,EACJ,UAAU,EACV,eAAe,CAChB,CAAmB,CAAA;QAEpB,MAAM,eAAe,GAAG,cAAc,CAAC,SAAoC,CAAA;QAG3E,aAAa,CAAC,YAAY,C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,CAAC;QACpB,MAAM,WAAW,GAAG,MAAM,IAAA,sDAA2B,EACnD,MAAM,EACN,IAAI,EACJ,GAAG,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAC,CAAC,CAAC,MAAM,eAAe,EAAE,CAChE,CAAA;QAED,aAAa,CAAC,YAAY,CAAC,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE;YACrD,KAAK,EAAE;gBACL,IAAI,EAAE,4BAAa,CAAC,iBAAiB;gBACrC,OAAO,EACL,mEAAmE;gBACrE,WAAW;aACZ;SACF,CAAC,CAAA;QACF,MAAM,CAAC,CAAA;IACT,CAAC;AACH,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { LiFiStep, StatusResponse } from '@lifi/types';
|
|
2
|
-
import type {
|
|
2
|
+
import type { ExecutionActionType, SDKClient } from '../types/core.js';
|
|
3
3
|
import type { StatusManager } from './StatusManager.js';
|
|
4
|
-
export declare function waitForTransactionStatus(client: SDKClient, statusManager: StatusManager, txHash: string, step: LiFiStep,
|
|
4
|
+
export declare function waitForTransactionStatus(client: SDKClient, statusManager: StatusManager, txHash: string, step: LiFiStep, actionType: ExecutionActionType, interval?: number): Promise<StatusResponse>;
|
|
@@ -4,9 +4,9 @@ exports.waitForTransactionStatus = waitForTransactionStatus;
|
|
|
4
4
|
const getStatus_js_1 = require("../actions/getStatus.js");
|
|
5
5
|
const errors_js_1 = require("../errors/errors.js");
|
|
6
6
|
const waitForResult_js_1 = require("../utils/waitForResult.js");
|
|
7
|
-
const
|
|
7
|
+
const actionMessages_js_1 = require("./actionMessages.js");
|
|
8
8
|
const TRANSACTION_HASH_OBSERVERS = {};
|
|
9
|
-
async function waitForTransactionStatus(client, statusManager, txHash, step,
|
|
9
|
+
async function waitForTransactionStatus(client, statusManager, txHash, step, actionType, interval = 5_000) {
|
|
10
10
|
const _getStatus = () => {
|
|
11
11
|
return (0, getStatus_js_1.getStatus)(client, {
|
|
12
12
|
fromChain: step.action.fromChainId,
|
|
@@ -20,10 +20,10 @@ async function waitForTransactionStatus(client, statusManager, txHash, step, pro
|
|
|
20
20
|
case 'DONE':
|
|
21
21
|
return statusResponse;
|
|
22
22
|
case 'PENDING':
|
|
23
|
-
statusManager?.
|
|
23
|
+
statusManager?.updateAction(step, actionType, 'PENDING', {
|
|
24
24
|
substatus: statusResponse.substatus,
|
|
25
25
|
substatusMessage: statusResponse.substatusMessage ||
|
|
26
|
-
(0,
|
|
26
|
+
(0, actionMessages_js_1.getSubstatusMessage)(statusResponse.status, statusResponse.substatus),
|
|
27
27
|
txLink: statusResponse.bridgeExplorerLink,
|
|
28
28
|
});
|
|
29
29
|
return undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"waitForTransactionStatus.js","sourceRoot":"","sources":["../../../src/core/waitForTransactionStatus.ts"],"names":[],"mappings":";;AAUA,4DA8DC;AAvED,0DAAmD;AACnD,mDAAiD;AAEjD,gEAAyD;AACzD,
|
|
1
|
+
{"version":3,"file":"waitForTransactionStatus.js","sourceRoot":"","sources":["../../../src/core/waitForTransactionStatus.ts"],"names":[],"mappings":";;AAUA,4DA8DC;AAvED,0DAAmD;AACnD,mDAAiD;AAEjD,gEAAyD;AACzD,2DAAyD;AAGzD,MAAM,0BAA0B,GAA4C,EAAE,CAAA;AAEvE,KAAK,UAAU,wBAAwB,CAC5C,MAAiB,EACjB,aAA4B,EAC5B,MAAc,EACd,IAAc,EACd,UAA+B,EAC/B,QAAQ,GAAG,KAAK;IAEhB,MAAM,UAAU,GAAG,GAAwC,EAAE;QAC3D,OAAO,IAAA,wBAAS,EAAC,MAAM,EAAE;YACvB,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,WAAW;YAClC,WAAW,EAAE,IAAI,CAAC,MAAM,CAAC,WAAW;YACpC,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC,SAAS;YAC9B,MAAM;YACN,GAAG,CAAC,IAAI,CAAC,IAAI,KAAK,QAAQ,IAAI,EAAE,MAAM,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B,uDAAuD,CACxD,CAAA;IACH,CAAC;IAED,OAAO,cAAc,CAAA;AACvB,CAAC"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import type { LiFiStep } from '@lifi/types';
|
|
2
|
-
import type {
|
|
2
|
+
import type { ExecutionAction } from '../types/core.js';
|
|
3
3
|
import type { BaseError } from './baseError.js';
|
|
4
4
|
import type { ErrorCode } from './constants.js';
|
|
5
5
|
export declare class SDKError extends Error {
|
|
6
6
|
step?: LiFiStep;
|
|
7
|
-
|
|
7
|
+
action?: ExecutionAction;
|
|
8
8
|
code: ErrorCode;
|
|
9
9
|
name: string;
|
|
10
10
|
cause: BaseError;
|
|
11
|
-
constructor(cause: BaseError, step?: LiFiStep,
|
|
11
|
+
constructor(cause: BaseError, step?: LiFiStep, action?: ExecutionAction);
|
|
12
12
|
}
|
|
@@ -4,16 +4,16 @@ exports.SDKError = void 0;
|
|
|
4
4
|
const version_js_1 = require("../version.js");
|
|
5
5
|
class SDKError extends Error {
|
|
6
6
|
step;
|
|
7
|
-
|
|
7
|
+
action;
|
|
8
8
|
code;
|
|
9
9
|
name = 'SDKError';
|
|
10
10
|
cause;
|
|
11
|
-
constructor(cause, step,
|
|
11
|
+
constructor(cause, step, action) {
|
|
12
12
|
const errorMessage = `${cause.message ? `[${cause.name}] ${cause.message}` : 'Unknown error occurred'}\nLI.FI SDK version: ${version_js_1.version}`;
|
|
13
13
|
super(errorMessage);
|
|
14
14
|
this.name = 'SDKError';
|
|
15
15
|
this.step = step;
|
|
16
|
-
this.
|
|
16
|
+
this.action = action;
|
|
17
17
|
this.cause = cause;
|
|
18
18
|
this.stack = this.cause.stack;
|
|
19
19
|
this.code = cause.code;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SDKError.js","sourceRoot":"","sources":["../../../src/errors/SDKError.ts"],"names":[],"mappings":";;;AAEA,8CAAuC;AAMvC,MAAa,QAAS,SAAQ,KAAK;IACjC,IAAI,CAAW;IACf,
|
|
1
|
+
{"version":3,"file":"SDKError.js","sourceRoot":"","sources":["../../../src/errors/SDKError.ts"],"names":[],"mappings":";;;AAEA,8CAAuC;AAMvC,MAAa,QAAS,SAAQ,KAAK;IACjC,IAAI,CAAW;IACf,MAAM,CAAkB;IACxB,IAAI,CAAW;IACN,IAAI,GAAG,UAAU,CAAA;IACjB,KAAK,CAAW;IAEzB,YAAY,KAAgB,EAAE,IAAe,EAAE,MAAwB;QACrE,MAAM,YAAY,GAAG,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,IAAI,KAAK,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,wBAAwB,wBAAwB,oBAAO,EAAE,CAAA;QACtI,KAAK,CAAC,YAAY,CAAC,CAAA;QACnB,IAAI,CAAC,IAAI,GAAG,UAAU,CAAA;QACtB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QAChB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QACpB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;QAClB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAA;QAC7B,IAAI,CAAC,IAAI,GAAG,KAAK,CAAC,IAAI,CAAA;IACxB,CAAC;CACF;AAjBD,4BAiBC"}
|
package/dist/cjs/index.d.ts
CHANGED
|
@@ -34,7 +34,7 @@ export { ErrorMessage, ErrorName, LiFiErrorCode } from './errors/constants.js';
|
|
|
34
34
|
export { BalanceError, ProviderError, RPCError, ServerError, TransactionError, UnknownError, ValidationError, } from './errors/errors.js';
|
|
35
35
|
export { HTTPError } from './errors/httpError.js';
|
|
36
36
|
export { SDKError } from './errors/SDKError.js';
|
|
37
|
-
export type { AcceptExchangeRateUpdateHook, AcceptSlippageUpdateHook, AcceptSlippageUpdateHookParams, ContractCallParams, ContractTool, ExchangeRateUpdateParams, Execution, ExecutionOptions, ExecutionStatus, GetContractCallsHook, GetContractCallsResult, InteractionSettings, LiFiStepExtended,
|
|
37
|
+
export type { AcceptExchangeRateUpdateHook, AcceptSlippageUpdateHook, AcceptSlippageUpdateHookParams, ContractCallParams, ContractTool, ExchangeRateUpdateParams, Execution, ExecutionAction, ExecutionActionStatus, ExecutionActionType, ExecutionOptions, ExecutionStatus, GetContractCallsHook, GetContractCallsResult, InteractionSettings, LiFiStepExtended, RequestInterceptor, RouteExecutionData, RouteExecutionDataDictionary, RouteExecutionDictionary, RouteExtended, RPCUrls, SDKBaseConfig, SDKClient, SDKConfig, SDKProvider, StepExecutor, StepExecutorOptions, StepExtended, TransactionMethodType, TransactionParameters, TransactionRequestParameters, TransactionRequestUpdateHook, UpdateRouteHook, } from './types/core.js';
|
|
38
38
|
export { checkPackageUpdates } from './utils/checkPackageUpdates.js';
|
|
39
39
|
export { convertQuoteToRoute } from './utils/convertQuoteToRoute.js';
|
|
40
40
|
export { fetchTxErrorDetails } from './utils/fetchTxErrorDetails.js';
|
package/dist/cjs/types/core.d.ts
CHANGED
|
@@ -132,22 +132,17 @@ export interface ExecutionOptions {
|
|
|
132
132
|
infiniteApproval?: boolean;
|
|
133
133
|
}
|
|
134
134
|
export type ExecutionStatus = 'ACTION_REQUIRED' | 'PENDING' | 'FAILED' | 'DONE';
|
|
135
|
-
export type
|
|
136
|
-
export type
|
|
137
|
-
export type
|
|
138
|
-
type:
|
|
139
|
-
status:
|
|
135
|
+
export type ExecutionActionStatus = 'STARTED' | 'ACTION_REQUIRED' | 'MESSAGE_REQUIRED' | 'RESET_REQUIRED' | 'PENDING' | 'FAILED' | 'DONE' | 'CANCELLED';
|
|
136
|
+
export type ExecutionActionType = 'TOKEN_ALLOWANCE' | 'PERMIT' | 'SWAP' | 'CROSS_CHAIN' | 'RECEIVING_CHAIN';
|
|
137
|
+
export type ExecutionAction = {
|
|
138
|
+
type: ExecutionActionType;
|
|
139
|
+
status: ExecutionActionStatus;
|
|
140
140
|
substatus?: Substatus;
|
|
141
141
|
chainId?: number;
|
|
142
142
|
txHash?: string;
|
|
143
143
|
taskId?: string;
|
|
144
144
|
txLink?: string;
|
|
145
145
|
txType?: TransactionMethodType;
|
|
146
|
-
actionRequiredAt?: number;
|
|
147
|
-
doneAt?: number;
|
|
148
|
-
failedAt?: number;
|
|
149
|
-
pendingAt?: number;
|
|
150
|
-
startedAt: number;
|
|
151
146
|
message?: string;
|
|
152
147
|
error?: {
|
|
153
148
|
code: string | number;
|
|
@@ -158,9 +153,9 @@ export type Process = {
|
|
|
158
153
|
};
|
|
159
154
|
export interface Execution {
|
|
160
155
|
startedAt: number;
|
|
161
|
-
|
|
156
|
+
signedAt?: number;
|
|
162
157
|
status: ExecutionStatus;
|
|
163
|
-
|
|
158
|
+
actions: Array<ExecutionAction>;
|
|
164
159
|
fromAmount?: string;
|
|
165
160
|
toAmount?: string;
|
|
166
161
|
toToken?: Token;
|
package/dist/cjs/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export declare const name = "@lifi/sdk";
|
|
2
|
-
export declare const version = "4.0.0-alpha.
|
|
2
|
+
export declare const version = "4.0.0-alpha.9";
|
package/dist/cjs/version.js
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import type { ChainId, LiFiStep } from '@lifi/types';
|
|
2
|
-
import type { Execution,
|
|
3
|
-
type
|
|
2
|
+
import type { Execution, ExecutionAction, ExecutionActionStatus, ExecutionActionType, ExecutionStatus, LiFiStepExtended } from '../types/core.js';
|
|
3
|
+
type FindOrCreateActionProps = {
|
|
4
4
|
step: LiFiStepExtended;
|
|
5
|
-
type:
|
|
5
|
+
type: ExecutionActionType;
|
|
6
6
|
chainId?: ChainId;
|
|
7
|
-
status?:
|
|
8
|
-
startedAt?: number;
|
|
7
|
+
status?: ExecutionActionStatus;
|
|
9
8
|
};
|
|
10
9
|
/**
|
|
11
|
-
* Manages status updates of a route and provides various functions for tracking
|
|
10
|
+
* Manages status updates of a route and provides various functions for tracking actions
|
|
12
11
|
* @param {string} routeId The route dd this StatusManger belongs to.
|
|
13
12
|
* @returns {StatusManager} An instance of StatusManager.
|
|
14
13
|
*/
|
|
@@ -31,37 +30,37 @@ export declare class StatusManager {
|
|
|
31
30
|
*/
|
|
32
31
|
updateExecution(step: LiFiStepExtended, status: ExecutionStatus, execution?: Partial<Execution>): LiFiStep;
|
|
33
32
|
/**
|
|
34
|
-
* Finds
|
|
33
|
+
* Finds an action of the specified type in the step's execution
|
|
35
34
|
* @param step The step to search in
|
|
36
|
-
* @param type The
|
|
37
|
-
* @param status Optional status to update the
|
|
38
|
-
* @returns The found
|
|
35
|
+
* @param type The action type to find
|
|
36
|
+
* @param status Optional status to update the action with if found
|
|
37
|
+
* @returns The found action or undefined if not found
|
|
39
38
|
*/
|
|
40
|
-
|
|
39
|
+
findAction(step: LiFiStepExtended, type: ExecutionActionType, status?: ExecutionActionStatus): ExecutionAction | undefined;
|
|
41
40
|
/**
|
|
42
|
-
* Create and push a new
|
|
43
|
-
* @param step The step that should contain the new
|
|
44
|
-
* @param type Type of the
|
|
45
|
-
* @param chainId Chain Id of the
|
|
46
|
-
* @param status By default created
|
|
47
|
-
* @returns Returns
|
|
41
|
+
* Create and push a new action into the execution.
|
|
42
|
+
* @param step The step that should contain the new action.
|
|
43
|
+
* @param type Type of the action. Used to identify already existing actions.
|
|
44
|
+
* @param chainId Chain Id of the action.
|
|
45
|
+
* @param status By default created action is set to the STARTED status. We can override new action with the needed status.
|
|
46
|
+
* @returns Returns action.
|
|
48
47
|
*/
|
|
49
|
-
|
|
48
|
+
findOrCreateAction: ({ step, type, chainId, status, }: FindOrCreateActionProps) => ExecutionAction;
|
|
50
49
|
/**
|
|
51
|
-
* Update
|
|
52
|
-
* @param step The step where the
|
|
53
|
-
* @param type The
|
|
54
|
-
* @param status The status the
|
|
55
|
-
* @param [params] Additional parameters to append to the
|
|
56
|
-
* @returns The
|
|
50
|
+
* Update an action object.
|
|
51
|
+
* @param step The step where the action should be updated
|
|
52
|
+
* @param type The action type to update
|
|
53
|
+
* @param status The status the action gets.
|
|
54
|
+
* @param [params] Additional parameters to append to the action.
|
|
55
|
+
* @returns The updated action
|
|
57
56
|
*/
|
|
58
|
-
|
|
57
|
+
updateAction: (step: LiFiStepExtended, type: ExecutionActionType, status: ExecutionActionStatus, params?: Partial<ExecutionAction>) => ExecutionAction;
|
|
59
58
|
/**
|
|
60
|
-
* Remove
|
|
61
|
-
* @param step The step where the
|
|
62
|
-
* @param type The
|
|
59
|
+
* Remove an action from the execution
|
|
60
|
+
* @param step The step where the action should be removed from
|
|
61
|
+
* @param type The action type to remove
|
|
63
62
|
*/
|
|
64
|
-
|
|
63
|
+
removeAction: (step: LiFiStepExtended, type: ExecutionActionType) => void;
|
|
65
64
|
updateStepInRoute: (step: LiFiStep) => LiFiStep;
|
|
66
65
|
allowUpdates(value: boolean): void;
|
|
67
66
|
}
|