@alephium/web3 0.0.3 → 0.1.0-rc.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.
Files changed (144) hide show
  1. package/.editorconfig +13 -0
  2. package/.eslintignore +2 -0
  3. package/.eslintrc.json +21 -0
  4. package/README.md +2 -2
  5. package/contracts/add.ral +7 -3
  6. package/contracts/greeter.ral +3 -1
  7. package/contracts/greeter_interface.ral +3 -0
  8. package/contracts/greeter_main.ral +9 -0
  9. package/contracts/main.ral +3 -5
  10. package/dev/user.conf +8 -4
  11. package/dist/alephium-web3.min.js +1 -1
  12. package/dist/alephium-web3.min.js.map +1 -1
  13. package/dist/scripts/check-versions.d.ts +1 -0
  14. package/dist/scripts/check-versions.js +39 -0
  15. package/dist/{cli → scripts}/create-project.d.ts +0 -0
  16. package/dist/scripts/create-project.js +124 -0
  17. package/dist/scripts/header.d.ts +0 -0
  18. package/dist/scripts/header.js +18 -0
  19. package/dist/scripts/rename-gitignore.d.ts +1 -0
  20. package/dist/scripts/rename-gitignore.js +24 -0
  21. package/dist/scripts/start-devnet.d.ts +1 -0
  22. package/dist/scripts/start-devnet.js +131 -0
  23. package/dist/scripts/stop-devnet.d.ts +1 -0
  24. package/dist/scripts/stop-devnet.js +32 -0
  25. package/dist/{api → src/api}/api-alephium.d.ts +287 -168
  26. package/dist/{api → src/api}/api-alephium.js +497 -115
  27. package/dist/{api → src/api}/api-explorer.d.ts +117 -19
  28. package/dist/{api → src/api}/api-explorer.js +206 -46
  29. package/dist/src/api/index.d.ts +10 -0
  30. package/dist/src/api/index.js +55 -0
  31. package/dist/{lib → src}/constants.d.ts +0 -0
  32. package/dist/{lib → src}/constants.js +0 -0
  33. package/dist/src/contract/contract.d.ts +182 -0
  34. package/dist/src/contract/contract.js +760 -0
  35. package/dist/src/contract/events.d.ts +29 -0
  36. package/dist/src/contract/events.js +77 -0
  37. package/dist/src/contract/index.d.ts +3 -0
  38. package/dist/src/contract/index.js +32 -0
  39. package/dist/src/contract/ralph.d.ts +12 -0
  40. package/dist/src/contract/ralph.js +362 -0
  41. package/dist/src/index.d.ts +5 -0
  42. package/dist/src/index.js +34 -0
  43. package/dist/src/signer/index.d.ts +2 -0
  44. package/dist/src/signer/index.js +31 -0
  45. package/dist/src/signer/node-wallet.d.ts +13 -0
  46. package/dist/src/signer/node-wallet.js +60 -0
  47. package/dist/src/signer/signer.d.ts +143 -0
  48. package/dist/src/signer/signer.js +184 -0
  49. package/dist/src/test/index.d.ts +7 -0
  50. package/dist/src/test/index.js +41 -0
  51. package/dist/src/test/privatekey-wallet.d.ts +12 -0
  52. package/dist/src/test/privatekey-wallet.js +68 -0
  53. package/dist/{lib → src/utils}/address.d.ts +0 -0
  54. package/dist/{lib → src/utils}/address.js +1 -1
  55. package/dist/{lib → src/utils}/bs58.d.ts +2 -2
  56. package/dist/{lib → src/utils}/bs58.js +3 -1
  57. package/dist/{lib → src/utils}/djb2.d.ts +0 -0
  58. package/dist/{lib → src/utils}/djb2.js +1 -1
  59. package/dist/src/utils/index.d.ts +6 -0
  60. package/dist/src/utils/index.js +35 -0
  61. package/dist/{lib → src/utils}/password-crypto.d.ts +0 -0
  62. package/dist/{lib → src/utils}/password-crypto.js +8 -7
  63. package/dist/src/utils/transaction.d.ts +2 -0
  64. package/dist/src/utils/transaction.js +58 -0
  65. package/dist/src/utils/utils.d.ts +30 -0
  66. package/dist/{lib → src/utils}/utils.js +83 -19
  67. package/gitignore +5 -4
  68. package/package.json +56 -40
  69. package/scripts/create-project.ts +136 -0
  70. package/scripts/header.js +17 -0
  71. package/scripts/start-devnet.js +3 -3
  72. package/src/api/api-alephium.ts +2323 -0
  73. package/src/api/api-explorer.ts +808 -0
  74. package/src/api/index.ts +35 -0
  75. package/src/constants.ts +20 -0
  76. package/src/contract/contract.ts +1014 -0
  77. package/src/contract/events.ts +102 -0
  78. package/src/contract/index.ts +21 -0
  79. package/src/contract/ralph.test.ts +178 -0
  80. package/src/contract/ralph.ts +362 -0
  81. package/src/fixtures/address.json +36 -0
  82. package/src/fixtures/balance.json +9 -0
  83. package/src/fixtures/self-clique.json +19 -0
  84. package/src/fixtures/transaction.json +13 -0
  85. package/src/fixtures/transactions.json +179 -0
  86. package/src/index.ts +24 -0
  87. package/src/signer/fixtures/genesis.json +26 -0
  88. package/src/signer/fixtures/wallets.json +26 -0
  89. package/src/signer/index.ts +20 -0
  90. package/src/signer/node-wallet.ts +74 -0
  91. package/src/signer/signer.ts +313 -0
  92. package/src/test/index.ts +32 -0
  93. package/src/test/privatekey-wallet.ts +58 -0
  94. package/src/utils/address.test.ts +47 -0
  95. package/src/utils/address.ts +39 -0
  96. package/src/utils/bs58.ts +26 -0
  97. package/src/utils/djb2.test.ts +35 -0
  98. package/src/utils/djb2.ts +25 -0
  99. package/src/utils/index.ts +24 -0
  100. package/src/utils/password-crypto.test.ts +27 -0
  101. package/src/utils/password-crypto.ts +77 -0
  102. package/src/utils/transaction.test.ts +50 -0
  103. package/src/utils/transaction.ts +39 -0
  104. package/src/utils/utils.test.ts +160 -0
  105. package/src/utils/utils.ts +209 -0
  106. package/templates/{README.md → base/README.md} +4 -4
  107. package/templates/base/package.json +35 -0
  108. package/templates/base/src/greeter.ts +41 -0
  109. package/templates/base/tsconfig.json +19 -0
  110. package/templates/react/README.md +34 -0
  111. package/templates/react/config-overrides.js +18 -0
  112. package/templates/react/package.json +66 -0
  113. package/templates/react/src/App.tsx +42 -0
  114. package/templates/react/src/artifacts/greeter.ral.json +26 -0
  115. package/templates/react/src/artifacts/greeter_main.ral.json +22 -0
  116. package/templates/shared/.eslintrc.json +12 -0
  117. package/templates/shared/scripts/header.js +0 -0
  118. package/test/contract.test.ts +161 -0
  119. package/test/events.test.ts +139 -0
  120. package/webpack.config.js +1 -1
  121. package/contracts/greeter-main.ral +0 -8
  122. package/dist/cli/create-project.js +0 -87
  123. package/dist/lib/clique.d.ts +0 -23
  124. package/dist/lib/clique.js +0 -149
  125. package/dist/lib/contract.d.ts +0 -152
  126. package/dist/lib/contract.js +0 -711
  127. package/dist/lib/explorer.d.ts +0 -8
  128. package/dist/lib/explorer.js +0 -46
  129. package/dist/lib/index.d.ts +0 -12
  130. package/dist/lib/index.js +0 -60
  131. package/dist/lib/node.d.ts +0 -10
  132. package/dist/lib/node.js +0 -64
  133. package/dist/lib/numbers.d.ts +0 -7
  134. package/dist/lib/numbers.js +0 -128
  135. package/dist/lib/signer.d.ts +0 -17
  136. package/dist/lib/signer.js +0 -70
  137. package/dist/lib/storage-browser.d.ts +0 -9
  138. package/dist/lib/storage-browser.js +0 -52
  139. package/dist/lib/storage-node.d.ts +0 -9
  140. package/dist/lib/storage-node.js +0 -65
  141. package/dist/lib/utils.d.ts +0 -11
  142. package/dist/lib/wallet.d.ts +0 -30
  143. package/dist/lib/wallet.js +0 -142
  144. package/templates/package.json +0 -29
