@exodus/solana-api 3.2.0 → 3.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-api",
3
- "version": "3.2.0",
3
+ "version": "3.3.0",
4
4
  "description": "Exodus internal Solana asset API wrapper",
5
5
  "main": "src/index.js",
6
6
  "files": [
@@ -29,7 +29,7 @@
29
29
  "@exodus/models": "^10.1.0",
30
30
  "@exodus/nfts-core": "^0.5.0",
31
31
  "@exodus/simple-retry": "^0.0.6",
32
- "@exodus/solana-lib": "^2.1.0",
32
+ "@exodus/solana-lib": "^2.3.0",
33
33
  "@exodus/solana-meta": "^1.0.7",
34
34
  "bn.js": "^4.11.0",
35
35
  "debug": "^4.1.1",
@@ -44,5 +44,5 @@
44
44
  "devDependencies": {
45
45
  "@exodus/assets-testing": "^1.0.0"
46
46
  },
47
- "gitHead": "12ce714047305f7ac06cec7608a59c90aa25c34d"
47
+ "gitHead": "5be11b271fd14c54f4fe8dd04b146361100e2a4d"
48
48
  }
package/src/api.js CHANGED
@@ -148,6 +148,12 @@ export class Api {
148
148
  return lodash.get(result, 'value.feeCalculator.lamportsPerSignature')
149
149
  }
150
150
 
151
+ async getPriorityFee(transaction) {
152
+ // https://docs.helius.dev/solana-rpc-nodes/alpha-priority-fee-api
153
+ const result = await this.rpcCall('getPriorityFeeEstimate', [{ transaction }])
154
+ return result.priorityFeeEstimate
155
+ }
156
+
151
157
  async getBalance(address) {
152
158
  const result = await this.rpcCall('getBalance', [address, { encoding: 'jsonParsed' }], {
153
159
  address,
package/src/tx-send.js CHANGED
@@ -1,9 +1,11 @@
1
1
  import {
2
2
  createUnsignedTx,
3
3
  findAssociatedTokenAddress,
4
+ prepareForSigning,
4
5
  TOKEN_PROGRAM_ID,
5
6
  TOKEN_2022_PROGRAM_ID,
6
7
  } from '@exodus/solana-lib'
8
+ import { transactionToBase58 } from '@exodus/solana-lib/src/tx/common'
7
9
  import assert from 'minimalistic-assert'
8
10
 
9
11
  export const createAndBroadcastTXFactory =
@@ -137,6 +139,20 @@ export const createAndBroadcastTXFactory =
137
139
  ...magicEdenParams,
138
140
  })
139
141
 
142
+ let { priorityFee } = feeData
143
+
144
+ if (!priorityFee) {
145
+ try {
146
+ const transactionForFeeEstimation = prepareForSigning(unsignedTransaction)
147
+ priorityFee = await api.getPriorityFee(transactionToBase58(transactionForFeeEstimation))
148
+ } catch (e) {
149
+ console.warn(`Failed to fetch priority fee: ${e.message}`)
150
+ priorityFee = feeData.fallbackPriorityFee
151
+ }
152
+ }
153
+
154
+ unsignedTransaction.txData.priorityFee = priorityFee
155
+
140
156
  const { txId, rawTx } = await assetClientInterface.signTransaction({
141
157
  assetName: baseAsset.name,
142
158
  unsignedTx: unsignedTransaction,