@alephium/web3 0.2.0-test.1 → 0.2.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 (128) hide show
  1. package/.eslintignore +2 -2
  2. package/README.md +2 -135
  3. package/dist/alephium-web3.min.js +1 -1
  4. package/dist/alephium-web3.min.js.LICENSE.txt +0 -17
  5. package/dist/alephium-web3.min.js.map +1 -1
  6. package/dist/src/api/api-alephium.d.ts +115 -17
  7. package/dist/src/api/api-alephium.js +145 -80
  8. package/dist/src/api/api-explorer.d.ts +178 -51
  9. package/dist/src/api/api-explorer.js +172 -37
  10. package/dist/src/api/index.d.ts +40 -5
  11. package/dist/src/api/index.js +115 -7
  12. package/dist/src/api/types.d.ts +23 -0
  13. package/dist/src/api/types.js +235 -0
  14. package/dist/src/api/utils.d.ts +6 -0
  15. package/dist/{scripts/rename-gitignore.js → src/api/utils.js} +11 -6
  16. package/dist/src/contract/contract.d.ts +68 -55
  17. package/dist/src/contract/contract.js +235 -384
  18. package/dist/src/contract/events.d.ts +4 -4
  19. package/dist/src/contract/events.js +2 -1
  20. package/dist/src/contract/index.js +5 -1
  21. package/dist/src/contract/ralph.d.ts +5 -4
  22. package/dist/src/contract/ralph.js +27 -1
  23. package/dist/src/global.d.ts +6 -2
  24. package/dist/src/global.js +19 -3
  25. package/dist/src/index.d.ts +2 -1
  26. package/dist/src/index.js +23 -2
  27. package/dist/src/signer/index.d.ts +0 -1
  28. package/dist/src/signer/index.js +5 -2
  29. package/dist/src/signer/signer.d.ts +59 -60
  30. package/dist/src/signer/signer.js +99 -70
  31. package/dist/src/transaction/index.d.ts +0 -1
  32. package/dist/src/transaction/index.js +5 -2
  33. package/dist/src/transaction/status.d.ts +2 -1
  34. package/dist/src/transaction/status.js +2 -1
  35. package/dist/src/utils/bs58.d.ts +1 -0
  36. package/dist/src/utils/bs58.js +13 -1
  37. package/dist/src/utils/index.d.ts +0 -1
  38. package/dist/src/utils/index.js +5 -2
  39. package/dist/src/utils/subscription.d.ts +0 -2
  40. package/dist/src/utils/subscription.js +0 -2
  41. package/dist/src/utils/utils.d.ts +4 -9
  42. package/dist/src/utils/utils.js +20 -24
  43. package/jest-config.json +11 -0
  44. package/package.json +11 -45
  45. package/src/api/api-alephium.ts +162 -25
  46. package/src/api/api-explorer.ts +247 -54
  47. package/src/api/index.ts +140 -6
  48. package/src/api/types.ts +229 -0
  49. package/{scripts/rename-gitignore.js → src/api/utils.ts} +7 -6
  50. package/src/contract/contract.ts +398 -429
  51. package/src/contract/events.ts +6 -5
  52. package/src/contract/ralph.ts +29 -4
  53. package/src/global.ts +23 -3
  54. package/src/index.ts +7 -1
  55. package/src/signer/index.ts +0 -1
  56. package/src/signer/signer.ts +165 -135
  57. package/src/transaction/index.ts +0 -1
  58. package/src/transaction/status.ts +5 -2
  59. package/src/utils/bs58.ts +11 -0
  60. package/src/utils/index.ts +0 -1
  61. package/src/utils/subscription.ts +0 -4
  62. package/src/utils/utils.ts +11 -19
  63. package/webpack.config.js +3 -0
  64. package/.eslintrc.json +0 -21
  65. package/LICENSE +0 -165
  66. package/contracts/add/add.ral +0 -13
  67. package/contracts/greeter/greeter.ral +0 -7
  68. package/contracts/greeter/greeter_interface.ral +0 -4
  69. package/contracts/greeter_main.ral +0 -7
  70. package/contracts/main.ral +0 -4
  71. package/contracts/sub/sub.ral +0 -10
  72. package/contracts/test/metadata.ral +0 -18
  73. package/contracts/test/warnings.ral +0 -8
  74. package/dev/user.conf +0 -29
  75. package/dist/scripts/create-project.d.ts +0 -2
  76. package/dist/scripts/create-project.js +0 -125
  77. package/dist/scripts/rename-gitignore.d.ts +0 -1
  78. package/dist/scripts/start-devnet.d.ts +0 -1
  79. package/dist/scripts/start-devnet.js +0 -131
  80. package/dist/scripts/stop-devnet.d.ts +0 -1
  81. package/dist/scripts/stop-devnet.js +0 -32
  82. package/dist/src/signer/node-wallet.d.ts +0 -11
  83. package/dist/src/signer/node-wallet.js +0 -57
  84. package/dist/src/test/index.d.ts +0 -6
  85. package/dist/src/test/index.js +0 -41
  86. package/dist/src/test/privatekey-wallet.d.ts +0 -11
  87. package/dist/src/test/privatekey-wallet.js +0 -68
  88. package/dist/src/transaction/sign-verify.d.ts +0 -2
  89. package/dist/src/transaction/sign-verify.js +0 -58
  90. package/dist/src/utils/password-crypto.d.ts +0 -2
  91. package/dist/src/utils/password-crypto.js +0 -69
  92. package/gitignore +0 -9
  93. package/scripts/create-project.ts +0 -137
  94. package/scripts/start-devnet.js +0 -141
  95. package/scripts/stop-devnet.js +0 -32
  96. package/src/contract/ralph.test.ts +0 -178
  97. package/src/fixtures/address.json +0 -36
  98. package/src/fixtures/balance.json +0 -9
  99. package/src/fixtures/self-clique.json +0 -19
  100. package/src/fixtures/transaction.json +0 -13
  101. package/src/fixtures/transactions.json +0 -179
  102. package/src/signer/fixtures/genesis.json +0 -26
  103. package/src/signer/fixtures/wallets.json +0 -26
  104. package/src/signer/node-wallet.ts +0 -65
  105. package/src/test/index.ts +0 -31
  106. package/src/test/privatekey-wallet.ts +0 -57
  107. package/src/transaction/sign-verify.test.ts +0 -50
  108. package/src/transaction/sign-verify.ts +0 -39
  109. package/src/utils/address.test.ts +0 -47
  110. package/src/utils/djb2.test.ts +0 -35
  111. package/src/utils/password-crypto.test.ts +0 -27
  112. package/src/utils/password-crypto.ts +0 -77
  113. package/src/utils/utils.test.ts +0 -161
  114. package/templates/base/README.md +0 -34
  115. package/templates/base/package.json +0 -35
  116. package/templates/base/src/greeter.ts +0 -42
  117. package/templates/base/tsconfig.json +0 -19
  118. package/templates/react/README.md +0 -34
  119. package/templates/react/config-overrides.js +0 -18
  120. package/templates/react/package.json +0 -66
  121. package/templates/react/src/App.tsx +0 -42
  122. package/templates/react/src/artifacts/greeter.ral.json +0 -26
  123. package/templates/react/src/artifacts/greeter_main.ral.json +0 -22
  124. package/templates/shared/.eslintrc.json +0 -12
  125. package/templates/shared/scripts/header.js +0 -0
  126. package/test/contract.test.ts +0 -213
  127. package/test/events.test.ts +0 -141
  128. package/test/transaction.test.ts +0 -73
