@lifi/sdk 3.7.0-beta.2 → 3.7.0-beta.3

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 (104) hide show
  1. package/package.json +7 -5
  2. package/src/_cjs/core/EVM/EVMStepExecutor.js +4 -2
  3. package/src/_cjs/core/EVM/EVMStepExecutor.js.map +1 -1
  4. package/src/_cjs/core/Solana/SolanaStepExecutor.js.map +1 -1
  5. package/src/_cjs/core/Solana/types.js.map +1 -1
  6. package/src/_cjs/core/Sui/Sui.js +37 -0
  7. package/src/_cjs/core/Sui/Sui.js.map +1 -0
  8. package/src/_cjs/core/Sui/SuiStepExecutor.js +117 -0
  9. package/src/_cjs/core/Sui/SuiStepExecutor.js.map +1 -0
  10. package/src/_cjs/core/Sui/getSuiBalance.js +54 -0
  11. package/src/_cjs/core/Sui/getSuiBalance.js.map +1 -0
  12. package/src/_cjs/core/Sui/getSuiNSAddress.js +32 -0
  13. package/src/_cjs/core/Sui/getSuiNSAddress.js.map +1 -0
  14. package/src/_cjs/core/Sui/parseSuiErrors.js +38 -0
  15. package/src/_cjs/core/Sui/parseSuiErrors.js.map +1 -0
  16. package/src/_cjs/core/Sui/suiClient.js +38 -0
  17. package/src/_cjs/core/Sui/suiClient.js.map +1 -0
  18. package/src/_cjs/core/Sui/types.js +11 -0
  19. package/src/_cjs/core/Sui/types.js.map +1 -0
  20. package/src/_cjs/core/checkBalance.js +2 -2
  21. package/src/_cjs/core/checkBalance.js.map +1 -1
  22. package/src/_cjs/core/rpc.js +1 -1
  23. package/src/_cjs/core/rpc.js.map +1 -1
  24. package/src/_cjs/createConfig.js +1 -1
  25. package/src/_cjs/createConfig.js.map +1 -1
  26. package/src/_cjs/index.js +5 -1
  27. package/src/_cjs/index.js.map +1 -1
  28. package/src/_cjs/services/balance.js +1 -5
  29. package/src/_cjs/services/balance.js.map +1 -1
  30. package/src/_cjs/version.js +1 -1
  31. package/src/_esm/core/EVM/EVMStepExecutor.js +6 -2
  32. package/src/_esm/core/EVM/EVMStepExecutor.js.map +1 -1
  33. package/src/_esm/core/Solana/SolanaStepExecutor.js.map +1 -1
  34. package/src/_esm/core/Solana/types.js.map +1 -1
  35. package/src/_esm/core/StatusManager.js +1 -1
  36. package/src/_esm/core/Sui/Sui.js +34 -0
  37. package/src/_esm/core/Sui/Sui.js.map +1 -0
  38. package/src/_esm/core/Sui/SuiStepExecutor.js +118 -0
  39. package/src/_esm/core/Sui/SuiStepExecutor.js.map +1 -0
  40. package/src/_esm/core/Sui/getSuiBalance.js +51 -0
  41. package/src/_esm/core/Sui/getSuiBalance.js.map +1 -0
  42. package/src/_esm/core/Sui/getSuiNSAddress.js +29 -0
  43. package/src/_esm/core/Sui/getSuiNSAddress.js.map +1 -0
  44. package/src/_esm/core/Sui/parseSuiErrors.js +34 -0
  45. package/src/_esm/core/Sui/parseSuiErrors.js.map +1 -0
  46. package/src/_esm/core/Sui/suiClient.js +47 -0
  47. package/src/_esm/core/Sui/suiClient.js.map +1 -0
  48. package/src/_esm/core/Sui/types.js +7 -0
  49. package/src/_esm/core/Sui/types.js.map +1 -0
  50. package/src/_esm/core/checkBalance.js +2 -2
  51. package/src/_esm/core/checkBalance.js.map +1 -1
  52. package/src/_esm/core/rpc.js +1 -1
  53. package/src/_esm/core/rpc.js.map +1 -1
  54. package/src/_esm/createConfig.js +1 -1
  55. package/src/_esm/createConfig.js.map +1 -1
  56. package/src/_esm/index.js +3 -1
  57. package/src/_esm/index.js.map +1 -1
  58. package/src/_esm/services/balance.js +1 -5
  59. package/src/_esm/services/balance.js.map +1 -1
  60. package/src/_esm/version.js +1 -1
  61. package/src/_types/core/EVM/EVMStepExecutor.d.ts.map +1 -1
  62. package/src/_types/core/Solana/SolanaStepExecutor.d.ts +2 -5
  63. package/src/_types/core/Solana/SolanaStepExecutor.d.ts.map +1 -1
  64. package/src/_types/core/Solana/types.d.ts +4 -1
  65. package/src/_types/core/Solana/types.d.ts.map +1 -1
  66. package/src/_types/core/StatusManager.d.ts +1 -1
  67. package/src/_types/core/Sui/Sui.d.ts +3 -0
  68. package/src/_types/core/Sui/Sui.d.ts.map +1 -0
  69. package/src/_types/core/Sui/SuiStepExecutor.d.ts +10 -0
  70. package/src/_types/core/Sui/SuiStepExecutor.d.ts.map +1 -0
  71. package/src/_types/core/Sui/getSuiBalance.d.ts +3 -0
  72. package/src/_types/core/Sui/getSuiBalance.d.ts.map +1 -0
  73. package/src/_types/core/Sui/getSuiNSAddress.d.ts +2 -0
  74. package/src/_types/core/Sui/getSuiNSAddress.d.ts.map +1 -0
  75. package/src/_types/core/Sui/parseSuiErrors.d.ts +5 -0
  76. package/src/_types/core/Sui/parseSuiErrors.d.ts.map +1 -0
  77. package/src/_types/core/Sui/suiClient.d.ts +18 -0
  78. package/src/_types/core/Sui/suiClient.d.ts.map +1 -0
  79. package/src/_types/core/Sui/types.d.ts +15 -0
  80. package/src/_types/core/Sui/types.d.ts.map +1 -0
  81. package/src/_types/core/UTXO/getUTXOPublicClient.d.ts +32 -2
  82. package/src/_types/core/UTXO/getUTXOPublicClient.d.ts.map +1 -1
  83. package/src/_types/index.d.ts +5 -2
  84. package/src/_types/index.d.ts.map +1 -1
  85. package/src/_types/services/balance.d.ts +1 -1
  86. package/src/_types/services/balance.d.ts.map +1 -1
  87. package/src/_types/version.d.ts +1 -1
  88. package/src/core/EVM/EVMStepExecutor.ts +6 -2
  89. package/src/core/Solana/SolanaStepExecutor.ts +2 -10
  90. package/src/core/Solana/types.ts +5 -1
  91. package/src/core/StatusManager.ts +1 -1
  92. package/src/core/Sui/Sui.ts +41 -0
  93. package/src/core/Sui/SuiStepExecutor.ts +203 -0
  94. package/src/core/Sui/getSuiBalance.ts +86 -0
  95. package/src/core/Sui/getSuiNSAddress.ts +40 -0
  96. package/src/core/Sui/parseSuiErrors.ts +55 -0
  97. package/src/core/Sui/suiClient.ts +51 -0
  98. package/src/core/Sui/types.ts +23 -0
  99. package/src/core/checkBalance.ts +2 -2
  100. package/src/core/rpc.ts +1 -1
  101. package/src/createConfig.ts +1 -1
  102. package/src/index.ts +5 -9
  103. package/src/services/balance.ts +2 -7
  104. package/src/version.ts +1 -1
