@exodus/solana-lib 3.12.0 → 3.12.2
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,22 @@
|
|
|
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.2](https://github.com/ExodusMovement/assets/compare/@exodus/solana-lib@3.12.1...@exodus/solana-lib@3.12.2) (2025-09-29)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @exodus/solana-lib
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## [3.12.1](https://github.com/ExodusMovement/assets/compare/@exodus/solana-lib@3.12.0...@exodus/solana-lib@3.12.1) (2025-09-29)
|
|
15
|
+
|
|
16
|
+
**Note:** Version bump only for package @exodus/solana-lib
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
6
22
|
## [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
23
|
|
|
8
24
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@exodus/solana-lib",
|
|
3
|
-
"version": "3.12.
|
|
3
|
+
"version": "3.12.2",
|
|
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",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"@exodus/asset-lib": "^5.0.0",
|
|
24
24
|
"@exodus/buffer-layout": "^1.2.0-exodus1",
|
|
25
|
-
"@exodus/crypto": "^1.0.0-rc.
|
|
25
|
+
"@exodus/crypto": "^1.0.0-rc.26",
|
|
26
26
|
"@exodus/currency": "^6.0.1",
|
|
27
27
|
"@exodus/key-utils": "^3.7.0",
|
|
28
28
|
"@exodus/solana-web3.js": "^1.63.1-exodus.9-rc4",
|
|
@@ -46,5 +46,5 @@
|
|
|
46
46
|
"type": "git",
|
|
47
47
|
"url": "git+https://github.com/ExodusMovement/assets.git"
|
|
48
48
|
},
|
|
49
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "fbe5c357400fe730fccfad285d25083e874c1cce"
|
|
50
50
|
}
|
package/src/msg/sign-message.js
CHANGED
package/src/transaction.js
CHANGED
|
@@ -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 === '
|
|
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
|
|
181
|
+
if (amountLeft.isZero()) break
|
|
190
182
|
|
|
191
|
-
balance =
|
|
192
|
-
if (balance
|
|
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
|
|
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
|
|
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,
|
|
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.
|
|
45
|
-
fee: fee ? fee.
|
|
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).
|
|
53
|
+
? new BN(isNumberUnit(unitAmount) ? unitAmount.toBaseString() : unitAmount).toString()
|
|
54
54
|
: unitAmount
|
|
55
55
|
|
|
56
56
|
const fee = feeAmount
|