@@ -12,6 +12,23 @@ export interface AddressInfo {
12
12
  /** @format int32 */
13
13
  txNumber: number;
14
14
  }
15
+ export interface AssetOutput {
16
+ /** @format int32 */
17
+ hint: number;
18
+ /** @format 32-byte-hash */
19
+ key: string;
20
+ /** @format uint256 */
21
+ attoAlphAmount: string;
22
+ address: string;
23
+ tokens?: Token[];
24
+ /** @format int64 */
25
+ lockTime?: number;
26
+ /** @format hex-string */
27
+ message?: string;
28
+ /** @format 32-byte-hash */
29
+ spent?: string;
30
+ type: string;
31
+ }
15
32
  export interface BadRequest {
16
33
  detail: string;
17
34
  }
@@ -47,6 +64,19 @@ export interface ConfirmedTransaction {
47
64
  gasPrice: string;
48
65
  type: string;
49
66
  }
67
+ export interface ContractOutput {
68
+ /** @format int32 */
69
+ hint: number;
70
+ /** @format 32-byte-hash */
71
+ key: string;
72
+ /** @format uint256 */
73
+ attoAlphAmount: string;
74
+ address: string;
75
+ tokens?: Token[];
76
+ /** @format 32-byte-hash */
77
+ spent?: string;
78
+ type: string;
79
+ }
50
80
  export interface ExplorerInfo {
51
81
  releaseVersion: string;
52
82
  commit: string;
@@ -59,12 +89,12 @@ export interface Hashrate {
59
89
  }
60
90
  export interface Input {
61
91
  outputRef: OutputRef;
92
+ /** @format hex-string */
62
93
  unlockScript?: string;
63
- /** @format 32-byte-hash */
64
- txHashRef: string;
65
- address: string;
94
+ address?: string;
66
95
  /** @format uint256 */
67
- amount: string;
96
+ attoAlphAmount?: string;
97
+ tokens?: Token[];
68
98
  }
69
99
  export interface InternalServerError {
70
100
  detail: string;
@@ -74,23 +104,15 @@ export interface ListBlocks {
74
104
  total: number;
75
105
  blocks?: BlockEntryLite[];
76
106
  }
107
+ export interface LogbackValue {
108
+ name: string;
109
+ level: string;
110
+ }
77
111
  export interface NotFound {
78
112
  detail: string;
79
113
  resource: string;
80
114
  }
81
- export interface Output {
82
- /** @format int32 */
83
- hint: number;
84
- /** @format 32-byte-hash */
85
- key: string;
86
- /** @format uint256 */
87
- amount: string;
88
- address: string;
89
- /** @format int64 */
90
- lockTime?: number;
91
- /** @format 32-byte-hash */
92
- spent?: string;
93
- }
115
+ export declare type Output = AssetOutput | ContractOutput;
94
116
  export interface OutputRef {
95
117
  /** @format int32 */
96
118
  hint: number;
@@ -139,6 +161,12 @@ export interface TimedCount {
139
161
  /** @format int64 */
140
162
  totalCountAllChains: number;
141
163
  }
164
+ export interface Token {
165
+ /** @format 32-byte-hash */
166
+ id: string;
167
+ /** @format uint256 */
168
+ amount: string;
169
+ }
142
170
  export interface TokenSupply {
143
171
  /** @format int64 */
144
172
  timestamp: number;
@@ -168,17 +196,6 @@ export interface Transaction {
168
196
  gasPrice: string;
169
197
  }
170
198
  export declare type TransactionLike = ConfirmedTransaction | UnconfirmedTransaction;
171
- export interface UInput {
172
- outputRef: OutputRef;
173
- unlockScript?: string;
174
- }
175
- export interface UOutput {
176
- /** @format uint256 */
177
- amount: string;
178
- address: string;
179
- /** @format int64 */
180
- lockTime?: number;
181
- }
182
199
  export interface Unauthorized {
183
200
  detail: string;
184
201
  }
@@ -189,12 +206,14 @@ export interface UnconfirmedTransaction {
189
206
  chainFrom: number;
190
207
  /** @format int32 */
191
208
  chainTo: number;
192
- inputs?: UInput[];
193
- outputs?: UOutput[];
209
+ inputs?: Input[];
210
+ outputs?: Output[];
194
211
  /** @format int32 */
195
212
  gasAmount: number;
196
213
  /** @format uint256 */
197
214
  gasPrice: string;
215
+ /** @format int64 */
216
+ lastSeen: number;
198
217
  type: string;
199
218
  }
200
219
  import 'cross-fetch/polyfill';
@@ -269,16 +288,16 @@ export declare class Api<SecurityDataType extends unknown> extends HttpClient<Se
269
288
  * @request GET:/blocks
270
289
  */
271
290
  getBlocks: (query?: {
272
- page?: number | undefined;
273
- limit?: number | undefined;
274
- reverse?: boolean | undefined;
275
- } | undefined, params?: RequestParams) => Promise<ListBlocks>;
291
+ page?: number;
292
+ limit?: number;
293
+ reverse?: boolean;
294
+ }, params?: RequestParams) => Promise<ListBlocks>;
276
295
  /**
277
296
  * @description Get a block with hash
278
297
  *
279
298
  * @tags Blocks
280
299
  * @name GetBlocksBlockHash
281
- * @request GET:/blocks/{block-hash}
300
+ * @request GET:/blocks/{block_hash}
282
301
  */
283
302
  getBlocksBlockHash: (blockHash: string, params?: RequestParams) => Promise<BlockEntryLite>;
284
303
  /**
@@ -286,13 +305,13 @@ export declare class Api<SecurityDataType extends unknown> extends HttpClient<Se
286
305
  *
287
306
  * @tags Blocks
288
307
  * @name GetBlocksBlockHashTransactions
289
- * @request GET:/blocks/{block-hash}/transactions
308
+ * @request GET:/blocks/{block_hash}/transactions
290
309
  */
291
310
  getBlocksBlockHashTransactions: (blockHash: string, query?: {
292
- page?: number | undefined;
293
- limit?: number | undefined;
294
- reverse?: boolean | undefined;
295
- } | undefined, params?: RequestParams) => Promise<Transaction[]>;
311
+ page?: number;
312
+ limit?: number;
313
+ reverse?: boolean;
314
+ }, params?: RequestParams) => Promise<Transaction[]>;
296
315
  };
