@exodus/solana-lib 3.12.0 → 3.12.1

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,14 @@
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.12.1](https://github.com/ExodusMovement/assets/compare/@exodus/solana-lib@3.12.0...@exodus/solana-lib@3.12.1) (2025-09-29)
7
+
8
+ **Note:** Version bump only for package @exodus/solana-lib
9
+
10
+
11
+
12
+
13
+
6
14
  ## [3.12.0](https://github.com/ExodusMovement/assets/compare/@exodus/solana-lib@3.11.2...@exodus/solana-lib@3.12.0) (2025-09-25)
7
15
 
8
16
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@exodus/solana-lib",
3
- "version": "3.12.0",
3
+ "version": "3.12.1",
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",
@@ -46,5 +46,5 @@
46
46
  "type": "git",
47
47
  "url": "git+https://github.com/ExodusMovement/assets.git"
48
48
  },
49
- "gitHead": "50814bd63872e287b650e161010e77be15b7994e"
49
+ "gitHead": "bdbe86b58adda62d0ea7ef8cc8d4c633d3bd32be"
50
50
  }
@@ -71,7 +71,7 @@ export const createTokenTransferInstruction = (owner, fromTokenAddress, to, amou
71
71
  destinationPubkey,
72
72
  ownerAccountOrWalletPublicKey,
73
73
  [],
74
- amount
74
+ amount.toString()
75
75
  )
76
76
  }
77
77
 
@@ -30,7 +30,6 @@ class Tx {
30
30
  to,
31
31
  amount,
32
32
  recentBlockhash,
33
- fee, // (Fee per Signature: 5000 lamports)
34
33
  // Tokens related:
35
34
  // pass either name or mintAddress, if both, mintAddress has priority
36
35
  tokenMintAddress,
@@ -48,7 +47,7 @@ class Tx {
48
47
  assert(from, 'from is required')
49
48
  assert(to, 'to is required')
50
49
  assert(amount, 'amount is required')
51
- assert(typeof amount === 'number', 'amount must be a number')
50
+ assert(typeof amount === 'string', 'amount must be a string')
52
51
  }
53
52
 
54
53
  assert(recentBlockhash, 'recentBlockhash is required')
@@ -105,7 +104,7 @@ class Tx {
105
104
  const txInstruction = SystemProgram.transfer({
106
105
  fromPubkey: new PublicKey(from),
107
106
  toPubkey: new PublicKey(to),
108
- lamports: amount,
107
+ lamports: new BN(amount),
109
108
  })
110
109
 
111
110
  // If reference accounts are provided, add them to the transfer instruction
@@ -171,32 +170,25 @@ class Tx {
171
170
  this.transaction.add(createAssociatedTokenAccount(from, tokenMintAddress, to, tokenProgram))
172
171
  }
173
172
 
174
- let amountLeft = amount
173
+ let amountLeft = new BN(amount)
175
174
  let amountToSend
176
175
  let isNotEnoughBalance = false
177
- for (let {
178
- mintAddress,
179
- tokenAccountAddress,
180
- balance,
181
- decimals,
182
- feeBasisPoints,
183
- maximumFee,
184
- } of fromTokenAddresses) {
176
+ for (let { mintAddress, tokenAccountAddress, balance, decimals } of fromTokenAddresses) {
185
177
  // need to add more of this instruction until we reach the desired balance (amount) to send
186
178
  assert(mintAddress === tokenMintAddress, `Got unexpected mintAddress ${mintAddress}`)
187
179
 
188
180
  if (checkBalances) {
189
- if (amountLeft === 0) break
181
+ if (amountLeft.isZero()) break
190
182
 
191
- balance = Number(balance)
192
- if (balance >= amountLeft) {
183
+ balance = new BN(balance)
184
+ if (balance.gte(amountLeft)) {
193
185
  amountToSend = amountLeft
194
- amountLeft = 0
186
+ amountLeft = new BN(0)
195
187
  } else {
196
188
  // Not enough balance case.
197
189
  isNotEnoughBalance = true
198
190
  amountToSend = balance
199
- amountLeft -= amountToSend
191
+ amountLeft = amountLeft.sub(amountToSend)
200
192
  }
201
193
  } else {
202
194
  amountToSend = amountLeft
@@ -207,18 +199,13 @@ class Tx {
207
199
  : to
208
200
  let tokenTransferInstruction
209
201
  if (tokenProgram === TOKEN_2022_PROGRAM_ID.toBase58()) {
210
- // token transfer fee
211
- const fee = Math.ceil((amountToSend * feeBasisPoints) / 10_000)
212
- const feeCharged = fee > maximumFee ? maximumFee : fee
213
-
214
202
  tokenTransferInstruction = createTransferCheckedWithFeeInstruction(
215
203
  tokenAccountAddress,
216
204
  tokenMintAddress,
217
205
  dest,
218
206
  from,
219
207
  amountToSend,
220
- decimals, // token decimals
221
- feeCharged // token fee (not SOL fee)
208
+ decimals // token decimals
222
209
  )
223
210
  } else {
224
211
  tokenTransferInstruction = createTokenTransferInstruction(
@@ -264,7 +251,7 @@ class Tx {
264
251
  seed,
265
252
  authorized,
266
253
  lockup,
267
- lamports: amount, // number
254
+ lamports: new BN(amount),
268
255
  })
269
256
 
270
257
  // delegate funds instruction
@@ -41,9 +41,8 @@ export function createUnsignedTx({
41
41
  txData: {
42
42
  from,
43
43
  to,
44
- amount: amount ? amount.toBaseNumber() : null,
45
- fee: fee ? fee.toBaseNumber() : null,
46
- fixedFee: feeData ? feeData.fee.toBaseNumber() : null,
44
+ amount: amount ? amount.toBaseString() : null,
45
+ fee: fee ? fee.toBaseString() : null,
47
46
  recentBlockhash,
48
47
  // Tokens related:
49
48
  tokenMintAddress,
@@ -50,7 +50,7 @@ export function prepareForSigning(unsignedTx, { checkBalances = true } = {}) {
50
50
  const address = from
51
51
 
52
52
  const amount = unitAmount
53
- ? new BN(isNumberUnit(unitAmount) ? unitAmount.toBaseString() : unitAmount).toNumber()
53
+ ? new BN(isNumberUnit(unitAmount) ? unitAmount.toBaseString() : unitAmount).toString()
54
54
  : unitAmount
55
55
 
56
56
  const fee = feeAmount