@exodus/solana-lib 1.8.0 → 1.8.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@exodus/solana-lib",
3
- "version": "1.8.0",
3
+ "version": "1.8.2",
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": "dc0ae33970f29ed4ac1d66ea4211f6da10202d14"
38
+ "gitHead": "4c01d2640992ed8487c6a018844a96ba1990095e"
39
39
  }
@@ -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,23 @@
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
+ const feeAmountNU = asset.currency.baseUnit(feeAmount || 0)
11
+ if (feeAmountNU.gt(feeData.fee)) {
12
+ const ratio = feeAmountNU.sub(feeData.fee).toBaseNumber()
13
+ if (ratio > 1_000_000) throw new Error('Prioritization fee is too high')
14
+
15
+ const priorityFeeInstruction = ComputeBudgetProgram.setComputeUnitPrice({
16
+ microLamports: ratio || 100,
17
+ }) // 1 microLamport = 0.000001 lamports
18
+ transaction.add(priorityFeeInstruction)
19
+ }
20
+ }
6
21
 
7
22
  /**
8
23
  * Prepares the transaction to be signed (exodus & ledger).
@@ -21,7 +36,7 @@ export function prepareForSigning(unsignedTx) {
21
36
  const txData = { ...unsignedTx.txData, address, amount, fee }
22
37
 
23
38
  const transaction = createTx({ txData, method })
24
-
39
+ addPriorityFeeToTransaction({ transaction, feeAmount })
25
40
  if (!transaction.feePayer) {
26
41
  transaction.feePayer = new PublicKey(from)
27
42
  }