Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b6af4b9877 | ||
|
|
3f368e721d | ||
|
|
22b4257636 | ||
|
|
ca7a631032 | ||
|
|
da5bbd17af | ||
|
|
b58f3f5c3e | ||
|
|
8c30194f59 | ||
|
|
dc9ec37490 | ||
|
|
5175e77eec | ||
|
|
9553c5467c | ||
|
|
a1f07e3274 | ||
|
|
58deb2eb14 | ||
|
|
83caad7f1b | ||
|
|
26c3cc9126 | ||
|
|
1a231dfb0d | ||
|
|
712d0425d0 | ||
|
|
eaa5db517f | ||
|
|
88c3850d1b | ||
|
|
943df72ae9 | ||
|
|
67ab11a036 | ||
|
|
c87ef7526b | ||
|
|
bccf2d52ad | ||
|
|
be6dbdd3e4 | ||
|
|
3c34ee9897 | ||
|
|
9ad97813e3 | ||
|
|
028f04e47f | ||
|
|
4974c9247f | ||
|
|
1ffe6a11bf | ||
|
|
19699ea445 | ||
|
|
d98ccfb12a | ||
|
|
41cb056b0f | ||
|
|
48bda0bdea | ||
|
|
1b393c7b67 | ||
|
|
f52e518b7b | ||
|
|
08970cff88 | ||
|
|
6d38ca6453 | ||
|
|
60db4bc66b | ||
|
|
0661237b28 | ||
|
|
6ccac712a8 | ||
|
|
3d4877940c | ||
|
|
70fc95ef27 | ||
|
|
463f65d25c | ||
|
|
09d176c82e | ||
|
|
fce96baf3d | ||
|
|
c6785c533f | ||
|
|
64de021149 | ||
|
|
de9e17a1a0 | ||
|
|
987bccea2e | ||
|
|
1434b86b8f | ||
|
|
a398b2201f | ||
|
|
f015837c38 | ||
|
|
5b51588995 | ||
|
|
7383e521e5 | ||
|
|
b10f05786c | ||
|
|
a212351528 | ||
|
|
55c01af260 | ||
|
|
1cf6ffad2b | ||
|
|
00d0ab9de1 | ||
|
|
b38e60a9a7 | ||
|
|
29f7e46439 | ||
|
|
fa0add8564 | ||
|
|
5bec38c404 | ||
|
|
43b66b6507 | ||
|
|
7e370b3a23 | ||
|
|
2b270a3c9f | ||
|
|
cf0d9a2d3f | ||
|
|
5d70622819 | ||
|
|
fcebdb6d6f | ||
|
|
3d020b5159 | ||
|
|
530d1bcd03 | ||
|
|
a4151c2941 | ||
|
|
a801d30fb6 | ||
|
|
1fe9b605dd | ||
|
|
ecfd822d94 | ||
|
|
a5e4d68993 | ||
|
|
ca5c002d37 | ||
|
|
6e28760da4 | ||
|
|
a253c4edb5 | ||
|
|
7c96525d35 | ||
|
|
3f0457efc2 | ||
|
|
bfb241d995 | ||
|
|
314ad8c3f2 | ||
|
|
aa85371f82 | ||
|
|
d0a08dadd9 | ||
|
|
eeff764345 | ||
|
|
4870ec4f40 | ||
|
|
1c3cfbfa0c | ||
|
|
3c9b7de6c7 | ||
|
|
22e5488f16 | ||
|
|
b37887993e | ||
|
|
75361cb0ff | ||
|
|
894992bc4c | ||
|
|
d955fab169 | ||
|
|
580d225387 | ||
|
|
d48f59e48d | ||
|
|
108b49ea03 | ||
|
|
9295349886 | ||
|
|
a51658ffac | ||
|
|
47f08e9e04 | ||
|
|
7906ae63dc | ||
|
|
0e76271dba | ||
|
|
e117619e34 | ||
|
|
67b416fe80 | ||
|
|
78dbfa46fa | ||
|
|
01db9261d5 | ||
|
|
674c38b384 | ||
|
|
0700e824eb | ||
|
|
0362eaf472 | ||
|
|
696b3964e6 | ||
|
|
5d0c2eed7b | ||
|
|
e4c3289ad8 | ||
|
|
4449bdae6f | ||
|
|
064957db81 | ||
|
|
ccd89ef0a6 | ||
|
|
47beb5f41f | ||
|
|
9f205392a3 | ||
|
|
adce7ccbee | ||
|
|
b83b3a9437 | ||
|
|
147dbcf24f | ||
|
|
2afff1b41f | ||
|
|
d1a1be49c5 | ||
|
|
4b6ad647a2 | ||
|
|
04f656cafa | ||
|
|
09bbd5f6c9 | ||
|
|
dbc3df6d09 | ||
|
|
26865f92e3 | ||
|
|
73045de73d | ||
|
|
6d3491b9f1 | ||
|
|
886f3a3c08 | ||
|
|
c72f976895 | ||
|
|
ab8b381d8b | ||
|
|
443e29a3be | ||
|
|
117bb5717a | ||
|
|
5fb76baa16 | ||
|
|
274b3498d4 | ||
|
|
fa9e1c53e1 | ||
|
|
3ebf7eb424 | ||
|
|
7d11e6f9a5 | ||
|
|
a0d6384b01 | ||
|
|
47afe2cfc6 | ||
|
|
c37a2fc756 | ||
|
|
e2545276bb | ||
|
|
4219409ef8 | ||
|
|
c9e64d2a32 | ||
|
|
41db3b2e35 | ||
|
|
ebe15dada6 | ||
|
|
c2cb5dc574 | ||
|
|
ba451348c0 | ||
|
|
ec76b11666 | ||
|
|
7603f9e6c1 | ||
|
|
b50eab11c0 | ||
|
|
66d05c1771 | ||
|
|
fd7c3d7e10 | ||
|
|
28d4c7d808 | ||
|
|
43d36fbcf6 | ||
|
|
e54eef2369 | ||
|
|
296842858f | ||
|
|
ba8849a3e9 | ||
|
|
e333c3d8d9 | ||
|
|
0fe6a21624 | ||
|
|
0abedb81c6 | ||
|
|
08eda72d4b | ||
|
|
70d4126c84 | ||
|
|
dcccab705c | ||
|
|
e45ff6d026 | ||
|
|
b49c2314e7 | ||
|
|
0ac085756a | ||
|
|
542a690c89 | ||
|
|
ff23ead797 | ||
|
|
ae55e4fbf7 | ||
|
|
b17412163d | ||
|
|
46dcbf9a42 | ||
|
|
193dfcc32f | ||
|
|
a81011cf94 | ||
|
|
d43a8b2e11 | ||
|
|
dff859ba68 | ||
|
|
5169b6ee69 | ||
|
|
f4405667fe | ||
|
|
49ff636305 | ||
|
|
d77d686c76 | ||
|
|
502c6a3451 | ||
|
|
b58c77683d | ||
|
|
b9f82fc549 | ||
|
|
25b8dba607 | ||
|
|
1bc4f2c334 | ||
|
|
aee8ac6b0a | ||
|
|
aa7e30070f | ||
|
|
64b5855f65 | ||
|
|
d7ff9e706e | ||
|
|
15ba6f6261 | ||
|
|
8c88a880c6 | ||
|
|
74566cce7b | ||
|
|
16f6deed5e | ||
|
|
40edc131fe | ||
|
|
3e014b38e6 | ||
|
|
b4cfdbffab | ||
|
|
cbfb6f8f59 | ||
|
|
b5bc15ab8b | ||
|
|
0b343fc0f8 | ||
|
|
e7f9693873 | ||
|
|
a0a5c3185d | ||
|
|
151d4693a9 | ||
|
|
cdb27d8ec2 | ||
|
|
055e4d1261 | ||
|
|
bf753255ab | ||
|
|
e2230ef454 | ||
|
|
0f5b01b856 | ||
|
|
82787c96c6 | ||
|
|
f89028d5fe | ||
|
|
ba24a2e917 | ||
|
|
b549bbf46b | ||
|
|
1e87f58f36 | ||
|
|
f643426067 | ||
|
|
94d26c76ec | ||
|
|
8fe262a712 | ||
|
|
122ee968cb | ||
|
|
d2ff350db9 | ||
|
|
9100aabbac | ||
|
|
1e73f69253 | ||
|
|
7153cb4158 | ||
|
|
999dc6f8a5 | ||
|
|
724574afe7 | ||
|
|
0352a30b6b | ||
|
|
41b4cd5c55 | ||
|
|
89f16f3123 | ||
|
|
261a4eede3 | ||
|
|
f623b382f7 | ||
|
|
51537c619a | ||
|
|
3df943572f | ||
|
|
aa10804f6f | ||
|
|
981407f00f | ||
|
|
74f7098e0a | ||
|
|
c2e46bf16d | ||
|
|
78b26d2d40 | ||
|
|
e4d5be85f6 | ||
|
|
23b5601eeb | ||
|
|
859679ce09 | ||
|
|
71543c2351 | ||
|
|
edae5057c8 | ||
|
|
8dd450ded4 | ||
|
|
bc2061723e | ||
|
|
5753e37307 | ||
|
|
e74da70a9d | ||
|
|
737bbc225a | ||
|
|
9313551559 | ||
|
|
5b8f53f050 | ||
|
|
7358e4715b | ||
|
|
a9005d86d6 | ||
|
|
788c05d86e | ||
|
|
de6ba69631 | ||
|
|
4153fed250 | ||
|
|
c68b89831e | ||
|
|
01c9c5ed53 | ||
|
|
573fb135a7 | ||
|
|
0ee7256e37 | ||
|
|
9829ee558c | ||
|
|
34b563dd48 | ||
|
|
f6bb200146 | ||
|
|
af36e3a52c | ||
|
|
c50c7ae6ef | ||
|
|
61739d5ba1 | ||
|
|
34c4a6055e | ||
|
|
27dabdaf52 | ||
|
|
2ee3242f41 | ||
|
|
67ae9627af | ||
|
|
29f7e12df6 | ||
|
|
a4bb2c8268 | ||
|
|
6521c5f533 | ||
|
|
6925c18821 | ||
|
|
9269d94677 | ||
|
|
d438814ad6 | ||
|
|
bc205a350b | ||
|
|
6bf6fddd28 | ||
|
|
23f8eb9713 | ||
|
|
8ab3097328 | ||
|
|
644d0e6c2e | ||
|
|
6a69fdfbbf | ||
|
|
16e9a64941 | ||
|
|
f3cbc070ea | ||
|
|
df22526229 | ||
|
|
3739bdaa89 | ||
|
|
1f55f38bd2 | ||
|
|
c9deb0d88f | ||
|
|
eecfb39463 | ||
|
|
51bb27da42 | ||
|
|
9c0d296e87 | ||
|
|
0793e0bf8c | ||
|
|
e9ad88d50e | ||
|
|
fbe24c04b8 | ||
|
|
8a7d4d3be3 | ||
|
|
61c9a3bb93 | ||
|
|
3721a11f34 | ||
|
|
21039dec1f | ||
|
|
1393f565d8 | ||
|
|
1530e55f9d | ||
|
|
c982505f73 | ||
|
|
ec8c0d3e8b | ||
|
|
8cb0269676 | ||
|
|
27f460cfe3 | ||
|
|
e98e8d6a0d | ||
|
|
2f94662837 | ||
|
|
d46d6a9acd | ||
|
|
093d2cfa7c | ||
|
|
35b31a21dc | ||
|
|
8b9741a722 | ||
|
|
d5cfa9b0e9 | ||
|
|
129d1214fe | ||
|
|
abb3375c3a | ||
|
|
4cfa06b43f | ||
|
|
8fa80ac0f6 | ||
|
|
2d011c68df | ||
|
|
640ef4bdab | ||
|
|
cdd20c0b99 | ||
|
|
3a12123bf9 | ||
|
|
5657d5395b | ||
|
|
66b1108c5c | ||
|
|
7bf7e207c2 | ||
|
|
01098395ec | ||
|
|
3e21dfdc03 | ||
|
|
a400fb2362 | ||
|
|
44172aa359 | ||
|
|
82cab2827a | ||
|
|
a198eb1515 | ||
|
|
6e67cd6c97 | ||
|
|
e51e89df56 | ||
|
|
e46fd07d39 | ||
|
|
b2cf9aed83 | ||
|
|
c632030437 | ||
|
|
9dc683d289 | ||
|
|
6cef6190b1 | ||
|
|
75dd443d79 | ||
|
|
13dacb591d | ||
|
|
429bf5456e | ||
|
|
527c0f5015 | ||
|
|
527ab27bee | ||
|
|
7991403022 | ||
|
|
61d2e6c5e5 | ||
|
|
e005a3fc0c | ||
|
|
2dfb0fb59a | ||
|
|
70c011e7e2 | ||
|
|
8134322626 | ||
|
|
60152749bb | ||
|
|
b257e120d4 | ||
|
|
6dc75acd21 | ||
|
|
a04400170c | ||
|
|
e3f16e6066 | ||
|
|
c3b697d52d | ||
|
|
645fb58e82 | ||
|
|
474e509507 | ||
|
|
df9aff3bac | ||
|
|
caface921e | ||
|
|
ba9cc785c1 | ||
|
|
4ff9b51af2 | ||
|
|
2c20a9f395 | ||
|
|
ee17aa7464 | ||
|
|
2d01a7b593 | ||
|
|
000e8089d9 | ||
|
|
43000b6aaf | ||
|
|
0f8b204db8 | ||
|
|
679f4103e1 | ||
|
|
6c61708eff | ||
|
|
f0ce53f5a5 | ||
|
|
d826ac85fa | ||
|
|
18a81fbbcb | ||
|
|
9ab59c9241 | ||
|
|
0161996cf6 | ||
|
|
99463a3f1d | ||
|
|
cec4c69374 | ||
|
|
44077c7cf6 | ||
|
|
ac7b1bdeeb | ||
|
|
1c86333b5f | ||
|
|
da4108ff9b | ||
|
|
0c5fc15935 | ||
|
|
970039775d | ||
|
|
2ddcd59ed0 | ||
|
|
a4519495ad | ||
|
|
a9c9fb5769 | ||
|
|
0e928a2a11 | ||
|
|
756b24f10a | ||
|
|
85a37b2604 | ||
|
|
e0e8d37a64 | ||
|
|
4c4fd2afd1 | ||
|
|
926d1e55d1 | ||
|
|
491e7cd155 | ||
|
|
ed2d6e8d0e | ||
|
|
714f72d6c3 | ||
|
|
8671171061 | ||
|
|
45b176de7d | ||
|
|
1901b8899d | ||
|
|
9ead0103a9 | ||
|
|
af0bcc80e8 | ||
|
|
e0b7dd13e0 | ||
|
|
9e13b6f54e | ||
|
|
6aa5a2dd0c | ||
|
|
361f9e4419 | ||
|
|
1ca00c7633 | ||
|
|
83f36e466f | ||
|
|
e685923102 | ||
|
|
3aaa6db190 | ||
|
|
a98b6b9bf8 | ||
|
|
fc0148fd41 | ||
|
|
1dc04ec8bd | ||
|
|
3c2617fe5c | ||
|
|
9e20006d24 | ||
|
|
dcd5a0b620 | ||
|
|
6f5b852bf7 | ||
|
|
22e4abc903 | ||
|
|
b5e37c020d | ||
|
|
a806e4a2ee | ||
|
|
9164637c44 | ||
|
|
1ba8f71da1 | ||
|
|
91693bf587 | ||
|
|
e6a99b9f07 | ||
|
|
f6d9ba2471 | ||
|
|
af24955bc7 | ||
|
|
3e66807716 | ||
|
|
f34d48ad09 | ||
|
|
0d7be67499 | ||
|
|
7804794233 | ||
|
|
c7a68a4e05 | ||
|
|
811f9f7868 | ||
|
|
d9acf1cfea | ||
|
|
0967dbba6b | ||
|
|
025a745258 | ||
|
|
88eb4fd6e5 | ||
|
|
0dcdffd59c | ||
|
|
1f39ad264a | ||
|
|
e357a08118 | ||
|
|
d6b2b4a1a3 | ||
|
|
47f2ee725f | ||
|
|
1028e14761 | ||
|
|
5fdefa9e58 | ||
|
|
80209da5c5 | ||
|
|
bbdf0e3192 | ||
|
|
9ee1c0bf13 | ||
|
|
5490947384 | ||
|
|
b1788be796 | ||
|
|
f4ec312656 | ||
|
|
e1057603fc | ||
|
|
0268e398c1 | ||
|
|
757d45b39e | ||
|
|
4f57a5a611 | ||
|
|
987896e323 | ||
|
|
1b9d3bf38e | ||
|
|
b8a0f39da4 | ||
|
|
e4e20f8a88 | ||
|
|
131729e438 | ||
|
|
4672439bce | ||
|
|
0b11fc98b9 | ||
|
|
ece0a4b19a | ||
|
|
1dac7e3f1b | ||
|
|
3e1c93d4a8 | ||
|
|
19e9af02d8 | ||
|
|
2200cc2fab | ||
|
|
33990b6d02 | ||
|
|
333313fd6a | ||
|
|
33fd09c053 | ||
|
|
7dadac7344 | ||
|
|
340554a659 | ||
|
|
236ad16406 | ||
|
|
aae4671db5 | ||
|
|
d0f9eb7d03 | ||
|
|
d6106b3253 | ||
|
|
9740c282d8 | ||
|
|
f65b5c77ec | ||
|
|
0f920ee77d | ||
|
|
62d1415d1b | ||
|
|
f8792e09c9 | ||
|
|
8d4b03d066 | ||
|
|
5d3c728cf0 | ||
|
|
04340de6ae | ||
|
|
d709a5b3be | ||
|
|
1d3dfc77a3 | ||
|
|
a72d33ad24 | ||
|
|
e4948ef579 | ||
|
|
f9812585b8 | ||
|
|
e2654dd2f8 | ||
|
|
5f0ea88a42 | ||
|
|
69be690be6 | ||
|
|
67d4637786 | ||
|
|
d2557a3cac | ||
|
|
e2911a33c4 | ||
|
|
9b45901760 | ||
|
|
450f53d563 | ||
|
|
5374c863ad | ||
|
|
ce29ae6e0e | ||
|
|
d420c65c2b | ||
|
|
427ae64fab | ||
|
|
173c40b0e5 | ||
|
|
208fbb24d5 | ||
|
|
9ee563e3f6 | ||
|
|
70acb27218 | ||
|
|
dd29ebbeae | ||
|
|
b01935122f | ||
|
|
71d54821e0 | ||
|
|
5df3e1605a | ||
|
|
50737b7ef7 | ||
|
|
ecc86f797c | ||
|
|
ff020d14e4 | ||
|
|
ff36cb97c2 | ||
|
|
01f2fe7c86 | ||
|
|
948d8cccc1 | ||
|
|
da2e2f89c9 | ||
|
|
6b4fd110a1 | ||
|
|
a48eba101c | ||
|
|
78b9d29fa0 | ||
|
|
92c9ce15d6 | ||
|
|
11c4239614 | ||
|
|
0cb7b34ff0 | ||
|
|
a74382c539 | ||
|
|
beccc2ed9b | ||
|
|
c29f66c7c5 | ||
|
|
dba23e3923 | ||
|
|
f633b3d6c1 | ||
|
|
b1c7409c59 | ||
|
|
a2423b1004 | ||
|
|
c0f1bf7f1e | ||
|
|
8e6a1c8fb1 | ||
|
|
92ee9ab339 | ||
|
|
70f1fa5514 | ||
|
|
37f49b30de | ||
|
|
8b4d3872d7 | ||
|
|
4e2ab3d11c | ||
|
|
b1291bfbe3 | ||
|
|
026ef3c4ed | ||
|
|
158fe79c43 | ||
|
|
c467efdb3b | ||
|
|
b1d0eb9597 | ||
|
|
3b9149d3ac | ||
|
|
a9e8388cc8 | ||
|
|
a33265e5ed | ||
|
|
1d6bfb69ff | ||
|
|
96f32c63fd | ||
|
|
07b69fe635 | ||
|
|
a579f3e09c | ||
|
|
6559b1ad11 | ||
|
|
f7da1d0fb2 | ||
|
|
94e57f6dcf | ||
|
|
1364c45d16 | ||
|
|
54b5b38ba6 | ||
|
|
944f4ddf1d | ||
|
|
895d44fe9f | ||
|
|
eccc6cc2c9 | ||
|
|
a7c2d11a56 | ||
|
|
a71744bd16 | ||
|
|
0e52e8fe23 | ||
|
|
2769336344 | ||
|
|
522906695f | ||
|
|
f7c968b7a6 | ||
|
|
c1b7660122 | ||
|
|
811a2291ed | ||
|
|
90cc148383 | ||
|
|
b652bdc2de | ||
|
|
f6942cc0f0 | ||
|
|
8e852db87c | ||
|
|
75f97bb1ff | ||
|
|
c8d7e971bc | ||
|
|
09aa046ab4 | ||
|
|
25e29d9565 | ||
|
|
c396b963ee | ||
|
|
46be42705b | ||
|
|
d65eb7a27f | ||
|
|
a1a73cbf01 | ||
|
|
72e03138e8 | ||
|
|
b0e7440ca6 | ||
|
|
4847988a94 | ||
|
|
a58be22764 | ||
|
|
f6af257051 | ||
|
|
790e0ebdcf | ||
|
|
1db2cfbedf | ||
|
|
8a75c9bac0 | ||
|
|
ab05224c71 | ||
|
|
986e8fbb20 | ||
|
|
2906b02e41 | ||
|
|
683c37b171 | ||
|
|
20bdc6e63d | ||
|
|
b200b20972 | ||
|
|
7a4fe4fe5f | ||
|
|
aa6ec6c9dc | ||
|
|
0871e074c7 | ||
|
|
aa7d34dca1 | ||
|
|
65b4d5bb43 | ||
|
|
acc1edaddc | ||
|
|
ba9b9c6fa2 | ||
|
|
aa4f593d79 | ||
|
|
dd2dde5701 | ||
|
|
033cba718d | ||
|
|
c4470eba14 | ||
|
|
fb2bc42fe0 | ||
|
|
d3b13bceb0 | ||
|
|
0fc5e1d387 | ||
|
|
ce6c25e4e2 | ||
|
|
165381d79a | ||
|
|
2da3f16bda | ||
|
|
02c349093b | ||
|
|
82873c44f8 | ||
|
|
7afc696da3 | ||
|
|
4e0d430504 | ||
|
|
0b091fa935 | ||
|
|
4db33b6caf | ||
|
|
4dd0372702 | ||
|
|
98b01a462d | ||
|
|
03570f2f11 | ||
|
|
f810e65ea2 | ||
|
|
c04b63e4af | ||
|
|
98a2ef9d72 | ||
|
|
999e69b031 | ||
|
|
79e99fd6e3 | ||
|
|
d91460b79d | ||
|
|
b1f7b72043 | ||
|
|
5a1fd4a1bb | ||
|
|
3ec469bbaf | ||
|
|
091ee7624a | ||
|
|
1918547fdc | ||
|
|
a8a956c85d | ||
|
|
143febf807 | ||
|
|
af9437f80a | ||
|
|
5cf585c8dd | ||
|
|
e6dbbfae34 | ||
|
|
8993844739 | ||
|
|
21d0622f84 | ||
|
|
e787c08bd9 | ||
|
|
ce6d9424e6 | ||
|
|
930252e3bc | ||
|
|
613aebd26d | ||
|
|
79e0d807ab | ||
|
|
0cbd702c93 | ||
|
|
e7ee68d138 | ||
|
|
46fb44d3d8 | ||
|
|
2085a0662c | ||
|
|
4476f2838a | ||
|
|
ddd994ea4a | ||
|
|
06a325795b | ||
|
|
67d7df82d3 | ||
|
|
ca1bd8fa19 | ||
|
|
33978d5007 | ||
|
|
b6ff8a400e | ||
|
|
2bc3b711b2 | ||
|
|
09348d1197 | ||
|
|
cb791d3963 | ||
|
|
bc49e75e61 | ||
|
|
67f8dcafdb | ||
|
|
e95117839b | ||
|
|
9f60a8cd5f | ||
|
|
e23fae86d5 | ||
|
|
94a4594d32 | ||
|
|
5be8ef8f0d | ||
|
|
e855d5a9d4 | ||
|
|
2a0e481710 | ||
|
|
161c121cb2 | ||
|
|
de38735498 | ||
|
|
ce1e6615e3 | ||
|
|
3ebe9f5243 | ||
|
|
f686cfcce7 | ||
|
|
c27e49c6f5 | ||
|
|
5c69f78676 | ||
|
|
8f00351405 | ||
|
|
1f6c8c2eb8 | ||
|
|
9bb1343255 | ||
|
|
94ebb321f1 | ||
|
|
63fd5baa8f | ||
|
|
ea3ee428d8 | ||
|
|
5cb1c2d33a | ||
|
|
600666de1c | ||
|
|
524885e8de | ||
|
|
1476e5e5e9 | ||
|
|
3f48b3c29f | ||
|
|
9debb854f9 | ||
|
|
db3fe7d103 | ||
|
|
a93063c6fb | ||
|
|
8e4bbd2b23 | ||
|
|
cf1c2ea58a | ||
|
|
ca2909e4ba | ||
|
|
cc9ea53e1a | ||
|
|
d876e19fa1 | ||
|
|
bb7b94dc35 | ||
|
|
be1deb1a75 | ||
|
|
14026fef42 | ||
|
|
b2ea2da6aa | ||
|
|
f1d21847db | ||
|
|
b1fcfd11f4 | ||
|
|
7d1f0e2900 | ||
|
|
fb377fb0d4 | ||
|
|
26de59ed79 | ||
|
|
964bd33bb1 | ||
|
|
f068ef76a5 | ||
|
|
e6e60ec6d0 | ||
|
|
9f9680ba92 | ||
|
|
bb63de1653 | ||
|
|
a2c2b24198 | ||
|
|
1944ffe017 | ||
|
|
d4aa36981d | ||
|
|
2c735fbc53 | ||
|
|
7038045bc8 | ||
|
|
0be5c969aa | ||
|
|
9ead2bdc41 | ||
|
|
1ae37ed2d3 | ||
|
|
7ca78c5679 | ||
|
|
cd94d01b06 | ||
|
|
dafc92809d | ||
|
|
298884d885 | ||
|
|
2a64c7c29a | ||
|
|
d2b7dc550a | ||
|
|
25f18d5455 | ||
|
|
c9c872c736 | ||
|
|
8394b7fb5a | ||
|
|
fb82db382e | ||
|
|
9f83f5cac3 | ||
|
|
45a895b64f | ||
|
|
93fbd6e13f | ||
|
|
b53490bd26 | ||
|
|
594376367a | ||
|
|
180fe57531 | ||
|
|
bddb4465fb | ||
|
|
3cdc647506 | ||
|
|
82ee7cc4f1 | ||
|
|
9f9658d6a0 | ||
|
|
1abc519297 | ||
|
|
b939bcd57d | ||
|
|
d487a27676 | ||
|
|
0525feb6f2 | ||
|
|
4ea343e369 | ||
|
|
6f2173778e | ||
|
|
bb6166e65f | ||
|
|
dec82380c3 | ||
|
|
a980d4ae11 | ||
|
|
5c194b6f5f | ||
|
|
c4662e6fd8 | ||
|
|
995de2012e | ||
|
|
b1a8c011f4 | ||
|
|
86cd550ad3 | ||
|
|
57529998f9 | ||
|
|
0e0d733e65 | ||
|
|
773618acfb | ||
|
|
c5fcb0d06b | ||
|
|
e25272c986 | ||
|
|
d389c6737e | ||
|
|
9e1313f140 | ||
|
|
d2a2887d32 | ||
|
|
b3d9549c0b | ||
|
|
240cadd045 | ||
|
|
d47faa4687 | ||
|
|
393c677a16 | ||
|
|
074ddd8632 | ||
|
|
a8a10aec0c | ||
|
|
fed93e2459 | ||
|
|
374df23011 | ||
|
|
9c098c3fbf | ||
|
|
4e799858ad | ||
|
|
ee6924324f | ||
|
|
75f86bb43e | ||
|
|
bfd3113a55 | ||
|
|
8d8d5bd7d7 |
+16
-2
@@ -1,7 +1,21 @@
|
||||
25
|
||||
27
|
||||
1.4.2
|
||||
1.6.2
|
||||
1.11.2
|
||||
1.12.2
|
||||
1.17.2
|
||||
1.31.2
|
||||
1.31.2
|
||||
2.8.2
|
||||
3.2.2
|
||||
3.2.3
|
||||
3.3.2
|
||||
3.6.2
|
||||
3.6.3
|
||||
3.6.4
|
||||
3.7.2
|
||||
3.7.3
|
||||
3.9.2
|
||||
3.9.3
|
||||
3.10.2
|
||||
4.0.2
|
||||
4.0.3
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
// Copyright 2017-2020 @polkadot/api authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
module.exports = require('./babel.config.js');
|
||||
@@ -1,5 +0,0 @@
|
||||
.eslintrc.js
|
||||
**/build/*
|
||||
**/coverage/*
|
||||
**/node_modules/*
|
||||
docs/examples/promise/90_typegen/*
|
||||
+11
-4
@@ -1,10 +1,19 @@
|
||||
// Copyright 2017-2020 @polkadot/api authors & contributors
|
||||
// Copyright 2017-2021 @polkadot/api authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
const base = require('@polkadot/dev/config/eslint');
|
||||
const base = require('@polkadot/dev/config/eslint.cjs');
|
||||
|
||||
module.exports = {
|
||||
...base,
|
||||
ignorePatterns: [
|
||||
'.eslintrc.js',
|
||||
'.github/**',
|
||||
'.vscode/**',
|
||||
'.yarn/**',
|
||||
'**/build/*',
|
||||
'**/coverage/*',
|
||||
'**/node_modules/*'
|
||||
],
|
||||
parserOptions: {
|
||||
...base.parserOptions,
|
||||
project: [
|
||||
@@ -15,8 +24,6 @@ module.exports = {
|
||||
...base.rules,
|
||||
// add override for any (a metric ton of them, initial conversion)
|
||||
'@typescript-eslint/no-explicit-any': 'off',
|
||||
// these should be removed, there are 8 of them as errors
|
||||
'@typescript-eslint/no-non-null-assertion': 'off',
|
||||
// this seems very broken atm, false positives
|
||||
'@typescript-eslint/unbound-method': 'off'
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ jobs:
|
||||
name: ${{ matrix.step }}
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- uses: actions/checkout@v2
|
||||
- name: ${{ matrix.step }}
|
||||
run: |
|
||||
yarn install --immutable | grep -v 'YN0013'
|
||||
|
||||
@@ -13,7 +13,7 @@ jobs:
|
||||
if: "! startsWith(github.event.head_commit.message, '[CI Skip]') && github.repository == 'polkadot-js/api'"
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
token: ${{ secrets.GH_PAT }}
|
||||
- name: ${{ matrix.step }}
|
||||
|
||||
+46
-7
File diff suppressed because one or more lines are too long
+46
-21
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Vendored
-55
File diff suppressed because one or more lines are too long
+55
File diff suppressed because one or more lines are too long
+1
-3
@@ -9,7 +9,5 @@ plugins:
|
||||
spec: "@yarnpkg/plugin-interactive-tools"
|
||||
- path: .yarn/plugins/@yarnpkg/plugin-version.cjs
|
||||
spec: "@yarnpkg/plugin-version"
|
||||
- path: .yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs
|
||||
spec: "@yarnpkg/plugin-workspace-tools"
|
||||
|
||||
yarnPath: .yarn/releases/yarn-2.2.2.cjs
|
||||
yarnPath: .yarn/releases/yarn-2.4.1.cjs
|
||||
|
||||
+556
-3
@@ -1,6 +1,558 @@
|
||||
# CHANGELOG
|
||||
|
||||
## 2.2.1 Oct 13, 2020
|
||||
## 4.4.1 Apr 5, 2021
|
||||
|
||||
Upgrade priority: Low. Recommended with usage with the Rococo testnet.
|
||||
|
||||
Changes:
|
||||
|
||||
- Add `ServiceQuality` type for Cumulus
|
||||
- Adjust XCM MultiLocation type (X5 to X8 junctions)
|
||||
- Add Polkadot 29 upgrade block
|
||||
|
||||
|
||||
## 4.3.1 Mar 29, 2021
|
||||
|
||||
Upgrade priority: Low.
|
||||
|
||||
Contributed:
|
||||
|
||||
- Fix documentation on ABI parameters (Thanks to https://github.com/vminkov)
|
||||
|
||||
Changes:
|
||||
|
||||
- Warn on usage of deprecated contract interfaces
|
||||
- Update `ParaInfo` type
|
||||
- Council should be optional in treasury derives
|
||||
- Allow extraction of session derives indexes with no staking
|
||||
|
||||
|
||||
## 4.2.1 Mar 22, 2021
|
||||
|
||||
Upgrade priority: Low. Recommended when tracking the latest updates from Substrate.
|
||||
|
||||
Contributed:
|
||||
|
||||
- Fix contract even decoding on Substrate 3 (Thanks to https://github.com/vminkov)
|
||||
|
||||
Changes:
|
||||
|
||||
- Adjust `Extender{Header, SignedBlock}` types to ensure at-block `Header` types are used
|
||||
- Explicit definition for new Rococo triple refcount `AccountData` types
|
||||
- Convert metadata private class fields to ES-private
|
||||
- Adjust `SignedBlock` type for new `justifications` field
|
||||
- Optimize society derive for multi accounts
|
||||
- Bump metadata to latest substrate version
|
||||
|
||||
|
||||
## 4.1.1 Mar 15, 2021
|
||||
|
||||
Upgrade priority: Low. Recommended when tracking the latest updates from Substrate.
|
||||
|
||||
Changes:
|
||||
|
||||
- Fix author extraction for last block in a session
|
||||
- Expand `SignerPayload` to inject/expose custom signed extensions
|
||||
- `ConsensusEngineId` formats non-Ascii engines correctly
|
||||
- Allow `getBlock/Header` derives to use as-at registry (instead of latest)
|
||||
- Cleanup `RpcCore` augmentation (removing TS warnings on typegen chains)
|
||||
- Add upgrade block for Kusama 2029
|
||||
- Ensure that type alias overrides also apply to map keys
|
||||
- Check type generation against fallbacks (build-time only sanity check)
|
||||
- Add `mmr_generateProof` RPC
|
||||
- Align types with latest substrate master
|
||||
- Apply latest Polkadot auctions/crowdloan/parachains/slots types
|
||||
|
||||
|
||||
## 4.0.3 Mar 8, 2021
|
||||
|
||||
Upgrade priority: Low. Recommended if you use the API to sync the full chain, most notably Polkadot.
|
||||
|
||||
Contributed:
|
||||
|
||||
- Re-add unused historical `SudoBalances` to `ProxyType` (Thanks to https://github.com/emostov)
|
||||
|
||||
|
||||
## 4.0.2 Mar 8, 2021
|
||||
|
||||
Upgrade priority: High. Required if you are using 4.0.1 in a Node.js environment.
|
||||
|
||||
Changes:
|
||||
|
||||
- Fix import from `@polkadot/x-rxjs` in Node environments (From common)
|
||||
- Add correct types for `Phase` is new validator elections module
|
||||
|
||||
|
||||
## 4.0.1 Mar 7, 2021
|
||||
|
||||
Upgrade priority: Low. Recommended for users wanting to keep updated with chain changes.
|
||||
|
||||
**Important** In the 4.0 version the default package type has been changed to ESM modules by default. This should not affect usage, however since the output formats changed, a new major version is required.
|
||||
|
||||
Contributed:
|
||||
|
||||
- Expose `unknownTypes` on the registry interface (Thanks to https://github.com/ii-ii-ii)
|
||||
|
||||
Changes:
|
||||
|
||||
- Build to ESM by default (with cjs versions via export map)
|
||||
- Enum `.toSON()` now encodes all keys as `camelCase` (aligning with the output from Substrate)
|
||||
- Add `createdAtHash?: Hash` to `Codec` interface (filled-in by storage retrievals)
|
||||
- Expose the source hash as `wamHash` on Abi parsed instances
|
||||
- Use `parentHash` when creating mortal era (handles frequent forks better)
|
||||
- Add `AccountInfoWithTripleRefCount` to cater for latest Substrate
|
||||
- Add upgrade block for Westend 49
|
||||
|
||||
|
||||
## 3.11.1 Feb 28, 2021
|
||||
|
||||
Upgrade priority: Low. Recommended for users wanting to keep updated with chain changes.
|
||||
|
||||
Contributed:
|
||||
|
||||
- Clean Websocket states on disconnects (Thanks to https://github.com/ianhe8x)
|
||||
- Support for C-like indexed enums (Thanks to https://github.com/xlc)
|
||||
|
||||
Changes:
|
||||
|
||||
- Adjust council derives to cater for current-generation candidate mapping
|
||||
- Allow for override of codec hasher (& output type)
|
||||
- Adjust submittables to submit hex-encoded addresses to queries
|
||||
- Adjust initialization to always retrieve tx version from Metadata only
|
||||
- Update election types as per latest Substrate
|
||||
- Add types for the new gilt module
|
||||
- Upgrade to the latest Substrate metadata
|
||||
- Adjust package detection to check for local monorepo dependencies
|
||||
- Ensure that metadata `.toJSON()` does apply type aliasses
|
||||
|
||||
|
||||
## 3.10.2 Feb 23, 2021
|
||||
|
||||
Upgrade priority: Medium. Recommended for users of chains where `MultiAddress` is in-use and blocks are decoded.
|
||||
|
||||
Changes:
|
||||
|
||||
- Fix decoding for `MultiAddress` enum where non-`AccountId` variable-lengths are provided as part of a stream
|
||||
- Added known Polkadot 28 upgrade block
|
||||
- Update for latest Substrate contracts `Schedule` types
|
||||
|
||||
|
||||
## 3.10.1 Feb 22, 2021
|
||||
|
||||
Upgrade priority: Low.
|
||||
|
||||
Changes:
|
||||
|
||||
- Adjust ConsumedWeight types to align with Rust module code
|
||||
- Check for connection status in subscription unsubscribe
|
||||
- Adjust staking reward derives ordering for better performance
|
||||
- Adapt detection imports to remove `.json` dependencies (Better behavior using Node.js with ESM)
|
||||
|
||||
|
||||
## 3.9.3 Feb 16, 2021
|
||||
|
||||
Upgrade priority: Low. Recommended for parachain builders since it contains the updated parachain types.
|
||||
|
||||
Changes:
|
||||
|
||||
- Adjusted parachain `PersistedValidationData` structure
|
||||
|
||||
|
||||
## 3.9.2 Feb 15, 2021
|
||||
|
||||
Upgrade priority: Low. Recommended for parachain builders since it contains the latest parachain types.
|
||||
|
||||
Contributed:
|
||||
|
||||
- Update README links (Thanks to https://github.com/wirednkod)
|
||||
|
||||
Changes:
|
||||
|
||||
- Added missing Culmulus `ParachainInherentData` & `MessageQueueChain` types
|
||||
- Add alias for `system_unstable_networkState` RPC
|
||||
|
||||
|
||||
## 3.9.1 Feb 14, 2021
|
||||
|
||||
Upgrade priority: Low.
|
||||
|
||||
- **Important** The `Result<T, E>` has been updated in the generation and the base types to follow the Rust version 100%. This means `{as, is}Error` is now available as `{as, is}Err` on the `Result` type. The older versions can still be used, but the `*Error` interfaces are now marked as deprecated.
|
||||
|
||||
Changes:
|
||||
|
||||
- Adjust `Result<T, E>` interface to be 100% compatible with the Rust version
|
||||
- Add the `2028` upgrade to the known upgrades (optimizing certain `.at` queries)
|
||||
- Adjust council derives to cater for latest Substrate & Polkadot
|
||||
- Adjust Rococo know type definitions to cater for the latest update
|
||||
- Update types for latest Polkadot/Substrate
|
||||
- Add generic arguments for TypeScript users to `.entries/.keys` to deal with the key typings
|
||||
|
||||
|
||||
## 3.8.1 Feb 7, 2021
|
||||
|
||||
Upgrade priority: Low. Recommended for users of the latest Substrate master, especially using contracts.
|
||||
|
||||
- **Important** The `api-contract` `Code` now supports deploying the code and a contract in on operation. This aligns with the latest Substrate where code cannot be uploaded with a contract. The `createBlueprint` is therefore deprecated, use `code.tx.<constructor>(...)` to deploy code. (Compatible with both old and new versions of Substrate)
|
||||
|
||||
Contributed:
|
||||
|
||||
- Add support for latest Frontier RPCs (Thanks to https://github.com/jnaviask)
|
||||
- Fix user-supplied signed extensions type signature (Thanks to https://github.com/ntduan)
|
||||
|
||||
Changes:
|
||||
|
||||
- Expand `api-contract` to allow for `Code` to deploy contract alongside code. `createBlueprint` is now deprecated, replaced by `createContract` or the preferred `code.tx.<constructor>`, which uploads and deploys the code in one operation. This aligns with the current Substrate master contracts implementation.
|
||||
- Allow for signed extensions to be supplied inside type bundles
|
||||
- Ensure that the auto-connect state is checked on auto-connections (respecting disconnect)
|
||||
- Added `CancelProxy` to `ProxyTypes on Polkadot, Kusama & Westend
|
||||
- Updated to latest Substrate metadata
|
||||
|
||||
|
||||
## 3.7.3 Feb 2, 2021
|
||||
|
||||
Changes:
|
||||
|
||||
- Added Polkadot upgrade block for runtime 27 (known checkpoint optimization)
|
||||
|
||||
|
||||
## 3.7.2 Feb 2, 2021
|
||||
|
||||
Changes:
|
||||
|
||||
- Adjusted the `Keys` type for the 28 runtime on Kusama, Polkadot & Westend
|
||||
|
||||
|
||||
## 3.7.1 Feb 1, 2021
|
||||
|
||||
Upgrade priority: Low. However recommended for current Substrate master, Polkadot and Rococo users and those wishing to support the upcoming Polkadot 28 runtime with the new `MultiAddress`.
|
||||
|
||||
- **Breaking change** As indicated in the 3.5.1 release notes, the `Address`/`LookupSource` defaults have now been adjusted for `MultiAddress`. If your chain does not use these types, explicitly add the correct `Address`/`LookupSource` types. This new extensible format is mean to cater for all address types into the future, removing a lot of discrepancies between chains.
|
||||
|
||||
Contributed:
|
||||
|
||||
- Extraction of the block author on Moonbeam (Thanks to https://github.com/joelamouche)
|
||||
- Cleanup logs with HTTP providers, no subs (Thanks to https://github.com/Tbaut)
|
||||
|
||||
Changes:
|
||||
|
||||
- Allow `.slice` operator on the `Vec` type
|
||||
- Apply `MultiAddress` as a default
|
||||
- Adds support for the upcoming Polkadot 28 and Kusama 2028 runtimes
|
||||
- Add checkpoint for Kusama 2027 upgrade
|
||||
- Update all parachain types (as per latest Rococo)
|
||||
- Correctly use relay blockNumber in parachain validation data
|
||||
- remove information log for capabilities detection (creates confusion)
|
||||
- Remove explicit references to `global`, use the `x-global` detection
|
||||
- Remove explicit `module` in `package.json` (exports map available)
|
||||
|
||||
|
||||
## 3.6.1 Jan 24, 2020
|
||||
|
||||
Upgrade priority: Medium if not already on at least 3.3.1. The next upgrade of Kusama/Polkadot requires it.
|
||||
|
||||
- **Breaking change** To support chains with multiple tokens, such as bridges, the `ChainProperties` type now returns an array of tokens and decimals (instead of singular values) in the `token{Decimals, Symbol}` getters. Additionally, this means that the `registry` interfaces has been changes, to `registry.chainDecimals: number[]` and `registry.chainTokens: string[]`. Where used the `[0]` index will return the first value if only interested in a single, for a straight conversion.
|
||||
|
||||
Changes:
|
||||
|
||||
- Allow for the detection of on-chain capabilities as available (e.g. `AccountData`, `ValidatorPrefs`)
|
||||
- Cater for multiple tokens and decimals in the chain the chain `system.properties` (as per the chain specification)
|
||||
- Add a `instances: { [key]: [module1, module2] }` definition in teh bundle types, allowing for multiple instances (e.g. Balances)
|
||||
- Adjust the `api-derive` for balances to retrieve values via `instances` as well as across multiple modules
|
||||
- Ensure all types are registered for all metadata typegen steps
|
||||
- Add `rpc.payment.queryFeeDetails` RPC endpoint
|
||||
- Update types & metadata to latest Substrate
|
||||
- Move the `@polkadot/x-rxjs` package into the common repo
|
||||
- Allow doc generation for errors/events (markdown outputs)
|
||||
|
||||
|
||||
## 3.5.1 Jan 18, 2020
|
||||
|
||||
Upgrade priority: Low. Recommended for parachain developers.
|
||||
|
||||
- **Important** The default for Substrate on the Address types are `MultiAddress`. It is recommended that chains add explicit definitions for `Address` and `LookupSource` in their types, instead of relying on the API-defaults. A future update will swap the API defaults to align with Substrate.
|
||||
- **Important** Like the above changes in Substrate, the `AccountInfo` structure has also changed. It is recommended that chain developers explicitly add `AccountInfo: 'AccountInfoWithRefCount'` for the version with `refCount` on and `AccountInfoWithProviders` for the latest Substrate version. As per the above, the API defaults will be changed to align with Substrate.
|
||||
|
||||
Contributed:
|
||||
|
||||
- Apply correct TypeScript type for `toBigInt()` (Thanks to https://github.com/ianhe8x)
|
||||
- Expand type definitions for storage key tuples (Thanks to https://github.com/monitz87)
|
||||
- Adjust bounty derive to cater for non-council chains (Thanks to https://github.com/ekowalsk)
|
||||
|
||||
Changes:
|
||||
|
||||
- Remove recursion in vector/struct U8a stream decoding
|
||||
- Availability of staking made optional in session length calcs (era does require it)
|
||||
- Updates to parachain types, ensuring it has coverage for all the latest
|
||||
- Update all Rococo types to the latest (session keys, session reports, parachain indexes)
|
||||
- Update known upgrade checkpoints fo WestEnd
|
||||
- Add types of the lottery module in Substrate
|
||||
- Add and extend types for the crowdloan module in Polkadot
|
||||
- Adjust node-template to default to `MultiAddress` on specVersion >= 100
|
||||
|
||||
|
||||
## 3.4.1 Jan 11, 2020
|
||||
|
||||
Upgrade priority: Low. Fixes for parachain types, `.entries()` (with no values) and `event.is(...)` checks, users of these interfaces will have benefit.
|
||||
|
||||
- **Breaking change** The `derive.chain.{getBlock, subscribeNewBlocks}` now return `SignedBlockExtended`, all with the actual extrinsics and events mapped. Users of the latter interface should take note.
|
||||
|
||||
Contributed:
|
||||
|
||||
- Fix `SessionKeys{6-9}` definitions (Thanks to https://github.com/icodezjb)
|
||||
- Support `Vec<(a, b)>` in enums (Thanks to https://github.com/monitz87)
|
||||
- Add motions to bounty derive (Thanks to https://github.com/ekowalsk)
|
||||
|
||||
Changes:
|
||||
|
||||
- `derive.chain.getBlock()` now maps events to extrinsics via `.extrinsics` getter
|
||||
- Ensure dispatchInfo is extracted on failed extrinsics (`getBlock` derive)
|
||||
- Allow specification of additional signed extrinsic via API options
|
||||
- Add missing parachain types, `ParaGenesisArgs`
|
||||
- Correct `EthTransaction` type (as per the correct cargo crate)
|
||||
- Update with latest contract types for Substrate master
|
||||
- Update alias mapping for asset palette (including Substrate starting defaults)
|
||||
- Allow `.entries()` call where 0 keys are present
|
||||
- Fix `.is` on events not checking the correct index
|
||||
- Construction of `i*` types ow correctly checks for max positive/negative
|
||||
|
||||
|
||||
## 3.3.1 Jan 4, 2021
|
||||
|
||||
Upgrade priority: Low. Recommended for users of frontier evm module with additional types.
|
||||
|
||||
Contributed:
|
||||
|
||||
- Expand bounty derives (Thanks to https://github.com/ekowalsk)
|
||||
- Adjust known-types (Thanks to https://github.com/mikiquantum)
|
||||
|
||||
Changes:
|
||||
|
||||
- Parallelize the API-init RPC calls for faster overall startup
|
||||
- Add `ExitReason` types for the frontier evm module
|
||||
- Adjust checks for indexed/non-indexed module checks (metadata decoration)
|
||||
- Apply module aliases on constants (aligning with events, extrinsics)
|
||||
- Allow for use of `system.ss58Prefix` as exposed (current Substrate master)
|
||||
- Correct use of api-contract `blockWeights.maxBlock` in estimation
|
||||
- Build metadata docs & interfaces with section aliases
|
||||
- Update to latest Substrate master metadata in tests
|
||||
|
||||
|
||||
## 3.2.1 Dec 27, 2020
|
||||
|
||||
Upgrade priority: Low. Recommended for users of parachains.
|
||||
|
||||
Contributed:
|
||||
|
||||
- Adjust metadata `.asV12` type signature (Thanks to https://github.com/yjhmelody)
|
||||
|
||||
Changes:
|
||||
|
||||
- Add `api.{errors, events, query, tx}.<section>.<name>.is(...)`
|
||||
- Remove support for staking pre Substrate 2.0
|
||||
- Add all frontier types & RPCs
|
||||
- Support `AccountInfo` with new provider/consumer refCount structure
|
||||
- Additional Cumulus parachain types
|
||||
- Consistently format number JSON based on bitLength
|
||||
- Cleanup metadata -> api dependencies
|
||||
- Update `@polkadot/util` to 5.2.1
|
||||
|
||||
|
||||
## 3.1.1 Dec 20, 2020
|
||||
|
||||
Upgrade priority: Low. Recommended for users of parachains.
|
||||
|
||||
Contributed:
|
||||
|
||||
- Additional parachain types (Thanks to https://github.com/joelamouche)
|
||||
- Support for multi queries with `HttpProvider` (Thanks to https://github.com/ianhe8x)
|
||||
- Configurable error logging with `createTypeUnsafe` (Thanks to https://github.com/dvdplm)
|
||||
|
||||
Changes:
|
||||
|
||||
- Adjust core type creation, removing storage duplication
|
||||
- Update parachain types to support Rococo v1
|
||||
- Adjust bounties derive to cater for new Substrate namespaces (& move to bounties)
|
||||
- Mark `detectPackage` as known side-effect
|
||||
- Add `detectPackage` to `@polkadot/metadata` (a number of requests on this)
|
||||
- Adjust x-rxjs wrapper to expose all methods, incl. Node.js esm fixes
|
||||
- Update to latest Substrate static metadata
|
||||
- Update `@polkadot/util` to 5.1.1
|
||||
|
||||
|
||||
## 3.0.1 Dec 14, 2020
|
||||
|
||||
Upgrade priority: Low. Recommended for the next Kusama/Polkadot upgrades due to additional types and those following chains following Substrate master closely.
|
||||
|
||||
**Important** While this package contains no external interface changes, it now compiles and ships both cjs and esm modules. This means that modern bundlers will have more information for tree-shaking available. Additionally when using Node with `.mjs` extensions, the esm version imports will be used on recent Node versions. Adding an export map, as here, may have some impacts so a major semver bump is advised. There may be (small) dragons hiding in the dark corners...
|
||||
|
||||
Contributed:
|
||||
|
||||
- Injection of derives via typesBundle (Thanks to https://github.com/pr0fedt)
|
||||
- Added derives for bounties (Thanks to https://github.com/krzysztof-jelski)
|
||||
|
||||
Changes:
|
||||
|
||||
- Build and expose both cjs and esm via exports map
|
||||
- Inject RPC definitions for typesBundle, allowing per-spec configuration
|
||||
- Added `query.<section>.<method>.sizeAt(hash, [...params])` for all storage
|
||||
- Add new Substrate consumed Weight types
|
||||
- Expand `SessionKeys<n>` definitions (up to 9)
|
||||
- Cleanup circular `Type` <-> `Text` definitions
|
||||
- Cleanup circular `Metadata` <-> `TypeRegistry` imports
|
||||
- Update `@polkadot/util` to 5.0.1
|
||||
|
||||
|
||||
## 2.10.1 Dec 7, 2020
|
||||
|
||||
Upgrade priority: Low. Recommended when following Substrate master and/or parachains development, contains the latest types for both.
|
||||
|
||||
- **Breaking change** If using the `staking.query` derive, you now need to pass flags as to which values to retrieve
|
||||
|
||||
Changes:
|
||||
|
||||
- Ensure that maximum era is limited to `consts.system.blockHashCount` (don't overflow on very low blocktimes)
|
||||
- Apply current Polkadot master parachain types
|
||||
- Apply current Substrate master asset types
|
||||
- Add `system_{addLogFilter, resetLogFilter}` RPCs
|
||||
- Adjust tests for latest Substrate metadata
|
||||
- Adjust staking derives to be more performant (flags indicate which query values to retrieve)
|
||||
- Add account derive to cater for the availability of identities
|
||||
- Use `import type` in all cases
|
||||
|
||||
|
||||
## 2.9.1 Nov 30, 2020
|
||||
|
||||
Upgrade priority: Low. No major changes when on at least 2.8.2. Users encouraged to upgrade to at least that patch.
|
||||
|
||||
- **Breaking change** The API will now not attempt to queue calls made while not connected and send on connection. Rather when making a call and the RPC node is not connected, an error will be thrown.
|
||||
|
||||
Contributed:
|
||||
|
||||
- Add typegen capability for custom RPCs (Thanks to https://github.com/holygits)
|
||||
|
||||
Changes:
|
||||
|
||||
- Remove rpc-core send queue, only allow sends while connected
|
||||
- Adjust staking derive for `electedInfo` to contain details of current validators
|
||||
- Extract identity-only derive from `accounts.info` for simpler reusability
|
||||
- Add types for Substrate master node (to allow for consistent swapping to `MultiAddress`)
|
||||
- Adjust `Bytes` with `.slice` to be consistent for `Uint8array` extensions (already released in 2.8.2 as a bugfix)
|
||||
|
||||
|
||||
## 2.8.1 Nov 23, 2020
|
||||
|
||||
Upgrade priority: Low. Recommended if using Substrate master with new `MultiAddress`.
|
||||
|
||||
Contributed:
|
||||
|
||||
- Export `derive.chain.getBlock` (Thanks to https://github.com/lovesh)
|
||||
|
||||
Changes:
|
||||
|
||||
- Expand `MultiAddress` construction with multi type detection
|
||||
- Rename `GenericLookupSource` to `IndicesLookupSource` (internal use)
|
||||
- Cleanup list retrievals with `Raw` data results for undecodable entries
|
||||
- Export actual version via `RegistryMetadata`
|
||||
- Dedupe bn.js (one version shared between dependencies)
|
||||
|
||||
|
||||
## 2.7.1 Nov 16, 2020
|
||||
|
||||
Upgrade priority: Medium. Recommended for users of Polkadot/Kusama and api-contract users.
|
||||
|
||||
Changes:
|
||||
|
||||
- Allow for `ExtrinsicSignature` overrides (defaults to `MultiSignature`)
|
||||
- Update api-contract `Blueprint` to allow for optional salt (auto if not provided)
|
||||
- Support for ink! `.contract` files (in addition to ABI `.json`)
|
||||
- Fix contract event decoding with pass-through of raw `Bytes`
|
||||
- Fix support for enum encoding in api-contract
|
||||
- Support new contract `Schedule` type as per Substrate
|
||||
- Update Kusama/Polkadot known upgrade blocks
|
||||
- Adjust typegen generated `@polkadot/types` imports
|
||||
- Adjust internal `@polkadot/types` imports/exports (overall bundle sizes)
|
||||
|
||||
|
||||
## 2.6.1 Nov 9, 2020
|
||||
|
||||
Upgrade priority: Low. Should be done alongside an update to `@polkadot/util` to 4.0
|
||||
|
||||
Changes:
|
||||
|
||||
- Adjust auto-gas to contract RPC call to 5 * 10 ^ 12 (align with Rust)
|
||||
- Adjust derive `AccountId` check to take Ethereum-compatible chains into account
|
||||
- Fallback for chains with invalid council proposal data in derives
|
||||
- Bump static v12 Metadata (tests) to latest Substrate version
|
||||
- Bump `@polkadot/{util,util-crypto}` to 4.0 (optimized WASM layers)
|
||||
|
||||
|
||||
## 2.5.1 Nov 2, 2020
|
||||
|
||||
Upgrade priority: Low. Recommended for `api-contract` developers.
|
||||
|
||||
- **Breaking change** Substrate changed the `ContractExecResult` from `api.rpc.contracts.call`. The API does have pass-through support for both old and new variants via the `Contract` interface, however it means the structure has changed to accommodate the new Substrate structure. Refer to the [docs for the latest interface](https://polkadot.js.org/docs/api-contract/start/contract.read) (including `isSuccess/isError` -> `isOk/isErr`, and the availability of the `gasConsumed`)
|
||||
|
||||
Contributed:
|
||||
|
||||
- Dedup similar types on generation (Thanks to https://github.com/monitz87)
|
||||
|
||||
Changes:
|
||||
|
||||
- `Contract` execution will now return contract events decoded in the result
|
||||
- Add `.dryRun` on extrinsics (alongside `.paymentInfo` usage)
|
||||
- Add `system_syncState` and `syncstate_genSyncSpec` RPCs
|
||||
- Enhance error reporting, `Call` indicates explicit call as found
|
||||
- Adjust internal metadata decoration and use as exposed from `@types/metadata`
|
||||
- Expand Rococo known types to cater for v1 (specVersion 10)
|
||||
- `registry.hash` now returns an `H256` object (as opposed to raw Uint8Array)
|
||||
- Use utility logger in all relevant error messages (consistency in logging)
|
||||
- Add `derive.council.proposal(<hash>)` for retrieval of a single (expanded) proposal
|
||||
- Correctly and transparently format type generation types (allowing for nested variants)
|
||||
|
||||
|
||||
## 2.4.1 Oct 26, 2020
|
||||
|
||||
Upgrade priority: Low. No breaking changes, however it does move `api-contract` forward with additional features.
|
||||
|
||||
Contributed:
|
||||
|
||||
- Add support for both `{i,u}256` types on contracts (Thanks to https://github.com/seanyoung)
|
||||
|
||||
Changes:
|
||||
|
||||
- Add `.keysAt` & `.entriesAt` to query maps at a specific blockHash
|
||||
- Adjust ordering of type injection, any `types: { ... }` definitions not have precedence
|
||||
- Correctly format Tuples in both RPC and const definitions as part of type generation
|
||||
- Add node-template to known types (tracking inside API), remove warnings for the spec
|
||||
- Add initial implementation for new Substrate `MultiAddress` type
|
||||
- Add `api.derive.chain.subscribeNewBlocks` for full block retrievals
|
||||
- Contracts identifiers to `.{exec, read}('name', ...)` now matches on both snake_case and camelCase (consistency)
|
||||
- Cleanup contracts serialization for messages to allow both to and from
|
||||
- Add deserialization of contract events against the ABI
|
||||
- Adjust contracts metadata parsing to be future-proof with type retrievals
|
||||
- Add tests for Solang into contracts, re-organize layout per type
|
||||
|
||||
|
||||
## 2.3.1 Oct 19, 2020
|
||||
|
||||
Upgrade priority: Low. Recommended for `api-contract` developers and those using large messages via Node.js WS.
|
||||
|
||||
Contributed:
|
||||
|
||||
- Adjust frame size for Node.js WebSockets (Thanks to https://github.com/mnaamani)
|
||||
- Update warnings to reflect new docs URLs (Thanks to https://github.com/aphelionz)
|
||||
|
||||
Changes:
|
||||
|
||||
- Expose `dispatch{Error, Info}` on all `.tx` results (less boilerplate on info checks)
|
||||
- Add missing primitive types inside contracts type parsing
|
||||
- Adjust api-contract to expose `Contract.{query, tx}.<message>` and `Blueprint.tx.<constructor>`
|
||||
- Rework contracts registry to be generic to all scale-info definitions
|
||||
- Allow for auto-max weight on contract read/exec (useful in estimation)
|
||||
- Fix memoization where `BigInt` params are passed
|
||||
|
||||
|
||||
## 2.2.1 Oct 12, 2020
|
||||
|
||||
Upgrade priority: Low.
|
||||
|
||||
@@ -14,10 +566,11 @@ Contributed:
|
||||
Changes:
|
||||
|
||||
- Introduce `OriginCaller` type (& apply to scheduler types)
|
||||
- Adjust `ContractInfo` struct to cater for latest Substrate
|
||||
- Adjust `ContractInfo` type for latest Substrate (contracts)
|
||||
- Adjust `Schedule` type for latest Substrate (contracts)
|
||||
- Allow snake_case to be handled transparently in structs
|
||||
- Full new api-contract developer interfaces (Code, Blueprint, Contract)
|
||||
- Rework Abi & Abi Registry use & parse (on-top-of-contributed) for efficiency & non-global clobber
|
||||
- Rework Abi & Abi Registry use & parse (based on contributed) for efficiency & non-global clobber
|
||||
- Allow `null` input on `Text` values in addition to existing `undefined`
|
||||
- Remove all documentation after move to https://github.com/polkadot-js/docs repo
|
||||
- Adjust type encoding from TypeDef, s/encodeType/encodeTypeDef/
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
# @polkadot/api
|
||||
|
||||
This library provides a clean wrapper around all the methods exposed by a Polkadot/Substrate network client and defines all the types exposed by a node. For complete documentation around the classes, interfaces and their use, visit the [documentation portal](https://polkadot.js.org/api/).
|
||||
This library provides a clean wrapper around all the methods exposed by a Polkadot/Substrate network client and defines all the types exposed by a node. For complete documentation around the classes, interfaces and their use, visit the [documentation portal](https://polkadot.js.org/docs/api/).
|
||||
|
||||
If you are an existing user, please be sure to track the [CHANGELOG](CHANGELOG.md) and [UPGRADING](UPGRADING.md) guides when changing versions.
|
||||
|
||||
@@ -22,25 +22,9 @@ The API is split up into a number of internal packages -
|
||||
- [@polkadot/api](packages/api/) The API library, providing both Promise and RxJS Observable-based interfaces. This is the main user-facing entry point.
|
||||
- [@polkadot/api-derive](packages/api-derive/) Derived results that are injected into the API, allowing for combinations of various query results (only used internally and exposed on the Api instances via `api.derive.*`)
|
||||
- [@polkadot/api-metadata](packages/api-metadata/) Base extrinsic, storage and constant injectors for injection
|
||||
- [@polkadot/rpc-core](packages/rpc-core/) Wrapper around all [JSON-RPC methods](https://polkadot.js.org/api/substrate/rpc.html) exposed by a Polkadot network client
|
||||
- [@polkadot/rpc-core](packages/rpc-core/) Wrapper around all [JSON-RPC methods](https://polkadot.js.org/docs/substrate/rpc) exposed by a Polkadot network client
|
||||
- [@polkadot/rpc-provider](packages/rpc-provider/) Providers for connecting to nodes, including WebSockets and Http
|
||||
|
||||
Type definitions for interfaces as exposed by Polkadot & Substrate clients -
|
||||
|
||||
- [@polkadot/types](packages/types/) Codecs for all Polkadot and Substrate primitives
|
||||
|
||||
## development
|
||||
|
||||
Contributions are welcome!
|
||||
|
||||
To start off, this repo (along with others in the [@polkadot](https://github.com/polkadot-js/) family) uses yarn workspaces to organise the code. As such, after cloning, its dependencies _should_ be installed via `yarn`, not via npm; the latter will result in broken dependencies.
|
||||
|
||||
To get started -
|
||||
|
||||
1. Clone the repo locally, via `git clone https://github.com/polkadot-js/api <optional local path>`
|
||||
2. Ensure that you have a recent version of Node.js, for development purposes [Node 10](https://nodejs.org/en/) is recommended.
|
||||
3. Ensure that you have a recent version of Yarn, for development purposes [Yarn >=1.10.1](https://yarnpkg.com/docs/install) is required.
|
||||
4. Install the dependencies by running `yarn`
|
||||
5. Build the everything via `yarn run build`
|
||||
6. You can also launch the API Docs, via `yarn vuepress dev docs`
|
||||
7. Access the docs via [http://localhost:8080](http://localhost:8080)
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
// Copyright 2017-2021 @polkadot/api authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
module.exports = require('@polkadot/dev/config/babel-config-cjs.cjs');
|
||||
@@ -1,4 +0,0 @@
|
||||
// Copyright 2017-2020 @polkadot/api authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
module.exports = require('@polkadot/dev/config/babel');
|
||||
@@ -1,25 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
# Copyright 2017-2020 @polkadot/api authors & contributors
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
function copy_folder () {
|
||||
SRC="packages/$1/build"
|
||||
DST="../apps/node_modules/@polkadot/$1"
|
||||
|
||||
echo "** Copying $SRC to $DST"
|
||||
|
||||
rm -rf $DST
|
||||
cp -r $SRC $DST
|
||||
}
|
||||
|
||||
yarn polkadot-dev-build-ts
|
||||
|
||||
copy_folder "api"
|
||||
copy_folder "api-contract"
|
||||
copy_folder "api-derive"
|
||||
copy_folder "metadata"
|
||||
copy_folder "rpc-core"
|
||||
copy_folder "rpc-provider"
|
||||
copy_folder "types"
|
||||
copy_folder "types-known"
|
||||
copy_folder "typegen"
|
||||
@@ -1,25 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
# Copyright 2017-2020 @polkadot/api authors & contributors
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
function copy_folder () {
|
||||
SRC="packages/$1/build"
|
||||
DST="../test/js-test/node_modules/@polkadot/$1"
|
||||
|
||||
echo "** Copying $SRC to $DST"
|
||||
|
||||
rm -rf $DST
|
||||
cp -r $SRC $DST
|
||||
}
|
||||
|
||||
yarn polkadot-dev-build-ts
|
||||
|
||||
copy_folder "api"
|
||||
copy_folder "api-contract"
|
||||
copy_folder "api-derive"
|
||||
copy_folder "metadata"
|
||||
copy_folder "rpc-core"
|
||||
copy_folder "rpc-provider"
|
||||
copy_folder "types"
|
||||
copy_folder "types-known"
|
||||
copy_folder "typegen"
|
||||
@@ -1,102 +0,0 @@
|
||||
# Docker compose file to run Polkadot-JS API e2e test files on supported versions of Polkadot and Substrate
|
||||
#
|
||||
# Setup:
|
||||
# Builds 5 containers with different supported versions of Substrate and Polkadot.
|
||||
# Runs Polkadot-JS API Tests
|
||||
#
|
||||
# Before you can run this script, you need to install Docker and 'Docker Compose' on your machine.
|
||||
# Please follow the steps described here (including the prerequisites): https://docs.docker.com/compose/install/
|
||||
#
|
||||
# Usage:
|
||||
# 1. BUILD: Run `docker-compose pull && docker-compose up -d` to pull the latest docker imaged and run docker-compose in detached mode. This will run the substrate and polkadot containers in the background.
|
||||
# 2. INFO: Run `docker ps` to get a list of Docker containers running in the background including their mapped ports on localhost
|
||||
# 3. TEST: Run `docker-compose logs -f js-api-tests` to run the API tests and print the logs
|
||||
# 4. QUIT: Run `docker-compose down` to stop and remove all running containers.
|
||||
#
|
||||
# Provided Endpoints for localhost:
|
||||
# - Substrate Master: ws://127.0.0.1:9945/
|
||||
# - Substrate 1.0: ws://127.0.0.1:9946/
|
||||
# - Substrate 2.0: ws://127.0.0.1:9947/
|
||||
# - Polkadot Master: ws://127.0.0.1:9948/
|
||||
# - Polkadot Alexander: ws://127.0.0.1:9949/
|
||||
#
|
||||
# Find more Docker images of Substrate https://hub.docker.com/r/parity/substrate/tags
|
||||
# Find more Docker images of Polkadot https://hub.docker.com/r/parity/polkadot/tags
|
||||
|
||||
|
||||
version: "3.7"
|
||||
services:
|
||||
substrate-master:
|
||||
image: parity/substrate:latest
|
||||
ports:
|
||||
- "9945:9944"
|
||||
- "9935:9933"
|
||||
networks:
|
||||
- internet
|
||||
command:
|
||||
- "--dev"
|
||||
- "--ws-external"
|
||||
- "--rpc-external"
|
||||
|
||||
substrate-1.0:
|
||||
image: parity/substrate:v1.0.0
|
||||
ports:
|
||||
- "9946:9944"
|
||||
- "9936:9933"
|
||||
networks:
|
||||
- internet
|
||||
command:
|
||||
- "--dev"
|
||||
- "--ws-external"
|
||||
- "--rpc-external"
|
||||
|
||||
substrate-2.0:
|
||||
image: parity/substrate:2.0.0-b65c315a1
|
||||
ports:
|
||||
- "9947:9944"
|
||||
- "9937:9933"
|
||||
networks:
|
||||
- internet
|
||||
command:
|
||||
- "--dev"
|
||||
- "--ws-external"
|
||||
- "--rpc-external"
|
||||
|
||||
polkadot-master:
|
||||
image: parity/polkadot:latest
|
||||
ports:
|
||||
- "9948:9944"
|
||||
- "9938:9933"
|
||||
networks:
|
||||
- internet
|
||||
command:
|
||||
- "--dev"
|
||||
- "--ws-external"
|
||||
- "--rpc-external"
|
||||
|
||||
polkadot-alexander:
|
||||
image: parity/polkadot:v0.4.4
|
||||
ports:
|
||||
- "9949:9944"
|
||||
- "9939:9933"
|
||||
networks:
|
||||
- internet
|
||||
command:
|
||||
- "--dev"
|
||||
- "--ws-external"
|
||||
- "--rpc-external"
|
||||
|
||||
# This is the container running the API tests
|
||||
js-api-tests:
|
||||
image: node:11
|
||||
volumes:
|
||||
- ./:/polkadot-js/api
|
||||
working_dir: /polkadot-js/api
|
||||
network_mode: host
|
||||
tty: true
|
||||
environment:
|
||||
- TERM=xterm-256color`
|
||||
command: bash -c "NODE_ENV=abc /usr/local/bin/yarn && /usr/local/bin/yarn test:all"
|
||||
|
||||
networks:
|
||||
internet:
|
||||
@@ -0,0 +1,12 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="initial-scale=0.5, maximum-scale=1">
|
||||
<meta http-equiv="refresh" content="0;URL='https://polkadot.js.org/docs/api/'" />
|
||||
<title>Redirecting to https://polkadot.js.org/docs/api/</title>
|
||||
</head>
|
||||
<body>
|
||||
Redirecting to <a href="https://polkadot.js.org/docs/api/">https://polkadot.js.org/docs/api/</a>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,12 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="initial-scale=0.5, maximum-scale=1">
|
||||
<meta http-equiv="refresh" content="0;URL='https://polkadot.js.org/docs/api/'" />
|
||||
<title>Redirecting to https://polkadot.js.org/docs/api/</title>
|
||||
</head>
|
||||
<body>
|
||||
Redirecting to <a href="https://polkadot.js.org/docs/api/">https://polkadot.js.org/docs/api/</a>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,29 +1,31 @@
|
||||
// Copyright 2017-2020 @polkadot/api authors & contributors
|
||||
// Copyright 2017-2021 @polkadot/api authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
const config = require('@polkadot/dev/config/jest');
|
||||
const config = require('@polkadot/dev/config/jest.cjs');
|
||||
|
||||
module.exports = Object.assign({}, config, {
|
||||
module.exports = {
|
||||
...config,
|
||||
moduleNameMapper: {
|
||||
'@polkadot/api-contract(.*)$': '<rootDir>/packages/api-contract/src/$1',
|
||||
'@polkadot/api-derive(.*)$': '<rootDir>/packages/api-derive/src/$1',
|
||||
'@polkadot/api-(contract|derive)(.*)$': '<rootDir>/packages/api-$1/src/$2',
|
||||
// eslint-disable-next-line sort-keys
|
||||
'@polkadot/api(.*)$': '<rootDir>/packages/api/src/$1',
|
||||
'@polkadot/metadata(.*)$': '<rootDir>/packages/metadata/src/$1',
|
||||
'@polkadot/rpc-(core|provider)(.*)$': '<rootDir>/packages/rpc-$1/src/$2',
|
||||
'@polkadot/typegen(.*)$': '<rootDir>/packages/typegen/src/$1',
|
||||
'@polkadot/types-known(.*)$': '<rootDir>/packages/types-known/src/$1',
|
||||
// eslint-disable-next-line sort-keys
|
||||
'@polkadot/types(.*)$': '<rootDir>/packages/types/src/$1'
|
||||
},
|
||||
modulePathIgnorePatterns: [
|
||||
'<rootDir>/packages/api/build',
|
||||
'<rootDir>/packages/api-derive/build',
|
||||
'<rootDir>/packages/api-contract/build',
|
||||
'<rootDir>/packages/api-derive/build',
|
||||
'<rootDir>/packages/metadata/build',
|
||||
'<rootDir>/packages/rpc-core/build',
|
||||
'<rootDir>/packages/rpc-provider/build',
|
||||
'<rootDir>/packages/typegen/build',
|
||||
'<rootDir>/packages/types/build',
|
||||
'<rootDir>/packages/types-known/build'
|
||||
],
|
||||
resolver: './jest.resolver.js'
|
||||
});
|
||||
transformIgnorePatterns: ['/node_modules/(?!@polkadot|@babel/runtime/helpers/esm/)']
|
||||
};
|
||||
@@ -1,12 +0,0 @@
|
||||
// Copyright 2017-2020 @polkadot/api authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
const path = require('path');
|
||||
|
||||
module.exports = function resolver (file, config) {
|
||||
if (file.includes('package.json')) {
|
||||
return path.join(config.basedir.replace('/src', '/'), file);
|
||||
}
|
||||
|
||||
return config.defaultResolver(file, config);
|
||||
};
|
||||
+12
-15
@@ -3,15 +3,16 @@
|
||||
"author": "Jaco Greeff <jacogr@gmail.com>",
|
||||
"license": "Apache-2",
|
||||
"private": true,
|
||||
"type": "commonjs",
|
||||
"workspaces": [
|
||||
"packages/*"
|
||||
],
|
||||
"resolutions": {
|
||||
"babel-core": "^7.0.0-bridge.0",
|
||||
"typescript": "^4.0.3"
|
||||
"typescript": "^4.2.3"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "yarn build:interfaces && polkadot-dev-build-ts && (cd packages/typegen && copyfiles scripts/* build)",
|
||||
"build": "yarn build:interfaces && polkadot-dev-build-ts",
|
||||
"build:extra": "(cd packages/typegen && copyfiles scripts/* build)",
|
||||
"build:interfaces": "polkadot-types-internal-interfaces",
|
||||
"build:release": "polkadot-ci-ghact-build",
|
||||
"docs:metadata": "polkadot-types-internal-metadata",
|
||||
@@ -24,18 +25,14 @@
|
||||
"test:watch": "polkadot-dev-run-test --watch"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.11.6",
|
||||
"@babel/register": "^7.11.5",
|
||||
"@babel/runtime": "^7.11.2",
|
||||
"@polkadot/dev": "^0.58.1",
|
||||
"@polkadot/ts": "^0.3.49",
|
||||
"@babel/core": "^7.13.13",
|
||||
"@babel/register": "^7.13.8",
|
||||
"@babel/runtime": "^7.13.10",
|
||||
"@polkadot/dev": "^0.62.7",
|
||||
"@polkadot/ts": "^0.3.62",
|
||||
"@polkadot/typegen": "workspace:packages/typegen",
|
||||
"@types/jest": "^26.0.14",
|
||||
"@vuepress/plugin-search": "^1.6.0",
|
||||
"copyfiles": "^2.4.0",
|
||||
"typedoc": "^0.19.2",
|
||||
"typedoc-plugin-markdown": "^3.0.7",
|
||||
"typedoc-plugin-no-inherit": "^1.2.0"
|
||||
"@types/jest": "^26.0.22",
|
||||
"copyfiles": "^2.4.1"
|
||||
},
|
||||
"version": "2.2.1"
|
||||
"version": "4.4.1"
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ import { Abi } from '@polkadot/api-contract';
|
||||
|
||||
const wsProvider = new WsProvider(<...Node Url...>);
|
||||
const api = await ApiPromise.create({ provider: wsProvider });
|
||||
const abi = new Abi(api.registry, <...JSON ABI...>);
|
||||
const abi = new Abi(<...JSON ABI...>, api.registry.getChainProperties());
|
||||
|
||||
api.tx.contracts
|
||||
.call(<contract addr>, <value>, <max gas>, abi.messages.<method name>(<...params...>))
|
||||
|
||||
@@ -1,37 +1,26 @@
|
||||
{
|
||||
"name": "@polkadot/api-contract",
|
||||
"version": "2.2.1",
|
||||
"version": "4.4.1",
|
||||
"type": "module",
|
||||
"description": "Interfaces for interacting with contracts and contract ABIs",
|
||||
"main": "index.js",
|
||||
"keywords": [
|
||||
"Polkadot",
|
||||
"ABI"
|
||||
"sideEffects": [
|
||||
"./detectPackage.js",
|
||||
"./detectPackage.cjs"
|
||||
],
|
||||
"author": "Jaco Greeff <jacogr@gmail.com>",
|
||||
"maintainers": [
|
||||
"Jaco Greeff <jacogr@gmail.com>"
|
||||
],
|
||||
"maintainers": [],
|
||||
"contributors": [],
|
||||
"license": "Apache-2.0",
|
||||
"publishConfig": {
|
||||
"access": "public",
|
||||
"registry": "https://registry.npmjs.org"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/polkadot-js/api.git"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/polkadot-js/api/issues"
|
||||
},
|
||||
"repository": "github:polkadot-js/api",
|
||||
"bugs": "https://github.com/polkadot-js/api/issues",
|
||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/api-contract#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.11.2",
|
||||
"@polkadot/api": "2.2.1",
|
||||
"@polkadot/rpc-core": "2.2.1",
|
||||
"@polkadot/types": "2.2.1",
|
||||
"@polkadot/util": "^3.5.1",
|
||||
"bn.js": "^5.1.3",
|
||||
"rxjs": "^6.6.3"
|
||||
"@babel/runtime": "^7.13.10",
|
||||
"@polkadot/api": "4.4.1",
|
||||
"@polkadot/types": "4.4.1",
|
||||
"@polkadot/util": "^6.0.5",
|
||||
"@polkadot/x-rxjs": "^6.0.5",
|
||||
"bn.js": "^4.11.9"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,94 +1,52 @@
|
||||
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
|
||||
// Copyright 2017-2021 @polkadot/api-contract authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import Abi from './Abi';
|
||||
import { blake2AsHex } from '@polkadot/util-crypto';
|
||||
|
||||
import * as testContracts from '../test/contracts';
|
||||
import abis from '../test/contracts';
|
||||
import { Abi } from '.';
|
||||
|
||||
const abis: Record<string, any> = { ...testContracts };
|
||||
|
||||
function compare (name: string, messageIds: string[]): void {
|
||||
try {
|
||||
const inkAbi = new Abi(abis[name]);
|
||||
|
||||
expect(inkAbi.messages.map(({ identifier }) => identifier)).toEqual(messageIds);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
|
||||
throw error;
|
||||
interface JSONAbi {
|
||||
source: {
|
||||
compiler: string,
|
||||
hash: string,
|
||||
language: string,
|
||||
wasm: string
|
||||
},
|
||||
spec: {
|
||||
messages: {
|
||||
name: string[] | string
|
||||
}[]
|
||||
}
|
||||
}
|
||||
|
||||
describe('Abi', (): void => {
|
||||
describe('construction', (): void => {
|
||||
it('initializes from a contract ABI (flipper)', (): void => {
|
||||
compare('flipper', ['flip', 'get']);
|
||||
});
|
||||
Object.entries(abis).forEach(([abiName, abi]) => {
|
||||
it(`initializes from a contract ABI (${abiName})`, (): void => {
|
||||
try {
|
||||
const messageIds = (abi as JSONAbi).spec.messages.map(({ name }) => Array.isArray(name) ? name[0] : name);
|
||||
const inkAbi = new Abi(abis[abiName]);
|
||||
|
||||
it('initializes from a contract ABI (incrementer)', (): void => {
|
||||
compare('incrementer', ['inc', 'get']);
|
||||
});
|
||||
expect(inkAbi.messages.map(({ identifier }) => identifier)).toEqual(messageIds);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
|
||||
it('initializes from a contract ABI (erc20)', (): void => {
|
||||
compare('erc20', [
|
||||
'total_supply',
|
||||
'balance_of',
|
||||
'allowance',
|
||||
'transfer',
|
||||
'approve',
|
||||
'transfer_from'
|
||||
]);
|
||||
});
|
||||
|
||||
it('initializes from a contract ABI (delegator)', (): void => {
|
||||
compare('delegator', [
|
||||
'get',
|
||||
'change',
|
||||
'switch'
|
||||
]);
|
||||
});
|
||||
|
||||
it('initializes from a contract ABI (dns)', (): void => {
|
||||
compare('dns', [
|
||||
'register',
|
||||
'set_address',
|
||||
'transfer',
|
||||
'get_address'
|
||||
]);
|
||||
});
|
||||
|
||||
it('initializes from a contract ABI (erc721)', (): void => {
|
||||
compare('erc721', [
|
||||
'balance_of',
|
||||
'owner_of',
|
||||
'get_approved',
|
||||
'is_approved_for_all',
|
||||
'set_approval_for_all',
|
||||
'approve',
|
||||
'transfer',
|
||||
'transfer_from',
|
||||
'mint',
|
||||
'burn'
|
||||
]);
|
||||
});
|
||||
|
||||
it('initializes from a contract ABI (multisig_plain)', (): void => {
|
||||
compare('multisigPlain', [
|
||||
'add_owner',
|
||||
'remove_owner',
|
||||
'replace_owner',
|
||||
'change_requirement',
|
||||
'submit_transaction',
|
||||
'cancel_transaction',
|
||||
'confirm_transaction',
|
||||
'revoke_confirmation',
|
||||
'invoke_transaction',
|
||||
'eval_transaction'
|
||||
]);
|
||||
throw error;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
it('stores base project as JSON', (): void => {
|
||||
expect(new Abi(abis.dns).json).toEqual(abis.dns);
|
||||
it('has the correct hash for the source', (): void => {
|
||||
const bundle = abis.ink_flipperBundle as JSONAbi;
|
||||
const abi = new Abi(bundle as any);
|
||||
|
||||
// manual
|
||||
expect(bundle.source.hash).toEqual(blake2AsHex(bundle.source.wasm));
|
||||
|
||||
// the Codec hash
|
||||
expect(bundle.source.hash).toEqual(abi.project.source.wasm.hash.toHex());
|
||||
|
||||
// the hash as per the actual Abi
|
||||
expect(bundle.source.hash).toEqual(abi.project.source.wasmHash.toHex());
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,33 +1,42 @@
|
||||
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
|
||||
// Copyright 2017-2021 @polkadot/api-contract authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { AnyJson } from '@polkadot/types/types';
|
||||
import { ChainProperties, InkConstructorSpec, InkMessageSpec } from '@polkadot/types/interfaces';
|
||||
import { AbiConstructor, AbiMessage, AbiMessageParam } from './types';
|
||||
import type { Bytes } from '@polkadot/types';
|
||||
import type { ChainProperties, ContractConstructorSpec, ContractEventSpec, ContractMessageParamSpec, ContractMessageSpec, ContractProject } from '@polkadot/types/interfaces';
|
||||
import type { AnyJson, Codec, CodecArg } from '@polkadot/types/types';
|
||||
import type { AbiConstructor, AbiEvent, AbiMessage, AbiParam, DecodedEvent, DecodedMessage } from './types';
|
||||
|
||||
import { assert, isNumber, isObject, isString, stringCamelCase } from '@polkadot/util';
|
||||
import { assert, assertReturn, compactAddLength, compactStripLength, isNumber, isObject, isString, logger, stringCamelCase, u8aConcat, u8aToHex } from '@polkadot/util';
|
||||
|
||||
import ContractRegistry from './ContractRegistry';
|
||||
import { MetaRegistry } from './MetaRegistry';
|
||||
|
||||
const EMPTY_U8A = new Uint8Array();
|
||||
|
||||
const l = logger('Abi');
|
||||
|
||||
function findMessage <T extends AbiMessage> (list: T[], messageOrId: T | string | number): T {
|
||||
const message = isNumber(messageOrId)
|
||||
? list[messageOrId]
|
||||
: isString(messageOrId)
|
||||
? list.find(({ identifier }: T) => identifier === messageOrId.toString())
|
||||
? list.find(({ identifier }) => [identifier, stringCamelCase(identifier)].includes(messageOrId.toString()))
|
||||
: messageOrId;
|
||||
|
||||
assert(message, `Attempted to call an invalid contract interface, ${JSON.stringify(messageOrId)}`);
|
||||
|
||||
return message;
|
||||
return assertReturn(message, `Attempted to call an invalid contract interface, ${JSON.stringify(messageOrId)}`);
|
||||
}
|
||||
|
||||
export default class Abi extends ContractRegistry {
|
||||
export class Abi {
|
||||
readonly #events: AbiEvent[];
|
||||
|
||||
public readonly constructors: AbiConstructor[];
|
||||
|
||||
public readonly json: AnyJson;
|
||||
|
||||
public readonly messages: AbiMessage[];
|
||||
|
||||
public readonly project: ContractProject;
|
||||
|
||||
public readonly registry: MetaRegistry;
|
||||
|
||||
constructor (abiJson: AnyJson, chainProperties?: ChainProperties) {
|
||||
const json = isString(abiJson)
|
||||
? JSON.parse(abiJson) as AnyJson
|
||||
@@ -35,27 +44,62 @@ export default class Abi extends ContractRegistry {
|
||||
|
||||
assert(isObject(json) && !Array.isArray(json) && json.metadataVersion && isObject(json.spec) && !Array.isArray(json.spec) && Array.isArray(json.spec.constructors) && Array.isArray(json.spec.messages), 'Invalid JSON ABI structure supplied, expected a recent metadata version');
|
||||
|
||||
super(json, chainProperties);
|
||||
|
||||
this.json = json;
|
||||
this.constructors = this.project.spec.constructors.map((spec: InkConstructorSpec, index) =>
|
||||
this._createBase(spec, index, {
|
||||
this.registry = new MetaRegistry(chainProperties);
|
||||
this.project = this.registry.createType('ContractProject', json);
|
||||
|
||||
this.registry.setMetaTypes(this.project.types);
|
||||
|
||||
this.project.types.forEach((_, index) =>
|
||||
this.registry.getMetaTypeDef({ type: this.registry.createType('SiLookupTypeId', index + 1) })
|
||||
);
|
||||
this.constructors = this.project.spec.constructors.map((spec: ContractConstructorSpec, index) =>
|
||||
this.#createMessage(spec, index, {
|
||||
isConstructor: true
|
||||
})
|
||||
);
|
||||
this.messages = this.project.spec.messages.map((spec: InkMessageSpec, index): AbiMessage => {
|
||||
this.#events = this.project.spec.events.map((spec: ContractEventSpec, index) =>
|
||||
this.#createEvent(spec, index)
|
||||
);
|
||||
this.messages = this.project.spec.messages.map((spec: ContractMessageSpec, index): AbiMessage => {
|
||||
const typeSpec = spec.returnType.unwrapOr(null);
|
||||
|
||||
return this._createBase(spec, index, {
|
||||
return this.#createMessage(spec, index, {
|
||||
isMutating: spec.mutates.isTrue,
|
||||
isPayable: spec.payable.isTrue,
|
||||
returnType: typeSpec
|
||||
? this.typeDefAt(typeSpec.type, { displayName: typeSpec.displayName.map((s) => s.toString()).join('::') || undefined })
|
||||
? this.registry.getMetaTypeDef(typeSpec)
|
||||
: null
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Warning: Unstable API, bound to change
|
||||
*/
|
||||
public decodeEvent (data: Bytes | Uint8Array): DecodedEvent {
|
||||
const index = data[0];
|
||||
const event = this.#events[index];
|
||||
|
||||
assert(event, `Unable to find event with index ${index}`);
|
||||
|
||||
return event.fromU8a(data.subarray(1));
|
||||
}
|
||||
|
||||
/**
|
||||
* Warning: Unstable API, bound to change
|
||||
*/
|
||||
public decodeConstructor (data: Uint8Array): DecodedMessage {
|
||||
return this.#decodeMessage('message', this.constructors, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Warning: Unstable API, bound to change
|
||||
*/
|
||||
public decodeMessage (data: Uint8Array): DecodedMessage {
|
||||
return this.#decodeMessage('message', this.messages, data);
|
||||
}
|
||||
|
||||
public findConstructor (constructorOrId: AbiConstructor | string | number): AbiConstructor {
|
||||
return findMessage(this.constructors, constructorOrId);
|
||||
}
|
||||
@@ -64,30 +108,92 @@ export default class Abi extends ContractRegistry {
|
||||
return findMessage(this.messages, messageOrId);
|
||||
}
|
||||
|
||||
private _createBase (spec: InkMessageSpec | InkConstructorSpec, index: number, add: Partial<AbiMessage> = {}): AbiMessage {
|
||||
const identifier = spec.name.toString();
|
||||
const args = spec.args.map((arg, index): AbiMessageParam => {
|
||||
#createArgs = (args: ContractMessageParamSpec[], spec: unknown): AbiParam[] => {
|
||||
return args.map((arg, index): AbiParam => {
|
||||
try {
|
||||
assert(isObject(arg.type), 'Invalid type definition found');
|
||||
|
||||
return {
|
||||
name: stringCamelCase(arg.name.toString()),
|
||||
type: this.typeDefAt(arg.type.type)
|
||||
name: stringCamelCase(arg.name),
|
||||
type: this.registry.getMetaTypeDef(arg.type)
|
||||
};
|
||||
} catch (error) {
|
||||
console.error(`Error expanding argument ${index} in ${JSON.stringify(spec)}`);
|
||||
l.error(`Error expanding argument ${index} in ${JSON.stringify(spec)}`);
|
||||
|
||||
throw error;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
#createEvent = (spec: ContractEventSpec, index: number): AbiEvent => {
|
||||
const args = this.#createArgs(spec.args, spec);
|
||||
const event = {
|
||||
args,
|
||||
docs: spec.docs.map((doc) => doc.toString()),
|
||||
fromU8a: (data: Uint8Array): DecodedEvent => ({
|
||||
args: this.#decodeArgs(args, data),
|
||||
event
|
||||
}),
|
||||
identifier: spec.name.toString(),
|
||||
index
|
||||
};
|
||||
|
||||
return event;
|
||||
}
|
||||
|
||||
#createMessage = (spec: ContractMessageSpec | ContractConstructorSpec, index: number, add: Partial<AbiMessage> = {}): AbiMessage => {
|
||||
const args = this.#createArgs(spec.args, spec);
|
||||
const message = {
|
||||
...add,
|
||||
args,
|
||||
docs: spec.docs.map((doc) => doc.toString()),
|
||||
identifier,
|
||||
fromU8a: (data: Uint8Array): DecodedMessage => ({
|
||||
args: this.#decodeArgs(args, data),
|
||||
message
|
||||
}),
|
||||
identifier: spec.name.toString(),
|
||||
index,
|
||||
selector: spec.selector
|
||||
selector: spec.selector,
|
||||
toU8a: (params: CodecArg[], additional?: Uint8Array) =>
|
||||
this.#encodeArgs(spec, args, params, additional)
|
||||
};
|
||||
|
||||
return message;
|
||||
}
|
||||
|
||||
#decodeArgs = (args: AbiParam[], data: Uint8Array): Codec[] => {
|
||||
// for decoding we expect the input to be just the arg data, no selectors
|
||||
// no length added (this allows use with events as well)
|
||||
let offset = 0;
|
||||
|
||||
return args.map(({ type }): Codec => {
|
||||
const value = this.registry.createType(type.type as 'Text', data.subarray(offset));
|
||||
|
||||
offset += value.encodedLength;
|
||||
|
||||
return value;
|
||||
});
|
||||
}
|
||||
|
||||
#decodeMessage = (type: 'constructor' | 'message', list: AbiMessage[], data: Uint8Array): DecodedMessage => {
|
||||
const [, trimmed] = compactStripLength(data);
|
||||
const selector = trimmed.subarray(0, 4);
|
||||
const message = list.find((m) => m.selector.eq(selector));
|
||||
|
||||
assert(message, `Unable to find ${type} with selector ${u8aToHex(selector)}`);
|
||||
|
||||
return message.fromU8a(trimmed.subarray(4));
|
||||
}
|
||||
|
||||
#encodeArgs = ({ name, selector }: ContractMessageSpec | ContractConstructorSpec, args: AbiParam[], data: CodecArg[], additional = EMPTY_U8A): Uint8Array => {
|
||||
assert(data.length === args.length, `Expected ${args.length} arguments to contract message '${name.toString()}', found ${data.length}`);
|
||||
|
||||
return compactAddLength(
|
||||
u8aConcat(
|
||||
this.registry.createType('ContractSelector', selector).toU8a(),
|
||||
...args.map(({ type }, index) => this.registry.createType(type.type as 'Text', data[index]).toU8a()),
|
||||
additional
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,58 +0,0 @@
|
||||
// Copyright 2017-2020 @polkadot/types authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
/* eslint-disable @typescript-eslint/no-var-requires */
|
||||
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
|
||||
import ContractRegistry from './ContractRegistry';
|
||||
|
||||
import * as testContracts from '../test/contracts';
|
||||
|
||||
const abis: Record<string, any> = { ...testContracts };
|
||||
|
||||
function compare (name: string): void {
|
||||
const inkRegistry = new ContractRegistry(abis[name]);
|
||||
|
||||
try {
|
||||
const cmpPath = path.join(__dirname, `../test/compare/${name}.test.json`);
|
||||
|
||||
if (!fs.existsSync(cmpPath)) {
|
||||
fs.writeFileSync(cmpPath, JSON.stringify(inkRegistry.typeDefs, null, 2), { flag: 'w' });
|
||||
}
|
||||
|
||||
expect(inkRegistry.typeDefs).toEqual(require(cmpPath));
|
||||
} catch (error) {
|
||||
console.error(JSON.stringify(inkRegistry.typeDefs));
|
||||
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
describe('ContractRegistry', (): void => {
|
||||
describe('construction', (): void => {
|
||||
it('initializes from a contract ABI (flipper)', (): void => {
|
||||
compare('flipper');
|
||||
});
|
||||
|
||||
it('initializes from a contract ABI (incrementer)', (): void => {
|
||||
compare('incrementer');
|
||||
});
|
||||
|
||||
it('initializes from a contract ABI (erc20)', (): void => {
|
||||
compare('erc20');
|
||||
});
|
||||
|
||||
it('initializes from a contract ABI (dns)', (): void => {
|
||||
compare('dns');
|
||||
});
|
||||
|
||||
it('initializes from a contract ABI (erc721)', (): void => {
|
||||
compare('erc721');
|
||||
});
|
||||
|
||||
it('initializes from a contract ABI (multisig_plain)', (): void => {
|
||||
compare('multisigPlain');
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -1,226 +0,0 @@
|
||||
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { ChainProperties, InkProject, MtField, MtLookupTypeId, MtType, MtTypeDefArray, MtTypeDefVariant, MtTypeDefSequence, MtTypeDefTuple, MtVariant } from '@polkadot/types/interfaces';
|
||||
import { AnyJson, Registry, TypeDef, TypeDefInfo } from '@polkadot/types/types';
|
||||
|
||||
import { assert, isUndefined } from '@polkadot/util';
|
||||
import { TypeRegistry, withTypeString } from '@polkadot/types';
|
||||
|
||||
// convert the offset into project-specific, index-1
|
||||
export function getRegistryOffset (id: MtLookupTypeId): number {
|
||||
return id.toNumber() - 1;
|
||||
}
|
||||
|
||||
export default class ContractRegistry {
|
||||
public readonly typeDefs: TypeDef[] = [];
|
||||
|
||||
public readonly registry: Registry;
|
||||
|
||||
public readonly project: InkProject;
|
||||
|
||||
constructor (json: Record<string, AnyJson>, chainProperties?: ChainProperties) {
|
||||
this.registry = new TypeRegistry();
|
||||
|
||||
if (chainProperties) {
|
||||
this.registry.setChainProperties(chainProperties);
|
||||
}
|
||||
|
||||
this.project = this.registry.createType('InkProject', json);
|
||||
|
||||
// Generate TypeDefs for each provided registry type
|
||||
this.project.types.forEach((_, index) => this.setTypeDef(this.registry.createType('MtLookupTypeId', index + 1)));
|
||||
}
|
||||
|
||||
public getAbiType (id: MtLookupTypeId): MtType {
|
||||
const offset = getRegistryOffset(id);
|
||||
const type = this.project.types[offset];
|
||||
|
||||
assert(!isUndefined(type), `getAbiType:: Unable to find ${id.toNumber()} in type values`);
|
||||
|
||||
return this.registry.createType('MtType', type);
|
||||
}
|
||||
|
||||
public typeDefAt (id: MtLookupTypeId, extra: Pick<TypeDef, never> = {}): TypeDef {
|
||||
if (!this.typeDefs[getRegistryOffset(id)]) {
|
||||
this.setTypeDef(id);
|
||||
}
|
||||
|
||||
return {
|
||||
...this.typeDefs[getRegistryOffset(id)],
|
||||
...extra
|
||||
};
|
||||
}
|
||||
|
||||
public setTypeDef (id: MtLookupTypeId): void {
|
||||
const typeDef = this.extractType(this.getAbiType(id), id) as TypeDef;
|
||||
|
||||
this.typeDefs[getRegistryOffset(id)] = typeDef;
|
||||
|
||||
// We have a displayName for non-primitives and non-results
|
||||
// FIXME here we protect against "Option: 'Option<...something...>' definitions (same with result)
|
||||
if (typeDef.displayName && typeDef.info !== TypeDefInfo.Plain && !typeDef.type.startsWith(typeDef.displayName)) {
|
||||
this.registry.register({ [typeDef.displayName]: typeDef.type });
|
||||
}
|
||||
}
|
||||
|
||||
private extractType (inkType: MtType, id: MtLookupTypeId): Pick<TypeDef, never> {
|
||||
const path = [...inkType.path];
|
||||
let typeDef;
|
||||
|
||||
if (inkType.path.join('::').startsWith('ink_env::types::') || inkType.def.isPrimitive) {
|
||||
typeDef = this.extractPrimitive(inkType);
|
||||
} else if (inkType.def.isComposite) {
|
||||
typeDef = this.extractFields(inkType.def.asComposite.fields);
|
||||
} else if (inkType.def.isVariant) {
|
||||
typeDef = this.extractVariant(inkType.def.asVariant, id);
|
||||
} else if (inkType.def.isArray) {
|
||||
typeDef = this.extractArray(inkType.def.asArray);
|
||||
} else if (inkType.def.isSequence) {
|
||||
typeDef = this.extractSequence(inkType.def.asSequence, id);
|
||||
} else if (inkType.def.isTuple) {
|
||||
typeDef = this.extractTuple(inkType.def.asTuple);
|
||||
} else {
|
||||
throw new Error(`Invalid ink! type at index ${id.toString()}`);
|
||||
}
|
||||
|
||||
const displayName = path.pop()?.toString();
|
||||
|
||||
return withTypeString({
|
||||
...(displayName
|
||||
? { displayName }
|
||||
: {}
|
||||
),
|
||||
...(path.length > 1
|
||||
? { namespace: path.map((segment) => segment.toString()).join('::') }
|
||||
: {}
|
||||
),
|
||||
...(inkType.params.length > 0
|
||||
? { params: inkType.params.map((id) => this.typeDefAt(id)) }
|
||||
: {}
|
||||
),
|
||||
...typeDef
|
||||
});
|
||||
}
|
||||
|
||||
private extractVariant ({ variants }: MtTypeDefVariant, id: MtLookupTypeId): Pick<TypeDef, never> {
|
||||
const { params, path } = this.getAbiType(id);
|
||||
const specialVariant = path[0].toString();
|
||||
|
||||
if (specialVariant === 'Option') {
|
||||
return {
|
||||
info: TypeDefInfo.Option,
|
||||
sub: this.typeDefAt(params[0])
|
||||
};
|
||||
} else if (specialVariant === 'Result') {
|
||||
return {
|
||||
info: TypeDefInfo.Result,
|
||||
sub: params.map((param, index) => ({
|
||||
name: ['Ok', 'Error'][index],
|
||||
...this.typeDefAt(param)
|
||||
}))
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
info: TypeDefInfo.Enum,
|
||||
sub: this.extractVariantSub(variants)
|
||||
};
|
||||
}
|
||||
|
||||
private extractVariantSub (variants: MtVariant[]): Pick<TypeDef, any>[] {
|
||||
const isAllUnitVariants = variants.every(({ fields }) => fields.length === 0);
|
||||
|
||||
if (isAllUnitVariants) {
|
||||
return variants.map(({ discriminant, name }) => ({
|
||||
...(
|
||||
discriminant.isSome
|
||||
? { ext: { discriminant: discriminant.unwrap().toNumber() } }
|
||||
: {}
|
||||
),
|
||||
info: TypeDefInfo.Plain,
|
||||
name: name.toString(),
|
||||
type: 'Null'
|
||||
}));
|
||||
}
|
||||
|
||||
return variants.map(({ fields, name }) => ({
|
||||
...this.extractFields(fields),
|
||||
name: name.toString()
|
||||
}));
|
||||
}
|
||||
|
||||
private extractFields (fields: MtField[]): Pick<TypeDef, any> {
|
||||
const [isStruct, isTuple] = fields.reduce(([isAllNamed, isAllUnnamed], { name }) => ([
|
||||
isAllNamed && name.isSome,
|
||||
isAllUnnamed && name.isNone
|
||||
]),
|
||||
[true, true]);
|
||||
|
||||
let info;
|
||||
|
||||
// check for tuple first (no fields may be available)
|
||||
if (isTuple) {
|
||||
info = TypeDefInfo.Tuple;
|
||||
} else if (isStruct) {
|
||||
info = TypeDefInfo.Struct;
|
||||
} else {
|
||||
throw new Error('Invalid fields type detected, expected either Tuple or Struct');
|
||||
}
|
||||
|
||||
const sub = fields.map(({ name, type }) => {
|
||||
return {
|
||||
...this.typeDefAt(type),
|
||||
...(name.isSome ? { name: name.unwrap().toString() } : {})
|
||||
};
|
||||
});
|
||||
|
||||
return isTuple && sub.length === 1
|
||||
? sub[0]
|
||||
: { info, sub };
|
||||
}
|
||||
|
||||
private extractArray ({ len: length, type }: MtTypeDefArray): Pick<TypeDef, never> {
|
||||
assert(!length || length.toNumber() <= 256, 'ContractRegistry: Only support for [Type; <length>], where length > 256');
|
||||
|
||||
return {
|
||||
info: TypeDefInfo.VecFixed,
|
||||
length: length.toNumber(),
|
||||
sub: this.typeDefAt(type)
|
||||
};
|
||||
}
|
||||
|
||||
private extractSequence ({ type }: MtTypeDefSequence, id: MtLookupTypeId): Pick<TypeDef, never> {
|
||||
assert(!!type, `ContractRegistry: Invalid sequence type found at id ${id.toString()}`);
|
||||
|
||||
return {
|
||||
info: TypeDefInfo.Vec,
|
||||
sub: this.typeDefAt(type)
|
||||
};
|
||||
}
|
||||
|
||||
private extractTuple (ids: MtTypeDefTuple): Pick<TypeDef, never> {
|
||||
return ids.length === 1
|
||||
? this.typeDefAt(ids[0])
|
||||
: {
|
||||
info: TypeDefInfo.Tuple,
|
||||
sub: ids.map((id) => this.typeDefAt(id))
|
||||
};
|
||||
}
|
||||
|
||||
private extractPrimitive (inkType: MtType): Pick<TypeDef, never> {
|
||||
if (inkType.def.isPrimitive) {
|
||||
return {
|
||||
info: TypeDefInfo.Plain,
|
||||
type: inkType.def.asPrimitive.type.toLowerCase()
|
||||
};
|
||||
} else if (inkType.path.length > 1) {
|
||||
return {
|
||||
info: TypeDefInfo.Plain,
|
||||
type: inkType.path[inkType.path.length - 1].toString()
|
||||
};
|
||||
}
|
||||
|
||||
throw new Error('Invalid primitive type');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
// Copyright 2017-2021 @polkadot/api-contract authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
|
||||
import abis from '../test/contracts';
|
||||
import { Abi } from '.';
|
||||
|
||||
describe('MetaRegistry', (): void => {
|
||||
Object.keys(abis).forEach((abiName) => {
|
||||
it(`initializes from a contract ABI (${abiName})`, (): void => {
|
||||
const abi = new Abi(abis[abiName]);
|
||||
|
||||
try {
|
||||
const cmpPath = path.join(__dirname, `../test/compare/${abiName}.test.json`);
|
||||
|
||||
if (!fs.existsSync(cmpPath)) {
|
||||
fs.writeFileSync(cmpPath, JSON.stringify(abi.registry.metaTypeDefs, null, 2), { flag: 'w' });
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||
expect(abi.registry.metaTypeDefs).toEqual(require(cmpPath));
|
||||
} catch (error) {
|
||||
console.error(JSON.stringify(abi.registry.metaTypeDefs));
|
||||
|
||||
throw error;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
it('stores base project as JSON', (): void => {
|
||||
expect(new Abi(abis.ink_dns).json).toEqual(abis.ink_dns);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,252 @@
|
||||
// Copyright 2017-2021 @polkadot/api-contract authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { ChainProperties, ContractDisplayName, SiField, SiLookupTypeId, SiType, SiTypeDefArray, SiTypeDefSequence, SiTypeDefTuple, SiTypeDefVariant, SiVariant } from '@polkadot/types/interfaces';
|
||||
import type { InterfaceTypes, TypeDef } from '@polkadot/types/types';
|
||||
|
||||
import { TypeRegistry, withTypeString } from '@polkadot/types/create';
|
||||
import { TypeDefInfo } from '@polkadot/types/types';
|
||||
import { assert, isUndefined } from '@polkadot/util';
|
||||
|
||||
interface PartialTypeSpec {
|
||||
readonly type: SiLookupTypeId;
|
||||
readonly displayName?: ContractDisplayName;
|
||||
}
|
||||
|
||||
// convert the offset into project-specific, index-1
|
||||
export function getRegistryOffset (id: SiLookupTypeId): number {
|
||||
return id.toNumber() - 1;
|
||||
}
|
||||
|
||||
const PRIMITIVE_ALIAS: Record<string, keyof InterfaceTypes> = {
|
||||
Char: 'u32', // Rust char is 4-bytes
|
||||
Str: 'Text'
|
||||
};
|
||||
|
||||
const PRIMITIVE_ALWAYS = ['AccountId', 'AccountIndex', 'Address', 'Balance'];
|
||||
|
||||
export class MetaRegistry extends TypeRegistry {
|
||||
public readonly metaTypeDefs: TypeDef[] = [];
|
||||
|
||||
#siTypes: SiType[] = [];
|
||||
|
||||
constructor (chainProperties?: ChainProperties) {
|
||||
super();
|
||||
|
||||
if (chainProperties) {
|
||||
this.setChainProperties(chainProperties);
|
||||
}
|
||||
}
|
||||
|
||||
public setMetaTypes (metaTypes: SiType[]): void {
|
||||
this.#siTypes = metaTypes;
|
||||
}
|
||||
|
||||
public getMetaTypeDef (typeSpec: PartialTypeSpec): TypeDef {
|
||||
const offset = getRegistryOffset(typeSpec.type);
|
||||
let typeDef = this.metaTypeDefs[offset];
|
||||
|
||||
if (!typeDef) {
|
||||
typeDef = this.#extract(this.#getMetaType(typeSpec.type), typeSpec.type);
|
||||
|
||||
this.metaTypeDefs[offset] = typeDef;
|
||||
}
|
||||
|
||||
if (typeSpec.displayName && typeSpec.displayName.length) {
|
||||
const displayName = typeSpec.displayName[typeSpec.displayName.length - 1].toString();
|
||||
|
||||
if (!typeDef.type.startsWith(displayName)) {
|
||||
typeDef = {
|
||||
...typeDef,
|
||||
displayName,
|
||||
type: PRIMITIVE_ALWAYS.includes(displayName)
|
||||
? displayName
|
||||
: typeDef.type
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
// Here we protect against the following cases
|
||||
// - No displayName present, these are generally known primitives
|
||||
// - displayName === type, these generate circular references
|
||||
// - displayName Option & type Option<...something...>
|
||||
if (typeDef.displayName && !this.hasType(typeDef.displayName) && !(typeDef.type === typeDef.displayName || typeDef.type.startsWith(`${typeDef.displayName}<`))) {
|
||||
this.register({ [typeDef.displayName]: typeDef.type });
|
||||
}
|
||||
|
||||
return typeDef;
|
||||
}
|
||||
|
||||
#getMetaType = (id: SiLookupTypeId): SiType => {
|
||||
const type = this.#siTypes[getRegistryOffset(id)];
|
||||
|
||||
assert(!isUndefined(type), `getMetaType:: Unable to find ${id.toNumber()} in type values`);
|
||||
|
||||
return this.createType('SiType', type);
|
||||
}
|
||||
|
||||
#extract = (type: SiType, id: SiLookupTypeId): TypeDef => {
|
||||
const path = [...type.path];
|
||||
const pathFinal = path.length ? path[path.length - 1].toString() : '';
|
||||
let typeDef: Omit<TypeDef, 'type'>;
|
||||
|
||||
if (type.path.join('::').startsWith('ink_env::types::') || PRIMITIVE_ALWAYS.includes(pathFinal)) {
|
||||
typeDef = this.#extractPrimitivePath(type);
|
||||
} else if (type.def.isPrimitive) {
|
||||
typeDef = this.#extractPrimitive(type);
|
||||
} else if (type.def.isComposite) {
|
||||
typeDef = this.#extractFields(type.def.asComposite.fields);
|
||||
} else if (type.def.isVariant) {
|
||||
typeDef = this.#extractVariant(type.def.asVariant, id);
|
||||
} else if (type.def.isArray) {
|
||||
typeDef = this.#extractArray(type.def.asArray);
|
||||
} else if (type.def.isSequence) {
|
||||
typeDef = this.#extractSequence(type.def.asSequence, id);
|
||||
} else if (type.def.isTuple) {
|
||||
typeDef = this.#extractTuple(type.def.asTuple);
|
||||
} else {
|
||||
throw new Error(`Invalid ink! type at index ${id.toString()}`);
|
||||
}
|
||||
|
||||
const displayName = path.pop()?.toString();
|
||||
|
||||
return withTypeString({
|
||||
...(displayName
|
||||
? { displayName }
|
||||
: {}
|
||||
),
|
||||
...(path.length > 1
|
||||
? { namespace: path.map((segment) => segment.toString()).join('::') }
|
||||
: {}
|
||||
),
|
||||
...(type.params.length > 0
|
||||
? { sub: type.params.map((type) => this.getMetaTypeDef({ type })) }
|
||||
: {}
|
||||
),
|
||||
...typeDef
|
||||
});
|
||||
}
|
||||
|
||||
#extractArray = ({ len: length, type }: SiTypeDefArray): Omit<TypeDef, 'type'> => {
|
||||
assert(!length || length.toNumber() <= 256, 'MetaRegistry: Only support for [Type; <length>], where length > 256');
|
||||
|
||||
return {
|
||||
info: TypeDefInfo.VecFixed,
|
||||
length: length.toNumber(),
|
||||
sub: this.getMetaTypeDef({ type })
|
||||
};
|
||||
}
|
||||
|
||||
#extractFields = (fields: SiField[]): Omit<TypeDef, 'type'> => {
|
||||
const [isStruct, isTuple] = fields.reduce(([isAllNamed, isAllUnnamed], { name }) => ([
|
||||
isAllNamed && name.isSome,
|
||||
isAllUnnamed && name.isNone
|
||||
]),
|
||||
[true, true]);
|
||||
|
||||
let info;
|
||||
|
||||
// check for tuple first (no fields may be available)
|
||||
if (isTuple) {
|
||||
info = TypeDefInfo.Tuple;
|
||||
} else if (isStruct) {
|
||||
info = TypeDefInfo.Struct;
|
||||
} else {
|
||||
throw new Error('Invalid fields type detected, expected either Tuple or Struct');
|
||||
}
|
||||
|
||||
const sub = fields.map(({ name, type }) => {
|
||||
return {
|
||||
...this.getMetaTypeDef({ type }),
|
||||
...(name.isSome ? { name: name.unwrap().toString() } : {})
|
||||
};
|
||||
});
|
||||
|
||||
return isTuple && sub.length === 1
|
||||
? sub[0]
|
||||
: { info, sub };
|
||||
}
|
||||
|
||||
#extractPrimitive = (type: SiType): TypeDef => {
|
||||
const typeStr = type.def.asPrimitive.type.toString();
|
||||
|
||||
return {
|
||||
info: TypeDefInfo.Plain,
|
||||
type: PRIMITIVE_ALIAS[typeStr] || typeStr.toLowerCase()
|
||||
};
|
||||
}
|
||||
|
||||
#extractPrimitivePath = (type: SiType): TypeDef => {
|
||||
return {
|
||||
info: TypeDefInfo.Plain,
|
||||
type: type.path[type.path.length - 1].toString()
|
||||
};
|
||||
}
|
||||
|
||||
#extractSequence = ({ type }: SiTypeDefSequence, id: SiLookupTypeId): Omit<TypeDef, 'type'> => {
|
||||
assert(!!type, `ContractRegistry: Invalid sequence type found at id ${id.toString()}`);
|
||||
|
||||
return {
|
||||
info: TypeDefInfo.Vec,
|
||||
sub: this.getMetaTypeDef({ type })
|
||||
};
|
||||
}
|
||||
|
||||
#extractTuple = (ids: SiTypeDefTuple): Omit<TypeDef, 'type'> => {
|
||||
return ids.length === 1
|
||||
? this.getMetaTypeDef({ type: ids[0] })
|
||||
: {
|
||||
info: TypeDefInfo.Tuple,
|
||||
sub: ids.map((type) => this.getMetaTypeDef({ type }))
|
||||
};
|
||||
}
|
||||
|
||||
#extractVariant = ({ variants }: SiTypeDefVariant, id: SiLookupTypeId): Omit<TypeDef, 'type'> => {
|
||||
const { params, path } = this.#getMetaType(id);
|
||||
const specialVariant = path[0].toString();
|
||||
|
||||
if (specialVariant === 'Option') {
|
||||
return {
|
||||
info: TypeDefInfo.Option,
|
||||
sub: this.getMetaTypeDef({ type: params[0] })
|
||||
};
|
||||
} else if (specialVariant === 'Result') {
|
||||
return {
|
||||
info: TypeDefInfo.Result,
|
||||
sub: params.map((type, index) => ({
|
||||
name: ['Ok', 'Error'][index],
|
||||
...this.getMetaTypeDef({ type })
|
||||
}))
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
info: TypeDefInfo.Enum,
|
||||
sub: this.#extractVariantSub(variants)
|
||||
};
|
||||
}
|
||||
|
||||
#extractVariantSub = (variants: SiVariant[]): TypeDef[] => {
|
||||
const isAllUnitVariants = variants.every(({ fields }) => fields.length === 0);
|
||||
|
||||
if (isAllUnitVariants) {
|
||||
return variants.map(({ discriminant, name }) => ({
|
||||
...(
|
||||
discriminant.isSome
|
||||
? { ext: { discriminant: discriminant.unwrap().toNumber() } }
|
||||
: {}
|
||||
),
|
||||
info: TypeDefInfo.Plain,
|
||||
name: name.toString(),
|
||||
type: 'Null'
|
||||
}));
|
||||
}
|
||||
|
||||
return variants.map(({ fields, name }) =>
|
||||
withTypeString({
|
||||
...this.#extractFields(fields),
|
||||
name: name.toString()
|
||||
})
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,15 +1,15 @@
|
||||
// Copyright 2017-2020 @polkadot/api authors & contributors
|
||||
// Copyright 2017-2021 @polkadot/api authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { ApiTypes, DecorateMethod } from '@polkadot/api/types';
|
||||
import { AnyJson, Registry } from '@polkadot/types/types';
|
||||
import type { ApiTypes, DecorateMethod } from '@polkadot/api/types';
|
||||
import type { AnyJson, Registry } from '@polkadot/types/types';
|
||||
|
||||
import ApiBase from '@polkadot/api/base';
|
||||
import { ApiBase } from '@polkadot/api/base';
|
||||
import { assert } from '@polkadot/util';
|
||||
|
||||
import Abi from '../Abi';
|
||||
import { Abi } from '../Abi';
|
||||
|
||||
export default abstract class Base<ApiType extends ApiTypes> {
|
||||
export abstract class Base<ApiType extends ApiTypes> {
|
||||
public readonly abi: Abi;
|
||||
|
||||
public readonly api: ApiBase<ApiType>;
|
||||
@@ -26,6 +26,6 @@ export default abstract class Base<ApiType extends ApiTypes> {
|
||||
this.registry = this.abi.registry;
|
||||
this._decorateMethod = decorateMethod;
|
||||
|
||||
assert(this.api.rx.tx.contracts && this.api.rx.tx.contracts.putCode, 'You need to connect to a node with the contracts module, the metadata does not enable api.tx.contracts on this instance');
|
||||
assert(api.rx.tx.contracts?.instantiate, 'You need to connect to a node with the contracts module, the metadata does not enable api.tx.contracts on this instance');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,20 +1,22 @@
|
||||
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
|
||||
// Copyright 2017-2021 @polkadot/api-contract authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { ApiTypes, DecorateMethod } from '@polkadot/api/types';
|
||||
import { SubmittableExtrinsic } from '@polkadot/api/submittable/types';
|
||||
import { AccountId, EventRecord, Hash } from '@polkadot/types/interfaces';
|
||||
import { AnyJson, CodecArg, ISubmittableResult } from '@polkadot/types/types';
|
||||
import { AbiConstructor } from '../types';
|
||||
import type { SubmittableExtrinsic } from '@polkadot/api/submittable/types';
|
||||
import type { ApiTypes, DecorateMethod } from '@polkadot/api/types';
|
||||
import type { AccountId, EventRecord, Hash } from '@polkadot/types/interfaces';
|
||||
import type { AnyJson, CodecArg, ISubmittableResult } from '@polkadot/types/types';
|
||||
import type { AbiConstructor, BlueprintOptions } from '../types';
|
||||
import type { ContractGeneric, MapConstructorExec } from './types';
|
||||
|
||||
import BN from 'bn.js';
|
||||
import { SubmittableResult } from '@polkadot/api';
|
||||
import ApiBase from '@polkadot/api/base';
|
||||
import { ApiBase } from '@polkadot/api/base';
|
||||
import { isUndefined, stringCamelCase } from '@polkadot/util';
|
||||
|
||||
import Abi from '../Abi';
|
||||
import { applyOnEvent, encodeMessage } from '../util';
|
||||
import Base from './Base';
|
||||
import Contract from './Contract';
|
||||
import { Abi } from '../Abi';
|
||||
import { applyOnEvent } from '../util';
|
||||
import { Base } from './Base';
|
||||
import { Contract } from './Contract';
|
||||
import { createBluePrintTx, createBluePrintWithId, EMPTY_SALT, encodeSalt } from './util';
|
||||
|
||||
export class BlueprintSubmittableResult<ApiType extends ApiTypes> extends SubmittableResult {
|
||||
public readonly contract?: Contract<ApiType>;
|
||||
@@ -26,22 +28,53 @@ export class BlueprintSubmittableResult<ApiType extends ApiTypes> extends Submit
|
||||
}
|
||||
}
|
||||
|
||||
export default class Blueprint<ApiType extends ApiTypes> extends Base<ApiType> {
|
||||
export class Blueprint<ApiType extends ApiTypes> extends Base<ApiType> {
|
||||
/**
|
||||
* @description The on-chain code hash for this blueprint
|
||||
*/
|
||||
public readonly codeHash: Hash;
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* @description Deprecated. Use `.tx.<constructorName>`. Creates a contract in a non-deterministic way.
|
||||
*/
|
||||
public readonly createContract: ContractGeneric<BlueprintOptions, SubmittableExtrinsic<ApiType, BlueprintSubmittableResult<ApiType>>>;
|
||||
|
||||
readonly #tx: MapConstructorExec<ApiType> = {};
|
||||
|
||||
constructor (api: ApiBase<ApiType>, abi: AnyJson | Abi, codeHash: string | Hash | Uint8Array, decorateMethod: DecorateMethod<ApiType>) {
|
||||
super(api, abi, decorateMethod);
|
||||
|
||||
this.codeHash = this.registry.createType('Hash', codeHash);
|
||||
this.createContract = createBluePrintWithId(this.#deploy);
|
||||
|
||||
this.abi.constructors.forEach((c): void => {
|
||||
const messageName = stringCamelCase(c.identifier);
|
||||
|
||||
if (isUndefined(this.#tx[messageName])) {
|
||||
this.#tx[messageName] = createBluePrintTx((o, p) => this.#deploy(c, o, p));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public createContract (constructorOrId: AbiConstructor | string| number, endowment: BigInt | string | number | BN, gasLimit: BigInt | string | number | BN, ...params: CodecArg[]): SubmittableExtrinsic<ApiType, BlueprintSubmittableResult<ApiType>> {
|
||||
return this.api.tx.contracts
|
||||
.instantiate(endowment, gasLimit, this.codeHash, encodeMessage(this.registry, this.abi.findConstructor(constructorOrId), params))
|
||||
.withResultTransform((result: ISubmittableResult) =>
|
||||
new BlueprintSubmittableResult(result, applyOnEvent(result, 'Instantiated', (record: EventRecord) =>
|
||||
new Contract<ApiType>(this.api, this.abi, record.event.data[1] as AccountId, this._decorateMethod)
|
||||
))
|
||||
);
|
||||
public get tx (): MapConstructorExec<ApiType> {
|
||||
return this.#tx;
|
||||
}
|
||||
|
||||
#deploy = (constructorOrId: AbiConstructor | string | number, { gasLimit = 0, salt, value = 0 }: BlueprintOptions, params: CodecArg[]): SubmittableExtrinsic<ApiType, BlueprintSubmittableResult<ApiType>> => {
|
||||
const encodedSalt = encodeSalt(salt);
|
||||
const withSalt = this.api.tx.contracts.instantiate.meta.args.length === 5;
|
||||
const encoded = this.abi.findConstructor(constructorOrId).toU8a(params, withSalt ? EMPTY_SALT : encodedSalt);
|
||||
const tx = withSalt
|
||||
? this.api.tx.contracts.instantiate(value, gasLimit, this.codeHash, encoded, encodedSalt)
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore old style with salt included
|
||||
: this.api.tx.contracts.instantiate(value, gasLimit, this.codeHash, encoded);
|
||||
|
||||
return tx.withResultTransform((result: ISubmittableResult) =>
|
||||
new BlueprintSubmittableResult(result, applyOnEvent(result, ['Instantiated'], ([record]: EventRecord[]) =>
|
||||
new Contract<ApiType>(this.api, this.abi, record.event.data[1] as AccountId, this._decorateMethod)
|
||||
))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
// Copyright 2017-2021 @polkadot/api-contract authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
|
||||
import { decorateMethod } from '@polkadot/api/promise';
|
||||
|
||||
import contractFlipper from '../../test/contracts/ink/flipper.contract.json';
|
||||
import abiFlipper from '../../test/contracts/ink/flipper.json';
|
||||
import { Code } from './Code';
|
||||
import { mockApi } from './mock';
|
||||
|
||||
const wasmFlipper = fs.readFileSync(path.join(__dirname, '../../test/contracts/ink/flipper.wasm'));
|
||||
|
||||
describe('Code', (): void => {
|
||||
it('can construct with an individual ABI/WASM combo', (): void => {
|
||||
expect(
|
||||
() => new Code(mockApi, abiFlipper, wasmFlipper, decorateMethod)
|
||||
).not.toThrow();
|
||||
});
|
||||
|
||||
it('can construct with an .contract ABI', (): void => {
|
||||
expect(
|
||||
() => new Code(mockApi, contractFlipper, null, decorateMethod)
|
||||
).not.toThrow();
|
||||
});
|
||||
});
|
||||
@@ -1,46 +1,115 @@
|
||||
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
|
||||
// Copyright 2017-2021 @polkadot/api-contract authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { ApiTypes, DecorateMethod } from '@polkadot/api/types';
|
||||
import { SubmittableExtrinsic } from '@polkadot/api/submittable/types';
|
||||
import { EventRecord, Hash } from '@polkadot/types/interfaces';
|
||||
import { AnyJson, ISubmittableResult } from '@polkadot/types/types';
|
||||
import type { SubmittableExtrinsic } from '@polkadot/api/submittable/types';
|
||||
import type { ApiTypes, DecorateMethod } from '@polkadot/api/types';
|
||||
import type { EventRecord } from '@polkadot/types/interfaces';
|
||||
import type { AnyJson, CodecArg, ISubmittableResult } from '@polkadot/types/types';
|
||||
import type { AbiConstructor, BlueprintOptions } from '../types';
|
||||
import type { MapConstructorExec } from './types';
|
||||
|
||||
import { SubmittableResult } from '@polkadot/api';
|
||||
import ApiBase from '@polkadot/api/base';
|
||||
import { compactAddLength, u8aToU8a } from '@polkadot/util';
|
||||
import { ApiBase } from '@polkadot/api/base';
|
||||
import { assert, compactAddLength, isFunction, isUndefined, isWasm, logger, stringCamelCase, u8aToU8a } from '@polkadot/util';
|
||||
import { blake2AsU8a } from '@polkadot/util-crypto';
|
||||
|
||||
import Abi from '../Abi';
|
||||
import { Abi } from '../Abi';
|
||||
import { applyOnEvent } from '../util';
|
||||
import Base from './Base';
|
||||
import Blueprint from './Blueprint';
|
||||
import { Base } from './Base';
|
||||
import { Blueprint } from './Blueprint';
|
||||
import { Contract } from './Contract';
|
||||
import { createBluePrintTx, EMPTY_SALT, encodeSalt } from './util';
|
||||
|
||||
const l = logger('Code');
|
||||
|
||||
export class CodeSubmittableResult<ApiType extends ApiTypes> extends SubmittableResult {
|
||||
public readonly blueprint?: Blueprint<ApiType>;
|
||||
public readonly contract?: Contract<ApiType>;
|
||||
|
||||
constructor (result: ISubmittableResult, blueprint?: Blueprint<ApiType>) {
|
||||
constructor (result: ISubmittableResult, blueprint?: Blueprint<ApiType>, contract?: Contract<ApiType>) {
|
||||
super(result);
|
||||
|
||||
this.blueprint = blueprint;
|
||||
this.contract = contract;
|
||||
}
|
||||
}
|
||||
|
||||
export default class Code<ApiType extends ApiTypes> extends Base<ApiType> {
|
||||
export class Code<ApiType extends ApiTypes> extends Base<ApiType> {
|
||||
public readonly code: Uint8Array;
|
||||
|
||||
constructor (api: ApiBase<ApiType>, abi: AnyJson | Abi, wasm: Uint8Array | string | Buffer, decorateMethod: DecorateMethod<ApiType>) {
|
||||
readonly #tx: MapConstructorExec<ApiType> = {};
|
||||
|
||||
constructor (api: ApiBase<ApiType>, abi: AnyJson | Abi, wasm: Uint8Array | string | Buffer | null | undefined, decorateMethod: DecorateMethod<ApiType>) {
|
||||
super(api, abi, decorateMethod);
|
||||
|
||||
this.code = u8aToU8a(wasm);
|
||||
this.code = isWasm(this.abi.project.source.wasm)
|
||||
? this.abi.project.source.wasm
|
||||
: u8aToU8a(wasm);
|
||||
|
||||
assert(isWasm(this.code), 'No WASM code provided');
|
||||
|
||||
this.abi.constructors.forEach((c): void => {
|
||||
const messageName = stringCamelCase(c.identifier);
|
||||
|
||||
if (isUndefined(this.#tx[messageName])) {
|
||||
this.#tx[messageName] = createBluePrintTx((o, p) => this.#instantiate(c, o, p));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public createBlueprint (): SubmittableExtrinsic<ApiType, CodeSubmittableResult<ApiType>> {
|
||||
public get tx (): MapConstructorExec<ApiType> {
|
||||
return this.#tx;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Deploy the code bundle and the contract, creating a Blueprint.
|
||||
* @deprecated Use the `code.tx.<constructor>(...) format to put code and deploy
|
||||
*/
|
||||
public createContract (constructorOrId: AbiConstructor | string | number, options: BlueprintOptions, params: CodecArg[]): SubmittableExtrinsic<ApiType, CodeSubmittableResult<ApiType>> {
|
||||
l.warn('.createContract is deprecated, use code.tx.<constructorName>(...) instead (where code refers to this instance)');
|
||||
|
||||
return this.#instantiate(constructorOrId, options, params);
|
||||
}
|
||||
|
||||
#instantiate = (constructorOrId: AbiConstructor | string | number, options: BlueprintOptions, params: CodecArg[]): SubmittableExtrinsic<ApiType, CodeSubmittableResult<ApiType>> => {
|
||||
return isFunction(this.api.tx.contracts.instantiateWithCode)
|
||||
? this.#instantiateCurrent(constructorOrId, options, params)
|
||||
: this.#instantiatePrev(constructorOrId, options, params);
|
||||
}
|
||||
|
||||
#instantiateCurrent = (constructorOrId: AbiConstructor | string | number, { gasLimit = 0, salt, value = 0 }: BlueprintOptions, params: CodecArg[]): SubmittableExtrinsic<ApiType, CodeSubmittableResult<ApiType>> => {
|
||||
return this.api.tx.contracts
|
||||
.putCode(compactAddLength(this.code))
|
||||
.withResultTransform((result: ISubmittableResult) =>
|
||||
new CodeSubmittableResult(result, applyOnEvent(result, 'CodeStored', (record: EventRecord) =>
|
||||
new Blueprint<ApiType>(this.api, this.abi, record.event.data[0] as Hash, this._decorateMethod)
|
||||
))
|
||||
);
|
||||
.instantiateWithCode(value, gasLimit, compactAddLength(this.code), this.abi.findConstructor(constructorOrId).toU8a(params), encodeSalt(salt))
|
||||
.withResultTransform(this.#transformEvents);
|
||||
}
|
||||
|
||||
#instantiatePrev = (constructorOrId: AbiConstructor | string | number, { gasLimit = 0, salt, value = 0 }: BlueprintOptions, params: CodecArg[]): SubmittableExtrinsic<ApiType, CodeSubmittableResult<ApiType>> => {
|
||||
assert(isFunction(this.api.tx.utility?.batch), 'Your chain does not include the utility pallet, for contracts v2 deployment, this is required');
|
||||
|
||||
const encodedSalt = encodeSalt(salt);
|
||||
const withSalt = this.api.tx.contracts.instantiate.meta.args.length === 5;
|
||||
const encoded = this.abi.findConstructor(constructorOrId).toU8a(params, withSalt ? EMPTY_SALT : encodedSalt);
|
||||
const codeHash = blake2AsU8a(this.code);
|
||||
|
||||
return this.api.tx.utility.batch([
|
||||
this.api.tx.contracts.putCode(compactAddLength(this.code)),
|
||||
withSalt
|
||||
? this.api.tx.contracts.instantiate(value, gasLimit, codeHash, encoded, encodedSalt)
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore old style with salt included in the params itself
|
||||
: this.api.tx.contracts.instantiate(value, gasLimit, codeHash, encoded)
|
||||
]).withResultTransform(this.#transformEvents);
|
||||
}
|
||||
|
||||
#transformEvents = (result: ISubmittableResult): CodeSubmittableResult<ApiType> => {
|
||||
return new CodeSubmittableResult(result, ...(applyOnEvent(result, ['CodeStored', 'Instantiated'], (records: EventRecord[]) =>
|
||||
records.reduce(([blueprint, contract], { event }): [Blueprint<ApiType>?, Contract<ApiType>?] =>
|
||||
this.api.events.contracts.Instantiated.is(event)
|
||||
? [blueprint, new Contract<ApiType>(this.api, this.abi, event.data[1], this._decorateMethod)]
|
||||
: this.api.events.contracts.CodeStored.is(event)
|
||||
? [new Blueprint<ApiType>(this.api, this.abi, event.data[0], this._decorateMethod), contract]
|
||||
: [blueprint, contract],
|
||||
[] as [Blueprint<ApiType>?, Contract<ApiType>?])
|
||||
) || []));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,78 +1,208 @@
|
||||
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
|
||||
// Copyright 2017-2021 @polkadot/api-contract authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { ApiTypes, DecorateMethod, ObsInnerType } from '@polkadot/api/types';
|
||||
import { SubmittableExtrinsic } from '@polkadot/api/submittable/types';
|
||||
import { AccountId, ContractExecResult } from '@polkadot/types/interfaces';
|
||||
import { AnyJson, CodecArg, IKeyringPair } from '@polkadot/types/types';
|
||||
import { AbiMessage, ContractCallOutcome } from '../types';
|
||||
import type { SubmittableExtrinsic } from '@polkadot/api/submittable/types';
|
||||
import type { ApiTypes, DecorateMethod } from '@polkadot/api/types';
|
||||
import type { Bytes } from '@polkadot/types';
|
||||
import type { AccountId, ContractExecResult, EventRecord, Weight } from '@polkadot/types/interfaces';
|
||||
import type { AnyJson, CodecArg, ISubmittableResult, Registry } from '@polkadot/types/types';
|
||||
import type { AbiMessage, ContractCallOutcome, ContractOptions, DecodedEvent } from '../types';
|
||||
import type { ContractCallResult, ContractCallSend, ContractGeneric, ContractQuery, ContractTx, MapMessageQuery, MapMessageTx } from './types';
|
||||
|
||||
import BN from 'bn.js';
|
||||
import { Observable } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
|
||||
import { SubmittableResult } from '@polkadot/api';
|
||||
import ApiBase from '@polkadot/api/base';
|
||||
import { assert, isFunction } from '@polkadot/util';
|
||||
import { ApiBase } from '@polkadot/api/base';
|
||||
import { assert, bnToBn, isFunction, isUndefined, logger, stringCamelCase } from '@polkadot/util';
|
||||
import { map } from '@polkadot/x-rxjs/operators';
|
||||
|
||||
import Abi from '../Abi';
|
||||
import { encodeMessage, formatData } from '../util';
|
||||
import Base from './Base';
|
||||
import { Abi } from '../Abi';
|
||||
import { applyOnEvent, extractOptions, formatData, isOptions } from '../util';
|
||||
import { Base } from './Base';
|
||||
|
||||
type ContractCallTypes = 'tx' | 'rpc';
|
||||
// As per Rust, 5 * GAS_PER_SEC
|
||||
const MAX_CALL_GAS = new BN(5_000_000_000_000).subn(1);
|
||||
const ERROR_NO_CALL = 'Your node does not expose the contracts.call RPC. This is most probably due to a runtime configuration.';
|
||||
|
||||
type ContractCallResultSubscription<ApiType extends ApiTypes, CallType extends ContractCallTypes> = ApiType extends 'rxjs'
|
||||
// eslint-disable-next-line no-use-before-define
|
||||
? Observable<ContractCallResult<CallType>>
|
||||
// eslint-disable-next-line no-use-before-define
|
||||
: Promise<ObsInnerType<ContractCallResult<CallType>>>;
|
||||
const l = logger('Contract');
|
||||
|
||||
export interface ContractRead<ApiType extends ApiTypes> {
|
||||
send (account: IKeyringPair | string | AccountId): ContractCallResultSubscription<ApiType, 'rpc'>;
|
||||
function createQuery <ApiType extends ApiTypes> (fn: (origin: string | AccountId | Uint8Array, options: ContractOptions, params: CodecArg[]) => ContractCallResult<ApiType, ContractCallOutcome>): ContractQuery<ApiType> {
|
||||
return (origin: string | AccountId | Uint8Array, options: BigInt | string | number | BN | ContractOptions, ...params: CodecArg[]): ContractCallResult<ApiType, ContractCallOutcome> =>
|
||||
isOptions(options)
|
||||
? fn(origin, options, params)
|
||||
: fn(origin, ...extractOptions(options, params));
|
||||
}
|
||||
|
||||
export type ContractCallResult<CallType extends ContractCallTypes> = CallType extends 'rpc'
|
||||
? Observable<ContractCallOutcome>
|
||||
: Observable<SubmittableResult>;
|
||||
function createTx <ApiType extends ApiTypes> (fn: (options: ContractOptions, params: CodecArg[]) => SubmittableExtrinsic<ApiType>): ContractTx<ApiType> {
|
||||
return (options: BigInt | string | number | BN | ContractOptions, ...params: CodecArg[]): SubmittableExtrinsic<ApiType> =>
|
||||
isOptions(options)
|
||||
? fn(options, params)
|
||||
: fn(...extractOptions(options, params));
|
||||
}
|
||||
|
||||
export default class Contract<ApiType extends ApiTypes> extends Base<ApiType> {
|
||||
function createWithId <T> (fn: (messageOrId: AbiMessage | string | number, options: ContractOptions, params: CodecArg[]) => T, warn?: string): ContractGeneric<ContractOptions, T> {
|
||||
return (messageOrId: AbiMessage | string | number, options: BigInt | string | number | BN | ContractOptions, ...params: CodecArg[]): T => {
|
||||
warn && l.warn(warn);
|
||||
|
||||
return isOptions(options)
|
||||
? fn(messageOrId, options, params)
|
||||
: fn(messageOrId, ...extractOptions(options, params));
|
||||
};
|
||||
}
|
||||
|
||||
export class ContractSubmittableResult extends SubmittableResult {
|
||||
public readonly contractEvents?: DecodedEvent[];
|
||||
|
||||
constructor (result: ISubmittableResult, contractEvents?: DecodedEvent[]) {
|
||||
super(result);
|
||||
|
||||
this.contractEvents = contractEvents;
|
||||
}
|
||||
}
|
||||
|
||||
// map from a JSON result to current-style ContractExecResult
|
||||
function mapExecResult (registry: Registry, json: Record<string, AnyJson>): ContractExecResult {
|
||||
if (!Object.keys(json).some((key) => ['error', 'success'].includes(key))) {
|
||||
return registry.createType('ContractExecResult', json);
|
||||
}
|
||||
|
||||
const from = registry.createType('ContractExecResultTo260', json);
|
||||
|
||||
if (from.isSuccess) {
|
||||
const s = from.asSuccess;
|
||||
|
||||
return registry.createType('ContractExecResult', {
|
||||
gasConsumed: s.gasConsumed,
|
||||
result: {
|
||||
ok: {
|
||||
data: s.data,
|
||||
flags: s.flags
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// in the old format error has no additional information,
|
||||
// map it as-is with an "unknown" error
|
||||
return registry.createType('ContractExecResult', { result: { err: { other: 'unknown' } } });
|
||||
}
|
||||
|
||||
export class Contract<ApiType extends ApiTypes> extends Base<ApiType> {
|
||||
/**
|
||||
* @description The on-chain address for this contract
|
||||
*/
|
||||
public readonly address: AccountId;
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* @description Deprecated. Use `.tx.<messageName>` to send a transaction.
|
||||
*/
|
||||
public readonly exec: ContractGeneric<ContractOptions, SubmittableExtrinsic<ApiType>>;
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* @description Deprecated. Use `.tx.<messageName>` to send a transaction.
|
||||
*/
|
||||
public readonly read: ContractGeneric<ContractOptions, ContractCallSend<ApiType>>;
|
||||
|
||||
readonly #query: MapMessageQuery<ApiType> = {};
|
||||
|
||||
readonly #tx: MapMessageTx<ApiType> = {};
|
||||
|
||||
constructor (api: ApiBase<ApiType>, abi: AnyJson | Abi, address: string | AccountId, decorateMethod: DecorateMethod<ApiType>) {
|
||||
super(api, abi, decorateMethod);
|
||||
|
||||
this.address = this.registry.createType('AccountId', address);
|
||||
this.exec = createWithId(this.#exec, '.exec is deprecated, use contract.tx.<messageName>(...) instead (where contract refers to this instance)');
|
||||
this.read = createWithId(this.#read, '.read is deprecated, use contract.query.<messageName>(...) instead (where contract refers to this instance)');
|
||||
|
||||
this.abi.messages.forEach((m): void => {
|
||||
const messageName = stringCamelCase(m.identifier);
|
||||
|
||||
if (isUndefined(this.#tx[messageName])) {
|
||||
this.#tx[messageName] = createTx((o, p) => this.#exec(m, o, p));
|
||||
}
|
||||
|
||||
if (isUndefined(this.#query[messageName])) {
|
||||
this.#query[messageName] = createQuery((f, o, p) => this.#read(m, o, p).send(f));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public get hasRpcContractsCall (): boolean {
|
||||
return isFunction(this.api.rx.rpc.contracts?.call);
|
||||
}
|
||||
|
||||
public exec (messageOrId: AbiMessage | string | number, value: BigInt | BN | string | number, gasLimit: BigInt | BN | string | number, ...params: CodecArg[]): SubmittableExtrinsic<ApiType> {
|
||||
return this.api.tx.contracts.call(this.address, value, gasLimit, encodeMessage(this.registry, this.abi.findMessage(messageOrId), params));
|
||||
public get query (): MapMessageQuery<ApiType> {
|
||||
assert(this.hasRpcContractsCall, ERROR_NO_CALL);
|
||||
|
||||
return this.#query;
|
||||
}
|
||||
|
||||
public read (messageOrId: AbiMessage | string | number, value: BigInt | BN | string | number, gasLimit: BigInt | BN | string | number, ...params: CodecArg[]): ContractRead<ApiType> {
|
||||
assert(this.hasRpcContractsCall, 'Your node does not support contract RPC read calls');
|
||||
public get tx (): MapMessageTx<ApiType> {
|
||||
return this.#tx;
|
||||
}
|
||||
|
||||
#getGas = (_gasLimit: BigInt | BN | string | number, isCall = false): BN => {
|
||||
const gasLimit = bnToBn(_gasLimit);
|
||||
|
||||
return gasLimit.lten(0)
|
||||
? isCall
|
||||
? MAX_CALL_GAS
|
||||
: (this.api.consts.system.blockWeights
|
||||
? this.api.consts.system.blockWeights.maxBlock
|
||||
: this.api.consts.system.maximumBlockWeight as Weight
|
||||
).muln(64).divn(100)
|
||||
: gasLimit;
|
||||
}
|
||||
|
||||
#exec = (messageOrId: AbiMessage | string | number, { gasLimit = 0, value = 0 }: ContractOptions, params: CodecArg[]): SubmittableExtrinsic<ApiType> => {
|
||||
return this.api.tx.contracts
|
||||
.call(this.address, value, this.#getGas(gasLimit), this.abi.findMessage(messageOrId).toU8a(params))
|
||||
.withResultTransform((result: ISubmittableResult) =>
|
||||
// ContractEmitted is the current generation, ContractExecution is the previous generation
|
||||
new ContractSubmittableResult(result, applyOnEvent(result, ['ContractEmitted', 'ContractExecution'], (records: EventRecord[]) =>
|
||||
records
|
||||
.map(({ event: { data: [, data] } }): DecodedEvent | null => {
|
||||
try {
|
||||
return this.abi.decodeEvent(data as Bytes);
|
||||
} catch (error) {
|
||||
l.error(`Unable to decode contract event: ${(error as Error).message}`);
|
||||
|
||||
return null;
|
||||
}
|
||||
})
|
||||
.filter((decoded): decoded is DecodedEvent => !!decoded)
|
||||
))
|
||||
);
|
||||
}
|
||||
|
||||
#read = (messageOrId: AbiMessage | string | number, { gasLimit = 0, value = 0 }: ContractOptions, params: CodecArg[]): ContractCallSend<ApiType> => {
|
||||
assert(this.hasRpcContractsCall, ERROR_NO_CALL);
|
||||
|
||||
const message = this.abi.findMessage(messageOrId);
|
||||
|
||||
return {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
||||
send: this._decorateMethod((account: string | AccountId | Uint8Array): ContractCallResult<'rpc'> =>
|
||||
this.api.rx.rpc.contracts.call({
|
||||
send: this._decorateMethod((origin: string | AccountId | Uint8Array) =>
|
||||
this.api.rx.rpc.contracts.call.json({
|
||||
dest: this.address,
|
||||
gasLimit,
|
||||
inputData: encodeMessage(this.registry, message, params),
|
||||
origin: account,
|
||||
gasLimit: this.#getGas(gasLimit, true),
|
||||
inputData: message.toU8a(params),
|
||||
origin,
|
||||
value
|
||||
}).pipe(
|
||||
map((result: ContractExecResult): ContractCallOutcome => ({
|
||||
output: result.isSuccess && message.returnType
|
||||
? formatData(this.registry, result.asSuccess.data, message.returnType)
|
||||
}).pipe(map((json): ContractCallOutcome => {
|
||||
const { debugMessage, gasConsumed, result } = mapExecResult(this.registry, json.toJSON());
|
||||
|
||||
return {
|
||||
debugMessage,
|
||||
gasConsumed,
|
||||
output: result.isOk && message.returnType
|
||||
? formatData(this.registry, result.asOk.data, message.returnType)
|
||||
: null,
|
||||
result
|
||||
}))
|
||||
)
|
||||
};
|
||||
}))
|
||||
)
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Copyright 2017-2020 @polkadot/api authors & contributors
|
||||
// Copyright 2017-2021 @polkadot/api authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
export { default as Blueprint } from './Blueprint';
|
||||
export { default as Code } from './Code';
|
||||
export { default as Contract } from './Contract';
|
||||
export { Blueprint, BlueprintSubmittableResult } from './Blueprint';
|
||||
export { Code, CodeSubmittableResult } from './Code';
|
||||
export { Contract } from './Contract';
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
// Copyright 2017-2021 @polkadot/api-contract authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { ApiBase } from '@polkadot/api/base';
|
||||
import { TypeRegistry } from '@polkadot/types';
|
||||
|
||||
const registry = new TypeRegistry();
|
||||
|
||||
export const mockApi = {
|
||||
registry,
|
||||
rx: {
|
||||
tx: {
|
||||
contracts: {
|
||||
instantiate: (): never => {
|
||||
throw new Error('mock');
|
||||
},
|
||||
putCode: (): never => {
|
||||
throw new Error('mock');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} as unknown as ApiBase<'promise'>;
|
||||
@@ -0,0 +1,50 @@
|
||||
// Copyright 2017-2021 @polkadot/api-contract authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type BN from 'bn.js';
|
||||
import type { SubmittableExtrinsic } from '@polkadot/api/submittable/types';
|
||||
import type { ApiTypes, ObsInnerType } from '@polkadot/api/types';
|
||||
import type { AccountId } from '@polkadot/types/interfaces';
|
||||
import type { CodecArg } from '@polkadot/types/types';
|
||||
import type { Observable } from '@polkadot/x-rxjs';
|
||||
import type { AbiMessage, BlueprintOptions, ContractCallOutcome, ContractOptions } from '../types';
|
||||
|
||||
export interface BlueprintDeploy<ApiType extends ApiTypes> {
|
||||
(options: BlueprintOptions, ...params: CodecArg[]): SubmittableExtrinsic<ApiType>;
|
||||
(value: BigInt | string | number | BN, gasLimit: BigInt | string | number | BN, ...params: CodecArg[]): SubmittableExtrinsic<ApiType>;
|
||||
}
|
||||
|
||||
export interface ContractQuery<ApiType extends ApiTypes> {
|
||||
(origin: AccountId | string | Uint8Array, options: ContractOptions, ...params: CodecArg[]): ContractCallResult<ApiType, ContractCallOutcome>;
|
||||
(origin: AccountId | string | Uint8Array, value: BigInt | BN | string | number, gasLimit: BigInt | BN | string | number, ...params: CodecArg[]): ContractCallResult<ApiType, ContractCallOutcome>;
|
||||
}
|
||||
|
||||
export interface ContractTx<ApiType extends ApiTypes> {
|
||||
(options: ContractOptions, ...params: CodecArg[]): SubmittableExtrinsic<ApiType>;
|
||||
(value: BigInt | BN | string | number, gasLimit: BigInt | BN | string | number, ...params: CodecArg[]): SubmittableExtrinsic<ApiType>;
|
||||
}
|
||||
|
||||
export interface ContractGeneric<O, T> {
|
||||
(messageOrId: AbiMessage | string | number, options: O, ...params: CodecArg[]): T;
|
||||
(messageOrId: AbiMessage | string | number, value: BigInt | BN | string | number, gasLimit: BigInt | BN | string | number, ...params: CodecArg[]): T;
|
||||
}
|
||||
|
||||
export type ContractCallResult<ApiType extends ApiTypes, T> = ApiType extends 'rxjs'
|
||||
? Observable<Observable<T>>
|
||||
: Promise<ObsInnerType<Observable<T>>>;
|
||||
|
||||
export interface ContractCallSend<ApiType extends ApiTypes> {
|
||||
send (account: string | AccountId | Uint8Array): ContractCallResult<ApiType, ContractCallOutcome>;
|
||||
}
|
||||
|
||||
export interface MapConstructorExec<ApiType extends ApiTypes> {
|
||||
[message: string]: BlueprintDeploy<ApiType>;
|
||||
}
|
||||
|
||||
export interface MapMessageTx<ApiType extends ApiTypes> {
|
||||
[message: string]: ContractTx<ApiType>;
|
||||
}
|
||||
|
||||
export interface MapMessageQuery<ApiType extends ApiTypes> {
|
||||
[message: string]: ContractQuery<ApiType>;
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
// Copyright 2017-2021 @polkadot/api-contract authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { SubmittableResult } from '@polkadot/api';
|
||||
import type { SubmittableExtrinsic } from '@polkadot/api/submittable/types';
|
||||
import type { ApiTypes } from '@polkadot/api/types';
|
||||
import type { CodecArg } from '@polkadot/types/types';
|
||||
import type { AbiConstructor, BlueprintOptions } from '../types';
|
||||
import type { BlueprintDeploy, ContractGeneric } from './types';
|
||||
|
||||
import BN from 'bn.js';
|
||||
|
||||
import { Bytes } from '@polkadot/types';
|
||||
import { compactAddLength, u8aToU8a } from '@polkadot/util';
|
||||
import { randomAsU8a } from '@polkadot/util-crypto';
|
||||
|
||||
import { extractOptions, isOptions } from '../util';
|
||||
|
||||
export const EMPTY_SALT = new Uint8Array();
|
||||
|
||||
export function createBluePrintTx <ApiType extends ApiTypes, R extends SubmittableResult> (fn: (options: BlueprintOptions, params: CodecArg[]) => SubmittableExtrinsic<ApiType, R>): BlueprintDeploy<ApiType> {
|
||||
return (options: BigInt | string | number | BN | BlueprintOptions, ...params: CodecArg[]): SubmittableExtrinsic<ApiType, R> =>
|
||||
isOptions(options)
|
||||
? fn(options, params)
|
||||
: fn(...extractOptions(options, params));
|
||||
}
|
||||
|
||||
export function createBluePrintWithId <T> (fn: (constructorOrId: AbiConstructor | string | number, options: BlueprintOptions, params: CodecArg[]) => T): ContractGeneric<BlueprintOptions, T> {
|
||||
return (constructorOrId: AbiConstructor | string | number, options: BigInt | string | number | BN | BlueprintOptions, ...params: CodecArg[]): T =>
|
||||
isOptions(options)
|
||||
? fn(constructorOrId, options, params)
|
||||
: fn(constructorOrId, ...extractOptions(options, params));
|
||||
}
|
||||
|
||||
export function encodeSalt (salt: Uint8Array | string | null = randomAsU8a()): Uint8Array {
|
||||
return salt instanceof Bytes
|
||||
? salt
|
||||
: salt && salt.length
|
||||
? compactAddLength(u8aToU8a(salt))
|
||||
: EMPTY_SALT;
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
// Copyright 2017-2021 @polkadot/api-contract authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Simple non-runnable checks to test type definitions in the editor itself
|
||||
|
||||
import { ApiPromise } from '@polkadot/api';
|
||||
import { createTestPairs, TestKeyringMap } from '@polkadot/keyring/testingPairs';
|
||||
|
||||
import abiIncrementer from '../test/contracts/ink/incrementer.json';
|
||||
import { BlueprintPromise, ContractPromise } from '.';
|
||||
|
||||
async function checkBlueprint (api: ApiPromise, pairs: TestKeyringMap): Promise<void> {
|
||||
const blueprint = new BlueprintPromise(api, abiIncrementer, '0x1234');
|
||||
|
||||
// new style
|
||||
await blueprint.tx.new({ gasLimit: 456, salt: '0x1234', value: 123 }, 42).signAndSend(pairs.bob);
|
||||
await blueprint.tx.new({ gasLimit: 456, value: 123 }, 42).signAndSend(pairs.bob);
|
||||
|
||||
// old style
|
||||
await blueprint.tx.new(123, 456, 42).signAndSend(pairs.bob);
|
||||
}
|
||||
|
||||
async function checkContract (api: ApiPromise, pairs: TestKeyringMap): Promise<void> {
|
||||
const contract = new ContractPromise(api, abiIncrementer, '0x1234');
|
||||
|
||||
// queries
|
||||
await contract.query.get(pairs.alice.address, {});
|
||||
await contract.query.get(pairs.alice.address, 0, 0);
|
||||
|
||||
// execute
|
||||
await contract.tx.inc({ gasLimit: 1234 }, 123).signAndSend(pairs.eve);
|
||||
await contract.tx.inc(123, 456, 69).signAndSend(pairs.eve);
|
||||
|
||||
// deprecated
|
||||
await contract.read('get', {}).send(pairs.eve.address);
|
||||
await contract.exec('inc', {}, 123).signAndSend(pairs.dave);
|
||||
}
|
||||
|
||||
async function main (): Promise<void> {
|
||||
const api = await ApiPromise.create({
|
||||
hasher: (data: Uint8Array): Uint8Array => data
|
||||
});
|
||||
const pairs = createTestPairs();
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
||||
Promise.all([
|
||||
checkBlueprint(api, pairs),
|
||||
checkContract(api, pairs)
|
||||
]);
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/unbound-method
|
||||
main().catch(console.error);
|
||||
@@ -0,0 +1,10 @@
|
||||
// Copyright 2017-2021 @polkadot/api-contract authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { packageInfo as apiInfo } from '@polkadot/api/packageInfo';
|
||||
import { packageInfo as typesInfo } from '@polkadot/types/packageInfo';
|
||||
import { detectPackage } from '@polkadot/util';
|
||||
|
||||
import { packageInfo } from './packageInfo';
|
||||
|
||||
detectPackage(packageInfo, typeof __dirname !== 'undefined' && __dirname, [apiInfo, typesInfo]);
|
||||
@@ -1,10 +1,9 @@
|
||||
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
|
||||
// Copyright 2017-2021 @polkadot/api-contract authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
export { CodeSubmittableResult } from './base/Code';
|
||||
export { BlueprintSubmittableResult } from './base/Blueprint';
|
||||
import './detectPackage';
|
||||
|
||||
export { default as Abi } from './Abi';
|
||||
|
||||
export * from './rx';
|
||||
export * from './promise';
|
||||
export { Abi } from './Abi';
|
||||
export { packageInfo } from './packageInfo';
|
||||
export { Blueprint as BlueprintPromise, Code as CodePromise, Contract as ContractPromise } from './promise';
|
||||
export { Blueprint as BlueprintRx, Code as CodeRx, Contract as ContractRx } from './rx';
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
// Copyright 2017-2021 @polkadot/api-contract authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Auto-generated by @polkadot/dev, do not edit
|
||||
|
||||
export const packageInfo = { name: '@polkadot/api-contract', version: '4.4.1' };
|
||||
@@ -0,0 +1,17 @@
|
||||
// Copyright 2017-2021 @polkadot/api-contract authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { Hash } from '@polkadot/types/interfaces';
|
||||
import type { AnyJson } from '@polkadot/types/types';
|
||||
|
||||
import { ApiPromise } from '@polkadot/api';
|
||||
import { decorateMethod } from '@polkadot/api/promise';
|
||||
|
||||
import { Abi } from '../Abi';
|
||||
import { Blueprint as BaseBlueprint } from '../base';
|
||||
|
||||
export class Blueprint extends BaseBlueprint<'promise'> {
|
||||
constructor (api: ApiPromise, abi: AnyJson | Abi, codeHash: string | Hash) {
|
||||
super(api, abi, codeHash, decorateMethod);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
// Copyright 2017-2021 @polkadot/api-contract authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { ApiPromise } from '@polkadot/api';
|
||||
import type { AnyJson } from '@polkadot/types/types';
|
||||
|
||||
import { decorateMethod } from '@polkadot/api/promise';
|
||||
|
||||
import { Abi } from '../Abi';
|
||||
import { Code as BaseCode } from '../base';
|
||||
|
||||
export class Code extends BaseCode<'promise'> {
|
||||
constructor (api: ApiPromise, abi: AnyJson | Abi, wasm: Uint8Array | string | Buffer | null | undefined) {
|
||||
super(api, abi, wasm, decorateMethod);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
// Copyright 2017-2021 @polkadot/api-contract authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { AccountId } from '@polkadot/types/interfaces';
|
||||
import type { AnyJson } from '@polkadot/types/types';
|
||||
|
||||
import { ApiPromise } from '@polkadot/api';
|
||||
import { decorateMethod } from '@polkadot/api/promise';
|
||||
|
||||
import { Abi } from '../Abi';
|
||||
import { Contract as BaseContract } from '../base';
|
||||
|
||||
export class Contract extends BaseContract<'promise'> {
|
||||
constructor (api: ApiPromise, abi: AnyJson | Abi, address: string | AccountId) {
|
||||
super(api, abi, address, decorateMethod);
|
||||
}
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { Hash } from '@polkadot/types/interfaces';
|
||||
import { AnyJson } from '@polkadot/types/types';
|
||||
|
||||
import { ApiPromise } from '@polkadot/api';
|
||||
import { decorateMethod } from '@polkadot/api/promise';
|
||||
|
||||
import Abi from '../Abi';
|
||||
import Blueprint from '../base/Blueprint';
|
||||
|
||||
export default class PromiseBlueprint extends Blueprint<'promise'> {
|
||||
constructor (api: ApiPromise, abi: AnyJson | Abi, codeHash: string | Hash) {
|
||||
super(api, abi, codeHash, decorateMethod);
|
||||
}
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { ApiPromise } from '@polkadot/api';
|
||||
import { decorateMethod } from '@polkadot/api/promise';
|
||||
import { AnyJson } from '@polkadot/types/types';
|
||||
|
||||
import Abi from '../Abi';
|
||||
import Code from '../base/Code';
|
||||
|
||||
export default class PromiseCode extends Code<'promise'> {
|
||||
constructor (api: ApiPromise, abi: AnyJson | Abi, wasm: Uint8Array | string | Buffer) {
|
||||
super(api, abi, wasm, decorateMethod);
|
||||
}
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { AccountId } from '@polkadot/types/interfaces';
|
||||
import { AnyJson } from '@polkadot/types/types';
|
||||
|
||||
import { ApiPromise } from '@polkadot/api';
|
||||
import { decorateMethod } from '@polkadot/api/promise';
|
||||
|
||||
import Abi from '../Abi';
|
||||
import Contract from '../base/Contract';
|
||||
|
||||
export default class PromiseContract extends Contract<'promise'> {
|
||||
constructor (api: ApiPromise, abi: AnyJson | Abi, address: string | AccountId) {
|
||||
super(api, abi, address, decorateMethod);
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
|
||||
// Copyright 2017-2021 @polkadot/api-contract authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
export { default as BlueprintPromise } from './PromiseBlueprint';
|
||||
export { default as CodePromise } from './PromiseCode';
|
||||
export { default as ContractPromise } from './PromiseContract';
|
||||
export { Blueprint } from './Blueprint';
|
||||
export { Code } from './Code';
|
||||
export { Contract } from './Contract';
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
// Copyright 2017-2021 @polkadot/api-contract authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { BlueprintSubmittableResult as BaseBlueprintSubmittableResult, CodeSubmittableResult as BaseCodeSubmittableResult } from '../base';
|
||||
|
||||
export type BlueprintSubmittableResult = BaseBlueprintSubmittableResult<'promise'>;
|
||||
export type CodeSubmittableResult = BaseCodeSubmittableResult<'promise'>;
|
||||
@@ -0,0 +1,17 @@
|
||||
// Copyright 2017-2021 @polkadot/api-contract authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { Hash } from '@polkadot/types/interfaces';
|
||||
import type { AnyJson } from '@polkadot/types/types';
|
||||
|
||||
import { ApiRx } from '@polkadot/api';
|
||||
import { decorateMethod } from '@polkadot/api/rx';
|
||||
|
||||
import { Abi } from '../Abi';
|
||||
import { Blueprint as BaseBlueprint } from '../base';
|
||||
|
||||
export class Blueprint extends BaseBlueprint<'rxjs'> {
|
||||
constructor (api: ApiRx, abi: AnyJson | Abi, codeHash: string | Hash) {
|
||||
super(api, abi, codeHash, decorateMethod);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
// Copyright 2017-2021 @polkadot/api-contract authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { ApiRx } from '@polkadot/api';
|
||||
import type { AnyJson } from '@polkadot/types/types';
|
||||
|
||||
import { decorateMethod } from '@polkadot/api/rx';
|
||||
|
||||
import { Abi } from '../Abi';
|
||||
import { Code as BaseCode } from '../base';
|
||||
|
||||
export class Code extends BaseCode<'rxjs'> {
|
||||
constructor (api: ApiRx, abi: AnyJson | Abi, wasm: Uint8Array | string | Buffer | null | undefined) {
|
||||
super(api, abi, wasm, decorateMethod);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
// Copyright 2017-2021 @polkadot/api-contract authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { AccountId } from '@polkadot/types/interfaces';
|
||||
import type { AnyJson } from '@polkadot/types/types';
|
||||
|
||||
import { ApiRx } from '@polkadot/api';
|
||||
import { decorateMethod } from '@polkadot/api/rx';
|
||||
|
||||
import { Abi } from '../Abi';
|
||||
import { Contract as BaseContract } from '../base';
|
||||
|
||||
export class Contract extends BaseContract<'rxjs'> {
|
||||
constructor (api: ApiRx, abi: AnyJson | Abi, address: string | AccountId) {
|
||||
super(api, abi, address, decorateMethod);
|
||||
}
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { Hash } from '@polkadot/types/interfaces';
|
||||
import { AnyJson } from '@polkadot/types/types';
|
||||
|
||||
import { ApiRx } from '@polkadot/api';
|
||||
import { decorateMethod } from '@polkadot/api/rx';
|
||||
|
||||
import Abi from '../Abi';
|
||||
import Blueprint from '../base/Blueprint';
|
||||
|
||||
export default class RxBlueprint extends Blueprint<'rxjs'> {
|
||||
constructor (api: ApiRx, abi: AnyJson | Abi, codeHash: string | Hash) {
|
||||
super(api, abi, codeHash, decorateMethod);
|
||||
}
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { AnyJson } from '@polkadot/types/types';
|
||||
|
||||
import { ApiRx } from '@polkadot/api';
|
||||
import { decorateMethod } from '@polkadot/api/rx';
|
||||
|
||||
import Abi from '../Abi';
|
||||
import Code from '../base/Code';
|
||||
|
||||
export default class RxCode extends Code<'rxjs'> {
|
||||
constructor (api: ApiRx, abi: AnyJson | Abi, wasm: Uint8Array | string | Buffer) {
|
||||
super(api, abi, wasm, decorateMethod);
|
||||
}
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { AccountId } from '@polkadot/types/interfaces';
|
||||
import { AnyJson } from '@polkadot/types/types';
|
||||
|
||||
import { ApiRx } from '@polkadot/api';
|
||||
import { decorateMethod } from '@polkadot/api/rx';
|
||||
|
||||
import Abi from '../Abi';
|
||||
import Contract from '../base/Contract';
|
||||
|
||||
export default class RxContract extends Contract<'rxjs'> {
|
||||
constructor (api: ApiRx, abi: AnyJson | Abi, address: string | AccountId) {
|
||||
super(api, abi, address, decorateMethod);
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
|
||||
// Copyright 2017-2021 @polkadot/api-contract authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
export { default as BlueprintRx } from './RxBlueprint';
|
||||
export { default as CodeRx } from './RxCode';
|
||||
export { default as ContractRx } from './RxContract';
|
||||
export { Blueprint } from './Blueprint';
|
||||
export { Code } from './Code';
|
||||
export { Contract } from './Contract';
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
// Copyright 2017-2021 @polkadot/api-contract authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { BlueprintSubmittableResult as BaseBlueprintSubmittableResult, CodeSubmittableResult as BaseCodeSubmittableResult } from '../base';
|
||||
|
||||
export type BlueprintSubmittableResult = BaseBlueprintSubmittableResult<'promise'>;
|
||||
export type CodeSubmittableResult = BaseCodeSubmittableResult<'promise'>;
|
||||
@@ -1,12 +1,13 @@
|
||||
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
|
||||
// Copyright 2017-2021 @polkadot/api-contract authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { ApiTypes } from '@polkadot/api/types';
|
||||
import { ContractExecResult, InkSelector } from '@polkadot/types/interfaces';
|
||||
import { Codec, TypeDef } from '@polkadot/types/types';
|
||||
|
||||
import ApiBase from '@polkadot/api/base';
|
||||
import Abi from './Abi';
|
||||
import type BN from 'bn.js';
|
||||
import type { ApiBase } from '@polkadot/api/base';
|
||||
import type { ApiTypes } from '@polkadot/api/types';
|
||||
import type { Text, u64 } from '@polkadot/types';
|
||||
import type { ContractExecResultResult, ContractSelector } from '@polkadot/types/interfaces';
|
||||
import type { Codec, CodecArg, TypeDef } from '@polkadot/types/types';
|
||||
import type { Abi } from '.';
|
||||
|
||||
export interface ContractBase<ApiType extends ApiTypes> {
|
||||
readonly abi: Abi;
|
||||
@@ -16,21 +17,31 @@ export interface ContractBase<ApiType extends ApiTypes> {
|
||||
messages: AbiMessage[];
|
||||
}
|
||||
|
||||
export interface AbiMessageParam {
|
||||
export interface AbiParam {
|
||||
name: string;
|
||||
type: TypeDef;
|
||||
}
|
||||
|
||||
export interface AbiMessage {
|
||||
args: AbiMessageParam[];
|
||||
export interface AbiEvent {
|
||||
args: AbiParam[];
|
||||
docs: string[];
|
||||
fromU8a: (data: Uint8Array) => DecodedEvent;
|
||||
identifier: string;
|
||||
index: number;
|
||||
}
|
||||
|
||||
export interface AbiMessage {
|
||||
args: AbiParam[];
|
||||
docs: string[];
|
||||
fromU8a: (data: Uint8Array) => DecodedMessage;
|
||||
identifier: string;
|
||||
index: number;
|
||||
isConstructor?: boolean;
|
||||
isMutating?: boolean;
|
||||
isPayable?: boolean;
|
||||
returnType?: TypeDef | null;
|
||||
selector: InkSelector;
|
||||
selector: ContractSelector;
|
||||
toU8a: (params: CodecArg[], additional?: Uint8Array) => Uint8Array;
|
||||
}
|
||||
|
||||
export type AbiConstructor = AbiMessage;
|
||||
@@ -41,6 +52,29 @@ export interface InterfaceContractCalls {
|
||||
}
|
||||
|
||||
export interface ContractCallOutcome {
|
||||
debugMessage: Text;
|
||||
gasConsumed: u64;
|
||||
output: Codec | null;
|
||||
result: ContractExecResult;
|
||||
result: ContractExecResultResult;
|
||||
}
|
||||
|
||||
export interface DecodedEvent {
|
||||
args: Codec[];
|
||||
event: AbiEvent;
|
||||
}
|
||||
|
||||
export interface DecodedMessage {
|
||||
args: Codec[];
|
||||
message: AbiMessage;
|
||||
}
|
||||
|
||||
export interface BlueprintOptions {
|
||||
gasLimit?: BigInt | string | number | BN;
|
||||
salt?: Uint8Array | string | null;
|
||||
value?: BigInt | string | number | BN;
|
||||
}
|
||||
|
||||
export interface ContractOptions {
|
||||
gasLimit?: BigInt | BN | string | number;
|
||||
value?: BigInt | BN | string | number;
|
||||
}
|
||||
|
||||
@@ -1,46 +1,43 @@
|
||||
// Copyright 2017-2020 @polkadot/rpc-core authors & contributors
|
||||
// Copyright 2017-2021 @polkadot/rpc-contract authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { SubmittableResult } from '@polkadot/api';
|
||||
import { EventRecord } from '@polkadot/types/interfaces';
|
||||
import { Codec, CodecArg, Registry, TypeDef } from '@polkadot/types/types';
|
||||
import { AbiConstructor, AbiMessage } from './types';
|
||||
import type { SubmittableResult } from '@polkadot/api';
|
||||
import type { Raw } from '@polkadot/types';
|
||||
import type { EventRecord } from '@polkadot/types/interfaces';
|
||||
import type { Codec, CodecArg, Registry, TypeDef } from '@polkadot/types/types';
|
||||
import type { BlueprintOptions, ContractOptions } from './types';
|
||||
|
||||
import { Raw, createClass, createTypeUnsafe, encodeTypeDef } from '@polkadot/types';
|
||||
import BN from 'bn.js';
|
||||
|
||||
import { assert, compactAddLength } from '@polkadot/util';
|
||||
import { createTypeUnsafe } from '@polkadot/types/create';
|
||||
import { isBigInt, isBn, isNumber, isString } from '@polkadot/util';
|
||||
|
||||
type ContractEvents = 'CodeStored' | 'ContractEmitted' | 'ContractExecution' | 'Instantiated';
|
||||
|
||||
type TOptions = BlueprintOptions | ContractOptions;
|
||||
|
||||
export function formatData (registry: Registry, data: Raw, { type }: TypeDef): Codec {
|
||||
return createTypeUnsafe(registry, type, [data], true);
|
||||
return createTypeUnsafe(registry, type, [data], { isPedantic: true });
|
||||
}
|
||||
|
||||
export function applyOnEvent <T> (result: SubmittableResult, type: 'CodeStored' | 'Instantiated', fn: (record: EventRecord) => T): T | undefined {
|
||||
export function applyOnEvent <T> (result: SubmittableResult, types: ContractEvents[], fn: (records: EventRecord[]) => T): T | undefined {
|
||||
if (result.isInBlock || result.isFinalized) {
|
||||
const record = result.findRecord('contracts', type);
|
||||
const records = result.filterRecords('contracts', types);
|
||||
|
||||
if (record) {
|
||||
return fn(record);
|
||||
if (records.length) {
|
||||
return fn(records);
|
||||
}
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
export function encodeMessage (registry: Registry, message: AbiMessage | AbiConstructor, params: CodecArg[]): Uint8Array {
|
||||
assert(message, 'Attempted to call an invalid contract message');
|
||||
assert(params.length === message.args.length, `Expected ${message.args.length} arguments to contract message '${message.identifier}', found ${params.length}`);
|
||||
|
||||
const Clazz = createClass(registry, JSON.stringify(
|
||||
message.args.reduce((r: Record<string, any>, { name, type }): Record<string, any> => {
|
||||
r[name] = type.displayName || encodeTypeDef(type);
|
||||
|
||||
return r;
|
||||
}, { __selector: 'InkSelector' })
|
||||
));
|
||||
|
||||
return compactAddLength(new Clazz(registry, message.args.reduce((r: Record<string, CodecArg>, { name }, index): Record<string, CodecArg> => {
|
||||
r[name] = params[index];
|
||||
|
||||
return r;
|
||||
}, { __selector: message.selector })).toU8a());
|
||||
export function isOptions <T> (options: BigInt | string | number | BN | T): options is T {
|
||||
return !(isBn(options) || isBigInt(options) || isNumber(options) || isString(options));
|
||||
}
|
||||
|
||||
export function extractOptions <T extends TOptions> (value: BigInt | string | number | BN, params: CodecArg[]): [T, CodecArg[]] {
|
||||
const gasLimit = params.shift() as BN;
|
||||
|
||||
return [{ gasLimit, value } as T, params];
|
||||
}
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
[
|
||||
{
|
||||
"displayName": "AccountId",
|
||||
"namespace": "ink_env::types",
|
||||
"info": 6,
|
||||
"type": "AccountId"
|
||||
},
|
||||
{
|
||||
"info": 12,
|
||||
"length": 32,
|
||||
"sub": {
|
||||
"info": 6,
|
||||
"type": "u8"
|
||||
},
|
||||
"type": "[u8;32]"
|
||||
},
|
||||
{
|
||||
"info": 6,
|
||||
"type": "u8"
|
||||
},
|
||||
{
|
||||
"info": 6,
|
||||
"type": "i32"
|
||||
},
|
||||
{
|
||||
"displayName": "Hash",
|
||||
"namespace": "ink_env::types",
|
||||
"info": 6,
|
||||
"type": "Hash"
|
||||
}
|
||||
]
|
||||
+6
-61
@@ -29,15 +29,6 @@
|
||||
{
|
||||
"displayName": "Entry",
|
||||
"namespace": "ink_storage::collections::stash",
|
||||
"params": [
|
||||
{
|
||||
"displayName": "Hash",
|
||||
"namespace": "ink_env::types",
|
||||
"info": 6,
|
||||
"type": "Hash"
|
||||
}
|
||||
],
|
||||
"info": 3,
|
||||
"sub": [
|
||||
{
|
||||
"displayName": "VacantEntry",
|
||||
@@ -66,6 +57,7 @@
|
||||
"name": "Occupied"
|
||||
}
|
||||
],
|
||||
"info": 3,
|
||||
"type": "{\"_enum\":{\"Vacant\":\"VacantEntry\",\"Occupied\":\"Hash\"}}"
|
||||
},
|
||||
{
|
||||
@@ -108,15 +100,6 @@
|
||||
{
|
||||
"displayName": "ValueEntry",
|
||||
"namespace": "ink_storage::collections::hashmap",
|
||||
"params": [
|
||||
{
|
||||
"displayName": "AccountId",
|
||||
"namespace": "ink_env::types",
|
||||
"info": 6,
|
||||
"type": "AccountId"
|
||||
}
|
||||
],
|
||||
"info": 9,
|
||||
"sub": [
|
||||
{
|
||||
"displayName": "AccountId",
|
||||
@@ -131,6 +114,7 @@
|
||||
"name": "key_index"
|
||||
}
|
||||
],
|
||||
"info": 9,
|
||||
"type": "{\"value\":\"AccountId\",\"key_index\":\"u32\"}"
|
||||
},
|
||||
{
|
||||
@@ -141,38 +125,6 @@
|
||||
},
|
||||
{
|
||||
"displayName": "Result",
|
||||
"params": [
|
||||
{
|
||||
"info": 10,
|
||||
"sub": [],
|
||||
"type": "()"
|
||||
},
|
||||
{
|
||||
"displayName": "Error",
|
||||
"namespace": "dns::dns",
|
||||
"info": 3,
|
||||
"sub": [
|
||||
{
|
||||
"ext": {
|
||||
"discriminant": 0
|
||||
},
|
||||
"info": 6,
|
||||
"name": "NameAlreadyExists",
|
||||
"type": "Null"
|
||||
},
|
||||
{
|
||||
"ext": {
|
||||
"discriminant": 1
|
||||
},
|
||||
"info": 6,
|
||||
"name": "CallerIsNotOwner",
|
||||
"type": "Null"
|
||||
}
|
||||
],
|
||||
"type": "{ _enum: [\"NameAlreadyExists\", \"CallerIsNotOwner\"] }"
|
||||
}
|
||||
],
|
||||
"info": 7,
|
||||
"sub": [
|
||||
{
|
||||
"name": "Ok",
|
||||
@@ -203,9 +155,10 @@
|
||||
"type": "Null"
|
||||
}
|
||||
],
|
||||
"type": "{ _enum: [\"NameAlreadyExists\", \"CallerIsNotOwner\"] }"
|
||||
"type": "{\"_enum\":[\"NameAlreadyExists\",\"CallerIsNotOwner\"]}"
|
||||
}
|
||||
],
|
||||
"info": 7,
|
||||
"type": "Result<(), Error>"
|
||||
},
|
||||
{
|
||||
@@ -235,25 +188,17 @@
|
||||
"type": "Null"
|
||||
}
|
||||
],
|
||||
"type": "{ _enum: [\"NameAlreadyExists\", \"CallerIsNotOwner\"] }"
|
||||
"type": "{\"_enum\":[\"NameAlreadyExists\",\"CallerIsNotOwner\"]}"
|
||||
},
|
||||
{
|
||||
"displayName": "Option",
|
||||
"params": [
|
||||
{
|
||||
"displayName": "AccountId",
|
||||
"namespace": "ink_env::types",
|
||||
"info": 6,
|
||||
"type": "AccountId"
|
||||
}
|
||||
],
|
||||
"info": 5,
|
||||
"sub": {
|
||||
"displayName": "AccountId",
|
||||
"namespace": "ink_env::types",
|
||||
"info": 6,
|
||||
"type": "AccountId"
|
||||
},
|
||||
"info": 5,
|
||||
"type": "Option<AccountId>"
|
||||
}
|
||||
]
|
||||
+4
-46
@@ -33,15 +33,6 @@
|
||||
{
|
||||
"displayName": "Entry",
|
||||
"namespace": "ink_storage::collections::stash",
|
||||
"params": [
|
||||
{
|
||||
"displayName": "AccountId",
|
||||
"namespace": "ink_env::types",
|
||||
"info": 6,
|
||||
"type": "AccountId"
|
||||
}
|
||||
],
|
||||
"info": 3,
|
||||
"sub": [
|
||||
{
|
||||
"displayName": "VacantEntry",
|
||||
@@ -70,6 +61,7 @@
|
||||
"name": "Occupied"
|
||||
}
|
||||
],
|
||||
"info": 3,
|
||||
"type": "{\"_enum\":{\"Vacant\":\"VacantEntry\",\"Occupied\":\"AccountId\"}}"
|
||||
},
|
||||
{
|
||||
@@ -112,13 +104,6 @@
|
||||
{
|
||||
"displayName": "ValueEntry",
|
||||
"namespace": "ink_storage::collections::hashmap",
|
||||
"params": [
|
||||
{
|
||||
"info": 6,
|
||||
"type": "u128"
|
||||
}
|
||||
],
|
||||
"info": 9,
|
||||
"sub": [
|
||||
{
|
||||
"info": 6,
|
||||
@@ -131,32 +116,12 @@
|
||||
"name": "key_index"
|
||||
}
|
||||
],
|
||||
"info": 9,
|
||||
"type": "{\"value\":\"u128\",\"key_index\":\"u32\"}"
|
||||
},
|
||||
{
|
||||
"displayName": "Entry",
|
||||
"namespace": "ink_storage::collections::stash",
|
||||
"params": [
|
||||
{
|
||||
"info": 10,
|
||||
"sub": [
|
||||
{
|
||||
"displayName": "AccountId",
|
||||
"namespace": "ink_env::types",
|
||||
"info": 6,
|
||||
"type": "AccountId"
|
||||
},
|
||||
{
|
||||
"displayName": "AccountId",
|
||||
"namespace": "ink_env::types",
|
||||
"info": 6,
|
||||
"type": "AccountId"
|
||||
}
|
||||
],
|
||||
"type": "(AccountId, AccountId)"
|
||||
}
|
||||
],
|
||||
"info": 3,
|
||||
"sub": [
|
||||
{
|
||||
"displayName": "VacantEntry",
|
||||
@@ -197,6 +162,7 @@
|
||||
"name": "Occupied"
|
||||
}
|
||||
],
|
||||
"info": 3,
|
||||
"type": "{\"_enum\":{\"Vacant\":\"VacantEntry\",\"Occupied\":\"(AccountId, AccountId)\"}}"
|
||||
},
|
||||
{
|
||||
@@ -223,21 +189,13 @@
|
||||
},
|
||||
{
|
||||
"displayName": "Option",
|
||||
"params": [
|
||||
{
|
||||
"displayName": "AccountId",
|
||||
"namespace": "ink_env::types",
|
||||
"info": 6,
|
||||
"type": "AccountId"
|
||||
}
|
||||
],
|
||||
"info": 5,
|
||||
"sub": {
|
||||
"displayName": "AccountId",
|
||||
"namespace": "ink_env::types",
|
||||
"info": 6,
|
||||
"type": "AccountId"
|
||||
},
|
||||
"info": 5,
|
||||
"type": "Option<AccountId>"
|
||||
}
|
||||
]
|
||||
+10
-151
@@ -29,13 +29,6 @@
|
||||
{
|
||||
"displayName": "Entry",
|
||||
"namespace": "ink_storage::collections::stash",
|
||||
"params": [
|
||||
{
|
||||
"info": 6,
|
||||
"type": "u32"
|
||||
}
|
||||
],
|
||||
"info": 3,
|
||||
"sub": [
|
||||
{
|
||||
"displayName": "VacantEntry",
|
||||
@@ -62,6 +55,7 @@
|
||||
"name": "Occupied"
|
||||
}
|
||||
],
|
||||
"info": 3,
|
||||
"type": "{\"_enum\":{\"Vacant\":\"VacantEntry\",\"Occupied\":\"u32\"}}"
|
||||
},
|
||||
{
|
||||
@@ -85,15 +79,6 @@
|
||||
{
|
||||
"displayName": "ValueEntry",
|
||||
"namespace": "ink_storage::collections::hashmap",
|
||||
"params": [
|
||||
{
|
||||
"displayName": "AccountId",
|
||||
"namespace": "ink_env::types",
|
||||
"info": 6,
|
||||
"type": "AccountId"
|
||||
}
|
||||
],
|
||||
"info": 9,
|
||||
"sub": [
|
||||
{
|
||||
"displayName": "AccountId",
|
||||
@@ -108,6 +93,7 @@
|
||||
"name": "key_index"
|
||||
}
|
||||
],
|
||||
"info": 9,
|
||||
"type": "{\"value\":\"AccountId\",\"key_index\":\"u32\"}"
|
||||
},
|
||||
{
|
||||
@@ -132,15 +118,6 @@
|
||||
{
|
||||
"displayName": "Entry",
|
||||
"namespace": "ink_storage::collections::stash",
|
||||
"params": [
|
||||
{
|
||||
"displayName": "AccountId",
|
||||
"namespace": "ink_env::types",
|
||||
"info": 6,
|
||||
"type": "AccountId"
|
||||
}
|
||||
],
|
||||
"info": 3,
|
||||
"sub": [
|
||||
{
|
||||
"displayName": "VacantEntry",
|
||||
@@ -169,18 +146,12 @@
|
||||
"name": "Occupied"
|
||||
}
|
||||
],
|
||||
"info": 3,
|
||||
"type": "{\"_enum\":{\"Vacant\":\"VacantEntry\",\"Occupied\":\"AccountId\"}}"
|
||||
},
|
||||
{
|
||||
"displayName": "ValueEntry",
|
||||
"namespace": "ink_storage::collections::hashmap",
|
||||
"params": [
|
||||
{
|
||||
"info": 6,
|
||||
"type": "u32"
|
||||
}
|
||||
],
|
||||
"info": 9,
|
||||
"sub": [
|
||||
{
|
||||
"info": 6,
|
||||
@@ -193,32 +164,12 @@
|
||||
"name": "key_index"
|
||||
}
|
||||
],
|
||||
"info": 9,
|
||||
"type": "{\"value\":\"u32\",\"key_index\":\"u32\"}"
|
||||
},
|
||||
{
|
||||
"displayName": "Entry",
|
||||
"namespace": "ink_storage::collections::stash",
|
||||
"params": [
|
||||
{
|
||||
"info": 10,
|
||||
"sub": [
|
||||
{
|
||||
"displayName": "AccountId",
|
||||
"namespace": "ink_env::types",
|
||||
"info": 6,
|
||||
"type": "AccountId"
|
||||
},
|
||||
{
|
||||
"displayName": "AccountId",
|
||||
"namespace": "ink_env::types",
|
||||
"info": 6,
|
||||
"type": "AccountId"
|
||||
}
|
||||
],
|
||||
"type": "(AccountId, AccountId)"
|
||||
}
|
||||
],
|
||||
"info": 3,
|
||||
"sub": [
|
||||
{
|
||||
"displayName": "VacantEntry",
|
||||
@@ -259,6 +210,7 @@
|
||||
"name": "Occupied"
|
||||
}
|
||||
],
|
||||
"info": 3,
|
||||
"type": "{\"_enum\":{\"Vacant\":\"VacantEntry\",\"Occupied\":\"(AccountId, AccountId)\"}}"
|
||||
},
|
||||
{
|
||||
@@ -282,13 +234,6 @@
|
||||
{
|
||||
"displayName": "ValueEntry",
|
||||
"namespace": "ink_storage::collections::hashmap",
|
||||
"params": [
|
||||
{
|
||||
"info": 6,
|
||||
"type": "bool"
|
||||
}
|
||||
],
|
||||
"info": 9,
|
||||
"sub": [
|
||||
{
|
||||
"info": 6,
|
||||
@@ -301,6 +246,7 @@
|
||||
"name": "key_index"
|
||||
}
|
||||
],
|
||||
"info": 9,
|
||||
"type": "{\"value\":\"bool\",\"key_index\":\"u32\"}"
|
||||
},
|
||||
{
|
||||
@@ -309,105 +255,17 @@
|
||||
},
|
||||
{
|
||||
"displayName": "Option",
|
||||
"params": [
|
||||
{
|
||||
"displayName": "AccountId",
|
||||
"namespace": "ink_env::types",
|
||||
"info": 6,
|
||||
"type": "AccountId"
|
||||
}
|
||||
],
|
||||
"info": 5,
|
||||
"sub": {
|
||||
"displayName": "AccountId",
|
||||
"namespace": "ink_env::types",
|
||||
"info": 6,
|
||||
"type": "AccountId"
|
||||
},
|
||||
"info": 5,
|
||||
"type": "Option<AccountId>"
|
||||
},
|
||||
{
|
||||
"displayName": "Result",
|
||||
"params": [
|
||||
{
|
||||
"info": 10,
|
||||
"sub": [],
|
||||
"type": "()"
|
||||
},
|
||||
{
|
||||
"displayName": "Error",
|
||||
"namespace": "erc721::erc721",
|
||||
"info": 3,
|
||||
"sub": [
|
||||
{
|
||||
"ext": {
|
||||
"discriminant": 0
|
||||
},
|
||||
"info": 6,
|
||||
"name": "NotOwner",
|
||||
"type": "Null"
|
||||
},
|
||||
{
|
||||
"ext": {
|
||||
"discriminant": 1
|
||||
},
|
||||
"info": 6,
|
||||
"name": "NotApproved",
|
||||
"type": "Null"
|
||||
},
|
||||
{
|
||||
"ext": {
|
||||
"discriminant": 2
|
||||
},
|
||||
"info": 6,
|
||||
"name": "TokenExists",
|
||||
"type": "Null"
|
||||
},
|
||||
{
|
||||
"ext": {
|
||||
"discriminant": 3
|
||||
},
|
||||
"info": 6,
|
||||
"name": "TokenNotFound",
|
||||
"type": "Null"
|
||||
},
|
||||
{
|
||||
"ext": {
|
||||
"discriminant": 4
|
||||
},
|
||||
"info": 6,
|
||||
"name": "CannotInsert",
|
||||
"type": "Null"
|
||||
},
|
||||
{
|
||||
"ext": {
|
||||
"discriminant": 5
|
||||
},
|
||||
"info": 6,
|
||||
"name": "CannotRemove",
|
||||
"type": "Null"
|
||||
},
|
||||
{
|
||||
"ext": {
|
||||
"discriminant": 6
|
||||
},
|
||||
"info": 6,
|
||||
"name": "CannotFetchValue",
|
||||
"type": "Null"
|
||||
},
|
||||
{
|
||||
"ext": {
|
||||
"discriminant": 7
|
||||
},
|
||||
"info": 6,
|
||||
"name": "NotAllowed",
|
||||
"type": "Null"
|
||||
}
|
||||
],
|
||||
"type": "{ _enum: [\"NotOwner\", \"NotApproved\", \"TokenExists\", \"TokenNotFound\", \"CannotInsert\", \"CannotRemove\", \"CannotFetchValue\", \"NotAllowed\"] }"
|
||||
}
|
||||
],
|
||||
"info": 7,
|
||||
"sub": [
|
||||
{
|
||||
"name": "Ok",
|
||||
@@ -486,9 +344,10 @@
|
||||
"type": "Null"
|
||||
}
|
||||
],
|
||||
"type": "{ _enum: [\"NotOwner\", \"NotApproved\", \"TokenExists\", \"TokenNotFound\", \"CannotInsert\", \"CannotRemove\", \"CannotFetchValue\", \"NotAllowed\"] }"
|
||||
"type": "{\"_enum\":[\"NotOwner\",\"NotApproved\",\"TokenExists\",\"TokenNotFound\",\"CannotInsert\",\"CannotRemove\",\"CannotFetchValue\",\"NotAllowed\"]}"
|
||||
}
|
||||
],
|
||||
"info": 7,
|
||||
"type": "Result<(), Error>"
|
||||
},
|
||||
{
|
||||
@@ -566,6 +425,6 @@
|
||||
"type": "Null"
|
||||
}
|
||||
],
|
||||
"type": "{ _enum: [\"NotOwner\", \"NotApproved\", \"TokenExists\", \"TokenNotFound\", \"CannotInsert\", \"CannotRemove\", \"CannotFetchValue\", \"NotAllowed\"] }"
|
||||
"type": "{\"_enum\":[\"NotOwner\",\"NotApproved\",\"TokenExists\",\"TokenNotFound\",\"CannotInsert\",\"CannotRemove\",\"CannotFetchValue\",\"NotAllowed\"]}"
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,6 @@
|
||||
[
|
||||
{
|
||||
"info": 6,
|
||||
"type": "bool"
|
||||
}
|
||||
]
|
||||
+15
-181
@@ -29,25 +29,6 @@
|
||||
{
|
||||
"displayName": "Entry",
|
||||
"namespace": "ink_storage::collections::stash",
|
||||
"params": [
|
||||
{
|
||||
"info": 10,
|
||||
"sub": [
|
||||
{
|
||||
"info": 6,
|
||||
"type": "u32"
|
||||
},
|
||||
{
|
||||
"displayName": "AccountId",
|
||||
"namespace": "ink_env::types",
|
||||
"info": 6,
|
||||
"type": "AccountId"
|
||||
}
|
||||
],
|
||||
"type": "(u32, AccountId)"
|
||||
}
|
||||
],
|
||||
"info": 3,
|
||||
"sub": [
|
||||
{
|
||||
"displayName": "VacantEntry",
|
||||
@@ -86,6 +67,7 @@
|
||||
"name": "Occupied"
|
||||
}
|
||||
],
|
||||
"info": 3,
|
||||
"type": "{\"_enum\":{\"Vacant\":\"VacantEntry\",\"Occupied\":\"(u32, AccountId)\"}}"
|
||||
},
|
||||
{
|
||||
@@ -144,14 +126,6 @@
|
||||
{
|
||||
"displayName": "ValueEntry",
|
||||
"namespace": "ink_storage::collections::hashmap",
|
||||
"params": [
|
||||
{
|
||||
"info": 10,
|
||||
"sub": [],
|
||||
"type": "()"
|
||||
}
|
||||
],
|
||||
"info": 9,
|
||||
"sub": [
|
||||
{
|
||||
"info": 10,
|
||||
@@ -165,6 +139,7 @@
|
||||
"name": "key_index"
|
||||
}
|
||||
],
|
||||
"info": 9,
|
||||
"type": "{\"value\":\"()\",\"key_index\":\"u32\"}"
|
||||
},
|
||||
{
|
||||
@@ -175,13 +150,6 @@
|
||||
{
|
||||
"displayName": "Entry",
|
||||
"namespace": "ink_storage::collections::stash",
|
||||
"params": [
|
||||
{
|
||||
"info": 6,
|
||||
"type": "u32"
|
||||
}
|
||||
],
|
||||
"info": 3,
|
||||
"sub": [
|
||||
{
|
||||
"displayName": "VacantEntry",
|
||||
@@ -208,18 +176,12 @@
|
||||
"name": "Occupied"
|
||||
}
|
||||
],
|
||||
"info": 3,
|
||||
"type": "{\"_enum\":{\"Vacant\":\"VacantEntry\",\"Occupied\":\"u32\"}}"
|
||||
},
|
||||
{
|
||||
"displayName": "ValueEntry",
|
||||
"namespace": "ink_storage::collections::hashmap",
|
||||
"params": [
|
||||
{
|
||||
"info": 6,
|
||||
"type": "u32"
|
||||
}
|
||||
],
|
||||
"info": 9,
|
||||
"sub": [
|
||||
{
|
||||
"info": 6,
|
||||
@@ -232,58 +194,12 @@
|
||||
"name": "key_index"
|
||||
}
|
||||
],
|
||||
"info": 9,
|
||||
"type": "{\"value\":\"u32\",\"key_index\":\"u32\"}"
|
||||
},
|
||||
{
|
||||
"displayName": "Entry",
|
||||
"namespace": "ink_storage::collections::stash",
|
||||
"params": [
|
||||
{
|
||||
"displayName": "Transaction",
|
||||
"namespace": "multisig_plain::multisig_plain",
|
||||
"info": 9,
|
||||
"sub": [
|
||||
{
|
||||
"displayName": "AccountId",
|
||||
"namespace": "ink_env::types",
|
||||
"info": 6,
|
||||
"type": "AccountId",
|
||||
"name": "callee"
|
||||
},
|
||||
{
|
||||
"info": 12,
|
||||
"length": 4,
|
||||
"sub": {
|
||||
"info": 6,
|
||||
"type": "u8"
|
||||
},
|
||||
"type": "[u8;4]",
|
||||
"name": "selector"
|
||||
},
|
||||
{
|
||||
"info": 11,
|
||||
"sub": {
|
||||
"info": 6,
|
||||
"type": "u8"
|
||||
},
|
||||
"type": "Vec<u8>",
|
||||
"name": "input"
|
||||
},
|
||||
{
|
||||
"info": 6,
|
||||
"type": "u128",
|
||||
"name": "transferred_value"
|
||||
},
|
||||
{
|
||||
"info": 6,
|
||||
"type": "u64",
|
||||
"name": "gas_limit"
|
||||
}
|
||||
],
|
||||
"type": "{\"callee\":\"AccountId\",\"selector\":\"[u8;4]\",\"input\":\"Vec<u8>\",\"transferred_value\":\"u128\",\"gas_limit\":\"u64\"}"
|
||||
}
|
||||
],
|
||||
"info": 3,
|
||||
"sub": [
|
||||
{
|
||||
"displayName": "VacantEntry",
|
||||
@@ -350,6 +266,7 @@
|
||||
"name": "Occupied"
|
||||
}
|
||||
],
|
||||
"info": 3,
|
||||
"type": "{\"_enum\":{\"Vacant\":\"VacantEntry\",\"Occupied\":\"Transaction\"}}"
|
||||
},
|
||||
{
|
||||
@@ -424,15 +341,6 @@
|
||||
{
|
||||
"displayName": "Entry",
|
||||
"namespace": "ink_storage::collections::stash",
|
||||
"params": [
|
||||
{
|
||||
"displayName": "AccountId",
|
||||
"namespace": "ink_env::types",
|
||||
"info": 6,
|
||||
"type": "AccountId"
|
||||
}
|
||||
],
|
||||
"info": 3,
|
||||
"sub": [
|
||||
{
|
||||
"displayName": "VacantEntry",
|
||||
@@ -461,6 +369,7 @@
|
||||
"name": "Occupied"
|
||||
}
|
||||
],
|
||||
"info": 3,
|
||||
"type": "{\"_enum\":{\"Vacant\":\"VacantEntry\",\"Occupied\":\"AccountId\"}}"
|
||||
},
|
||||
{
|
||||
@@ -488,7 +397,8 @@
|
||||
{
|
||||
"info": 10,
|
||||
"sub": [],
|
||||
"name": "Confirmed"
|
||||
"name": "Confirmed",
|
||||
"type": "()"
|
||||
},
|
||||
{
|
||||
"info": 6,
|
||||
@@ -509,7 +419,8 @@
|
||||
{
|
||||
"info": 10,
|
||||
"sub": [],
|
||||
"name": "Confirmed"
|
||||
"name": "Confirmed",
|
||||
"type": "()"
|
||||
},
|
||||
{
|
||||
"info": 6,
|
||||
@@ -521,19 +432,6 @@
|
||||
},
|
||||
{
|
||||
"displayName": "Result",
|
||||
"params": [
|
||||
{
|
||||
"info": 10,
|
||||
"sub": [],
|
||||
"type": "()"
|
||||
},
|
||||
{
|
||||
"info": 10,
|
||||
"sub": [],
|
||||
"type": "()"
|
||||
}
|
||||
],
|
||||
"info": 7,
|
||||
"sub": [
|
||||
{
|
||||
"name": "Ok",
|
||||
@@ -548,26 +446,11 @@
|
||||
"type": "()"
|
||||
}
|
||||
],
|
||||
"info": 7,
|
||||
"type": "Result<(), ()>"
|
||||
},
|
||||
{
|
||||
"displayName": "Result",
|
||||
"params": [
|
||||
{
|
||||
"info": 11,
|
||||
"sub": {
|
||||
"info": 6,
|
||||
"type": "u8"
|
||||
},
|
||||
"type": "Vec<u8>"
|
||||
},
|
||||
{
|
||||
"info": 10,
|
||||
"sub": [],
|
||||
"type": "()"
|
||||
}
|
||||
],
|
||||
"info": 7,
|
||||
"sub": [
|
||||
{
|
||||
"name": "Ok",
|
||||
@@ -585,56 +468,15 @@
|
||||
"type": "()"
|
||||
}
|
||||
],
|
||||
"info": 7,
|
||||
"type": "Result<Vec<u8>, ()>"
|
||||
},
|
||||
{
|
||||
"displayName": "Result",
|
||||
"params": [
|
||||
{
|
||||
"displayName": "Option",
|
||||
"params": [
|
||||
{
|
||||
"info": 11,
|
||||
"sub": {
|
||||
"info": 6,
|
||||
"type": "u8"
|
||||
},
|
||||
"type": "Vec<u8>"
|
||||
}
|
||||
],
|
||||
"info": 5,
|
||||
"sub": {
|
||||
"info": 11,
|
||||
"sub": {
|
||||
"info": 6,
|
||||
"type": "u8"
|
||||
},
|
||||
"type": "Vec<u8>"
|
||||
},
|
||||
"type": "Option<Vec<u8>>"
|
||||
},
|
||||
{
|
||||
"info": 10,
|
||||
"sub": [],
|
||||
"type": "()"
|
||||
}
|
||||
],
|
||||
"info": 7,
|
||||
"sub": [
|
||||
{
|
||||
"name": "Ok",
|
||||
"displayName": "Option",
|
||||
"params": [
|
||||
{
|
||||
"info": 11,
|
||||
"sub": {
|
||||
"info": 6,
|
||||
"type": "u8"
|
||||
},
|
||||
"type": "Vec<u8>"
|
||||
}
|
||||
],
|
||||
"info": 5,
|
||||
"sub": {
|
||||
"info": 11,
|
||||
"sub": {
|
||||
@@ -643,6 +485,7 @@
|
||||
},
|
||||
"type": "Vec<u8>"
|
||||
},
|
||||
"info": 5,
|
||||
"type": "Option<Vec<u8>>"
|
||||
},
|
||||
{
|
||||
@@ -652,21 +495,11 @@
|
||||
"type": "()"
|
||||
}
|
||||
],
|
||||
"info": 7,
|
||||
"type": "Result<Option<Vec<u8>>, ()>"
|
||||
},
|
||||
{
|
||||
"displayName": "Option",
|
||||
"params": [
|
||||
{
|
||||
"info": 11,
|
||||
"sub": {
|
||||
"info": 6,
|
||||
"type": "u8"
|
||||
},
|
||||
"type": "Vec<u8>"
|
||||
}
|
||||
],
|
||||
"info": 5,
|
||||
"sub": {
|
||||
"info": 11,
|
||||
"sub": {
|
||||
@@ -675,6 +508,7 @@
|
||||
},
|
||||
"type": "Vec<u8>"
|
||||
},
|
||||
"info": 5,
|
||||
"type": "Option<Vec<u8>>"
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,6 @@
|
||||
[
|
||||
{
|
||||
"info": 6,
|
||||
"type": "u256"
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,28 @@
|
||||
[
|
||||
{
|
||||
"info": 6,
|
||||
"type": "u256"
|
||||
},
|
||||
{
|
||||
"info": 6,
|
||||
"type": "u8"
|
||||
},
|
||||
{
|
||||
"info": 12,
|
||||
"length": 32,
|
||||
"sub": {
|
||||
"info": 6,
|
||||
"type": "u8"
|
||||
},
|
||||
"type": "[u8;32]"
|
||||
},
|
||||
{
|
||||
"displayName": "AccountId",
|
||||
"info": 6,
|
||||
"type": "AccountId"
|
||||
},
|
||||
{
|
||||
"info": 6,
|
||||
"type": "Text"
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,422 @@
|
||||
[
|
||||
{
|
||||
"info": 6,
|
||||
"type": "i32"
|
||||
},
|
||||
{
|
||||
"info": 6,
|
||||
"type": "u32"
|
||||
},
|
||||
{
|
||||
"info": 6,
|
||||
"type": "u8"
|
||||
},
|
||||
{
|
||||
"displayName": "Variant",
|
||||
"namespace": "enum_example::enum_example",
|
||||
"info": 3,
|
||||
"sub": [
|
||||
{
|
||||
"info": 10,
|
||||
"sub": [],
|
||||
"name": "None",
|
||||
"type": "()"
|
||||
},
|
||||
{
|
||||
"displayName": "Weekday",
|
||||
"namespace": "enum_example::enum_example",
|
||||
"info": 3,
|
||||
"sub": [
|
||||
{
|
||||
"ext": {
|
||||
"discriminant": 0
|
||||
},
|
||||
"info": 6,
|
||||
"name": "Monday",
|
||||
"type": "Null"
|
||||
},
|
||||
{
|
||||
"ext": {
|
||||
"discriminant": 1
|
||||
},
|
||||
"info": 6,
|
||||
"name": "Tuesday",
|
||||
"type": "Null"
|
||||
},
|
||||
{
|
||||
"ext": {
|
||||
"discriminant": 2
|
||||
},
|
||||
"info": 6,
|
||||
"name": "Wednesday",
|
||||
"type": "Null"
|
||||
},
|
||||
{
|
||||
"ext": {
|
||||
"discriminant": 3
|
||||
},
|
||||
"info": 6,
|
||||
"name": "Thursday",
|
||||
"type": "Null"
|
||||
},
|
||||
{
|
||||
"ext": {
|
||||
"discriminant": 4
|
||||
},
|
||||
"info": 6,
|
||||
"name": "Friday",
|
||||
"type": "Null"
|
||||
},
|
||||
{
|
||||
"ext": {
|
||||
"discriminant": 5
|
||||
},
|
||||
"info": 6,
|
||||
"name": "Saturday",
|
||||
"type": "Null"
|
||||
},
|
||||
{
|
||||
"ext": {
|
||||
"discriminant": 6
|
||||
},
|
||||
"info": 6,
|
||||
"name": "Sunday",
|
||||
"type": "Null"
|
||||
}
|
||||
],
|
||||
"type": "{\"_enum\":[\"Monday\",\"Tuesday\",\"Wednesday\",\"Thursday\",\"Friday\",\"Saturday\",\"Sunday\"]}",
|
||||
"name": "Weekday"
|
||||
},
|
||||
{
|
||||
"displayName": "TupleMaybeSigned",
|
||||
"namespace": "enum_example::enum_example",
|
||||
"info": 3,
|
||||
"sub": [
|
||||
{
|
||||
"info": 6,
|
||||
"type": "i32",
|
||||
"name": "Signed"
|
||||
},
|
||||
{
|
||||
"info": 6,
|
||||
"type": "u32",
|
||||
"name": "Unsigned"
|
||||
}
|
||||
],
|
||||
"type": "{\"_enum\":{\"Signed\":\"i32\",\"Unsigned\":\"u32\"}}",
|
||||
"name": "TupleMaybeSigned"
|
||||
},
|
||||
{
|
||||
"displayName": "NamedMaybeSigned",
|
||||
"namespace": "enum_example::enum_example",
|
||||
"info": 3,
|
||||
"sub": [
|
||||
{
|
||||
"info": 9,
|
||||
"sub": [
|
||||
{
|
||||
"info": 6,
|
||||
"type": "i32",
|
||||
"name": "value"
|
||||
}
|
||||
],
|
||||
"name": "Signed",
|
||||
"type": "{\"value\":\"i32\"}"
|
||||
},
|
||||
{
|
||||
"info": 9,
|
||||
"sub": [
|
||||
{
|
||||
"info": 6,
|
||||
"type": "u32",
|
||||
"name": "value"
|
||||
}
|
||||
],
|
||||
"name": "Unsigned",
|
||||
"type": "{\"value\":\"u32\"}"
|
||||
}
|
||||
],
|
||||
"type": "{\"_enum\":{\"Signed\":\"{\\\"value\\\":\\\"i32\\\"}\",\"Unsigned\":\"{\\\"value\\\":\\\"u32\\\"}\"}}",
|
||||
"name": "NamedMaybeSigned"
|
||||
},
|
||||
{
|
||||
"displayName": "Color",
|
||||
"namespace": "enum_example::enum_example",
|
||||
"info": 3,
|
||||
"sub": [
|
||||
{
|
||||
"info": 10,
|
||||
"sub": [],
|
||||
"name": "Red",
|
||||
"type": "()"
|
||||
},
|
||||
{
|
||||
"info": 10,
|
||||
"sub": [],
|
||||
"name": "Blue",
|
||||
"type": "()"
|
||||
},
|
||||
{
|
||||
"info": 10,
|
||||
"sub": [],
|
||||
"name": "Green",
|
||||
"type": "()"
|
||||
},
|
||||
{
|
||||
"info": 10,
|
||||
"sub": [],
|
||||
"name": "Yellow",
|
||||
"type": "()"
|
||||
},
|
||||
{
|
||||
"info": 9,
|
||||
"sub": [
|
||||
{
|
||||
"info": 6,
|
||||
"type": "u8",
|
||||
"name": "r"
|
||||
},
|
||||
{
|
||||
"info": 6,
|
||||
"type": "u8",
|
||||
"name": "g"
|
||||
},
|
||||
{
|
||||
"info": 6,
|
||||
"type": "u8",
|
||||
"name": "b"
|
||||
}
|
||||
],
|
||||
"name": "Rgb",
|
||||
"type": "{\"r\":\"u8\",\"g\":\"u8\",\"b\":\"u8\"}"
|
||||
},
|
||||
{
|
||||
"info": 9,
|
||||
"sub": [
|
||||
{
|
||||
"info": 6,
|
||||
"type": "u8",
|
||||
"name": "r"
|
||||
},
|
||||
{
|
||||
"info": 6,
|
||||
"type": "u8",
|
||||
"name": "g"
|
||||
},
|
||||
{
|
||||
"info": 6,
|
||||
"type": "u8",
|
||||
"name": "b"
|
||||
},
|
||||
{
|
||||
"info": 6,
|
||||
"type": "u8",
|
||||
"name": "a"
|
||||
}
|
||||
],
|
||||
"name": "Rgba",
|
||||
"type": "{\"r\":\"u8\",\"g\":\"u8\",\"b\":\"u8\",\"a\":\"u8\"}"
|
||||
}
|
||||
],
|
||||
"type": "{\"_enum\":{\"Red\":\"()\",\"Blue\":\"()\",\"Green\":\"()\",\"Yellow\":\"()\",\"Rgb\":\"{\\\"r\\\":\\\"u8\\\",\\\"g\\\":\\\"u8\\\",\\\"b\\\":\\\"u8\\\"}\",\"Rgba\":\"{\\\"r\\\":\\\"u8\\\",\\\"g\\\":\\\"u8\\\",\\\"b\\\":\\\"u8\\\",\\\"a\\\":\\\"u8\\\"}\"}}",
|
||||
"name": "Color"
|
||||
}
|
||||
],
|
||||
"type": "{\"_enum\":{\"None\":\"()\",\"Weekday\":\"Weekday\",\"TupleMaybeSigned\":\"TupleMaybeSigned\",\"NamedMaybeSigned\":\"NamedMaybeSigned\",\"Color\":\"Color\"}}"
|
||||
},
|
||||
{
|
||||
"displayName": "Weekday",
|
||||
"namespace": "enum_example::enum_example",
|
||||
"info": 3,
|
||||
"sub": [
|
||||
{
|
||||
"ext": {
|
||||
"discriminant": 0
|
||||
},
|
||||
"info": 6,
|
||||
"name": "Monday",
|
||||
"type": "Null"
|
||||
},
|
||||
{
|
||||
"ext": {
|
||||
"discriminant": 1
|
||||
},
|
||||
"info": 6,
|
||||
"name": "Tuesday",
|
||||
"type": "Null"
|
||||
},
|
||||
{
|
||||
"ext": {
|
||||
"discriminant": 2
|
||||
},
|
||||
"info": 6,
|
||||
"name": "Wednesday",
|
||||
"type": "Null"
|
||||
},
|
||||
{
|
||||
"ext": {
|
||||
"discriminant": 3
|
||||
},
|
||||
"info": 6,
|
||||
"name": "Thursday",
|
||||
"type": "Null"
|
||||
},
|
||||
{
|
||||
"ext": {
|
||||
"discriminant": 4
|
||||
},
|
||||
"info": 6,
|
||||
"name": "Friday",
|
||||
"type": "Null"
|
||||
},
|
||||
{
|
||||
"ext": {
|
||||
"discriminant": 5
|
||||
},
|
||||
"info": 6,
|
||||
"name": "Saturday",
|
||||
"type": "Null"
|
||||
},
|
||||
{
|
||||
"ext": {
|
||||
"discriminant": 6
|
||||
},
|
||||
"info": 6,
|
||||
"name": "Sunday",
|
||||
"type": "Null"
|
||||
}
|
||||
],
|
||||
"type": "{\"_enum\":[\"Monday\",\"Tuesday\",\"Wednesday\",\"Thursday\",\"Friday\",\"Saturday\",\"Sunday\"]}"
|
||||
},
|
||||
{
|
||||
"displayName": "TupleMaybeSigned",
|
||||
"namespace": "enum_example::enum_example",
|
||||
"info": 3,
|
||||
"sub": [
|
||||
{
|
||||
"info": 6,
|
||||
"type": "i32",
|
||||
"name": "Signed"
|
||||
},
|
||||
{
|
||||
"info": 6,
|
||||
"type": "u32",
|
||||
"name": "Unsigned"
|
||||
}
|
||||
],
|
||||
"type": "{\"_enum\":{\"Signed\":\"i32\",\"Unsigned\":\"u32\"}}"
|
||||
},
|
||||
{
|
||||
"displayName": "NamedMaybeSigned",
|
||||
"namespace": "enum_example::enum_example",
|
||||
"info": 3,
|
||||
"sub": [
|
||||
{
|
||||
"info": 9,
|
||||
"sub": [
|
||||
{
|
||||
"info": 6,
|
||||
"type": "i32",
|
||||
"name": "value"
|
||||
}
|
||||
],
|
||||
"name": "Signed",
|
||||
"type": "{\"value\":\"i32\"}"
|
||||
},
|
||||
{
|
||||
"info": 9,
|
||||
"sub": [
|
||||
{
|
||||
"info": 6,
|
||||
"type": "u32",
|
||||
"name": "value"
|
||||
}
|
||||
],
|
||||
"name": "Unsigned",
|
||||
"type": "{\"value\":\"u32\"}"
|
||||
}
|
||||
],
|
||||
"type": "{\"_enum\":{\"Signed\":\"{\\\"value\\\":\\\"i32\\\"}\",\"Unsigned\":\"{\\\"value\\\":\\\"u32\\\"}\"}}"
|
||||
},
|
||||
{
|
||||
"displayName": "Color",
|
||||
"namespace": "enum_example::enum_example",
|
||||
"info": 3,
|
||||
"sub": [
|
||||
{
|
||||
"info": 10,
|
||||
"sub": [],
|
||||
"name": "Red",
|
||||
"type": "()"
|
||||
},
|
||||
{
|
||||
"info": 10,
|
||||
"sub": [],
|
||||
"name": "Blue",
|
||||
"type": "()"
|
||||
},
|
||||
{
|
||||
"info": 10,
|
||||
"sub": [],
|
||||
"name": "Green",
|
||||
"type": "()"
|
||||
},
|
||||
{
|
||||
"info": 10,
|
||||
"sub": [],
|
||||
"name": "Yellow",
|
||||
"type": "()"
|
||||
},
|
||||
{
|
||||
"info": 9,
|
||||
"sub": [
|
||||
{
|
||||
"info": 6,
|
||||
"type": "u8",
|
||||
"name": "r"
|
||||
},
|
||||
{
|
||||
"info": 6,
|
||||
"type": "u8",
|
||||
"name": "g"
|
||||
},
|
||||
{
|
||||
"info": 6,
|
||||
"type": "u8",
|
||||
"name": "b"
|
||||
}
|
||||
],
|
||||
"name": "Rgb",
|
||||
"type": "{\"r\":\"u8\",\"g\":\"u8\",\"b\":\"u8\"}"
|
||||
},
|
||||
{
|
||||
"info": 9,
|
||||
"sub": [
|
||||
{
|
||||
"info": 6,
|
||||
"type": "u8",
|
||||
"name": "r"
|
||||
},
|
||||
{
|
||||
"info": 6,
|
||||
"type": "u8",
|
||||
"name": "g"
|
||||
},
|
||||
{
|
||||
"info": 6,
|
||||
"type": "u8",
|
||||
"name": "b"
|
||||
},
|
||||
{
|
||||
"info": 6,
|
||||
"type": "u8",
|
||||
"name": "a"
|
||||
}
|
||||
],
|
||||
"name": "Rgba",
|
||||
"type": "{\"r\":\"u8\",\"g\":\"u8\",\"b\":\"u8\",\"a\":\"u8\"}"
|
||||
}
|
||||
],
|
||||
"type": "{\"_enum\":{\"Red\":\"()\",\"Blue\":\"()\",\"Green\":\"()\",\"Yellow\":\"()\",\"Rgb\":\"{\\\"r\\\":\\\"u8\\\",\\\"g\\\":\\\"u8\\\",\\\"b\\\":\\\"u8\\\"}\",\"Rgba\":\"{\\\"r\\\":\\\"u8\\\",\\\"g\\\":\\\"u8\\\",\\\"b\\\":\\\"u8\\\",\\\"a\\\":\\\"u8\\\"}\"}}"
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,205 @@
|
||||
[
|
||||
{
|
||||
"info": 6,
|
||||
"type": "u128"
|
||||
},
|
||||
{
|
||||
"displayName": "Header",
|
||||
"namespace": "ink_storage::collections::stash",
|
||||
"info": 9,
|
||||
"sub": [
|
||||
{
|
||||
"info": 6,
|
||||
"type": "u32",
|
||||
"name": "last_vacant"
|
||||
},
|
||||
{
|
||||
"info": 6,
|
||||
"type": "u32",
|
||||
"name": "len"
|
||||
},
|
||||
{
|
||||
"info": 6,
|
||||
"type": "u32",
|
||||
"name": "len_entries"
|
||||
}
|
||||
],
|
||||
"type": "{\"last_vacant\":\"u32\",\"len\":\"u32\",\"len_entries\":\"u32\"}"
|
||||
},
|
||||
{
|
||||
"info": 6,
|
||||
"type": "u32"
|
||||
},
|
||||
{
|
||||
"displayName": "Entry",
|
||||
"namespace": "ink_storage::collections::stash",
|
||||
"sub": [
|
||||
{
|
||||
"displayName": "VacantEntry",
|
||||
"namespace": "ink_storage::collections::stash",
|
||||
"info": 9,
|
||||
"sub": [
|
||||
{
|
||||
"info": 6,
|
||||
"type": "u32",
|
||||
"name": "next"
|
||||
},
|
||||
{
|
||||
"info": 6,
|
||||
"type": "u32",
|
||||
"name": "prev"
|
||||
}
|
||||
],
|
||||
"type": "{\"next\":\"u32\",\"prev\":\"u32\"}",
|
||||
"name": "Vacant"
|
||||
},
|
||||
{
|
||||
"displayName": "AccountId",
|
||||
"namespace": "ink_env::types",
|
||||
"info": 6,
|
||||
"type": "AccountId",
|
||||
"name": "Occupied"
|
||||
}
|
||||
],
|
||||
"info": 3,
|
||||
"type": "{\"_enum\":{\"Vacant\":\"VacantEntry\",\"Occupied\":\"AccountId\"}}"
|
||||
},
|
||||
{
|
||||
"displayName": "AccountId",
|
||||
"namespace": "ink_env::types",
|
||||
"info": 6,
|
||||
"type": "AccountId"
|
||||
},
|
||||
{
|
||||
"info": 12,
|
||||
"length": 32,
|
||||
"sub": {
|
||||
"info": 6,
|
||||
"type": "u8"
|
||||
},
|
||||
"type": "[u8;32]"
|
||||
},
|
||||
{
|
||||
"info": 6,
|
||||
"type": "u8"
|
||||
},
|
||||
{
|
||||
"displayName": "VacantEntry",
|
||||
"namespace": "ink_storage::collections::stash",
|
||||
"info": 9,
|
||||
"sub": [
|
||||
{
|
||||
"info": 6,
|
||||
"type": "u32",
|
||||
"name": "next"
|
||||
},
|
||||
{
|
||||
"info": 6,
|
||||
"type": "u32",
|
||||
"name": "prev"
|
||||
}
|
||||
],
|
||||
"type": "{\"next\":\"u32\",\"prev\":\"u32\"}"
|
||||
},
|
||||
{
|
||||
"displayName": "ValueEntry",
|
||||
"namespace": "ink_storage::collections::hashmap",
|
||||
"sub": [
|
||||
{
|
||||
"info": 6,
|
||||
"type": "u128",
|
||||
"name": "value"
|
||||
},
|
||||
{
|
||||
"info": 6,
|
||||
"type": "u32",
|
||||
"name": "key_index"
|
||||
}
|
||||
],
|
||||
"info": 9,
|
||||
"type": "{\"value\":\"u128\",\"key_index\":\"u32\"}"
|
||||
},
|
||||
{
|
||||
"displayName": "Entry",
|
||||
"namespace": "ink_storage::collections::stash",
|
||||
"sub": [
|
||||
{
|
||||
"displayName": "VacantEntry",
|
||||
"namespace": "ink_storage::collections::stash",
|
||||
"info": 9,
|
||||
"sub": [
|
||||
{
|
||||
"info": 6,
|
||||
"type": "u32",
|
||||
"name": "next"
|
||||
},
|
||||
{
|
||||
"info": 6,
|
||||
"type": "u32",
|
||||
"name": "prev"
|
||||
}
|
||||
],
|
||||
"type": "{\"next\":\"u32\",\"prev\":\"u32\"}",
|
||||
"name": "Vacant"
|
||||
},
|
||||
{
|
||||
"info": 10,
|
||||
"sub": [
|
||||
{
|
||||
"displayName": "AccountId",
|
||||
"namespace": "ink_env::types",
|
||||
"info": 6,
|
||||
"type": "AccountId"
|
||||
},
|
||||
{
|
||||
"displayName": "AccountId",
|
||||
"namespace": "ink_env::types",
|
||||
"info": 6,
|
||||
"type": "AccountId"
|
||||
}
|
||||
],
|
||||
"type": "(AccountId, AccountId)",
|
||||
"name": "Occupied"
|
||||
}
|
||||
],
|
||||
"info": 3,
|
||||
"type": "{\"_enum\":{\"Vacant\":\"VacantEntry\",\"Occupied\":\"(AccountId, AccountId)\"}}"
|
||||
},
|
||||
{
|
||||
"info": 10,
|
||||
"sub": [
|
||||
{
|
||||
"displayName": "AccountId",
|
||||
"namespace": "ink_env::types",
|
||||
"info": 6,
|
||||
"type": "AccountId"
|
||||
},
|
||||
{
|
||||
"displayName": "AccountId",
|
||||
"namespace": "ink_env::types",
|
||||
"info": 6,
|
||||
"type": "AccountId"
|
||||
}
|
||||
],
|
||||
"type": "(AccountId, AccountId)"
|
||||
},
|
||||
{
|
||||
"info": 6,
|
||||
"type": "Text"
|
||||
},
|
||||
{
|
||||
"info": 6,
|
||||
"type": "bool"
|
||||
},
|
||||
{
|
||||
"displayName": "Option",
|
||||
"sub": {
|
||||
"displayName": "AccountId",
|
||||
"namespace": "ink_env::types",
|
||||
"info": 6,
|
||||
"type": "AccountId"
|
||||
},
|
||||
"info": 5,
|
||||
"type": "Option<AccountId>"
|
||||
}
|
||||
]
|
||||
@@ -1,10 +1,21 @@
|
||||
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
|
||||
// Copyright 2017-2021 @polkadot/api-contract authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
export { default as delegator } from './delegator.json';
|
||||
export { default as dns } from './dns.json';
|
||||
export { default as erc20 } from './erc20.json';
|
||||
export { default as erc721 } from './erc721.json';
|
||||
export { default as flipper } from './flipper.json';
|
||||
export { default as incrementer } from './incrementer.json';
|
||||
export { default as multisigPlain } from './multisig_plain.json';
|
||||
import * as ink from './ink';
|
||||
import * as solang from './solang';
|
||||
import * as user from './user';
|
||||
|
||||
const all: Record<string, any> = {};
|
||||
|
||||
function addExport (type: string, abis: Record<string, any>): void {
|
||||
Object.keys(abis).forEach((key): void => {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
||||
all[`${type}_${key}`] = abis[key];
|
||||
});
|
||||
}
|
||||
|
||||
addExport('ink', ink);
|
||||
addExport('solang', solang);
|
||||
addExport('user', user);
|
||||
|
||||
export default all;
|
||||
|
||||
@@ -0,0 +1,107 @@
|
||||
{
|
||||
"metadataVersion": "0.1.0",
|
||||
"source": {
|
||||
"hash": "0x98086d5ccadd437459b812682380250f51a3034272cd1108e499acc0cafe9f42",
|
||||
"language": "ink! 3.0.0-rc2",
|
||||
"compiler": "rustc 1.49.0-nightly",
|
||||
"wasm": "0x0061736d01000000012c0860027f7f0060037f7f7f0060017f017f60017f006000017f60037f7f7f017f60047f7f7f7f0060017f017e02880106057365616c30107365616c5f6765745f73746f726167650005057365616c30107365616c5f7365745f73746f726167650001057365616c30167365616c5f76616c75655f7472616e736665727265640000057365616c300a7365616c5f696e7075740000057365616c300b7365616c5f72657475726e000103656e76066d656d6f72790201021003121102020002000100070303060402040503010608017f01418080040b071102066465706c6f7900100463616c6c00120a8e1111c90101017f230041406a22012400200141206a200041186a290300370300200141186a200041106a290300370300200141106a200041086a2903003703002001420037032820012000290300370308200141086a1006200141808001360234200141a4800436023020014180800136023841a48004200141386a10002100200141306a20012802381007024002400240024020000e0401000002000b000b20012001290330370338200141386a100841ff017122004102470d01000b000b200141406b240020004100470b6001037e200029032021012000420137032020002001200029030022027c22013703002000200029030822032001200254ad7c22013703082000200029031022022001200354ad7c2201370310200020002903182001200254ad7c37031820000b4901037f230041106b22022400200028020421032000410036020420002802002104200041a48004360200200241086a200120042003100f20002002290308370200200241106a24000b4201027f230041106b22012400200141086a2000100b20012d0009210020012d00082102200141106a240041024101410220004101461b410020001b20024101711b0b8f0101017f230041406a22022400200241206a200141186a290300370300200241186a200141106a290300370300200241106a200141086a2903003703002002420037032820022001290300370308200241086a1006200241386a41808001360200200241a48004360234200241003602302002200241306a2000100a200228020020022802041001200241406b24000b9d0101037f230041106b22032400200141086a220428020021052004410036020020012802042104200141a48004360204200320023a000f2003410120042005100f024020032802044101460440200328020020032d000f3a000020014100360208200141a480043602042005450d0120012005417f6a3602082001200441016a3602042000410136020420002004360200200341106a24000f0b000b000b4801027f230041106b22022400200241003a000f024020012002410f6a4101101345044020022d000f21010c010b410121030b200020013a0001200020033a0000200241106a24000b890101027f230041106b22012400200142003c000c200142003e0208027f0340200241044604402001280208210241000c020b20012000100b20012d0000410171450440200141086a20026a20012d00013a00002001200241016a22023a000c0c010b0b200241ff01710440200141003a000c0b4100210241010b200141106a2400ad2002ad420886840b2201017f230041106b220124002001200036020c2001410c6a2802002d0000100e000b4601017f230041206b22012400200141186a41808001360200200141a4800436021420014100360210200141086a200141106a2000100a41002001280208200128020c1004000b2300410020014d0440200320014f044020002001360204200020023602000f0b000b000b15004100101141ff0171410274418080046a2802000bd80502057f017e230041306b220124000240027f024002402000044020014180800136020c200141a48004360208200141086a10142001200129030837031041012103200141106a100c2206a722054101710440410121020c030b200642ffffffffff1f832206422088a721002006421888a721042006421088a72102200541087641ff01712205411e470440200541c00147200041f3014772200241ff017141960147720d0241002102200441ff017141a501460d030c020b200041d60047200241ff017141dc0047720d014100210241002103200441ff017141a401470d010c020b20014180800136020c200141a48004360208200141086a101420012001290308370310410321020240200141106a100c2206a722044101710d00200642ffffffffff1f832206422088a721002006421888a721032006421088a7210202400240200441087641ff0171220441ea00470440200441d101472000412b4772200241ff017141830147720d02200341ff017141d100460d010c020b200041e20147200241ff0171413747720d0141022102200341ff01714112470d010c020b41032102200141106a100841ff017122004102460d01200041004721020c010b410321020b4106200241034622030d021a4106200220031b22024102460440200141286a4200370300200141206a4200370300200141186a4200370300200142003703104100200141106a100941080c030b200141286a4200370300200141206a4200370300200141186a4200370300200142003703102002410171200141106a100941080c020b41012102410121030b410620020d001a2003450d01200141286a4200370300200141206a4200370300200141186a420037030020014200370310200141106a1005410173200141106a100941080b200141306a24000f0b200141286a4200370300200141206a4200370300200141186a4200370300200142003703102001200141106a10053a0008200141086a100d000ba90102027f027e230041206b22002400200041808001360204200041a4800436020020004180800136021041a48004200041106a100220002000280210100720002000290300370308200041186a2201420037030020004200370310027f4101200041086a200041106a411010130d001a200129030021022000290310210341000b200220038450457245044041011011200041206a240041ff0171410274418080046a2802000f0b000b45000240200028020420024f047f2001200028020020021015200028020422012002490d012000200120026b3602042000200028020020026a36020041000541010b0f0b000b3301017f230041106b220124002001200028020436020c20002802002001410c6a10032000200128020c1007200141106a24000b2c01017f037f2002200346047f200005200020036a200120036a2d00003a0000200341016a21030c010b0b1a0b0b250100418080040b1d0100000002000000030000000400000005000000060000000700000008"
|
||||
},
|
||||
"contract": {
|
||||
"name": "flipper",
|
||||
"version": "3.0.0-rc2",
|
||||
"authors": [
|
||||
"Parity Technologies <admin@parity.io>"
|
||||
]
|
||||
},
|
||||
"spec": {
|
||||
"constructors": [
|
||||
{
|
||||
"args": [
|
||||
{
|
||||
"name": "init_value",
|
||||
"type": {
|
||||
"displayName": [
|
||||
"bool"
|
||||
],
|
||||
"type": 1
|
||||
}
|
||||
}
|
||||
],
|
||||
"docs": [
|
||||
" Creates a new flipper smart contract initialized with the given value."
|
||||
],
|
||||
"name": [
|
||||
"new"
|
||||
],
|
||||
"selector": "0xd183512b"
|
||||
},
|
||||
{
|
||||
"args": [],
|
||||
"docs": [
|
||||
" Creates a new flipper smart contract initialized to `false`."
|
||||
],
|
||||
"name": [
|
||||
"default"
|
||||
],
|
||||
"selector": "0x6a3712e2"
|
||||
}
|
||||
],
|
||||
"docs": [],
|
||||
"events": [],
|
||||
"messages": [
|
||||
{
|
||||
"args": [],
|
||||
"docs": [
|
||||
" Flips the current value of the Flipper's bool."
|
||||
],
|
||||
"mutates": true,
|
||||
"name": [
|
||||
"flip"
|
||||
],
|
||||
"payable": false,
|
||||
"returnType": null,
|
||||
"selector": "0xc096a5f3"
|
||||
},
|
||||
{
|
||||
"args": [],
|
||||
"docs": [
|
||||
" Returns the current value of the Flipper's bool."
|
||||
],
|
||||
"mutates": false,
|
||||
"name": [
|
||||
"get"
|
||||
],
|
||||
"payable": false,
|
||||
"returnType": {
|
||||
"displayName": [
|
||||
"bool"
|
||||
],
|
||||
"type": 1
|
||||
},
|
||||
"selector": "0x1e5ca456"
|
||||
}
|
||||
]
|
||||
},
|
||||
"storage": {
|
||||
"struct": {
|
||||
"fields": [
|
||||
{
|
||||
"layout": {
|
||||
"cell": {
|
||||
"key": "0x0000000000000000000000000000000000000000000000000000000000000000",
|
||||
"ty": 1
|
||||
}
|
||||
},
|
||||
"name": "value"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"types": [
|
||||
{
|
||||
"def": {
|
||||
"primitive": "bool"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
// Copyright 2017-2021 @polkadot/api-contract authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
export { default as delegator } from './delegator.json';
|
||||
export { default as dns } from './dns.json';
|
||||
export { default as erc20 } from './erc20.json';
|
||||
export { default as erc721 } from './erc721.json';
|
||||
export { default as flipper } from './flipper.json';
|
||||
export { default as flipperBundle } from './flipper.contract.json';
|
||||
export { default as incrementer } from './incrementer.json';
|
||||
export { default as multisigPlain } from './multisig_plain.json';
|
||||
@@ -0,0 +1,4 @@
|
||||
// Copyright 2017-2021 @polkadot/api-contract authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
export { default as ints256 } from './ints256.json';
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user