@avalabs/glacier-sdk 2.8.0-canary.f2340be.0 → 2.8.0-canary.f3e3bdc.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
@@ -33,71 +33,75 @@ class CancelError extends Error {
33
33
  }
34
34
  }
35
35
  class CancelablePromise {
36
- [Symbol.toStringTag];
37
- _isResolved;
38
- _isRejected;
39
- _isCancelled;
40
- _cancelHandlers;
41
- _promise;
42
- _resolve;
43
- _reject;
36
+ #isResolved;
37
+ #isRejected;
38
+ #isCancelled;
39
+ #cancelHandlers;
40
+ #promise;
41
+ #resolve;
42
+ #reject;
44
43
  constructor(executor) {
45
- this._isResolved = false;
46
- this._isRejected = false;
47
- this._isCancelled = false;
48
- this._cancelHandlers = [];
49
- this._promise = new Promise((resolve, reject) => {
50
- this._resolve = resolve;
51
- this._reject = reject;
44
+ this.#isResolved = false;
45
+ this.#isRejected = false;
46
+ this.#isCancelled = false;
47
+ this.#cancelHandlers = [];
48
+ this.#promise = new Promise((resolve, reject) => {
49
+ this.#resolve = resolve;
50
+ this.#reject = reject;
52
51
  const onResolve = (value) => {
53
- if (this._isResolved || this._isRejected || this._isCancelled) {
52
+ if (this.#isResolved || this.#isRejected || this.#isCancelled) {
54
53
  return;
55
54
  }
56
- this._isResolved = true;
57
- this._resolve?.(value);
55
+ this.#isResolved = true;
56
+ if (this.#resolve)
57
+ this.#resolve(value);
58
58
  };
59
59
  const onReject = (reason) => {
60
- if (this._isResolved || this._isRejected || this._isCancelled) {
60
+ if (this.#isResolved || this.#isRejected || this.#isCancelled) {
61
61
  return;
62
62
  }
63
- this._isRejected = true;
64
- this._reject?.(reason);
63
+ this.#isRejected = true;
64
+ if (this.#reject)
65
+ this.#reject(reason);
65
66
  };
66
67
  const onCancel = (cancelHandler) => {
67
- if (this._isResolved || this._isRejected || this._isCancelled) {
68
+ if (this.#isResolved || this.#isRejected || this.#isCancelled) {
68
69
  return;
69
70
  }
70
- this._cancelHandlers.push(cancelHandler);
71
+ this.#cancelHandlers.push(cancelHandler);
71
72
  };
72
73
  Object.defineProperty(onCancel, "isResolved", {
73
- get: () => this._isResolved
74
+ get: () => this.#isResolved
74
75
  });
75
76
  Object.defineProperty(onCancel, "isRejected", {
76
- get: () => this._isRejected
77
+ get: () => this.#isRejected
77
78
  });
78
79
  Object.defineProperty(onCancel, "isCancelled", {
79
- get: () => this._isCancelled
80
+ get: () => this.#isCancelled
80
81
  });
81
82
  return executor(onResolve, onReject, onCancel);
82
83
  });
83
84
  }
85
+ get [Symbol.toStringTag]() {
86
+ return "Cancellable Promise";
87
+ }
84
88
  then(onFulfilled, onRejected) {
85
- return this._promise.then(onFulfilled, onRejected);
89
+ return this.#promise.then(onFulfilled, onRejected);
86
90
  }
87
91
  catch(onRejected) {
88
- return this._promise.catch(onRejected);
92
+ return this.#promise.catch(onRejected);
89
93
  }
90
94
  finally(onFinally) {
91
- return this._promise.finally(onFinally);
95
+ return this.#promise.finally(onFinally);
92
96
  }
93
97
  cancel() {
94
- if (this._isResolved || this._isRejected || this._isCancelled) {
98
+ if (this.#isResolved || this.#isRejected || this.#isCancelled) {
95
99
  return;
96
100
  }
97
- this._isCancelled = true;
98
- if (this._cancelHandlers.length) {
101
+ this.#isCancelled = true;
102
+ if (this.#cancelHandlers.length) {
99
103
  try {
100
- for (const cancelHandler of this._cancelHandlers) {
104
+ for (const cancelHandler of this.#cancelHandlers) {
101
105
  cancelHandler();
102
106
  }
103
107
  } catch (error) {
@@ -105,11 +109,12 @@ class CancelablePromise {
105
109
  return;
106
110
  }
107
111
  }
108
- this._cancelHandlers.length = 0;
109
- this._reject?.(new CancelError("Request aborted"));
112
+ this.#cancelHandlers.length = 0;
113
+ if (this.#reject)
114
+ this.#reject(new CancelError("Request aborted"));
110
115
  }
111
116
  get isCancelled() {
112
- return this._isCancelled;
117
+ return this.#isCancelled;
113
118
  }
114
119
  }
115
120
 
@@ -205,10 +210,12 @@ const resolve = async (options, resolver) => {
205
210
  return resolver;
206
211
  };
207
212
  const getHeaders = async (config, options) => {
208
- const token = await resolve(options, config.TOKEN);
209
- const username = await resolve(options, config.USERNAME);
210
- const password = await resolve(options, config.PASSWORD);
211
- const additionalHeaders = await resolve(options, config.HEADERS);
213
+ const [token, username, password, additionalHeaders] = await Promise.all([
214
+ resolve(options, config.TOKEN),
215
+ resolve(options, config.USERNAME),
216
+ resolve(options, config.PASSWORD),
217
+ resolve(options, config.HEADERS)
218
+ ]);
212
219
  const headers = Object.entries({
213
220
  Accept: "application/json",
214
221
  ...additionalHeaders,
@@ -224,7 +231,7 @@ const getHeaders = async (config, options) => {
224
231
  const credentials = base64(`${username}:${password}`);
225
232
  headers["Authorization"] = `Basic ${credentials}`;
226
233
  }
227
- if (options.body) {
234
+ if (options.body !== void 0) {
228
235
  if (options.mediaType) {
229
236
  headers["Content-Type"] = options.mediaType;
230
237
  } else if (isBlob(options.body)) {
@@ -238,7 +245,7 @@ const getHeaders = async (config, options) => {
238
245
  return new Headers(headers);
239
246
  };
240
247
  const getRequestBody = (options) => {
241
- if (options.body) {
248
+ if (options.body !== void 0) {
242
249
  if (options.mediaType?.includes("/json")) {
243
250
  return JSON.stringify(options.body);
244
251
  } else if (isString(options.body) || isBlob(options.body) || isFormData(options.body)) {
@@ -277,7 +284,8 @@ const getResponseBody = async (response) => {
277
284
  try {
278
285
  const contentType = response.headers.get("Content-Type");
279
286
  if (contentType) {
280
- const isJSON = contentType.toLowerCase().startsWith("application/json");
287
+ const jsonTypes = ["application/json", "application/problem+json"];
288
+ const isJSON = jsonTypes.some((type) => contentType.toLowerCase().startsWith(type));
281
289
  if (isJSON) {
282
290
  return await response.json();
283
291
  } else {
@@ -306,7 +314,20 @@ const catchErrorCodes = (options, result) => {
306
314
  throw new ApiError(options, result, error);
307
315
  }
308
316
  if (!result.ok) {
309
- throw new ApiError(options, result, "Generic Error");
317
+ const errorStatus = result.status ?? "unknown";
318
+ const errorStatusText = result.statusText ?? "unknown";
319
+ const errorBody = (() => {
320
+ try {
321
+ return JSON.stringify(result.body, null, 2);
322
+ } catch (e) {
323
+ return void 0;
324
+ }
325
+ })();
326
+ throw new ApiError(
327
+ options,
328
+ result,
329
+ `Generic Error: status: ${errorStatus}; status text: ${errorStatusText}; body: ${errorBody}`
330
+ );
310
331
  }
311
332
  };
312
333
  const request = (config, options) => {
@@ -355,77 +376,21 @@ class DefaultService {
355
376
  url: "/v1/media/uploadImage"
356
377
  });
357
378
  }
358
- registerWebhook({
379
+ rpc({
380
+ chainId,
359
381
  requestBody
360
382
  }) {
361
383
  return this.httpRequest.request({
362
384
  method: "POST",
363
- url: "/v1/webhooks",
364
- body: requestBody,
365
- mediaType: "application/json"
366
- });
367
- }
368
- listWebhooks({
369
- pageToken,
370
- pageSize = 10,
371
- status
372
- }) {
373
- return this.httpRequest.request({
374
- method: "GET",
375
- url: "/v1/webhooks",
376
- query: {
377
- "pageToken": pageToken,
378
- "pageSize": pageSize,
379
- "status": status
380
- }
381
- });
382
- }
383
- getWebhook({
384
- id
385
- }) {
386
- return this.httpRequest.request({
387
- method: "GET",
388
- url: "/v1/webhooks/{id}",
385
+ url: "/v1/ext/bc/{chainId}/rpc",
389
386
  path: {
390
- "id": id
391
- }
392
- });
393
- }
394
- deactivateWebhook({
395
- id
396
- }) {
397
- return this.httpRequest.request({
398
- method: "DELETE",
399
- url: "/v1/webhooks/{id}",
400
- path: {
401
- "id": id
402
- }
403
- });
404
- }
405
- updateWebhook({
406
- id,
407
- requestBody
408
- }) {
409
- return this.httpRequest.request({
410
- method: "PATCH",
411
- url: "/v1/webhooks/{id}",
412
- path: {
413
- "id": id
387
+ "chainId": chainId
414
388
  },
415
389
  body: requestBody,
416
- mediaType: "application/json"
417
- });
418
- }
419
- generateSharedSecret() {
420
- return this.httpRequest.request({
421
- method: "POST",
422
- url: "/v1/webhooks:generateOrRotateSharedSecret"
423
- });
424
- }
425
- getSharedSecret() {
426
- return this.httpRequest.request({
427
- method: "GET",
428
- url: "/v1/webhooks:getSharedSecret"
390
+ mediaType: "application/json",
391
+ errors: {
392
+ 504: `Request timed out`
393
+ }
429
394
  });
430
395
  }
431
396
  }
@@ -1543,6 +1508,85 @@ class TeleporterService {
1543
1508
  }
1544
1509
  }
1545
1510
 
1511
+ class WebhooksService {
1512
+ constructor(httpRequest) {
1513
+ this.httpRequest = httpRequest;
1514
+ }
1515
+ registerWebhook({
1516
+ requestBody
1517
+ }) {
1518
+ return this.httpRequest.request({
1519
+ method: "POST",
1520
+ url: "/v1/webhooks",
1521
+ body: requestBody,
1522
+ mediaType: "application/json"
1523
+ });
1524
+ }
1525
+ listWebhooks({
1526
+ pageToken,
1527
+ pageSize = 10,
1528
+ status
1529
+ }) {
1530
+ return this.httpRequest.request({
1531
+ method: "GET",
1532
+ url: "/v1/webhooks",
1533
+ query: {
1534
+ "pageToken": pageToken,
1535
+ "pageSize": pageSize,
1536
+ "status": status
1537
+ }
1538
+ });
1539
+ }
1540
+ getWebhook({
1541
+ id
1542
+ }) {
1543
+ return this.httpRequest.request({
1544
+ method: "GET",
1545
+ url: "/v1/webhooks/{id}",
1546
+ path: {
1547
+ "id": id
1548
+ }
1549
+ });
1550
+ }
1551
+ deactivateWebhook({
1552
+ id
1553
+ }) {
1554
+ return this.httpRequest.request({
1555
+ method: "DELETE",
1556
+ url: "/v1/webhooks/{id}",
1557
+ path: {
1558
+ "id": id
1559
+ }
1560
+ });
1561
+ }
1562
+ updateWebhook({
1563
+ id,
1564
+ requestBody
1565
+ }) {
1566
+ return this.httpRequest.request({
1567
+ method: "PATCH",
1568
+ url: "/v1/webhooks/{id}",
1569
+ path: {
1570
+ "id": id
1571
+ },
1572
+ body: requestBody,
1573
+ mediaType: "application/json"
1574
+ });
1575
+ }
1576
+ generateSharedSecret() {
1577
+ return this.httpRequest.request({
1578
+ method: "POST",
1579
+ url: "/v1/webhooks:generateOrRotateSharedSecret"
1580
+ });
1581
+ }
1582
+ getSharedSecret() {
1583
+ return this.httpRequest.request({
1584
+ method: "GET",
1585
+ url: "/v1/webhooks:getSharedSecret"
1586
+ });
1587
+ }
1588
+ }
1589
+
1546
1590
  class Glacier {
1547
1591
  default;
1548
1592
  evmBalances;
@@ -1561,6 +1605,7 @@ class Glacier {
1561
1605
  primaryNetworkUtxOs;
1562
1606
  primaryNetworkVertices;
1563
1607
  teleporter;
1608
+ webhooks;
1564
1609
  request;
1565
1610
  constructor(config, HttpRequest = FetchHttpRequest) {
1566
1611
  this.request = new HttpRequest({
@@ -1591,6 +1636,7 @@ class Glacier {
1591
1636
  this.primaryNetworkUtxOs = new PrimaryNetworkUtxOsService(this.request);
1592
1637
  this.primaryNetworkVertices = new PrimaryNetworkVerticesService(this.request);
1593
1638
  this.teleporter = new TeleporterService(this.request);
1639
+ this.webhooks = new WebhooksService(this.request);
1594
1640
  }
1595
1641
  }
1596
1642
 
@@ -2173,5 +2219,6 @@ exports.ValidationStatusType = ValidationStatusType;
2173
2219
  exports.VmName = VmName;
2174
2220
  exports.WebhookStatus = WebhookStatus;
2175
2221
  exports.WebhookStatusType = WebhookStatusType;
2222
+ exports.WebhooksService = WebhooksService;
2176
2223
  exports.XChainId = XChainId;
2177
2224
  exports.XChainTransactionType = XChainTransactionType;
@@ -17,6 +17,7 @@ import { PrimaryNetworkTransactionsService } from './services/PrimaryNetworkTran
17
17
  import { PrimaryNetworkUtxOsService } from './services/PrimaryNetworkUtxOsService.js';
18
18
  import { PrimaryNetworkVerticesService } from './services/PrimaryNetworkVerticesService.js';
19
19
  import { TeleporterService } from './services/TeleporterService.js';
20
+ import { WebhooksService } from './services/WebhooksService.js';
20
21
 
21
22
  type HttpRequestConstructor = new (config: OpenAPIConfig) => BaseHttpRequest;
22
23
  declare class Glacier {
@@ -37,6 +38,7 @@ declare class Glacier {
37
38
  readonly primaryNetworkUtxOs: PrimaryNetworkUtxOsService;
38
39
  readonly primaryNetworkVertices: PrimaryNetworkVerticesService;
39
40
  readonly teleporter: TeleporterService;
41
+ readonly webhooks: WebhooksService;
40
42
  readonly request: BaseHttpRequest;
41
43
  constructor(config?: Partial<OpenAPIConfig>, HttpRequest?: HttpRequestConstructor);
42
44
  }
@@ -16,6 +16,7 @@ import { PrimaryNetworkTransactionsService } from './services/PrimaryNetworkTran
16
16
  import { PrimaryNetworkUtxOsService } from './services/PrimaryNetworkUtxOsService.js';
17
17
  import { PrimaryNetworkVerticesService } from './services/PrimaryNetworkVerticesService.js';
18
18
  import { TeleporterService } from './services/TeleporterService.js';
19
+ import { WebhooksService } from './services/WebhooksService.js';
19
20
 
20
21
  class Glacier {
21
22
  default;
@@ -35,6 +36,7 @@ class Glacier {
35
36
  primaryNetworkUtxOs;
36
37
  primaryNetworkVertices;
37
38
  teleporter;
39
+ webhooks;
38
40
  request;
39
41
  constructor(config, HttpRequest = FetchHttpRequest) {
40
42
  this.request = new HttpRequest({
@@ -65,6 +67,7 @@ class Glacier {
65
67
  this.primaryNetworkUtxOs = new PrimaryNetworkUtxOsService(this.request);
66
68
  this.primaryNetworkVertices = new PrimaryNetworkVerticesService(this.request);
67
69
  this.teleporter = new TeleporterService(this.request);
70
+ this.webhooks = new WebhooksService(this.request);
68
71
  }
69
72
  }
70
73
 
@@ -9,15 +9,9 @@ interface OnCancel {
9
9
  (cancelHandler: () => void): void;
10
10
  }
11
11
  declare class CancelablePromise<T> implements Promise<T> {
12
- readonly [Symbol.toStringTag]: string;
13
- private _isResolved;
14
- private _isRejected;
15
- private _isCancelled;
16
- private readonly _cancelHandlers;
17
- private readonly _promise;
18
- private _resolve?;
19
- private _reject?;
12
+ #private;
20
13
  constructor(executor: (resolve: (value: T | PromiseLike<T>) => void, reject: (reason?: any) => void, onCancel: OnCancel) => void);
14
+ get [Symbol.toStringTag](): string;
21
15
  then<TResult1 = T, TResult2 = never>(onFulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | null, onRejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null): Promise<TResult1 | TResult2>;
22
16
  catch<TResult = never>(onRejected?: ((reason: any) => TResult | PromiseLike<TResult>) | null): Promise<T | TResult>;
23
17
  finally(onFinally?: (() => void) | null): Promise<T>;
@@ -8,71 +8,75 @@ 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
+ #isResolved;
12
+ #isRejected;
13
+ #isCancelled;
14
+ #cancelHandlers;
15
+ #promise;
16
+ #resolve;
17
+ #reject;
19
18
  constructor(executor) {
20
- this._isResolved = false;
21
- this._isRejected = false;
22
- this._isCancelled = false;
23
- this._cancelHandlers = [];
24
- this._promise = new Promise((resolve, reject) => {
25
- this._resolve = resolve;
26
- this._reject = reject;
19
+ this.#isResolved = false;
20
+ this.#isRejected = false;
21
+ this.#isCancelled = false;
22
+ this.#cancelHandlers = [];
23
+ this.#promise = new Promise((resolve, reject) => {
24
+ this.#resolve = resolve;
25
+ this.#reject = reject;
27
26
  const onResolve = (value) => {
28
- if (this._isResolved || this._isRejected || this._isCancelled) {
27
+ if (this.#isResolved || this.#isRejected || this.#isCancelled) {
29
28
  return;
30
29
  }
31
- this._isResolved = true;
32
- this._resolve?.(value);
30
+ this.#isResolved = true;
31
+ if (this.#resolve)
32
+ this.#resolve(value);
33
33
  };
34
34
  const onReject = (reason) => {
35
- if (this._isResolved || this._isRejected || this._isCancelled) {
35
+ if (this.#isResolved || this.#isRejected || this.#isCancelled) {
36
36
  return;
37
37
  }
38
- this._isRejected = true;
39
- this._reject?.(reason);
38
+ this.#isRejected = true;
39
+ if (this.#reject)
40
+ this.#reject(reason);
40
41
  };
41
42
  const onCancel = (cancelHandler) => {
42
- if (this._isResolved || this._isRejected || this._isCancelled) {
43
+ if (this.#isResolved || this.#isRejected || this.#isCancelled) {
43
44
  return;
44
45
  }
45
- this._cancelHandlers.push(cancelHandler);
46
+ this.#cancelHandlers.push(cancelHandler);
46
47
  };
47
48
  Object.defineProperty(onCancel, "isResolved", {
48
- get: () => this._isResolved
49
+ get: () => this.#isResolved
49
50
  });
50
51
  Object.defineProperty(onCancel, "isRejected", {
51
- get: () => this._isRejected
52
+ get: () => this.#isRejected
52
53
  });
53
54
  Object.defineProperty(onCancel, "isCancelled", {
54
- get: () => this._isCancelled
55
+ get: () => this.#isCancelled
55
56
  });
56
57
  return executor(onResolve, onReject, onCancel);
57
58
  });
58
59
  }
60
+ get [Symbol.toStringTag]() {
61
+ return "Cancellable Promise";
62
+ }
59
63
  then(onFulfilled, onRejected) {
60
- return this._promise.then(onFulfilled, onRejected);
64
+ return this.#promise.then(onFulfilled, onRejected);
61
65
  }
62
66
  catch(onRejected) {
63
- return this._promise.catch(onRejected);
67
+ return this.#promise.catch(onRejected);
64
68
  }
65
69
  finally(onFinally) {
66
- return this._promise.finally(onFinally);
70
+ return this.#promise.finally(onFinally);
67
71
  }
68
72
  cancel() {
69
- if (this._isResolved || this._isRejected || this._isCancelled) {
73
+ if (this.#isResolved || this.#isRejected || this.#isCancelled) {
70
74
  return;
71
75
  }
72
- this._isCancelled = true;
73
- if (this._cancelHandlers.length) {
76
+ this.#isCancelled = true;
77
+ if (this.#cancelHandlers.length) {
74
78
  try {
75
- for (const cancelHandler of this._cancelHandlers) {
79
+ for (const cancelHandler of this.#cancelHandlers) {
76
80
  cancelHandler();
77
81
  }
78
82
  } catch (error) {
@@ -80,11 +84,12 @@ class CancelablePromise {
80
84
  return;
81
85
  }
82
86
  }
83
- this._cancelHandlers.length = 0;
84
- this._reject?.(new CancelError("Request aborted"));
87
+ this.#cancelHandlers.length = 0;
88
+ if (this.#reject)
89
+ this.#reject(new CancelError("Request aborted"));
85
90
  }
86
91
  get isCancelled() {
87
- return this._isCancelled;
92
+ return this.#isCancelled;
88
93
  }
89
94
  }
90
95
 
@@ -7,11 +7,11 @@ type OpenAPIConfig = {
7
7
  VERSION: string;
8
8
  WITH_CREDENTIALS: boolean;
9
9
  CREDENTIALS: 'include' | 'omit' | 'same-origin';
10
- TOKEN?: string | Resolver<string>;
11
- USERNAME?: string | Resolver<string>;
12
- PASSWORD?: string | Resolver<string>;
13
- HEADERS?: Headers | Resolver<Headers>;
14
- ENCODE_PATH?: (path: string) => string;
10
+ TOKEN?: string | Resolver<string> | undefined;
11
+ USERNAME?: string | Resolver<string> | undefined;
12
+ PASSWORD?: string | Resolver<string> | undefined;
13
+ HEADERS?: Headers | Resolver<Headers> | undefined;
14
+ ENCODE_PATH?: ((path: string) => string) | undefined;
15
15
  };
16
16
  declare const OpenAPI: OpenAPIConfig;
17
17
 
@@ -93,10 +93,12 @@ const resolve = async (options, resolver) => {
93
93
  return resolver;
94
94
  };
95
95
  const getHeaders = async (config, options) => {
96
- const token = await resolve(options, config.TOKEN);
97
- const username = await resolve(options, config.USERNAME);
98
- const password = await resolve(options, config.PASSWORD);
99
- const additionalHeaders = await resolve(options, config.HEADERS);
96
+ const [token, username, password, additionalHeaders] = await Promise.all([
97
+ resolve(options, config.TOKEN),
98
+ resolve(options, config.USERNAME),
99
+ resolve(options, config.PASSWORD),
100
+ resolve(options, config.HEADERS)
101
+ ]);
100
102
  const headers = Object.entries({
101
103
  Accept: "application/json",
102
104
  ...additionalHeaders,
@@ -112,7 +114,7 @@ const getHeaders = async (config, options) => {
112
114
  const credentials = base64(`${username}:${password}`);
113
115
  headers["Authorization"] = `Basic ${credentials}`;
114
116
  }
115
- if (options.body) {
117
+ if (options.body !== void 0) {
116
118
  if (options.mediaType) {
117
119
  headers["Content-Type"] = options.mediaType;
118
120
  } else if (isBlob(options.body)) {
@@ -126,7 +128,7 @@ const getHeaders = async (config, options) => {
126
128
  return new Headers(headers);
127
129
  };
128
130
  const getRequestBody = (options) => {
129
- if (options.body) {
131
+ if (options.body !== void 0) {
130
132
  if (options.mediaType?.includes("/json")) {
131
133
  return JSON.stringify(options.body);
132
134
  } else if (isString(options.body) || isBlob(options.body) || isFormData(options.body)) {
@@ -165,7 +167,8 @@ const getResponseBody = async (response) => {
165
167
  try {
166
168
  const contentType = response.headers.get("Content-Type");
167
169
  if (contentType) {
168
- const isJSON = contentType.toLowerCase().startsWith("application/json");
170
+ const jsonTypes = ["application/json", "application/problem+json"];
171
+ const isJSON = jsonTypes.some((type) => contentType.toLowerCase().startsWith(type));
169
172
  if (isJSON) {
170
173
  return await response.json();
171
174
  } else {
@@ -194,7 +197,20 @@ const catchErrorCodes = (options, result) => {
194
197
  throw new ApiError(options, result, error);
195
198
  }
196
199
  if (!result.ok) {
197
- throw new ApiError(options, result, "Generic Error");
200
+ const errorStatus = result.status ?? "unknown";
201
+ const errorStatusText = result.statusText ?? "unknown";
202
+ const errorBody = (() => {
203
+ try {
204
+ return JSON.stringify(result.body, null, 2);
205
+ } catch (e) {
206
+ return void 0;
207
+ }
208
+ })();
209
+ throw new ApiError(
210
+ options,
211
+ result,
212
+ `Generic Error: status: ${errorStatus}; status text: ${errorStatusText}; body: ${errorBody}`
213
+ );
198
214
  }
199
215
  };
200
216
  const request = (config, options) => {
@@ -224,4 +240,4 @@ const request = (config, options) => {
224
240
  });
225
241
  };
226
242
 
227
- export { request, sendRequest };
243
+ export { base64, catchErrorCodes, getFormData, getHeaders, getQueryString, getRequestBody, getResponseBody, getResponseHeader, isBlob, isDefined, isFormData, isString, isStringWithValue, request, resolve, sendRequest };
@@ -7,14 +7,6 @@ type AddressActivityMetadata = {
7
7
  * Array of hexadecimal strings of the event signatures.
8
8
  */
9
9
  eventSignatures?: Array<string>;
10
- /**
11
- * Whether to include traces in the webhook payload.
12
- */
13
- includeTraces?: boolean;
14
- /**
15
- * Whether to include logs in the webhook payload.
16
- */
17
- includeLogs?: boolean;
18
10
  };
19
11
 
20
12
  export { AddressActivityMetadata };
@@ -1,5 +1,5 @@
1
1
  type PrimaryNetworkOptions = {
2
- addresses: Array<string>;
2
+ addresses?: Array<string>;
3
3
  cChainEvmAddresses?: Array<string>;
4
4
  includeChains: Array<'11111111111111111111111111111111LpoYY' | '2oYMBNV4eNHyqk2fjjV5nVQLDbtmNJzq5s3qs3Lo6ftnC6FByM' | '2JVSBoinj9C2J33VntvzYtVJNZdN2NKiwwKjcumHUWEb5DbBrm' | '2q9e4r6Mu3U68nU1fYjgbR6JvwrRx36CohpAX5UQxse55x1Q5' | 'yH8D7ThNJkxmtkuv2jgBa4P1Rn3Qpr4pPr7QYNfcdoS6k6HWp' | 'p-chain' | 'x-chain' | 'c-chain'>;
5
5
  };