@@ -1,3 +1,9 @@
1
+ export interface AddressBalance {
2
+ /** @format uint256 */
3
+ balance: string;
4
+ /** @format uint256 */
5
+ lockedBalance: string;
6
+ }
1
7
  export interface AddressInfo {
2
8
  /** @format uint256 */
3
9
  balance: string;
@@ -39,6 +45,7 @@ export interface ExplorerInfo {
39
45
  export interface Hashrate {
40
46
  /** @format int64 */
41
47
  timestamp: number;
48
+ hashrate: string;
42
49
  value: string;
43
50
  }
44
51
  export interface Input {
@@ -62,6 +69,7 @@ export interface NotFound {
62
69
  }
63
70
  export interface Output {
64
71
  hint: number;
72
+ /** @format 32-byte-hash */
65
73
  key: string;
66
74
  /** @format uint256 */
67
75
  amount: string;
@@ -72,17 +80,45 @@ export interface Output {
72
80
  }
73
81
  export interface OutputRef {
74
82
  hint: number;
83
+ /** @format 32-byte-hash */
75
84
  key: string;
76
85
  }
77
- export interface PerChainValue {
86
+ export interface PerChainCount {
87
+ chainFrom: number;
88
+ chainTo: number;
89
+ /** @format int64 */
90
+ count: number;
91
+ }
92
+ export interface PerChainDuration {
93
+ chainFrom: number;
94
+ chainTo: number;
95
+ /** @format int64 */
96
+ duration: number;
97
+ /** @format int64 */
98
+ value: number;
99
+ }
100
+ export interface PerChainHeight {
78
101
  chainFrom: number;
79
102
  chainTo: number;
80
103
  /** @format int64 */
104
+ height: number;
105
+ /** @format int64 */
81
106
  value: number;
82
107
  }
108
+ export interface PerChainTimedCount {
109
+ /** @format int64 */
110
+ timestamp: number;
111
+ totalCountPerChain?: PerChainCount[];
112
+ }
83
113
  export interface ServiceUnavailable {
84
114
  detail: string;
85
115
  }
116
+ export interface TimedCount {
117
+ /** @format int64 */
118
+ timestamp: number;
119
+ /** @format int64 */
120
+ totalCountAllChains: number;
121
+ }
86
122
  export interface TokenSupply {
87
123
  /** @format int64 */
88
124
  timestamp: number;
@@ -91,6 +127,10 @@ export interface TokenSupply {
91
127
  /** @format uint256 */
92
128
  circulating: string;
93
129
  /** @format uint256 */
130
+ reserved: string;
131
+ /** @format uint256 */
132
+ locked: string;
133
+ /** @format uint256 */
94
134
  maximum: string;
95
135
  }
96
136
  export interface Transaction {
@@ -205,7 +245,7 @@ export declare class Api<SecurityDataType extends unknown> extends HttpClient<Se
205
245
  page?: number | undefined;
206
246
  limit?: number | undefined;
207
247
  reverse?: boolean | undefined;
208
- } | undefined, params?: RequestParams) => Promise<HttpResponse<ListBlocks, BadRequest | InternalServerError | NotFound | ServiceUnavailable | Unauthorized>>;
248
+ } | undefined, params?: RequestParams) => Promise<ListBlocks>;
209
249
  /**
210
250
  * @description Get a block with hash
211
251
  *
@@ -213,7 +253,7 @@ export declare class Api<SecurityDataType extends unknown> extends HttpClient<Se
213
253
  * @name GetBlocksBlockHash
214
254
  * @request GET:/blocks/{block-hash}
215
255
  */
216
- getBlocksBlockHash: (blockHash: string, params?: RequestParams) => Promise<HttpResponse<BlockEntryLite, BadRequest | InternalServerError | NotFound | ServiceUnavailable | Unauthorized>>;
256
+ getBlocksBlockHash: (blockHash: string, params?: RequestParams) => Promise<BlockEntryLite>;
217
257
  /**
218
258
  * @description Get block's transactions
219
259
  *
@@ -225,7 +265,7 @@ export declare class Api<SecurityDataType extends unknown> extends HttpClient<Se
225
265
  page?: number | undefined;
226
266
  limit?: number | undefined;
227
267
  reverse?: boolean | undefined;
228
- } | undefined, params?: RequestParams) => Promise<HttpResponse<Transaction[], BadRequest | InternalServerError | NotFound | ServiceUnavailable | Unauthorized>>;
268
+ } | undefined, params?: RequestParams) => Promise<Transaction[]>;
229
269
  };
230
270
  transactions: {
231
271
  /**
@@ -235,21 +275,21 @@ export declare class Api<SecurityDataType extends unknown> extends HttpClient<Se
235
275
  * @name GetTransactionsTransactionHash
236
276
  * @request GET:/transactions/{transaction-hash}
237
277
  */
238
- getTransactionsTransactionHash: (transactionHash: string, params?: RequestParams) => Promise<HttpResponse<TransactionLike, BadRequest | InternalServerError | NotFound | ServiceUnavailable | Unauthorized>>;
278
+ getTransactionsTransactionHash: (transactionHash: string, params?: RequestParams) => Promise<ConfirmedTransaction | UnconfirmedTransaction>;
239
279
  };
240
280
  addresses: {
241
281
  /**
242
282
  * @description Get address information
243
283
  *
244
- * @tags Addressess
284
+ * @tags Addresses
245
285
  * @name GetAddressesAddress
246
286
  * @request GET:/addresses/{address}
247
287
  */
248
- getAddressesAddress: (address: string, params?: RequestParams) => Promise<HttpResponse<AddressInfo, BadRequest | InternalServerError | NotFound | ServiceUnavailable | Unauthorized>>;
288
+ getAddressesAddress: (address: string, params?: RequestParams) => Promise<AddressInfo>;
249
289
  /**
250
290
  * @description List transactions of a given address
251
291
  *
252
- * @tags Addressess
292
+ * @tags Addresses
253
293
  * @name GetAddressesAddressTransactions
254
294
  * @request GET:/addresses/{address}/transactions
255
295
  */
@@ -257,7 +297,23 @@ export declare class Api<SecurityDataType extends unknown> extends HttpClient<Se
257
297
  page?: number | undefined;
258
298
  limit?: number | undefined;
259
299
  reverse?: boolean | undefined;
260
- } | undefined, params?: RequestParams) => Promise<HttpResponse<Transaction[], BadRequest | InternalServerError | NotFound | ServiceUnavailable | Unauthorized>>;
300
+ } | undefined, params?: RequestParams) => Promise<Transaction[]>;
301
+ /**
302
+ * @description Get total transactions of a given address
303
+ *
304
+ * @tags Addresses
305
+ * @name GetAddressesAddressTotalTransactions
306
+ * @request GET:/addresses/{address}/total-transactions
307
+ */
308
+ getAddressesAddressTotalTransactions: (address: string, params?: RequestParams) => Promise<number>;
309
+ /**
310
+ * @description Get address balance
311
+ *
312
+ * @tags Addresses
313
+ * @name GetAddressesAddressBalance
314
+ * @request GET:/addresses/{address}/balance
315
+ */
316
+ getAddressesAddressBalance: (address: string, params?: RequestParams) => Promise<AddressBalance>;
261
317
  };
