Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f6490217ec | ||
|
|
601cc62d70 | ||
|
|
201480be56 | ||
|
|
519823bc0e | ||
|
|
0b134c1eb8 | ||
|
|
e6e96aa9c9 | ||
|
|
84d0d8594e | ||
|
|
6be25966d8 | ||
|
|
a5eb11e5f3 | ||
|
|
19f87aac4d | ||
|
|
b217a59310 | ||
|
|
2de7a3c130 | ||
|
|
deecf4853e | ||
|
|
8889e69341 | ||
|
|
14194a363e | ||
|
|
9c50e81ab9 | ||
|
|
6505e73355 | ||
|
|
cefeb37ae6 | ||
|
|
9e29e89baf | ||
|
|
b82c90679d | ||
|
|
eeb8d20e58 | ||
|
|
b891edbd37 | ||
|
|
2ee3afcd61 | ||
|
|
328630fb17 | ||
|
|
325080cf71 | ||
|
|
549a536328 | ||
|
|
23f41a0bab | ||
|
|
5e0c0ba91a | ||
|
|
812a077e63 | ||
|
|
6ba28c8ad2 | ||
|
|
6cd0074ce4 | ||
|
|
b3d592357f | ||
|
|
f499946f1f | ||
|
|
56e28bed7f | ||
|
|
c76fb20a83 | ||
|
|
9d4b0ea56a | ||
|
|
f9d569ddd1 | ||
|
|
7221a3637c | ||
|
|
438c830366 | ||
|
|
3d0fd5a6a8 | ||
|
|
de57876c7f | ||
|
|
b24a1ff350 | ||
|
|
5f8c623179 | ||
|
|
00026a173f | ||
|
|
8da895efd4 | ||
|
|
89d029eca3 | ||
|
|
ac2a7eea67 | ||
|
|
4f0e573adf | ||
|
|
8417eff2b3 | ||
|
|
4aa5693906 | ||
|
|
982665c337 | ||
|
|
6dce57b394 | ||
|
|
ca7edf1593 | ||
|
|
59e069f091 | ||
|
|
65ff5c8f30 | ||
|
|
1c327c60d9 | ||
|
|
de9f033d99 | ||
|
|
9c913fb482 | ||
|
|
e19e530c1c | ||
|
|
aa91e0b8b5 | ||
|
|
9a6ba2fe0f | ||
|
|
de853d9cc0 | ||
|
|
07063134b8 | ||
|
|
20b8cd762d | ||
|
|
bd3338c3df | ||
|
|
4c328964d5 | ||
|
|
70e5e2b60a | ||
|
|
4329c0a411 | ||
|
|
0713afa0e0 | ||
|
|
8b518a909b | ||
|
|
794f1fe398 | ||
|
|
51423e20b5 | ||
|
|
d4b27ba670 | ||
|
|
8ca194a3d2 | ||
|
|
5fd2c70924 | ||
|
|
d36ee7de2f | ||
|
|
3683f9e5ff | ||
|
|
18c302d2cf | ||
|
|
1686f8b357 | ||
|
|
15158b763c | ||
|
|
f5f338a9ae | ||
|
|
458dec53dc | ||
|
|
ab05045686 | ||
|
|
b2c84eb461 | ||
|
|
1ee1d70d55 | ||
|
|
7de647ec0b | ||
|
|
cedbd8fa06 | ||
|
|
cba34b4b65 | ||
|
|
1a99d67c77 | ||
|
|
2a5c5ce3fe | ||
|
|
e4ca0a1c64 | ||
|
|
e6018f2f75 | ||
|
|
a9b4f8d841 | ||
|
|
7fe68857a0 | ||
|
|
4f63fc77a3 | ||
|
|
6e2ad7789e | ||
|
|
edb856c94f | ||
|
|
2f215fe2de | ||
|
|
ffa1279c64 | ||
|
|
83aca87dac | ||
|
|
bf782f6f65 | ||
|
|
7adad82786 | ||
|
|
693cf855f0 | ||
|
|
854a520517 | ||
|
|
6e6fc98cd1 | ||
|
|
3db15e73a5 | ||
|
|
215b659a9a | ||
|
|
7ef945d15b | ||
|
|
73ec345fcc | ||
|
|
c1c537a3b5 | ||
|
|
dc64076c79 | ||
|
|
da8ff51615 | ||
|
|
60b1bc87a4 | ||
|
|
7ed1857589 | ||
|
|
4c0e60f3d6 | ||
|
|
20ed3bb5fe | ||
|
|
be3f9c8fe8 | ||
|
|
e850955e55 | ||
|
|
eb5ee9860b | ||
|
|
f31bbdde02 | ||
|
|
f67c435378 | ||
|
|
bf9a60a202 | ||
|
|
9c3c07fa9b | ||
|
|
11786ca102 | ||
|
|
ffaea83e3e | ||
|
|
954540b944 | ||
|
|
204cf6769d | ||
|
|
f319bc4c50 | ||
|
|
7b9a11ac25 | ||
|
|
5d2feca2d4 | ||
|
|
dd97e9daee | ||
|
|
be258a1f7c | ||
|
|
72e9474f6f | ||
|
|
d1f63a7864 | ||
|
|
07ca18502b | ||
|
|
cddbe411f7 | ||
|
|
ffa60d1cfa | ||
|
|
88193b6a75 | ||
|
|
cc4a4607f1 | ||
|
|
6c25d0ab0d | ||
|
|
fbbbcd2612 | ||
|
|
dd57b1a007 | ||
|
|
47d0e68f7d | ||
|
|
7b6397215d | ||
|
|
5739b69757 | ||
|
|
2ca79f2f70 | ||
|
|
8fb64f77cd | ||
|
|
d1f86ce78e | ||
|
|
64ff226535 | ||
|
|
e762746ff0 | ||
|
|
ce5c8f7443 | ||
|
|
fc4cbb608c | ||
|
|
7ac3043f83 | ||
|
|
44b56fb0cb | ||
|
|
758ce567e5 | ||
|
|
cb5308b476 | ||
|
|
a9211690be | ||
|
|
a7db14a261 | ||
|
|
3a1f284fa8 | ||
|
|
a0b6c42629 | ||
|
|
f77ae4d99f | ||
|
|
5fa9af8fd3 | ||
|
|
1ff029dc11 | ||
|
|
4c8c9fbb07 | ||
|
|
7057cf365b | ||
|
|
d1bc48e936 | ||
|
|
2dee50f019 | ||
|
|
fa76378702 | ||
|
|
e855da1f13 | ||
|
|
adffde368c | ||
|
|
5278138cc3 | ||
|
|
98249a282e | ||
|
|
b7eeb992cd | ||
|
|
01daf32646 | ||
|
|
51a866fd35 | ||
|
|
53401e29ea | ||
|
|
774f41e6db | ||
|
|
1ca3b295a4 | ||
|
|
82828d8e09 | ||
|
|
131055c1d5 | ||
|
|
bd2e690261 | ||
|
|
1a2ca8ea38 | ||
|
|
0c98593aee | ||
|
|
416e2fbc96 | ||
|
|
c04fb9073e | ||
|
|
4f85ceb2c3 | ||
|
|
9196ce85a0 | ||
|
|
26734bf8bf | ||
|
|
53959d482d | ||
|
|
0a0f110c42 | ||
|
|
47f1350652 | ||
|
|
3c3b7290c2 | ||
|
|
006c686c18 | ||
|
|
44d4a07005 | ||
|
|
6e61be960c | ||
|
|
bd57359dc5 | ||
|
|
10bc6b4060 | ||
|
|
9e681c0666 | ||
|
|
e969382fd0 | ||
|
|
1949a13810 | ||
|
|
362262c4e1 | ||
|
|
ddd5eab7f5 | ||
|
|
1da6193f34 | ||
|
|
c4e553ad80 | ||
|
|
0b83a61600 | ||
|
|
382f7d75c8 | ||
|
|
88e4518f64 | ||
|
|
b1a657d68a | ||
|
|
067f17b28b | ||
|
|
99073e2a88 | ||
|
|
f9a42e47e7 | ||
|
|
b80d72edbd | ||
|
|
1f7b9f7f3a | ||
|
|
843efb2146 | ||
|
|
3619fabe5f | ||
|
|
bf598e392e | ||
|
|
f026137545 | ||
|
|
2264f53a43 | ||
|
|
8ba4029633 | ||
|
|
05cb2cef5a | ||
|
|
3a70594594 | ||
|
|
019cb58dd1 | ||
|
|
d487490ca0 | ||
|
|
b9fad61da0 | ||
|
|
77bf33b4e4 | ||
|
|
7ed7c9d3a8 | ||
|
|
0d2896630d | ||
|
|
74dbff32df | ||
|
|
4653cc0d84 | ||
|
|
50e115f6a1 | ||
|
|
8a5a86e8b3 | ||
|
|
48ef5af93f | ||
|
|
e5c20be666 | ||
|
|
6bf0d5eea9 | ||
|
|
21c57b60a1 | ||
|
|
b1dff22954 | ||
|
|
a3d0cb0999 | ||
|
|
bf946c20db | ||
|
|
664d2c8ab6 | ||
|
|
01a4d6b4a9 | ||
|
|
18454083db | ||
|
|
191abe4e08 | ||
|
|
97fbb4732d | ||
|
|
01f3666cc7 | ||
|
|
468fcdccaa | ||
|
|
c8dd26b0da | ||
|
|
61d5dec63a | ||
|
|
64a4bb2e17 | ||
|
|
f78bf9dde1 | ||
|
|
b7ba654e48 | ||
|
|
532a252fe0 | ||
|
|
614cf4e484 | ||
|
|
c576c689d0 | ||
|
|
d86cd94fe2 | ||
|
|
762b16ea13 | ||
|
|
09a72c0f31 | ||
|
|
eded5fede2 | ||
|
|
704df82b1d | ||
|
|
46efc10939 | ||
|
|
74cf8aa30c | ||
|
|
7a60ab81f8 | ||
|
|
c1d7ca67d5 | ||
|
|
7e1eb0fab0 | ||
|
|
af76d7fb04 | ||
|
|
afbe072ad5 | ||
|
|
d86c5be413 | ||
|
|
a695d2a5b5 | ||
|
|
1c087967d3 | ||
|
|
906732bcdc | ||
|
|
c9352af81c | ||
|
|
e2e8e3fedd | ||
|
|
3ca07a5bc8 | ||
|
|
89700f98c5 | ||
|
|
0cae3cf0fa | ||
|
|
eade586044 | ||
|
|
c227c6625c | ||
|
|
4cb8462d50 | ||
|
|
1d671d531c | ||
|
|
a49cd799dd | ||
|
|
8ed2bda3a8 | ||
|
|
2aabbe3cce | ||
|
|
7b37cc79a3 | ||
|
|
34a719e443 | ||
|
|
b440c9b0ea | ||
|
|
03e9a9676f | ||
|
|
094d6f7a1c | ||
|
|
33fd1b1c78 | ||
|
|
9968aa4606 | ||
|
|
9c337422a5 | ||
|
|
cc432e2291 | ||
|
|
aaff64404a | ||
|
|
bfe788cd31 | ||
|
|
883b191ae7 | ||
|
|
fa46debb90 | ||
|
|
ed4af1d04b | ||
|
|
4cea617b13 | ||
|
|
26b6a59725 | ||
|
|
35c63a52c8 | ||
|
|
61bc20aa7b | ||
|
|
db59fbff25 | ||
|
|
49b3104d04 | ||
|
|
2338ecc2d7 | ||
|
|
bab8c852a4 | ||
|
|
cba17aeb55 | ||
|
|
deca8ad216 | ||
|
|
fb4c840549 | ||
|
|
610234c1a1 | ||
|
|
7f39c573ce | ||
|
|
114c437671 | ||
|
|
e12f2f67c6 | ||
|
|
0c61850ad6 | ||
|
|
8b1a7a8584 | ||
|
|
4b6b0305e6 | ||
|
|
3b758a0d64 | ||
|
|
ea2c320f33 | ||
|
|
306857ae07 | ||
|
|
448ecd13bb | ||
|
|
011e24bd49 | ||
|
|
099992627b | ||
|
|
74e20864a6 | ||
|
|
d006f051a3 | ||
|
|
f1fe498801 | ||
|
|
1f2cd5a6f7 | ||
|
|
d6239cbe56 | ||
|
|
d82bb63acb | ||
|
|
a3ae4cf5d2 | ||
|
|
6b74ea39c2 | ||
|
|
87aab2eca5 | ||
|
|
1c6a2582f3 | ||
|
|
ea49095334 | ||
|
|
b2daf7482f | ||
|
|
b0165e41e7 | ||
|
|
0a27f63423 | ||
|
|
20d8a31258 | ||
|
|
ca186a4b2c | ||
|
|
7bd593c8f7 | ||
|
|
75220eb54f | ||
|
|
dde7d49598 | ||
|
|
a31921b88e | ||
|
|
a4c5ca45b2 | ||
|
|
c44cb1858e | ||
|
|
f89867a9ae | ||
|
|
be4b9a4133 | ||
|
|
46b1429da9 | ||
|
|
a70af20eba | ||
|
|
09dc78d6b1 | ||
|
|
921e329d18 | ||
|
|
f86aebf7e1 | ||
|
|
eef1c5327b | ||
|
|
2c25936e2c | ||
|
|
734213a2f9 | ||
|
|
16e0ea9315 | ||
|
|
c87ba33893 | ||
|
|
2875fdf2cf | ||
|
|
e73c147275 | ||
|
|
f080d6ed1c | ||
|
|
8ea07727ba | ||
|
|
3c47c3fdc3 | ||
|
|
06418913e5 | ||
|
|
188363d407 | ||
|
|
ec79087bab | ||
|
|
155fd0f8b1 | ||
|
|
05b7def1a0 | ||
|
|
5671af8db7 | ||
|
|
6aebeec028 | ||
|
|
5b5d0a3fb8 | ||
|
|
d405ed1005 | ||
|
|
2be97310d3 | ||
|
|
1f44e4473f | ||
|
|
022c7ea645 | ||
|
|
fe078ca67c | ||
|
|
479c742471 | ||
|
|
a52c629ecf | ||
|
|
c077d0f2e7 | ||
|
|
679994a6fb | ||
|
|
8cc256fdcf | ||
|
|
b6b2f2beec | ||
|
|
6075a21efb | ||
|
|
fa98f8f06d | ||
|
|
ad570cac5a | ||
|
|
cb32acc409 | ||
|
|
3998b1bcbd | ||
|
|
3fd03b2498 | ||
|
|
cba5710fec | ||
|
|
1ffdba03b3 | ||
|
|
fcf89d1501 | ||
|
|
56dc116d92 | ||
|
|
2371d6a29c | ||
|
|
d39878c875 | ||
|
|
287ceb2ded | ||
|
|
7c04be6abc | ||
|
|
e601ae27a1 | ||
|
|
487ad475c7 | ||
|
|
506b042f8c | ||
|
|
0e037de1b1 | ||
|
|
8d3cb72189 | ||
|
|
f8b9615e6b | ||
|
|
7cc961f789 | ||
|
|
1d92b7bead | ||
|
|
2c44b5ca8a | ||
|
|
8d9b50a004 | ||
|
|
d41f6ec3ef | ||
|
|
6aff7db89a | ||
|
|
dc105e6b31 | ||
|
|
f41ad2eee7 | ||
|
|
276da86dbe | ||
|
|
5aa64dddf3 | ||
|
|
cf01c41b33 | ||
|
|
64bc3fbffa | ||
|
|
453aacb669 | ||
|
|
2f350e3bc2 | ||
|
|
8379689eaa | ||
|
|
2676909cd0 | ||
|
|
a53c924248 | ||
|
|
a044a959b6 | ||
|
|
7555a3a7ce | ||
|
|
0fac973645 | ||
|
|
f533f51003 | ||
|
|
b4c0875ebf | ||
|
|
8cab499a83 | ||
|
|
f2daae3986 | ||
|
|
41cf32c808 | ||
|
|
b0e970a815 | ||
|
|
fed9e8f7de | ||
|
|
d2e2d3be76 | ||
|
|
07b9cb1a16 | ||
|
|
4f24af6d8a | ||
|
|
a30d467618 | ||
|
|
3daf44bac2 | ||
|
|
b69d8ec789 | ||
|
|
d1b2664071 | ||
|
|
8d0f20c2a7 | ||
|
|
f200a348de | ||
|
|
fae67e72ee | ||
|
|
a23e71bfb0 | ||
|
|
6e96fd6a55 | ||
|
|
3ba2bbd581 | ||
|
|
f8084c2d12 | ||
|
|
1ad552f03d | ||
|
|
6b8d0207a6 | ||
|
|
27871135a0 | ||
|
|
26be5e0cc5 | ||
|
|
66142c0137 | ||
|
|
de395c7053 | ||
|
|
ab78245576 | ||
|
|
6ff0efca25 | ||
|
|
fa0fd7140c | ||
|
|
0b71291cf1 | ||
|
|
44d0ced5af | ||
|
|
a8bfa90b87 | ||
|
|
835361d3c5 | ||
|
|
3bb719fcfc | ||
|
|
00a3001df9 | ||
|
|
cac0056fc4 | ||
|
|
a9e55e66d6 | ||
|
|
c10f0e47b2 | ||
|
|
0b45bc6ab9 | ||
|
|
30f62f4024 | ||
|
|
262f01b54e | ||
|
|
26c2774992 | ||
|
|
58ff26cc78 | ||
|
|
62eab2d661 | ||
|
|
d4ab4f8293 | ||
|
|
aed4b3ee6a | ||
|
|
4c90c6158f | ||
|
|
b911bdbd2d | ||
|
|
b5edcb8529 | ||
|
|
9086592252 | ||
|
|
c0b428dfbc | ||
|
|
e49427ac61 | ||
|
|
64149de2d4 | ||
|
|
fe3de4379f | ||
|
|
5532daf640 | ||
|
|
e197c6f114 | ||
|
|
f3b71b21b5 | ||
|
|
db3cb47d05 | ||
|
|
3f135f2da2 | ||
|
|
4ec6a0f9b8 | ||
|
|
eca0d8d81a | ||
|
|
e056675b3a | ||
|
|
71a4b39698 | ||
|
|
d194a6e4c9 | ||
|
|
4a7d8677a3 | ||
|
|
21ac0ac2fb | ||
|
|
acfd856b25 | ||
|
|
d5d8b59f8b | ||
|
|
b24fe30a40 | ||
|
|
207e2982d7 | ||
|
|
6fab577e23 | ||
|
|
f7ca638a1a | ||
|
|
0c96ba7a02 | ||
|
|
7143f5e643 | ||
|
|
910fa20b78 | ||
|
|
4855e631b5 | ||
|
|
698f2725c9 | ||
|
|
492fce1af7 | ||
|
|
397e9494eb | ||
|
|
b8d7f4803b | ||
|
|
89f0d452f4 | ||
|
|
bf8bed36ef | ||
|
|
38529ad13c | ||
|
|
8a6d23d461 | ||
|
|
d80cc717e2 | ||
|
|
a207348c13 | ||
|
|
4a795b4c50 | ||
|
|
e54cee1fad | ||
|
|
4e4108abfa | ||
|
|
3196e66efb | ||
|
|
7e0f20908c | ||
|
|
985749ade1 | ||
|
|
ec8deb8be3 | ||
|
|
b8d4bc5c6a | ||
|
|
2870513453 | ||
|
|
e27b35cd9f | ||
|
|
bc86dbb31e | ||
|
|
d1b047f675 | ||
|
|
8b43ee6ca1 | ||
|
|
f6e5068dae | ||
|
|
fe40e2378a | ||
|
|
2e9192ca02 | ||
|
|
05ec4964fe | ||
|
|
64f8444d47 | ||
|
|
c0f9b45dca | ||
|
|
ffadc335d5 | ||
|
|
9c09386600 | ||
|
|
7cc541c45f | ||
|
|
2accd13bb6 | ||
|
|
647e605c9f | ||
|
|
eaa9dd00c7 | ||
|
|
fb7e067737 | ||
|
|
eaa71e0097 | ||
|
|
cd7767d39a | ||
|
|
cf07d4f743 | ||
|
|
525b6bf4ad | ||
|
|
f73c01889f | ||
|
|
56d20ceb41 | ||
|
|
25d1a1195e | ||
|
|
db593d2303 | ||
|
|
e17572d845 | ||
|
|
73704b68ab | ||
|
|
d594149ed1 | ||
|
|
6b0e2fe919 | ||
|
|
b36660a0cc | ||
|
|
29922c2bef | ||
|
|
1e67aeed9a | ||
|
|
c28df79c3b | ||
|
|
f145fe7c8b | ||
|
|
a03a303b8f | ||
|
|
eda93d25f6 | ||
|
|
44d89ed204 | ||
|
|
d632f25a9b | ||
|
|
2f6a397484 | ||
|
|
a54286c98b | ||
|
|
ddd21c691f | ||
|
|
d0f9114fda | ||
|
|
275593b6fb | ||
|
|
17a10fbffe | ||
|
|
afff880c20 | ||
|
|
739625c171 | ||
|
|
5fc8e3975b | ||
|
|
fadb1ffdd8 | ||
|
|
bddb48f452 | ||
|
|
af682bc23b | ||
|
|
7b2cf6dcb0 | ||
|
|
9807ff70fa | ||
|
|
d30bd0dd86 | ||
|
|
25f78a7354 | ||
|
|
0bc0ef6110 | ||
|
|
b231b7b8cb | ||
|
|
8b0ef159c0 | ||
|
|
96937666d1 | ||
|
|
da6cd98e6a | ||
|
|
ad4a6e63ce | ||
|
|
c0a804332b | ||
|
|
32c4aa3bfe | ||
|
|
8293f4b585 | ||
|
|
4d2dfb43b8 | ||
|
|
a0b8619093 | ||
|
|
c1396bc23a | ||
|
|
692c208b20 | ||
|
|
498e3a1481 | ||
|
|
8de45cb09e | ||
|
|
539b26ed87 | ||
|
|
68a3b18385 | ||
|
|
1573185bf8 | ||
|
|
fff6f311e0 | ||
|
|
a7b733daa7 | ||
|
|
00d86011a7 | ||
|
|
84b9b8dc09 | ||
|
|
06d0c1fdfb | ||
|
|
bc8782a885 | ||
|
|
e7f488ed89 | ||
|
|
7b56a52fc3 | ||
|
|
67929d34bd | ||
|
|
5eef25c815 | ||
|
|
134c4b611a | ||
|
|
095f63c46e | ||
|
|
73d7a57d38 | ||
|
|
229fd72526 | ||
|
|
db9dcbdad5 | ||
|
|
9f065abb07 | ||
|
|
564964a482 | ||
|
|
ceee734ab1 | ||
|
|
3720cf86cc | ||
|
|
a4f1651f99 | ||
|
|
5b6762373c | ||
|
|
a72fbece96 | ||
|
|
587c9881f8 | ||
|
|
36991fb845 | ||
|
|
bed3f9f4c5 | ||
|
|
5576dacd9a | ||
|
|
5d2caddcaf | ||
|
|
ed7bd61230 | ||
|
|
cd272e890f | ||
|
|
0f21d522d7 |
+1
-1
@@ -1 +1 @@
|
||||
6
|
||||
17
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
version: 2
|
||||
jobs:
|
||||
build:
|
||||
branches:
|
||||
ignore:
|
||||
- gh-pages
|
||||
working_directory: ~/polkadot-js
|
||||
docker:
|
||||
- image: circleci/node:10
|
||||
steps:
|
||||
- checkout
|
||||
- restore_cache:
|
||||
key: dependency-cache-{{ checksum "yarn.lock" }}
|
||||
- run:
|
||||
name: install-deps
|
||||
command: yarn install --frozen-lockfile
|
||||
- save_cache:
|
||||
key: dependency-cache-{{ checksum "yarn.lock" }}
|
||||
paths:
|
||||
- ./node_modules
|
||||
- ~/.cache/yarn
|
||||
- run:
|
||||
name: build
|
||||
command: yarn polkadot-dev-circleci-build
|
||||
@@ -4,5 +4,6 @@ exclude_patterns:
|
||||
- "**/*.test.js"
|
||||
- "**/*.test.ts"
|
||||
- "docs/**/*.js"
|
||||
- "packages/api/src/types/augment/"
|
||||
- "packages/types/src/interfaces/"
|
||||
- "packages/types/src/scripts/"
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@ module.exports = {
|
||||
parserOptions: {
|
||||
...base.parserOptions,
|
||||
project: [
|
||||
'./tsconfig.eslint.json'
|
||||
'./tsconfig.json'
|
||||
]
|
||||
},
|
||||
rules: {
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
name: PR
|
||||
on: [pull_request]
|
||||
|
||||
jobs:
|
||||
lint:
|
||||
name: Linting
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
node-version: [12.x]
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- name: Use Node.js ${{ matrix.node-version }}
|
||||
uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
- name: lint
|
||||
run: |
|
||||
yarn install --frozen-lockfile
|
||||
yarn lint
|
||||
|
||||
test:
|
||||
name: Testing
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
node-version: [12.x]
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- name: Use Node.js ${{ matrix.node-version }}
|
||||
uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
- name: test
|
||||
run: |
|
||||
yarn install --frozen-lockfile
|
||||
yarn test
|
||||
|
||||
build_code:
|
||||
name: Build Code
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
node-version: [12.x]
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- name: Use Node.js ${{ matrix.node-version }}
|
||||
uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
- name: build
|
||||
run: |
|
||||
yarn install --frozen-lockfile
|
||||
yarn build
|
||||
|
||||
build_docs:
|
||||
name: Build Docs
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
node-version: [12.x]
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- name: Use Node.js ${{ matrix.node-version }}
|
||||
uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
- name: build
|
||||
run: |
|
||||
yarn install --frozen-lockfile
|
||||
yarn docs
|
||||
@@ -0,0 +1,67 @@
|
||||
name: Master
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
|
||||
jobs:
|
||||
build_code:
|
||||
name: Build Code
|
||||
if: "! contains(github.event.head_commit.message, '[CI Skip]')"
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
node-version: [12.x]
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
with:
|
||||
token: ${{ secrets.GH_PAT }}
|
||||
- name: Use Node.js ${{ matrix.node-version }}
|
||||
uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
- name: build
|
||||
env:
|
||||
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
|
||||
GH_PAT: ${{ secrets.GH_PAT }}
|
||||
GH_TOKEN: ${{ secrets.GH_PAT }}
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||
run: |
|
||||
yarn install --frozen-lockfile
|
||||
yarn polkadot-dev-ghact-build
|
||||
|
||||
build_docs:
|
||||
name: Build Docs
|
||||
if: "! contains(github.event.head_commit.message, '[CI Skip]')"
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
node-version: [12.x]
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- name: Use Node.js ${{ matrix.node-version }}
|
||||
uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
- name: build
|
||||
env:
|
||||
GH_PAT: ${{ secrets.GH_PAT }}
|
||||
GH_TOKEN: ${{ secrets.GH_PAT }}
|
||||
GH_PAGES_SRC: build-docs
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
yarn install --frozen-lockfile
|
||||
yarn polkadot-dev-ghact-docs
|
||||
|
||||
dummy:
|
||||
name: Dummy
|
||||
if: "contains(github.event.head_commit.message, '[CI Skip]')"
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
node-version: [12.x]
|
||||
steps:
|
||||
- name: dummy
|
||||
run: |
|
||||
echo "Dummy skip step"
|
||||
@@ -12,6 +12,7 @@ tmp/
|
||||
.env.production.local
|
||||
.npmrc
|
||||
.rpt2_cache
|
||||
.vscode/
|
||||
cc-test-reporter
|
||||
lerna-debug.log*
|
||||
npm-debug.log*
|
||||
|
||||
-28
@@ -1,28 +0,0 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- "10"
|
||||
env:
|
||||
global:
|
||||
- CC_TEST_REPORTER_ID=b8983d04997f43ff9b9df9aa92904967547680e2a229af812b3cf14985713e84
|
||||
- GH_PAGES_SRC="build-docs"
|
||||
cache:
|
||||
yarn: true
|
||||
directories:
|
||||
- node_modules
|
||||
before_install:
|
||||
- curl -o- -L https://yarnpkg.com/install.sh | bash
|
||||
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
|
||||
- chmod +x ./cc-test-reporter
|
||||
- export PATH=$HOME/.yarn/bin::$(yarn global bin):$PATH
|
||||
before_script:
|
||||
- ./cc-test-reporter before-build
|
||||
script:
|
||||
- yarn polkadot-dev-travis-build
|
||||
after_script:
|
||||
- ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
|
||||
deploy:
|
||||
skip_cleanup: true
|
||||
provider: script
|
||||
script: yarn polkadot-dev-travis-deploy
|
||||
on:
|
||||
branch: master
|
||||
+130
-11
@@ -1,3 +1,122 @@
|
||||
# 1.1.1
|
||||
|
||||
- Add support for `balances.account` in all applicable derives (incl. `vesting` module)
|
||||
- Inject and use SignedExtensions by name from V11 metadata (V4 extrinsics only)
|
||||
- Add typings for `api.tx.*.*` - the `polkadot-types-from-chain` now also generates these
|
||||
- Remove additional V1-only derives `(staking.recentlyOffline`, `balances.nominatorsFor`)
|
||||
- Add `.isMax()` on int values, an opposite of `isZero()` (e.g. `u128`, as well as derived, e.g. `Balances`)
|
||||
- Add `.keyPrefix()` to all `api.query.*` complementing the `.key()` call, both returning a hex string
|
||||
- Council derives now takes bootstrapping (member, no elections) into account
|
||||
- Account derives now allow for an optional indices module (not required)
|
||||
- Adjust balances fees derivation with optional transfer and creation fees (removed in Substrate)
|
||||
- Adjust enum `.toJSON()` to return type name as specified
|
||||
|
||||
# 1.0.1
|
||||
|
||||
- **Breaking change** Drop support for Substrate v1 chain in all derives
|
||||
- Return unsub functions from provider .on emitters (Thanks to https://github.com/jak-pan)
|
||||
- `ApiPromise.isReady` now rejects on unrecoverable errors (Thanks to https://github.com/laec)
|
||||
- Add `polkadot-types-from-chain` & `polkadot-types-from-defs` TypeScript generators to `@polkadot/types`
|
||||
- Only decorate derives where relevant parent `api.query.*` is available
|
||||
- Support `.entries(arg?: any)` lookups on DoubleMaps (in addition to previously supported maps)
|
||||
- Allow v9 metadata to parse even in cases where it was wrongly deployed pre-v10
|
||||
- Allow type-aliases on a per-module basis (e.g. `Judgement` in identity as well as society)
|
||||
- Allow passing `{ signer }` to both `api.tx.*` and `api.sign` (in addition to `api.setSigner`)
|
||||
- Add derives for the society module
|
||||
- Don't map empty tuples, e.. `()` to `Null`, rather keep them empty
|
||||
- Add lookups to the metadata errors via `findMetaError`
|
||||
- Update metadata and types for the latest Substrate & Polkadot versions
|
||||
- Support metadata V11 as per latest Substrate
|
||||
- Remove support for un-deployed metadata
|
||||
- Remove old known types for Substrate V1
|
||||
|
||||
# 0.100.1
|
||||
|
||||
- **Important** This will the the last API version with Substrate 1.x support. Although you will still be able to use subsequent versions with older chans, dependent libraries such as sr25519 may not be compatible.
|
||||
- Add support for the Substrate identity module
|
||||
- Remove the `codec/Data` type, to remove a conflict with Substrate. This type is now named `Raw`
|
||||
- Fix for linked maps using `Option`
|
||||
- Add support for `BTreeSet` (Thanks to https://github.com/satellitex)
|
||||
- Add support for Metadata v10
|
||||
- Add support for latest Polkadot/Substrate types
|
||||
- Add `paymentInfo` to submittables to calculate fees
|
||||
|
||||
# 0.99.1
|
||||
|
||||
- **Breaking change** The `Data` and `U8a` type has been renamed and just replaced with the `Raw` type
|
||||
- **Breaking change** The `api.derive.staking.info` has been split into 2 - `staking.query` for non-balance related information (more effective) and `staking.account` that enhances query for all the information previously found `.info`
|
||||
- Cleanup `DoubleMap` hashing to always hash over the full value (in the case of `Vec<T>`, this includes the length)
|
||||
- Update democracy derives to take care of nextTally and lowestU*nbaked
|
||||
- Add additional derives for both council & treasury
|
||||
- Alignment with latest Polkadot/Substrate master branch types
|
||||
|
||||
# 0.98.1
|
||||
|
||||
- Make the TypeScript generation script mor re-usable (Thanks to https://github.com/xlc)
|
||||
- Add `.entries()` for all map-types, returning storage keys and values
|
||||
- Add `.signAsync` to submittable extrinsics (Thanks to https://github.com/c410-f3r)
|
||||
- Cleanup circular references between internal dependencies
|
||||
- Support for new Substrate democracy with preimages in derive
|
||||
- Alignment of types with Substrate/Polkadot master branches
|
||||
|
||||
# 0.97.1
|
||||
|
||||
- **Breaking change** Add the passing on an explicit `Registry` to all calls to `createType` as well as all codec classes. If you are upgrading form an older version, use the [migration guide](UPGRADING.md) to walk through the changes required.
|
||||
- **Breaking change** The metadata classes have been moved from `@polkadot/types` into `@polkadot/metadata`. If you explicitly create `Metadata` classes, you now would need to do so with the `import Metadata from '@polkadot/metadata';` This is a decorated class, where the previous metadata is now available on `Metadata.metadata`, alongside decorated `consts.*`', `tx.*` and `query.*`.
|
||||
- **Breaking change** Session `Keys` defaults to 4 keys now (Substrate master), depending on your node config, you would want to override with e.g. `Keys: 'SessionKeys3'` (1, 2, 3, 4, 5 & 6)
|
||||
- **Breaking change** `ValidatorPrefs` now default to the new percentage commission model, to use the previous `validatorPayment`, you can override with `ValidatorPrefs: 'ValidatorPrefsTo196'`
|
||||
- `api.derive.*` now has built-in memomization
|
||||
- Various fixes and cleanups to `api.derive.*` including era length progress and vesting calculations
|
||||
- Aligned all types with the latest Polkadot & Substrate, including Kusama CC3
|
||||
- Support for Metadata V9, which adjusts the hashing methods of storage entries
|
||||
- Support for Metadata V10 (still un-released), which includes prefixed map support
|
||||
|
||||
# 0.96.1
|
||||
|
||||
- Updated types for latest Kusama
|
||||
- Add `filterRecords` (in addition to `findRecord`) on submittable results
|
||||
- Various ABI v2 contract fixes
|
||||
- Update derive for elections (incl. RunnersUp) and heartbeat derives (with blocks & messages)
|
||||
- Add vesting totals & locked breakdowns to derive balances
|
||||
- Update council derives for the latest Substrate master support (with constants)
|
||||
- Derive cleanups, including sharing of instances between the API and internal to derives
|
||||
|
||||
# 0.95.2
|
||||
|
||||
- Temporary removal of `account_nextIndex` use, will be re-added in a future release
|
||||
|
||||
# 0.95.1
|
||||
|
||||
- Support Extrinsic V4 with additional signature indicator (Latest Polkadot/Substrate/Kusama)
|
||||
- Adjust subscription update checks to avoid duplicated data updates
|
||||
- Support Metadata V8 (exposes per-module `decl_error` definitions)
|
||||
- Support next generation contracts ABI (with additional type definitions)
|
||||
- Support for `BTreeMap<K, V>` types and definitions
|
||||
- All latest Polkadot & Substrate types (as per master branches)
|
||||
- **Breaking change** `Call.injectMethods` is moved to `Call.injectMetadata` to align with `Events` (This _should_ not be used externally, however mentioned as breaking here)
|
||||
|
||||
# 0.94.1
|
||||
|
||||
- Add handling of `Result<Ok, Error>` definitions
|
||||
- Adjust API cloning now takes RPC filters from source into account
|
||||
- Simplification of isPedantic checks and less overhead on StorageData types
|
||||
- Cleanups and fixes around RPC and derive type definitions
|
||||
- Fix `derive.imOnline.receivedHeatbeats` to query via indexes
|
||||
- Adjustment of `api.derive.elections.{approvalsOf|approvalsOfAt}` to allow ss58 address input
|
||||
- Cleanup `Enum` `.eq` handling to be more exhaustive
|
||||
- Add documentation for custom extrinsic formats (advanced chains)
|
||||
- Update to latest substrate master metadata
|
||||
|
||||
# 0.93.1
|
||||
|
||||
- Support for Kusama CC2
|
||||
- In extrinsic submission, use `rpc.account.nextIndex` to retrieve the nonce when available
|
||||
- For TypeScript users `api.query.*.*` is now properly typed for default Substrate calls, i.e. `api.query.balances.freeBalance(...)` will return a `Balance` type. Additionally the `api.queryMulti` and `.multi` on queries not allow generic type params.
|
||||
- Add `api.rpc.accounts.nextIndex`, `api.rpc.contracts.call` and `api.rpc.rpc.methods` calls. Optional calls (such as account/contracts) is decorated based on the results from `rpc.methods`, so they don't show up on nodes where they are not active.
|
||||
- Updated types to support the latest Polkadot/Substrate master changes
|
||||
- Support recursive type registration (self-referencing via `Box`) in addition to better sanitation of user-defined-types
|
||||
- Documentation and example updates (thanks mostly to contributions)
|
||||
|
||||
# 0.92.1
|
||||
|
||||
- The API now correctly sets the ss58 prefix as retrieved from the chain properties via `ss58Format`
|
||||
@@ -13,7 +132,7 @@
|
||||
- The `getRuntimeVersion` and `subscribeRuntimeVersion` RPCs are now only available on the `rpc.state.*` endpoints. This aligns with the Substrate implementation.
|
||||
- The `author_insertKey` RPC's last argument `publicKey` is now required, as to reflect Substrate implementation.
|
||||
- Support for extrinsics with versions that is not in the base Substrate implementation (V1-V3) can now be done by providing an implementation for `ExtrinsicUnknown`
|
||||
- Redeemed balance calculation if `api.derive` now returns the correct values again (bugfix)
|
||||
- Redeemed balance calculation if `api.derive` now returns the correct values again (bug fix)
|
||||
- added the `yarn chain:info [--ws URL]` utility to extract a calls-only metadata version
|
||||
- Missing types are now logged via a `console.warn`, not via `.error`
|
||||
- `Extrinsic`, `ExtrinsicPayload` & `SignerPayload` is registered in the type registry and can be overriden now
|
||||
@@ -29,7 +148,7 @@ If you are upgrading form an older version, use the CHANGELOG hand-in-hand with
|
||||
- **Breaking change** `Api.create(...)` and `new Api(...)` now only takes an options Object, so if you passed the provider directly previously, you need to swap the use to `Api.create({ provider: ... })`
|
||||
- **Breaking change** Runtime types have been extended and moved to definitions instead of classes
|
||||
- Primitive types for `i*` and `u*` (e.g. `u32`) are now only available in their lowercase versions. Additionally `Vector` is now only available as `Vec`, and `Method` has been renamed to `Call`, in both cases aligning with Rust.
|
||||
- `Moment` now implements as `u64` as per the Substrate codebase. (It it up to the user to interpret, for substrate 2.x it is not mili-second resolution)
|
||||
- `Moment` now implements as `u64` as per the Substrate codebase. (It it up to the user to interpret, for substrate 2.x it is not ms resolution)
|
||||
- For creation of types, it is recommended to use `createType(<TypeName>, <value>)` instead of e.g. `new Proposal(...)`. When passing these to methods/queries, construction should not be needed, the raw value can be passed.
|
||||
- For moved types, a previous import would have been from `@polkadot/types`, i.e. `import { SetIndex } from '@polkadot/types`, now just the interfaces (TypeScript) are available via `import { SetIndex } from '@polkadot/types/interfaces`
|
||||
- `usize` is now a blacklisted type that will throw on construction. Since it is platform-specific, it creates incompatibilities between native (generally `u64`) and WASM (always `u32`) code. Use one of the `u32` or `u64` types explicitly.
|
||||
@@ -113,7 +232,7 @@ If you are upgrading form an older version, use the CHANGELOG hand-in-hand with
|
||||
# 0.77.1
|
||||
|
||||
- Support Metadata v4, which introduces the use of a custom hasher to hash storage map keys.
|
||||
- Add TresuryProposal (not the same as democracy, type aliassed)
|
||||
- Add TreasuryProposal (not the same as democracy, type aliased)
|
||||
|
||||
|
||||
# 0.76.1
|
||||
@@ -135,7 +254,7 @@ If you are upgrading form an older version, use the CHANGELOG hand-in-hand with
|
||||
- For extrinsic status results, if you have checked the type returns, i.e. `result.type === 'Finalised'` now check on the status for `result.status.isFinalized` or `result.status.isBroadcast`, ... (the `type` property is now accessible only on `result.status.type`)
|
||||
- If using `subscribeFinalisedHeads` update this to `subscribeFinalizedHeads` (likewise `getFinalisedHead` should be updated to `getFinalizedHead` and `derive.bestNumberFinalized`)
|
||||
|
||||
- The underlying ss58 addess checksums have changed
|
||||
- The underlying ss58 address checksums have changed
|
||||
- The updated keyring with support for this has been made available
|
||||
- All examples have been updated with sr25519 addresses (with the new checksums)
|
||||
|
||||
@@ -153,12 +272,12 @@ If you are upgrading form an older version, use the CHANGELOG hand-in-hand with
|
||||
# 0.51.1
|
||||
|
||||
- Support metadata V2 as per latest substrate master
|
||||
- Update metadata with new types as per lastest substrate master
|
||||
- Update metadata with new types as per latest substrate master
|
||||
|
||||
|
||||
# 0.50.1
|
||||
|
||||
- Lastest util-crypto (usage of WASM with JS fallbacks if not available)
|
||||
- Latest util-crypto (usage of WASM with JS fallbacks if not available)
|
||||
- Update upstream @polkadot dependencies (for new crypto)
|
||||
|
||||
|
||||
@@ -181,7 +300,7 @@ If you are upgrading form an older version, use the CHANGELOG hand-in-hand with
|
||||
# 0.46.1
|
||||
|
||||
- Extended type registration to now handle internal types as well. Additionally the built-in Extrinsic type can now we overridden with a custom version.
|
||||
- Where `Extrinsic` and `Method` is used as types, considder importing `{ IMethod, IExtrinsic }` from `@polkadot/types/types`, especially in the cases where this is uased from a `SubmittableExtrinsic`
|
||||
- Where `Extrinsic` and `Method` is used as types, consider importing `{ IMethod, IExtrinsic }` from `@polkadot/types/types`, especially in the cases where this is used from a `SubmittableExtrinsic`
|
||||
- The `typeRegistry` constant is now `getTypeRegistry()` as a function
|
||||
|
||||
|
||||
@@ -204,7 +323,7 @@ console.log('llo', llo.unwrapOr('not set') /* Option<BlockNumber> */)
|
||||
|
||||
# 0.44.1
|
||||
|
||||
- Split primitives and types into seperate folders. This should not affect external use since the exports remain the same, however does have an impact where classes are referenced directly. e.g.
|
||||
- Split primitives and types into separate folders. This should not affect external use since the exports remain the same, however does have an impact where classes are referenced directly. e.g.
|
||||
|
||||
```js
|
||||
// old (affected)
|
||||
@@ -222,7 +341,7 @@ import { Method, Signature } from '@polkadot/types';
|
||||
|
||||
# 0.43.1
|
||||
|
||||
- Intrduces support for the new keyring with sr25519 support in addition to ed25519. While this does not change the exposed API, it is considerred breaking since @polkadot/keyring has interface changes. (Unless needed, don't rush the upgrade)
|
||||
- Introduces support for the new keyring with sr25519 support in addition to ed25519. While this does not change the exposed API, it is considered breaking since @polkadot/keyring has interface changes. (Unless needed, don't rush the upgrade)
|
||||
|
||||
|
||||
# 0.42.1
|
||||
@@ -233,7 +352,7 @@ import { Method, Signature } from '@polkadot/types';
|
||||
|
||||
# 0.41.1
|
||||
|
||||
- Support the V1 metadata specification from Substrate in addition to the currently testnet-active V0 version
|
||||
- Support the V1 metadata specification from Substrate in addition to the currently testnet active V0 version
|
||||
|
||||
|
||||
# 0.40.1
|
||||
@@ -253,7 +372,7 @@ Substrate has been updated with a breaking new transaction format where the Inde
|
||||
|
||||
# 0.37.1
|
||||
|
||||
api-observable has been removed. This was only used in /apps and inconsistent with the api/rx and api/promise APIs. Future work will include derivates like was included in api-observable into the base.
|
||||
api-observable has been removed. This was only used in /apps and inconsistent with the api/rx and api/promise APIs. Future work will include derives like was included in api-observable into the base.
|
||||
|
||||
Tuples now return single types when only one type is available, i.e. `(AccountId)` would now resolve as `AccountId`. The extra type wrapper adds no benefit to users here.
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ 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/METHODS_RPC.html) exposed by a Polkadot network client
|
||||
- [@polkadot/rpc-core](packages/rpc-core/) Wrapper around all [JSON-RPC methods](https://polkadot.js.org/api/substrate/rpc.html) exposed by a Polkadot network client
|
||||
- [@polkadot/rpc-provider](packages/rpc-provider/) Providers for connecting to nodes, including WebSockets and Http
|
||||
|
||||
Type definitions for interfaces as exposed by Polkadot & Substrate clients -
|
||||
|
||||
+90
-6
@@ -2,7 +2,91 @@
|
||||
|
||||
This is an upgrade guide for users of the API. It does not attempt to detail each version (the [CHANGELOG](CHANGELOG.md) has all the changes between versions), but rather tries to explain the rationale behind major breaking changes and how users of the API should handle this.
|
||||
|
||||
While we try to keep the user-facing interfaces as stable as possible, sometimes you just need to make additions to move forward and improve things down the road, as painful as they may be. Like you, we are also users of the API, and eat our own dogfood - and as such, feel any pains introduced first.
|
||||
While we try to keep the user-facing interfaces as stable as possible, sometimes you just need to make additions to move forward and improve things down the road, as painful as they may be. Like you, we are also users of the API, and eat our own dog food - and as such, feel any pains introduced first.
|
||||
|
||||
|
||||
## 0.97.1 (and newer)
|
||||
|
||||
The 0.97 series lays the groundwork to allow type registration to be ties to a specific chain and a specific Api instance. In the past, 2 Api instances in the same process would share types, which mean that you could not connect to 2 independent chains with different types. This is very problematic for Polkadot chains, where the idea is to connect to multiple chains.
|
||||
|
||||
When using the Api, a new `Registry` will be created on using `new Api(...)` or `Api.create(...)` and this will be transparently passed when creating types. In the cases where you create type instances explicitly or create type classes for injection, you would need to make adjustments.
|
||||
|
||||
### Type classes
|
||||
|
||||
In a number of instances, developers are creating classes and making these available for interacting with their chains. For instance, an example of a custom type could be -
|
||||
|
||||
```js
|
||||
import { Struct, Text, u32 } from '@polkadot/types';
|
||||
|
||||
export class Preferences extends Struct {
|
||||
constructor (value?: ahy) {
|
||||
super({
|
||||
name: Text,
|
||||
id: u32
|
||||
}, value);
|
||||
}
|
||||
|
||||
...
|
||||
}
|
||||
```
|
||||
|
||||
In the current iteration, the underlying `@polkadot/types` bases structures now require a `Registry` to be passed as the first parameter. This means that the above signature would be adjusted to -
|
||||
|
||||
```js
|
||||
// the next import is only required for TypeScript
|
||||
import { Registry } from '@polkadot/types/types';
|
||||
import { Struct, Text, u32 } from '@polkadot/types';
|
||||
|
||||
export class Preferences extends Struct {
|
||||
constructor (registry: Registry, value?: ahy) {
|
||||
super(registry, {
|
||||
name: Text,
|
||||
id: u32
|
||||
}, value);
|
||||
}
|
||||
|
||||
...
|
||||
}
|
||||
```
|
||||
|
||||
Where the type is used or returned from the API, the `Registry` will be automatically passed to class creation.
|
||||
|
||||
### createType
|
||||
|
||||
Previously, when creating a type instance such as `BlockNumber`, you would do `api.createType('BlockNumber', <initValue>)`, this is unchanged. In the cases where you directly import from `@polkadot/types`, the following pattern is required -
|
||||
|
||||
```js
|
||||
import { createType } from '@polkadot/types';
|
||||
|
||||
...
|
||||
const blockNumber = createType(api.registry, 'BlockNumber', 12345);
|
||||
```
|
||||
|
||||
In some cases, you would want to explicitly pass a `Registry` interface to the API, instead of relying on it explicitly. This is generally applicable in the cases where you want to use the `createType` independently from the API -
|
||||
|
||||
```js
|
||||
import { ApiPromise } from '@polkadot/api';
|
||||
import { TypeRegistry, createType } from '@polkadot/types';
|
||||
|
||||
...
|
||||
const registry = new TypeRegistry();
|
||||
const blockNumber = createType(registry, 'BlockNumber', 12345);
|
||||
const api = await ApiPromise.create({ registry });
|
||||
```
|
||||
|
||||
### Extrinsic metadata
|
||||
|
||||
In some applications, the undocumented `findFunction` has been used to determine the Api has the metadata for a specific extrinsic. The has been exposed on top of `GenericCall`, and it typically used in applications such as signers. Along with the compulsory registry, the above functions have been moved to the `Registry` itself, so if you previously had -
|
||||
|
||||
```js
|
||||
const { meta, method, section } = GenericCall.findFunction(extrinsic.callIndex);
|
||||
```
|
||||
|
||||
You need to change it to -
|
||||
|
||||
```js
|
||||
const { meta, method, section } = registry.findMetaCall(extrinsic.callIndex);
|
||||
```
|
||||
|
||||
## 0.90.1 (and newer), from 0.81.1 (and older)
|
||||
|
||||
@@ -29,10 +113,10 @@ To better align with the actual types from the metadata, and avoid (too much) co
|
||||
|
||||
The [@polkadot/api](packages/api) has always handled the conversion of types for parameters when making calls or queries. For example, when making a transfer to `BOB` (address), any of the following is valid -
|
||||
|
||||
- `api.tx.balances.transfer(BOB, 12345)` - value specied as a number
|
||||
- `api.tx.balances.transfer(BOB, '12345')` - value specied as a string
|
||||
- `api.tx.balances.transfer(BOB, '0x3039')` - value specied as a hex
|
||||
- `api.tx.balances.transfer(BOB, new BN(12345))` - value specied as a [BN](https://github.com/indutny/bn.js/)
|
||||
- `api.tx.balances.transfer(BOB, 12345)` - value specified as a number
|
||||
- `api.tx.balances.transfer(BOB, '12345')` - value specified as a string
|
||||
- `api.tx.balances.transfer(BOB, '0x3039')` - value specified as a hex
|
||||
- `api.tx.balances.transfer(BOB, new BN(12345))` - value specified as a [BN](https://github.com/indutny/bn.js/)
|
||||
|
||||
Internally the API will take the input and convert the value into a `Balance`, serialize it using the SCALE codec and transfer it to the node. In some cases users would construct the `Balance` type manually, by importing the class and calling `new` on it. This last approach has now been removed, and where classes are still available (limited reach), discouraged.
|
||||
|
||||
@@ -108,7 +192,7 @@ export class MyStruct extends Struct {
|
||||
}
|
||||
```
|
||||
|
||||
Internally the [@polkadot/types](packages/types) package now only defines classes where there are specific encoding logic applied. For all other types, the definitions are done via a JSON-like format and then the TypeScript definitions are generated from these. (In a world where nodes inject types and the type definitions are not needed, this functionality will be useful to allow TS devs to auto-generate type definitions based on what the node defines.)
|
||||
Internally the [@polkadot/types](packages/types) package now only defines classes where there are specific encoding logic applied. For all other types, the definitions are done via a JSON-like format and then the TypeScript definitions are generated from these. (In a world where nodes inject types and the type definitions are not needed, this functionality will be useful to allow TS developers to auto-generate type definitions based on what the node defines.)
|
||||
|
||||
### Signing transactions (Signer interface)
|
||||
|
||||
|
||||
+1
-1
@@ -15,7 +15,7 @@ yarn polkadot-dev-build-ts
|
||||
copy_folder "api" "api"
|
||||
copy_folder "api-contract" "api-contract"
|
||||
copy_folder "api-derive" "api-derive"
|
||||
copy_folder "api-metadata" "api-metadata"
|
||||
copy_folder "metadata" "metadata"
|
||||
copy_folder "rpc-core" "rpc-core"
|
||||
copy_folder "rpc-provider" "rpc-provider"
|
||||
copy_folder "type-jsonrpc" "jsonrpc"
|
||||
|
||||
@@ -43,7 +43,9 @@ module.exports = {
|
||||
['start/api.tx.wrap.md', 'Complex transactions'],
|
||||
['start/types.basics.md', 'Type basics'],
|
||||
['start/types.extend.md', 'Extending types'],
|
||||
['start/extrinsic.extend.md', 'Extending extrinsics'],
|
||||
['start/typescript.md', 'TypeScript interfaces'],
|
||||
['start/typescript.user.md', 'TypeScript user generated'],
|
||||
['start/FAQ.md', 'FAQ']
|
||||
]
|
||||
},
|
||||
|
||||
+2
-1
@@ -17,6 +17,7 @@
|
||||
- [Type basics](start/types.basics.md)
|
||||
- [Type extension](start/types.extend.md)
|
||||
- [TypeScript interfaces](start/typescript.md)
|
||||
- [TypeScript user generated](start/typescript.user.md)
|
||||
|
||||
## Packages
|
||||
|
||||
@@ -46,7 +47,7 @@
|
||||
- [Unsubscribe from listening](examples/promise/04_unsubscribe/README.md)
|
||||
- [Read chain state](examples/promise/05_read_storage/README.md)
|
||||
- [Make a transfer](examples/promise/06_make_transfer/README.md)
|
||||
- [Display system events](examples/promise/08_system_events/README.md)(
|
||||
- [Display system events](examples/promise/08_system_events/README.md)
|
||||
- [Transaction with events](examples/promise/09_transfer_events/README.md)
|
||||
- [Upgrade via sudo](examples/promise/10_upgrade_chain/README.md)
|
||||
- [ApiRx](examples/rx/README.md)
|
||||
|
||||
@@ -10,7 +10,7 @@ async function main () {
|
||||
// the API has connected to the node and completed the initialisation process
|
||||
const api = await ApiPromise.create();
|
||||
|
||||
// we only display a couple, then unsubscribe
|
||||
// We only display a couple, then unsubscribe
|
||||
let count = 0;
|
||||
|
||||
// Subscribe to the new headers on-chain. The callback is fired when new headers
|
||||
|
||||
@@ -8,8 +8,8 @@ async function main () {
|
||||
// Create a new instance of the api
|
||||
const api = await ApiPromise.create();
|
||||
|
||||
// Subscribe to chain updates and log the current block number on update.
|
||||
const unsubscribe = await api.rpc.chain.subscribeNewHead((header) => {
|
||||
// Subscribe to chain updates and log the current block number on update.
|
||||
const unsubscribe = await api.rpc.chain.subscribeNewHeads((header) => {
|
||||
console.log(`Chain is at block: #${header.number}`);
|
||||
});
|
||||
|
||||
|
||||
@@ -2,4 +2,4 @@
|
||||
|
||||
In addition to querying the latest storage, you can make storage queries at a specific blockhash. Be aware that the node applies a pruning strategy and typically only keeps the last 256 blocks, unless run in archive mode.
|
||||
|
||||
<<< @/docs/examples/promise/07_read_storage_at/index.js
|
||||
<<< @/docs/examples/promise/05_read_storage_at/index.js
|
||||
|
||||
@@ -12,18 +12,18 @@ async function main () {
|
||||
// Create our API with a default connection to the local node
|
||||
const api = await ApiPromise.create();
|
||||
|
||||
// retrieve the last block header, extracting the hash and parentHash
|
||||
// Retrieve the last block header, extracting the hash and parentHash
|
||||
const { hash, parentHash } = await api.rpc.chain.getHeader();
|
||||
|
||||
console.log(`last header hash ${hash.toHex()}`);
|
||||
|
||||
// retrieve the balance at the preceding block for Alice. For at queries
|
||||
// Retrieve the balance at the preceding block for Alice. For at queries
|
||||
// the format is always `.at(<blockhash>, ...params)`
|
||||
const balance = await api.query.balances.freeBalance.at(parentHash, ALICE);
|
||||
|
||||
console.log(`Alice's balance at ${parentHash.toHex()} was ${balance}`);
|
||||
|
||||
// now perform a multi query, returning multiple balances at once
|
||||
// Now perform a multi query, returning multiple balances at once
|
||||
const balances = await api.query.balances.freeBalance.multi([ALICE, BOB]);
|
||||
|
||||
console.log(`Current balances for Alice and Bob are ${balances[0]} and ${balances[1]}`);
|
||||
|
||||
@@ -14,7 +14,7 @@ async function main () {
|
||||
// Constuct the keying after the API (crypto has an async init)
|
||||
const keyring = new Keyring({ type: 'sr25519' });
|
||||
|
||||
// Add alice to our keyring with a hard-deived path (empty phrase, so uses dev)
|
||||
// Add Alice to our keyring with a hard-deived path (empty phrase, so uses dev)
|
||||
const alice = keyring.addFromUri('//Alice');
|
||||
|
||||
// Create a extrinsic, transferring 12345 units to Bob
|
||||
|
||||
@@ -15,16 +15,16 @@ async function main () {
|
||||
// Constuct the keying after the API (crypto has an async init)
|
||||
const keyring = new Keyring({ type: 'sr25519' });
|
||||
|
||||
// Add alice to our keyring with a hard-derived path (empty phrase, so uses dev)
|
||||
// Add Alice to our keyring with a hard-derived path (empty phrase, so uses dev)
|
||||
const alice = keyring.addFromUri('//Alice');
|
||||
|
||||
// Get nonce for account
|
||||
const nonce = await api.query.system.accountNonce(alice.address);
|
||||
|
||||
// get current block
|
||||
// Get current block
|
||||
const signedBlock = await api.rpc.chain.getBlock();
|
||||
|
||||
// get current block height and hash
|
||||
// Get current block height and hash
|
||||
const currentHeight = signedBlock.block.header.number;
|
||||
const blockHash = signedBlock.block.header.hash;
|
||||
|
||||
|
||||
+1
-2
@@ -10,8 +10,7 @@
|
||||
"start": "node index.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@polkadot/api": "0.80.1",
|
||||
"@polkadot/keyring": "^0.93.1"
|
||||
"@polkadot/api": "*"
|
||||
},
|
||||
"devDependencies": {
|
||||
"rimraf": "^2.6.2"
|
||||
|
||||
@@ -8,21 +8,21 @@ async function main () {
|
||||
// Create our API with a default connection to the local node
|
||||
const api = await ApiPromise.create();
|
||||
|
||||
// subscribe to system events via storage
|
||||
// Subscribe to system events via storage
|
||||
api.query.system.events((events) => {
|
||||
console.log(`\nReceived ${events.length} events:`);
|
||||
|
||||
// loop through the Vec<EventRecord>
|
||||
// Loop through the Vec<EventRecord>
|
||||
events.forEach((record) => {
|
||||
// extract the phase, event and the event types
|
||||
// Extract the phase, event and the event types
|
||||
const { event, phase } = record;
|
||||
const types = event.typeDef;
|
||||
|
||||
// show what we are busy with
|
||||
// Show what we are busy with
|
||||
console.log(`\t${event.section}:${event.method}:: (phase=${phase.toString()})`);
|
||||
console.log(`\t\t${event.meta.documentation.toString()}`);
|
||||
|
||||
// loop through each of the parameters, displaying the type and data
|
||||
// Loop through each of the parameters, displaying the type and data
|
||||
event.data.forEach((data, index) => {
|
||||
console.log(`\t\t\t${types[index].type}: ${data.toString()}`);
|
||||
});
|
||||
|
||||
@@ -4,13 +4,13 @@
|
||||
// Import the API & Provider and some utility functions
|
||||
const { ApiPromise } = require('@polkadot/api');
|
||||
|
||||
// import the test keyring (already has dev keys for Alice, Bob, Charlie, Eve & Ferdie)
|
||||
// Import the test keyring (already has dev keys for Alice, Bob, Charlie, Eve & Ferdie)
|
||||
const testKeyring = require('@polkadot/keyring/testing');
|
||||
|
||||
// utility function for random values
|
||||
// Utility function for random values
|
||||
const { randomAsU8a } = require('@polkadot/util-crypto');
|
||||
|
||||
// some constants we are using in this sample
|
||||
// Some constants we are using in this sample
|
||||
const ALICE = '5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY';
|
||||
const AMOUNT = 10000;
|
||||
|
||||
@@ -18,18 +18,18 @@ async function main () {
|
||||
// Create the API and wait until ready
|
||||
const api = await ApiPromise.create();
|
||||
|
||||
// create an instance of our testing keyring
|
||||
// Create an instance of our testing keyring
|
||||
// If you're using ES6 module imports instead of require, just change this line to:
|
||||
// const keyring = testKeyring();
|
||||
const keyring = testKeyring.default();
|
||||
|
||||
// get the nonce for the admin key
|
||||
// Get the nonce for the admin key
|
||||
const nonce = await api.query.system.accountNonce(ALICE);
|
||||
|
||||
// find the actual keypair in the keyring
|
||||
// Find the actual keypair in the keyring
|
||||
const alicePair = keyring.getPair(ALICE);
|
||||
|
||||
// create a new random recipient
|
||||
// Create a new random recipient
|
||||
const recipient = keyring.addFromSeed(randomAsU8a(32)).address;
|
||||
|
||||
console.log('Sending', AMOUNT, 'from', alicePair.address, 'to', recipient, 'with nonce', nonce.toString());
|
||||
|
||||
@@ -16,22 +16,24 @@ async function main () {
|
||||
// Create the API and wait until ready (optional provider passed through)
|
||||
const api = await ApiPromise.create({ provider });
|
||||
|
||||
// retrieve the upgrade key from the chain state
|
||||
// Retrieve the upgrade key from the chain state
|
||||
const adminId = await api.query.sudo.key();
|
||||
|
||||
// find the actual keypair in the keyring (if this is an changed value, the key
|
||||
// Find the actual keypair in the keyring (if this is a changed value, the key
|
||||
// needs to be added to the keyring before - this assumes we have defaults, i.e.
|
||||
// Alice as the key - and this already exists on the test keyring)
|
||||
const keyring = testKeyring.default();
|
||||
const adminPair = keyring.getPair(adminId.toString());
|
||||
|
||||
// retrieve the runtime to upgrade to
|
||||
// Retrieve the runtime to upgrade
|
||||
const code = fs.readFileSync('./test.wasm').toString('hex');
|
||||
const proposal = api.tx.consensus.setCode(`0x${code}`);
|
||||
const proposal = api.tx.system && api.tx.system.setCode
|
||||
? api.tx.system.setCode(`0x${code}`) // For newer versions of Substrate
|
||||
: api.tx.consensus.setCode(`0x${code}`); // For previous versions
|
||||
|
||||
console.log(`Upgrading from ${adminId}, ${code.length / 2} bytes`);
|
||||
|
||||
// preform the actual chain upgrade via the sudo module
|
||||
// Perform the actual chain upgrade via the sudo module
|
||||
api.tx.sudo
|
||||
.sudo(proposal)
|
||||
.signAndSend(adminPair, ({ events = [], status }) => {
|
||||
|
||||
@@ -12,7 +12,7 @@ async function main () {
|
||||
new ApiRx().isReady
|
||||
.pipe(
|
||||
switchMap((api) =>
|
||||
api.rpc.chain.subscribeNewHead()
|
||||
api.rpc.chain.subscribeNewHeads()
|
||||
))
|
||||
.subscribe((header) => {
|
||||
console.log(`Chain is at block: #${header.number}`);
|
||||
|
||||
@@ -2,4 +2,4 @@
|
||||
|
||||
This example shows how to instantiate a Polkadot API object and use it to connect to a node and retrieve balance updates.
|
||||
|
||||
<<< @/docs/examples/rx/03_listent_to_balance_change/index.js
|
||||
<<< @/docs/examples/rx/03_listen_to_balance_change/index.js
|
||||
|
||||
@@ -7,11 +7,11 @@ const { switchMap } = require('rxjs/operators');
|
||||
|
||||
async function main () {
|
||||
// Create a new instance of the api
|
||||
// Subscribe to chain updates and log the current block number on update.
|
||||
// Subscribe to chain updates and log the current block number on update.
|
||||
const subscription = new ApiRx().isReady
|
||||
.pipe(
|
||||
switchMap((api) =>
|
||||
api.rpc.chain.subscribeNewHead()
|
||||
api.rpc.chain.subscribeNewHeads()
|
||||
))
|
||||
.subscribe((header) => {
|
||||
console.log(`Chain is at block: #${header.number}`);
|
||||
|
||||
@@ -12,13 +12,13 @@ async function main () {
|
||||
const api = await ApiRx.create().toPromise();
|
||||
|
||||
// Create an instance of the keyring
|
||||
const keyring = new Keyring({ type: 's25519' });
|
||||
const keyring = new Keyring({ type: 'sr25519' });
|
||||
|
||||
// Add Alice to our keyring (with the known seed for the account)
|
||||
const alice = keyring.addFomUri('//Alice');
|
||||
const alice = keyring.addFromUri('//Alice');
|
||||
|
||||
// Create a extrinsic, transferring 12345 units to Bob.
|
||||
api.tx.balances
|
||||
// Create a extrinsic, transferring 12345 units to Bob.
|
||||
const subscription = api.tx.balances
|
||||
// create transfer
|
||||
.transfer(BOB, 12345)
|
||||
// Sign and send the transcation
|
||||
@@ -27,10 +27,11 @@ async function main () {
|
||||
.subscribe(({ status }) => {
|
||||
if (status.isFinalized) {
|
||||
console.log(`Successful transfer of 12345 from Alice to Bob with hash ${status.asFinalized.toHex()}`);
|
||||
subscription.unsubscribe();
|
||||
} else {
|
||||
console.log(`Staus of transfer: ${status.type}`);
|
||||
console.log(`Status of transfer: ${status.type}`);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
main().catch(console.error).finally(() => process.exit());
|
||||
main().catch(console.error);
|
||||
|
||||
@@ -4,13 +4,13 @@
|
||||
// Import the API and some utility functions
|
||||
const { ApiRx } = require('@polkadot/api');
|
||||
|
||||
// import the test keyring (already has dev keys for Alice, Bob, Charlie, Eve & Ferdie)
|
||||
// Import the test keyring (already has dev keys for Alice, Bob, Charlie, Eve & Ferdie)
|
||||
const testKeyring = require('@polkadot/keyring/testing');
|
||||
|
||||
// utility function for random values
|
||||
// Utility function for random values
|
||||
const { randomAsU8a } = require('@polkadot/util-crypto');
|
||||
|
||||
// some constants we are using in this sample
|
||||
// Some constants we are using in this sample
|
||||
const ALICE = '5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY';
|
||||
const AMOUNT = 10000;
|
||||
|
||||
@@ -18,21 +18,21 @@ async function main () {
|
||||
// Create our API with a connection to the node
|
||||
const api = await ApiRx.create().toPromise();
|
||||
|
||||
// create an instance of our testign keyring
|
||||
// Create an instance of our testign keyring
|
||||
// If you're using ES6 module imports instead of require, just change this line to:
|
||||
// const keyring = testKeyring();
|
||||
const keyring = testKeyring.default();
|
||||
|
||||
// find the actual keypair in the keyring
|
||||
// Find the actual keypair in the keyring
|
||||
const alicePair = keyring.getPair(ALICE);
|
||||
|
||||
// create a new random recipient
|
||||
// Create a new random recipient
|
||||
const recipient = keyring.addFromSeed(randomAsU8a(32)).address;
|
||||
|
||||
console.log('Sending', AMOUNT, 'from', alicePair.address, 'to', recipient);
|
||||
|
||||
// get the nonce for the admin key
|
||||
// Create a extrinsic, transferring 12345 units to Bob.
|
||||
// Get the nonce for the admin key
|
||||
// Create a extrinsic, transferring 12345 units to Bob.
|
||||
api.tx.balances
|
||||
// Do the transfer
|
||||
.transfer(recipient, AMOUNT)
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
/* eslint-disable @typescript-eslint/no-var-requires */
|
||||
// Import the API & Provider and some utility functions
|
||||
const { ApiRx, WsProvider } = require('@polkadot/api');
|
||||
// import the test keyring (already has dev keys for Alice, Bob, Charlie, Eve & Ferdie)
|
||||
// Import the test keyring (already has dev keys for Alice, Bob, Charlie, Eve & Ferdie)
|
||||
const testKeyring = require('@polkadot/keyring/testing');
|
||||
const fs = require('fs');
|
||||
|
||||
@@ -14,27 +14,28 @@ async function main () {
|
||||
// Create the API and wait until ready (optional provider passed through)
|
||||
const api = await ApiRx.create({ provider }).toPromise();
|
||||
|
||||
// retrieve the upgrade key from the chain state
|
||||
// Retrieve the upgrade key from the chain state
|
||||
// TODO It seems like this promise doesn't resolve
|
||||
const adminId = await api.query.sudo.key().toPromise();
|
||||
|
||||
// find the actual keypair in the keyring (if this is an changed value, the key
|
||||
// Find the actual keypair in the keyring (if this is an changed value, the key
|
||||
// needs to be added to the keyring before - this assumes we have defaults, i.e.
|
||||
// Alice as the key - and this already exists on the test keyring)
|
||||
const keyring = testKeyring.default();
|
||||
const adminPair = keyring.getPair(adminId.toString());
|
||||
|
||||
// retrieve the runtime to upgrade to
|
||||
// Retrieve the runtime to upgrade to
|
||||
const code = fs.readFileSync('./test.wasm').toString('hex');
|
||||
const proposal = api.tx.consensus.setCode(`0x${code}`);
|
||||
|
||||
console.log(`Upgrading chain runtime from ${adminId}`);
|
||||
|
||||
api.tx.sudo
|
||||
// preform the actual chain upgrade via the sudo module
|
||||
// Perform the actual chain upgrade via the sudo module
|
||||
.sudo(proposal)
|
||||
// sign and send the proposal
|
||||
// Sign and send the proposal
|
||||
.signAndSend(adminPair)
|
||||
// subscribe to overall result
|
||||
// Subscribe to overall result
|
||||
.subscribe(({ events = [], status }) => {
|
||||
// Log transfer events
|
||||
console.log('Proposal status:', status.type);
|
||||
|
||||
+17
-1
@@ -4,7 +4,7 @@ The list will be updated/expanded as questions come up, dealing with some common
|
||||
|
||||
## I am getting a "Unknown types found, no types for ..." error
|
||||
|
||||
There are 2 caused for this, both related to the version of the API that you are using and the support of types. As explained in the elsewhere, types on Polkadot/Substrate are continuously evolving - the latest version of the API always tries to support types for the latest Polkadot networks, such as [Kusama](https://kusama.network/). So for Polkadot public chains, ensure that you are using the latest released API version.
|
||||
There are 2 causes for this, both related to the version of the API that you are using and the support of types. As explained in the elsewhere, types on Polkadot/Substrate are continuously evolving - the latest version of the API always tries to support types for the latest Polkadot networks, such as [Kusama](https://kusama.network/). So for Polkadot public chains, ensure that you are using the latest released API version.
|
||||
|
||||
If however you are running against a master branch of either Polkadot or Substrate, you may well be better suited running [a beta version, tracking master](install.md#betas). If you are connected to a customized chain, you would rather want to [register the types](types.extend.md) either on your own, or via packages that the chain vendor provides.
|
||||
|
||||
@@ -17,3 +17,19 @@ Update your version of the API to the [latest version](install.md). Like types,
|
||||
The API itself is independent on where the signature comes from and how it is injected. Additionally it implements a signer interface, that can be used for external signing - an example of this is the [polkadot-js/apps](https://github.com/polkadot-js/apps) support for signing via extensions and even the [polkadot-js/extension](https://github.com/polkadot-js/extension) support for tools such as the [Parity Signer](https://github.com/paritytech/parity-signer).
|
||||
|
||||
As of this writing we don't have an explicit example of implementing the signer interface in these docs, although we do use one in [our tests](https://github.com/polkadot-js/api/blob/master/packages/api/test/util/SingleAccountSigner.ts). Additionally, the [polkadot-js/tools](https://github.com/polkadot-js/tools) has an implementation of [a very basic offline signer](https://github.com/polkadot-js/tools/tree/master/packages/signer-cli) where transactions are generated in one process and signatures in another non-connected process.
|
||||
|
||||
## I would like to send a root transaction
|
||||
|
||||
Some calls in Polkadot/Substrate can only be submitted as root, these are indicated by `ensure_root(origin)` in the Rust codebase. Root here does not refer to the actual account, i.e. `//Alice` on a `--dev` chain, but rather that it cannot be submitted as a bare user transaction. This restriction applies to chain upgrades, changing balances or anything that modifies the state and/or chain operation.
|
||||
|
||||
To submit these transactions, it needs to be send as a [wrapped transaction](api.tx.wrap.md#sudo-use) via either `sudo.sudo` (assuming you have access on your chain) or `democracy.proposal` (which would allow users of the chain to vote on it).
|
||||
|
||||
## How do I call a function with a Tuple input
|
||||
|
||||
Tuples, as defined in the Polkadot/Substrate types appear as `(TypeA, TypeB)`. For instance we may have an `(AccountId, u64)` input as defined in the metadata or as part of the user types. To specify a Tuple as an input, wrap it is an array format, for instance to call `query.module.get((u32, u64))` where a `(u32, u64)` Tuple input is expected, you would do `query.module.get([123, 456])`
|
||||
|
||||
## How long do transactions live
|
||||
|
||||
Polkadot/Substrate supports both immortal and mortal transactions. For immortal, this means that the transaction has an infinite lifetime, for mortals, the transactions expire after a defined period. By default the API sends mortal transactions when no explicit extrinsic era has been specified. This means that all transaction has a limited lifetime and will expire if not included in the period set.
|
||||
|
||||
The length for this transaction validity is set to 50 blocks, which translates to 5 minutes assuming a default of 6 second blocktimes. (10 blocks per minute in this default configuration).
|
||||
|
||||
@@ -4,7 +4,7 @@ These sections should provide you with all the information needed to install the
|
||||
|
||||
## What this is not
|
||||
|
||||
This is not line-by-line documentation of all the extising function calls available, nor it is tied to a specific chain. (Although the examples do refer to the base Polkadot & Substrate chains). There will be some things in the API that are probably not covered, which brings us to the next point...
|
||||
This is not line-by-line documentation of all the existing function calls available, nor it is tied to a specific chain. (Although the examples do refer to the base Polkadot & Substrate chains). There will be some things in the API that are probably not covered, which brings us to the next point...
|
||||
|
||||
## Help us help others
|
||||
|
||||
|
||||
@@ -5,16 +5,16 @@ Constant queries will introduce you to the concepts behind the types and the int
|
||||
For some background: constants are values that are defined in the runtime and used as part of chain operations. These constants can be changed as part of an upgrade.
|
||||
|
||||
```js
|
||||
// initialize the API as per previous sections
|
||||
// Initialize the API as per previous sections
|
||||
...
|
||||
|
||||
// the length of an epoch (session) in Babe
|
||||
// The length of an epoch (session) in Babe
|
||||
console.log(api.consts.babe.epochDuration.toNumber());
|
||||
|
||||
// the amount required to create a new account
|
||||
// The amount required to create a new account
|
||||
console.log(api.consts.balances.creationFee.toNumber());
|
||||
|
||||
// the amount required per byte on an extrinsic
|
||||
// The amount required per byte on an extrinsic
|
||||
console.log(api.consts.balances.transactionByteFee.toNumber());
|
||||
```
|
||||
|
||||
|
||||
@@ -7,20 +7,20 @@ In previous sections, we initialized the API and retrieved runtime constants. Th
|
||||
Let's dive right in, connect to a general chain and retrieve some information on the current state. Of interest may be retrieving the nonce of a particular account as well as the current balance, this can be achieved via -
|
||||
|
||||
```js
|
||||
// initialize the API as in previous sections
|
||||
// Initialize the API as in previous sections
|
||||
...
|
||||
|
||||
// the actual address that we will use
|
||||
// The actual address that we will use
|
||||
const ADDR = '5DTestUPts3kjeXSTMyerHihn1uwMfLj8vU8sqF7qYrFabHE';
|
||||
|
||||
// retrieve the last timestamp
|
||||
// Retrieve the last timestamp
|
||||
const now = await api.query.timestamp.now();
|
||||
|
||||
// retrieve the account nonce via the system module
|
||||
// Retrieve the account nonce via the system module
|
||||
const nonce = await api.query.system.accountNonce(ADDR);
|
||||
|
||||
// retrieve the account balance via the balances module
|
||||
const balance = await api.query.balance.freeBalance(ADDR);
|
||||
// Retrieve the account balance via the balances module
|
||||
const balance = await api.query.balances.freeBalance(ADDR);
|
||||
|
||||
console.log(`${now}: balance of ${balance} and a nonce of ${nonce}`);
|
||||
```
|
||||
@@ -29,11 +29,11 @@ There have been some additions in the code above comparing with retrieving runti
|
||||
|
||||
```js
|
||||
...
|
||||
// retrieve last block timestamp, account nonce & balance
|
||||
// Retrieve last block timestamp, account nonce & balance
|
||||
const [now, nonce, balance] = await Promise.all([
|
||||
api.query.timestamp.now(),
|
||||
api.query.system.accountNonce(ADDR),
|
||||
api.query.balance.freeBalance(ADDR)
|
||||
api.query.balances.freeBalance(ADDR)
|
||||
]);
|
||||
```
|
||||
|
||||
@@ -41,7 +41,7 @@ const [now, nonce, balance] = await Promise.all([
|
||||
|
||||
As indicated in previous sections, any return value is always an object with a consistent interface that reflects the type being returned. In the above example, the timestamp is a `Moment` (a `u64` value), the nonce is an `Index` (a `u32` value) and the `Balance` is an underlying `u128`.
|
||||
|
||||
Additionally we have provided some parameters for the query calls, specifically for the retrieval of the nonce and balance. It is important to note that the API will automatically convert any parameters into the correct type for encoding and making calls, in this case the `AccountId` parameter could be specified as a ss58 address (as it was), an actual `AccountId` (retrieved via another call) or just a plain `Uint8Array` (or even hex-string representation) for a publicKey.
|
||||
Additionally we have provided some parameters for the query calls, specifically for the retrieval of the nonce and balance. It is important to note that the API will automatically convert any parameters into the correct type for encoding and making calls, in this case the `AccountId` parameter could be specified as a ss58 address (as it was), an actual `AccountId` (retrieved via another call) or just a plain `Uint8Array` (or even hex-string representation) for a publicKey.
|
||||
|
||||
## Exploring RPCs
|
||||
|
||||
|
||||
@@ -4,12 +4,12 @@ In a number of applications, it is useful to monitor a number of like-queries at
|
||||
|
||||
## Multi queries, same type
|
||||
|
||||
Where possible, the use of multi queries are encouraged since it tracks a number of state entries over a single RPC call, instead of making a call for each single item. In addition it allows you to have a single callback to track changes. For queries of the same type we can use `.multi`, for example to retrieve the balances of a number of accounts at once -
|
||||
Where possible, the use of multi queries are encouraged since it tracks a number of state entries over a single RPC call, instead of making a call for each single item. In addition it allows you to have a single callback to track changes. For queries of the same type we can use `.multi`, for example to retrieve the balances of a number of accounts at once -
|
||||
|
||||
```js
|
||||
...
|
||||
|
||||
// subscribe to balance changes for 2 accounts, ADDR1 & ADDR2 (already defined)
|
||||
// Subscribe to balance changes for 2 accounts, ADDR1 & ADDR2 (already defined)
|
||||
const unsub = await api.query.balances.freeBalance.multi([ADDR1, ADDR2], (balances) => {
|
||||
const [balance1, balance2] = balances;
|
||||
|
||||
@@ -22,10 +22,10 @@ A couple of items to note in the example above: we don't call `freeBalance` dire
|
||||
```js
|
||||
...
|
||||
|
||||
// retrieve a snapshot of the validators
|
||||
// Retrieve a snapshot of the validators
|
||||
const validators = await api.query.session.validators();
|
||||
|
||||
// subscribe to the balances for these accounts
|
||||
// Subscribe to the balances for these accounts
|
||||
const unsub = await api.query.balances.freeBalance.multi(validators, (balances) => {
|
||||
console.log(`The balances are: ${balances}`);
|
||||
});
|
||||
@@ -40,7 +40,7 @@ The previous `.multi` examples assumes that we do queries for the same types, i.
|
||||
```js
|
||||
...
|
||||
|
||||
// subscribe to the timestamp, our index and balance
|
||||
// Subscribe to the timestamp, our index and balance
|
||||
const unsub = await api.queryMulti([
|
||||
api.query.timestamp.now,
|
||||
[api.query.system.accountNonce, ADDR],
|
||||
|
||||
@@ -9,16 +9,16 @@ Quite often is is useful (taking pruning into account, more on this later) to re
|
||||
```js
|
||||
...
|
||||
|
||||
// retrieve the current block header
|
||||
// Retrieve the current block header
|
||||
const lastHdr = await api.rpc.chain.getHeader();
|
||||
|
||||
// retrieve the balance at both the current and the parent hashes
|
||||
// Retrieve the balance at both the current and the parent hashes
|
||||
const [balanceNow, balancePrev] = await Promise.all([
|
||||
api.query.balances.freeBalance.at(lastHdr.hash, ADDR),
|
||||
api.query.balances.freeBalance.at(lastHdr.parentHash, ADDR)
|
||||
]);
|
||||
|
||||
// display the difference
|
||||
// Display the difference
|
||||
console.log(`The delta was ${balanceNow.sub(balancePrev)}`);
|
||||
```
|
||||
|
||||
@@ -27,13 +27,13 @@ In the above example, we introduce the `.at(<hash>[, ...params])` query. For all
|
||||
```js
|
||||
...
|
||||
|
||||
// retrieve the timestampt for the previous block
|
||||
// Retrieve the timestamp for the previous block
|
||||
const momentPrev = await api.query.timestamp.now.at(lastHdr.parentHash);
|
||||
```
|
||||
|
||||
The `.at` queries are all single-shot, i.e. there are no subscription option to these, since the state for a previous block should be static. (This is true to a certain extent, i.e. when blocks have been finalized).
|
||||
|
||||
An additional point to take care of (briefly mentioned above), is state pruning. By default a Polkadot/Substrate node will only keep state for the last 256 blocks, unless it is explicitly run in archive mode. This means that querying state further back than the pruning period will result in an error returned from the Node. (Generaly most public RPC nodes only run with default settings, which includes agressive state pruning)
|
||||
An additional point to take care of (briefly mentioned above), is state pruning. By default a Polkadot/Substrate node will only keep state for the last 256 blocks, unless it is explicitly run in archive mode. This means that querying state further back than the pruning period will result in an error returned from the Node. (Generally most public RPC nodes only run with default settings, which includes aggressive state pruning)
|
||||
|
||||
## State entries
|
||||
|
||||
@@ -42,13 +42,13 @@ In addition to using `api.query` to make actual on-chain queries, it can also be
|
||||
```js
|
||||
...
|
||||
|
||||
// retrieve the hash & size of the entry as stored on-chain
|
||||
// Retrieve the hash & size of the entry as stored on-chain
|
||||
const [entryHash, entrySize] = await Promise.all([
|
||||
api.query.freeBalance.hash(ADDR),
|
||||
api.query.freeBalance.size(ADDR)
|
||||
api.query.balances.freeBalance.hash(ADDR),
|
||||
api.query.balances.freeBalance.size(ADDR)
|
||||
]);
|
||||
|
||||
// output the info
|
||||
// Output the info
|
||||
console.log(`The current size is ${entrySize} bytes with a hash of ${entryHash}`);
|
||||
```
|
||||
|
||||
@@ -59,17 +59,17 @@ As per the previous examples, the params here apply explicitly to the actual nee
|
||||
It has been explained that the `api.query` interfaces are decorated from the metadata. This also means that there is some information that we can gather from the entry, as decorated -
|
||||
|
||||
```js
|
||||
// extract the info
|
||||
// Extract the info
|
||||
const { meta, method, section } = api.query.balances.freeBalance;
|
||||
|
||||
// display some info on a specific entry
|
||||
// Display some info on a specific entry
|
||||
console.log(`${section}.${method}: ${meta.documentation.join(' ')}`);
|
||||
console.log(`query key: ${api.query.balances.freeBalance.key(ADDR)}`);
|
||||
```
|
||||
|
||||
The `section` & `method` is an indication of where it is exposed on the API. In addition the `meta` holds an array with the metadata documentation for the entry.
|
||||
|
||||
The `key` endpoint requires some explanation. In the chain state, the key values (identified by the module, method & params) are hashed and this is used as a lookup. So underlying a single-shot query would utilize the `api.rpc.state.getStorage` entry, passing the output of `key` (which is a hashed representation of the values). Apart from the hashing, the API also takes care of type formatting, handling optional values and merging results accross multiple subscriptions.
|
||||
The `key` endpoint requires some explanation. In the chain state, the key values (identified by the module, method & params) are hashed and this is used as a lookup. So underlying a single-shot query would utilize the `api.rpc.state.getStorage` entry, passing the output of `key` (which is a hashed representation of the values). Apart from the hashing, the API also takes care of type formatting, handling optional values and merging results across multiple subscriptions.
|
||||
|
||||
## Let's transact already!
|
||||
|
||||
|
||||
@@ -2,14 +2,14 @@
|
||||
|
||||
Previously we explained the concepts between `api.query`. In this section we will expand on that knowledge to introduce subscriptions (akin to what we found in `api.rpc`) to stream results from the state, as it changes between blocks.
|
||||
|
||||
## Subcriptions
|
||||
## Subscriptions
|
||||
|
||||
As in the case with `api.rpc` subscriptions, query subscriptions follow exactly the same form - an actual call is augmented with a callback to return the current state value that is updated as the underlying value changes. As an example, we can extend on what we had previously -
|
||||
|
||||
```js
|
||||
...
|
||||
|
||||
// retrieve the current timestamp via subscription
|
||||
// Retrieve the current timestamp via subscription
|
||||
const unsub = await api.query.timestamp.now((moment) => {
|
||||
console.log(`The last block has a timestamp of ${moment}`);
|
||||
});
|
||||
@@ -24,7 +24,7 @@ If we had a query with parameters, i.e. where we wish to perform a query for a s
|
||||
```js
|
||||
...
|
||||
|
||||
// subscribe to balance changes for our account
|
||||
// Subscribe to balance changes for our account
|
||||
const unsub = await api.query.balances.freeBalance(ADDR, (balance) => {
|
||||
console.log(`Your account balance is ${balance}`);
|
||||
});
|
||||
|
||||
@@ -7,13 +7,13 @@ Since you are already familiar with the `api.query` interface, the `api.rpc` int
|
||||
```js
|
||||
...
|
||||
|
||||
// retrieve the chain name
|
||||
// Retrieve the chain name
|
||||
const chain = await api.rpc.system.chain();
|
||||
|
||||
// retrieve the latest header
|
||||
// Retrieve the latest header
|
||||
const lastHeader = await api.rpc.chain.getHeader();
|
||||
|
||||
// log the information
|
||||
// Log the information
|
||||
console.log(`${chain}: last block #${lastHeader.number} has hash ${lastHeader.hash}`);
|
||||
```
|
||||
|
||||
@@ -26,13 +26,13 @@ The RPCs lend themselves to using subscriptions, for instance in the above case
|
||||
```js
|
||||
...
|
||||
|
||||
// subscribe to the new headers
|
||||
// Subscribe to the new headers
|
||||
await api.rpc.chain.subscribeNewHeads((lastHeader) => {
|
||||
console.log(`${chain}: last block #${lastHeader.number} has hash ${lastHeader.hash}`);
|
||||
});
|
||||
```
|
||||
|
||||
Since we are dealing with a subscription, we now pass a callback into the `subscribeNewHeads` function, and this will be triggered on each header, as they are imported. The same pattern would apply to each of the `api.rpc.subscribe*` functions - as a last parameter a callback is to be provided that streams the latest data, as it becomes available.
|
||||
Since we are dealing with a subscription, we now pass a callback into the `subscribeNewHeads` function, and this will be triggered on each header, as they are imported. The same pattern would apply to each of the `api.rpc.subscribe*` functions - as a last parameter a callback is to be provided that streams the latest data, as it becomes available.
|
||||
|
||||
In general, whenever we create a subscription, we would like to cleanup after ourselves and unsubscribe, so assuming we only want to log the first 10 headers, the above example can be adjusted in the following manner -
|
||||
|
||||
@@ -40,7 +40,7 @@ In general, whenever we create a subscription, we would like to cleanup after ou
|
||||
...
|
||||
let count = 0;
|
||||
|
||||
// subscribe to the new headers
|
||||
// Subscribe to the new headers
|
||||
const unsubHeads = await api.rpc.chain.subscribeNewHeads((lastHeader) => {
|
||||
console.log(`${chain}: last block #${lastHeader.number} has hash ${lastHeader.hash}`);
|
||||
|
||||
|
||||
@@ -9,12 +9,12 @@ To start off, let's make a balance transfer from Alice to Bob.
|
||||
```js
|
||||
...
|
||||
|
||||
// sign and send a transfer from Alice to Bob
|
||||
// Sign and send a transfer from Alice to Bob
|
||||
const txHash = await api.tx.balances
|
||||
.transfer(BOB, 12345)
|
||||
.signAndSend(alice);
|
||||
|
||||
// show the hash
|
||||
// Show the hash
|
||||
console.log(`Submitted with hash ${txHash}`);
|
||||
```
|
||||
|
||||
@@ -26,10 +26,10 @@ The result for this call (we will deal with subscriptions in a short while), is
|
||||
|
||||
## Under the hood
|
||||
|
||||
Despite the single-line format of `signAndSend`, there is a lot hapenning under the hood (and all of this can be manually provided) -
|
||||
Despite the single-line format of `signAndSend`, there is a lot happening under the hood (and all of this can be manually provided) -
|
||||
|
||||
- Based on the sender, the API will retrieve the `system.accountNonce` to determine the next nonce to use
|
||||
- The API will retrieve the current block hash and use it to create a mortal transaction, i.e. the transaction will only be valid for a limited number of blocks (by default this is 5 mins at 6s blocktimes)
|
||||
- The API will retrieve the current block hash and use it to create a mortal transaction, i.e. the transaction will only be valid for a limited number of blocks (by default this is 5 mins at 6s block times)
|
||||
- It will construct a payload and sign this, this includes the `genesisHash`, the `blockHash` for the start of the mortal era as well as the current chain `specVersion`
|
||||
- The transaction is submitted to the node
|
||||
|
||||
|
||||
@@ -9,10 +9,10 @@ To send a transaction and then waiting until it has been included in a block, we
|
||||
```js
|
||||
...
|
||||
|
||||
// create alice (carry-over from the keyring section)
|
||||
// Create alice (carry-over from the keyring section)
|
||||
const alice = keyring.addFromUri('//Alice');
|
||||
|
||||
// make a transfer from Alice to BOB, waiting for inclusion
|
||||
// Make a transfer from Alice to BOB, waiting for inclusion
|
||||
const unsub = await api.tx.balances
|
||||
.transfer(BOB, 12345)
|
||||
.signAndSend(alice, (result) => {
|
||||
@@ -39,7 +39,7 @@ To display or act on these events, we can do the following -
|
||||
|
||||
```js
|
||||
...
|
||||
// make a transfer from Alice to BOB, waiting for inclusion
|
||||
// Make a transfer from Alice to BOB, waiting for inclusion
|
||||
const unsub = await api.tx.balances
|
||||
.transfer(BOB, 12345)
|
||||
.signAndSend(alice, ({ events = [], status }) => {
|
||||
@@ -48,7 +48,7 @@ const unsub = await api.tx.balances
|
||||
if (status.isFinalized) {
|
||||
console.log(`Transaction included at blockHash ${status.asFinalized}`);
|
||||
|
||||
// loop through Vec<EventRecord> to display all events
|
||||
// Loop through Vec<EventRecord> to display all events
|
||||
events.forEach(({ phase, event: { data, method, section } }) => {
|
||||
console.log(`\t' ${phase}: ${section}.${method}:: ${data}`);
|
||||
});
|
||||
@@ -58,7 +58,7 @@ const unsub = await api.tx.balances
|
||||
});
|
||||
```
|
||||
|
||||
Be aware that when a transaction status is `isFinalized`, it means it is included, but it may still have failed - for instance if you try to send a larger amount that you have free, the transaction is included in a block, however from a end-user perspective the transaction failed since the transfer did not occur. In these cases a `system.ExtrinsicFailed` event will be available in the events array.
|
||||
Be aware that when a transaction status is `isFinalized`, it means it is included, but it may still have failed - for instance if you try to send a larger amount that you have free, the transaction is included in a block, however from a end-user perspective the transaction failed since the transfer did not occur. In these cases a `system.ExtrinsicFailed` event will be available in the events array.
|
||||
|
||||
## Complex transactions
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Complex transactions
|
||||
|
||||
Up till now we have focussed on the base operation of transactions. There are however some more complex operations that deserve some more information, for instance when doing either democracy proposals or excuting sudo calls, in both these cases the transaction wraps a call or proposal to be evaluated.
|
||||
Up till now we have focussed on the base operation of transactions. There are however some more complex operations that deserve some more information, for instance when doing either democracy proposals or executing sudo calls, in both these cases the transaction wraps a call or proposal to be evaluated.
|
||||
|
||||
## Sudo use
|
||||
|
||||
@@ -8,13 +8,13 @@ When running a development chain (Polkadot/Substrate with a `--dev` flag), or in
|
||||
|
||||
```js
|
||||
...
|
||||
// get the current sudo key in the system
|
||||
// Get the current sudo key in the system
|
||||
const sudoKey = await api.query.sudo.key();
|
||||
|
||||
// lookup from keyring (assuming we have added all, on --dev this would be `//Alice`)
|
||||
// Lookup from keyring (assuming we have added all, on --dev this would be `//Alice`)
|
||||
const sudoPair = keyring.getPair(sudoKey);
|
||||
|
||||
// send the actual sudo transaction
|
||||
// Send the actual sudo transaction
|
||||
const unsub = await api.tx.sudo
|
||||
.sudo(
|
||||
api.tx.balances.setBalance(ADDR, 12345, 678)
|
||||
@@ -41,4 +41,4 @@ In the above example, all we need to provide is a the fields for the `ValidatorP
|
||||
|
||||
## Understanding types
|
||||
|
||||
As has been very apparent in all the preceding sections, the management of types is what allows the API to communicate with the node. Most values are in a [binary SCALE-encoded format](https://github.com/paritytech/parity-scale-codec) and it is the reponsibility of the API is to encode and decode these. In the next section we will [take a look at what interfaces the API provides around types](types.basics.md).
|
||||
As has been very apparent in all the preceding sections, the management of types is what allows the API to communicate with the node. Most values are in a [binary SCALE-encoded format](https://github.com/paritytech/parity-scale-codec) and it is the responsibility of the API is to encode and decode these. In the next section we will [take a look at what interfaces the API provides around types](types.basics.md).
|
||||
|
||||
@@ -16,7 +16,7 @@ Additionally the metadata also provides information on [events](../substrate/eve
|
||||
|
||||
## Types
|
||||
|
||||
The metadata defiends the calls with all the type names used in the various interfaces. At the moment (this is undergoing investigations and could improve in future versions of metadata), this also means that the types between the API and the node need to be aligned. For instance, by default Substrate defines a `BlockNumber` type as a `u32` and the API follows the Substrate defaults - if a chain has a different definitions, the API needs to be aware of this so it can actually decode (and encode) the type.
|
||||
The metadata defines the calls with all the type names used in the various interfaces. At the moment (this is undergoing investigations and could improve in future versions of metadata), this also means that the types between the API and the node need to be aligned. For instance, by default Substrate defines a `BlockNumber` type as a `u32` and the API follows the Substrate defaults - if a chain has a different definitions, the API needs to be aware of this so it can actually decode (and encode) the type.
|
||||
|
||||
At this point just be aware of it, we will touch on types, custom chains and their impacts in a later section.
|
||||
|
||||
@@ -27,7 +27,7 @@ In addition to the `api.[consts | query | tx]` detailed above, the API, upon con
|
||||
- `api.genesisHash` - The genesisHash of the connected chain
|
||||
- `api.runtimeMetadata` - The metadata as retrieved from the chain
|
||||
- `api.runtimeVersion` - The chain runtime version (including spec/impl. versions and types)
|
||||
- `api.libraryInfo` - The version of the API, i.e. `@polkadot/api v0.90.1`
|
||||
- `api.libraryInfo` - The version of the API, i.e. `@polkadot/api v0.90.1`
|
||||
|
||||
## Let's do something!
|
||||
|
||||
|
||||
+10
-10
@@ -3,30 +3,30 @@
|
||||
We have the API installed, we have an understanding of what will actually be exposed and how the API knows what to expose. So down the rabbit hole we go - let's create an actual API instance, and then take it from there -
|
||||
|
||||
```js
|
||||
// import
|
||||
// Import
|
||||
import { ApiPromise, WsProvider } from '@polkadot/api';
|
||||
|
||||
...
|
||||
// construct
|
||||
// Construct
|
||||
const wsProvider = new WsProvider('wss://poc-3.polkadot.io');
|
||||
const api = await ApiPromise.create({ provider: wsProvider });
|
||||
|
||||
// do something
|
||||
// Do something
|
||||
console.log(api.genesisHash.toHex());
|
||||
```
|
||||
|
||||
We will have some explanation on the ES2015 syntax used next, but just a small note on the above - where other code is included (or just some previous boilerplate is used), you will see `...` in most of the examples. This is not due to lazyness, but rather just to keep things straight and to the point.
|
||||
We will have some explanation on the ES2015 syntax used next, but just a small note on the above - where other code is included (or just some previous boilerplate is used), you will see `...` in most of the examples. This is not due to laziness, but rather just to keep things straight and to the point.
|
||||
|
||||
## ES2015 Usage and examples
|
||||
|
||||
Before we jump into an explanation of the above example, be aware that in all cases we are using ES2015, including using things like `async`/`await`, `import` and others. Depending on your environment, this may require some adjustments.
|
||||
|
||||
While we are using the `await` naked in all examples (this removes boilerplate), it will need to be wrapped in an `async` block, for we could warp all samples inside a `async function main () { ... }` and then just call `main()`.
|
||||
While we are using the `await` naked in all examples (this removes boilerplate), it will need to be wrapped in an `async` block, for we could warp all samples inside a `async function main () { ... }` and then just call `main()`.
|
||||
|
||||
In the case of Node.js you would change the `import` into `require`, i.e.
|
||||
|
||||
```js
|
||||
// import
|
||||
// Import
|
||||
const { ApiPromise, WsProvider } = require('@polkadot/api');
|
||||
...
|
||||
```
|
||||
@@ -58,13 +58,13 @@ ApiPromise
|
||||
In most cases we would suggest using the `.create` shortcut, which really just takes care of the following boilerplate that otherwise needs to be provided -
|
||||
|
||||
```js
|
||||
// create the instance
|
||||
// Create the instance
|
||||
const api = new ApiPromise({ provider: wsProvider });
|
||||
|
||||
// wait until we are ready and connected
|
||||
// Wait until we are ready and connected
|
||||
await api.isReady;
|
||||
|
||||
// do something
|
||||
// Do something
|
||||
console.log(api.genesisHash.toHex());
|
||||
```
|
||||
|
||||
@@ -76,4 +76,4 @@ In these cases, create via `new`, attach listeners and then wait for the `isRead
|
||||
|
||||
## Do something
|
||||
|
||||
Now that we have the API initialized, the next step would be to start using it to interact and extract data [starting with chain constants](api.consts.md).
|
||||
Now that we have the API initialized, the next step would be to start using it to interact and extract data [starting with chain constants](api.consts.md).
|
||||
|
||||
@@ -0,0 +1,158 @@
|
||||
# Extending extrinsics
|
||||
|
||||
On some chains, the need may arise to customize the extrinsic format. In this section we will explain what extrinsics and their payloads contain, explain how signed extensions work and provide a walk through of an advanced use-case where extrinsics are customized for a specific Substrate chain.
|
||||
|
||||
## Extensions
|
||||
|
||||
In Substrate (which forms the base of Polkadot and a number of custom chains), an extrinsic has a specific version, flag to indicating if it has been signed, the address, signature, extra data as well as the actual method with params. In addition, the signature is generated over the call and may include values that are not encoded into the final extrinsic.
|
||||
|
||||
For instance, with version 3 extrinsics, the signature payload contains the runtime spec version as well as the `genesisHash` and `blockHash` (the latter being equivalent to the `genesisHash` in case of immortal transactions), however while these 3 fields are signed together with the method data, they do not actually appear in the extrinsic itself. Rather the chain executing the transaction will retrieve this information, add it to the method data and compare the signatures thereof.
|
||||
|
||||
So in both the cases of the `genesisHash` and `specVersion`, if these do not match the signer version, the transaction won't be accepted - however the extrinsic doesn't explicitly carry this information in the data being transmitted, rather only implicitly as part of the signature. And it always forms part of the validation.
|
||||
|
||||
## Default extrinsics
|
||||
|
||||
With the above in-mind, the extrinsic format is explicitly defined as having the following structure in Substrate -
|
||||
|
||||
```rust
|
||||
pub struct UncheckedExtrinsic<Address, Call, Signature, Extra>
|
||||
where Extra: SignedExtension
|
||||
{
|
||||
pub signature: Option<(Address, Signature, Extra)>,
|
||||
pub function: Call,
|
||||
}
|
||||
```
|
||||
|
||||
The `Option` is here encoded such that is conveys both the extrinsic version `0x03` for Substrate 2.x chains (`0x01` for Substrate 1.x chains) as well as a high-bit that indicates if the transaction is signed or unsigned. (For unsigned the `signature` details therefore does not appear). The `SignedExtension` part defined both the data in the actual extrinsic as well as data, i.e. `AdditionalSigned`, that appears in the payload for the signature, but is not explicitly contained in the extrinsic.
|
||||
|
||||
The default `SignedExtension` for Substrate 2.x with extrinsic version 3 is defined as follow -
|
||||
|
||||
```rust
|
||||
pub type SignedExtra = (
|
||||
system::CheckVersion<Runtime>,
|
||||
system::CheckGenesis<Runtime>,
|
||||
system::CheckEra<Runtime>,
|
||||
system::CheckNonce<Runtime>,
|
||||
system::CheckWeight<Runtime>,
|
||||
balances::TakeFees<Runtime>,
|
||||
contracts::CheckBlockGasLimit<Runtime>,
|
||||
);
|
||||
```
|
||||
|
||||
Some of these are only checks, requiring no additional data in the payload or extrinsic itself, i.e. the contracts checks do exactly that. It only applies checks and invalidates when those checks are invalid. This is a powerful concept, for instance on the [initial Kusama chain this was used to limit the types of calls allowed](https://github.com/paritytech/polkadot/blob/f52c714ec3411eea58647d0f5176f4eb81660188/runtime/src/lib.rs#L117-L139).
|
||||
|
||||
## Extension deep-dive
|
||||
|
||||
For each of the default extensions, we will take a look through to understand the implications of the specific extension and how it relates to both the data contained in the extrinsic as well as the signature payload.
|
||||
|
||||
- `system::CheckVersion` - This checks that the spec version matches between the extrinsic and the chain. It takes no parameters which means that these is no explicit data in the extrinsic format for this field, however it has `type AdditionalSigned = u32` which means that a `u32` containing the runtime spec version is part of the signature payload.
|
||||
|
||||
- `system::CheckGenesis` - This checks that the `genesisHash` matches between extrinsic and chain. Like the previous check, no additional data is added to the extrinsic, however with `type AdditionalSigned = T::Hash`, the `genesisHash` is part of the signature payload.
|
||||
|
||||
- `system::CheckEra` - This checks the era (mortal or immortal) for the transaction being sent. It checks both the `era: Era` as part of the actual extrinsic and the `blockHash` via the `type AdditionalSigned = T::Hash`. This means that the extrinsic era is both in the data being signed and the extrinsic itself, while the `blockHash` the era applies to is only available in the signature payload.
|
||||
|
||||
- `system::CheckNonce` - This checks the nonce for the sending account. Unlike the preceding checks, it has no payload-specific data, however the `nonce: Compact<T::Index>` (`Index` is default `u32`) is applicable to both the extrinsic and, therefore, the actual signature payload as well.
|
||||
|
||||
- `system::CheckWeight` - This checks the weight and length of the block and ensure that it does not exceed the limits. It does not have any specific data attached to either the extrinsic nor payload, but rather just does calculations based on the weights and type of transaction received.
|
||||
|
||||
- `balances::TakeFees` - Consumes fees proportional to the length and weight of the transaction. It operates on the `fee: Compact<T::Balance>`, which means this value is included in both the extrinsic and subsequent payload being signed.
|
||||
|
||||
- `contracts::CheckBlockGasLimit` - As explained briefly above, this extension does not add data to the extrinsic, or the signature payload, however it ensures that the transaction does not exceeds the block gas limit.
|
||||
|
||||
## Extrinsic and signature payloads
|
||||
|
||||
With the above extension, the following formats for the extrinsic and payloads are the outcome of the application of the signed extension. For the extrinsic the following data is [always encoded for v3 extrinsics](https://github.com/polkadot-js/api/blob/8b0ef159c05bcb5d9b664546d0e7289e79b5c9d5/packages/types/src/primitive/Extrinsic/v3/Extrinsic.ts#L27) -
|
||||
|
||||
```js
|
||||
class ExtrinsicV3 extends Struct {
|
||||
constructor (value) {
|
||||
super({
|
||||
signer: 'Address',
|
||||
signature: 'Signature',
|
||||
era: 'ExtrinsicEra', // extra via system::CheckEra
|
||||
nonce: 'Compact<Index>', // extra via system::CheckNonce
|
||||
tip: 'Compact<Balance>', // extra via balances::TakeFees
|
||||
method: 'Call'
|
||||
}, value);
|
||||
}
|
||||
...
|
||||
```
|
||||
|
||||
The signature payload will contain the same information as the extrinsic, with the following [additional information](https://github.com/polkadot-js/api/blob/8b0ef159c05bcb5d9b664546d0e7289e79b5c9d5/packages/types/src/primitive/Extrinsic/v3/ExtrinsicPayload.ts#L33) as expected by the `AdditionalSigned` portions of the extensions -
|
||||
|
||||
```js
|
||||
class ExtrinsicPayloadV3 extends Struct {
|
||||
constructor (value) {
|
||||
super({
|
||||
method: 'Bytes',
|
||||
era: 'ExtrinsicEra', // extra via system::CheckEra
|
||||
nonce: 'Compact<Index>', // extra via system::CheckNonce
|
||||
tip: 'Compact<Balance>', // extra via balances::TakeFees
|
||||
specVersion: 'u32', // additional via system::CheckVersion
|
||||
genesisHash: 'Hash', // additional via system::CheckGenesis
|
||||
blockHash: 'Hash' // additional via system::CheckEra
|
||||
}, value);
|
||||
}
|
||||
...
|
||||
```
|
||||
|
||||
As per the above structures, it means that both the extrinsic sent on-chain as well as the data being signed to generate the signature is tied by the hip based on the logic the chain expects via `SignedExtension`. The API is only aware of the version of the extrinsic being used on-chain (it determines this on connection) and therefore only knows about the specific logic that has been coded for the extrinsic version.
|
||||
|
||||
## Extending existing or implementing new
|
||||
|
||||
When the API encodes or decodes an extrinsic, it uses the first `Option` byte to determine the version. Once it has this value, it will create a specific extrinsic via `createType('ExtrinsicV3', value)`. This means that at any point, you can supply your own version of either the `Extrinsic` or `ExtrinsicPayload` and you can do so via 2 avenues -
|
||||
|
||||
- If you are extending/replacing the existing version, you can inject your own types for both `ExtrinsicV3` and `ExtrinsicV3Payload` (assuming you are replacing v3)
|
||||
|
||||
- If you are adding a new version, you can add a handler for both `ExtrinsicUnknown` and `ExtrinsicPayloadUnknown`. These will be constructed when the version the API is aware of does not match with the on-chain version.
|
||||
|
||||
While we will not provide a full example of all the code here, the above links will show the existing implementations. However, assuming we have a chain where neither the nonce or tip is applicable (or we just don't care) and we are ignoring the check to the runtime versioning.
|
||||
|
||||
Additionally assuming that we have made the required `SignedExtension` updates by removing `system::CheckVersion`, `system::CheckNonce` and `balances::TakeFees`, we can do the following -
|
||||
|
||||
```js
|
||||
...
|
||||
class OwnExtrinsic extends Struct {
|
||||
constructor (value) {
|
||||
super({
|
||||
signer: 'Address',
|
||||
signature: 'Signature',
|
||||
era: 'ExtrinsicEra', // extra via system::CheckEra
|
||||
method: 'Call'
|
||||
}, value);
|
||||
}
|
||||
...
|
||||
}
|
||||
|
||||
class OwnExtrinsicPayload extends Struct {
|
||||
constructor (value) {
|
||||
super({
|
||||
method: 'Bytes',
|
||||
era: 'ExtrinsicEra', // extra via system::CheckEra
|
||||
genesisHash: 'Hash', // additional via system::CheckGenesis
|
||||
blockHash: 'Hash' // additional via system::CheckEra
|
||||
}, value);
|
||||
}
|
||||
...
|
||||
// signing logic needs to be included, as per existing
|
||||
}
|
||||
...
|
||||
|
||||
// inject our types at API construction
|
||||
const api = ApiPromise.create({
|
||||
types: {
|
||||
'ExtrinsicV3': OwnExtrinsic,
|
||||
'ExtrinsicV3Payload': OwnExtrinsicPayload,
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
The above example is certainly an advanced example, but it shows that all data types in the API can be adjusted and these adjustment can be provided to the API. In all cases, if you made updates to the formats and types of the actual runtime, you need to ensure that the API is aware of these changes.
|
||||
|
||||
In the above example, should these updates only be made on the node side, without the required API adjustments, the API will generate invalid transactions for the node since it is unaware of the changes and adjusted formats. Making the adjustments on only one side will mean that the signature verification can fail and that the format will not be decodable via the node.
|
||||
|
||||
(These extensions are not exposed via metadata at all, and would be quite difficult to do as well - since each of these have specific logic as well as data types assigned.)
|
||||
|
||||
## Using with TypeScript
|
||||
|
||||
The API is built with TypeScript (as are all projects in the [polkadot-js organization](https://github.com/polkadot-js/)) and as such allows developers using TS to have access to all the type interfaces defined on the chain, as well as having access to typings on interacting with the `api.*` namespaces. In the next section we will provide an overview of [what is available in terms of types and TypeScript](typescript.md).
|
||||
@@ -4,11 +4,11 @@ Yes, it really is as simple as [installing from npm](https://www.npmjs.com/packa
|
||||
|
||||
`yarn add @polkadot/api`
|
||||
|
||||
And it will be added and ready for use. The above will always install the latest stable release, which should allow you to connect to testsnets and local nodes that are tracking versioned releases for [Polkadot](https://github.com/paritytech/polkadot) and [Substrate](https://github.com/paritytech/substrate).
|
||||
And it will be added and ready for use. The above will always install the latest stable release, which should allow you to connect to test networks and local nodes that are tracking versioned releases for [Polkadot](https://github.com/paritytech/polkadot) and [Substrate](https://github.com/paritytech/substrate).
|
||||
|
||||
## Betas
|
||||
|
||||
For users who have a slightly higher appetite for risk, or are using bleeding-edge master branches of either Polkadot/Substrate, we also publish a beta version as soon as anything is merged into the API master branch. This version really contains all the latest fixes and features and is the version we actually use inside the polkadot-js projects - eating our own dogfood.
|
||||
For users who have a slightly higher appetite for risk, or are using bleeding-edge master branches of either Polkadot/Substrate, we also publish a beta version as soon as anything is merged into the API master branch. This version really contains all the latest fixes and features and is the version we actually use inside the polkadot-js projects - eating our own dog food.
|
||||
|
||||
To install a beta version, either to test or for support of a feature that is available in Substrate master (and has not yet made it to a stable api release), you can install it via the `@beta` tag, i.e.
|
||||
|
||||
|
||||
+35
-18
@@ -6,20 +6,20 @@ This section will give a quick introduction into the Keyring, including the addi
|
||||
|
||||
They [@polkadot/keyring](https://github.com/polkadot-js/common/tree/master/packages/keyring) keyring is included directly with the API as a dependency, so it is directly importable (since the 0.92 version) alongside the API.
|
||||
|
||||
If you do opt to install it seperately, ensure that the version of `@polkadot/util-crypto` that is included with the API matches with the version of `@polkadot/keyring` installed. So if the API depends on `util-crypto 1.4.1`, it would make sense to include `keyring 1.4.1` as the installed version. (This helps in making sure extra versions of the libraries are not included as duplicates, especially in the case where bundles are created. Additionally, this makes sure that weird side-effects in the WASM initialization is avoided.)
|
||||
If you do opt to install it separately, ensure that the version of `@polkadot/util-crypto` that is included with the API matches with the version of `@polkadot/keyring` installed. So if the API depends on `util-crypto 1.4.1`, it would make sense to include `keyring 1.4.1` as the installed version. (This helps in making sure extra versions of the libraries are not included as duplicates, especially in the case where bundles are created. Additionally, this makes sure that weird side-effects in the WASM initialization is avoided.)
|
||||
|
||||
## Creating a keyring instance
|
||||
|
||||
Once installed, you can create an instance by just creating an instance of the `Keyring` class -
|
||||
|
||||
```js
|
||||
// import the keyring as required
|
||||
// Import the keyring as required
|
||||
import { Keyring } from '@polkadot/api';
|
||||
|
||||
// initialize the API as we would normally do
|
||||
// Initialize the API as we would normally do
|
||||
...
|
||||
|
||||
// create a keyring instance
|
||||
// Create a keyring instance
|
||||
const keyring = new Keyring({ type: 'sr25519' });
|
||||
```
|
||||
|
||||
@@ -27,18 +27,18 @@ In the above example, the import is self-explanatory. Upon creation we pass thro
|
||||
|
||||
So effectively, when creating an account and not specifying a type, it will be `sr25519` by default based on the above construction params, however we can also add an `ed25519` account and use it transparently in the same keyring.
|
||||
|
||||
One "trick" that is done implictly in the above sample is that that keyring is only initialized after the API. In the case of `sr25519` the keyring relies on a [WASM build](https://github.com/polkadot-js/wasm) of the [schnorrkel libraries](https://github.com/w3f/schnorrkel). Since the API inlitialization is already async, it initializes the WASM libraries are part of the setup.
|
||||
One "trick" that is done implicitly in the above sample is that that keyring is only initialized after the API. In the case of `sr25519` the keyring relies on a [WASM build](https://github.com/polkadot-js/wasm) of the [schnorrkel libraries](https://github.com/w3f/schnorrkel). Since the API inlitialization is already async, it initializes the WASM libraries are part of the setup.
|
||||
|
||||
However, this initialization can also be done explicitly, mostly for more advances use-cases, or in cases where the API won't be attached until much later -
|
||||
|
||||
```js
|
||||
// crypto promise, package used by keyring internally
|
||||
// Crypto promise, package used by keyring internally
|
||||
import { cryptoWaitReady } from '@polkadot/util-crypto';
|
||||
|
||||
// wait for the promise to resolve, async WASM or `cryptoWaitReady().then(() => { ... })`
|
||||
// Wait for the promise to resolve, async WASM or `cryptoWaitReady().then(() => { ... })`
|
||||
await cryptoWaitReady();
|
||||
|
||||
// create a keyring instance
|
||||
// Create a keyring instance
|
||||
const keyring = new Keyring({ type: 'sr25519' });
|
||||
```
|
||||
|
||||
@@ -49,20 +49,37 @@ The recommended catch-all approach to adding accounts is via `.addFromUri(<suri>
|
||||
```js
|
||||
...
|
||||
|
||||
// some mnemonic phrase
|
||||
// Some mnemonic phrase
|
||||
const PHRASE = 'entire material egg meadow latin bargain dutch coral blood melt acoustic thought';
|
||||
|
||||
// add an account, straight menemonic
|
||||
// Add an account, straight mnemonic
|
||||
const newPair = keyring.addFromUri(PHRASE);
|
||||
|
||||
// (advanced) add an account with a derivation path (hard & soft)
|
||||
// (Advanced) add an account with a derivation path (hard & soft)
|
||||
const newDeri = keyring.addFromUri(`${PHRASE}//hard-derived/soft-derived`);
|
||||
|
||||
// (advanced, development-only) add with an implied dev seed and hard derivation
|
||||
// (Advanced, development-only) add with an implied dev seed and hard derivation
|
||||
const alice = keyring.addFromUri('//Alice', { name: 'Alice default' });
|
||||
```
|
||||
|
||||
The above additions cater for most of the usecases and aligns with the you would find in the Substrate `subkey`. Be very wary of the last "dev-seed" option, it is explicitly added for `subkey` compatibility and implies using the "known-everywhere" dev seed. It is however useful when running Polkadot/Substrate with a `--dev` flag.
|
||||
The above additions cater for most of the use cases and aligns with the you would find in the Substrate `subkey`. Be very wary of the last "dev-seed" option, it is explicitly added for `subkey` compatibility and implies using the "known-everywhere" dev seed. It is however useful when running Polkadot/Substrate with a `--dev` flag.
|
||||
|
||||
## Adding accounts with raw seeds
|
||||
|
||||
Since mnemonics are recommended and the defacto standard for current Polkadot/Substrate generations, the only mentioned way of adding keys thus far has been via mnemonic. However, the `addFromUri` method on the keyring is intelligent enough to detect and add from inputs specified as mnemonics, hex seeds and string seeds (appropriately padded).
|
||||
|
||||
With the above in mind, we could extend our examples above for custom raw seed. For instance to add both a hex and string seed, we can follow the following approach -
|
||||
|
||||
```js
|
||||
...
|
||||
// add a hex seed, 32-characters in length
|
||||
const hexPair = keyring.addFromUri('0x1234567890123456789012345678901234567890123456789012345678901234');
|
||||
|
||||
// add a string seed, internally this is padded with ' ' to 32-bytes in length
|
||||
const strPair = keyring.addFromUri('Janice');
|
||||
```
|
||||
|
||||
You could extend derivation from these specified seeds with derivation paths if applicable, i.e. `Janice//hard` will perform a hard derivation with the path `hard` on the pair that is generated from the `Janice` seed. As far as possible, try to stick with mnemonics in your applications, unless you have a good reason to not do so. Humans are generally bad at generating their own entropy and mnemonics has additional properties such as built-in checksums.
|
||||
|
||||
## Working with pairs
|
||||
|
||||
@@ -71,27 +88,27 @@ In the previous examples we added a pair to the keyring (and we actually immedia
|
||||
```js
|
||||
...
|
||||
|
||||
// add our Alice dev account
|
||||
// Add our Alice dev account
|
||||
const alice = keyring.addFromUri('//Alice', { name: 'Alice default' });
|
||||
|
||||
// log some info
|
||||
// Log some info
|
||||
console.log(`${alice.meta.name}: has address ${alice.address} with publicKey [${alice.publicKey}]`);
|
||||
```
|
||||
|
||||
Additionally you can sign and verify using the pairs. This is the same internally to the API when constructing transactions -
|
||||
|
||||
```js
|
||||
// some helper functions used here
|
||||
// Some helper functions used here
|
||||
import { stringToU8a, u8aToHex } from '@polkadot/util';
|
||||
|
||||
...
|
||||
|
||||
// convert message, sign and then verify
|
||||
// Convert message, sign and then verify
|
||||
const message = stringToU8a('this is our message');
|
||||
const signature = alice.sign(message);
|
||||
const isValid = alice.verify(message, signature);
|
||||
|
||||
// log info
|
||||
// Log info
|
||||
console.log(`The signature ${u8aToHex(signature)}, is ${isValid ? '' : 'in'}valid`);
|
||||
```
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ We've touched upon types in most previous sections, i.e. that these are driven b
|
||||
|
||||
## Everything is a type
|
||||
|
||||
Just to re-iterate from the above. Eveything returned by the API is a type and has a consistent interface. This means that a `Vec<u32>` (an array of `u32` values) as well as a `Struct` (an pre-defined object) or an `Enum` has the same consistent base interface. Specific types types will have values, based on the type - decorated and available.
|
||||
Just to re-iterate from the above. Everything returned by the API is a type and has a consistent interface. This means that a `Vec<u32>` (an array of `u32` values) as well as a `Struct` (an pre-defined object) or an `Enum` has the same consistent base interface. Specific types types will have values, based on the type - decorated and available.
|
||||
|
||||
As a minimum, anything returned by the API, be it a `Vec<...>`, `Option<...>`, `Struct` or any normal type will always have the following methods -
|
||||
|
||||
@@ -16,12 +16,29 @@ As a minimum, anything returned by the API, be it a `Vec<...>`, `Option<...>`, `
|
||||
|
||||
Additionally, the following getters and utilities are available -
|
||||
|
||||
- `.isEmpty` - `true` if the value is an all-empy value, i.e. `0` in for numbers, all-zero for Arrays (or anything `Uint8Array`), `false` is non-zero
|
||||
- `.isEmpty` - `true` if the value is an all-empty value, i.e. `0` in for numbers, all-zero for Arrays (or anything `Uint8Array`), `false` is non-zero
|
||||
- `.hash` - a `Hash` (once again with all the methods above) that is a `blake2-256` representation of the contained value
|
||||
|
||||
## Comparing types
|
||||
|
||||
To reiterate the above API, the `.eq` method is the preferred means of comparing base types, rather than the JavaScript equality operator (`===`).
|
||||
|
||||
For example:
|
||||
|
||||
```js
|
||||
const { metadata } = await api.rpc.state.getMetadata();
|
||||
const modules = metadata.asV3.modules;
|
||||
|
||||
// This will not work, because `name` is an instance of `Text`, not a string
|
||||
// const system = modules.find(m => m.name === 'system');
|
||||
|
||||
// This will work, because `Text.eq()` can compare against a string
|
||||
const system = modules.find(m => m.name.eq('system'));
|
||||
```
|
||||
|
||||
## Working with numbers
|
||||
|
||||
All numbers wrap and extend an instance of [bn.js](https://github.com/indutny/bn.js/). This means that in addition to the interfaces defined above, they have some additional methods -
|
||||
All numbers wrap and extend an instance of [bn.js](https://github.com/indutny/bn.js/). This means that in addition to the interfaces defined above, they have some additional methods -
|
||||
|
||||
- `.toNumber()` - a JS number (limited to 2^53 - 1). This does mean that for large values, e.g. `Balance` (a `u128` extension), this can cause overflows
|
||||
- `.add(...)`, `.sub(...)`, ... - all the base methods available on the `BN` object
|
||||
@@ -30,7 +47,7 @@ In cases where a `Compact` is returned, i.e. `Compact<Balance>`, the value is wr
|
||||
|
||||
## Working with structures
|
||||
|
||||
All structures, a wrapping of an object containing a number of member variables, is an implementation of a standard JS `Map` object, so all the functions available on a `Map` such as `.entries()` are available. Additionally it is decorated with actual getters for the fields.
|
||||
All structures, a wrapping of an object containing a number of member variables, is an implementation of a standard JS `Map` object, so all the functions available on a `Map` such as `.entries()` are available. Additionally it is decorated with actual getters for the fields.
|
||||
|
||||
As an example, a `Header` will have getters for the `.parentHash`, `.number`, `.stateRoot`, `.extrinsicsRoot` and `.digest` fields. The same applies for all structures, as they are returned, each member will have an associated getter.
|
||||
|
||||
@@ -46,9 +63,9 @@ As a real-world example, when an extrinsic is applied, the `Phase` enum has one
|
||||
|
||||
An `Option<Type>` attempts to mimic the Rust approach of having `None` and `Some` available. This means the following getters & methods are available on an `Option` -
|
||||
|
||||
- `.isNone` - is `true` if no underlying values is warpped, effectively the same as `.isEmpty`
|
||||
- `.isNone` - is `true` if no underlying values is wrapped, effectively the same as `.isEmpty`
|
||||
- `.isSome` - this is `true` is a value is wrapped, i.e. if a `Option<u32>` has an actual underlying `u32`
|
||||
- `.unwrap()` - when `isSome`, this will return the wrapped value, i.e. for `Option<u32>`, this would return the `u32`. When the value is `isNone`, this call will throw an exception.
|
||||
- `.unwrap()` - when `isSome`, this will return the wrapped value, i.e. for `Option<u32>`, this would return the `u32`. When the value is `isNone`, this call will throw an exception.
|
||||
- `.unwrapOr(<default value>)` - this extends `unwrap()`, returning the wrapped value when `isSome` and in the case of `isNone` it will return the `<default value>` passed.
|
||||
|
||||
## Working with Tuples
|
||||
@@ -56,7 +73,7 @@ An `Option<Type>` attempts to mimic the Rust approach of having `None` and `Some
|
||||
A tuple is defined in the form of `(u32, AccountId)`. To access the individual values, you can access t via the index, i.e.
|
||||
|
||||
```js
|
||||
// assuming a tuple defined as `(32, AccountId)`
|
||||
// Assuming a tuple defined as `(32, AccountId)`
|
||||
const [count, accountId] = tuple;
|
||||
|
||||
console.log(`${accountId} has ${count.toNumber()} values`);
|
||||
|
||||
@@ -4,9 +4,9 @@ Circling back to metadata, by default the metadata information (at this point in
|
||||
|
||||
Therefore to cater for all types, a mapping in done on the [@polkadot/types library](https://github.com/polkadot-js/api/tree/master/packages/types/src/interfaces) to define each of the types and align with their underlying structures as it maps to a default Polkadot or Substrate chain.
|
||||
|
||||
Additionally, the API contains some logic for chain type detection, for instance in the case of Substrate 1.x based chains, it will define `BlockNumber` & `Index` (nonce) as a `u64`, while for current-generation chains, these will be defined as `u32`. Some of the work in maintaining the API for Polkadot/Substrate is the addition of types as they appear and gets used in the Rust codebases.
|
||||
Additionally, the API contains some logic for chain type detection, for instance in the case of Substrate 1.x based chains, it will define `BlockNumber` & `Index` (nonce) as a `u64`, while for current-generation chains, these will be defined as `u32`. Some of the work in maintaining the API for Polkadot/Substrate is the addition of types as they appear and gets used in the Rust codebase.
|
||||
|
||||
There is a the [recommentation](install.md#betas) to use a `@polkadot/api@beta` should you wish to track the master branches of Polkadot or Substrate, since master changes for the addition of new types do not make it into a stable release immediately.
|
||||
There is a the [recommendation](install.md#betas) to use a `@polkadot/api@beta` should you wish to track the master branches of Polkadot or Substrate, since master changes for the addition of new types do not make it into a stable release immediately.
|
||||
|
||||
## Extension
|
||||
|
||||
@@ -24,7 +24,7 @@ const api = await ApiPromise.create({
|
||||
});
|
||||
```
|
||||
|
||||
The above introduces the `types` registry, effectively allowing overrides and the definition of new types. The override above would mean that immediately the API will treat all occurences of `Balance` not as the default, but rather as the defined size.
|
||||
The above introduces the `types` registry, effectively allowing overrides and the definition of new types. The override above would mean that immediately the API will treat all occurrences of `Balance` not as the default, but rather as the defined size.
|
||||
|
||||
## User-defined types
|
||||
|
||||
@@ -52,7 +52,7 @@ const api = await ApiPromise.create({
|
||||
})
|
||||
```
|
||||
|
||||
The example above defines non-primitive types (as found in the specific implementation) as structs. Additionally it also shows the user-defined types can depend on other user-defined types with `Transaction` referencing both `TransactionInput` and `TransactionOutput`. Here you can reference any known types, i.e. in the above we have referenced primitives such as `u32` and `Signature` (itself an alias for `H512`).
|
||||
The example above defines non-primitive types (as found in the specific implementation) as structures. Additionally it also shows the user-defined types can depend on other user-defined types with `Transaction` referencing both `TransactionInput` and `TransactionOutput`. Here you can reference any known types, i.e. in the above we have referenced primitives such as `u32` and `Signature` (itself an alias for `H512`).
|
||||
|
||||
One form of types that appear regularly is enums, these can be defined as follow -
|
||||
|
||||
@@ -102,7 +102,7 @@ const api = await ApiPromise.create({
|
||||
});
|
||||
```
|
||||
|
||||
In the same way `typesChain` can be used to match on the actual chain name, i.e. for a chain such as Kusama, the following overrides can be made (as per example only - Kusama uses the Polkadot defaults, so no overrides are needed) -
|
||||
In the same way `typesChain` can be used to match on the actual chain name, i.e. for a chain such as Kusama, the following overrides can be made (as per example only - Kusama uses the Polkadot defaults, so no overrides are needed) -
|
||||
|
||||
```js
|
||||
...
|
||||
@@ -137,6 +137,6 @@ const api = await ApiPromise.create({
|
||||
|
||||
`Balance` would be defined as an `u128` at the end. Effectively based on the flow it is first registered as a `u32`, then overridden as a `u64` and finally overridden once more as a `u128` by the chain types.
|
||||
|
||||
## Using with TypeScript
|
||||
## Extending extrinsics
|
||||
|
||||
The API is built with TypeScript (as are all projects in the [polkadot-js organization](https://github.com/polkadot-js/)) and as such allows developers using TS to have access to all the type interfaces defined on the chain, as well as having access to typings on interacting with the `api.*` namespaces. In the next section we will provide an overview of [what is available in terms of types and TypeScript](typescript.md).
|
||||
On customized chains, it is possible to [extend the format of the extrinsics and extrinsic payload as customized on the chain](extrinsic.extend.md), next up we will look at this advanced use-case.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# TypeScript interfaces
|
||||
|
||||
The API is written in TypeScript, and as such definitions for all actual exposed interfaces are available. In general terms, care has been taken to expose types via a `@polkadot/<package>/types` interface, for instance the `ApiOptions` type which is passed through on the `.create` interface is available under `@polkadot/api/types`.
|
||||
The API is written in TypeScript, and as such definitions for all actual exposed interfaces are available. In general terms, care has been taken to expose types via a `@polkadot/<package>/types` interface, for instance the `ApiOptions` type which is passed through on the `.create` interface is available under `@polkadot/api/types`.
|
||||
|
||||
## RPC interfaces
|
||||
|
||||
@@ -13,19 +13,19 @@ import { Header } from '@polkadot/types/interfaces';
|
||||
const firstHead = api.rpc.chain.getHeader();
|
||||
|
||||
api.rpc.chain.subscribeNewHeads((lastHead: Header): void => {
|
||||
console.log('current header:', JSON.stringify(header));
|
||||
console.log('current header:', JSON.stringify(lastHead));
|
||||
});
|
||||
```
|
||||
|
||||
In the above example a couple of things are introduced - most of the chain definitions (the default types for both Polkadot & Substrate) can be imported as interfaces from the `@polkadot/types/interfaces` endpoint. These are not classes (since they are [generated from definitions](https://github.com/polkadot-js/api/tree/master/packages/types/src/interfaces)) but rather a combination of TypeScript `interfaces` (where structures are involved) and `type`, i.e. `type Balance = u128`.
|
||||
|
||||
In the subscription example, we explicitly define `lastHead: Header`, although the same definition is missing for `firstHead`. However, in both these cases the definitions for the `api.rpc` sections are such that TypeScript understands that `firstHead` and `lastHead` are of type `Header`. The `: Header` here is rather for our own understanding (and could be needed based on your eslint/tslint config).
|
||||
In the subscription example, we explicitly define `lastHead: Header`, although the same definition is missing for `firstHead`. However, in both these cases the definitions for the `api.rpc` sections are such that TypeScript understands that `firstHead` and `lastHead` are of type `Header`. The `: Header` here is rather for our own understanding (and could be needed based on your eslint/tslint config).
|
||||
|
||||
As indicated, most of the Polkadot/Substrate default types are available via `types/interfaces`. However, for primitives types where there is an actual implementation, these are made available via `@polkadot/types` directly. For instance, `import { u32 } from '@polkadot/types` is valid in this context.
|
||||
|
||||
## Metadata injected
|
||||
|
||||
For any interface injected by metadata, the types are not available by default (although it may be in the future for default interfaces), but rather what the API understands is that all results need to comply to the `Codec` interface. (The bas of all out types)
|
||||
For any interface injected by metadata, the types are not available by default (although it may be in the future for default interfaces), but rather what the API understands is that all results need to comply to the `Codec` interface. (The base of all our types)
|
||||
|
||||
However, to make this sane from a developer perspective the injected methods are generic, effectively making the following possible -
|
||||
|
||||
@@ -46,11 +46,6 @@ As of this writing, there are still some gray areas to type detection, specifica
|
||||
- `.at` & `.multi` on `api.query` does not (yet) have a `<TypeOverride>` interface. This means `as <TypeOverride>` casts are presently needed for these results
|
||||
- `api.queryMulti` does not (yet) allow you to provide a hint to the types returned, this ties to the previous point
|
||||
|
||||
In additiont to expanding the type covereage, we wish to make the actual generation script for the types from `@polkadot/types/interfaces` available in 2 ways -
|
||||
## Adding user types
|
||||
|
||||
- allowing you to point to a folder of types and auto-generate the TypeScript typings from those. (Which is akin to what we do internally). This would allow a reduction in type classes explicitly written and injected.
|
||||
- once the metadata itself supports full type definitions, the script can be used to generate interface definitions specifically tailored for a chain
|
||||
|
||||
## And it is a wrap
|
||||
|
||||
This brings us to the end of our overview and jump through the API. While the documentation is still very much and ever evolving item, we can encourage you to try out what you have learned with some [examples](../examples). As we [indicated right at the start of this journey](README.md#help-us-help-others), if there are areas for improvement, let us know.
|
||||
In addition to the generated and available interfaces, there is also the ability to [create TypeScript interfaces from your own definitions and well as your on-chain modules](typescript.user.md).
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
# TypeScript user generated
|
||||
|
||||
In the previous section we looked at the TypeScript definitions that are available and is generated from both the chain and definitions. Here we will expand upon the use of the infrastructure created to define types as part of the `@polkadot/types` library and see how to use them to generate your onw defintions and chain types.
|
||||
|
||||
## Definitions
|
||||
|
||||
A large part of the type definitions are defined not as classes, but rather as structures from which type definitions are extracted and that can be used as-is to let the API know how to decode a type. By now you should be familiar with [type extensions](types.extend.md), but effectively the [types library does exactly the same](https://github.com/polkadot-js/api/tree/master/packages/types/src/interfaces).
|
||||
|
||||
To create TypeScript-aware definitions and keep your files in a single place, you can follow the same approach. Assuming you have a package named `@MeInc/stuff` where you have the definitions in an `stuff/interfaces` folder. Each sub-folder would indicate a runtime module, e.g.
|
||||
|
||||
- `stuff/interfaces/<module>/definitions.ts` for each module (`types.ts` & `index.ts` will be generated)
|
||||
- `stuff/interfaces/defnitions.ts` importing all sub-definitions`
|
||||
|
||||
With this structure setup, you can generate TypeScript defintions.
|
||||
|
||||
In the root of your project (with the `@polkadot/api`), you can run `yarn polkadot-types-from-defs --input ./stuff/interfaces --package @MeInc/stuff/interfaces` which will create `types.ts` and `index.ts` files with the generated types. You can use these in exactly the same way as you would use your types from `@polkadot/types/interfaces`.
|
||||
|
||||
## Chain modules
|
||||
|
||||
In the same way as the type library provides defaults from a substrate-base chain, you can also, directly from chain from metadata, generate a complete `api.{consts,query}.*` defintion for your specific chain. The command will create 2 files, `{consts, query}.types.ts` which you can either use to augment the TypeScript defintions, or replace those in `@polkadot/api/*` with your versions (copy, TypeScript replacement or browser/node aliassing).
|
||||
|
||||
In the root of your project, you can run `yarn polkadot-types-from-chain --endpoint wss://<url> --output ./stuff` and it will create the required output. (Here you can specify an optional `--package @MeInc/stuff` to read definitions for the targetted output folder with the specified package name.)
|
||||
|
||||
## And that's a wrap
|
||||
|
||||
This brings us to the end of our overview and jump through the API. While the documentation is still very much and ever evolving item, we can encourage you to try out what you have learned with some [examples](../examples). As we [indicated right at the start of this journey](README.md#help-us-help-others), if there are areas for improvement, let us know.
|
||||
+54
-51
@@ -30,10 +30,10 @@ ___
|
||||
### babe
|
||||
|
||||
▸ **epochDuration**: `u64`
|
||||
- **summary**: The number of **slots** that an epoch takes. We couple sessions to epochs, i.e. we start a new session once the new epoch begins.
|
||||
- **summary**: The number of **slots** that an epoch takes. We couple sessions to epochs, i.e. we start a new session once the new epoch begins.
|
||||
|
||||
▸ **expectedBlockTime**: `Moment`
|
||||
- **summary**: The expected average block time at which BABE should be creating blocks. Since BABE is probabilistic it is not trivial to figure out what the expected average block time should be based on the slot duration and the security parameter `c` (where `1 - c` represents the probability of a slot being empty).
|
||||
- **summary**: The expected average block time at which BABE should be creating blocks. Since BABE is probabilistic it is not trivial to figure out what the expected average block time should be based on the slot duration and the security parameter `c` (where `1 - c` represents the probability of a slot being empty).
|
||||
|
||||
___
|
||||
|
||||
@@ -41,19 +41,19 @@ ___
|
||||
### balances
|
||||
|
||||
▸ **creationFee**: `Balance`
|
||||
- **summary**: The fee required to create an account.
|
||||
- **summary**: The fee required to create an account.
|
||||
|
||||
▸ **existentialDeposit**: `Balance`
|
||||
- **summary**: The minimum amount required to keep an account open.
|
||||
- **summary**: The minimum amount required to keep an account open.
|
||||
|
||||
▸ **transactionBaseFee**: `Balance`
|
||||
- **summary**: The fee to be paid for making a transaction; the base.
|
||||
- **summary**: The fee to be paid for making a transaction; the base.
|
||||
|
||||
▸ **transactionByteFee**: `Balance`
|
||||
- **summary**: The fee to be paid for making a transaction; the per-byte portion.
|
||||
- **summary**: The fee to be paid for making a transaction; the per-byte portion.
|
||||
|
||||
▸ **transferFee**: `Balance`
|
||||
- **summary**: The fee required to make a transfer.
|
||||
- **summary**: The fee required to make a transfer.
|
||||
|
||||
___
|
||||
|
||||
@@ -61,52 +61,52 @@ ___
|
||||
### contracts
|
||||
|
||||
▸ **blockGasLimit**: `Gas`
|
||||
- **summary**: The maximum amount of gas that could be expended per block. A reasonable default value is 10_000_000.
|
||||
- **summary**: The maximum amount of gas that could be expended per block. A reasonable default value is 10_000_000.
|
||||
|
||||
▸ **callBaseFee**: `Gas`
|
||||
- **summary**: The base fee charged for calling into a contract. A reasonable default value is 135.
|
||||
- **summary**: The base fee charged for calling into a contract. A reasonable default value is 135.
|
||||
|
||||
▸ **contractFee**: `BalanceOf`
|
||||
- **summary**: The fee required to create a contract instance. A reasonable default value is 21.
|
||||
|
||||
▸ **createBaseFee**: `Gas`
|
||||
- **summary**: The base fee charged for creating a contract. A reasonable default value is 175.
|
||||
- **summary**: The fee required to instantiate a contract instance. A reasonable default value is 21.
|
||||
|
||||
▸ **creationFee**: `BalanceOf`
|
||||
- **summary**: The fee required to create an account.
|
||||
- **summary**: The fee required to create an account.
|
||||
|
||||
▸ **instantiateBaseFee**: `Gas`
|
||||
- **summary**: The base fee charged for instantiating a contract. A reasonable default value is 175.
|
||||
|
||||
▸ **maxDepth**: `u32`
|
||||
- **summary**: The maximum nesting level of a call/create stack. A reasonable default value is 100.
|
||||
- **summary**: The maximum nesting level of a call/instantiate stack. A reasonable default value is 100.
|
||||
|
||||
▸ **maxValueSize**: `u32`
|
||||
- **summary**: The maximum size of a storage value in bytes. A reasonable default is 16 KiB.
|
||||
- **summary**: The maximum size of a storage value in bytes. A reasonable default is 16 KiB.
|
||||
|
||||
▸ **rentByteFee**: `BalanceOf`
|
||||
- **summary**: Price of a byte of storage per one block interval. Should be greater than 0.
|
||||
- **summary**: Price of a byte of storage per one block interval. Should be greater than 0.
|
||||
|
||||
▸ **rentDepositOffset**: `BalanceOf`
|
||||
- **summary**: The amount of funds a contract should deposit in order to offset the cost of one byte. Let's suppose the deposit is 1,000 BU (balance units)/byte and the rent is 1 BU/byte/day, then a contract with 1,000,000 BU that uses 1,000 bytes of storage would pay no rent. But if the balance reduced to 500,000 BU and the storage stayed the same at 1,000, then it would pay 500 BU/day.
|
||||
- **summary**: The amount of funds a contract should deposit in order to offset the cost of one byte. Let's suppose the deposit is 1,000 BU (balance units)/byte and the rent is 1 BU/byte/day, then a contract with 1,000,000 BU that uses 1,000 bytes of storage would pay no rent. But if the balance reduced to 500,000 BU and the storage stayed the same at 1,000, then it would pay 500 BU/day.
|
||||
|
||||
▸ **signedClaimHandicap**: `BlockNumber`
|
||||
- **summary**: Number of block delay an extrinsic claim surcharge has. When claim surcharge is called by an extrinsic the rent is checked for current_block - delay
|
||||
- **summary**: Number of block delay an extrinsic claim surcharge has. When claim surcharge is called by an extrinsic the rent is checked for current_block - delay
|
||||
|
||||
▸ **storageSizeOffset**: `u32`
|
||||
- **summary**: Size of a contract at the time of creation. This is a simple way to ensure that empty contracts eventually gets deleted.
|
||||
- **summary**: Size of a contract at the time of instantiaion. This is a simple way to ensure that empty contracts eventually gets deleted.
|
||||
|
||||
▸ **surchargeReward**: `BalanceOf`
|
||||
- **summary**: Reward that is received by the party whose touch has led to removal of a contract.
|
||||
- **summary**: Reward that is received by the party whose touch has led to removal of a contract.
|
||||
|
||||
▸ **tombstoneDeposit**: `BalanceOf`
|
||||
- **summary**: The minimum amount required to generate a tombstone.
|
||||
- **summary**: The minimum amount required to generate a tombstone.
|
||||
|
||||
▸ **transactionBaseFee**: `BalanceOf`
|
||||
- **summary**: The fee to be paid for making a transaction; the base.
|
||||
- **summary**: The fee to be paid for making a transaction; the base.
|
||||
|
||||
▸ **transactionByteFee**: `BalanceOf`
|
||||
- **summary**: The fee to be paid for making a transaction; the per-byte portion.
|
||||
- **summary**: The fee to be paid for making a transaction; the per-byte portion.
|
||||
|
||||
▸ **transferFee**: `BalanceOf`
|
||||
- **summary**: The fee required to make a transfer.
|
||||
- **summary**: The fee required to make a transfer.
|
||||
|
||||
___
|
||||
|
||||
@@ -114,22 +114,22 @@ ___
|
||||
### democracy
|
||||
|
||||
▸ **cooloffPeriod**: `BlockNumber`
|
||||
- **summary**: Period in blocks where an external proposal may not be re-submitted after being vetoed.
|
||||
- **summary**: Period in blocks where an external proposal may not be re-submitted after being vetoed.
|
||||
|
||||
▸ **emergencyVotingPeriod**: `BlockNumber`
|
||||
- **summary**: Minimum voting period allowed for an emergency referendum.
|
||||
- **summary**: Minimum voting period allowed for an emergency referendum.
|
||||
|
||||
▸ **enactmentPeriod**: `BlockNumber`
|
||||
- **summary**: The minimum period of locking and the period between a proposal being approved and enacted. It should generally be a little more than the unstake period to ensure that voting stakers have an opportunity to remove themselves from the system in the case where they are on the losing side of a vote.
|
||||
- **summary**: The minimum period of locking and the period between a proposal being approved and enacted. It should generally be a little more than the unstake period to ensure that voting stakers have an opportunity to remove themselves from the system in the case where they are on the losing side of a vote.
|
||||
|
||||
▸ **launchPeriod**: `BlockNumber`
|
||||
- **summary**: How often (in blocks) new public referenda are launched.
|
||||
- **summary**: How often (in blocks) new public referenda are launched.
|
||||
|
||||
▸ **minimumDeposit**: `BalanceOf`
|
||||
- **summary**: The minimum amount to be used as a deposit for a public referendum proposal.
|
||||
- **summary**: The minimum amount to be used as a deposit for a public referendum proposal.
|
||||
|
||||
▸ **votingPeriod**: `BlockNumber`
|
||||
- **summary**: How often (in blocks) to check for new votes.
|
||||
- **summary**: How often (in blocks) to check for new votes.
|
||||
|
||||
___
|
||||
|
||||
@@ -137,34 +137,37 @@ ___
|
||||
### elections
|
||||
|
||||
▸ **approvalSetSize**: `u32`
|
||||
- **summary**: The chunk size of the approval vector.
|
||||
- **summary**: The chunk size of the approval vector.
|
||||
|
||||
▸ **candidacyBond**: `BalanceOf`
|
||||
- **summary**: How much should be locked up in order to submit one's candidacy. A reasonable default value is 9.
|
||||
- **summary**: How much should be locked up in order to submit one's candidacy. A reasonable default value is 9.
|
||||
|
||||
▸ **carryCount**: `u32`
|
||||
- **summary**: How many runners-up should have their approvals persist until the next vote. A reasonable default value is 2.
|
||||
- **summary**: How many runners-up should have their approvals persist until the next vote. A reasonable default value is 2.
|
||||
|
||||
▸ **decayRatio**: `u32`
|
||||
- **summary**: Decay factor of weight when being accumulated. It should typically be set to __at least__ `membership_size -1` to keep the collective secure. When set to `N`, it indicates `(1/N)^t` of staked is decayed at weight increment step `t`. 0 will result in no weight being added at all (normal approval voting). A reasonable default value is 24.
|
||||
- **summary**: Decay factor of weight when being accumulated. It should typically be set to __at least__ `membership_size -1` to keep the collective secure. When set to `N`, it indicates `(1/N)^t` of staked is decayed at weight increment step `t`. 0 will result in no weight being added at all (normal approval voting). A reasonable default value is 24.
|
||||
|
||||
▸ **inactiveGracePeriod**: `VoteIndex`
|
||||
- **summary**: How many vote indices need to go by after a target voter's last vote before they can be reaped if their approvals are moot. A reasonable default value is 1.
|
||||
- **summary**: How many vote indices need to go by after a target voter's last vote before they can be reaped if their approvals are moot. A reasonable default value is 1.
|
||||
|
||||
▸ **minimumVotingLock**: `BalanceOf`
|
||||
- **summary**: Minimum about that can be used as the locked value for voting.
|
||||
|
||||
▸ **presentSlashPerVoter**: `BalanceOf`
|
||||
- **summary**: The punishment, per voter, if you provide an invalid presentation. A reasonable default value is 1.
|
||||
- **summary**: The punishment, per voter, if you provide an invalid presentation. A reasonable default value is 1.
|
||||
|
||||
▸ **voterSetSize**: `u32`
|
||||
- **summary**: The chunk size of the voter vector.
|
||||
- **summary**: The chunk size of the voter vector.
|
||||
|
||||
▸ **votingBond**: `BalanceOf`
|
||||
- **summary**: How much should be locked up in order to be able to submit votes.
|
||||
- **summary**: How much should be locked up in order to be able to submit votes.
|
||||
|
||||
▸ **votingFee**: `BalanceOf`
|
||||
- **summary**: The amount of fee paid upon each vote submission, unless if they submit a _hole_ index and replace it.
|
||||
- **summary**: The amount of fee paid upon each vote submission, unless if they submit a _hole_ index and replace it.
|
||||
|
||||
▸ **votingPeriod**: `BlockNumber`
|
||||
- **summary**: How often (in blocks) to check for new votes. A reasonable default value is 1000.
|
||||
- **summary**: How often (in blocks) to check for new votes. A reasonable default value is 1000.
|
||||
|
||||
___
|
||||
|
||||
@@ -172,10 +175,10 @@ ___
|
||||
### finalityTracker
|
||||
|
||||
▸ **reportLatency**: `BlockNumber`
|
||||
- **summary**: The delay after which point things become suspicious. Default is 1000.
|
||||
- **summary**: The delay after which point things become suspicious. Default is 1000.
|
||||
|
||||
▸ **windowSize**: `BlockNumber`
|
||||
- **summary**: The number of recent samples to keep from this chain. Default is 101.
|
||||
- **summary**: The number of recent samples to keep from this chain. Default is 101.
|
||||
|
||||
___
|
||||
|
||||
@@ -183,7 +186,7 @@ ___
|
||||
### session
|
||||
|
||||
▸ **dedupKeyPrefix**: `Bytes`
|
||||
- **summary**: Used as first key for `NextKeys` and `KeyOwner` to put all the data into the same branch of the trie.
|
||||
- **summary**: Used as first key for `NextKeys` and `KeyOwner` to put all the data into the same branch of the trie.
|
||||
|
||||
___
|
||||
|
||||
@@ -191,10 +194,10 @@ ___
|
||||
### staking
|
||||
|
||||
▸ **bondingDuration**: `EraIndex`
|
||||
- **summary**: Number of eras that staked funds must remain bonded for.
|
||||
- **summary**: Number of eras that staked funds must remain bonded for.
|
||||
|
||||
▸ **sessionsPerEra**: `SessionIndex`
|
||||
- **summary**: Number of sessions per era.
|
||||
- **summary**: Number of sessions per era.
|
||||
|
||||
___
|
||||
|
||||
@@ -202,7 +205,7 @@ ___
|
||||
### timestamp
|
||||
|
||||
▸ **minimumPeriod**: `Moment`
|
||||
- **summary**: The minimum period between blocks. Beware that this is different to the *expected* period that the block production apparatus provides. Your chosen consensus system will generally work with this to determine a sensible block time. e.g. For Aura, it will be double this period on default settings.
|
||||
- **summary**: The minimum period between blocks. Beware that this is different to the *expected* period that the block production apparatus provides. Your chosen consensus system will generally work with this to determine a sensible block time. e.g. For Aura, it will be double this period on default settings.
|
||||
|
||||
___
|
||||
|
||||
@@ -210,13 +213,13 @@ ___
|
||||
### treasury
|
||||
|
||||
▸ **burn**: `Permill`
|
||||
- **summary**: Percentage of spare funds (if any) that are burnt per spend period.
|
||||
- **summary**: Percentage of spare funds (if any) that are burnt per spend period.
|
||||
|
||||
▸ **proposalBond**: `Permill`
|
||||
- **summary**: Fraction of a proposal's value that should be bonded in order to place the proposal. An accepted proposal gets these back. A rejected proposal does not.
|
||||
- **summary**: Fraction of a proposal's value that should be bonded in order to place the proposal. An accepted proposal gets these back. A rejected proposal does not.
|
||||
|
||||
▸ **proposalBondMinimum**: `BalanceOf`
|
||||
- **summary**: Minimum amount of funds that should be placed in a deposit for making a proposal.
|
||||
- **summary**: Minimum amount of funds that should be placed in a deposit for making a proposal.
|
||||
|
||||
▸ **spendPeriod**: `BlockNumber`
|
||||
- **summary**: Period between successive spends.
|
||||
- **summary**: Period between successive spends.
|
||||
|
||||
+61
-49
@@ -35,6 +35,8 @@ Events are emitted for certain operations on the runtime. The following sections
|
||||
|
||||
- **[treasury](#treasury)**
|
||||
|
||||
- **[utility](#utility)**
|
||||
|
||||
|
||||
___
|
||||
|
||||
@@ -42,13 +44,13 @@ ___
|
||||
### balances
|
||||
|
||||
▸ **NewAccount**(`AccountId`, `Balance`)
|
||||
- **summary**: A new account was created.
|
||||
- **summary**: A new account was created.
|
||||
|
||||
▸ **ReapedAccount**(`AccountId`)
|
||||
- **summary**: An account was reaped.
|
||||
- **summary**: An account was reaped.
|
||||
|
||||
▸ **Transfer**(`AccountId`, `AccountId`, `Balance`, `Balance`)
|
||||
- **summary**: Transfer succeeded (from, to, value, fees).
|
||||
- **summary**: Transfer succeeded (from, to, value, fees).
|
||||
|
||||
___
|
||||
|
||||
@@ -56,22 +58,22 @@ ___
|
||||
### contracts
|
||||
|
||||
▸ **CodeStored**(`Hash`)
|
||||
- **summary**: Code with the specified hash has been stored.
|
||||
- **summary**: Code with the specified hash has been stored.
|
||||
|
||||
▸ **Contract**(`AccountId`, `Bytes`)
|
||||
- **summary**: An event from contract of account.
|
||||
- **summary**: An event from contract of account.
|
||||
|
||||
▸ **Dispatched**(`AccountId`, `bool`)
|
||||
- **summary**: A call was dispatched from the given account. The bool signals whether it was successful execution or not.
|
||||
- **summary**: A call was dispatched from the given account. The bool signals whether it was successful execution or not.
|
||||
|
||||
▸ **Instantiated**(`AccountId`, `AccountId`)
|
||||
- **summary**: Contract deployed by address at the specified address.
|
||||
- **summary**: Contract deployed by address at the specified address.
|
||||
|
||||
▸ **ScheduleUpdated**(`u32`)
|
||||
- **summary**: Triggered when the current schedule is updated.
|
||||
- **summary**: Triggered when the current schedule is updated.
|
||||
|
||||
▸ **Transfer**(`AccountId`, `AccountId`, `Balance`)
|
||||
- **summary**: Transfer happened `from` to `to` with given `value` as part of a `call` or `create`.
|
||||
- **summary**: Transfer happened `from` to `to` with given `value` as part of a `call` or `instantiate`.
|
||||
|
||||
___
|
||||
|
||||
@@ -79,22 +81,22 @@ ___
|
||||
### council
|
||||
|
||||
▸ **Approved**(`Hash`)
|
||||
- **summary**: A motion was approved by the required threshold.
|
||||
- **summary**: A motion was approved by the required threshold.
|
||||
|
||||
▸ **Disapproved**(`Hash`)
|
||||
- **summary**: A motion was not approved by the required threshold.
|
||||
- **summary**: A motion was not approved by the required threshold.
|
||||
|
||||
▸ **Executed**(`Hash`, `bool`)
|
||||
- **summary**: A motion was executed; `bool` is true if returned without error.
|
||||
- **summary**: A motion was executed; `bool` is true if returned without error.
|
||||
|
||||
▸ **MemberExecuted**(`Hash`, `bool`)
|
||||
- **summary**: A single member did some action; `bool` is true if returned without error.
|
||||
- **summary**: A single member did some action; `bool` is true if returned without error.
|
||||
|
||||
▸ **Proposed**(`AccountId`, `ProposalIndex`, `Hash`, `MemberCount`)
|
||||
- **summary**: A motion (given hash) has been proposed (by given account) with a threshold (given `MemberCount`).
|
||||
- **summary**: A motion (given hash) has been proposed (by given account) with a threshold (given `MemberCount`).
|
||||
|
||||
▸ **Voted**(`AccountId`, `Hash`, `bool`, `MemberCount`, `MemberCount`)
|
||||
- **summary**: A motion (given hash) has been voted on by given account, leaving a tally (yes votes and no votes given respectively as `MemberCount`).
|
||||
- **summary**: A motion (given hash) has been voted on by given account, leaving a tally (yes votes and no votes given respectively as `MemberCount`).
|
||||
|
||||
___
|
||||
|
||||
@@ -129,16 +131,16 @@ ___
|
||||
### elections
|
||||
|
||||
▸ **BadReaperSlashed**(`AccountId`)
|
||||
- **summary**: slashed reaper
|
||||
- **summary**: slashed reaper
|
||||
|
||||
▸ **TallyFinalized**(`Vec<AccountId>`, `Vec<AccountId>`)
|
||||
- **summary**: A tally (for approval votes of seat(s)) has ended (with one or more new members).
|
||||
- **summary**: A tally (for approval votes of seat(s)) has ended (with one or more new members).
|
||||
|
||||
▸ **TallyStarted**(`u32`)
|
||||
- **summary**: A tally (for approval votes of seat(s)) has started.
|
||||
- **summary**: A tally (for approval votes of seat(s)) has started.
|
||||
|
||||
▸ **VoterReaped**(`AccountId`, `AccountId`)
|
||||
- **summary**: reaped voter, reaper
|
||||
- **summary**: reaped voter, reaper
|
||||
|
||||
___
|
||||
|
||||
@@ -146,13 +148,13 @@ ___
|
||||
### grandpa
|
||||
|
||||
▸ **NewAuthorities**(`Vec<(AuthorityId,AuthorityWeight)>`)
|
||||
- **summary**: New authority set has been applied.
|
||||
- **summary**: New authority set has been applied.
|
||||
|
||||
▸ **Paused**()
|
||||
- **summary**: Current authority set has been paused.
|
||||
- **summary**: Current authority set has been paused.
|
||||
|
||||
▸ **Resumed**()
|
||||
- **summary**: Current authority set has been resumed.
|
||||
- **summary**: Current authority set has been resumed.
|
||||
|
||||
___
|
||||
|
||||
@@ -160,7 +162,7 @@ ___
|
||||
### imOnline
|
||||
|
||||
▸ **HeartbeatReceived**(`AuthorityId`)
|
||||
- **summary**: A new heartbeat was received from `AuthorityId`
|
||||
- **summary**: A new heartbeat was received from `AuthorityId`
|
||||
|
||||
___
|
||||
|
||||
@@ -168,7 +170,7 @@ ___
|
||||
### indices
|
||||
|
||||
▸ **NewAccountIndex**(`AccountId`, `AccountIndex`)
|
||||
- **summary**: A new account index was assigned. This event is not triggered when an existing index is reassigned to another `AccountId`.
|
||||
- **summary**: A new account index was assigned. This event is not triggered when an existing index is reassigned to another `AccountId`.
|
||||
|
||||
___
|
||||
|
||||
@@ -176,7 +178,7 @@ ___
|
||||
### offences
|
||||
|
||||
▸ **Offence**(`Kind`, `OpaqueTimeSlot`)
|
||||
- **summary**: There is an offence reported of the given `kind` happened at the `session_index` and (kind-specific) time slot. This event is not deposited for duplicate slashes.
|
||||
- **summary**: There is an offence reported of the given `kind` happened at the `session_index` and (kind-specific) time slot. This event is not deposited for duplicate slashes.
|
||||
|
||||
___
|
||||
|
||||
@@ -184,7 +186,7 @@ ___
|
||||
### session
|
||||
|
||||
▸ **NewSession**(`SessionIndex`)
|
||||
- **summary**: New session has happened. Note that the argument is the session index, not the block number as the type might suggest.
|
||||
- **summary**: New session has happened. Note that the argument is the session index, not the block number as the type might suggest.
|
||||
|
||||
___
|
||||
|
||||
@@ -192,13 +194,13 @@ ___
|
||||
### staking
|
||||
|
||||
▸ **OldSlashingReportDiscarded**(`SessionIndex`)
|
||||
- **summary**: An old slashing report from a prior era was discarded because it could not be processed.
|
||||
- **summary**: An old slashing report from a prior era was discarded because it could not be processed.
|
||||
|
||||
▸ **Reward**(`Balance`)
|
||||
- **summary**: All validators have been rewarded by the given balance.
|
||||
- **summary**: All validators have been rewarded by the given balance.
|
||||
|
||||
▸ **Slash**(`AccountId`, `Balance`)
|
||||
- **summary**: One validator (and its nominators) has been slashed by the given amount.
|
||||
- **summary**: One validator (and its nominators) has been slashed by the given amount.
|
||||
|
||||
___
|
||||
|
||||
@@ -206,10 +208,13 @@ ___
|
||||
### sudo
|
||||
|
||||
▸ **KeyChanged**(`AccountId`)
|
||||
- **summary**: The sudoer just switched identity; the old key is supplied.
|
||||
- **summary**: The sudoer just switched identity; the old key is supplied.
|
||||
|
||||
▸ **Sudid**(`bool`)
|
||||
- **summary**: A sudo just took place.
|
||||
- **summary**: A sudo just took place.
|
||||
|
||||
▸ **SudoAsDone**(`bool`)
|
||||
- **summary**: A sudo just took place.
|
||||
|
||||
___
|
||||
|
||||
@@ -217,10 +222,10 @@ ___
|
||||
### system
|
||||
|
||||
▸ **ExtrinsicFailed**(`DispatchError`)
|
||||
- **summary**: An extrinsic failed.
|
||||
- **summary**: An extrinsic failed.
|
||||
|
||||
▸ **ExtrinsicSuccess**()
|
||||
- **summary**: An extrinsic completed successfully.
|
||||
- **summary**: An extrinsic completed successfully.
|
||||
|
||||
___
|
||||
|
||||
@@ -228,22 +233,22 @@ ___
|
||||
### technicalCommittee
|
||||
|
||||
▸ **Approved**(`Hash`)
|
||||
- **summary**: A motion was approved by the required threshold.
|
||||
- **summary**: A motion was approved by the required threshold.
|
||||
|
||||
▸ **Disapproved**(`Hash`)
|
||||
- **summary**: A motion was not approved by the required threshold.
|
||||
- **summary**: A motion was not approved by the required threshold.
|
||||
|
||||
▸ **Executed**(`Hash`, `bool`)
|
||||
- **summary**: A motion was executed; `bool` is true if returned without error.
|
||||
- **summary**: A motion was executed; `bool` is true if returned without error.
|
||||
|
||||
▸ **MemberExecuted**(`Hash`, `bool`)
|
||||
- **summary**: A single member did some action; `bool` is true if returned without error.
|
||||
- **summary**: A single member did some action; `bool` is true if returned without error.
|
||||
|
||||
▸ **Proposed**(`AccountId`, `ProposalIndex`, `Hash`, `MemberCount`)
|
||||
- **summary**: A motion (given hash) has been proposed (by given account) with a threshold (given `MemberCount`).
|
||||
- **summary**: A motion (given hash) has been proposed (by given account) with a threshold (given `MemberCount`).
|
||||
|
||||
▸ **Voted**(`AccountId`, `Hash`, `bool`, `MemberCount`, `MemberCount`)
|
||||
- **summary**: A motion (given hash) has been voted on by given account, leaving a tally (yes votes and no votes given respectively as `MemberCount`).
|
||||
- **summary**: A motion (given hash) has been voted on by given account, leaving a tally (yes votes and no votes given respectively as `MemberCount`).
|
||||
|
||||
___
|
||||
|
||||
@@ -251,19 +256,19 @@ ___
|
||||
### technicalMembership
|
||||
|
||||
▸ **Dummy**(`PhantomData`)
|
||||
- **summary**: Phantom member, never used.
|
||||
- **summary**: Phantom member, never used.
|
||||
|
||||
▸ **MemberAdded**()
|
||||
- **summary**: The given member was added; see the transaction for who.
|
||||
- **summary**: The given member was added; see the transaction for who.
|
||||
|
||||
▸ **MemberRemoved**()
|
||||
- **summary**: The given member was removed; see the transaction for who.
|
||||
- **summary**: The given member was removed; see the transaction for who.
|
||||
|
||||
▸ **MembersReset**()
|
||||
- **summary**: The membership was reset; see the transaction for who the new set is.
|
||||
- **summary**: The membership was reset; see the transaction for who the new set is.
|
||||
|
||||
▸ **MembersSwapped**()
|
||||
- **summary**: Two members were swapped; see the transaction for who.
|
||||
- **summary**: Two members were swapped; see the transaction for who.
|
||||
|
||||
___
|
||||
|
||||
@@ -271,16 +276,23 @@ ___
|
||||
### treasury
|
||||
|
||||
▸ **Awarded**(`ProposalIndex`, `Balance`, `AccountId`)
|
||||
- **summary**: Some funds have been allocated.
|
||||
- **summary**: Some funds have been allocated.
|
||||
|
||||
▸ **Burnt**(`Balance`)
|
||||
- **summary**: Some of our funds have been burnt.
|
||||
- **summary**: Some of our funds have been burnt.
|
||||
|
||||
▸ **Proposed**(`ProposalIndex`)
|
||||
- **summary**: New proposal.
|
||||
- **summary**: New proposal.
|
||||
|
||||
▸ **Rollover**(`Balance`)
|
||||
- **summary**: Spending has finished; this is the amount that rolls over until next spend.
|
||||
- **summary**: Spending has finished; this is the amount that rolls over until next spend.
|
||||
|
||||
▸ **Spending**(`Balance`)
|
||||
- **summary**: We have ended a spend period and will now allocate funds.
|
||||
- **summary**: We have ended a spend period and will now allocate funds.
|
||||
|
||||
___
|
||||
|
||||
|
||||
### utility
|
||||
|
||||
▸ **BatchExecuted**(`Vec<DispatchResult>`)
|
||||
|
||||
@@ -5,8 +5,6 @@ The following sections contain Extrinsics methods are part of the default Substr
|
||||
(NOTE: These were generated from a static/snapshot view of a recent Substrate master node. Some items may not be available in older nodes, or in any customized implementations.)
|
||||
- **[authorship](#authorship)**
|
||||
|
||||
- **[babe](#babe)**
|
||||
|
||||
- **[balances](#balances)**
|
||||
|
||||
- **[contracts](#contracts)**
|
||||
@@ -39,6 +37,8 @@ The following sections contain Extrinsics methods are part of the default Substr
|
||||
|
||||
- **[treasury](#treasury)**
|
||||
|
||||
- **[utility](#utility)**
|
||||
|
||||
|
||||
___
|
||||
|
||||
@@ -46,15 +46,7 @@ ___
|
||||
### authorship
|
||||
|
||||
▸ **setUncles**(new_uncles: `Vec<Header>`)
|
||||
- **summary**: Provide a set of uncles.
|
||||
|
||||
___
|
||||
|
||||
|
||||
### babe
|
||||
|
||||
▸ **setPendingSecondarySlotsChange**(change: `Option<bool>`)
|
||||
- **summary**: Sets a pending change to enable / disable secondary slot assignment. The pending change will be set at the end of the current epoch and will be enacted at `current_epoch + 2`.
|
||||
- **summary**: Provide a set of uncles.
|
||||
|
||||
___
|
||||
|
||||
@@ -62,13 +54,13 @@ ___
|
||||
### balances
|
||||
|
||||
▸ **forceTransfer**(source: `Address`, dest: `Address`, value: `Compact<Balance>`)
|
||||
- **summary**: Exactly as `transfer`, except the origin must be root and the source account may be specified.
|
||||
- **summary**: Exactly as `transfer`, except the origin must be root and the source account may be specified.
|
||||
|
||||
▸ **setBalance**(who: `Address`, new_free: `Compact<Balance>`, new_reserved: `Compact<Balance>`)
|
||||
- **summary**: Set the balances of a given account. This will alter `FreeBalance` and `ReservedBalance` in storage. it will also decrease the total issuance of the system (`TotalIssuance`). If the new free or reserved balance is below the existential deposit, it will reset the account nonce (`system::AccountNonce`). The dispatch origin for this call is `root`. # <weight> - Independent of the arguments. - Contains a limited number of reads and writes. # </weight>
|
||||
- **summary**: Set the balances of a given account. This will alter `FreeBalance` and `ReservedBalance` in storage. it will also decrease the total issuance of the system (`TotalIssuance`). If the new free or reserved balance is below the existential deposit, it will reset the account nonce (`system::AccountNonce`). The dispatch origin for this call is `root`. # <weight> - Independent of the arguments. - Contains a limited number of reads and writes. # </weight>
|
||||
|
||||
▸ **transfer**(dest: `Address`, value: `Compact<Balance>`)
|
||||
- **summary**: Transfer some liquid free balance to another account. `transfer` will set the `FreeBalance` of the sender and receiver. It will decrease the total issuance of the system by the `TransferFee`. If the sender's account is below the existential deposit as a result of the transfer, the account will be reaped. The dispatch origin for this call must be `Signed` by the transactor. # <weight> - Dependent on arguments but not critical, given proper implementations for input config types. See related functions below. - It contains a limited number of reads and writes internally and no complex computation. Related functions: - `ensure_can_withdraw` is always called internally but has a bounded complexity. - Transferring balances to accounts that did not exist before will cause `T::OnNewAccount::on_new_account` to be called. - Removing enough funds from an account will trigger `T::DustRemoval::on_unbalanced` and `T::OnFreeBalanceZero::on_free_balance_zero`. # </weight>
|
||||
- **summary**: Transfer some liquid free balance to another account. `transfer` will set the `FreeBalance` of the sender and receiver. It will decrease the total issuance of the system by the `TransferFee`. If the sender's account is below the existential deposit as a result of the transfer, the account will be reaped. The dispatch origin for this call must be `Signed` by the transactor. # <weight> - Dependent on arguments but not critical, given proper implementations for input config types. See related functions below. - It contains a limited number of reads and writes internally and no complex computation. Related functions: - `ensure_can_withdraw` is always called internally but has a bounded complexity. - Transferring balances to accounts that did not exist before will cause `T::OnNewAccount::on_new_account` to be called. - Removing enough funds from an account will trigger `T::DustRemoval::on_unbalanced` and `T::OnFreeBalanceZero::on_free_balance_zero`. # </weight>
|
||||
|
||||
___
|
||||
|
||||
@@ -76,19 +68,19 @@ ___
|
||||
### contracts
|
||||
|
||||
▸ **call**(dest: `Address`, value: `Compact<BalanceOf>`, gas_limit: `Compact<Gas>`, data: `Bytes`)
|
||||
- **summary**: Makes a call to an account, optionally transferring some balance. * If the account is a smart-contract account, the associated code will be executed and any value will be transferred. * If the account is a regular account, any value will be transferred. * If no account exists and the call value is not less than `existential_deposit`, a regular account will be created and any value will be transferred.
|
||||
- **summary**: Makes a call to an account, optionally transferring some balance. * If the account is a smart-contract account, the associated code will be executed and any value will be transferred. * If the account is a regular account, any value will be transferred. * If no account exists and the call value is not less than `existential_deposit`, a regular account will be created and any value will be transferred.
|
||||
|
||||
▸ **claimSurcharge**(dest: `AccountId`, aux_sender: `Option<AccountId>`)
|
||||
- **summary**: Allows block producers to claim a small reward for evicting a contract. If a block producer fails to do so, a regular users will be allowed to claim the reward. If contract is not evicted as a result of this call, no actions are taken and the sender is not eligible for the reward.
|
||||
- **summary**: Allows block producers to claim a small reward for evicting a contract. If a block producer fails to do so, a regular users will be allowed to claim the reward. If contract is not evicted as a result of this call, no actions are taken and the sender is not eligible for the reward.
|
||||
|
||||
▸ **create**(endowment: `Compact<BalanceOf>`, gas_limit: `Compact<Gas>`, code_hash: `CodeHash`, data: `Bytes`)
|
||||
- **summary**: Creates a new contract from the `codehash` generated by `put_code`, optionally transferring some balance. Creation is executed as follows: - The destination address is computed based on the sender and hash of the code. - The smart-contract account is created at the computed address. - The `ctor_code` is executed in the context of the newly-created account. Buffer returned after the execution is saved as the `code` of the account. That code will be invoked upon any call received by this account. - The contract is initialized.
|
||||
▸ **instantiate**(endowment: `Compact<BalanceOf>`, gas_limit: `Compact<Gas>`, code_hash: `CodeHash`, data: `Bytes`)
|
||||
- **summary**: Instantiates a new contract from the `codehash` generated by `put_code`, optionally transferring some balance. Instantiation is executed as follows: - The destination address is computed based on the sender and hash of the code. - The smart-contract account is created at the computed address. - The `ctor_code` is executed in the context of the newly-created account. Buffer returned after the execution is saved as the `code` of the account. That code will be invoked upon any call received by this account. - The contract is initialized.
|
||||
|
||||
▸ **putCode**(gas_limit: `Compact<Gas>`, code: `Bytes`)
|
||||
- **summary**: Stores the given binary Wasm code into the chain's storage and returns its `codehash`. You can instantiate contracts only with stored code.
|
||||
- **summary**: Stores the given binary Wasm code into the chain's storage and returns its `codehash`. You can instantiate contracts only with stored code.
|
||||
|
||||
▸ **updateSchedule**(schedule: `Schedule`)
|
||||
- **summary**: Updates the schedule for metering contracts. The schedule must have a greater version than the stored schedule.
|
||||
- **summary**: Updates the schedule for metering contracts. The schedule must have a greater version than the stored schedule.
|
||||
|
||||
___
|
||||
|
||||
@@ -96,16 +88,16 @@ ___
|
||||
### council
|
||||
|
||||
▸ **execute**(proposal: `Proposal`)
|
||||
- **summary**: Dispatch a proposal from a member using the `Member` origin. Origin must be a member of the collective.
|
||||
- **summary**: Dispatch a proposal from a member using the `Member` origin. Origin must be a member of the collective.
|
||||
|
||||
▸ **propose**(threshold: `Compact<MemberCount>`, proposal: `Proposal`)
|
||||
- **summary**: # <weight> - Bounded storage reads and writes. - Argument `threshold` has bearing on weight. # </weight>
|
||||
- **summary**: # <weight> - Bounded storage reads and writes. - Argument `threshold` has bearing on weight. # </weight>
|
||||
|
||||
▸ **setMembers**(new_members: `Vec<AccountId>`)
|
||||
- **summary**: Set the collective's membership manually to `new_members`. Be nice to the chain and provide it pre-sorted. Requires root origin.
|
||||
- **summary**: Set the collective's membership manually to `new_members`. Be nice to the chain and provide it pre-sorted. Requires root origin.
|
||||
|
||||
▸ **vote**(proposal: `Hash`, index: `Compact<ProposalIndex>`, approve: `bool`)
|
||||
- **summary**: # <weight> - Bounded storage read and writes. - Will be slightly heavier if the proposal is approved / disapproved after the vote. # </weight>
|
||||
- **summary**: # <weight> - Bounded storage read and writes. - Will be slightly heavier if the proposal is approved / disapproved after the vote. # </weight>
|
||||
|
||||
___
|
||||
|
||||
@@ -113,55 +105,55 @@ ___
|
||||
### democracy
|
||||
|
||||
▸ **cancelQueued**(when: `Compact<BlockNumber>`, which: `Compact<u32>`, what: `Compact<ReferendumIndex>`)
|
||||
- **summary**: Cancel a proposal queued for enactment.
|
||||
- **summary**: Cancel a proposal queued for enactment.
|
||||
|
||||
▸ **cancelReferendum**(ref_index: `Compact<ReferendumIndex>`)
|
||||
- **summary**: Remove a referendum.
|
||||
- **summary**: Remove a referendum.
|
||||
|
||||
▸ **delegate**(to: `AccountId`, conviction: `Conviction`)
|
||||
- **summary**: Delegate vote. # <weight> - One extra DB entry. # </weight>
|
||||
- **summary**: Delegate vote. # <weight> - One extra DB entry. # </weight>
|
||||
|
||||
▸ **emergencyCancel**(ref_index: `ReferendumIndex`)
|
||||
- **summary**: Schedule an emergency cancellation of a referendum. Cannot happen twice to the same referendum.
|
||||
- **summary**: Schedule an emergency cancellation of a referendum. Cannot happen twice to the same referendum.
|
||||
|
||||
▸ **externalPropose**(proposal: `Proposal`)
|
||||
- **summary**: Schedule a referendum to be tabled once it is legal to schedule an external referendum.
|
||||
- **summary**: Schedule a referendum to be tabled once it is legal to schedule an external referendum.
|
||||
|
||||
▸ **externalProposeDefault**(proposal: `Proposal`)
|
||||
- **summary**: Schedule a negative-turnout-bias referendum to be tabled next once it is legal to schedule an external referendum. Unlike `external_propose`, blacklisting has no effect on this and it may replace a pre-scheduled `external_propose` call.
|
||||
- **summary**: Schedule a negative-turnout-bias referendum to be tabled next once it is legal to schedule an external referendum. Unlike `external_propose`, blacklisting has no effect on this and it may replace a pre-scheduled `external_propose` call.
|
||||
|
||||
▸ **externalProposeMajority**(proposal: `Proposal`)
|
||||
- **summary**: Schedule a majority-carries referendum to be tabled next once it is legal to schedule an external referendum. Unlike `external_propose`, blacklisting has no effect on this and it may replace a pre-scheduled `external_propose` call.
|
||||
- **summary**: Schedule a majority-carries referendum to be tabled next once it is legal to schedule an external referendum. Unlike `external_propose`, blacklisting has no effect on this and it may replace a pre-scheduled `external_propose` call.
|
||||
|
||||
▸ **fastTrack**(proposal_hash: `Hash`, voting_period: `BlockNumber`, delay: `BlockNumber`)
|
||||
- **summary**: Schedule the currently externally-proposed majority-carries referendum to be tabled immediately. If there is no externally-proposed referendum currently, or if there is one but it is not a majority-carries referendum then it fails. - `proposal_hash`: The hash of the current external proposal. - `voting_period`: The period that is allowed for voting on this proposal. - `delay`: The number of block after voting has ended in approval and this should be enacted. Increased to `EmergencyVotingPeriod` if too low.
|
||||
- **summary**: Schedule the currently externally-proposed majority-carries referendum to be tabled immediately. If there is no externally-proposed referendum currently, or if there is one but it is not a majority-carries referendum then it fails. - `proposal_hash`: The hash of the current external proposal. - `voting_period`: The period that is allowed for voting on this proposal. - `delay`: The number of block after voting has ended in approval and this should be enacted. Increased to `EmergencyVotingPeriod` if too low.
|
||||
|
||||
▸ **propose**(proposal: `Proposal`, value: `Compact<BalanceOf>`)
|
||||
- **summary**: Propose a sensitive action to be taken. # <weight> - O(1). - Two DB changes, one DB entry. # </weight>
|
||||
- **summary**: Propose a sensitive action to be taken. # <weight> - O(1). - Two DB changes, one DB entry. # </weight>
|
||||
|
||||
▸ **proxyVote**(ref_index: `Compact<ReferendumIndex>`, vote: `Vote`)
|
||||
- **summary**: Vote in a referendum on behalf of a stash. If `vote.is_aye()`, the vote is to enact the proposal; otherwise it is a vote to keep the status quo. # <weight> - O(1). - One DB change, one DB entry. # </weight>
|
||||
- **summary**: Vote in a referendum on behalf of a stash. If `vote.is_aye()`, the vote is to enact the proposal; otherwise it is a vote to keep the status quo. # <weight> - O(1). - One DB change, one DB entry. # </weight>
|
||||
|
||||
▸ **removeProxy**(proxy: `AccountId`)
|
||||
- **summary**: Clear the proxy. Called by the stash. # <weight> - One DB clear. # </weight>
|
||||
- **summary**: Clear the proxy. Called by the stash. # <weight> - One DB clear. # </weight>
|
||||
|
||||
▸ **resignProxy**()
|
||||
- **summary**: Clear the proxy. Called by the proxy. # <weight> - One DB clear. # </weight>
|
||||
- **summary**: Clear the proxy. Called by the proxy. # <weight> - One DB clear. # </weight>
|
||||
|
||||
▸ **second**(proposal: `Compact<PropIndex>`)
|
||||
- **summary**: Propose a sensitive action to be taken. # <weight> - O(1). - One DB entry. # </weight>
|
||||
- **summary**: Propose a sensitive action to be taken. # <weight> - O(1). - One DB entry. # </weight>
|
||||
|
||||
▸ **setProxy**(proxy: `AccountId`)
|
||||
- **summary**: Specify a proxy. Called by the stash. # <weight> - One extra DB entry. # </weight>
|
||||
- **summary**: Specify a proxy. Called by the stash. # <weight> - One extra DB entry. # </weight>
|
||||
|
||||
▸ **undelegate**()
|
||||
- **summary**: Undelegate vote. # <weight> - O(1). # </weight>
|
||||
- **summary**: Undelegate vote. # <weight> - O(1). # </weight>
|
||||
|
||||
▸ **vetoExternal**(proposal_hash: `Hash`)
|
||||
- **summary**: Veto and blacklist the external proposal hash.
|
||||
- **summary**: Veto and blacklist the external proposal hash.
|
||||
|
||||
▸ **vote**(ref_index: `Compact<ReferendumIndex>`, vote: `Vote`)
|
||||
- **summary**: Vote in a referendum. If `vote.is_aye()`, the vote is to enact the proposal; otherwise it is a vote to keep the status quo. # <weight> - O(1). - One DB change, one DB entry. # </weight>
|
||||
- **summary**: Vote in a referendum. If `vote.is_aye()`, the vote is to enact the proposal; otherwise it is a vote to keep the status quo. # <weight> - O(1). - One DB change, one DB entry. # </weight>
|
||||
|
||||
___
|
||||
|
||||
@@ -169,34 +161,34 @@ ___
|
||||
### elections
|
||||
|
||||
▸ **presentWinner**(candidate: `Address`, total: `Compact<BalanceOf>`, index: `Compact<VoteIndex>`)
|
||||
- **summary**: Claim that `signed` is one of the top Self::carry_count() + current_vote().1 candidates. Only works if the `block_number >= current_vote().0` and `< current_vote().0 + presentation_duration()` `signed` should have at least # <weight> - O(voters) compute. - One DB change. # </weight>
|
||||
- **summary**: Claim that `candidate` is one of the top `carry_count + desired_seats` candidates. Only works iff the presentation period is active. `candidate` should have at least collected some non-zero `total` votes and `origin` must have enough funds to pay for a potential slash. # <weight> - O(voters) compute. - One DB change. # </weight>
|
||||
|
||||
▸ **proxySetApprovals**(votes: `Vec<bool>`, index: `Compact<VoteIndex>`, hint: `SetIndex`)
|
||||
- **summary**: Set candidate approvals from a proxy. Approval slots stay valid as long as candidates in those slots are registered. # <weight> - Same as `set_approvals` with one additional storage read. # </weight>
|
||||
▸ **proxySetApprovals**(votes: `Vec<bool>`, index: `Compact<VoteIndex>`, hint: `SetIndex`, value: `Compact<BalanceOf>`)
|
||||
- **summary**: Set candidate approvals from a proxy. Approval slots stay valid as long as candidates in those slots are registered. # <weight> - Same as `set_approvals` with one additional storage read. # </weight>
|
||||
|
||||
▸ **reapInactiveVoter**(reporter_index: `Compact<u32>`, who: `Address`, who_index: `Compact<u32>`, assumed_vote_index: `Compact<VoteIndex>`)
|
||||
- **summary**: Remove a voter. For it not to be a bond-consuming no-op, all approved candidate indices must now be either unregistered or registered to a candidate that registered the slot after the voter gave their last approval set. Both indices must be provided as explained in [`voter_at`] function. May be called by anyone. Returns the voter deposit to `signed`. # <weight> - O(1). - Two fewer DB entries, one DB change. # </weight>
|
||||
- **summary**: Remove a voter. For it not to be a bond-consuming no-op, all approved candidate indices must now be either unregistered or registered to a candidate that registered the slot after the voter gave their last approval set. Both indices must be provided as explained in [`voter_at`] function. May be called by anyone. Returns the voter deposit to `signed`. # <weight> - O(1). - Two fewer DB entries, one DB change. # </weight>
|
||||
|
||||
▸ **removeMember**(who: `Address`)
|
||||
- **summary**: Remove a particular member from the set. This is effective immediately. Note: A tally should happen instantly (if not already in a presentation period) to fill the seat if removal means that the desired members are not met.
|
||||
- **summary**: Remove a particular member from the set. This is effective immediately. Note: A tally should happen instantly (if not already in a presentation period) to fill the seat if removal means that the desired members are not met.
|
||||
|
||||
▸ **retractVoter**(index: `Compact<u32>`)
|
||||
- **summary**: Remove a voter. All votes are cancelled and the voter deposit is returned. The index must be provided as explained in [`voter_at`] function. Also removes the lock on the balance of the voter. See [`do_set_approvals()`]. # <weight> - O(1). - Two fewer DB entries, one DB change. # </weight>
|
||||
- **summary**: Remove a voter. All votes are cancelled and the voter deposit is returned. The index must be provided as explained in [`voter_at`] function. Also removes the lock on the balance of the voter. See [`do_set_approvals()`]. # <weight> - O(1). - Two fewer DB entries, one DB change. # </weight>
|
||||
|
||||
▸ **setApprovals**(votes: `Vec<bool>`, index: `Compact<VoteIndex>`, hint: `SetIndex`)
|
||||
- **summary**: Set candidate approvals. Approval slots stay valid as long as candidates in those slots are registered. Locks the total balance of caller indefinitely. Only [`retract_voter`] or [`reap_inactive_voter`] can unlock the balance. `hint` argument is interpreted differently based on: - if `origin` is setting approvals for the first time: The index will be checked for being a valid _hole_ in the voter list. - if the hint is correctly pointing to a hole, no fee is deducted from `origin`. - Otherwise, the call will succeed but the index is ignored and simply a push to the last chunk with free space happens. If the new push causes a new chunk to be created, a fee indicated by [`VotingFee`] is deducted. - if `origin` is already a voter: the index __must__ be valid and point to the correct position of the `origin` in the current voters list. Note that any trailing `false` votes in `votes` is ignored; In approval voting, not voting for a candidate and voting false, are equal. # <weight> - O(1). - Two extra DB entries, one DB change. - Argument `votes` is limited in length to number of candidates. # </weight>
|
||||
▸ **setApprovals**(votes: `Vec<bool>`, index: `Compact<VoteIndex>`, hint: `SetIndex`, value: `Compact<BalanceOf>`)
|
||||
- **summary**: Set candidate approvals. Approval slots stay valid as long as candidates in those slots are registered. Locks `value` from the balance of `origin` indefinitely. Only [`retract_voter`] or [`reap_inactive_voter`] can unlock the balance. `hint` argument is interpreted differently based on: - if `origin` is setting approvals for the first time: The index will be checked for being a valid _hole_ in the voter list. - if the hint is correctly pointing to a hole, no fee is deducted from `origin`. - Otherwise, the call will succeed but the index is ignored and simply a push to the last chunk with free space happens. If the new push causes a new chunk to be created, a fee indicated by [`VotingFee`] is deducted. - if `origin` is already a voter: the index __must__ be valid and point to the correct position of the `origin` in the current voters list. Note that any trailing `false` votes in `votes` is ignored; In approval voting, not voting for a candidate and voting false, are equal. # <weight> - O(1). - Two extra DB entries, one DB change. - Argument `votes` is limited in length to number of candidates. # </weight>
|
||||
|
||||
▸ **setDesiredSeats**(count: `Compact<u32>`)
|
||||
- **summary**: Set the desired member count; if lower than the current count, then seats will not be up election when they expire. If more, then a new vote will be started if one is not already in progress.
|
||||
- **summary**: Set the desired member count; if lower than the current count, then seats will not be up election when they expire. If more, then a new vote will be started if one is not already in progress.
|
||||
|
||||
▸ **setPresentationDuration**(count: `Compact<BlockNumber>`)
|
||||
- **summary**: Set the presentation duration. If there is currently a vote being presented for, will invoke `finalize_vote`.
|
||||
- **summary**: Set the presentation duration. If there is currently a vote being presented for, will invoke `finalize_vote`.
|
||||
|
||||
▸ **setTermDuration**(count: `Compact<BlockNumber>`)
|
||||
- **summary**: Set the presentation duration. If there is current a vote being presented for, will invoke `finalize_vote`.
|
||||
- **summary**: Set the presentation duration. If there is current a vote being presented for, will invoke `finalize_vote`.
|
||||
|
||||
▸ **submitCandidacy**(slot: `Compact<u32>`)
|
||||
- **summary**: Submit oneself for candidacy. Account must have enough transferrable funds in it to pay the bond. NOTE: if `origin` has already assigned approvals via [`set_approvals`], it will NOT have any usable funds to pass candidacy bond and must first retract. Note that setting approvals will lock the entire balance of the voter until retraction or being reported. # <weight> - Independent of input. - Three DB changes. # </weight>
|
||||
- **summary**: Submit oneself for candidacy. Account must have enough transferrable funds in it to pay the bond. NOTE: if `origin` has already assigned approvals via [`set_approvals`], it will NOT have any usable funds to pass candidacy bond and must first retract. Note that setting approvals will lock the entire balance of the voter until retraction or being reported. # <weight> - Independent of input. - Three DB changes. # </weight>
|
||||
|
||||
___
|
||||
|
||||
@@ -204,7 +196,7 @@ ___
|
||||
### finalityTracker
|
||||
|
||||
▸ **finalHint**(hint: `Compact<BlockNumber>`)
|
||||
- **summary**: Hint that the author of this block thinks the best finalized block is the given number.
|
||||
- **summary**: Hint that the author of this block thinks the best finalized block is the given number.
|
||||
|
||||
___
|
||||
|
||||
@@ -212,7 +204,7 @@ ___
|
||||
### grandpa
|
||||
|
||||
▸ **reportMisbehavior**(_report: `Bytes`)
|
||||
- **summary**: Report some misbehavior.
|
||||
- **summary**: Report some misbehavior.
|
||||
|
||||
___
|
||||
|
||||
@@ -227,7 +219,7 @@ ___
|
||||
### session
|
||||
|
||||
▸ **setKeys**(keys: `Keys`, proof: `Bytes`)
|
||||
- **summary**: Sets the session key(s) of the function caller to `key`. Allows an account to set its session key prior to becoming a validator. This doesn't take effect until the next session. The dispatch origin of this function must be signed. # <weight> - O(log n) in number of accounts. - One extra DB entry. # </weight>
|
||||
- **summary**: Sets the session key(s) of the function caller to `key`. Allows an account to set its session key prior to becoming a validator. This doesn't take effect until the next session. The dispatch origin of this function must be signed. # <weight> - O(log n) in number of accounts. - One extra DB entry. # </weight>
|
||||
|
||||
___
|
||||
|
||||
@@ -235,43 +227,43 @@ ___
|
||||
### staking
|
||||
|
||||
▸ **bond**(controller: `Address`, value: `Compact<BalanceOf>`, payee: `RewardDestination`)
|
||||
- **summary**: Take the origin account as a stash and lock up `value` of its balance. `controller` will be the account that controls it. `value` must be more than the `minimum_balance` specified by `T::Currency`. The dispatch origin for this call must be _Signed_ by the stash account. # <weight> - Independent of the arguments. Moderate complexity. - O(1). - Three extra DB entries. NOTE: Two of the storage writes (`Self::bonded`, `Self::payee`) are _never_ cleaned unless the `origin` falls below _existential deposit_ and gets removed as dust. # </weight>
|
||||
- **summary**: Take the origin account as a stash and lock up `value` of its balance. `controller` will be the account that controls it. `value` must be more than the `minimum_balance` specified by `T::Currency`. The dispatch origin for this call must be _Signed_ by the stash account. # <weight> - Independent of the arguments. Moderate complexity. - O(1). - Three extra DB entries. NOTE: Two of the storage writes (`Self::bonded`, `Self::payee`) are _never_ cleaned unless the `origin` falls below _existential deposit_ and gets removed as dust. # </weight>
|
||||
|
||||
▸ **bondExtra**(max_additional: `Compact<BalanceOf>`)
|
||||
- **summary**: Add some extra amount that have appeared in the stash `free_balance` into the balance up for staking. Use this if there are additional funds in your stash account that you wish to bond. Unlike [`bond`] or [`unbond`] this function does not impose any limitation on the amount that can be added. The dispatch origin for this call must be _Signed_ by the stash, not the controller. # <weight> - Independent of the arguments. Insignificant complexity. - O(1). - One DB entry. # </weight>
|
||||
- **summary**: Add some extra amount that have appeared in the stash `free_balance` into the balance up for staking. Use this if there are additional funds in your stash account that you wish to bond. Unlike [`bond`] or [`unbond`] this function does not impose any limitation on the amount that can be added. The dispatch origin for this call must be _Signed_ by the stash, not the controller. # <weight> - Independent of the arguments. Insignificant complexity. - O(1). - One DB entry. # </weight>
|
||||
|
||||
▸ **chill**()
|
||||
- **summary**: Declare no desire to either validate or nominate. Effects will be felt at the beginning of the next era. The dispatch origin for this call must be _Signed_ by the controller, not the stash. # <weight> - Independent of the arguments. Insignificant complexity. - Contains one read. - Writes are limited to the `origin` account key. # </weight>
|
||||
- **summary**: Declare no desire to either validate or nominate. Effects will be felt at the beginning of the next era. The dispatch origin for this call must be _Signed_ by the controller, not the stash. # <weight> - Independent of the arguments. Insignificant complexity. - Contains one read. - Writes are limited to the `origin` account key. # </weight>
|
||||
|
||||
▸ **forceNewEra**()
|
||||
- **summary**: Force there to be a new era at the end of the next session. After this, it will be reset to normal (non-forced) behaviour. # <weight> - No arguments. # </weight>
|
||||
- **summary**: Force there to be a new era at the end of the next session. After this, it will be reset to normal (non-forced) behaviour. # <weight> - No arguments. # </weight>
|
||||
|
||||
▸ **forceNoEras**()
|
||||
- **summary**: Force there to be no new eras indefinitely. # <weight> - No arguments. # </weight>
|
||||
- **summary**: Force there to be no new eras indefinitely. # <weight> - No arguments. # </weight>
|
||||
|
||||
▸ **nominate**(targets: `Vec<Address>`)
|
||||
- **summary**: Declare the desire to nominate `targets` for the origin controller. Effects will be felt at the beginning of the next era. The dispatch origin for this call must be _Signed_ by the controller, not the stash. # <weight> - The transaction's complexity is proportional to the size of `targets`, which is capped at `MAX_NOMINATIONS`. - Both the reads and writes follow a similar pattern. # </weight>
|
||||
- **summary**: Declare the desire to nominate `targets` for the origin controller. Effects will be felt at the beginning of the next era. The dispatch origin for this call must be _Signed_ by the controller, not the stash. # <weight> - The transaction's complexity is proportional to the size of `targets`, which is capped at `MAX_NOMINATIONS`. - Both the reads and writes follow a similar pattern. # </weight>
|
||||
|
||||
▸ **setController**(controller: `Address`)
|
||||
- **summary**: (Re-)set the controller of a stash. Effects will be felt at the beginning of the next era. The dispatch origin for this call must be _Signed_ by the stash, not the controller. # <weight> - Independent of the arguments. Insignificant complexity. - Contains a limited number of reads. - Writes are limited to the `origin` account key. # </weight>
|
||||
- **summary**: (Re-)set the controller of a stash. Effects will be felt at the beginning of the next era. The dispatch origin for this call must be _Signed_ by the stash, not the controller. # <weight> - Independent of the arguments. Insignificant complexity. - Contains a limited number of reads. - Writes are limited to the `origin` account key. # </weight>
|
||||
|
||||
▸ **setInvulnerables**(validators: `Vec<AccountId>`)
|
||||
- **summary**: Set the validators who cannot be slashed (if any).
|
||||
- **summary**: Set the validators who cannot be slashed (if any).
|
||||
|
||||
▸ **setPayee**(payee: `RewardDestination`)
|
||||
- **summary**: (Re-)set the payment target for a controller. Effects will be felt at the beginning of the next era. The dispatch origin for this call must be _Signed_ by the controller, not the stash. # <weight> - Independent of the arguments. Insignificant complexity. - Contains a limited number of reads. - Writes are limited to the `origin` account key. # </weight>
|
||||
- **summary**: (Re-)set the payment target for a controller. Effects will be felt at the beginning of the next era. The dispatch origin for this call must be _Signed_ by the controller, not the stash. # <weight> - Independent of the arguments. Insignificant complexity. - Contains a limited number of reads. - Writes are limited to the `origin` account key. # </weight>
|
||||
|
||||
▸ **setValidatorCount**(new: `Compact<u32>`)
|
||||
- **summary**: The ideal number of validators.
|
||||
- **summary**: The ideal number of validators.
|
||||
|
||||
▸ **unbond**(value: `Compact<BalanceOf>`)
|
||||
- **summary**: Schedule a portion of the stash to be unlocked ready for transfer out after the bond period ends. If this leaves an amount actively bonded less than T::Currency::minimum_balance(), then it is increased to the full amount. Once the unlock period is done, you can call `withdraw_unbonded` to actually move the funds out of management ready for transfer. No more than a limited number of unlocking chunks (see `MAX_UNLOCKING_CHUNKS`) can co-exists at the same time. In that case, [`Call::withdraw_unbonded`] need to be called first to remove some of the chunks (if possible). The dispatch origin for this call must be _Signed_ by the controller, not the stash. See also [`Call::withdraw_unbonded`]. # <weight> - Independent of the arguments. Limited but potentially exploitable complexity. - Contains a limited number of reads. - Each call (requires the remainder of the bonded balance to be above `minimum_balance`) will cause a new entry to be inserted into a vector (`Ledger.unlocking`) kept in storage. The only way to clean the aforementioned storage item is also user-controlled via `withdraw_unbonded`. - One DB entry. </weight>
|
||||
- **summary**: Schedule a portion of the stash to be unlocked ready for transfer out after the bond period ends. If this leaves an amount actively bonded less than T::Currency::minimum_balance(), then it is increased to the full amount. Once the unlock period is done, you can call `withdraw_unbonded` to actually move the funds out of management ready for transfer. No more than a limited number of unlocking chunks (see `MAX_UNLOCKING_CHUNKS`) can co-exists at the same time. In that case, [`Call::withdraw_unbonded`] need to be called first to remove some of the chunks (if possible). The dispatch origin for this call must be _Signed_ by the controller, not the stash. See also [`Call::withdraw_unbonded`]. # <weight> - Independent of the arguments. Limited but potentially exploitable complexity. - Contains a limited number of reads. - Each call (requires the remainder of the bonded balance to be above `minimum_balance`) will cause a new entry to be inserted into a vector (`Ledger.unlocking`) kept in storage. The only way to clean the aforementioned storage item is also user-controlled via `withdraw_unbonded`. - One DB entry. </weight>
|
||||
|
||||
▸ **validate**(prefs: `ValidatorPrefs`)
|
||||
- **summary**: Declare the desire to validate for the origin controller. Effects will be felt at the beginning of the next era. The dispatch origin for this call must be _Signed_ by the controller, not the stash. # <weight> - Independent of the arguments. Insignificant complexity. - Contains a limited number of reads. - Writes are limited to the `origin` account key. # </weight>
|
||||
- **summary**: Declare the desire to validate for the origin controller. Effects will be felt at the beginning of the next era. The dispatch origin for this call must be _Signed_ by the controller, not the stash. # <weight> - Independent of the arguments. Insignificant complexity. - Contains a limited number of reads. - Writes are limited to the `origin` account key. # </weight>
|
||||
|
||||
▸ **withdrawUnbonded**()
|
||||
- **summary**: Remove any unlocked chunks from the `unlocking` queue from our management. This essentially frees up that balance to be used by the stash account to do whatever it wants. The dispatch origin for this call must be _Signed_ by the controller, not the stash. See also [`Call::unbond`]. # <weight> - Could be dependent on the `origin` argument and how much `unlocking` chunks exist. It implies `consolidate_unlocked` which loops over `Ledger.unlocking`, which is indirectly user-controlled. See [`unbond`] for more detail. - Contains a limited number of reads, yet the size of which could be large based on `ledger`. - Writes are limited to the `origin` account key. # </weight>
|
||||
- **summary**: Remove any unlocked chunks from the `unlocking` queue from our management. This essentially frees up that balance to be used by the stash account to do whatever it wants. The dispatch origin for this call must be _Signed_ by the controller, not the stash. See also [`Call::unbond`]. # <weight> - Could be dependent on the `origin` argument and how much `unlocking` chunks exist. It implies `consolidate_unlocked` which loops over `Ledger.unlocking`, which is indirectly user-controlled. See [`unbond`] for more detail. - Contains a limited number of reads, yet the size of which could be large based on `ledger`. - Writes are limited to the `origin` account key. # </weight>
|
||||
|
||||
___
|
||||
|
||||
@@ -279,10 +271,13 @@ ___
|
||||
### sudo
|
||||
|
||||
▸ **setKey**(new: `Address`)
|
||||
- **summary**: Authenticates the current sudo key and sets the given AccountId (`new`) as the new sudo key. The dispatch origin for this call must be _Signed_. # <weight> - O(1). - Limited storage reads. - One DB change. # </weight>
|
||||
- **summary**: Authenticates the current sudo key and sets the given AccountId (`new`) as the new sudo key. The dispatch origin for this call must be _Signed_. # <weight> - O(1). - Limited storage reads. - One DB change. # </weight>
|
||||
|
||||
▸ **sudo**(proposal: `Proposal`)
|
||||
- **summary**: Authenticates the sudo key and dispatches a function call with `Root` origin. The dispatch origin for this call must be _Signed_. # <weight> - O(1). - Limited storage reads. - No DB writes. # </weight>
|
||||
- **summary**: Authenticates the sudo key and dispatches a function call with `Root` origin. The dispatch origin for this call must be _Signed_. # <weight> - O(1). - Limited storage reads. - One DB write (event). - Unknown weight of derivative `proposal` execution. # </weight>
|
||||
|
||||
▸ **sudoAs**(who: `Address`, proposal: `Proposal`)
|
||||
- **summary**: Authenticates the sudo key and dispatches a function call with `Signed` origin from a given account. The dispatch origin for this call must be _Signed_. # <weight> - O(1). - Limited storage reads. - One DB write (event). - Unknown weight of derivative `proposal` execution. # </weight>
|
||||
|
||||
___
|
||||
|
||||
@@ -290,22 +285,25 @@ ___
|
||||
### system
|
||||
|
||||
▸ **fillBlock**()
|
||||
- **summary**: A big dispatch that will disallow any other transaction to be included.
|
||||
- **summary**: A big dispatch that will disallow any other transaction to be included.
|
||||
|
||||
▸ **killPrefix**(prefix: `Key`)
|
||||
- **summary**: Kill all storage items with a key that starts with the given prefix.
|
||||
|
||||
▸ **killStorage**(keys: `Vec<Key>`)
|
||||
- **summary**: Kill some items from storage.
|
||||
- **summary**: Kill some items from storage.
|
||||
|
||||
▸ **remark**(_remark: `Bytes`)
|
||||
- **summary**: Make some on-chain remark.
|
||||
- **summary**: Make some on-chain remark.
|
||||
|
||||
▸ **setCode**(new: `Bytes`)
|
||||
- **summary**: Set the new code.
|
||||
- **summary**: Set the new code.
|
||||
|
||||
▸ **setHeapPages**(pages: `u64`)
|
||||
- **summary**: Set the number of pages in the WebAssembly environment's heap.
|
||||
- **summary**: Set the number of pages in the WebAssembly environment's heap.
|
||||
|
||||
▸ **setStorage**(items: `Vec<KeyValue>`)
|
||||
- **summary**: Set some items of storage.
|
||||
- **summary**: Set some items of storage.
|
||||
|
||||
___
|
||||
|
||||
@@ -313,16 +311,16 @@ ___
|
||||
### technicalCommittee
|
||||
|
||||
▸ **execute**(proposal: `Proposal`)
|
||||
- **summary**: Dispatch a proposal from a member using the `Member` origin. Origin must be a member of the collective.
|
||||
- **summary**: Dispatch a proposal from a member using the `Member` origin. Origin must be a member of the collective.
|
||||
|
||||
▸ **propose**(threshold: `Compact<MemberCount>`, proposal: `Proposal`)
|
||||
- **summary**: # <weight> - Bounded storage reads and writes. - Argument `threshold` has bearing on weight. # </weight>
|
||||
- **summary**: # <weight> - Bounded storage reads and writes. - Argument `threshold` has bearing on weight. # </weight>
|
||||
|
||||
▸ **setMembers**(new_members: `Vec<AccountId>`)
|
||||
- **summary**: Set the collective's membership manually to `new_members`. Be nice to the chain and provide it pre-sorted. Requires root origin.
|
||||
- **summary**: Set the collective's membership manually to `new_members`. Be nice to the chain and provide it pre-sorted. Requires root origin.
|
||||
|
||||
▸ **vote**(proposal: `Hash`, index: `Compact<ProposalIndex>`, approve: `bool`)
|
||||
- **summary**: # <weight> - Bounded storage read and writes. - Will be slightly heavier if the proposal is approved / disapproved after the vote. # </weight>
|
||||
- **summary**: # <weight> - Bounded storage read and writes. - Will be slightly heavier if the proposal is approved / disapproved after the vote. # </weight>
|
||||
|
||||
___
|
||||
|
||||
@@ -330,16 +328,16 @@ ___
|
||||
### technicalMembership
|
||||
|
||||
▸ **addMember**(who: `AccountId`)
|
||||
- **summary**: Add a member `who` to the set. May only be called from `AddOrigin` or root.
|
||||
- **summary**: Add a member `who` to the set. May only be called from `AddOrigin` or root.
|
||||
|
||||
▸ **removeMember**(who: `AccountId`)
|
||||
- **summary**: Remove a member `who` from the set. May only be called from `RemoveOrigin` or root.
|
||||
- **summary**: Remove a member `who` from the set. May only be called from `RemoveOrigin` or root.
|
||||
|
||||
▸ **resetMembers**(members: `Vec<AccountId>`)
|
||||
- **summary**: Change the membership to a new set, disregarding the existing membership. Be nice and pass `members` pre-sorted. May only be called from `ResetOrigin` or root.
|
||||
- **summary**: Change the membership to a new set, disregarding the existing membership. Be nice and pass `members` pre-sorted. May only be called from `ResetOrigin` or root.
|
||||
|
||||
▸ **swapMember**(remove: `AccountId`, add: `AccountId`)
|
||||
- **summary**: Swap out one member `remove` for another `add`. May only be called from `SwapOrigin` or root.
|
||||
- **summary**: Swap out one member `remove` for another `add`. May only be called from `SwapOrigin` or root.
|
||||
|
||||
___
|
||||
|
||||
@@ -347,7 +345,7 @@ ___
|
||||
### timestamp
|
||||
|
||||
▸ **set**(now: `Compact<Moment>`)
|
||||
- **summary**: Set the current time. This call should be invoked exactly once per block. It will panic at the finalization phase, if this call hasn't been invoked by that time. The timestamp should be greater than the previous one by the amount specified by `MinimumPeriod`. The dispatch origin for this call must be `Inherent`.
|
||||
- **summary**: Set the current time. This call should be invoked exactly once per block. It will panic at the finalization phase, if this call hasn't been invoked by that time. The timestamp should be greater than the previous one by the amount specified by `MinimumPeriod`. The dispatch origin for this call must be `Inherent`.
|
||||
|
||||
___
|
||||
|
||||
@@ -355,10 +353,18 @@ ___
|
||||
### treasury
|
||||
|
||||
▸ **approveProposal**(proposal_id: `Compact<ProposalIndex>`)
|
||||
- **summary**: Approve a proposal. At a later time, the proposal will be allocated to the beneficiary and the original deposit will be returned. # <weight> - O(1). - Limited storage reads. - One DB change. # </weight>
|
||||
- **summary**: Approve a proposal. At a later time, the proposal will be allocated to the beneficiary and the original deposit will be returned. # <weight> - O(1). - Limited storage reads. - One DB change. # </weight>
|
||||
|
||||
▸ **proposeSpend**(value: `Compact<BalanceOf>`, beneficiary: `Address`)
|
||||
- **summary**: Put forward a suggestion for spending. A deposit proportional to the value is reserved and slashed if the proposal is rejected. It is returned once the proposal is awarded. # <weight> - O(1). - Limited storage reads. - One DB change, one extra DB entry. # </weight>
|
||||
- **summary**: Put forward a suggestion for spending. A deposit proportional to the value is reserved and slashed if the proposal is rejected. It is returned once the proposal is awarded. # <weight> - O(1). - Limited storage reads. - One DB change, one extra DB entry. # </weight>
|
||||
|
||||
▸ **rejectProposal**(proposal_id: `Compact<ProposalIndex>`)
|
||||
- **summary**: Reject a proposed spend. The original deposit will be slashed. # <weight> - O(1). - Limited storage reads. - One DB clear. # </weight>
|
||||
- **summary**: Reject a proposed spend. The original deposit will be slashed. # <weight> - O(1). - Limited storage reads. - One DB clear. # </weight>
|
||||
|
||||
___
|
||||
|
||||
|
||||
### utility
|
||||
|
||||
▸ **batch**(calls: `Vec<Call>`)
|
||||
- **summary**: Send a batch of dispatch calls (only root).
|
||||
|
||||
@@ -2,10 +2,16 @@
|
||||
|
||||
The following sections contain RPC methods that are Remote Calls available by default and allow you to interact with the actual node, query, and submit.
|
||||
|
||||
- **[account](#account)**
|
||||
|
||||
- **[author](#author)**
|
||||
|
||||
- **[chain](#chain)**
|
||||
|
||||
- **[contracts](#contracts)**
|
||||
|
||||
- **[rpc](#rpc)**
|
||||
|
||||
- **[state](#state)**
|
||||
|
||||
- **[system](#system)**
|
||||
@@ -14,6 +20,16 @@ The following sections contain RPC methods that are Remote Calls available by de
|
||||
___
|
||||
|
||||
|
||||
### account
|
||||
|
||||
_(Optional) Methods that retrieves account-specific information_
|
||||
|
||||
▸ **nextIndex**(accountId: `AccountId`): `Index`
|
||||
- **summary**: Retrieves the next accountIndex as available on the node
|
||||
|
||||
___
|
||||
|
||||
|
||||
### author
|
||||
|
||||
_Authoring of network items_
|
||||
@@ -64,6 +80,26 @@ _Retrieval of chain data_
|
||||
___
|
||||
|
||||
|
||||
### contracts
|
||||
|
||||
_(Optional) Methods that performs actions on contracts_
|
||||
|
||||
▸ **call**(callRequest: `ContractCallRequest`, at?: `Hash`): `ContractExecResult`
|
||||
- **summary**: Executes a call to a contract
|
||||
|
||||
___
|
||||
|
||||
|
||||
### rpc
|
||||
|
||||
_Retrieves information about the RPC endpoints_
|
||||
|
||||
▸ **methods**(): `RpcMethods`
|
||||
- **summary**: Retrieves the list of RPC methods that are exposed by the node
|
||||
|
||||
___
|
||||
|
||||
|
||||
### state
|
||||
|
||||
_Query of state_
|
||||
|
||||
+130
-134
@@ -50,13 +50,13 @@ ___
|
||||
### authorship
|
||||
|
||||
▸ **author**(): `Option<AccountId>`
|
||||
- **summary**: Author of current block.
|
||||
- **summary**: Author of current block.
|
||||
|
||||
▸ **didSetUncles**(): `bool`
|
||||
- **summary**: Whether uncles were already set in this block.
|
||||
- **summary**: Whether uncles were already set in this block.
|
||||
|
||||
▸ **uncles**(): `Vec<UncleEntryItem>`
|
||||
- **summary**: Uncles
|
||||
- **summary**: Uncles
|
||||
|
||||
___
|
||||
|
||||
@@ -64,34 +64,28 @@ ___
|
||||
### babe
|
||||
|
||||
▸ **authorities**(): `Vec<(AuthorityId,BabeAuthorityWeight)>`
|
||||
- **summary**: Current epoch authorities.
|
||||
- **summary**: Current epoch authorities.
|
||||
|
||||
▸ **currentSlot**(): `u64`
|
||||
- **summary**: Current slot number.
|
||||
- **summary**: Current slot number.
|
||||
|
||||
▸ **epochIndex**(): `u64`
|
||||
- **summary**: Current epoch index.
|
||||
- **summary**: Current epoch index.
|
||||
|
||||
▸ **epochStartSlot**(): `u64`
|
||||
- **summary**: Slot at which the current epoch started. It is possible that no block was authored at the given slot and the epoch change was signalled later than this.
|
||||
▸ **genesisSlot**(): `u64`
|
||||
- **summary**: The slot at which the first epoch actually started. This is 0 until the first block of the chain.
|
||||
|
||||
▸ **initialized**(): `Option<bool>`
|
||||
- **summary**: Temporary value (cleared at block finalization) which is true if per-block initialization has already been called for current block.
|
||||
▸ **initialized**(): `Option<MaybeVrf>`
|
||||
- **summary**: Temporary value (cleared at block finalization) which is `Some` if per-block initialization has already been called for current block.
|
||||
|
||||
▸ **nextRandomness**(): `[u8;32]`
|
||||
- **summary**: Next epoch randomness.
|
||||
|
||||
▸ **pendingSecondarySlotsChange**(): `Option<bool>`
|
||||
- **summary**: Pending change to enable/disable secondary slots which will be triggered at `current_epoch + 2`.
|
||||
- **summary**: Next epoch randomness.
|
||||
|
||||
▸ **randomness**(): `[u8;32]`
|
||||
- **summary**: The epoch randomness for the *current* epoch. # Security This MUST NOT be used for gambling, as it can be influenced by a malicious validator in the short term. It MAY be used in many cryptographic protocols, however, so long as one remembers that this (like everything else on-chain) it is public. For example, it can be used where a number is needed that cannot have been chosen by an adversary, for purposes such as public-coin zero-knowledge proofs.
|
||||
|
||||
▸ **secondarySlots**(): `(bool,bool)`
|
||||
- **summary**: Whether secondary slots are enabled in case the VRF-based slot is empty for the current epoch and the next epoch, respectively.
|
||||
- **summary**: The epoch randomness for the *current* epoch. # Security This MUST NOT be used for gambling, as it can be influenced by a malicious validator in the short term. It MAY be used in many cryptographic protocols, however, so long as one remembers that this (like everything else on-chain) it is public. For example, it can be used where a number is needed that cannot have been chosen by an adversary, for purposes such as public-coin zero-knowledge proofs.
|
||||
|
||||
▸ **segmentIndex**(): `u32`
|
||||
- **summary**: Randomness under construction. We make a tradeoff between storage accesses and list length. We store the under-construction randomness in segments of up to `UNDER_CONSTRUCTION_SEGMENT_LENGTH`. Once a segment reaches this length, we begin the next one. We reset all segments and return to `0` at the beginning of every epoch.
|
||||
- **summary**: Randomness under construction. We make a tradeoff between storage accesses and list length. We store the under-construction randomness in segments of up to `UNDER_CONSTRUCTION_SEGMENT_LENGTH`. Once a segment reaches this length, we begin the next one. We reset all segments and return to `0` at the beginning of every epoch.
|
||||
|
||||
▸ **underConstruction**(`u32`): `Vec<[u8;32]>`
|
||||
|
||||
@@ -101,19 +95,19 @@ ___
|
||||
### balances
|
||||
|
||||
▸ **freeBalance**(`AccountId`): `Balance`
|
||||
- **summary**: The 'free' balance of a given account. This is the only balance that matters in terms of most operations on tokens. It alone is used to determine the balance when in the contract execution environment. When this balance falls below the value of `ExistentialDeposit`, then the 'current account' is deleted: specifically `FreeBalance`. Further, the `OnFreeBalanceZero` callback is invoked, giving a chance to external modules to clean up data associated with the deleted account. `system::AccountNonce` is also deleted if `ReservedBalance` is also zero (it also gets collapsed to zero if it ever becomes less than `ExistentialDeposit`.
|
||||
- **summary**: The 'free' balance of a given account. This is the only balance that matters in terms of most operations on tokens. It alone is used to determine the balance when in the contract execution environment. When this balance falls below the value of `ExistentialDeposit`, then the 'current account' is deleted: specifically `FreeBalance`. Further, the `OnFreeBalanceZero` callback is invoked, giving a chance to external modules to clean up data associated with the deleted account. `system::AccountNonce` is also deleted if `ReservedBalance` is also zero (it also gets collapsed to zero if it ever becomes less than `ExistentialDeposit`.
|
||||
|
||||
▸ **locks**(`AccountId`): `Vec<BalanceLock>`
|
||||
- **summary**: Any liquidity locks on some account balances.
|
||||
- **summary**: Any liquidity locks on some account balances.
|
||||
|
||||
▸ **reservedBalance**(`AccountId`): `Balance`
|
||||
- **summary**: The amount of the balance of a given account that is externally reserved; this can still get slashed, but gets slashed last of all. This balance is a 'reserve' balance that other subsystems use in order to set aside tokens that are still 'owned' by the account holder, but which are suspendable. When this balance falls below the value of `ExistentialDeposit`, then this 'reserve account' is deleted: specifically, `ReservedBalance`. `system::AccountNonce` is also deleted if `FreeBalance` is also zero (it also gets collapsed to zero if it ever becomes less than `ExistentialDeposit`.)
|
||||
- **summary**: The amount of the balance of a given account that is externally reserved; this can still get slashed, but gets slashed last of all. This balance is a 'reserve' balance that other subsystems use in order to set aside tokens that are still 'owned' by the account holder, but which are suspendable. When this balance falls below the value of `ExistentialDeposit`, then this 'reserve account' is deleted: specifically, `ReservedBalance`. `system::AccountNonce` is also deleted if `FreeBalance` is also zero (it also gets collapsed to zero if it ever becomes less than `ExistentialDeposit`.)
|
||||
|
||||
▸ **totalIssuance**(): `Balance`
|
||||
- **summary**: The total units issued in the system.
|
||||
- **summary**: The total units issued in the system.
|
||||
|
||||
▸ **vesting**(`AccountId`): `Option<VestingSchedule>`
|
||||
- **summary**: Information regarding the vesting of a given account.
|
||||
- **summary**: Information regarding the vesting of a given account.
|
||||
|
||||
___
|
||||
|
||||
@@ -121,25 +115,25 @@ ___
|
||||
### contracts
|
||||
|
||||
▸ **accountCounter**(): `u64`
|
||||
- **summary**: The subtrie counter.
|
||||
- **summary**: The subtrie counter.
|
||||
|
||||
▸ **codeStorage**(`CodeHash`): `Option<PrefabWasmModule>`
|
||||
- **summary**: A mapping between an original code hash and instrumented wasm code, ready for execution.
|
||||
- **summary**: A mapping between an original code hash and instrumented wasm code, ready for execution.
|
||||
|
||||
▸ **contractInfoOf**(`AccountId`): `Option<ContractInfo>`
|
||||
- **summary**: The code associated with a given account.
|
||||
- **summary**: The code associated with a given account.
|
||||
|
||||
▸ **currentSchedule**(): `Schedule`
|
||||
- **summary**: Current cost schedule for contracts.
|
||||
- **summary**: Current cost schedule for contracts.
|
||||
|
||||
▸ **gasPrice**(): `BalanceOf`
|
||||
- **summary**: The price of one unit of gas.
|
||||
- **summary**: The price of one unit of gas.
|
||||
|
||||
▸ **gasSpent**(): `Gas`
|
||||
- **summary**: Gas spent so far in this block.
|
||||
- **summary**: Gas spent so far in this block.
|
||||
|
||||
▸ **pristineCode**(`CodeHash`): `Option<Bytes>`
|
||||
- **summary**: A mapping from an original code hash to the original code, untouched by instrumentation.
|
||||
- **summary**: A mapping from an original code hash to the original code, untouched by instrumentation.
|
||||
|
||||
___
|
||||
|
||||
@@ -147,19 +141,19 @@ ___
|
||||
### council
|
||||
|
||||
▸ **members**(): `Vec<AccountId>`
|
||||
- **summary**: The current members of the collective. This is stored sorted (just by value).
|
||||
- **summary**: The current members of the collective. This is stored sorted (just by value).
|
||||
|
||||
▸ **proposalCount**(): `u32`
|
||||
- **summary**: Proposals so far.
|
||||
- **summary**: Proposals so far.
|
||||
|
||||
▸ **proposalOf**(`Hash`): `Option<Proposal>`
|
||||
- **summary**: Actual proposal for a given hash, if it's current.
|
||||
- **summary**: Actual proposal for a given hash, if it's current.
|
||||
|
||||
▸ **proposals**(): `Vec<Hash>`
|
||||
- **summary**: The hashes of the active proposals.
|
||||
- **summary**: The hashes of the active proposals.
|
||||
|
||||
▸ **voting**(`Hash`): `Option<Votes>`
|
||||
- **summary**: Votes on a given proposal, if it is ongoing.
|
||||
- **summary**: Votes on a given proposal, if it is ongoing.
|
||||
|
||||
___
|
||||
|
||||
@@ -167,49 +161,49 @@ ___
|
||||
### democracy
|
||||
|
||||
▸ **blacklist**(`Hash`): `Option<(BlockNumber,Vec<AccountId>)>`
|
||||
- **summary**: A record of who vetoed what. Maps proposal hash to a possible existent block number (until when it may not be resubmitted) and who vetoed it.
|
||||
- **summary**: A record of who vetoed what. Maps proposal hash to a possible existent block number (until when it may not be resubmitted) and who vetoed it.
|
||||
|
||||
▸ **cancellations**(`Hash`): `bool`
|
||||
- **summary**: Record of all proposals that have been subject to emergency cancellation.
|
||||
- **summary**: Record of all proposals that have been subject to emergency cancellation.
|
||||
|
||||
▸ **delegations**(`AccountId`): `((AccountId,Conviction), Linkage<AccountId>)`
|
||||
- **summary**: Get the account (and lock periods) to which another account is delegating vote.
|
||||
- **summary**: Get the account (and lock periods) to which another account is delegating vote.
|
||||
|
||||
▸ **depositOf**(`PropIndex`): `Option<(BalanceOf,Vec<AccountId>)>`
|
||||
- **summary**: Those who have locked a deposit.
|
||||
- **summary**: Those who have locked a deposit.
|
||||
|
||||
▸ **dispatchQueue**(`BlockNumber`): `Vec<Option<(Proposal,ReferendumIndex)>>`
|
||||
- **summary**: Queue of successful referenda to be dispatched.
|
||||
- **summary**: Queue of successful referenda to be dispatched.
|
||||
|
||||
▸ **lastTabledWasExternal**(): `bool`
|
||||
- **summary**: True if the last referendum tabled was submitted externally. False if it was a public proposal.
|
||||
- **summary**: True if the last referendum tabled was submitted externally. False if it was a public proposal.
|
||||
|
||||
▸ **nextExternal**(): `Option<(Proposal,VoteThreshold)>`
|
||||
- **summary**: The referendum to be tabled whenever it would be valid to table an external proposal. This happens when a referendum needs to be tabled and one of two conditions are met: - `LastTabledWasExternal` is `false`; or - `PublicProps` is empty.
|
||||
- **summary**: The referendum to be tabled whenever it would be valid to table an external proposal. This happens when a referendum needs to be tabled and one of two conditions are met: - `LastTabledWasExternal` is `false`; or - `PublicProps` is empty.
|
||||
|
||||
▸ **nextTally**(): `ReferendumIndex`
|
||||
- **summary**: The next referendum index that should be tallied.
|
||||
- **summary**: The next referendum index that should be tallied.
|
||||
|
||||
▸ **proxy**(`AccountId`): `Option<AccountId>`
|
||||
- **summary**: Who is able to vote for whom. Value is the fund-holding account, key is the vote-transaction-sending account.
|
||||
- **summary**: Who is able to vote for whom. Value is the fund-holding account, key is the vote-transaction-sending account.
|
||||
|
||||
▸ **publicPropCount**(): `PropIndex`
|
||||
- **summary**: The number of (public) proposals that have been made so far.
|
||||
- **summary**: The number of (public) proposals that have been made so far.
|
||||
|
||||
▸ **publicProps**(): `Vec<(PropIndex,Proposal,AccountId)>`
|
||||
- **summary**: The public proposals. Unsorted.
|
||||
- **summary**: The public proposals. Unsorted.
|
||||
|
||||
▸ **referendumCount**(): `ReferendumIndex`
|
||||
- **summary**: The next free referendum index, aka the number of referenda started so far.
|
||||
- **summary**: The next free referendum index, aka the number of referenda started so far.
|
||||
|
||||
▸ **referendumInfoOf**(`ReferendumIndex`): `Option<ReferendumInfo>`
|
||||
- **summary**: Information concerning any given referendum.
|
||||
- **summary**: Information concerning any given referendum.
|
||||
|
||||
▸ **voteOf**(`(ReferendumIndex,AccountId)`): `Vote`
|
||||
- **summary**: Get the vote in a given referendum of a particular voter. The result is meaningful only if `voters_for` includes the voter when called with the referendum (you'll get the default `Vote` value otherwise). If you don't want to check `voters_for`, then you can also check for simple existence with `VoteOf::exists` first.
|
||||
- **summary**: Get the vote in a given referendum of a particular voter. The result is meaningful only if `voters_for` includes the voter when called with the referendum (you'll get the default `Vote` value otherwise). If you don't want to check `voters_for`, then you can also check for simple existence with `VoteOf::exists` first.
|
||||
|
||||
▸ **votersFor**(`ReferendumIndex`): `Vec<AccountId>`
|
||||
- **summary**: Get the voters for the current proposal.
|
||||
- **summary**: Get the voters for the current proposal.
|
||||
|
||||
___
|
||||
|
||||
@@ -217,52 +211,51 @@ ___
|
||||
### elections
|
||||
|
||||
▸ **approvalsOf**(`(AccountId,SetIndex)`): `Vec<ApprovalFlag>`
|
||||
- **summary**: A list of votes for each voter. The votes are stored as numeric values and parsed in a bit-wise manner. In order to get a human-readable representation (`Vec<bool>`), use [`all_approvals_of`]. Furthermore, each vector of scalars is chunked with the cap of `APPROVAL_SET_SIZE`.
|
||||
|
||||
▸ **candidateCount**(): `u32`
|
||||
- **summary**: Current number of active candidates
|
||||
- **summary**: Current number of active candidates
|
||||
|
||||
▸ **candidates**(): `Vec<AccountId>`
|
||||
- **summary**: The present candidate list.
|
||||
- **summary**: The present candidate list.
|
||||
|
||||
▸ **desiredSeats**(): `u32`
|
||||
- **summary**: Number of accounts that should constitute the collective.
|
||||
- **summary**: Number of accounts that should constitute the collective.
|
||||
|
||||
▸ **leaderboard**(): `Option<Vec<(BalanceOf,AccountId)>>`
|
||||
- **summary**: Get the leaderboard if we're in the presentation phase. The first element is the weight of each entry; It may be the direct summed approval stakes, or a weighted version of it.
|
||||
- **summary**: Get the leaderboard if we're in the presentation phase. The first element is the weight of each entry; It may be the direct summed approval stakes, or a weighted version of it. Sorted from low to high.
|
||||
|
||||
▸ **members**(): `Vec<(AccountId,BlockNumber)>`
|
||||
- **summary**: The current membership. When there's a vote going on, this should still be used for executive matters. The block number (second element in the tuple) is the block that their position is active until (calculated by the sum of the block number when the member was elected and their term duration).
|
||||
- **summary**: The current membership. When there's a vote going on, this should still be used for executive matters. The block number (second element in the tuple) is the block that their position is active until (calculated by the sum of the block number when the member was elected and their term duration).
|
||||
|
||||
▸ **nextFinalize**(): `Option<(BlockNumber,u32,Vec<AccountId>)>`
|
||||
- **summary**: The accounts holding the seats that will become free on the next tally.
|
||||
- **summary**: The accounts holding the seats that will become free on the next tally.
|
||||
|
||||
▸ **nextVoterSet**(): `SetIndex`
|
||||
- **summary**: the next free set to store a voter in. This will keep growing.
|
||||
- **summary**: the next free set to store a voter in. This will keep growing.
|
||||
|
||||
▸ **presentationDuration**(): `BlockNumber`
|
||||
- **summary**: How long to give each top candidate to present themselves after the vote ends.
|
||||
- **summary**: How long to give each top candidate to present themselves after the vote ends.
|
||||
|
||||
▸ **proxy**(`AccountId`): `Option<AccountId>`
|
||||
- **summary**: Who is able to vote for whom. Value is the fund-holding account, key is the vote-transaction-sending account.
|
||||
- **summary**: Who is able to vote for whom. Value is the fund-holding account, key is the vote-transaction-sending account.
|
||||
|
||||
▸ **registerInfoOf**(`AccountId`): `Option<(VoteIndex,u32)>`
|
||||
- **summary**: The vote index and list slot that the candidate `who` was registered or `None` if they are not currently registered.
|
||||
- **summary**: The vote index and list slot that the candidate `who` was registered or `None` if they are not currently registered.
|
||||
|
||||
▸ **termDuration**(): `BlockNumber`
|
||||
- **summary**: How long each position is active for.
|
||||
- **summary**: How long each position is active for.
|
||||
|
||||
▸ **voteCount**(): `VoteIndex`
|
||||
- **summary**: The total number of vote rounds that have happened or are in progress.
|
||||
- **summary**: The total number of vote rounds that have happened or are in progress.
|
||||
|
||||
▸ **voterCount**(): `SetIndex`
|
||||
- **summary**: Current number of Voters.
|
||||
- **summary**: Current number of Voters.
|
||||
|
||||
▸ **voterInfoOf**(`AccountId`): `Option<VoterInfo>`
|
||||
- **summary**: Basic information about a voter.
|
||||
- **summary**: Basic information about a voter.
|
||||
|
||||
▸ **voters**(`SetIndex`): `Vec<Option<AccountId>>`
|
||||
- **summary**: The present voter list (chunked and capped at [`VOTER_SET_SIZE`]).
|
||||
- **summary**: The present voter list (chunked and capped at [`VOTER_SET_SIZE`]).
|
||||
|
||||
___
|
||||
|
||||
@@ -270,25 +263,25 @@ ___
|
||||
### grandpa
|
||||
|
||||
▸ **authorities**(): `Vec<(AuthorityId,AuthorityWeight)>`
|
||||
- **summary**: The current authority set.
|
||||
- **summary**: The current authority set.
|
||||
|
||||
▸ **currentSetId**(): `SetId`
|
||||
- **summary**: The number of changes (both in terms of keys and underlying economic responsibilities) in the "set" of Grandpa validators from genesis.
|
||||
- **summary**: The number of changes (both in terms of keys and underlying economic responsibilities) in the "set" of Grandpa validators from genesis.
|
||||
|
||||
▸ **nextForced**(): `Option<BlockNumber>`
|
||||
- **summary**: next block number where we can force a change.
|
||||
- **summary**: next block number where we can force a change.
|
||||
|
||||
▸ **pendingChange**(): `Option<StoredPendingChange>`
|
||||
- **summary**: Pending change: (signaled at, scheduled change).
|
||||
- **summary**: Pending change: (signaled at, scheduled change).
|
||||
|
||||
▸ **setIdSession**(`SetId`): `Option<SessionIndex>`
|
||||
- **summary**: A mapping from grandpa set ID to the index of the *most recent* session for which its members were responsible.
|
||||
- **summary**: A mapping from grandpa set ID to the index of the *most recent* session for which its members were responsible.
|
||||
|
||||
▸ **stalled**(): `Option<(BlockNumber,BlockNumber)>`
|
||||
- **summary**: `true` if we are currently stalled.
|
||||
- **summary**: `true` if we are currently stalled.
|
||||
|
||||
▸ **state**(): `StoredState`
|
||||
- **summary**: State of the current authority set.
|
||||
- **summary**: State of the current authority set.
|
||||
|
||||
___
|
||||
|
||||
@@ -296,13 +289,13 @@ ___
|
||||
### imOnline
|
||||
|
||||
▸ **gossipAt**(): `BlockNumber`
|
||||
- **summary**: The block number when we should gossip.
|
||||
- **summary**: The block number when we should gossip.
|
||||
|
||||
▸ **keys**(): `Vec<AuthorityId>`
|
||||
- **summary**: The current set of keys that may issue a heartbeat.
|
||||
- **summary**: The current set of keys that may issue a heartbeat.
|
||||
|
||||
▸ **receivedHeartbeats**(`SessionIndex, AuthIndex`): `Bytes`
|
||||
- **summary**: For each session index we keep a mapping of `AuthorityId` to `offchain::OpaqueNetworkState`.
|
||||
- **summary**: For each session index we keep a mapping of `AuthorityId` to `offchain::OpaqueNetworkState`.
|
||||
|
||||
___
|
||||
|
||||
@@ -310,10 +303,10 @@ ___
|
||||
### indices
|
||||
|
||||
▸ **enumSet**(`AccountIndex`): `Vec<AccountId>`
|
||||
- **summary**: The enumeration sets.
|
||||
- **summary**: The enumeration sets.
|
||||
|
||||
▸ **nextEnumSet**(): `AccountIndex`
|
||||
- **summary**: The next free enumeration set.
|
||||
- **summary**: The next free enumeration set.
|
||||
|
||||
___
|
||||
|
||||
@@ -321,13 +314,13 @@ ___
|
||||
### offences
|
||||
|
||||
▸ **concurrentReportsIndex**(`Kind, OpaqueTimeSlot`): `Vec<ReportIdOf>`
|
||||
- **summary**: A vector of reports of the same kind that happened at the same time slot.
|
||||
- **summary**: A vector of reports of the same kind that happened at the same time slot.
|
||||
|
||||
▸ **reports**(`ReportIdOf`): `Option<OffenceDetails>`
|
||||
- **summary**: The primary structure that holds all offence records keyed by report identifiers.
|
||||
- **summary**: The primary structure that holds all offence records keyed by report identifiers.
|
||||
|
||||
▸ **reportsByKindIndex**(`Kind`): `Bytes`
|
||||
- **summary**: Enumerates all reports of a kind along with the time they happened. All reports are sorted by the time of offence. Note that the actual type of this mapping is `Vec<u8>`, this is because values of different types are not supported at the moment so we are doing the manual serialization.
|
||||
- **summary**: Enumerates all reports of a kind along with the time they happened. All reports are sorted by the time of offence. Note that the actual type of this mapping is `Vec<u8>`, this is because values of different types are not supported at the moment so we are doing the manual serialization.
|
||||
|
||||
___
|
||||
|
||||
@@ -335,22 +328,25 @@ ___
|
||||
### session
|
||||
|
||||
▸ **currentIndex**(): `SessionIndex`
|
||||
- **summary**: Current index of the session.
|
||||
- **summary**: Current index of the session.
|
||||
|
||||
▸ **disabledValidators**(): `Vec<u32>`
|
||||
- **summary**: Indices of disabled validators. The set is cleared when `on_session_ending` returns a new set of identities.
|
||||
|
||||
▸ **keyOwner**(`Bytes, (KeyTypeId,Bytes)`): `Option<ValidatorId>`
|
||||
- **summary**: The owner of a key. The second key is the `KeyTypeId` + the encoded key. The first key is always `DEDUP_KEY_PREFIX` to have all the data in the same branch of the trie. Having all data in the same branch should prevent slowing down other queries.
|
||||
- **summary**: The owner of a key. The second key is the `KeyTypeId` + the encoded key. The first key is always `DEDUP_KEY_PREFIX` to have all the data in the same branch of the trie. Having all data in the same branch should prevent slowing down other queries.
|
||||
|
||||
▸ **nextKeys**(`Bytes, ValidatorId`): `Option<Keys>`
|
||||
- **summary**: The next session keys for a validator. The first key is always `DEDUP_KEY_PREFIX` to have all the data in the same branch of the trie. Having all data in the same branch should prevent slowing down other queries.
|
||||
- **summary**: The next session keys for a validator. The first key is always `DEDUP_KEY_PREFIX` to have all the data in the same branch of the trie. Having all data in the same branch should prevent slowing down other queries.
|
||||
|
||||
▸ **queuedChanged**(): `bool`
|
||||
- **summary**: True if the underlying economic identities or weighting behind the validators has changed in the queued validator set.
|
||||
- **summary**: True if the underlying economic identities or weighting behind the validators has changed in the queued validator set.
|
||||
|
||||
▸ **queuedKeys**(): `Vec<(ValidatorId,Keys)>`
|
||||
- **summary**: The queued keys for the next session. When the next session begins, these keys will be used to determine the validator's session keys.
|
||||
- **summary**: The queued keys for the next session. When the next session begins, these keys will be used to determine the validator's session keys.
|
||||
|
||||
▸ **validators**(): `Vec<ValidatorId>`
|
||||
- **summary**: The current set of validators.
|
||||
- **summary**: The current set of validators.
|
||||
|
||||
___
|
||||
|
||||
@@ -358,61 +354,61 @@ ___
|
||||
### staking
|
||||
|
||||
▸ **bonded**(`AccountId`): `Option<AccountId>`
|
||||
- **summary**: Map from all locked "stash" accounts to the controller account.
|
||||
- **summary**: Map from all locked "stash" accounts to the controller account.
|
||||
|
||||
▸ **bondedEras**(): `Vec<(EraIndex,SessionIndex)>`
|
||||
- **summary**: A mapping from still-bonded eras to the first session index of that era.
|
||||
- **summary**: A mapping from still-bonded eras to the first session index of that era.
|
||||
|
||||
▸ **currentElected**(): `Vec<AccountId>`
|
||||
- **summary**: The currently elected validator set keyed by stash account ID.
|
||||
- **summary**: The currently elected validator set keyed by stash account ID.
|
||||
|
||||
▸ **currentEra**(): `EraIndex`
|
||||
- **summary**: The current era index.
|
||||
- **summary**: The current era index.
|
||||
|
||||
▸ **currentEraPointsEarned**(): `EraPoints`
|
||||
- **summary**: Rewards for the current era. Using indices of current elected set.
|
||||
- **summary**: Rewards for the current era. Using indices of current elected set.
|
||||
|
||||
▸ **currentEraStart**(): `MomentOf`
|
||||
- **summary**: The start of the current era.
|
||||
- **summary**: The start of the current era.
|
||||
|
||||
▸ **currentEraStartSessionIndex**(): `SessionIndex`
|
||||
- **summary**: The session index at which the current era started.
|
||||
- **summary**: The session index at which the current era started.
|
||||
|
||||
▸ **eraSlashJournal**(`EraIndex`): `Vec<SlashJournalEntry>`
|
||||
- **summary**: All slashes that have occurred in a given era.
|
||||
- **summary**: All slashes that have occurred in a given era.
|
||||
|
||||
▸ **forceEra**(): `Forcing`
|
||||
- **summary**: True if the next session change will be a new era regardless of index.
|
||||
- **summary**: True if the next session change will be a new era regardless of index.
|
||||
|
||||
▸ **invulnerables**(): `Vec<AccountId>`
|
||||
- **summary**: Any validators that may never be slashed or forcibly kicked. It's a Vec since they're easy to initialize and the performance hit is minimal (we expect no more than four invulnerables) and restricted to testnets.
|
||||
- **summary**: Any validators that may never be slashed or forcibly kicked. It's a Vec since they're easy to initialize and the performance hit is minimal (we expect no more than four invulnerables) and restricted to testnets.
|
||||
|
||||
▸ **ledger**(`AccountId`): `Option<StakingLedger>`
|
||||
- **summary**: Map from all (unlocked) "controller" accounts to the info regarding the staking.
|
||||
- **summary**: Map from all (unlocked) "controller" accounts to the info regarding the staking.
|
||||
|
||||
▸ **minimumValidatorCount**(): `u32`
|
||||
- **summary**: Minimum number of staking participants before emergency conditions are imposed.
|
||||
- **summary**: Minimum number of staking participants before emergency conditions are imposed.
|
||||
|
||||
▸ **nominators**(`AccountId`): `(Vec<AccountId>, Linkage<AccountId>)`
|
||||
- **summary**: The map from nominator stash key to the set of stash keys of all validators to nominate.
|
||||
- **summary**: The map from nominator stash key to the set of stash keys of all validators to nominate.
|
||||
|
||||
▸ **payee**(`AccountId`): `RewardDestination`
|
||||
- **summary**: Where the reward payment should be made. Keyed by stash.
|
||||
- **summary**: Where the reward payment should be made. Keyed by stash.
|
||||
|
||||
▸ **slashRewardFraction**(): `Perbill`
|
||||
- **summary**: The percentage of the slash that is distributed to reporters. The rest of the slashed value is handled by the `Slash`.
|
||||
- **summary**: The percentage of the slash that is distributed to reporters. The rest of the slashed value is handled by the `Slash`.
|
||||
|
||||
▸ **slotStake**(): `BalanceOf`
|
||||
- **summary**: The amount of balance actively at stake for each validator slot, currently. This is used to derive rewards and punishments.
|
||||
- **summary**: The amount of balance actively at stake for each validator slot, currently. This is used to derive rewards and punishments.
|
||||
|
||||
▸ **stakers**(`AccountId`): `Exposure`
|
||||
- **summary**: Nominators for a particular account that is in action right now. You can't iterate through validators here, but you can find them in the Session module. This is keyed by the stash account.
|
||||
- **summary**: Nominators for a particular account that is in action right now. You can't iterate through validators here, but you can find them in the Session module. This is keyed by the stash account.
|
||||
|
||||
▸ **validatorCount**(): `u32`
|
||||
- **summary**: The ideal number of staking participants.
|
||||
- **summary**: The ideal number of staking participants.
|
||||
|
||||
▸ **validators**(`AccountId`): `(ValidatorPrefs, Linkage<AccountId>)`
|
||||
- **summary**: The map from (wannabe) validator stash key to the preferences of that validator.
|
||||
- **summary**: The map from (wannabe) validator stash key to the preferences of that validator.
|
||||
|
||||
___
|
||||
|
||||
@@ -420,7 +416,7 @@ ___
|
||||
### sudo
|
||||
|
||||
▸ **key**(): `AccountId`
|
||||
- **summary**: The `AccountId` of the sudo key.
|
||||
- **summary**: The `AccountId` of the sudo key.
|
||||
|
||||
___
|
||||
|
||||
@@ -428,49 +424,49 @@ ___
|
||||
### system
|
||||
|
||||
▸ **accountNonce**(`AccountId`): `Index`
|
||||
- **summary**: Extrinsics nonce for accounts.
|
||||
- **summary**: Extrinsics nonce for accounts.
|
||||
|
||||
▸ **allExtrinsicsLen**(): `Option<u32>`
|
||||
- **summary**: Total length (in bytes) for all extrinsics put together, for the current block.
|
||||
- **summary**: Total length (in bytes) for all extrinsics put together, for the current block.
|
||||
|
||||
▸ **allExtrinsicsWeight**(): `Option<Weight>`
|
||||
- **summary**: Total weight for all extrinsics put together, for the current block.
|
||||
- **summary**: Total weight for all extrinsics put together, for the current block.
|
||||
|
||||
▸ **blockHash**(`BlockNumber`): `Hash`
|
||||
- **summary**: Map of block numbers to block hashes.
|
||||
- **summary**: Map of block numbers to block hashes.
|
||||
|
||||
▸ **digest**(): `DigestOf`
|
||||
- **summary**: Digest of the current block, also part of the block header.
|
||||
- **summary**: Digest of the current block, also part of the block header.
|
||||
|
||||
▸ **eventCount**(): `EventIndex`
|
||||
- **summary**: The number of events in the `Events<T>` list.
|
||||
- **summary**: The number of events in the `Events<T>` list.
|
||||
|
||||
▸ **events**(): `Vec<EventRecord>`
|
||||
- **summary**: Events deposited for the current block.
|
||||
- **summary**: Events deposited for the current block.
|
||||
|
||||
▸ **eventTopics**(`Null, Hash`): `Vec<(BlockNumber,EventIndex)>`
|
||||
- **summary**: Mapping between a topic (represented by T::Hash) and a vector of indexes of events in the `<Events<T>>` list. The first key serves no purpose. This field is declared as double_map just for convenience of using `remove_prefix`. All topic vectors have deterministic storage locations depending on the topic. This allows light-clients to leverage the changes trie storage tracking mechanism and in case of changes fetch the list of events of interest. The value has the type `(T::BlockNumber, EventIndex)` because if we used only just the `EventIndex` then in case if the topic has the same contents on the next block no notification will be triggered thus the event might be lost.
|
||||
- **summary**: Mapping between a topic (represented by T::Hash) and a vector of indexes of events in the `<Events<T>>` list. The first key serves no purpose. This field is declared as double_map just for convenience of using `remove_prefix`. All topic vectors have deterministic storage locations depending on the topic. This allows light-clients to leverage the changes trie storage tracking mechanism and in case of changes fetch the list of events of interest. The value has the type `(T::BlockNumber, EventIndex)` because if we used only just the `EventIndex` then in case if the topic has the same contents on the next block no notification will be triggered thus the event might be lost.
|
||||
|
||||
▸ **extrinsicCount**(): `Option<u32>`
|
||||
- **summary**: Total extrinsics count for the current block.
|
||||
- **summary**: Total extrinsics count for the current block.
|
||||
|
||||
▸ **extrinsicData**(`u32`): `Bytes`
|
||||
- **summary**: Extrinsics data for the current block (maps an extrinsic's index to its data).
|
||||
- **summary**: Extrinsics data for the current block (maps an extrinsic's index to its data).
|
||||
|
||||
▸ **extrinsicsRoot**(): `Hash`
|
||||
- **summary**: Extrinsics root of the current block, also part of the block header.
|
||||
- **summary**: Extrinsics root of the current block, also part of the block header.
|
||||
|
||||
▸ **nextWeightMultiplier**(): `WeightMultiplier`
|
||||
- **summary**: The next weight multiplier. This should be updated at the end of each block based on the saturation level (weight).
|
||||
- **summary**: The next weight multiplier. This should be updated at the end of each block based on the saturation level (weight).
|
||||
|
||||
▸ **number**(): `BlockNumber`
|
||||
- **summary**: The current block number being processed. Set by `execute_block`.
|
||||
- **summary**: The current block number being processed. Set by `execute_block`.
|
||||
|
||||
▸ **parentHash**(): `Hash`
|
||||
- **summary**: Hash of the previous block.
|
||||
- **summary**: Hash of the previous block.
|
||||
|
||||
▸ **randomMaterial**(): `(i8,Vec<Hash>)`
|
||||
- **summary**: Series of block headers from the last 81 blocks that acts as random seed material. This is arranged as a ring buffer with the `i8` prefix being the index into the `Vec` of the oldest hash.
|
||||
- **summary**: Series of block headers from the last 81 blocks that acts as random seed material. This is arranged as a ring buffer with the `i8` prefix being the index into the `Vec` of the oldest hash.
|
||||
|
||||
___
|
||||
|
||||
@@ -478,19 +474,19 @@ ___
|
||||
### technicalCommittee
|
||||
|
||||
▸ **members**(): `Vec<AccountId>`
|
||||
- **summary**: The current members of the collective. This is stored sorted (just by value).
|
||||
- **summary**: The current members of the collective. This is stored sorted (just by value).
|
||||
|
||||
▸ **proposalCount**(): `u32`
|
||||
- **summary**: Proposals so far.
|
||||
- **summary**: Proposals so far.
|
||||
|
||||
▸ **proposalOf**(`Hash`): `Option<Proposal>`
|
||||
- **summary**: Actual proposal for a given hash, if it's current.
|
||||
- **summary**: Actual proposal for a given hash, if it's current.
|
||||
|
||||
▸ **proposals**(): `Vec<Hash>`
|
||||
- **summary**: The hashes of the active proposals.
|
||||
- **summary**: The hashes of the active proposals.
|
||||
|
||||
▸ **voting**(`Hash`): `Option<Votes>`
|
||||
- **summary**: Votes on a given proposal, if it is ongoing.
|
||||
- **summary**: Votes on a given proposal, if it is ongoing.
|
||||
|
||||
___
|
||||
|
||||
@@ -498,7 +494,7 @@ ___
|
||||
### technicalMembership
|
||||
|
||||
▸ **members**(): `Vec<AccountId>`
|
||||
- **summary**: The current membership, stored as an ordered Vec.
|
||||
- **summary**: The current membership, stored as an ordered Vec.
|
||||
|
||||
___
|
||||
|
||||
@@ -506,10 +502,10 @@ ___
|
||||
### timestamp
|
||||
|
||||
▸ **didUpdate**(): `bool`
|
||||
- **summary**: Did the timestamp get updated in this block?
|
||||
- **summary**: Did the timestamp get updated in this block?
|
||||
|
||||
▸ **now**(): `Moment`
|
||||
- **summary**: Current time for the current block.
|
||||
- **summary**: Current time for the current block.
|
||||
|
||||
___
|
||||
|
||||
@@ -517,13 +513,13 @@ ___
|
||||
### treasury
|
||||
|
||||
▸ **approvals**(): `Vec<ProposalIndex>`
|
||||
- **summary**: Proposal indices that have been approved but not yet awarded.
|
||||
- **summary**: Proposal indices that have been approved but not yet awarded.
|
||||
|
||||
▸ **proposalCount**(): `ProposalIndex`
|
||||
- **summary**: Number of proposals that have been made.
|
||||
- **summary**: Number of proposals that have been made.
|
||||
|
||||
▸ **proposals**(`ProposalIndex`): `Option<TreasuryProposal>`
|
||||
- **summary**: Proposals that have been made.
|
||||
- **summary**: Proposals that have been made.
|
||||
|
||||
---
|
||||
|
||||
|
||||
+4
-3
@@ -6,8 +6,8 @@ module.exports = Object.assign({}, config, {
|
||||
moduleNameMapper: {
|
||||
'@polkadot/api-contract(.*)$': '<rootDir>/packages/api-contract/src/$1',
|
||||
'@polkadot/api-derive(.*)$': '<rootDir>/packages/api-derive/src/$1',
|
||||
'@polkadot/api-metadata(.*)$': '<rootDir>/packages/api-metadata/src/$1',
|
||||
'@polkadot/api(.*)$': '<rootDir>/packages/api/src/$1',
|
||||
'@polkadot/metadata(.*)$': '<rootDir>/packages/metadata/src/$1',
|
||||
'@polkadot/rpc-(core|provider)(.*)$': '<rootDir>/packages/rpc-$1/src/$2',
|
||||
'@polkadot/jsonrpc(.*)$': '<rootDir>/packages/type-jsonrpc/src/$1',
|
||||
'@polkadot/types(.*)$': '<rootDir>/packages/types/src/$1'
|
||||
@@ -16,7 +16,7 @@ module.exports = Object.assign({}, config, {
|
||||
'<rootDir>/packages/api/build',
|
||||
'<rootDir>/packages/api-derive/build',
|
||||
'<rootDir>/packages/api-contract/build',
|
||||
'<rootDir>/packages/api-metadata/build',
|
||||
'<rootDir>/packages/metadata/build',
|
||||
'<rootDir>/packages/rpc-core/build',
|
||||
'<rootDir>/packages/rpc-provider/build',
|
||||
'<rootDir>/packages/type-jsonrpc/build',
|
||||
@@ -31,5 +31,6 @@ module.exports = Object.assign({}, config, {
|
||||
ws_local_polkadot_alex: 'ws://127.0.0.1:9949/',
|
||||
ws_substrate_1: 'wss://substrate-rpc.parity.io/',
|
||||
ws_polkadot_alex: 'wss://poc3-rpc.polkadot.io/'
|
||||
}
|
||||
},
|
||||
resolver: './jest.resolver.js'
|
||||
});
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
// Copyright 2017-2020 @polkadot/util authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||
const path = require('path');
|
||||
|
||||
module.exports = function resolver (file, config) {
|
||||
if (file.includes('package.json')) {
|
||||
console.error(file, config);
|
||||
return path.join(config.basedir.replace('/src', '/'), file);
|
||||
}
|
||||
|
||||
return config.defaultResolver(file, config);
|
||||
};
|
||||
+1
-1
@@ -9,5 +9,5 @@
|
||||
"packages": [
|
||||
"packages/*"
|
||||
],
|
||||
"version": "0.92.1"
|
||||
"version": "1.1.1"
|
||||
}
|
||||
|
||||
+10
-15
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"version": "0.92.1",
|
||||
"version": "1.1.1",
|
||||
"private": true,
|
||||
"engines": {
|
||||
"yarn": "^1.10.1"
|
||||
@@ -9,32 +9,27 @@
|
||||
],
|
||||
"resolutions": {
|
||||
"babel-core": "^7.0.0-bridge.0",
|
||||
"typescript": "^3.6.3"
|
||||
"typescript": "^3.7.5"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "yarn build:interfaces && polkadot-dev-build-ts && yarn run build:methodsdoc && polkadot-dev-build-docs",
|
||||
"build:htmldoc": "yarn clean && typedoc --theme default --out docs/html",
|
||||
"build": "yarn build:interfaces && polkadot-dev-build-ts",
|
||||
"build:interfaces": "node packages/types/src/scripts/interfacesTsWrapper.js",
|
||||
"build:methodsdoc": "node packages/types/src/scripts/MetadataMdWrapper.js",
|
||||
"circular": "madge --circular --extensions ts ./",
|
||||
"docs": "node packages/types/src/scripts/MetadataMdWrapper.js && polkadot-dev-build-docs",
|
||||
"chain:info": "node packages/types/src/scripts/extractChainWrapper.js",
|
||||
"check": "yarn lint",
|
||||
"lint": "eslint --ext .js,.jsx,.ts,.tsx . && tsc --noEmit --pretty",
|
||||
"clean": "polkadot-dev-clean-build",
|
||||
"postinstall": "polkadot-dev-yarn-only",
|
||||
"test": "jest --coverage --runInBand --testPathIgnorePatterns e2e",
|
||||
"test:all": "jest",
|
||||
"test:e2e": "jest packages/api/test/e2e",
|
||||
"test:e2e-docker": "TEST_DOCKER=1 jest packages/api/test/e2e",
|
||||
"test:e2e-remote": "TEST_REMOTE=1 jest packages/api/test/e2e",
|
||||
"test:one": "jest",
|
||||
"test:watch": "jest --coverage --watch"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.6.0",
|
||||
"@babel/register": "^7.6.0",
|
||||
"@babel/runtime": "^7.6.0",
|
||||
"@polkadot/dev": "^0.31.0-beta.8",
|
||||
"@polkadot/ts": "^0.1.72",
|
||||
"gh-pages": "^2.1.1"
|
||||
"@babel/core": "^7.8.3",
|
||||
"@babel/register": "^7.8.3",
|
||||
"@babel/runtime": "^7.8.3",
|
||||
"@polkadot/dev": "^0.33.3",
|
||||
"@polkadot/ts": "^0.2.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,9 +3,12 @@
|
||||
Interfaces to allow for the encoding and decoding of Substrate contract ABIs.
|
||||
|
||||
```js
|
||||
import {ApiPromise, WsProvider } from '@polkadot/api';
|
||||
import { Abi } from '@polkadot/api-contract';
|
||||
|
||||
const abi = new Abi(<...JSON ABI...>);
|
||||
const wsProvider = new WsProvider(<...Node Url...>);
|
||||
const api = await ApiPromise.create({ provider: wsProvider });
|
||||
const abi = new Abi(api.registry, <...JSON ABI...>);
|
||||
|
||||
api.tx.contracts
|
||||
.call(<contract addr>, <value>, <max gas>, abi.messages.<method name>(<...params...>))
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/api-contract",
|
||||
"version": "0.92.1",
|
||||
"version": "1.1.1",
|
||||
"description": "Interfaces for interacting with contracts and contract ABIs",
|
||||
"main": "index.js",
|
||||
"keywords": [
|
||||
@@ -26,7 +26,7 @@
|
||||
},
|
||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/api-contract#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.6.0",
|
||||
"@polkadot/types": "^0.92.1"
|
||||
"@babel/runtime": "^7.8.3",
|
||||
"@polkadot/types": "^1.1.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,119 +1,25 @@
|
||||
// Copyright 2017-2019 @polkadot/api-contract authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { ContractABIArg } from './types';
|
||||
|
||||
import typesAbi from '../test/abi/types.json';
|
||||
import erc20Abi from '../test/contracts/Erc20.json';
|
||||
import { TypeRegistry } from '@polkadot/types';
|
||||
|
||||
import incrementerAbi from '../test/contracts/incrementer.json';
|
||||
import { Abi } from '.';
|
||||
|
||||
describe('Abi', (): void => {
|
||||
describe('types encoding', (): void => {
|
||||
let abi: Abi;
|
||||
const registry = new TypeRegistry();
|
||||
|
||||
beforeAll((): void => {
|
||||
abi = new Abi(typesAbi);
|
||||
});
|
||||
|
||||
function check (method: string, args: ContractABIArg[], type: string | null): void {
|
||||
const fn = abi.messages[method];
|
||||
|
||||
expect(fn.args).toEqual(args);
|
||||
expect(fn.type).toEqual(type);
|
||||
}
|
||||
|
||||
it('has the primitive method with args & return', (): void => {
|
||||
check(
|
||||
'primitive',
|
||||
[
|
||||
{ name: 'bool', type: 'bool' },
|
||||
{ name: 'u32', type: 'u32' }
|
||||
],
|
||||
'bool'
|
||||
);
|
||||
});
|
||||
|
||||
it('has the vector method with args & return', (): void => {
|
||||
check(
|
||||
'vector',
|
||||
[
|
||||
{ name: 'vecU8', type: 'Vec<u8>' },
|
||||
{ name: 'vecU32', type: 'Vec<u32>' }
|
||||
],
|
||||
'Vec<bool>'
|
||||
);
|
||||
});
|
||||
|
||||
it('has the vector_fixed method with args & return', (): void => {
|
||||
check(
|
||||
'vectorFixed',
|
||||
[
|
||||
{ name: 'vecU8Length32', type: '[u8;32]' }
|
||||
],
|
||||
'[u32;8]'
|
||||
);
|
||||
});
|
||||
|
||||
it('has the option method with args & return', (): void => {
|
||||
check(
|
||||
'option',
|
||||
[
|
||||
{ name: 'optionU32', type: 'Option<u32>' }
|
||||
],
|
||||
'Option<bool>'
|
||||
);
|
||||
});
|
||||
|
||||
it('has the result method with return (empty)', (): void => {
|
||||
check(
|
||||
'result',
|
||||
[],
|
||||
'()'
|
||||
);
|
||||
});
|
||||
|
||||
it('allows for nested args', (): void => {
|
||||
check(
|
||||
'nested',
|
||||
[
|
||||
{ name: 'optionVec', type: 'Option<Vec<u32>>' }
|
||||
],
|
||||
'Vec<(u32,u64)>'
|
||||
);
|
||||
});
|
||||
|
||||
describe('messages', (): void => {
|
||||
it('fails when invalid args are supplied', (): void => {
|
||||
expect(
|
||||
(): Uint8Array => abi.messages.primitive(false)
|
||||
).toThrow(/Expected 2 arguments to contract messages.primitive, found 1/);
|
||||
});
|
||||
|
||||
it('encodes primitives correctly', (): void => {
|
||||
expect(
|
||||
abi.messages.primitive(true, 0x12345678)
|
||||
).toEqual(new Uint8Array([
|
||||
9 << 2, // total length (4 + 1 + 4)
|
||||
0x67, 0x2b, 0, 0, // 11111 -> hex (LE)
|
||||
1, // true
|
||||
0x78, 0x56, 0x34, 0x12 // u32
|
||||
]));
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('erc20', (): void => {
|
||||
describe('incrementer', (): void => {
|
||||
let abi: Abi;
|
||||
|
||||
beforeEach((): void => {
|
||||
abi = new Abi(erc20Abi);
|
||||
abi = new Abi(registry, incrementerAbi);
|
||||
});
|
||||
|
||||
it('has the attached methods', (): void => {
|
||||
expect(Object.keys(abi.messages)).toEqual(
|
||||
['totalSupply', 'balanceOf', 'allowance', 'transfer', 'approve', 'transferFrom']
|
||||
expect(Object.values(abi.abi.contract.messages).map(({ name }): string => name)).toEqual(
|
||||
['inc', 'get', 'compare']
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,31 +1,48 @@
|
||||
// Copyright 2017-2019 @polkadot/api-contract authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { ContractABI, ContractABIFn, InterfaceAbi, AbiMessages } from './types';
|
||||
import { Registry } from '@polkadot/types/types';
|
||||
import { AbiConstructors, AbiMessages, ContractABI, ContractABIPre, ContractABIFn, InterfaceAbi } from './types';
|
||||
|
||||
import { stringCamelCase } from '@polkadot/util';
|
||||
|
||||
import { createMethod } from './method';
|
||||
import { validateAbi } from './validation';
|
||||
import ContractRegistry from './ContractRegistry';
|
||||
|
||||
export default class ContractAbi implements InterfaceAbi {
|
||||
export default class ContractAbi extends ContractRegistry implements InterfaceAbi {
|
||||
public readonly abi: ContractABI;
|
||||
|
||||
public readonly deploy: ContractABIFn;
|
||||
public readonly constructors: AbiConstructors;
|
||||
|
||||
public readonly messages: AbiMessages = {};
|
||||
public readonly messages: AbiMessages;
|
||||
|
||||
public constructor (abi: ContractABI) {
|
||||
validateAbi(abi);
|
||||
constructor (registry: Registry, abi: ContractABIPre) {
|
||||
super(registry, abi);
|
||||
[this.abi, this.constructors, this.messages] = this.decodeAbi(abi);
|
||||
}
|
||||
|
||||
this.abi = abi;
|
||||
this.deploy = createMethod('deploy', abi.deploy);
|
||||
private decodeAbi (abiPre: ContractABIPre): [ContractABI, ContractABIFn[], AbiMessages] {
|
||||
this.validateAbi(abiPre);
|
||||
|
||||
abi.messages.forEach((method): void => {
|
||||
const name = stringCamelCase(method.name);
|
||||
const abi = this.convertAbi(abiPre);
|
||||
const constructors = abi.contract.constructors.map(
|
||||
(constructor, index): ContractABIFn => {
|
||||
return this.createMessage(`constructor ${index}`, constructor);
|
||||
}
|
||||
);
|
||||
|
||||
this.messages[name] = createMethod(`messages.${name}`, method);
|
||||
});
|
||||
const messages: AbiMessages = abi.contract.messages.reduce(
|
||||
(result: AbiMessages, message): AbiMessages => {
|
||||
const name = stringCamelCase(message.name);
|
||||
|
||||
return {
|
||||
...result,
|
||||
[name]: this.createMessage(`messages.${name}`, message)
|
||||
};
|
||||
},
|
||||
{}
|
||||
);
|
||||
|
||||
return [abi, constructors, messages];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,221 @@
|
||||
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { CodecArg, Constructor, Registry, TypeDef } from '@polkadot/types/types';
|
||||
import { ContractABIArgBasePre, ContractABIContract, ContractABIContractPre, ContractABIEvent, ContractABIEventPre, ContractABIFn, ContractABIFnArg, ContractABIMessage, ContractABIMessageBase, ContractABIMessagePre, ContractABI, ContractABIMessageCommon, ContractABIPre, ContractABIRange, ContractABIRangePre, ContractABIStorage, ContractABIStorageLayout, ContractABIStorageLayoutPre, ContractABIStoragePre, ContractABIStorageStruct, ContractABIStorageStructPre, ContractABITypePre } from './types';
|
||||
|
||||
import { Compact, u32, createClass, createType, encodeType } from '@polkadot/types';
|
||||
import { assert, hexToU8a, isNumber, isString, isNull, isObject, isUndefined, stringCamelCase, isHex, hexToNumber } from '@polkadot/util';
|
||||
|
||||
import MetaRegistry from './MetaRegistry';
|
||||
|
||||
// parse a selector, this can be a number (older) or of [<hex>, <hex>, ...]. However,
|
||||
// just catch everything (since this is now non-standard for u32 anyway)
|
||||
function parseSelector (registry: Registry, fnname: string, input: ContractABIMessageCommon['selector']): u32 {
|
||||
if (isNumber(input)) {
|
||||
return createType(registry, 'u32', input);
|
||||
} else if (isHex(input)) {
|
||||
return createType(registry, 'u32', hexToU8a(input));
|
||||
} else if (typeof input === 'string') {
|
||||
try {
|
||||
const array = JSON.parse(input);
|
||||
|
||||
assert(array.length === 4, `${fnname}: Invalid selector length`);
|
||||
|
||||
return createType(registry, 'u32', Uint8Array.from(
|
||||
// the as number[] is here to pacify TS, it doesn't quite know how to handle the cb
|
||||
(array as number[]).map((value: string | number): number =>
|
||||
isHex(value)
|
||||
? hexToNumber(value.toString())
|
||||
: value
|
||||
)
|
||||
));
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
throw new Error(`${fnname}: Unable to parse selector`);
|
||||
}
|
||||
|
||||
function createArgClass (registry: Registry, args: ContractABIFnArg[], baseDef: Record<string, string>): Constructor {
|
||||
return createClass(
|
||||
registry,
|
||||
JSON.stringify(
|
||||
args.reduce((base: Record<string, any>, { name, type }): Record<string, any> => {
|
||||
base[name] = type.displayName || encodeType(type);
|
||||
|
||||
return base;
|
||||
}, baseDef)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
export default class ContractRegistry extends MetaRegistry {
|
||||
// Contract ABI helpers
|
||||
public validateArgs (name: string, args: ContractABIArgBasePre[]): void {
|
||||
assert(Array.isArray(args), `Expected 'args' to exist on ${name}`);
|
||||
|
||||
args.forEach((arg): void => {
|
||||
const unknownKeys = Object.keys(arg).filter((key): boolean => !['name', 'type'].includes(key));
|
||||
|
||||
assert(unknownKeys.length === 0, `Unknown keys ${unknownKeys.join(', ')} found in ABI args for ${name}`);
|
||||
assert(isNumber(arg.name) && isString(this.stringAt(arg.name)), `${name} args should have valid name `);
|
||||
assert(isNumber(arg.type.ty) && isObject(this.typeDefAt(arg.type.ty)), `${name} args should have valid type`);
|
||||
});
|
||||
}
|
||||
|
||||
public validateConstructors ({ contract: { constructors } }: ContractABIPre): void {
|
||||
constructors.forEach((constructor: ContractABIMessagePre, index): void => {
|
||||
const unknownKeys = Object.keys(constructor).filter((key): boolean => !['args', 'docs', 'name', 'selector'].includes(key));
|
||||
|
||||
assert(unknownKeys.length === 0, `Unknown keys ${unknownKeys.join(', ')} found in ABI constructor`);
|
||||
|
||||
this.validateArgs(`constructor ${index}`, constructor.args);
|
||||
});
|
||||
}
|
||||
|
||||
public validateMessages ({ contract: { messages } }: ContractABIPre): void {
|
||||
messages.forEach((message): void => {
|
||||
const unknownKeys = Object.keys(message).filter((key): boolean => !['args', 'docs', 'mutates', 'name', 'selector', 'return_type'].includes(key));
|
||||
const fnname = `messages.${message.name}`;
|
||||
|
||||
assert(unknownKeys.length === 0, `Unknown keys ${unknownKeys.join(', ')} found in ABI args for messages.${message.name}`);
|
||||
|
||||
const { name, selector, return_type: returnType } = message;
|
||||
|
||||
assert(isNumber(name) && isString(this.stringAt(name)), `Expected name for ${fnname}`);
|
||||
assert(isNull(returnType) || (isNumber(returnType.ty) && isObject(this.typeDefAt(returnType.ty))), `Expected return_type for ${fnname}`);
|
||||
|
||||
parseSelector(this.registry, fnname, selector);
|
||||
this.validateArgs(fnname, message.args);
|
||||
});
|
||||
}
|
||||
|
||||
public validateAbi (abi: ContractABIPre): void {
|
||||
const unknownKeys = Object.keys(abi.contract).filter((key): boolean => !['constructors', 'docs', 'events', 'messages', 'name'].includes(key));
|
||||
|
||||
assert(unknownKeys.length === 0, `Unknown fields ${unknownKeys.join(', ')} found in ABI`);
|
||||
|
||||
const { contract: { constructors, messages, name } } = abi;
|
||||
|
||||
assert(constructors && messages && isString(this.stringAt(name)), 'ABI should have constructors, messages & name sections');
|
||||
|
||||
this.validateConstructors(abi);
|
||||
this.validateMessages(abi);
|
||||
}
|
||||
|
||||
public createMessage (name: string, message: Partial<ContractABIMessage> & ContractABIMessageBase): ContractABIFn {
|
||||
const args = message.args.map(({ name, type }): ContractABIFnArg => {
|
||||
assert(isObject(type), `Invalid type at index ${type}`);
|
||||
return {
|
||||
name: stringCamelCase(name),
|
||||
type
|
||||
};
|
||||
});
|
||||
const Clazz = createArgClass(this.registry, args, isUndefined(message.selector) ? {} : { __selector: 'u32' });
|
||||
const baseStruct: { [index: string]: any } = { __selector: isUndefined(message.selector) ? undefined : parseSelector(this.registry, name, message.selector) };
|
||||
const encoder = (...params: CodecArg[]): Uint8Array => {
|
||||
assert(params.length === args.length, `Expected ${args.length} arguments to contract ${name}, found ${params.length}`);
|
||||
|
||||
const u8a = new Clazz(
|
||||
this.registry,
|
||||
args.reduce((mapped, { name }, index): Record<string, CodecArg> => {
|
||||
mapped[name] = params[index];
|
||||
|
||||
return mapped;
|
||||
}, { ...baseStruct })
|
||||
).toU8a();
|
||||
|
||||
return Compact.addLengthPrefix(u8a);
|
||||
};
|
||||
|
||||
const fn = (encoder as ContractABIFn);
|
||||
|
||||
fn.args = args;
|
||||
fn.isConstant = !(message.mutates || false);
|
||||
fn.type = message.returnType || null;
|
||||
return fn;
|
||||
}
|
||||
|
||||
public convertAbi ({ contract, storage }: ContractABIPre): ContractABI {
|
||||
return {
|
||||
contract: this.convertContract(contract),
|
||||
storage: this.convertStorage(storage)
|
||||
};
|
||||
}
|
||||
|
||||
public convertArgs (args: ContractABIArgBasePre[]): any[] {
|
||||
return args.map(({ name, type, ...arg }) => ({ ...arg, name: this.stringAt(name), type: this.convertType(type) }));
|
||||
}
|
||||
|
||||
public convertType ({ ty, display_name: displayNameIndices }: ContractABITypePre): TypeDef {
|
||||
const displayName = this.stringsAt(displayNameIndices).join('::');
|
||||
return this.typeDefAt(ty, { displayName });
|
||||
}
|
||||
|
||||
public convertContract ({ constructors, messages, name, events, ...contract }: ContractABIContractPre): ContractABIContract {
|
||||
return {
|
||||
constructors: this.convertConstructors(constructors),
|
||||
messages: messages.map(message => this.convertMessage(message)),
|
||||
name: this.stringAt(name),
|
||||
...(events
|
||||
? { events: events.map(event => this.convertEvent(event)) }
|
||||
: {}),
|
||||
...contract
|
||||
};
|
||||
}
|
||||
|
||||
public convertConstructors (constructors: ContractABIMessagePre[]): ContractABIMessage[] {
|
||||
return constructors.map(
|
||||
(constructor: ContractABIMessagePre): ContractABIMessage => {
|
||||
return this.convertMessage(constructor);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
public convertMessage ({ args, name, return_type: returnType, ...message }: ContractABIMessagePre): ContractABIMessage {
|
||||
return {
|
||||
...message,
|
||||
args: this.convertArgs(args),
|
||||
name: this.stringAt(name),
|
||||
returnType: returnType ? this.convertType(returnType) : null
|
||||
};
|
||||
}
|
||||
|
||||
public convertEvent ({ args }: ContractABIEventPre): ContractABIEvent {
|
||||
return {
|
||||
args: this.convertArgs(args)
|
||||
};
|
||||
}
|
||||
|
||||
public convertStorage (storage: ContractABIStoragePre): ContractABIStorage {
|
||||
return this.convertStorageStruct(storage);
|
||||
}
|
||||
|
||||
public convertStorageLayout (storageLayout: ContractABIStorageLayoutPre): ContractABIStorageLayout {
|
||||
if ((storageLayout as ContractABIStorageStructPre)['struct.type']) {
|
||||
return this.convertStorageStruct(storageLayout as ContractABIStorageStructPre);
|
||||
} else {
|
||||
return this.convertStorageRange(storageLayout as ContractABIRangePre);
|
||||
}
|
||||
}
|
||||
|
||||
public convertStorageStruct ({ 'struct.type': structType, 'struct.fields': structFields }: ContractABIStorageStructPre): ContractABIStorageStruct {
|
||||
return {
|
||||
'struct.type': this.typeDefAt(structType),
|
||||
'struct.fields': structFields.map(({ name, layout }) => ({
|
||||
name: this.stringAt(name),
|
||||
layout: this.convertStorageLayout(layout)
|
||||
}))
|
||||
};
|
||||
}
|
||||
|
||||
public convertStorageRange ({ 'range.elem_type': type, ...range }: ContractABIRangePre): ContractABIRange {
|
||||
return {
|
||||
...range,
|
||||
'range.elem_type': this.typeDefAt(type)
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
// Copyright 2017-2020 @polkadot/types authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { TypeRegistry } from '@polkadot/types';
|
||||
|
||||
import MetaRegistry from './MetaRegistry';
|
||||
|
||||
import erc20Abi from '../test/contracts/Erc20.json';
|
||||
import erc20Cmp from '../test/compare/erc20.test.json';
|
||||
import sharedVecAbi from '../test/contracts/SharedVecV2.json';
|
||||
import sharedVecCmp from '../test/compare/shared-vec.test.json';
|
||||
import test001Abi from '../test/abi/test001.json';
|
||||
import test001Cmp from '../test/compare/test001.cmp.json';
|
||||
|
||||
function compare (meta: MetaRegistry, other: any): void {
|
||||
try {
|
||||
expect(meta.typeDefs).toEqual(other);
|
||||
} catch (error) {
|
||||
console.error(JSON.stringify(meta.typeDefs));
|
||||
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
describe('MetaRegistry', (): void => {
|
||||
const registry = new TypeRegistry();
|
||||
|
||||
describe('construction', (): void => {
|
||||
it('initializes from a contract ABI (ERC20)', (): void => {
|
||||
compare(new MetaRegistry(registry, erc20Abi), erc20Cmp);
|
||||
});
|
||||
|
||||
it('initializes from a contract ABI (SharedVec)', (): void => {
|
||||
compare(new MetaRegistry(registry, sharedVecAbi), sharedVecCmp);
|
||||
});
|
||||
|
||||
it('initializes from a contract ABI (Other, test001)', (): void => {
|
||||
compare(new MetaRegistry(registry, test001Abi), test001Cmp);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,351 @@
|
||||
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { MetaRegistryItem, MetaRegistryJson, MetaTypeDefClikeEnum, MetaType, MetaTypeDefEnum, MetaTypeDefEnumVariant, MetaTypeDefEnumVariantStruct, MetaTypeDefEnumVariantTupleStruct, MetaTypeDefEnumVariantUnit, MetaTypeDefStruct, MetaTypeDefStructField, MetaTypeDefTupleStruct, MetaTypeDefUnion, MetaTypeIdCustom, MetaTypeIdVec, MetaTypeIdVecFixed, MetaTypeInfo, Registry, StringIndex, TypeDef, TypeDefInfo, TypeIndex } from '@polkadot/types/types';
|
||||
|
||||
import { assert } from '@polkadot/util';
|
||||
import { displayType, withTypeString } from '@polkadot/types';
|
||||
|
||||
const builtinMap: [(id: any) => boolean, MetaTypeInfo][] = [
|
||||
[(id: any): boolean => typeof id === 'string', MetaTypeInfo.BuiltinPlain],
|
||||
[(id: any): boolean => Array.isArray(id), MetaTypeInfo.BuiltinTuple],
|
||||
[(id: any): boolean => !!(id['array.type']), MetaTypeInfo.BuiltinVecFixed],
|
||||
[(id: any): boolean => !!(id['slice.type']), MetaTypeInfo.BuiltinVec]
|
||||
];
|
||||
|
||||
const typeMap: [string, MetaTypeInfo][] = [
|
||||
['enum.variants', MetaTypeInfo.Enum],
|
||||
['clike_enum.variants', MetaTypeInfo.ClikeEnum],
|
||||
['struct.fields', MetaTypeInfo.Struct],
|
||||
['tuple_struct.types', MetaTypeInfo.TupleStruct]
|
||||
];
|
||||
|
||||
function detectedType ({ def, id }: MetaType): MetaTypeInfo {
|
||||
assert(!(def as MetaTypeDefUnion)['union.fields'], 'Invalid union type definition found');
|
||||
|
||||
const lookup = def === 'builtin'
|
||||
? builtinMap.find(([test]): boolean => test(id))
|
||||
: typeMap.find(([test]): boolean => !!(def as any)[test]);
|
||||
|
||||
return lookup
|
||||
? lookup[1]
|
||||
: MetaTypeInfo.Null;
|
||||
}
|
||||
|
||||
class MetadataRegistryLookup {
|
||||
public readonly registry: Registry;
|
||||
|
||||
protected _strings: string[] = [];
|
||||
|
||||
protected _types: MetaType[] = [];
|
||||
|
||||
public typeDefs: TypeDef[] = [];
|
||||
|
||||
constructor (registry: Registry, { registry: { strings, types } }: MetaRegistryJson) {
|
||||
this.registry = registry;
|
||||
this._strings = strings;
|
||||
this._types = types;
|
||||
}
|
||||
|
||||
protected hasItemAt (index: number, variant: MetaRegistryItem): boolean {
|
||||
switch (variant) {
|
||||
case MetaRegistryItem.String:
|
||||
return this._strings && !!this._strings[index - 1];
|
||||
case MetaRegistryItem.Type:
|
||||
return this._types && !!this._types[index - 1];
|
||||
case MetaRegistryItem.TypeDef:
|
||||
return this.typeDefs && !!this.typeDefs[index - 1];
|
||||
}
|
||||
}
|
||||
|
||||
protected itemAt (index: number, variant: MetaRegistryItem): any {
|
||||
assert(this.hasItemAt(index, variant), `MetaRegistry: Invalid ${variant} index ${index} found in metadata`);
|
||||
|
||||
switch (variant) {
|
||||
case MetaRegistryItem.String:
|
||||
return this._strings[index - 1];
|
||||
case MetaRegistryItem.Type:
|
||||
return this._types[index - 1];
|
||||
case MetaRegistryItem.TypeDef:
|
||||
return this.typeDefs[index - 1];
|
||||
}
|
||||
}
|
||||
|
||||
protected itemsAt (indices: number[], variant: MetaRegistryItem): any[] {
|
||||
return indices.map((index: number): string => this.itemAt(index, variant));
|
||||
}
|
||||
|
||||
protected stringAt (index: StringIndex): string {
|
||||
return this.itemAt(index, MetaRegistryItem.String);
|
||||
}
|
||||
|
||||
public stringsAt (indices: StringIndex[]): string[] {
|
||||
return this.itemsAt(indices, MetaRegistryItem.String);
|
||||
}
|
||||
|
||||
public typeAt (index: TypeIndex): MetaType {
|
||||
return this.itemAt(index, MetaRegistryItem.Type);
|
||||
}
|
||||
|
||||
public typesAt (indices: TypeIndex[]): MetaType[] {
|
||||
return this.itemsAt(indices, MetaRegistryItem.Type);
|
||||
}
|
||||
|
||||
public hasTypeDefAt (index: TypeIndex): boolean {
|
||||
return this.hasItemAt(index, MetaRegistryItem.TypeDef);
|
||||
}
|
||||
|
||||
public typeDefAt (index: TypeIndex, extra: Pick<TypeDef, never> = {}): TypeDef {
|
||||
return {
|
||||
...this.itemAt(index, MetaRegistryItem.TypeDef),
|
||||
...extra
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export default class MetaRegistry extends MetadataRegistryLookup {
|
||||
constructor (registry: Registry, json: MetaRegistryJson) {
|
||||
super(registry, json);
|
||||
|
||||
// Generate TypeDefs for each provided registry type
|
||||
this._types.forEach((_, index: number): void => this.setTypeDefAtIndex(index + 1));
|
||||
}
|
||||
|
||||
public setTypeDefAtIndex (typeIndex: TypeIndex): void {
|
||||
this.typeDefs[typeIndex - 1] = this.typeDefFromMetaType(this.typeAt(typeIndex), typeIndex);
|
||||
}
|
||||
|
||||
private typeDefIdFields ({ id }: MetaType): Pick<TypeDef, never> {
|
||||
const { 'custom.name': nameIndex, 'custom.namespace': namespaceIndices, 'custom.params': paramsIndices } = id as MetaTypeIdCustom;
|
||||
|
||||
if (!nameIndex) {
|
||||
return {};
|
||||
}
|
||||
|
||||
return {
|
||||
name: this.stringAt(nameIndex),
|
||||
...(namespaceIndices && namespaceIndices.length
|
||||
? { namespace: this.stringsAt(namespaceIndices).join('::') }
|
||||
: {}
|
||||
),
|
||||
...(paramsIndices && paramsIndices.length
|
||||
? { params: this.typesAt(paramsIndices).map((type): TypeDef => this.typeDefFromMetaType(type)) }
|
||||
: {}
|
||||
)
|
||||
};
|
||||
}
|
||||
|
||||
private typeDefDefFields (metaType: MetaType, typeIndex?: TypeIndex): Pick<TypeDef, never> {
|
||||
let typeDef;
|
||||
|
||||
switch (detectedType(metaType)) {
|
||||
case MetaTypeInfo.BuiltinPlain:
|
||||
typeDef = this.typeDefForBuiltinPlain(metaType.id as string);
|
||||
break;
|
||||
case MetaTypeInfo.BuiltinTuple:
|
||||
typeDef = this.typeDefForBuiltinTuple(metaType.id as TypeIndex[]);
|
||||
break;
|
||||
case MetaTypeInfo.BuiltinVec:
|
||||
typeDef = this.typeDefForBuiltinVec(metaType.id as MetaTypeIdVec, typeIndex);
|
||||
break;
|
||||
case MetaTypeInfo.BuiltinVecFixed:
|
||||
typeDef = this.typeDefForBuiltinVecFixed(metaType.id as MetaTypeIdVecFixed, typeIndex);
|
||||
break;
|
||||
case MetaTypeInfo.Enum:
|
||||
typeDef = this.typeDefForEnum(metaType.def as MetaTypeDefEnum, metaType.id as MetaTypeIdCustom, typeIndex);
|
||||
break;
|
||||
case MetaTypeInfo.ClikeEnum:
|
||||
typeDef = this.typeDefForClikeEnum(metaType.def as MetaTypeDefClikeEnum);
|
||||
break;
|
||||
case MetaTypeInfo.Struct:
|
||||
typeDef = this.typeDefForStruct(metaType.def as MetaTypeDefStruct);
|
||||
break;
|
||||
case MetaTypeInfo.TupleStruct:
|
||||
typeDef = this.typeDefForTupleStruct(metaType.def as MetaTypeDefTupleStruct);
|
||||
break;
|
||||
case MetaTypeInfo.Null:
|
||||
default:
|
||||
throw new Error(`Invalid type detected at index ${typeIndex}`);
|
||||
}
|
||||
|
||||
return typeDef;
|
||||
}
|
||||
|
||||
public typeDefFromMetaType (metaType: MetaType, typeIndex?: TypeIndex): TypeDef {
|
||||
return withTypeString({
|
||||
info: TypeDefInfo.Null,
|
||||
type: '',
|
||||
...this.typeDefDefFields(metaType, typeIndex),
|
||||
...this.typeDefIdFields(metaType)
|
||||
}) as TypeDef;
|
||||
}
|
||||
|
||||
public typeDefFromMetaTypeAt (typeIndex: TypeIndex): TypeDef {
|
||||
if (!this.hasTypeDefAt(typeIndex)) {
|
||||
this.setTypeDefAtIndex(typeIndex);
|
||||
}
|
||||
|
||||
return this.typeDefAt(typeIndex);
|
||||
}
|
||||
|
||||
private typeDefForEnumVariant (variant: MetaTypeDefEnumVariant): Pick<TypeDef, any> {
|
||||
const { 'unit_variant.name': unitNameIndex } = variant as MetaTypeDefEnumVariantUnit;
|
||||
|
||||
if (unitNameIndex) {
|
||||
return {
|
||||
info: TypeDefInfo.Plain,
|
||||
name: this.stringAt(unitNameIndex),
|
||||
type: 'Null'
|
||||
};
|
||||
}
|
||||
|
||||
const { 'tuple_struct_variant.name': tupleStructVariantNameIndex } = variant as MetaTypeDefEnumVariantTupleStruct;
|
||||
|
||||
if (tupleStructVariantNameIndex) {
|
||||
return this.typeDefForTupleStruct(variant as MetaTypeDefEnumVariantTupleStruct);
|
||||
}
|
||||
|
||||
const { 'struct_variant.name': structVariantNameIndex } = variant as MetaTypeDefEnumVariantStruct;
|
||||
|
||||
if (structVariantNameIndex) {
|
||||
return this.typeDefForStruct(variant as MetaTypeDefEnumVariantStruct);
|
||||
}
|
||||
|
||||
return {
|
||||
info: TypeDefInfo.Null,
|
||||
type: 'Null'
|
||||
};
|
||||
}
|
||||
|
||||
private typeDefForBuiltinPlain (id: string): Pick<TypeDef, never> {
|
||||
return {
|
||||
info: TypeDefInfo.Plain,
|
||||
type: id
|
||||
};
|
||||
}
|
||||
|
||||
private typeDefForBuiltinTuple (id: TypeIndex[]): Pick<TypeDef, never> {
|
||||
const sub = id.map((tupleTypeIndex: number): TypeDef => this.typeDefFromMetaTypeAt(tupleTypeIndex));
|
||||
|
||||
return {
|
||||
info: TypeDefInfo.Tuple,
|
||||
sub
|
||||
};
|
||||
}
|
||||
|
||||
private typeDefForBuiltinVec (id: MetaTypeIdVec, typeIndex?: TypeIndex): Pick<TypeDef, never> {
|
||||
const { 'slice.type': vecTypeIndex } = id;
|
||||
|
||||
assert(!typeIndex || vecTypeIndex !== typeIndex, `MetaRegistry: self-referencing registry type at index ${typeIndex}`);
|
||||
|
||||
const type = displayType(this.typeDefFromMetaTypeAt(vecTypeIndex));
|
||||
assert(type && type.length > 0, `MetaRegistry: Invalid builtin Vec type found at index ${typeIndex}`);
|
||||
|
||||
return {
|
||||
info: TypeDefInfo.Vec,
|
||||
type: `Vec<${type}>`,
|
||||
sub: this.typeDefFromMetaTypeAt(vecTypeIndex)
|
||||
};
|
||||
}
|
||||
|
||||
private typeDefForBuiltinVecFixed (id: MetaTypeIdVecFixed, typeIndex?: TypeIndex): Pick<TypeDef, never> {
|
||||
const { 'array.type': vecTypeIndex, 'array.len': vecLength } = id;
|
||||
|
||||
assert(!vecLength || vecLength <= 256, 'MetaRegistry: Only support for [Type; <length>], where length <= 256');
|
||||
assert(!typeIndex || vecTypeIndex !== typeIndex, `MetaRegistry: self-referencing registry type at index ${typeIndex}`);
|
||||
|
||||
const type = displayType(this.typeDefFromMetaTypeAt(vecTypeIndex));
|
||||
assert(type && type.length > 0, `MetaRegistry: Invalid vector type found at index ${typeIndex}`);
|
||||
|
||||
return {
|
||||
info: TypeDefInfo.VecFixed,
|
||||
ext: { length: vecLength, type },
|
||||
type: `[${type};${vecLength}]`,
|
||||
sub: this.typeDefFromMetaTypeAt(vecTypeIndex)
|
||||
};
|
||||
}
|
||||
|
||||
private typeDefForEnum (def: MetaTypeDefEnum, id: MetaTypeIdCustom, typeIndex?: TypeIndex): Pick<TypeDef, any> {
|
||||
const name = id && this.stringAt(id['custom.name']);
|
||||
|
||||
switch (name) {
|
||||
case 'Option':
|
||||
return this.typeDefForOption(id, typeIndex);
|
||||
case 'Result':
|
||||
return this.typeDefForResult(id, typeIndex);
|
||||
default: {
|
||||
const sub = def['enum.variants'].map(variant => this.typeDefForEnumVariant(variant));
|
||||
|
||||
return {
|
||||
info: TypeDefInfo.Enum,
|
||||
sub
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private typeDefForClikeEnum (def: MetaTypeDefClikeEnum): Pick<TypeDef, never> {
|
||||
return {
|
||||
info: TypeDefInfo.Enum,
|
||||
sub: def['clike_enum.variants'].map(({ name: nameIndex, discriminant }): TypeDef => ({
|
||||
ext: { discriminant },
|
||||
info: TypeDefInfo.Plain,
|
||||
name: this.stringAt(nameIndex),
|
||||
type: 'Null'
|
||||
}))
|
||||
};
|
||||
}
|
||||
|
||||
public typeDefForOption (id: MetaTypeIdCustom, typeIndex?: TypeIndex): Pick<TypeDef, any> {
|
||||
assert(id['custom.params'] && id['custom.params'][0], `Invalid Option type defined at index ${typeIndex}`);
|
||||
|
||||
return {
|
||||
info: TypeDefInfo.Option,
|
||||
sub: this.typeDefFromMetaTypeAt(id['custom.params']![0])
|
||||
};
|
||||
}
|
||||
|
||||
public typeDefForResult (id: MetaTypeIdCustom, typeIndex?: TypeIndex): Pick<TypeDef, any> {
|
||||
assert(id['custom.params'] && id['custom.params'][0] && id['custom.params'][1], `Invalid Result type defined at index ${typeIndex}`);
|
||||
|
||||
return {
|
||||
info: TypeDefInfo.Result,
|
||||
sub: id['custom.params']!.map((typeIndex): TypeDef => this.typeDefFromMetaTypeAt(typeIndex))
|
||||
};
|
||||
}
|
||||
|
||||
public typeDefForStruct (def: MetaTypeDefStruct | MetaTypeDefEnumVariantStruct): Pick<TypeDef, any> {
|
||||
const structFields = (def as MetaTypeDefStruct)['struct.fields'] || (def as MetaTypeDefEnumVariantStruct)['struct_variant.fields'];
|
||||
const structNameIndex = (def as MetaTypeDefEnumVariantStruct)['struct_variant.name'];
|
||||
|
||||
return withTypeString({
|
||||
info: TypeDefInfo.Struct,
|
||||
...(structNameIndex
|
||||
? { name: this.stringAt(structNameIndex) }
|
||||
: {}
|
||||
),
|
||||
sub: structFields.map((field: MetaTypeDefStructField): TypeDef => ({
|
||||
...this.typeDefFromMetaTypeAt(field.type),
|
||||
name: this.stringAt(field.name)
|
||||
}))
|
||||
});
|
||||
}
|
||||
|
||||
private typeDefForTupleStruct (def: MetaTypeDefTupleStruct | MetaTypeDefEnumVariantTupleStruct): Pick<TypeDef, any> {
|
||||
const tupleStructTypes = (def as MetaTypeDefTupleStruct)['tuple_struct.types'] || (def as MetaTypeDefEnumVariantTupleStruct)['tuple_struct_variant.types'];
|
||||
const tupleStructNameIndex = (def as MetaTypeDefEnumVariantTupleStruct)['tuple_struct_variant.name'];
|
||||
|
||||
return withTypeString({
|
||||
info: TypeDefInfo.Tuple,
|
||||
...(tupleStructNameIndex
|
||||
? { name: this.stringAt(tupleStructNameIndex) }
|
||||
: {}
|
||||
),
|
||||
sub: tupleStructTypes.map((fieldIndex: number, index: number): TypeDef => ({
|
||||
...this.typeDefFromMetaTypeAt(fieldIndex),
|
||||
index
|
||||
}))
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
// Copyright 2017-2019 @polkadot/api-contract authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { SubmittableModuleExtrinsics } from '@polkadot/api/types';
|
||||
import { ApiObject, ContractABI, ContractBase } from './types';
|
||||
|
||||
import { assert } from '@polkadot/util';
|
||||
|
||||
import Abi from './Abi';
|
||||
|
||||
// NOTE Experimental, POC, bound to change
|
||||
export default abstract class RxBase implements ContractBase<'rxjs'> {
|
||||
public readonly abi: Abi;
|
||||
|
||||
public readonly api: ApiObject<'rxjs'>;
|
||||
|
||||
public readonly apiContracts: SubmittableModuleExtrinsics<'rxjs'>;
|
||||
|
||||
public constructor (api: ApiObject<'rxjs'>, abi: ContractABI | Abi) {
|
||||
this.abi = abi instanceof Abi
|
||||
? abi
|
||||
: new Abi(abi);
|
||||
this.api = api;
|
||||
|
||||
// cater for substrate 2.x & 1.x (in order)
|
||||
this.apiContracts = api.tx.contracts || api.tx.contract;
|
||||
|
||||
assert(this.apiContracts && this.apiContracts.putCode, 'You need to connect to a node with the contracts module, the metadata does not enable api.tx.contracts on this instance');
|
||||
}
|
||||
}
|
||||
@@ -1,70 +0,0 @@
|
||||
// Copyright 2017-2019 @polkadot/api-contract authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { SubmittableResultImpl } from '@polkadot/api/types';
|
||||
import { AccountId, Address, Hash } from '@polkadot/types/interfaces';
|
||||
import { IKeyringPair } from '@polkadot/types/types';
|
||||
import { ContractABI } from './types';
|
||||
|
||||
import BN from 'bn.js';
|
||||
import { Observable } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { ApiRx, SubmittableResult } from '@polkadot/api';
|
||||
import { createType } from '@polkadot/types';
|
||||
|
||||
import Abi from './Abi';
|
||||
import RxBase from './RxBase';
|
||||
import RxContract from './RxContract';
|
||||
|
||||
type BlueprintCreateResultSubscription = Observable<BlueprintCreateResult>;
|
||||
|
||||
export interface BlueprintCreate {
|
||||
signAndSend (account: IKeyringPair | string | AccountId | Address): BlueprintCreateResultSubscription;
|
||||
}
|
||||
|
||||
class BlueprintCreateResult extends SubmittableResult {
|
||||
public readonly contract?: RxContract;
|
||||
|
||||
public constructor (result: SubmittableResultImpl, contract?: RxContract) {
|
||||
super(result);
|
||||
|
||||
this.contract = contract;
|
||||
}
|
||||
}
|
||||
|
||||
// NOTE Experimental, POC, bound to change
|
||||
export default class Blueprint extends RxBase {
|
||||
public readonly codeHash: Hash;
|
||||
|
||||
public constructor (api: ApiRx, abi: ContractABI | Abi, codeHash: string | Hash) {
|
||||
super(api, abi);
|
||||
|
||||
this.codeHash = createType('Hash', codeHash);
|
||||
}
|
||||
|
||||
public deployContract (endowment: number | BN, maxGas: number | BN, ...params: any[]): BlueprintCreate {
|
||||
const signAndSend = (account: IKeyringPair | string | AccountId | Address): BlueprintCreateResultSubscription => {
|
||||
return this.apiContracts
|
||||
.create(endowment, maxGas, this.codeHash, this.abi.deploy(...params))
|
||||
.signAndSend(account)
|
||||
.pipe(map(this.createResult));
|
||||
};
|
||||
|
||||
return { signAndSend };
|
||||
}
|
||||
|
||||
private createResult = (result: SubmittableResult): BlueprintCreateResult => {
|
||||
let contract: RxContract | undefined;
|
||||
|
||||
if (result.isFinalized) {
|
||||
const record = result.findRecord('contract', 'Instantiated');
|
||||
|
||||
if (record) {
|
||||
contract = new RxContract(this.api, this.abi, record.event.data[1] as Address);
|
||||
}
|
||||
}
|
||||
|
||||
return new BlueprintCreateResult(result, contract);
|
||||
}
|
||||
}
|
||||
@@ -1,83 +0,0 @@
|
||||
// Copyright 2017-2019 @polkadot/api-contract authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { SubmittableResultImpl } from '@polkadot/api/types';
|
||||
import { AccountId, Address, Hash } from '@polkadot/types/interfaces';
|
||||
import { IKeyringPair } from '@polkadot/types/types';
|
||||
import { ContractABI } from './types';
|
||||
|
||||
import BN from 'bn.js';
|
||||
import { Observable } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { ApiRx, SubmittableResult } from '@polkadot/api';
|
||||
import { compactAddLength, u8aToU8a } from '@polkadot/util';
|
||||
|
||||
import Abi from './Abi';
|
||||
import RxBase from './RxBase';
|
||||
import RxBlueprint from './RxBlueprint';
|
||||
|
||||
// Ok, tried, failed, eventually ... well, we are only trying with RxJs as a
|
||||
// start, so take a big fat shortcut with this version, real intended version
|
||||
// follows this and is commented out
|
||||
type CodePutCodeResultSubscription = Observable<CodePutCodeResult>;
|
||||
// type ICodePutCodeResultSubscription<ApiType> =
|
||||
// ApiType extends 'rxjs'
|
||||
// ? Observable<CodePutCodeResult>
|
||||
// : Promise<() => void>;
|
||||
|
||||
// unlike the ISubmittableExtrinsic, it doesn't extend IExtrinsic and only
|
||||
// implements one var iant of signAndSend - this is purely done to see what
|
||||
// is hanging where, with the bare-mainimum from a simplicity perspective
|
||||
// Very obvious is that it supports only 1 version of signAndSend
|
||||
// (we need to revisit this, but probably ok for initial?)
|
||||
// eslint-disable-next-line @typescript-eslint/interface-name-prefix
|
||||
export interface CodePutCode {
|
||||
signAndSend (account: IKeyringPair | string | AccountId | Address): CodePutCodeResultSubscription;
|
||||
}
|
||||
|
||||
class CodePutCodeResult extends SubmittableResult {
|
||||
public readonly blueprint?: RxBlueprint;
|
||||
|
||||
public constructor (result: SubmittableResultImpl, blueprint?: RxBlueprint) {
|
||||
super(result);
|
||||
|
||||
this.blueprint = blueprint;
|
||||
}
|
||||
}
|
||||
|
||||
// NOTE Experimental, POC, bound to change
|
||||
export default class RxCode extends RxBase {
|
||||
public readonly code: Uint8Array;
|
||||
|
||||
public constructor (api: ApiRx, abi: ContractABI | Abi, wasm: string | Uint8Array) {
|
||||
super(api, abi);
|
||||
|
||||
this.code = u8aToU8a(wasm);
|
||||
}
|
||||
|
||||
public createBlueprint (maxGas: number | BN): CodePutCode {
|
||||
const signAndSend = (account: IKeyringPair | string | AccountId | Address): CodePutCodeResultSubscription => {
|
||||
return this.apiContracts
|
||||
.putCode(maxGas, compactAddLength(this.code))
|
||||
.signAndSend(account)
|
||||
.pipe(map(this.createResult));
|
||||
};
|
||||
|
||||
return { signAndSend };
|
||||
}
|
||||
|
||||
private createResult = (result: SubmittableResultImpl): CodePutCodeResult => {
|
||||
let blueprint: RxBlueprint | undefined;
|
||||
|
||||
if (result.isFinalized) {
|
||||
const record = result.findRecord('contract', 'CodeStored');
|
||||
|
||||
if (record) {
|
||||
blueprint = new RxBlueprint(this.api, this.abi, record.event.data[0] as Hash);
|
||||
}
|
||||
}
|
||||
|
||||
return new CodePutCodeResult(result, blueprint);
|
||||
}
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
// Copyright 2017-2019 @polkadot/api-contract authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { AccountId, Address } from '@polkadot/types/interfaces';
|
||||
import { IKeyringPair } from '@polkadot/types/types';
|
||||
import { ContractABI, ContractABIFn, InterfaceContract, InterfaceContractCalls } from './types';
|
||||
|
||||
import BN from 'bn.js';
|
||||
import { Observable } from 'rxjs';
|
||||
import { ApiRx, SubmittableResult } from '@polkadot/api';
|
||||
import { createType } from '@polkadot/types';
|
||||
import Abi from './Abi';
|
||||
import RxBase from './RxBase';
|
||||
|
||||
export type ContractCallResultSubscription = Observable<SubmittableResult>;
|
||||
|
||||
export interface ContractCall {
|
||||
signAndSend (account: IKeyringPair | string | AccountId | Address): ContractCallResultSubscription;
|
||||
}
|
||||
|
||||
type CallResult = (value: BN | number, maxGas: BN | number, ...params: any[]) => ContractCall;
|
||||
|
||||
// NOTE Experimental, POC, bound to change
|
||||
export default class RxContract extends RxBase implements InterfaceContract {
|
||||
public readonly address: Address;
|
||||
|
||||
public readonly calls: InterfaceContractCalls = {};
|
||||
|
||||
public constructor (api: ApiRx, abi: ContractABI | Abi, address: string | AccountId | Address) {
|
||||
super(api, abi);
|
||||
|
||||
this.address = createType('Address', address);
|
||||
|
||||
Object.entries(abi.messages).forEach(([name]): void => {
|
||||
this.calls[name] = (fn: ContractABIFn): CallResult =>
|
||||
(value: BN | number, maxGas: BN | number, ...params: any[]): ContractCall =>
|
||||
this.apiContracts.call(this.address, value, maxGas, fn(...params));
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { ApiTypes, DecorateMethod, SubmittableResultImpl } from '@polkadot/api/types';
|
||||
import { AccountId, Address, Hash } from '@polkadot/types/interfaces';
|
||||
import { IKeyringPair } from '@polkadot/types/types';
|
||||
import { ApiObject, ContractABIPre } from '../types';
|
||||
|
||||
import BN from 'bn.js';
|
||||
import { Observable } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { SubmittableResult } from '@polkadot/api';
|
||||
import { createType } from '@polkadot/types';
|
||||
import { assert } from '@polkadot/util';
|
||||
|
||||
import Abi from '../Abi';
|
||||
import Contract from './Contract';
|
||||
import { BaseWithTx } from './util';
|
||||
|
||||
type BlueprintCreateResultSubscription<ApiType extends ApiTypes> = Observable<BlueprintCreateResult<ApiType>>;
|
||||
|
||||
export interface BlueprintCreate<ApiType extends ApiTypes> {
|
||||
signAndSend (account: IKeyringPair | string | AccountId | Address): BlueprintCreateResultSubscription<ApiType>;
|
||||
}
|
||||
|
||||
class BlueprintCreateResult<ApiType extends ApiTypes> extends SubmittableResult {
|
||||
public readonly contract?: Contract<ApiType>;
|
||||
|
||||
constructor (result: SubmittableResultImpl, contract?: Contract<ApiType>) {
|
||||
super(result);
|
||||
|
||||
this.contract = contract;
|
||||
}
|
||||
}
|
||||
|
||||
// NOTE Experimental, POC, bound to change
|
||||
export default class Blueprint<ApiType extends ApiTypes> extends BaseWithTx<ApiType> {
|
||||
public readonly codeHash: Hash;
|
||||
|
||||
constructor (api: ApiObject<ApiType>, abi: ContractABIPre | Abi, decorateMethod: DecorateMethod<ApiType>, codeHash: string | Hash) {
|
||||
super(api, abi, decorateMethod);
|
||||
|
||||
this.codeHash = createType(this.registry, 'Hash', codeHash);
|
||||
}
|
||||
|
||||
public deployContract (constructorIndex = 0, endowment: number | BN, maxGas: number | BN, ...params: any[]): BlueprintCreate<ApiType> {
|
||||
assert(!!this.abi.constructors[constructorIndex], `Specified constructor index ${constructorIndex} does not exist`);
|
||||
|
||||
return {
|
||||
signAndSend: this.decorateMethod(
|
||||
(account: IKeyringPair | string | AccountId | Address): BlueprintCreateResultSubscription<ApiType> => {
|
||||
return this.apiContracts
|
||||
.create(endowment, maxGas, this.codeHash, this.abi.constructors[constructorIndex](...params))
|
||||
.signAndSend(account)
|
||||
.pipe(map(this.createResult));
|
||||
}
|
||||
)
|
||||
};
|
||||
}
|
||||
|
||||
private createResult = (result: SubmittableResult): BlueprintCreateResult<ApiType> => {
|
||||
let contract: Contract<ApiType> | undefined;
|
||||
|
||||
if (result.isFinalized) {
|
||||
const record = result.findRecord('contract', 'Instantiated');
|
||||
|
||||
if (record) {
|
||||
contract = new Contract<ApiType>(this.api, this.abi, this.decorateMethod, record.event.data[1] as Address);
|
||||
}
|
||||
}
|
||||
|
||||
return new BlueprintCreateResult(result, contract);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { ApiTypes, DecorateMethod, SubmittableResultImpl } from '@polkadot/api/types';
|
||||
import { AccountId, Address, Hash } from '@polkadot/types/interfaces';
|
||||
import { IKeyringPair } from '@polkadot/types/types';
|
||||
import { ApiObject, ContractABIPre } from '../types';
|
||||
|
||||
import BN from 'bn.js';
|
||||
import { Observable } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { SubmittableResult } from '@polkadot/api';
|
||||
import { compactAddLength, u8aToU8a } from '@polkadot/util';
|
||||
|
||||
import Abi from '../Abi';
|
||||
import Blueprint from './Blueprint';
|
||||
import { BaseWithTx } from './util';
|
||||
|
||||
type CodePutCodeResultSubscription<ApiType extends ApiTypes> = Observable<CodePutCodeResult<ApiType>>;
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/interface-name-prefix
|
||||
export interface CodePutCode<ApiType extends ApiTypes> {
|
||||
signAndSend (account: IKeyringPair | string | AccountId | Address): CodePutCodeResultSubscription<ApiType>;
|
||||
}
|
||||
|
||||
class CodePutCodeResult<ApiType extends ApiTypes> extends SubmittableResult {
|
||||
public readonly blueprint?: Blueprint<ApiType>;
|
||||
|
||||
constructor (result: SubmittableResultImpl, blueprint?: Blueprint<ApiType>) {
|
||||
super(result);
|
||||
|
||||
this.blueprint = blueprint;
|
||||
}
|
||||
}
|
||||
|
||||
// NOTE Experimental, POC, bound to change
|
||||
export default class Code<ApiType extends ApiTypes> extends BaseWithTx<ApiType> {
|
||||
public readonly code: Uint8Array;
|
||||
|
||||
constructor (api: ApiObject<ApiType>, abi: ContractABIPre | Abi, decorateMethod: DecorateMethod<ApiType>, wasm: string | Uint8Array) {
|
||||
super(api, abi, decorateMethod);
|
||||
|
||||
this.code = u8aToU8a(wasm);
|
||||
}
|
||||
|
||||
public createBlueprint = (maxGas: number | BN): CodePutCode<ApiType> => {
|
||||
return {
|
||||
signAndSend: this.decorateMethod(
|
||||
(account: IKeyringPair | string | AccountId | Address): CodePutCodeResultSubscription<ApiType> => this.apiContracts
|
||||
.putCode(maxGas, compactAddLength(this.code))
|
||||
.signAndSend(account)
|
||||
.pipe(map(this.createResult))
|
||||
)
|
||||
};
|
||||
}
|
||||
|
||||
private createResult = (result: SubmittableResultImpl): CodePutCodeResult<ApiType> => {
|
||||
let blueprint: Blueprint<ApiType> | undefined;
|
||||
|
||||
if (result.isFinalized) {
|
||||
const record = result.findRecord('contract', 'CodeStored');
|
||||
|
||||
if (record) {
|
||||
blueprint = new Blueprint<ApiType>(this.api, this.abi, this.decorateMethod, record.event.data[0] as Hash);
|
||||
}
|
||||
}
|
||||
|
||||
return new CodePutCodeResult(result, blueprint);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { ApiTypes, DecorateMethod, ObsInnerType } from '@polkadot/api/types';
|
||||
import { AccountId, Address, ContractExecResult } from '@polkadot/types/interfaces';
|
||||
import { Codec, IKeyringPair } from '@polkadot/types/types';
|
||||
import { ApiObject, ContractABIMessage, ContractABIPre, ContractCallOutcome } from '../types';
|
||||
|
||||
import BN from 'bn.js';
|
||||
import { Observable } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { SubmittableResult } from '@polkadot/api';
|
||||
import { createType } from '@polkadot/types';
|
||||
import Abi from '../Abi';
|
||||
import { formatData } from '../util';
|
||||
import { BaseWithTxAndRpcCall } from './util';
|
||||
|
||||
type ContractCallTypes = 'tx' | 'rpc';
|
||||
|
||||
type ContractCallResultSubscription<ApiType extends ApiTypes, CallType extends ContractCallTypes> = ApiType extends 'rxjs'
|
||||
? Observable<ContractCallResult<CallType>>
|
||||
: Promise<ObsInnerType<ContractCallResult<CallType>>>;
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/interface-name-prefix
|
||||
export interface ContractCall<ApiType extends ApiTypes, CallType extends ContractCallTypes> {
|
||||
send (account: IKeyringPair | string | AccountId | Address): ContractCallResultSubscription<ApiType, CallType>;
|
||||
}
|
||||
|
||||
export type ContractCallResult<CallType extends ContractCallTypes> = CallType extends 'rpc'
|
||||
? Observable<ContractCallOutcome>
|
||||
: Observable<SubmittableResult>;
|
||||
|
||||
export default class Contract<ApiType extends ApiTypes> extends BaseWithTxAndRpcCall<ApiType> {
|
||||
public readonly address: Address;
|
||||
|
||||
public call (as: 'rpc', message: string, value: BN | number, gasLimit: BN | number, ...params: any[]): ContractCall<ApiType, 'rpc'>;
|
||||
public call (as: 'tx', message: string, value: BN | number, gasLimit: BN | number, ...params: any[]): ContractCall<ApiType, 'tx'>;
|
||||
public call<CallType extends ContractCallTypes> (as: CallType, message: string, value: BN | number, gasLimit: BN | number, ...params: any[]): ContractCall<ApiType, CallType> {
|
||||
const { fn, def } = this.getMessage(message);
|
||||
|
||||
return {
|
||||
send: this.decorateMethod(
|
||||
as === 'rpc' && this.hasRpcContractsCall
|
||||
? (account: IKeyringPair | string | AccountId | Address): ContractCallResult<'rpc'> => {
|
||||
return this.rpcContractsCall(
|
||||
createType(this.registry, 'ContractCallRequest', {
|
||||
origin: account,
|
||||
dest: this.address.toString(),
|
||||
value,
|
||||
gasLimit,
|
||||
inputData: fn(...params)
|
||||
})
|
||||
)
|
||||
.pipe(
|
||||
map((result: ContractExecResult): ContractCallOutcome =>
|
||||
this.createOutcome(result, createType(this.registry, 'AccountId', account), def, params)
|
||||
)
|
||||
);
|
||||
}
|
||||
: (account: IKeyringPair | string | AccountId | Address): ContractCallResult<'tx'> => {
|
||||
return this.apiContracts
|
||||
.call(this.address, value, gasLimit, fn(...params))
|
||||
.signAndSend(account);
|
||||
}
|
||||
)
|
||||
};
|
||||
}
|
||||
|
||||
private createOutcome (result: ContractExecResult, origin: AccountId, message: ContractABIMessage, params: any[]): ContractCallOutcome {
|
||||
let output: Codec | null = null;
|
||||
|
||||
if (result.isSuccess) {
|
||||
const { data } = result.asSuccess;
|
||||
|
||||
output = message.returnType
|
||||
? formatData(this.registry, data, message.returnType)
|
||||
: createType(this.registry, 'Raw', data);
|
||||
}
|
||||
|
||||
return {
|
||||
time: Date.now(),
|
||||
message,
|
||||
origin,
|
||||
params,
|
||||
result,
|
||||
isSuccess: result.isSuccess,
|
||||
output
|
||||
};
|
||||
}
|
||||
|
||||
constructor (api: ApiObject<ApiType>, abi: ContractABIPre | Abi, decorateMethod: DecorateMethod<ApiType>, address: string | AccountId | Address) {
|
||||
super(api, abi, decorateMethod);
|
||||
|
||||
this.address = createType(this.registry, 'Address', address);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
// Copyright 2017-2020 @polkadot/api authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
export { default as Blueprint } from './Blueprint';
|
||||
export { default as Code } from './Code';
|
||||
export { default as Contract } from './Contract';
|
||||
@@ -0,0 +1,78 @@
|
||||
// Copyright 2017-2020 @polkadot/api authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { ApiTypes, DecorateMethod, DecoratedRpc, SubmittableModuleExtrinsics } from '@polkadot/api/types';
|
||||
import { RpcInterface } from '@polkadot/rpc-core/types';
|
||||
import { Registry } from '@polkadot/types/types';
|
||||
import { ApiObject, ContractABIMessage, ContractABIPre, ContractBase, ContractMessage } from '../types';
|
||||
|
||||
import { assert, isFunction, stringCamelCase } from '@polkadot/util';
|
||||
import Abi from '../Abi';
|
||||
|
||||
export abstract class Base<ApiType extends ApiTypes> implements ContractBase<ApiType> {
|
||||
public readonly abi: Abi;
|
||||
|
||||
public readonly api: ApiObject<ApiType>;
|
||||
|
||||
public readonly decorateMethod: DecorateMethod<ApiType>;
|
||||
|
||||
public readonly registry: Registry;
|
||||
|
||||
constructor (api: ApiObject<ApiType>, abi: ContractABIPre | Abi, decorateMethod: DecorateMethod<ApiType>) {
|
||||
this.abi = abi instanceof Abi
|
||||
? abi
|
||||
: new Abi(api.registry, abi);
|
||||
this.registry = api.registry;
|
||||
this.api = api;
|
||||
this.decorateMethod = decorateMethod;
|
||||
}
|
||||
|
||||
public get messages (): ContractMessage[] {
|
||||
return this.abi.abi.contract.messages
|
||||
.map(
|
||||
(def: ContractABIMessage, index): ContractMessage => ({
|
||||
index,
|
||||
def,
|
||||
fn: this.abi.messages[def.name] || this.abi.messages[stringCamelCase(name)]
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
public getMessage (nameOrIndex?: string | number): ContractMessage {
|
||||
const index = nameOrIndex
|
||||
? typeof nameOrIndex === 'number'
|
||||
? nameOrIndex
|
||||
: this.abi.abi.contract.messages.findIndex((message): boolean => nameOrIndex === message.name || nameOrIndex === stringCamelCase(message.name))
|
||||
: 0;
|
||||
const def = this.abi.abi.contract.messages[index];
|
||||
assert(!!def, `Attempted to access a contract message that does not exist: ${typeof nameOrIndex === 'number' ? `index ${nameOrIndex}` : nameOrIndex}`);
|
||||
|
||||
const fn = this.abi.messages[def.name] || this.abi.messages[stringCamelCase(def.name)];
|
||||
return { index, def, fn };
|
||||
}
|
||||
}
|
||||
|
||||
export abstract class BaseWithTx<ApiType extends ApiTypes> extends Base<ApiType> {
|
||||
protected get apiContracts (): SubmittableModuleExtrinsics<'rxjs'> {
|
||||
return this.api.rx.tx.contracts;
|
||||
}
|
||||
|
||||
constructor (api: ApiObject<ApiType>, abi: ContractABIPre | Abi, decorateMethod: DecorateMethod<ApiType>) {
|
||||
super(api, abi, 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');
|
||||
}
|
||||
}
|
||||
|
||||
export abstract class BaseWithTxAndRpcCall<ApiType extends ApiTypes> extends BaseWithTx<ApiType> {
|
||||
public get hasRpcContractsCall (): boolean {
|
||||
return isFunction(this.api.rx.rpc.contracts?.call);
|
||||
}
|
||||
|
||||
protected get rpcContractsCall (): DecoratedRpc<'rxjs', RpcInterface>['contracts']['call'] {
|
||||
assert(this.hasRpcContractsCall, 'You need to connect to a node with the contracts.call RPC method.');
|
||||
|
||||
return this.api.rx.rpc.contracts.call;
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,7 @@
|
||||
// Copyright 2017-2019 @polkadot/api-contract authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
export { default as Abi } from './Abi';
|
||||
export { default as RxBlueprint } from './RxBlueprint';
|
||||
export { default as RxCode } from './RxCode';
|
||||
export { default as RxContract } from './RxContract';
|
||||
export * from './rx';
|
||||
export * from './promise';
|
||||
|
||||
@@ -1,69 +0,0 @@
|
||||
// Copyright 2017-2019 @polkadot/api-contract authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { CodecArg, Constructor } from '@polkadot/types/types';
|
||||
import { ContractABIFn, ContractABIFnArg, ContractABIMethod, ContractABIMethodBase, ContractABITypes } from './types';
|
||||
|
||||
import { Compact, createClass } from '@polkadot/types';
|
||||
import { assert, isString, isUndefined, stringCamelCase } from '@polkadot/util';
|
||||
|
||||
export function typeToString (type: ContractABITypes): string {
|
||||
if (isString(type)) {
|
||||
return type;
|
||||
} else if (Array.isArray(type)) {
|
||||
return `(${type.map((type): string => typeToString(type)).join(',')})`;
|
||||
} else if (type['Option<T>']) {
|
||||
return `Option<${typeToString(type['Option<T>'].T)}>`;
|
||||
} else if (type['Result<T,E>']) {
|
||||
return '()'; // Result is not supported, but only applicable for returns
|
||||
} else if (type['Vec<T>']) {
|
||||
return `Vec<${typeToString(type['Vec<T>'].T)}>`;
|
||||
} else if (type['[T;n]']) {
|
||||
return `[${typeToString(type['[T;n]'].T)};${type['[T;n]'].n}]`;
|
||||
}
|
||||
|
||||
throw new Error(`Unknown type specified ${JSON.stringify(type)}`);
|
||||
}
|
||||
|
||||
export function createArgClass (args: ContractABIFnArg[], baseDef: Record<string, string>): Constructor {
|
||||
return createClass(
|
||||
JSON.stringify(
|
||||
args.reduce((base: Record<string, any>, { name, type }): Record<string, any> => {
|
||||
base[name] = type;
|
||||
|
||||
return base;
|
||||
}, baseDef)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
export function createMethod (name: string, method: Partial<ContractABIMethod> & ContractABIMethodBase): ContractABIFn {
|
||||
const args: ContractABIFnArg[] = method.args.map(({ name, type }): ContractABIFnArg => ({
|
||||
name: stringCamelCase(name),
|
||||
type: typeToString(type)
|
||||
}));
|
||||
const Clazz = createArgClass(args, isUndefined(method.selector) ? {} : { __selector: 'u32' });
|
||||
const baseStruct: { [index: string]: any } = { __selector: method.selector };
|
||||
const encoder = (...params: CodecArg[]): Uint8Array => {
|
||||
assert(params.length === args.length, `Expected ${args.length} arguments to contract ${name}, found ${params.length}`);
|
||||
|
||||
const u8a = new Clazz(
|
||||
args.reduce((mapped, { name }, index): Record<string, CodecArg> => {
|
||||
mapped[name] = params[index];
|
||||
|
||||
return mapped;
|
||||
}, { ...baseStruct })
|
||||
).toU8a();
|
||||
|
||||
return Compact.addLengthPrefix(u8a);
|
||||
};
|
||||
|
||||
const fn = (encoder as ContractABIFn);
|
||||
|
||||
fn.args = args;
|
||||
fn.isConstant = !(method.mutates || false);
|
||||
fn.type = method.return_type ? typeToString(method.return_type) : null;
|
||||
|
||||
return fn;
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { Hash } from '@polkadot/types/interfaces';
|
||||
import { ContractABIPre } from '../types';
|
||||
|
||||
import { ApiPromise } from '@polkadot/api';
|
||||
import { decorateMethod } from '@polkadot/api/promise';
|
||||
|
||||
import Abi from '../Abi';
|
||||
import Blueprint from '../base/Blueprint';
|
||||
|
||||
export default class PromiseBlueprint extends Blueprint<'promise'> {
|
||||
constructor (api: ApiPromise, abi: ContractABIPre | Abi, codeHash: string | Hash) {
|
||||
super(api, abi, decorateMethod, codeHash);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { ContractABIPre } from '../types';
|
||||
|
||||
import { ApiPromise } from '@polkadot/api';
|
||||
import { decorateMethod } from '@polkadot/api/promise';
|
||||
|
||||
import Abi from '../Abi';
|
||||
import Code from '../base/Code';
|
||||
|
||||
export default class PromiseCode extends Code<'promise'> {
|
||||
constructor (api: ApiPromise, abi: ContractABIPre | Abi, wasm: string | Uint8Array) {
|
||||
super(api, abi, decorateMethod, wasm);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { AccountId } from '@polkadot/types/interfaces';
|
||||
import { ContractABIPre } from '../types';
|
||||
|
||||
import { ApiPromise } from '@polkadot/api';
|
||||
import { decorateMethod } from '@polkadot/api/promise';
|
||||
|
||||
import Abi from '../Abi';
|
||||
import Contract from '../base/Contract';
|
||||
|
||||
export default class PromiseContract extends Contract<'promise'> {
|
||||
constructor (api: ApiPromise, abi: ContractABIPre | Abi, address: string | AccountId) {
|
||||
super(api, abi, decorateMethod, address);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
export { default as PromiseBlueprint } from './PromiseBlueprint';
|
||||
export { default as PromiseCode } from './PromiseCode';
|
||||
export { default as PromiseContract } from './PromiseContract';
|
||||
@@ -0,0 +1,18 @@
|
||||
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { Hash } from '@polkadot/types/interfaces';
|
||||
import { ContractABIPre } from '../types';
|
||||
|
||||
import { ApiRx } from '@polkadot/api';
|
||||
import { decorateMethod } from '@polkadot/api/rx';
|
||||
|
||||
import Abi from '../Abi';
|
||||
import Blueprint from '../base/Blueprint';
|
||||
|
||||
export default class RxBlueprint extends Blueprint<'rxjs'> {
|
||||
constructor (api: ApiRx, abi: ContractABIPre | Abi, codeHash: string | Hash) {
|
||||
super(api, abi, decorateMethod, codeHash);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { ContractABIPre } from '../types';
|
||||
|
||||
import { ApiRx } from '@polkadot/api';
|
||||
import { decorateMethod } from '@polkadot/api/rx';
|
||||
|
||||
import Abi from '../Abi';
|
||||
import Code from '../base/Code';
|
||||
|
||||
export default class RxCode extends Code<'rxjs'> {
|
||||
constructor (api: ApiRx, abi: ContractABIPre | Abi, wasm: string | Uint8Array) {
|
||||
super(api, abi, decorateMethod, wasm);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { AccountId } from '@polkadot/types/interfaces';
|
||||
import { ContractABIPre } from '../types';
|
||||
|
||||
import { ApiRx } from '@polkadot/api';
|
||||
import { decorateMethod } from '@polkadot/api/rx';
|
||||
|
||||
import Abi from '../Abi';
|
||||
import Contract from '../base/Contract';
|
||||
|
||||
export default class RxContract extends Contract<'rxjs'> {
|
||||
constructor (api: ApiRx, abi: ContractABIPre | Abi, address: string | AccountId) {
|
||||
super(api, abi, decorateMethod, address);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
export { default as RxBlueprint } from './RxBlueprint';
|
||||
export { default as RxCode } from './RxCode';
|
||||
export { default as RxContract } from './RxContract';
|
||||
@@ -1,87 +1,192 @@
|
||||
// Copyright 2017-2019 @polkadot/api-contract authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { SubmittableModuleExtrinsics } from '@polkadot/api/types';
|
||||
import { Address } from '@polkadot/types/interfaces';
|
||||
import { CodecArg } from '@polkadot/types/types';
|
||||
import { ApiTypes, DecorateMethod } from '@polkadot/api/types';
|
||||
import { AccountId, Address, ContractExecResult } from '@polkadot/types/interfaces';
|
||||
import { Codec, CodecArg } from '@polkadot/types/types';
|
||||
import { MetaRegistryJson, StringIndex, TypeIndex, TypeDef } from '@polkadot/types/codec/create/types';
|
||||
|
||||
// import { Observable } from 'rxjs';
|
||||
import { ApiPromise, ApiRx } from '@polkadot/api';
|
||||
|
||||
export type ApiObject<ApiType> = ApiType extends 'rxjs'
|
||||
export type ApiObject<ApiType extends ApiTypes> = ApiType extends 'rxjs'
|
||||
? ApiRx
|
||||
: ApiPromise;
|
||||
|
||||
export interface ContractABITypesStruct {
|
||||
'Option<T>'?: {
|
||||
T: ContractABITypes;
|
||||
};
|
||||
'Result<T,E>'?: {
|
||||
T: ContractABITypes;
|
||||
E: ContractABITypes;
|
||||
};
|
||||
'Vec<T>'?: {
|
||||
T: ContractABITypes;
|
||||
};
|
||||
'[T;n]'?: {
|
||||
T: ContractABITypes;
|
||||
n: number;
|
||||
};
|
||||
export interface ContractBase<ApiType extends ApiTypes> {
|
||||
readonly abi: InterfaceAbi;
|
||||
readonly api: ApiObject<ApiType>;
|
||||
readonly decorateMethod: DecorateMethod<ApiType>;
|
||||
getMessage: (name: string) => ContractMessage;
|
||||
messages: ContractMessage[];
|
||||
}
|
||||
|
||||
export type ContractABITypes = string | ContractABITypesStruct | (string | ContractABITypesStruct)[];
|
||||
export interface ContractABITypePre {
|
||||
ty: TypeIndex;
|
||||
display_name: StringIndex[];
|
||||
}
|
||||
|
||||
export interface ContractABIArg {
|
||||
export interface ContractABIArgBasePre {
|
||||
name: StringIndex;
|
||||
type: ContractABITypePre;
|
||||
}
|
||||
|
||||
export interface ContractABIArgBase {
|
||||
name: string;
|
||||
type: ContractABITypes;
|
||||
type: TypeDef;
|
||||
}
|
||||
|
||||
export interface ContractABIMethodBase {
|
||||
args: ContractABIArg[];
|
||||
export type ContractABIMessageArgPre = ContractABIArgBasePre;
|
||||
|
||||
export type ContractABIMessageArg = ContractABIArgBase;
|
||||
|
||||
export interface ContractABIMessageBase {
|
||||
args: ContractABIMessageArg[];
|
||||
}
|
||||
|
||||
export interface ContractABIMethod extends ContractABIMethodBase {
|
||||
export interface ContractABIMessageBasePre {
|
||||
args: ContractABIMessageArgPre[];
|
||||
}
|
||||
|
||||
export interface ContractABIMessageCommon {
|
||||
docs?: ContractABIDocs;
|
||||
mutates?: boolean;
|
||||
selector: string | number;
|
||||
}
|
||||
|
||||
export interface ContractABIMessagePre extends ContractABIMessageCommon, ContractABIMessageBasePre {
|
||||
name: StringIndex;
|
||||
return_type: ContractABITypePre | null;
|
||||
}
|
||||
|
||||
export interface ContractABIMessage extends ContractABIMessageCommon {
|
||||
args: ContractABIMessageArg[];
|
||||
name: string;
|
||||
selector: number;
|
||||
return_type: ContractABITypes | null;
|
||||
returnType: TypeDef | null;
|
||||
}
|
||||
|
||||
export interface ContractABIContractCommon {
|
||||
docs?: ContractABIDocs;
|
||||
}
|
||||
|
||||
export interface ContractABIContractPre extends ContractABIContractCommon {
|
||||
constructors: ContractABIMessagePre[];
|
||||
messages: ContractABIMessagePre[];
|
||||
name: StringIndex;
|
||||
events?: ContractABIEventPre[];
|
||||
docs?: ContractABIDocs;
|
||||
}
|
||||
|
||||
export interface ContractABIContract extends ContractABIContractCommon {
|
||||
constructors: ContractABIMessage[];
|
||||
messages: ContractABIMessage[];
|
||||
name: string;
|
||||
events?: ContractABIEvent[];
|
||||
docs?: ContractABIDocs;
|
||||
}
|
||||
|
||||
export interface ContractABIPre extends MetaRegistryJson {
|
||||
storage: ContractABIStoragePre;
|
||||
contract: ContractABIContractPre;
|
||||
}
|
||||
|
||||
export interface ContractABI {
|
||||
deploy: ContractABIMethodBase;
|
||||
messages: ContractABIMethod[];
|
||||
name: string;
|
||||
storage: ContractABIStorage;
|
||||
contract: ContractABIContract;
|
||||
}
|
||||
|
||||
export interface ContractABIFnArg {
|
||||
name: string;
|
||||
type: string;
|
||||
type: TypeDef;
|
||||
}
|
||||
|
||||
export interface ContractABIMeta {
|
||||
args: ContractABIFnArg[];
|
||||
isConstant: boolean;
|
||||
type: string | null;
|
||||
type: TypeDef | null;
|
||||
}
|
||||
|
||||
export interface ContractABIFn extends ContractABIMeta {
|
||||
(...args: CodecArg[]): Uint8Array;
|
||||
}
|
||||
|
||||
export interface ContractABIEventArgBase {
|
||||
indexed: boolean;
|
||||
}
|
||||
|
||||
export interface ContractABIEventArgPre extends ContractABIArgBasePre, ContractABIEventArgBase {}
|
||||
|
||||
export interface ContractABIEventArg extends ContractABIArgBase, ContractABIEventArgBase {}
|
||||
|
||||
export type ContractABIDocs = string[];
|
||||
|
||||
export interface ContractABIEventPre {
|
||||
args: ContractABIEventArgPre[];
|
||||
}
|
||||
|
||||
export interface ContractABIEvent {
|
||||
args: ContractABIEventArg[];
|
||||
}
|
||||
|
||||
export interface ContractABIRangeBase {
|
||||
// can be number[] (old) or hex (new)
|
||||
'range.offset': number[] | string;
|
||||
'range.len': number;
|
||||
}
|
||||
|
||||
export interface ContractABIRangePre extends ContractABIRangeBase {
|
||||
'range.elem_type': TypeIndex;
|
||||
}
|
||||
|
||||
export interface ContractABIRange extends ContractABIRangeBase {
|
||||
'range.elem_type': TypeDef;
|
||||
}
|
||||
|
||||
export type ContractABIStorageLayoutPre = ContractABIStorageStructPre | ContractABIRangePre;
|
||||
|
||||
export type ContractABIStorageLayout = ContractABIStorageStruct | ContractABIRange;
|
||||
|
||||
export interface ContractABIStorageStructFieldPre {
|
||||
name: StringIndex;
|
||||
layout: ContractABIStorageLayoutPre;
|
||||
}
|
||||
|
||||
export interface ContractABIStorageStructField {
|
||||
name: string;
|
||||
layout: ContractABIStorageLayout;
|
||||
}
|
||||
|
||||
export interface ContractABIStorageStructPre {
|
||||
'struct.type': TypeIndex;
|
||||
'struct.fields': ContractABIStorageStructFieldPre[];
|
||||
}
|
||||
|
||||
export interface ContractABIStorageStruct {
|
||||
'struct.type': TypeDef;
|
||||
'struct.fields': ContractABIStorageStructField[];
|
||||
}
|
||||
|
||||
export type ContractABIStoragePre = ContractABIStorageStructPre;
|
||||
|
||||
export type ContractABIStorage = ContractABIStorageStruct;
|
||||
|
||||
export interface ContractMessage {
|
||||
index: number;
|
||||
fn: ContractABIFn;
|
||||
def: ContractABIMessage;
|
||||
}
|
||||
|
||||
export type AbiConstructors = ContractABIFn[];
|
||||
|
||||
export type AbiMessages = Record<string, ContractABIFn>;
|
||||
|
||||
export interface InterfaceAbi {
|
||||
readonly abi: ContractABI;
|
||||
readonly deploy: ContractABIFn;
|
||||
readonly constructors: AbiConstructors;
|
||||
readonly messages: AbiMessages;
|
||||
}
|
||||
|
||||
export interface ContractBase<ApiType> {
|
||||
readonly abi: InterfaceAbi;
|
||||
readonly api: ApiObject<ApiType>;
|
||||
readonly apiContracts: SubmittableModuleExtrinsics<ApiType>;
|
||||
}
|
||||
|
||||
export interface InterfaceContractCalls {
|
||||
[index: string]: Function;
|
||||
}
|
||||
@@ -90,3 +195,13 @@ export interface InterfaceContract {
|
||||
readonly address: Address;
|
||||
readonly calls: InterfaceContractCalls;
|
||||
}
|
||||
|
||||
export interface ContractCallOutcome {
|
||||
time: number;
|
||||
result: ContractExecResult;
|
||||
origin: AccountId;
|
||||
output: Codec | null;
|
||||
params: any[];
|
||||
isSuccess: boolean;
|
||||
message: ContractABIMessage;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
// Copyright 2017-2020 @polkadot/rpc-core authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { Codec, Registry, TypeDefInfo, TypeDef } from '@polkadot/types/types';
|
||||
|
||||
import { Option, Raw, createClass } from '@polkadot/types';
|
||||
import { createTypeUnsafe } from '@polkadot/types/codec';
|
||||
|
||||
export function formatData (registry: Registry, data: Raw, { info, type }: TypeDef): Codec {
|
||||
if (info === TypeDefInfo.Option) {
|
||||
return new Option(
|
||||
registry,
|
||||
createClass(registry, type),
|
||||
createTypeUnsafe(registry, type, [data], true)
|
||||
);
|
||||
}
|
||||
|
||||
return createTypeUnsafe(registry, type, [data], true);
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,50 +0,0 @@
|
||||
// Copyright 2017-2019 @polkadot/api-contract authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { ContractABI, ContractABIArg } from './types';
|
||||
|
||||
import { assert, isNumber, isNull, isString, isObject } from '@polkadot/util';
|
||||
|
||||
export function validateArgs (name: string, args: ContractABIArg[]): void {
|
||||
assert(Array.isArray(args), `Expected 'args' to exist on ${name}`);
|
||||
|
||||
args.forEach((arg): void => {
|
||||
const unknownKeys = Object.keys(arg).filter((key): boolean => !['name', 'type'].includes(key));
|
||||
|
||||
assert(unknownKeys.length === 0, `Unknown keys ${unknownKeys.join(', ')} found in ABI args for ${name}`);
|
||||
assert(isString(arg.name), `${name} args should have valid name `);
|
||||
assert(isString(arg.type) || isObject(arg.type), `${name} args should have valid type`);
|
||||
});
|
||||
}
|
||||
|
||||
export function validateDeploy ({ deploy }: ContractABI): void {
|
||||
const unknownKeys = Object.keys(deploy).filter((key): boolean => !['args'].includes(key));
|
||||
|
||||
assert(unknownKeys.length === 0, `Unknown keys ${unknownKeys.join(', ')} found in ABI deploy`);
|
||||
|
||||
validateArgs('deploy', deploy.args);
|
||||
}
|
||||
|
||||
export function validateMethods ({ messages }: ContractABI): void {
|
||||
messages.forEach((method): void => {
|
||||
const unknownKeys = Object.keys(method).filter((key): boolean => !['args', 'mutates', 'name', 'selector', 'return_type'].includes(key));
|
||||
|
||||
assert(unknownKeys.length === 0, `Unknown keys ${unknownKeys.join(', ')} found in ABI args for messages.${method.name}`);
|
||||
assert(isString(method.name), `Expected name for messages.${method.name}`);
|
||||
assert(isNumber(method.selector), `Expected selector for messages.${method.name}`);
|
||||
assert(isNull(method.return_type) || isString(method.return_type) || isObject(method.return_type), `Expected return_type for messages.${method.name}`);
|
||||
|
||||
validateArgs(`messages.${method.name}`, method.args);
|
||||
});
|
||||
}
|
||||
|
||||
export function validateAbi (abi: ContractABI): void {
|
||||
const unknownKeys = Object.keys(abi).filter((key): boolean => !['deploy', 'messages', 'name'].includes(key));
|
||||
|
||||
assert(unknownKeys.length === 0, `Unknown fields ${unknownKeys.join(', ')} found in ABI`);
|
||||
assert(abi.deploy && abi.messages && isString(abi.name), 'ABI should have deploy, messages & name sections');
|
||||
|
||||
validateDeploy(abi);
|
||||
validateMethods(abi);
|
||||
}
|
||||
@@ -0,0 +1,467 @@
|
||||
{
|
||||
"registry": {
|
||||
"strings": [
|
||||
"StorageAndEnv",
|
||||
"app",
|
||||
"__ink_private",
|
||||
"__ink_storage",
|
||||
"__storage",
|
||||
"Storage",
|
||||
"value",
|
||||
"Value",
|
||||
"ink_core",
|
||||
"storage",
|
||||
"cell",
|
||||
"SyncCell",
|
||||
"sync_cell",
|
||||
"Key",
|
||||
"key",
|
||||
"name",
|
||||
"vec",
|
||||
"Vec",
|
||||
"elems",
|
||||
"__env",
|
||||
"EnvAccess",
|
||||
"env2",
|
||||
"env_access",
|
||||
"immutable",
|
||||
"TestEnv",
|
||||
"test",
|
||||
"accessor",
|
||||
"DefaultSrmlTypes",
|
||||
"types",
|
||||
"access",
|
||||
"EnvAccessMut",
|
||||
"mutable",
|
||||
"env",
|
||||
"PhantomData",
|
||||
"buffer",
|
||||
"has_interacted",
|
||||
"has_returned_value",
|
||||
"new",
|
||||
"init_value",
|
||||
"bool",
|
||||
"default",
|
||||
"flip",
|
||||
"get"
|
||||
],
|
||||
"types": [
|
||||
{
|
||||
"id": {
|
||||
"custom.name": 1,
|
||||
"custom.namespace": [
|
||||
2,
|
||||
2,
|
||||
3,
|
||||
4
|
||||
],
|
||||
"custom.params": []
|
||||
},
|
||||
"def": {
|
||||
"struct.fields": [
|
||||
{
|
||||
"name": 5,
|
||||
"type": 2
|
||||
},
|
||||
{
|
||||
"name": 20,
|
||||
"type": 14
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": {
|
||||
"custom.name": 6,
|
||||
"custom.namespace": [
|
||||
2,
|
||||
2,
|
||||
3,
|
||||
4
|
||||
],
|
||||
"custom.params": []
|
||||
},
|
||||
"def": {
|
||||
"struct.fields": [
|
||||
{
|
||||
"name": 7,
|
||||
"type": 3
|
||||
},
|
||||
{
|
||||
"name": 16,
|
||||
"type": 9
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": {
|
||||
"custom.name": 8,
|
||||
"custom.namespace": [
|
||||
9,
|
||||
10,
|
||||
7
|
||||
],
|
||||
"custom.params": [
|
||||
4
|
||||
]
|
||||
},
|
||||
"def": {
|
||||
"struct.fields": [
|
||||
{
|
||||
"name": 11,
|
||||
"type": 5
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "bool",
|
||||
"def": "builtin"
|
||||
},
|
||||
{
|
||||
"id": {
|
||||
"custom.name": 12,
|
||||
"custom.namespace": [
|
||||
9,
|
||||
10,
|
||||
11,
|
||||
13
|
||||
],
|
||||
"custom.params": [
|
||||
4
|
||||
]
|
||||
},
|
||||
"def": {
|
||||
"struct.fields": [
|
||||
{
|
||||
"name": 11,
|
||||
"type": 6
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": {
|
||||
"custom.name": 14,
|
||||
"custom.namespace": [
|
||||
9,
|
||||
10,
|
||||
15
|
||||
],
|
||||
"custom.params": []
|
||||
},
|
||||
"def": {
|
||||
"tuple_struct.types": [
|
||||
7
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": {
|
||||
"array.len": 32,
|
||||
"array.type": 8
|
||||
},
|
||||
"def": "builtin"
|
||||
},
|
||||
{
|
||||
"id": "u8",
|
||||
"def": "builtin"
|
||||
},
|
||||
{
|
||||
"id": {
|
||||
"custom.name": 8,
|
||||
"custom.namespace": [
|
||||
9,
|
||||
10,
|
||||
7
|
||||
],
|
||||
"custom.params": [
|
||||
10
|
||||
]
|
||||
},
|
||||
"def": {
|
||||
"struct.fields": [
|
||||
{
|
||||
"name": 11,
|
||||
"type": 13
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "str",
|
||||
"def": {
|
||||
"struct.fields": [
|
||||
{
|
||||
"name": 17,
|
||||
"type": 11
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": {
|
||||
"custom.name": 18,
|
||||
"custom.namespace": [],
|
||||
"custom.params": [
|
||||
8
|
||||
]
|
||||
},
|
||||
"def": {
|
||||
"struct.fields": [
|
||||
{
|
||||
"name": 19,
|
||||
"type": 12
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": {
|
||||
"slice.type": 8
|
||||
},
|
||||
"def": "builtin"
|
||||
},
|
||||
{
|
||||
"id": {
|
||||
"custom.name": 12,
|
||||
"custom.namespace": [
|
||||
9,
|
||||
10,
|
||||
11,
|
||||
13
|
||||
],
|
||||
"custom.params": [
|
||||
10
|
||||
]
|
||||
},
|
||||
"def": {
|
||||
"struct.fields": [
|
||||
{
|
||||
"name": 11,
|
||||
"type": 6
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": {
|
||||
"custom.name": 21,
|
||||
"custom.namespace": [
|
||||
9,
|
||||
22,
|
||||
23,
|
||||
24
|
||||
],
|
||||
"custom.params": [
|
||||
15
|
||||
]
|
||||
},
|
||||
"def": {
|
||||
"struct.fields": [
|
||||
{
|
||||
"name": 30,
|
||||
"type": 17
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": {
|
||||
"custom.name": 25,
|
||||
"custom.namespace": [
|
||||
9,
|
||||
22,
|
||||
26,
|
||||
27
|
||||
],
|
||||
"custom.params": [
|
||||
16
|
||||
]
|
||||
},
|
||||
"def": {
|
||||
"struct.fields": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": {
|
||||
"custom.name": 28,
|
||||
"custom.namespace": [
|
||||
9,
|
||||
22,
|
||||
29
|
||||
],
|
||||
"custom.params": []
|
||||
},
|
||||
"def": {
|
||||
"clike_enum.variants": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": {
|
||||
"custom.name": 31,
|
||||
"custom.namespace": [
|
||||
9,
|
||||
22,
|
||||
23,
|
||||
32
|
||||
],
|
||||
"custom.params": [
|
||||
15
|
||||
]
|
||||
},
|
||||
"def": {
|
||||
"struct.fields": [
|
||||
{
|
||||
"name": 33,
|
||||
"type": 18
|
||||
},
|
||||
{
|
||||
"name": 35,
|
||||
"type": 11
|
||||
},
|
||||
{
|
||||
"name": 36,
|
||||
"type": 4
|
||||
},
|
||||
{
|
||||
"name": 37,
|
||||
"type": 4
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": {
|
||||
"custom.name": 34,
|
||||
"custom.namespace": [],
|
||||
"custom.params": [
|
||||
15
|
||||
]
|
||||
},
|
||||
"def": {
|
||||
"tuple_struct.types": []
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"storage": {
|
||||
"struct.type": 1,
|
||||
"struct.fields": [
|
||||
{
|
||||
"name": 10,
|
||||
"layout": {
|
||||
"struct.type": 2,
|
||||
"struct.fields": [
|
||||
{
|
||||
"name": 7,
|
||||
"layout": {
|
||||
"struct.type": 3,
|
||||
"struct.fields": [
|
||||
{
|
||||
"name": 11,
|
||||
"layout": {
|
||||
"range.offset": "0x0000000000000000000000000000000000000000000000000000000000000000",
|
||||
"range.len": 1,
|
||||
"range.elem_type": 4
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": 16,
|
||||
"layout": {
|
||||
"struct.type": 9,
|
||||
"struct.fields": [
|
||||
{
|
||||
"name": 11,
|
||||
"layout": {
|
||||
"range.offset": "0x0000000000000000000000000000000000000000000000000000000000000001",
|
||||
"range.len": 1,
|
||||
"range.elem_type": 10
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"contract": {
|
||||
"name": 2,
|
||||
"constructors": [
|
||||
{
|
||||
"name": 38,
|
||||
"selector": "[\"0x5E\",\"0xBD\",\"0x88\",\"0xD6\"]",
|
||||
"args": [
|
||||
{
|
||||
"name": 16,
|
||||
"type": {
|
||||
"ty": 11,
|
||||
"display_name": [
|
||||
18
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": 39,
|
||||
"type": {
|
||||
"ty": 4,
|
||||
"display_name": [
|
||||
40
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"docs": [
|
||||
"Constructor that initializes the `bool` value to the given `init_value`."
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": 41,
|
||||
"selector": "[\"0x02\",\"0x22\",\"0xFF\",\"0x18\"]",
|
||||
"args": [],
|
||||
"docs": [
|
||||
"Constructor that initializes the `bool` value to `false`.",
|
||||
"",
|
||||
"Constructors can delegate to other constructors."
|
||||
]
|
||||
}
|
||||
],
|
||||
"messages": [
|
||||
{
|
||||
"name": 42,
|
||||
"selector": "[\"0x8C\",\"0x97\",\"0xDB\",\"0x39\"]",
|
||||
"mutates": true,
|
||||
"args": [],
|
||||
"return_type": null,
|
||||
"docs": [
|
||||
"A message that can be called on instantiated contracts.",
|
||||
"This one flips the value of the stored `bool` from `true`",
|
||||
"to `false` and vice versa."
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": 43,
|
||||
"selector": "[\"0x25\",\"0x44\",\"0x4A\",\"0xFE\"]",
|
||||
"mutates": false,
|
||||
"args": [],
|
||||
"return_type": {
|
||||
"ty": 4,
|
||||
"display_name": [
|
||||
40
|
||||
]
|
||||
},
|
||||
"docs": [
|
||||
"Simply returns the current value of our `bool`."
|
||||
]
|
||||
}
|
||||
],
|
||||
"events": [],
|
||||
"docs": []
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,184 @@
|
||||
[
|
||||
{
|
||||
"info": 8,
|
||||
"type": "{\"value\": {\"cell\": {\"cell\": ([u8;32])}}}",
|
||||
"name": "Flipper",
|
||||
"namespace": "flipper::normal",
|
||||
"sub": [
|
||||
{
|
||||
"info": 8,
|
||||
"type": "{\"cell\": {\"cell\": ([u8;32])}}",
|
||||
"name": "value",
|
||||
"namespace": "ink_core::storage::value",
|
||||
"params": [
|
||||
{
|
||||
"info": 6,
|
||||
"type": "bool"
|
||||
}
|
||||
],
|
||||
"sub": [
|
||||
{
|
||||
"info": 8,
|
||||
"type": "{\"cell\": ([u8;32])}",
|
||||
"name": "cell",
|
||||
"namespace": "ink_core::storage::cell::sync_cell",
|
||||
"params": [
|
||||
{
|
||||
"info": 6,
|
||||
"type": "bool"
|
||||
}
|
||||
],
|
||||
"sub": [
|
||||
{
|
||||
"info": 9,
|
||||
"type": "([u8;32])",
|
||||
"name": "cell",
|
||||
"namespace": "ink_core::storage::key",
|
||||
"sub": [
|
||||
{
|
||||
"info": 11,
|
||||
"type": "[u8;32]",
|
||||
"ext": {
|
||||
"length": 32,
|
||||
"type": ""
|
||||
},
|
||||
"sub": {
|
||||
"info": 6,
|
||||
"type": "u8"
|
||||
},
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"info": 8,
|
||||
"type": "{\"cell\": {\"cell\": ([u8;32])}}",
|
||||
"name": "Value",
|
||||
"namespace": "ink_core::storage::value",
|
||||
"params": [
|
||||
{
|
||||
"info": 6,
|
||||
"type": "bool"
|
||||
}
|
||||
],
|
||||
"sub": [
|
||||
{
|
||||
"info": 8,
|
||||
"type": "{\"cell\": ([u8;32])}",
|
||||
"name": "cell",
|
||||
"namespace": "ink_core::storage::cell::sync_cell",
|
||||
"params": [
|
||||
{
|
||||
"info": 6,
|
||||
"type": "bool"
|
||||
}
|
||||
],
|
||||
"sub": [
|
||||
{
|
||||
"info": 9,
|
||||
"type": "([u8;32])",
|
||||
"name": "cell",
|
||||
"namespace": "ink_core::storage::key",
|
||||
"sub": [
|
||||
{
|
||||
"info": 11,
|
||||
"type": "[u8;32]",
|
||||
"ext": {
|
||||
"length": 32,
|
||||
"type": ""
|
||||
},
|
||||
"sub": {
|
||||
"info": 6,
|
||||
"type": "u8"
|
||||
},
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"info": 6,
|
||||
"type": "bool"
|
||||
},
|
||||
{
|
||||
"info": 8,
|
||||
"type": "{\"cell\": ([u8;32])}",
|
||||
"name": "SyncCell",
|
||||
"namespace": "ink_core::storage::cell::sync_cell",
|
||||
"params": [
|
||||
{
|
||||
"info": 6,
|
||||
"type": "bool"
|
||||
}
|
||||
],
|
||||
"sub": [
|
||||
{
|
||||
"info": 9,
|
||||
"type": "([u8;32])",
|
||||
"name": "cell",
|
||||
"namespace": "ink_core::storage::key",
|
||||
"sub": [
|
||||
{
|
||||
"info": 11,
|
||||
"type": "[u8;32]",
|
||||
"ext": {
|
||||
"length": 32,
|
||||
"type": ""
|
||||
},
|
||||
"sub": {
|
||||
"info": 6,
|
||||
"type": "u8"
|
||||
},
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"info": 9,
|
||||
"type": "([u8;32])",
|
||||
"name": "Key",
|
||||
"namespace": "ink_core::storage::key",
|
||||
"sub": [
|
||||
{
|
||||
"info": 11,
|
||||
"type": "[u8;32]",
|
||||
"ext": {
|
||||
"length": 32,
|
||||
"type": ""
|
||||
},
|
||||
"sub": {
|
||||
"info": 6,
|
||||
"type": "u8"
|
||||
},
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"info": 11,
|
||||
"type": "[u8;32]",
|
||||
"ext": {
|
||||
"length": 32,
|
||||
"type": ""
|
||||
},
|
||||
"sub": {
|
||||
"info": 6,
|
||||
"type": "u8"
|
||||
}
|
||||
},
|
||||
{
|
||||
"info": 6,
|
||||
"type": "u8"
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,188 @@
|
||||
[
|
||||
{
|
||||
"info": 10,
|
||||
"type": "{ \"value\": \"{ \"cell\": \"{ \"cell\": \"([u8;32])\"} }<u32>\"} }<u32>\"} }",
|
||||
"sub": [
|
||||
{
|
||||
"info": 10,
|
||||
"type": "{ \"cell\": \"{ \"cell\": \"([u8;32])\"} }<u32>\"} }",
|
||||
"sub": [
|
||||
{
|
||||
"info": 10,
|
||||
"type": "{ \"cell\": \"([u8;32])\"} }",
|
||||
"sub": [
|
||||
{
|
||||
"info": 11,
|
||||
"type": "([u8;32])",
|
||||
"sub": [
|
||||
{
|
||||
"info": 13,
|
||||
"type": "[u8;32]",
|
||||
"ext": {
|
||||
"length": 32,
|
||||
"type": "u8"
|
||||
},
|
||||
"sub": {
|
||||
"info": 7,
|
||||
"type": "u8"
|
||||
},
|
||||
"index": 0
|
||||
}
|
||||
],
|
||||
"name": "cell",
|
||||
"namespace": "ink_core::storage::key"
|
||||
}
|
||||
],
|
||||
"name": "cell",
|
||||
"namespace": "ink_core::storage::cell::sync_cell",
|
||||
"params": [
|
||||
{
|
||||
"info": 7,
|
||||
"type": "u32"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"name": "value",
|
||||
"namespace": "ink_core::storage::value",
|
||||
"params": [
|
||||
{
|
||||
"info": 7,
|
||||
"type": "u32"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"name": "Incrementer",
|
||||
"namespace": "incrementer::normal"
|
||||
},
|
||||
{
|
||||
"info": 10,
|
||||
"type": "{ \"cell\": \"{ \"cell\": \"([u8;32])\"} }<u32>\"} }",
|
||||
"sub": [
|
||||
{
|
||||
"info": 10,
|
||||
"type": "{ \"cell\": \"([u8;32])\"} }",
|
||||
"sub": [
|
||||
{
|
||||
"info": 11,
|
||||
"type": "([u8;32])",
|
||||
"sub": [
|
||||
{
|
||||
"info": 13,
|
||||
"type": "[u8;32]",
|
||||
"ext": {
|
||||
"length": 32,
|
||||
"type": "u8"
|
||||
},
|
||||
"sub": {
|
||||
"info": 7,
|
||||
"type": "u8"
|
||||
},
|
||||
"index": 0
|
||||
}
|
||||
],
|
||||
"name": "cell",
|
||||
"namespace": "ink_core::storage::key"
|
||||
}
|
||||
],
|
||||
"name": "cell",
|
||||
"namespace": "ink_core::storage::cell::sync_cell",
|
||||
"params": [
|
||||
{
|
||||
"info": 7,
|
||||
"type": "u32"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"name": "Value",
|
||||
"namespace": "ink_core::storage::value",
|
||||
"params": [
|
||||
{
|
||||
"info": 7,
|
||||
"type": "u32"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"info": 7,
|
||||
"type": "u32"
|
||||
},
|
||||
{
|
||||
"info": 10,
|
||||
"type": "{ \"cell\": \"([u8;32])\"} }",
|
||||
"sub": [
|
||||
{
|
||||
"info": 11,
|
||||
"type": "([u8;32])",
|
||||
"sub": [
|
||||
{
|
||||
"info": 13,
|
||||
"type": "[u8;32]",
|
||||
"ext": {
|
||||
"length": 32,
|
||||
"type": "u8"
|
||||
},
|
||||
"sub": {
|
||||
"info": 7,
|
||||
"type": "u8"
|
||||
},
|
||||
"index": 0
|
||||
}
|
||||
],
|
||||
"name": "cell",
|
||||
"namespace": "ink_core::storage::key"
|
||||
}
|
||||
],
|
||||
"name": "SyncCell",
|
||||
"namespace": "ink_core::storage::cell::sync_cell",
|
||||
"params": [
|
||||
{
|
||||
"info": 7,
|
||||
"type": "u32"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"info": 11,
|
||||
"type": "([u8;32])",
|
||||
"sub": [
|
||||
{
|
||||
"info": 13,
|
||||
"type": "[u8;32]",
|
||||
"ext": {
|
||||
"length": 32,
|
||||
"type": "u8"
|
||||
},
|
||||
"sub": {
|
||||
"info": 7,
|
||||
"type": "u8"
|
||||
},
|
||||
"index": 0
|
||||
}
|
||||
],
|
||||
"name": "Key",
|
||||
"namespace": "ink_core::storage::key"
|
||||
},
|
||||
{
|
||||
"info": 13,
|
||||
"type": "[u8;32]",
|
||||
"ext": {
|
||||
"length": 32,
|
||||
"type": "u8"
|
||||
},
|
||||
"sub": {
|
||||
"info": 7,
|
||||
"type": "u8"
|
||||
}
|
||||
},
|
||||
{
|
||||
"info": 7,
|
||||
"type": "u8"
|
||||
},
|
||||
{
|
||||
"info": 7,
|
||||
"type": "bool"
|
||||
}
|
||||
]
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,201 @@
|
||||
{
|
||||
"registry": {
|
||||
"strings": [
|
||||
"Flipper",
|
||||
"flipper",
|
||||
"normal",
|
||||
"value",
|
||||
"Value",
|
||||
"ink_core",
|
||||
"storage",
|
||||
"cell",
|
||||
"SyncCell",
|
||||
"sync_cell",
|
||||
"Key",
|
||||
"key",
|
||||
"flip",
|
||||
"get"
|
||||
],
|
||||
"types": [
|
||||
{
|
||||
"id": {
|
||||
"custom.name": 1,
|
||||
"custom.namespace": [
|
||||
2,
|
||||
3
|
||||
],
|
||||
"custom.params": []
|
||||
},
|
||||
"def": {
|
||||
"struct.fields": [
|
||||
{
|
||||
"name": 4,
|
||||
"type": 2
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": {
|
||||
"custom.name": 5,
|
||||
"custom.namespace": [
|
||||
6,
|
||||
7,
|
||||
4
|
||||
],
|
||||
"custom.params": [
|
||||
3
|
||||
]
|
||||
},
|
||||
"def": {
|
||||
"struct.fields": [
|
||||
{
|
||||
"name": 8,
|
||||
"type": 4
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "bool",
|
||||
"def": "builtin"
|
||||
},
|
||||
{
|
||||
"id": {
|
||||
"custom.name": 9,
|
||||
"custom.namespace": [
|
||||
6,
|
||||
7,
|
||||
8,
|
||||
10
|
||||
],
|
||||
"custom.params": [
|
||||
3
|
||||
]
|
||||
},
|
||||
"def": {
|
||||
"struct.fields": [
|
||||
{
|
||||
"name": 8,
|
||||
"type": 5
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": {
|
||||
"custom.name": 11,
|
||||
"custom.namespace": [
|
||||
6,
|
||||
7,
|
||||
12
|
||||
],
|
||||
"custom.params": []
|
||||
},
|
||||
"def": {
|
||||
"tuple_struct.types": [
|
||||
6
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": {
|
||||
"array.len": 32,
|
||||
"array.type": 7
|
||||
},
|
||||
"def": "builtin"
|
||||
},
|
||||
{
|
||||
"id": "u8",
|
||||
"def": "builtin"
|
||||
}
|
||||
]
|
||||
},
|
||||
"storage": {
|
||||
"struct.type": 1,
|
||||
"struct.fields": [
|
||||
{
|
||||
"name": 4,
|
||||
"layout": {
|
||||
"struct.type": 2,
|
||||
"struct.fields": [
|
||||
{
|
||||
"name": 8,
|
||||
"layout": {
|
||||
"range.offset": [
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
"range.len": 1,
|
||||
"range.elem_type": 3
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"contract": {
|
||||
"name": 1,
|
||||
"deploy": {
|
||||
"args": [],
|
||||
"docs": [
|
||||
"Initializes our state to `false` upon deploying our smart contract."
|
||||
]
|
||||
},
|
||||
"messages": [
|
||||
{
|
||||
"name": 13,
|
||||
"selector": 970692492,
|
||||
"mutates": true,
|
||||
"args": [],
|
||||
"return_type": null,
|
||||
"docs": [
|
||||
"Flips the current state of our smart contract."
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": 14,
|
||||
"selector": 4266279973,
|
||||
"mutates": false,
|
||||
"args": [],
|
||||
"return_type": 3,
|
||||
"docs": [
|
||||
"Returns the current state."
|
||||
]
|
||||
}
|
||||
],
|
||||
"events": [],
|
||||
"docs": []
|
||||
}
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
{"name":"Incrementer","deploy":{"args":[{"name":"init_value","type":"u32"}]},"messages":[{"name":"inc","selector":257544423,"mutates":true,"args":[{"name":"by","type":"u32"}],"return_type":null},{"name":"get","selector":4266279973,"mutates":false,"args":[],"return_type":"u32"},{"name":"compare","selector":363906316,"mutates":false,"args":[{"name":"with","type":"u32"}],"return_type":"bool"}]}
|
||||
@@ -0,0 +1,935 @@
|
||||
{
|
||||
"registry": {
|
||||
"strings": [
|
||||
"SharedVec",
|
||||
"shared_vec",
|
||||
"normal",
|
||||
"mutators",
|
||||
"HashMap",
|
||||
"ink_core",
|
||||
"storage",
|
||||
"collections",
|
||||
"hash_map",
|
||||
"impls",
|
||||
"AccountId",
|
||||
"env",
|
||||
"srml",
|
||||
"types",
|
||||
"Access",
|
||||
"begin",
|
||||
"Option",
|
||||
"None",
|
||||
"Some",
|
||||
"end",
|
||||
"len",
|
||||
"Value",
|
||||
"value",
|
||||
"cell",
|
||||
"SyncCell",
|
||||
"sync_cell",
|
||||
"Key",
|
||||
"key",
|
||||
"entries",
|
||||
"SyncChunk",
|
||||
"chunk",
|
||||
"sync_chunk",
|
||||
"Entry",
|
||||
"Occupied",
|
||||
"OccupiedEntry",
|
||||
"val",
|
||||
"Removed",
|
||||
"cells_key",
|
||||
"vec",
|
||||
"Vec",
|
||||
"cells",
|
||||
"on_deploy",
|
||||
"push",
|
||||
"i32",
|
||||
"Result",
|
||||
"Ok",
|
||||
"Err",
|
||||
"register",
|
||||
"mutator",
|
||||
"set",
|
||||
"at",
|
||||
"u32",
|
||||
"to",
|
||||
"get",
|
||||
"Mutate",
|
||||
"Push",
|
||||
"Register"
|
||||
],
|
||||
"types": [
|
||||
{
|
||||
"id": {
|
||||
"custom.name": 1,
|
||||
"custom.namespace": [
|
||||
2,
|
||||
3
|
||||
],
|
||||
"custom.params": []
|
||||
},
|
||||
"def": {
|
||||
"struct.fields": [
|
||||
{
|
||||
"name": 4,
|
||||
"type": 2
|
||||
},
|
||||
{
|
||||
"name": 39,
|
||||
"type": 15
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": {
|
||||
"custom.name": 5,
|
||||
"custom.namespace": [
|
||||
6,
|
||||
7,
|
||||
8,
|
||||
9,
|
||||
10
|
||||
],
|
||||
"custom.params": [
|
||||
3,
|
||||
6
|
||||
]
|
||||
},
|
||||
"def": {
|
||||
"struct.fields": [
|
||||
{
|
||||
"name": 21,
|
||||
"type": 9
|
||||
},
|
||||
{
|
||||
"name": 29,
|
||||
"type": 12
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": {
|
||||
"custom.name": 11,
|
||||
"custom.namespace": [
|
||||
6,
|
||||
12,
|
||||
13,
|
||||
14
|
||||
],
|
||||
"custom.params": []
|
||||
},
|
||||
"def": {
|
||||
"tuple_struct.types": [
|
||||
4
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": {
|
||||
"array.len": 32,
|
||||
"array.type": 5
|
||||
},
|
||||
"def": "builtin"
|
||||
},
|
||||
{
|
||||
"id": "u8",
|
||||
"def": "builtin"
|
||||
},
|
||||
{
|
||||
"id": {
|
||||
"custom.name": 15,
|
||||
"custom.namespace": [
|
||||
2
|
||||
],
|
||||
"custom.params": []
|
||||
},
|
||||
"def": {
|
||||
"struct.fields": [
|
||||
{
|
||||
"name": 16,
|
||||
"type": 7
|
||||
},
|
||||
{
|
||||
"name": 20,
|
||||
"type": 7
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": {
|
||||
"custom.name": 17,
|
||||
"custom.namespace": [],
|
||||
"custom.params": [
|
||||
8
|
||||
]
|
||||
},
|
||||
"def": {
|
||||
"enum.variants": [
|
||||
{
|
||||
"unit_variant.name": 18
|
||||
},
|
||||
{
|
||||
"tuple_struct_variant.name": 19,
|
||||
"tuple_struct_variant.types": [
|
||||
8
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "u32",
|
||||
"def": "builtin"
|
||||
},
|
||||
{
|
||||
"id": {
|
||||
"custom.name": 22,
|
||||
"custom.namespace": [
|
||||
6,
|
||||
7,
|
||||
23
|
||||
],
|
||||
"custom.params": [
|
||||
8
|
||||
]
|
||||
},
|
||||
"def": {
|
||||
"struct.fields": [
|
||||
{
|
||||
"name": 24,
|
||||
"type": 10
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": {
|
||||
"custom.name": 25,
|
||||
"custom.namespace": [
|
||||
6,
|
||||
7,
|
||||
24,
|
||||
26
|
||||
],
|
||||
"custom.params": [
|
||||
8
|
||||
]
|
||||
},
|
||||
"def": {
|
||||
"struct.fields": [
|
||||
{
|
||||
"name": 24,
|
||||
"type": 11
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": {
|
||||
"custom.name": 27,
|
||||
"custom.namespace": [
|
||||
6,
|
||||
7,
|
||||
28
|
||||
],
|
||||
"custom.params": []
|
||||
},
|
||||
"def": {
|
||||
"tuple_struct.types": [
|
||||
4
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": {
|
||||
"custom.name": 30,
|
||||
"custom.namespace": [
|
||||
6,
|
||||
7,
|
||||
31,
|
||||
32,
|
||||
31
|
||||
],
|
||||
"custom.params": [
|
||||
13
|
||||
]
|
||||
},
|
||||
"def": {
|
||||
"struct.fields": [
|
||||
{
|
||||
"name": 38,
|
||||
"type": 11
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": {
|
||||
"custom.name": 33,
|
||||
"custom.namespace": [
|
||||
6,
|
||||
7,
|
||||
8,
|
||||
9,
|
||||
10
|
||||
],
|
||||
"custom.params": [
|
||||
3,
|
||||
6
|
||||
]
|
||||
},
|
||||
"def": {
|
||||
"enum.variants": [
|
||||
{
|
||||
"tuple_struct_variant.name": 34,
|
||||
"tuple_struct_variant.types": [
|
||||
14
|
||||
]
|
||||
},
|
||||
{
|
||||
"unit_variant.name": 37
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": {
|
||||
"custom.name": 35,
|
||||
"custom.namespace": [
|
||||
6,
|
||||
7,
|
||||
8,
|
||||
9,
|
||||
10
|
||||
],
|
||||
"custom.params": [
|
||||
3,
|
||||
6
|
||||
]
|
||||
},
|
||||
"def": {
|
||||
"struct.fields": [
|
||||
{
|
||||
"name": 28,
|
||||
"type": 3
|
||||
},
|
||||
{
|
||||
"name": 36,
|
||||
"type": 6
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": {
|
||||
"custom.name": 40,
|
||||
"custom.namespace": [
|
||||
6,
|
||||
7,
|
||||
8,
|
||||
39,
|
||||
10
|
||||
],
|
||||
"custom.params": [
|
||||
16
|
||||
]
|
||||
},
|
||||
"def": {
|
||||
"struct.fields": [
|
||||
{
|
||||
"name": 21,
|
||||
"type": 9
|
||||
},
|
||||
{
|
||||
"name": 41,
|
||||
"type": 17
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "i32",
|
||||
"def": "builtin"
|
||||
},
|
||||
{
|
||||
"id": {
|
||||
"custom.name": 30,
|
||||
"custom.namespace": [
|
||||
6,
|
||||
7,
|
||||
31,
|
||||
32,
|
||||
31
|
||||
],
|
||||
"custom.params": [
|
||||
16
|
||||
]
|
||||
},
|
||||
"def": {
|
||||
"struct.fields": [
|
||||
{
|
||||
"name": 38,
|
||||
"type": 11
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": {
|
||||
"custom.name": 45,
|
||||
"custom.namespace": [],
|
||||
"custom.params": [
|
||||
19,
|
||||
8
|
||||
]
|
||||
},
|
||||
"def": {
|
||||
"enum.variants": [
|
||||
{
|
||||
"tuple_struct_variant.name": 46,
|
||||
"tuple_struct_variant.types": [
|
||||
19
|
||||
]
|
||||
},
|
||||
{
|
||||
"tuple_struct_variant.name": 47,
|
||||
"tuple_struct_variant.types": [
|
||||
8
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": [],
|
||||
"def": "builtin"
|
||||
},
|
||||
{
|
||||
"id": {
|
||||
"custom.name": 45,
|
||||
"custom.namespace": [],
|
||||
"custom.params": [
|
||||
16,
|
||||
8
|
||||
]
|
||||
},
|
||||
"def": {
|
||||
"enum.variants": [
|
||||
{
|
||||
"tuple_struct_variant.name": 46,
|
||||
"tuple_struct_variant.types": [
|
||||
16
|
||||
]
|
||||
},
|
||||
{
|
||||
"tuple_struct_variant.name": 47,
|
||||
"tuple_struct_variant.types": [
|
||||
8
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": {
|
||||
"custom.name": 17,
|
||||
"custom.namespace": [],
|
||||
"custom.params": [
|
||||
16
|
||||
]
|
||||
},
|
||||
"def": {
|
||||
"enum.variants": [
|
||||
{
|
||||
"unit_variant.name": 18
|
||||
},
|
||||
{
|
||||
"tuple_struct_variant.name": 19,
|
||||
"tuple_struct_variant.types": [
|
||||
16
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"storage": {
|
||||
"struct.type": 1,
|
||||
"struct.fields": [
|
||||
{
|
||||
"name": 4,
|
||||
"layout": {
|
||||
"struct.type": 2,
|
||||
"struct.fields": [
|
||||
{
|
||||
"name": 21,
|
||||
"layout": {
|
||||
"struct.type": 9,
|
||||
"struct.fields": [
|
||||
{
|
||||
"name": 24,
|
||||
"layout": {
|
||||
"range.offset": [
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
"range.len": 1,
|
||||
"range.elem_type": 8
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": 29,
|
||||
"layout": {
|
||||
"range.offset": [
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
1
|
||||
],
|
||||
"range.len": 4294967295,
|
||||
"range.elem_type": 13
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": 39,
|
||||
"layout": {
|
||||
"struct.type": 15,
|
||||
"struct.fields": [
|
||||
{
|
||||
"name": 21,
|
||||
"layout": {
|
||||
"struct.type": 9,
|
||||
"struct.fields": [
|
||||
{
|
||||
"name": 24,
|
||||
"layout": {
|
||||
"range.offset": [
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
"range.len": 1,
|
||||
"range.elem_type": 8
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": 41,
|
||||
"layout": {
|
||||
"range.offset": [
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
1
|
||||
],
|
||||
"range.len": 4294967295,
|
||||
"range.elem_type": 16
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"contract": {
|
||||
"name": 1,
|
||||
"constructors": [
|
||||
{
|
||||
"name": 42,
|
||||
"selector": 0,
|
||||
"args": [],
|
||||
"docs": [
|
||||
"Initializes the value to the initial value."
|
||||
]
|
||||
}
|
||||
],
|
||||
"messages": [
|
||||
{
|
||||
"name": 43,
|
||||
"selector": 865577567,
|
||||
"mutates": true,
|
||||
"args": [
|
||||
{
|
||||
"name": 23,
|
||||
"type": {
|
||||
"ty": 16,
|
||||
"display_name": [
|
||||
44
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"return_type": {
|
||||
"ty": 18,
|
||||
"display_name": [
|
||||
45
|
||||
]
|
||||
},
|
||||
"docs": [
|
||||
"Pushes a new value to the shared vector.",
|
||||
"",
|
||||
"# Errors",
|
||||
"",
|
||||
"- If the caller does not have unlimited access rights."
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": 48,
|
||||
"selector": 572030971,
|
||||
"mutates": true,
|
||||
"args": [
|
||||
{
|
||||
"name": 49,
|
||||
"type": {
|
||||
"ty": 3,
|
||||
"display_name": [
|
||||
11
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": 16,
|
||||
"type": {
|
||||
"ty": 7,
|
||||
"display_name": [
|
||||
17
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": 20,
|
||||
"type": {
|
||||
"ty": 7,
|
||||
"display_name": [
|
||||
17
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"return_type": {
|
||||
"ty": 18,
|
||||
"display_name": [
|
||||
45
|
||||
]
|
||||
},
|
||||
"docs": [
|
||||
"Registers a new user with the given access rights.",
|
||||
"",
|
||||
"Can also be used to change access rights of an already existing user.",
|
||||
"",
|
||||
"# Errors",
|
||||
"",
|
||||
"- If the caller does not have unlimited access rights."
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": 50,
|
||||
"selector": 2028185770,
|
||||
"mutates": true,
|
||||
"args": [
|
||||
{
|
||||
"name": 51,
|
||||
"type": {
|
||||
"ty": 8,
|
||||
"display_name": [
|
||||
52
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": 53,
|
||||
"type": {
|
||||
"ty": 16,
|
||||
"display_name": [
|
||||
44
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"return_type": {
|
||||
"ty": 20,
|
||||
"display_name": [
|
||||
45
|
||||
]
|
||||
},
|
||||
"docs": [
|
||||
"Sets the value at the given position to the given value.",
|
||||
"",
|
||||
"Returns the previous value.",
|
||||
"",
|
||||
"# Errors",
|
||||
"",
|
||||
"- If the given position is out of bounds.",
|
||||
"- If the caller does not have the required access rights."
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": 54,
|
||||
"selector": 4266279973,
|
||||
"mutates": false,
|
||||
"args": [
|
||||
{
|
||||
"name": 51,
|
||||
"type": {
|
||||
"ty": 8,
|
||||
"display_name": [
|
||||
52
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"return_type": {
|
||||
"ty": 21,
|
||||
"display_name": [
|
||||
17
|
||||
]
|
||||
},
|
||||
"docs": [
|
||||
"Returns the value of the shared vector at the given position",
|
||||
"or `None` if the access is out of bounds."
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": 21,
|
||||
"selector": 1403873684,
|
||||
"mutates": false,
|
||||
"args": [],
|
||||
"return_type": {
|
||||
"ty": 8,
|
||||
"display_name": [
|
||||
52
|
||||
]
|
||||
},
|
||||
"docs": [
|
||||
"Returns the length of the shared vector."
|
||||
]
|
||||
}
|
||||
],
|
||||
"events": [
|
||||
{
|
||||
"name": 55,
|
||||
"args": [
|
||||
{
|
||||
"name": 51,
|
||||
"indexed": false,
|
||||
"type": {
|
||||
"ty": 8,
|
||||
"display_name": [
|
||||
52
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": 23,
|
||||
"indexed": false,
|
||||
"type": {
|
||||
"ty": 16,
|
||||
"display_name": [
|
||||
44
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"docs": [
|
||||
"Fires whenever a mutator changes the vector."
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": 56,
|
||||
"args": [
|
||||
{
|
||||
"name": 49,
|
||||
"indexed": false,
|
||||
"type": {
|
||||
"ty": 3,
|
||||
"display_name": [
|
||||
11
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": 23,
|
||||
"indexed": false,
|
||||
"type": {
|
||||
"ty": 16,
|
||||
"display_name": [
|
||||
44
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"docs": [
|
||||
"Fires whenever a mutator pushes the vector successfully."
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": 57,
|
||||
"args": [
|
||||
{
|
||||
"name": 49,
|
||||
"indexed": false,
|
||||
"type": {
|
||||
"ty": 3,
|
||||
"display_name": [
|
||||
11
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": 16,
|
||||
"indexed": false,
|
||||
"type": {
|
||||
"ty": 7,
|
||||
"display_name": [
|
||||
17
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": 20,
|
||||
"indexed": false,
|
||||
"type": {
|
||||
"ty": 7,
|
||||
"display_name": [
|
||||
17
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"docs": [
|
||||
"Fires whenever a new mutator is registered",
|
||||
"or when a mutators access rights are changed."
|
||||
]
|
||||
}
|
||||
],
|
||||
"docs": []
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,697 @@
|
||||
{
|
||||
"registry": {
|
||||
"strings": [
|
||||
"RustStructures",
|
||||
"structures",
|
||||
"normal",
|
||||
"my_tuple_struct",
|
||||
"Value",
|
||||
"ink_core",
|
||||
"storage",
|
||||
"value",
|
||||
"TupleStruct",
|
||||
"cell",
|
||||
"SyncCell",
|
||||
"sync_cell",
|
||||
"Key",
|
||||
"key",
|
||||
"my_struct",
|
||||
"Struct",
|
||||
"first",
|
||||
"seconds",
|
||||
"my_clike_enum",
|
||||
"ClikeEnum",
|
||||
"FirstVariant",
|
||||
"SecondVariant",
|
||||
"ThirdVariant",
|
||||
"my_enum",
|
||||
"RustEnum",
|
||||
"NoData",
|
||||
"TupleVariant",
|
||||
"StructVariant",
|
||||
"second",
|
||||
"my_union",
|
||||
"Union"
|
||||
],
|
||||
"types": [
|
||||
{
|
||||
"id": {
|
||||
"custom.name": 1,
|
||||
"custom.namespace": [
|
||||
2,
|
||||
3
|
||||
],
|
||||
"custom.params": []
|
||||
},
|
||||
"def": {
|
||||
"struct.fields": [
|
||||
{
|
||||
"name": 4,
|
||||
"type": 2
|
||||
},
|
||||
{
|
||||
"name": 15,
|
||||
"type": 9
|
||||
},
|
||||
{
|
||||
"name": 19,
|
||||
"type": 12
|
||||
},
|
||||
{
|
||||
"name": 24,
|
||||
"type": 15
|
||||
},
|
||||
{
|
||||
"name": 30,
|
||||
"type": 18
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": {
|
||||
"custom.name": 5,
|
||||
"custom.namespace": [
|
||||
6,
|
||||
7,
|
||||
8
|
||||
],
|
||||
"custom.params": [
|
||||
3
|
||||
]
|
||||
},
|
||||
"def": {
|
||||
"struct.fields": [
|
||||
{
|
||||
"name": 10,
|
||||
"type": 6
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": {
|
||||
"custom.name": 9,
|
||||
"custom.namespace": [
|
||||
2
|
||||
],
|
||||
"custom.params": []
|
||||
},
|
||||
"def": {
|
||||
"tuple_struct.types": [
|
||||
4,
|
||||
5
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "u8",
|
||||
"def": "builtin"
|
||||
},
|
||||
{
|
||||
"id": "u16",
|
||||
"def": "builtin"
|
||||
},
|
||||
{
|
||||
"id": {
|
||||
"custom.name": 11,
|
||||
"custom.namespace": [
|
||||
6,
|
||||
7,
|
||||
10,
|
||||
12
|
||||
],
|
||||
"custom.params": [
|
||||
3
|
||||
]
|
||||
},
|
||||
"def": {
|
||||
"struct.fields": [
|
||||
{
|
||||
"name": 10,
|
||||
"type": 7
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": {
|
||||
"custom.name": 13,
|
||||
"custom.namespace": [
|
||||
6,
|
||||
7,
|
||||
14
|
||||
],
|
||||
"custom.params": []
|
||||
},
|
||||
"def": {
|
||||
"tuple_struct.types": [
|
||||
8
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": {
|
||||
"array.len": 32,
|
||||
"array.type": 4
|
||||
},
|
||||
"def": "builtin"
|
||||
},
|
||||
{
|
||||
"id": {
|
||||
"custom.name": 5,
|
||||
"custom.namespace": [
|
||||
6,
|
||||
7,
|
||||
8
|
||||
],
|
||||
"custom.params": [
|
||||
10
|
||||
]
|
||||
},
|
||||
"def": {
|
||||
"struct.fields": [
|
||||
{
|
||||
"name": 10,
|
||||
"type": 11
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": {
|
||||
"custom.name": 16,
|
||||
"custom.namespace": [
|
||||
2
|
||||
],
|
||||
"custom.params": []
|
||||
},
|
||||
"def": {
|
||||
"struct.fields": [
|
||||
{
|
||||
"name": 17,
|
||||
"type": 4
|
||||
},
|
||||
{
|
||||
"name": 18,
|
||||
"type": 5
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": {
|
||||
"custom.name": 11,
|
||||
"custom.namespace": [
|
||||
6,
|
||||
7,
|
||||
10,
|
||||
12
|
||||
],
|
||||
"custom.params": [
|
||||
10
|
||||
]
|
||||
},
|
||||
"def": {
|
||||
"struct.fields": [
|
||||
{
|
||||
"name": 10,
|
||||
"type": 7
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": {
|
||||
"custom.name": 5,
|
||||
"custom.namespace": [
|
||||
6,
|
||||
7,
|
||||
8
|
||||
],
|
||||
"custom.params": [
|
||||
13
|
||||
]
|
||||
},
|
||||
"def": {
|
||||
"struct.fields": [
|
||||
{
|
||||
"name": 10,
|
||||
"type": 14
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": {
|
||||
"custom.name": 20,
|
||||
"custom.namespace": [
|
||||
2
|
||||
],
|
||||
"custom.params": []
|
||||
},
|
||||
"def": {
|
||||
"clike_enum.variants": [
|
||||
{
|
||||
"name": 21,
|
||||
"discriminant": 0
|
||||
},
|
||||
{
|
||||
"name": 22,
|
||||
"discriminant": 1
|
||||
},
|
||||
{
|
||||
"name": 23,
|
||||
"discriminant": 42
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": {
|
||||
"custom.name": 11,
|
||||
"custom.namespace": [
|
||||
6,
|
||||
7,
|
||||
10,
|
||||
12
|
||||
],
|
||||
"custom.params": [
|
||||
13
|
||||
]
|
||||
},
|
||||
"def": {
|
||||
"struct.fields": [
|
||||
{
|
||||
"name": 10,
|
||||
"type": 7
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": {
|
||||
"custom.name": 5,
|
||||
"custom.namespace": [
|
||||
6,
|
||||
7,
|
||||
8
|
||||
],
|
||||
"custom.params": [
|
||||
16
|
||||
]
|
||||
},
|
||||
"def": {
|
||||
"struct.fields": [
|
||||
{
|
||||
"name": 10,
|
||||
"type": 17
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": {
|
||||
"custom.name": 25,
|
||||
"custom.namespace": [
|
||||
2
|
||||
],
|
||||
"custom.params": []
|
||||
},
|
||||
"def": {
|
||||
"enum.variants": [
|
||||
{
|
||||
"unit_variant.name": 26
|
||||
},
|
||||
{
|
||||
"tuple_struct_variant.name": 27,
|
||||
"tuple_struct_variant.types": [
|
||||
4,
|
||||
5
|
||||
]
|
||||
},
|
||||
{
|
||||
"struct_variant.name": 28,
|
||||
"struct_variant.fields": [
|
||||
{
|
||||
"name": 17,
|
||||
"type": 4
|
||||
},
|
||||
{
|
||||
"name": 29,
|
||||
"type": 5
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": {
|
||||
"custom.name": 11,
|
||||
"custom.namespace": [
|
||||
6,
|
||||
7,
|
||||
10,
|
||||
12
|
||||
],
|
||||
"custom.params": [
|
||||
16
|
||||
]
|
||||
},
|
||||
"def": {
|
||||
"struct.fields": [
|
||||
{
|
||||
"name": 10,
|
||||
"type": 7
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": {
|
||||
"custom.name": 5,
|
||||
"custom.namespace": [
|
||||
6,
|
||||
7,
|
||||
8
|
||||
],
|
||||
"custom.params": [
|
||||
19
|
||||
]
|
||||
},
|
||||
"def": {
|
||||
"struct.fields": [
|
||||
{
|
||||
"name": 10,
|
||||
"type": 20
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": {
|
||||
"custom.name": 31,
|
||||
"custom.namespace": [
|
||||
2
|
||||
],
|
||||
"custom.params": []
|
||||
},
|
||||
"def": {
|
||||
"union.fields": [
|
||||
{
|
||||
"name": 17,
|
||||
"type": 4
|
||||
},
|
||||
{
|
||||
"name": 29,
|
||||
"type": 5
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": {
|
||||
"custom.name": 11,
|
||||
"custom.namespace": [
|
||||
6,
|
||||
7,
|
||||
10,
|
||||
12
|
||||
],
|
||||
"custom.params": [
|
||||
19
|
||||
]
|
||||
},
|
||||
"def": {
|
||||
"struct.fields": [
|
||||
{
|
||||
"name": 10,
|
||||
"type": 7
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"storage": {
|
||||
"struct.type": 1,
|
||||
"struct.fields": [
|
||||
{
|
||||
"name": 4,
|
||||
"layout": {
|
||||
"struct.type": 2,
|
||||
"struct.fields": [
|
||||
{
|
||||
"name": 10,
|
||||
"layout": {
|
||||
"range.offset": [
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
"range.len": 1,
|
||||
"range.elem_type": 3
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": 15,
|
||||
"layout": {
|
||||
"struct.type": 9,
|
||||
"struct.fields": [
|
||||
{
|
||||
"name": 10,
|
||||
"layout": {
|
||||
"range.offset": [
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
1
|
||||
],
|
||||
"range.len": 1,
|
||||
"range.elem_type": 10
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": 19,
|
||||
"layout": {
|
||||
"struct.type": 12,
|
||||
"struct.fields": [
|
||||
{
|
||||
"name": 10,
|
||||
"layout": {
|
||||
"range.offset": [
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
2
|
||||
],
|
||||
"range.len": 1,
|
||||
"range.elem_type": 13
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": 24,
|
||||
"layout": {
|
||||
"struct.type": 15,
|
||||
"struct.fields": [
|
||||
{
|
||||
"name": 10,
|
||||
"layout": {
|
||||
"range.offset": [
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
3
|
||||
],
|
||||
"range.len": 1,
|
||||
"range.elem_type": 16
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": 30,
|
||||
"layout": {
|
||||
"struct.type": 18,
|
||||
"struct.fields": [
|
||||
{
|
||||
"name": 10,
|
||||
"layout": {
|
||||
"range.offset": [
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
4
|
||||
],
|
||||
"range.len": 1,
|
||||
"range.elem_type": 19
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"contract": {
|
||||
"name": 1,
|
||||
"deploy": {
|
||||
"args": [],
|
||||
"docs": []
|
||||
},
|
||||
"messages": [],
|
||||
"events": [],
|
||||
"docs": []
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user