@alephium/web3 0.12.0 → 0.12.1
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/alephium-web3.min.js +1 -1
- package/dist/alephium-web3.min.js.map +1 -1
- package/dist/src/api/api-explorer.d.ts +5 -5
- package/dist/src/api/api-explorer.js +12 -6
- package/dist/src/api/utils.d.ts +6 -0
- package/dist/src/api/utils.js +10 -1
- package/package.json +1 -1
- package/src/api/api-explorer.ts +13 -7
- package/src/api/utils.ts +11 -0
|
@@ -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<
|
|
672
|
+
getInfosSupplyTotalAlph: (params?: RequestParams) => Promise<string>;
|
|
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<
|
|
680
|
+
getInfosSupplyCirculatingAlph: (params?: RequestParams) => Promise<string>;
|
|
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<
|
|
688
|
+
getInfosSupplyReservedAlph: (params?: RequestParams) => Promise<string>;
|
|
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<
|
|
696
|
+
getInfosSupplyLockedAlph: (params?: RequestParams) => Promise<string>;
|
|
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<
|
|
704
|
+
getInfosTotalTransactions: (params?: RequestParams) => Promise<string>;
|
|
705
705
|
/**
|
|
706
706
|
* @description Get the average block time for each chain
|
|
707
707
|
*
|
|
@@ -383,8 +383,9 @@ class Api extends HttpClient {
|
|
|
383
383
|
path: `/addresses/${address}/export-transactions/csv`,
|
|
384
384
|
method: 'GET',
|
|
385
385
|
query: query,
|
|
386
|
+
format: 'text',
|
|
386
387
|
...params
|
|
387
|
-
}).then(utils_1.
|
|
388
|
+
}).then(utils_1.convertTextHttpResponse),
|
|
388
389
|
/**
|
|
389
390
|
* No description
|
|
390
391
|
*
|
|
@@ -451,8 +452,9 @@ class Api extends HttpClient {
|
|
|
451
452
|
getInfosSupplyTotalAlph: (params = {}) => this.request({
|
|
452
453
|
path: `/infos/supply/total-alph`,
|
|
453
454
|
method: 'GET',
|
|
455
|
+
format: 'text',
|
|
454
456
|
...params
|
|
455
|
-
}).then(utils_1.
|
|
457
|
+
}).then(utils_1.convertTextHttpResponse),
|
|
456
458
|
/**
|
|
457
459
|
* @description Get the ALPH circulating supply
|
|
458
460
|
*
|
|
@@ -463,8 +465,9 @@ class Api extends HttpClient {
|
|
|
463
465
|
getInfosSupplyCirculatingAlph: (params = {}) => this.request({
|
|
464
466
|
path: `/infos/supply/circulating-alph`,
|
|
465
467
|
method: 'GET',
|
|
468
|
+
format: 'text',
|
|
466
469
|
...params
|
|
467
|
-
}).then(utils_1.
|
|
470
|
+
}).then(utils_1.convertTextHttpResponse),
|
|
468
471
|
/**
|
|
469
472
|
* @description Get the ALPH reserved supply
|
|
470
473
|
*
|
|
@@ -475,8 +478,9 @@ class Api extends HttpClient {
|
|
|
475
478
|
getInfosSupplyReservedAlph: (params = {}) => this.request({
|
|
476
479
|
path: `/infos/supply/reserved-alph`,
|
|
477
480
|
method: 'GET',
|
|
481
|
+
format: 'text',
|
|
478
482
|
...params
|
|
479
|
-
}).then(utils_1.
|
|
483
|
+
}).then(utils_1.convertTextHttpResponse),
|
|
480
484
|
/**
|
|
481
485
|
* @description Get the ALPH locked supply
|
|
482
486
|
*
|
|
@@ -487,8 +491,9 @@ class Api extends HttpClient {
|
|
|
487
491
|
getInfosSupplyLockedAlph: (params = {}) => this.request({
|
|
488
492
|
path: `/infos/supply/locked-alph`,
|
|
489
493
|
method: 'GET',
|
|
494
|
+
format: 'text',
|
|
490
495
|
...params
|
|
491
|
-
}).then(utils_1.
|
|
496
|
+
}).then(utils_1.convertTextHttpResponse),
|
|
492
497
|
/**
|
|
493
498
|
* @description Get the total number of transactions
|
|
494
499
|
*
|
|
@@ -499,8 +504,9 @@ class Api extends HttpClient {
|
|
|
499
504
|
getInfosTotalTransactions: (params = {}) => this.request({
|
|
500
505
|
path: `/infos/total-transactions`,
|
|
501
506
|
method: 'GET',
|
|
507
|
+
format: 'text',
|
|
502
508
|
...params
|
|
503
|
-
}).then(utils_1.
|
|
509
|
+
}).then(utils_1.convertTextHttpResponse),
|
|
504
510
|
/**
|
|
505
511
|
* @description Get the average block time for each chain
|
|
506
512
|
*
|
package/dist/src/api/utils.d.ts
CHANGED
|
@@ -5,6 +5,12 @@ 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>;
|
|
8
14
|
export declare function retryFetch(...fetchParams: Parameters<typeof fetch>): ReturnType<typeof fetch>;
|
|
9
15
|
export declare function throttledFetch(ratePerSec: number): typeof fetch;
|
|
10
16
|
export declare const RETRY_LIMIT_WHEN_429 = 3;
|
package/dist/src/api/utils.js
CHANGED
|
@@ -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.convertHttpResponse = void 0;
|
|
20
|
+
exports.DEFAULT_THROTTLE_FETCH = exports.DEFAULT_RATE_LIMIT = exports.RETRY_LIMIT_WHEN_429 = exports.throttledFetch = exports.retryFetch = exports.convertTextHttpResponse = 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,6 +30,15 @@ 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;
|
|
33
42
|
async function retryFetch(...fetchParams) {
|
|
34
43
|
const retry = async (retryCount) => {
|
|
35
44
|
const response = await fetch(...fetchParams);
|
package/package.json
CHANGED
package/src/api/api-explorer.ts
CHANGED
|
@@ -346,7 +346,7 @@ export interface ValU256 {
|
|
|
346
346
|
}
|
|
347
347
|
|
|
348
348
|
import 'cross-fetch/polyfill'
|
|
349
|
-
import { convertHttpResponse } from './utils'
|
|
349
|
+
import { convertHttpResponse, convertTextHttpResponse } from './utils'
|
|
350
350
|
|
|
351
351
|
export type QueryParamsType = Record<string | number, any>
|
|
352
352
|
export type ResponseFormat = keyof Omit<Body, 'body' | 'bodyUsed'>
|
|
@@ -960,8 +960,9 @@ export class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDa
|
|
|
960
960
|
path: `/addresses/${address}/export-transactions/csv`,
|
|
961
961
|
method: 'GET',
|
|
962
962
|
query: query,
|
|
963
|
+
format: 'text',
|
|
963
964
|
...params
|
|
964
|
-
}).then(
|
|
965
|
+
}).then(convertTextHttpResponse),
|
|
965
966
|
|
|
966
967
|
/**
|
|
967
968
|
* No description
|
|
@@ -1069,8 +1070,9 @@ export class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDa
|
|
|
1069
1070
|
this.request<number, BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable>({
|
|
1070
1071
|
path: `/infos/supply/total-alph`,
|
|
1071
1072
|
method: 'GET',
|
|
1073
|
+
format: 'text',
|
|
1072
1074
|
...params
|
|
1073
|
-
}).then(
|
|
1075
|
+
}).then(convertTextHttpResponse),
|
|
1074
1076
|
|
|
1075
1077
|
/**
|
|
1076
1078
|
* @description Get the ALPH circulating supply
|
|
@@ -1083,8 +1085,9 @@ export class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDa
|
|
|
1083
1085
|
this.request<number, BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable>({
|
|
1084
1086
|
path: `/infos/supply/circulating-alph`,
|
|
1085
1087
|
method: 'GET',
|
|
1088
|
+
format: 'text',
|
|
1086
1089
|
...params
|
|
1087
|
-
}).then(
|
|
1090
|
+
}).then(convertTextHttpResponse),
|
|
1088
1091
|
|
|
1089
1092
|
/**
|
|
1090
1093
|
* @description Get the ALPH reserved supply
|
|
@@ -1097,8 +1100,9 @@ export class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDa
|
|
|
1097
1100
|
this.request<number, BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable>({
|
|
1098
1101
|
path: `/infos/supply/reserved-alph`,
|
|
1099
1102
|
method: 'GET',
|
|
1103
|
+
format: 'text',
|
|
1100
1104
|
...params
|
|
1101
|
-
}).then(
|
|
1105
|
+
}).then(convertTextHttpResponse),
|
|
1102
1106
|
|
|
1103
1107
|
/**
|
|
1104
1108
|
* @description Get the ALPH locked supply
|
|
@@ -1111,8 +1115,9 @@ export class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDa
|
|
|
1111
1115
|
this.request<number, BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable>({
|
|
1112
1116
|
path: `/infos/supply/locked-alph`,
|
|
1113
1117
|
method: 'GET',
|
|
1118
|
+
format: 'text',
|
|
1114
1119
|
...params
|
|
1115
|
-
}).then(
|
|
1120
|
+
}).then(convertTextHttpResponse),
|
|
1116
1121
|
|
|
1117
1122
|
/**
|
|
1118
1123
|
* @description Get the total number of transactions
|
|
@@ -1125,8 +1130,9 @@ export class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDa
|
|
|
1125
1130
|
this.request<number, BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable>({
|
|
1126
1131
|
path: `/infos/total-transactions`,
|
|
1127
1132
|
method: 'GET',
|
|
1133
|
+
format: 'text',
|
|
1128
1134
|
...params
|
|
1129
|
-
}).then(
|
|
1135
|
+
}).then(convertTextHttpResponse),
|
|
1130
1136
|
|
|
1131
1137
|
/**
|
|
1132
1138
|
* @description Get the average block time for each chain
|
package/src/api/utils.ts
CHANGED
|
@@ -28,6 +28,17 @@ 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
|
+
|
|
31
42
|
export async function retryFetch(...fetchParams: Parameters<typeof fetch>): ReturnType<typeof fetch> {
|
|
32
43
|
const retry = async (retryCount: number): ReturnType<typeof fetch> => {
|
|
33
44
|
const response = await fetch(...fetchParams)
|