@exodus/solana-api 2.5.28 → 2.5.29

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": "2.5.28",
3
+ "version": "2.5.29",
4
4
  "description": "Exodus internal Solana asset API wrapper",
5
5
  "main": "src/index.js",
6
6
  "files": [
@@ -34,5 +34,5 @@
34
34
  "devDependencies": {
35
35
  "@exodus/assets-testing": "file:../../../__testing__"
36
36
  },
37
- "gitHead": "e46dbfdf19c725e5e7d4aa98a9e0eac913c44ed2"
37
+ "gitHead": "7ec211abf9ccbc6b8bc84440f3bc6da659aebaaf"
38
38
  }
package/src/api.js CHANGED
@@ -22,8 +22,9 @@ import { Connection } from './connection'
22
22
 
23
23
  // Doc: https://docs.solana.com/apps/jsonrpc-api
24
24
 
25
- const RPC_URL = 'https://solana.a.exodus.io' // https://vip-api.mainnet-beta.solana.com/, https://api.mainnet-beta.solana.com, https://solana-api.projectserum.com
26
- const WS_ENDPOINT = 'wss://solana.a.exodus.io/ws'
25
+ const RPC_URL = 'https://solana.a.exodus.io' // https://vip-api.mainnet-beta.solana.com/, https://api.mainnet-beta.solana.com
26
+ const WS_ENDPOINT = 'wss://solana.a.exodus.io/ws' // not standard across all node providers (we're compatible only with Quicknode)
27
+ const FORCE_HTTP = true // use https over ws
27
28
 
28
29
  // Tokens + SOL api support
29
30
  export class Api {
@@ -63,6 +64,7 @@ export class Api {
63
64
  handleReconnect,
64
65
  reconnectDelay,
65
66
  }) {
67
+ if (FORCE_HTTP) return false
66
68
  const conn = new Connection({
67
69
  endpoint: this.wsUrl,
68
70
  address,
@@ -89,7 +91,7 @@ export class Api {
89
91
  if (handleTransfers) return handleTransfers(updates)
90
92
  }
91
93
 
92
- async rpcCall(method, params = [], { address = '', forceHttp = false } = {}) {
94
+ async rpcCall(method, params = [], { address = '', forceHttp = FORCE_HTTP } = {}) {
93
95
  // ws request
94
96
  const connection = this.connections[address] || lodash.sample(Object.values(this.connections)) // pick random connection
95
97
  if (lodash.get(connection, 'isOpen') && !lodash.get(connection, 'shutdown') && !forceHttp) {
@@ -119,7 +121,7 @@ export class Api {
119
121
 
120
122
  async getRecentBlockHash(commitment?) {
121
123
  const result = await this.rpcCall(
122
- 'getRecentBlockhash',
124
+ 'getLatestBlockhash',
123
125
  [{ commitment: commitment || 'finalized', encoding: 'jsonParsed' }],
124
126
  { forceHttp: true }
125
127
  )
@@ -802,7 +804,7 @@ export class Api {
802
804
  */
803
805
  broadcastTransaction = async (signedTx, options) => {
804
806
  console.log('Solana broadcasting TX:', signedTx) // base64
805
- const defaultOptions = { encoding: 'base64', preflightCommitment: 'finalized' }
807
+ const defaultOptions = { encoding: 'base64', preflightCommitment: 'confirmed' }
806
808
 
807
809
  const params = [signedTx, { ...defaultOptions, ...options }]
808
810
  const errorMessagesToRetry = ['Blockhash not found']
package/src/index.js CHANGED
@@ -9,6 +9,12 @@ export { default as SolanaFeeMonitor } from './fee-monitor'
9
9
  export { SolanaMonitor } from './tx-log'
10
10
  export { SolanaAccountState } from './account-state'
11
11
  export { getSolStakedFee, getStakingInfo, getUnstakingFee } from './staking-utils'
12
+ export {
13
+ isSolanaStaking,
14
+ isSolanaUnstaking,
15
+ isSolanaWithdrawn,
16
+ isSolanaRewardsActivityTx,
17
+ } from './txs-utils'
12
18
  export { createAndBroadcastTXFactory } from './tx-send'
13
19
  export { getBalancesFactory } from './get-balances'
14
20
 
@@ -0,0 +1,11 @@
1
+ import { get } from 'lodash'
2
+
3
+ const isSolanaTx = (tx) => tx.coinName === 'solana'
4
+ export const isSolanaStaking = (tx) =>
5
+ isSolanaTx(tx) && ['createAccountWithSeed', 'delegate'].includes(get(tx, 'data.staking.method'))
6
+ export const isSolanaUnstaking = (tx) =>
7
+ isSolanaTx(tx) && get(tx, 'data.staking.method') === 'undelegate'
8
+ export const isSolanaWithdrawn = (tx) =>
9
+ isSolanaTx(tx) && get(tx, 'data.staking.method') === 'withdraw'
10
+ export const isSolanaRewardsActivityTx = (tx) =>
11
+ [isSolanaStaking, isSolanaUnstaking, isSolanaWithdrawn].some((fn) => fn(tx))