@alephium/web3 0.5.0-rc.9 → 0.5.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 (38) hide show
  1. package/dist/alephium-web3.min.js +1 -1
  2. package/dist/alephium-web3.min.js.map +1 -1
  3. package/dist/src/api/api-alephium.d.ts +56 -6
  4. package/dist/src/api/api-alephium.js +5 -3
  5. package/dist/src/api/api-explorer.d.ts +222 -52
  6. package/dist/src/api/api-explorer.js +17 -15
  7. package/dist/src/api/explorer-provider.d.ts +18 -0
  8. package/dist/src/api/explorer-provider.js +65 -0
  9. package/dist/src/api/index.d.ts +2 -42
  10. package/dist/src/api/index.js +6 -117
  11. package/dist/src/api/node-provider.d.ts +21 -0
  12. package/dist/src/api/node-provider.js +68 -0
  13. package/dist/src/api/types.d.ts +9 -1
  14. package/dist/src/api/types.js +17 -1
  15. package/dist/src/contract/contract.d.ts +6 -3
  16. package/dist/src/contract/contract.js +31 -28
  17. package/dist/src/signer/signer.d.ts +4 -8
  18. package/dist/src/signer/signer.js +26 -8
  19. package/dist/src/signer/types.d.ts +4 -16
  20. package/dist/src/utils/index.d.ts +1 -0
  21. package/dist/src/utils/index.js +1 -0
  22. package/dist/src/utils/number.d.ts +18 -0
  23. package/dist/src/utils/number.fixture.d.ts +12 -0
  24. package/dist/src/utils/number.fixture.js +189 -0
  25. package/dist/src/utils/number.js +148 -0
  26. package/package.json +6 -5
  27. package/src/api/api-alephium.ts +177 -180
  28. package/src/api/api-explorer.ts +327 -126
  29. package/src/api/explorer-provider.ts +78 -0
  30. package/src/api/index.ts +2 -148
  31. package/src/api/node-provider.ts +84 -0
  32. package/src/api/types.ts +24 -1
  33. package/src/contract/contract.ts +31 -29
  34. package/src/signer/signer.ts +33 -26
  35. package/src/signer/types.ts +12 -9
  36. package/src/utils/index.ts +1 -0
  37. package/src/utils/number.fixture.ts +187 -0
  38. package/src/utils/number.ts +162 -0
