@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,20 +1,19 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { ExecutionOptions, StepExecutor } from './types.js'
|
|
1
|
+
import type { ExecutionOptions, RouteExtended, StepExecutor } from './types.js'
|
|
3
2
|
|
|
4
3
|
export interface ExecutionData {
|
|
5
|
-
route:
|
|
4
|
+
route: RouteExtended
|
|
6
5
|
executors: StepExecutor[]
|
|
7
6
|
executionOptions?: ExecutionOptions
|
|
8
|
-
promise?: Promise<
|
|
7
|
+
promise?: Promise<RouteExtended>
|
|
9
8
|
}
|
|
10
9
|
|
|
11
10
|
export interface ExecutionState {
|
|
12
11
|
state: Partial<Record<string, ExecutionData>>
|
|
13
12
|
get(routeId: string): ExecutionData | undefined
|
|
14
13
|
create(
|
|
15
|
-
route:
|
|
14
|
+
route: RouteExtended,
|
|
16
15
|
executionOptions?: ExecutionOptions,
|
|
17
|
-
promise?: Promise<
|
|
16
|
+
promise?: Promise<RouteExtended>
|
|
18
17
|
): ExecutionData
|
|
19
18
|
delete(routeId: string): void
|
|
20
19
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import type { LiFiStep
|
|
1
|
+
import type { LiFiStep } from '@lifi/types'
|
|
2
|
+
import type { LiFiStepExtended, RouteExtended } from './types.js'
|
|
2
3
|
|
|
3
|
-
export const prepareRestart = async (route:
|
|
4
|
+
export const prepareRestart = async (route: RouteExtended) => {
|
|
4
5
|
for (let index = 0; index < route.steps.length; index++) {
|
|
5
6
|
const step = route.steps[index]
|
|
6
7
|
const stepHasFailed = step.execution?.status === 'FAILED'
|
|
@@ -68,7 +69,7 @@ export const prepareRestart = async (route: Route) => {
|
|
|
68
69
|
// }
|
|
69
70
|
// }
|
|
70
71
|
|
|
71
|
-
const deleteFailedProcesses = (step:
|
|
72
|
+
const deleteFailedProcesses = (step: LiFiStepExtended) => {
|
|
72
73
|
if (step.execution) {
|
|
73
74
|
step.execution.process = step.execution.process.filter(
|
|
74
75
|
(process) => process.status === 'DONE'
|
package/src/core/types.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type {
|
|
2
2
|
ChainType,
|
|
3
|
+
Execution,
|
|
3
4
|
LiFiStep,
|
|
4
5
|
Route,
|
|
5
6
|
Token,
|
|
@@ -29,7 +30,15 @@ export interface StepExecutor {
|
|
|
29
30
|
allowUserInteraction: boolean
|
|
30
31
|
allowExecution: boolean
|
|
31
32
|
setInteraction(settings?: InteractionSettings): void
|
|
32
|
-
executeStep(step:
|
|
33
|
+
executeStep(step: LiFiStepExtended): Promise<LiFiStepExtended>
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export interface RouteExtended extends Omit<Route, 'steps'> {
|
|
37
|
+
steps: LiFiStepExtended[]
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export interface LiFiStepExtended extends LiFiStep {
|
|
41
|
+
execution?: Execution
|
|
33
42
|
}
|
|
34
43
|
|
|
35
44
|
export type TransactionParameters = {
|
package/src/createConfig.ts
CHANGED
|
@@ -20,27 +20,29 @@ function createBaseConfig(options: SDKOptions) {
|
|
|
20
20
|
export async function createChainsConfig() {
|
|
21
21
|
const _config = config.get()
|
|
22
22
|
const chainTypes = _config.providers?.map((provider) => provider.type)
|
|
23
|
-
config.loading = getChains({ chainTypes: chainTypes })
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
const
|
|
23
|
+
config.loading = getChains({ chainTypes: chainTypes })
|
|
24
|
+
.then((chains) => {
|
|
25
|
+
config.chains = chains
|
|
26
|
+
const evmProvider = _config.providers?.find(isEVM)
|
|
27
|
+
const multicallAddresses: Partial<Record<ChainId, string>> = {}
|
|
28
|
+
for (const chain of chains) {
|
|
29
|
+
const chainId = chain.id as ChainId
|
|
29
30
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
// set RPCs if they were not configured by the user before
|
|
32
|
+
if (!_config.rpcUrls[chainId]?.length) {
|
|
33
|
+
_config.rpcUrls[chainId] = chain.metamask.rpcUrls
|
|
34
|
+
}
|
|
34
35
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
// set multicall addresses if they exist and were not configured by the user before
|
|
37
|
+
if (chain.multicallAddress && !evmProvider?.multicall?.[chainId]) {
|
|
38
|
+
multicallAddresses[chainId] = chain.multicallAddress
|
|
39
|
+
}
|
|
38
40
|
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
41
|
+
evmProvider?.setOptions({
|
|
42
|
+
multicall: multicallAddresses,
|
|
43
|
+
})
|
|
42
44
|
})
|
|
43
|
-
|
|
45
|
+
.catch()
|
|
44
46
|
await config.loading
|
|
45
47
|
}
|
|
46
48
|
|
package/src/version.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export const name = '@lifi/sdk'
|
|
2
|
-
export const version = '3.0.0-alpha.
|
|
2
|
+
export const version = '3.0.0-alpha.29'
|