@exodus/solana-api 2.2.0 → 2.2.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 +4 -3
- package/src/api.js +26 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@exodus/solana-api",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.2",
|
|
4
4
|
"description": "Exodus internal Solana asset API wrapper",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"files": [
|
|
@@ -20,7 +20,8 @@
|
|
|
20
20
|
"@exodus/fetch": "^1.2.0",
|
|
21
21
|
"@exodus/models": "^8.7.2",
|
|
22
22
|
"@exodus/nfts-core": "^0.5.0",
|
|
23
|
-
"@exodus/
|
|
23
|
+
"@exodus/simple-retry": "^0.0.6",
|
|
24
|
+
"@exodus/solana-lib": "^1.4.3",
|
|
24
25
|
"@exodus/solana-web3.js": "1.31.0-exodus.5",
|
|
25
26
|
"@ungap/url-search-params": "^0.2.2",
|
|
26
27
|
"bignumber.js": "^9.0.1",
|
|
@@ -34,5 +35,5 @@
|
|
|
34
35
|
"devDependencies": {
|
|
35
36
|
"node-fetch": "~2.6.0"
|
|
36
37
|
},
|
|
37
|
-
"gitHead": "
|
|
38
|
+
"gitHead": "78b7f5c6d314b393f038848ef5b5815d46b8dd35"
|
|
38
39
|
}
|
package/src/api.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// @flow
|
|
2
2
|
import BN from 'bn.js'
|
|
3
3
|
import createApi from '@exodus/asset-json-rpc'
|
|
4
|
+
import { retry } from '@exodus/simple-retry'
|
|
4
5
|
import {
|
|
5
6
|
getMetadataAccount,
|
|
6
7
|
deserializeMetaplexMetadata,
|
|
@@ -806,10 +807,32 @@ export class Api {
|
|
|
806
807
|
const defaultOptions = { encoding: 'base64', preflightCommitment: 'finalized' }
|
|
807
808
|
|
|
808
809
|
const params = [signedTx, { ...defaultOptions, ...options }]
|
|
809
|
-
const
|
|
810
|
+
const errorMessagesToRetry = ['Blockhash not found']
|
|
810
811
|
|
|
811
|
-
|
|
812
|
-
|
|
812
|
+
const broadcastTxWithRetry = retry(
|
|
813
|
+
async () => {
|
|
814
|
+
try {
|
|
815
|
+
const result = await this.rpcCall('sendTransaction', params, { forceHttp: true })
|
|
816
|
+
console.log(`tx ${JSON.stringify(result)} sent!`)
|
|
817
|
+
|
|
818
|
+
return result || null
|
|
819
|
+
} catch (error) {
|
|
820
|
+
if (
|
|
821
|
+
error.message &&
|
|
822
|
+
!errorMessagesToRetry.find((errorMessage) => error.message.includes(errorMessage))
|
|
823
|
+
) {
|
|
824
|
+
error.finalError = true
|
|
825
|
+
}
|
|
826
|
+
|
|
827
|
+
console.warn(`Error broadcasting tx. Retrying...`, error)
|
|
828
|
+
|
|
829
|
+
throw error
|
|
830
|
+
}
|
|
831
|
+
},
|
|
832
|
+
{ delayTimesMs: ['6s', '6s', '8s', '10s'] }
|
|
833
|
+
)
|
|
834
|
+
|
|
835
|
+
return broadcastTxWithRetry()
|
|
813
836
|
}
|
|
814
837
|
|
|
815
838
|
simulateTransaction = async (encodedTransaction, options) => {
|