@exodus/solana-lib 3.8.0 → 3.9.0

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,16 @@
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.9.0](https://github.com/ExodusMovement/assets/compare/@exodus/solana-lib@3.8.0...@exodus/solana-lib@3.9.0) (2024-11-29)
7
+
8
+
9
+ ### Features
10
+
11
+
12
+ * feat: avoid checking a balance (#4597)
13
+
14
+
15
+
6
16
  ## [3.8.0](https://github.com/ExodusMovement/assets/compare/@exodus/solana-lib@3.7.1...@exodus/solana-lib@3.8.0) (2024-11-29)
7
17
 
8
18
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@exodus/solana-lib",
3
- "version": "3.8.0",
3
+ "version": "3.9.0",
4
4
  "description": "Solana utils, such as for cryptography, address encoding/decoding, transaction building, etc.",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
@@ -45,5 +45,5 @@
45
45
  "type": "git",
46
46
  "url": "git+https://github.com/ExodusMovement/assets.git"
47
47
  },
48
- "gitHead": "a12da3edd237eb63aa06b726374094d63f29612a"
48
+ "gitHead": "a5ab26da60a57ffb982a7001843af9cf06f899f8"
49
49
  }
@@ -183,17 +183,22 @@ class Tx {
183
183
  } of fromTokenAddresses) {
184
184
  // need to add more of this instruction until we reach the desired balance (amount) to send
185
185
  assert(mintAddress === tokenMintAddress, `Got unexpected mintAddress ${mintAddress}`)
186
- if (amountLeft === 0) break
187
186
 
188
- balance = Number(balance)
189
- if (balance >= amountLeft) {
190
- amountToSend = amountLeft
191
- amountLeft = 0
187
+ if (checkBalances) {
188
+ if (amountLeft === 0) break
189
+
190
+ balance = Number(balance)
191
+ if (balance >= amountLeft) {
192
+ amountToSend = amountLeft
193
+ amountLeft = 0
194
+ } else {
195
+ // Not enough balance case.
196
+ isNotEnoughBalance = true
197
+ amountToSend = balance
198
+ amountLeft -= amountToSend
199
+ }
192
200
  } else {
193
- // Not enough balance case.
194
- isNotEnoughBalance = true
195
- amountToSend = balance
196
- amountLeft -= amountToSend
201
+ amountToSend = amountLeft
197
202
  }
198
203
 
199
204
  const dest = isSOLaddress
@@ -238,12 +243,7 @@ class Tx {
238
243
  this.transaction.add(tokenTransferInstruction)
239
244
  }
240
245
 
241
- if (checkBalances) {
242
- assert(
243
- isNotEnoughBalance === false,
244
- `Not enough balance to send ${amount} ${tokenMintAddress}`
245
- )
246
- }
246
+ assert(isNotEnoughBalance === false, `Not enough balance to send ${amount} ${tokenMintAddress}`)
247
247
  }
248
248
 
249
249
  static createStakeAccountTransaction({ address, amount, seed = SEED, pool, recentBlockhash }) {