@dashevo/dapi-client 0.23.0-dev.6 → 0.23.0-dev.9
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.
|
@@ -26,7 +26,7 @@ class ListDAPIAddressProvider {
|
|
|
26
26
|
const liveAddress = sample(liveAddresses);
|
|
27
27
|
|
|
28
28
|
if (liveAddress === undefined) {
|
|
29
|
-
return
|
|
29
|
+
return undefined;
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
// This is a temporary fix for a localhost masternode.
|
|
@@ -34,7 +34,11 @@ class ListDAPIAddressProvider {
|
|
|
34
34
|
// not really possible to bind to that address, so that workaround is introduced.
|
|
35
35
|
const network = networks.get(this.options.network);
|
|
36
36
|
if (network && network.regtestEnabled) {
|
|
37
|
+
const randomNodeIndex = Math.floor(Math.random() * liveAddresses.length);
|
|
38
|
+
|
|
37
39
|
liveAddress.host = '127.0.0.1';
|
|
40
|
+
liveAddress.httpPort = 3000 + randomNodeIndex * 100;
|
|
41
|
+
liveAddress.grpcPort = 3010 + randomNodeIndex * 100;
|
|
38
42
|
}
|
|
39
43
|
|
|
40
44
|
return liveAddress;
|
|
@@ -47,36 +47,34 @@ function createGrpcTransportError(grpcError, dapiAddress) {
|
|
|
47
47
|
// Extract error code and data
|
|
48
48
|
let data = {};
|
|
49
49
|
let { code } = grpcError;
|
|
50
|
+
|
|
50
51
|
const message = grpcError.details || grpcError.message;
|
|
51
52
|
|
|
52
53
|
if (grpcError.metadata) {
|
|
53
|
-
|
|
54
|
-
|
|
54
|
+
// In cases of gRPC-Web client we get plain map instead of Metadata instance
|
|
55
|
+
let metadataMap = grpcError.metadata;
|
|
55
56
|
if (grpcError.metadata instanceof Metadata) {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
[encodedData] = cboredMetaData;
|
|
59
|
-
}
|
|
57
|
+
metadataMap = grpcError.metadata.getMap();
|
|
58
|
+
}
|
|
60
59
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
} else {
|
|
68
|
-
if (grpcError.metadata['drive-error-data-bin']) {
|
|
69
|
-
encodedData = Buffer.from(grpcError.metadata['drive-error-data-bin'], 'base64');
|
|
70
|
-
}
|
|
60
|
+
// Error data
|
|
61
|
+
const driveErrorData = metadataMap['drive-error-data-bin'];
|
|
62
|
+
if (driveErrorData) {
|
|
63
|
+
const encodedData = Buffer.from(driveErrorData, 'base64');
|
|
64
|
+
data = cbor.decode(encodedData);
|
|
65
|
+
}
|
|
71
66
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
67
|
+
// Error code
|
|
68
|
+
const driveErrorCode = metadataMap.code;
|
|
69
|
+
if (driveErrorCode) {
|
|
70
|
+
code = Number(driveErrorCode);
|
|
76
71
|
}
|
|
77
72
|
|
|
78
|
-
|
|
79
|
-
|
|
73
|
+
// Error stack
|
|
74
|
+
const driveErrorStack = metadataMap['stack-bin'];
|
|
75
|
+
if (driveErrorStack) {
|
|
76
|
+
const encodedStack = Buffer.from(driveErrorStack, 'base64');
|
|
77
|
+
data.stack = cbor.decode(encodedStack);
|
|
80
78
|
}
|
|
81
79
|
}
|
|
82
80
|
|
|
@@ -84,14 +84,14 @@ class JsonRpcTransport {
|
|
|
84
84
|
throw error;
|
|
85
85
|
}
|
|
86
86
|
|
|
87
|
-
address.markAsBanned();
|
|
88
|
-
|
|
89
87
|
const responseError = this.createJsonTransportError(error, address);
|
|
90
88
|
|
|
91
89
|
if (!(responseError instanceof RetriableResponseError)) {
|
|
92
90
|
throw responseError;
|
|
93
91
|
}
|
|
94
92
|
|
|
93
|
+
address.markAsBanned();
|
|
94
|
+
|
|
95
95
|
if (options.retries === 0) {
|
|
96
96
|
throw new MaxRetriesReachedError(responseError);
|
|
97
97
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dashevo/dapi-client",
|
|
3
|
-
"version": "0.23.0-dev.
|
|
3
|
+
"version": "0.23.0-dev.9",
|
|
4
4
|
"description": "Client library used to access Dash DAPI endpoints",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"contributors": [
|
|
@@ -26,11 +26,11 @@
|
|
|
26
26
|
}
|
|
27
27
|
],
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@dashevo/dapi-grpc": "~0.23.0-dev.
|
|
30
|
-
"@dashevo/dash-spv": "~1.1.7-
|
|
31
|
-
"@dashevo/dashcore-lib": "~0.19.
|
|
32
|
-
"@dashevo/dpp": "~0.23.0-dev.
|
|
33
|
-
"@dashevo/grpc-common": "~0.23.0-dev.
|
|
29
|
+
"@dashevo/dapi-grpc": "~0.23.0-dev.9",
|
|
30
|
+
"@dashevo/dash-spv": "~1.1.7-6",
|
|
31
|
+
"@dashevo/dashcore-lib": "~0.19.41",
|
|
32
|
+
"@dashevo/dpp": "~0.23.0-dev.9",
|
|
33
|
+
"@dashevo/grpc-common": "~0.23.0-dev.9",
|
|
34
34
|
"@grpc/grpc-js": "^1.3.7",
|
|
35
35
|
"axios": "^0.21.1",
|
|
36
36
|
"bs58": "^4.0.1",
|