@alephium/web3 0.1.0-rc.3 → 0.2.0-test.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 (49) 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 +75 -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 +111 -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/transaction/index.ts +20 -0
  38. package/src/{utils/transaction.test.ts → transaction/sign-verify.test.ts} +1 -1
  39. package/src/{utils/transaction.ts → transaction/sign-verify.ts} +1 -1
  40. package/src/transaction/status.ts +58 -0
  41. package/src/utils/index.ts +1 -1
  42. package/src/utils/subscription.ts +72 -0
  43. package/src/utils/utils.test.ts +2 -1
  44. package/src/utils/utils.ts +8 -0
  45. package/templates/base/package.json +1 -1
  46. package/templates/react/package.json +1 -1
  47. package/test/contract.test.ts +24 -7
  48. package/test/events.test.ts +18 -19
  49. 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 {
@@ -189,7 +210,10 @@ export interface BuildDeployContractTx {
189
210
  }
190
211
 
191
212
  export interface BuildDeployContractTxResult {
213
+ /** @format int32 */
192
214
  fromGroup: number
215
+
216
+ /** @format int32 */
193
217
  toGroup: number
194
218
  unsignedTx: string
195
219
 
@@ -225,7 +249,10 @@ export interface BuildExecuteScriptTx {
225
249
  }
226
250
 
227
251
  export interface BuildExecuteScriptTxResult {
252
+ /** @format int32 */
228
253
  fromGroup: number
254
+
255
+ /** @format int32 */
229
256
  toGroup: number
230
257
  unsignedTx: string
231
258
 
@@ -259,6 +286,8 @@ export interface BuildMultisig {
259
286
 
260
287
  export interface BuildMultisigAddress {
261
288
  keys: string[]
289
+
290
+ /** @format int32 */
262
291
  mrequired: number
263
292
  }
264
293
 
@@ -286,7 +315,11 @@ export interface BuildSweepAddressTransactions {
286
315
 
287
316
  export interface BuildSweepAddressTransactionsResult {
288
317
  unsignedTxs: SweepAddressTransaction[]
318
+
319
+ /** @format int32 */
289
320
  fromGroup: number
321
+
322
+ /** @format int32 */
290
323
  toGroup: number
291
324
  }
292
325
 
@@ -314,11 +347,16 @@ export interface BuildTransactionResult {
314
347
 
315
348
  /** @format 32-byte-hash */
316
349
  txId: string
350
+
351
+ /** @format int32 */
317
352
  fromGroup: number
353
+
354
+ /** @format int32 */
318
355
  toGroup: number
319
356
  }
320
357
 
321
358
  export interface CallContract {
359
+ /** @format int32 */
322
360
  group: number
323
361
 
324
362
  /** @format block-hash */
@@ -329,6 +367,8 @@ export interface CallContract {
329
367
 
330
368
  /** @format address */
331
369
  address: string
370
+
371
+ /** @format int32 */
332
372
  methodIndex: number
333
373
  args?: Val[]
334
374
  existingContracts?: string[]
@@ -337,6 +377,8 @@ export interface CallContract {
337
377
 
338
378
  export interface CallContractResult {
339
379
  returns: Val[]
380
+
381
+ /** @format int32 */
340
382
  gasUsed: number
341
383
  contracts: ContractState[]
342
384
  txInputs: string[]
@@ -345,13 +387,20 @@ export interface CallContractResult {
345
387
  }
346
388
 
347
389
  export interface ChainInfo {
390
+ /** @format int32 */
348
391
  currentHeight: number
349
392
  }
350
393
 
351
394
  export interface ChainParams {
352
395
  networkId: number
396
+
397
+ /** @format int32 */
353
398
  numZerosAtLeastInHash: number
399
+
400
+ /** @format int32 */
354
401
  groupNumPerBroker: number
402
+
403
+ /** @format int32 */
355
404
  groups: number
356
405
  }
357
406
 
@@ -379,9 +428,17 @@ export interface CompileScriptResult {
379
428
  export interface Confirmed {
380
429
  /** @format block-hash */
381
430
  blockHash: string
431
+
432
+ /** @format int32 */
382
433
  txIndex: number
434
+
435
+ /** @format int32 */
383
436
  chainConfirmations: number
437
+
438
+ /** @format int32 */
384
439
  fromGroupConfirmations: number
440
+
441
+ /** @format int32 */
385
442
  toGroupConfirmations: number
386
443
  type: string
387
444
  }
@@ -396,6 +453,8 @@ export interface ContractEvent {
396
453
 
397
454
  /** @format 32-byte-hash */
398
455
  txId: string
456
+
457
+ /** @format int32 */
399
458
  eventIndex: number
400
459
  fields: Val[]
401
460
  }
@@ -406,21 +465,28 @@ export interface ContractEventByTxId {
406
465
 
407
466
  /** @format address */
408
467
  contractAddress: string
468
+
469
+ /** @format int32 */
409
470
  eventIndex: number
410
471
  fields: Val[]
411
472
  }
412
473
 
413
474
  export interface ContractEvents {
414
475
  events: ContractEvent[]
476
+
477
+ /** @format int32 */
415
478
  nextStart: number
416
479
  }
417
480
 
418
481
  export interface ContractEventsByTxId {
419
482
  events: ContractEventByTxId[]
483
+
484
+ /** @format int32 */
420
485
  nextStart: number
421
486
  }
422
487
 
423
488
  export interface ContractOutput {
489
+ /** @format int32 */
424
490
  hint: number
425
491
 
426
492
  /** @format 32-byte-hash */
@@ -456,7 +522,10 @@ export interface DecodeUnsignedTx {
456
522
  }
457
523
 
458
524
  export interface DecodeUnsignedTxResult {
525
+ /** @format int32 */
459
526
  fromGroup: number
527
+
528
+ /** @format int32 */
460
529
  toGroup: number
461
530
  unsignedTx: UnsignedTx
462
531
  }
@@ -496,6 +565,7 @@ export interface FieldsSig {
496
565
  }
497
566
 
498
567
  export interface FixedAssetOutput {
568
+ /** @format int32 */
499
569
  hint: number
500
570
 
501
571
  /** @format 32-byte-hash */
@@ -524,6 +594,7 @@ export interface FunctionSig {
524
594
  }
525
595
 
526
596
  export interface Group {
597
+ /** @format int32 */
527
598
  group: number
528
599
  }
529
600
 
@@ -534,11 +605,15 @@ export interface HashesAtHeight {
534
605
  export interface InterCliquePeerInfo {
535
606
  /** @format clique-id */
536
607
  cliqueId: string
608
+
609
+ /** @format int32 */
537
610
  brokerId: number
611
+
612
+ /** @format int32 */
538
613
  groupNumPerBroker: number
539
614
 
540
615
  /** @format inet-socket-address */
541
- address: string
616
+ address: { addr: string; port: number }
542
617
  isSynced: boolean
543
618
  clientVersion: string
544
619
  }
@@ -566,7 +641,7 @@ export interface NodeInfo {
566
641
  upnp: boolean
567
642
 
568
643
  /** @format inet-socket-address */
569
- externalAddress?: string
644
+ externalAddress?: { addr: string; port: number }
570
645
  }
571
646
 
572
647
  export interface NodeVersion {
@@ -581,6 +656,7 @@ export interface NotFound {
581
656
  export type Output = AssetOutput | ContractOutput
582
657
 
583
658
  export interface OutputRef {
659
+ /** @format int32 */
584
660
  hint: number
585
661
 
586
662
  /** @format 32-byte-hash */
@@ -590,8 +666,14 @@ export interface OutputRef {
590
666
  export interface PeerAddress {
591
667
  /** @format inet-address */
592
668
  address: string
669
+
670
+ /** @format int32 */
593
671
  restPort: number
672
+
673
+ /** @format int32 */
594
674
  wsPort: number
675
+
676
+ /** @format int32 */
595
677
  minerApiPort: number
596
678
  }
597
679
 
@@ -604,6 +686,7 @@ export interface PeerMisbehavior {
604
686
  export type PeerStatus = Banned | Penalty
605
687
 
606
688
  export interface Penalty {
689
+ /** @format int32 */
607
690
  value: number
608
691
  type: string
609
692
  }
@@ -614,8 +697,13 @@ export interface Reachable {
614
697
  }
615
698
 
616
699
  export interface ReleaseVersion {
700
+ /** @format int32 */
617
701
  major: number
702
+
703
+ /** @format int32 */
618
704
  minor: number
705
+
706
+ /** @format int32 */
619
707
  patch: number
620
708
  }
621
709
 
@@ -667,7 +755,11 @@ export interface SubmitTransaction {
667
755
  export interface SubmitTxResult {
668
756
  /** @format 32-byte-hash */
669
757
  txId: string
758
+
759
+ /** @format int32 */
670
760
  fromGroup: number
761
+
762
+ /** @format int32 */
671
763
  toGroup: number
672
764
  }
673
765
 
@@ -683,6 +775,8 @@ export interface Sweep {
683
775
 
684
776
  /** @format uint256 */
685
777
  gasPrice?: string
778
+
779
+ /** @format int32 */
686
780
  utxosLimit?: number
687
781
  }
688
782
 
@@ -699,6 +793,7 @@ export interface SweepAddressTransaction {
699
793
  }
700
794
 
701
795
  export interface TestContract {
796
+ /** @format int32 */
702
797
  group?: number
703
798
 
704
799
  /** @format block-hash */
@@ -714,6 +809,8 @@ export interface TestContract {
714
809
  bytecode: string
715
810
  initialFields?: Val[]
716
811
  initialAsset?: AssetState
812
+
813
+ /** @format int32 */
717
814
  methodIndex?: number
718
815
  args?: Val[]
719
816
  existingContracts?: ContractState[]
@@ -727,6 +824,8 @@ export interface TestContractResult {
727
824
  /** @format 32-byte-hash */
728
825
  codeHash: string
729
826
  returns: Val[]
827
+
828
+ /** @format int32 */
730
829
  gasUsed: number
731
830
  contracts: ContractState[]
732
831
  txInputs: string[]
@@ -771,6 +870,8 @@ export interface Transfer {
771
870
 
772
871
  /** @format uint256 */
773
872
  gasPrice?: string
873
+
874
+ /** @format int32 */
774
875
  utxosLimit?: number
775
876
  }
776
877
 
@@ -824,7 +925,10 @@ export interface Unban {
824
925
  }
825
926
 
826
927
  export interface UnconfirmedTransactions {
928
+ /** @format int32 */
827
929
  fromGroup: number
930
+
931
+ /** @format int32 */
828
932
  toGroup: number
829
933
  unconfirmedTransactions: TransactionTemplate[]
830
934
  }
@@ -842,6 +946,8 @@ export interface UnsignedTx {
842
946
 
843
947
  /** @format script */
844
948
  scriptOpt?: string
949
+
950
+ /** @format int32 */
845
951
  gasAmount: number
846
952
 
847
953
  /** @format uint256 */
@@ -875,6 +981,7 @@ export interface ValByteVec {
875
981
  }
876
982
 
877
983
  export interface ValI256 {
984
+ /** @format bigint */
878
985
  value: string
879
986
  type: string
880
987
  }
@@ -1157,7 +1264,7 @@ export class HttpClient<SecurityDataType = unknown> {
1157
1264
 
1158
1265
  /**
1159
1266
  * @title Alephium API
1160
- * @version 1.4.0
1267
+ * @version 1.4.2
1161
1268
  * @baseUrl {protocol}://{host}:{port}
1162
1269
  */
1163
1270
  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