@exodus/solana-lib 1.8.0 → 1.8.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/package.json +2 -2
- package/src/transaction.js +0 -13
- package/src/tx/prepare-for-signing.js +16 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@exodus/solana-lib",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.1",
|
|
4
4
|
"description": "Exodus internal Solana low-level library",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"files": [
|
|
@@ -35,5 +35,5 @@
|
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@solana/web3.js": "^1.90.0"
|
|
37
37
|
},
|
|
38
|
-
"gitHead": "
|
|
38
|
+
"gitHead": "4a4e5e5ea8765b595cb83acd293305bb28b2a103"
|
|
39
39
|
}
|
package/src/transaction.js
CHANGED
|
@@ -2,7 +2,6 @@ import assert from 'assert'
|
|
|
2
2
|
import BN from 'bn.js'
|
|
3
3
|
import bs58 from 'bs58'
|
|
4
4
|
import { get } from 'lodash'
|
|
5
|
-
import feeData from './fee-data/solana'
|
|
6
5
|
|
|
7
6
|
import { getKeyPairFromPrivateKey } from './keypair'
|
|
8
7
|
import { findAssociatedTokenAddress, createStakeAddress } from './encode'
|
|
@@ -21,7 +20,6 @@ import {
|
|
|
21
20
|
Authorized,
|
|
22
21
|
Lockup,
|
|
23
22
|
TransactionInstruction,
|
|
24
|
-
ComputeBudgetProgram,
|
|
25
23
|
} from './vendor'
|
|
26
24
|
import { MagicEdenEscrowProgram } from './magiceden/escrow-program'
|
|
27
25
|
import { MEMO_PROGRAM_ID, SEED, STAKE_PROGRAM_ID } from './constants'
|
|
@@ -98,17 +96,6 @@ class Tx {
|
|
|
98
96
|
})
|
|
99
97
|
)
|
|
100
98
|
}
|
|
101
|
-
|
|
102
|
-
// if fee greater than base fee. Add prioritization fee:
|
|
103
|
-
if (fee > feeData.fee.toBaseNumber()) {
|
|
104
|
-
const ratio = fee - feeData.fee.toBaseNumber()
|
|
105
|
-
if (ratio > 1_000_000) throw new Error('Prioritization fee is too high')
|
|
106
|
-
|
|
107
|
-
const priorityFeeInstruction = ComputeBudgetProgram.setComputeUnitPrice({
|
|
108
|
-
microLamports: ratio || 100,
|
|
109
|
-
}) // 1 microLamport = 0.000001 lamports
|
|
110
|
-
this.transaction.add(priorityFeeInstruction)
|
|
111
|
-
}
|
|
112
99
|
}
|
|
113
100
|
|
|
114
101
|
buildSOLtransaction({ from, to, amount, recentBlockhash, feePayer, reference }) {
|
|
@@ -1,8 +1,22 @@
|
|
|
1
1
|
import { asset } from '@exodus/solana-meta'
|
|
2
2
|
|
|
3
|
-
import { PublicKey } from '../vendor'
|
|
3
|
+
import { ComputeBudgetProgram, PublicKey } from '../vendor'
|
|
4
4
|
import Transaction from '../transaction'
|
|
5
5
|
import { createMetaplexTransferTransaction } from '../helpers/metaplex-transfer'
|
|
6
|
+
import feeData from '../fee-data/solana'
|
|
7
|
+
|
|
8
|
+
const addPriorityFeeToTransaction = ({ transaction, feeAmount }) => {
|
|
9
|
+
// if fee greater than base fee. Add prioritization fee:
|
|
10
|
+
if (feeAmount > feeData.fee.toBaseNumber()) {
|
|
11
|
+
const ratio = feeAmount - feeData.fee.toBaseNumber()
|
|
12
|
+
if (ratio > 1_000_000) throw new Error('Prioritization fee is too high')
|
|
13
|
+
|
|
14
|
+
const priorityFeeInstruction = ComputeBudgetProgram.setComputeUnitPrice({
|
|
15
|
+
microLamports: ratio || 100,
|
|
16
|
+
}) // 1 microLamport = 0.000001 lamports
|
|
17
|
+
transaction.add(priorityFeeInstruction)
|
|
18
|
+
}
|
|
19
|
+
}
|
|
6
20
|
|
|
7
21
|
/**
|
|
8
22
|
* Prepares the transaction to be signed (exodus & ledger).
|
|
@@ -21,7 +35,7 @@ export function prepareForSigning(unsignedTx) {
|
|
|
21
35
|
const txData = { ...unsignedTx.txData, address, amount, fee }
|
|
22
36
|
|
|
23
37
|
const transaction = createTx({ txData, method })
|
|
24
|
-
|
|
38
|
+
addPriorityFeeToTransaction({ transaction, feeAmount })
|
|
25
39
|
if (!transaction.feePayer) {
|
|
26
40
|
transaction.feePayer = new PublicKey(from)
|
|
27
41
|
}
|