@exodus/solana-lib 2.2.0 → 2.3.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@exodus/solana-lib",
3
- "version": "2.2.0",
3
+ "version": "2.3.0",
4
4
  "description": "Exodus internal Solana low-level library",
5
5
  "main": "src/index.js",
6
6
  "files": [
@@ -39,5 +39,5 @@
39
39
  "@solana/web3.js": "^1.90.0",
40
40
  "bip39": "^2.6.0"
41
41
  },
42
- "gitHead": "85fd61e1f2f77aff4c32b5684eb5f4845f06794a"
42
+ "gitHead": "5be11b271fd14c54f4fe8dd04b146361100e2a4d"
43
43
  }
@@ -4,6 +4,8 @@ export const createFeeData = ({ asset }) =>
4
4
  new FeeData({
5
5
  config: {
6
6
  fee: `0.000005 ${asset.ticker}`,
7
+ priorityFee: 0,
8
+ fallbackPriorityFee: 100_000,
7
9
  fuelThreshold: `0.000015 ${asset.ticker}`,
8
10
  },
9
11
  mainKey: 'fee',
package/src/tx/common.js CHANGED
@@ -8,6 +8,10 @@ export function isLegacyTransaction(tx) {
8
8
  return !isVersionedTransaction(tx)
9
9
  }
10
10
 
11
+ export function transactionToBase58(tx) {
12
+ return base58.encode(tx.serialize())
13
+ }
14
+
11
15
  export function getTxId(tx) {
12
16
  const signature = getFirstSignature(tx)
13
17
  if (signature === null) {
package/src/tx/index.js CHANGED
@@ -6,4 +6,6 @@ export * from './simulate-and-sign-tx'
6
6
  export * from './decode-tx-instructions'
7
7
  export * from './build-raw-transaction'
8
8
  export * from './sign-hardware'
9
+ export * from './prepare-for-signing'
10
+ export { transactionToBase58 } from './common'
9
11
  export { default as signMessage } from './sign-message'
@@ -5,17 +5,11 @@ import { ComputeBudgetProgram, PublicKey } from '../vendor'
5
5
  import Transaction from '../transaction'
6
6
  import { createMetaplexTransferTransaction } from '../helpers/metaplex-transfer'
7
7
 
8
- const addPriorityFeeToTransaction = ({ transaction, feeAmount = 0, fixedFee = 0 }) => {
9
- // if fee greater than base fee. Add prioritization fee:
10
- if (feeAmount > fixedFee) {
11
- const ratio = feeAmount - fixedFee
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
- }
8
+ const addPriorityFeeToTransaction = ({ transaction, priorityFee }) => {
9
+ const priorityFeeInstruction = ComputeBudgetProgram.setComputeUnitPrice({
10
+ microLamports: priorityFee,
11
+ }) // 1 microLamport = 0.000001 lamports
12
+ transaction.add(priorityFeeInstruction)
19
13
  }
20
14
 
21
15
  /**
@@ -24,14 +18,7 @@ const addPriorityFeeToTransaction = ({ transaction, feeAmount = 0, fixedFee = 0
24
18
  * @returns a Solana Web3.js Transaction object
25
19
  */
26
20
  export function prepareForSigning(unsignedTx) {
27
- const {
28
- amount: unitAmount,
29
- fee: feeAmount,
30
- fixedFee,
31
- from,
32
- method,
33
- transaction,
34
- } = unsignedTx.txData
21
+ const { amount: unitAmount, fee: feeAmount, from, method, transaction } = unsignedTx.txData
35
22
 
36
23
  if (!transaction) {
37
24
  // Create a transaction in web3.js format
@@ -49,7 +36,12 @@ export function prepareForSigning(unsignedTx) {
49
36
 
50
37
  const transaction = createTx({ txData, method })
51
38
 
52
- addPriorityFeeToTransaction({ transaction, feeAmount, fixedFee })
39
+ if (txData.priorityFee) {
40
+ addPriorityFeeToTransaction({
41
+ transaction,
42
+ priorityFee: txData.priorityFee,
43
+ })
44
+ }
53
45
 
54
46
  if (!transaction.feePayer) {
55
47
  transaction.feePayer = new PublicKey(from)