@@ -12,16 +12,12 @@
12
12
  export interface AddressBalance {
13
13
  /** @format address */
14
14
  address: string
15
-
16
15
  /** @format uint256 */
17
16
  balance: string
18
-
19
17
  /** @format x.x ALPH */
20
18
  balanceHint: string
21
-
22
19
  /** @format uint256 */
23
20
  lockedBalance: string
24
-
25
21
  /** @format x.x ALPH */
26
22
  lockedBalanceHint: string
27
23
  warning?: string
@@ -30,10 +26,8 @@ export interface AddressBalance {
30
26
  export interface AddressInfo {
31
27
  /** @format address */
32
28
  address: string
33
-
34
29
  /** @format public-key */
35
30
  publicKey: string
36
-
37
31
  /** @format group-index */
38
32
  group: number
39
33
  path: string
@@ -47,7 +41,6 @@ export interface Addresses {
47
41
 
48
42
  export interface AssetInput {
49
43
  outputRef: OutputRef
50
-
51
44
  /** @format hex-string */
52
45
  unlockScript: string
53
46
  }
@@ -55,20 +48,15 @@ export interface AssetInput {
55
48
  export interface AssetOutput {
56
49
  /** @format int32 */
57
50
  hint: number
58
-
59
51
  /** @format 32-byte-hash */
60
52
  key: string
61
-
62
53
  /** @format uint256 */
63
54
  attoAlphAmount: string
64
-
65
55
  /** @format address */
66
56
  address: string
67
57
  tokens: Token[]
68
-
69
58
  /** @format int64 */
70
59
  lockTime: number
71
-
72
60
  /** @format hex-string */
73
61
  message: string
74
62
  type: string
@@ -87,18 +75,14 @@ export interface BadRequest {
87
75
  export interface Balance {
88
76
  /** @format uint256 */
89
77
  balance: string
90
-
91
78
  /** @format x.x ALPH */
92
79
  balanceHint: string
93
-
94
80
  /** @format uint256 */
95
81
  lockedBalance: string
96
-
97
82
  /** @format x.x ALPH */
98
83
  lockedBalanceHint: string
99
84
  tokenBalances?: Token[]
100
85
  lockedTokenBalances?: Token[]
101
-
102
86
  /** @format int32 */
103
87
  utxoNum: number
104
88
  warning?: string
@@ -107,7 +91,6 @@ export interface Balance {
107
91
  export interface Balances {
108
92
  /** @format uint256 */
109
93
  totalBalance: string
110
-
111
94
  /** @format x.x ALPH */
112
95
  totalBalanceHint: string
113
96
  balances: AddressBalance[]
@@ -132,31 +115,23 @@ export interface BlockAndEvents {
132
115
  export interface BlockEntry {
133
116
  /** @format block-hash */
134
117
  hash: string
135
-
136
118
  /** @format int64 */
137
119
  timestamp: number
138
-
139
120
  /** @format int32 */
140
121
  chainFrom: number
141
-
142
122
  /** @format int32 */
143
123
  chainTo: number
144
-
145
124
  /** @format int32 */
146
125
  height: number
147
126
  deps: string[]
148
127
  transactions: Transaction[]
149
-
150
128
  /** @format hex-string */
151
129
  nonce: string
152
130
  version: number
153
-
154
131
  /** @format 32-byte-hash */
155
132
  depStateHash: string
156
-
157
133
  /** @format 32-byte-hash */
158
134
  txsHash: string
159
-
160
135
  /** @format hex-string */
161
136
  target: string
162
137
  }
@@ -164,16 +139,12 @@ export interface BlockEntry {
164
139
  export interface BlockHeaderEntry {
165
140
  /** @format block-hash */
166
141
  hash: string
167
-
168
142
  /** @format int64 */
169
143
  timestamp: number
170
-
171
144
  /** @format int32 */
172
145
  chainFrom: number
173
-
174
146
  /** @format int32 */
175
147
  chainTo: number
176
-
177
148
  /** @format int32 */
178
149
  height: number
179
150
  deps: string[]
@@ -190,40 +161,34 @@ export interface BlocksPerTimeStampRange {
190
161
  export interface BrokerInfo {
191
162
  /** @format clique-id */
192
163
  cliqueId: string
193
-
194
164
  /** @format int32 */
195
165
  brokerId: number
196
-
197
166
  /** @format int32 */
198
167
  brokerNum: number
199
-
200
168
  /** @format inet-socket-address */
201
- address: { addr: string; port: number }
169
+ address: {
170
+ addr: string
171
+ /** @format int32 */
172
+ port: number
173
+ }
202
174
  }
203
175
 
204
176
  export interface BuildDeployContractTx {
205
177
  /** @format hex-string */
206
178
  fromPublicKey: string
207
-
208
179
  /** @format hex-string */
209
180
  fromPublicKeyType?: string
210
-
211
181
  /** @format hex-string */
212
182
  bytecode: string
213
-
214
183
  /** @format uint256 */
215
184
  initialAttoAlphAmount?: string
216
185
  initialTokenAmounts?: Token[]
217
-
218
186
  /** @format uint256 */
219
187
  issueTokenAmount?: string
220
-
221
188
  /** @format gas */
222
189
  gasAmount?: number
223
-
224
190
  /** @format uint256 */
225
191
  gasPrice?: string
226
-
227
192
  /** @format block-hash */
228
193
  targetBlockHash?: string
229
194
  }
@@ -231,20 +196,15 @@ export interface BuildDeployContractTx {
231
196
  export interface BuildDeployContractTxResult {
232
197
  /** @format int32 */
233
198
  fromGroup: number
234
-
235
199
  /** @format int32 */
236
200
  toGroup: number
237
201
  unsignedTx: string
238
-
239
202
  /** @format gas */
240
203
  gasAmount: number
241
-
242
204
  /** @format uint256 */
243
205
  gasPrice: string
244
-
245
206
  /** @format 32-byte-hash */
246
207
  txId: string
247
-
248
208
  /** @format address */
249
209
  contractAddress: string
250
210
  }
@@ -252,23 +212,17 @@ export interface BuildDeployContractTxResult {
252
212
  export interface BuildExecuteScriptTx {
253
213
  /** @format hex-string */
254
214
  fromPublicKey: string
255
-
256
215
  /** @format hex-string */
257
216
  fromPublicKeyType?: string
258
-
259
217
  /** @format hex-string */
260
218
  bytecode: string
261
-
262
219
  /** @format uint256 */
263
220
  attoAlphAmount?: string
264
221
  tokens?: Token[]
265
-
266
222
  /** @format gas */
267
223
  gasAmount?: number
268
-
269
224
  /** @format uint256 */
270
225
  gasPrice?: string
271
-
272
226
  /** @format block-hash */
273
227
  targetBlockHash?: string
274
228
  }
@@ -276,17 +230,13 @@ export interface BuildExecuteScriptTx {
276
230
  export interface BuildExecuteScriptTxResult {
277
231
  /** @format int32 */
278
232
  fromGroup: number
279
-
280
233
  /** @format int32 */
281
234
  toGroup: number
282
235
  unsignedTx: string
283
-
284
236
  /** @format gas */
285
237
  gasAmount: number
286
-
287
238
  /** @format uint256 */
288
239
  gasPrice: string
289
-
290
240
  /** @format 32-byte-hash */
291
241
  txId: string
292
242
  }
@@ -301,17 +251,14 @@ export interface BuildMultisig {
301
251
  fromAddress: string
302
252
  fromPublicKeys: string[]
303
253
  destinations: Destination[]
304
-
305
254
  /** @format gas */
306
255
  gas?: number
307
-
308
256
  /** @format uint256 */
309
257
  gasPrice?: string
310
258
  }
311
259
 
312
260
  export interface BuildMultisigAddress {
313
261
  keys: string[]
314
-
315
262
  /** @format int32 */
316
263
  mrequired: number
317
264
  }
@@ -324,29 +271,22 @@ export interface BuildMultisigAddressResult {
324
271
  export interface BuildSweepAddressTransactions {
325
272
  /** @format public-key */
326
273
  fromPublicKey: string
327
-
328
274
  /** @format address */
329
275
  toAddress: string
330
-
331
276
  /** @format int64 */
332
277
  lockTime?: number
333
-
334
278
  /** @format gas */
335
279
  gasAmount?: number
336
-
337
280
  /** @format uint256 */
338
281
  gasPrice?: string
339
-
340
282
  /** @format block-hash */
341
283
  targetBlockHash?: string
342
284
  }
343
285
 
344
286
  export interface BuildSweepAddressTransactionsResult {
345
287
  unsignedTxs: SweepAddressTransaction[]
346
-
347
288
  /** @format int32 */
348
289
  fromGroup: number
349
-
350
290
  /** @format int32 */
351
291
  toGroup: number
352
292
  }
@@ -354,37 +294,28 @@ export interface BuildSweepAddressTransactionsResult {
354
294
  export interface BuildTransaction {
355
295
  /** @format hex-string */
356
296
  fromPublicKey: string
357
-
358
297
  /** @format hex-string */
359
298
  fromPublicKeyType?: string
360
299
  destinations: Destination[]
361
300
  utxos?: OutputRef[]
362
-
363
301
  /** @format gas */
364
302
  gasAmount?: number
365
-
366
303
  /** @format uint256 */
367
304
  gasPrice?: string
368
-
369
305
  /** @format block-hash */
370
306
  targetBlockHash?: string
371
307
  }
372
308
 
373
309
  export interface BuildTransactionResult {
374
310
  unsignedTx: string
375
-
376
311
  /** @format gas */
377
312
  gasAmount: number
378
-
379
313
  /** @format uint256 */
380
314
  gasPrice: string
381
-
382
315
  /** @format 32-byte-hash */
383
316
  txId: string
384
-
385
317
  /** @format int32 */
386
318
  fromGroup: number
387
-
388
319
  /** @format int32 */
389
320
  toGroup: number
390
321
  }
@@ -392,16 +323,12 @@ export interface BuildTransactionResult {
392
323
  export interface CallContract {
393
324
  /** @format int32 */
394
325
  group: number
395
-
396
326
  /** @format block-hash */
397
327
  worldStateBlockHash?: string
398
-
399
328
  /** @format 32-byte-hash */
400
329
  txId?: string
401
-
402
330
  /** @format address */
403
331
  address: string
404
-
405
332
  /** @format int32 */
406
333
  methodIndex: number
407
334
  args?: Val[]
@@ -411,7 +338,6 @@ export interface CallContract {
411
338
 
412
339
  export interface CallContractResult {
413
340
  returns: Val[]
414
-
415
341
  /** @format int32 */
416
342
  gasUsed: number
417
343
  contracts: ContractState[]
@@ -427,13 +353,10 @@ export interface ChainInfo {
427
353
 
428
354
  export interface ChainParams {
429
355
  networkId: number
430
-
431
356
  /** @format int32 */
432
357
  numZerosAtLeastInHash: number
433
-
434
358
  /** @format int32 */
435
359
  groupNumPerBroker: number
436
-
437
360
  /** @format int32 */
438
361
  groups: number
439
362
  }
@@ -448,10 +371,8 @@ export interface CompileContractResult {
448
371
  name: string
449
372
  bytecode: string
450
373
  bytecodeDebugPatch: string
451
-
452
374
  /** @format 32-byte-hash */
453
375
  codeHash: string
454
-
455
376
  /** @format 32-byte-hash */
456
377
  codeHashDebug: string
457
378
  fields: FieldsSig
@@ -487,16 +408,12 @@ export interface CompilerOptions {
487
408
  export interface Confirmed {
488
409
  /** @format block-hash */
489
410
  blockHash: string
490
-
491
411
  /** @format int32 */
492
412
  txIndex: number
493
-
494
413
  /** @format int32 */
495
414
  chainConfirmations: number
496
-
497
415
  /** @format int32 */
498
416
  fromGroupConfirmations: number
499
-
500
417
  /** @format int32 */
501
418
  toGroupConfirmations: number
502
419
  type: string
@@ -510,10 +427,8 @@ export interface Contract {
510
427
  export interface ContractEvent {
511
428
  /** @format block-hash */
512
429
  blockHash: string
513
-
514
430
  /** @format 32-byte-hash */
515
431
  txId: string
516
-
517
432
  /** @format int32 */
518
433
  eventIndex: number
519
434
  fields: Val[]
@@ -522,10 +437,8 @@ export interface ContractEvent {
522
437
  export interface ContractEventByBlockHash {
523
438
  /** @format 32-byte-hash */
524
439
  txId: string
525
-
526
440
  /** @format address */
527
441
  contractAddress: string
528
-
529
442
  /** @format int32 */
530
443
  eventIndex: number
531
444
  fields: Val[]
@@ -534,10 +447,8 @@ export interface ContractEventByBlockHash {
534
447
  export interface ContractEventByTxId {
535
448
  /** @format block-hash */
536
449
  blockHash: string
537
-
538
450
  /** @format address */
539
451
  contractAddress: string
540
-
541
452
  /** @format int32 */
542
453
  eventIndex: number
543
454
  fields: Val[]
@@ -545,7 +456,6 @@ export interface ContractEventByTxId {
545
456
 
546
457
  export interface ContractEvents {
547
458
  events: ContractEvent[]
548
-
549
459
  /** @format int32 */
550
460
  nextStart: number
551
461
  }
@@ -561,13 +471,10 @@ export interface ContractEventsByTxId {
561
471
  export interface ContractOutput {
562
472
  /** @format int32 */
563
473
  hint: number
564
-
565
474
  /** @format 32-byte-hash */
566
475
  key: string
567
-
568
476
  /** @format uint256 */
569
477
  attoAlphAmount: string
570
-
571
478
  /** @format address */
572
479
  address: string
573
480
  tokens: Token[]
@@ -577,13 +484,10 @@ export interface ContractOutput {
577
484
  export interface ContractState {
578
485
  /** @format address */
579
486
  address: string
580
-
581
487
  /** @format contract */
582
488
  bytecode: string
583
-
584
489
  /** @format 32-byte-hash */
585
490
  codeHash: string
586
-
587
491
  /** @format 32-byte-hash */
588
492
  initialStateHash?: string
589
493
  immFields: Val[]
@@ -604,7 +508,6 @@ export interface DecodeUnsignedTx {
604
508
  export interface DecodeUnsignedTxResult {
605
509
  /** @format int32 */
606
510
  fromGroup: number
607
-
608
511
  /** @format int32 */
609
512
  toGroup: number
610
513
  unsignedTx: UnsignedTx
@@ -613,14 +516,11 @@ export interface DecodeUnsignedTxResult {
613
516
  export interface Destination {
614
517
  /** @format address */
615
518
  address: string
616
-
617
519
  /** @format uint256 */
618
520
  attoAlphAmount: string
619
521
  tokens?: Token[]
620
-
621
522
  /** @format int64 */
622
523
  lockTime?: number
623
-
624
524
  /** @format hex-string */
625
525
  message?: string
626
526
  }
@@ -642,20 +542,15 @@ export interface FieldsSig {
642
542
  export interface FixedAssetOutput {
643
543
  /** @format int32 */
644
544
  hint: number
645
-
646
545
  /** @format 32-byte-hash */
647
546
  key: string
648
-
649
547
  /** @format uint256 */
650
548
  attoAlphAmount: string
651
-
652
549
  /** @format address */
653
550
  address: string
654
551
  tokens: Token[]
655
-
656
552
  /** @format int64 */
657
553
  lockTime: number
658
-
659
554
  /** @format hex-string */
660
555
  message: string
661
556
  }
@@ -683,15 +578,16 @@ export interface HashesAtHeight {
683
578
  export interface InterCliquePeerInfo {
684
579
  /** @format clique-id */
685
580
  cliqueId: string
686
-
687
581
  /** @format int32 */
688
582
  brokerId: number
689
-
690
583
  /** @format int32 */
691
584
  groupNumPerBroker: number
692
-
693
585
  /** @format inet-socket-address */
694
- address: { addr: string; port: number }
586
+ address: {
587
+ addr: string
588
+ /** @format int32 */
589
+ port: number
590
+ }
695
591
  isSynced: boolean
696
592
  clientVersion: string
697
593
  }
@@ -707,7 +603,6 @@ export interface MemPooled {
707
603
  export interface MempoolTransactions {
708
604
  /** @format int32 */
709
605
  fromGroup: number
710
-
711
606
  /** @format int32 */
712
607
  toGroup: number
713
608
  transactions: TransactionTemplate[]
@@ -726,9 +621,12 @@ export type MisbehaviorAction = Ban | Unban
726
621
  export interface NodeInfo {
727
622
  buildInfo: BuildInfo
728
623
  upnp: boolean
729
-
730
624
  /** @format inet-socket-address */
731
- externalAddress?: { addr: string; port: number }
625
+ externalAddress?: {
626
+ addr: string
627
+ /** @format int32 */
628
+ port: number
629
+ }
732
630
  }
733
631
 
734
632
  export interface NodeVersion {
@@ -745,7 +643,6 @@ export type Output = AssetOutput | ContractOutput
745
643
  export interface OutputRef {
746
644
  /** @format int32 */
747
645
  hint: number
748
-
749
646
  /** @format 32-byte-hash */
750
647
  key: string
751
648
  }
@@ -753,13 +650,10 @@ export interface OutputRef {
753
650
  export interface PeerAddress {
754
651
  /** @format inet-address */
755
652
  address: string
756
-
757
653
  /** @format int32 */
758
654
  restPort: number
759
-
760
655
  /** @format int32 */
761
656
  wsPort: number
762
-
763
657
  /** @format int32 */
764
658
  minerApiPort: number
765
659
  }
@@ -791,10 +685,8 @@ export interface Reachable {
791
685
  export interface ReleaseVersion {
792
686
  /** @format int32 */
793
687
  major: number
794
-
795
688
  /** @format int32 */
796
689
  minor: number
797
-
798
690
  /** @format int32 */
799
691
  patch: number
800
692
  }
@@ -840,7 +732,6 @@ export interface SubmitMultisig {
840
732
 
841
733
  export interface SubmitTransaction {
842
734
  unsignedTx: string
843
-
844
735
  /** @format signature */
845
736
  signature: string
846
737
  }
@@ -848,10 +739,8 @@ export interface SubmitTransaction {
848
739
  export interface SubmitTxResult {
849
740
  /** @format 32-byte-hash */
850
741
  txId: string
851
-
852
742
  /** @format int32 */
853
743
  fromGroup: number
854
-
855
744
  /** @format int32 */
856
745
  toGroup: number
857
746
  }
@@ -859,19 +748,14 @@ export interface SubmitTxResult {
859
748
  export interface Sweep {
860
749
  /** @format address */
861
750
  toAddress: string
862
-
863
751
  /** @format int64 */
864
752
  lockTime?: number
865
-
866
753
  /** @format gas */
867
754
  gasAmount?: number
868
-
869
755
  /** @format uint256 */
870
756
  gasPrice?: string
871
-
872
757
  /** @format int32 */
873
758
  utxosLimit?: number
874
-
875
759
  /** @format block-hash */
876
760
  targetBlockHash?: string
877
761
  }
@@ -880,10 +764,8 @@ export interface SweepAddressTransaction {
880
764
  /** @format 32-byte-hash */
881
765
  txId: string
882
766
  unsignedTx: string
883
-
884
767
  /** @format gas */
885
768
  gasAmount: number
886
-
887
769
  /** @format uint256 */
888
770
  gasPrice: string
889
771
  }
@@ -891,22 +773,17 @@ export interface SweepAddressTransaction {
891
773
  export interface TestContract {
892
774
  /** @format int32 */
893
775
  group?: number
894
-
895
776
  /** @format block-hash */
896
777
  blockHash?: string
897
-
898
778
  /** @format 32-byte-hash */
899
779
  txId?: string
900
-
901
780
  /** @format address */
902
781
  address?: string
903
-
904
782
  /** @format contract */
905
783
  bytecode: string
906
784
  initialImmFields?: Val[]
907
785
  initialMutFields?: Val[]
908
786
  initialAsset?: AssetState
909
-
910
787
  /** @format int32 */
911
788
  methodIndex?: number
912
789
  args?: Val[]
@@ -917,11 +794,9 @@ export interface TestContract {
917
794
  export interface TestContractResult {
918
795
  /** @format address */
919
796
  address: string
920
-
921
797
  /** @format 32-byte-hash */
922
798
  codeHash: string
923
799
  returns: Val[]
924
-
925
800
  /** @format int32 */
926
801
  gasUsed: number
927
802
  contracts: ContractState[]
@@ -940,7 +815,6 @@ export interface TestInputAsset {
940
815
  export interface Token {
941
816
  /** @format 32-byte-hash */
942
817
  id: string
943
-
944
818
  /** @format uint256 */
945
819
  amount: string
946
820
  }
@@ -962,13 +836,10 @@ export interface TransactionTemplate {
962
836
 
963
837
  export interface Transfer {
964
838
  destinations: Destination[]
965
-
966
839
  /** @format gas */
967
840
  gas?: number
968
-
969
841
  /** @format uint256 */
970
842
  gasPrice?: string
971
-
972
843
  /** @format int32 */
973
844
  utxosLimit?: number
974
845
  }
@@ -976,10 +847,8 @@ export interface Transfer {
976
847
  export interface TransferResult {
977
848
  /** @format 32-byte-hash */
978
849
  txId: string
979
-
980
850
  /** @format group-index */
981
851
  fromGroup: number
982
-
983
852
  /** @format group-index */
984
853
  toGroup: number
985
854
  }
@@ -996,14 +865,11 @@ export type TxStatus = Confirmed | MemPooled | TxNotFound
996
865
 
997
866
  export interface UTXO {
998
867
  ref: OutputRef
999
-
1000
868
  /** @format uint256 */
1001
869
  amount: string
1002
870
  tokens?: Token[]
1003
-
1004
871
  /** @format int64 */
1005
872
  lockTime?: number
1006
-
1007
873
  /** @format hex-string */
1008
874
  additionalData?: string
1009
875
  }
@@ -1032,13 +898,10 @@ export interface UnsignedTx {
1032
898
  txId: string
1033
899
  version: number
1034
900
  networkId: number
1035
-
1036
901
  /** @format script */
1037
902
  scriptOpt?: string
1038
-
1039
903
  /** @format int32 */
1040
904
  gasAmount: number
1041
-
1042
905
  /** @format uint256 */
1043
906
  gasPrice: string
1044
907
  inputs: AssetInput[]
@@ -1084,10 +947,8 @@ export interface ValU256 {
1084
947
  export interface VerifySignature {
1085
948
  /** @format hex-string */
1086
949
  data: string
1087
-
1088
950
  /** @format signature */
1089
951
  signature: string
1090
-
1091
952
  /** @format public-key */
1092
953
  publicKey: string
1093
954
  }
@@ -1175,7 +1036,8 @@ type CancelToken = Symbol | string | number
1175
1036
  export enum ContentType {
1176
1037
  Json = 'application/json',
1177
1038
  FormData = 'multipart/form-data',
1178
- UrlEncoded = 'application/x-www-form-urlencoded'
1039
+ UrlEncoded = 'application/x-www-form-urlencoded',
1040
+ Text = 'text/plain'
1179
1041
  }
1180
1042
 
1181
1043
  export class HttpClient<SecurityDataType = unknown> {
@@ -1200,16 +1062,16 @@ export class HttpClient<SecurityDataType = unknown> {
1200
1062
  this.securityData = data
1201
1063
  }
1202
1064
 
1203
- private encodeQueryParam(key: string, value: any) {
1065
+ protected encodeQueryParam(key: string, value: any) {
1204
1066
  const encodedKey = encodeURIComponent(key)
1205
1067
  return `${encodedKey}=${encodeURIComponent(typeof value === 'number' ? value : `${value}`)}`
1206
1068
  }
1207
1069
 
1208
- private addQueryParam(query: QueryParamsType, key: string) {
1070
+ protected addQueryParam(query: QueryParamsType, key: string) {
1209
1071
  return this.encodeQueryParam(key, query[key])
1210
1072
  }
1211
1073
 
1212
- private addArrayQueryParam(query: QueryParamsType, key: string) {
1074
+ protected addArrayQueryParam(query: QueryParamsType, key: string) {
1213
1075
  const value = query[key]
1214
1076
  return value.map((v: any) => this.encodeQueryParam(key, v)).join('&')
1215
1077
  }
@@ -1230,6 +1092,7 @@ export class HttpClient<SecurityDataType = unknown> {
1230
1092
  private contentFormatters: Record<ContentType, (input: any) => any> = {
1231
1093
  [ContentType.Json]: (input: any) =>
1232
1094
  input !== null && (typeof input === 'object' || typeof input === 'string') ? JSON.stringify(input) : input,
1095
+ [ContentType.Text]: (input: any) => (input !== null && typeof input !== 'string' ? JSON.stringify(input) : input),
1233
1096
  [ContentType.FormData]: (input: any) =>
1234
1097
  Object.keys(input || {}).reduce((formData, key) => {
1235
1098
  const property = input[key]
@@ -1246,7 +1109,7 @@ export class HttpClient<SecurityDataType = unknown> {
1246
1109
  [ContentType.UrlEncoded]: (input: any) => this.toQueryString(input)
1247
1110
  }
1248
1111
 
1249
- private mergeRequestParams(params1: RequestParams, params2?: RequestParams): RequestParams {
1112
+ protected mergeRequestParams(params1: RequestParams, params2?: RequestParams): RequestParams {
1250
1113
  return {
1251
1114
  ...this.baseApiParams,
1252
1115
  ...params1,
@@ -1259,7 +1122,7 @@ export class HttpClient<SecurityDataType = unknown> {
1259
1122
  }
1260
1123
  }
1261
1124
 
1262
- private createAbortSignal = (cancelToken: CancelToken): AbortSignal | undefined => {
1125
+ protected createAbortSignal = (cancelToken: CancelToken): AbortSignal | undefined => {
1263
1126
  if (this.abortControllers.has(cancelToken)) {
1264
1127
  const abortController = this.abortControllers.get(cancelToken)
1265
1128
  if (abortController) {
@@ -1306,10 +1169,10 @@ export class HttpClient<SecurityDataType = unknown> {
1306
1169
  return this.customFetch(`${baseUrl || this.baseUrl || ''}${path}${queryString ? `?${queryString}` : ''}`, {
1307
1170
  ...requestParams,
1308
1171
  headers: {
1309
- ...(type && type !== ContentType.FormData ? { 'Content-Type': type } : {}),
1310
- ...(requestParams.headers || {})
1172
+ ...(requestParams.headers || {}),
1173
+ ...(type && type !== ContentType.FormData ? { 'Content-Type': type } : {})
1311
1174
  },
1312
- signal: cancelToken ? this.createAbortSignal(cancelToken) : void 0,
1175
+ signal: cancelToken ? this.createAbortSignal(cancelToken) : requestParams.signal,
1313
1176
  body: typeof body === 'undefined' || body === null ? null : payloadFormatter(body)
1314
1177
  }).then(async (response) => {
1315
1178
  const r = response as HttpResponse<T, E>
@@ -1641,7 +1504,10 @@ export class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDa
1641
1504
  */
1642
1505
  postWalletsWalletNameDeriveNextAddress: (
1643
1506
  walletName: string,
1644
- query?: { group?: number },
1507
+ query?: {
1508
+ /** @format int32 */
1509
+ group?: number
1510
+ },
1645
1511
  params: RequestParams = {}
1646
1512
  ) =>
1647
1513
  this.request<AddressInfo, BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable>({
@@ -1863,7 +1729,21 @@ export class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDa
1863
1729
  * @summary Get history average hashrate on the given time interval
1864
1730
  * @request GET:/infos/history-hashrate
1865
1731
  */
1866
- getInfosHistoryHashrate: (query: { fromTs: number; toTs?: number }, params: RequestParams = {}) =>
1732
+ getInfosHistoryHashrate: (
1733
+ query: {
1734
+ /**
1735
+ * @format int64
1736
+ * @min 0
1737
+ */
1738
+ fromTs: number
1739
+ /**
1740
+ * @format int64
1741
+ * @min 0
1742
+ */
1743
+ toTs?: number
1744
+ },
1745
+ params: RequestParams = {}
1746
+ ) =>
1867
1747
  this.request<string, BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable>({
1868
1748
  path: `/infos/history-hashrate`,
1869
1749
  method: 'GET',
@@ -1880,7 +1760,16 @@ export class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDa
1880
1760
  * @summary Get average hashrate from `now - timespan(millis)` to `now`
1881
1761
  * @request GET:/infos/current-hashrate
1882
1762
  */
1883
- getInfosCurrentHashrate: (query?: { timespan?: number }, params: RequestParams = {}) =>
1763
+ getInfosCurrentHashrate: (
1764
+ query?: {
1765
+ /**
1766
+ * @format int64
1767
+ * @min 1
1768
+ */
1769
+ timespan?: number
1770
+ },
1771
+ params: RequestParams = {}
1772
+ ) =>
1884
1773
  this.request<string, BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable>({
1885
1774
  path: `/infos/current-hashrate`,
1886
1775
  method: 'GET',
@@ -1898,7 +1787,21 @@ export class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDa
1898
1787
  * @summary List blocks on the given time interval
1899
1788
  * @request GET:/blockflow/blocks
1900
1789
  */
1901
- getBlockflowBlocks: (query: { fromTs: number; toTs?: number }, params: RequestParams = {}) =>
1790
+ getBlockflowBlocks: (
1791
+ query: {
1792
+ /**
1793
+ * @format int64
1794
+ * @min 0
1795
+ */
1796
+ fromTs: number
1797
+ /**
1798
+ * @format int64
1799
+ * @min 0
1800
+ */
1801
+ toTs?: number
1802
+ },
1803
+ params: RequestParams = {}
1804
+ ) =>
1902
1805
  this.request<
1903
1806
  BlocksPerTimeStampRange,
1904
1807
  BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable
@@ -1918,7 +1821,21 @@ export class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDa
1918
1821
  * @summary List blocks with events on the given time interval
1919
1822
  * @request GET:/blockflow/blocks-with-events
1920
1823
  */
1921
- getBlockflowBlocksWithEvents: (query: { fromTs: number; toTs?: number }, params: RequestParams = {}) =>
1824
+ getBlockflowBlocksWithEvents: (
1825
+ query: {
1826
+ /**
1827
+ * @format int64
1828
+ * @min 0
1829
+ */
1830
+ fromTs: number
1831
+ /**
1832
+ * @format int64
1833
+ * @min 0
1834
+ */
1835
+ toTs?: number
1836
+ },
1837
+ params: RequestParams = {}
1838
+ ) =>
1922
1839
  this.request<
1923
1840
  BlocksAndEventsPerTimeStampRange,
1924
1841
  BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable
@@ -1970,7 +1887,12 @@ export class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDa
1970
1887
  * @summary Check if the block is in main chain
1971
1888
  * @request GET:/blockflow/is-block-in-main-chain
1972
1889
  */
1973
- getBlockflowIsBlockInMainChain: (query: { blockHash: string }, params: RequestParams = {}) =>
1890
+ getBlockflowIsBlockInMainChain: (
1891
+ query: {
1892
+ blockHash: string
1893
+ },
1894
+ params: RequestParams = {}
1895
+ ) =>
1974
1896
  this.request<boolean, BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable>({
1975
1897
  path: `/blockflow/is-block-in-main-chain`,
1976
1898
  method: 'GET',
@@ -1987,7 +1909,17 @@ export class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDa
1987
1909
  * @summary Get all block's hashes at given height for given groups
1988
1910
  * @request GET:/blockflow/hashes
1989
1911
  */
1990
- getBlockflowHashes: (query: { fromGroup: number; toGroup: number; height: number }, params: RequestParams = {}) =>
1912
+ getBlockflowHashes: (
1913
+ query: {
1914
+ /** @format int32 */
1915
+ fromGroup: number
1916
+ /** @format int32 */
1917
+ toGroup: number
1918
+ /** @format int32 */
1919
+ height: number
1920
+ },
1921
+ params: RequestParams = {}
1922
+ ) =>
1991
1923
  this.request<HashesAtHeight, BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable>({
1992
1924
  path: `/blockflow/hashes`,
1993
1925
  method: 'GET',
@@ -2004,7 +1936,15 @@ export class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDa
2004
1936
  * @summary Get infos about the chain from the given groups
2005
1937
  * @request GET:/blockflow/chain-info
2006
1938
  */
2007
- getBlockflowChainInfo: (query: { fromGroup: number; toGroup: number }, params: RequestParams = {}) =>
1939
+ getBlockflowChainInfo: (
1940
+ query: {
1941
+ /** @format int32 */
1942
+ fromGroup: number
1943
+ /** @format int32 */
1944
+ toGroup: number
1945
+ },
1946
+ params: RequestParams = {}
1947
+ ) =>
2008
1948
  this.request<ChainInfo, BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable>({
2009
1949
  path: `/blockflow/chain-info`,
2010
1950
  method: 'GET',
@@ -2170,7 +2110,12 @@ export class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDa
2170
2110
  */
2171
2111
  getTransactionsDetailsTxid: (
2172
2112
  txId: string,
2173
- query?: { fromGroup?: number; toGroup?: number },
2113
+ query?: {
2114
+ /** @format int32 */
2115
+ fromGroup?: number
2116
+ /** @format int32 */
2117
+ toGroup?: number
2118
+ },
2174
2119
  params: RequestParams = {}
2175
2120
  ) =>
2176
2121
  this.request<Transaction, BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable>({
@@ -2190,7 +2135,13 @@ export class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDa
2190
2135
  * @request GET:/transactions/status
2191
2136
  */
2192
2137
  getTransactionsStatus: (
2193
- query: { txId: string; fromGroup?: number; toGroup?: number },
2138
+ query: {
2139
+ txId: string
2140
+ /** @format int32 */
2141
+ fromGroup?: number
2142
+ /** @format int32 */
2143
+ toGroup?: number
2144
+ },
2194
2145
  params: RequestParams = {}
2195
2146
  ) =>
2196
2147
  this.request<TxStatus, BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable>({
@@ -2244,7 +2195,12 @@ export class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDa
2244
2195
  * @summary Rebroadcase a mempool transaction to the network
2245
2196
  * @request PUT:/mempool/transactions/rebroadcast
2246
2197
  */
2247
- putMempoolTransactionsRebroadcast: (query: { txId: string }, params: RequestParams = {}) =>
2198
+ putMempoolTransactionsRebroadcast: (
2199
+ query: {
2200
+ txId: string
2201
+ },
2202
+ params: RequestParams = {}
2203
+ ) =>
2248
2204
  this.request<void, BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable>({
2249
2205
  path: `/mempool/transactions/rebroadcast`,
2250
2206
  method: 'PUT',
@@ -2381,7 +2337,14 @@ export class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDa
2381
2337
  * @summary Get contract state
2382
2338
  * @request GET:/contracts/{address}/state
2383
2339
  */
2384
- getContractsAddressState: (address: string, query: { group: number }, params: RequestParams = {}) =>
2340
+ getContractsAddressState: (
2341
+ address: string,
2342
+ query: {
2343
+ /** @format int32 */
2344
+ group: number
2345
+ },
2346
+ params: RequestParams = {}
2347
+ ) =>
2385
2348
  this.request<ContractState, BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable>({
2386
2349
  path: `/contracts/${address}/state`,
2387
2350
  method: 'GET',
@@ -2534,7 +2497,12 @@ export class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDa
2534
2497
  * @summary Execute an action on CPU miner. !!! for test only !!!
2535
2498
  * @request POST:/miners/cpu-mining
2536
2499
  */
2537
- postMinersCpuMining: (query: { action: string }, params: RequestParams = {}) =>
2500
+ postMinersCpuMining: (
2501
+ query: {
2502
+ action: string
2503
+ },
2504
+ params: RequestParams = {}
2505
+ ) =>
2538
2506
  this.request<boolean, BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable>({
2539
2507
  path: `/miners/cpu-mining`,
2540
2508
  method: 'POST',
@@ -2551,7 +2519,15 @@ export class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDa
2551
2519
  * @summary Mine a block on CPU miner. !!! for test only !!!
2552
2520
  * @request POST:/miners/cpu-mining/mine-one-block
2553
2521
  */
2554
- postMinersCpuMiningMineOneBlock: (query: { fromGroup: number; toGroup: number }, params: RequestParams = {}) =>
2522
+ postMinersCpuMiningMineOneBlock: (
2523
+ query: {
2524
+ /** @format int32 */
2525
+ fromGroup: number
2526
+ /** @format int32 */
2527
+ toGroup: number
2528
+ },
2529
+ params: RequestParams = {}
2530
+ ) =>
2555
2531
  this.request<boolean, BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable>({
2556
2532
  path: `/miners/cpu-mining/mine-one-block`,
2557
2533
  method: 'POST',
@@ -2604,7 +2580,14 @@ export class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDa
2604
2580
  */
2605
2581
  getEventsContractContractaddress: (
2606
2582
  contractAddress: string,
2607
- query: { start: number; limit?: number; group?: number },
2583
+ query: {
2584
+ /** @format int32 */
2585
+ start: number
2586
+ /** @format int32 */
2587
+ limit?: number
2588
+ /** @format int32 */
2589
+ group?: number
2590
+ },
2608
2591
  params: RequestParams = {}
2609
2592
  ) =>
2610
2593
  this.request<ContractEvents, BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable>({
@@ -2639,7 +2622,14 @@ export class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDa
2639
2622
  * @summary Get contract events for a transaction
2640
2623
  * @request GET:/events/tx-id/{txId}
2641
2624
  */
2642
- getEventsTxIdTxid: (txId: string, query?: { group?: number }, params: RequestParams = {}) =>
2625
+ getEventsTxIdTxid: (
2626
+ txId: string,
2627
+ query?: {
2628
+ /** @format int32 */
2629
+ group?: number
2630
+ },
2631
+ params: RequestParams = {}
2632
+ ) =>
2643
2633
  this.request<
2644
2634
  ContractEventsByTxId,
2645
2635
  BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable
@@ -2659,7 +2649,14 @@ export class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDa
2659
2649
  * @summary Get contract events for a block
2660
2650
  * @request GET:/events/block-hash/{blockHash}
2661
2651
  */
2662
- getEventsBlockHashBlockhash: (blockHash: string, query?: { group?: number }, params: RequestParams = {}) =>
2652
+ getEventsBlockHashBlockhash: (
2653
+ blockHash: string,
2654
+ query?: {
2655
+ /** @format int32 */
2656
+ group?: number
2657
+ },
2658
+ params: RequestParams = {}
2659
+ ) =>
2663
2660
  this.request<
2664
2661
  ContractEventsByBlockHash,
2665
2662
  BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable