@alephium/web3 0.1.0-rc.3 → 0.2.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 (50) hide show
  1. package/contracts/{add.ral → add/add.ral} +1 -1
  2. package/contracts/{greeter.ral → greeter/greeter.ral} +0 -0
  3. package/contracts/{greeter_interface.ral → greeter/greeter_interface.ral} +0 -0
  4. package/contracts/greeter_main.ral +1 -1
  5. package/contracts/main.ral +1 -1
  6. package/contracts/{sub.ral → sub/sub.ral} +0 -0
  7. package/dev/user.conf +1 -0
  8. package/dist/alephium-web3.min.js +1 -1
  9. package/dist/alephium-web3.min.js.map +1 -1
  10. package/dist/src/api/api-alephium.d.ts +85 -4
  11. package/dist/src/api/api-alephium.js +1 -1
  12. package/dist/src/api/api-explorer.d.ts +33 -6
  13. package/dist/src/contract/contract.d.ts +18 -10
  14. package/dist/src/contract/contract.js +95 -56
  15. package/dist/src/contract/events.d.ts +7 -25
  16. package/dist/src/contract/events.js +18 -31
  17. package/dist/src/index.d.ts +1 -0
  18. package/dist/src/index.js +1 -0
  19. package/dist/src/transaction/index.d.ts +2 -0
  20. package/dist/src/transaction/index.js +31 -0
  21. package/dist/src/{utils/transaction.d.ts → transaction/sign-verify.d.ts} +0 -0
  22. package/dist/src/{utils/transaction.js → transaction/sign-verify.js} +1 -1
  23. package/dist/src/transaction/status.d.ts +10 -0
  24. package/dist/src/transaction/status.js +48 -0
  25. package/dist/src/utils/index.d.ts +1 -1
  26. package/dist/src/utils/index.js +1 -1
  27. package/dist/src/utils/subscription.d.ts +24 -0
  28. package/dist/src/utils/subscription.js +52 -0
  29. package/dist/src/utils/utils.d.ts +2 -0
  30. package/dist/src/utils/utils.js +9 -1
  31. package/package.json +3 -3
  32. package/src/api/api-alephium.ts +126 -4
  33. package/src/api/api-explorer.ts +50 -6
  34. package/src/contract/contract.ts +112 -66
  35. package/src/contract/events.ts +21 -48
  36. package/src/index.ts +1 -0
  37. package/src/signer/signer.ts +1 -1
  38. package/src/transaction/index.ts +20 -0
  39. package/src/{utils/transaction.test.ts → transaction/sign-verify.test.ts} +1 -1
  40. package/src/{utils/transaction.ts → transaction/sign-verify.ts} +1 -1
  41. package/src/transaction/status.ts +58 -0
  42. package/src/utils/index.ts +1 -1
  43. package/src/utils/subscription.ts +72 -0
  44. package/src/utils/utils.test.ts +2 -1
  45. package/src/utils/utils.ts +8 -0
  46. package/templates/base/package.json +2 -2
  47. package/templates/react/package.json +2 -2
  48. package/test/contract.test.ts +24 -7
  49. package/test/events.test.ts +18 -19
  50. package/test/transaction.test.ts +72 -0
@@ -53,6 +53,7 @@ export interface AssetInput {
53
53
  }
54
54
 
