@alephium/web3 0.5.0-rc.2 → 0.5.0-rc.20
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 +113 -26
- package/dist/src/api/api-alephium.js +62 -18
- 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 -41
- package/dist/src/api/index.js +6 -116
- 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 +10 -2
- package/dist/src/api/types.js +23 -3
- package/dist/src/contract/contract.d.ts +15 -7
- package/dist/src/contract/contract.js +62 -42
- package/dist/src/signer/signer.d.ts +25 -30
- package/dist/src/signer/signer.js +57 -30
- package/dist/src/signer/tx-builder.d.ts +2 -7
- package/dist/src/signer/tx-builder.js +10 -7
- package/dist/src/signer/types.d.ts +12 -16
- package/dist/src/transaction/sign-verify.d.ts +3 -2
- package/dist/src/transaction/sign-verify.js +4 -14
- package/dist/src/utils/index.d.ts +2 -0
- package/dist/src/utils/index.js +2 -0
- package/dist/src/utils/number.d.ts +17 -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 +144 -0
- package/dist/src/utils/sign.d.ts +3 -0
- package/dist/src/utils/sign.js +89 -0
- package/dist/src/utils/utils.d.ts +4 -3
- package/dist/src/utils/utils.js +25 -10
- package/package.json +7 -5
- package/src/api/api-alephium.ts +260 -207
- package/src/api/api-explorer.ts +327 -126
- package/src/api/explorer-provider.ts +78 -0
- package/src/api/index.ts +2 -146
- package/src/api/node-provider.ts +84 -0
- package/src/api/types.ts +36 -3
- package/src/contract/contract.ts +80 -49
- package/src/signer/signer.ts +87 -66
- package/src/signer/tx-builder.ts +13 -7
- package/src/signer/types.ts +22 -11
- package/src/transaction/sign-verify.ts +10 -15
- package/src/utils/index.ts +2 -0
- package/src/utils/number.fixture.ts +187 -0
- package/src/utils/number.ts +158 -0
- package/src/utils/sign.ts +66 -0
- package/src/utils/utils.ts +26 -10
|
@@ -1,3 +1,19 @@
|
|
|
1
|
+
export interface AcceptedTransaction {
|
|
2
|
+
/** @format 32-byte-hash */
|
|
3
|
+
hash: string;
|
|
4
|
+
/** @format block-hash */
|
|
5
|
+
blockHash: string;
|
|
6
|
+
/** @format int64 */
|
|
7
|
+
timestamp: number;
|
|
8
|
+
inputs?: Input[];
|
|
9
|
+
outputs?: Output[];
|
|
10
|
+
/** @format int32 */
|
|
11
|
+
gasAmount: number;
|
|
12
|
+
/** @format uint256 */
|
|
13
|
+
gasPrice: string;
|
|
14
|
+
coinbase: boolean;
|
|
15
|
+
type: string;
|
|
16
|
+
}
|
|
1
17
|
export interface AddressBalance {
|
|
2
18
|
/** @format uint256 */
|
|
3
19
|
balance: string;
|
|
@@ -19,6 +35,7 @@ export interface AssetOutput {
|
|
|
19
35
|
key: string;
|
|
20
36
|
/** @format uint256 */
|
|
21
37
|
attoAlphAmount: string;
|
|
38
|
+
/** @format address */
|
|
22
39
|
address: string;
|
|
23
40
|
tokens?: Token[];
|
|
24
41
|
/** @format int64 */
|
|
@@ -49,22 +66,6 @@ export interface BlockEntryLite {
|
|
|
49
66
|
/** @format bigint */
|
|
50
67
|
hashRate: string;
|
|
51
68
|
}
|
|
52
|
-
export interface ConfirmedTransaction {
|
|
53
|
-
/** @format 32-byte-hash */
|
|
54
|
-
hash: string;
|
|
55
|
-
/** @format block-hash */
|
|
56
|
-
blockHash: string;
|
|
57
|
-
/** @format int64 */
|
|
58
|
-
timestamp: number;
|
|
59
|
-
inputs?: Input[];
|
|
60
|
-
outputs?: Output[];
|
|
61
|
-
/** @format int32 */
|
|
62
|
-
gasAmount: number;
|
|
63
|
-
/** @format uint256 */
|
|
64
|
-
gasPrice: string;
|
|
65
|
-
coinbase: boolean;
|
|
66
|
-
type: string;
|
|
67
|
-
}
|
|
68
69
|
export interface ContractOutput {
|
|
69
70
|
/** @format int32 */
|
|
70
71
|
hint: number;
|
|
@@ -72,6 +73,7 @@ export interface ContractOutput {
|
|
|
72
73
|
key: string;
|
|
73
74
|
/** @format uint256 */
|
|
74
75
|
attoAlphAmount: string;
|
|
76
|
+
/** @format address */
|
|
75
77
|
address: string;
|
|
76
78
|
tokens?: Token[];
|
|
77
79
|
/** @format 32-byte-hash */
|
|
@@ -83,7 +85,9 @@ export interface Event {
|
|
|
83
85
|
blockHash: string;
|
|
84
86
|
/** @format 32-byte-hash */
|
|
85
87
|
txHash: string;
|
|
88
|
+
/** @format address */
|
|
86
89
|
contractAddress: string;
|
|
90
|
+
/** @format address */
|
|
87
91
|
inputAddress?: string;
|
|
88
92
|
/** @format int32 */
|
|
89
93
|
eventIndex: number;
|
|
@@ -105,6 +109,7 @@ export interface Input {
|
|
|
105
109
|
unlockScript?: string;
|
|
106
110
|
/** @format 32-byte-hash */
|
|
107
111
|
txHashRef?: string;
|
|
112
|
+
/** @format address */
|
|
108
113
|
address?: string;
|
|
109
114
|
/** @format uint256 */
|
|
110
115
|
attoAlphAmount?: string;
|
|
@@ -126,6 +131,22 @@ export interface LogbackValue {
|
|
|
126
131
|
name: string;
|
|
127
132
|
level: string;
|
|
128
133
|
}
|
|
134
|
+
export interface MempoolTransaction {
|
|
135
|
+
/** @format 32-byte-hash */
|
|
136
|
+
hash: string;
|
|
137
|
+
/** @format int32 */
|
|
138
|
+
chainFrom: number;
|
|
139
|
+
/** @format int32 */
|
|
140
|
+
chainTo: number;
|
|
141
|
+
inputs?: Input[];
|
|
142
|
+
outputs?: Output[];
|
|
143
|
+
/** @format int32 */
|
|
144
|
+
gasAmount: number;
|
|
145
|
+
/** @format uint256 */
|
|
146
|
+
gasPrice: string;
|
|
147
|
+
/** @format int64 */
|
|
148
|
+
lastSeen: number;
|
|
149
|
+
}
|
|
129
150
|
export interface NotFound {
|
|
130
151
|
detail: string;
|
|
131
152
|
resource: string;
|
|
@@ -137,6 +158,23 @@ export interface OutputRef {
|
|
|
137
158
|
/** @format 32-byte-hash */
|
|
138
159
|
key: string;
|
|
139
160
|
}
|
|
161
|
+
export interface PendingTransaction {
|
|
162
|
+
/** @format 32-byte-hash */
|
|
163
|
+
hash: string;
|
|
164
|
+
/** @format int32 */
|
|
165
|
+
chainFrom: number;
|
|
166
|
+
/** @format int32 */
|
|
167
|
+
chainTo: number;
|
|
168
|
+
inputs?: Input[];
|
|
169
|
+
outputs?: Output[];
|
|
170
|
+
/** @format int32 */
|
|
171
|
+
gasAmount: number;
|
|
172
|
+
/** @format uint256 */
|
|
173
|
+
gasPrice: string;
|
|
174
|
+
/** @format int64 */
|
|
175
|
+
lastSeen: number;
|
|
176
|
+
type: string;
|
|
177
|
+
}
|
|
140
178
|
export interface PerChainCount {
|
|
141
179
|
/** @format int32 */
|
|
142
180
|
chainFrom: number;
|
|
@@ -214,27 +252,10 @@ export interface Transaction {
|
|
|
214
252
|
gasPrice: string;
|
|
215
253
|
coinbase: boolean;
|
|
216
254
|
}
|
|
217
|
-
export declare type TransactionLike =
|
|
255
|
+
export declare type TransactionLike = AcceptedTransaction | PendingTransaction;
|
|
218
256
|
export interface Unauthorized {
|
|
219
257
|
detail: string;
|
|
220
258
|
}
|
|
221
|
-
export interface UnconfirmedTransaction {
|
|
222
|
-
/** @format 32-byte-hash */
|
|
223
|
-
hash: string;
|
|
224
|
-
/** @format int32 */
|
|
225
|
-
chainFrom: number;
|
|
226
|
-
/** @format int32 */
|
|
227
|
-
chainTo: number;
|
|
228
|
-
inputs?: Input[];
|
|
229
|
-
outputs?: Output[];
|
|
230
|
-
/** @format int32 */
|
|
231
|
-
gasAmount: number;
|
|
232
|
-
/** @format uint256 */
|
|
233
|
-
gasPrice: string;
|
|
234
|
-
/** @format int64 */
|
|
235
|
-
lastSeen: number;
|
|
236
|
-
type: string;
|
|
237
|
-
}
|
|
238
259
|
export declare type Val = ValAddress | ValArray | ValBool | ValByteVec | ValI256 | ValU256;
|
|
239
260
|
export interface ValAddress {
|
|
240
261
|
/** @format address */
|
|
@@ -300,7 +321,8 @@ declare type CancelToken = Symbol | string | number;
|
|
|
300
321
|
export declare enum ContentType {
|
|
301
322
|
Json = "application/json",
|
|
302
323
|
FormData = "multipart/form-data",
|
|
303
|
-
UrlEncoded = "application/x-www-form-urlencoded"
|
|
324
|
+
UrlEncoded = "application/x-www-form-urlencoded",
|
|
325
|
+
Text = "text/plain"
|
|
304
326
|
}
|
|
305
327
|
export declare class HttpClient<SecurityDataType = unknown> {
|
|
306
328
|
baseUrl: string;
|
|
@@ -311,14 +333,14 @@ export declare class HttpClient<SecurityDataType = unknown> {
|
|
|
311
333
|
private baseApiParams;
|
|
312
334
|
constructor(apiConfig?: ApiConfig<SecurityDataType>);
|
|
313
335
|
setSecurityData: (data: SecurityDataType | null) => void;
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
336
|
+
protected encodeQueryParam(key: string, value: any): string;
|
|
337
|
+
protected addQueryParam(query: QueryParamsType, key: string): string;
|
|
338
|
+
protected addArrayQueryParam(query: QueryParamsType, key: string): any;
|
|
317
339
|
protected toQueryString(rawQuery?: QueryParamsType): string;
|
|
318
340
|
protected addQueryParams(rawQuery?: QueryParamsType): string;
|
|
319
341
|
private contentFormatters;
|
|
320
|
-
|
|
321
|
-
|
|
342
|
+
protected mergeRequestParams(params1: RequestParams, params2?: RequestParams): RequestParams;
|
|
343
|
+
protected createAbortSignal: (cancelToken: CancelToken) => AbortSignal | undefined;
|
|
322
344
|
abortRequest: (cancelToken: CancelToken) => void;
|
|
323
345
|
request: <T = any, E = any>({ body, secure, path, type, query, format, baseUrl, cancelToken, ...params }: FullRequestParams) => Promise<HttpResponse<T, E>>;
|
|
324
346
|
}
|
|
@@ -336,8 +358,17 @@ export declare class Api<SecurityDataType extends unknown> extends HttpClient<Se
|
|
|
336
358
|
* @request GET:/blocks
|
|
337
359
|
*/
|
|
338
360
|
getBlocks: (query?: {
|
|
361
|
+
/**
|
|
362
|
+
* Page number
|
|
363
|
+
* @format int32
|
|
364
|
+
*/
|
|
339
365
|
page?: number;
|
|
366
|
+
/**
|
|
367
|
+
* Number of items per page
|
|
368
|
+
* @format int32
|
|
369
|
+
*/
|
|
340
370
|
limit?: number;
|
|
371
|
+
/** Reverse pagination */
|
|
341
372
|
reverse?: boolean;
|
|
342
373
|
}, params?: RequestParams) => Promise<ListBlocks>;
|
|
343
374
|
/**
|
|
@@ -356,8 +387,17 @@ export declare class Api<SecurityDataType extends unknown> extends HttpClient<Se
|
|
|
356
387
|
* @request GET:/blocks/{block_hash}/transactions
|
|
357
388
|
*/
|
|
358
389
|
getBlocksBlockHashTransactions: (blockHash: string, query?: {
|
|
390
|
+
/**
|
|
391
|
+
* Page number
|
|
392
|
+
* @format int32
|
|
393
|
+
*/
|
|
359
394
|
page?: number;
|
|
395
|
+
/**
|
|
396
|
+
* Number of items per page
|
|
397
|
+
* @format int32
|
|
398
|
+
*/
|
|
360
399
|
limit?: number;
|
|
400
|
+
/** Reverse pagination */
|
|
361
401
|
reverse?: boolean;
|
|
362
402
|
}, params?: RequestParams) => Promise<Transaction[]>;
|
|
363
403
|
};
|
|
@@ -369,7 +409,7 @@ export declare class Api<SecurityDataType extends unknown> extends HttpClient<Se
|
|
|
369
409
|
* @name GetTransactionsTransactionHash
|
|
370
410
|
* @request GET:/transactions/{transaction_hash}
|
|
371
411
|
*/
|
|
372
|
-
getTransactionsTransactionHash: (transactionHash: string, params?: RequestParams) => Promise<
|
|
412
|
+
getTransactionsTransactionHash: (transactionHash: string, params?: RequestParams) => Promise<AcceptedTransaction | PendingTransaction>;
|
|
373
413
|
};
|
|
374
414
|
addresses: {
|
|
375
415
|
/**
|
|
@@ -388,8 +428,17 @@ export declare class Api<SecurityDataType extends unknown> extends HttpClient<Se
|
|
|
388
428
|
* @request GET:/addresses/{address}/transactions
|
|
389
429
|
*/
|
|
390
430
|
getAddressesAddressTransactions: (address: string, query?: {
|
|
431
|
+
/**
|
|
432
|
+
* Page number
|
|
433
|
+
* @format int32
|
|
434
|
+
*/
|
|
391
435
|
page?: number;
|
|
436
|
+
/**
|
|
437
|
+
* Number of items per page
|
|
438
|
+
* @format int32
|
|
439
|
+
*/
|
|
392
440
|
limit?: number;
|
|
441
|
+
/** Reverse pagination */
|
|
393
442
|
reverse?: boolean;
|
|
394
443
|
}, params?: RequestParams) => Promise<Transaction[]>;
|
|
395
444
|
/**
|
|
@@ -400,8 +449,17 @@ export declare class Api<SecurityDataType extends unknown> extends HttpClient<Se
|
|
|
400
449
|
* @request POST:/addresses/transactions
|
|
401
450
|
*/
|
|
402
451
|
postAddressesTransactions: (query?: {
|
|
452
|
+
/**
|
|
453
|
+
* Page number
|
|
454
|
+
* @format int32
|
|
455
|
+
*/
|
|
403
456
|
page?: number;
|
|
457
|
+
/**
|
|
458
|
+
* Number of items per page
|
|
459
|
+
* @format int32
|
|
460
|
+
*/
|
|
404
461
|
limit?: number;
|
|
462
|
+
/** Reverse pagination */
|
|
405
463
|
reverse?: boolean;
|
|
406
464
|
}, data?: string[], params?: RequestParams) => Promise<Transaction[]>;
|
|
407
465
|
/**
|
|
@@ -412,10 +470,27 @@ export declare class Api<SecurityDataType extends unknown> extends HttpClient<Se
|
|
|
412
470
|
* @request GET:/addresses/{address}/timeranged-transactions
|
|
413
471
|
*/
|
|
414
472
|
getAddressesAddressTimerangedTransactions: (address: string, query: {
|
|
473
|
+
/**
|
|
474
|
+
* @format int64
|
|
475
|
+
* @min 0
|
|
476
|
+
*/
|
|
415
477
|
fromTs: number;
|
|
478
|
+
/**
|
|
479
|
+
* @format int64
|
|
480
|
+
* @min 0
|
|
481
|
+
*/
|
|
416
482
|
toTs: number;
|
|
483
|
+
/**
|
|
484
|
+
* Page number
|
|
485
|
+
* @format int32
|
|
486
|
+
*/
|
|
417
487
|
page?: number;
|
|
488
|
+
/**
|
|
489
|
+
* Number of items per page
|
|
490
|
+
* @format int32
|
|
491
|
+
*/
|
|
418
492
|
limit?: number;
|
|
493
|
+
/** Reverse pagination */
|
|
419
494
|
reverse?: boolean;
|
|
420
495
|
}, params?: RequestParams) => Promise<Transaction[]>;
|
|
421
496
|
/**
|
|
@@ -427,13 +502,13 @@ export declare class Api<SecurityDataType extends unknown> extends HttpClient<Se
|
|
|
427
502
|
*/
|
|
428
503
|
getAddressesAddressTotalTransactions: (address: string, params?: RequestParams) => Promise<number>;
|
|
429
504
|
/**
|
|
430
|
-
* @description List
|
|
505
|
+
* @description List mempool transactions of a given address
|
|
431
506
|
*
|
|
432
507
|
* @tags Addresses
|
|
433
|
-
* @name
|
|
434
|
-
* @request GET:/addresses/{address}/
|
|
508
|
+
* @name GetAddressesAddressMempoolTransactions
|
|
509
|
+
* @request GET:/addresses/{address}/mempool/transactions
|
|
435
510
|
*/
|
|
436
|
-
|
|
511
|
+
getAddressesAddressMempoolTransactions: (address: string, params?: RequestParams) => Promise<MempoolTransaction[]>;
|
|
437
512
|
/**
|
|
438
513
|
* @description Get address balance
|
|
439
514
|
*
|
|
@@ -458,8 +533,17 @@ export declare class Api<SecurityDataType extends unknown> extends HttpClient<Se
|
|
|
458
533
|
* @request GET:/addresses/{address}/tokens/{token_id}/transactions
|
|
459
534
|
*/
|
|
460
535
|
getAddressesAddressTokensTokenIdTransactions: (address: string, tokenId: string, query?: {
|
|
536
|
+
/**
|
|
537
|
+
* Page number
|
|
538
|
+
* @format int32
|
|
539
|
+
*/
|
|
461
540
|
page?: number;
|
|
541
|
+
/**
|
|
542
|
+
* Number of items per page
|
|
543
|
+
* @format int32
|
|
544
|
+
*/
|
|
462
545
|
limit?: number;
|
|
546
|
+
/** Reverse pagination */
|
|
463
547
|
reverse?: boolean;
|
|
464
548
|
}, params?: RequestParams) => Promise<Transaction[]>;
|
|
465
549
|
/**
|
|
@@ -486,7 +570,15 @@ export declare class Api<SecurityDataType extends unknown> extends HttpClient<Se
|
|
|
486
570
|
* @request GET:/addresses/{address}/export-transactions/csv
|
|
487
571
|
*/
|
|
488
572
|
getAddressesAddressExportTransactionsCsv: (address: string, query: {
|
|
573
|
+
/**
|
|
574
|
+
* @format int64
|
|
575
|
+
* @min 0
|
|
576
|
+
*/
|
|
489
577
|
fromTs: number;
|
|
578
|
+
/**
|
|
579
|
+
* @format int64
|
|
580
|
+
* @min 0
|
|
581
|
+
*/
|
|
490
582
|
toTs: number;
|
|
491
583
|
}, params?: RequestParams) => Promise<string>;
|
|
492
584
|
};
|
|
@@ -515,8 +607,17 @@ export declare class Api<SecurityDataType extends unknown> extends HttpClient<Se
|
|
|
515
607
|
* @request GET:/infos/supply
|
|
516
608
|
*/
|
|
517
609
|
getInfosSupply: (query?: {
|
|
610
|
+
/**
|
|
611
|
+
* Page number
|
|
612
|
+
* @format int32
|
|
613
|
+
*/
|
|
518
614
|
page?: number;
|
|
615
|
+
/**
|
|
616
|
+
* Number of items per page
|
|
617
|
+
* @format int32
|
|
618
|
+
*/
|
|
519
619
|
limit?: number;
|
|
620
|
+
/** Reverse pagination */
|
|
520
621
|
reverse?: boolean;
|
|
521
622
|
}, params?: RequestParams) => Promise<TokenSupply[]>;
|
|
522
623
|
/**
|
|
@@ -568,19 +669,28 @@ export declare class Api<SecurityDataType extends unknown> extends HttpClient<Se
|
|
|
568
669
|
*/
|
|
569
670
|
getInfosAverageBlockTimes: (params?: RequestParams) => Promise<PerChainDuration[]>;
|
|
570
671
|
};
|
|
571
|
-
|
|
672
|
+
mempool: {
|
|
572
673
|
/**
|
|
573
|
-
* @description list
|
|
674
|
+
* @description list mempool transactions
|
|
574
675
|
*
|
|
575
|
-
* @tags
|
|
576
|
-
* @name
|
|
577
|
-
* @request GET:/
|
|
676
|
+
* @tags Mempool
|
|
677
|
+
* @name GetMempoolTransactions
|
|
678
|
+
* @request GET:/mempool/transactions
|
|
578
679
|
*/
|
|
579
|
-
|
|
680
|
+
getMempoolTransactions: (query?: {
|
|
681
|
+
/**
|
|
682
|
+
* Page number
|
|
683
|
+
* @format int32
|
|
684
|
+
*/
|
|
580
685
|
page?: number;
|
|
686
|
+
/**
|
|
687
|
+
* Number of items per page
|
|
688
|
+
* @format int32
|
|
689
|
+
*/
|
|
581
690
|
limit?: number;
|
|
691
|
+
/** Reverse pagination */
|
|
582
692
|
reverse?: boolean;
|
|
583
|
-
}, params?: RequestParams) => Promise<
|
|
693
|
+
}, params?: RequestParams) => Promise<MempoolTransaction[]>;
|
|
584
694
|
};
|
|
585
695
|
tokens: {
|
|
586
696
|
/**
|
|
@@ -591,8 +701,17 @@ export declare class Api<SecurityDataType extends unknown> extends HttpClient<Se
|
|
|
591
701
|
* @request GET:/tokens
|
|
592
702
|
*/
|
|
593
703
|
getTokens: (query?: {
|
|
704
|
+
/**
|
|
705
|
+
* Page number
|
|
706
|
+
* @format int32
|
|
707
|
+
*/
|
|
594
708
|
page?: number;
|
|
709
|
+
/**
|
|
710
|
+
* Number of items per page
|
|
711
|
+
* @format int32
|
|
712
|
+
*/
|
|
595
713
|
limit?: number;
|
|
714
|
+
/** Reverse pagination */
|
|
596
715
|
reverse?: boolean;
|
|
597
716
|
}, params?: RequestParams) => Promise<string[]>;
|
|
598
717
|
/**
|
|
@@ -603,8 +722,17 @@ export declare class Api<SecurityDataType extends unknown> extends HttpClient<Se
|
|
|
603
722
|
* @request GET:/tokens/{token_id}/transactions
|
|
604
723
|
*/
|
|
605
724
|
getTokensTokenIdTransactions: (tokenId: string, query?: {
|
|
725
|
+
/**
|
|
726
|
+
* Page number
|
|
727
|
+
* @format int32
|
|
728
|
+
*/
|
|
606
729
|
page?: number;
|
|
730
|
+
/**
|
|
731
|
+
* Number of items per page
|
|
732
|
+
* @format int32
|
|
733
|
+
*/
|
|
607
734
|
limit?: number;
|
|
735
|
+
/** Reverse pagination */
|
|
608
736
|
reverse?: boolean;
|
|
609
737
|
}, params?: RequestParams) => Promise<Transaction[]>;
|
|
610
738
|
};
|
|
@@ -618,7 +746,15 @@ export declare class Api<SecurityDataType extends unknown> extends HttpClient<Se
|
|
|
618
746
|
* @request GET:/charts/hashrates
|
|
619
747
|
*/
|
|
620
748
|
getChartsHashrates: (query: {
|
|
749
|
+
/**
|
|
750
|
+
* @format int64
|
|
751
|
+
* @min 0
|
|
752
|
+
*/
|
|
621
753
|
fromTs: number;
|
|
754
|
+
/**
|
|
755
|
+
* @format int64
|
|
756
|
+
* @min 0
|
|
757
|
+
*/
|
|
622
758
|
toTs: number;
|
|
623
759
|
'interval-type': IntervalType;
|
|
624
760
|
}, params?: RequestParams) => Promise<Hashrate[]>;
|
|
@@ -631,7 +767,15 @@ export declare class Api<SecurityDataType extends unknown> extends HttpClient<Se
|
|
|
631
767
|
* @request GET:/charts/transactions-count
|
|
632
768
|
*/
|
|
633
769
|
getChartsTransactionsCount: (query: {
|
|
770
|
+
/**
|
|
771
|
+
* @format int64
|
|
772
|
+
* @min 0
|
|
773
|
+
*/
|
|
634
774
|
fromTs: number;
|
|
775
|
+
/**
|
|
776
|
+
* @format int64
|
|
777
|
+
* @min 0
|
|
778
|
+
*/
|
|
635
779
|
toTs: number;
|
|
636
780
|
'interval-type': IntervalType;
|
|
637
781
|
}, params?: RequestParams) => Promise<TimedCount[]>;
|
|
@@ -644,7 +788,15 @@ export declare class Api<SecurityDataType extends unknown> extends HttpClient<Se
|
|
|
644
788
|
* @request GET:/charts/transactions-count-per-chain
|
|
645
789
|
*/
|
|
646
790
|
getChartsTransactionsCountPerChain: (query: {
|
|
791
|
+
/**
|
|
792
|
+
* @format int64
|
|
793
|
+
* @min 0
|
|
794
|
+
*/
|
|
647
795
|
fromTs: number;
|
|
796
|
+
/**
|
|
797
|
+
* @format int64
|
|
798
|
+
* @min 0
|
|
799
|
+
*/
|
|
648
800
|
toTs: number;
|
|
649
801
|
'interval-type': IntervalType;
|
|
650
802
|
}, params?: RequestParams) => Promise<PerChainTimedCount[]>;
|
|
@@ -666,8 +818,17 @@ export declare class Api<SecurityDataType extends unknown> extends HttpClient<Se
|
|
|
666
818
|
* @request GET:/contract-events/contract-address/{contract_address}
|
|
667
819
|
*/
|
|
668
820
|
getContractEventsContractAddressContractAddress: (contractAddress: string, query?: {
|
|
821
|
+
/**
|
|
822
|
+
* Page number
|
|
823
|
+
* @format int32
|
|
824
|
+
*/
|
|
669
825
|
page?: number;
|
|
826
|
+
/**
|
|
827
|
+
* Number of items per page
|
|
828
|
+
* @format int32
|
|
829
|
+
*/
|
|
670
830
|
limit?: number;
|
|
831
|
+
/** Reverse pagination */
|
|
671
832
|
reverse?: boolean;
|
|
672
833
|
}, params?: RequestParams) => Promise<Event[]>;
|
|
673
834
|
/**
|
|
@@ -678,8 +839,17 @@ export declare class Api<SecurityDataType extends unknown> extends HttpClient<Se
|
|
|
678
839
|
* @request GET:/contract-events/contract-address/{contract_address}/input-address/{input_address}
|
|
679
840
|
*/
|
|
680
841
|
getContractEventsContractAddressContractAddressInputAddressInputAddress: (contractAddress: string, inputAddress: string, query?: {
|
|
842
|
+
/**
|
|
843
|
+
* Page number
|
|
844
|
+
* @format int32
|
|
845
|
+
*/
|
|
681
846
|
page?: number;
|
|
847
|
+
/**
|
|
848
|
+
* Number of items per page
|
|
849
|
+
* @format int32
|
|
850
|
+
*/
|
|
682
851
|
limit?: number;
|
|
852
|
+
/** Reverse pagination */
|
|
683
853
|
reverse?: boolean;
|
|
684
854
|
}, params?: RequestParams) => Promise<Event[]>;
|
|
685
855
|
};
|
|
@@ -23,6 +23,7 @@ var ContentType;
|
|
|
23
23
|
ContentType["Json"] = "application/json";
|
|
24
24
|
ContentType["FormData"] = "multipart/form-data";
|
|
25
25
|
ContentType["UrlEncoded"] = "application/x-www-form-urlencoded";
|
|
26
|
+
ContentType["Text"] = "text/plain";
|
|
26
27
|
})(ContentType = exports.ContentType || (exports.ContentType = {}));
|
|
27
28
|
class HttpClient {
|
|
28
29
|
constructor(apiConfig = {}) {
|
|
@@ -41,6 +42,7 @@ class HttpClient {
|
|
|
41
42
|
};
|
|
42
43
|
this.contentFormatters = {
|
|
43
44
|
[ContentType.Json]: (input) => input !== null && (typeof input === 'object' || typeof input === 'string') ? JSON.stringify(input) : input,
|
|
45
|
+
[ContentType.Text]: (input) => (input !== null && typeof input !== 'string' ? JSON.stringify(input) : input),
|
|
44
46
|
[ContentType.FormData]: (input) => Object.keys(input || {}).reduce((formData, key) => {
|
|
45
47
|
const property = input[key];
|
|
46
48
|
formData.append(key, property instanceof Blob
|
|
@@ -83,10 +85,10 @@ class HttpClient {
|
|
|
83
85
|
return this.customFetch(`${baseUrl || this.baseUrl || ''}${path}${queryString ? `?${queryString}` : ''}`, {
|
|
84
86
|
...requestParams,
|
|
85
87
|
headers: {
|
|
86
|
-
...(
|
|
87
|
-
...(
|
|
88
|
+
...(requestParams.headers || {}),
|
|
89
|
+
...(type && type !== ContentType.FormData ? { 'Content-Type': type } : {})
|
|
88
90
|
},
|
|
89
|
-
signal: cancelToken ? this.createAbortSignal(cancelToken) :
|
|
91
|
+
signal: cancelToken ? this.createAbortSignal(cancelToken) : requestParams.signal,
|
|
90
92
|
body: typeof body === 'undefined' || body === null ? null : payloadFormatter(body)
|
|
91
93
|
}).then(async (response) => {
|
|
92
94
|
const r = response;
|
|
@@ -289,14 +291,14 @@ class Api extends HttpClient {
|
|
|
289
291
|
...params
|
|
290
292
|
}).then(utils_1.convertHttpResponse),
|
|
291
293
|
/**
|
|
292
|
-
* @description List
|
|
294
|
+
* @description List mempool transactions of a given address
|
|
293
295
|
*
|
|
294
296
|
* @tags Addresses
|
|
295
|
-
* @name
|
|
296
|
-
* @request GET:/addresses/{address}/
|
|
297
|
+
* @name GetAddressesAddressMempoolTransactions
|
|
298
|
+
* @request GET:/addresses/{address}/mempool/transactions
|
|
297
299
|
*/
|
|
298
|
-
|
|
299
|
-
path: `/addresses/${address}/
|
|
300
|
+
getAddressesAddressMempoolTransactions: (address, params = {}) => this.request({
|
|
301
|
+
path: `/addresses/${address}/mempool/transactions`,
|
|
300
302
|
method: 'GET',
|
|
301
303
|
format: 'json',
|
|
302
304
|
...params
|
|
@@ -498,16 +500,16 @@ class Api extends HttpClient {
|
|
|
498
500
|
...params
|
|
499
501
|
}).then(utils_1.convertHttpResponse)
|
|
500
502
|
};
|
|
501
|
-
this.
|
|
503
|
+
this.mempool = {
|
|
502
504
|
/**
|
|
503
|
-
* @description list
|
|
505
|
+
* @description list mempool transactions
|
|
504
506
|
*
|
|
505
|
-
* @tags
|
|
506
|
-
* @name
|
|
507
|
-
* @request GET:/
|
|
507
|
+
* @tags Mempool
|
|
508
|
+
* @name GetMempoolTransactions
|
|
509
|
+
* @request GET:/mempool/transactions
|
|
508
510
|
*/
|
|
509
|
-
|
|
510
|
-
path: `/
|
|
511
|
+
getMempoolTransactions: (query, params = {}) => this.request({
|
|
512
|
+
path: `/mempool/transactions`,
|
|
511
513
|
method: 'GET',
|
|
512
514
|
query: query,
|
|
513
515
|
format: 'json',
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ApiRequestArguments, ApiRequestHandler } from './types';
|
|
2
|
+
import { Api as ExplorerApi } from './api-explorer';
|
|
3
|
+
export declare class ExplorerProvider {
|
|
4
|
+
readonly blocks: ExplorerApi<string>['blocks'];
|
|
5
|
+
readonly transactions: ExplorerApi<string>['transactions'];
|
|
6
|
+
readonly addresses: ExplorerApi<string>['addresses'];
|
|
7
|
+
readonly infos: ExplorerApi<string>['infos'];
|
|
8
|
+
readonly mempool: ExplorerApi<string>['mempool'];
|
|
9
|
+
readonly tokens: ExplorerApi<string>['tokens'];
|
|
10
|
+
readonly charts: ExplorerApi<string>['charts'];
|
|
11
|
+
readonly utils: ExplorerApi<string>['utils'];
|
|
12
|
+
constructor(baseUrl: string, apiKey?: string);
|
|
13
|
+
constructor(provider: ExplorerProvider);
|
|
14
|
+
constructor(handler: ApiRequestHandler);
|
|
15
|
+
request: (args: ApiRequestArguments) => Promise<any>;
|
|
16
|
+
static Proxy(explorerProvider: ExplorerProvider): ExplorerProvider;
|
|
17
|
+
static Remote(handler: ApiRequestHandler): ExplorerProvider;
|
|
18
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
Copyright 2018 - 2022 The Alephium Authors
|
|
4
|
+
This file is part of the alephium project.
|
|
5
|
+
|
|
6
|
+
The library is free software: you can redistribute it and/or modify
|
|
7
|
+
it under the terms of the GNU Lesser General Public License as published by
|
|
8
|
+
the Free Software Foundation, either version 3 of the License, or
|
|
9
|
+
(at your option) any later version.
|
|
10
|
+
|
|
11
|
+
The library is distributed in the hope that it will be useful,
|
|
12
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
14
|
+
GNU Lesser General Public License for more details.
|
|
15
|
+
|
|
16
|
+
You should have received a copy of the GNU Lesser General Public License
|
|
17
|
+
along with the library. If not, see <http://www.gnu.org/licenses/>.
|
|
18
|
+
*/
|
|
19
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
+
exports.ExplorerProvider = void 0;
|
|
21
|
+
const types_1 = require("./types");
|
|
22
|
+
const api_explorer_1 = require("./api-explorer");
|
|
23
|
+
function initializeExplorerApi(baseUrl, apiKey) {
|
|
24
|
+
const explorerApi = new api_explorer_1.Api({
|
|
25
|
+
baseUrl: baseUrl,
|
|
26
|
+
baseApiParams: { secure: true },
|
|
27
|
+
securityWorker: (accessToken) => (accessToken !== null ? { headers: { 'X-API-KEY': `${accessToken}` } } : {})
|
|
28
|
+
});
|
|
29
|
+
explorerApi.setSecurityData(apiKey ?? null);
|
|
30
|
+
return explorerApi;
|
|
31
|
+
}
|
|
32
|
+
class ExplorerProvider {
|
|
33
|
+
constructor(param0, apiKey) {
|
|
34
|
+
this.request = (args) => {
|
|
35
|
+
return (0, types_1.request)(this, args);
|
|
36
|
+
};
|
|
37
|
+
let explorerApi;
|
|
38
|
+
if (typeof param0 === 'string') {
|
|
39
|
+
explorerApi = initializeExplorerApi(param0, apiKey);
|
|
40
|
+
}
|
|
41
|
+
else if (typeof param0 === 'function') {
|
|
42
|
+
explorerApi = new ExplorerProvider('https://1.2.3.4:0');
|
|
43
|
+
(0, types_1.forwardRequests)(explorerApi, param0);
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
explorerApi = param0;
|
|
47
|
+
}
|
|
48
|
+
this.blocks = { ...explorerApi.blocks };
|
|
49
|
+
this.transactions = { ...explorerApi.transactions };
|
|
50
|
+
this.addresses = { ...explorerApi.addresses };
|
|
51
|
+
this.infos = { ...explorerApi.infos };
|
|
52
|
+
this.mempool = { ...explorerApi.mempool };
|
|
53
|
+
this.tokens = { ...explorerApi.tokens };
|
|
54
|
+
this.charts = { ...explorerApi.charts };
|
|
55
|
+
this.utils = { ...explorerApi.utils };
|
|
56
|
+
}
|
|
57
|
+
// This can prevent the proxied explorer provider from being modified
|
|
58
|
+
static Proxy(explorerProvider) {
|
|
59
|
+
return new ExplorerProvider(explorerProvider);
|
|
60
|
+
}
|
|
61
|
+
static Remote(handler) {
|
|
62
|
+
return new ExplorerProvider(handler);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
exports.ExplorerProvider = ExplorerProvider;
|