@alephium/web3 0.12.1 → 0.12.2

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.
@@ -669,7 +669,7 @@ export declare class Api<SecurityDataType extends unknown> extends HttpClient<Se
669
669
  * @name GetInfosSupplyTotalAlph
670
670
  * @request GET:/infos/supply/total-alph
671
671
  */
672
- getInfosSupplyTotalAlph: (params?: RequestParams) => Promise<string>;
672
+ getInfosSupplyTotalAlph: (params?: RequestParams) => Promise<number>;
673
673
  /**
674
674
  * @description Get the ALPH circulating supply
675
675
  *
@@ -677,7 +677,7 @@ export declare class Api<SecurityDataType extends unknown> extends HttpClient<Se
677
677
  * @name GetInfosSupplyCirculatingAlph
678
678
  * @request GET:/infos/supply/circulating-alph
679
679
  */
680
- getInfosSupplyCirculatingAlph: (params?: RequestParams) => Promise<string>;
680
+ getInfosSupplyCirculatingAlph: (params?: RequestParams) => Promise<number>;
681
681
  /**
682
682
  * @description Get the ALPH reserved supply
683
683
  *
@@ -685,7 +685,7 @@ export declare class Api<SecurityDataType extends unknown> extends HttpClient<Se
685
685
  * @name GetInfosSupplyReservedAlph
686
686
  * @request GET:/infos/supply/reserved-alph
687
687
  */
688
- getInfosSupplyReservedAlph: (params?: RequestParams) => Promise<string>;
688
+ getInfosSupplyReservedAlph: (params?: RequestParams) => Promise<number>;
689
689
  /**
690
690
  * @description Get the ALPH locked supply
691
691
  *
@@ -693,7 +693,7 @@ export declare class Api<SecurityDataType extends unknown> extends HttpClient<Se
693
693
  * @name GetInfosSupplyLockedAlph
694
694
  * @request GET:/infos/supply/locked-alph
695
695
  */
696
- getInfosSupplyLockedAlph: (params?: RequestParams) => Promise<string>;
696
+ getInfosSupplyLockedAlph: (params?: RequestParams) => Promise<number>;
697
697
  /**
698
698
  * @description Get the total number of transactions
699
699
  *
@@ -701,7 +701,7 @@ export declare class Api<SecurityDataType extends unknown> extends HttpClient<Se
701
701
  * @name GetInfosTotalTransactions
702
702
  * @request GET:/infos/total-transactions
703
703
  */
704
- getInfosTotalTransactions: (params?: RequestParams) => Promise<string>;
704
+ getInfosTotalTransactions: (params?: RequestParams) => Promise<number>;
705
705
  /**
706
706
  * @description Get the average block time for each chain
707
707
  *
@@ -385,7 +385,7 @@ class Api extends HttpClient {
385
385
  query: query,
386
386
  format: 'text',
387
387
  ...params
388
- }).then(utils_1.convertTextHttpResponse),
388
+ }).then(utils_1.convertHttpResponse),
389
389
  /**
390
390
  * No description
391
391
  *
@@ -454,7 +454,7 @@ class Api extends HttpClient {
454
454
  method: 'GET',
455
455
  format: 'text',
456
456
  ...params
457
- }).then(utils_1.convertTextHttpResponse),
457
+ }).then(utils_1.convertHttpResponse),
458
458
  /**
459
459
  * @description Get the ALPH circulating supply
460
460
  *
@@ -467,7 +467,7 @@ class Api extends HttpClient {
467
467
  method: 'GET',
468
468
  format: 'text',
469
469
  ...params
470
- }).then(utils_1.convertTextHttpResponse),
470
+ }).then(utils_1.convertHttpResponse),
471
471
  /**
472
472
  * @description Get the ALPH reserved supply
473
473
  *
@@ -480,7 +480,7 @@ class Api extends HttpClient {
480
480
  method: 'GET',
481
481
  format: 'text',
482
482
  ...params
483
- }).then(utils_1.convertTextHttpResponse),
483
+ }).then(utils_1.convertHttpResponse),
484
484
  /**
485
485
  * @description Get the ALPH locked supply
486
486
  *
@@ -493,7 +493,7 @@ class Api extends HttpClient {
493
493
  method: 'GET',
494
494
  format: 'text',
495
495
  ...params
496
- }).then(utils_1.convertTextHttpResponse),
496
+ }).then(utils_1.convertHttpResponse),
497
497
  /**
498
498
  * @description Get the total number of transactions
499
499
  *
@@ -506,7 +506,7 @@ class Api extends HttpClient {
506
506
  method: 'GET',
507
507
  format: 'text',
508
508
  ...params
509
- }).then(utils_1.convertTextHttpResponse),
509
+ }).then(utils_1.convertHttpResponse),
510
510
  /**
511
511
  * @description Get the average block time for each chain
512
512
  *
@@ -5,12 +5,6 @@ export declare function convertHttpResponse<T>(response: {
5
5
  detail: string;
6
6
  };
7
7
  }): T;
8
- export declare function convertTextHttpResponse(response: {
9
- text: () => Promise<string>;
10
- error?: {
11
- detail: string;
12
- };
13
- }): Promise<string>;
14
8
  export declare function retryFetch(...fetchParams: Parameters<typeof fetch>): ReturnType<typeof fetch>;
15
9
  export declare function throttledFetch(ratePerSec: number): typeof fetch;
16
10
  export declare const RETRY_LIMIT_WHEN_429 = 3;
@@ -17,7 +17,7 @@ You should have received a copy of the GNU Lesser General Public License
17
17
  along with the library. If not, see <http://www.gnu.org/licenses/>.
18
18
  */