262
318
  infos: {
263
319
  /**
@@ -267,7 +323,7 @@ export declare class Api<SecurityDataType extends unknown> extends HttpClient<Se
267
323
  * @name GetInfos
268
324
  * @request GET:/infos
269
325
  */
270
- getInfos: (params?: RequestParams) => Promise<HttpResponse<ExplorerInfo, BadRequest | InternalServerError | NotFound | ServiceUnavailable | Unauthorized>>;
326
+ getInfos: (params?: RequestParams) => Promise<ExplorerInfo>;
271
327
  /**
272
328
  * @description List latest height for each chain
273
329
  *
@@ -275,7 +331,7 @@ export declare class Api<SecurityDataType extends unknown> extends HttpClient<Se
275
331
  * @name GetInfosHeights
276
332
  * @request GET:/infos/heights
277
333
  */
278
- getInfosHeights: (params?: RequestParams) => Promise<HttpResponse<PerChainValue[], BadRequest | InternalServerError | NotFound | ServiceUnavailable | Unauthorized>>;
334
+ getInfosHeights: (params?: RequestParams) => Promise<PerChainHeight[]>;
279
335
  /**
280
336
  * @description Get token supply list
281
337
  *
@@ -287,7 +343,7 @@ export declare class Api<SecurityDataType extends unknown> extends HttpClient<Se
287
343
  page?: number | undefined;
288
344
  limit?: number | undefined;
289
345
  reverse?: boolean | undefined;
290
- } | undefined, params?: RequestParams) => Promise<HttpResponse<TokenSupply[], BadRequest | InternalServerError | NotFound | ServiceUnavailable | Unauthorized>>;
346
+ } | undefined, params?: RequestParams) => Promise<TokenSupply[]>;
291
347
  /**
292
348
  * @description Get the ALPH total supply
293
349
  *
@@ -295,7 +351,7 @@ export declare class Api<SecurityDataType extends unknown> extends HttpClient<Se
295
351
  * @name GetInfosSupplyTotalAlph
296
352
  * @request GET:/infos/supply/total-alph
297
353
  */
298
- getInfosSupplyTotalAlph: (params?: RequestParams) => Promise<HttpResponse<string, BadRequest | InternalServerError | NotFound | ServiceUnavailable | Unauthorized>>;
354
+ getInfosSupplyTotalAlph: (params?: RequestParams) => Promise<string>;
299
355
  /**
300
356
  * @description Get the ALPH circulating supply
301
357
  *
@@ -303,7 +359,23 @@ export declare class Api<SecurityDataType extends unknown> extends HttpClient<Se
303
359
  * @name GetInfosSupplyCirculatingAlph
304
360
  * @request GET:/infos/supply/circulating-alph
305
361
  */
306
- getInfosSupplyCirculatingAlph: (params?: RequestParams) => Promise<HttpResponse<string, BadRequest | InternalServerError | NotFound | ServiceUnavailable | Unauthorized>>;
362
+ getInfosSupplyCirculatingAlph: (params?: RequestParams) => Promise<string>;
363
+ /**
364
+ * @description Get the ALPH reserved supply
365
+ *
366
+ * @tags Infos
367
+ * @name GetInfosSupplyReservedAlph
368
+ * @request GET:/infos/supply/reserved-alph
369
+ */
370
+ getInfosSupplyReservedAlph: (params?: RequestParams) => Promise<string>;
371
+ /**
372
+ * @description Get the ALPH locked supply
373
+ *
374
+ * @tags Infos
375
+ * @name GetInfosSupplyLockedAlph
376
+ * @request GET:/infos/supply/locked-alph
377
+ */
378
+ getInfosSupplyLockedAlph: (params?: RequestParams) => Promise<string>;
307
379
  /**
308
380
  * @description Get the total number of transactions
309
381
  *
@@ -311,7 +383,7 @@ export declare class Api<SecurityDataType extends unknown> extends HttpClient<Se
311
383
  * @name GetInfosTotalTransactions
312
384
  * @request GET:/infos/total-transactions
313
385
  */
314
- getInfosTotalTransactions: (params?: RequestParams) => Promise<HttpResponse<number, BadRequest | InternalServerError | NotFound | ServiceUnavailable | Unauthorized>>;
386
+ getInfosTotalTransactions: (params?: RequestParams) => Promise<number>;
315
387
  /**
316
388
  * @description Get the average block time for each chain
317
389
  *
@@ -319,7 +391,7 @@ export declare class Api<SecurityDataType extends unknown> extends HttpClient<Se
319
391
  * @name GetInfosAverageBlockTimes
320
392
  * @request GET:/infos/average-block-times
321
393
  */
322
- getInfosAverageBlockTimes: (params?: RequestParams) => Promise<HttpResponse<PerChainValue[], BadRequest | InternalServerError | NotFound | ServiceUnavailable | Unauthorized>>;
394
+ getInfosAverageBlockTimes: (params?: RequestParams) => Promise<PerChainDuration[]>;
323
395
  };
