@cityofzion/bs-ethereum 2.2.4 → 2.2.5
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.
|
@@ -51,6 +51,9 @@ class BlockscoutNeoXBDSEthereum extends RpcBDSEthereum_1.RpcBDSEthereum {
|
|
|
51
51
|
}
|
|
52
52
|
const client = BlockscoutNeoXBDSEthereum.getClient(this._network);
|
|
53
53
|
const { data } = yield client.get(`/transactions/${txid}`);
|
|
54
|
+
if (!data || 'message' in data) {
|
|
55
|
+
throw new Error('Transaction not found');
|
|
56
|
+
}
|
|
54
57
|
const nativeToken = BSEthereumHelper_1.BSEthereumHelper.getNativeAsset(this._network);
|
|
55
58
|
const transfers = __classPrivateFieldGet(this, _BlockscoutNeoXBDSEthereum_instances, "m", _BlockscoutNeoXBDSEthereum_parseTransfers).call(this, data, nativeToken);
|
|
56
59
|
return {
|
|
@@ -77,6 +80,9 @@ class BlockscoutNeoXBDSEthereum extends RpcBDSEthereum_1.RpcBDSEthereum {
|
|
|
77
80
|
next_page_params: params.nextPageParams,
|
|
78
81
|
},
|
|
79
82
|
});
|
|
83
|
+
if (!data || 'message' in data) {
|
|
84
|
+
throw new Error('Transactions not found');
|
|
85
|
+
}
|
|
80
86
|
const nativeToken = BSEthereumHelper_1.BSEthereumHelper.getNativeAsset(this._network);
|
|
81
87
|
const transactions = [];
|
|
82
88
|
data.items.forEach(item => {
|
|
@@ -107,6 +113,9 @@ class BlockscoutNeoXBDSEthereum extends RpcBDSEthereum_1.RpcBDSEthereum {
|
|
|
107
113
|
try {
|
|
108
114
|
const client = BlockscoutNeoXBDSEthereum.getClient(this._network);
|
|
109
115
|
const { data } = yield client.get(`/smart-contracts/${contractHash}`);
|
|
116
|
+
if (!data || 'message' in data) {
|
|
117
|
+
throw new Error('Contract not found');
|
|
118
|
+
}
|
|
110
119
|
const methods = [];
|
|
111
120
|
data.abi.forEach(abi => {
|
|
112
121
|
var _a, _b;
|
|
@@ -149,6 +158,9 @@ class BlockscoutNeoXBDSEthereum extends RpcBDSEthereum_1.RpcBDSEthereum {
|
|
|
149
158
|
}
|
|
150
159
|
const client = BlockscoutNeoXBDSEthereum.getClient(this._network);
|
|
151
160
|
const { data } = yield client.get(`/tokens/${tokenHash}`);
|
|
161
|
+
if (!data || 'message' in data) {
|
|
162
|
+
throw new Error('Token not found');
|
|
163
|
+
}
|
|
152
164
|
return {
|
|
153
165
|
decimals: parseInt(data.decimals),
|
|
154
166
|
hash: tokenHash,
|
|
@@ -167,6 +179,9 @@ class BlockscoutNeoXBDSEthereum extends RpcBDSEthereum_1.RpcBDSEthereum {
|
|
|
167
179
|
}
|
|
168
180
|
const client = BlockscoutNeoXBDSEthereum.getClient(this._network);
|
|
169
181
|
const { data: nativeBalance } = yield client.get(`/addresses/${address}`);
|
|
182
|
+
if (!nativeBalance || 'message' in nativeBalance) {
|
|
183
|
+
throw new Error('Native balance not found');
|
|
184
|
+
}
|
|
170
185
|
const balances = [
|
|
171
186
|
{
|
|
172
187
|
amount: ethers_1.ethers.utils.formatUnits(nativeBalance.coin_balance, 18),
|
|
@@ -174,6 +189,9 @@ class BlockscoutNeoXBDSEthereum extends RpcBDSEthereum_1.RpcBDSEthereum {
|
|
|
174
189
|
},
|
|
175
190
|
];
|
|
176
191
|
const { data: erc20Balances } = yield client.get(`/addresses/${address}/token-balances`);
|
|
192
|
+
if (!erc20Balances || 'message' in erc20Balances) {
|
|
193
|
+
throw new Error('ERC20 balance not found');
|
|
194
|
+
}
|
|
177
195
|
erc20Balances.forEach(balance => {
|
|
178
196
|
const token = {
|
|
179
197
|
decimals: parseInt(balance.token.decimals),
|
|
@@ -199,6 +217,9 @@ class BlockscoutNeoXBDSEthereum extends RpcBDSEthereum_1.RpcBDSEthereum {
|
|
|
199
217
|
}
|
|
200
218
|
const client = BlockscoutNeoXBDSEthereum.getClient(this._network);
|
|
201
219
|
const { data } = yield client.get('/blocks');
|
|
220
|
+
if (!data || 'message' in data) {
|
|
221
|
+
throw new Error('Block not found');
|
|
222
|
+
}
|
|
202
223
|
return data.items[0].height;
|
|
203
224
|
});
|
|
204
225
|
}
|
|
@@ -231,7 +252,7 @@ _BlockscoutNeoXBDSEthereum_instances = new WeakSet(), _BlockscoutNeoXBDSEthereum
|
|
|
231
252
|
symbol: tokenTransfer.token.symbol,
|
|
232
253
|
name: tokenTransfer.token.name,
|
|
233
254
|
hash: tokenTransfer.token.address,
|
|
234
|
-
decimals: tokenTransfer.total.decimals,
|
|
255
|
+
decimals: Number(tokenTransfer.total.decimals),
|
|
235
256
|
},
|
|
236
257
|
});
|
|
237
258
|
continue;
|