297
316
  transactions: {
298
317
  /**
@@ -300,9 +319,17 @@ export declare class Api<SecurityDataType extends unknown> extends HttpClient<Se
300
319
  *
301
320
  * @tags Transactions
302
321
  * @name GetTransactionsTransactionHash
303
- * @request GET:/transactions/{transaction-hash}
322
+ * @request GET:/transactions/{transaction_hash}
304
323
  */
305
324
  getTransactionsTransactionHash: (transactionHash: string, params?: RequestParams) => Promise<ConfirmedTransaction | UnconfirmedTransaction>;
325
+ /**
326
+ * @description Get a transaction from a output reference key
327
+ *
328
+ * @tags Transactions
329
+ * @name GetTransactionsByOutputRefKeyOutputRefKey
330
+ * @request GET:/transactions/by/output-ref-key/{output_ref_key}
331
+ */
332
+ getTransactionsByOutputRefKeyOutputRefKey: (outputRefKey: string, params?: RequestParams) => Promise<Transaction>;
306
333
  };
307
334
  addresses: {
308
335
  /**
@@ -321,10 +348,24 @@ export declare class Api<SecurityDataType extends unknown> extends HttpClient<Se
321
348
  * @request GET:/addresses/{address}/transactions
322
349
  */
323
350
  getAddressesAddressTransactions: (address: string, query?: {
324
- page?: number | undefined;
325
- limit?: number | undefined;
326
- reverse?: boolean | undefined;
327
- } | undefined, params?: RequestParams) => Promise<Transaction[]>;
351
+ page?: number;
352
+ limit?: number;
353
+ reverse?: boolean;
354
+ }, params?: RequestParams) => Promise<Transaction[]>;
355
+ /**
356
+ * @description List transactions of a given address within a time-range
357
+ *
358
+ * @tags Addresses
359
+ * @name GetAddressesAddressTimerangedTransactions
360
+ * @request GET:/addresses/{address}/timeranged-transactions
361
+ */
362
+ getAddressesAddressTimerangedTransactions: (address: string, query: {
363
+ fromTs: number;
364
+ toTs: number;
365
+ page?: number;
366
+ limit?: number;
367
+ reverse?: boolean;
368
+ }, params?: RequestParams) => Promise<Transaction[]>;
328
369
  /**
329
370
  * @description Get total transactions of a given address
330
371
  *
@@ -333,6 +374,14 @@ export declare class Api<SecurityDataType extends unknown> extends HttpClient<Se
333
374
  * @request GET:/addresses/{address}/total-transactions
334
375
  */
