@exodus/solana-api 2.5.18 → 2.5.19
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 +2 -2
- package/src/api.js +1 -1
- package/src/connection.js +21 -16
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@exodus/solana-api",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.19",
|
|
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": "
|
|
37
|
+
"gitHead": "90e76fd28a32060fd779a487dab6bbaf4d19208f"
|
|
38
38
|
}
|
package/src/api.js
CHANGED
|
@@ -189,7 +189,7 @@ export class Api {
|
|
|
189
189
|
// get txs details in parallel
|
|
190
190
|
const txsDetails = await Promise.all(txsId.map((tx) => this.getTransactionById(tx.signature)))
|
|
191
191
|
txsDetails.forEach((txDetail) => {
|
|
192
|
-
if (txDetail
|
|
192
|
+
if (!txDetail) return
|
|
193
193
|
|
|
194
194
|
const timestamp = txDetail.blockTime * 1000
|
|
195
195
|
const parsedTx = this.parseTransaction(address, txDetail, tokenAccountsByOwner, {
|
package/src/connection.js
CHANGED
|
@@ -3,6 +3,7 @@ import delay from 'delay'
|
|
|
3
3
|
import lodash from 'lodash'
|
|
4
4
|
import debugLogger from 'debug'
|
|
5
5
|
import { WebSocket } from '@exodus/fetch'
|
|
6
|
+
import makeConcurrent from 'make-concurrent'
|
|
6
7
|
|
|
7
8
|
// WS subscriptions: https://docs.solana.com/developing/clients/jsonrpc-api#subscription-websocket
|
|
8
9
|
|
|
@@ -37,6 +38,26 @@ export class Connection {
|
|
|
37
38
|
this.pingTimeout = null
|
|
38
39
|
this.reconnectTimeout = null
|
|
39
40
|
this.txCache = {}
|
|
41
|
+
|
|
42
|
+
this.sendMessage = makeConcurrent(
|
|
43
|
+
async (method, params = []) => {
|
|
44
|
+
return new Promise((resolve, reject) => {
|
|
45
|
+
if (this.isClosed || this.shutdown) return reject(new Error('connection not started'))
|
|
46
|
+
const id = Math.floor(Math.random() * 1e7) + 1
|
|
47
|
+
|
|
48
|
+
this.rpcQueue[id] = { resolve, reject }
|
|
49
|
+
this.rpcQueue[id].timeout = setTimeout(() => {
|
|
50
|
+
delete this.rpcQueue[id]
|
|
51
|
+
console.log(`solana ws: reply timeout (${method}) - ${JSON.stringify(params)} - ${id}`)
|
|
52
|
+
resolve(null)
|
|
53
|
+
}, TIMEOUT)
|
|
54
|
+
if (typeof this.rpcQueue[id].timeout.unref === 'function')
|
|
55
|
+
this.rpcQueue[id].timeout.unref()
|
|
56
|
+
this.ws.send(JSON.stringify({ jsonrpc: '2.0', method, params, id }))
|
|
57
|
+
})
|
|
58
|
+
},
|
|
59
|
+
{ concurrency: 15 }
|
|
60
|
+
)
|
|
40
61
|
}
|
|
41
62
|
|
|
42
63
|
newSocket(reqUrl) {
|
|
@@ -174,22 +195,6 @@ export class Connection {
|
|
|
174
195
|
}
|
|
175
196
|
}
|
|
176
197
|
|
|
177
|
-
async sendMessage(method, params = []) {
|
|
178
|
-
return new Promise((resolve, reject) => {
|
|
179
|
-
if (this.isClosed || this.shutdown) return reject(new Error('connection not started'))
|
|
180
|
-
const id = Math.floor(Math.random() * 1e7) + 1
|
|
181
|
-
|
|
182
|
-
this.rpcQueue[id] = { resolve, reject }
|
|
183
|
-
this.rpcQueue[id].timeout = setTimeout(() => {
|
|
184
|
-
delete this.rpcQueue[id]
|
|
185
|
-
debug(`ws timeout command: ${method} - ${JSON.stringify(params)} - ${id}`)
|
|
186
|
-
reject(new Error('solana ws: reply timeout'))
|
|
187
|
-
}, TIMEOUT)
|
|
188
|
-
if (typeof this.rpcQueue[id].timeout.unref === 'function') this.rpcQueue[id].timeout.unref()
|
|
189
|
-
this.ws.send(JSON.stringify({ jsonrpc: '2.0', method, params, id }))
|
|
190
|
-
})
|
|
191
|
-
}
|
|
192
|
-
|
|
193
198
|
async processMessages() {
|
|
194
199
|
if (this.inProcessMessages) return null
|
|
195
200
|
this.inProcessMessages = true
|