@lifi/sdk 3.0.0-alpha.34 → 3.0.0-alpha.36

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 (101) hide show
  1. package/package.json +2 -2
  2. package/src/_cjs/config.js +41 -21
  3. package/src/_cjs/config.js.map +1 -1
  4. package/src/_cjs/core/EVM/EVM.js +0 -3
  5. package/src/_cjs/core/EVM/EVM.js.map +1 -1
  6. package/src/_cjs/core/EVM/EVMStepExecutor.js.map +1 -1
  7. package/src/_cjs/core/EVM/checkAllowance.js.map +1 -1
  8. package/src/_cjs/core/EVM/getAllowance.js.map +1 -1
  9. package/src/_cjs/core/EVM/getEVMBalance.js.map +1 -1
  10. package/src/_cjs/core/EVM/multisig.js.map +1 -1
  11. package/src/_cjs/core/EVM/publicClient.js.map +1 -1
  12. package/src/_cjs/core/EVM/setAllowance.js.map +1 -1
  13. package/src/_cjs/core/EVM/switchChain.js.map +1 -1
  14. package/src/_cjs/core/EVM/types.js.map +1 -1
  15. package/src/_cjs/core/EVM/utils.js +2 -5
  16. package/src/_cjs/core/EVM/utils.js.map +1 -1
  17. package/src/_cjs/core/Solana/Solana.js.map +1 -1
  18. package/src/_cjs/core/Solana/SolanaStepExecutor.js.map +1 -1
  19. package/src/_cjs/core/Solana/connection.js.map +1 -1
  20. package/src/_cjs/core/Solana/getSolanaBalance.js.map +1 -1
  21. package/src/_cjs/core/StatusManager.js.map +1 -1
  22. package/src/_cjs/core/checkBalance.js.map +1 -1
  23. package/src/_cjs/core/execution.js.map +1 -1
  24. package/src/_cjs/core/prepareRestart.js.map +1 -1
  25. package/src/_cjs/core/provider.js.map +1 -1
  26. package/src/_cjs/core/stepComparison.js.map +1 -1
  27. package/src/_cjs/core/utils.js.map +1 -1
  28. package/src/_cjs/core/waitForReceivingTransaction.js.map +1 -1
  29. package/src/_cjs/createConfig.js +10 -25
  30. package/src/_cjs/createConfig.js.map +1 -1
  31. package/src/_cjs/helpers.js.map +1 -1
  32. package/src/_cjs/request.js.map +1 -1
  33. package/src/_cjs/services/api.js.map +1 -1
  34. package/src/_cjs/services/balance.js.map +1 -1
  35. package/src/_cjs/utils/errors.js.map +1 -1
  36. package/src/_cjs/utils/getTransactionMessage.js.map +1 -1
  37. package/src/_cjs/utils/median.js.map +1 -1
  38. package/src/_cjs/utils/parseBackendError.js.map +1 -1
  39. package/src/_cjs/utils/parseError.js.map +1 -1
  40. package/src/_cjs/utils/utils.js.map +1 -1
  41. package/src/_cjs/version.js +1 -1
  42. package/src/_esm/config.js +40 -20
  43. package/src/_esm/config.js.map +1 -1
  44. package/src/_esm/core/EVM/EVM.js +0 -3
  45. package/src/_esm/core/EVM/EVM.js.map +1 -1
  46. package/src/_esm/core/EVM/EVMStepExecutor.js.map +1 -1
  47. package/src/_esm/core/EVM/checkAllowance.js.map +1 -1
  48. package/src/_esm/core/EVM/getAllowance.js.map +1 -1
  49. package/src/_esm/core/EVM/getEVMBalance.js.map +1 -1
  50. package/src/_esm/core/EVM/multisig.js.map +1 -1
  51. package/src/_esm/core/EVM/publicClient.js.map +1 -1
  52. package/src/_esm/core/EVM/setAllowance.js.map +1 -1
  53. package/src/_esm/core/EVM/switchChain.js.map +1 -1
  54. package/src/_esm/core/EVM/types.js.map +1 -1
  55. package/src/_esm/core/EVM/utils.js +3 -5
  56. package/src/_esm/core/EVM/utils.js.map +1 -1
  57. package/src/_esm/core/Solana/Solana.js.map +1 -1
  58. package/src/_esm/core/Solana/SolanaStepExecutor.js.map +1 -1
  59. package/src/_esm/core/Solana/connection.js.map +1 -1
  60. package/src/_esm/core/Solana/getSolanaBalance.js.map +1 -1
  61. package/src/_esm/core/StatusManager.js.map +1 -1
  62. package/src/_esm/core/checkBalance.js.map +1 -1
  63. package/src/_esm/core/execution.js.map +1 -1
  64. package/src/_esm/core/prepareRestart.js.map +1 -1
  65. package/src/_esm/core/provider.js.map +1 -1
  66. package/src/_esm/core/stepComparison.js.map +1 -1
  67. package/src/_esm/core/utils.js.map +1 -1
  68. package/src/_esm/core/waitForReceivingTransaction.js.map +1 -1
  69. package/src/_esm/createConfig.js +11 -27
  70. package/src/_esm/createConfig.js.map +1 -1
  71. package/src/_esm/helpers.js.map +1 -1
  72. package/src/_esm/request.js.map +1 -1
  73. package/src/_esm/services/api.js.map +1 -1
  74. package/src/_esm/services/balance.js.map +1 -1
  75. package/src/_esm/utils/errors.js.map +1 -1
  76. package/src/_esm/utils/getTransactionMessage.js.map +1 -1
  77. package/src/_esm/utils/median.js.map +1 -1
  78. package/src/_esm/utils/parseBackendError.js.map +1 -1
  79. package/src/_esm/utils/parseError.js.map +1 -1
  80. package/src/_esm/utils/utils.js.map +1 -1
  81. package/src/_esm/version.js +1 -1
  82. package/src/_types/config.d.ts +5 -3
  83. package/src/_types/config.d.ts.map +1 -1
  84. package/src/_types/core/EVM/EVM.d.ts.map +1 -1
  85. package/src/_types/core/EVM/EVMStepExecutor.d.ts.map +1 -1
  86. package/src/_types/core/EVM/types.d.ts +1 -3
  87. package/src/_types/core/EVM/types.d.ts.map +1 -1
  88. package/src/_types/core/EVM/utils.d.ts.map +1 -1
  89. package/src/_types/createConfig.d.ts +1 -10
  90. package/src/_types/createConfig.d.ts.map +1 -1
  91. package/src/_types/types/internal.d.ts +8 -6
  92. package/src/_types/types/internal.d.ts.map +1 -1
  93. package/src/_types/version.d.ts +1 -1
  94. package/src/config.ts +40 -20
  95. package/src/core/EVM/EVM.ts +0 -3
  96. package/src/core/EVM/EVMStepExecutor.ts +4 -2
  97. package/src/core/EVM/types.ts +1 -3
  98. package/src/core/EVM/utils.ts +3 -8
  99. package/src/createConfig.ts +10 -30
  100. package/src/types/internal.ts +8 -6
  101. package/src/version.ts +1 -1