335
376
  getAddressesAddressTotalTransactions: (address: string, params?: RequestParams) => Promise<number>;
377
+ /**
378
+ * @description List unconfirmed transactions of a given address
379
+ *
380
+ * @tags Addresses
381
+ * @name GetAddressesAddressUnconfirmedTransactions
382
+ * @request GET:/addresses/{address}/unconfirmed-transactions
383
+ */
384
+ getAddressesAddressUnconfirmedTransactions: (address: string, params?: RequestParams) => Promise<TransactionLike[]>;
336
385
  /**
337
386
  * @description Get address balance
338
387
  *
@@ -341,6 +390,44 @@ export declare class Api<SecurityDataType extends unknown> extends HttpClient<Se
341
390
  * @request GET:/addresses/{address}/balance
342
391
  */
343
392
  getAddressesAddressBalance: (address: string, params?: RequestParams) => Promise<AddressBalance>;
393
+ /**
394
+ * @description List address tokens
395
+ *
396
+ * @tags Addresses
397
+ * @name GetAddressesAddressTokens
398
+ * @request GET:/addresses/{address}/tokens
399
+ */
400
+ getAddressesAddressTokens: (address: string, params?: RequestParams) => Promise<string[]>;
401
+ /**
402
+ * @description List address tokens
403
+ *
404
+ * @tags Addresses
405
+ * @name GetAddressesAddressTokensTokenIdTransactions
406
+ * @request GET:/addresses/{address}/tokens/{token_id}/transactions
407
+ */
408
+ getAddressesAddressTokensTokenIdTransactions: (address: string, tokenId: string, query?: {
409
+ page?: number;
410
+ limit?: number;
411
+ reverse?: boolean;
412
+ }, params?: RequestParams) => Promise<Transaction[]>;
413
+ /**
414
+ * @description Get address balance of given token
415
+ *
416
+ * @tags Addresses
417
+ * @name GetAddressesAddressTokensTokenIdBalance
418
+ * @request GET:/addresses/{address}/tokens/{token_id}/balance
419
+ */
420
+ getAddressesAddressTokensTokenIdBalance: (address: string, tokenId: string, params?: RequestParams) => Promise<AddressBalance>;
421
+ };
422
+ addressesActive: {
423
+ /**
424
+ * @description Are the addresses active (at least 1 transaction)
425
+ *
426
+ * @tags Addresses
427
+ * @name PostAddressesActive
428
+ * @request POST:/addresses-active
429
+ */
430
+ postAddressesActive: (data?: string[], params?: RequestParams) => Promise<boolean[]>;
344
431
  };
