@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.
Files changed (67) hide show
  1. package/package.json +2 -2
  2. package/src/_cjs/constants.js +2 -1
  3. package/src/_cjs/constants.js.map +1 -1
  4. package/src/_cjs/core/EVM/EVMStepExecutor.js.map +1 -1
  5. package/src/_cjs/core/EVM/switchChain.js.map +1 -1
  6. package/src/_cjs/core/Solana/SolanaStepExecutor.js.map +1 -1
  7. package/src/_cjs/core/Solana/getSolanaBalance.js +23 -13
  8. package/src/_cjs/core/Solana/getSolanaBalance.js.map +1 -1
  9. package/src/_cjs/core/StatusManager.js.map +1 -1
  10. package/src/_cjs/core/execution.js +1 -1
  11. package/src/_cjs/core/execution.js.map +1 -1
  12. package/src/_cjs/core/executionState.js.map +1 -1
  13. package/src/_cjs/core/prepareRestart.js.map +1 -1
  14. package/src/_cjs/createConfig.js +4 -2
  15. package/src/_cjs/createConfig.js.map +1 -1
  16. package/src/_cjs/version.js +1 -1
  17. package/src/_esm/constants.js +1 -0
  18. package/src/_esm/constants.js.map +1 -1
  19. package/src/_esm/core/EVM/EVMStepExecutor.js.map +1 -1
  20. package/src/_esm/core/EVM/switchChain.js.map +1 -1
  21. package/src/_esm/core/Solana/SolanaStepExecutor.js.map +1 -1
  22. package/src/_esm/core/Solana/getSolanaBalance.js +23 -13
  23. package/src/_esm/core/Solana/getSolanaBalance.js.map +1 -1
  24. package/src/_esm/core/StatusManager.js.map +1 -1
  25. package/src/_esm/core/execution.js +1 -1
  26. package/src/_esm/core/execution.js.map +1 -1
  27. package/src/_esm/core/executionState.js.map +1 -1
  28. package/src/_esm/core/prepareRestart.js.map +1 -1
  29. package/src/_esm/createConfig.js +4 -2
  30. package/src/_esm/createConfig.js.map +1 -1
  31. package/src/_esm/version.js +1 -1
  32. package/src/_types/constants.d.ts +1 -0
  33. package/src/_types/constants.d.ts.map +1 -1
  34. package/src/_types/core/EVM/EVMStepExecutor.d.ts +2 -3
  35. package/src/_types/core/EVM/EVMStepExecutor.d.ts.map +1 -1
  36. package/src/_types/core/EVM/switchChain.d.ts +2 -3
  37. package/src/_types/core/EVM/switchChain.d.ts.map +1 -1
  38. package/src/_types/core/Solana/SolanaStepExecutor.d.ts +4 -5
  39. package/src/_types/core/Solana/SolanaStepExecutor.d.ts.map +1 -1
  40. package/src/_types/core/Solana/getSolanaBalance.d.ts.map +1 -1
  41. package/src/_types/core/Solana/types.d.ts +2 -2
  42. package/src/_types/core/Solana/types.d.ts.map +1 -1
  43. package/src/_types/core/StatusManager.d.ts +6 -5
  44. package/src/_types/core/StatusManager.d.ts.map +1 -1
  45. package/src/_types/core/execution.d.ts +5 -5
  46. package/src/_types/core/execution.d.ts.map +1 -1
  47. package/src/_types/core/executionState.d.ts +4 -5
  48. package/src/_types/core/executionState.d.ts.map +1 -1
  49. package/src/_types/core/prepareRestart.d.ts +2 -2
  50. package/src/_types/core/prepareRestart.d.ts.map +1 -1
  51. package/src/_types/core/types.d.ts +8 -2
  52. package/src/_types/core/types.d.ts.map +1 -1
  53. package/src/_types/createConfig.d.ts.map +1 -1
  54. package/src/_types/version.d.ts +1 -1
  55. package/src/constants.ts +1 -0
  56. package/src/core/EVM/EVMStepExecutor.ts +7 -7
  57. package/src/core/EVM/switchChain.ts +2 -3
  58. package/src/core/Solana/SolanaStepExecutor.ts +10 -10
  59. package/src/core/Solana/getSolanaBalance.ts +28 -18
  60. package/src/core/Solana/types.ts +2 -2
  61. package/src/core/StatusManager.ts +10 -5
  62. package/src/core/execution.ts +9 -9
  63. package/src/core/executionState.ts +5 -6
  64. package/src/core/prepareRestart.ts +4 -3
  65. package/src/core/types.ts +10 -1
  66. package/src/createConfig.ts +19 -17
  67. package/src/version.ts +1 -1
@@ -1,20 +1,19 @@
1
- import type { Route } from '@lifi/types'
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: Route
4
+ route: RouteExtended
6
5
  executors: StepExecutor[]
7
6
  executionOptions?: ExecutionOptions
8
- promise?: Promise<Route>
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: Route,
14
+ route: RouteExtended,
16
15
  executionOptions?: ExecutionOptions,
17
- promise?: Promise<Route>
16
+ promise?: Promise<RouteExtended>
18
17
  ): ExecutionData
19
18
  delete(routeId: string): void
20
19
  }
@@ -1,6 +1,7 @@
1
- import type { LiFiStep, Route } from '@lifi/types'
1
+ import type { LiFiStep } from '@lifi/types'
2
+ import type { LiFiStepExtended, RouteExtended } from './types.js'
2
3
 
3
- export const prepareRestart = async (route: 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: LiFiStep) => {
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: LiFiStep): Promise<LiFiStep>
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 = {
@@ -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 }).then((chains) => {
24
- config.chains = chains
25
- const evmProvider = _config.providers?.find(isEVM)
26
- const multicallAddresses: Partial<Record<ChainId, string>> = {}
27
- for (const chain of chains) {
28
- const chainId = chain.id as ChainId
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
- // set RPCs if they were not configured by the user before
31
- if (!_config.rpcUrls[chainId]?.length) {
32
- _config.rpcUrls[chainId] = chain.metamask.rpcUrls
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
- // set multicall addresses if they exist and were not configured by the user before
36
- if (chain.multicallAddress && !evmProvider?.multicall?.[chainId]) {
37
- multicallAddresses[chainId] = chain.multicallAddress
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
- evmProvider?.setOptions({
41
- multicall: multicallAddresses,
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.28'
2
+ export const version = '3.0.0-alpha.29'