@dashevo/dapi-client 0.24.0-dev.12 → 0.24.0-dev.13

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/README.md CHANGED
@@ -50,8 +50,7 @@ const DAPIClient = require('@dashevo/dapi-client');
50
50
  var client = new DAPIClient({
51
51
  seeds: [{
52
52
  host: 'seed-1.evonet.networks.dash.org',
53
- httpPort: 3000,
54
- grpcPort: 3010,
53
+ port: 3000,
55
54
  }],
56
55
  });
57
56
 
@@ -71,8 +70,8 @@ const DAPIClient = require('@dashevo/dapi-client');
71
70
 
72
71
  var client = new DAPIClient({
73
72
  dapiAddresses: [
74
- '127.0.0.1:3000:3010',
75
- '127.0.0.2:3000:3010',
73
+ '127.0.0.1:3000',
74
+ '127.0.0.2:3000',
76
75
  ],
77
76
  });
78
77
 
@@ -10,13 +10,12 @@ class DAPIAddress {
10
10
  }
11
11
 
12
12
  if (typeof address === 'string') {
13
- const [host, httpPort, grpcPort, ssl] = address.split(':');
13
+ const [host, port, ssl] = address.split(':');
14
14
 
15
15
  // eslint-disable-next-line no-param-reassign
16
16
  address = {
17
17
  host,
18
- httpPort: httpPort ? parseInt(httpPort, 10) : DAPIAddress.DEFAULT_HTTP_PORT,
19
- grpcPort: grpcPort ? parseInt(grpcPort, 10) : DAPIAddress.DEFAULT_GRPC_PORT,
18
+ port: port ? parseInt(port, 10) : DAPIAddress.DEFAULT_PORT,
20
19
  protocol: ssl === 'no-ssl' ? 'http' : DAPIAddress.DEFAULT_PROTOCOL,
21
20
  allowSelfSignedCertificate: ssl === 'self-signed',
22
21
  };
@@ -28,8 +27,7 @@ class DAPIAddress {
28
27
 
29
28
  this.protocol = address.protocol || DAPIAddress.DEFAULT_PROTOCOL;
30
29
  this.host = address.host;
31
- this.httpPort = address.httpPort || DAPIAddress.DEFAULT_HTTP_PORT;
32
- this.grpcPort = address.grpcPort || DAPIAddress.DEFAULT_GRPC_PORT;
30
+ this.port = address.port || DAPIAddress.DEFAULT_PORT;
33
31
  this.proRegTxHash = address.proRegTxHash;
34
32
  this.allowSelfSignedCertificate = address.allowSelfSignedCertificate || false;
35
33
 
@@ -68,43 +66,22 @@ class DAPIAddress {
68
66
  }
69
67
 
70
68
  /**
71
- * Get HTTP port
69
+ * Get port
72
70
  *
73
71
  * @returns {number}
74
72
  */
75
- getHttpPort() {
76
- return this.httpPort;
73
+ getPort() {
74
+ return this.port;
77
75
  }
78
76
 
79
77
  /**
80
- * Set HTTP port
78
+ * Set port
81
79
  *
82
80
  * @param {number} port
83
81
  * @returns {DAPIAddress}
84
82
  */
85
- setHttpPort(port) {
86
- this.httpPort = port;
87
-
88
- return this;
89
- }
90
-
91
- /**
92
- * Get gRPC port
93
- *
94
- * @returns {number}
95
- */
96
- getGrpcPort() {
97
- return this.grpcPort;
98
- }
99
-
100
- /**
101
- * Set gRPC port
102
- *
103
- * @param {number} port
104
- * @returns {DAPIAddress}
105
- */
106
- setGrpcPort(port) {
107
- this.grpcPort = port;
83
+ setPort(port) {
84
+ this.port = port;
108
85
 
109
86
  return this;
110
87
  }
@@ -179,28 +156,25 @@ class DAPIAddress {
179
156
  return {
180
157
  protocol: this.getProtocol(),
181
158
  host: this.getHost(),
182
- httpPort: this.getHttpPort(),
183
- grpcPort: this.getGrpcPort(),
159
+ port: this.getPort(),
184
160
  proRegTxHash: this.getProRegTxHash(),
185
161
  allowSelfSignedCertificate: this.isSelfSignedCertificateAllowed(),
186
162
  };
187
163
  }
188
164
 
189
165
  toString() {
190
- return `${this.getProtocol()}://${this.getHost()}:${this.getHttpPort()}:${this.getGrpcPort()}`;
166
+ return `${this.getProtocol()}://${this.getHost()}:${this.getPort()}`;
191
167
  }
192
168
  }
193
169
 
194
- DAPIAddress.DEFAULT_HTTP_PORT = 3000;
195
- DAPIAddress.DEFAULT_GRPC_PORT = 3010;
196
- DAPIAddress.DEFAULT_PROTOCOL = 'http';
170
+ DAPIAddress.DEFAULT_PORT = 3000;
171
+ DAPIAddress.DEFAULT_PROTOCOL = 'https';
197
172
 
198
173
  /**
199
174
  * @typedef {object} RawDAPIAddress
200
175
  * @property {string} protocol
201
176
  * @property {string} host
202
- * @property {number} [httpPort=3000]
203
- * @property {number} [grpcPort=3010]
177
+ * @property {number} [port=3000]
204
178
  * @property {string} [proRegTxHash]
205
179
  * @property {bool} [selfSigned]
206
180
  */
@@ -39,8 +39,7 @@ class ListDAPIAddressProvider {
39
39
  liveAddress.protocol = 'https';
40
40
  liveAddress.host = '127.0.0.1';
41
41
  liveAddress.allowSelfSignedCertificate = true;
42
- liveAddress.httpPort = 3000 + randomNodeIndex * 100;
43
- liveAddress.grpcPort = 3010 + randomNodeIndex * 100;
42
+ liveAddress.port = 3000 + randomNodeIndex * 100;
44
43
  }
45
44
 
46
45
  return liveAddress;
@@ -133,20 +133,15 @@ class GrpcTransport {
133
133
  */
134
134
  makeGrpcUrlFromAddress(address) {
135
135
  let protocol = address.getProtocol();
136
- let port = address.getHttpPort();
137
-
138
136
  // For NodeJS Client
139
137
  if (typeof process !== 'undefined'
140
138
  && process.versions != null
141
- && process.versions.node != null) {
142
- port = address.getGrpcPort();
143
-
144
- if (address.isSelfSignedCertificateAllowed()) {
145
- protocol = 'http';
146
- }
139
+ && process.versions.node != null
140
+ && address.isSelfSignedCertificateAllowed()) {
141
+ protocol = 'http';
147
142
  }
148
143
 
149
- return `${protocol}://${address.getHost()}:${port}`;
144
+ return `${protocol}://${address.getHost()}:${address.getPort()}`;
150
145
  }
151
146
  }
152
147
 
@@ -67,7 +67,7 @@ class JsonRpcTransport {
67
67
  const result = await this.requestJsonRpc(
68
68
  address.getProtocol(),
69
69
  address.getHost(),
70
- address.getHttpPort(),
70
+ address.getPort(),
71
71
  address.isSelfSignedCertificateAllowed(),
72
72
  method,
73
73
  params,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dashevo/dapi-client",
3
- "version": "0.24.0-dev.12",
3
+ "version": "0.24.0-dev.13",
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.24.0-dev.12",
30
- "@dashevo/dash-spv": "0.24.0-dev.12",
29
+ "@dashevo/dapi-grpc": "0.24.0-dev.13",
30
+ "@dashevo/dash-spv": "0.24.0-dev.13",
31
31
  "@dashevo/dashcore-lib": "~0.19.44",
32
- "@dashevo/dpp": "0.24.0-dev.12",
33
- "@dashevo/grpc-common": "0.24.0-dev.12",
32
+ "@dashevo/dpp": "0.24.0-dev.13",
33
+ "@dashevo/grpc-common": "0.24.0-dev.13",
34
34
  "bs58": "^4.0.1",
35
35
  "cbor": "^8.0.0",
36
36
  "lodash": "^4.17.21",
@@ -77,7 +77,8 @@
77
77
  },
78
78
  "files": [
79
79
  "docs",
80
- "lib"
80
+ "lib",
81
+ "polyfills"
81
82
  ],
82
83
  "scripts": {
83
84
  "build:web": "webpack",
@@ -0,0 +1,10 @@
1
+ /* eslint-disable */
2
+
3
+ const { default: fetch, Headers, Request, Response } = require('node-fetch');
4
+
5
+ if (!globalThis.fetch) {
6
+ globalThis.fetch = fetch;
7
+ globalThis.Headers = Headers;
8
+ globalThis.Request = Request;
9
+ globalThis.Response = Response;
10
+ }