@lifi/sdk 3.0.0-alpha.28 → 3.0.0-alpha.29
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/package.json +2 -2
- package/src/_cjs/constants.js +2 -1
- package/src/_cjs/constants.js.map +1 -1
- package/src/_cjs/core/EVM/EVMStepExecutor.js.map +1 -1
- package/src/_cjs/core/EVM/switchChain.js.map +1 -1
- package/src/_cjs/core/Solana/SolanaStepExecutor.js.map +1 -1
- package/src/_cjs/core/Solana/getSolanaBalance.js +23 -13
- package/src/_cjs/core/Solana/getSolanaBalance.js.map +1 -1
- package/src/_cjs/core/StatusManager.js.map +1 -1
- package/src/_cjs/core/execution.js +1 -1
- package/src/_cjs/core/execution.js.map +1 -1
- package/src/_cjs/core/executionState.js.map +1 -1
- package/src/_cjs/core/prepareRestart.js.map +1 -1
- package/src/_cjs/createConfig.js +4 -2
- package/src/_cjs/createConfig.js.map +1 -1
- package/src/_cjs/version.js +1 -1
- package/src/_esm/constants.js +1 -0
- package/src/_esm/constants.js.map +1 -1
- package/src/_esm/core/EVM/EVMStepExecutor.js.map +1 -1
- package/src/_esm/core/EVM/switchChain.js.map +1 -1
- package/src/_esm/core/Solana/SolanaStepExecutor.js.map +1 -1
- package/src/_esm/core/Solana/getSolanaBalance.js +23 -13
- package/src/_esm/core/Solana/getSolanaBalance.js.map +1 -1
- package/src/_esm/core/StatusManager.js.map +1 -1
- package/src/_esm/core/execution.js +1 -1
- package/src/_esm/core/execution.js.map +1 -1
- package/src/_esm/core/executionState.js.map +1 -1
- package/src/_esm/core/prepareRestart.js.map +1 -1
- package/src/_esm/createConfig.js +4 -2
- package/src/_esm/createConfig.js.map +1 -1
- package/src/_esm/version.js +1 -1
- package/src/_types/constants.d.ts +1 -0
- package/src/_types/constants.d.ts.map +1 -1
- package/src/_types/core/EVM/EVMStepExecutor.d.ts +2 -3
- package/src/_types/core/EVM/EVMStepExecutor.d.ts.map +1 -1
- package/src/_types/core/EVM/switchChain.d.ts +2 -3
- package/src/_types/core/EVM/switchChain.d.ts.map +1 -1
- package/src/_types/core/Solana/SolanaStepExecutor.d.ts +4 -5
- package/src/_types/core/Solana/SolanaStepExecutor.d.ts.map +1 -1
- package/src/_types/core/Solana/getSolanaBalance.d.ts.map +1 -1
- package/src/_types/core/Solana/types.d.ts +2 -2
- package/src/_types/core/Solana/types.d.ts.map +1 -1
- package/src/_types/core/StatusManager.d.ts +6 -5
- package/src/_types/core/StatusManager.d.ts.map +1 -1
- package/src/_types/core/execution.d.ts +5 -5
- package/src/_types/core/execution.d.ts.map +1 -1
- package/src/_types/core/executionState.d.ts +4 -5
- package/src/_types/core/executionState.d.ts.map +1 -1
- package/src/_types/core/prepareRestart.d.ts +2 -2
- package/src/_types/core/prepareRestart.d.ts.map +1 -1
- package/src/_types/core/types.d.ts +8 -2
- package/src/_types/core/types.d.ts.map +1 -1
- package/src/_types/createConfig.d.ts.map +1 -1
- package/src/_types/version.d.ts +1 -1
- package/src/constants.ts +1 -0
- package/src/core/EVM/EVMStepExecutor.ts +7 -7
- package/src/core/EVM/switchChain.ts +2 -3
- package/src/core/Solana/SolanaStepExecutor.ts +10 -10
- package/src/core/Solana/getSolanaBalance.ts +28 -18
- package/src/core/Solana/types.ts +2 -2
- package/src/core/StatusManager.ts +10 -5
- package/src/core/execution.ts +9 -9
- package/src/core/executionState.ts +5 -6
- package/src/core/prepareRestart.ts +4 -3
- package/src/core/types.ts +10 -1
- package/src/createConfig.ts +19 -17
- package/src/version.ts +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createConfig.js","sourceRoot":"","sources":["../createConfig.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAC3C,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAA;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,mBA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OAAO;QACL,GAAG,EAAE,MAAM,CAAC,GAAG;QACf,GAAG,EAAE,MAAM,CAAC,GAAG;KAChB,CAAA;AACH,CAAC"}
|
package/src/_esm/version.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export declare const AddressZero = "0x0000000000000000000000000000000000000000";
|
|
2
2
|
export declare const AlternativeAddressZero = "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee";
|
|
3
|
+
export declare const wrappedSolAddress = "So11111111111111111111111111111111111111112";
|
|
3
4
|
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,WAAW,+CAA+C,CAAA;AACvE,eAAO,MAAM,sBAAsB,+CACW,CAAA"}
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,WAAW,+CAA+C,CAAA;AACvE,eAAO,MAAM,sBAAsB,+CACW,CAAA;AAC9C,eAAO,MAAM,iBAAiB,gDAAgD,CAAA"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import type { LiFiStep } from '@lifi/types';
|
|
2
1
|
import type { WalletClient } from 'viem';
|
|
3
2
|
import { BaseStepExecutor } from '../BaseStepExecutor.js';
|
|
4
|
-
import type { StepExecutorOptions } from '../types.js';
|
|
3
|
+
import type { LiFiStepExtended, StepExecutorOptions } from '../types.js';
|
|
5
4
|
import type { MultisigConfig } from './types.js';
|
|
6
5
|
export interface EVMStepExecutorOptions extends StepExecutorOptions {
|
|
7
6
|
walletClient: WalletClient;
|
|
@@ -12,6 +11,6 @@ export declare class EVMStepExecutor extends BaseStepExecutor {
|
|
|
12
11
|
private multisig?;
|
|
13
12
|
constructor(options: EVMStepExecutorOptions);
|
|
14
13
|
checkChain: () => never;
|
|
15
|
-
executeStep: (step:
|
|
14
|
+
executeStep: (step: LiFiStepExtended) => Promise<LiFiStepExtended>;
|
|
16
15
|
}
|
|
17
16
|
//# sourceMappingURL=EVMStepExecutor.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EVMStepExecutor.d.ts","sourceRoot":"","sources":["../../../core/EVM/EVMStepExecutor.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"EVMStepExecutor.d.ts","sourceRoot":"","sources":["../../../core/EVM/EVMStepExecutor.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAMV,YAAY,EACb,MAAM,MAAM,CAAA;AAYb,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AAGzD,OAAO,KAAK,EACV,gBAAgB,EAChB,mBAAmB,EAEpB,MAAM,aAAa,CAAA;AAMpB,OAAO,KAAK,EAAE,cAAc,EAAuB,MAAM,YAAY,CAAA;AAGrE,MAAM,WAAW,sBAAuB,SAAQ,mBAAmB;IACjE,YAAY,EAAE,YAAY,CAAA;IAC1B,QAAQ,CAAC,EAAE,cAAc,CAAA;CAC1B;AAED,qBAAa,eAAgB,SAAQ,gBAAgB;IACnD,OAAO,CAAC,YAAY,CAAc;IAClC,OAAO,CAAC,QAAQ,CAAC,CAAgB;gBAErB,OAAO,EAAE,sBAAsB;IAS3C,UAAU,cAET;IAED,WAAW,SAAgB,gBAAgB,KAAG,QAAQ,gBAAgB,CAAC,CA4ZtE;CACF"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import type { LiFiStep } from '@lifi/types';
|
|
2
1
|
import type { WalletClient } from 'viem';
|
|
3
2
|
import type { StatusManager } from '../StatusManager.js';
|
|
4
|
-
import type { SwitchChainHook } from '../types.js';
|
|
3
|
+
import type { LiFiStepExtended, SwitchChainHook } from '../types.js';
|
|
5
4
|
/**
|
|
6
5
|
* This method checks whether the wallet client is configured for the correct chain.
|
|
7
6
|
* If yes it returns the wallet clien.
|
|
@@ -19,5 +18,5 @@ import type { SwitchChainHook } from '../types.js';
|
|
|
19
18
|
* @param allowUserInteraction
|
|
20
19
|
* @returns New WalletClient
|
|
21
20
|
*/
|
|
22
|
-
export declare const switchChain: (walletClient: WalletClient, statusManager: StatusManager, step:
|
|
21
|
+
export declare const switchChain: (walletClient: WalletClient, statusManager: StatusManager, step: LiFiStepExtended, allowUserInteraction: boolean, switchChainHook?: SwitchChainHook) => Promise<WalletClient | undefined>;
|
|
23
22
|
//# sourceMappingURL=switchChain.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"switchChain.d.ts","sourceRoot":"","sources":["../../../core/EVM/switchChain.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"switchChain.d.ts","sourceRoot":"","sources":["../../../core/EVM/switchChain.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,MAAM,CAAA;AAExC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AACxD,OAAO,KAAK,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAEpE;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,WAAW,iBACR,YAAY,iBACX,aAAa,QACtB,gBAAgB,wBACA,OAAO,oBACX,eAAe,KAChC,QAAQ,YAAY,GAAG,SAAS,CA+ClC,CAAA"}
|
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { WalletAdapter } from '@solana/wallet-adapter-base';
|
|
1
|
+
import type { Adapter } from '@solana/wallet-adapter-base';
|
|
3
2
|
import { BaseStepExecutor } from '../BaseStepExecutor.js';
|
|
4
|
-
import type { StepExecutorOptions } from '../types.js';
|
|
3
|
+
import type { LiFiStepExtended, StepExecutorOptions } from '../types.js';
|
|
5
4
|
export interface SolanaStepExecutorOptions extends StepExecutorOptions {
|
|
6
|
-
walletAdapter:
|
|
5
|
+
walletAdapter: Adapter;
|
|
7
6
|
}
|
|
8
7
|
export declare class SolanaStepExecutor extends BaseStepExecutor {
|
|
9
8
|
private walletAdapter;
|
|
10
9
|
constructor(options: SolanaStepExecutorOptions);
|
|
11
|
-
executeStep: (step:
|
|
10
|
+
executeStep: (step: LiFiStepExtended) => Promise<LiFiStepExtended>;
|
|
12
11
|
}
|
|
13
12
|
//# sourceMappingURL=SolanaStepExecutor.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SolanaStepExecutor.d.ts","sourceRoot":"","sources":["../../../core/Solana/SolanaStepExecutor.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"SolanaStepExecutor.d.ts","sourceRoot":"","sources":["../../../core/Solana/SolanaStepExecutor.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAA;AAc1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AAGzD,OAAO,KAAK,EACV,gBAAgB,EAChB,mBAAmB,EAEpB,MAAM,aAAa,CAAA;AAKpB,MAAM,WAAW,yBAA0B,SAAQ,mBAAmB;IACpE,aAAa,EAAE,OAAO,CAAA;CACvB;AAED,qBAAa,kBAAmB,SAAQ,gBAAgB;IACtD,OAAO,CAAC,aAAa,CAAS;gBAElB,OAAO,EAAE,yBAAyB;IAK9C,WAAW,SAAgB,gBAAgB,KAAG,QAAQ,gBAAgB,CAAC,CAoNtE;CACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getSolanaBalance.d.ts","sourceRoot":"","sources":["../../../core/Solana/getSolanaBalance.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAW,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"getSolanaBalance.d.ts","sourceRoot":"","sources":["../../../core/Solana/getSolanaBalance.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAW,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAM9D,eAAO,MAAM,gBAAgB,kBACZ,MAAM,UACb,KAAK,EAAE,KACd,QAAQ,WAAW,EAAE,CAYvB,CAAA"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { type ChainId } from '@lifi/types';
|
|
2
|
-
import type {
|
|
2
|
+
import type { Adapter } from '@solana/wallet-adapter-base';
|
|
3
3
|
import { type SDKProvider } from '../types.js';
|
|
4
4
|
export interface SolanaProviderOptions {
|
|
5
|
-
getWalletAdapter?: () => Promise<
|
|
5
|
+
getWalletAdapter?: () => Promise<Adapter>;
|
|
6
6
|
}
|
|
7
7
|
export interface SolanaProvider extends SDKProvider {
|
|
8
8
|
rpcUrls?: Record<ChainId, string[]>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../core/Solana/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,KAAK,OAAO,EAAE,MAAM,aAAa,CAAA;AACrD,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../core/Solana/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,KAAK,OAAO,EAAE,MAAM,aAAa,CAAA;AACrD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAA;AAC1D,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,aAAa,CAAA;AAE9C,MAAM,WAAW,qBAAqB;IACpC,gBAAgB,CAAC,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,CAAA;CAC1C;AAED,MAAM,WAAW,cAAe,SAAQ,WAAW;IACjD,OAAO,CAAC,EAAE,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,CAAC,CAAA;IACnC,UAAU,CAAC,OAAO,EAAE,qBAAqB,GAAG,IAAI,CAAA;CACjD;AAED,wBAAgB,QAAQ,CAAC,QAAQ,EAAE,WAAW,GAAG,QAAQ,IAAI,cAAc,CAE1E;AAED,eAAO,MAAM,mBAAmB,gDAAgD,CAAA"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Execution, LiFiStep, Process, ProcessType, Status, Token } from '@lifi/types';
|
|
2
|
+
import type { LiFiStepExtended } from './types.js';
|
|
2
3
|
interface Receipt {
|
|
3
4
|
fromAmount?: string;
|
|
4
5
|
toAmount?: string;
|
|
@@ -24,7 +25,7 @@ export declare class StatusManager {
|
|
|
24
25
|
* @param step The current step in execution
|
|
25
26
|
* @returns The initialized execution object for this step and a function to update this step
|
|
26
27
|
*/
|
|
27
|
-
initExecutionObject: (step:
|
|
28
|
+
initExecutionObject: (step: LiFiStepExtended) => Execution;
|
|
28
29
|
/**
|
|
29
30
|
* Updates the execution object of a Step.
|
|
30
31
|
* @param step The current step in execution
|
|
@@ -32,7 +33,7 @@ export declare class StatusManager {
|
|
|
32
33
|
* @param receipt Optional. Information about received tokens
|
|
33
34
|
* @returns The step with the updated execution object
|
|
34
35
|
*/
|
|
35
|
-
updateExecution(step:
|
|
36
|
+
updateExecution(step: LiFiStepExtended, status: Status, receipt?: Receipt): LiFiStep;
|
|
36
37
|
/**
|
|
37
38
|
* Create and push a new process into the execution.
|
|
38
39
|
* @param step The step that should contain the new process.
|
|
@@ -40,7 +41,7 @@ export declare class StatusManager {
|
|
|
40
41
|
* @param status By default created procces is set to the STARTED status. We can override new process with the needed status.
|
|
41
42
|
* @returns Returns process.
|
|
42
43
|
*/
|
|
43
|
-
findOrCreateProcess: (step:
|
|
44
|
+
findOrCreateProcess: (step: LiFiStepExtended, type: ProcessType, status?: Status) => Process;
|
|
44
45
|
/**
|
|
45
46
|
* Update a process object.
|
|
46
47
|
* @param step The step where the process should be updated
|
|
@@ -49,13 +50,13 @@ export declare class StatusManager {
|
|
|
49
50
|
* @param [params] Additional parameters to append to the process.
|
|
50
51
|
* @returns The update process
|
|
51
52
|
*/
|
|
52
|
-
updateProcess: (step:
|
|
53
|
+
updateProcess: (step: LiFiStepExtended, type: ProcessType, status: Status, params?: OptionalParameters) => Process;
|
|
53
54
|
/**
|
|
54
55
|
* Remove a process from the execution
|
|
55
56
|
* @param step The step where the process should be removed from
|
|
56
57
|
* @param type The process type to remove
|
|
57
58
|
*/
|
|
58
|
-
removeProcess: (step:
|
|
59
|
+
removeProcess: (step: LiFiStepExtended, type: ProcessType) => void;
|
|
59
60
|
updateStepInRoute: (step: LiFiStep) => LiFiStep;
|
|
60
61
|
allowUpdates(value: boolean): void;
|
|
61
62
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StatusManager.d.ts","sourceRoot":"","sources":["../../core/StatusManager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,SAAS,EACT,QAAQ,EACR,OAAO,EACP,WAAW,EACX,MAAM,EACN,KAAK,EACN,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"StatusManager.d.ts","sourceRoot":"","sources":["../../core/StatusManager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,SAAS,EACT,QAAQ,EACR,OAAO,EACP,WAAW,EACX,MAAM,EACN,KAAK,EACN,MAAM,aAAa,CAAA;AAGpB,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAGlD,UAAU,OAAO;IACf,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,OAAO,CAAC,EAAE,KAAK,CAAA;IACf,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,QAAQ,CAAC,EAAE,KAAK,CAAA;IAChB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,YAAY,CAAC,EAAE,MAAM,CAAA;CACtB;AAED,KAAK,kBAAkB,GAAG,OAAO,CAC/B,IAAI,CACF,OAAO,EACL,QAAQ,GACR,UAAU,GACV,QAAQ,GACR,QAAQ,GACR,OAAO,GACP,WAAW,GACX,kBAAkB,GAClB,gBAAgB,CACnB,CACF,CAAA;AAED;;;;GAIG;AACH,qBAAa,aAAa;IACxB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAQ;IAChC,OAAO,CAAC,YAAY,CAAO;gBAEf,OAAO,EAAE,MAAM;IAI3B;;;;OAIG;IACH,mBAAmB,SAAU,gBAAgB,KAAG,SAAS,CAcxD;IAED;;;;;;OAMG;IACH,eAAe,CACb,IAAI,EAAE,gBAAgB,EACtB,MAAM,EAAE,MAAM,EACd,OAAO,CAAC,EAAE,OAAO,GAChB,QAAQ;IAeX;;;;;;OAMG;IACH,mBAAmB,SACX,gBAAgB,QAChB,WAAW,WACR,MAAM,KACd,OAAO,CAyBT;IAED;;;;;;;OAOG;IACH,aAAa,SACL,gBAAgB,QAChB,WAAW,UACT,MAAM,WACL,kBAAkB,KAC1B,OAAO,CAkDT;IAED;;;;OAIG;IACH,aAAa,SAAU,gBAAgB,QAAQ,WAAW,KAAG,IAAI,CAOhE;IAED,iBAAiB,SAAU,QAAQ,KAAG,QAAQ,CAsB7C;IAED,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI;CAGnC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Route } from '@lifi/types';
|
|
2
|
-
import type { ExecutionOptions } from './types.js';
|
|
2
|
+
import type { ExecutionOptions, RouteExtended } from './types.js';
|
|
3
3
|
/**
|
|
4
4
|
* Execute a route.
|
|
5
5
|
* @param route - The route that should be executed. Cannot be an active route.
|
|
@@ -7,7 +7,7 @@ import type { ExecutionOptions } from './types.js';
|
|
|
7
7
|
* @returns The executed route.
|
|
8
8
|
* @throws {LiFiError} Throws a LiFiError if the execution fails.
|
|
9
9
|
*/
|
|
10
|
-
export declare const executeRoute: (route: Route, executionOptions?: ExecutionOptions) => Promise<
|
|
10
|
+
export declare const executeRoute: (route: Route, executionOptions?: ExecutionOptions) => Promise<RouteExtended>;
|
|
11
11
|
/**
|
|
12
12
|
* Resume the execution of a route that has been stopped or had an error while executing.
|
|
13
13
|
* @param route - The route that is to be executed. Cannot be an active route.
|
|
@@ -15,7 +15,7 @@ export declare const executeRoute: (route: Route, executionOptions?: ExecutionOp
|
|
|
15
15
|
* @returns The executed route.
|
|
16
16
|
* @throws {LiFiError} Throws a LiFiError if the execution fails.
|
|
17
17
|
*/
|
|
18
|
-
export declare const resumeRoute: (route: Route, executionOptions?: ExecutionOptions) => Promise<
|
|
18
|
+
export declare const resumeRoute: (route: Route, executionOptions?: ExecutionOptions) => Promise<RouteExtended>;
|
|
19
19
|
/**
|
|
20
20
|
* Updates route execution to background or foreground state.
|
|
21
21
|
* @param route - A route that is currently in execution.
|
|
@@ -32,11 +32,11 @@ export declare const stopRouteExecution: (route: Route) => Route;
|
|
|
32
32
|
* Get the list of active routes.
|
|
33
33
|
* @returns A list of routes.
|
|
34
34
|
*/
|
|
35
|
-
export declare const getActiveRoutes: () =>
|
|
35
|
+
export declare const getActiveRoutes: () => RouteExtended[];
|
|
36
36
|
/**
|
|
37
37
|
* Return the current route information for given route. The route has to be active.
|
|
38
38
|
* @param routeId - A route id.
|
|
39
39
|
* @returns The updated route.
|
|
40
40
|
*/
|
|
41
|
-
export declare const getActiveRoute: (routeId: string) =>
|
|
41
|
+
export declare const getActiveRoute: (routeId: string) => RouteExtended | undefined;
|
|
42
42
|
//# sourceMappingURL=execution.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"execution.d.ts","sourceRoot":"","sources":["../../core/execution.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AAIxC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;
|
|
1
|
+
{"version":3,"file":"execution.d.ts","sourceRoot":"","sources":["../../core/execution.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AAIxC,OAAO,KAAK,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAEjE;;;;;;GAMG;AACH,eAAO,MAAM,YAAY,UAChB,KAAK,qBACO,gBAAgB,KAClC,QAAQ,aAAa,CAevB,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,WAAW,UACf,KAAK,qBACO,gBAAgB,KAClC,QAAQ,aAAa,CA6BvB,CAAA;AA4ED;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,UACxB,KAAK,WACH,gBAAgB,KACxB,IAmBF,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,UAAW,KAAK,KAAG,KAejD,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,eAAe,QAAO,aAAa,EAI/C,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,cAAc,YAAa,MAAM,KAAG,aAAa,GAAG,SAEhE,CAAA"}
|
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { ExecutionOptions, StepExecutor } from './types.js';
|
|
1
|
+
import type { ExecutionOptions, RouteExtended, StepExecutor } from './types.js';
|
|
3
2
|
export interface ExecutionData {
|
|
4
|
-
route:
|
|
3
|
+
route: RouteExtended;
|
|
5
4
|
executors: StepExecutor[];
|
|
6
5
|
executionOptions?: ExecutionOptions;
|
|
7
|
-
promise?: Promise<
|
|
6
|
+
promise?: Promise<RouteExtended>;
|
|
8
7
|
}
|
|
9
8
|
export interface ExecutionState {
|
|
10
9
|
state: Partial<Record<string, ExecutionData>>;
|
|
11
10
|
get(routeId: string): ExecutionData | undefined;
|
|
12
|
-
create(route:
|
|
11
|
+
create(route: RouteExtended, executionOptions?: ExecutionOptions, promise?: Promise<RouteExtended>): ExecutionData;
|
|
13
12
|
delete(routeId: string): void;
|
|
14
13
|
}
|
|
15
14
|
export declare const executionState: ExecutionState;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"executionState.d.ts","sourceRoot":"","sources":["../../core/executionState.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"executionState.d.ts","sourceRoot":"","sources":["../../core/executionState.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAE/E,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,aAAa,CAAA;IACpB,SAAS,EAAE,YAAY,EAAE,CAAA;IACzB,gBAAgB,CAAC,EAAE,gBAAgB,CAAA;IACnC,OAAO,CAAC,EAAE,OAAO,CAAC,aAAa,CAAC,CAAA;CACjC;AAED,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC,CAAA;IAC7C,GAAG,CAAC,OAAO,EAAE,MAAM,GAAG,aAAa,GAAG,SAAS,CAAA;IAC/C,MAAM,CACJ,KAAK,EAAE,aAAa,EACpB,gBAAgB,CAAC,EAAE,gBAAgB,EACnC,OAAO,CAAC,EAAE,OAAO,CAAC,aAAa,CAAC,GAC/B,aAAa,CAAA;IAChB,MAAM,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAA;CAC9B;AAED,eAAO,MAAM,cAAc,EAAE,cAkB5B,CAAA"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare const prepareRestart: (route:
|
|
1
|
+
import type { RouteExtended } from './types.js';
|
|
2
|
+
export declare const prepareRestart: (route: RouteExtended) => Promise<void>;
|
|
3
3
|
//# sourceMappingURL=prepareRestart.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prepareRestart.d.ts","sourceRoot":"","sources":["../../core/prepareRestart.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"prepareRestart.d.ts","sourceRoot":"","sources":["../../core/prepareRestart.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAoB,aAAa,EAAE,MAAM,YAAY,CAAA;AAEjE,eAAO,MAAM,cAAc,UAAiB,aAAa,kBAWxD,CAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ChainType, LiFiStep, Route, Token, TokenAmount } from '@lifi/types';
|
|
1
|
+
import type { ChainType, Execution, LiFiStep, Route, Token, TokenAmount } from '@lifi/types';
|
|
2
2
|
import type { WalletClient } from 'viem';
|
|
3
3
|
export interface SDKProvider {
|
|
4
4
|
readonly type: ChainType;
|
|
@@ -19,7 +19,13 @@ export interface StepExecutor {
|
|
|
19
19
|
allowUserInteraction: boolean;
|
|
20
20
|
allowExecution: boolean;
|
|
21
21
|
setInteraction(settings?: InteractionSettings): void;
|
|
22
|
-
executeStep(step:
|
|
22
|
+
executeStep(step: LiFiStepExtended): Promise<LiFiStepExtended>;
|
|
23
|
+
}
|
|
24
|
+
export interface RouteExtended extends Omit<Route, 'steps'> {
|
|
25
|
+
steps: LiFiStepExtended[];
|
|
26
|
+
}
|
|
27
|
+
export interface LiFiStepExtended extends LiFiStep {
|
|
28
|
+
execution?: Execution;
|
|
23
29
|
}
|
|
24
30
|
export type TransactionParameters = {
|
|
25
31
|
chainId?: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../core/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,SAAS,EACT,QAAQ,EACR,KAAK,EACL,KAAK,EACL,WAAW,EACZ,MAAM,aAAa,CAAA;AACpB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,MAAM,CAAA;AAExC,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAA;IACxB,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAA;IACnC,eAAe,CAAC,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,YAAY,CAAC,CAAA;IACpE,UAAU,CAAC,aAAa,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,OAAO,CAAC,WAAW,EAAE,CA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UAAU,EAAE,MAAM,kBAAkB,CAAA;AAalD,wBAAsB,kBAAkB,
|
|
1
|
+
{"version":3,"file":"createConfig.d.ts","sourceRoot":"","sources":["../createConfig.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAalD,wBAAsB,kBAAkB,kBA2BvC;AAED,wBAAgB,YAAY,CAAC,OAAO,EAAE,UAAU;;;EAO/C"}
|
package/src/_types/version.d.ts
CHANGED
package/src/constants.ts
CHANGED
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
ExtendedTransactionInfo,
|
|
3
|
-
FullStatusData,
|
|
4
|
-
LiFiStep,
|
|
5
|
-
} from '@lifi/types'
|
|
1
|
+
import type { ExtendedTransactionInfo, FullStatusData } from '@lifi/types'
|
|
6
2
|
import type {
|
|
7
3
|
Address,
|
|
8
4
|
Hash,
|
|
@@ -25,7 +21,11 @@ import {
|
|
|
25
21
|
import { BaseStepExecutor } from '../BaseStepExecutor.js'
|
|
26
22
|
import { checkBalance } from '../checkBalance.js'
|
|
27
23
|
import { stepComparison } from '../stepComparison.js'
|
|
28
|
-
import type {
|
|
24
|
+
import type {
|
|
25
|
+
LiFiStepExtended,
|
|
26
|
+
StepExecutorOptions,
|
|
27
|
+
TransactionParameters,
|
|
28
|
+
} from '../types.js'
|
|
29
29
|
import { getSubstatusMessage } from '../utils.js'
|
|
30
30
|
import { waitForReceivingTransaction } from '../waitForReceivingTransaction.js'
|
|
31
31
|
import { checkAllowance } from './checkAllowance.js'
|
|
@@ -56,7 +56,7 @@ export class EVMStepExecutor extends BaseStepExecutor {
|
|
|
56
56
|
throw new Error('checkChain is not implemented.')
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
-
executeStep = async (step:
|
|
59
|
+
executeStep = async (step: LiFiStepExtended): Promise<LiFiStepExtended> => {
|
|
60
60
|
// Make sure that the chain is still correct
|
|
61
61
|
|
|
62
62
|
// Find if it's bridging and the step is waiting for a transaction on the receiving chain
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import type { LiFiStep } from '@lifi/types'
|
|
2
1
|
import type { WalletClient } from 'viem'
|
|
3
2
|
import { LiFiErrorCode, ProviderError } from '../../utils/errors.js'
|
|
4
3
|
import type { StatusManager } from '../StatusManager.js'
|
|
5
|
-
import type { SwitchChainHook } from '../types.js'
|
|
4
|
+
import type { LiFiStepExtended, SwitchChainHook } from '../types.js'
|
|
6
5
|
|
|
7
6
|
/**
|
|
8
7
|
* This method checks whether the wallet client is configured for the correct chain.
|
|
@@ -24,7 +23,7 @@ import type { SwitchChainHook } from '../types.js'
|
|
|
24
23
|
export const switchChain = async (
|
|
25
24
|
walletClient: WalletClient,
|
|
26
25
|
statusManager: StatusManager,
|
|
27
|
-
step:
|
|
26
|
+
step: LiFiStepExtended,
|
|
28
27
|
allowUserInteraction: boolean,
|
|
29
28
|
switchChainHook?: SwitchChainHook
|
|
30
29
|
): Promise<WalletClient | undefined> => {
|
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
FullStatusData,
|
|
4
|
-
LiFiStep,
|
|
5
|
-
} from '@lifi/types'
|
|
6
|
-
import type { WalletAdapter } from '@solana/wallet-adapter-base'
|
|
1
|
+
import type { ExtendedTransactionInfo, FullStatusData } from '@lifi/types'
|
|
2
|
+
import type { Adapter } from '@solana/wallet-adapter-base'
|
|
7
3
|
import {
|
|
8
4
|
VersionedTransaction,
|
|
9
5
|
type TransactionConfirmationStrategy,
|
|
@@ -20,24 +16,28 @@ import {
|
|
|
20
16
|
import { BaseStepExecutor } from '../BaseStepExecutor.js'
|
|
21
17
|
import { checkBalance } from '../checkBalance.js'
|
|
22
18
|
import { stepComparison } from '../stepComparison.js'
|
|
23
|
-
import type {
|
|
19
|
+
import type {
|
|
20
|
+
LiFiStepExtended,
|
|
21
|
+
StepExecutorOptions,
|
|
22
|
+
TransactionParameters,
|
|
23
|
+
} from '../types.js'
|
|
24
24
|
import { getSubstatusMessage } from '../utils.js'
|
|
25
25
|
import { waitForReceivingTransaction } from '../waitForReceivingTransaction.js'
|
|
26
26
|
import { getSolanaConnection } from './connection.js'
|
|
27
27
|
|
|
28
28
|
export interface SolanaStepExecutorOptions extends StepExecutorOptions {
|
|
29
|
-
walletAdapter:
|
|
29
|
+
walletAdapter: Adapter
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
export class SolanaStepExecutor extends BaseStepExecutor {
|
|
33
|
-
private walletAdapter:
|
|
33
|
+
private walletAdapter: Adapter
|
|
34
34
|
|
|
35
35
|
constructor(options: SolanaStepExecutorOptions) {
|
|
36
36
|
super(options)
|
|
37
37
|
this.walletAdapter = options.walletAdapter
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
executeStep = async (step:
|
|
40
|
+
executeStep = async (step: LiFiStepExtended): Promise<LiFiStepExtended> => {
|
|
41
41
|
step.execution = this.statusManager.initExecutionObject(step)
|
|
42
42
|
|
|
43
43
|
const fromChain = await config.getChainById(step.action.fromChainId)
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ChainId, Token, TokenAmount } from '@lifi/types'
|
|
2
2
|
import { PublicKey } from '@solana/web3.js'
|
|
3
|
+
import { wrappedSolAddress } from '../../constants.js'
|
|
3
4
|
import { getSolanaConnection } from './connection.js'
|
|
4
5
|
import { TokenProgramAddress } from './types.js'
|
|
5
6
|
|
|
@@ -26,36 +27,45 @@ const getSolanaBalanceDefault = async (
|
|
|
26
27
|
walletAddress: string
|
|
27
28
|
): Promise<TokenAmount[]> => {
|
|
28
29
|
const connection = await getSolanaConnection()
|
|
29
|
-
const blockNumber = await connection.getSlot()
|
|
30
30
|
const accountPublicKey = new PublicKey(walletAddress)
|
|
31
31
|
const tokenProgramPublicKey = new PublicKey(TokenProgramAddress)
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
const [slot, balance, tokenAccountsByOwner] = await Promise.allSettled([
|
|
33
|
+
connection.getSlot(),
|
|
34
|
+
connection.getBalance(accountPublicKey),
|
|
35
|
+
connection.getParsedTokenAccountsByOwner(accountPublicKey, {
|
|
35
36
|
programId: tokenProgramPublicKey,
|
|
36
|
-
}
|
|
37
|
-
)
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
37
|
+
}),
|
|
38
|
+
])
|
|
39
|
+
const blockNumber = slot.status === 'fulfilled' ? BigInt(slot.value) : 0n
|
|
40
|
+
const solBalance = balance.status === 'fulfilled' ? BigInt(balance.value) : 0n
|
|
41
|
+
const walletTokenAmounts =
|
|
42
|
+
tokenAccountsByOwner.status === 'fulfilled'
|
|
43
|
+
? tokenAccountsByOwner.value.value.reduce(
|
|
44
|
+
(tokenAmounts, value) => {
|
|
45
|
+
const amount = BigInt(
|
|
46
|
+
value.account.data.parsed.info.tokenAmount.amount
|
|
47
|
+
)
|
|
48
|
+
if (amount > 0n) {
|
|
49
|
+
tokenAmounts[value.account.data.parsed.info.mint] = amount
|
|
50
|
+
}
|
|
51
|
+
return tokenAmounts
|
|
52
|
+
},
|
|
53
|
+
{} as Record<string, bigint>
|
|
54
|
+
)
|
|
55
|
+
: {}
|
|
56
|
+
walletTokenAmounts[wrappedSolAddress] ??= 0n
|
|
57
|
+
walletTokenAmounts[wrappedSolAddress] += solBalance
|
|
48
58
|
const tokenAmounts: TokenAmount[] = tokens.map((token) => {
|
|
49
59
|
if (walletTokenAmounts[token.address]) {
|
|
50
60
|
return {
|
|
51
61
|
...token,
|
|
52
62
|
amount: walletTokenAmounts[token.address],
|
|
53
|
-
blockNumber
|
|
63
|
+
blockNumber,
|
|
54
64
|
}
|
|
55
65
|
}
|
|
56
66
|
return {
|
|
57
67
|
...token,
|
|
58
|
-
blockNumber
|
|
68
|
+
blockNumber,
|
|
59
69
|
}
|
|
60
70
|
})
|
|
61
71
|
return tokenAmounts
|
package/src/core/Solana/types.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { ChainType, type ChainId } from '@lifi/types'
|
|
2
|
-
import type {
|
|
2
|
+
import type { Adapter } from '@solana/wallet-adapter-base'
|
|
3
3
|
import { type SDKProvider } from '../types.js'
|
|
4
4
|
|
|
5
5
|
export interface SolanaProviderOptions {
|
|
6
|
-
getWalletAdapter?: () => Promise<
|
|
6
|
+
getWalletAdapter?: () => Promise<Adapter>
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
export interface SolanaProvider extends SDKProvider {
|
|
@@ -8,6 +8,7 @@ import type {
|
|
|
8
8
|
} from '@lifi/types'
|
|
9
9
|
import { emptyExecution } from '@lifi/types'
|
|
10
10
|
import { executionState } from './executionState.js'
|
|
11
|
+
import type { LiFiStepExtended } from './types.js'
|
|
11
12
|
import { getProcessMessage } from './utils.js'
|
|
12
13
|
|
|
13
14
|
interface Receipt {
|
|
@@ -53,7 +54,7 @@ export class StatusManager {
|
|
|
53
54
|
* @param step The current step in execution
|
|
54
55
|
* @returns The initialized execution object for this step and a function to update this step
|
|
55
56
|
*/
|
|
56
|
-
initExecutionObject = (step:
|
|
57
|
+
initExecutionObject = (step: LiFiStepExtended): Execution => {
|
|
57
58
|
if (!step.execution) {
|
|
58
59
|
step.execution = structuredClone<Execution>(emptyExecution)
|
|
59
60
|
step.execution.status = 'PENDING'
|
|
@@ -76,7 +77,11 @@ export class StatusManager {
|
|
|
76
77
|
* @param receipt Optional. Information about received tokens
|
|
77
78
|
* @returns The step with the updated execution object
|
|
78
79
|
*/
|
|
79
|
-
updateExecution(
|
|
80
|
+
updateExecution(
|
|
81
|
+
step: LiFiStepExtended,
|
|
82
|
+
status: Status,
|
|
83
|
+
receipt?: Receipt
|
|
84
|
+
): LiFiStep {
|
|
80
85
|
if (!step.execution) {
|
|
81
86
|
throw Error("Can't update empty execution.")
|
|
82
87
|
}
|
|
@@ -99,7 +104,7 @@ export class StatusManager {
|
|
|
99
104
|
* @returns Returns process.
|
|
100
105
|
*/
|
|
101
106
|
findOrCreateProcess = (
|
|
102
|
-
step:
|
|
107
|
+
step: LiFiStepExtended,
|
|
103
108
|
type: ProcessType,
|
|
104
109
|
status?: Status
|
|
105
110
|
): Process => {
|
|
@@ -138,7 +143,7 @@ export class StatusManager {
|
|
|
138
143
|
* @returns The update process
|
|
139
144
|
*/
|
|
140
145
|
updateProcess = (
|
|
141
|
-
step:
|
|
146
|
+
step: LiFiStepExtended,
|
|
142
147
|
type: ProcessType,
|
|
143
148
|
status: Status,
|
|
144
149
|
params?: OptionalParameters
|
|
@@ -199,7 +204,7 @@ export class StatusManager {
|
|
|
199
204
|
* @param step The step where the process should be removed from
|
|
200
205
|
* @param type The process type to remove
|
|
201
206
|
*/
|
|
202
|
-
removeProcess = (step:
|
|
207
|
+
removeProcess = (step: LiFiStepExtended, type: ProcessType): void => {
|
|
203
208
|
if (!step.execution) {
|
|
204
209
|
throw new Error("Execution hasn't been initialized.")
|
|
205
210
|
}
|
package/src/core/execution.ts
CHANGED
|
@@ -3,7 +3,7 @@ import type { Route } from '@lifi/types'
|
|
|
3
3
|
import { config } from '../config.js'
|
|
4
4
|
import { executionState } from './executionState.js'
|
|
5
5
|
import { prepareRestart } from './prepareRestart.js'
|
|
6
|
-
import type { ExecutionOptions } from './types.js'
|
|
6
|
+
import type { ExecutionOptions, RouteExtended } from './types.js'
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Execute a route.
|
|
@@ -15,7 +15,7 @@ import type { ExecutionOptions } from './types.js'
|
|
|
15
15
|
export const executeRoute = async (
|
|
16
16
|
route: Route,
|
|
17
17
|
executionOptions?: ExecutionOptions
|
|
18
|
-
): Promise<
|
|
18
|
+
): Promise<RouteExtended> => {
|
|
19
19
|
// Deep clone to prevent side effects
|
|
20
20
|
const clonedRoute = structuredClone<Route>(route)
|
|
21
21
|
|
|
@@ -42,7 +42,7 @@ export const executeRoute = async (
|
|
|
42
42
|
export const resumeRoute = async (
|
|
43
43
|
route: Route,
|
|
44
44
|
executionOptions?: ExecutionOptions
|
|
45
|
-
): Promise<
|
|
45
|
+
): Promise<RouteExtended> => {
|
|
46
46
|
// Deep clone to prevent side effects
|
|
47
47
|
const clonedRoute = structuredClone<Route>(route)
|
|
48
48
|
|
|
@@ -74,9 +74,9 @@ export const resumeRoute = async (
|
|
|
74
74
|
}
|
|
75
75
|
|
|
76
76
|
const executeSteps = async (
|
|
77
|
-
route:
|
|
77
|
+
route: RouteExtended,
|
|
78
78
|
executionOptions?: ExecutionOptions
|
|
79
|
-
): Promise<
|
|
79
|
+
): Promise<RouteExtended> => {
|
|
80
80
|
executionState.create(route, executionOptions)
|
|
81
81
|
|
|
82
82
|
// Loop over steps and execute them
|
|
@@ -195,17 +195,17 @@ export const stopRouteExecution = (route: Route): Route => {
|
|
|
195
195
|
})
|
|
196
196
|
}
|
|
197
197
|
executionState.delete(route.id)
|
|
198
|
-
return route
|
|
198
|
+
return execution.route
|
|
199
199
|
}
|
|
200
200
|
|
|
201
201
|
/**
|
|
202
202
|
* Get the list of active routes.
|
|
203
203
|
* @returns A list of routes.
|
|
204
204
|
*/
|
|
205
|
-
export const getActiveRoutes = ():
|
|
205
|
+
export const getActiveRoutes = (): RouteExtended[] => {
|
|
206
206
|
return Object.values(executionState.state)
|
|
207
207
|
.map((dict) => dict?.route)
|
|
208
|
-
.filter(Boolean) as
|
|
208
|
+
.filter(Boolean) as RouteExtended[]
|
|
209
209
|
}
|
|
210
210
|
|
|
211
211
|
/**
|
|
@@ -213,6 +213,6 @@ export const getActiveRoutes = (): Route[] => {
|
|
|
213
213
|
* @param routeId - A route id.
|
|
214
214
|
* @returns The updated route.
|
|
215
215
|
*/
|
|
216
|
-
export const getActiveRoute = (routeId: string):
|
|
216
|
+
export const getActiveRoute = (routeId: string): RouteExtended | undefined => {
|
|
217
217
|
return executionState.get(routeId)?.route
|
|
218
218
|
}
|