324
396
  charts: {
325
397
  /**
@@ -327,14 +399,40 @@ export declare class Api<SecurityDataType extends unknown> extends HttpClient<Se
327
399
  *
328
400
  * @tags Charts
329
401
  * @name GetChartsHashrates
330
- * @summary Get explorer informations.
402
+ * @summary Get hashrate chart in H/s
331
403
  * @request GET:/charts/hashrates
332
404
  */
333
405
  getChartsHashrates: (query: {
334
406
  fromTs: number;
335
407
  toTs: number;
336
408
  'interval-type': string;
337
- }, params?: RequestParams) => Promise<HttpResponse<Hashrate[], BadRequest | InternalServerError | NotFound | ServiceUnavailable | Unauthorized>>;
409
+ }, params?: RequestParams) => Promise<Hashrate[]>;
410
+ /**
411
+ * @description `interval-type` query param: hourly, daily
412
+ *
413
+ * @tags Charts
414
+ * @name GetChartsTransactionsCount
415
+ * @summary Get transaction count history
416
+ * @request GET:/charts/transactions-count
417
+ */
418
+ getChartsTransactionsCount: (query: {
419
+ fromTs: number;
420
+ toTs: number;
421
+ 'interval-type': string;
422
+ }, params?: RequestParams) => Promise<TimedCount[]>;
423
+ /**
424
+ * @description `interval-type` query param: hourly, daily
425
+ *
426
+ * @tags Charts
427
+ * @name GetChartsTransactionsCountPerChain
428
+ * @summary Get transaction count history per chain
429
+ * @request GET:/charts/transactions-count-per-chain
430
+ */
431
+ getChartsTransactionsCountPerChain: (query: {
432
+ fromTs: number;
433
+ toTs: number;
434
+ 'interval-type': string;
435
+ }, params?: RequestParams) => Promise<PerChainTimedCount[]>;
338
436
  };
339
437
  utils: {
340
438
  /**
@@ -344,7 +442,7 @@ export declare class Api<SecurityDataType extends unknown> extends HttpClient<Se
344
442
  * @name PutUtilsSanityCheck
345
443
  * @request PUT:/utils/sanity-check
346
444
  */
347
- putUtilsSanityCheck: (params?: RequestParams) => Promise<HttpResponse<void, BadRequest | InternalServerError | NotFound | ServiceUnavailable | Unauthorized>>;
445
+ putUtilsSanityCheck: (params?: RequestParams) => Promise<void>;
348
446
  };
349
447
  }
350
448
  export {};