Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
09831fe325 | ||
|
|
c7dda6fe85 | ||
|
|
285bbab055 | ||
|
|
b73010a506 | ||
|
|
9c951fe1cb | ||
|
|
f7dfb633d6 | ||
|
|
e32286b610 | ||
|
|
fe2687b514 | ||
|
|
1adde99e1b | ||
|
|
33dcc9c8aa | ||
|
|
db563bc131 | ||
|
|
35d2fa31e0 | ||
|
|
399637280c | ||
|
|
f46916b215 | ||
|
|
94aa79d1e5 | ||
|
|
10dacf1d16 | ||
|
|
bdaacfdd56 | ||
|
|
4fa77b3654 | ||
|
|
400e14d6c9 | ||
|
|
09f247432f | ||
|
|
fd195dd4f0 | ||
|
|
0038227680 | ||
|
|
89dec0bc0b | ||
|
|
a55a835504 | ||
|
|
c1266a6657 | ||
|
|
b78f08e2e6 | ||
|
|
298ef03787 | ||
|
|
dd80b1873c | ||
|
|
f7672e053b | ||
|
|
281e9d2dee | ||
|
|
3f0d11b026 | ||
|
|
0c997d2850 | ||
|
|
cb0beea7cd | ||
|
|
4ed783878d | ||
|
|
3846b5cc18 | ||
|
|
57b8915101 | ||
|
|
4f3f7e8dff | ||
|
|
a42c266a35 | ||
|
|
b03b2db3f8 | ||
|
|
5347db445d | ||
|
|
2a15b65385 | ||
|
|
7f1952acfc | ||
|
|
d8920b4bac | ||
|
|
3b46505027 | ||
|
|
ba3ac3f73d | ||
|
|
81d460ccc8 | ||
|
|
e6bb6c49b3 | ||
|
|
82ffa8a6e2 | ||
|
|
adc1af1f21 | ||
|
|
a05d6ad7dc | ||
|
|
be592f53b8 | ||
|
|
8e74eca435 | ||
|
|
8a28d2cf46 | ||
|
|
d36886fcbf | ||
|
|
3bbc9fbf6e | ||
|
|
1d4539f3ef | ||
|
|
215b20f7db | ||
|
|
c034b54822 | ||
|
|
261ca2149d | ||
|
|
eaa67c8ea6 | ||
|
|
db287d6997 | ||
|
|
b85bf7e41c | ||
|
|
84b82dd9b5 | ||
|
|
3df5b01375 | ||
|
|
2e6a59e2a0 | ||
|
|
2f91561166 | ||
|
|
b307772be2 | ||
|
|
d14d2ccc86 | ||
|
|
0f26ec47e2 | ||
|
|
40065e300b | ||
|
|
bbdb8a317f | ||
|
|
668085262c | ||
|
|
508400684a | ||
|
|
3273556f7b | ||
|
|
d36144bf36 | ||
|
|
444479011e | ||
|
|
8ac713abcf | ||
|
|
728bc5294f | ||
|
|
fd2f331bdf | ||
|
|
2aebbb89cb | ||
|
|
532c011495 | ||
|
|
e2802df9ce | ||
|
|
cc181e2cc3 | ||
|
|
1b8ba41715 | ||
|
|
648be9aecb | ||
|
|
292af97dc9 | ||
|
|
bcdd537214 | ||
|
|
514c5e4825 | ||
|
|
9b9581487d | ||
|
|
d443f31a9a | ||
|
|
3951da5df3 | ||
|
|
5f3a1e5b24 | ||
|
|
b1a6ccd425 | ||
|
|
adc40e581f | ||
|
|
c6b0b0c161 | ||
|
|
bf5b14580b | ||
|
|
088c02862b | ||
|
|
a05980900e | ||
|
|
77019def08 | ||
|
|
ae6a3307b1 | ||
|
|
8cb15c6a87 | ||
|
|
389dbb58a9 | ||
|
|
2d02f61fa7 | ||
|
|
7497ac723f | ||
|
|
711a145e1e | ||
|
|
05e3db01ba | ||
|
|
6158c07e0a | ||
|
|
ce505aaf62 | ||
|
|
09f9a48037 | ||
|
|
700c1cfcd4 | ||
|
|
7d2463e53f | ||
|
|
a2ecd9bd3b | ||
|
|
b0de692147 | ||
|
|
dcd53c76d7 | ||
|
|
6ed90c6111 | ||
|
|
babef6d7bc | ||
|
|
e2205a65e9 | ||
|
|
32d55dfb18 | ||
|
|
60e0d0eae4 | ||
|
|
9cef1febe1 | ||
|
|
4c9032fedc | ||
|
|
5b6f222e5e | ||
|
|
47235d01bf | ||
|
|
32efe83136 | ||
|
|
c4c099e693 | ||
|
|
f26ca0e624 | ||
|
|
5f496f1809 | ||
|
|
f1cbf8cc70 | ||
|
|
8b7fccb744 | ||
|
|
66d3486674 | ||
|
|
2dbd217f6d | ||
|
|
fea9ae8f97 | ||
|
|
4e81bbc43c | ||
|
|
83650b8f28 | ||
|
|
50a3501dd2 | ||
|
|
526a3fd139 | ||
|
|
3b996b3444 | ||
|
|
c72c9e4a5e | ||
|
|
60a71a5ac9 | ||
|
|
26c3ccccc3 | ||
|
|
963e25934d | ||
|
|
55d9f8a062 | ||
|
|
700c8ba21f | ||
|
|
cbc255b4e7 | ||
|
|
2fe1e5031e | ||
|
|
f2cdac7875 | ||
|
|
165405bdc3 | ||
|
|
f86d71524d | ||
|
|
4d6d59f1c5 | ||
|
|
7a709898e5 | ||
|
|
121bfc7913 | ||
|
|
a04ccec445 | ||
|
|
2611fc5e1a | ||
|
|
cd5c306b22 | ||
|
|
ca6a7819f6 | ||
|
|
29c0ea9856 | ||
|
|
c82ed58d68 | ||
|
|
59a3867c50 | ||
|
|
0fca4e6866 | ||
|
|
3f9e65a179 | ||
|
|
92bde9de6f | ||
|
|
9b3158599c | ||
|
|
206fb49df5 | ||
|
|
cc0ad9b04b | ||
|
|
39902dd8ac | ||
|
|
324e4ab89b | ||
|
|
68bf0a487f | ||
|
|
3acf7e0fd7 | ||
|
|
edaf13abe1 | ||
|
|
b3649a70ce | ||
|
|
80ab628643 | ||
|
|
76363c0142 | ||
|
|
80c18c2201 | ||
|
|
fcf9b86b87 | ||
|
|
1113a3d2f8 | ||
|
|
c899dbf893 | ||
|
|
be137b2a03 | ||
|
|
122d780fe8 | ||
|
|
12be027b18 | ||
|
|
dfeef40037 | ||
|
|
a7b4fe4dd0 | ||
|
|
f4ec64d6f5 | ||
|
|
9a0d39199e | ||
|
|
77d82d9511 | ||
|
|
5464b91cc6 | ||
|
|
64ff87952a | ||
|
|
0de39e4c52 | ||
|
|
60bc384d22 | ||
|
|
ca7ea0e143 | ||
|
|
23d50248de | ||
|
|
ad4e54a2f6 | ||
|
|
e659df27ae | ||
|
|
6dc3c06fe8 | ||
|
|
776956f166 | ||
|
|
4c5203acba | ||
|
|
d80070a041 | ||
|
|
1c00cb4c4e | ||
|
|
736505603e | ||
|
|
c243da79e1 | ||
|
|
2677f38090 | ||
|
|
41d05d2402 | ||
|
|
0f38584566 | ||
|
|
2b7fb8667e | ||
|
|
ca18846bfb | ||
|
|
4ba372d29b | ||
|
|
bdc2d24366 | ||
|
|
3de06c1d4c | ||
|
|
b51149d895 | ||
|
|
e0fef55366 | ||
|
|
e2aac5f94a | ||
|
|
8f44f84c7f | ||
|
|
d53a61ec86 | ||
|
|
cf18f79c14 | ||
|
|
beb8011b4c | ||
|
|
38a601b665 | ||
|
|
11a3483ce5 | ||
|
|
1db133b741 | ||
|
|
716dce0093 | ||
|
|
3b53442172 | ||
|
|
253d94a47d | ||
|
|
fb1129a49b | ||
|
|
1cc56d6e44 | ||
|
|
9e2983a735 | ||
|
|
a6fcba95de | ||
|
|
c8c535834e | ||
|
|
b8d7c2e3e3 | ||
|
|
0283d4727b | ||
|
|
a4ab732478 | ||
|
|
0dc121a796 | ||
|
|
a827131457 | ||
|
|
2174537f76 | ||
|
|
53fca2406a | ||
|
|
0eaba284ae | ||
|
|
378f359a76 | ||
|
|
5460d96b5d | ||
|
|
b1353edc84 | ||
|
|
9129fed6e5 | ||
|
|
7c4abacaca | ||
|
|
3664c7d81b | ||
|
|
f75b87c5a5 | ||
|
|
1c228216cd | ||
|
|
cec3c12795 | ||
|
|
0d0d12e85b | ||
|
|
3a16e69be5 | ||
|
|
4ae8e3909f | ||
|
|
6e18bb3b1d | ||
|
|
be153e13a6 | ||
|
|
4c01dfd0ab | ||
|
|
b57c7a1343 | ||
|
|
da62acdf50 | ||
|
|
cc95e4fc0a | ||
|
|
7f5647c6e1 | ||
|
|
c636d63bc0 | ||
|
|
30c98ef857 | ||
|
|
debecde50f | ||
|
|
cd2cdd1184 | ||
|
|
f5c25d75ff | ||
|
|
780cc62942 | ||
|
|
165568c905 | ||
|
|
976a48d8f9 | ||
|
|
35cbbbe0ed | ||
|
|
772769c981 | ||
|
|
1ba2bd1766 | ||
|
|
4afa345a7d | ||
|
|
5c03359f32 | ||
|
|
04120505f0 | ||
|
|
7bd9dd65f8 | ||
|
|
5f57ecb2e1 | ||
|
|
9123f1d805 | ||
|
|
7050c4a554 | ||
|
|
62afb0b534 | ||
|
|
5157ca5608 | ||
|
|
315617c027 | ||
|
|
7d33b4dec6 | ||
|
|
2345f69c71 | ||
|
|
3cef2fb4d5 | ||
|
|
2bbf5513b2 | ||
|
|
c146f06178 | ||
|
|
5903704b61 | ||
|
|
90d8db651b | ||
|
|
557283a3d1 | ||
|
|
88b84dcf75 | ||
|
|
45d190eaca | ||
|
|
6d32328509 | ||
|
|
ba470e7417 | ||
|
|
4a16e46f88 | ||
|
|
ada0d99a84 | ||
|
|
e486fc4316 | ||
|
|
6e5c6f4e0b | ||
|
|
21ddcaf173 | ||
|
|
6085b994f6 | ||
|
|
7c3bf05868 | ||
|
|
8bce5b4a09 | ||
|
|
7a6077301f | ||
|
|
3f2767462f | ||
|
|
ecc37d11df | ||
|
|
0589d151da | ||
|
|
47cd6c6410 | ||
|
|
65688f9e0e | ||
|
|
5eb2a95ef2 | ||
|
|
282b39d27a | ||
|
|
f21e3d317a | ||
|
|
c2af7cf8f2 | ||
|
|
0958a4c693 | ||
|
|
c687181130 | ||
|
|
685f1ec0b6 | ||
|
|
e0069b6f7d | ||
|
|
cf48762ff2 | ||
|
|
31a7545a19 | ||
|
|
5cd8e8fb97 | ||
|
|
96e4090174 | ||
|
|
0bbebab90b | ||
|
|
57dac0ef47 | ||
|
|
6c3d24551b | ||
|
|
e7dc6d7a5a | ||
|
|
a63b7f611e | ||
|
|
82e15dc36d | ||
|
|
6f96037cb5 | ||
|
|
b6da84b8b2 | ||
|
|
41209f074c | ||
|
|
c47964c942 | ||
|
|
5f13a634e5 | ||
|
|
40af520fe7 | ||
|
|
1e506e0f8c | ||
|
|
96ea5803d4 | ||
|
|
7d99459f50 | ||
|
|
8fa090f435 | ||
|
|
d3c60d197c | ||
|
|
ad8550f7f5 | ||
|
|
a899aa439d | ||
|
|
e0e075b350 | ||
|
|
34ff14547e | ||
|
|
681a80d456 | ||
|
|
ed5f2673ce | ||
|
|
43e87603e2 | ||
|
|
d056416b47 | ||
|
|
1bcf94131d | ||
|
|
17b607b6c3 | ||
|
|
5a16d1dd8b | ||
|
|
144b74306a | ||
|
|
16b9fa956d | ||
|
|
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 |
+20
-2
@@ -1,7 +1,25 @@
|
||||
25
|
||||
30
|
||||
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
|
||||
4.6.2
|
||||
4.7.2
|
||||
4.9.2
|
||||
4.11.2
|
||||
|
||||
+1
-3
@@ -1,4 +1,4 @@
|
||||
// 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.cjs');
|
||||
@@ -24,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'
|
||||
}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
name: 'Lock Threads'
|
||||
|
||||
on:
|
||||
schedule:
|
||||
- cron: '30 1/2 * * *'
|
||||
|
||||
jobs:
|
||||
lock:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: dessant/lock-threads@v2
|
||||
with:
|
||||
github-token: ${{ secrets.GH_PAT_BOT }}
|
||||
issue-lock-inactive-days: '7'
|
||||
issue-lock-comment: >
|
||||
This thread has been automatically locked since there has not been
|
||||
any recent activity after it was closed. Please open a new issue
|
||||
if you think you have a related problem or query.
|
||||
pr-lock-inactive-days: '2'
|
||||
pr-lock-comment: >
|
||||
This pull request has been automatically locked since there
|
||||
has not been any recent activity after it was closed.
|
||||
Please open a new issue for related bugs.
|
||||
@@ -6,11 +6,11 @@ on:
|
||||
|
||||
jobs:
|
||||
master:
|
||||
if: "! startsWith(github.event.head_commit.message, '[CI Skip]')"
|
||||
strategy:
|
||||
matrix:
|
||||
step: ['build:release']
|
||||
name: ${{ matrix.step }}
|
||||
if: "! startsWith(github.event.head_commit.message, '[CI Skip]') && github.repository == 'polkadot-js/api'"
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
@@ -25,10 +25,3 @@ jobs:
|
||||
run: |
|
||||
yarn install --immutable | grep -v 'YN0013'
|
||||
yarn ${{ matrix.step }}
|
||||
|
||||
dummy:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: dummy
|
||||
run: |
|
||||
echo "Dummy skip step"
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
name: Semgrep
|
||||
on:
|
||||
pull_request: {}
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
|
||||
jobs:
|
||||
check:
|
||||
if: "! startsWith(github.event.head_commit.message, '[CI Skip]') && (!github.event.pull_request || github.event.pull_request.head.repo.full_name == github.repository)"
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: returntocorp/semgrep-action@v1
|
||||
with:
|
||||
auditOn: push
|
||||
publishToken: ${{ secrets.SEMGREP_APP_TOKEN }}
|
||||
publishDeployment: 1395
|
||||
@@ -0,0 +1,17 @@
|
||||
name: 'Close stale issues and PRs'
|
||||
on:
|
||||
schedule:
|
||||
- cron: '30 2/2 * * *'
|
||||
|
||||
jobs:
|
||||
stale:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/stale@v3
|
||||
with:
|
||||
repo-token: ${{ secrets.GH_PAT_BOT }}
|
||||
stale-issue-message: 'This issue has been open for 21 days with no activity and is not labelled as an enhancement. It will be closed in 7 days.'
|
||||
stale-issue-label: 'stale'
|
||||
exempt-issue-labels: '-size-l,-size-m,-size-s,-size-xl,-size-xs,[bug]'
|
||||
days-before-stale: 21
|
||||
days-before-close: 7
|
||||
@@ -0,0 +1,3 @@
|
||||
build
|
||||
coverage
|
||||
packages
|
||||
@@ -0,0 +1,4 @@
|
||||
// Copyright 2017-2021 @polkadot/api authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
module.exports = require('@polkadot/dev/config/prettier.cjs');
|
||||
+46
-9
File diff suppressed because one or more lines are too long
+46
-23
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
+591
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.3.3.cjs
|
||||
yarnPath: .yarn/releases/yarn-3.0.0-rc.2.cjs
|
||||
|
||||
+683
@@ -1,5 +1,688 @@
|
||||
# CHANGELOG
|
||||
|
||||
## 4.14.1 Jun 14, 2021
|
||||
|
||||
Upgrade priority: Low. Internal adjustment only, no major external usage changes.
|
||||
|
||||
Contributed:
|
||||
|
||||
- Adjust types for uniques (Thanks to https://github.com/hamidra)
|
||||
- Add `ValidationCodeHash` type (Thanks to https://github.com/andresilva)
|
||||
- Extend `OriginCaller` type creation (Thanks to https://github.com/xlc)
|
||||
|
||||
Changes:
|
||||
|
||||
- Do strict length checking on `[u8; <length>]` type inputs
|
||||
- Adjust keys/entries retrieval batch sizes
|
||||
- Add upgrade block for Kusama 9040
|
||||
- Use `BN` imports from `@polkadot/util`
|
||||
|
||||
|
||||
## 4.13.1 Jun 6, 2021
|
||||
|
||||
Upgrade priority: Medium. Required for users connecting to Statemine and future Kusama upgrades.
|
||||
|
||||
Changes:
|
||||
|
||||
- Overrides for `westmint` spec (same as `statemint`)
|
||||
- Adjust `tx.session.setKeys` TS augmentation to allow `string` & `Uint8Array` keys
|
||||
- Add & adjust types for latest Cumulus code
|
||||
- Added 9031-9033 upgrade block for Westend
|
||||
- Update static metadata to latest Substrate
|
||||
- Optimize map retrieval with split page sizes for keys & values
|
||||
- Sanitizing `BN` imports to `type`-only as required
|
||||
|
||||
|
||||
## 4.12.1 May 30, 2021
|
||||
|
||||
Upgrade priority: Low. Internal adjustment only, no major external usage changes.
|
||||
|
||||
Changelog:
|
||||
|
||||
- Update `FundInfo` type with Polkadot (Thanks to https://github.com/arjanz)
|
||||
|
||||
Changes:
|
||||
|
||||
- Allow storage queries with default keys values
|
||||
- Align identity `Data` to limit to 32 bytes in the `Raw` enum (as per Substrate)
|
||||
- Align static (test & docs-only) metadata with latest Substrate master
|
||||
- Added 9030 upgrade blocks for Kusama & Westend
|
||||
- Cleanup of Eth pallet RPC definitions
|
||||
- Cleanup README for `@polkadot/rpc-core` (recommended for internal-usage only)
|
||||
- Cleanup internal tests (no dangling handles, cater for Jest 27)
|
||||
|
||||
|
||||
## 4.11.2 May 24, 2021
|
||||
|
||||
Upgrade priority: Low. Recommended where users are having TS mismatches with type definitions created on older versions.
|
||||
|
||||
Changes:
|
||||
|
||||
- Add backwards-compatible TS-only `AugmentedQueryDoubleMap` type (unused now in type generation)
|
||||
|
||||
|
||||
## 4.11.1 May 23, 2021
|
||||
|
||||
Upgrade priority: Low. Recommended for users using staking entries on Polkadot and users of Substrate master.
|
||||
|
||||
Changes:
|
||||
|
||||
- Fix metadata v13 storage decoding on `NMap`
|
||||
- Add augmentation & keys/entries for NMap types
|
||||
- Return additional error information from internal u8a decoding failures
|
||||
- Adjust Westend types for 16 nominators-only
|
||||
- Add support for `DisallowSigned` (as per shell runtime) extension
|
||||
- Display small hex-slice with u8a decoding failures
|
||||
- Add `state_getChildReadProof` RPC
|
||||
- Cleanup Rococo known types (only as used)
|
||||
- Under Node.js allow for WS receiving up to 16MB messages
|
||||
- Update entries/keys for max of 256 items per call
|
||||
|
||||
|
||||
## 4.10.1 May 17, 2021
|
||||
|
||||
Upgrade priority: Medium. Recommended for uses of Polkadot/Kusama 9010 runtimes.
|
||||
|
||||
- **Breaking change** Support for the contracts V2 compatibility has been dropped in `@polkadot/api-contract`
|
||||
|
||||
Contributed:
|
||||
|
||||
- Expose RPC definitions via `.meta` (Thanks to https://github.com/jiqiang90)
|
||||
- Adjust staking derives for chain-specific optional fields (https://github.com/WoeOm)
|
||||
- Update base Centrifuge types (Thanks to https://github.com/branan)
|
||||
|
||||
Changes:
|
||||
|
||||
- Allow for `Bounded*` type usage (as per latest Substrate)
|
||||
- Adjust internal TS definitions for providers
|
||||
- Fix `ContractRx` query result definitions (no extra Observable)
|
||||
- Handle contract call RPC result directly as `Raw` (returned as hex)
|
||||
- Use `BN_*` constants as non-specified defaults in contract interfaces
|
||||
- Remove all type overrides for node/node-template (API tracks latest)
|
||||
- Contracts ABI now supports metadata version where indexes are 0-based
|
||||
- Remove support for the old-style V2 contracts from `@polkadot/api-contract`
|
||||
- Adjust historic decoration, return as-at registry via `getHeader`, `getMetadata` & `getRuntimeVersion`
|
||||
- Adjust `VecFixed` to allow for the handling of hex inputs
|
||||
- Adjust `Compact<*>` to allow for wrapped `toBigInt()` conversions
|
||||
- Fix `isPedantic` decoding to correctly handle `Text`
|
||||
- Cater for new `phragmenElection` module naming
|
||||
- Add Kusama & Westend 9010 upgrade blocks
|
||||
- Adjust `CompactSolution` for 24 nominators
|
||||
- Bump static metadata to latest Substrate
|
||||
|
||||
|
||||
## 4.9.1 May 6, 2021
|
||||
|
||||
Upgrade priority: Medium. Required for the next v0.9.0 Polkadot/Kusama chain upgrades where parachains are used.
|
||||
|
||||
- **Breaking change** The previously deprecated contracts interfaces, has been removed. Update to `<myContract>.query.*`, `<myContract>.tx.*` and `<myCode>.tx.*` interfaces as per the previous code usage hints.
|
||||
- **Important** By default the `isPedantic` mode is now switched on for storage queries. This means that the API will fail on any types where the input/output decoding doesn't match 100%
|
||||
|
||||
Changes:
|
||||
|
||||
- Re-add isPedantic check on storage decoding
|
||||
- `ConsensusEngineId` now implements `[u8;4]` (mapping closer to Rust source)
|
||||
- Additional Xcm types
|
||||
- Adjust parachain types
|
||||
- Remove error logging on createType (details passed in error)
|
||||
- Adjust `ContractInfo` type as per latest Substrate
|
||||
- Adjust `DigestItem` type as per latest Substrate
|
||||
- Adjust re-encoding of `BitVec` based on decoded length
|
||||
- Added `contracts_instantiate`, `state_traceBlock` & `system_reservedPeers` RPCs
|
||||
- Prepare for auto-capability detection with historic `.at` queries
|
||||
- Add known upgrade block for Westend 900 & 9000
|
||||
- Remove all deprecated interfaces inside `@polkadot/api-contracts`
|
||||
- Initial support for NMap storage keys
|
||||
- Support metadata v13 from Substrate (upcoming upgrade)
|
||||
- Optimize historic metadata retrieval from rpc core
|
||||
|
||||
|
||||
## 4.8.1 May 2, 2021
|
||||
|
||||
Upgrade priority: Low. Recommended when using or developing for parachains.
|
||||
|
||||
Changes:
|
||||
|
||||
- De-alias xcm `Outcome` (used in multiple pallettes)
|
||||
- Adjust xcm types as per latest, e.g. `XcmError`
|
||||
- Fix generate of well-known storage keys (e.g. `:code`)
|
||||
- Optimize metadata unknown type validation
|
||||
- Allow metadata creation for `Map` or `Record`
|
||||
- Expose additional camelCase `method` on `AbiMessage` (maps to decorated name)
|
||||
- Added explicit double-byte ss58 `AccountId` encoding test
|
||||
- Add known upgrade block for Polkadot v30
|
||||
- Cleanup WebSocket handlers when close event has been received
|
||||
- Update to latest Substrate metadata
|
||||
|
||||
|
||||
## 4.7.2 Apr 26, 2021
|
||||
|
||||
Upgrade priority: Low. Recommended for users of 4.7.1 using nvm
|
||||
|
||||
Changes:
|
||||
|
||||
- Update `EthBlock`/`EthHeader` types (as per Rust origin)
|
||||
- Updated Xcm `OriginKind` enum
|
||||
- Add derives for `membership`
|
||||
- Cleanups on encodedLength calculations
|
||||
- Update `.nvmrc` to reflect engines changes
|
||||
|
||||
|
||||
## 4.7.1 Apr 25, 2021
|
||||
|
||||
Upgrade priority: Low. Recommended for users following Substrate master.
|
||||
|
||||
Changes:
|
||||
|
||||
- Adjust Struct decoding with better error messages on invalid input objects
|
||||
- Add support for new `BoundedVec` type
|
||||
- Expand `Data` type (as used in identity), with all is/as getters
|
||||
- Updated `Xcm` types (with Plularity)
|
||||
- Adjust `DispatchError` type as per current Substrate master
|
||||
- Adjusted Statemint `Proxy` type
|
||||
- Remove metadata generation dependency on well-known.json (dedupe)
|
||||
- Adjust WebSocket reconnection delay from 1s to 2.5s
|
||||
- Revert Beefy keys addition for Westend
|
||||
- Add explicit `engines` config to `package.json`
|
||||
- Support for `None` in `RewardDestination`
|
||||
- Align with latest substrate metadata
|
||||
|
||||
|
||||
## 4.6.2 Apr 19, 2021
|
||||
|
||||
Upgrade priority: Low. Recommended for users of Kusama/Polkadot.
|
||||
|
||||
Changes:
|
||||
|
||||
- Correct Kusama/Polkadot runtime 30 session key definitions
|
||||
|
||||
|
||||
## 4.6.1 Apr 19, 2021
|
||||
|
||||
Upgrade priority: Low. Recommended if used in a Node.js 15.x environment.
|
||||
|
||||
Changes:
|
||||
|
||||
- Assert keypair validity in signing operations
|
||||
- Expose `internalError` on submittable results (e.g. event decoding errors)
|
||||
- Simplify session derives for old/new
|
||||
- Add Statemint to known types
|
||||
- Add support for `rpc.beefy.subscribeJustifications`
|
||||
- Update Xcm types
|
||||
- Explicitly handle `isReadyOrError` with `Api.create`
|
||||
- Add Kusama upgrade block for 2030
|
||||
|
||||
|
||||
## 4.5.1 Apr 12, 2021
|
||||
|
||||
Upgrade priority: Low. Recommended with usage with the Rococo testnet.
|
||||
|
||||
Changes:
|
||||
|
||||
- Update parachain types as per latest Polkadot
|
||||
- Cater for `Keys` with `BEEFY` session keys
|
||||
- Update `Keys` injection to allow for on-chain type detection
|
||||
- Add `Westend` known upgrade block for runtime 50
|
||||
- Align types with latest Substrate master
|
||||
- Adjust keepalive `system_health` timer
|
||||
|
||||
|
||||
## 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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -21,26 +21,10 @@ 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/metadata](packages/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/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)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2020 @polkadot/api authors & contributors
|
||||
// Copyright 2017-2021 @polkadot/api authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
module.exports = require('@polkadot/dev/config/babel-config-cjs.cjs');
|
||||
@@ -1,9 +1,10 @@
|
||||
// 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.cjs');
|
||||
|
||||
module.exports = Object.assign({}, config, {
|
||||
module.exports = {
|
||||
...config,
|
||||
moduleNameMapper: {
|
||||
'@polkadot/api-(contract|derive)(.*)$': '<rootDir>/packages/api-$1/src/$2',
|
||||
// eslint-disable-next-line sort-keys
|
||||
@@ -26,5 +27,6 @@ module.exports = Object.assign({}, config, {
|
||||
'<rootDir>/packages/types/build',
|
||||
'<rootDir>/packages/types-known/build'
|
||||
],
|
||||
resolver: '@polkadot/dev/config/jest-resolver.cjs'
|
||||
});
|
||||
testTimeout: 10000,
|
||||
transformIgnorePatterns: ['/node_modules/(?!@polkadot|@babel/runtime/helpers/esm/)']
|
||||
};
|
||||
+14
-12
@@ -3,14 +3,16 @@
|
||||
"author": "Jaco Greeff <jacogr@gmail.com>",
|
||||
"license": "Apache-2",
|
||||
"private": true,
|
||||
"type": "commonjs",
|
||||
"workspaces": [
|
||||
"packages/*"
|
||||
],
|
||||
"resolutions": {
|
||||
"typescript": "^4.0.5"
|
||||
"typescript": "^4.3.2"
|
||||
},
|
||||
"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",
|
||||
@@ -18,19 +20,19 @@
|
||||
"lint": "polkadot-dev-run-lint",
|
||||
"clean": "polkadot-dev-clean-build",
|
||||
"postinstall": "polkadot-dev-yarn-only",
|
||||
"test": "polkadot-dev-run-test --coverage --runInBand --testPathIgnorePatterns e2e",
|
||||
"test:one": "polkadot-dev-run-test",
|
||||
"test": "polkadot-dev-run-test --coverage --detectOpenHandles --forceExit --runInBand --testPathIgnorePatterns e2e",
|
||||
"test:one": "polkadot-dev-run-test --detectOpenHandles --forceExit",
|
||||
"test:watch": "polkadot-dev-run-test --watch"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.12.3",
|
||||
"@babel/register": "^7.12.1",
|
||||
"@babel/runtime": "^7.12.5",
|
||||
"@polkadot/dev": "^0.60.2",
|
||||
"@polkadot/ts": "^0.3.55",
|
||||
"@babel/core": "^7.14.5",
|
||||
"@babel/register": "^7.14.5",
|
||||
"@babel/runtime": "^7.14.5",
|
||||
"@polkadot/dev": "^0.62.42",
|
||||
"@polkadot/ts": "^0.3.90",
|
||||
"@polkadot/typegen": "workspace:packages/typegen",
|
||||
"@types/jest": "^26.0.15",
|
||||
"copyfiles": "^2.4.0"
|
||||
"@types/jest": "^26.0.23",
|
||||
"copyfiles": "^2.4.1"
|
||||
},
|
||||
"version": "2.7.1"
|
||||
"version": "4.14.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,13 +1,16 @@
|
||||
{
|
||||
"name": "@polkadot/api-contract",
|
||||
"version": "2.7.1",
|
||||
"version": "4.14.1",
|
||||
"type": "module",
|
||||
"description": "Interfaces for interacting with contracts and contract ABIs",
|
||||
"main": "index.js",
|
||||
"sideEffects": false,
|
||||
"keywords": [
|
||||
"Polkadot",
|
||||
"ABI"
|
||||
"sideEffects": [
|
||||
"./detectPackage.js",
|
||||
"./detectPackage.cjs"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=14.0.0"
|
||||
},
|
||||
"author": "Jaco Greeff <jacogr@gmail.com>",
|
||||
"maintainers": [],
|
||||
"contributors": [],
|
||||
@@ -16,11 +19,10 @@
|
||||
"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.12.5",
|
||||
"@polkadot/api": "2.7.1",
|
||||
"@polkadot/types": "2.7.1",
|
||||
"@polkadot/util": "^4.1.1",
|
||||
"bn.js": "^5.1.3",
|
||||
"rxjs": "^6.6.3"
|
||||
"@babel/runtime": "^7.14.5",
|
||||
"@polkadot/api": "4.14.1",
|
||||
"@polkadot/types": "4.14.1",
|
||||
"@polkadot/util": "^6.8.1",
|
||||
"@polkadot/x-rxjs": "^6.8.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,18 @@
|
||||
// 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 '.';
|
||||
import { blake2AsHex } from '@polkadot/util-crypto';
|
||||
|
||||
import abis from '../test/contracts';
|
||||
import { Abi } from '.';
|
||||
|
||||
interface JSONAbi {
|
||||
source: {
|
||||
compiler: string,
|
||||
hash: string,
|
||||
language: string,
|
||||
wasm: string
|
||||
},
|
||||
spec: {
|
||||
messages: {
|
||||
name: string[] | string
|
||||
@@ -28,4 +35,18 @@ describe('Abi', (): void => {
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
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,17 +1,15 @@
|
||||
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
|
||||
// Copyright 2017-2021 @polkadot/api-contract authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { AnyJson, Codec, CodecArg } from '@polkadot/types/types';
|
||||
import { ChainProperties, ContractConstructorSpec, ContractEventSpec, ContractMessageSpec, ContractMessageParamSpec, ContractProject } from '@polkadot/types/interfaces';
|
||||
import { AbiConstructor, AbiEvent, AbiMessage, AbiParam, DecodedEvent, DecodedMessage } 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 { Bytes } from '@polkadot/types';
|
||||
import { assert, assertReturn, compactAddLength, compactStripLength, isNumber, isObject, isString, logger, stringCamelCase, u8aConcat, u8aToHex } from '@polkadot/util';
|
||||
import { assert, assertReturn, compactAddLength, compactStripLength, isNumber, isObject, isString, logger, stringCamelCase, stringify, u8aConcat, u8aToHex } from '@polkadot/util';
|
||||
|
||||
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 {
|
||||
@@ -21,7 +19,7 @@ function findMessage <T extends AbiMessage> (list: T[], messageOrId: T | string
|
||||
? list.find(({ identifier }) => [identifier, stringCamelCase(identifier)].includes(messageOrId.toString()))
|
||||
: messageOrId;
|
||||
|
||||
return assertReturn(message, `Attempted to call an invalid contract interface, ${JSON.stringify(messageOrId)}`);
|
||||
return assertReturn(message, `Attempted to call an invalid contract interface, ${stringify(messageOrId)}`);
|
||||
}
|
||||
|
||||
export class Abi {
|
||||
@@ -45,13 +43,13 @@ export class Abi {
|
||||
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');
|
||||
|
||||
this.json = json;
|
||||
this.registry = new MetaRegistry(chainProperties);
|
||||
this.registry = new MetaRegistry(json.metadataVersion as string, 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.registry.getMetaTypeDef({ type: this.registry.createType('SiLookupTypeId', index + this.registry.typeOffset) })
|
||||
);
|
||||
this.constructors = this.project.spec.constructors.map((spec: ContractConstructorSpec, index) =>
|
||||
this.#createMessage(spec, index, {
|
||||
@@ -81,7 +79,7 @@ export class Abi {
|
||||
const index = data[0];
|
||||
const event = this.#events[index];
|
||||
|
||||
assert(event, `Unable to find event with index ${index}`);
|
||||
assert(event, () => `Unable to find event with index ${index}`);
|
||||
|
||||
return event.fromU8a(data.subarray(1));
|
||||
}
|
||||
@@ -118,7 +116,7 @@ export class Abi {
|
||||
type: this.registry.getMetaTypeDef(arg.type)
|
||||
};
|
||||
} catch (error) {
|
||||
l.error(`Error expanding argument ${index} in ${JSON.stringify(spec)}`);
|
||||
l.error(`Error expanding argument ${index} in ${stringify(spec)}`);
|
||||
|
||||
throw error;
|
||||
}
|
||||
@@ -143,6 +141,7 @@ export class Abi {
|
||||
|
||||
#createMessage = (spec: ContractMessageSpec | ContractConstructorSpec, index: number, add: Partial<AbiMessage> = {}): AbiMessage => {
|
||||
const args = this.#createArgs(spec.args, spec);
|
||||
const identifier = spec.name.toString();
|
||||
const message = {
|
||||
...add,
|
||||
args,
|
||||
@@ -151,11 +150,12 @@ export class Abi {
|
||||
args: this.#decodeArgs(args, data),
|
||||
message
|
||||
}),
|
||||
identifier: spec.name.toString(),
|
||||
identifier,
|
||||
index,
|
||||
method: stringCamelCase(identifier),
|
||||
selector: spec.selector,
|
||||
toU8a: (params: CodecArg[], additional?: Uint8Array) =>
|
||||
this.#encodeArgs(spec, args, params, additional)
|
||||
toU8a: (params: CodecArg[]) =>
|
||||
this.#encodeArgs(spec, args, params)
|
||||
};
|
||||
|
||||
return message;
|
||||
@@ -185,14 +185,13 @@ export class Abi {
|
||||
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}`);
|
||||
#encodeArgs = ({ name, selector }: ContractMessageSpec | ContractConstructorSpec, args: AbiParam[], data: CodecArg[]): 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
|
||||
...args.map(({ type }, index) => this.registry.createType(type.type as 'Text', data[index]).toU8a())
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
|
||||
// Copyright 2017-2021 @polkadot/api-contract authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
|
||||
import { Abi } from '.';
|
||||
|
||||
import abis from '../test/contracts';
|
||||
import { Abi } from '.';
|
||||
|
||||
describe('MetaRegistry', (): void => {
|
||||
Object.keys(abis).forEach((abiName) => {
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
|
||||
// Copyright 2017-2021 @polkadot/api-contract authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { ContractDisplayName, ChainProperties, SiField, SiLookupTypeId, SiType, SiTypeDefArray, SiTypeDefVariant, SiTypeDefSequence, SiTypeDefTuple, SiVariant } from '@polkadot/types/interfaces';
|
||||
import { InterfaceTypes, TypeDef, TypeDefInfo } from '@polkadot/types/types';
|
||||
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 { assert, isUndefined } from '@polkadot/util';
|
||||
import { TypeRegistry, withTypeString } from '@polkadot/types/create';
|
||||
import { TypeDefInfo } from '@polkadot/types/types';
|
||||
import { assert, isUndefined } from '@polkadot/util';
|
||||
|
||||
interface PartialTypeSpec {
|
||||
readonly type: SiLookupTypeId;
|
||||
@@ -13,8 +14,8 @@ interface PartialTypeSpec {
|
||||
}
|
||||
|
||||
// convert the offset into project-specific, index-1
|
||||
export function getRegistryOffset (id: SiLookupTypeId): number {
|
||||
return id.toNumber() - 1;
|
||||
export function getRegistryOffset (id: SiLookupTypeId, typeOffset: number): number {
|
||||
return id.toNumber() - typeOffset;
|
||||
}
|
||||
|
||||
const PRIMITIVE_ALIAS: Record<string, keyof InterfaceTypes> = {
|
||||
@@ -27,11 +28,16 @@ const PRIMITIVE_ALWAYS = ['AccountId', 'AccountIndex', 'Address', 'Balance'];
|
||||
export class MetaRegistry extends TypeRegistry {
|
||||
public readonly metaTypeDefs: TypeDef[] = [];
|
||||
|
||||
public readonly typeOffset;
|
||||
|
||||
#siTypes: SiType[] = [];
|
||||
|
||||
constructor (chainProperties?: ChainProperties) {
|
||||
constructor (metadataVersion: string, chainProperties?: ChainProperties) {
|
||||
super();
|
||||
|
||||
// type indexes are 1-based pre-1.0 and 0-based post-1.0
|
||||
this.typeOffset = metadataVersion.split('.')[0] === '0' ? 1 : 0;
|
||||
|
||||
if (chainProperties) {
|
||||
this.setChainProperties(chainProperties);
|
||||
}
|
||||
@@ -42,7 +48,7 @@ export class MetaRegistry extends TypeRegistry {
|
||||
}
|
||||
|
||||
public getMetaTypeDef (typeSpec: PartialTypeSpec): TypeDef {
|
||||
const offset = getRegistryOffset(typeSpec.type);
|
||||
const offset = getRegistryOffset(typeSpec.type, this.typeOffset);
|
||||
let typeDef = this.metaTypeDefs[offset];
|
||||
|
||||
if (!typeDef) {
|
||||
@@ -77,19 +83,22 @@ export class MetaRegistry extends TypeRegistry {
|
||||
}
|
||||
|
||||
#getMetaType = (id: SiLookupTypeId): SiType => {
|
||||
const type = this.#siTypes[getRegistryOffset(id)];
|
||||
const type = this.#siTypes[getRegistryOffset(id, this.typeOffset)];
|
||||
|
||||
assert(!isUndefined(type), `getMetaType:: Unable to find ${id.toNumber()} in type values`);
|
||||
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() : '';
|
||||
const isPrimitivePath = !!path.length && (
|
||||
(path.length > 2 && path[0].eq('ink_env') && path[1].eq('types')) ||
|
||||
PRIMITIVE_ALWAYS.includes(path[path.length - 1].toString())
|
||||
);
|
||||
let typeDef: Omit<TypeDef, 'type'>;
|
||||
|
||||
if (type.path.join('::').startsWith('ink_env::types::') || PRIMITIVE_ALWAYS.includes(pathFinal)) {
|
||||
if (isPrimitivePath) {
|
||||
typeDef = this.#extractPrimitivePath(type);
|
||||
} else if (type.def.isPrimitive) {
|
||||
typeDef = this.#extractPrimitive(type);
|
||||
@@ -127,7 +136,7 @@ export class MetaRegistry extends TypeRegistry {
|
||||
}
|
||||
|
||||
#extractArray = ({ len: length, type }: SiTypeDefArray): Omit<TypeDef, 'type'> => {
|
||||
assert(!length || length.toNumber() <= 256, 'MetaRegistry: Only support for [Type; <length>], where length > 256');
|
||||
assert(!length || length.toNumber() <= 256, 'MetaRegistry: Only support for [Type; <length>], where length <= 256');
|
||||
|
||||
return {
|
||||
info: TypeDefInfo.VecFixed,
|
||||
@@ -143,27 +152,27 @@ export class MetaRegistry extends TypeRegistry {
|
||||
]),
|
||||
[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');
|
||||
}
|
||||
assert(isTuple || isStruct, '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() } : {})
|
||||
...(name.isSome
|
||||
? { name: name.unwrap().toString() }
|
||||
: {}
|
||||
)
|
||||
};
|
||||
});
|
||||
|
||||
return isTuple && sub.length === 1
|
||||
? sub[0]
|
||||
: { info, sub };
|
||||
: {
|
||||
// check for tuple first (no fields may be available)
|
||||
info: isTuple
|
||||
? TypeDefInfo.Tuple
|
||||
: TypeDefInfo.Struct,
|
||||
sub
|
||||
};
|
||||
}
|
||||
|
||||
#extractPrimitive = (type: SiType): TypeDef => {
|
||||
@@ -183,7 +192,7 @@ export class MetaRegistry extends TypeRegistry {
|
||||
}
|
||||
|
||||
#extractSequence = ({ type }: SiTypeDefSequence, id: SiLookupTypeId): Omit<TypeDef, 'type'> => {
|
||||
assert(!!type, `ContractRegistry: Invalid sequence type found at id ${id.toString()}`);
|
||||
assert(!!type, () => `ContractRegistry: Invalid sequence type found at id ${id.toString()}`);
|
||||
|
||||
return {
|
||||
info: TypeDefInfo.Vec,
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
// 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 { assert } from '@polkadot/util';
|
||||
import { assert, isFunction } from '@polkadot/util';
|
||||
|
||||
import { Abi } from '../Abi';
|
||||
|
||||
@@ -26,6 +26,6 @@ export 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(isFunction(api.rx.tx.contracts?.instantiateWithCode), 'You need to connect to a node with a V3 contracts module. Your node does not expose api.tx.contracts.instantiateWithCode on this instance');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,48 +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, BlueprintOptions } from '../types';
|
||||
import { BlueprintDeploy, ContractGeneric, MapConstructorExec } 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 { MapConstructorExec } from './types';
|
||||
|
||||
import BN from 'bn.js';
|
||||
import { SubmittableResult } from '@polkadot/api';
|
||||
import { ApiBase } from '@polkadot/api/base';
|
||||
import { Bytes } from '@polkadot/types';
|
||||
import { isUndefined, stringCamelCase, compactAddLength, u8aToU8a } from '@polkadot/util';
|
||||
import { randomAsU8a } from '@polkadot/util-crypto';
|
||||
import { BN_ZERO, isUndefined } from '@polkadot/util';
|
||||
|
||||
import { Abi } from '../Abi';
|
||||
import { applyOnEvent, extractOptions, isOptions } from '../util';
|
||||
import { applyOnEvent } from '../util';
|
||||
import { Base } from './Base';
|
||||
import { Contract } from './Contract';
|
||||
|
||||
const EMPTY_SALT = new Uint8Array();
|
||||
|
||||
function createTx <ApiType extends ApiTypes> (fn: (options: BlueprintOptions, params: CodecArg[]) => SubmittableExtrinsic<ApiType, BlueprintSubmittableResult<ApiType>>): BlueprintDeploy<ApiType> {
|
||||
return (options: BigInt | string | number | BN | BlueprintOptions, ...params: CodecArg[]): SubmittableExtrinsic<ApiType, BlueprintSubmittableResult<ApiType>> =>
|
||||
isOptions(options)
|
||||
? fn(options, params)
|
||||
: fn(...extractOptions(options, params));
|
||||
}
|
||||
|
||||
function createWithId <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));
|
||||
}
|
||||
|
||||
function encodeSalt (salt: Uint8Array | string | null = randomAsU8a()) {
|
||||
return salt instanceof Bytes
|
||||
? salt
|
||||
: salt && salt.length
|
||||
? compactAddLength(u8aToU8a(salt))
|
||||
: EMPTY_SALT;
|
||||
}
|
||||
import { createBluePrintTx, encodeSalt } from './util';
|
||||
|
||||
export class BlueprintSubmittableResult<ApiType extends ApiTypes> extends SubmittableResult {
|
||||
public readonly contract?: Contract<ApiType>;
|
||||
@@ -60,25 +34,16 @@ export class Blueprint<ApiType extends ApiTypes> extends Base<ApiType> {
|
||||
*/
|
||||
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 = createWithId(this.#deploy);
|
||||
|
||||
this.abi.constructors.forEach((c): void => {
|
||||
const messageName = stringCamelCase(c.identifier);
|
||||
|
||||
if (isUndefined(this.#tx[messageName])) {
|
||||
this.#tx[messageName] = createTx((o, p) => this.#deploy(c, o, p));
|
||||
if (isUndefined(this.#tx[c.method])) {
|
||||
this.#tx[c.method] = createBluePrintTx((o, p) => this.#deploy(c, o, p));
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -87,20 +52,19 @@ export class Blueprint<ApiType extends ApiTypes> extends Base<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
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore new style with salt included
|
||||
? this.api.tx.contracts.instantiate(value, gasLimit, this.codeHash, encoded, encodedSalt)
|
||||
: 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)
|
||||
))
|
||||
);
|
||||
#deploy = (constructorOrId: AbiConstructor | string | number, { gasLimit = BN_ZERO, salt, value = BN_ZERO }: BlueprintOptions, params: CodecArg[]): SubmittableExtrinsic<ApiType, BlueprintSubmittableResult<ApiType>> => {
|
||||
return this.api.tx.contracts
|
||||
.instantiate(
|
||||
value,
|
||||
gasLimit,
|
||||
this.codeHash,
|
||||
this.abi.findConstructor(constructorOrId).toU8a(params),
|
||||
encodeSalt(salt)
|
||||
)
|
||||
.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)
|
||||
))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
|
||||
// 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 { mockApi } from './mock';
|
||||
import { Code } from './Code';
|
||||
import { mockApi } from './mock';
|
||||
|
||||
const wasmFlipper = fs.readFileSync(path.join(__dirname, '../../test/contracts/ink/flipper.wasm'));
|
||||
|
||||
|
||||
@@ -1,33 +1,41 @@
|
||||
// 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 { assert, compactAddLength, isWasm, u8aToU8a } from '@polkadot/util';
|
||||
import { assert, BN_ZERO, compactAddLength, isUndefined, isWasm, u8aToU8a } from '@polkadot/util';
|
||||
|
||||
import { Abi } from '../Abi';
|
||||
import { applyOnEvent } from '../util';
|
||||
import { Base } from './Base';
|
||||
import { Blueprint } from './Blueprint';
|
||||
import { Contract } from './Contract';
|
||||
import { createBluePrintTx, encodeSalt } from './util';
|
||||
|
||||
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 class Code<ApiType extends ApiTypes> extends Base<ApiType> {
|
||||
public readonly code: Uint8Array;
|
||||
|
||||
readonly #tx: MapConstructorExec<ApiType> = {};
|
||||
|
||||
constructor (api: ApiBase<ApiType>, abi: AnyJson | Abi, wasm: Uint8Array | string | Buffer | null | undefined, decorateMethod: DecorateMethod<ApiType>) {
|
||||
super(api, abi, decorateMethod);
|
||||
|
||||
@@ -36,18 +44,37 @@ export class Code<ApiType extends ApiTypes> extends Base<ApiType> {
|
||||
: u8aToU8a(wasm);
|
||||
|
||||
assert(isWasm(this.code), 'No WASM code provided');
|
||||
|
||||
this.abi.constructors.forEach((c): void => {
|
||||
if (isUndefined(this.#tx[c.method])) {
|
||||
this.#tx[c.method] = createBluePrintTx((o, p) => this.#instantiate(c, o, p));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Deploy the code bundle, creating a Blueprint.
|
||||
*/
|
||||
public createBlueprint (): SubmittableExtrinsic<ApiType, CodeSubmittableResult<ApiType>> {
|
||||
public get tx (): MapConstructorExec<ApiType> {
|
||||
return this.#tx;
|
||||
}
|
||||
|
||||
#instantiate = (constructorOrId: AbiConstructor | string | number, { gasLimit = BN_ZERO, salt, value = BN_ZERO }: BlueprintOptions, params: CodecArg[]): SubmittableExtrinsic<ApiType, CodeSubmittableResult<ApiType>> => {
|
||||
return this.api.tx.contracts
|
||||
.putCode(compactAddLength(this.code))
|
||||
.instantiateWithCode(
|
||||
value,
|
||||
gasLimit,
|
||||
compactAddLength(this.code),
|
||||
this.abi.findConstructor(constructorOrId).toU8a(params),
|
||||
encodeSalt(salt)
|
||||
)
|
||||
.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)
|
||||
))
|
||||
new CodeSubmittableResult(result, ...(applyOnEvent(result, ['CodeStored', 'Instantiated'], (records: EventRecord[]) =>
|
||||
records.reduce<[Blueprint<ApiType>?, Contract<ApiType>?]>(([blueprint, contract], { event }) =>
|
||||
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],
|
||||
[])
|
||||
) || []))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,27 +1,28 @@
|
||||
// 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, ContractExecResult, EventRecord } from '@polkadot/types/interfaces';
|
||||
import { AnyJson, CodecArg, ISubmittableResult, Registry } from '@polkadot/types/types';
|
||||
import { AbiMessage, ContractCallOutcome, ContractOptions, DecodedEvent } from '../types';
|
||||
import { ContractCallResult, ContractCallSend, ContractGeneric, ContractQuery, ContractTx, MapMessageQuery, MapMessageTx } 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, EventRecord, Weight } from '@polkadot/types/interfaces';
|
||||
import type { AnyJson, CodecArg, ISubmittableResult } from '@polkadot/types/types';
|
||||
import type { AbiMessage, ContractCallOutcome, ContractOptions, DecodedEvent } from '../types';
|
||||
import type { ContractCallResult, ContractCallSend, ContractQuery, ContractTx, MapMessageQuery, MapMessageTx } from './types';
|
||||
|
||||
import BN from 'bn.js';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { SubmittableResult } from '@polkadot/api';
|
||||
import { ApiBase } from '@polkadot/api/base';
|
||||
import { Bytes } from '@polkadot/types';
|
||||
import { assert, bnToBn, isFunction, isUndefined, logger, stringCamelCase } from '@polkadot/util';
|
||||
import { createTypeUnsafe } from '@polkadot/types';
|
||||
import { assert, BN, BN_HUNDRED, BN_ONE, BN_ZERO, bnToBn, isFunction, isUndefined, logger } from '@polkadot/util';
|
||||
import { map } from '@polkadot/x-rxjs/operators';
|
||||
|
||||
import { Abi } from '../Abi';
|
||||
import { applyOnEvent, extractOptions, formatData, isOptions } from '../util';
|
||||
import { applyOnEvent, extractOptions, isOptions } from '../util';
|
||||
import { Base } from './Base';
|
||||
|
||||
// As per Rust, 5 * GAS_PER_SEC
|
||||
const MAX_CALL_GAS = new BN(5_000_000_000_000).subn(1);
|
||||
const MAX_CALL_GAS = new BN(5_000_000_000_000).isub(BN_ONE);
|
||||
const ERROR_NO_CALL = 'Your node does not expose the contracts.call RPC. This is most probably due to a runtime configuration.';
|
||||
|
||||
const l = logger('Contract');
|
||||
|
||||
function createQuery <ApiType extends ApiTypes> (fn: (origin: string | AccountId | Uint8Array, options: ContractOptions, params: CodecArg[]) => ContractCallResult<ApiType, ContractCallOutcome>): ContractQuery<ApiType> {
|
||||
@@ -38,13 +39,6 @@ function createTx <ApiType extends ApiTypes> (fn: (options: ContractOptions, par
|
||||
: fn(...extractOptions(options, params));
|
||||
}
|
||||
|
||||
function createWithId <T> (fn: (messageOrId: AbiMessage | string | number, options: ContractOptions, params: CodecArg[]) => T): ContractGeneric<ContractOptions, T> {
|
||||
return (messageOrId: AbiMessage | string | number, options: BigInt | string | number | BN | ContractOptions, ...params: CodecArg[]): T =>
|
||||
isOptions(options)
|
||||
? fn(messageOrId, options, params)
|
||||
: fn(messageOrId, ...extractOptions(options, params));
|
||||
}
|
||||
|
||||
export class ContractSubmittableResult extends SubmittableResult {
|
||||
public readonly contractEvents?: DecodedEvent[];
|
||||
|
||||
@@ -55,51 +49,12 @@ export class ContractSubmittableResult extends SubmittableResult {
|
||||
}
|
||||
}
|
||||
|
||||
// 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> = {};
|
||||
@@ -108,18 +63,14 @@ export class Contract<ApiType extends ApiTypes> extends Base<ApiType> {
|
||||
super(api, abi, decorateMethod);
|
||||
|
||||
this.address = this.registry.createType('AccountId', address);
|
||||
this.exec = createWithId(this.#exec);
|
||||
this.read = createWithId(this.#read);
|
||||
|
||||
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.#tx[m.method])) {
|
||||
this.#tx[m.method] = 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));
|
||||
if (isUndefined(this.#query[m.method])) {
|
||||
this.#query[m.method] = createQuery((f, o, p) => this.#read(m, o, p).send(f));
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -141,18 +92,27 @@ export class Contract<ApiType extends ApiTypes> extends Base<ApiType> {
|
||||
#getGas = (_gasLimit: BigInt | BN | string | number, isCall = false): BN => {
|
||||
const gasLimit = bnToBn(_gasLimit);
|
||||
|
||||
return gasLimit.lten(0)
|
||||
return gasLimit.lte(BN_ZERO)
|
||||
? isCall
|
||||
? MAX_CALL_GAS
|
||||
: this.api.consts.system.maximumBlockWeight.muln(64).divn(100)
|
||||
: (this.api.consts.system.blockWeights
|
||||
? this.api.consts.system.blockWeights.maxBlock
|
||||
: this.api.consts.system.maximumBlockWeight as Weight
|
||||
).muln(64).div(BN_HUNDRED)
|
||||
: gasLimit;
|
||||
}
|
||||
|
||||
#exec = (messageOrId: AbiMessage | string | number, { gasLimit = 0, value = 0 }: ContractOptions, params: CodecArg[]): SubmittableExtrinsic<ApiType> => {
|
||||
#exec = (messageOrId: AbiMessage | string | number, { gasLimit = BN_ZERO, value = BN_ZERO }: ContractOptions, params: CodecArg[]): SubmittableExtrinsic<ApiType> => {
|
||||
return this.api.tx.contracts
|
||||
.call(this.address, value, this.#getGas(gasLimit), this.abi.findMessage(messageOrId).toU8a(params))
|
||||
.call(
|
||||
this.address,
|
||||
value,
|
||||
this.#getGas(gasLimit),
|
||||
this.abi.findMessage(messageOrId).toU8a(params)
|
||||
)
|
||||
.withResultTransform((result: ISubmittableResult) =>
|
||||
new ContractSubmittableResult(result, applyOnEvent(result, 'ContractExecution', (records: EventRecord[]) =>
|
||||
// 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 {
|
||||
@@ -168,7 +128,7 @@ export class Contract<ApiType extends ApiTypes> extends Base<ApiType> {
|
||||
);
|
||||
}
|
||||
|
||||
#read = (messageOrId: AbiMessage | string | number, { gasLimit = 0, value = 0 }: ContractOptions, params: CodecArg[]): ContractCallSend<ApiType> => {
|
||||
#read = (messageOrId: AbiMessage | string | number, { gasLimit = BN_ZERO, value = BN_ZERO }: ContractOptions, params: CodecArg[]): ContractCallSend<ApiType> => {
|
||||
assert(this.hasRpcContractsCall, ERROR_NO_CALL);
|
||||
|
||||
const message = this.abi.findMessage(messageOrId);
|
||||
@@ -176,24 +136,24 @@ export class Contract<ApiType extends ApiTypes> extends Base<ApiType> {
|
||||
return {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
||||
send: this._decorateMethod((origin: string | AccountId | Uint8Array) =>
|
||||
this.api.rx.rpc.contracts.call.json({
|
||||
dest: this.address,
|
||||
gasLimit: this.#getGas(gasLimit, true),
|
||||
inputData: message.toU8a(params),
|
||||
origin,
|
||||
value
|
||||
}).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
|
||||
};
|
||||
}))
|
||||
this.api.rx.rpc.contracts
|
||||
.call({
|
||||
dest: this.address,
|
||||
gasLimit: this.#getGas(gasLimit, true),
|
||||
inputData: message.toU8a(params),
|
||||
origin,
|
||||
value
|
||||
})
|
||||
.pipe(
|
||||
map(({ debugMessage, gasConsumed, result }): ContractCallOutcome => ({
|
||||
debugMessage,
|
||||
gasConsumed,
|
||||
output: result.isOk && message.returnType
|
||||
? createTypeUnsafe(this.registry, message.returnType.type, [result.asOk.data.toU8a(true)], { isPedantic: true })
|
||||
: null,
|
||||
result
|
||||
}))
|
||||
)
|
||||
)
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2020 @polkadot/api authors & contributors
|
||||
// Copyright 2017-2021 @polkadot/api authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
export { Blueprint, BlueprintSubmittableResult } from './Blueprint';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
|
||||
// Copyright 2017-2021 @polkadot/api-contract authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { ApiBase } from '@polkadot/api/base';
|
||||
@@ -11,7 +11,7 @@ export const mockApi = {
|
||||
rx: {
|
||||
tx: {
|
||||
contracts: {
|
||||
putCode: (): never => {
|
||||
instantiateWithCode: (): never => {
|
||||
throw new Error('mock');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +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, ObsInnerType } from '@polkadot/api/types';
|
||||
import { SubmittableExtrinsic } from '@polkadot/api/submittable/types';
|
||||
import { AccountId } from '@polkadot/types/interfaces';
|
||||
import { CodecArg } from '@polkadot/types/types';
|
||||
import { AbiMessage, BlueprintOptions, ContractCallOutcome, ContractOptions } from '../types';
|
||||
|
||||
import BN from 'bn.js';
|
||||
import { Observable } from 'rxjs';
|
||||
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 { BN } from '@polkadot/util';
|
||||
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>;
|
||||
@@ -31,7 +30,7 @@ export interface ContractGeneric<O, T> {
|
||||
}
|
||||
|
||||
export type ContractCallResult<ApiType extends ApiTypes, T> = ApiType extends 'rxjs'
|
||||
? Observable<Observable<T>>
|
||||
? Observable<T>
|
||||
: Promise<ObsInnerType<Observable<T>>>;
|
||||
|
||||
export interface ContractCallSend<ApiType extends ApiTypes> {
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
// 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 { BN } from '@polkadot/util';
|
||||
import type { AbiConstructor, BlueprintOptions } from '../types';
|
||||
import type { BlueprintDeploy, ContractGeneric } from './types';
|
||||
|
||||
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;
|
||||
}
|
||||
@@ -1,10 +1,10 @@
|
||||
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
|
||||
// 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 { TestKeyringMap, createTestPairs } from '@polkadot/keyring/testingPairs';
|
||||
import { createTestPairs, TestKeyringMap } from '@polkadot/keyring/testingPairs';
|
||||
|
||||
import abiIncrementer from '../test/contracts/ink/incrementer.json';
|
||||
import { BlueprintPromise, ContractPromise } from '.';
|
||||
@@ -30,14 +30,12 @@ async function checkContract (api: ApiPromise, pairs: TestKeyringMap): Promise<v
|
||||
// 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();
|
||||
const api = await ApiPromise.create({
|
||||
hasher: (data: Uint8Array): Uint8Array => data
|
||||
});
|
||||
const pairs = createTestPairs();
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
||||
|
||||
@@ -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,7 +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 { Abi } from './Abi';
|
||||
import './detectPackage';
|
||||
|
||||
export { Blueprint as BlueprintRx, Code as CodeRx, Contract as ContractRx } from './rx';
|
||||
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.14.1' };
|
||||
@@ -1,8 +1,8 @@
|
||||
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
|
||||
// Copyright 2017-2021 @polkadot/api-contract authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { Hash } from '@polkadot/types/interfaces';
|
||||
import { AnyJson } from '@polkadot/types/types';
|
||||
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';
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
|
||||
// Copyright 2017-2021 @polkadot/api-contract authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { ApiPromise } from '@polkadot/api';
|
||||
import type { ApiPromise } from '@polkadot/api';
|
||||
import type { AnyJson } from '@polkadot/types/types';
|
||||
|
||||
import { decorateMethod } from '@polkadot/api/promise';
|
||||
import { AnyJson } from '@polkadot/types/types';
|
||||
|
||||
import { Abi } from '../Abi';
|
||||
import { Code as BaseCode } from '../base';
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
|
||||
// Copyright 2017-2021 @polkadot/api-contract authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { AccountId } from '@polkadot/types/interfaces';
|
||||
import { AnyJson } from '@polkadot/types/types';
|
||||
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';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
|
||||
// Copyright 2017-2021 @polkadot/api-contract authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
export { Blueprint } from './Blueprint';
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
|
||||
// Copyright 2017-2021 @polkadot/api-contract authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { BlueprintSubmittableResult as BaseBlueprintSubmittableResult, CodeSubmittableResult as BaseCodeSubmittableResult } from '../base';
|
||||
import type { BlueprintSubmittableResult as BaseBlueprintSubmittableResult, CodeSubmittableResult as BaseCodeSubmittableResult } from '../base';
|
||||
|
||||
export type BlueprintSubmittableResult = BaseBlueprintSubmittableResult<'promise'>;
|
||||
export type CodeSubmittableResult = BaseCodeSubmittableResult<'promise'>;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
|
||||
// Copyright 2017-2021 @polkadot/api-contract authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { Hash } from '@polkadot/types/interfaces';
|
||||
import { AnyJson } from '@polkadot/types/types';
|
||||
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';
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
// 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 type { ApiRx } from '@polkadot/api';
|
||||
import type { AnyJson } from '@polkadot/types/types';
|
||||
|
||||
import { ApiRx } from '@polkadot/api';
|
||||
import { decorateMethod } from '@polkadot/api/rx';
|
||||
|
||||
import { Abi } from '../Abi';
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
|
||||
// Copyright 2017-2021 @polkadot/api-contract authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { AccountId } from '@polkadot/types/interfaces';
|
||||
import { AnyJson } from '@polkadot/types/types';
|
||||
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';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
|
||||
// Copyright 2017-2021 @polkadot/api-contract authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
export { Blueprint } from './Blueprint';
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
|
||||
// Copyright 2017-2021 @polkadot/api-contract authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { BlueprintSubmittableResult as BaseBlueprintSubmittableResult, CodeSubmittableResult as BaseCodeSubmittableResult } from '../base';
|
||||
import type { BlueprintSubmittableResult as BaseBlueprintSubmittableResult, CodeSubmittableResult as BaseCodeSubmittableResult } from '../base';
|
||||
|
||||
export type BlueprintSubmittableResult = BaseBlueprintSubmittableResult<'promise'>;
|
||||
export type CodeSubmittableResult = BaseCodeSubmittableResult<'promise'>;
|
||||
|
||||
@@ -1,15 +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 { ContractExecResultResult, ContractSelector } from '@polkadot/types/interfaces';
|
||||
import { Codec, CodecArg, TypeDef } from '@polkadot/types/types';
|
||||
|
||||
import BN from 'bn.js';
|
||||
import { ApiBase } from '@polkadot/api/base';
|
||||
import { Text, u64 } from '@polkadot/types';
|
||||
|
||||
import { Abi } from '.';
|
||||
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 { BN } from '@polkadot/util';
|
||||
import type { Abi } from '.';
|
||||
|
||||
export interface ContractBase<ApiType extends ApiTypes> {
|
||||
readonly abi: Abi;
|
||||
@@ -41,9 +39,10 @@ export interface AbiMessage {
|
||||
isConstructor?: boolean;
|
||||
isMutating?: boolean;
|
||||
isPayable?: boolean;
|
||||
method: string;
|
||||
returnType?: TypeDef | null;
|
||||
selector: ContractSelector;
|
||||
toU8a: (params: CodecArg[], additional?: Uint8Array) => Uint8Array;
|
||||
toU8a: (params: CodecArg[]) => Uint8Array;
|
||||
}
|
||||
|
||||
export type AbiConstructor = AbiMessage;
|
||||
|
||||
@@ -1,27 +1,21 @@
|
||||
// Copyright 2017-2020 @polkadot/rpc-contract 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 { BlueprintOptions, ContractOptions } from './types';
|
||||
import type { SubmittableResult } from '@polkadot/api';
|
||||
import type { EventRecord } from '@polkadot/types/interfaces';
|
||||
import type { CodecArg } from '@polkadot/types/types';
|
||||
import type { BN } from '@polkadot/util';
|
||||
import type { BlueprintOptions, ContractOptions } from './types';
|
||||
|
||||
import BN from 'bn.js';
|
||||
import { Raw } from '@polkadot/types';
|
||||
import { createTypeUnsafe } from '@polkadot/types/create';
|
||||
import { isBn, isBigInt, isNumber, isString } from '@polkadot/util';
|
||||
import { isBigInt, isBn, isNumber, isString } from '@polkadot/util';
|
||||
|
||||
type ContractEvents = 'CodeStored' | 'ContractExecution' | 'Instantiated';
|
||||
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);
|
||||
}
|
||||
|
||||
export function applyOnEvent <T> (result: SubmittableResult, type: ContractEvents, fn: (records: EventRecord[]) => T): T | undefined {
|
||||
export function applyOnEvent <T> (result: SubmittableResult, types: ContractEvents[], fn: (records: EventRecord[]) => T): T | undefined {
|
||||
if (result.isInBlock || result.isFinalized) {
|
||||
const records = result.filterRecords('contracts', type);
|
||||
const records = result.filterRecords('contracts', types);
|
||||
|
||||
if (records.length) {
|
||||
return fn(records);
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
[
|
||||
{
|
||||
"info": 6,
|
||||
"type": "bool"
|
||||
}
|
||||
]
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
|
||||
// Copyright 2017-2021 @polkadot/api-contract authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import * as ink from './ink';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// 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';
|
||||
@@ -6,5 +6,6 @@ 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';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// 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 ints256 } from './ints256.json';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// 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 assetTransfer } from './assetTransfer.json';
|
||||
|
||||
@@ -1,14 +1,16 @@
|
||||
{
|
||||
"name": "@polkadot/api-derive",
|
||||
"version": "2.7.1",
|
||||
"version": "4.14.1",
|
||||
"type": "module",
|
||||
"description": "Common functions used across Polkadot, derived from RPC calls and storage queries.",
|
||||
"main": "index.js",
|
||||
"sideEffects": false,
|
||||
"keywords": [
|
||||
"Polkadot",
|
||||
"Promise",
|
||||
"RxJs"
|
||||
"sideEffects": [
|
||||
"./detectPackage.js",
|
||||
"./detectPackage.cjs"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=14.0.0"
|
||||
},
|
||||
"author": "Jaco Greeff <jacogr@gmail.com>",
|
||||
"maintainers": [],
|
||||
"contributors": [],
|
||||
@@ -17,18 +19,16 @@
|
||||
"bugs": "https://github.com/polkadot-js/api/issues",
|
||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/api-derive#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.12.5",
|
||||
"@polkadot/api": "2.7.1",
|
||||
"@polkadot/rpc-core": "2.7.1",
|
||||
"@polkadot/types": "2.7.1",
|
||||
"@polkadot/util": "^4.1.1",
|
||||
"@polkadot/util-crypto": "^4.1.1",
|
||||
"bn.js": "^5.1.3",
|
||||
"memoizee": "^0.4.14",
|
||||
"rxjs": "^6.6.3"
|
||||
"@babel/runtime": "^7.14.5",
|
||||
"@polkadot/api": "4.14.1",
|
||||
"@polkadot/rpc-core": "4.14.1",
|
||||
"@polkadot/types": "4.14.1",
|
||||
"@polkadot/util": "^6.8.1",
|
||||
"@polkadot/util-crypto": "^6.8.1",
|
||||
"@polkadot/x-rxjs": "^6.8.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/keyring": "^4.1.1",
|
||||
"@polkadot/rpc-provider": "2.7.1"
|
||||
"@polkadot/keyring": "^6.8.1",
|
||||
"@polkadot/rpc-provider": "4.14.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { AccountId, AccountIndex, Address } from '@polkadot/types/interfaces';
|
||||
import type { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import type { AccountId, AccountIndex, Address } from '@polkadot/types/interfaces';
|
||||
import type { Observable } from '@polkadot/x-rxjs';
|
||||
|
||||
import { Observable, of } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import { isU8a, assertReturn } from '@polkadot/util';
|
||||
import { assertReturn, isU8a } from '@polkadot/util';
|
||||
import { decodeAddress } from '@polkadot/util-crypto';
|
||||
import { of } from '@polkadot/x-rxjs';
|
||||
import { map } from '@polkadot/x-rxjs/operators';
|
||||
|
||||
import { memo } from '../util';
|
||||
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import { AccountId, Address, Balance } from '@polkadot/types/interfaces';
|
||||
import { ITuple } from '@polkadot/types/types';
|
||||
import { DeriveAccountFlags } from '../types';
|
||||
import type { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import type { Vec } from '@polkadot/types';
|
||||
import type { AccountId, Address, Balance } from '@polkadot/types/interfaces';
|
||||
import type { ITuple } from '@polkadot/types/types';
|
||||
import type { Observable } from '@polkadot/x-rxjs';
|
||||
import type { DeriveAccountFlags } from '../types';
|
||||
|
||||
import { Observable, combineLatest, of } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { Vec } from '@polkadot/types';
|
||||
import { combineLatest, of } from '@polkadot/x-rxjs';
|
||||
import { map } from '@polkadot/x-rxjs/operators';
|
||||
|
||||
import { memo } from '../util';
|
||||
|
||||
@@ -40,7 +41,11 @@ function parseFlags (address: AccountId | Address | string | null | undefined, [
|
||||
*/
|
||||
export function flags (instanceId: string, api: ApiInterfaceRx): (address?: AccountId | Address | string | null) => Observable<DeriveAccountFlags> {
|
||||
return memo(instanceId, (address?: AccountId | Address | string | null): Observable<DeriveAccountFlags> => {
|
||||
const councilSection = api.query.electionsPhragmen ? 'electionsPhragmen' : 'elections';
|
||||
const councilSection = api.query.phragmenElection
|
||||
? 'phragmenElection'
|
||||
: api.query.electionsPhragmen
|
||||
? 'electionsPhragmen'
|
||||
: 'elections';
|
||||
|
||||
return combineLatest<FlagsIntermediate>([
|
||||
address && api.query[councilSection]?.members
|
||||
|
||||
@@ -1,18 +1,19 @@
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { AccountId, AccountIndex, Address } from '@polkadot/types/interfaces';
|
||||
import { AccountIdAndIndex } from '../types';
|
||||
import type { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import type { AccountId, AccountIndex, Address } from '@polkadot/types/interfaces';
|
||||
import type { Observable } from '@polkadot/x-rxjs';
|
||||
import type { AccountIdAndIndex } from '../types';
|
||||
|
||||
import { Observable, of } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import { isU8a } from '@polkadot/util';
|
||||
import { decodeAddress } from '@polkadot/util-crypto';
|
||||
import { of } from '@polkadot/x-rxjs';
|
||||
import { map } from '@polkadot/x-rxjs/operators';
|
||||
|
||||
import { memo } from '../util';
|
||||
|
||||
function retrieve (api: ApiInterfaceRx, address: Address | AccountId | AccountIndex | string | null | undefined): Observable<AccountIdAndIndex> {
|
||||
function retrieve (api: ApiInterfaceRx, address: Address | AccountId | AccountIndex | Uint8Array | string | null | undefined): Observable<AccountIdAndIndex> {
|
||||
try {
|
||||
// yes, this can fail, don't care too much, catch will catch it
|
||||
const decoded = isU8a(address)
|
||||
@@ -39,7 +40,7 @@ function retrieve (api: ApiInterfaceRx, address: Address | AccountId | AccountIn
|
||||
|
||||
/**
|
||||
* @name idAndIndex
|
||||
* @param {(Address | AccountId | AccountIndex | string | null)} address - An accounts address in various formats.
|
||||
* @param {(Address | AccountId | AccountIndex | Uint8Array | string | null)} address - An accounts address in various formats.
|
||||
* @description An array containing the [[AccountId]] and [[AccountIndex]] as optional values.
|
||||
* @example
|
||||
* <BR>
|
||||
@@ -50,7 +51,7 @@ function retrieve (api: ApiInterfaceRx, address: Address | AccountId | AccountIn
|
||||
* });
|
||||
* ```
|
||||
*/
|
||||
export function idAndIndex (instanceId: string, api: ApiInterfaceRx): (address?: Address | AccountId | AccountIndex | string | null) => Observable<AccountIdAndIndex> {
|
||||
return memo(instanceId, (address?: Address | AccountId | AccountIndex | string | null): Observable<AccountIdAndIndex> =>
|
||||
export function idAndIndex (instanceId: string, api: ApiInterfaceRx): (address?: Address | AccountId | AccountIndex | Uint8Array | string | null) => Observable<AccountIdAndIndex> {
|
||||
return memo(instanceId, (address?: Address | AccountId | AccountIndex | Uint8Array | string | null): Observable<AccountIdAndIndex> =>
|
||||
retrieve(api, address));
|
||||
}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { AccountId, AccountIndex } from '@polkadot/types/interfaces';
|
||||
import { AccountIndexes } from '../types';
|
||||
import type { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import type { AccountId, AccountIndex } from '@polkadot/types/interfaces';
|
||||
import type { Observable } from '@polkadot/x-rxjs';
|
||||
import type { AccountIndexes } from '../types';
|
||||
|
||||
import { Observable } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import { map } from '@polkadot/x-rxjs/operators';
|
||||
|
||||
import { memo } from '../util';
|
||||
|
||||
|
||||
@@ -0,0 +1,141 @@
|
||||
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import type { Data, Option } from '@polkadot/types';
|
||||
import type { AccountId, IdentityInfoAdditional, Registration } from '@polkadot/types/interfaces';
|
||||
import type { ITuple } from '@polkadot/types/types';
|
||||
import type { Observable } from '@polkadot/x-rxjs';
|
||||
import type { DeriveAccountRegistration, DeriveHasIdentity } from '../types';
|
||||
|
||||
import { isHex, u8aToString } from '@polkadot/util';
|
||||
import { combineLatest, of } from '@polkadot/x-rxjs';
|
||||
import { map, switchMap } from '@polkadot/x-rxjs/operators';
|
||||
|
||||
import { memo } from '../util';
|
||||
|
||||
const UNDEF_HEX = { toHex: () => undefined };
|
||||
|
||||
function dataAsString (data: Data): string | undefined {
|
||||
return data.isRaw
|
||||
? u8aToString(data.asRaw.toU8a(true))
|
||||
: data.isNone
|
||||
? undefined
|
||||
: data.toHex();
|
||||
}
|
||||
|
||||
function extractOther (additional: IdentityInfoAdditional[]): Record<string, string> {
|
||||
return additional.reduce((other: Record<string, string>, [_key, _value]): Record<string, string> => {
|
||||
const key = dataAsString(_key);
|
||||
const value = dataAsString(_value);
|
||||
|
||||
if (key && value) {
|
||||
other[key] = value;
|
||||
}
|
||||
|
||||
return other;
|
||||
}, {});
|
||||
}
|
||||
|
||||
function extractIdentity (identityOfOpt?: Option<Registration>, superOf?: [AccountId, Data]): DeriveAccountRegistration {
|
||||
if (!identityOfOpt?.isSome) {
|
||||
return { judgements: [] };
|
||||
}
|
||||
|
||||
const { info, judgements } = identityOfOpt.unwrap();
|
||||
const topDisplay = dataAsString(info.display);
|
||||
|
||||
return {
|
||||
display: (superOf && dataAsString(superOf[1])) || topDisplay,
|
||||
displayParent: superOf && topDisplay,
|
||||
email: dataAsString(info.email),
|
||||
image: dataAsString(info.image),
|
||||
judgements,
|
||||
legal: dataAsString(info.legal),
|
||||
other: extractOther(info.additional),
|
||||
parent: superOf && superOf[0],
|
||||
pgp: info.pgpFingerprint.unwrapOr(UNDEF_HEX).toHex(),
|
||||
riot: dataAsString(info.riot),
|
||||
twitter: dataAsString(info.twitter),
|
||||
web: dataAsString(info.web)
|
||||
};
|
||||
}
|
||||
|
||||
function getParent (api: ApiInterfaceRx, identityOfOpt: Option<Registration> | undefined, superOfOpt: Option<ITuple<[AccountId, Data]>> | undefined): Observable<[Option<Registration> | undefined, [AccountId, Data] | undefined]> {
|
||||
if (identityOfOpt?.isSome) {
|
||||
// this identity has something set
|
||||
return of([identityOfOpt, undefined]);
|
||||
} else if (superOfOpt?.isSome) {
|
||||
const superOf = superOfOpt.unwrap();
|
||||
|
||||
// we have a super
|
||||
return combineLatest([
|
||||
api.query.identity.identityOf<Option<Registration>>(superOf[0]),
|
||||
of(superOf)
|
||||
]);
|
||||
}
|
||||
|
||||
// nothing of value returned
|
||||
return of([undefined, undefined]);
|
||||
}
|
||||
|
||||
function getBase (api: ApiInterfaceRx, accountId?: AccountId | Uint8Array | string): Observable<[Option<Registration> | undefined, Option<ITuple<[AccountId, Data]>> | undefined]> {
|
||||
return accountId && api.query.identity?.identityOf
|
||||
? api.queryMulti<[Option<Registration>, Option<ITuple<[AccountId, Data]>>]>([
|
||||
[api.query.identity.identityOf, accountId],
|
||||
[api.query.identity.superOf, accountId]
|
||||
])
|
||||
: of([undefined, undefined]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @name identity
|
||||
* @description Returns identity info for an account
|
||||
*/
|
||||
export function identity (instanceId: string, api: ApiInterfaceRx): (accountId?: AccountId | Uint8Array | string) => Observable<DeriveAccountRegistration> {
|
||||
return memo(instanceId, (accountId?: AccountId | Uint8Array | string): Observable<DeriveAccountRegistration> =>
|
||||
getBase(api, accountId).pipe(
|
||||
switchMap(([identityOfOpt, superOfOpt]) => getParent(api, identityOfOpt, superOfOpt)),
|
||||
map(([identityOfOpt, superOf]) => extractIdentity(identityOfOpt, superOf))
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
export function hasIdentity (instanceId: string, api: ApiInterfaceRx): (accountId: AccountId | Uint8Array | string) => Observable<DeriveHasIdentity> {
|
||||
return memo(instanceId, (accountId: AccountId | Uint8Array | string): Observable<DeriveHasIdentity> =>
|
||||
api.derive.accounts.hasIdentityMulti([accountId]).pipe(
|
||||
map(([first]) => first)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
export function hasIdentityMulti (instanceId: string, api: ApiInterfaceRx): (accountIds: (AccountId | Uint8Array | string)[]) => Observable<DeriveHasIdentity[]> {
|
||||
return memo(instanceId, (accountIds: (AccountId | Uint8Array | string)[]): Observable<DeriveHasIdentity[]> =>
|
||||
api.query.identity?.identityOf
|
||||
? combineLatest([
|
||||
api.query.identity.identityOf.multi<Option<Registration>>(accountIds),
|
||||
api.query.identity.superOf.multi<Option<ITuple<[AccountId, Data]>>>(accountIds)
|
||||
]).pipe(
|
||||
map(([identities, supers]) =>
|
||||
identities.map((identityOfOpt, index): DeriveHasIdentity => {
|
||||
const superOfOpt = supers[index];
|
||||
const parentId = superOfOpt && superOfOpt.isSome
|
||||
? superOfOpt.unwrap()[0].toString()
|
||||
: undefined;
|
||||
let display: string | undefined;
|
||||
|
||||
if (identityOfOpt && identityOfOpt.isSome) {
|
||||
const value = dataAsString(identityOfOpt.unwrap().info.display);
|
||||
|
||||
if (value && !isHex(value)) {
|
||||
display = value;
|
||||
}
|
||||
}
|
||||
|
||||
return { display, hasIdentity: !!(display || parentId), parentId };
|
||||
})
|
||||
)
|
||||
)
|
||||
: of(accountIds.map(() => ({ hasIdentity: false })))
|
||||
);
|
||||
}
|
||||
@@ -1,10 +1,11 @@
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
export * from './accountId';
|
||||
export * from './flags';
|
||||
export * from './idAndIndex';
|
||||
export * from './idToIndex';
|
||||
export * from './identity';
|
||||
export * from './indexToId';
|
||||
export * from './indexes';
|
||||
export * from './info';
|
||||
|
||||
@@ -1,40 +1,17 @@
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { AccountId, AccountIndex, BalanceOf } from '@polkadot/types/interfaces';
|
||||
import { ITuple } from '@polkadot/types/types';
|
||||
import type { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import type { Option } from '@polkadot/types';
|
||||
import type { AccountId, AccountIndex, BalanceOf } from '@polkadot/types/interfaces';
|
||||
import type { ITuple } from '@polkadot/types/types';
|
||||
import type { Observable } from '@polkadot/x-rxjs';
|
||||
|
||||
import { Observable, of } from 'rxjs';
|
||||
import { map, startWith } from 'rxjs/operators';
|
||||
import { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import { ENUMSET_SIZE } from '@polkadot/types/generic/AccountIndex';
|
||||
import { Option, Vec } from '@polkadot/types';
|
||||
import { isFunction } from '@polkadot/util';
|
||||
import { of } from '@polkadot/x-rxjs';
|
||||
import { map } from '@polkadot/x-rxjs/operators';
|
||||
|
||||
import { memo } from '../util';
|
||||
|
||||
function queryEnumSet (api: ApiInterfaceRx, _accountIndex: AccountIndex | string): Observable<AccountId | undefined> {
|
||||
const accountIndex = _accountIndex instanceof api.registry.createClass('AccountIndex')
|
||||
? _accountIndex
|
||||
: api.registry.createType('AccountIndex', _accountIndex);
|
||||
|
||||
return api.query.indices.enumSet<Vec<AccountId>>(accountIndex.div(ENUMSET_SIZE)).pipe(
|
||||
startWith([]),
|
||||
map((accounts): AccountId | undefined =>
|
||||
(accounts || [])[accountIndex.mod(ENUMSET_SIZE).toNumber()]
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
// current
|
||||
function query (api: ApiInterfaceRx, accountIndex: AccountIndex | string): Observable<AccountId | undefined> {
|
||||
return api.query.indices.accounts<Option<ITuple<[AccountId, BalanceOf]>>>(accountIndex).pipe(
|
||||
map((optResult): AccountId | undefined =>
|
||||
optResult.unwrapOr([])[0]
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @name indexToId
|
||||
* @param {( AccountIndex | string )} accountIndex - An accounts index in different formats.
|
||||
@@ -51,9 +28,11 @@ function query (api: ApiInterfaceRx, accountIndex: AccountIndex | string): Obser
|
||||
export function indexToId (instanceId: string, api: ApiInterfaceRx): (accountIndex: AccountIndex | string) => Observable<AccountId | undefined> {
|
||||
return memo(instanceId, (accountIndex: AccountIndex | string): Observable<AccountId | undefined> =>
|
||||
api.query.indices
|
||||
? isFunction(api.query.indices.accounts)
|
||||
? query(api, accountIndex)
|
||||
: queryEnumSet(api, accountIndex)
|
||||
? api.query.indices.accounts<Option<ITuple<[AccountId, BalanceOf]>>>(accountIndex).pipe(
|
||||
map((optResult): AccountId | undefined =>
|
||||
optResult.unwrapOr([])[0]
|
||||
)
|
||||
)
|
||||
: of(undefined)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,53 +1,23 @@
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import { AccountId, AccountIndex } from '@polkadot/types/interfaces';
|
||||
import { AccountIndexes } from '../types';
|
||||
import type { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import type { Observable } from '@polkadot/x-rxjs';
|
||||
import type { AccountIndexes } from '../types';
|
||||
|
||||
import { Observable, of } from 'rxjs';
|
||||
import { map, startWith, switchMap } from 'rxjs/operators';
|
||||
import { ENUMSET_SIZE } from '@polkadot/types/generic/AccountIndex';
|
||||
import { Vec } from '@polkadot/types';
|
||||
import { isFunction } from '@polkadot/util';
|
||||
import { of } from '@polkadot/x-rxjs';
|
||||
import { map, startWith } from '@polkadot/x-rxjs/operators';
|
||||
|
||||
import { memo } from '../util';
|
||||
|
||||
const enumsetSize = ENUMSET_SIZE.toNumber();
|
||||
|
||||
let indicesCache: AccountIndexes | null = null;
|
||||
|
||||
function queryEnumSet (api: ApiInterfaceRx): Observable<AccountIndexes> {
|
||||
return api.query.indices.nextEnumSet<AccountIndex>().pipe(
|
||||
// use the nextEnumSet (which is a counter of the number of sets) to construct
|
||||
// a range of values to query [0, 1, 2, ...]. Retrieve the full enum set for the
|
||||
// specific index - each query can return up to ENUMSET_SIZE (64) records, each
|
||||
// containing an AccountId
|
||||
switchMap((next: AccountIndex): Observable<Vec<AccountId>[]> =>
|
||||
api.query.indices.enumSet.multi<Vec<AccountId>>([...Array(next.toNumber() + 1).keys()])
|
||||
),
|
||||
map((all: AccountId[][]): AccountIndexes =>
|
||||
all.reduce((indexes: AccountIndexes, list, outerIndex): AccountIndexes => {
|
||||
(list || []).forEach((accountId, innerIndex): void => {
|
||||
// re-create the index based on position 0 is [0][0] and likewise
|
||||
// 64 (0..63 in first) is [1][0] (the first index value in set 2)
|
||||
const index = (outerIndex * enumsetSize) + innerIndex;
|
||||
|
||||
indexes[accountId.toString()] = api.registry.createType('AccountIndex', index);
|
||||
});
|
||||
|
||||
return indexes;
|
||||
}, {})
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
function queryAccounts (api: ApiInterfaceRx): Observable<AccountIndexes> {
|
||||
return api.query.indices.accounts.entries().pipe(
|
||||
map((entries): AccountIndexes =>
|
||||
entries.reduce((indexes: AccountIndexes, [key, idOpt]): AccountIndexes => {
|
||||
if (idOpt.isSome) {
|
||||
indexes[idOpt.unwrap()[0].toString()] = key.args[0] as AccountIndex;
|
||||
indexes[idOpt.unwrap()[0].toString()] = key.args[0];
|
||||
}
|
||||
|
||||
return indexes;
|
||||
@@ -77,9 +47,7 @@ export function indexes (instanceId: string, api: ApiInterfaceRx): () => Observa
|
||||
? of(indicesCache)
|
||||
: (
|
||||
api.query.indices
|
||||
? isFunction(api.query.indices.accounts)
|
||||
? queryAccounts(api).pipe(startWith({}))
|
||||
: queryEnumSet(api).pipe(startWith({}))
|
||||
? queryAccounts(api).pipe(startWith({}))
|
||||
: of({} as AccountIndexes)
|
||||
).pipe(
|
||||
map((indices): AccountIndexes => {
|
||||
|
||||
@@ -1,28 +1,19 @@
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import { AccountId, AccountIndex, Address, Balance, IdentityInfoAdditional, Registration } from '@polkadot/types/interfaces';
|
||||
import { ITuple } from '@polkadot/types/types';
|
||||
import { DeriveAccountInfo, DeriveAccountRegistration } from '../types';
|
||||
import type { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import type { Bytes, Option, u32 } from '@polkadot/types';
|
||||
import type { AccountId, AccountIndex, Address, Balance } from '@polkadot/types/interfaces';
|
||||
import type { ITuple } from '@polkadot/types/types';
|
||||
import type { Observable } from '@polkadot/x-rxjs';
|
||||
import type { DeriveAccountInfo, DeriveAccountRegistration } from '../types';
|
||||
|
||||
import { Observable, combineLatest, of } from 'rxjs';
|
||||
import { map, switchMap } from 'rxjs/operators';
|
||||
import { Bytes, Data, Option, u32 } from '@polkadot/types';
|
||||
import { u8aToString } from '@polkadot/util';
|
||||
import { combineLatest, of } from '@polkadot/x-rxjs';
|
||||
import { map, switchMap } from '@polkadot/x-rxjs/operators';
|
||||
|
||||
import { memo } from '../util';
|
||||
|
||||
const UNDEF_HEX = { toHex: () => undefined };
|
||||
|
||||
function dataAsString (data: Data): string | undefined {
|
||||
return data.isRaw
|
||||
? u8aToString(data.asRaw.toU8a(true))
|
||||
: data.isNone
|
||||
? undefined
|
||||
: data.toHex();
|
||||
}
|
||||
|
||||
function retrieveNick (api: ApiInterfaceRx, accountId?: AccountId): Observable<string | undefined> {
|
||||
return ((
|
||||
accountId && api.query.nicks?.nameOf
|
||||
@@ -37,86 +28,17 @@ function retrieveNick (api: ApiInterfaceRx, accountId?: AccountId): Observable<s
|
||||
);
|
||||
}
|
||||
|
||||
function extractOther (additional: IdentityInfoAdditional[]): Record<string, string> {
|
||||
return additional.reduce((other: Record<string, string>, [_key, _value]): Record<string, string> => {
|
||||
const key = dataAsString(_key);
|
||||
const value = dataAsString(_value);
|
||||
|
||||
if (key && value) {
|
||||
other[key] = value;
|
||||
}
|
||||
|
||||
return other;
|
||||
}, {});
|
||||
}
|
||||
|
||||
function extractIdentity (identityOfOpt?: Option<Registration>, superOf?: [AccountId, Data]): DeriveAccountRegistration {
|
||||
if (!identityOfOpt?.isSome) {
|
||||
return { judgements: [] };
|
||||
}
|
||||
|
||||
const { info, judgements } = identityOfOpt.unwrap();
|
||||
const topDisplay = dataAsString(info.display);
|
||||
|
||||
return {
|
||||
display: (superOf && dataAsString(superOf[1])) || topDisplay,
|
||||
displayParent: superOf && topDisplay,
|
||||
email: dataAsString(info.email),
|
||||
image: dataAsString(info.image),
|
||||
judgements,
|
||||
legal: dataAsString(info.legal),
|
||||
other: extractOther(info.additional),
|
||||
parent: superOf && superOf[0],
|
||||
pgp: info.pgpFingerprint.unwrapOr(UNDEF_HEX).toHex(),
|
||||
riot: dataAsString(info.riot),
|
||||
twitter: dataAsString(info.twitter),
|
||||
web: dataAsString(info.web)
|
||||
};
|
||||
}
|
||||
|
||||
function retrieveIdentity (api: ApiInterfaceRx, accountId?: AccountId): Observable<DeriveAccountRegistration> {
|
||||
return ((
|
||||
accountId && api.query.identity?.identityOf
|
||||
? api.queryMulti([
|
||||
[api.query.identity.identityOf, accountId],
|
||||
[api.query.identity.superOf, accountId]
|
||||
])
|
||||
: of([undefined, undefined])
|
||||
) as Observable<[Option<Registration> | undefined, Option<ITuple<[AccountId, Data]>> | undefined]>).pipe(
|
||||
switchMap(([identityOfOpt, superOfOpt]): Observable<[Option<Registration> | undefined, [AccountId, Data] | undefined]> => {
|
||||
if (identityOfOpt?.isSome) {
|
||||
// this identity has something set
|
||||
return of([identityOfOpt, undefined]);
|
||||
} else if (superOfOpt?.isSome) {
|
||||
const superOf = superOfOpt.unwrap();
|
||||
|
||||
// we have a super
|
||||
return combineLatest([
|
||||
api.query.identity.identityOf<Option<Registration>>(superOf[0]),
|
||||
of(superOf)
|
||||
]);
|
||||
}
|
||||
|
||||
// nothing of value returned
|
||||
return of([undefined, undefined]);
|
||||
}),
|
||||
map(([identityOfOpt, superOf]): DeriveAccountRegistration =>
|
||||
extractIdentity(identityOfOpt, superOf)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @name info
|
||||
* @description Returns aux. info with regards to an account, current that includes the accountId, accountIndex and nickname
|
||||
*/
|
||||
export function info (instanceId: string, api: ApiInterfaceRx): (address?: AccountIndex | AccountId | Address | string | null) => Observable<DeriveAccountInfo> {
|
||||
return memo(instanceId, (address?: AccountIndex | AccountId | Address | string | null): Observable<DeriveAccountInfo> =>
|
||||
export function info (instanceId: string, api: ApiInterfaceRx): (address?: AccountIndex | AccountId | Address | Uint8Array | string | null) => Observable<DeriveAccountInfo> {
|
||||
return memo(instanceId, (address?: AccountIndex | AccountId | Address | Uint8Array | string | null): Observable<DeriveAccountInfo> =>
|
||||
api.derive.accounts.idAndIndex(address).pipe(
|
||||
switchMap(([accountId, accountIndex]): Observable<[Partial<DeriveAccountInfo>, DeriveAccountRegistration, string?]> =>
|
||||
combineLatest([
|
||||
of({ accountId, accountIndex }),
|
||||
retrieveIdentity(api, accountId),
|
||||
api.derive.accounts.identity(accountId),
|
||||
retrieveNick(api, accountId)
|
||||
])
|
||||
),
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { AccountId, AccountIndex, RegistrationJudgement } from '@polkadot/types/interfaces';
|
||||
import type { AccountId, AccountIndex, RegistrationJudgement } from '@polkadot/types/interfaces';
|
||||
|
||||
export type AccountIdAndIndex = [AccountId?, AccountIndex?];
|
||||
|
||||
@@ -35,3 +35,9 @@ export interface DeriveAccountInfo {
|
||||
identity: DeriveAccountRegistration;
|
||||
nickname?: string;
|
||||
}
|
||||
|
||||
export interface DeriveHasIdentity {
|
||||
display?: string;
|
||||
hasIdentity: boolean;
|
||||
parentId?: string;
|
||||
}
|
||||
|
||||
@@ -1,23 +1,30 @@
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { AccountId, AccountData, AccountIndex, AccountInfo, Address, Balance, Index } from '@polkadot/types/interfaces';
|
||||
import { ITuple } from '@polkadot/types/types';
|
||||
import { DeriveBalancesAccount } from '../types';
|
||||
import type { ApiInterfaceRx, QueryableStorageMultiArg } from '@polkadot/api/types';
|
||||
import type { AccountData, AccountId, AccountIndex, AccountInfo, Address, Balance, Index } from '@polkadot/types/interfaces';
|
||||
import type { ITuple } from '@polkadot/types/types';
|
||||
import type { Observable } from '@polkadot/x-rxjs';
|
||||
import type { DeriveBalancesAccount, DeriveBalancesAccountData } from '../types';
|
||||
|
||||
import { Observable, combineLatest, of } from 'rxjs';
|
||||
import { map, switchMap } from 'rxjs/operators';
|
||||
import { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import { isFunction } from '@polkadot/util';
|
||||
import { assert, isFunction } from '@polkadot/util';
|
||||
import { combineLatest, of } from '@polkadot/x-rxjs';
|
||||
import { map, switchMap } from '@polkadot/x-rxjs/operators';
|
||||
|
||||
import { memo } from '../util';
|
||||
|
||||
type Result = [Balance, Balance, Balance, Balance, Index];
|
||||
type BalanceResult = [Balance, Balance, Balance, Balance];
|
||||
|
||||
function calcBalances (api: ApiInterfaceRx, [accountId, [freeBalance, reservedBalance, frozenFee, frozenMisc, accountNonce]]: [AccountId, Result]): DeriveBalancesAccount {
|
||||
type Result = [Index, BalanceResult[]];
|
||||
|
||||
type DeriveCustomAccount = ApiInterfaceRx['derive'] & {
|
||||
[custom: string]: {
|
||||
customAccount?: ApiInterfaceRx['query']['balances']['account']
|
||||
}
|
||||
}
|
||||
|
||||
function getBalance (api: ApiInterfaceRx, [freeBalance, reservedBalance, frozenFee, frozenMisc]: BalanceResult): DeriveBalancesAccountData {
|
||||
return {
|
||||
accountId,
|
||||
accountNonce,
|
||||
freeBalance,
|
||||
frozenFee,
|
||||
frozenMisc,
|
||||
@@ -26,6 +33,19 @@ function calcBalances (api: ApiInterfaceRx, [accountId, [freeBalance, reservedBa
|
||||
};
|
||||
}
|
||||
|
||||
function calcBalances (api: ApiInterfaceRx, [accountId, [accountNonce, balances]]: [AccountId, Result]): DeriveBalancesAccount {
|
||||
const primary = balances[0];
|
||||
|
||||
assert(primary, 'No balances retrieved for account');
|
||||
|
||||
return {
|
||||
accountId,
|
||||
accountNonce,
|
||||
additional: balances.filter((_, index) => index !== 0).map((b) => getBalance(api, b)),
|
||||
...getBalance(api, primary)
|
||||
};
|
||||
}
|
||||
|
||||
// old
|
||||
function queryBalancesFree (api: ApiInterfaceRx, accountId: AccountId): Observable<Result> {
|
||||
return api.queryMulti<[Balance, Balance, Index]>([
|
||||
@@ -33,21 +53,31 @@ function queryBalancesFree (api: ApiInterfaceRx, accountId: AccountId): Observab
|
||||
[api.query.balances.reservedBalance, accountId],
|
||||
[api.query.system.accountNonce, accountId]
|
||||
]).pipe(
|
||||
map(([freeBalance, reservedBalance, accountNonce]): Result =>
|
||||
[freeBalance, reservedBalance, api.registry.createType('Balance'), api.registry.createType('Balance'), accountNonce]
|
||||
)
|
||||
map(([freeBalance, reservedBalance, accountNonce]): Result => [
|
||||
accountNonce,
|
||||
[[freeBalance, reservedBalance, api.registry.createType('Balance'), api.registry.createType('Balance')]]
|
||||
])
|
||||
);
|
||||
}
|
||||
|
||||
function queryBalancesAccount (api: ApiInterfaceRx, accountId: AccountId): Observable<Result> {
|
||||
return api.queryMulti<[AccountData, Index]>([
|
||||
[api.query.balances.account, accountId],
|
||||
[api.query.system.accountNonce, accountId]
|
||||
]).pipe(
|
||||
map(([{ feeFrozen, free, miscFrozen, reserved }, accountNonce]): Result =>
|
||||
[free, reserved, feeFrozen, miscFrozen, accountNonce]
|
||||
)
|
||||
function queryBalancesAccount (api: ApiInterfaceRx, accountId: AccountId, modules: string[] = ['balances']): Observable<Result> {
|
||||
const balances = modules.map(
|
||||
(m): QueryableStorageMultiArg<'rxjs'> => [
|
||||
(api.derive as DeriveCustomAccount)[m]?.customAccount || api.query[m].account,
|
||||
accountId
|
||||
]
|
||||
);
|
||||
|
||||
const extract = (data: AccountData[]) =>
|
||||
data.map(({ feeFrozen, free, miscFrozen, reserved }): BalanceResult => [free, reserved, feeFrozen, miscFrozen]);
|
||||
|
||||
return isFunction(api.query.system.account)
|
||||
? api.queryMulti<[AccountInfo, ...(AccountData[])]>([[api.query.system.account, accountId], ...balances]).pipe(
|
||||
map(([{ nonce }, ...balances]): Result => [nonce, extract(balances)])
|
||||
)
|
||||
: api.queryMulti<[Index, ...(AccountData[])]>([[api.query.system.accountNonce, accountId], ...balances]).pipe(
|
||||
map(([nonce, ...balances]): Result => [nonce, extract(balances)])
|
||||
);
|
||||
}
|
||||
|
||||
function queryCurrent (api: ApiInterfaceRx, accountId: AccountId): Observable<Result> {
|
||||
@@ -57,9 +87,11 @@ function queryCurrent (api: ApiInterfaceRx, accountId: AccountId): Observable<Re
|
||||
const { feeFrozen, free, miscFrozen, reserved } = (infoOrTuple as AccountInfo).nonce
|
||||
? (infoOrTuple as AccountInfo).data
|
||||
: (infoOrTuple as [Index, AccountData])[1];
|
||||
const accountNonce = (infoOrTuple as AccountInfo).nonce || (infoOrTuple as [Index, AccountData])[0];
|
||||
|
||||
return [free, reserved, feeFrozen, miscFrozen, accountNonce];
|
||||
return [
|
||||
(infoOrTuple as AccountInfo).nonce || (infoOrTuple as [Index, AccountData])[0],
|
||||
[[free, reserved, feeFrozen, miscFrozen]]
|
||||
];
|
||||
})
|
||||
);
|
||||
}
|
||||
@@ -80,19 +112,29 @@ function queryCurrent (api: ApiInterfaceRx, accountId: AccountId): Observable<Re
|
||||
* ```
|
||||
*/
|
||||
export function account (instanceId: string, api: ApiInterfaceRx): (address: AccountIndex | AccountId | Address | string) => Observable<DeriveBalancesAccount> {
|
||||
const balanceInstances = api.registry.getModuleInstances(api.runtimeVersion.specName.toString(), 'balances');
|
||||
|
||||
return memo(instanceId, (address: AccountIndex | AccountId | Address | string): Observable<DeriveBalancesAccount> =>
|
||||
api.derive.accounts.accountId(address).pipe(
|
||||
switchMap((accountId): Observable<[AccountId, Result]> =>
|
||||
(accountId
|
||||
? combineLatest([
|
||||
of(accountId),
|
||||
isFunction(api.query.system.account)
|
||||
? queryCurrent(api, accountId)
|
||||
: isFunction(api.query.balances.account)
|
||||
? queryBalancesAccount(api, accountId)
|
||||
: queryBalancesFree(api, accountId)
|
||||
balanceInstances
|
||||
? queryBalancesAccount(api, accountId, balanceInstances)
|
||||
: isFunction(api.query.system.account)
|
||||
? queryCurrent(api, accountId)
|
||||
: isFunction(api.query.balances.account)
|
||||
? queryBalancesAccount(api, accountId)
|
||||
: queryBalancesFree(api, accountId)
|
||||
])
|
||||
: of([
|
||||
api.registry.createType('AccountId'),
|
||||
[
|
||||
api.registry.createType('Index'),
|
||||
[[api.registry.createType('Balance'), api.registry.createType('Balance'), api.registry.createType('Balance'), api.registry.createType('Balance')]]
|
||||
]
|
||||
])
|
||||
: of([api.registry.createType('AccountId'), [api.registry.createType('Balance'), api.registry.createType('Balance'), api.registry.createType('Balance'), api.registry.createType('Balance'), api.registry.createType('Index')]])
|
||||
)
|
||||
),
|
||||
map((result): DeriveBalancesAccount => calcBalances(api, result))
|
||||
|
||||
@@ -1,19 +1,21 @@
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { AccountId, AccountIndex, Address, Balance, BalanceLock, BalanceLockTo212, BlockNumber, VestingInfo, VestingSchedule } from '@polkadot/types/interfaces';
|
||||
import { DeriveBalancesAccount, DeriveBalancesAll } from '../types';
|
||||
import type { ApiInterfaceRx, QueryableStorageMultiArg } from '@polkadot/api/types';
|
||||
import type { Option, Vec } from '@polkadot/types';
|
||||
import type { AccountId, AccountIndex, Address, Balance, BalanceLock, BalanceLockTo212, BlockNumber, VestingInfo, VestingSchedule } from '@polkadot/types/interfaces';
|
||||
import type { Observable } from '@polkadot/x-rxjs';
|
||||
import type { DeriveBalancesAccount, DeriveBalancesAccountData, DeriveBalancesAll, DeriveBalancesAllAccountData } from '../types';
|
||||
|
||||
import BN from 'bn.js';
|
||||
import { Observable, combineLatest, of } from 'rxjs';
|
||||
import { map, switchMap } from 'rxjs/operators';
|
||||
import { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import { Option, Vec } from '@polkadot/types';
|
||||
import { bnMax, isFunction } from '@polkadot/util';
|
||||
import { BN, bnMax, isFunction } from '@polkadot/util';
|
||||
import { combineLatest, of } from '@polkadot/x-rxjs';
|
||||
import { map, switchMap } from '@polkadot/x-rxjs/operators';
|
||||
|
||||
import { memo } from '../util';
|
||||
|
||||
type ResultBalance = [VestingInfo | null, (BalanceLock | BalanceLockTo212)[]];
|
||||
type BalanceLocksEntry = Vec<BalanceLock | BalanceLockTo212>;
|
||||
type BalanceLocks = BalanceLocksEntry[];
|
||||
type ResultBalance = [VestingInfo | null, ((BalanceLock | BalanceLockTo212)[])[]];
|
||||
type Result = [DeriveBalancesAccount, BlockNumber, ResultBalance];
|
||||
|
||||
interface AllLocked {
|
||||
@@ -23,6 +25,12 @@ interface AllLocked {
|
||||
vestingLocked: Balance
|
||||
}
|
||||
|
||||
type DeriveCustomLocks = ApiInterfaceRx['derive'] & {
|
||||
[custom: string]: {
|
||||
customLocks?: ApiInterfaceRx['query']['balances']['locks']
|
||||
}
|
||||
}
|
||||
|
||||
const VESTING_ID = '0x76657374696e6720';
|
||||
|
||||
function calcLocked (api: ApiInterfaceRx, bestNumber: BlockNumber, locks: (BalanceLock | BalanceLockTo212)[]): AllLocked {
|
||||
@@ -34,11 +42,11 @@ function calcLocked (api: ApiInterfaceRx, bestNumber: BlockNumber, locks: (Balan
|
||||
if (Array.isArray(locks)) {
|
||||
// only get the locks that are valid until passed the current block
|
||||
lockedBreakdown = (locks as BalanceLockTo212[]).filter(({ until }): boolean => !until || (bestNumber && until.gt(bestNumber)));
|
||||
allLocked = lockedBreakdown.some(({ amount }) => amount.isMax());
|
||||
allLocked = lockedBreakdown.some(({ amount }) => amount && amount.isMax());
|
||||
vestingLocked = api.registry.createType('Balance', lockedBreakdown.filter(({ id }) => id.eq(VESTING_ID)).reduce((result: BN, { amount }) => result.iadd(amount), new BN(0)));
|
||||
|
||||
// get the maximum of the locks according to https://github.com/paritytech/substrate/blob/master/srml/balances/src/lib.rs#L699
|
||||
const notAll = lockedBreakdown.filter(({ amount }) => !amount.isMax());
|
||||
const notAll = lockedBreakdown.filter(({ amount }) => amount && !amount.isMax());
|
||||
|
||||
if (notAll.length) {
|
||||
lockedBalance = api.registry.createType('Balance', bnMax(...notAll.map(({ amount }): Balance => amount)));
|
||||
@@ -48,8 +56,20 @@ function calcLocked (api: ApiInterfaceRx, bestNumber: BlockNumber, locks: (Balan
|
||||
return { allLocked, lockedBalance, lockedBreakdown, vestingLocked };
|
||||
}
|
||||
|
||||
function calcBalances (api: ApiInterfaceRx, [{ accountId, accountNonce, freeBalance, frozenFee, frozenMisc, reservedBalance, votingBalance }, bestNumber, [vesting, locks]]: Result): DeriveBalancesAll {
|
||||
function calcShared (api: ApiInterfaceRx, bestNumber: BlockNumber, data: DeriveBalancesAccountData, locks: (BalanceLock | BalanceLockTo212)[]): DeriveBalancesAllAccountData {
|
||||
const { allLocked, lockedBalance, lockedBreakdown, vestingLocked } = calcLocked(api, bestNumber, locks);
|
||||
|
||||
return {
|
||||
...data,
|
||||
availableBalance: api.registry.createType('Balance', allLocked ? 0 : bnMax(new BN(0), data.freeBalance.sub(lockedBalance))),
|
||||
lockedBalance,
|
||||
lockedBreakdown,
|
||||
vestingLocked
|
||||
};
|
||||
}
|
||||
|
||||
function calcBalances (api: ApiInterfaceRx, [data, bestNumber, [vesting, allLocks]]: Result): DeriveBalancesAll {
|
||||
const shared = calcShared(api, bestNumber, data, allLocks[0]);
|
||||
// Calculate the vesting balances,
|
||||
// - offset = balance locked at startingBlock
|
||||
// - perBlock is the unlock amount
|
||||
@@ -57,29 +77,19 @@ function calcBalances (api: ApiInterfaceRx, [{ accountId, accountNonce, freeBala
|
||||
const isStarted = bestNumber.gt(startingBlock);
|
||||
const vestedNow = isStarted ? perBlock.mul(bestNumber.sub(startingBlock)) : new BN(0);
|
||||
const vestedBalance = vestedNow.gt(vestingTotal) ? vestingTotal : api.registry.createType('Balance', vestedNow);
|
||||
const isVesting = isStarted && !vestingLocked.isZero();
|
||||
const vestedClaimable = api.registry.createType('Balance', isVesting ? vestingLocked.sub(vestingTotal.sub(vestedBalance)) : 0);
|
||||
const availableBalance = api.registry.createType('Balance', allLocked ? 0 : bnMax(new BN(0), freeBalance.sub(lockedBalance)));
|
||||
const vestingEndBlock = api.registry.createType('BlockNumber', isVesting ? vestingTotal.div(perBlock).add(startingBlock) : 0);
|
||||
const isVesting = isStarted && !shared.vestingLocked.isZero();
|
||||
|
||||
return {
|
||||
accountId,
|
||||
accountNonce,
|
||||
availableBalance,
|
||||
freeBalance,
|
||||
frozenFee,
|
||||
frozenMisc,
|
||||
...shared,
|
||||
accountId: data.accountId,
|
||||
accountNonce: data.accountNonce,
|
||||
additional: allLocks.filter((_, index) => index !== 0).map((l, index) => calcShared(api, bestNumber, data.additional[index], l)),
|
||||
isVesting,
|
||||
lockedBalance,
|
||||
lockedBreakdown,
|
||||
reservedBalance,
|
||||
vestedBalance,
|
||||
vestedClaimable,
|
||||
vestingEndBlock,
|
||||
vestingLocked,
|
||||
vestedClaimable: api.registry.createType('Balance', isVesting ? shared.vestingLocked.sub(vestingTotal.sub(vestedBalance)) : 0),
|
||||
vestingEndBlock: api.registry.createType('BlockNumber', isVesting ? vestingTotal.div(perBlock).add(startingBlock) : 0),
|
||||
vestingPerBlock: perBlock,
|
||||
vestingTotal,
|
||||
votingBalance
|
||||
vestingTotal
|
||||
};
|
||||
}
|
||||
|
||||
@@ -98,28 +108,43 @@ function queryOld (api: ApiInterfaceRx, accountId: AccountId): Observable<Result
|
||||
vestingNew = api.registry.createType('VestingInfo', { locked, perBlock, startingBlock });
|
||||
}
|
||||
|
||||
return [vestingNew, locks];
|
||||
return [vestingNew, [locks]];
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
// current (balances vesting)
|
||||
function queryCurrent (api: ApiInterfaceRx, accountId: AccountId): Observable<ResultBalance> {
|
||||
const isNonNullable = <T>(nullable: T): nullable is NonNullable<T> => !!nullable;
|
||||
|
||||
// current (balances, vesting)
|
||||
function queryCurrent (api: ApiInterfaceRx, accountId: AccountId, balanceInstances: string[] = ['balances']): Observable<ResultBalance> {
|
||||
const lockCalls = balanceInstances.map(
|
||||
(m): ApiInterfaceRx['query']['balances']['locks'] | undefined =>
|
||||
(api.derive as DeriveCustomLocks)[m]?.customLocks || api.query[m as 'balances']?.locks
|
||||
);
|
||||
|
||||
const lockEmpty = lockCalls.map((c) => !c);
|
||||
const lockQueries = lockCalls.filter(isNonNullable).map((c): QueryableStorageMultiArg<'rxjs'> => [c, accountId]);
|
||||
|
||||
return (
|
||||
api.query.vesting?.vesting
|
||||
? api.queryMulti<[Vec<BalanceLock>, Option<VestingInfo>]>([
|
||||
[api.query.balances.locks, accountId],
|
||||
[api.query.vesting.vesting, accountId]
|
||||
? api.queryMulti<[Option<VestingInfo>, ...BalanceLocks]>([
|
||||
[api.query.vesting.vesting, accountId],
|
||||
...lockQueries
|
||||
])
|
||||
: api.query.balances.locks(accountId).pipe(
|
||||
map((locks): [Vec<BalanceLock>, Option<VestingInfo>] =>
|
||||
[locks, api.registry.createType('Option<VestingInfo>')]
|
||||
// TODO We need to check module instances here as well, not only the balances module
|
||||
: lockQueries.length
|
||||
? api.queryMulti<[...(Vec<BalanceLock>)[]]>(lockQueries).pipe(
|
||||
map((locks): [Option<VestingInfo>, ...BalanceLocks] =>
|
||||
[api.registry.createType('Option<VestingInfo>'), ...locks]
|
||||
)
|
||||
)
|
||||
)
|
||||
: of([api.registry.createType('Option<VestingInfo>')] as [Option<VestingInfo>])
|
||||
).pipe(
|
||||
map(([locks, optVesting]): ResultBalance =>
|
||||
[optVesting.unwrapOr(null), locks]
|
||||
)
|
||||
map(([optVesting, ...locks]): ResultBalance => {
|
||||
let offset = -1;
|
||||
|
||||
return [optVesting.unwrapOr(null), lockEmpty.map((e) => e ? api.registry.createType('Vec<BalanceLock>') : locks[++offset])];
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
@@ -139,6 +164,8 @@ function queryCurrent (api: ApiInterfaceRx, accountId: AccountId): Observable<Re
|
||||
* ```
|
||||
*/
|
||||
export function all (instanceId: string, api: ApiInterfaceRx): (address: AccountIndex | AccountId | Address | string) => Observable<DeriveBalancesAll> {
|
||||
const balanceInstances = api.registry.getModuleInstances(api.runtimeVersion.specName.toString(), 'balances');
|
||||
|
||||
return memo(instanceId, (address: AccountIndex | AccountId | Address | string): Observable<DeriveBalancesAll> =>
|
||||
api.derive.balances.account(address).pipe(
|
||||
switchMap((account): Observable<Result> =>
|
||||
@@ -146,11 +173,11 @@ export function all (instanceId: string, api: ApiInterfaceRx): (address: Account
|
||||
? combineLatest([
|
||||
of(account),
|
||||
api.derive.chain.bestNumber(),
|
||||
isFunction(api.query.system.account) || isFunction(api.query.balances.account)
|
||||
? queryCurrent(api, account.accountId)
|
||||
isFunction(api.query.system?.account) || isFunction(api.query.balances?.account)
|
||||
? queryCurrent(api, account.accountId, balanceInstances)
|
||||
: queryOld(api, account.accountId)
|
||||
])
|
||||
: of([account, api.registry.createType('BlockNumber'), [null, api.registry.createType('Vec<BalanceLock>')]])
|
||||
: of([account, api.registry.createType('BlockNumber'), [null, []]])
|
||||
)
|
||||
),
|
||||
map((result): DeriveBalancesAll => calcBalances(api, result))
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import { Balance } from '@polkadot/types/interfaces';
|
||||
import { DeriveFees } from '../types';
|
||||
import type { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import type { Balance } from '@polkadot/types/interfaces';
|
||||
import type { Observable } from '@polkadot/x-rxjs';
|
||||
import type { DeriveFees } from '../types';
|
||||
|
||||
import { Observable, of } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { of } from '@polkadot/x-rxjs';
|
||||
import { map } from '@polkadot/x-rxjs/operators';
|
||||
|
||||
import { memo } from '../util';
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { all } from './all';
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { AccountId, AccountIndex, Address } from '@polkadot/types/interfaces';
|
||||
import { DeriveBalancesAccount } from '../types';
|
||||
import type { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import type { AccountId, AccountIndex, Address } from '@polkadot/types/interfaces';
|
||||
import type { Observable } from '@polkadot/x-rxjs';
|
||||
import type { DeriveBalancesAccount } from '../types';
|
||||
|
||||
import { Observable, combineLatest, of } from 'rxjs';
|
||||
import { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import { combineLatest, of } from '@polkadot/x-rxjs';
|
||||
|
||||
import { memo } from '../util';
|
||||
|
||||
|
||||
@@ -0,0 +1,161 @@
|
||||
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { ApiInterfaceRx, SubmittableExtrinsic } from '@polkadot/api/types';
|
||||
import type { Bytes, Option, StorageKey } from '@polkadot/types';
|
||||
import type { Bounty, BountyIndex, ProposalIndex } from '@polkadot/types/interfaces';
|
||||
import type { Codec, InterfaceTypes } from '@polkadot/types/types';
|
||||
|
||||
import { ApiPromise } from '@polkadot/api';
|
||||
import { DeriveCollectiveProposal } from '@polkadot/api-derive/types';
|
||||
import { Proposal } from '@polkadot/types/interfaces';
|
||||
import { of } from '@polkadot/x-rxjs';
|
||||
|
||||
import { BountyFactory } from '../../test/bountyFactory';
|
||||
import { BytesFactory } from '../../test/bytesFactory';
|
||||
import { createApiWithAugmentations } from '../../test/helpers';
|
||||
import { ProposalFactory } from '../../test/proposalFactory';
|
||||
import { bounties } from '.';
|
||||
|
||||
const DEFAULT_PROPOSER = '5C4hrfjw9DjXZTzV3MwzrrAr9P1MJhSrvWGWqi1eSuyUpnhM';
|
||||
|
||||
describe('bounties derive', () => {
|
||||
let storageKey: (index: number) => StorageKey;
|
||||
let defaultBounty: () => Bounty;
|
||||
let emptyOption: <T extends Codec> (typeName: keyof InterfaceTypes) => Option<T>;
|
||||
let optionOf: <T extends Codec> (value: T) => Option<T>;
|
||||
let bountyIndex: (index: number) => BountyIndex;
|
||||
let proposalIndex: (index: number) => ProposalIndex;
|
||||
let bytes: (value: string) => Bytes;
|
||||
let api: ApiPromise;
|
||||
let createProposal: (method: SubmittableExtrinsic<'promise'>) => Proposal;
|
||||
let defaultMockApi: ApiInterfaceRx;
|
||||
|
||||
beforeAll(() => {
|
||||
api = createApiWithAugmentations();
|
||||
|
||||
({ bountyIndex, defaultBounty, emptyOption, optionOf, storageKey } = new BountyFactory(api));
|
||||
({ bytes } = new BytesFactory(api.registry));
|
||||
({ createProposal, proposalIndex } = new ProposalFactory(api));
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
defaultMockApi = {
|
||||
derive: {
|
||||
council: {
|
||||
proposals: () => of([] as DeriveCollectiveProposal[])
|
||||
}
|
||||
},
|
||||
query: {
|
||||
council: {
|
||||
proposalCount: () => of(proposalIndex(2))
|
||||
},
|
||||
treasury: {
|
||||
bounties: {
|
||||
keys: () => of([storageKey(0), storageKey(1)]),
|
||||
multi: () => of([optionOf(defaultBounty()), optionOf(defaultBounty())])
|
||||
},
|
||||
bountyCount: () => of(bountyIndex(2)),
|
||||
bountyDescriptions: {
|
||||
multi: () => of([
|
||||
optionOf(bytes('make polkadot even better')),
|
||||
optionOf(bytes('some other bounty'))
|
||||
])
|
||||
}
|
||||
}
|
||||
},
|
||||
tx: api.tx
|
||||
} as unknown as ApiInterfaceRx;
|
||||
});
|
||||
|
||||
it('creates storage key', function () {
|
||||
expect(storageKey(194).args[0].eq(194)).toBe(true);
|
||||
});
|
||||
|
||||
it('creates proposal', function () {
|
||||
expect(createProposal(api.tx.balances.transfer('5EYCAe5ijiYfyeZ2JJCGq56LmPyNRAKzpG4QkoQkkQNB5e6Z', 1))).toBeTruthy();
|
||||
});
|
||||
|
||||
it('combines bounties with descriptions', async () => {
|
||||
const mockApi = {
|
||||
...defaultMockApi,
|
||||
query: {
|
||||
...defaultMockApi.query,
|
||||
treasury: {
|
||||
bounties: {
|
||||
keys: () => of([storageKey(0), storageKey(2), storageKey(3)]),
|
||||
multi: () => of([optionOf(defaultBounty()), emptyOption('Bounty'), optionOf(defaultBounty())])
|
||||
},
|
||||
bountyCount: () => of(bountyIndex(3)),
|
||||
bountyDescriptions: {
|
||||
multi: () => of([
|
||||
optionOf(bytes('make polkadot even better')),
|
||||
optionOf(bytes('this will be totally ignored')),
|
||||
emptyOption('Bytes')
|
||||
])
|
||||
}
|
||||
}
|
||||
}
|
||||
} as unknown as ApiInterfaceRx;
|
||||
|
||||
const result = await bounties('', mockApi)().toPromise();
|
||||
|
||||
expect(result).toHaveLength(2);
|
||||
expect(result[0].bounty.proposer.toString()).toEqual(DEFAULT_PROPOSER);
|
||||
expect(result[0].description).toEqual('make polkadot even better');
|
||||
expect(result[0].index.eq(0)).toBe(true);
|
||||
expect(result[1].bounty.proposer.toString()).toEqual(DEFAULT_PROPOSER);
|
||||
expect(result[1].description).toEqual('');
|
||||
expect(result[1].index.eq(3)).toBe(true);
|
||||
});
|
||||
|
||||
it('returns motions', async () => {
|
||||
const result = await bounties('', defaultMockApi)().toPromise();
|
||||
|
||||
expect(result).toHaveLength(2);
|
||||
expect(result[0].proposals).toHaveLength(0);
|
||||
expect(result[1].proposals).toHaveLength(0);
|
||||
});
|
||||
|
||||
it('when no council, returns bounties without motions', async () => {
|
||||
const mockApi = {
|
||||
...defaultMockApi,
|
||||
query: {
|
||||
...defaultMockApi.query,
|
||||
council: null
|
||||
}
|
||||
} as unknown as ApiInterfaceRx;
|
||||
|
||||
const result = await bounties('', mockApi)().toPromise();
|
||||
|
||||
expect(result).toHaveLength(2);
|
||||
expect(result[0].bounty.proposer.toString()).toEqual(DEFAULT_PROPOSER);
|
||||
expect(result[0].description).toEqual('make polkadot even better');
|
||||
expect(result[0].index.eq(0)).toBe(true);
|
||||
expect(result[0].proposals).toHaveLength(0);
|
||||
expect(result[1].bounty.proposer.toString()).toEqual(DEFAULT_PROPOSER);
|
||||
expect(result[1].description).toEqual('some other bounty');
|
||||
expect(result[1].index.eq(1)).toBe(true);
|
||||
expect(result[1].proposals).toHaveLength(0);
|
||||
});
|
||||
|
||||
it('combines bounties with motions', async () => {
|
||||
const mockApi = {
|
||||
...defaultMockApi,
|
||||
derive: {
|
||||
council: {
|
||||
proposals: () => of([
|
||||
{ proposal: createProposal(api.tx.bounties.approveBounty(1)) },
|
||||
{ proposal: createProposal(api.tx.treasury.approveProposal(1)) }] as DeriveCollectiveProposal[])
|
||||
}
|
||||
}
|
||||
} as unknown as ApiInterfaceRx;
|
||||
|
||||
const result = await bounties('', mockApi)().toPromise();
|
||||
|
||||
expect(result).toHaveLength(2);
|
||||
expect(result[0].proposals).toHaveLength(0);
|
||||
expect(result[1].proposals).toHaveLength(1);
|
||||
expect(result[1].proposals[0].proposal.method).toEqual('approveBounty');
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,65 @@
|
||||
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import type { DeriveBounties, DeriveCollectiveProposal } from '@polkadot/api-derive/types';
|
||||
import type { Bytes, Option } from '@polkadot/types';
|
||||
import type { Bounty, BountyIndex, ProposalIndex } from '@polkadot/types/interfaces';
|
||||
|
||||
import { memo } from '@polkadot/api-derive/util';
|
||||
import { combineLatest, Observable, of } from '@polkadot/x-rxjs';
|
||||
import { map, switchMap } from '@polkadot/x-rxjs/operators';
|
||||
|
||||
import { filterBountiesProposals } from './helpers/filterBountyProposals';
|
||||
|
||||
type Result = [Option<Bounty>[], Option<Bytes>[], BountyIndex[], DeriveCollectiveProposal[]];
|
||||
|
||||
function parseResult ([maybeBounties, maybeDescriptions, ids, bountyProposals]: Result): DeriveBounties {
|
||||
const bounties: DeriveBounties = [];
|
||||
|
||||
maybeBounties.forEach((bounty, index) => {
|
||||
if (bounty.isSome) {
|
||||
bounties.push({
|
||||
bounty: bounty.unwrap(),
|
||||
description: maybeDescriptions[index].unwrapOrDefault().toUtf8(),
|
||||
index: ids[index],
|
||||
proposals: bountyProposals.filter((bountyProposal) => ids[index].eq(bountyProposal.proposal.args[0]))
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
return bounties;
|
||||
}
|
||||
|
||||
export function bounties (instanceId: string, api: ApiInterfaceRx): () => Observable<DeriveBounties> {
|
||||
const bountyBase = api.query.bounties || api.query.treasury;
|
||||
|
||||
return memo(instanceId, (): Observable<DeriveBounties> =>
|
||||
combineLatest([
|
||||
bountyBase.bountyCount<BountyIndex>(),
|
||||
api.query.council
|
||||
? api.query.council.proposalCount<ProposalIndex>()
|
||||
: of(0)
|
||||
]).pipe(
|
||||
switchMap(() =>
|
||||
combineLatest([
|
||||
bountyBase.bounties.keys<[BountyIndex]>(),
|
||||
api.derive.council
|
||||
? api.derive.council.proposals()
|
||||
: of([])
|
||||
])
|
||||
),
|
||||
switchMap(([keys, proposals]): Observable<Result> => {
|
||||
const ids = keys.map(({ args: [id] }) => id);
|
||||
|
||||
return combineLatest([
|
||||
bountyBase.bounties.multi<Option<Bounty>>(ids),
|
||||
bountyBase.bountyDescriptions.multi<Option<Bytes>>(ids),
|
||||
of(ids),
|
||||
of(filterBountiesProposals(api, proposals))
|
||||
]);
|
||||
}),
|
||||
map(parseResult)
|
||||
)
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import { DeriveCollectiveProposal } from '@polkadot/api-derive/types';
|
||||
|
||||
export function filterBountiesProposals (api: ApiInterfaceRx, allProposals: DeriveCollectiveProposal[]): DeriveCollectiveProposal[] {
|
||||
const bountyTxBase = api.tx.bounties ? api.tx.bounties : api.tx.treasury;
|
||||
const bountyProposalCalls = [bountyTxBase.approveBounty, bountyTxBase.closeBounty, bountyTxBase.proposeCurator, bountyTxBase.unassignCurator];
|
||||
|
||||
return allProposals.filter((proposal) => bountyProposalCalls.find((bountyCall) => bountyCall.is(proposal.proposal)));
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
export * from './bounties';
|
||||
@@ -1,11 +1,11 @@
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { BlockNumber } from '@polkadot/types/interfaces';
|
||||
import type { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import type { BlockNumber } from '@polkadot/types/interfaces';
|
||||
import type { Observable } from '@polkadot/x-rxjs';
|
||||
|
||||
import { Observable } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import { map } from '@polkadot/x-rxjs/operators';
|
||||
|
||||
import { memo } from '../util';
|
||||
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { BlockNumber } from '@polkadot/types/interfaces';
|
||||
import type { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import type { BlockNumber } from '@polkadot/types/interfaces';
|
||||
import type { Observable } from '@polkadot/x-rxjs';
|
||||
|
||||
import { Observable } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import { map } from '@polkadot/x-rxjs/operators';
|
||||
|
||||
import { memo } from '../util';
|
||||
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { BlockNumber } from '@polkadot/types/interfaces';
|
||||
import type { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import type { BlockNumber } from '@polkadot/types/interfaces';
|
||||
import type { Observable } from '@polkadot/x-rxjs';
|
||||
|
||||
import { Observable, combineLatest } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import { combineLatest } from '@polkadot/x-rxjs';
|
||||
import { map } from '@polkadot/x-rxjs/operators';
|
||||
|
||||
import { memo } from '../util';
|
||||
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import type { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import type { Observable } from '@polkadot/x-rxjs';
|
||||
import type { SignedBlockExtended } from '../type/types';
|
||||
|
||||
import { Observable, combineLatest, of } from 'rxjs';
|
||||
import { catchError, map } from 'rxjs/operators';
|
||||
import { combineLatest, of } from '@polkadot/x-rxjs';
|
||||
import { catchError, map } from '@polkadot/x-rxjs/operators';
|
||||
|
||||
import { SignedBlockExtended } from '../type';
|
||||
import { createSignedBlockExtended } from '../type';
|
||||
import { memo } from '../util';
|
||||
|
||||
/**
|
||||
@@ -17,25 +19,26 @@ import { memo } from '../util';
|
||||
* <BR>
|
||||
*
|
||||
* ```javascript
|
||||
* const { author, number } = await api.derive.chain.getHeader('0x123...456');
|
||||
* const { author, block } = await api.derive.chain.getBlock('0x123...456');
|
||||
*
|
||||
* console.log(`block #${number} was authored by ${author}`);
|
||||
* console.log(`block #${block.header.number} was authored by ${author}`);
|
||||
* ```
|
||||
*/
|
||||
export function getHeader (instanceId: string, api: ApiInterfaceRx): (hash: Uint8Array | string) => Observable<SignedBlockExtended | undefined> {
|
||||
export function getBlock (instanceId: string, api: ApiInterfaceRx): (hash: Uint8Array | string) => Observable<SignedBlockExtended | undefined> {
|
||||
return memo(instanceId, (hash: Uint8Array | string): Observable<SignedBlockExtended | undefined> =>
|
||||
combineLatest([
|
||||
api.rpc.chain.getBlock(hash),
|
||||
api.query.system.events.at(hash),
|
||||
api.query.session
|
||||
? api.query.session.validators.at(hash)
|
||||
: of([])
|
||||
]).pipe(
|
||||
map(([signedBlock, validators]): SignedBlockExtended =>
|
||||
new SignedBlockExtended(api.registry, signedBlock, validators)
|
||||
map(([signedBlock, events, validators]): SignedBlockExtended =>
|
||||
createSignedBlockExtended(api.registry, signedBlock, events, validators)
|
||||
),
|
||||
catchError((): Observable<undefined> =>
|
||||
// where rpc.chain.getHeader throws, we will land here - it can happen that
|
||||
// we supplied an invalid hash. (Due to defaults, storeage will have an
|
||||
// we supplied an invalid hash. (Due to defaults, storage will have an
|
||||
// empty value, so only the RPC is affected). So return undefined
|
||||
of()
|
||||
)
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import type { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import type { Observable } from '@polkadot/x-rxjs';
|
||||
import type { HeaderExtended } from '../type/types';
|
||||
|
||||
import { Observable, combineLatest, of } from 'rxjs';
|
||||
import { catchError, map } from 'rxjs/operators';
|
||||
import { combineLatest, of } from '@polkadot/x-rxjs';
|
||||
import { catchError, map } from '@polkadot/x-rxjs/operators';
|
||||
|
||||
import { HeaderExtended } from '../type';
|
||||
import { createHeaderExtended } from '../type';
|
||||
import { memo } from '../util';
|
||||
|
||||
/**
|
||||
@@ -32,7 +34,7 @@ export function getHeader (instanceId: string, api: ApiInterfaceRx): (hash: Uint
|
||||
: of([])
|
||||
]).pipe(
|
||||
map(([header, validators]): HeaderExtended =>
|
||||
new HeaderExtended(api.registry, header, validators)
|
||||
createHeaderExtended(header.registry, header, validators)
|
||||
),
|
||||
catchError((): Observable<undefined> =>
|
||||
// where rpc.chain.getHeader throws, we will land here - it can happen that
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
export * from './bestNumber';
|
||||
export * from './bestNumberFinalized';
|
||||
export * from './bestNumberLag';
|
||||
export * from './getHeader';
|
||||
export * from './getBlock';
|
||||
export * from './subscribeNewBlocks';
|
||||
export * from './subscribeNewHeads';
|
||||
|
||||
@@ -1,32 +1,37 @@
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import { EventRecord, Hash, SignedBlock } from '@polkadot/types/interfaces';
|
||||
import { FullNewBlock } from '../types';
|
||||
import type { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import type { Vec } from '@polkadot/types';
|
||||
import type { EventRecord, SignedBlock } from '@polkadot/types/interfaces';
|
||||
import type { Observable } from '@polkadot/x-rxjs';
|
||||
import type { HeaderExtended, SignedBlockExtended } from '../type/types';
|
||||
|
||||
import { Observable, combineLatest, of } from 'rxjs';
|
||||
import { map, switchMap } from 'rxjs/operators';
|
||||
import { combineLatest, of } from '@polkadot/x-rxjs';
|
||||
import { map, switchMap } from '@polkadot/x-rxjs/operators';
|
||||
|
||||
import { createSignedBlockExtended } from '../type';
|
||||
import { memo } from '../util';
|
||||
|
||||
/**
|
||||
* @name subscribeNewBlocks
|
||||
* @returns The latest block & events for that block
|
||||
*/
|
||||
export function subscribeNewBlocks (instanceId: string, api: ApiInterfaceRx): () => Observable<FullNewBlock> {
|
||||
return memo(instanceId, (): Observable<FullNewBlock> =>
|
||||
export function subscribeNewBlocks (instanceId: string, api: ApiInterfaceRx): () => Observable<SignedBlockExtended> {
|
||||
return memo(instanceId, (): Observable<SignedBlockExtended> =>
|
||||
api.derive.chain.subscribeNewHeads().pipe(
|
||||
switchMap((header): Observable<[Hash, EventRecord[], SignedBlock]> => {
|
||||
const blockHash = header.hash;
|
||||
switchMap((header): Observable<[SignedBlock, Vec<EventRecord>, HeaderExtended]> => {
|
||||
const blockHash = header.createdAtHash || header.hash;
|
||||
|
||||
return combineLatest(
|
||||
of(blockHash),
|
||||
api.rpc.chain.getBlock(blockHash),
|
||||
api.query.system.events.at(blockHash),
|
||||
api.rpc.chain.getBlock(header.hash)
|
||||
of(header)
|
||||
);
|
||||
}),
|
||||
map(([blockHash, events, block]) => ({ block: block.block, blockHash, blockNumber: block.block.header.number.unwrap(), events, justification: block.justification }))
|
||||
map(([block, events, header]) =>
|
||||
createSignedBlockExtended(block.registry, block, events, header.validators)
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import type { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import type { Observable } from '@polkadot/x-rxjs';
|
||||
import type { HeaderExtended } from '../type/types';
|
||||
|
||||
import { Observable, combineLatest, of } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { combineLatest, of } from '@polkadot/x-rxjs';
|
||||
import { map } from '@polkadot/x-rxjs/operators';
|
||||
|
||||
import { HeaderExtended } from '../type';
|
||||
import { createHeaderExtended } from '../type';
|
||||
import { memo } from '../util';
|
||||
|
||||
/**
|
||||
@@ -28,10 +30,13 @@ export function subscribeNewHeads (instanceId: string, api: ApiInterfaceRx): ()
|
||||
api.rpc.chain.subscribeNewHeads(),
|
||||
api.query.session
|
||||
? api.query.session.validators()
|
||||
: of([])
|
||||
: of(undefined)
|
||||
]).pipe(
|
||||
map(([header, validators]): HeaderExtended =>
|
||||
new HeaderExtended(api.registry, header, validators)
|
||||
)
|
||||
));
|
||||
map(([header, validators]): HeaderExtended => {
|
||||
header.createdAtHash = header.hash;
|
||||
|
||||
return createHeaderExtended(header.registry, header, validators);
|
||||
})
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { Block, BlockNumber, EventRecord, Hash, Justification } from '@polkadot/types/interfaces';
|
||||
|
||||
export interface FullNewBlock {
|
||||
block: Block;
|
||||
blockHash: Hash;
|
||||
blockNumber: BlockNumber;
|
||||
events: EventRecord[];
|
||||
justification: Justification;
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
export * from './proposals';
|
||||
|
||||
@@ -1,17 +1,20 @@
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import { Hash, Proposal, Votes } from '@polkadot/types/interfaces';
|
||||
import { DeriveCollectiveProposal } from '../types';
|
||||
import type { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import type { Option } from '@polkadot/types';
|
||||
import type { Hash, Proposal, Votes } from '@polkadot/types/interfaces';
|
||||
import type { Observable } from '@polkadot/x-rxjs';
|
||||
import type { DeriveCollectiveProposal } from '../types';
|
||||
|
||||
import { Observable, combineLatest, of } from 'rxjs';
|
||||
import { catchError, map, switchMap } from 'rxjs/operators';
|
||||
import { Option } from '@polkadot/types';
|
||||
import { isFunction } from '@polkadot/util';
|
||||
import { combineLatest, of } from '@polkadot/x-rxjs';
|
||||
import { catchError, map, switchMap } from '@polkadot/x-rxjs/operators';
|
||||
|
||||
import { memo } from '../util';
|
||||
|
||||
type Collective = 'council' | 'membership' | 'technicalCommittee';
|
||||
|
||||
type Result = [(Hash | Uint8Array | string)[], (Option<Proposal> | null)[], Option<Votes>[]];
|
||||
|
||||
function parse (api: ApiInterfaceRx, [hashes, proposals, votes]: Result): DeriveCollectiveProposal[] {
|
||||
@@ -28,7 +31,7 @@ function parse (api: ApiInterfaceRx, [hashes, proposals, votes]: Result): Derive
|
||||
.filter((proposal): proposal is DeriveCollectiveProposal => !!proposal);
|
||||
}
|
||||
|
||||
function _proposalsFrom (instanceId: string, api: ApiInterfaceRx, section: 'council' | 'technicalCommittee' = 'council'): (hashes: (Hash | Uint8Array | string)[]) => Observable<DeriveCollectiveProposal[]> {
|
||||
function _proposalsFrom (instanceId: string, api: ApiInterfaceRx, section: Collective): (hashes: (Hash | Uint8Array | string)[]) => Observable<DeriveCollectiveProposal[]> {
|
||||
return memo(instanceId, (hashes: (Hash | Uint8Array | string)[]): Observable<DeriveCollectiveProposal[]> =>
|
||||
(isFunction(api.query[section]?.proposals) && hashes.length
|
||||
? combineLatest<Result>([
|
||||
@@ -48,19 +51,19 @@ function _proposalsFrom (instanceId: string, api: ApiInterfaceRx, section: 'coun
|
||||
);
|
||||
}
|
||||
|
||||
export function proposals (instanceId: string, api: ApiInterfaceRx, section: 'council' | 'technicalCommittee' = 'council'): () => Observable<DeriveCollectiveProposal[]> {
|
||||
export function proposals (instanceId: string, api: ApiInterfaceRx, section: Collective): () => Observable<DeriveCollectiveProposal[]> {
|
||||
const proposalsFrom = _proposalsFrom(instanceId, api, section);
|
||||
|
||||
return memo(instanceId, (): Observable<DeriveCollectiveProposal[]> =>
|
||||
isFunction(api.query[section]?.proposals)
|
||||
? api.query[section].proposals().pipe(
|
||||
? api.query[section as 'council'].proposals().pipe(
|
||||
switchMap(proposalsFrom)
|
||||
)
|
||||
: of([] as DeriveCollectiveProposal[])
|
||||
);
|
||||
}
|
||||
|
||||
export function proposal (instanceId: string, api: ApiInterfaceRx, section: 'council' | 'technicalCommittee' = 'council'): (hash: Hash | Uint8Array | string) => Observable<DeriveCollectiveProposal | null> {
|
||||
export function proposal (instanceId: string, api: ApiInterfaceRx, section: Collective): (hash: Hash | Uint8Array | string) => Observable<DeriveCollectiveProposal | null> {
|
||||
const proposalsFrom = _proposalsFrom(instanceId, api, section);
|
||||
|
||||
return memo(instanceId, (hash: Hash | Uint8Array | string): Observable<DeriveCollectiveProposal | null> =>
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import { DeriveContractFees } from '../types';
|
||||
import type { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import type { BN } from '@polkadot/util';
|
||||
import type { Observable } from '@polkadot/x-rxjs';
|
||||
import type { DeriveContractFees } from '../types';
|
||||
|
||||
import BN from 'bn.js';
|
||||
import { Observable, of } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { of } from '@polkadot/x-rxjs';
|
||||
import { map } from '@polkadot/x-rxjs/operators';
|
||||
|
||||
import { memo } from '../util';
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
export * from './fees';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
export * from './proposals';
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import { Hash } from '@polkadot/types/interfaces';
|
||||
import { DeriveCollectiveProposal } from '../types';
|
||||
import type { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import type { Hash } from '@polkadot/types/interfaces';
|
||||
import type { Observable } from '@polkadot/x-rxjs';
|
||||
import type { DeriveCollectiveProposal } from '../types';
|
||||
|
||||
import { Observable } from 'rxjs';
|
||||
import { proposal as collectiveProposal, proposals as collectiveProposals } from '../collective';
|
||||
import { memo } from '../util';
|
||||
|
||||
export function proposal (instanceId: string, api: ApiInterfaceRx): (hash: Hash | Uint8Array | string) => Observable<DeriveCollectiveProposal | null> {
|
||||
return memo(instanceId, collectiveProposal(instanceId, api));
|
||||
return memo(instanceId, collectiveProposal(instanceId, api, 'council'));
|
||||
}
|
||||
|
||||
export function proposals (instanceId: string, api: ApiInterfaceRx): () => Observable<DeriveCollectiveProposal[]> {
|
||||
return memo(instanceId, collectiveProposals(instanceId, api));
|
||||
return memo(instanceId, collectiveProposals(instanceId, api, 'council'));
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { AccountId, Balance } from '@polkadot/types/interfaces';
|
||||
import type { AccountId, Balance } from '@polkadot/types/interfaces';
|
||||
|
||||
export interface DeriveCouncilVote {
|
||||
stake: Balance;
|
||||
|
||||
@@ -1,29 +1,37 @@
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { AccountId, Balance } from '@polkadot/types/interfaces';
|
||||
import { ITuple } from '@polkadot/types/types';
|
||||
import { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import { DeriveCouncilVote, DeriveCouncilVotes } from '../types';
|
||||
import type { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import type { Vec } from '@polkadot/types';
|
||||
import type { AccountId, Balance, Voter } from '@polkadot/types/interfaces';
|
||||
import type { ITuple } from '@polkadot/types/types';
|
||||
import type { Observable } from '@polkadot/x-rxjs';
|
||||
import type { DeriveCouncilVote, DeriveCouncilVotes } from '../types';
|
||||
|
||||
import { Observable, combineLatest } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { Vec } from '@polkadot/types';
|
||||
import { combineLatest } from '@polkadot/x-rxjs';
|
||||
import { map } from '@polkadot/x-rxjs/operators';
|
||||
|
||||
import { memo } from '../util';
|
||||
|
||||
// Voter is current tuple is 2.x-era
|
||||
type VoteEntry = Voter | ITuple<[Balance, Vec<AccountId>]>;
|
||||
|
||||
function isVoter (value: VoteEntry): value is Voter {
|
||||
return !Array.isArray(value);
|
||||
}
|
||||
|
||||
function retrieveStakeOf (api: ApiInterfaceRx): Observable<[AccountId, Balance][]> {
|
||||
return (api.query.electionsPhragmen || api.query.elections).stakeOf.entries<Balance>().pipe(
|
||||
return (api.query.phragmenElection || api.query.electionsPhragmen || api.query.elections).stakeOf.entries<Balance, [AccountId]>().pipe(
|
||||
map((entries) =>
|
||||
entries.map(([key, stake]) => [key.args[0] as AccountId, stake])
|
||||
entries.map(([{ args: [accountId] }, stake]) => [accountId, stake])
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
function retrieveVoteOf (api: ApiInterfaceRx): Observable<[AccountId, AccountId[]][]> {
|
||||
return (api.query.electionsPhragmen || api.query.elections).votesOf.entries<Vec<AccountId>>().pipe(
|
||||
return (api.query.phragmenElection || api.query.electionsPhragmen || api.query.elections).votesOf.entries<Vec<AccountId>, [AccountId]>().pipe(
|
||||
map((entries) =>
|
||||
entries.map(([key, votes]) => [key.args[0] as AccountId, votes])
|
||||
entries.map(([{ args: [accountId] }, votes]) => [accountId, votes])
|
||||
)
|
||||
);
|
||||
}
|
||||
@@ -53,20 +61,23 @@ function retrievePrev (api: ApiInterfaceRx): Observable<DeriveCouncilVotes> {
|
||||
}
|
||||
|
||||
function retrieveCurrent (api: ApiInterfaceRx): Observable<DeriveCouncilVotes> {
|
||||
const elections = (api.query.electionsPhragmen || api.query.elections);
|
||||
const elections = (api.query.phragmenElection || api.query.electionsPhragmen || api.query.elections);
|
||||
|
||||
return elections.voting.entries<ITuple<[Balance, Vec<AccountId>]>>().pipe(
|
||||
return elections.voting.entries<VoteEntry, [AccountId]>().pipe(
|
||||
map((entries): DeriveCouncilVotes =>
|
||||
entries.map(([key, [stake, votes]]): [AccountId, DeriveCouncilVote] =>
|
||||
[key.args[0] as AccountId, { stake, votes }]
|
||||
)
|
||||
entries.map(([{ args: [accountId] }, value]): [AccountId, DeriveCouncilVote] => [
|
||||
accountId,
|
||||
isVoter(value)
|
||||
? { stake: value.stake, votes: value.votes }
|
||||
: { stake: value[0], votes: value[1] }
|
||||
])
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
export function votes (instanceId: string, api: ApiInterfaceRx): () => Observable<DeriveCouncilVotes> {
|
||||
return memo(instanceId, (): Observable<DeriveCouncilVotes> =>
|
||||
(api.query.electionsPhragmen || api.query.elections).stakeOf
|
||||
(api.query.phragmenElection || api.query.electionsPhragmen || api.query.elections).stakeOf
|
||||
? retrievePrev(api)
|
||||
: retrieveCurrent(api)
|
||||
);
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { AccountId } from '@polkadot/types/interfaces';
|
||||
import { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import { DeriveCouncilVote } from '../types';
|
||||
import type { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import type { AccountId } from '@polkadot/types/interfaces';
|
||||
import type { Observable } from '@polkadot/x-rxjs';
|
||||
import type { DeriveCouncilVote } from '../types';
|
||||
|
||||
import { map } from '@polkadot/x-rxjs/operators';
|
||||
|
||||
import { Observable } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { memo } from '../util';
|
||||
|
||||
export function votesOf (instanceId: string, api: ApiInterfaceRx): (accountId: string | Uint8Array | AccountId) => Observable<DeriveCouncilVote> {
|
||||
|
||||
@@ -1,15 +1,16 @@
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { BlockNumber, Hash, ReferendumIndex, Scheduled } from '@polkadot/types/interfaces';
|
||||
import { ITuple } from '@polkadot/types/types';
|
||||
import { DeriveDispatch, DeriveProposalImage } from '../types';
|
||||
import type { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import type { Option, u64, Vec } from '@polkadot/types';
|
||||
import type { BlockNumber, Hash, ReferendumIndex, Scheduled } from '@polkadot/types/interfaces';
|
||||
import type { ITuple } from '@polkadot/types/types';
|
||||
import type { Observable } from '@polkadot/x-rxjs';
|
||||
import type { DeriveDispatch, DeriveProposalImage } from '../types';
|
||||
|
||||
import { Observable, combineLatest, of } from 'rxjs';
|
||||
import { map, switchMap } from 'rxjs/operators';
|
||||
import { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import { Option, Vec, u64 } from '@polkadot/types';
|
||||
import { isFunction, stringToHex } from '@polkadot/util';
|
||||
import { combineLatest, of } from '@polkadot/x-rxjs';
|
||||
import { map, switchMap } from '@polkadot/x-rxjs/operators';
|
||||
|
||||
import { memo } from '../util';
|
||||
|
||||
@@ -50,7 +51,7 @@ function schedulerEntries (api: ApiInterfaceRx): Observable<[BlockNumber[], Opti
|
||||
api.query.scheduler.agenda.keys()
|
||||
),
|
||||
switchMap((keys) => {
|
||||
const blockNumbers = keys.map((key) => key.args[0] as BlockNumber);
|
||||
const blockNumbers = keys.map(({ args: [blockNumber] }) => blockNumber);
|
||||
|
||||
return combineLatest([
|
||||
of(blockNumbers),
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
export * from './dispatchQueue';
|
||||
|
||||
@@ -1,15 +1,16 @@
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { AccountId, ReferendumInfo, ReferendumInfoFinished, ReferendumInfoTo239, Vote, VotingDelegating, VotingDirect, VotingDirectVote } from '@polkadot/types/interfaces';
|
||||
import { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import { DeriveDemocracyLock } from '../types';
|
||||
import type { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import type { Option } from '@polkadot/types';
|
||||
import type { AccountId, ReferendumInfo, ReferendumInfoFinished, ReferendumInfoTo239, Vote, VotingDelegating, VotingDirect, VotingDirectVote } from '@polkadot/types/interfaces';
|
||||
import type { BN } from '@polkadot/util';
|
||||
import type { Observable } from '@polkadot/x-rxjs';
|
||||
import type { DeriveDemocracyLock } from '../types';
|
||||
|
||||
import BN from 'bn.js';
|
||||
import { Observable, of } from 'rxjs';
|
||||
import { map, switchMap } from 'rxjs/operators';
|
||||
import { Option } from '@polkadot/types';
|
||||
import { BN_ZERO, isUndefined } from '@polkadot/util';
|
||||
import { of } from '@polkadot/x-rxjs';
|
||||
import { map, switchMap } from '@polkadot/x-rxjs/operators';
|
||||
|
||||
import { memo } from '../util';
|
||||
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { Hash, VoteThreshold } from '@polkadot/types/interfaces';
|
||||
import { ITuple } from '@polkadot/types/types';
|
||||
import { DeriveProposalExternal } from '../types';
|
||||
import type { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import type { Option } from '@polkadot/types';
|
||||
import type { Hash, VoteThreshold } from '@polkadot/types/interfaces';
|
||||
import type { ITuple } from '@polkadot/types/types';
|
||||
import type { Observable } from '@polkadot/x-rxjs';
|
||||
import type { DeriveProposalExternal } from '../types';
|
||||
|
||||
import { Observable, of } from 'rxjs';
|
||||
import { map, switchMap } from 'rxjs/operators';
|
||||
import { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import { Option } from '@polkadot/types';
|
||||
import { of } from '@polkadot/x-rxjs';
|
||||
import { map, switchMap } from '@polkadot/x-rxjs/operators';
|
||||
|
||||
import { memo } from '../util';
|
||||
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { AccountId, Balance, BlockNumber, Hash } from '@polkadot/types/interfaces';
|
||||
import { ITuple } from '@polkadot/types/types';
|
||||
import { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import { DeriveProposalImage } from '../types';
|
||||
import type { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import type { Bytes, Option } from '@polkadot/types';
|
||||
import type { AccountId, Balance, BlockNumber, Hash } from '@polkadot/types/interfaces';
|
||||
import type { ITuple } from '@polkadot/types/types';
|
||||
import type { Observable } from '@polkadot/x-rxjs';
|
||||
import type { DeriveProposalImage } from '../types';
|
||||
|
||||
import { Observable } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { Bytes, Option } from '@polkadot/types';
|
||||
import { map } from '@polkadot/x-rxjs/operators';
|
||||
|
||||
import { memo } from '../util';
|
||||
import { parseImage } from './util';
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { AccountId, Balance, BlockNumber, Hash } from '@polkadot/types/interfaces';
|
||||
import { ITuple } from '@polkadot/types/types';
|
||||
import { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import { DeriveProposalImage } from '../types';
|
||||
import type { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import type { Bytes, Option } from '@polkadot/types';
|
||||
import type { AccountId, Balance, BlockNumber, Hash } from '@polkadot/types/interfaces';
|
||||
import type { ITuple } from '@polkadot/types/types';
|
||||
import type { Observable } from '@polkadot/x-rxjs';
|
||||
import type { DeriveProposalImage } from '../types';
|
||||
|
||||
import { Observable } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { Bytes, Option } from '@polkadot/types';
|
||||
import { map } from '@polkadot/x-rxjs/operators';
|
||||
|
||||
import { memo } from '../util';
|
||||
import { parseImage } from './util';
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user