@exodus/solana-api 1.0.1 → 1.0.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 +2 -2
- package/src/index.js +17 -9
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@exodus/solana-api",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "Exodus internal Solana asset API wrapper",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"files": [
|
|
@@ -20,5 +20,5 @@
|
|
|
20
20
|
"devDependencies": {
|
|
21
21
|
"node-fetch": "~1.6.3"
|
|
22
22
|
},
|
|
23
|
-
"gitHead": "
|
|
23
|
+
"gitHead": "946e63be238d27a4e69b657c9979788e04bccea0"
|
|
24
24
|
}
|
package/src/index.js
CHANGED
|
@@ -34,7 +34,8 @@ class Api {
|
|
|
34
34
|
return result.value.blockhash
|
|
35
35
|
} catch (err) {
|
|
36
36
|
console.log(err)
|
|
37
|
-
|
|
37
|
+
if (err.response) err = new Error(JSON.stringify(await concatStream(err.response)))
|
|
38
|
+
throw err
|
|
38
39
|
}
|
|
39
40
|
}
|
|
40
41
|
|
|
@@ -51,7 +52,8 @@ class Api {
|
|
|
51
52
|
return result
|
|
52
53
|
} catch (err) {
|
|
53
54
|
console.log(err)
|
|
54
|
-
|
|
55
|
+
if (err.response) err = new Error(JSON.stringify(await concatStream(err.response)))
|
|
56
|
+
throw err
|
|
55
57
|
}
|
|
56
58
|
}
|
|
57
59
|
|
|
@@ -66,7 +68,8 @@ class Api {
|
|
|
66
68
|
if (error) throw new Error(error.message)
|
|
67
69
|
return result.value.feeCalculator.lamportsPerSignature
|
|
68
70
|
} catch (err) {
|
|
69
|
-
|
|
71
|
+
if (err.response) err = new Error(JSON.stringify(await concatStream(err.response)))
|
|
72
|
+
throw err
|
|
70
73
|
}
|
|
71
74
|
}
|
|
72
75
|
|
|
@@ -82,7 +85,8 @@ class Api {
|
|
|
82
85
|
return result.value || 0
|
|
83
86
|
} catch (err) {
|
|
84
87
|
console.log(err)
|
|
85
|
-
|
|
88
|
+
if (err.response) err = new Error(JSON.stringify(await concatStream(err.response)))
|
|
89
|
+
throw err
|
|
86
90
|
}
|
|
87
91
|
}
|
|
88
92
|
|
|
@@ -99,7 +103,8 @@ class Api {
|
|
|
99
103
|
return result
|
|
100
104
|
} catch (err) {
|
|
101
105
|
console.log(err)
|
|
102
|
-
|
|
106
|
+
if (err.response) err = new Error(JSON.stringify(await concatStream(err.response)))
|
|
107
|
+
throw err
|
|
103
108
|
}
|
|
104
109
|
}
|
|
105
110
|
|
|
@@ -116,7 +121,8 @@ class Api {
|
|
|
116
121
|
return result
|
|
117
122
|
} catch (err) {
|
|
118
123
|
console.log(err)
|
|
119
|
-
|
|
124
|
+
if (err.response) err = new Error(JSON.stringify(await concatStream(err.response)))
|
|
125
|
+
throw err
|
|
120
126
|
}
|
|
121
127
|
}
|
|
122
128
|
|
|
@@ -137,11 +143,13 @@ class Api {
|
|
|
137
143
|
|
|
138
144
|
for (let tx of txsId) {
|
|
139
145
|
// get tx details
|
|
140
|
-
const txDetails = await
|
|
146
|
+
const [txDetails, blockTime] = await Promise.all([
|
|
147
|
+
this.getTransactionById(tx.signature),
|
|
148
|
+
this.getBlockTime(tx.slot),
|
|
149
|
+
])
|
|
141
150
|
if (txDetails === null) continue
|
|
142
151
|
|
|
143
|
-
const timestamp =
|
|
144
|
-
|
|
152
|
+
const timestamp = blockTime * 1000
|
|
145
153
|
const from = txDetails.transaction.message.accountKeys[0]
|
|
146
154
|
const to = txDetails.transaction.message.accountKeys[1]
|
|
147
155
|
let { preBalances, postBalances, fee } = txDetails.meta
|