@@ -0,0 +1,203 @@
1
+ import {
2
+ type WalletWithRequiredFeatures,
3
+ signAndExecuteTransaction,
4
+ } from '@mysten/wallet-standard'
5
+ import { config } from '../../config.js'
6
+ import { LiFiErrorCode } from '../../errors/constants.js'
7
+ import { TransactionError } from '../../errors/errors.js'
8
+ import { getStepTransaction } from '../../services/api.js'
9
+ import { BaseStepExecutor } from '../BaseStepExecutor.js'
10
+ import { checkBalance } from '../checkBalance.js'
11
+ import { stepComparison } from '../stepComparison.js'
12
+ import type { LiFiStepExtended, TransactionParameters } from '../types.js'
13
+ import { waitForDestinationChainTransaction } from '../waitForDestinationChainTransaction.js'
14
+ import { parseSuiErrors } from './parseSuiErrors.js'
15
+ import { callSuiWithRetry } from './suiClient.js'
16
+ import type { SuiStepExecutorOptions } from './types.js'
17
+
18
+ export class SuiStepExecutor extends BaseStepExecutor {
19
+ private wallet: WalletWithRequiredFeatures
20
+
21
+ constructor(options: SuiStepExecutorOptions) {
22
+ super(options)
23
+ this.wallet = options.wallet
24
+ }
25
+
26
+ checkWallet = (step: LiFiStepExtended) => {
27
+ // Prevent execution of the quote by wallet different from the one which requested the quote
28
+ if (
29
+ !this.wallet.accounts?.some?.(
30
+ (account) => account.address === step.action.fromAddress
31
+ )
32
+ ) {
33
+ throw new TransactionError(
34
+ LiFiErrorCode.WalletChangedDuringExecution,
35
+ 'The wallet address that requested the quote does not match the wallet address attempting to sign the transaction.'
36
+ )
37
+ }
38
+ }
39
+
40
+ executeStep = async (step: LiFiStepExtended): Promise<LiFiStepExtended> => {
41
+ step.execution = this.statusManager.initExecutionObject(step)
42
+
43
+ const fromChain = await config.getChainById(step.action.fromChainId)
44
+ const toChain = await config.getChainById(step.action.toChainId)
45
+
46
+ const isBridgeExecution = fromChain.id !== toChain.id
47
+ const currentProcessType = isBridgeExecution ? 'CROSS_CHAIN' : 'SWAP'
48
+
49
+ let process = this.statusManager.findOrCreateProcess({
50
+ step,
51
+ type: currentProcessType,
52
+ chainId: fromChain.id,
53
+ })
54
+
55
+ if (process.status !== 'DONE') {
56
+ try {
57
+ process = this.statusManager.updateProcess(
58
+ step,
59
+ process.type,
60
+ 'STARTED'
61
+ )
62
+
63
+ // Check balance
64
+ await checkBalance(step.action.fromAddress!, step)
65
+
66
+ // Create new transaction
67
+ if (!step.transactionRequest) {
68
+ const { execution, ...stepBase } = step
69
+ const updatedStep = await getStepTransaction(stepBase)
70
+ const comparedStep = await stepComparison(
71
+ this.statusManager,
72
+ step,
73
+ updatedStep,
74
+ this.allowUserInteraction,
75
+ this.executionOptions
76
+ )
77
+ Object.assign(step, {
78
+ ...comparedStep,
79
+ execution: step.execution,
80
+ })
81
+ }
82
+
83
+ if (!step.transactionRequest?.data) {
84
+ throw new TransactionError(
85
+ LiFiErrorCode.TransactionUnprepared,
86
+ 'Unable to prepare transaction.'
87
+ )
88
+ }
89
+
90
+ process = this.statusManager.updateProcess(
91
+ step,
92
+ process.type,
93
+ 'ACTION_REQUIRED'
94
+ )
95
+
96
+ if (!this.allowUserInteraction) {
97
+ return step
98
+ }
99
+
100
+ let transactionRequest: TransactionParameters = {
101
+ data: step.transactionRequest.data,
102
+ }
103
+
104
+ if (this.executionOptions?.updateTransactionRequestHook) {
105
+ const customizedTransactionRequest: TransactionParameters =
106
+ await this.executionOptions.updateTransactionRequestHook({
107
+ requestType: 'transaction',
108
+ ...transactionRequest,
109
+ })
110
+
111
+ transactionRequest = {
112
+ ...transactionRequest,
113
+ ...customizedTransactionRequest,
114
+ }
115
+ }
116
+
117
+ const transactionRequestData = transactionRequest.data
118
+
119
+ if (!transactionRequestData) {
120
+ throw new TransactionError(
121
+ LiFiErrorCode.TransactionUnprepared,
122
+ 'Unable to prepare transaction.'
123
+ )
124
+ }
125
+
126
+ this.checkWallet(step)
127
+
128
+ // We give users 2 minutes to sign the transaction
129
+ const signedTx = await signAndExecuteTransaction(this.wallet, {
130
+ account: this.wallet.accounts.find(
131
+ (account) => account.address === step.action.fromAddress
132
+ )!,
133
+ chain: 'sui:mainnet',
134
+ transaction: {
135
+ toJSON: async () => transactionRequestData,
136
+ },
137
+ })
138
+
139
+ process = this.statusManager.updateProcess(
140
+ step,
141
+ process.type,
142
+ 'PENDING'
143
+ )
144
+
145
+ const result = await callSuiWithRetry((client) =>
146
+ client.waitForTransaction({
147
+ digest: signedTx.digest,
148
+ options: {
149
+ showEffects: true,
150
+ },
151
+ })
152
+ )
153
+
154
+ if (result.effects?.status.status !== 'success') {
155
+ throw new TransactionError(
156
+ LiFiErrorCode.TransactionFailed,
157
+ `Transaction failed: ${result.effects?.status.error}`
158
+ )
159
+ }
160
+
161
+ // Transaction has been confirmed and we can update the process
162
+ process = this.statusManager.updateProcess(
163
+ step,
164
+ process.type,
165
+ 'PENDING',
166
+ {
167
+ txHash: result.digest,
168
+ txLink: `${fromChain.metamask.blockExplorerUrls[0]}txblock/${result.digest}`,
169
+ }
170
+ )
171
+
172
+ if (isBridgeExecution) {
173
+ process = this.statusManager.updateProcess(step, process.type, 'DONE')
174
+ }
175
+ } catch (e: any) {
176
+ const error = await parseSuiErrors(e, step, process)
177
+ process = this.statusManager.updateProcess(
178
+ step,
179
+ process.type,
180
+ 'FAILED',
181
+ {
182
+ error: {
183
+ message: error.cause.message,
184
+ code: error.code,
185
+ },
186
+ }
187
+ )
188
+ this.statusManager.updateExecution(step, 'FAILED')
189
+ throw error
190
+ }
191
+ }
192
+
193
+ await waitForDestinationChainTransaction(
194
+ step,
195
+ process,
196
+ fromChain,
197
+ toChain,
198
+ this.statusManager
199
+ )
200
+
201
+ return step
202
+ }
203
+ }
@@ -0,0 +1,86 @@
1
+ import type { Token, TokenAmount } from '@lifi/types'
2
+ import { withDedupe } from '../../utils/withDedupe.js'
3
+ import { callSuiWithRetry } from './suiClient.js'
4
+ import { SuiTokenLongAddress, SuiTokenShortAddress } from './types.js'
5
+
6
+ export async function getSuiBalance(
7
+ walletAddress: string,
8
+ tokens: Token[]
9
+ ): Promise<TokenAmount[]> {
10
+ if (tokens.length === 0) {
11
+ return []
12
+ }
13
+
14
+ const { chainId } = tokens[0]
15
+ for (const token of tokens) {
16
+ if (token.chainId !== chainId) {
17
+ console.warn('Requested tokens have to be on the same chain.')
18
+ }
19
+ }
20
+
21
+ return getSuiBalanceDefault(chainId, tokens, walletAddress)
22
+ }
23
+
24
+ const getSuiBalanceDefault = async (
25
+ _chainId: number,
26
+ tokens: Token[],
27
+ walletAddress: string
28
+ ): Promise<TokenAmount[]> => {
29
+ const [coins, checkpoint] = await Promise.allSettled([
30
+ withDedupe(
31
+ () =>
32
+ callSuiWithRetry((client) =>
33
+ client.getAllBalances({
34
+ owner: walletAddress,
35
+ })
36
+ ),
37
+ { id: `${getSuiBalanceDefault.name}.getAllBalances` }
38
+ ),
39
+ withDedupe(
40
+ () =>
41
+ callSuiWithRetry((client) =>
42
+ client.getLatestCheckpointSequenceNumber()
43
+ ),
44
+ { id: `${getSuiBalanceDefault.name}.getLatestCheckpointSequenceNumber` }
45
+ ),
46
+ ])
47
+
48
+ const coinsResult = coins.status === 'fulfilled' ? coins.value : []
49
+ const blockNumber =
50
+ checkpoint.status === 'fulfilled' ? BigInt(checkpoint.value) : 0n
51
+
52
+ const walletTokenAmounts = coinsResult.reduce(
53
+ (tokenAmounts, coin) => {
54
+ const amount = BigInt(coin.totalBalance)
55
+ if (amount > 0n) {
56
+ tokenAmounts[coin.coinType] = amount
57
+ }
58
+ return tokenAmounts
59
+ },
60
+ {} as Record<string, bigint>
61
+ )
62
+
63
+ const suiTokenBalance = coinsResult.find(
64
+ (coin) => coin.coinType === SuiTokenShortAddress
65
+ )
66
+ if (suiTokenBalance?.totalBalance) {
67
+ walletTokenAmounts[SuiTokenLongAddress] = BigInt(
68
+ suiTokenBalance.totalBalance
69
+ )
70
+ }
71
+
72
+ const tokenAmounts: TokenAmount[] = tokens.map((token) => {
73
+ if (walletTokenAmounts[token.address]) {
74
+ return {
75
+ ...token,
76
+ amount: walletTokenAmounts[token.address],
77
+ blockNumber,
78
+ }
79
+ }
80
+ return {
81
+ ...token,
82
+ blockNumber,
83
+ }
84
+ })
85
+ return tokenAmounts
86
+ }
@@ -0,0 +1,40 @@
1
+ import { SuiClient } from '@mysten/sui/client'
2
+
3
+ const SNS_REGISTRY_ID =
4
+ '0x6e0ddefc0ad3ed64f53f5f91b7023077b2f7c131d7e6d5e0d1a0e4e6f1a2c3b4'
5
+
6
+ export async function getSuiNSAddress(
7
+ name: string,
8
+ rpcUrl?: string
9
+ ): Promise<string | undefined> {
10
+ const client = new SuiClient({
11
+ url: rpcUrl || 'https://fullnode.mainnet.sui.io:443',
12
+ })
13
+
14
+ try {
15
+ const result = await client.getObject({
16
+ id: SNS_REGISTRY_ID,
17
+ options: {
18
+ showContent: true,
19
+ },
20
+ })
21
+
22
+ if (!result.data?.content) {
23
+ return
24
+ }
25
+
26
+ const registry = result.data.content as any
27
+ const nameRecord = registry.fields.records.find(
28
+ (record: any) => record.fields.name === name
29
+ )
30
+
31
+ if (!nameRecord) {
32
+ return
33
+ }
34
+
35
+ return nameRecord.fields.address
36
+ } catch (error) {
37
+ console.error('Error resolving SuiNS address:', error)
38
+ return
39
+ }
40
+ }
@@ -0,0 +1,55 @@
1
+ import type { LiFiStep } from '@lifi/types'
2
+ import { SDKError } from '../../errors/SDKError.js'
3
+ import { BaseError } from '../../errors/baseError.js'
4
+ import { ErrorMessage, LiFiErrorCode } from '../../errors/constants.js'
5
+ import { TransactionError, UnknownError } from '../../errors/errors.js'
6
+ import type { Process } from '../types.js'
7
+
8
+ export const parseSuiErrors = async (
9
+ e: Error,
10
+ step?: LiFiStep,
11
+ process?: Process
12
+ ): Promise<SDKError> => {
13
+ if (e instanceof SDKError) {
14
+ e.step = e.step ?? step
15
+ e.process = e.process ?? process
16
+ return e
17
+ }
18
+
19
+ const baseError = handleSpecificErrors(e)
20
+
21
+ return new SDKError(baseError, step, process)
22
+ }
23
+
24
+ const handleSpecificErrors = (e: any) => {
25
+ const isRejection =
26
+ typeof e === 'string'
27
+ ? e.toLowerCase().includes('reject')
28
+ : e.message?.toLowerCase().includes('reject')
29
+
30
+ if (isRejection) {
31
+ return new TransactionError(LiFiErrorCode.SignatureRejected, e.message, e)
32
+ }
33
+
34
+ if (
35
+ e.message?.toLowerCase().includes('transaction') &&
36
+ (e.message?.toLowerCase().includes('failed') ||
37
+ e.message?.toLowerCase().includes('error'))
38
+ ) {
39
+ return new TransactionError(LiFiErrorCode.TransactionFailed, e.message, e)
40
+ }
41
+
42
+ if (e.message?.includes('simulate') || e.message?.includes('simulation')) {
43
+ return new TransactionError(
44
+ LiFiErrorCode.TransactionSimulationFailed,
45
+ e.message,
46
+ e
47
+ )
48
+ }
49
+
50
+ if (e instanceof BaseError) {
51
+ return e
52
+ }
53
+
54
+ return new UnknownError(e.message || ErrorMessage.UnknownError, e)
55
+ }
@@ -0,0 +1,51 @@
1
+ import { ChainId } from '@lifi/types'
2
+ import { SuiClient } from '@mysten/sui/client'
3
+ import { getRpcUrls } from '../rpc.js'
4
+
5
+ const clients = new Map<string, SuiClient>()
6
+
7
+ /**
8
+ * Initializes the Sui clients if they haven't been initialized yet.
9
+ * @returns - Promise that resolves when clients are initialized.
10
+ */
11
+ export const ensureClients = async (): Promise<void> => {
12
+ const rpcUrls = await getRpcUrls(ChainId.SUI)
13
+ for (const rpcUrl of rpcUrls) {
14
+ if (!clients.get(rpcUrl)) {
15
+ const client = new SuiClient({ url: rpcUrl })
16
+ clients.set(rpcUrl, client)
17
+ }
18
+ }
19
+ }
20
+
21
+ /**
22
+ * Wrapper around getting the client (RPC provider) for Sui
23
+ * @returns - Sui RPC clients
24
+ */
25
+ export const getSuiClients = async (): Promise<SuiClient[]> => {
26
+ await ensureClients()
27
+ return Array.from(clients.values())
28
+ }
29
+
30
+ /**
31
+ * Calls a function on the SuiClient instances with retry logic.
32
+ * @param fn - The function to call, which receives a SuiClient instance.
33
+ * @returns - The result of the function call.
34
+ */
35
+ export async function callSuiWithRetry<R>(
36
+ fn: (client: SuiClient) => Promise<R>
37
+ ): Promise<R> {
38
+ // Ensure clients are initialized
39
+ await ensureClients()
40
+ let lastError: any = null
41
+ for (const client of clients.values()) {
42
+ try {
43
+ const result = await fn(client)
44
+ return result
45
+ } catch (error) {
46
+ lastError = error
47
+ }
48
+ }
49
+ // Throw the last encountered error
50
+ throw lastError
51
+ }
@@ -0,0 +1,23 @@
1
+ import { ChainType } from '@lifi/types'
2
+ import type { WalletWithRequiredFeatures } from '@mysten/wallet-standard'
3
+ import type { SDKProvider, StepExecutorOptions } from '../types.js'
4
+
5
+ export interface SuiProviderOptions {
6
+ getWallet?: () => Promise<WalletWithRequiredFeatures>
7
+ }
8
+
9
+ export interface SuiProvider extends SDKProvider {
10
+ setOptions(options: SuiProviderOptions): void
11
+ }
12
+
13
+ export function isSui(provider: SDKProvider): provider is SuiProvider {
14
+ return provider.type === ChainType.MVM
15
+ }
16
+
17
+ export interface SuiStepExecutorOptions extends StepExecutorOptions {
18
+ wallet: WalletWithRequiredFeatures
19
+ }
20
+
21
+ export const SuiTokenShortAddress = '0x2::sui::SUI'
22
+ export const SuiTokenLongAddress =
23
+ '0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI'
@@ -27,9 +27,9 @@ export const checkBalance = async (
27
27
  // adjust amount in slippage limits
28
28
  step.action.fromAmount = currentBalance.toString()
29
29
  } else {
30
- const neeeded = formatUnits(neededBalance, token.decimals)
30
+ const needed = formatUnits(neededBalance, token.decimals)
31
31
  const current = formatUnits(currentBalance, token.decimals)
32
- let errorMessage = `Your ${token.symbol} balance is too low, you try to transfer ${neeeded} ${token.symbol}, but your wallet only holds ${current} ${token.symbol}. No funds have been sent.`
32
+ let errorMessage = `Your ${token.symbol} balance is too low, you try to transfer ${needed} ${token.symbol}, but your wallet only holds ${current} ${token.symbol}. No funds have been sent.`
33
33
 
34
34
  if (currentBalance !== 0n) {
35
35
  errorMessage += `If the problem consists, please delete this transfer and start a new one with a maximum of ${current} ${token.symbol}.`
package/src/core/rpc.ts CHANGED
@@ -9,7 +9,7 @@ export const getRpcUrl = async (chainId: ChainId): Promise<string> => {
9
9
  export const getRpcUrls = async (chainId: ChainId): Promise<string[]> => {
10
10
  const rpcUrls = (await config.getRPCUrls())[chainId]
11
11
  if (!rpcUrls?.length) {
12
- throw new Error('RPC URL not found')
12
+ throw new Error(`RPC URL not found for chainId: ${chainId}`)
13
13
  }
14
14
  return rpcUrls
15
15
  }
@@ -20,7 +20,7 @@ function createBaseConfig(options: SDKConfig) {
20
20
 
21
21
  export async function createChainsConfig() {
22
22
  config.loading = getChains({
23
- chainTypes: [ChainType.EVM, ChainType.SVM, ChainType.UTXO],
23
+ chainTypes: [ChainType.EVM, ChainType.SVM, ChainType.UTXO, ChainType.MVM],
24
24
  })
25
25
  .then((chains) => config.setChains(chains))
26
26
  .catch()
package/src/index.ts CHANGED
@@ -15,10 +15,7 @@ export { isEVM } from './core/EVM/types.js'
15
15
  export { isBatchingSupported } from './core/EVM/isBatchingSupported.js'
16
16
  export { isExtendedChain, convertExtendedChain } from './core/EVM/utils.js'
17
17
  export { isRelayerStep, isGaslessStep } from './core/EVM/typeguards.js'
18
- export type {
19
- EVMProvider,
20
- EVMProviderOptions,
21
- } from './core/EVM/types.js'
18
+ export type { EVMProvider, EVMProviderOptions } from './core/EVM/types.js'
22
19
  export { StatusManager } from './core/StatusManager.js'
23
20
  export {
24
21
  executeRoute,
@@ -96,11 +93,7 @@ export {
96
93
  export { getNameServiceAddress } from './services/getNameServiceAddress.js'
97
94
  export type { RPCUrls, SDKBaseConfig, SDKConfig } from './types/internal.js'
98
95
  export { BaseError } from './errors/baseError.js'
99
- export {
100
- ErrorMessage,
101
- ErrorName,
102
- LiFiErrorCode,
103
- } from './errors/constants.js'
96
+ export { ErrorMessage, ErrorName, LiFiErrorCode } from './errors/constants.js'
104
97
  export type { ErrorCode } from './errors/constants.js'
105
98
  export {
106
99
  BalanceError,
@@ -113,3 +106,6 @@ export {
113
106
  } from './errors/errors.js'
114
107
  export { HTTPError } from './errors/httpError.js'
115
108
  export { SDKError } from './errors/SDKError.js'
109
+ export { Sui } from './core/Sui/Sui.js'
110
+ export { isSui } from './core/Sui/types.js'
111
+ export type { SuiProvider, SuiProviderOptions } from './core/Sui/types.js'
@@ -1,4 +1,4 @@
1
- import { ChainType, type Token, type TokenAmount } from '@lifi/types'
1
+ import type { Token, TokenAmount } from '@lifi/types'
2
2
  import { config } from '../config.js'
3
3
  import { ValidationError } from '../errors/errors.js'
4
4
  import { isToken } from '../typeguards.js'
@@ -74,14 +74,9 @@ export const getTokenBalancesByChain = async (
74
74
  Object.keys(tokensByChain).map(async (chainIdStr) => {
75
75
  const chainId = Number.parseInt(chainIdStr)
76
76
  const chain = await config.getChainById(chainId)
77
- const tokenAddress = tokensByChain[chainId][0].address
78
77
  const provider = config
79
78
  .get()
80
- .providers.find((provider) =>
81
- chain.chainType === ChainType.UTXO
82
- ? provider.isAddress(walletAddress)
83
- : provider.isAddress(tokenAddress)
84
- )
79
+ .providers.find((provider) => provider.isAddress(walletAddress))
85
80
  if (!provider) {
86
81
  throw new Error(
87
82
  `SDK Token Provider for ${chain.chainType} is not found.`
package/src/version.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  export const name = '@lifi/sdk'
2
- export const version = '3.7.0-beta.2'
2
+ export const version = '3.7.0-beta.3'