@exodus/solana-api 3.14.2 → 3.14.4

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/CHANGELOG.md CHANGED
@@ -3,6 +3,24 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [3.14.4](https://github.com/ExodusMovement/assets/compare/@exodus/solana-api@3.14.3...@exodus/solana-api@3.14.4) (2025-03-20)
7
+
8
+ **Note:** Version bump only for package @exodus/solana-api
9
+
10
+
11
+
12
+
13
+
14
+ ## [3.14.3](https://github.com/ExodusMovement/assets/compare/@exodus/solana-api@3.14.2...@exodus/solana-api@3.14.3) (2025-03-14)
15
+
16
+
17
+ ### Bug Fixes
18
+
19
+
20
+ * fix(SOL): set amount as lamports for internal multi send (#5253)
21
+
22
+
23
+
6
24
  ## [3.14.2](https://github.com/ExodusMovement/assets/compare/@exodus/solana-api@3.14.1...@exodus/solana-api@3.14.2) (2025-03-12)
7
25
 
8
26
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@exodus/solana-api",
3
- "version": "3.14.2",
3
+ "version": "3.14.4",
4
4
  "description": "Transaction monitors, fee monitors, RPC with the blockchain node, and other networking code for Solana",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
@@ -46,7 +46,7 @@
46
46
  "@exodus/assets-testing": "^1.0.0",
47
47
  "@exodus/solana-web3.js": "^1.63.1-exodus.9-rc3"
48
48
  },
49
- "gitHead": "8ceb21b35e59dd7c7d4db2035ccba873d889464a",
49
+ "gitHead": "ece04a00d01566ab21cd4b4af57501fb7e50d1af",
50
50
  "bugs": {
51
51
  "url": "https://github.com/ExodusMovement/assets/issues?q=is%3Aissue+is%3Aopen+label%3Asolana-api"
52
52
  },
package/src/api.js CHANGED
@@ -487,7 +487,7 @@ export class Api {
487
487
  sent: [
488
488
  {
489
489
  address: solanaTransferTx.to,
490
- amount: solanaTransferTx.amount,
490
+ amount: lamports,
491
491
  },
492
492
  ],
493
493
  }
@@ -495,7 +495,7 @@ export class Api {
495
495
  }
496
496
 
497
497
  solanaTransferTx.to.push(destination)
498
- solanaTransferTx.data.sent.push({ address: destination, amount })
498
+ solanaTransferTx.data.sent.push({ address: destination, amount: lamports })
499
499
  } else {
500
500
  solanaTransferTx = {
501
501
  source,
@@ -508,7 +508,7 @@ export class Api {
508
508
  sent: [
509
509
  {
510
510
  address: destination,
511
- amount,
511
+ amount: lamports,
512
512
  },
513
513
  ],
514
514
  },
@@ -841,25 +841,28 @@ export class Api {
841
841
  : tokenAccounts
842
842
  }
843
843
 
844
- async getTokensBalance({ address, filterByTokens = [], tokenAccounts }) {
845
- const accounts = tokenAccounts || (await this.getTokenAccountsByOwner(address))
844
+ async getTokensBalancesAndAccounts({ address, filterByTokens = [] }) {
845
+ const accounts = await this.getTokenAccountsByOwner(address)
846
846
 
847
- return accounts.reduce((acc, { tokenName, balance }) => {
848
- if (
849
- tokenName === 'unknown' ||
850
- (filterByTokens.length > 0 && !filterByTokens.includes(tokenName))
851
- )
852
- return acc // filter by supported tokens only
853
- if (acc[tokenName]) {
854
- acc[tokenName] += Number(balance)
855
- }
856
- // e.g { 'serum': 123 }
857
- else {
858
- acc[tokenName] = Number(balance)
859
- } // merge same token account balance
847
+ return {
848
+ balances: accounts.reduce((acc, { tokenName, balance }) => {
849
+ if (
850
+ tokenName === 'unknown' ||
851
+ (filterByTokens.length > 0 && !filterByTokens.includes(tokenName))
852
+ )
853
+ return acc // filter by supported tokens only
854
+ if (acc[tokenName]) {
855
+ acc[tokenName] += Number(balance)
856
+ }
857
+ // e.g { 'serum': 123 }
858
+ else {
859
+ acc[tokenName] = Number(balance)
860
+ } // merge same token account balance
860
861
 
861
- return acc
862
- }, {})
862
+ return acc
863
+ }, {}),
864
+ accounts,
865
+ }
863
866
  }
864
867
 
865
868
  async isAssociatedTokenAccountActive(tokenAddress) {
@@ -143,19 +143,6 @@ export class SolanaMonitor extends BaseMonitor {
143
143
  return true
144
144
  }
145
145
 
146
- async getAccountsAndBalances({ refresh, address, accountState, walletAccount }) {
147
- const tokenAccounts = await this.api.getTokenAccountsByOwner(address)
148
- const { account, staking } = await this.getAccount({
149
- refresh,
150
- address,
151
- tokenAccounts,
152
- accountState,
153
- walletAccount,
154
- })
155
-
156
- return { account, tokenAccounts, staking }
157
- }
158
-
159
146
  async tick({ walletAccount, refresh }) {
160
147
  // Check for new wallet account
161
148
  await this.initWalletAccount({ walletAccount })
@@ -300,21 +287,22 @@ export class SolanaMonitor extends BaseMonitor {
300
287
  }
301
288
  }
302
289
 
303
- async getAccount({ refresh, address, tokenAccounts, accountState, walletAccount }) {
290
+ async getAccountsAndBalances({ refresh, address, accountState, walletAccount }) {
304
291
  const tokens = Object.keys(this.assets).filter((name) => name !== this.asset.name)
305
- const accountInfo = await this.api.getAccountInfo(address).catch(() => {})
292
+ const [accountInfo, { balances: splBalances, accounts: tokenAccounts }] = await Promise.all([
293
+ this.api.getAccountInfo(address).catch(() => {}),
294
+ this.api.getTokensBalancesAndAccounts({
295
+ address,
296
+ filterByTokens: tokens,
297
+ }),
298
+ ])
299
+
306
300
  const accountSize = accountInfo?.space || 0
307
301
  const solBalance = accountInfo?.lamports || 0
308
302
 
309
303
  const rentExemptValue = await this.api.getMinimumBalanceForRentExemption(accountSize)
310
304
  const rentExemptAmount = this.asset.currency.baseUnit(rentExemptValue)
311
305
 
312
- const splBalances = await this.api.getTokensBalance({
313
- address,
314
- filterByTokens: tokens,
315
- tokenAccounts,
316
- })
317
-
318
306
  const tokenBalances = _.mapValues(splBalances, (balance, name) =>
319
307
  this.assets[name].currency.baseUnit(balance)
320
308
  )
@@ -352,6 +340,7 @@ export class SolanaMonitor extends BaseMonitor {
352
340
  rentExemptAmount,
353
341
  },
354
342
  staking,
343
+ tokenAccounts,
355
344
  }
356
345
  }
357
346