@@ -1,9 +1,7 @@
1
- import { ChainType, type ChainId } from '@lifi/types'
1
+ import { type ChainId } from '@lifi/types'
2
2
  import type { PublicClient, Transaction } from 'viem'
3
3
  import { config } from '../../config.js'
4
4
  import { median } from '../../utils/median.js'
5
- import { getProvider } from '../provider.js'
6
- import type { EVMProvider } from './types.js'
7
5
 
8
6
  export const getMaxPriorityFeePerGas = async (
9
7
  client: PublicClient
@@ -39,9 +37,6 @@ export const getMaxPriorityFeePerGas = async (
39
37
  export const getMulticallAddress = async (
40
38
  chainId: ChainId
41
39
  ): Promise<string | undefined> => {
42
- const provider = getProvider<EVMProvider>(ChainType.EVM)
43
- return (
44
- provider.multicall?.[chainId] ??
45
- config.chains.find((chain) => chain.id === chainId)?.multicallAddress
46
- )
40
+ const chains = await config.getChains()
41
+ return chains.find((chain) => chain.id === chainId)?.multicallAddress
47
42
  }
@@ -1,7 +1,6 @@
1
1
  /* eslint-disable @typescript-eslint/no-empty-function */
2
- import type { ChainId } from '@lifi/types'
2
+ import { ChainType } from '@lifi/types'
3
3
  import { config } from './config.js'
4
- import { isEVM } from './core/EVM/types.js'
5
4
  import { checkPackageUpdates } from './helpers.js'
6
5
  import { getChains } from './services/api.js'
7
6
  import type { SDKOptions } from './types/index.js'
@@ -13,41 +12,22 @@ function createBaseConfig(options: SDKOptions) {
13
12
  'Integrator not found. Please see documentation https://docs.li.fi/integrate-li.fi-js-sdk/set-up-the-sdk'
14
13
  )
15
14
  }
16
- config.set(options)
15
+ const _config = config.set(options)
17
16
  checkPackageUpdates(name, version, options.disableVersionCheck)
17
+ return _config
18
18
  }
19
19
 
20
20
  export async function createChainsConfig() {
21
- const _config = config.get()
22
- const chainTypes = _config.providers?.map((provider) => provider.type)
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
30
-
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
- }
35
-
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
- }
40
- }
41
- evmProvider?.setOptions({
42
- multicall: multicallAddresses,
43
- })
44
- })
21
+ config.loading = getChains({ chainTypes: Object.values(ChainType) })
22
+ .then((chains) => config.setChains(chains))
45
23
  .catch()
46
24
  await config.loading
47
25
  }
48
26
 
49
27
  export function createConfig(options: SDKOptions) {
50
- createBaseConfig(options)
51
- createChainsConfig()
52
- return config
28
+ const _config = createBaseConfig(options)
29
+ if (_config.preloadChains) {
30
+ createChainsConfig()
31
+ }
32
+ return _config
53
33
  }
@@ -1,16 +1,18 @@
1
- import type { ChainId, RouteOptions } from '@lifi/types'
1
+ import type { ChainId, ExtendedChain, RouteOptions } from '@lifi/types'
2
2
  import type { SDKProvider } from '../core/types.js'
3
3
 
4
4
  export interface SDKConfig {
5
- integrator: string
6
- apiUrl: string
7
5
  apiKey?: string
6
+ apiUrl: string
7
+ integrator: string
8
8
  userId?: string
9
- disableVersionCheck?: boolean
10
- widgetVersion?: string
11
- routeOptions?: RouteOptions
12
9
  providers?: SDKProvider[]
10
+ routeOptions?: RouteOptions
13
11
  rpcUrls: Partial<Record<ChainId, string[]>>
12
+ chains: ExtendedChain[]
13
+ disableVersionCheck?: boolean
14
+ widgetVersion?: string
15
+ preloadChains: boolean
14
16
  }
15
17
 
16
18
  export interface SDKOptions extends Partial<Omit<SDKConfig, 'integrator'>> {
package/src/version.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  export const name = '@lifi/sdk'
2
- export const version = '3.0.0-alpha.34'
2
+ export const version = '3.0.0-alpha.36'