19
19
  Object.defineProperty(exports, "__esModule", { value: true });
20
- exports.DEFAULT_THROTTLE_FETCH = exports.DEFAULT_RATE_LIMIT = exports.RETRY_LIMIT_WHEN_429 = exports.throttledFetch = exports.retryFetch = exports.convertTextHttpResponse = exports.convertHttpResponse = void 0;
20
+ exports.DEFAULT_THROTTLE_FETCH = exports.DEFAULT_RATE_LIMIT = exports.RETRY_LIMIT_WHEN_429 = exports.throttledFetch = exports.retryFetch = exports.convertHttpResponse = void 0;
21
21
  require("cross-fetch/polyfill");
22
22
  const utils_1 = require("../utils");
23
23
  const async_sema_1 = require("async-sema");
@@ -30,15 +30,6 @@ function convertHttpResponse(response) {
30
30
  }
31
31
  }
32
32
  exports.convertHttpResponse = convertHttpResponse;
33
- async function convertTextHttpResponse(response) {
34
- if (response.error) {
35
- throw new Error(`[API Error] - ${response.error.detail}`);
36
- }
37
- else {
38
- return await response.text();
39
- }
40
- }
41
- exports.convertTextHttpResponse = convertTextHttpResponse;
42
33
  async function retryFetch(...fetchParams) {
43
34
  const retry = async (retryCount) => {
44
35
  const response = await fetch(...fetchParams);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alephium/web3",
3
- "version": "0.12.1",
3
+ "version": "0.12.2",
4
4
  "description": "A JS/TS library to interact with the Alephium platform",
5
5
  "license": "GPL",
6
6
  "main": "dist/src/index.js",
@@ -346,7 +346,7 @@ export interface ValU256 {
346
346
  }
347
347
 
348
348
  import 'cross-fetch/polyfill'
349
- import { convertHttpResponse, convertTextHttpResponse } from './utils'
349
+ import { convertHttpResponse } from './utils'
350
350
 
351
351
  export type QueryParamsType = Record<string | number, any>
352
352
  export type ResponseFormat = keyof Omit<Body, 'body' | 'bodyUsed'>
@@ -962,7 +962,7 @@ export class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDa
962
962
  query: query,
963
963
  format: 'text',
964
964
  ...params
965
- }).then(convertTextHttpResponse),
965
+ }).then(convertHttpResponse),
966
966
 
967
967
  /**
968
968
  * No description
@@ -1072,7 +1072,7 @@ export class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDa
1072
1072
  method: 'GET',
1073
1073
  format: 'text',
1074
1074
  ...params
1075
- }).then(convertTextHttpResponse),
1075
+ }).then(convertHttpResponse),
1076
1076
 
1077
1077
  /**
1078
1078
  * @description Get the ALPH circulating supply
@@ -1087,7 +1087,7 @@ export class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDa
1087
1087
  method: 'GET',
1088
1088
  format: 'text',
1089
1089
  ...params
1090
- }).then(convertTextHttpResponse),
1090
+ }).then(convertHttpResponse),
1091
1091
 
1092
1092
  /**
1093
1093
  * @description Get the ALPH reserved supply
@@ -1102,7 +1102,7 @@ export class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDa
1102
1102
  method: 'GET',
1103
1103
  format: 'text',
1104
1104
  ...params
1105
- }).then(convertTextHttpResponse),
1105
+ }).then(convertHttpResponse),
1106
1106
 
1107
1107
  /**
1108
1108
  * @description Get the ALPH locked supply
@@ -1117,7 +1117,7 @@ export class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDa
1117
1117
  method: 'GET',
1118
1118
  format: 'text',
1119
1119
  ...params
1120
- }).then(convertTextHttpResponse),
1120
+ }).then(convertHttpResponse),
1121
1121
 
1122
1122
  /**
1123
1123
  * @description Get the total number of transactions
@@ -1132,7 +1132,7 @@ export class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDa
1132
1132
  method: 'GET',
1133
1133
  format: 'text',
1134
1134
  ...params
1135
- }).then(convertTextHttpResponse),
1135
+ }).then(convertHttpResponse),
1136
1136
 
1137
1137
  /**
1138
1138
  * @description Get the average block time for each chain
package/src/api/utils.ts CHANGED
@@ -28,17 +28,6 @@ export function convertHttpResponse<T>(response: { data: T; error?: { detail: st
28
28
  }
29
29
  }
30
30
 
31
- export async function convertTextHttpResponse(response: {
32
- text: () => Promise<string>
33
- error?: { detail: string }
34
- }): Promise<string> {
35
- if (response.error) {
36
- throw new Error(`[API Error] - ${response.error.detail}`)
37
- } else {
38
- return await response.text()
39
- }
40
- }
41
-
42
31
  export async function retryFetch(...fetchParams: Parameters<typeof fetch>): ReturnType<typeof fetch> {
43
32
  const retry = async (retryCount: number): ReturnType<typeof fetch> => {
44
33
  const response = await fetch(...fetchParams)