@exodus/solana-api 2.1.3 → 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 +29 -5
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@exodus/solana-api",
|
|
3
|
-
"version": "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,
|
|
@@ -801,14 +802,37 @@ export class Api {
|
|
|
801
802
|
/**
|
|
802
803
|
* Broadcast a signed transaction
|
|
803
804
|
*/
|
|
804
|
-
broadcastTransaction = async (signedTx: string): string => {
|
|
805
|
+
broadcastTransaction = async (signedTx: string, options): string => {
|
|
805
806
|
console.log('Solana broadcasting TX:', signedTx) // base64
|
|
807
|
+
const defaultOptions = { encoding: 'base64', preflightCommitment: 'finalized' }
|
|
806
808
|
|
|
807
|
-
const params = [signedTx, {
|
|
808
|
-
const
|
|
809
|
+
const params = [signedTx, { ...defaultOptions, ...options }]
|
|
810
|
+
const errorMessagesToRetry = ['Blockhash not found']
|
|
809
811
|
|
|
810
|
-
|
|
811
|
-
|
|
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()
|
|
812
836
|
}
|
|
813
837
|
|
|
814
838
|
simulateTransaction = async (encodedTransaction, options) => {
|