345
432
  infos: {
346
433
  /**
@@ -367,10 +454,10 @@ export declare class Api<SecurityDataType extends unknown> extends HttpClient<Se
367
454
  * @request GET:/infos/supply
368
455
  */
369
456
  getInfosSupply: (query?: {
370
- page?: number | undefined;
371
- limit?: number | undefined;
372
- reverse?: boolean | undefined;
373
- } | undefined, params?: RequestParams) => Promise<TokenSupply[]>;
457
+ page?: number;
458
+ limit?: number;
459
+ reverse?: boolean;
460
+ }, params?: RequestParams) => Promise<TokenSupply[]>;
374
461
  /**
375
462
  * @description Get the ALPH total supply
376
463
  *
@@ -420,6 +507,46 @@ export declare class Api<SecurityDataType extends unknown> extends HttpClient<Se
420
507
  */
421
508
  getInfosAverageBlockTimes: (params?: RequestParams) => Promise<PerChainDuration[]>;
422
509
  };
510
+ unconfirmedTransactions: {
511
+ /**
512
+ * @description list unconfirmed transactions
513
+ *
514
+ * @tags Transactions
515
+ * @name GetUnconfirmedTransactions
516
+ * @request GET:/unconfirmed-transactions
517
+ */
518
+ getUnconfirmedTransactions: (query?: {
519
+ page?: number;
520
+ limit?: number;
521
+ reverse?: boolean;
522
+ }, params?: RequestParams) => Promise<TransactionLike[]>;
523
+ };
524
+ tokens: {
525
+ /**
526
+ * @description List tokens
527
+ *
528
+ * @tags Tokens
529
+ * @name GetTokens
530
+ * @request GET:/tokens
531
+ */
532
+ getTokens: (query?: {
533
+ page?: number;
534
+ limit?: number;
535
+ reverse?: boolean;
536
+ }, params?: RequestParams) => Promise<string[]>;
537
+ /**
538
+ * @description List token transactions
539
+ *
540
+ * @tags Tokens
541
+ * @name GetTokensTokenIdTransactions
542
+ * @request GET:/tokens/{token_id}/transactions
543
+ */
544
+ getTokensTokenIdTransactions: (tokenId: string, query?: {
545
+ page?: number;
546
+ limit?: number;
547
+ reverse?: boolean;
548
+ }, params?: RequestParams) => Promise<Transaction[]>;
549
+ };
423
550
  charts: {
424
551
  /**
425
552
  * @description `interval-type` query param: hourly, daily
@@ -479,13 +606,13 @@ export declare class Api<SecurityDataType extends unknown> extends HttpClient<Se
479
606
  */
480
607
  putUtilsUpdateGlobalLoglevel: (data: 'TRACE' | 'DEBUG' | 'INFO' | 'WARN' | 'ERROR', params?: RequestParams) => Promise<void>;
481
608
  /**
482
- * @description Update logging file, only logback.xml is accepted
609
+ * @description Update logback values
483
610
  *
484
611
  * @tags Utils
485
612
  * @name PutUtilsUpdateLogConfig
486
613
  * @request PUT:/utils/update-log-config
487
614
  */
488
- putUtilsUpdateLogConfig: (data: string, params?: RequestParams) => Promise<void>;
615
+ putUtilsUpdateLogConfig: (data?: LogbackValue[], params?: RequestParams) => Promise<void>;
489
616
  };
490
617
  }
491
618
  export {};