@avalabs/glacier-sdk 2.8.0-canary.b9648ce.0 → 2.8.0-canary.fdc2483.0
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/dist/index.js
CHANGED
|
@@ -7,6 +7,11 @@ class BaseHttpRequest {
|
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
class ApiError extends Error {
|
|
10
|
+
url;
|
|
11
|
+
status;
|
|
12
|
+
statusText;
|
|
13
|
+
body;
|
|
14
|
+
request;
|
|
10
15
|
constructor(request, response, message) {
|
|
11
16
|
super(message);
|
|
12
17
|
this.name = "ApiError";
|
|
@@ -28,6 +33,14 @@ class CancelError extends Error {
|
|
|
28
33
|
}
|
|
29
34
|
}
|
|
30
35
|
class CancelablePromise {
|
|
36
|
+
[Symbol.toStringTag];
|
|
37
|
+
_isResolved;
|
|
38
|
+
_isRejected;
|
|
39
|
+
_isCancelled;
|
|
40
|
+
_cancelHandlers;
|
|
41
|
+
_promise;
|
|
42
|
+
_resolve;
|
|
43
|
+
_reject;
|
|
31
44
|
constructor(executor) {
|
|
32
45
|
this._isResolved = false;
|
|
33
46
|
this._isRejected = false;
|
|
@@ -37,20 +50,18 @@ class CancelablePromise {
|
|
|
37
50
|
this._resolve = resolve;
|
|
38
51
|
this._reject = reject;
|
|
39
52
|
const onResolve = (value) => {
|
|
40
|
-
var _a;
|
|
41
53
|
if (this._isResolved || this._isRejected || this._isCancelled) {
|
|
42
54
|
return;
|
|
43
55
|
}
|
|
44
56
|
this._isResolved = true;
|
|
45
|
-
|
|
57
|
+
this._resolve?.(value);
|
|
46
58
|
};
|
|
47
59
|
const onReject = (reason) => {
|
|
48
|
-
var _a;
|
|
49
60
|
if (this._isResolved || this._isRejected || this._isCancelled) {
|
|
50
61
|
return;
|
|
51
62
|
}
|
|
52
63
|
this._isRejected = true;
|
|
53
|
-
|
|
64
|
+
this._reject?.(reason);
|
|
54
65
|
};
|
|
55
66
|
const onCancel = (cancelHandler) => {
|
|
56
67
|
if (this._isResolved || this._isRejected || this._isCancelled) {
|
|
@@ -80,7 +91,6 @@ class CancelablePromise {
|
|
|
80
91
|
return this._promise.finally(onFinally);
|
|
81
92
|
}
|
|
82
93
|
cancel() {
|
|
83
|
-
var _a;
|
|
84
94
|
if (this._isResolved || this._isRejected || this._isCancelled) {
|
|
85
95
|
return;
|
|
86
96
|
}
|
|
@@ -96,32 +106,13 @@ class CancelablePromise {
|
|
|
96
106
|
}
|
|
97
107
|
}
|
|
98
108
|
this._cancelHandlers.length = 0;
|
|
99
|
-
|
|
109
|
+
this._reject?.(new CancelError("Request aborted"));
|
|
100
110
|
}
|
|
101
111
|
get isCancelled() {
|
|
102
112
|
return this._isCancelled;
|
|
103
113
|
}
|
|
104
114
|
}
|
|
105
115
|
|
|
106
|
-
var __defProp = Object.defineProperty;
|
|
107
|
-
var __defProps = Object.defineProperties;
|
|
108
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
109
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
110
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
111
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
112
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
113
|
-
var __spreadValues = (a, b) => {
|
|
114
|
-
for (var prop in b || (b = {}))
|
|
115
|
-
if (__hasOwnProp.call(b, prop))
|
|
116
|
-
__defNormalProp(a, prop, b[prop]);
|
|
117
|
-
if (__getOwnPropSymbols)
|
|
118
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
119
|
-
if (__propIsEnum.call(b, prop))
|
|
120
|
-
__defNormalProp(a, prop, b[prop]);
|
|
121
|
-
}
|
|
122
|
-
return a;
|
|
123
|
-
};
|
|
124
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
125
116
|
const isDefined = (value) => {
|
|
126
117
|
return value !== void 0 && value !== null;
|
|
127
118
|
};
|
|
@@ -175,8 +166,7 @@ const getQueryString = (params) => {
|
|
|
175
166
|
const getUrl = (config, options) => {
|
|
176
167
|
const encoder = config.ENCODE_PATH || encodeURI;
|
|
177
168
|
const path = options.url.replace("{api-version}", config.VERSION).replace(/{(.*?)}/g, (substring, group) => {
|
|
178
|
-
|
|
179
|
-
if ((_a = options.path) == null ? void 0 : _a.hasOwnProperty(group)) {
|
|
169
|
+
if (options.path?.hasOwnProperty(group)) {
|
|
180
170
|
return encoder(String(options.path[group]));
|
|
181
171
|
}
|
|
182
172
|
return substring;
|
|
@@ -219,9 +209,12 @@ const getHeaders = async (config, options) => {
|
|
|
219
209
|
const username = await resolve(options, config.USERNAME);
|
|
220
210
|
const password = await resolve(options, config.PASSWORD);
|
|
221
211
|
const additionalHeaders = await resolve(options, config.HEADERS);
|
|
222
|
-
const headers = Object.entries(
|
|
223
|
-
Accept: "application/json"
|
|
224
|
-
|
|
212
|
+
const headers = Object.entries({
|
|
213
|
+
Accept: "application/json",
|
|
214
|
+
...additionalHeaders,
|
|
215
|
+
...options.headers
|
|
216
|
+
}).filter(([_, value]) => isDefined(value)).reduce((headers2, [key, value]) => ({
|
|
217
|
+
...headers2,
|
|
225
218
|
[key]: String(value)
|
|
226
219
|
}), {});
|
|
227
220
|
if (isStringWithValue(token)) {
|
|
@@ -245,9 +238,8 @@ const getHeaders = async (config, options) => {
|
|
|
245
238
|
return new Headers(headers);
|
|
246
239
|
};
|
|
247
240
|
const getRequestBody = (options) => {
|
|
248
|
-
var _a;
|
|
249
241
|
if (options.body) {
|
|
250
|
-
if (
|
|
242
|
+
if (options.mediaType?.includes("/json")) {
|
|
251
243
|
return JSON.stringify(options.body);
|
|
252
244
|
} else if (isString(options.body) || isBlob(options.body) || isFormData(options.body)) {
|
|
253
245
|
return options.body;
|
|
@@ -261,7 +253,7 @@ const sendRequest = async (config, options, url, body, formData, headers, onCanc
|
|
|
261
253
|
const controller = new AbortController();
|
|
262
254
|
const request2 = {
|
|
263
255
|
headers,
|
|
264
|
-
body: body
|
|
256
|
+
body: body ?? formData,
|
|
265
257
|
method: options.method,
|
|
266
258
|
signal: controller.signal
|
|
267
259
|
};
|
|
@@ -299,15 +291,16 @@ const getResponseBody = async (response) => {
|
|
|
299
291
|
return void 0;
|
|
300
292
|
};
|
|
301
293
|
const catchErrorCodes = (options, result) => {
|
|
302
|
-
const errors =
|
|
294
|
+
const errors = {
|
|
303
295
|
400: "Bad Request",
|
|
304
296
|
401: "Unauthorized",
|
|
305
297
|
403: "Forbidden",
|
|
306
298
|
404: "Not Found",
|
|
307
299
|
500: "Internal Server Error",
|
|
308
300
|
502: "Bad Gateway",
|
|
309
|
-
503: "Service Unavailable"
|
|
310
|
-
|
|
301
|
+
503: "Service Unavailable",
|
|
302
|
+
...options.errors
|
|
303
|
+
};
|
|
311
304
|
const error = errors[result.status];
|
|
312
305
|
if (error) {
|
|
313
306
|
throw new ApiError(options, result, error);
|
|
@@ -332,7 +325,7 @@ const request = (config, options) => {
|
|
|
332
325
|
ok: response.ok,
|
|
333
326
|
status: response.status,
|
|
334
327
|
statusText: response.statusText,
|
|
335
|
-
body: responseHeader
|
|
328
|
+
body: responseHeader ?? responseBody
|
|
336
329
|
};
|
|
337
330
|
catchErrorCodes(options, result);
|
|
338
331
|
resolve2(result.body);
|
|
@@ -1320,18 +1313,31 @@ class PrimaryNetworkVerticesService {
|
|
|
1320
1313
|
}
|
|
1321
1314
|
|
|
1322
1315
|
class Glacier {
|
|
1316
|
+
evmBalances;
|
|
1317
|
+
evmBlocks;
|
|
1318
|
+
evmChains;
|
|
1319
|
+
evmTransactions;
|
|
1320
|
+
healthCheck;
|
|
1321
|
+
operations;
|
|
1322
|
+
primaryNetwork;
|
|
1323
|
+
primaryNetworkBalances;
|
|
1324
|
+
primaryNetworkBlocks;
|
|
1325
|
+
primaryNetworkRewards;
|
|
1326
|
+
primaryNetworkTransactions;
|
|
1327
|
+
primaryNetworkUtxOs;
|
|
1328
|
+
primaryNetworkVertices;
|
|
1329
|
+
request;
|
|
1323
1330
|
constructor(config, HttpRequest = FetchHttpRequest) {
|
|
1324
|
-
var _a, _b, _c, _d;
|
|
1325
1331
|
this.request = new HttpRequest({
|
|
1326
|
-
BASE:
|
|
1327
|
-
VERSION:
|
|
1328
|
-
WITH_CREDENTIALS:
|
|
1329
|
-
CREDENTIALS:
|
|
1330
|
-
TOKEN: config
|
|
1331
|
-
USERNAME: config
|
|
1332
|
-
PASSWORD: config
|
|
1333
|
-
HEADERS: config
|
|
1334
|
-
ENCODE_PATH: config
|
|
1332
|
+
BASE: config?.BASE ?? "https://glacier-api-dev.avax.network",
|
|
1333
|
+
VERSION: config?.VERSION ?? "Beta",
|
|
1334
|
+
WITH_CREDENTIALS: config?.WITH_CREDENTIALS ?? false,
|
|
1335
|
+
CREDENTIALS: config?.CREDENTIALS ?? "include",
|
|
1336
|
+
TOKEN: config?.TOKEN,
|
|
1337
|
+
USERNAME: config?.USERNAME,
|
|
1338
|
+
PASSWORD: config?.PASSWORD,
|
|
1339
|
+
HEADERS: config?.HEADERS,
|
|
1340
|
+
ENCODE_PATH: config?.ENCODE_PATH
|
|
1335
1341
|
});
|
|
1336
1342
|
this.evmBalances = new EvmBalancesService(this.request);
|
|
1337
1343
|
this.evmBlocks = new EvmBlocksService(this.request);
|
package/esm/generated/Glacier.js
CHANGED
|
@@ -14,18 +14,31 @@ import { PrimaryNetworkUtxOsService } from './services/PrimaryNetworkUtxOsServic
|
|
|
14
14
|
import { PrimaryNetworkVerticesService } from './services/PrimaryNetworkVerticesService.js';
|
|
15
15
|
|
|
16
16
|
class Glacier {
|
|
17
|
+
evmBalances;
|
|
18
|
+
evmBlocks;
|
|
19
|
+
evmChains;
|
|
20
|
+
evmTransactions;
|
|
21
|
+
healthCheck;
|
|
22
|
+
operations;
|
|
23
|
+
primaryNetwork;
|
|
24
|
+
primaryNetworkBalances;
|
|
25
|
+
primaryNetworkBlocks;
|
|
26
|
+
primaryNetworkRewards;
|
|
27
|
+
primaryNetworkTransactions;
|
|
28
|
+
primaryNetworkUtxOs;
|
|
29
|
+
primaryNetworkVertices;
|
|
30
|
+
request;
|
|
17
31
|
constructor(config, HttpRequest = FetchHttpRequest) {
|
|
18
|
-
var _a, _b, _c, _d;
|
|
19
32
|
this.request = new HttpRequest({
|
|
20
|
-
BASE:
|
|
21
|
-
VERSION:
|
|
22
|
-
WITH_CREDENTIALS:
|
|
23
|
-
CREDENTIALS:
|
|
24
|
-
TOKEN: config
|
|
25
|
-
USERNAME: config
|
|
26
|
-
PASSWORD: config
|
|
27
|
-
HEADERS: config
|
|
28
|
-
ENCODE_PATH: config
|
|
33
|
+
BASE: config?.BASE ?? "https://glacier-api-dev.avax.network",
|
|
34
|
+
VERSION: config?.VERSION ?? "Beta",
|
|
35
|
+
WITH_CREDENTIALS: config?.WITH_CREDENTIALS ?? false,
|
|
36
|
+
CREDENTIALS: config?.CREDENTIALS ?? "include",
|
|
37
|
+
TOKEN: config?.TOKEN,
|
|
38
|
+
USERNAME: config?.USERNAME,
|
|
39
|
+
PASSWORD: config?.PASSWORD,
|
|
40
|
+
HEADERS: config?.HEADERS,
|
|
41
|
+
ENCODE_PATH: config?.ENCODE_PATH
|
|
29
42
|
});
|
|
30
43
|
this.evmBalances = new EvmBalancesService(this.request);
|
|
31
44
|
this.evmBlocks = new EvmBlocksService(this.request);
|
|
@@ -8,6 +8,14 @@ class CancelError extends Error {
|
|
|
8
8
|
}
|
|
9
9
|
}
|
|
10
10
|
class CancelablePromise {
|
|
11
|
+
[Symbol.toStringTag];
|
|
12
|
+
_isResolved;
|
|
13
|
+
_isRejected;
|
|
14
|
+
_isCancelled;
|
|
15
|
+
_cancelHandlers;
|
|
16
|
+
_promise;
|
|
17
|
+
_resolve;
|
|
18
|
+
_reject;
|
|
11
19
|
constructor(executor) {
|
|
12
20
|
this._isResolved = false;
|
|
13
21
|
this._isRejected = false;
|
|
@@ -17,20 +25,18 @@ class CancelablePromise {
|
|
|
17
25
|
this._resolve = resolve;
|
|
18
26
|
this._reject = reject;
|
|
19
27
|
const onResolve = (value) => {
|
|
20
|
-
var _a;
|
|
21
28
|
if (this._isResolved || this._isRejected || this._isCancelled) {
|
|
22
29
|
return;
|
|
23
30
|
}
|
|
24
31
|
this._isResolved = true;
|
|
25
|
-
|
|
32
|
+
this._resolve?.(value);
|
|
26
33
|
};
|
|
27
34
|
const onReject = (reason) => {
|
|
28
|
-
var _a;
|
|
29
35
|
if (this._isResolved || this._isRejected || this._isCancelled) {
|
|
30
36
|
return;
|
|
31
37
|
}
|
|
32
38
|
this._isRejected = true;
|
|
33
|
-
|
|
39
|
+
this._reject?.(reason);
|
|
34
40
|
};
|
|
35
41
|
const onCancel = (cancelHandler) => {
|
|
36
42
|
if (this._isResolved || this._isRejected || this._isCancelled) {
|
|
@@ -60,7 +66,6 @@ class CancelablePromise {
|
|
|
60
66
|
return this._promise.finally(onFinally);
|
|
61
67
|
}
|
|
62
68
|
cancel() {
|
|
63
|
-
var _a;
|
|
64
69
|
if (this._isResolved || this._isRejected || this._isCancelled) {
|
|
65
70
|
return;
|
|
66
71
|
}
|
|
@@ -76,7 +81,7 @@ class CancelablePromise {
|
|
|
76
81
|
}
|
|
77
82
|
}
|
|
78
83
|
this._cancelHandlers.length = 0;
|
|
79
|
-
|
|
84
|
+
this._reject?.(new CancelError("Request aborted"));
|
|
80
85
|
}
|
|
81
86
|
get isCancelled() {
|
|
82
87
|
return this._isCancelled;
|
|
@@ -1,25 +1,6 @@
|
|
|
1
1
|
import { ApiError } from './ApiError.js';
|
|
2
2
|
import { CancelablePromise } from './CancelablePromise.js';
|
|
3
3
|
|
|
4
|
-
var __defProp = Object.defineProperty;
|
|
5
|
-
var __defProps = Object.defineProperties;
|
|
6
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
7
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
8
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
10
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
11
|
-
var __spreadValues = (a, b) => {
|
|
12
|
-
for (var prop in b || (b = {}))
|
|
13
|
-
if (__hasOwnProp.call(b, prop))
|
|
14
|
-
__defNormalProp(a, prop, b[prop]);
|
|
15
|
-
if (__getOwnPropSymbols)
|
|
16
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
17
|
-
if (__propIsEnum.call(b, prop))
|
|
18
|
-
__defNormalProp(a, prop, b[prop]);
|
|
19
|
-
}
|
|
20
|
-
return a;
|
|
21
|
-
};
|
|
22
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
23
4
|
const isDefined = (value) => {
|
|
24
5
|
return value !== void 0 && value !== null;
|
|
25
6
|
};
|
|
@@ -73,8 +54,7 @@ const getQueryString = (params) => {
|
|
|
73
54
|
const getUrl = (config, options) => {
|
|
74
55
|
const encoder = config.ENCODE_PATH || encodeURI;
|
|
75
56
|
const path = options.url.replace("{api-version}", config.VERSION).replace(/{(.*?)}/g, (substring, group) => {
|
|
76
|
-
|
|
77
|
-
if ((_a = options.path) == null ? void 0 : _a.hasOwnProperty(group)) {
|
|
57
|
+
if (options.path?.hasOwnProperty(group)) {
|
|
78
58
|
return encoder(String(options.path[group]));
|
|
79
59
|
}
|
|
80
60
|
return substring;
|
|
@@ -117,9 +97,12 @@ const getHeaders = async (config, options) => {
|
|
|
117
97
|
const username = await resolve(options, config.USERNAME);
|
|
118
98
|
const password = await resolve(options, config.PASSWORD);
|
|
119
99
|
const additionalHeaders = await resolve(options, config.HEADERS);
|
|
120
|
-
const headers = Object.entries(
|
|
121
|
-
Accept: "application/json"
|
|
122
|
-
|
|
100
|
+
const headers = Object.entries({
|
|
101
|
+
Accept: "application/json",
|
|
102
|
+
...additionalHeaders,
|
|
103
|
+
...options.headers
|
|
104
|
+
}).filter(([_, value]) => isDefined(value)).reduce((headers2, [key, value]) => ({
|
|
105
|
+
...headers2,
|
|
123
106
|
[key]: String(value)
|
|
124
107
|
}), {});
|
|
125
108
|
if (isStringWithValue(token)) {
|
|
@@ -143,9 +126,8 @@ const getHeaders = async (config, options) => {
|
|
|
143
126
|
return new Headers(headers);
|
|
144
127
|
};
|
|
145
128
|
const getRequestBody = (options) => {
|
|
146
|
-
var _a;
|
|
147
129
|
if (options.body) {
|
|
148
|
-
if (
|
|
130
|
+
if (options.mediaType?.includes("/json")) {
|
|
149
131
|
return JSON.stringify(options.body);
|
|
150
132
|
} else if (isString(options.body) || isBlob(options.body) || isFormData(options.body)) {
|
|
151
133
|
return options.body;
|
|
@@ -159,7 +141,7 @@ const sendRequest = async (config, options, url, body, formData, headers, onCanc
|
|
|
159
141
|
const controller = new AbortController();
|
|
160
142
|
const request2 = {
|
|
161
143
|
headers,
|
|
162
|
-
body: body
|
|
144
|
+
body: body ?? formData,
|
|
163
145
|
method: options.method,
|
|
164
146
|
signal: controller.signal
|
|
165
147
|
};
|
|
@@ -197,15 +179,16 @@ const getResponseBody = async (response) => {
|
|
|
197
179
|
return void 0;
|
|
198
180
|
};
|
|
199
181
|
const catchErrorCodes = (options, result) => {
|
|
200
|
-
const errors =
|
|
182
|
+
const errors = {
|
|
201
183
|
400: "Bad Request",
|
|
202
184
|
401: "Unauthorized",
|
|
203
185
|
403: "Forbidden",
|
|
204
186
|
404: "Not Found",
|
|
205
187
|
500: "Internal Server Error",
|
|
206
188
|
502: "Bad Gateway",
|
|
207
|
-
503: "Service Unavailable"
|
|
208
|
-
|
|
189
|
+
503: "Service Unavailable",
|
|
190
|
+
...options.errors
|
|
191
|
+
};
|
|
209
192
|
const error = errors[result.status];
|
|
210
193
|
if (error) {
|
|
211
194
|
throw new ApiError(options, result, error);
|
|
@@ -230,7 +213,7 @@ const request = (config, options) => {
|
|
|
230
213
|
ok: response.ok,
|
|
231
214
|
status: response.status,
|
|
232
215
|
statusText: response.statusText,
|
|
233
|
-
body: responseHeader
|
|
216
|
+
body: responseHeader ?? responseBody
|
|
234
217
|
};
|
|
235
218
|
catchErrorCodes(options, result);
|
|
236
219
|
resolve2(result.body);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@avalabs/glacier-sdk",
|
|
3
|
-
"version": "2.8.0-canary.
|
|
3
|
+
"version": "2.8.0-canary.fdc2483.0+fdc2483",
|
|
4
4
|
"description": "sdk for interacting with glacier-api",
|
|
5
5
|
"author": "Oliver Wang <oliver.wang@avalabs.org>",
|
|
6
6
|
"homepage": "https://github.com/ava-labs/avalanche-sdks#readme",
|
|
@@ -29,5 +29,5 @@
|
|
|
29
29
|
"bugs": {
|
|
30
30
|
"url": "https://github.com/ava-labs/avalanche-sdks/issues"
|
|
31
31
|
},
|
|
32
|
-
"gitHead": "
|
|
32
|
+
"gitHead": "fdc2483ed601882eb6d5d047efc062816b735ebe"
|
|
33
33
|
}
|