-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathhelp.js
1669 lines (1584 loc) · 49.9 KB
/
help.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
Help = function (ethers) {
class DummyClass { }
class Returns {
props() { return null; }
static fromBasic(value) {
if (value instanceof Uint8Array) { return B("Uint8Array"); }
if (value instanceof Promise) { return B("Promise"); }
if (Array.isArray(value)) { return B("Array"); }
const type = typeof(value);
if (type in Basic) { return B(type); }
return null;
}
static from(value) {
if (value === "_") { return B("_"); }
const basic = Returns.fromBasic(value);
if (basic) { return basic; }
const clsNameMatch = Help.filter((h) => (h.cls && h.name === value));
if (clsNameMatch.length) { return H(clsNameMatch.pop().name); }
const clsMatch = Help.filter((h) => (h.cls === value));
if (clsMatch) { return B("class", H(clsMatch.name)); }
return null;
}
}
class HelpReturns extends Returns {
constructor(name) {
super();
this.name = name;
}
props() {
const help = Help.filter(h => (h.name === this.name));
if (help.length !== 1) { throw new Error(`Bad HelpReturns: ${ this.name }`); }
return help[0].properties;
}
}
class BasicReturns extends Returns {
constructor(type, subtype) {
super();
this.type = type;
this.subtype = subtype || null;
this.text = type;
if (subtype) { this.text += `<${ subtype.text }>`; }
}
props() {
const props = Basic[this.type];
if (props == null) { throw new Error(`unknown basic type: ${ JSON.stringify(this.type) }`); }
return props;
}
};
class DescrReturns extends Returns {
constructor(name) {
super();
this.name = name;
}
props() {
return null;
}
}
function B(type, subtype) { return new BasicReturns(type, subtype); }
function H(name) { return new HelpReturns(name); }
function D(name) { return new DescrReturns(name); }
function Func(params, returns, descr) {
return { descr, params, returns };
}
const Basic = {
"_": { },
// "object": { },
"Uint8Array": {
length: { returns: B("number") },
slice: Func([ "start", "%end" ], B("Uint8Array")),
},
"Array": {
length: { returns: B("number") },
slice: Func([ "start", "%end" ], B("Array")),
join: Func([ "separator" ], B("string")),
},
"Promise": {
then: Func([ "%resolve=(res) => { %actions }" ], B("Promise")),
"catch": Func([ "%rejected=(err) => { %actions }" ], B("Promise")),
},
"boolean": {
toString: Func([ ], B("string")),
},
"string": {
length: { returns: B("number") },
normalize: Func([ "form" ], B("string")),
split: Func([ "delimiter", "%limit" ], B("Array", B("string"))),
substring: Func([ "start", "%end" ], B("string")),
toLowerCase: Func([], B("string")),
toUpperCase: Func([], B("string")),
trim: Func([], B("string")),
trimStart: Func([], B("string")),
trimEnd: Func([], B("string")),
},
"null": { },
"number": {
toString: Func([ "radix" ], B("string")),
},
};
const Globals = {
"Infinity": { returns: B("number") },
"NaN": { returns: B("number") },
"undefined": { returns: B("number") },
"null": { returns: B("null") },
JSON: {
parse: Func([ "string" ], B("_")),
stringify: Func([ "object" ], B("string")),
},
setTimeout: Func([ "%cb=() => { %actions }", "interval" ], B("_")),
clearTimeout: Func([ "id" ], B("_")),
setInterval: Func([ "%cb=() => { %actions }", "interval" ], B("_")),
clearInterval: Func([ "id" ], B("_")),
parseInt: Func([ "value" ], B("number")),
parseFloat: Func([ "value" ], B("number")),
console: {
log: Func([ "args" ], B("_")),
},
Math: {
atan2: Func([ "y", "x" ], B("number")),
random: Func([ ], B("number")),
},
Object: {
assign: { params: [ "target={ }", "source" ], returns: B("_") },
keys: Func([ "object" ], B("Array")),
}
};
// Math constants
"E LN2 LN10 LOG2E LOG10E PI SQRT1_2 SQRT2".split(" ").forEach((name) => {
Globals.Math[name] = { returns: B("number") };
});
// Math Funcs
"abs acos acosh asin asinh atan atanh cbrt ceil clz32 cos cosh exp expm1 floor fround log log1p log10 log2 round sign sin sinh sqrt tan tanh trunc".split(" ").forEach((name) => {
Globals.Math[name] = { params: [ "x" ], returns: B("number") };
});
"hypot imul max min pow".split(" ").forEach((name) => {
Globals.Math[name] = { params: [ "x", "y" ], returns: B("number") };
});
// Object
"freeze getOwnPropertyDescriptors getOwnPropertyNames getOwnPropertySymbols getPrototypeOf is isExtensible isFrozen isPrototypeOf isSealed keys preventExtensions seal values".split(" ").forEach((name) => {
Globals.Object[name] = { params: [ "object" ], returns: B("_") }
});
const Help = [
{
name: "BigNumber",
cls: ethers.BigNumber,
descr: "a BigNumber",
staticProperties: {
from: Func([ "value" ], H("BigNumber"), "returns a new BigNumber from value"),
isBigNumber: Func([ "value" ], "boolean", "returns true if value is a BigNumber"),
},
properties: {
add: Func([ "other" ], H("BigNumber"), "return a BigNumber with other added to this"),
mul: Func([ "other" ], H("BigNumber"), ""),
sub: Func([ "other" ], H("BigNumber"), ""),
div: Func([ "other" ], H("BigNumber"), ""),
toString: Func([ ], B("string"), ""),
toHexString: Func([ ], B("string"), ""),
}
},
{
name: "Contract",
cls: ethers.Contract,
params: [ "address", "abi", "providerOrSigner" ],
//description: "creates a new Contract meta-class instance",
//descriptions: [
// "the address to onnect to",
// "the ABI of the deployed contract",
// "the Signer or Provider to connect with"
//],
insert: "new Contract(%address, %abi, provider)"
},
{
name: "ContractFactory",
cls: ethers.ContractFactory,
params: [ "abi", "bytecode", "signer" ],
staticProperties: {
fromSolidity: Func([ "compilerOutput", "signer" ], H("ContractFactory"), ""),
getInterface: Func([ "interface" ], H("Interface"), ""),
getContractAddress: Func([ "tx" ], B("string"), ""),
getContract: Func([ "address", "interface", "signer" ], H("Contract"), ""),
},
properties: {
interface: { returns: H("Interface") },
bytecode: { returns: B("string") },
signer: { returns: H("AbstractSigner") },
getDeployTransaction: Func([], B("_"), ""), // TODO
deploy: Func([ ], B("Promise", H("Contract")), ""),
attach: Func([ "address" ], H("Contract"), ""),
connect: Func([ "signer" ], H("Contract"), ""),
},
//description: "creates a new ContractFactory for deploying contracts",
//returns: "ContractFactory",
//descriptions: [
// "the ABI of the deployed contract",
// "the contract initcode",
// "the Signer to deploy with"
//],
insert: "new ContractFactory(%abi, %bytecode, %signer)"
},
{
name: "FixedNumber",
cls: ethers.FixedNumber,
descr: "",
staticProperties: {
from: Func([ "value", '%format="fixed128x18"' ], H("FixedNumber"), "")
},
properties: {
addUnsafe: Func([ "other" ], H("FixedNumber"), ""),
subUnsafe: Func([ "other" ], H("FixedNumber"), ""),
mulUnsafe: Func([ "other" ], H("FixedNumber"), ""),
divUnsafe: Func([ "other" ], H("FixedNumber"), ""),
floor: Func([ ], H("FixedNumber"), ""),
ceiling: Func([ ], H("FixedNumber"), ""),
round: Func([ "decimals" ], H("FixedNumber"), ""),
isZero: Func([], B("boolean"), ""),
isNegative: Func([], B("boolean"), ""),
toString: Func([], B("string"), ""),
toHexString: Func([], B("string"), ""),
toUnsafeFloat: Func([], B("number"), ""),
toFormat: Func([ "format" ], B("FixedNumber"), ""),
}
},
{
name: "Resolver",
cls: ethers.providers.Resolver,
descr: "",
properties: {
name: { returns: B("string") },
address: { returns: B("string") },
provider: { returns: H("BaseProvider") },
getAddress: Func([ "%coinType" ], B("Promise", B("string")), ""),
getContentHash: Func([], B("Promise", B("string")), ""),
getText: Func([ "key" ], B("Promise", B("string")), ""),
}
},
{
name: "VoidSigner",
cls: ethers.VoidSigner,
inherits: "AbstractSigner",
params: [ "address" ],
properties: {
address: { returns: B("string") },
connect: Func([ "provider" ], H("VoidSigner"), ""),
},
//description: "create a read-only Signer",
//descriptions: [
// "the address to mock as the from address"
//],
insert: "new VoidSigner(%address)"
},
{
name: "Wallet",
cls: ethers.Wallet,
inherits: "AbstractSigner",
descr: "A Wallet instance",
params: [ "privateKey", "%provider=provider" ],
staticProperties: {
createRandom: {
descr: "creates a new random wallet",
params: [ ],
returns: H("Wallet")
},
fromMnemonic: {
descr: "from a mnemonic",
params: [ "mnemonic", "%locale" ],
returns: H("Wallet")
//descriptions: [
// "a mnemonic backup phrase; 12 - 24 words",
// `the HD path to derive (default: ${ JSON.stringify(ethers.utils.defaultPath) })`,
// "the Wordlist or locale string to use (default: \"en\")"
//],
}
},
properties: {
address: {
descr: "the wallet address",
returns: B("string")
},
connect: Func([ "provider" ], H("Wallet"), "returns a new Wallet connected to provider"),
privateKey: {
descr: "the wallet private key",
returns: B("string")
},
getAddress: {
descr: "Get the wallet address",
params: [ ],
returns: B("Promise", B("string"))
},
getBalance: Func([ ], B("Promise", H("BigNumber")), "gets the account balance"),
getTransactionCount: Func([ ], B("Promise", B("number")), "gets the next account nonce"),
sendTransaction: {
descr: "Sends a transaction",
params: [ "tx" ],
returns: B("Promise", H("TransactionResponse"))
}
},
},
{
group: "ethers.providers",
insert: "providers"
},
{
name: "BaseProvider",
cls: ethers.providers.BaseProvider,
inherits: "AbstractProvider",
properties: {
formatter: { returns: B("_") }, // @TODO
network: { returns: H("Network") },
anyNetwork: { returns: B("boolean") },
polling: { returns: B("boolean") },
pollingInterval: { returns: B("number") },
ready: { returns: B("Promise", H("Network")) },
poll: Func([ ], B("Promise", B("_")), ""),
perform: Func([ "method", "params" ], B("Promise", B("_")), ""),
getNetwork: Func([ ], B("Promise", H("Network")), ""),
getEtherPrice: Func([ ], B("Promise", B("number")), ""),
getResolver: Func([ "name" ], B("Promise", H("Resolver")), ""),
},
},
{
name: "AlchemyProvider",
cls: ethers.providers.AlchemyProvider,
inherits: "StaticJsonRpcProvider",
description: "create a Provider connected to the Alchemy service",
params: [ "%network", "%apiKey" ],
properties: {
apiKey: { returns: B("string") },
},
staticProperties: {
getWebSocketProvider: Func([ "%network", "%apiKey" ], H("AlchemyProvider"), ""),
//description: "create a Provider connected to the Alchemy WebSocket service",
//descriptions: [
// "the network to connect to (default: homestead)",
// "the service API key (default: a highly throttled shared key)"
//]
},
descriptions: [
"the network to connect to (default: homestead)",
"the service API key (default: a highly throttled shared key)"
],
insert: "new AlchemyProvider(%network)"
},
{
name: "CloudflareProvider",
cls: ethers.providers.CloudflareProvider,
inherits: "StaticJsonRpcProvider",
params: [ ],
//description: "create a Provider connected to the Cloudflare service",
//descriptions: [ ],
insert: "new CloudflareProvider()"
},
{
name: "EtherscanProvider",
cls: ethers.providers.EtherscanProvider,
inherits: "StaticJsonRpcProvider",
properties: {
apiKey: { returns: B("string") },
},
params: [ "%network", "%apiKey" ],
//description: "create a Provider connected to the Etherscan service",
//descriptions: [
// "the netwowk to connect to (default: homestead)",
// "the service API key (default: a highly throttled shared key)"
//],
insert: "new EtherscanProvider(%network)"
},
{
name: "FallbackProvider",
cls: ethers.providers.FallbackProvider,
inherits: "BaseProvider",
properties: {
providerConfigs: { returns: B("Array", B("_")) },
quorum: { returns: B("number") },
},
params: [ "providers", "%quorum" ],
//description: "create a Fallback Provider for handling multiple providers",
//descriptions: [
// "an array of Providers or ProviderConfigs",
// "the total weight that providers must agree (default: totalWeight / 2)"
//],
insert: "new FallbackProvider(%providers)"
},
{
name: "getDefaultProvider",
func: ethers.providers.getDefaultProvider,
returns: H("BaseProvider"),
params: [ "%network", "%config" ],
//description: "creates a Provider with a default configuration",
descriptions: [
"the network to connect to or a URL",
"configuration to use depending on the network"
],
insert: "ethers.getDefaultProvider(%network)"
},
{
name: "getNetwork",
func: ethers.providers.getNetwork,
returns: H("Network"),
params: [ "network" ],
//description: "normalize and expand a network object or name",
//descriptions: [
// "the netwowk to normalize"
//]
},
{
name: "InfuraProvider",
cls: ethers.providers.InfuraProvider,
inherits: "StaticJsonRpcProvider",
properties: {
apiKey: { returns: B("string") },
projectId: { returns: B("string") },
projectSecret: { returns: B("string") },
},
staticProperties: {
getWebSocketProvider: Func([ "%network", "%projectId" ], H("InfuraProvider"), ""),
},
description: "create a Provider connected to the INFURA service",
params: [ "%network", "%projectId" ],
//descriptions: [
// "the netwowk to connect to (default: homestead)",
// "the service Project ID or ProjectID and Project Secret keys (default: a highly throttled shared key)"
//],
insert: "new InfuraProvider(%network)"
},
{
name: "JsonRpcSigner",
cls: ethers.providers.JsonRpcSigner,
inherits: "AbstractSigner",
properties: {
provider: { returns: H("JsonRpcProvider") },
unlock: Func([ "password" ], B("Promise", B("boolean")), ""),
}
},
{
name: "JsonRpcProvider",
cls: ethers.providers.JsonRpcProvider,
inherits: "BaseProvider",
staticProperties: {
hexlifyTransaction: Func([ "tx", "%extra" ], B("_"), ""),
},
properties: {
send: Func([ "method", "params" ], B("_"), ""),
prepareRequest: Func([ "method", "params" ], B("_"), ""),
getSigner: Func([ "index" ], H("JsonRpcSigner"), ""),
//getUncheckedSigner:
listAccounts: Func([], B("Array", B("string")), ""),
},
params: [ "%url", "%network" ],
//description: "create a Provider connected to a JSON-RPC URL",
//warnings: "Secure Websites (such as this) cannot connect to insecure localhost",
//descriptions: [
// "the URL to connect to (default: http:/\/127.0.0.1:8545)",
// "the netwowk to connect to (default: auto-detect via eth_chainId)",
//],
insert: "new JsonRpcProvider(%url)"
},
{
name: "JsonRpcBatchProvider",
cls: ethers.providers.JsonRpcBatchProvider,
inherits: "JsonRpcProvider",
params: [ "%url", "%network" ],
//description: "create a Provider connected to a JSON-RPC URL which batches requests",
//warnings: "Secure Websites (such as this) cannot connect to insecure localhost",
//descriptions: [
// "the URL to connect to (default: http:/\/127.0.0.1:8545)",
// "the netwowk to connect to (default: auto-detect via eth_chainId)",
//],
insert: "new JsonRpcBatchProvider(%url)"
},
{
name: "PocketProvider",
cls: ethers.providers.PocketProvider,
inherits: "StaticJsonRpcProvider",
properties: {
apiKey: { returns: B("string") },
},
params: [ "%network", "%apiKey" ],
//description: "create a Provider connected to the Pocket service",
//descriptions: [
// "the netwowk to connect to (default: homestead)",
// "the service API key or configuration (default: a highly throttled shared key)"
//],
insert: "new PocketProvider(%network)"
},
{
name: "StaticJsonRpcProvider",
cls: ethers.providers.StaticJsonRpcProvider,
inherits: "JsonRpcProvider",
params: [ "%url", "%network" ],
//description: "create a Provider connected to a JSON-RPC URL which cannot change its chain ID",
//warnings: "Secure Websites (such as this) cannot connect to insecure localhost",
//descriptions: [
// "the URL to connect to (default: http:/\/127.0.0.1:8545)",
// "the netwowk to connect to (default: auto-detect via eth_chainId)",
//],
insert: "new StaticJsonRpcProvider(%url)"
},
{
name: "Web3Provider",
cls: ethers.providers.Web3Provider,
inherits: "JsonRpcProvider",
params: [ "provider", "%network" ],
//description: "create a Provider backed by an EIP-1193 source or legacy Web3.js provider",
//descriptions: [
// "the existing source to connect via",
// "the netwowk to connect to (default: auto-detect via eth_chainId)",
//],
insert: "new Web3Provider(%source)"
},
{
name: "WebSocketProvider",
cls: ethers.providers.WebSocketProvider,
inherits: "JsonRpcProvider",
params: [ "url", "%network" ],
//description: "create a Provider connected to JSON-RPC web socket URL",
warnings: "Secure Websites (such as this) cannot connect to insecure localhost",
//descriptions: [
// "the web socket URL to connect to",
// "the netwowk to connect to (default: auto-detect via eth_chainId)"
//],
insert: "new WebSocketProvider(%url)"
},
{
group: "ethers.utils",
insert: "utils.",
populate: (descr) => {
if (descr.cls == null && !descr.func) {
const func = ethers.utils[descr.name];
if (!func) { throw new Error("missing func"); }
descr.func = func;
}
if (descr.func && !(descr.returns instanceof Returns)) {
throw new Error(`Bad help: ${ descr.name }`);
}
}
},
{
name: "arrayify",
description: "converts bytes-like values to Uint8Array.",
returns: B("Uint8Array"),
params: [ "bytesLike" ],
descriptions: [
"the bytes-like value to convert"
]
},
/*
{
_name: "base58.decode",
name: "decode",
func: ethers.utils.base58.decode,
description: "decodes a Base-58 encoded payload",
returns: B("Uint8Array"),
params: [ "data" ],
descriptions: [
"the encoded data to decode"
]
},
{
name: "base58.encode",
description: "encodes a bytes-like using the Base-58 encoding",
returns: B("string"),
params: [ "data" ],
descriptions: [
"the data to encode"
]
},
{
name: "base64.decode",
description: "decodes a Base-64 encoded payload",
returns: B("Uint8Array"),
params: [ "data" ],
descriptions: [
"the encoded data to decode"
]
},
{
name: "base64.encode",
description: "encodes a bytes-like using the Base-64 encoding",
returns: B("string"),
params: [ "data" ],
descriptions: [
"the data to encode"
]
},
*/
{
name: "computeAddress",
description: "compute the address of a public or private key",
returns: B("string", D("Address")),
params: [ "key" ],
descriptions: [
"the key to compute the address of"
]
},
{
name: "computeHmac",
description: "compute the HMAC of a bytes-like",
returns: B("Uint8Array"),
params: [ "algorithm", "key", "data" ],
descriptions: [
"the SHA2 algoritm to use",
"the HMAC key to process with",
"the data to process"
]
},
{
name: "computePublicKey",
description: "compute the public key of a public or private key",
returns: B("string", D("Bytes")),
params: [ "key", "%compressed" ],
descriptions: [
"the key to compute the public key of",
"whether to use the compressed form"
]
},
{
name: "concat",
description: "concatenates multiple bytes-like",
returns: B("Uint8Array"),
params: [ "datas" ],
descriptions: [
"the array of bytes-like objects"
]
},
/*
{
name: "ConstructorFragment",
cls: ethers.utils.ConstructorFragment,
description: "creates a new Constructor Fragment",
staticProperties: {
from: Func([ "signature" ], H("ConstructorFragment"), "returns a new ContracutroFragment"),
},
properties: {
name: { returns: B("string") },
type: { returns: B("string") },
stateMutability: { returns: B("string") },
payable: { returns: B("boolean") },
},
returns: H("ConstructorFragment"),
params: [ "description" ],
descriptions: [
"the human-readable or JSON ABI"
]
},
*/
{
name: "AbiCoder",
cls: ethers.utils.AbiCoder,
description: "",
properties: {
decode: Func([ "types", "data" ], B("_"), "decode values"),
encode: Func([ "types", "values" ], B("string"), "encode values"),
},
staticProperties: {
}
},
{
name: "defaultAbiCoder",
description: "the default ABI coder",
returns: H("AbiCoder"),
},
/*
{
_name: "defaultAbiCoder.decode",
name: "decode",
insert: "decode()",
cls: ethers.utils.defaultAbiCoder,
description: "decode ABI encoded data",
returns: B("_"),
params: [ "types", "data" ],
descriptions: [
"the array of types",
"the encoded data"
]
},
{
name: "defaultAbiCoder.encode",
description: "encode objects as ABI data",
returns: B("string", D("Bytes")),
params: [ "types", "value" ],
descriptions: [
"the array of types",
"the value to encode"
]
},
*/
{
name: "defaultPath",
description: "the default BIP-44 path for Ethereum",
returns: B("string")
},
{
name: "entropyToMnemonic",
description: "converts BIP-39 entropy to its mnemonic",
returns: B("string"),
params: [ "entropy", "%wordlist" ],
descriptions: [
"the BIP-39 entropy",
"the wordlist to use"
]
},
/*
{
name: "ErrorFragment.from",
description: "creates a new Error Fragment",
returns: "ErrorFragment",
params: [ "description" ],
descriptions: [
"the human-readable or JSON ABI"
]
},
{
name: "EventFragment.from",
description: "creates a new Event Fragment",
returns: "EventFragment",
params: [ "description" ],
descriptions: [
"the human-readable or JSON ABI"
]
},
*/
{
name: "fetchJson",
description: "fetch a JSON payload.",
returns: B("_"),
params: [ "url", "%body", "%processFunc" ],
descriptions: [
"the url to fetch",
"the payload body to send (default: none)",
"a function to post-process the result"
]
},
{
name: "formatBytes32String",
description: "formats a string as a Bytes32 hexdataString.",
returns: B("string", D("Bytes32")),
params: [ "text" ],
descriptions: [
"the text to convert"
]
},
/*
{
name: "Fragment.from",
description: "creates a new Fragment",
returns: "Fragment",
params: [ "description" ],
example: 'Fragment.from("function foo(string bar) view returns (uint256)")',
descriptions: [
"the human-readable or JSON ABI"
]
},
{
name: "FormatTypes.full",
description: "constant for formatting Fragments as a human-readable ABI",
returns: B("string"),
},
{
name: "FormatTypes.minimal",
description: "constant for formatting Fragments as a human-readable ABI with minimal details",
returns: B("string"),
},
{
name: "FormatTypes.json",
description: "constant for formatting Fragments as a JSON string",
returns: B("string"),
},
{
name: "FormatTypes.sighash",
description: "constant for formatting Fragments as a normalized string to compute selectors",
returns: B("string"),
},
*/
{
name: "formatEther",
description: "formats a value as an ether decimal string.",
returns: B("string"),
params: [ "value" ],
descriptions: [
"the value to format"
]
},
{
name: "formatUnits",
description: "formats a value as a decimal string.",
returns: B("string"),
params: [ "value", "%decimals" ],
descriptions: [
"the value to format",
"the number of decimal places"
],
insert: "formatUnits(%value, 18)"
},
/*
{
name: "FunctionFragment.from",
description: "creates a new Function Fragment",
returns: "FunctionFragment",
params: [ "description" ],
descriptions: [
"the human-readable or JSON ABI"
]
},
*/
{
name: "getAccountPath",
description: "computes the BIP-44 HD path for an account",
returns: B("string"),
params: [ "index" ],
descriptions: [
"the account index to derive for"
],
},
{
name: "getAddress",
description: "verifies and normalizes an address to a check-sum address",
returns: B("string"),
params: [ "address" ],
descriptions: [
"the address to examine"
],
},
{
name: "getContractAddress",
description: "computes a contract address",
returns: B("string"),
params: [ "txData" ],
descriptions: [
"an object with a .from address and .nonce"
],
},
{
name: "getCreate2Address",
description: "computes a CREATE2 contract address",
returns: B("string"),
params: [ "from", "salt", "initcode" ],
descriptions: [
"the from address",
"the CREATE2 salt",
"the initcode used to deploy the contract"
],
},
{
name: "getIcapAddress",
description: "verifies and normalizes an address to an ICAP address",
returns: B("string"),
params: [ "address" ],
descriptions: [
"the address to examine"
],
},
{
name: "hashMessage",
description: "computes the EIP-191 prefixed personal message hash",
returns: B("string", D("Bytes32")),
params: [ "message" ],
descriptions: [
"the message to hash"
]
},
{
name: "HDNode",
cls: ethers.utils.HDNode,
description: "",
staticProperties: {
fromExtendedKey: Func([ "extendedKey" ], H("HDNode"), "create a new HDNode from an extended public or private key"),
//descriptions: [
// "the bytes-like extended key"
//]
fromMnemonic: Func([ "mnemoinc", "%password", "%wordlist" ], H("HDNode"), "create a new HDNode from a mnemonic"),
//descriptions: [
// "the BIP-44 mnemonic",
// 'the password to decrypt with (defualt: no password)',
// "the Wordlist or locale to use (default: en)"
//]
fromSeed: Func([ "seed" ], H("HDNode"), "create a new HDNode from a seed"),
//descriptions: [
// "the bytes-like seed"
//]
},
properties: {
privateKey: { returns: B("string") },
publicKey: { returns: B("string") },
fingerprint: { returns: B("string") },
parentFingerprint: { returns: B("string") },
address: { returns: B("string") },
mnemonic: { returns: B("string") },
path: { returns: B("string") },
chainCode: { returns: B("string") },
index: { returns: B("number") },
depth: { returns: B("number") },
extendedKey: { returns: B("string") },
neuter: Func([], H("HDNode"), ""),
derivePath: Func([ "path" ], H("HDNode"), ""),
}
},
{
name: "hexConcat",
description: "concatenates multiple bytes-likes",
returns: B("string", D("Bytes")),
params: [ "datas" ],
paramDescr: [
"the array of bytes-like objects"
]
},
{
name: "hexDataLength",
description: "computes the length (in bytes) of bytes-like",
returns: B("number"),
params: [ "data" ],
paramDescr: [
"the data to examine"
]
},
{
name: "hexDataSlice",
description: "slices a bytes-like",
returns: B("string", D("Bytes")),
params: [ "bytesLike", "start", "%end" ],
paramDescr: [
"the data to slice",
"the start index, in bytes",
"the end index, in bytes (default: end of data)",
]
},
{
name: "hexlify",
descr: "convert a data-like to a hexdatastring",
returns: B("string", D("Bytes")),
params: [ "datalike" ],
paramDescr: [
"the bytes-like value to convert"
]
},
{
name: "hexStripZeros",
description: "removes all leading zeros from a bytes-like",
returns: B("string", D("Bytes")),
params: [ "data" ],
paramDescr: [
"the bytes-like object to strip"
]
},
{
name: "hexValue",
description: "encodes a value as a JSON-RPC quantity",
returns: B("string"),
params: [ "value" ],
paramDescr: [
"the value to encode"
]
},
{
name: "hexZeroPad",
description: "pad a bytes-like with leading zeros",