@alephium/web3 0.5.0-rc.8 → 0.5.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/alephium-web3.min.js +1 -1
- package/dist/alephium-web3.min.js.LICENSE.txt +2 -0
- package/dist/alephium-web3.min.js.map +1 -1
- package/dist/src/api/api-alephium.d.ts +56 -6
- package/dist/src/api/api-alephium.js +5 -3
- package/dist/src/api/api-explorer.d.ts +222 -52
- package/dist/src/api/api-explorer.js +17 -15
- package/dist/src/api/explorer-provider.d.ts +18 -0
- package/dist/src/api/explorer-provider.js +65 -0
- package/dist/src/api/index.d.ts +2 -42
- package/dist/src/api/index.js +6 -117
- package/dist/src/api/node-provider.d.ts +21 -0
- package/dist/src/api/node-provider.js +68 -0
- package/dist/src/api/types.d.ts +9 -1
- package/dist/src/api/types.js +17 -1
- package/dist/src/contract/contract.d.ts +6 -3
- package/dist/src/contract/contract.js +31 -28
- package/dist/src/signer/signer.d.ts +4 -8
- package/dist/src/signer/signer.js +26 -8
- package/dist/src/signer/types.d.ts +4 -16
- package/dist/src/utils/index.d.ts +1 -0
- package/dist/src/utils/index.js +1 -0
- package/dist/src/utils/number.d.ts +18 -0
- package/dist/src/utils/number.fixture.d.ts +12 -0
- package/dist/src/utils/number.fixture.js +189 -0
- package/dist/src/utils/number.js +148 -0
- package/dist/src/utils/sign.js +15 -3
- package/package.json +7 -5
- package/src/api/api-alephium.ts +177 -180
- package/src/api/api-explorer.ts +327 -126
- package/src/api/explorer-provider.ts +78 -0
- package/src/api/index.ts +2 -148
- package/src/api/node-provider.ts +84 -0
- package/src/api/types.ts +24 -1
- package/src/contract/contract.ts +31 -29
- package/src/signer/signer.ts +33 -26
- package/src/signer/types.ts +12 -9
- package/src/utils/index.ts +1 -0
- package/src/utils/number.fixture.ts +187 -0
- package/src/utils/number.ts +162 -0
- package/src/utils/sign.ts +16 -3
- package/dist/b7fcfab78f8ae7713cfe.module.wasm +0 -0
|
@@ -141,6 +141,7 @@ export interface BrokerInfo {
|
|
|
141
141
|
/** @format inet-socket-address */
|
|
142
142
|
address: {
|
|
143
143
|
addr: string;
|
|
144
|
+
/** @format int32 */
|
|
144
145
|
port: number;
|
|
145
146
|
};
|
|
146
147
|
}
|
|
@@ -514,6 +515,7 @@ export interface InterCliquePeerInfo {
|
|
|
514
515
|
/** @format inet-socket-address */
|
|
515
516
|
address: {
|
|
516
517
|
addr: string;
|
|
518
|
+
/** @format int32 */
|
|
517
519
|
port: number;
|
|
518
520
|
};
|
|
519
521
|
isSynced: boolean;
|
|
@@ -545,6 +547,7 @@ export interface NodeInfo {
|
|
|
545
547
|
/** @format inet-socket-address */
|
|
546
548
|
externalAddress?: {
|
|
547
549
|
addr: string;
|
|
550
|
+
/** @format int32 */
|
|
548
551
|
port: number;
|
|
549
552
|
};
|
|
550
553
|
}
|
|
@@ -892,7 +895,8 @@ declare type CancelToken = Symbol | string | number;
|
|
|
892
895
|
export declare enum ContentType {
|
|
893
896
|
Json = "application/json",
|
|
894
897
|
FormData = "multipart/form-data",
|
|
895
|
-
UrlEncoded = "application/x-www-form-urlencoded"
|
|
898
|
+
UrlEncoded = "application/x-www-form-urlencoded",
|
|
899
|
+
Text = "text/plain"
|
|
896
900
|
}
|
|
897
901
|
export declare class HttpClient<SecurityDataType = unknown> {
|
|
898
902
|
baseUrl: string;
|
|
@@ -903,14 +907,14 @@ export declare class HttpClient<SecurityDataType = unknown> {
|
|
|
903
907
|
private baseApiParams;
|
|
904
908
|
constructor(apiConfig?: ApiConfig<SecurityDataType>);
|
|
905
909
|
setSecurityData: (data: SecurityDataType | null) => void;
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
910
|
+
protected encodeQueryParam(key: string, value: any): string;
|
|
911
|
+
protected addQueryParam(query: QueryParamsType, key: string): string;
|
|
912
|
+
protected addArrayQueryParam(query: QueryParamsType, key: string): any;
|
|
909
913
|
protected toQueryString(rawQuery?: QueryParamsType): string;
|
|
910
914
|
protected addQueryParams(rawQuery?: QueryParamsType): string;
|
|
911
915
|
private contentFormatters;
|
|
912
|
-
|
|
913
|
-
|
|
916
|
+
protected mergeRequestParams(params1: RequestParams, params2?: RequestParams): RequestParams;
|
|
917
|
+
protected createAbortSignal: (cancelToken: CancelToken) => AbortSignal | undefined;
|
|
914
918
|
abortRequest: (cancelToken: CancelToken) => void;
|
|
915
919
|
request: <T = any, E = any>({ body, secure, path, type, query, format, baseUrl, cancelToken, ...params }: FullRequestParams) => Promise<HttpResponse<T, E>>;
|
|
916
920
|
}
|
|
@@ -1074,6 +1078,7 @@ export declare class Api<SecurityDataType extends unknown> extends HttpClient<Se
|
|
|
1074
1078
|
* @request POST:/wallets/{wallet_name}/derive-next-address
|
|
1075
1079
|
*/
|
|
1076
1080
|
postWalletsWalletNameDeriveNextAddress: (walletName: string, query?: {
|
|
1081
|
+
/** @format int32 */
|
|
1077
1082
|
group?: number;
|
|
1078
1083
|
}, params?: RequestParams) => Promise<AddressInfo>;
|
|
1079
1084
|
/**
|
|
@@ -1195,7 +1200,15 @@ export declare class Api<SecurityDataType extends unknown> extends HttpClient<Se
|
|
|
1195
1200
|
* @request GET:/infos/history-hashrate
|
|
1196
1201
|
*/
|
|
1197
1202
|
getInfosHistoryHashrate: (query: {
|
|
1203
|
+
/**
|
|
1204
|
+
* @format int64
|
|
1205
|
+
* @min 0
|
|
1206
|
+
*/
|
|
1198
1207
|
fromTs: number;
|
|
1208
|
+
/**
|
|
1209
|
+
* @format int64
|
|
1210
|
+
* @min 0
|
|
1211
|
+
*/
|
|
1199
1212
|
toTs?: number;
|
|
1200
1213
|
}, params?: RequestParams) => Promise<string>;
|
|
1201
1214
|
/**
|
|
@@ -1207,6 +1220,10 @@ export declare class Api<SecurityDataType extends unknown> extends HttpClient<Se
|
|
|
1207
1220
|
* @request GET:/infos/current-hashrate
|
|
1208
1221
|
*/
|
|
1209
1222
|
getInfosCurrentHashrate: (query?: {
|
|
1223
|
+
/**
|
|
1224
|
+
* @format int64
|
|
1225
|
+
* @min 1
|
|
1226
|
+
*/
|
|
1210
1227
|
timespan?: number;
|
|
1211
1228
|
}, params?: RequestParams) => Promise<string>;
|
|
1212
1229
|
};
|
|
@@ -1220,7 +1237,15 @@ export declare class Api<SecurityDataType extends unknown> extends HttpClient<Se
|
|
|
1220
1237
|
* @request GET:/blockflow/blocks
|
|
1221
1238
|
*/
|
|
1222
1239
|
getBlockflowBlocks: (query: {
|
|
1240
|
+
/**
|
|
1241
|
+
* @format int64
|
|
1242
|
+
* @min 0
|
|
1243
|
+
*/
|
|
1223
1244
|
fromTs: number;
|
|
1245
|
+
/**
|
|
1246
|
+
* @format int64
|
|
1247
|
+
* @min 0
|
|
1248
|
+
*/
|
|
1224
1249
|
toTs?: number;
|
|
1225
1250
|
}, params?: RequestParams) => Promise<BlocksPerTimeStampRange>;
|
|
1226
1251
|
/**
|
|
@@ -1232,7 +1257,15 @@ export declare class Api<SecurityDataType extends unknown> extends HttpClient<Se
|
|
|
1232
1257
|
* @request GET:/blockflow/blocks-with-events
|
|
1233
1258
|
*/
|
|
1234
1259
|
getBlockflowBlocksWithEvents: (query: {
|
|
1260
|
+
/**
|
|
1261
|
+
* @format int64
|
|
1262
|
+
* @min 0
|
|
1263
|
+
*/
|
|
1235
1264
|
fromTs: number;
|
|
1265
|
+
/**
|
|
1266
|
+
* @format int64
|
|
1267
|
+
* @min 0
|
|
1268
|
+
*/
|
|
1236
1269
|
toTs?: number;
|
|
1237
1270
|
}, params?: RequestParams) => Promise<BlocksAndEventsPerTimeStampRange>;
|
|
1238
1271
|
/**
|
|
@@ -1273,8 +1306,11 @@ export declare class Api<SecurityDataType extends unknown> extends HttpClient<Se
|
|
|
1273
1306
|
* @request GET:/blockflow/hashes
|
|
1274
1307
|
*/
|
|
1275
1308
|
getBlockflowHashes: (query: {
|
|
1309
|
+
/** @format int32 */
|
|
1276
1310
|
fromGroup: number;
|
|
1311
|
+
/** @format int32 */
|
|
1277
1312
|
toGroup: number;
|
|
1313
|
+
/** @format int32 */
|
|
1278
1314
|
height: number;
|
|
1279
1315
|
}, params?: RequestParams) => Promise<HashesAtHeight>;
|
|
1280
1316
|
/**
|
|
@@ -1286,7 +1322,9 @@ export declare class Api<SecurityDataType extends unknown> extends HttpClient<Se
|
|
|
1286
1322
|
* @request GET:/blockflow/chain-info
|
|
1287
1323
|
*/
|
|
1288
1324
|
getBlockflowChainInfo: (query: {
|
|
1325
|
+
/** @format int32 */
|
|
1289
1326
|
fromGroup: number;
|
|
1327
|
+
/** @format int32 */
|
|
1290
1328
|
toGroup: number;
|
|
1291
1329
|
}, params?: RequestParams) => Promise<ChainInfo>;
|
|
1292
1330
|
/**
|
|
@@ -1374,7 +1412,9 @@ export declare class Api<SecurityDataType extends unknown> extends HttpClient<Se
|
|
|
1374
1412
|
* @request GET:/transactions/details/{txId}
|
|
1375
1413
|
*/
|
|
1376
1414
|
getTransactionsDetailsTxid: (txId: string, query?: {
|
|
1415
|
+
/** @format int32 */
|
|
1377
1416
|
fromGroup?: number;
|
|
1417
|
+
/** @format int32 */
|
|
1378
1418
|
toGroup?: number;
|
|
1379
1419
|
}, params?: RequestParams) => Promise<Transaction>;
|
|
1380
1420
|
/**
|
|
@@ -1387,7 +1427,9 @@ export declare class Api<SecurityDataType extends unknown> extends HttpClient<Se
|
|
|
1387
1427
|
*/
|
|
1388
1428
|
getTransactionsStatus: (query: {
|
|
1389
1429
|
txId: string;
|
|
1430
|
+
/** @format int32 */
|
|
1390
1431
|
fromGroup?: number;
|
|
1432
|
+
/** @format int32 */
|
|
1391
1433
|
toGroup?: number;
|
|
1392
1434
|
}, params?: RequestParams) => Promise<Confirmed | MemPooled | TxNotFound>;
|
|
1393
1435
|
};
|
|
@@ -1486,6 +1528,7 @@ export declare class Api<SecurityDataType extends unknown> extends HttpClient<Se
|
|
|
1486
1528
|
* @request GET:/contracts/{address}/state
|
|
1487
1529
|
*/
|
|
1488
1530
|
getContractsAddressState: (address: string, query: {
|
|
1531
|
+
/** @format int32 */
|
|
1489
1532
|
group: number;
|
|
1490
1533
|
}, params?: RequestParams) => Promise<ContractState>;
|
|
1491
1534
|
/**
|
|
@@ -1577,7 +1620,9 @@ export declare class Api<SecurityDataType extends unknown> extends HttpClient<Se
|
|
|
1577
1620
|
* @request POST:/miners/cpu-mining/mine-one-block
|
|
1578
1621
|
*/
|
|
1579
1622
|
postMinersCpuMiningMineOneBlock: (query: {
|
|
1623
|
+
/** @format int32 */
|
|
1580
1624
|
fromGroup: number;
|
|
1625
|
+
/** @format int32 */
|
|
1581
1626
|
toGroup: number;
|
|
1582
1627
|
}, params?: RequestParams) => Promise<boolean>;
|
|
1583
1628
|
/**
|
|
@@ -1609,8 +1654,11 @@ export declare class Api<SecurityDataType extends unknown> extends HttpClient<Se
|
|
|
1609
1654
|
* @request GET:/events/contract/{contractAddress}
|
|
1610
1655
|
*/
|
|
1611
1656
|
getEventsContractContractaddress: (contractAddress: string, query: {
|
|
1657
|
+
/** @format int32 */
|
|
1612
1658
|
start: number;
|
|
1659
|
+
/** @format int32 */
|
|
1613
1660
|
limit?: number;
|
|
1661
|
+
/** @format int32 */
|
|
1614
1662
|
group?: number;
|
|
1615
1663
|
}, params?: RequestParams) => Promise<ContractEvents>;
|
|
1616
1664
|
/**
|
|
@@ -1631,6 +1679,7 @@ export declare class Api<SecurityDataType extends unknown> extends HttpClient<Se
|
|
|
1631
1679
|
* @request GET:/events/tx-id/{txId}
|
|
1632
1680
|
*/
|
|
1633
1681
|
getEventsTxIdTxid: (txId: string, query?: {
|
|
1682
|
+
/** @format int32 */
|
|
1634
1683
|
group?: number;
|
|
1635
1684
|
}, params?: RequestParams) => Promise<ContractEventsByTxId>;
|
|
1636
1685
|
/**
|
|
@@ -1642,6 +1691,7 @@ export declare class Api<SecurityDataType extends unknown> extends HttpClient<Se
|
|
|
1642
1691
|
* @request GET:/events/block-hash/{blockHash}
|
|
1643
1692
|
*/
|
|
1644
1693
|
getEventsBlockHashBlockhash: (blockHash: string, query?: {
|
|
1694
|
+
/** @format int32 */
|
|
1645
1695
|
group?: number;
|
|
1646
1696
|
}, params?: RequestParams) => Promise<ContractEventsByBlockHash>;
|
|
1647
1697
|
};
|
|
@@ -18,6 +18,7 @@ var ContentType;
|
|
|
18
18
|
ContentType["Json"] = "application/json";
|
|
19
19
|
ContentType["FormData"] = "multipart/form-data";
|
|
20
20
|
ContentType["UrlEncoded"] = "application/x-www-form-urlencoded";
|
|
21
|
+
ContentType["Text"] = "text/plain";
|
|
21
22
|
})(ContentType = exports.ContentType || (exports.ContentType = {}));
|
|
22
23
|
class HttpClient {
|
|
23
24
|
constructor(apiConfig = {}) {
|
|
@@ -36,6 +37,7 @@ class HttpClient {
|
|
|
36
37
|
};
|
|
37
38
|
this.contentFormatters = {
|
|
38
39
|
[ContentType.Json]: (input) => input !== null && (typeof input === 'object' || typeof input === 'string') ? JSON.stringify(input) : input,
|
|
40
|
+
[ContentType.Text]: (input) => (input !== null && typeof input !== 'string' ? JSON.stringify(input) : input),
|
|
39
41
|
[ContentType.FormData]: (input) => Object.keys(input || {}).reduce((formData, key) => {
|
|
40
42
|
const property = input[key];
|
|
41
43
|
formData.append(key, property instanceof Blob
|
|
@@ -78,10 +80,10 @@ class HttpClient {
|
|
|
78
80
|
return this.customFetch(`${baseUrl || this.baseUrl || ''}${path}${queryString ? `?${queryString}` : ''}`, {
|
|
79
81
|
...requestParams,
|
|
80
82
|
headers: {
|
|
81
|
-
...(
|
|
82
|
-
...(
|
|
83
|
+
...(requestParams.headers || {}),
|
|
84
|
+
...(type && type !== ContentType.FormData ? { 'Content-Type': type } : {})
|
|
83
85
|
},
|
|
84
|
-
signal: cancelToken ? this.createAbortSignal(cancelToken) :
|
|
86
|
+
signal: cancelToken ? this.createAbortSignal(cancelToken) : requestParams.signal,
|
|
85
87
|
body: typeof body === 'undefined' || body === null ? null : payloadFormatter(body)
|
|
86
88
|
}).then(async (response) => {
|
|
87
89
|
const r = response;
|