55
55
  export interface AssetOutput {
56
+ /** @format int32 */
56
57
  hint: number
57
58
 
58
59
  /** @format 32-byte-hash */
@@ -95,6 +96,10 @@ export interface Balance {
95
96
 
96
97
  /** @format x.x ALPH */
97
98
  lockedBalanceHint: string
99
+ tokenBalances?: Token[]
100
+ lockedTokenBalances?: Token[]
101
+
102
+ /** @format int32 */
98
103
  utxoNum: number
99
104
  warning?: string
100
105
  }
@@ -125,8 +130,14 @@ export interface BlockEntry {
125
130
 
126
131
  /** @format int64 */
127
132
  timestamp: number
133
+
134
+ /** @format int32 */
128
135
  chainFrom: number
136
+
137
+ /** @format int32 */
129
138
  chainTo: number
139
+
140
+ /** @format int32 */
130
141
  height: number
131
142
  deps: string[]
132
143
  transactions: Transaction[]
@@ -151,8 +162,14 @@ export interface BlockHeaderEntry {
151
162
 
152
163
  /** @format int64 */
153
164
  timestamp: number
165
+
166
+ /** @format int32 */
154
167
  chainFrom: number
168
+
169
+ /** @format int32 */
155
170
  chainTo: number
171
+
172
+ /** @format int32 */
156
173
  height: number
157
174
  deps: string[]
158
175
  }
@@ -160,11 +177,15 @@ export interface BlockHeaderEntry {
160
177
  export interface BrokerInfo {
161
178
  /** @format clique-id */
162
179
  cliqueId: string
180
+
181
+ /** @format int32 */
163
182
  brokerId: number
183
+
184
+ /** @format int32 */
164
185
  brokerNum: number
165
186
 
166
187
  /** @format inet-socket-address */
167
- address: string
188
+ address: { addr: string; port: number }
168
189
  }
169
190
 
170
191
  export interface BuildDeployContractTx {
@@ -186,10 +207,16 @@ export interface BuildDeployContractTx {
186
207
 
187
208
  /** @format uint256 */
188
209
  gasPrice?: string
210
+
211
+ /** @format block-hash */
212
+ targetBlockHash?: string
189
213
  }
190
214
 
191
215
  export interface BuildDeployContractTxResult {
216
+ /** @format int32 */
192
217
  fromGroup: number
218
+
219
+ /** @format int32 */
193
220
  toGroup: number
194
221
  unsignedTx: string
195
222
 
@@ -222,10 +249,16 @@ export interface BuildExecuteScriptTx {
222
249
 
223
250
  /** @format uint256 */
224
251
  gasPrice?: string
252
+
253
+ /** @format block-hash */
254
+ targetBlockHash?: string
225
255
  }
226
256
 
227
257
  export interface BuildExecuteScriptTxResult {
258
+ /** @format int32 */
228
259
  fromGroup: number
260
+
261
+ /** @format int32 */
229
262
  toGroup: number
230
263
  unsignedTx: string
231
264
 
@@ -259,6 +292,8 @@ export interface BuildMultisig {
259
292
 
260
293
  export interface BuildMultisigAddress {
261
294
  keys: string[]
295
+
296
+ /** @format int32 */
262
297
  mrequired: number
263
298
  }
264
299
 
@@ -282,11 +317,18 @@ export interface BuildSweepAddressTransactions {
282
317
 
283
318
  /** @format uint256 */
284
319
  gasPrice?: string
320
+
321
+ /** @format block-hash */
322
+ targetBlockHash?: string
285
323
  }
286
324
 
287
325
  export interface BuildSweepAddressTransactionsResult {
288
326
  unsignedTxs: SweepAddressTransaction[]
327
+
328
+ /** @format int32 */
289
329
  fromGroup: number
330
+
331
+ /** @format int32 */
290
332
  toGroup: number
291
333
  }
292
334
 
@@ -301,6 +343,9 @@ export interface BuildTransaction {
301
343
 
302
344
  /** @format uint256 */
303
345
  gasPrice?: string
346
+
347
+ /** @format block-hash */
348
+ targetBlockHash?: string
304
349
  }
305
350
 
306
351
  export interface BuildTransactionResult {
@@ -314,11 +359,16 @@ export interface BuildTransactionResult {
314
359
 
315
360
  /** @format 32-byte-hash */
316
361
  txId: string
362
+
363
+ /** @format int32 */
317
364
  fromGroup: number
365
+
366
+ /** @format int32 */
318
367
  toGroup: number
319
368
  }
320
369
 
321
370
  export interface CallContract {
371
+ /** @format int32 */
322
372
  group: number
323
373
 
324
374
  /** @format block-hash */
@@ -329,6 +379,8 @@ export interface CallContract {
329
379
 
330
380
  /** @format address */
331
381
  address: string
382
+
383
+ /** @format int32 */
332
384
  methodIndex: number
333
385
  args?: Val[]
334
386
  existingContracts?: string[]
@@ -337,6 +389,8 @@ export interface CallContract {
337
389
 
338
390
  export interface CallContractResult {
339
391
  returns: Val[]
392
+
393
+ /** @format int32 */
340
394
  gasUsed: number
341
395
  contracts: ContractState[]
342
396
  txInputs: string[]
@@ -345,13 +399,20 @@ export interface CallContractResult {
345
399
  }
346
400
 
347
401
  export interface ChainInfo {
402
+ /** @format int32 */
348
403
  currentHeight: number
349
404
  }
350
405
 
351
406
  export interface ChainParams {
352
407
  networkId: number
408
+
409
+ /** @format int32 */
353
410
  numZerosAtLeastInHash: number
411
+
412
+ /** @format int32 */
354
413
  groupNumPerBroker: number
414
+
415
+ /** @format int32 */
355
416
  groups: number
356
417
  }
357
418
 
@@ -379,9 +440,17 @@ export interface CompileScriptResult {
379
440
  export interface Confirmed {
380
441
  /** @format block-hash */
381
442
  blockHash: string
443
+
444
+ /** @format int32 */
382
445
  txIndex: number
446
+
447
+ /** @format int32 */
383
448
  chainConfirmations: number
449
+
450
+ /** @format int32 */
384
451
  fromGroupConfirmations: number
452
+
453
+ /** @format int32 */
385
454
  toGroupConfirmations: number
386
455
  type: string
387
456
  }
@@ -396,6 +465,8 @@ export interface ContractEvent {
396
465
 
397
466
  /** @format 32-byte-hash */
398
467
  txId: string
468
+
469
+ /** @format int32 */
399
470
  eventIndex: number
400
471
  fields: Val[]
401
472
  }
@@ -406,21 +477,28 @@ export interface ContractEventByTxId {
406
477
 
407
478
  /** @format address */
408
479
  contractAddress: string
480
+
481
+ /** @format int32 */
409
482
  eventIndex: number
410
483
  fields: Val[]
411
484
  }
412
485
 
413
486
  export interface ContractEvents {
414
487
  events: ContractEvent[]
488
+
489
+ /** @format int32 */
415
490
  nextStart: number
416
491
  }
417
492
 
418
493
  export interface ContractEventsByTxId {
419
494
  events: ContractEventByTxId[]
495
+
496
+ /** @format int32 */
420
497
  nextStart: number
421
498
  }
422
499
 
423
500
  export interface ContractOutput {
501
+ /** @format int32 */
424
502
  hint: number
425
503
 
426
504
  /** @format 32-byte-hash */
@@ -456,7 +534,10 @@ export interface DecodeUnsignedTx {
456
534
  }
457
535
 
458
536
  export interface DecodeUnsignedTxResult {
537
+ /** @format int32 */
459
538
  fromGroup: number
539
+
540
+ /** @format int32 */
460
541
  toGroup: number
461
542
  unsignedTx: UnsignedTx
462
543
  }
@@ -496,6 +577,7 @@ export interface FieldsSig {
496
577
  }
497
578
 
498
579
  export interface FixedAssetOutput {
580
+ /** @format int32 */
499
581
  hint: number
500
582
 
501
583
  /** @format 32-byte-hash */
@@ -524,6 +606,7 @@ export interface FunctionSig {
524
606
  }
525
607
 
526
608
  export interface Group {
609
+ /** @format int32 */
527
610
  group: number
528
611
  }
529
612
 
@@ -534,11 +617,15 @@ export interface HashesAtHeight {
534
617
  export interface InterCliquePeerInfo {
535
618
  /** @format clique-id */
536
619
  cliqueId: string
620
+
621
+ /** @format int32 */
537
622
  brokerId: number
623
+
624
+ /** @format int32 */
538
625
  groupNumPerBroker: number
539
626
 
540
627
  /** @format inet-socket-address */
541
- address: string
628
+ address: { addr: string; port: number }
542
629
  isSynced: boolean
543
630
  clientVersion: string
544
631
  }
@@ -566,7 +653,7 @@ export interface NodeInfo {
566
653
  upnp: boolean
567
654
 
568
655
  /** @format inet-socket-address */
569
- externalAddress?: string
656
+ externalAddress?: { addr: string; port: number }
570
657
  }
571
658
 
572
659
  export interface NodeVersion {
@@ -581,6 +668,7 @@ export interface NotFound {
581
668
  export type Output = AssetOutput | ContractOutput
582
669
 
583
670
  export interface OutputRef {
671
+ /** @format int32 */
584
672
  hint: number
585
673
 
586
674
  /** @format 32-byte-hash */
@@ -590,8 +678,14 @@ export interface OutputRef {
590
678
  export interface PeerAddress {
591
679
  /** @format inet-address */
592
680
  address: string
681
+
682
+ /** @format int32 */
593
683
  restPort: number
684
+
685
+ /** @format int32 */
594
686
  wsPort: number
687
+
688
+ /** @format int32 */
595
689
  minerApiPort: number
596
690
  }
597
691
 
@@ -604,6 +698,7 @@ export interface PeerMisbehavior {
604
698
  export type PeerStatus = Banned | Penalty
605
699
 
606
700
  export interface Penalty {
701
+ /** @format int32 */
607
702
  value: number
608
703
  type: string
609
704
  }
@@ -614,8 +709,13 @@ export interface Reachable {
614
709
  }
615
710
 
616
711
  export interface ReleaseVersion {
712
+ /** @format int32 */
617
713
  major: number
714
+
715
+ /** @format int32 */
618
716
  minor: number
717
+
718
+ /** @format int32 */
619
719
  patch: number
620
720
  }
621
721
 
@@ -667,7 +767,11 @@ export interface SubmitTransaction {
667
767
  export interface SubmitTxResult {
668
768
  /** @format 32-byte-hash */
669
769
  txId: string
770
+
771
+ /** @format int32 */
670
772
  fromGroup: number
773
+
774
+ /** @format int32 */
671
775
  toGroup: number
672
776
  }
673
777
 
@@ -683,7 +787,12 @@ export interface Sweep {
683
787
 
684
788
  /** @format uint256 */
685
789
  gasPrice?: string
790
+
791
+ /** @format int32 */
686
792
  utxosLimit?: number
793
+
794
+ /** @format block-hash */
795
+ targetBlockHash?: string
687
796
  }
688
797
 
689
798
  export interface SweepAddressTransaction {
@@ -699,6 +808,7 @@ export interface SweepAddressTransaction {
699
808
  }
700
809
 
701
810
  export interface TestContract {
811
+ /** @format int32 */
702
812
  group?: number
703
813
 
704
814
  /** @format block-hash */
@@ -714,6 +824,8 @@ export interface TestContract {
714
824
  bytecode: string
715
825
  initialFields?: Val[]
716
826
  initialAsset?: AssetState
827
+
828
+ /** @format int32 */
717
829
  methodIndex?: number
718
830
  args?: Val[]
719
831
  existingContracts?: ContractState[]
@@ -727,6 +839,8 @@ export interface TestContractResult {
727
839
  /** @format 32-byte-hash */
728
840
  codeHash: string
729
841
  returns: Val[]
842
+
843
+ /** @format int32 */
730
844
  gasUsed: number
731
845
  contracts: ContractState[]
732
846
  txInputs: string[]
@@ -771,6 +885,8 @@ export interface Transfer {
771
885
 
772
886
  /** @format uint256 */
773
887
  gasPrice?: string
888
+
889
+ /** @format int32 */
774
890
  utxosLimit?: number
775
891
  }
776
892
 
@@ -824,7 +940,10 @@ export interface Unban {
824
940
  }
825
941
 
826
942
  export interface UnconfirmedTransactions {
943
+ /** @format int32 */
827
944
  fromGroup: number
945
+
946
+ /** @format int32 */
828
947
  toGroup: number
829
948
  unconfirmedTransactions: TransactionTemplate[]
830
949
  }
@@ -842,6 +961,8 @@ export interface UnsignedTx {
842
961
 
843
962
  /** @format script */
844
963
  scriptOpt?: string
964
+
965
+ /** @format int32 */
845
966
  gasAmount: number
846
967
 
847
968
  /** @format uint256 */
@@ -875,6 +996,7 @@ export interface ValByteVec {
875
996
  }
876
997
 
877
998
  export interface ValI256 {
999
+ /** @format bigint */
878
1000
  value: string
879
1001
  type: string
880
1002
  }
@@ -1157,7 +1279,7 @@ export class HttpClient<SecurityDataType = unknown> {
1157
1279
 
1158
1280
  /**
1159
1281
  * @title Alephium API
1160
- * @version 1.4.0
1282
+ * @version 1.5.0-rc0
1161
1283
  * @baseUrl {protocol}://{host}:{port}
1162
1284
  */
1163
1285
  export class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDataType> {
@@ -23,6 +23,8 @@ export interface AddressInfo {
23
23
 
24
24
  /** @format uint256 */
25
25
  lockedBalance: string
26
+
27
+ /** @format int32 */
26
28
  txNumber: number
27
29
  }
28
30
 
@@ -31,13 +33,22 @@ export interface BadRequest {
31
33
  }
32
34
 
33
35
  export interface BlockEntryLite {
36
+ /** @format block-hash */
34
37
  hash: string
35
38
 
36
39
  /** @format int64 */
37
40
  timestamp: number
41
+
42
+ /** @format int32 */
38
43
  chainFrom: number
44
+
45
+ /** @format int32 */
39
46
  chainTo: number
47
+
48
+ /** @format int32 */
40
49
  height: number
50
+
51
+ /** @format int32 */
41
52
  txNumber: number
42
53
  mainChain: boolean
43
54
 
@@ -46,13 +57,18 @@ export interface BlockEntryLite {
46
57
  }
47
58
 
48
59
  export interface ConfirmedTransaction {
60
+ /** @format 32-byte-hash */
49
61
  hash: string
62
+
63
+ /** @format block-hash */
50
64
  blockHash: string
51
65
 
52
66
  /** @format int64 */
53
67
  timestamp: number
54
68
  inputs?: Input[]
55
69
  outputs?: Output[]
70
+
71
+ /** @format int32 */
56
72
  gasAmount: number
57
73
 
58
74
  /** @format uint256 */
@@ -68,13 +84,15 @@ export interface ExplorerInfo {
68
84
  export interface Hashrate {
69
85
  /** @format int64 */
70
86
  timestamp: number
71
- hashrate: string
72
- value: string
87
+ hashrate: number
88
+ value: number
73
89
  }
74
90
 
75
91
  export interface Input {
76
92
  outputRef: OutputRef
77
93
  unlockScript?: string
94
+
95
+ /** @format 32-byte-hash */
78
96
  txHashRef: string
79
97
  address: string
80
98
 
@@ -87,6 +105,7 @@ export interface InternalServerError {
87
105
  }
88
106
 
89
107
  export interface ListBlocks {
108
+ /** @format int32 */
90
109
  total: number
91
110
  blocks?: BlockEntryLite[]
92
111
  }
@@ -97,6 +116,7 @@ export interface NotFound {
97
116
  }
98
117
 
99
118
  export interface Output {
119
+ /** @format int32 */
100
120
  hint: number
101
121
 
102
122
  /** @format 32-byte-hash */
@@ -108,10 +128,13 @@ export interface Output {
108
128
 
109
129
  /** @format int64 */
110
130
  lockTime?: number
131
+
132
+ /** @format 32-byte-hash */
111
133
  spent?: string
112
134
  }
113
135
 
114
136
  export interface OutputRef {
137
+ /** @format int32 */
115
138
  hint: number
116
139
 
117
140
  /** @format 32-byte-hash */
@@ -119,7 +142,10 @@ export interface OutputRef {
119
142
  }
120
143
 
121
144
  export interface PerChainCount {
145
+ /** @format int32 */
122
146
  chainFrom: number
147
+
148
+ /** @format int32 */
123
149
  chainTo: number
124
150
 
125
151
  /** @format int64 */
@@ -127,7 +153,10 @@ export interface PerChainCount {
127
153
  }
128
154
 
129
155
  export interface PerChainDuration {
156
+ /** @format int32 */
130
157
  chainFrom: number
158
+
159
+ /** @format int32 */
131
160
  chainTo: number
132
161
 
133
162
  /** @format int64 */
@@ -138,7 +167,10 @@ export interface PerChainDuration {
138
167
  }
139
168
 
140
169
  export interface PerChainHeight {
170
+ /** @format int32 */
141
171
  chainFrom: number
172
+
173
+ /** @format int32 */
142
174
  chainTo: number
143
175
 
144
176
  /** @format int64 */
@@ -187,13 +219,18 @@ export interface TokenSupply {
187
219
  }
188
220
 
189
221
  export interface Transaction {
222
+ /** @format 32-byte-hash */
190
223
  hash: string
224
+
225
+ /** @format block-hash */
191
226
  blockHash: string
192
227
 
193
228
  /** @format int64 */
194
229
  timestamp: number
195
230
  inputs?: Input[]
196
231
  outputs?: Output[]
232
+
233
+ /** @format int32 */
197
234
  gasAmount: number
198
235
 
199
236
  /** @format uint256 */
@@ -221,11 +258,18 @@ export interface Unauthorized {
221
258
  }
222
259
 
223
260
  export interface UnconfirmedTransaction {
261
+ /** @format 32-byte-hash */
224
262
  hash: string
263
+
264
+ /** @format int32 */
225
265
  chainFrom: number
266
+
267
+ /** @format int32 */
226
268
  chainTo: number
227
269
  inputs?: UInput[]
228
270
  outputs?: UOutput[]
271
+
272
+ /** @format int32 */
229
273
  gasAmount: number
230
274
 
231
275
  /** @format uint256 */
@@ -647,7 +691,7 @@ export class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDa
647
691
  * @request GET:/infos/supply/total-alph
648
692
  */
649
693
  getInfosSupplyTotalAlph: (params: RequestParams = {}) =>
650
- this.request<string, BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable>({
694
+ this.request<number, BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable>({
651
695
  path: `/infos/supply/total-alph`,
652
696
  method: 'GET',
653
697
  ...params
@@ -661,7 +705,7 @@ export class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDa
661
705
  * @request GET:/infos/supply/circulating-alph
662
706
  */
663
707
  getInfosSupplyCirculatingAlph: (params: RequestParams = {}) =>
664
- this.request<string, BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable>({
708
+ this.request<number, BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable>({
665
709
  path: `/infos/supply/circulating-alph`,
666
710
  method: 'GET',
667
711
  ...params
@@ -675,7 +719,7 @@ export class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDa
675
719
  * @request GET:/infos/supply/reserved-alph
676
720
  */
677
721
  getInfosSupplyReservedAlph: (params: RequestParams = {}) =>
678
- this.request<string, BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable>({
722
+ this.request<number, BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable>({
679
723
  path: `/infos/supply/reserved-alph`,
680
724
  method: 'GET',
681
725
  ...params
@@ -689,7 +733,7 @@ export class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDa
689
733
  * @request GET:/infos/supply/locked-alph
690
734
  */
691
735
  getInfosSupplyLockedAlph: (params: RequestParams = {}) =>
692
- this.request<string, BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable>({
736
+ this.request<number, BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable>({
693
737
  path: `/infos/supply/locked-alph`,
694
738
  method: 'GET',
695
739
  ...params