Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4fbdbcf8c5 | ||
|
|
ac5c993b27 | ||
|
|
e05dcf7383 | ||
|
|
c9ea3ab1ae | ||
|
|
4b097dcaef | ||
|
|
2a9cca5f1b | ||
|
|
8ce3a40c66 | ||
|
|
958a13384d | ||
|
|
e25545c39f | ||
|
|
bca1e0c5c4 | ||
|
|
bf36024568 | ||
|
|
1292a270e0 | ||
|
|
68fe800f63 | ||
|
|
ceb1575e1a | ||
|
|
4916d63832 | ||
|
|
d2176485b9 | ||
|
|
e9dd421b62 | ||
|
|
802c241820 | ||
|
|
a3b5ced423 | ||
|
|
b975766d35 | ||
|
|
eb460570ac | ||
|
|
a8658d5b60 | ||
|
|
fbe462e2e3 | ||
|
|
04bbf28a57 | ||
|
|
47b79675da | ||
|
|
4ed83e737c | ||
|
|
2ee863becc | ||
|
|
b343c31317 | ||
|
|
04759e563e | ||
|
|
6a5478919c | ||
|
|
ac828b31e6 | ||
|
|
86f17113e3 | ||
|
|
cb0429fae9 | ||
|
|
f23418ad84 | ||
|
|
8386a70bfe | ||
|
|
843cb3d00a | ||
|
|
3143e9df1c | ||
|
|
b76bdb5ed5 | ||
|
|
0e80e88456 | ||
|
|
46bfe643a6 | ||
|
|
2e0b8e4d11 | ||
|
|
a8668c3c44 | ||
|
|
11431f0e68 | ||
|
|
6c664498dd | ||
|
|
7721ac722d | ||
|
|
0070f33089 | ||
|
|
a1267eb891 | ||
|
|
1803ba6a8e | ||
|
|
ae4b166c2f | ||
|
|
38d6136aa8 | ||
|
|
02fea57a48 | ||
|
|
882826a7e3 | ||
|
|
56a7788e28 | ||
|
|
82c4b75a12 | ||
|
|
ca3c932701 | ||
|
|
76b155c269 | ||
|
|
faed35e208 | ||
|
|
c46cd5030e | ||
|
|
c7e474cdc6 | ||
|
|
ac7a678a30 | ||
|
|
f956759865 | ||
|
|
2768b70d43 | ||
|
|
cc4a579905 | ||
|
|
450b7b8e8b | ||
|
|
a248bc9f96 | ||
|
|
35f677f2e9 | ||
|
|
fccba5d93d | ||
|
|
ae172e2c53 | ||
|
|
aa9bf0780b | ||
|
|
11f1d8057b | ||
|
|
e2f1e7c033 | ||
|
|
bb213425f8 | ||
|
|
162596ed93 | ||
|
|
aa3ba246a7 | ||
|
|
baf65438fe | ||
|
|
8b443dfa4b | ||
|
|
12f3f8695f | ||
|
|
964d308491 | ||
|
|
a1bf03e40e | ||
|
|
ff940e5d26 | ||
|
|
e2fa0ad11f | ||
|
|
654e44aa99 | ||
|
|
476689f615 | ||
|
|
fc1582aa70 | ||
|
|
a616b84045 | ||
|
|
73708b72c7 | ||
|
|
8f0807ddbe | ||
|
|
5547f885be | ||
|
|
5f8d521c6a | ||
|
|
51a169a88a | ||
|
|
ad89ed5f3d | ||
|
|
ca1362c595 | ||
|
|
9621d90613 | ||
|
|
50efeb06d1 | ||
|
|
e236acc29d | ||
|
|
1062ace58d | ||
|
|
298a901921 | ||
|
|
c2f453481c | ||
|
|
54e6b61972 | ||
|
|
c52a7b1e64 | ||
|
|
749cd2e381 | ||
|
|
24b1790c99 | ||
|
|
62823635b0 | ||
|
|
bc84220108 | ||
|
|
5158951326 | ||
|
|
500b739ddd | ||
|
|
b741d228ac | ||
|
|
437ff8b51d | ||
|
|
354dd0a7a4 | ||
|
|
3804123ca6 | ||
|
|
bbc752e475 | ||
|
|
80f69b88b2 | ||
|
|
a02eab478e | ||
|
|
22fdb9a1f9 | ||
|
|
496d2123ed | ||
|
|
15a2e6c6cf | ||
|
|
62a9a7aeb5 | ||
|
|
8541088893 | ||
|
|
e558cf8f7f | ||
|
|
01827deaf5 | ||
|
|
6d71677c17 | ||
|
|
ee42a717aa | ||
|
|
cfa8ab7ab6 | ||
|
|
4ecd14c187 | ||
|
|
d9318bc917 | ||
|
|
6f6db63580 | ||
|
|
ebd1e64694 | ||
|
|
f12aa92383 | ||
|
|
2df0638b19 | ||
|
|
542f484703 | ||
|
|
f9dbedb93a | ||
|
|
2492ae5d60 | ||
|
|
c5ab1c0e1a | ||
|
|
fa9a7c197b | ||
|
|
05b9f13a45 | ||
|
|
b4511920b0 | ||
|
|
4d6ee85071 | ||
|
|
3f96caf54d | ||
|
|
0b804ff776 | ||
|
|
0b1cec4e2d | ||
|
|
dd4bf9feba | ||
|
|
4d41bbcf04 | ||
|
|
04780bda5c | ||
|
|
becc991dc8 | ||
|
|
815756d168 | ||
|
|
c960cee703 | ||
|
|
c7da06215d | ||
|
|
55053f76a9 | ||
|
|
19fb9dafc9 | ||
|
|
f0f0dec8ea | ||
|
|
649b2f5e4a | ||
|
|
af06ec22c5 | ||
|
|
bb976e746a | ||
|
|
814f8418f2 | ||
|
|
a00dd1e4ca | ||
|
|
66e24c3750 | ||
|
|
1ff4c58fe3 | ||
|
|
5ff15b18a1 | ||
|
|
83975e9235 | ||
|
|
3adf475ef4 | ||
|
|
ccc6edebbb | ||
|
|
0d7ed7420d | ||
|
|
dbf1837b97 | ||
|
|
9ae738ac51 | ||
|
|
a4000efc43 | ||
|
|
7871a17942 | ||
|
|
5aad1d09b2 | ||
|
|
4eb5d7dfd3 | ||
|
|
0a841e8f4a | ||
|
|
53ffd0c9f0 | ||
|
|
5d3a9f2e2e | ||
|
|
9d6f38edb3 | ||
|
|
9e5e032e1d | ||
|
|
31426858c6 | ||
|
|
46b4ca0c91 | ||
|
|
f4cb68c567 | ||
|
|
ab4b234510 | ||
|
|
d5151c4f01 | ||
|
|
6df4689aa3 | ||
|
|
9727a6a9a5 | ||
|
|
7f00182fd9 | ||
|
|
261b0add27 | ||
|
|
5d6e753384 | ||
|
|
15c2e79e6e | ||
|
|
f763a66219 | ||
|
|
1061df6e4a | ||
|
|
4c121e6f50 | ||
|
|
74b3a04c4a | ||
|
|
e4488463ba | ||
|
|
c6fd67b5d5 | ||
|
|
e5dc596867 | ||
|
|
a28f8dad37 | ||
|
|
7855658bfd | ||
|
|
de14a85817 | ||
|
|
de2206bb27 | ||
|
|
451a7aecde | ||
|
|
5170194105 | ||
|
|
b2286ac06a | ||
|
|
57cc6d6d46 | ||
|
|
6e1b5901b3 | ||
|
|
203db7467f | ||
|
|
aa7d4838c7 | ||
|
|
b778f606c5 | ||
|
|
45146efce8 | ||
|
|
9229f9f295 | ||
|
|
2e1c29a5a8 | ||
|
|
79f925b589 | ||
|
|
572c2789cc | ||
|
|
913f9636ba | ||
|
|
83e5592305 | ||
|
|
b7e579f6b8 | ||
|
|
c211b811a6 | ||
|
|
4c02b25a2d | ||
|
|
28b2435019 | ||
|
|
a0e5d60a0a | ||
|
|
311eceec0d | ||
|
|
cf24dcdf22 | ||
|
|
ead3eceef4 | ||
|
|
59df9aefc4 | ||
|
|
cb97cc1786 | ||
|
|
cf18ecf193 | ||
|
|
6e6b13f29a | ||
|
|
f75a16159d | ||
|
|
b8fe6be9cc | ||
|
|
9993325679 | ||
|
|
ce8fe9f49d | ||
|
|
408a6706b1 | ||
|
|
79c7fa3b75 | ||
|
|
e9713b6c93 | ||
|
|
706a3e0cc2 | ||
|
|
b1a40516c1 | ||
|
|
7cf449074d | ||
|
|
2ce7a79263 | ||
|
|
cfa5660d54 | ||
|
|
1256f2a54a | ||
|
|
2695afa68e | ||
|
|
af71673c7b | ||
|
|
7f489e1a99 | ||
|
|
10fb33877c | ||
|
|
731def1f56 | ||
|
|
06057da172 | ||
|
|
af3e79e70a | ||
|
|
9e5ee72adf | ||
|
|
6a8344020f | ||
|
|
a1ad6f1dd0 | ||
|
|
71f2b64868 | ||
|
|
ad7e949c8c | ||
|
|
d24241d656 | ||
|
|
91d2e9bbbd | ||
|
|
8acc5680ac | ||
|
|
4d54ce4686 | ||
|
|
441e89edd7 | ||
|
|
f1da9f05fb | ||
|
|
464d2d38b4 | ||
|
|
1ea282c803 | ||
|
|
974559bf2e | ||
|
|
c353003c70 | ||
|
|
623bde1a61 | ||
|
|
67234fc013 | ||
|
|
4a6d6d647a | ||
|
|
b375b6c2d5 | ||
|
|
1c6fd4558c | ||
|
|
3800ffd61a | ||
|
|
d447ed8fc9 | ||
|
|
abb1062462 | ||
|
|
c6bdf78606 | ||
|
|
7687d5bf00 | ||
|
|
5b246891d7 | ||
|
|
3b9617faf4 | ||
|
|
aa57da0806 | ||
|
|
66841bba88 | ||
|
|
7d963e3602 | ||
|
|
82b25aecfb | ||
|
|
9b204fc660 | ||
|
|
68bcce7a27 | ||
|
|
3a57c7da69 | ||
|
|
055c4f82f5 | ||
|
|
12d8b07ff1 | ||
|
|
f07d66562b | ||
|
|
80f28da707 | ||
|
|
1aec77922f | ||
|
|
f431f02f11 | ||
|
|
2063183f50 | ||
|
|
8280af08a6 | ||
|
|
8029a54508 | ||
|
|
9e5478e0c0 | ||
|
|
c67c1966d7 | ||
|
|
e1aa096cef | ||
|
|
7135941b6a | ||
|
|
dc24fb82a8 | ||
|
|
32cfe3707e | ||
|
|
97378be94e | ||
|
|
db0559e9c9 | ||
|
|
94d6a900f7 | ||
|
|
d751c03d45 | ||
|
|
aef8003d50 | ||
|
|
2810b35d6c | ||
|
|
6148932389 | ||
|
|
f4889a36d4 | ||
|
|
e8879c0ffc | ||
|
|
ed64514415 | ||
|
|
fcc25ee2c8 | ||
|
|
695e19a8a7 | ||
|
|
384bf9a41a | ||
|
|
8f24a2758e | ||
|
|
3230663ae1 | ||
|
|
4a0fa7f615 | ||
|
|
0f05954dc5 | ||
|
|
55f442f9fa | ||
|
|
7e5edc46a3 | ||
|
|
d500f98fb4 | ||
|
|
7b8902ce3f | ||
|
|
98b3ad642f | ||
|
|
14466e27ac | ||
|
|
16ffd1b467 | ||
|
|
ca52fd7e5b | ||
|
|
ea5d3df64c | ||
|
|
b51ed71796 | ||
|
|
bf28507ae8 | ||
|
|
6715bef24a | ||
|
|
badbbd76cb | ||
|
|
253776a510 | ||
|
|
e1ef295bfa | ||
|
|
73c89f4e3c | ||
|
|
a52e0dfb16 | ||
|
|
9f8ed7bb50 | ||
|
|
a932f9408a | ||
|
|
7907ce6dbf | ||
|
|
230d510491 | ||
|
|
415fd1b2d1 | ||
|
|
89c954216d | ||
|
|
b689796b25 | ||
|
|
c4c18d324b | ||
|
|
b7bf500343 | ||
|
|
e5c6baf425 | ||
|
|
0127899c5e | ||
|
|
f23611cad6 | ||
|
|
a74df109b0 | ||
|
|
9582013bfa | ||
|
|
6c148dcb3b | ||
|
|
65488bbff8 | ||
|
|
40cbb81d1e | ||
|
|
77b896054f | ||
|
|
89c717bd11 | ||
|
|
b22f5643a9 | ||
|
|
8d68ed3117 | ||
|
|
65b1c81c21 | ||
|
|
28cd140cfb | ||
|
|
73b553fbd2 | ||
|
|
f12075798d | ||
|
|
323db21306 | ||
|
|
d54302eacc | ||
|
|
9a98d5b6e4 | ||
|
|
5ec613adf9 | ||
|
|
567ce7955a | ||
|
|
b185dcb072 | ||
|
|
79010f83dc | ||
|
|
5354f93946 | ||
|
|
e787e66ef9 | ||
|
|
440e826fed | ||
|
|
d2e5e1d441 | ||
|
|
32fc32f414 | ||
|
|
0a7b2a7a9f | ||
|
|
c315e6fdaa | ||
|
|
b5d9ed36e1 | ||
|
|
f24c7983c8 | ||
|
|
3447cd40bf | ||
|
|
95f4702e26 | ||
|
|
506142da8a | ||
|
|
34f6eac538 | ||
|
|
ae1a37cdf7 | ||
|
|
fab087bbe5 | ||
|
|
8608098996 | ||
|
|
220f4029b1 | ||
|
|
d21daf1434 | ||
|
|
1a4c16f797 | ||
|
|
975103fd3c | ||
|
|
fb84ac7c25 | ||
|
|
13ae8665d5 | ||
|
|
4e8b2beb0b | ||
|
|
dd1220ac97 | ||
|
|
b46308fa8f | ||
|
|
c366e637e9 | ||
|
|
81acc81ef7 | ||
|
|
eb7270ff3f | ||
|
|
30198d1a6d | ||
|
|
2fc078d994 | ||
|
|
bd1735cafb | ||
|
|
ca73e5bc4d | ||
|
|
aff78c2e30 | ||
|
|
fbd454eb5a | ||
|
|
ce964d2f12 | ||
|
|
2c26bc61da | ||
|
|
4111122cba | ||
|
|
e1e95dc6b3 | ||
|
|
e7c665e5da | ||
|
|
301eb587cb | ||
|
|
5c886b0f81 | ||
|
|
56a79924a0 | ||
|
|
beef1b38ed | ||
|
|
ce46a68187 | ||
|
|
94dc2d76b3 | ||
|
|
dcdde1cf4b | ||
|
|
e3a9099b58 | ||
|
|
fb03ff3994 | ||
|
|
1d42fbf2bf | ||
|
|
c0e4b1b93e | ||
|
|
139f3f90b0 | ||
|
|
cf6fae8e1d | ||
|
|
f8d69736c1 | ||
|
|
a4322cb99a | ||
|
|
9445006127 | ||
|
|
aeeaa91752 | ||
|
|
52fb4ac863 | ||
|
|
2a000a2a14 | ||
|
|
97fe3b2ea3 | ||
|
|
9b8a782d58 | ||
|
|
b56e40ea5b | ||
|
|
37d1bcb6eb | ||
|
|
f2b8c1fb4e | ||
|
|
92cc8fc4e3 | ||
|
|
701bd9335d | ||
|
|
d176c74715 | ||
|
|
0bf7c799f3 | ||
|
|
2f7d5cd4e1 | ||
|
|
c42b517293 | ||
|
|
e5dd55e419 | ||
|
|
83fdd11c59 | ||
|
|
08de8ce25a | ||
|
|
800bafc00c | ||
|
|
3b383b97ca | ||
|
|
b381c09ecf | ||
|
|
a53008fd67 | ||
|
|
899056c5a2 | ||
|
|
8554d47030 | ||
|
|
9808f58540 | ||
|
|
7228100835 | ||
|
|
08c1b413d2 | ||
|
|
27ae11860d | ||
|
|
9cc984e8ae | ||
|
|
d352782927 | ||
|
|
6e4a5281ed | ||
|
|
d11f6d9307 | ||
|
|
61b57687af | ||
|
|
3ab1623a40 | ||
|
|
f5acd60253 | ||
|
|
c4d368d2b5 | ||
|
|
e487d0a454 | ||
|
|
99ffcc52ec | ||
|
|
64510af8d3 | ||
|
|
52b14db475 | ||
|
|
c5fe5cd8d4 | ||
|
|
bdfc614ad5 | ||
|
|
0d03eac307 | ||
|
|
6c84edcb9d | ||
|
|
9d145e72b8 | ||
|
|
4529bc37b5 | ||
|
|
038ef42fe5 | ||
|
|
1871d36a97 | ||
|
|
45c2afae07 | ||
|
|
51edae2f67 | ||
|
|
437314e5ea | ||
|
|
ce6f9d8bc8 | ||
|
|
0cf65e1671 | ||
|
|
a0251ff650 | ||
|
|
9696badcd1 | ||
|
|
08817d199d | ||
|
|
df69a02e6f | ||
|
|
e845132d89 | ||
|
|
21e9b9a033 | ||
|
|
db61ea3077 | ||
|
|
d4a3d2392e | ||
|
|
88ecda706d | ||
|
|
184fb1f12e | ||
|
|
91340577df | ||
|
|
36729678e2 | ||
|
|
1c6b4bfc34 | ||
|
|
bbfd175579 | ||
|
|
0a6bd41444 | ||
|
|
ab21274c36 | ||
|
|
d4e6ad5553 | ||
|
|
49dbd757df | ||
|
|
20e82cc45b | ||
|
|
6a7fa80c55 | ||
|
|
12e34cd3e8 | ||
|
|
0a598fdf92 | ||
|
|
659b896ee7 | ||
|
|
7cda007a30 | ||
|
|
2288c4da8a | ||
|
|
fbfc21be1c | ||
|
|
787beb2aea | ||
|
|
6234e16c37 | ||
|
|
e9cbc0a0d9 | ||
|
|
166eeb8852 | ||
|
|
b321f92161 | ||
|
|
cf7d9d9ff5 | ||
|
|
fb5b3c1663 | ||
|
|
46bbc45145 | ||
|
|
dc8b4a6447 | ||
|
|
8ec38eca4a | ||
|
|
24b533689c | ||
|
|
5421e06fc9 | ||
|
|
7115efd94f | ||
|
|
92f88222c4 | ||
|
|
bc7aba71a6 | ||
|
|
1d8b8b3204 | ||
|
|
4a2e090ef8 | ||
|
|
8cf8d5b7e8 | ||
|
|
8d355ff6fc | ||
|
|
72456bb2bd | ||
|
|
87f3fd2827 | ||
|
|
7254aab68d | ||
|
|
95d7160ad0 | ||
|
|
611b1be481 | ||
|
|
73b35fc188 | ||
|
|
6c30d5b9fd | ||
|
|
56d151fe66 | ||
|
|
cd20fe6c8b | ||
|
|
28f8ca73aa | ||
|
|
f4a8bfc0c0 | ||
|
|
94b058d6a3 | ||
|
|
3d7ddb85a2 | ||
|
|
f7a2bb895f | ||
|
|
c1bfcc00b6 | ||
|
|
b16d8e7c26 | ||
|
|
2a4b363fcd | ||
|
|
de689b8e6f | ||
|
|
2e72ab920b | ||
|
|
565e6baecd | ||
|
|
1e15203b6c | ||
|
|
cc8639565d | ||
|
|
b77d2e6860 | ||
|
|
e1fbd8ff9f | ||
|
|
f56dd32b4a | ||
|
|
6077bef570 | ||
|
|
377d83d4ed | ||
|
|
bdb14f91a8 | ||
|
|
cc5b7ed0ad | ||
|
|
d4491aeb7f | ||
|
|
0f6e996799 | ||
|
|
1f3dd60a8d | ||
|
|
3351fb1cba | ||
|
|
32d176e424 | ||
|
|
aec1e26cb9 | ||
|
|
7d529b6c93 | ||
|
|
e22b39ae01 | ||
|
|
18a202c460 | ||
|
|
fd9ce319a5 | ||
|
|
a04c0a5e82 | ||
|
|
06cb5e57a0 | ||
|
|
103ea045bf | ||
|
|
4315c76814 | ||
|
|
6de6b871cd | ||
|
|
82e5d76821 | ||
|
|
d9a18a4acf | ||
|
|
2d1d4f808e | ||
|
|
d1de30907f | ||
|
|
d3583dc432 | ||
|
|
bb04fa28f7 | ||
|
|
bd8e862b62 | ||
|
|
0f45b7fbf3 | ||
|
|
03eb72f128 | ||
|
|
f76a4a98be | ||
|
|
c2b91ad8c2 | ||
|
|
ffc6b0323b | ||
|
|
b666db2721 | ||
|
|
b00d49564f | ||
|
|
34380caf1f | ||
|
|
277cc2b5a8 | ||
|
|
733e9e2729 | ||
|
|
482264c615 | ||
|
|
5d0abef952 | ||
|
|
2397e1c5d7 | ||
|
|
62ebe257a6 | ||
|
|
a2844a449c | ||
|
|
60a9866abe | ||
|
|
b196158125 | ||
|
|
6b1caacfb9 | ||
|
|
a7679fb07c | ||
|
|
c4acca6c7c | ||
|
|
5012792693 | ||
|
|
d40d6c65f7 | ||
|
|
2c0d8e4b59 | ||
|
|
d3d8caa0df | ||
|
|
a8f8525c9d | ||
|
|
caa5a8b9e6 | ||
|
|
ce6187f378 | ||
|
|
fe9c7a8a80 | ||
|
|
d5584c1837 | ||
|
|
adb1c1fea4 | ||
|
|
c87c228ab1 | ||
|
|
cbec4add88 | ||
|
|
6429cc307c | ||
|
|
c98e994777 | ||
|
|
697a452ba6 | ||
|
|
f68294c4e7 | ||
|
|
0130d18945 | ||
|
|
15c9904c96 | ||
|
|
add2749967 | ||
|
|
fe2f054389 | ||
|
|
bb1c117727 | ||
|
|
27c474bd78 | ||
|
|
039b5ec932 | ||
|
|
9eea21e0c4 | ||
|
|
aab533f92e | ||
|
|
2159270d80 | ||
|
|
f1b09eb2e5 | ||
|
|
d08cf8b5fe | ||
|
|
941618b830 | ||
|
|
983ca718ec | ||
|
|
41ebdd5c59 | ||
|
|
8971c89081 | ||
|
|
d1934060e0 | ||
|
|
6d9da39d8b | ||
|
|
4ed096024e | ||
|
|
ae36d58802 | ||
|
|
c8100dbe43 | ||
|
|
28d2ce38bd | ||
|
|
afce99ed1a | ||
|
|
29d13ab19c | ||
|
|
68a8bcb7db | ||
|
|
d2ecf1730a | ||
|
|
af56c10278 | ||
|
|
42f318fcb5 | ||
|
|
336df0d76d | ||
|
|
d85cedf5a0 | ||
|
|
a59187bce6 | ||
|
|
f9a5b75e10 | ||
|
|
87228149d4 | ||
|
|
67f36f6a13 | ||
|
|
75a9898daf | ||
|
|
0f726ce777 | ||
|
|
765f9baf44 | ||
|
|
2d181df360 | ||
|
|
77ff703a08 | ||
|
|
804ed13d0a | ||
|
|
341a6b0c08 | ||
|
|
614985b8ac | ||
|
|
d5bfa8c3c4 | ||
|
|
359981d2ef | ||
|
|
b0ee79f90c | ||
|
|
c2d595fb3f | ||
|
|
f837200a73 | ||
|
|
ea7dd553a2 | ||
|
|
7c1ca3a5c9 | ||
|
|
75cd547b49 | ||
|
|
91c4c407a9 | ||
|
|
20b46a65fa | ||
|
|
c60459e303 | ||
|
|
92ab4699b3 | ||
|
|
932f4c25f5 | ||
|
|
aaa35a8198 | ||
|
|
9708131620 | ||
|
|
c539430a0b | ||
|
|
8defc792a9 | ||
|
|
76a0daeed6 | ||
|
|
e236fdc396 | ||
|
|
e30dd7c0d9 | ||
|
|
f3ac6b2674 | ||
|
|
171015fbba | ||
|
|
dca36e41fd | ||
|
|
a602b0409c | ||
|
|
04d79da155 | ||
|
|
81a31519db | ||
|
|
78e39dcf34 | ||
|
|
6194660b3b | ||
|
|
2e08018718 | ||
|
|
b0d6ccdbd4 | ||
|
|
48b753b8ac | ||
|
|
506bc59f86 | ||
|
|
f86fcc6044 | ||
|
|
e8d2a439d5 | ||
|
|
9fa6b5bffa | ||
|
|
932ef41aae | ||
|
|
3910853ba1 | ||
|
|
6956e88708 | ||
|
|
3769b99cd2 | ||
|
|
ee17054b38 | ||
|
|
72cfbddd4a | ||
|
|
cffb23728d | ||
|
|
a69dc01c78 | ||
|
|
d889c71056 | ||
|
|
8eef3f9989 | ||
|
|
3112e43715 | ||
|
|
fc9a5ac25f | ||
|
|
242b107752 | ||
|
|
bf5ba0f405 | ||
|
|
e4de3a1339 | ||
|
|
69279f1b81 | ||
|
|
303c822d48 | ||
|
|
90ca8a0d78 | ||
|
|
94bbc6f2ee | ||
|
|
f4be1fe52e | ||
|
|
d3f6f3621b | ||
|
|
ea9ad6f389 | ||
|
|
b03ce51a31 | ||
|
|
b8411bb0ea | ||
|
|
36b53c5a8e | ||
|
|
e60bbbeb59 | ||
|
|
eb90564260 | ||
|
|
1c151ca04a | ||
|
|
249919502a | ||
|
|
a2f9614ce8 | ||
|
|
98bdc9950a | ||
|
|
1387839696 | ||
|
|
4e8cb2af2f | ||
|
|
dd0de55638 | ||
|
|
e09d0ca5ca | ||
|
|
41f024d0fc | ||
|
|
4ce452b40a | ||
|
|
0a8ab20744 | ||
|
|
d108970d09 | ||
|
|
7fb1adb94e | ||
|
|
b7635d7e2b | ||
|
|
2273ce8bd3 | ||
|
|
cfdf629b49 | ||
|
|
f5f35ee3bf | ||
|
|
c776f0d815 | ||
|
|
c1a23937bd | ||
|
|
241febb707 | ||
|
|
357c7368d2 | ||
|
|
4e4ff5de4b | ||
|
|
8d80bf869b | ||
|
|
337c67ff30 | ||
|
|
66573f6234 | ||
|
|
408129d5ca | ||
|
|
efa6661817 | ||
|
|
c988d5011c | ||
|
|
f173bb3d2a | ||
|
|
1f0368061f | ||
|
|
45ef924862 | ||
|
|
dec88b6ab7 | ||
|
|
ed402341dc | ||
|
|
76a9f2787c | ||
|
|
5b1c9b8ccb | ||
|
|
af751c6c89 | ||
|
|
4ab8dd70bd | ||
|
|
a5f59ca926 | ||
|
|
71f26aac8d | ||
|
|
cc7d6a2e01 | ||
|
|
e29f0a3920 | ||
|
|
f38975d126 | ||
|
|
dc4b59bb0c | ||
|
|
2f5df085b6 | ||
|
|
225ca1de00 | ||
|
|
aeb500e804 | ||
|
|
e9dd6f1efc | ||
|
|
563dbbf7e4 | ||
|
|
5a5bc7da0b | ||
|
|
fb2c51a49b | ||
|
|
568e3b7840 | ||
|
|
87d69d7098 | ||
|
|
255cd93bf4 | ||
|
|
ef5780996e | ||
|
|
5155ae8d2b | ||
|
|
f1447ffcbc | ||
|
|
64e9ec5044 | ||
|
|
05986f6d64 | ||
|
|
caca69525a | ||
|
|
845398846c | ||
|
|
412ca6ccd7 | ||
|
|
9232fd5a91 | ||
|
|
49174d181e | ||
|
|
c5bc09fde7 | ||
|
|
1a436906f5 | ||
|
|
d7bb55c003 | ||
|
|
50f015a713 | ||
|
|
1c94508d61 | ||
|
|
ddb007de7b | ||
|
|
8bee7d5d6b | ||
|
|
253eea9249 | ||
|
|
502fdc1e32 | ||
|
|
f3aaaede25 | ||
|
|
309d691938 | ||
|
|
4d6438c3e7 | ||
|
|
19817b213b | ||
|
|
20d4457483 | ||
|
|
a2d0f2b1a3 | ||
|
|
a512766bfb | ||
|
|
b11b42e2b6 | ||
|
|
c13c2022ca | ||
|
|
bf1c187969 | ||
|
|
16d077c87d | ||
|
|
00374effc5 | ||
|
|
891a855fb8 | ||
|
|
854cb56621 | ||
|
|
1018a11548 | ||
|
|
dc55f2170f | ||
|
|
36cd5cd504 | ||
|
|
a5d23696e6 | ||
|
|
5adc753f81 | ||
|
|
5e494b7163 |
+16
-1
@@ -1 +1,16 @@
|
||||
1
|
||||
6
|
||||
|
||||
2.6.2
|
||||
2.12.2
|
||||
5.2.2
|
||||
5.2.3
|
||||
5.4.2
|
||||
5.4.3
|
||||
5.4.4
|
||||
5.5.2
|
||||
5.6.2
|
||||
5.6.3
|
||||
5.9.2
|
||||
|
||||
6.0.2
|
||||
6.0.3
|
||||
@@ -1 +0,0 @@
|
||||
module.exports = require('./babel.config.js');
|
||||
@@ -1,21 +0,0 @@
|
||||
version: 2
|
||||
jobs:
|
||||
build:
|
||||
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
|
||||
+2
-1
@@ -1,4 +1,5 @@
|
||||
exclude_patterns:
|
||||
- "**/*.spec.js"
|
||||
- "**/*.spec.ts"
|
||||
- "docs/**/*.js"
|
||||
- "packages/networks/src/index.ts"
|
||||
- "packages/util/src/is/utf8.ts"
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
**/build/*
|
||||
**/coverage/*
|
||||
**/node_modules/*
|
||||
+19
-2
@@ -1,11 +1,28 @@
|
||||
const base = require('@polkadot/dev/config/eslint');
|
||||
// Copyright 2017-2021 @polkadot/util authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
const base = require('@polkadot/dev/config/eslint.cjs');
|
||||
|
||||
module.exports = {
|
||||
...base,
|
||||
ignorePatterns: [
|
||||
'.eslintrc.js',
|
||||
'.github/**',
|
||||
'.vscode/**',
|
||||
'.yarn/**',
|
||||
'**/build/*',
|
||||
'**/coverage/*',
|
||||
'**/node_modules/*'
|
||||
],
|
||||
parserOptions: {
|
||||
...base.parserOptions,
|
||||
project: [
|
||||
'./tsconfig.eslint.json'
|
||||
'./tsconfig.json'
|
||||
]
|
||||
},
|
||||
rules: {
|
||||
...base.rules,
|
||||
// this seems very broken atm, false positives
|
||||
'@typescript-eslint/unbound-method': 'off'
|
||||
}
|
||||
};
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
---
|
||||
title: SS58 registry is outdated
|
||||
labels: ['ci', '@networks']
|
||||
---
|
||||
|
||||
cc @polkadot-js/notifications
|
||||
|
||||
Discrepancies detected between https://github.com/paritytech/substrate/blob/master/ss58-registry.json and https://github.com/polkadot-js/common/blob/master/packages/networks/src/index.ts
|
||||
|
||||
Check the nightly cron output or run `yarn networks:crosscheck` locally. The output as found from the test includes:
|
||||
@@ -0,0 +1,18 @@
|
||||
name: PR
|
||||
on: [pull_request]
|
||||
|
||||
jobs:
|
||||
pr:
|
||||
strategy:
|
||||
matrix:
|
||||
step: ['lint', 'test', 'build']
|
||||
name: ${{ matrix.step }}
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: ${{ matrix.step }}
|
||||
env:
|
||||
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
|
||||
run: |
|
||||
yarn install --immutable | grep -v 'YN0013'
|
||||
yarn ${{ matrix.step }}
|
||||
@@ -0,0 +1,34 @@
|
||||
name: Master
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
|
||||
jobs:
|
||||
master:
|
||||
strategy:
|
||||
matrix:
|
||||
step: ['build:release']
|
||||
name: ${{ matrix.step }}
|
||||
if: "! startsWith(github.event.head_commit.message, '[CI Skip]') && github.repository == 'polkadot-js/common'"
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
token: ${{ secrets.GH_PAT }}
|
||||
- name: ${{ matrix.step }}
|
||||
env:
|
||||
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
|
||||
GH_PAT: ${{ secrets.GH_PAT }}
|
||||
GH_RELEASE_GITHUB_API_TOKEN: ${{ secrets.GH_PAT }}
|
||||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||
run: |
|
||||
yarn install --immutable | grep -v 'YN0013'
|
||||
yarn ${{ matrix.step }}
|
||||
|
||||
dummy:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: dummy
|
||||
run: |
|
||||
echo "Dummy skip step"
|
||||
@@ -0,0 +1,25 @@
|
||||
name: SS58
|
||||
on:
|
||||
schedule:
|
||||
- cron: '15 4/6 * * *'
|
||||
|
||||
jobs:
|
||||
ss58:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: check
|
||||
env:
|
||||
CI_LOG: 123
|
||||
run: |
|
||||
yarn install --immutable | grep -v 'YN0013'
|
||||
yarn networks:crosscheck
|
||||
|
||||
- name: issue
|
||||
if: ${{ failure() }}
|
||||
uses: JasonEtco/create-an-issue@v2
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GH_PAT_BOT }}
|
||||
with:
|
||||
filename: .github/ss58-check.md
|
||||
update_existing: true
|
||||
@@ -12,6 +12,10 @@ tmp/
|
||||
.env.test.local
|
||||
.env.production.local
|
||||
.npmrc
|
||||
.yarn/*
|
||||
!.yarn/releases
|
||||
!.yarn/plugins
|
||||
.pnp.*
|
||||
cc-test-reporter
|
||||
lerna-debug.log*
|
||||
npm-debug.log*
|
||||
@@ -20,3 +24,5 @@ yarn-debug.log*
|
||||
yarn-error.log*
|
||||
store.db
|
||||
store.db.compacted
|
||||
.idea
|
||||
.vscode
|
||||
|
||||
-28
@@ -1,28 +0,0 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- "10"
|
||||
env:
|
||||
global:
|
||||
- CC_TEST_REPORTER_ID=27a299582eb7fd9580e27897a6ecda1c82a1cd24bcfe2f2ebda1ca70238509b4
|
||||
- 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
|
||||
File diff suppressed because one or more lines are too long
+77
File diff suppressed because one or more lines are too long
+55
File diff suppressed because one or more lines are too long
+13
@@ -0,0 +1,13 @@
|
||||
enableImmutableInstalls: false
|
||||
|
||||
enableProgressBars: false
|
||||
|
||||
nodeLinker: node-modules
|
||||
|
||||
plugins:
|
||||
- path: .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs
|
||||
spec: "@yarnpkg/plugin-interactive-tools"
|
||||
- path: .yarn/plugins/@yarnpkg/plugin-version.cjs
|
||||
spec: "@yarnpkg/plugin-version"
|
||||
|
||||
yarnPath: .yarn/releases/yarn-2.4.1.cjs
|
||||
+710
-19
@@ -1,18 +1,599 @@
|
||||
# 1.2.1
|
||||
# CHANGELOG
|
||||
|
||||
## 6.0.3 Mar 5, 2021
|
||||
|
||||
Changes:
|
||||
|
||||
- Add import indirection for both CJS & ESM (where generated source file is commonjs)
|
||||
|
||||
|
||||
## 6.0.2 Mar 5, 2021
|
||||
|
||||
Changes:
|
||||
|
||||
- Fix `@polkadot/x-rxjs` ESM exports for Node environments (now different due to the ESM conversion)
|
||||
|
||||
|
||||
## 6.0.1 Mar 5, 2021
|
||||
|
||||
**Important** In the 6.0 version the default package type has been changed to ESM modules by default. This should not affect usage, however since the output formats changed, a new major version is required.
|
||||
|
||||
Contributed:
|
||||
|
||||
- Add dev addresses for Frontier-based chains (Thanks to https://github.com/joelamouche)
|
||||
|
||||
Changes:
|
||||
|
||||
- Build to ESM by default (with cjs versions via export map)
|
||||
- Allow addition or raw pairs on the keyring via `{add, create}FromPair`
|
||||
- Extract re-usable json encryption/decryption functions
|
||||
|
||||
|
||||
## 5.9.2 Feb 28, 2021
|
||||
|
||||
Changes:
|
||||
|
||||
- Fix package detection for `@polkadot/networks` (no dependencies)
|
||||
|
||||
|
||||
## 5.9.1 Feb 28, 2021
|
||||
|
||||
Changes:
|
||||
|
||||
- Expand `detectPackage` with optional param allowing checks for monorepo versions
|
||||
- Export logger `format` function directly as `loggerFormat`
|
||||
- Expand tests and checks for `hdValidatePath`
|
||||
- Remove `hdEthereum` class-based approach, simplify
|
||||
- Cleanup formatting on nested conditionals in the `@polkadot/x-` packages
|
||||
- All packages now export `packageInfo` from the root
|
||||
|
||||
|
||||
## 5.8.1 Feb 26, 2021
|
||||
|
||||
Contributed:
|
||||
|
||||
- Add ss58 information for HydraDX (Thanks to https://github.com/jak-pan)
|
||||
- HD derivation for Ethereum (Thanks to https://github.com/joelamouche)
|
||||
|
||||
Changes:
|
||||
|
||||
- Adjust base64 encoding/decoding to not rely on Buffer being available
|
||||
- Rework Ethereum derivation to only use Uint8Array internally
|
||||
- Shared HD path validation for Ledger & Ethereum
|
||||
- Additional derivation, encoding and decoding tests on keyring
|
||||
- Align networks with upstream ss58 registry
|
||||
- `@polkadot/wasm-crypto` 3.2.4
|
||||
|
||||
|
||||
## 5.7.1 Feb 21, 2021
|
||||
|
||||
**Breaking change** The signature of `pair.verify` now requires the signer public key as a parameter. If using `pair.verify` pass the publicKey (hex or Uint8Array) of the signer.
|
||||
|
||||
Changes:
|
||||
|
||||
- The signature on the keyring for `.verify` now explicitly requires the `publicKey` of the signer. Previously it only verified against an own public key.
|
||||
- Add additional ss58 test vectors (against chains with >63 prefixes in the Substrate registry)
|
||||
|
||||
|
||||
## 5.6.3 Feb 16, 2021
|
||||
|
||||
Contributed:
|
||||
|
||||
- Add ss58 information for Aventus (Thanks to https://github.com/nahuseyoum)
|
||||
|
||||
Changes:
|
||||
|
||||
- Add `unlock(password)` to keypair (less confusing than only having `decodePkcs8`, equivalent to `lock()`)
|
||||
- Change use of `detectPackage` to use `packageInfo.ts`
|
||||
- Align with upstream ss58 registry
|
||||
- `@polkadot/wasm-crypto` 3.2.3
|
||||
|
||||
|
||||
## 5.6.2 Feb 8, 2021
|
||||
|
||||
Changes:
|
||||
|
||||
- `@polkadot/networks` now filters the new upstream-introduced `null` networks
|
||||
|
||||
|
||||
## 5.6.1 Feb 7, 2021
|
||||
|
||||
Contributed:
|
||||
|
||||
- Fix installation instructions in `@polkadot/x-global` (Thanks to https://github.com/raoulmillais)
|
||||
|
||||
Changes:
|
||||
|
||||
- Conform to new ss58 encoding with ids up to 16,383 (>= 64 as 2 bytes)
|
||||
- Use JS sqrt inside `bnSqrt` when value <= MAX_SAFE_INTEGER
|
||||
- Adjust all `Buffer.from` usages, prefer `Uint8Array` where possible
|
||||
- Expand tests for keyring with `vrf{Sign, Verify}`
|
||||
- Align `@polkadot/networks` with latest ss58 registry
|
||||
|
||||
|
||||
## 5.5.2 Feb 2, 2021
|
||||
|
||||
Changes:
|
||||
|
||||
- Expose `BN_{MILLION, BILLION}` constants (in addition to 2-9)
|
||||
|
||||
|
||||
## 5.5.1 Jan 31, 2021
|
||||
|
||||
Changes:
|
||||
|
||||
- Added `hdLedger` to util-crypto for Ledger-compatible bip32+ed25519 derivation
|
||||
- Added `hmac{Sha256, 512}` to util-crypto
|
||||
- Add `slip44` indices for Ledger into `@polkadot/networks`
|
||||
- Remove `module` entry in `package.json` (only rely on exports map)
|
||||
- Remove direct references to `global` object, use `@polkadot/x-global`
|
||||
- Update `@ledgerhq` dependencies to latest
|
||||
|
||||
|
||||
## 5.4.1 Jan 24, 2021
|
||||
|
||||
Contributed:
|
||||
|
||||
- Adjust Ledger app lookup for Polymesh (Thanks to https://github.com/adamdossa)
|
||||
|
||||
Changes:
|
||||
|
||||
- Allow decimals as `number[]` & symbol as `string[]` in balanceFormat defaults
|
||||
- Add `schnorrkelVrf{Sign, Verify}` to `@polkadot/util-crypto`
|
||||
- Export `vrf{Sign, Verify}` on keyring interface
|
||||
- Move `@polkadot/x-rxjs` packages from the api repo
|
||||
- Align `@polkadot/networks` with Substrate master
|
||||
- Explicit edcsa tests for derivation
|
||||
- `@polkadot/wasm-crypto` 3.2.1
|
||||
|
||||
|
||||
## 5.3.1 Jan 17, 2021
|
||||
|
||||
**Important** For users of the `@polkadot/ledger` package, it is now included in this repo (since it is a general utility) and renamed to `@polkadot/hw-ledger`
|
||||
|
||||
Contributed:
|
||||
|
||||
- Add Dock Ledger integration (Thanks to https://github.com/lovesh)
|
||||
- Add Polymesh Ledger integration (Thanks to https://github.com/adamdossa)
|
||||
- Add flag for Ledger capabilities on networks (Thanks to https://github.com/Tbaut)
|
||||
|
||||
Changes:
|
||||
|
||||
- Move `@polkadot/ledger` packages into common
|
||||
- Update `@polkadot/networks` to align with latest Substrate ss58-registry
|
||||
|
||||
|
||||
## 5.2.1 Dec 27, 2020
|
||||
|
||||
Changes:
|
||||
|
||||
- Add `arrayFlatten` to merge a series of arrays into a single
|
||||
- Add `arrayChunk` to chunk an array into multiples of defined size
|
||||
- Add `bitLength` param (allowed 256, 512) to `keccakAs{Hex, U8a}`
|
||||
- Align `@polkadot/networks` with Substrate master
|
||||
|
||||
|
||||
## 5.1.1 Dec 19, 2020
|
||||
|
||||
Changes:
|
||||
|
||||
- `detectPackage` now can take a path-retrieval callback as second argument
|
||||
- Adjust `blake2js` imports to consistently cater for esm & cjs usage
|
||||
- Explicitly mark `detectPackage` usage as having side-effects
|
||||
- Align `@polkadot/networks` with Substrate master
|
||||
- `@polkadot/wasm-crypto` 3.1.1
|
||||
|
||||
|
||||
## 5.0.1 Dec 13, 2020
|
||||
|
||||
**Important** While this package contains no external interface changes, it now compiles and ships both cjs and esm modules. This means that modern bundlers will have more information for tree-shaking available. Additionally when using Node with `.mjs` extensions, the esm version imports will be used on recent Node versions. Adding an export map, as here, may have some impacts so a major semver bump is advised. There may be (small) dragons hiding in the dark corners...
|
||||
|
||||
Changes:
|
||||
|
||||
- Build and expose both cjs and esm via exports map
|
||||
- Use `import type { ... }` form for all type imports
|
||||
- Align with Substrate master network list
|
||||
- Debug logs now don't depend on `NODE_ENV`, but rather `DEBUG=<type,type,...>` (`*` logs all)
|
||||
- Limit debug console output via `DEBUG_MAX=<number>` value, trimming when passed
|
||||
- Add `memoize` util, allowing for function memoization (as used in the API)
|
||||
- Align `@polkadot/networks` with Substrate master
|
||||
- `@polkadot/wasm-crypto` 3.0.1
|
||||
|
||||
|
||||
## 4.2.1 Nov 23, 2020
|
||||
|
||||
Changes:
|
||||
|
||||
- Rename default Mega to Million, Giga to Billion and Tera to Trillion in formatter
|
||||
- Dedupe bn.js by aligning versions between different libraries
|
||||
- Add explicit link to base Substrate ss58 formats (as managed in `@polkadot/util`)
|
||||
|
||||
|
||||
## 4.1.1 Nov 16, 2020
|
||||
|
||||
Contributed:
|
||||
|
||||
- Expand ETH tests, allow for verification against address (Thanks to https://github.com/joelamouche)
|
||||
|
||||
Changes:
|
||||
|
||||
- Replace pbkdf2 imports with explicit use from sync-only package
|
||||
- Adjust secp256k1 imports with shared elliptic
|
||||
- Expand crypto tests for explicit wasm vs JS compares in all cases
|
||||
|
||||
|
||||
## 4.0.1 Nov 8, 2020
|
||||
|
||||
- **Breaking change** Polyfills are not injected by these libraries anymore to avoid clobbering external globals, the user should provide them if their environment is missing base functionality.
|
||||
|
||||
Changes:
|
||||
|
||||
- Remove built-in utility polyfills for `Array.fill`, `String.padStart`, `String.padEnd` as well as `Object.setPrototypeOf`. These should be provided by the actual user of the libraries if so required.
|
||||
- Update `@polkadot/wasm-crypto` library (under-the-hood cleanups)
|
||||
- Remove explicit crypto polyfill injection (aligning with updated `@polkadot/wasm-crypto`)
|
||||
- Add cross-environment `@polkadot/x-randomvalues` (for use in `@polkadot/wasm-crypto`)
|
||||
|
||||
|
||||
## 3.7.1 Nov 1, 2020
|
||||
|
||||
Changes:
|
||||
|
||||
- Remove the use of `chalk` (logger) for less overall dependencies
|
||||
- `string*` utilities now also allows `String` (class) inputs
|
||||
- Align bip39 use with wasm-crypto for English-only wordlist, default, non supplied)
|
||||
- Adjust elliptic imports for explicit paths (allows tree-shaking)
|
||||
- Add Totem (ss58 prefix 14) into `@polkadot/networks`
|
||||
- Move `@polkadot/x-{fetch,textdecoder,textencoder,ws}` into `common` repo
|
||||
|
||||
|
||||
## 3.6.1 Oct 18, 2020
|
||||
|
||||
Contributed:
|
||||
|
||||
- Add evmToAddress and addressToEvm `@polkadot/util-crypto` (Thanks to https://github.com/jnaviask)
|
||||
- Remove invalid link to docs (thanks to https://github.com/roccomuso)
|
||||
|
||||
Changes:
|
||||
|
||||
- Rename `mnemonicToBip39` to `mnemonicToLegacySeed` (used in non-Substrate compatible fashion)
|
||||
- Update pair signature verification to handle MultiSignature results
|
||||
- Move documentation to docs repo
|
||||
- Added `@polkadot/networks` for a list of known networks and their identifying information
|
||||
|
||||
|
||||
## 3.5.1 Sep 27, 2020
|
||||
|
||||
Contributed:
|
||||
|
||||
- Add Dock network identifiers (Thanks to https://github.com/lovesh)
|
||||
|
||||
Changes:
|
||||
|
||||
- Use cross-environment TextDecoder & TextEncoder from the polkadot-js polyfills
|
||||
- Add `isBase{32, 58, 64}` to `@polkadot/util-crypto`
|
||||
- Add `base64{Pad, Trim}` to add/remove padding characters
|
||||
- Add `createFromJson(json)` to keyring (create pair without adding)
|
||||
- Balance formatter now outputs 4 numbers after the decimal point
|
||||
|
||||
|
||||
## 3.4.1 Aug 31, 2020
|
||||
|
||||
Changes:
|
||||
|
||||
- Allow for WASM-as-available `mnemonicToBip39` call (used for Ethereum-compatible keypairs)
|
||||
- Add `isWasm` utility to check for valid WASM headers
|
||||
- `@polkadot/wasm-crypto` 1.4.1
|
||||
|
||||
|
||||
## 3.3.1 Aug 24, 2020
|
||||
|
||||
Changes:
|
||||
|
||||
- Add `addressRaw` to Keyring interface (if address encoding is different to publicKey)
|
||||
- Allow for Ethereum pair signing and verification
|
||||
|
||||
|
||||
## 3.2.1 Aug 17, 2020
|
||||
|
||||
Changes:
|
||||
|
||||
- Allow for (optional, default blake2) hasher to secp256k1 sign/verify functions
|
||||
- Utilities for secp256k1 publicKey expansion and compression
|
||||
- Add basic Ethereum address utils (encode with checksum & checksum verification)
|
||||
- Add Ethereum-compatible `mnemonicToBip39` seed creation function
|
||||
|
||||
|
||||
## 3.1.1 Aug 10, 2020
|
||||
|
||||
Changes:
|
||||
|
||||
- Add `deriveAddress(<address>, '/<soft>/<soft-b>')` via sr25519 soft
|
||||
- Use `scrypt` from WASM as available (JS fallback in place)
|
||||
- Add `base32{Encode, Decode}` utilities (IPFS-compatible alphabet)
|
||||
- Support IPFS compatibility flag in base58 encoding/decoding
|
||||
- Update to `@polkadot/wasm-crypto` 1.3.1
|
||||
|
||||
|
||||
## 3.0.1 Jul 27, 2020
|
||||
|
||||
Contributed:
|
||||
|
||||
- Add Katal ss58Format (Thanks to https://github.com/retotrinkler)
|
||||
|
||||
Changes:
|
||||
|
||||
- Adjust JSON pair output with scrypt kdf (version 3 output)
|
||||
|
||||
|
||||
## 2.18.1 Jul 13, 2020
|
||||
|
||||
Changes:
|
||||
|
||||
- Add `base64{Decode, Encode, Validate}` as crypto utils
|
||||
- Extract `base58Validate` from base58 decode checks
|
||||
- Add `isAscii` to allow detection of printable ASCII sequences (including tab, newline)
|
||||
- Add `isUtf8` to allow detection of valid Utf8 sequences
|
||||
|
||||
|
||||
## 2.17.1 Jul 6, 2020
|
||||
|
||||
Changes:
|
||||
|
||||
- Add `encode{Derived, Multi}Address` to encode derived/multi addresses
|
||||
- Correctly handle 0 inputs in `numberToU8a`
|
||||
- Simplify and flatten base58 dependencies
|
||||
|
||||
|
||||
## 2.16.1 Jun 29, 2020
|
||||
|
||||
Changes:
|
||||
|
||||
- Adjust `addressCheck` and `encodeAddress` function to check for valid base58 alphabets (better error reporting)
|
||||
- Rename `createKeySub` to `createKeyDerived` based on changed in Substrate (sub keys now named derived)
|
||||
|
||||
|
||||
## 2.15.1 Jun 22, 2020
|
||||
|
||||
Changes:
|
||||
|
||||
- Adjust keyring to no override 0-prefix (Polkadot live) settings with keychain default
|
||||
|
||||
|
||||
## 2.14.1 Jun 16, 2020
|
||||
|
||||
Contributed:
|
||||
|
||||
- Add `extractTime` utility conversion (Thanks to https://github.com/kwingram25)
|
||||
|
||||
|
||||
## 2.13.1 Jun 8, 2020
|
||||
|
||||
Changes:
|
||||
|
||||
- Fix JS blake2 fallback (non-wasm) to correctly deal with hex inputs
|
||||
- Align `bnToHex` signature with `bnToU8a` (with old/new style)
|
||||
- Allow `bnTo{Hex,U8a}` to take any value with `.toBn()` signatures
|
||||
|
||||
|
||||
## 2.12.2 Jun 1, 2020
|
||||
|
||||
Changes:
|
||||
|
||||
- Fix `isFunction` signature to assert `Function`
|
||||
|
||||
|
||||
## 2.12.1 Jun 1, 2020
|
||||
|
||||
- **Important** Removed `mnemonicToSeed`, it is only for bip39, use `mnemonicToMiniSecret` for the Substrate variant
|
||||
|
||||
Changes:
|
||||
|
||||
- Added `u8aEq` to compare two Uint8Array or hex values for an exact match
|
||||
- Added `addressEq` to compare two addresses (ss58, Uint8array or hex) for an exact match
|
||||
- Throw error on `{nacl,schnorrkel}Verify` on invalid input lengths
|
||||
- Performance optimizations in `u8aToHex` & `u8aConcat`
|
||||
|
||||
|
||||
## 2.11.1 May 26, 2020
|
||||
|
||||
Changes:
|
||||
|
||||
- Internal cleanups on typings
|
||||
- Support for latest TypeScript, eslint & typescript-eslint
|
||||
|
||||
|
||||
## 2.10.1 May 14, 2020
|
||||
|
||||
Contributed:
|
||||
|
||||
- Add Kulupu ss58 prefix as an allowed value (Thanks to https://github.com/sorpaas)
|
||||
|
||||
Changes:
|
||||
|
||||
- Make the `TextEncoder` polyfill handle non-compliant Buffer implementations (newer versions of Jest)
|
||||
- `DeriveJunction` now also allows for BigInt values (aligning with number types elsewhere)
|
||||
- Small code-flow optimizations
|
||||
|
||||
|
||||
## 2.9.1 Apr 30, 2020
|
||||
|
||||
Contributed:
|
||||
|
||||
- Add support for ECDSA keypairs (Thanks to https://github.com/akru)
|
||||
|
||||
Changes:
|
||||
|
||||
- Added `createKeyMulti` & `createKeySub` to create utility sub & multi keys
|
||||
- Added `u8aSorted` to sort `Uint8Arrays`
|
||||
- Added `sortAddresses` to sort addresses based on their internal representation
|
||||
|
||||
|
||||
## 2.8.1 Apr 9, 2020
|
||||
|
||||
- Keypair will now throw an error when attempting to sign/derive using a locked pair (Thanks to https://github.com/h4x3rotab)
|
||||
|
||||
Changes:
|
||||
|
||||
- Cleanup `isDevelopment` regex to cater for chains such as `Westend Development`
|
||||
|
||||
|
||||
## 2.7.1 Mar 31, 2020
|
||||
|
||||
Changes:
|
||||
|
||||
- Add `bnSqrt` to calculate the integer sqrt via Newton iteration
|
||||
- Allow for optional wasm-crypto, specifically via `@polkadot/util-crypto/noWasm`
|
||||
- Misc. CI infrastructure cleanups
|
||||
|
||||
|
||||
## 2.6.1 Feb 29, 2020
|
||||
|
||||
- **Breaking change** Following on the 2.0 release, `@polkadot/wasm` was updated to 1.1+. sr25510 now only verifies 0.8+ signatures, closing the loop on dropping Substrate 1.x-era support
|
||||
|
||||
Changes:
|
||||
|
||||
- Add `signatureVerify (message: Uint8Array | string, signature: Uint8Array | string, addressOrPublicKey: Uint8Array | string): VerifyResult` to verify any signature, regardless of type. Returns validity & detected crypto type.
|
||||
- Add `cryptoIsReady (): boolean` function to check status of initialization
|
||||
- Add `addressCheckChecksum (decoded: Uint8Array)` as an helper to extract and verify the ss58 checksum
|
||||
- Swap to yarn 2, allow use in yarn 2 projects
|
||||
|
||||
|
||||
## 2.5.1 Feb 22, 2020
|
||||
|
||||
- **Breaking change** (TypeScript only) The `*.d.ts` files now contain TypeScript 3.8 features, `#private`, which is not usable in older versions
|
||||
|
||||
Changes:
|
||||
|
||||
- Add `isBigInt(value)` to allow `BigInt` checks. Also add support in `bnToBn` as well as number conversion utils
|
||||
- Add `isChildClass(Parent, Child?)` to check if a class extends the parent, asserting Child is Parent
|
||||
- (internal) Use `#<field>` instead of `private _<field>` for private class variables
|
||||
|
||||
|
||||
## 2.4.1 Feb 18, 2020
|
||||
|
||||
Changes:
|
||||
|
||||
- Ensure that `formatBalance` does not apply unit overrides apply when no SI is applicable
|
||||
- Adjust `formatBalance(<balance>, <options>)` to take expanded `withUnit: string | boolean` option where string is an actual unit, e.g. `KSM`
|
||||
- The `decimals` option to `formatBalance` should now be passed as part of the `options` (previous last-param deprecated)
|
||||
- The `.setSS58Format` on keyring will now just operate on pairs created on the keyring, not globally. The global `setSS58Format` in `@polkadot/util-crypto` will be deprecated.
|
||||
- The deprecated `addressPrefix` option to keyring has been belatedly removed (Use `ss58Format` rather)
|
||||
|
||||
|
||||
## 2.3.1 Feb 15, 2020
|
||||
|
||||
Contributed:
|
||||
|
||||
- Remove dependency on moment.js with `formatDate` function (Thanks to https://github.com/AndreasGassmann)
|
||||
- Move TypeScript `@types/*` to dev deps (Thanks to https://github.com/AndreasGassmann)
|
||||
|
||||
Changes:
|
||||
|
||||
- Update to `@polkadot/wasm-crypto` 1.0
|
||||
- Cleanup dependencies to pave the way for using yarn 2 (Explicit instead of implicit)
|
||||
|
||||
|
||||
## 2.2.1 Feb 06, 2020
|
||||
|
||||
Changes:
|
||||
|
||||
- Add resolver for jest requires (tests from src)
|
||||
|
||||
|
||||
## 2.1.1 Feb 04, 2020
|
||||
|
||||
Changes:
|
||||
|
||||
- Update `detectPackage(<package.json>, __dirname?)` with calling folder
|
||||
|
||||
|
||||
## 2.0.1 Jan 30, 2020
|
||||
|
||||
Changes:
|
||||
|
||||
- Update w3f/schnorrkel to 0.8.5 (Full Substrate 2.x support, no 1.x support)
|
||||
- Remove Alice session (ed2551) account from testing keyring (not applicable to Substrate 2.x)
|
||||
- Remove `chainspec`, `db`, `trie-codec`, `trie-db` and `trie-hash` packages (moved to client)
|
||||
- Renamed `assertSingletonPackage` to `detectPackage` with inclusion of version listing
|
||||
- Swap to elliptic library for secp2561 recovery (No node bindings)
|
||||
|
||||
|
||||
## 1.8.1 Jan 09, 2020
|
||||
|
||||
Contributed:
|
||||
|
||||
- Add cross-client encryption/decryption support (Thanks to https://github.com/hskang9)
|
||||
|
||||
|
||||
## 1.7.1 Nov 27, 2019
|
||||
|
||||
Changes:
|
||||
|
||||
- `formatBalance` signature now allows to force unit displays
|
||||
- Keypair now allows for derive on a pair, with `pair.derive(...)`
|
||||
- `assert` now acts like a real asserts, with no return - signature adapted for new TS 3.7
|
||||
|
||||
|
||||
## 1.6.1 Oct 24, 2019
|
||||
|
||||
Changes:
|
||||
|
||||
- `pair.sign(message)` now takes an optional second `options?: SignOptions` parameter, where `SignOptions` is currently defined as `{ withType: boolean }`. Here `withType` instructs the signing to prepend the type of signature (ed2551, sr25519 or ecdsa). This is used for the new Polkadot/Substrate MultiSignature format.
|
||||
|
||||
|
||||
## 1.5.1 Sep 25, 2019
|
||||
|
||||
Changes:
|
||||
|
||||
- Fix typings on the Keyring-exposed encode & decodeAddress
|
||||
- Allow ss58Format = 0 as a valid value
|
||||
- Loosen type definitions for allowed ss58format values (still checked against allowed array)
|
||||
|
||||
|
||||
## 1.4.1 Sep 12, 2019
|
||||
|
||||
- **Breaking change** To set the `ss58Format`, you should now use `setSS58Format` as opposed to the old `setAddressPrefix`
|
||||
|
||||
Changes:
|
||||
|
||||
- Renamed `keyring.setAddressPrefix` to `keyring.setSS58Format`
|
||||
- Deprecated `addressPrefix` on the keyring options, added the `ss58Format` as a replacement (aligning with chain properties - the old version is still accepted)
|
||||
- Added `stringToHex` and `hexToString` conversion utilities to `@polkadot/util`
|
||||
- Swap to [Babel 7.6.0](https://babeljs.io/) for all compilation, for latest improvements in code generation
|
||||
|
||||
|
||||
## 1.3.1 Sep 10, 2019
|
||||
|
||||
Changes:
|
||||
|
||||
- Remove the `ExtError` class, always prefer the standard JS `Error` object for errors. This would bre a breaking change for any applications using `ExtError`
|
||||
|
||||
|
||||
## 1.2.1 Sep 09, 2019
|
||||
|
||||
Changes:
|
||||
|
||||
- Keyring `addFromAddress` can now be used to store external accounts, for example those provided by external signers
|
||||
- Maintainability updates
|
||||
|
||||
# 1.1.1
|
||||
|
||||
## 1.1.1 Aug 09, 2019
|
||||
|
||||
Changes:
|
||||
|
||||
- `assertSingletonPackage` now warns via console.warn, but does not throw. This does allow the info to come accross while still allowing the app developers using multiple libraries time to fix.
|
||||
|
||||
# 1.0.1
|
||||
|
||||
## 1.0.1 Aug 02, 2019
|
||||
|
||||
Changes:
|
||||
|
||||
- `formatBalance` now allows for `Compact` inputs
|
||||
- `formaBalance` now allows correct formatting of very large decimals
|
||||
|
||||
# 0.94.1
|
||||
|
||||
## 0.94.1 Jul 20, 2019
|
||||
Changes:
|
||||
|
||||
- Add `checkAddress(address, prefix)` to `@polkadot/util-crypto` that validates an ss-58 address
|
||||
- Add support for the Kusama network (as a valid checked prefix)
|
||||
@@ -20,7 +601,10 @@
|
||||
- The ed25519 key for Alice (representing the session), now appears in the test keyrings
|
||||
- Fix missing dependencies for keyring (after address moves in 0.93.1)
|
||||
|
||||
# 0.93.1
|
||||
|
||||
## 0.93.1 Jun 14, 2019
|
||||
|
||||
Changes:
|
||||
|
||||
- Breaking: External pair interface for keyring has been changed. Instead of
|
||||
- `getMeta` use the `meta` getter, i.e. `console.log(pair.meta.name)`
|
||||
@@ -28,69 +612,176 @@
|
||||
- `publicKey` use the `publicKey` getter, i.e. `console.log(pair.publicKey)`
|
||||
- `Move decodeAddress`, `encodeAddress` & `setAddressPrefix` functions into `@polkadot/util-crypto` from `@polkadot/keyring`. External interfaces should not be affected at this point since it is also (still) exported and exposed on keyring
|
||||
|
||||
# 0.92.1
|
||||
|
||||
## 0.92.1 Jun 04, 2019
|
||||
|
||||
Changes:
|
||||
|
||||
- Only allow integer input values into `formatBalance`
|
||||
- Allow `formatBalance`, `formatDecimal` & `formatNumber` to cater for negative numbers
|
||||
- Add 'Bob//stash' to testing keyring, joining the existing 'Alice//stash'
|
||||
|
||||
# 0.91.1
|
||||
|
||||
## 0.91.1 May 22, 2019
|
||||
|
||||
Changes:
|
||||
|
||||
- ed25519/sr25519 sign & verify functions can now take the message input as Uint8Array/string/hex and verify allows for the signature/publicKey to be specified as Uint8Array/hex
|
||||
- Update `@polkadot/wasm` to include a maintenance bump for the `w3f/schnorrkel` libraries
|
||||
|
||||
# 0.90.1
|
||||
|
||||
## 0.90.1 May 08, 2019
|
||||
|
||||
Changes:
|
||||
|
||||
- Moving towards 1.0
|
||||
- Added bnMin & bnMax functions
|
||||
|
||||
# 0.76.1
|
||||
|
||||
## 0.76.1 Apr 03, 2019
|
||||
|
||||
Changes:
|
||||
|
||||
- Fix `addFromMnemonic` to generate using new-style derivation.
|
||||
- Pull in `formatBalance`, `formatDecimal`, `formatElapsed`, `formatNumber`, `calcSi`, `findSi` & `isTestChain` utility functions from the originals in `@polkadot/ui-util`
|
||||
- Swap out `wasm-schnorrkel` & `wasm-ed25519` for combined version with `wasm-crypto`
|
||||
- Swap DB interfaces to optional LRU, removing `transactionAsync` (client-only changes)
|
||||
|
||||
# 0.75.1
|
||||
|
||||
## 0.75.1 Mar 29, 2019
|
||||
|
||||
Changes:
|
||||
|
||||
- Start journey to 1.0
|
||||
|
||||
# 0.42.1
|
||||
|
||||
## 0.42.1 Mar 28, 2019
|
||||
|
||||
Changes:
|
||||
|
||||
- Add `assertSingletonPackage` to util
|
||||
- Ensure that only a single keyring instance is loaded (uses above)
|
||||
|
||||
# 0.41.1
|
||||
|
||||
## 0.41.1 Mar 25, 2019
|
||||
|
||||
Changes:
|
||||
|
||||
- Extensions to the client-specific database interfaces (non-breaking for API and util users)
|
||||
|
||||
# 0.40.1
|
||||
|
||||
## 0.40.1 Mar 23, 2019
|
||||
|
||||
Changes:
|
||||
|
||||
- Add additional derivation path extraction mechanisms to util-crypto
|
||||
- Add createFromUri function to keypair (creates keypair, does not add it)
|
||||
- Allow all crypto hashing & ed25519 to use WASM (as available, JS fallbacks)
|
||||
|
||||
# 0.39.1
|
||||
|
||||
## 0.39.1 Mar 20, 2019
|
||||
|
||||
Changes:
|
||||
|
||||
- Pull in bip39 generation functions from `@poladkot/wasm-crypto` with a fallback to the pure JS versions
|
||||
|
||||
# 0.38.1
|
||||
|
||||
## 0.38.1 Mar 18, 2019
|
||||
|
||||
Changes:
|
||||
|
||||
- Align with current substrate master for sr25519 keys and hard/soft derivation
|
||||
- Swap default dev keys to derived (sr25519)
|
||||
|
||||
# 0.37.1
|
||||
|
||||
## 0.37.1 Mar 14, 2019
|
||||
|
||||
Changes:
|
||||
|
||||
- Swap to publishing -beta.x on merge (non-breaking testing)
|
||||
|
||||
# 0.36.1
|
||||
|
||||
## 0.36.1 Mar 13, 2019
|
||||
|
||||
Changes:
|
||||
|
||||
- Add `fromUri` to keyring along with hard & soft key derivation.
|
||||
|
||||
# 0.35.1
|
||||
|
||||
## 0.35.1 Mar 04, 2019
|
||||
|
||||
Changes:
|
||||
|
||||
- Remove NodeJs-only `syncify` function, not exported by the package (with binary dependency for Node)
|
||||
|
||||
# 0.34.1
|
||||
|
||||
## 0.34.1 Feb 13, 2019
|
||||
|
||||
Changes:
|
||||
|
||||
- Keyring now allows for ed25519 and sr25519 instances. Upon creation, you need to pass the `ed25519`or `sr25519` string to denote the type, i.e. `new Keyring({ type: 'sr25519' })`
|
||||
|
||||
|
||||
## 0.33.1 Nov 22, 2018
|
||||
|
||||
## 0.32.1 Oct 18, 2018
|
||||
|
||||
## 0.31.1 Oct 12, 2018
|
||||
|
||||
## 0.30.1 Sep 11, 2018
|
||||
|
||||
## 0.29.1 Sep 01, 2018
|
||||
|
||||
## 0.28.1 Aug 11, 2018
|
||||
|
||||
## 0.27.1 Aug 06, 2018
|
||||
|
||||
## 0.26.1 Jun 27, 2018
|
||||
|
||||
## 0.25.1 Jun 26, 2018
|
||||
|
||||
## 0.24.1 Jun 22, 2018
|
||||
|
||||
## 0.23.1 Jun 21, 2018
|
||||
|
||||
## 0.22.1 May 24, 2018
|
||||
|
||||
## 0.21.1 May 17, 2018
|
||||
|
||||
## 0.20.1 May 16, 2018
|
||||
|
||||
## 0.19.1 Apr 19, 2018
|
||||
|
||||
## 0.18.1 Mar 20, 2018
|
||||
|
||||
## 0.17.1 Mar0 8, 2018
|
||||
|
||||
## 0.16.1 Feb 23, 2018
|
||||
|
||||
## 0.15.1 Feb 15, 2018
|
||||
|
||||
## 0.14.1 Feb 07, 2018
|
||||
|
||||
## 0.13.1 Jan 25, 2018
|
||||
|
||||
## 0.12.1 Jan 11, 2018
|
||||
|
||||
## 0.11.1 Dec 30, 2017
|
||||
|
||||
## 0.10.1 Dec 17, 2017
|
||||
|
||||
## 0.9.1 Dec 14, 2017
|
||||
|
||||
## 0.8.1 Dec 12, 2017
|
||||
|
||||
## 0.7.1 Dec 11, 2017
|
||||
|
||||
## 0.6.1 Nov 30, 2017
|
||||
|
||||
## 0.5.1 Nov 20, 2017
|
||||
|
||||
## 0.4.1 Nov 19, 2017
|
||||
|
||||
## 0.3.1 Nov 19, 2017
|
||||
|
||||
## 0.2.1 Nov 18, 2017
|
||||
|
||||
@@ -16,13 +16,6 @@ This repository is split up into a number of internal packages, namely utilities
|
||||
- [keyring](packages/keyring/) Keyring management
|
||||
- [util](packages/util/) General utilities
|
||||
- [util-crypto](packages/util-crypto/) Crypto and hashing utilities
|
||||
- [util-rlp](packages/util-rlp/) RLP encoding & decoding
|
||||
|
||||
Various useful trie and database interfaces -
|
||||
|
||||
- [db](packages/db/) Sync memory and disk database interfaces
|
||||
- [trie-db](packages/trie-db/) Merkle Patricia Tree implementation adapted for Polkadot
|
||||
- [trie-hash](packages/trie-hash/) Calculate hashes (either ordered or unordered) from a set of inputs
|
||||
|
||||
## development
|
||||
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
// Copyright 2017-2021 @polkadot/util authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
module.exports = require('@polkadot/dev/config/babel-config-cjs.cjs');
|
||||
@@ -1,3 +0,0 @@
|
||||
module.exports = {
|
||||
extends: '@polkadot/dev/config/babel'
|
||||
};
|
||||
@@ -1,17 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
function copy_folder () {
|
||||
SRC="packages/$1/build"
|
||||
DST="../apps/node_modules/@polkadot/$1"
|
||||
|
||||
echo "** Copying $SRC to $DST"
|
||||
|
||||
rm -rf $DST
|
||||
cp -r $SRC $DST
|
||||
}
|
||||
|
||||
yarn polkadot-dev-build-ts
|
||||
|
||||
copy_folder "keyring"
|
||||
copy_folder "util"
|
||||
copy_folder "util-crypto"
|
||||
@@ -0,0 +1 @@
|
||||
|
||||
|
||||
@@ -1,41 +0,0 @@
|
||||
module.exports = {
|
||||
base: '/common/',
|
||||
title: 'polkadot-js/common',
|
||||
description: 'Common utilities and libraries that are in use accross all @polkadot projects',
|
||||
markdown: {
|
||||
lineNumbers: true
|
||||
},
|
||||
themeConfig: {
|
||||
displayAllHeaders: true,
|
||||
nav: [
|
||||
{ text: 'Polkadot/Substrate Apps', link: 'https://polkadot.js.org/apps/' },
|
||||
{ text: 'Project family', link: 'https://polkadot.js.org/' },
|
||||
{
|
||||
text: 'Documentation',
|
||||
items: [
|
||||
{ text: 'API Reference', link: 'https://polkadot.js.org/api/' },
|
||||
{ text: 'Utility Reference (this)', link: 'https://polkadot.js.org/common/' },
|
||||
{ text: 'UI Libs Reference', link: 'https://polkadot.js.org/ui/' },
|
||||
]
|
||||
},
|
||||
{ text: 'GitHub', link: 'https://github.com/polkadot-js/common' }
|
||||
],
|
||||
search: false,
|
||||
sidebar: [
|
||||
{
|
||||
title: 'Examples (keyring)',
|
||||
path: '/examples/keyring/',
|
||||
collapsable: false,
|
||||
sidebarDepth: 1,
|
||||
children: [
|
||||
['/examples/keyring/01_create_account/', 'Create account'],
|
||||
['/examples/keyring/02_load_accounts/', 'Load Accounts']
|
||||
]
|
||||
},
|
||||
['/util/', '@polkadot/util'],
|
||||
['/util-crypto/', '@polkadot/util-crypto'],
|
||||
['/keyring/', '@polkadot/keyring'],
|
||||
'/CONTRIBUTING.md'
|
||||
]
|
||||
}
|
||||
};
|
||||
@@ -1,9 +0,0 @@
|
||||
$accentColor = #fd8824
|
||||
$textColor = #2c3e50
|
||||
|
||||
.home .hero .description,
|
||||
.home .feature h2,
|
||||
.home .feature p {
|
||||
color: $textColor
|
||||
opacity: 0.75
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="initial-scale=0.5, maximum-scale=1">
|
||||
<meta http-equiv="refresh" content="0;URL='https://polkadot.js.org/docs/'" />
|
||||
<title>Redirecting to https://polkadot.js.org/docs/</title>
|
||||
</head>
|
||||
<body>
|
||||
Redirecting to <a href="https://polkadot.js.org/docs/">https://polkadot.js.org/docs/</a>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,51 +0,0 @@
|
||||
---
|
||||
home: true
|
||||
heroText:
|
||||
tagline:
|
||||
# Bringing JavaScript to the Polkadot world.
|
||||
# actionText: Repository Overview
|
||||
# actionLink: /REPOS.md
|
||||
features:
|
||||
- title: Keyring
|
||||
details: Manage user keys allowing for signing, encryption and decryption.
|
||||
- title: Utilities
|
||||
details: Various user utilities to work with data and perform check on it.
|
||||
- title: Crypto
|
||||
details: A thin and easy-to-use wrapper around cryptographic and hashing libraries.
|
||||
|
||||
footer: Apache-2 Licensed | Copyright © 2017-2019 polkadot-js authors and contributors
|
||||
---
|
||||
|
||||
## Welcome
|
||||
|
||||
Various useful utility functions that are used across all projects in the [@polkadot](https://polkadot.js.org) namespace. It provides utility functions with additional safety checks, allowing not only for consistent coding, but also reducing the general boilerplate.
|
||||
|
||||
::: tip Examples
|
||||
In a rush and just want examples? [Jump right in](/examples/keyring/) and get a handle on using the various components in your projects.
|
||||
:::
|
||||
|
||||
## Available packages
|
||||
|
||||
It is split up into a number of internal packages, namely utilities -
|
||||
|
||||
- [keyring](keyring/README.md) Keyring management
|
||||
- [util](util/README.md) General utilities
|
||||
- [util-crypto](util-crypto/README.md) Crypto and hashing utilities
|
||||
|
||||
## The Polkadot Project
|
||||
|
||||
You can read more about the Polkadot Network at [https://polkadot.network/](https://polkadot.network/)
|
||||
|
||||
## Github repositories
|
||||
|
||||
You can find the Polkadot repositories at:
|
||||
|
||||
- [https://github.com/polkadot-js](https://github.com/polkadot-js)
|
||||
- [https://github.com/paritytech/polkadot](https://github.com/paritytech/polkadot)
|
||||
- [https://github.com/paritytech/substrate](https://github.com/paritytech/substrate)
|
||||
|
||||
This documentation is generated from [https://github.com/polkadot-js/common](https://github.com/polkadot-js/common)
|
||||
|
||||
## Contributing
|
||||
|
||||
Contribution to Polkadot JS Common are more than welcome. You can [report issues](https://github.com/polkadot-js/common/issues/new) and [log feature requests](https://github.com/polkadot-js/common/issues/new).
|
||||
@@ -1 +0,0 @@
|
||||
yarn.lock
|
||||
@@ -1,5 +0,0 @@
|
||||
# Create Account
|
||||
|
||||
The following example shows how to create and account with keyring.
|
||||
|
||||
<<< @/docs/examples/keyring/01_create_account/index.js
|
||||
@@ -1,21 +0,0 @@
|
||||
/* eslint-disable @typescript-eslint/require-await */
|
||||
/* eslint-disable @typescript-eslint/unbound-method */
|
||||
/* eslint-disable @typescript-eslint/no-var-requires */
|
||||
// Import Keyring class and utility function
|
||||
const Keyring = require('@polkadot/keyring').default;
|
||||
const stringToU8a = require('@polkadot/util/string/toU8a').default;
|
||||
|
||||
async function main () {
|
||||
// Create account seed for Alice
|
||||
const ALICE_SEED = 'Alice'.padEnd(32, ' ');
|
||||
|
||||
// Create an instance of the Keyring
|
||||
const keyring = new Keyring();
|
||||
|
||||
// Create pair and add Alice to keyring pair dictionary (with account seed)
|
||||
const pairAlice = keyring.addFromSeed(stringToU8a(ALICE_SEED));
|
||||
|
||||
console.log(`Created keyring pair for Alice with address: ${keyring.getPair(pairAlice.address).address}`);
|
||||
}
|
||||
|
||||
main().catch(console.error).finally(() => process.exit());
|
||||
@@ -1,19 +0,0 @@
|
||||
{
|
||||
"name": "01_create_account",
|
||||
"version": "0.1.0",
|
||||
"description": "Example showing how to create an account",
|
||||
"main": "index.js",
|
||||
"author": "ltfschoen",
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"clean": "rimraf node_modules",
|
||||
"start": "node index.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@polkadot/util": "^0.32.10",
|
||||
"@polkadot/keyring": "^0.32.10"
|
||||
},
|
||||
"devDependencies": {
|
||||
"rimraf": "^2.6.2"
|
||||
}
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
# Load Accounts
|
||||
|
||||
The following example shows how to load all accounts from the keyring as pairs and convert them into JSON format.
|
||||
|
||||
<<< @/docs/examples/keyring/02_load_accounts/index.js
|
||||
@@ -1,33 +0,0 @@
|
||||
/* eslint-disable @typescript-eslint/require-await */
|
||||
/* eslint-disable @typescript-eslint/unbound-method */
|
||||
/* eslint-disable @typescript-eslint/no-var-requires */
|
||||
// Import Keyring class and utility function
|
||||
const Keyring = require('@polkadot/keyring').default;
|
||||
const stringToU8a = require('@polkadot/util/string/toU8a').default;
|
||||
|
||||
async function main () {
|
||||
// Create account seed for Alice and Bob
|
||||
const ALICE_SEED = 'Alice'.padEnd(32, ' ');
|
||||
const BOB_SEED = 'Bob'.padEnd(32, ' ');
|
||||
|
||||
// Create an instance of the Keyring
|
||||
const keyring = new Keyring();
|
||||
|
||||
// Create their pairs with account seeds. Add to keyring pair dictionary
|
||||
keyring.addFromSeed(stringToU8a(ALICE_SEED));
|
||||
keyring.addFromSeed(stringToU8a(BOB_SEED));
|
||||
|
||||
// Note that we did not use `addFromAddress` since it does not add the
|
||||
// secret key to memory so we cannot later retrieve it with `getPairs`
|
||||
|
||||
// Retrieve all keyring pairs from the keyring pair dictionary
|
||||
keyring
|
||||
.getPairs()
|
||||
.forEach((pair, index) => {
|
||||
const { address } = pair;
|
||||
|
||||
console.log(`\nAccount with index #${index} has json: `, JSON.stringify(keyring.toJson(address), null, 2));
|
||||
});
|
||||
}
|
||||
|
||||
main().catch(console.error).finally(() => process.exit());
|
||||
@@ -1,19 +0,0 @@
|
||||
{
|
||||
"name": "02_load_accounts",
|
||||
"version": "0.1.0",
|
||||
"description": "Example showing how to load accounts",
|
||||
"main": "index.js",
|
||||
"author": "ltfschoen",
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"clean": "rimraf node_modules",
|
||||
"start": "node index.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@polkadot/util": "^0.32.10",
|
||||
"@polkadot/keyring": "^0.32.10"
|
||||
},
|
||||
"devDependencies": {
|
||||
"rimraf": "^2.6.2"
|
||||
}
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
# Validate Adress
|
||||
|
||||
- This function will return true if the address is a legitamate Polkadot address and false if it is not
|
||||
|
||||
- Works both with Ed25519 and Sr25519 key types
|
||||
@@ -1,18 +0,0 @@
|
||||
/* eslint-disable @typescript-eslint/no-var-requires */
|
||||
const { encodeAddress, decodeAddress } = require('@polkadot/keyring');
|
||||
const { isHex, hexToU8a } = require('@polkadot/util');
|
||||
|
||||
const address = '5GrpknVvGGrGH3EFuURXeMrWHvbpj3VfER1oX5jFtuGbfzCE';
|
||||
|
||||
const isValidAddressPolkadotAddress = () => {
|
||||
try {
|
||||
encodeAddress(isHex(address) ? hexToU8a(address) : decodeAddress(address));
|
||||
return true;
|
||||
} catch (error) {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
const isValid = isValidAddressPolkadotAddress();
|
||||
|
||||
console.log(isValid);
|
||||
@@ -1,18 +0,0 @@
|
||||
{
|
||||
"name": "03_validate_address",
|
||||
"version": "0.1.0",
|
||||
"description": "Example showing how to validate a polkadot address",
|
||||
"main": "index.js",
|
||||
"author": "Jesse",
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"clean": "rimraf node_modules",
|
||||
"start": "node index.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@polkadot/keyring": "*"
|
||||
},
|
||||
"devDependencies": {
|
||||
"rimraf": "^2.6.2"
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
# Keyring Examples
|
||||
|
||||
Here you will find a list of examples that takes you through the basics of connecting to a local node, retrieving data from the Node and chain and execute transactions on the chain.
|
||||
|
||||
## Running the examples
|
||||
|
||||
From within each folder run the following to install required dependencies and to execute the example:
|
||||
```shell
|
||||
yarn;
|
||||
yarn start
|
||||
```
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
# Encrypt & Decrypt Message using NaCl
|
||||
|
||||
The following example shows how to encrypt and decrypt a message with NaCl (pronouced "salt"), which is a Networking and Cryptography library used in util-crypto.
|
||||
|
||||
[include](index.js)
|
||||
@@ -1,26 +0,0 @@
|
||||
/* eslint-disable @typescript-eslint/require-await */
|
||||
/* eslint-disable @typescript-eslint/unbound-method */
|
||||
/* eslint-disable @typescript-eslint/no-var-requires */
|
||||
const { naclEncrypt, naclDecrypt } = require('@polkadot/util-crypto');
|
||||
|
||||
async function main () {
|
||||
const secret = new Uint8Array(32);
|
||||
const messagePreEncryption = new Uint8Array([1, 2, 3, 4, 5, 4, 3, 2, 1]);
|
||||
const noncePreEncryption = new Uint8Array(24);
|
||||
|
||||
// Encrypt the message
|
||||
const { encrypted, nonce } = naclEncrypt(messagePreEncryption, secret, noncePreEncryption);
|
||||
|
||||
// Show contents of the encrypted message
|
||||
console.log(`Encrypted message: ${JSON.stringify(encrypted, null, 2)}`);
|
||||
|
||||
// Decrypt the message
|
||||
const messageDecrypted = naclDecrypt(encrypted, nonce, secret);
|
||||
// Convert each Uint8Array to a string for comparison
|
||||
const isMatch = messagePreEncryption.toString === messageDecrypted.toString;
|
||||
|
||||
// Verify that the decrypted message matches the original message
|
||||
console.log(`Does the decrypted message match the original message? ${isMatch}`);
|
||||
}
|
||||
|
||||
main().catch(console.error).finally(() => process.exit());
|
||||
@@ -1,18 +0,0 @@
|
||||
{
|
||||
"name": "01_encrypt_decrypt_message_nacl",
|
||||
"version": "0.1.0",
|
||||
"description": "Example showing how to encrypt and decrypt a message using NaCl",
|
||||
"main": "index.js",
|
||||
"author": "ltfschoen",
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"clean": "rimraf node_modules",
|
||||
"start": "node index.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@polkadot/util-crypto": "^0.32.10"
|
||||
},
|
||||
"devDependencies": {
|
||||
"rimraf": "^2.6.2"
|
||||
}
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
# Sign & Verify Message using NaCl
|
||||
|
||||
The following example shows how to sign and verify a message with NaCl (pronouced "salt"), which is a Networking and Cryptography library used in util-crypto.
|
||||
|
||||
[include](index.js)
|
||||
@@ -1,32 +0,0 @@
|
||||
/* eslint-disable @typescript-eslint/require-await */
|
||||
/* eslint-disable @typescript-eslint/unbound-method */
|
||||
/* eslint-disable @typescript-eslint/no-var-requires */
|
||||
const { stringToU8a, u8aToHex } = require('@polkadot/util');
|
||||
const { naclEncrypt, naclKeypairFromSeed, naclSign, naclVerify, randomAsU8a } = require('@polkadot/util-crypto');
|
||||
|
||||
async function main () {
|
||||
// Create account seed for Alice as fallback if generated mnemonic not valid
|
||||
const seedAlice = 'Alice'.padEnd(32, ' ');
|
||||
|
||||
// Generate new public/secret keypair for Alice from the supplied seed
|
||||
const { secretKey, publicKey } = naclKeypairFromSeed(stringToU8a(seedAlice));
|
||||
|
||||
// Encrypt message. Create Uint8Array's filled with random bytes of specified length
|
||||
const secret = randomAsU8a(32);
|
||||
const messagePreEncryption = stringToU8a('please send me DOTs');
|
||||
const noncePreEncryption = randomAsU8a(24);
|
||||
|
||||
const { encrypted } = naclEncrypt(messagePreEncryption, secret, noncePreEncryption);
|
||||
|
||||
// Sign the message with a valid signature
|
||||
const messageSignature = naclSign(encrypted, secretKey);
|
||||
|
||||
console.log(`Message signature: ${u8aToHex(messageSignature)}`);
|
||||
|
||||
// Validate that the message was correctly signed
|
||||
const isValidSignature = naclVerify(encrypted, messageSignature, publicKey);
|
||||
|
||||
console.log(`Was the message correctly signed? ${isValidSignature}`);
|
||||
}
|
||||
|
||||
main().catch(console.error).finally(() => process.exit());
|
||||
@@ -1,18 +0,0 @@
|
||||
{
|
||||
"name": "02_sign_verify_message_nacl",
|
||||
"version": "0.1.0",
|
||||
"description": "Example showing how to sign and verify a message using NaCl",
|
||||
"main": "index.js",
|
||||
"author": "ltfschoen",
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"clean": "rimraf node_modules",
|
||||
"start": "node index.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@polkadot/util-crypto": "^0.32.10"
|
||||
},
|
||||
"devDependencies": {
|
||||
"rimraf": "^2.6.2"
|
||||
}
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
# Create & Generate Mnemonic using BIP39
|
||||
|
||||
The following example shows how to create and generate mnemonics using BIP39.
|
||||
|
||||
[include](index.js)
|
||||
@@ -1,27 +0,0 @@
|
||||
/* eslint-disable @typescript-eslint/unbound-method */
|
||||
/* eslint-disable @typescript-eslint/require-await */
|
||||
/* eslint-disable @typescript-eslint/no-var-requires,@typescript-eslint/no-unused-vars */
|
||||
const { mnemonicGenerate, mnemonicToSeed, mnemonicValidate, naclKeypairFromSeed } = require('@polkadot/util-crypto');
|
||||
|
||||
async function main () {
|
||||
// Create mnemonic string for Alice using BIP39
|
||||
const mnemonicAlice = mnemonicGenerate();
|
||||
|
||||
console.log(`Generated mnemonic: ${mnemonicAlice}`);
|
||||
|
||||
// Validate the mnemic string that was generated
|
||||
const isValidMnemonic = mnemonicValidate(mnemonicAlice);
|
||||
|
||||
console.log(`isValidMnemonic: ${isValidMnemonic}`);
|
||||
|
||||
// Create valid seed from mnemonic as u8a and convert it to a string
|
||||
// FIXME - Replace with mnemonicToSeed once exposed
|
||||
const seedAlice = mnemonicToSeed(mnemonicAlice);
|
||||
|
||||
// Generate new public/secret keypair for Alice from the supplied seed
|
||||
const { secretKey, publicKey } = naclKeypairFromSeed(seedAlice);
|
||||
|
||||
// Encrypt, Sign and Validate the message. See Example 'Sign & Verify Message'
|
||||
}
|
||||
|
||||
main().catch(console.error).finally(() => process.exit());
|
||||
@@ -1,18 +0,0 @@
|
||||
{
|
||||
"name": "03_mnemonic_generate_validate_bip39",
|
||||
"version": "0.1.0",
|
||||
"description": "Example showing how to sign and verify a message using NaCl",
|
||||
"main": "index.js",
|
||||
"author": "ltfschoen",
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"clean": "rimraf node_modules",
|
||||
"start": "node index.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@polkadot/util-crypto": "^0.32.10"
|
||||
},
|
||||
"devDependencies": {
|
||||
"rimraf": "^2.6.2"
|
||||
}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
# Util-Crypto Examples
|
||||
|
||||
Here you will find a list of examples that takes you through the basics of encrypting and decrypting messages using NaCl, signing a message with a seed and verifying it using NaCl, and generating and validating mnemonics for account seeds.
|
||||
|
||||
## Running the examples
|
||||
|
||||
From within each folder run the following to install required dependencies and to execute the example:
|
||||
```shell
|
||||
yarn;
|
||||
yarn start
|
||||
```
|
||||
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="initial-scale=0.5, maximum-scale=1">
|
||||
<meta http-equiv="refresh" content="0;URL='https://polkadot.js.org/docs/'" />
|
||||
<title>Redirecting to https://polkadot.js.org/docs/</title>
|
||||
</head>
|
||||
<body>
|
||||
Redirecting to <a href="https://polkadot.js.org/docs/">https://polkadot.js.org/docs/</a>
|
||||
</body>
|
||||
</html>
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 7.3 KiB |
@@ -0,0 +1,36 @@
|
||||
// Copyright 2017-2021 @polkadot/util authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
const config = require('@polkadot/dev/config/jest.cjs');
|
||||
|
||||
module.exports = Object.assign({}, config, {
|
||||
moduleNameMapper: {
|
||||
'@polkadot/hw-ledger-transports(.*)$': '<rootDir>/packages/hw-ledger-transports/src/node',
|
||||
// eslint-disable-next-line sort-keys
|
||||
'@polkadot/hw-ledger(.*)$': '<rootDir>/packages/hw-ledger/src/$1',
|
||||
'@polkadot/keyring(.*)$': '<rootDir>/packages/keyring/src/$1',
|
||||
'@polkadot/networks(.*)$': '<rootDir>/packages/networks/src/$1',
|
||||
'@polkadot/util-(crypto)(.*)$': '<rootDir>/packages/util-$1/src/$2',
|
||||
// eslint-disable-next-line sort-keys
|
||||
'@polkadot/util(.*)$': '<rootDir>/packages/util/src/$1',
|
||||
'@polkadot/x-(fetch|randomvalues|textdecoder|textencoder|ws)(.*)$': '<rootDir>/packages/x-$1/src/node',
|
||||
'@polkadot/x-global(.*)$': '<rootDir>/packages/x-global/src/$1',
|
||||
'@polkadot/x-rxjs(.*)$': '<rootDir>/packages/x-rxjs/src/$1'
|
||||
},
|
||||
modulePathIgnorePatterns: [
|
||||
'<rootDir>/packages/hw-ledger/build',
|
||||
'<rootDir>/packages/hw-ledger-transports/build',
|
||||
'<rootDir>/packages/keyring/build',
|
||||
'<rootDir>/packages/networks/build',
|
||||
'<rootDir>/packages/util/build',
|
||||
'<rootDir>/packages/util-crypto/build',
|
||||
'<rootDir>/packages/x-fetch/build',
|
||||
'<rootDir>/packages/x-global/build',
|
||||
'<rootDir>/packages/x-randomvalues/build',
|
||||
'<rootDir>/packages/x-rxjs/build',
|
||||
'<rootDir>/packages/x-textdecoder/build',
|
||||
'<rootDir>/packages/x-textencoder/build',
|
||||
'<rootDir>/packages/x-ws/build'
|
||||
],
|
||||
transformIgnorePatterns: ['/node_modules/(?!@polkadot)']
|
||||
});
|
||||
@@ -1,24 +0,0 @@
|
||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||
const config = require('@polkadot/dev/config/jest');
|
||||
|
||||
module.exports = Object.assign({}, config, {
|
||||
moduleNameMapper: {
|
||||
'@polkadot/chainspec(.*)$': '<rootDir>/packages/chainspec/src/$1',
|
||||
'@polkadot/db(.*)$': '<rootDir>/packages/db/src/$1',
|
||||
'@polkadot/keyring(.*)$': '<rootDir>/packages/keyring/src/$1',
|
||||
'@polkadot/trie-(codec|db|hash)(.*)$': '<rootDir>/packages/trie-$1/src/$2',
|
||||
'@polkadot/util-(crypto|rlp)(.*)$': '<rootDir>/packages/util-$1/src/$2',
|
||||
'@polkadot/util(.*)$': '<rootDir>/packages/util/src/$1'
|
||||
},
|
||||
modulePathIgnorePatterns: [
|
||||
'<rootDir>/packages/db/build',
|
||||
'<rootDir>/packages/chainspec/build',
|
||||
'<rootDir>/packages/keyring/build',
|
||||
'<rootDir>/packages/trie-codec/build',
|
||||
'<rootDir>/packages/trie-db/build',
|
||||
'<rootDir>/packages/trie-hash/build',
|
||||
'<rootDir>/packages/util/build',
|
||||
'<rootDir>/packages/util-crypto/build',
|
||||
'<rootDir>/packages/util-rlp/build'
|
||||
]
|
||||
});
|
||||
-13
@@ -1,13 +0,0 @@
|
||||
{
|
||||
"npmClient": "yarn",
|
||||
"useWorkspaces": true,
|
||||
"command": {
|
||||
"publish": {
|
||||
"allowBranch": "master"
|
||||
}
|
||||
},
|
||||
"packages": [
|
||||
"packages/*"
|
||||
],
|
||||
"version": "1.2.1"
|
||||
}
|
||||
+16
-16
@@ -1,29 +1,29 @@
|
||||
{
|
||||
"version": "1.2.1",
|
||||
"repository": "https://github.com/polkadot-js/common",
|
||||
"author": "Jaco Greeff <jacogr@gmail.com>",
|
||||
"license": "Apache-2",
|
||||
"private": true,
|
||||
"engines": {
|
||||
"yarn": "^1.10.1"
|
||||
},
|
||||
"workspaces": [
|
||||
"packages/*"
|
||||
],
|
||||
"resolutions": {
|
||||
"babel-core": "^7.0.0-bridge.0",
|
||||
"typescript": "^3.6.2"
|
||||
"typescript": "^4.2.2"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "polkadot-dev-build-ts && polkadot-dev-build-docs",
|
||||
"check": "yarn lint",
|
||||
"lint": "eslint . --ext .js,.jsx,.ts,.tsx . && tsc --noEmit --pretty",
|
||||
"build": "polkadot-dev-build-ts",
|
||||
"build:release": "polkadot-ci-ghact-build",
|
||||
"lint": "polkadot-dev-run-lint",
|
||||
"clean": "polkadot-dev-clean-build",
|
||||
"networks:crosscheck": "polkadot-dev-run-test packages/networks/src/crosscheck",
|
||||
"postinstall": "polkadot-dev-yarn-only",
|
||||
"test": "jest --coverage --runInBand",
|
||||
"test:one": "jest"
|
||||
"test": "polkadot-dev-run-test --coverage --runInBand --testPathIgnorePatterns crosscheck",
|
||||
"test:one": "polkadot-dev-run-test"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.5.5",
|
||||
"@polkadot/dev": "^0.31.0-beta.7",
|
||||
"@polkadot/ts": "^0.1.71",
|
||||
"gh-pages": "^2.1.1"
|
||||
}
|
||||
"@babel/core": "^7.13.8",
|
||||
"@polkadot/dev": "^0.62.5",
|
||||
"@polkadot/ts": "^0.3.61",
|
||||
"@types/jest": "^26.0.20"
|
||||
},
|
||||
"version": "6.0.3"
|
||||
}
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
# @polkadot/chainspec
|
||||
|
||||
Chainspecs for known chains
|
||||
|
||||
## Utilities
|
||||
|
||||
[Utilities](SUMMARY.md)
|
||||
@@ -1,31 +0,0 @@
|
||||
{
|
||||
"name": "@polkadot/chainspec",
|
||||
"version": "1.2.1",
|
||||
"description": "Contains chain specifications for known chains",
|
||||
"main": "index.js",
|
||||
"keywords": [
|
||||
"Polkadot"
|
||||
],
|
||||
"author": "Jaco Greeff <jacogr@gmail.com>",
|
||||
"maintainers": [
|
||||
"Jaco Greeff <jacogr@gmail.com>"
|
||||
],
|
||||
"contributors": [],
|
||||
"license": "Apache-2.0",
|
||||
"publishConfig": {
|
||||
"access": "public",
|
||||
"registry": "https://registry.npmjs.org"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/polkadot-js/common.git"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/polkadot-js/common/issues"
|
||||
},
|
||||
"homepage": "https://github.com/polkadot-js/common/tree/master/packages/chainspec#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.5.5",
|
||||
"@polkadot/util": "^1.2.1"
|
||||
}
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -1,6 +0,0 @@
|
||||
// Copyright 2017-2019 @polkadot/chainspec 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 alexander } from './alexander';
|
||||
export { default as driedDanta } from './dried-danta';
|
||||
@@ -1,20 +0,0 @@
|
||||
// Copyright 2017-2019 @polkadot/chainspec 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 type Telemetry = [string, number];
|
||||
|
||||
export interface Chainspec {
|
||||
bootNodes: string[];
|
||||
id: string;
|
||||
genesis: {
|
||||
raw: Record<string, string>;
|
||||
};
|
||||
genesisRoot?: string;
|
||||
name: string;
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
properties: null | Record<string, any>;
|
||||
protocolId: string | null;
|
||||
telemetryUrl?: string | null;
|
||||
telemetryEndpoints?: Telemetry[];
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
# @polkadot/db
|
||||
|
||||
This is an implementation of a basic sync in-memory and on-disk database with overlays. Memory is currently used by polkadot-js/client
|
||||
|
||||
## Usage
|
||||
|
||||
Installation -
|
||||
|
||||
```
|
||||
yarn add @polkadot/db
|
||||
```
|
||||
|
||||
Classes can be imported as follows:
|
||||
|
||||
```js
|
||||
// Default exports
|
||||
import DiskDb from '@polkadot/db/Disk';
|
||||
import MemoryDb from '@polkadot/db/Memory';
|
||||
import TransactionDb from '@polkadot/db/engines/TransactionDb';
|
||||
```
|
||||
|
||||
## Utilities
|
||||
|
||||
[Utilities](SUMMARY.md)
|
||||
@@ -1,33 +0,0 @@
|
||||
{
|
||||
"name": "@polkadot/db",
|
||||
"version": "1.2.1",
|
||||
"description": "Implementation of a basic sync in-memory and on-disk databases with overlays",
|
||||
"main": "index.js",
|
||||
"keywords": [
|
||||
"Polkadot"
|
||||
],
|
||||
"author": "Jaco Greeff <jacogr@gmail.com>",
|
||||
"maintainers": [
|
||||
"Jaco Greeff <jacogr@gmail.com>"
|
||||
],
|
||||
"contributors": [],
|
||||
"license": "Apache-2.0",
|
||||
"publishConfig": {
|
||||
"access": "public",
|
||||
"registry": "https://registry.npmjs.org"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/polkadot-js/common.git"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/polkadot-js/common/issues"
|
||||
},
|
||||
"homepage": "https://github.com/polkadot-js/common/tree/master/packages/db#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.5.5",
|
||||
"@polkadot/trie-hash": "^1.2.1",
|
||||
"@polkadot/util": "^1.2.1",
|
||||
"lru_map": "^0.3.3"
|
||||
}
|
||||
}
|
||||
@@ -1,68 +0,0 @@
|
||||
// Copyright 2017-2019 @polkadot/db 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 MemoryDb from './engines/MemoryDb';
|
||||
import TransactionDb from './engines/TransactionDb';
|
||||
|
||||
/**
|
||||
* @name MemoryDb
|
||||
* @summary Creates a MemoryDb database extending TransactionDb
|
||||
* @description Create an instance of a Memory database using
|
||||
* MemoryDb and extending TransactionDb.
|
||||
* `options` argument (optional) used to specifies whether
|
||||
* to use compression.
|
||||
* - Enable compression when storing "blocks" since they compress well.
|
||||
* - Disable compression when storing "state" Transactions Trie
|
||||
* using @polkadot/trie-db or @polkadot/db/src/engines/TransactionDb.ts
|
||||
* (potentially LevelDb or RocksDb implementation of a Merkle Patricia Trie)
|
||||
* data structure serialised with Recursive Length Prefix (RLP) encoding
|
||||
* @example
|
||||
* <BR>
|
||||
*
|
||||
* ```javascript
|
||||
* import stringToU8a from '@polkadot/util/string/toU8a';
|
||||
* import MemoryDb from '@polkadot/db/Memory';
|
||||
* import TransactionDb from '@polkadot/db/engines/TransactionDb';
|
||||
*
|
||||
* const memoryDb = new MemoryDb();
|
||||
* const txDb = new TransactionDb(memoryDb);
|
||||
*
|
||||
* // Open the memory database
|
||||
* memoryDb.open();
|
||||
*
|
||||
* // Declare key/value pair to allocate to store under a the key
|
||||
* const key = stringToU8a('key');
|
||||
* const value = stringToU8a('some value');
|
||||
*
|
||||
* // Store key/value pair in memory db
|
||||
* memoryDb.put(key, value);
|
||||
*
|
||||
* // Retrieve value for key from memory db
|
||||
* valueRetrieved = memoryDb.get(key);
|
||||
*
|
||||
* // Delete key/value pair from memory db
|
||||
* memoryDb.del(key);
|
||||
*
|
||||
* // Transaction to Store key/value pair in transaction db
|
||||
* const isTxSuccess = txDb.transaction((): void => {
|
||||
* txDb.put(key, value);
|
||||
*
|
||||
* // Boolean to indicate whether transaction was successful or not
|
||||
* return true;
|
||||
* });
|
||||
*
|
||||
* console.log(`Transaction successful?: ${isTxSuccess}`);
|
||||
*
|
||||
* // Retrieve transaction value from memory db
|
||||
* console.log(`Transfered value: ${memoryDb.get(key)}`);
|
||||
*
|
||||
* // Close the memory database
|
||||
* memoryDb.close();
|
||||
* ```
|
||||
*/
|
||||
export default class Memory extends TransactionDb {
|
||||
public constructor () {
|
||||
super(new MemoryDb());
|
||||
}
|
||||
}
|
||||
@@ -1,63 +0,0 @@
|
||||
// Copyright 2017-2019 @polkadot/db 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 toU8a from '@polkadot/util/u8a/toU8a';
|
||||
|
||||
import LruDb from './LruDb';
|
||||
import MemoryDb from './MemoryDb';
|
||||
|
||||
describe('LruDb', (): void => {
|
||||
const memory = new MemoryDb();
|
||||
const db = new LruDb(memory);
|
||||
|
||||
it('retrieves an item from the backing when not available (caching it)', (): void => {
|
||||
const key = toU8a('test1');
|
||||
const value = toU8a('value1');
|
||||
|
||||
memory.put(key, value);
|
||||
|
||||
expect(db.get(key)).toEqual(value);
|
||||
expect(db._getLru(key)).toEqual({ value });
|
||||
});
|
||||
|
||||
it('replaces an item (caching and backing)', (): void => {
|
||||
const key = toU8a('test1');
|
||||
const value = toU8a('test');
|
||||
|
||||
db.put(key, value);
|
||||
|
||||
expect(db.get(key)).toEqual(value);
|
||||
expect(memory.get(key)).toEqual(value);
|
||||
expect(db._getLru(key)).toEqual({ value });
|
||||
});
|
||||
|
||||
it('retrieves item from LRU when available', (): void => {
|
||||
const key = toU8a('test1');
|
||||
const value = toU8a('test');
|
||||
|
||||
memory.del(key);
|
||||
|
||||
expect(db.get(key)).toEqual(value);
|
||||
});
|
||||
|
||||
it('puts item both in LRU and backing', (): void => {
|
||||
const key = toU8a('test0');
|
||||
const value = toU8a('value0');
|
||||
|
||||
db.put(key, value);
|
||||
|
||||
expect(memory.get(key)).toEqual(value);
|
||||
expect(db._getLru(key)).toEqual({ value });
|
||||
});
|
||||
|
||||
it('deletes an item from both backing and db', (): void => {
|
||||
const key = toU8a('test0');
|
||||
|
||||
db.del(key);
|
||||
|
||||
expect(memory.get(key)).toEqual(null);
|
||||
expect(db._getLru(key)).toEqual({ value: null });
|
||||
expect(db.get(key)).toEqual(null);
|
||||
});
|
||||
});
|
||||
@@ -1,116 +0,0 @@
|
||||
// Copyright 2017-2019 @polkadot/db 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 { BaseDb, ProgressCb } from '../types';
|
||||
|
||||
import { LRUMap } from 'lru_map';
|
||||
import { logger } from '@polkadot/util';
|
||||
|
||||
interface CachedValue {
|
||||
value: Uint8Array | null;
|
||||
}
|
||||
|
||||
const DEFAULT_ITEM_COUNT = 4096;
|
||||
|
||||
const l = logger('db/lru');
|
||||
|
||||
export default class LruDb implements BaseDb {
|
||||
private backing: BaseDb;
|
||||
|
||||
private lru: LRUMap<string, CachedValue>;
|
||||
|
||||
public constructor (backing: BaseDb, itemCount: number = DEFAULT_ITEM_COUNT) {
|
||||
this.backing = backing;
|
||||
this.lru = new LRUMap(itemCount);
|
||||
}
|
||||
|
||||
public close (): void {
|
||||
l.debug((): string[] => ['close']);
|
||||
|
||||
this.lru.clear();
|
||||
this.backing.close();
|
||||
}
|
||||
|
||||
public open (): void {
|
||||
l.debug((): string[] => ['open']);
|
||||
|
||||
this.lru.clear();
|
||||
this.backing.open();
|
||||
}
|
||||
|
||||
public drop (): void {
|
||||
this.backing.drop();
|
||||
}
|
||||
|
||||
public empty (): void {
|
||||
l.debug((): string[] => ['empty']);
|
||||
|
||||
this.lru.clear();
|
||||
this.backing.empty();
|
||||
}
|
||||
|
||||
public rename (base: string, file: string): void {
|
||||
this.backing.rename(base, file);
|
||||
}
|
||||
|
||||
public maintain (fn: ProgressCb): void {
|
||||
this.backing.maintain(fn);
|
||||
}
|
||||
|
||||
public size (): number {
|
||||
return this.backing.size();
|
||||
}
|
||||
|
||||
public del (key: Uint8Array): void {
|
||||
const keyStr = key.toString();
|
||||
|
||||
this.backing.del(key);
|
||||
this.lru.set(keyStr, { value: null });
|
||||
}
|
||||
|
||||
public get (key: Uint8Array): Uint8Array | null {
|
||||
const keyStr = key.toString();
|
||||
const cached = this.lru.get(keyStr);
|
||||
|
||||
if (cached) {
|
||||
return cached.value;
|
||||
}
|
||||
|
||||
const value = this.backing.get(key);
|
||||
|
||||
this.lru.set(keyStr, { value });
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
// Convenience methods used in tests
|
||||
public _getLru (key: Uint8Array): CachedValue | undefined {
|
||||
return this.lru.get(key.toString());
|
||||
}
|
||||
|
||||
public put (key: Uint8Array, value: Uint8Array): void {
|
||||
const keyStr = key.toString();
|
||||
|
||||
this.backing.put(key, value);
|
||||
this.lru.set(keyStr, { value });
|
||||
}
|
||||
|
||||
public txCommit (): void {
|
||||
if (this.backing.txCommit) {
|
||||
this.backing.txCommit();
|
||||
}
|
||||
}
|
||||
|
||||
public txRevert (): void {
|
||||
if (this.backing.txRevert) {
|
||||
this.backing.txRevert();
|
||||
}
|
||||
}
|
||||
|
||||
public txStart (): void {
|
||||
if (this.backing.txStart) {
|
||||
this.backing.txStart();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
// Copyright 2017-2019 @polkadot/db 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 MemoryDb from './MemoryDb';
|
||||
|
||||
describe('MemoryDb', (): void => {
|
||||
const memory = new MemoryDb();
|
||||
|
||||
it('gets the combioned size of the entry values', (): void => {
|
||||
memory.put(new Uint8Array([1]), new Uint8Array([1, 2, 3]));
|
||||
memory.put(new Uint8Array([2]), new Uint8Array([1, 2, 3]));
|
||||
memory.put(new Uint8Array([3]), new Uint8Array([1, 2, 3]));
|
||||
|
||||
expect(memory.size()).toEqual(9);
|
||||
});
|
||||
|
||||
it('does not throw on the stubs', (done): void => {
|
||||
memory.close();
|
||||
memory.open();
|
||||
memory.drop();
|
||||
memory.empty();
|
||||
memory.rename('foo', 'bar');
|
||||
|
||||
memory.maintain((): void => done());
|
||||
});
|
||||
});
|
||||
@@ -1,70 +0,0 @@
|
||||
// Copyright 2017-2019 @polkadot/db 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 { BaseDb, ProgressCb } from '../types';
|
||||
|
||||
import { logger } from '@polkadot/util';
|
||||
|
||||
const l = logger('db/memory');
|
||||
|
||||
export default class MemoryDb implements BaseDb {
|
||||
private _storage: Map<string, Uint8Array> = new Map();
|
||||
|
||||
public close (): void {
|
||||
this.empty();
|
||||
}
|
||||
|
||||
public open (): void {
|
||||
this.empty();
|
||||
}
|
||||
|
||||
public drop (): void {
|
||||
this.empty();
|
||||
}
|
||||
|
||||
public empty (): void {
|
||||
this._storage.clear();
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
public rename (base: string, file: string): void {
|
||||
l.warn('rename() is not implemented');
|
||||
}
|
||||
|
||||
public maintain (fn: ProgressCb): void {
|
||||
fn({
|
||||
isCompleted: true,
|
||||
keys: this._storage.size,
|
||||
percent: 100
|
||||
});
|
||||
}
|
||||
|
||||
public size (): number {
|
||||
let size = 0;
|
||||
|
||||
this._storage.forEach((value): void => {
|
||||
size += value.length;
|
||||
});
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
public del (key: Uint8Array): void {
|
||||
// l.debug(() => ['del', { key }]);
|
||||
|
||||
this._storage.delete(key.toString());
|
||||
}
|
||||
|
||||
public get (key: Uint8Array): Uint8Array | null {
|
||||
// l.debug(() => ['get', { key }]);
|
||||
|
||||
return this._storage.get(key.toString()) || null;
|
||||
}
|
||||
|
||||
public put (key: Uint8Array, value: Uint8Array): void {
|
||||
// l.debug(() => ['put', { key, value }]);
|
||||
|
||||
this._storage.set(key.toString(), value);
|
||||
}
|
||||
}
|
||||
@@ -1,93 +0,0 @@
|
||||
// Copyright 2017-2019 @polkadot/db 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 toU8a from '@polkadot/util/string/toU8a';
|
||||
|
||||
import MemoryDb from './MemoryDb';
|
||||
import TransactionDb from './TransactionDb';
|
||||
|
||||
describe('TransactionDb', (): void => {
|
||||
const memory = new MemoryDb();
|
||||
const db = new TransactionDb(memory);
|
||||
|
||||
it('passed through values immediately when not in transaction', (): void => {
|
||||
const key = toU8a('test0');
|
||||
const value = toU8a('value0');
|
||||
|
||||
db.put(key, value);
|
||||
|
||||
expect(memory.get(key)).toEqual(value);
|
||||
});
|
||||
|
||||
it('commits when transaction passes (result = true, put)', (): void => {
|
||||
const key = toU8a('test1');
|
||||
const value = toU8a('value1');
|
||||
|
||||
expect(
|
||||
db.transaction((): boolean => {
|
||||
db.put(key, value);
|
||||
|
||||
return true;
|
||||
})
|
||||
).toEqual(true);
|
||||
expect(memory.get(key)).toEqual(value);
|
||||
});
|
||||
|
||||
it('commits when transaction passes (result = true, del)', (): void => {
|
||||
const key = toU8a('test0');
|
||||
|
||||
expect(
|
||||
db.transaction((): boolean => {
|
||||
db.del(key);
|
||||
|
||||
return true;
|
||||
})
|
||||
).toEqual(true);
|
||||
expect(memory.get(key)).toEqual(null);
|
||||
});
|
||||
|
||||
it('does not commit when transaction fails (result = false)', (): void => {
|
||||
const key = toU8a('test2');
|
||||
const value = toU8a('value2');
|
||||
|
||||
expect(
|
||||
db.transaction((): boolean => {
|
||||
db.put(key, value);
|
||||
|
||||
return false;
|
||||
})
|
||||
).toEqual(false);
|
||||
expect(memory.get(key)).toEqual(null);
|
||||
});
|
||||
|
||||
it('does not commit when transaction throws', (): void => {
|
||||
const key = toU8a('test2');
|
||||
const value = toU8a('value2');
|
||||
|
||||
expect(
|
||||
(): void => {
|
||||
db.transaction((): void => {
|
||||
db.put(key, value);
|
||||
|
||||
throw new Error('test');
|
||||
});
|
||||
}
|
||||
).toThrow(/test/);
|
||||
expect(memory.get(key)).toEqual(null);
|
||||
});
|
||||
|
||||
it('inside the transaction, the value is set', (): void => {
|
||||
const key = toU8a('test2');
|
||||
const value = toU8a('value2');
|
||||
|
||||
db.transaction((): boolean => {
|
||||
db.put(key, value);
|
||||
|
||||
expect(db.get(key)).toEqual(value);
|
||||
|
||||
return false;
|
||||
});
|
||||
expect(memory.get(key)).toEqual(null);
|
||||
});
|
||||
});
|
||||
@@ -1,157 +0,0 @@
|
||||
// Copyright 2017-2019 @polkadot/db 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 { BaseDb, TxDb, ProgressCb } from '../types';
|
||||
|
||||
import { assert, isNull, logger } from '@polkadot/util';
|
||||
|
||||
interface OverlayItem {
|
||||
key: Uint8Array;
|
||||
value: Uint8Array | null;
|
||||
}
|
||||
|
||||
const l = logger('db/transact');
|
||||
|
||||
export default class TransactionDb implements TxDb {
|
||||
private backing: BaseDb;
|
||||
|
||||
private txOverlay: Map<string, OverlayItem> = new Map();
|
||||
|
||||
private txStarted: boolean;
|
||||
|
||||
public constructor (backing: BaseDb) {
|
||||
this.backing = backing;
|
||||
this.txStarted = false;
|
||||
}
|
||||
|
||||
public transaction<T> (fn: () => T): T {
|
||||
l.debug((): string[] => ['transaction']);
|
||||
|
||||
try {
|
||||
this.createTx();
|
||||
|
||||
const result = fn();
|
||||
|
||||
if (result) {
|
||||
this.commitTx();
|
||||
} else {
|
||||
this.revertTx();
|
||||
}
|
||||
|
||||
return result;
|
||||
} catch (error) {
|
||||
this.revertTx();
|
||||
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
public close (): void {
|
||||
this.backing.close();
|
||||
}
|
||||
|
||||
public open (): void {
|
||||
this.backing.open();
|
||||
}
|
||||
|
||||
public drop (): void {
|
||||
this.backing.drop();
|
||||
}
|
||||
|
||||
public empty (): void {
|
||||
this.backing.empty();
|
||||
}
|
||||
|
||||
public rename (base: string, file: string): void {
|
||||
this.backing.rename(base, file);
|
||||
}
|
||||
|
||||
public maintain (fn: ProgressCb): void {
|
||||
assert(this.txStarted === false, 'Cannot maintain inside an open transaction');
|
||||
|
||||
this.backing.maintain(fn);
|
||||
}
|
||||
|
||||
public size (): number {
|
||||
return this.backing.size();
|
||||
}
|
||||
|
||||
public del (key: Uint8Array): void {
|
||||
if (this.txStarted) {
|
||||
this.txOverlay.set(key.toString(), { key, value: null });
|
||||
return;
|
||||
}
|
||||
|
||||
this.backing.del(key);
|
||||
}
|
||||
|
||||
public get (key: Uint8Array): Uint8Array | null {
|
||||
// l.debug(() => ['get', u8aToHex(key)]);
|
||||
|
||||
if (this.txStarted) {
|
||||
const value = this.txOverlay.get(key.toString());
|
||||
|
||||
if (value) {
|
||||
return value.value;
|
||||
}
|
||||
}
|
||||
|
||||
return this.backing.get(key);
|
||||
}
|
||||
|
||||
public put (key: Uint8Array, value: Uint8Array): void {
|
||||
// l.debug(() => ['put', u8aToHex(key), u8aToHex(value)]);
|
||||
|
||||
if (this.txStarted) {
|
||||
this.txOverlay.set(key.toString(), { key, value });
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
return this.backing.put(key, value);
|
||||
}
|
||||
|
||||
private createTx (): void {
|
||||
l.debug((): string[] => ['createTx']);
|
||||
|
||||
assert(!this.txStarted, 'Cannot create a transaction when one is already active');
|
||||
|
||||
this.txOverlay.clear();
|
||||
this.txStarted = true;
|
||||
}
|
||||
|
||||
private commitTx (): void {
|
||||
l.debug((): [string, number, string] => ['commitTx', Object.keys(this.txOverlay).length, 'keys']);
|
||||
|
||||
assert(this.txStarted, 'Cannot commit when not in transaction');
|
||||
|
||||
if (this.backing.txStart) {
|
||||
this.backing.txStart();
|
||||
}
|
||||
|
||||
this.txOverlay.forEach(({ key, value }): void => {
|
||||
if (isNull(value)) {
|
||||
this.backing.del(key);
|
||||
} else {
|
||||
this.backing.put(key, value);
|
||||
}
|
||||
});
|
||||
|
||||
if (this.backing.txCommit) {
|
||||
this.backing.txCommit();
|
||||
}
|
||||
|
||||
this.txOverlay.clear();
|
||||
this.txStarted = false;
|
||||
}
|
||||
|
||||
private revertTx (): void {
|
||||
l.debug((): string[] => ['revertTx']);
|
||||
|
||||
assert(this.txStarted, 'Cannot revert when not in transaction');
|
||||
|
||||
this.txOverlay.clear();
|
||||
this.txStarted = false;
|
||||
}
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
// Copyright 2017-2019 @polkadot/db 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 interface ProgressValue {
|
||||
isCompleted?: boolean;
|
||||
keys: number;
|
||||
percent: number;
|
||||
}
|
||||
|
||||
export type ProgressCb = (progress: ProgressValue) => void;
|
||||
|
||||
export interface BaseDbOptions {
|
||||
isCompressed?: boolean;
|
||||
isLru?: boolean;
|
||||
isNative?: boolean;
|
||||
}
|
||||
|
||||
export interface BaseDb {
|
||||
close (): void;
|
||||
open (): void;
|
||||
drop (): void;
|
||||
empty (): void;
|
||||
maintain (fn: ProgressCb): void;
|
||||
rename (base: string, file: string): void;
|
||||
size (): number;
|
||||
|
||||
txCommit?: () => void;
|
||||
txRevert?: () => void;
|
||||
txStart?: () => void;
|
||||
|
||||
del (key: Uint8Array): void;
|
||||
get (key: Uint8Array): Uint8Array | null;
|
||||
put (key: Uint8Array, value: Uint8Array): void;
|
||||
}
|
||||
|
||||
export interface TxDb extends BaseDb {
|
||||
transaction <T> (fn: () => T): T;
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
# @polkadot/hw-ledger-transports
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"name": "@polkadot/hw-ledger-transports",
|
||||
"version": "6.0.3",
|
||||
"type": "module",
|
||||
"repository": "github:polkadot-js/common",
|
||||
"author": "Jaco Greeff <jacogr@gmail.com>",
|
||||
"maintainers": [],
|
||||
"contributors": [],
|
||||
"license": "Apache-2.0",
|
||||
"main": "node.js",
|
||||
"browser": "browser.js",
|
||||
"react-native": "react-native.js",
|
||||
"sideEffects": false,
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.13.9",
|
||||
"@ledgerhq/hw-transport-webusb": "^5.45.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/ledgerhq__hw-transport-node-hid": "^4.22.2",
|
||||
"@types/ledgerhq__hw-transport-webusb": "^4.70.1"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"@ledgerhq/hw-transport-node-hid-singleton": "^5.45.0"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
// Copyright 2017-2021 @polkadot/hw-ledger authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type Transport from '@ledgerhq/hw-transport';
|
||||
import type { TransportDef } from './types';
|
||||
|
||||
import LedgerWebUSB from '@ledgerhq/hw-transport-webusb';
|
||||
|
||||
export { packageInfo } from './packageInfo';
|
||||
|
||||
export const transports: TransportDef[] = [
|
||||
// deprecated
|
||||
// import LedgerU2F from '@ledgerhq/hw-transport-u2f';
|
||||
// {
|
||||
// create: (): Promise<Transport> =>
|
||||
// LedgerU2F.create(),
|
||||
// type: 'u2f'
|
||||
// },
|
||||
{
|
||||
create: (): Promise<Transport> =>
|
||||
LedgerWebUSB.create(),
|
||||
type: 'webusb'
|
||||
}
|
||||
];
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
// Copyright 2017-2021 @polkadot/hw-ledger authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
declare module '@ledgerhq/hw-transport-node-hid-noevents' {
|
||||
import Transport from '@ledgerhq/hw-transport';
|
||||
|
||||
export default class TransportNodeHidNoEvents extends Transport<string> {}
|
||||
export function getDevices(): Array<unknown>
|
||||
}
|
||||
|
||||
declare module '@ledgerhq/hw-transport-node-hid-singleton' {
|
||||
import TransportNodeHidNoEvents from '@ledgerhq/hw-transport-node-hid-noevents';
|
||||
|
||||
export default class TransportNodeHid extends TransportNodeHidNoEvents { }
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
// Copyright 2017-2021 @polkadot/hw-ledger authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type Transport from '@ledgerhq/hw-transport';
|
||||
import type { TransportDef } from './types';
|
||||
|
||||
import LedgerHid from '@ledgerhq/hw-transport-node-hid-singleton';
|
||||
|
||||
export { packageInfo } from './packageInfo';
|
||||
|
||||
export const transports: TransportDef[] = [
|
||||
{
|
||||
create: (): Promise<Transport> =>
|
||||
LedgerHid.create(),
|
||||
type: 'hid'
|
||||
}
|
||||
];
|
||||
@@ -0,0 +1,6 @@
|
||||
// Copyright 2017-2021 @polkadot/hw-ledger-transports authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Auto-generated by @polkadot/dev, do not edit
|
||||
|
||||
export const packageInfo = { name: '@polkadot/hw-ledger-transports', version: '6.0.3' };
|
||||
@@ -0,0 +1,8 @@
|
||||
// Copyright 2017-2021 @polkadot/hw-ledger authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { TransportDef } from './types';
|
||||
|
||||
export { packageInfo } from './packageInfo';
|
||||
|
||||
export const transports: TransportDef[] = [];
|
||||
@@ -0,0 +1,11 @@
|
||||
// Copyright 2017-2021 @polkadot/hw-ledger authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import Transport from '@ledgerhq/hw-transport';
|
||||
|
||||
export type LedgerTypes = 'hid' | 'u2f' | 'webusb';
|
||||
|
||||
export interface TransportDef {
|
||||
create (): Promise<Transport>;
|
||||
type: LedgerTypes;
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
# @polkadot/hw-ledger
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"name": "@polkadot/hw-ledger",
|
||||
"version": "6.0.3",
|
||||
"type": "module",
|
||||
"repository": "github:polkadot-js/common",
|
||||
"author": "Jaco Greeff <jacogr@gmail.com>",
|
||||
"maintainers": [],
|
||||
"contributors": [],
|
||||
"license": "Apache-2.0",
|
||||
"main": "index.js",
|
||||
"sideEffects": [
|
||||
"./detectPackage.js",
|
||||
"./detectPackage.cjs"
|
||||
],
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.13.9",
|
||||
"@polkadot/hw-ledger-transports": "6.0.3",
|
||||
"@polkadot/util": "^6.0.3",
|
||||
"@zondax/ledger-polkadot": "^0.13.4"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
// Copyright 2017-2021 @polkadot/hw-ledger authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { packageInfo as transportInfo } from '@polkadot/hw-ledger-transports/packageInfo';
|
||||
import { detectPackage, packageInfo as utilInfo } from '@polkadot/util';
|
||||
|
||||
import { packageInfo } from './packageInfo';
|
||||
|
||||
detectPackage(packageInfo, typeof __dirname !== 'undefined' && __dirname, [transportInfo, utilInfo]);
|
||||
@@ -0,0 +1,122 @@
|
||||
// Copyright 2017-2021 @polkadot/hw-ledger authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import './detectPackage';
|
||||
|
||||
import type Transport from '@ledgerhq/hw-transport';
|
||||
import type { AccountOptions, LedgerAddress, LedgerSignature, LedgerTypes, LedgerVersion } from './types';
|
||||
|
||||
import { newDockApp, newKusamaApp, newPolkadotApp, newPolymeshApp, ResponseBase, SubstrateApp } from '@zondax/ledger-polkadot';
|
||||
|
||||
import { transports } from '@polkadot/hw-ledger-transports';
|
||||
import { assert, u8aToBuffer } from '@polkadot/util';
|
||||
|
||||
export { packageInfo } from './packageInfo';
|
||||
|
||||
export const LEDGER_DEFAULT_ACCOUNT = 0x80000000;
|
||||
|
||||
export const LEDGER_DEFAULT_CHANGE = 0x80000000;
|
||||
|
||||
export const LEDGER_DEFAULT_INDEX = 0x80000000;
|
||||
|
||||
const SUCCESS_CODE = 0x9000;
|
||||
|
||||
// These match up with the network keys in the @polkadot/networks package
|
||||
// (which is turn aligns with the substrate/ss58-registry.json as the single
|
||||
// source of truth)
|
||||
const APPS: Record<string, (transport: Transport) => SubstrateApp> = {
|
||||
dock: newDockApp,
|
||||
kusama: newKusamaApp,
|
||||
polkadot: newPolkadotApp,
|
||||
polymesh: newPolymeshApp
|
||||
};
|
||||
|
||||
type Chain = keyof typeof APPS;
|
||||
|
||||
// A very basic wrapper for a ledger app -
|
||||
// - it connects automatically, creating an app as required
|
||||
// - Promises return errors (instead of wrapper errors)
|
||||
export class Ledger {
|
||||
#app: SubstrateApp | null = null;
|
||||
|
||||
#chain: Chain;
|
||||
|
||||
#transport: LedgerTypes;
|
||||
|
||||
constructor (transport: LedgerTypes, chain: Chain) {
|
||||
// u2f is deprecated
|
||||
assert(['hid', 'webusb'].includes(transport), `Unsupported transport ${transport}`);
|
||||
assert(Object.keys(APPS).includes(chain), `Unsupported chain ${chain}`);
|
||||
|
||||
this.#chain = chain;
|
||||
this.#transport = transport;
|
||||
}
|
||||
|
||||
public async getAddress (confirm = false, accountOffset = 0, addressOffset = 0, { account = LEDGER_DEFAULT_ACCOUNT, addressIndex = LEDGER_DEFAULT_INDEX, change = LEDGER_DEFAULT_CHANGE }: Partial<AccountOptions> = {}): Promise<LedgerAddress> {
|
||||
return this.#withApp(async (app: SubstrateApp): Promise<LedgerAddress> => {
|
||||
const { address, pubKey } = await this.#wrapError(app.getAddress(account + accountOffset, change, addressIndex + addressOffset, confirm));
|
||||
|
||||
return {
|
||||
address,
|
||||
publicKey: `0x${pubKey}`
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
public async getVersion (): Promise<LedgerVersion> {
|
||||
return this.#withApp(async (app: SubstrateApp): Promise<LedgerVersion> => {
|
||||
const { device_locked: isLocked, major, minor, patch, test_mode: isTestMode } = await this.#wrapError(app.getVersion());
|
||||
|
||||
return {
|
||||
isLocked,
|
||||
isTestMode,
|
||||
version: [major, minor, patch]
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
public async sign (message: Uint8Array, accountOffset = 0, addressOffset = 0, { account = LEDGER_DEFAULT_ACCOUNT, addressIndex = LEDGER_DEFAULT_INDEX, change = LEDGER_DEFAULT_CHANGE }: Partial<AccountOptions> = {}): Promise<LedgerSignature> {
|
||||
return this.#withApp(async (app: SubstrateApp): Promise<LedgerSignature> => {
|
||||
const buffer = u8aToBuffer(message);
|
||||
const { signature } = await this.#wrapError(app.sign(account + accountOffset, change, addressIndex + addressOffset, buffer));
|
||||
|
||||
return {
|
||||
signature: `0x${signature.toString('hex')}`
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
#getApp = async (): Promise<SubstrateApp> => {
|
||||
if (!this.#app) {
|
||||
const def = transports.find(({ type }) => type === this.#transport);
|
||||
|
||||
assert(def, `Unable to find a transport for ${this.#transport}`);
|
||||
|
||||
const transport = await def.create();
|
||||
|
||||
this.#app = APPS[this.#chain](transport);
|
||||
}
|
||||
|
||||
return this.#app;
|
||||
};
|
||||
|
||||
#withApp = async <T> (fn: (app: SubstrateApp) => Promise<T>): Promise<T> => {
|
||||
try {
|
||||
const app = await this.#getApp();
|
||||
|
||||
return await fn(app);
|
||||
} catch (error) {
|
||||
this.#app = null;
|
||||
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
#wrapError = async <T extends ResponseBase> (promise: Promise<T>): Promise<T> => {
|
||||
const result = await promise;
|
||||
|
||||
assert(result.return_code === SUCCESS_CODE, result.error_message);
|
||||
|
||||
return result;
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
// Copyright 2017-2021 @polkadot/hw-ledger authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Auto-generated by @polkadot/dev, do not edit
|
||||
|
||||
export const packageInfo = { name: '@polkadot/hw-ledger', version: '6.0.3' };
|
||||
@@ -0,0 +1,25 @@
|
||||
// Copyright 2017-2021 @polkadot/hw-ledger authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
export type LedgerTypes = 'hid' | 'u2f' | 'webusb';
|
||||
|
||||
export interface AccountOptions {
|
||||
account: number;
|
||||
addressIndex: number;
|
||||
change: number;
|
||||
}
|
||||
|
||||
export interface LedgerAddress {
|
||||
address: string;
|
||||
publicKey: string;
|
||||
}
|
||||
|
||||
export interface LedgerSignature {
|
||||
signature: string;
|
||||
}
|
||||
|
||||
export interface LedgerVersion {
|
||||
isLocked: boolean;
|
||||
isTestMode: boolean;
|
||||
version: [number, number, number];
|
||||
}
|
||||
@@ -15,7 +15,3 @@ Classes and Functions can be imported as follows:
|
||||
```js
|
||||
import Keyring from '@polkadot/keyring';
|
||||
```
|
||||
|
||||
## Utilities
|
||||
|
||||
[Utilities](SUMMARY.md)
|
||||
|
||||
@@ -1,34 +1,27 @@
|
||||
{
|
||||
"name": "@polkadot/keyring",
|
||||
"version": "1.2.1",
|
||||
"version": "6.0.3",
|
||||
"type": "module",
|
||||
"description": "Keyring management",
|
||||
"main": "index.js",
|
||||
"publishConfig": {
|
||||
"access": "public",
|
||||
"registry": "https://registry.npmjs.org"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/polkadot-js/common.git"
|
||||
},
|
||||
"keywords": [
|
||||
"Polkadot",
|
||||
"Keyring",
|
||||
"ed25519"
|
||||
],
|
||||
"author": "Jaco Greeff <jacogr@gmail.com>",
|
||||
"maintainers": [
|
||||
"Jaco Greeff <jacogr@gmail.com>"
|
||||
],
|
||||
"maintainers": [],
|
||||
"contributors": [],
|
||||
"license": "Apache-2.0",
|
||||
"bugs": {
|
||||
"url": "https://github.com/polkadot-js/common/issues"
|
||||
},
|
||||
"main": "index.js",
|
||||
"sideEffects": [
|
||||
"./detectPackage.js",
|
||||
"./detectPackage.cjs"
|
||||
],
|
||||
"repository": "github:polkadot-js/common",
|
||||
"bugs": "https://github.com/polkadot-js/common/issues",
|
||||
"homepage": "https://github.com/polkadot-js/common/tree/master/packages/keyring#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.5.5",
|
||||
"@polkadot/util": "^1.2.1",
|
||||
"@polkadot/util-crypto": "^1.2.1"
|
||||
"@babel/runtime": "^7.13.9",
|
||||
"@polkadot/util": "6.0.3",
|
||||
"@polkadot/util-crypto": "6.0.3"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@polkadot/util": "6.0.3",
|
||||
"@polkadot/util-crypto": "6.0.3"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +1,8 @@
|
||||
// Copyright 2017-2019 @polkadot/keyring authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
// Copyright 2017-2021 @polkadot/keyring authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// default substrate dev phrase
|
||||
const DEV_PHRASE = 'bottom drive obey lake curtain smoke basket hold race lonely fit walk';
|
||||
export const DEV_PHRASE = 'bottom drive obey lake curtain smoke basket hold race lonely fit walk';
|
||||
|
||||
// seed from the above phrase
|
||||
const DEV_SEED = '0xfac7959dbfe72f052e5a0c3c8d6530f202b02fd8f9f5ca3580ec8deb7797479e';
|
||||
|
||||
export {
|
||||
DEV_PHRASE,
|
||||
DEV_SEED
|
||||
};
|
||||
export const DEV_SEED = '0xfac7959dbfe72f052e5a0c3c8d6530f202b02fd8f9f5ca3580ec8deb7797479e';
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
// Copyright 2017-2021 @polkadot/keyring authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { detectPackage, packageInfo as utilInfo } from '@polkadot/util';
|
||||
import { packageInfo as cryptoInfo } from '@polkadot/util-crypto/packageInfo';
|
||||
|
||||
import { packageInfo } from './packageInfo';
|
||||
|
||||
detectPackage(packageInfo, typeof __dirname !== 'undefined' && __dirname, [utilInfo, cryptoInfo]);
|
||||
@@ -1,10 +1,12 @@
|
||||
// Copyright 2017-2019 @polkadot/keyring authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
// Copyright 2017-2021 @polkadot/keyring authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { KeyringPair$Json } from './types';
|
||||
|
||||
import { hexToU8a, stringToU8a } from '@polkadot/util';
|
||||
import { cryptoWaitReady, setAddressPrefix } from '@polkadot/util-crypto';
|
||||
import { base64Decode, cryptoWaitReady, encodeAddress, randomAsU8a, setSS58Format } from '@polkadot/util-crypto';
|
||||
|
||||
import { decodePair } from './pair/decode';
|
||||
import Keyring from '.';
|
||||
|
||||
describe('keypair', (): void => {
|
||||
@@ -17,53 +19,61 @@ describe('keypair', (): void => {
|
||||
const publicKeyTwo = new Uint8Array([215, 90, 152, 1, 130, 177, 10, 183, 213, 75, 254, 211, 201, 100, 7, 58, 14, 225, 114, 243, 218, 166, 35, 37, 175, 2, 26, 104, 247, 7, 81, 26]);
|
||||
const seedOne = stringToU8a('12345678901234567890123456789012');
|
||||
const seedTwo = hexToU8a('0x9d61b19deffd5a60ba844af492ec2cc44449c5697b326919703bac031cae7f60');
|
||||
let keypair: Keyring;
|
||||
let keyring: Keyring;
|
||||
|
||||
beforeEach((): void => {
|
||||
keypair = new Keyring({ type: 'ed25519' });
|
||||
keyring = new Keyring({ ss58Format: 42, type: 'ed25519' });
|
||||
|
||||
keypair.addFromSeed(seedOne, {});
|
||||
keyring.addFromSeed(seedOne, {});
|
||||
});
|
||||
|
||||
it('adds the pair', (): void => {
|
||||
expect(
|
||||
keypair.addFromSeed(seedTwo, {}).publicKey
|
||||
keyring.addFromSeed(seedTwo, {}).publicKey
|
||||
).toEqual(publicKeyTwo);
|
||||
});
|
||||
|
||||
it('creates via a dev seed', (): void => {
|
||||
expect(
|
||||
keyring.addFromUri('//Alice').address
|
||||
).toEqual('5FA9nQDVg267DEd8m1ZypXLBnvN7SFxYwV7ndqSYGiN9TTpu');
|
||||
});
|
||||
|
||||
it('creates a ed25519 pair via mnemonicToSeed', (): void => {
|
||||
expect(
|
||||
keypair.addFromUri(
|
||||
keyring.addFromUri(
|
||||
'seed sock milk update focus rotate barely fade car face mechanic mercy'
|
||||
).address
|
||||
).toEqual('5DkQP32jP4DVJLWWBRBoZF2tpWjqFrcrTBo6H5NcSk7MxKCC');
|
||||
});
|
||||
|
||||
it('adds from a mnemonic', (): void => {
|
||||
setAddressPrefix(68);
|
||||
it('adds from a mnemonic, with correct ss58', (): void => {
|
||||
setSS58Format(20); // this would not be used
|
||||
keyring.setSS58Format(2); // this would be used
|
||||
|
||||
expect(
|
||||
keypair.addFromMnemonic('moral movie very draw assault whisper awful rebuild speed purity repeat card', {}).address
|
||||
).toEqual('7sPsxWPE5DzAyPT3VuoJYw5NTGscx9QYN9oddQx4kALKC3hH');
|
||||
const pair = keyring.addFromMnemonic('moral movie very draw assault whisper awful rebuild speed purity repeat card', {});
|
||||
|
||||
expect(pair.address).toEqual('HSLu2eci2GCfWkRimjjdTXKoFSDL3rBv5Ey2JWCBj68cVZj');
|
||||
expect(encodeAddress(pair.publicKey)).toEqual('35cDYtPsdG1HUa2n2MaARgJyRz1WKMBZK1DL6c5cX7nugQh1');
|
||||
});
|
||||
|
||||
it('allows publicKeys retrieval', (): void => {
|
||||
keypair.addFromSeed(seedTwo, {});
|
||||
keyring.addFromSeed(seedTwo, {});
|
||||
|
||||
expect(
|
||||
keypair.getPublicKeys()
|
||||
keyring.getPublicKeys()
|
||||
).toEqual([publicKeyOne, publicKeyTwo]);
|
||||
});
|
||||
|
||||
it('allows retrieval of a specific item', (): void => {
|
||||
expect(
|
||||
keypair.getPair(publicKeyOne).publicKey
|
||||
keyring.getPair(publicKeyOne).publicKey
|
||||
).toEqual(publicKeyOne);
|
||||
});
|
||||
|
||||
it('allows adding from JSON', (): void => {
|
||||
expect(
|
||||
keypair.addFromJson(
|
||||
keyring.addFromJson(
|
||||
JSON.parse('{"address":"5GoKvZWG5ZPYL1WUovuHW3zJBWBP5eT8CbqjdRY4Q6iMaQua","encoded":"0xb4a14995d25ab609f3686e9fa45f1fb237cd833f33f00d4b12c51858ca070d96972e47d73aae5eeb0fc06f923826cf0943fdb02c2c2ee30ef52a7912663053940d1da4da66b3a3f520ae07422c1c94b2d95690fca9d1f4a997623bb2923a8833280e19e7f72c3c5cfa343974e60e2b3dc53b404fdaf330756daad5e4e3","encoding":{"content":"pkcs8","type":"xsalsa20-poly1305","version":"0"},"meta":{"isTesting":true,"name":"alice"}}')
|
||||
).publicKey
|
||||
).toEqual(
|
||||
@@ -73,10 +83,22 @@ describe('keypair', (): void => {
|
||||
|
||||
it('signs and verifies', (): void => {
|
||||
const MESSAGE = stringToU8a('this is a message');
|
||||
const pair = keypair.getPair(publicKeyOne);
|
||||
const pair = keyring.getPair(publicKeyOne);
|
||||
const signature = pair.sign(MESSAGE);
|
||||
|
||||
expect(pair.verify(MESSAGE, signature)).toBe(true);
|
||||
expect(pair.verify(MESSAGE, signature, pair.publicKey)).toBe(true);
|
||||
expect(pair.verify(MESSAGE, signature, randomAsU8a())).toBe(false);
|
||||
expect(pair.verify(new Uint8Array(), signature, pair.publicKey)).toBe(false);
|
||||
});
|
||||
|
||||
it('signs and verifies (withType)', (): void => {
|
||||
const MESSAGE = stringToU8a('this is a message');
|
||||
const pair = keyring.getPair(publicKeyOne);
|
||||
const signature = pair.sign(MESSAGE, { withType: true });
|
||||
|
||||
expect(pair.verify(MESSAGE, signature, pair.publicKey)).toBe(true);
|
||||
expect(pair.verify(MESSAGE, signature, randomAsU8a())).toBe(false);
|
||||
expect(pair.verify(new Uint8Array(), signature, pair.publicKey)).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -85,51 +107,51 @@ describe('keypair', (): void => {
|
||||
const publicKeyTwo = hexToU8a('0x44a996beb1eef7bdcab976ab6d2ca26104834164ecf28fb375600576fcc6eb0f');
|
||||
const seedOne = stringToU8a('12345678901234567890123456789012');
|
||||
const seedTwo = hexToU8a('0x9d61b19deffd5a60ba844af492ec2cc44449c5697b326919703bac031cae7f60');
|
||||
let keypair: Keyring;
|
||||
let keyring: Keyring;
|
||||
|
||||
beforeEach((): void => {
|
||||
keypair = new Keyring({ type: 'sr25519' });
|
||||
keyring = new Keyring({ ss58Format: 42, type: 'sr25519' });
|
||||
|
||||
keypair.addFromSeed(seedOne, {});
|
||||
keyring.addFromSeed(seedOne, {});
|
||||
});
|
||||
|
||||
it('creates with dev phrase when only path specified', (): void => {
|
||||
expect(
|
||||
keypair.createFromUri('//Alice').address
|
||||
keyring.createFromUri('//Alice').address
|
||||
).toEqual('5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY');
|
||||
});
|
||||
|
||||
it('adds the pair', (): void => {
|
||||
expect(
|
||||
keypair.addFromSeed(seedTwo, {}).publicKey
|
||||
keyring.addFromSeed(seedTwo, {}).publicKey
|
||||
).toEqual(publicKeyTwo);
|
||||
});
|
||||
|
||||
it('adds from a mnemonic', (): void => {
|
||||
setAddressPrefix(68);
|
||||
keyring.setSS58Format(2);
|
||||
|
||||
expect(
|
||||
keypair.addFromMnemonic('moral movie very draw assault whisper awful rebuild speed purity repeat card', {}).address
|
||||
).toEqual('7qQGarA4PWjPPVHG4USn1yuuVZvEHN7XZz8o7EbAp48jayZQ');
|
||||
keyring.addFromMnemonic('moral movie very draw assault whisper awful rebuild speed purity repeat card', {}).address
|
||||
).toEqual('FSjXNRT2K1R5caeHLPD6WMrqYUpfGZB7ua8W89JFctZ1YqV');
|
||||
});
|
||||
|
||||
it('allows publicKeys retrieval', (): void => {
|
||||
keypair.addFromSeed(seedTwo, {});
|
||||
keyring.addFromSeed(seedTwo, {});
|
||||
|
||||
expect(
|
||||
keypair.getPublicKeys()
|
||||
keyring.getPublicKeys()
|
||||
).toEqual([publicKeyOne, publicKeyTwo]);
|
||||
});
|
||||
|
||||
it('allows retrieval of a specific item', (): void => {
|
||||
expect(
|
||||
keypair.getPair(publicKeyOne).publicKey
|
||||
keyring.getPair(publicKeyOne).publicKey
|
||||
).toEqual(publicKeyOne);
|
||||
});
|
||||
|
||||
it('allows adding from JSON', (): void => {
|
||||
expect(
|
||||
keypair.addFromJson(
|
||||
keyring.addFromJson(
|
||||
JSON.parse('{"address":"5GoKvZWG5ZPYL1WUovuHW3zJBWBP5eT8CbqjdRY4Q6iMaQua","encoded":"0xb4a14995d25ab609f3686e9fa45f1fb237cd833f33f00d4b12c51858ca070d96972e47d73aae5eeb0fc06f923826cf0943fdb02c2c2ee30ef52a7912663053940d1da4da66b3a3f520ae07422c1c94b2d95690fca9d1f4a997623bb2923a8833280e19e7f72c3c5cfa343974e60e2b3dc53b404fdaf330756daad5e4e3","encoding":{"content":"pkcs8","type":"xsalsa20-poly1305","version":"0"},"meta":{"isTesting":true,"name":"alice"}}')
|
||||
).publicKey
|
||||
).toEqual(
|
||||
@@ -139,10 +161,387 @@ describe('keypair', (): void => {
|
||||
|
||||
it('signs and verifies', (): void => {
|
||||
const MESSAGE = stringToU8a('this is a message');
|
||||
const pair = keypair.getPair(publicKeyOne);
|
||||
const pair = keyring.getPair(publicKeyOne);
|
||||
const signature = pair.sign(MESSAGE);
|
||||
|
||||
expect(pair.verify(MESSAGE, signature)).toBe(true);
|
||||
expect(pair.verify(MESSAGE, signature, pair.publicKey)).toBe(true);
|
||||
expect(pair.verify(MESSAGE, signature, randomAsU8a())).toBe(false);
|
||||
expect(pair.verify(new Uint8Array(), signature, pair.publicKey)).toBe(false);
|
||||
});
|
||||
|
||||
it('signs and verifies (withType)', (): void => {
|
||||
const MESSAGE = stringToU8a('this is a message');
|
||||
const pair = keyring.getPair(publicKeyOne);
|
||||
const signature = pair.sign(MESSAGE, { withType: true });
|
||||
|
||||
expect(pair.verify(MESSAGE, signature, pair.publicKey)).toBe(true);
|
||||
expect(pair.verify(MESSAGE, signature, randomAsU8a())).toBe(false);
|
||||
expect(pair.verify(new Uint8Array(), signature, pair.publicKey)).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('ecdsa', (): void => {
|
||||
const seedOne = 'potato act energy ahead stone taxi receive fame gossip equip chest round';
|
||||
const seedTwo = hexToU8a('0x3c74be003bd9a876be439949ccf2b292bd966c94959a689173b295b326cd6da7');
|
||||
const publicKeyOne = hexToU8a('0x02c6b6c664db5ef505477bba1cf2f1789c98796b9bb5fa21abd0ac4589bed980e7');
|
||||
const publicKeyTwo = hexToU8a('0x021da683b913fb28c979ba3e5f1881415cef4b1f58a5d05ed3610a2995e7b4943c');
|
||||
const addressKeyOne = hexToU8a('0x0cfd0dd2c59a9987b9848919163931b6a42283ffd3d91e92c98b522525a7038f');
|
||||
let keyring: Keyring;
|
||||
|
||||
beforeEach((): void => {
|
||||
keyring = new Keyring({ ss58Format: 42, type: 'ecdsa' });
|
||||
|
||||
keyring.addFromMnemonic(seedOne, {});
|
||||
});
|
||||
|
||||
it('creates with dev phrase when only path specified', (): void => {
|
||||
expect(
|
||||
keyring.createFromUri('//Alice').address
|
||||
).toEqual('5C7C2Z5sWbytvHpuLTvzKunnnRwQxft1jiqrLD5rhucQ5S9X');
|
||||
});
|
||||
|
||||
it('adds the pair', (): void => {
|
||||
expect(
|
||||
keyring.addFromSeed(seedTwo, {}).publicKey
|
||||
).toEqual(publicKeyTwo);
|
||||
});
|
||||
|
||||
it('adds from a mnemonic', (): void => {
|
||||
keyring.setSS58Format(2);
|
||||
|
||||
expect(
|
||||
keyring.addFromMnemonic('moral movie very draw assault whisper awful rebuild speed purity repeat card').address
|
||||
).toEqual('DrRE1KAcs4pCicX8yJPh7YxkLPQ2vXnCFSVRPQfx38KjEFe');
|
||||
});
|
||||
|
||||
it('allows publicKeys retrieval', (): void => {
|
||||
keyring.addFromSeed(seedTwo, {});
|
||||
|
||||
expect(
|
||||
keyring.getPublicKeys()
|
||||
).toEqual([publicKeyOne, publicKeyTwo]);
|
||||
});
|
||||
|
||||
it('allows retrieval of a specific item', (): void => {
|
||||
expect(
|
||||
keyring.getPair(addressKeyOne).publicKey
|
||||
).toEqual(publicKeyOne);
|
||||
});
|
||||
|
||||
it('allows adding from JSON', (): void => {
|
||||
expect(
|
||||
keyring.addFromJson(
|
||||
JSON.parse('{"address":"5DzMsaYFhmpRdErWrP6K6PD7UXzYoeETToSBUrZSvxasqWRz","encoded":"0xa192d39b42bc1601bf61df31039a554228593fadf870bc837b658a5114627aca199fff596260c95fe8994c66a47636cf0270aa08f402ba5541038753960d00e6c3af5e239ec58fb1eef3db7d6bc266f4853bdfe4ed17122d9092d879014d53980d2ee57f6f55a88c38836447d8645008e8815379626addc8f81f80cd49a2","encoding":{"content":"pkcs8","type":"xsalsa20-poly1305","version":"2"},"meta":{}}')
|
||||
).address
|
||||
).toEqual('5DzMsaYFhmpRdErWrP6K6PD7UXzYoeETToSBUrZSvxasqWRz');
|
||||
});
|
||||
|
||||
it('allows creation from JSON', (): void => {
|
||||
keyring.setSS58Format(2);
|
||||
const pair = keyring.createFromJson(
|
||||
JSON.parse('{"address":"0x02fde629668eb2bcc7d748f40a7e597f7c7b363498ff3db31f03ce4854937883ad","encoded":"qIhAhKqtf2iyEoWEr8nmBdksSI8EHHCpgJHToqd6Pl8AgAAAAQAAAAgAAADDZ//fj/BRRj+0+bl1KAlYgoPJp6nEUwiw0fVqO2BW4mjEgQ+iWwJEgDf1JUtecbzOlfhTXBzqX/dIYzLgUADrF4EFEPpboCWiU1iN7W/3DM1cOTRVvTGcbdIqW//z3axhz961qzeJVUIFgllwGe/euLUPIlKbIkiN/CsRYdQ=","encoding":{"content":["pkcs8","ecdsa"],"type":["scrypt","xsalsa20-poly1305"],"version":"3"},"meta":{"genesisHash":"0xb0a8d493285c2df73290dfb7e61f870f17b41801197a149ca93654499ea3dafe","name":"ecdsa","tags":[],"whenCreated":1600925898271}}')
|
||||
);
|
||||
|
||||
expect(pair.address).toEqual('DHL8HKFuTTR55JzzLmkJRCAfPBbuevKaT9cXikxbEV97Ko8');
|
||||
expect(pair.publicKey).toEqual(hexToU8a('0x02fde629668eb2bcc7d748f40a7e597f7c7b363498ff3db31f03ce4854937883ad'));
|
||||
});
|
||||
|
||||
it('fails toJson() when password is incorrect', (): void => {
|
||||
const pair = keyring.createFromJson(
|
||||
JSON.parse('{"address":"0x02fde629668eb2bcc7d748f40a7e597f7c7b363498ff3db31f03ce4854937883ad","encoded":"qIhAhKqtf2iyEoWEr8nmBdksSI8EHHCpgJHToqd6Pl8AgAAAAQAAAAgAAADDZ//fj/BRRj+0+bl1KAlYgoPJp6nEUwiw0fVqO2BW4mjEgQ+iWwJEgDf1JUtecbzOlfhTXBzqX/dIYzLgUADrF4EFEPpboCWiU1iN7W/3DM1cOTRVvTGcbdIqW//z3axhz961qzeJVUIFgllwGe/euLUPIlKbIkiN/CsRYdQ=","encoding":{"content":["pkcs8","ecdsa"],"type":["scrypt","xsalsa20-poly1305"],"version":"3"},"meta":{"genesisHash":"0xb0a8d493285c2df73290dfb7e61f870f17b41801197a149ca93654499ea3dafe","name":"ecdsa","tags":[],"whenCreated":1600925898271}}')
|
||||
);
|
||||
|
||||
expect(
|
||||
() => pair.toJson('invalid')
|
||||
).toThrow(/Unable to decode using the supplied passphrase/);
|
||||
});
|
||||
|
||||
it('pass toJson() when password is correct', (): void => {
|
||||
const pair = keyring.createFromJson(
|
||||
JSON.parse('{"address":"0x02fde629668eb2bcc7d748f40a7e597f7c7b363498ff3db31f03ce4854937883ad","encoded":"qIhAhKqtf2iyEoWEr8nmBdksSI8EHHCpgJHToqd6Pl8AgAAAAQAAAAgAAADDZ//fj/BRRj+0+bl1KAlYgoPJp6nEUwiw0fVqO2BW4mjEgQ+iWwJEgDf1JUtecbzOlfhTXBzqX/dIYzLgUADrF4EFEPpboCWiU1iN7W/3DM1cOTRVvTGcbdIqW//z3axhz961qzeJVUIFgllwGe/euLUPIlKbIkiN/CsRYdQ=","encoding":{"content":["pkcs8","ecdsa"],"type":["scrypt","xsalsa20-poly1305"],"version":"3"},"meta":{"genesisHash":"0xb0a8d493285c2df73290dfb7e61f870f17b41801197a149ca93654499ea3dafe","name":"ecdsa","tags":[],"whenCreated":1600925898271}}')
|
||||
);
|
||||
|
||||
expect(
|
||||
() => pair.toJson('testing')
|
||||
).not.toThrow();
|
||||
});
|
||||
|
||||
it('encodes a pair toJSON (and decodes)', (): void => {
|
||||
const pair = keyring.createFromUri('moral movie very draw assault whisper awful rebuild speed purity repeat card');
|
||||
const json = pair.toJson('password');
|
||||
|
||||
expect(json.address).toEqual('0x03ddca309bd5fedd01f914d6fb76f23aa848a2a520802159215dba5085d7863619');
|
||||
expect(json.encoding).toEqual({
|
||||
content: ['pkcs8', 'ecdsa'],
|
||||
type: ['scrypt', 'xsalsa20-poly1305'],
|
||||
version: '3'
|
||||
});
|
||||
|
||||
const newPair = keyring.createFromJson(json);
|
||||
|
||||
expect(newPair.publicKey).toEqual(pair.publicKey);
|
||||
expect(
|
||||
() => newPair.unlock('password')
|
||||
).not.toThrow();
|
||||
});
|
||||
|
||||
it('signs and verifies', (): void => {
|
||||
const MESSAGE = stringToU8a('this is a message');
|
||||
const pair = keyring.getPair(addressKeyOne);
|
||||
const signature = pair.sign(MESSAGE);
|
||||
|
||||
expect(pair.verify(MESSAGE, signature, pair.publicKey)).toBe(true);
|
||||
expect(pair.verify(MESSAGE, signature, randomAsU8a())).toBe(false);
|
||||
expect(pair.verify(new Uint8Array(), signature, pair.publicKey)).toBe(false);
|
||||
});
|
||||
|
||||
it('signs and verifies (withType)', (): void => {
|
||||
const MESSAGE = stringToU8a('this is a message');
|
||||
const pair = keyring.getPair(addressKeyOne);
|
||||
const signature = pair.sign(MESSAGE, { withType: true });
|
||||
|
||||
expect(pair.verify(MESSAGE, signature, pair.publicKey)).toBe(true);
|
||||
expect(pair.verify(MESSAGE, signature, randomAsU8a())).toBe(false);
|
||||
expect(pair.verify(new Uint8Array(), signature, pair.publicKey)).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('ethereum', (): void => {
|
||||
// combine mnemonic with derivation path
|
||||
const PHRASE = 'seed sock milk update focus rotate barely fade car face mechanic mercy' + '/m/44\'/60\'/0\'/0/0';
|
||||
const PRIV_KEY_ONE = '0x070dc3117300011918e26b02176945cc15c3d548cf49fd8418d97f93af699e46';
|
||||
const ETH_ADDRESS_ONE = '0x31ea8795EE32D782C8ff41a5C68Dcbf0F5B27f6d';
|
||||
|
||||
let keyring: Keyring;
|
||||
|
||||
beforeEach((): void => {
|
||||
keyring = new Keyring({ type: 'ethereum' });
|
||||
});
|
||||
|
||||
it('creates with dev phrase from the private key', (): void => {
|
||||
const pair = keyring.addFromSeed(hexToU8a(PRIV_KEY_ONE));
|
||||
|
||||
expect(
|
||||
pair.address
|
||||
).toEqual(ETH_ADDRESS_ONE);
|
||||
});
|
||||
|
||||
it('creates with dev phrase from the private key in createFromUri', (): void => {
|
||||
const pair = keyring.createFromUri(PRIV_KEY_ONE);
|
||||
|
||||
expect(
|
||||
pair.address
|
||||
).toEqual(ETH_ADDRESS_ONE);
|
||||
});
|
||||
|
||||
it('creates with dev phrase with derivation path specified', (): void => {
|
||||
const pair = keyring.createFromUri(PHRASE);
|
||||
|
||||
expect(
|
||||
pair.address
|
||||
).toEqual(ETH_ADDRESS_ONE);
|
||||
});
|
||||
|
||||
it('creates with dev phrase with derivation path specified - addFromUri', (): void => {
|
||||
expect(
|
||||
keyring.addFromUri(PHRASE).address
|
||||
).toEqual(ETH_ADDRESS_ONE);
|
||||
});
|
||||
|
||||
it('encodes a pair toJSON (and decodes)', (): void => {
|
||||
const pair = keyring.createFromUri(PHRASE);
|
||||
const json = pair.toJson('password');
|
||||
|
||||
expect(json.address).toEqual('0x0381351b1b46d2602b0992bb5d5531f9c1696b0812feb2534b6884adc47e2e1d8b'); // this is the public key (different from address for ethereum)
|
||||
expect(json.encoding).toEqual({
|
||||
content: ['pkcs8', 'ethereum'],
|
||||
type: ['scrypt', 'xsalsa20-poly1305'],
|
||||
version: '3'
|
||||
});
|
||||
|
||||
const newPair = keyring.createFromJson(json);
|
||||
|
||||
expect(newPair.publicKey).toEqual(pair.publicKey);
|
||||
expect(
|
||||
() => newPair.unlock('password')
|
||||
).not.toThrow();
|
||||
});
|
||||
|
||||
it('encodes a pair toJSON and back', (): void => {
|
||||
const pairOriginal = keyring.createFromUri(PHRASE);
|
||||
const json = pairOriginal.toJson('password');
|
||||
const pair = keyring.addFromJson(
|
||||
json
|
||||
);
|
||||
|
||||
expect(pair.address).toEqual(ETH_ADDRESS_ONE);
|
||||
|
||||
pair.decodePkcs8('password');
|
||||
|
||||
expect(pair.isLocked).toBe(false);
|
||||
expect(pair.address).toBe(ETH_ADDRESS_ONE);
|
||||
});
|
||||
|
||||
it('allows adding from JSON', (): void => {
|
||||
const pair = keyring.addFromJson(
|
||||
JSON.parse('{"address":"KWCv1L3QX9LDPwY4VzvLmarEmXjVJidUzZcinvVnmxAJJCBou","encoded":"U8qFEaghhmNV2PgFhjqzmhyUy37Ok7abfFU2MNsBd0sAgAAAAQAAAAgAAAA3+NniKogzNphiMNueB1X0sGA07B6CaXWfpXPx45iSXoTTprwzU5mOoSqUWO0GKHROI72LN+uJ8Yfv6Ll6JOOV3VPKfoVoFmYm+zDrrMPa0gk5E5kUuSijxADcE6zUrliPVr0Ix/qaghu5SJ7RtWDQLBf4Hp86SJ8Gg6gTSSk=","encoding":{"content":["pkcs8","ethereum"],"type":["scrypt","xsalsa20-poly1305"],"version":"3"},"meta":{}}')
|
||||
);
|
||||
|
||||
expect(pair.publicKey).toEqual(hexToU8a('0x03b9dc646dd71118e5f7fda681ad9eca36eb3ee96f344f582fbe7b5bcdebb13077'));
|
||||
expect(pair.address).toEqual('0x4119b2e6c3Cb618F4f0B93ac77f9BeeC7FF02887');
|
||||
|
||||
pair.decodePkcs8('password');
|
||||
|
||||
expect(pair.isLocked).toBe(false);
|
||||
expect(pair.publicKey).toEqual(hexToU8a('0x03b9dc646dd71118e5f7fda681ad9eca36eb3ee96f344f582fbe7b5bcdebb13077'));
|
||||
expect(pair.address).toBe('0x4119b2e6c3Cb618F4f0B93ac77f9BeeC7FF02887');
|
||||
});
|
||||
|
||||
it('allows for signing/verification', (): void => {
|
||||
const MESSAGE = stringToU8a('just some test message');
|
||||
const signer = keyring.createFromUri(PHRASE);
|
||||
const verifier = keyring.addFromJson(
|
||||
JSON.parse('{"address":"KWCv1L3QX9LDPwY4VzvLmarEmXjVJidUzZcinvVnmxAJJCBou","encoded":"U8qFEaghhmNV2PgFhjqzmhyUy37Ok7abfFU2MNsBd0sAgAAAAQAAAAgAAAA3+NniKogzNphiMNueB1X0sGA07B6CaXWfpXPx45iSXoTTprwzU5mOoSqUWO0GKHROI72LN+uJ8Yfv6Ll6JOOV3VPKfoVoFmYm+zDrrMPa0gk5E5kUuSijxADcE6zUrliPVr0Ix/qaghu5SJ7RtWDQLBf4Hp86SJ8Gg6gTSSk=","encoding":{"content":["pkcs8","ethereum"],"type":["scrypt","xsalsa20-poly1305"],"version":"3"},"meta":{}}')
|
||||
);
|
||||
|
||||
const signature = signer.sign(MESSAGE);
|
||||
const dummyPublic = verifier.publicKey.slice();
|
||||
|
||||
dummyPublic[dummyPublic.length - 1] = 0;
|
||||
|
||||
expect(verifier.verify(MESSAGE, signature, signer.publicKey)).toBe(true);
|
||||
expect(verifier.verify(MESSAGE, signature, dummyPublic)).toBe(false);
|
||||
expect(verifier.verify(new Uint8Array(), signature, signer.publicKey)).toBe(false);
|
||||
});
|
||||
|
||||
it('allows for signing/verification (withType)', (): void => {
|
||||
const MESSAGE = stringToU8a('just some test message');
|
||||
const signer = keyring.createFromUri(PHRASE);
|
||||
const verifier = keyring.addFromJson(
|
||||
JSON.parse('{"address":"KWCv1L3QX9LDPwY4VzvLmarEmXjVJidUzZcinvVnmxAJJCBou","encoded":"U8qFEaghhmNV2PgFhjqzmhyUy37Ok7abfFU2MNsBd0sAgAAAAQAAAAgAAAA3+NniKogzNphiMNueB1X0sGA07B6CaXWfpXPx45iSXoTTprwzU5mOoSqUWO0GKHROI72LN+uJ8Yfv6Ll6JOOV3VPKfoVoFmYm+zDrrMPa0gk5E5kUuSijxADcE6zUrliPVr0Ix/qaghu5SJ7RtWDQLBf4Hp86SJ8Gg6gTSSk=","encoding":{"content":["pkcs8","ethereum"],"type":["scrypt","xsalsa20-poly1305"],"version":"3"},"meta":{}}')
|
||||
);
|
||||
|
||||
const signature = signer.sign(MESSAGE, { withType: true });
|
||||
const dummyPublic = verifier.publicKey.slice();
|
||||
|
||||
dummyPublic[dummyPublic.length - 1] = 0;
|
||||
|
||||
expect(verifier.verify(MESSAGE, signature, signer.publicKey)).toBe(true);
|
||||
expect(verifier.verify(MESSAGE, signature, dummyPublic)).toBe(false);
|
||||
expect(verifier.verify(new Uint8Array(), signature, signer.publicKey)).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('raw pair add/create', (): void => {
|
||||
const json = JSON.parse('{"address":"5PjeoaQzCoYbSi42aQRKB3Sx18StCaEAzCbGEEbWbZyfKS3H","encoded":"JQUl8ZpoXv2OMkL9TPylLmcIye2cYhaS9INICbFgZTsAgAAAAQAAAAgAAAAr/0hJOOzokIdBG71TstigLABX9D5xGD7L37ySxtjDrVRg26LL90jLQ47quT9o3bq6ppXMVL6USk7Q4p3WU66bojTFuCDyhpYRhNbUqU6s0rD3S4bhv9lG+pG9vQ4eD5PVQUvxdANmJpYuDg45nrTmsMC5AHGdFGkHW/LHnkmbFid1cvPYkdiBoef5CIEdoly512pxMupVxnJWF1NT","encoding":{"content":["pkcs8","sr25519"],"type":["scrypt","xsalsa20-poly1305"],"version":"3"},"meta":{"name":"hello"}}') as KeyringPair$Json;
|
||||
const decoded = decodePair('1', base64Decode(json.encoded), json.encoding.type);
|
||||
const keyring = new Keyring({ ss58Format: 44 });
|
||||
|
||||
it('creates a pair from a private/public combo', (): void => {
|
||||
const pair = keyring.createFromPair(decoded, json.meta, 'sr25519');
|
||||
|
||||
expect(pair.address).toEqual('5PjeoaQzCoYbSi42aQRKB3Sx18StCaEAzCbGEEbWbZyfKS3H');
|
||||
expect(pair.isLocked).toEqual(false);
|
||||
expect(pair.meta.name).toEqual('hello');
|
||||
});
|
||||
|
||||
it('adds a pair from a private/public combo', (): void => {
|
||||
keyring.addFromPair(decoded, json.meta, 'sr25519');
|
||||
|
||||
const pair = keyring.getPairs()[0];
|
||||
|
||||
expect(pair.address).toEqual('5PjeoaQzCoYbSi42aQRKB3Sx18StCaEAzCbGEEbWbZyfKS3H');
|
||||
expect(pair.isLocked).toEqual(false);
|
||||
expect(pair.meta.name).toEqual('hello');
|
||||
});
|
||||
});
|
||||
|
||||
describe('util', (): void => {
|
||||
let keyring: Keyring;
|
||||
|
||||
beforeEach((): void => {
|
||||
keyring = new Keyring({ ss58Format: 42 });
|
||||
});
|
||||
|
||||
it('can re-encode an address to Polkadot live', (): void => {
|
||||
expect(
|
||||
keyring.encodeAddress('5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY', 0)
|
||||
).toEqual('15oF4uVJwmo4TdGW7VfQxNLavjCXviqxT9S1MgbjMNHr6Sp5');
|
||||
});
|
||||
|
||||
it('can re-encode an address to keyring default', (): void => {
|
||||
expect(
|
||||
keyring.encodeAddress('15oF4uVJwmo4TdGW7VfQxNLavjCXviqxT9S1MgbjMNHr6Sp5')
|
||||
).toEqual('5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY');
|
||||
});
|
||||
});
|
||||
|
||||
describe('version 2 JSON', (): void => {
|
||||
const PAIR = '{"address":"5CczAE5AmGrZ93MeVhha3Ywam7j9dKB7cArnH7gtrXcMFJvu","encoded":"0xee8f236e2ac3217ce689692a4afc612220dc77fddaed0482f8f95136a7c3e034cccfbc495410a6e9b2439904974ed1d207abeca536ff6985ceb78edeeb3dc343e561c184c488101af8811d1331430b4ccf0e96ef507132e5132964e8564232e7100d973c5bee7b231dd0c8ad5273f3501515a422c8d7ed9d20a73c0ed17c98ee4588e54844bb73052dcad81f7a1094613d63c162fec7446c88b1fae70e","encoding":{"content":["pkcs8","sr25519"],"type":"xsalsa20-poly1305","version":"2"},"meta":{"genesisHash":"0xe143f23803ac50e8f6f8e62695d1ce9e4e1d68aa36c1cd2cfd15340213f3423e","name":"json v2","tags":[],"whenCreated":1595243159596}}';
|
||||
const PASS2 = 'versionTwo';
|
||||
const PASS3 = 'versionThree';
|
||||
let keyring: Keyring;
|
||||
|
||||
beforeEach((): void => {
|
||||
keyring = new Keyring({ ss58Format: 42 });
|
||||
});
|
||||
|
||||
it('can decode from a version 2 JSON file', (): void => {
|
||||
const pair = keyring.addFromJson(JSON.parse(PAIR));
|
||||
|
||||
pair.decodePkcs8(PASS2);
|
||||
|
||||
const json = pair.toJson(PASS3);
|
||||
|
||||
expect(pair.isLocked).toBe(false);
|
||||
expect(pair.address).toBe('5CczAE5AmGrZ93MeVhha3Ywam7j9dKB7cArnH7gtrXcMFJvu');
|
||||
expect(json.encoding).toEqual({
|
||||
content: ['pkcs8', 'sr25519'],
|
||||
type: ['scrypt', 'xsalsa20-poly1305'],
|
||||
version: '3'
|
||||
});
|
||||
|
||||
pair.decodePkcs8(PASS3);
|
||||
|
||||
expect(pair.address).toEqual('5CczAE5AmGrZ93MeVhha3Ywam7j9dKB7cArnH7gtrXcMFJvu');
|
||||
});
|
||||
});
|
||||
|
||||
describe('version 3 JSON (hex)', (): void => {
|
||||
const PAIR = '{"address":"FLiSDPCcJ6auZUGXALLj6jpahcP6adVFDBUQznPXUQ7yoqH","encoded":"0xcd238963070cc4d6806053ee1ac500c7add9c28732bb5d434a332f84a91d9be0008000000100000008000000cf630a1113941b350ddd06697e50399183162e5e9a0e893eafc7f5f4893a223dca5055706b9925b56fdb4304192143843da718e11717daf89cf4f4781f94fb443f61432f782d54280af9eec90bd3069c3cc2d957a42b7c18dc2e9497f623735518e0e49b58f8e4db2c09da3a45dbb935659d015fc94b946cba75b606a6ff7f4e823f6b049e2e6892026b49de02d6dbbd64646fe0933f537d9ea53a70be","encoding":{"content":["pkcs8","sr25519"],"type":["scrypt","xsalsa20-poly1305"],"version":"3"},"meta":{"genesisHash":"0xb0a8d493285c2df73290dfb7e61f870f17b41801197a149ca93654499ea3dafe","name":"version3","tags":[],"whenCreated":1595277797639}}';
|
||||
const PASS3 = 'version3';
|
||||
let keyring: Keyring;
|
||||
|
||||
beforeEach((): void => {
|
||||
keyring = new Keyring({ ss58Format: 2 });
|
||||
});
|
||||
|
||||
it('can decode from a version 3 JSON file', (): void => {
|
||||
const pair = keyring.addFromJson(JSON.parse(PAIR));
|
||||
|
||||
pair.decodePkcs8(PASS3);
|
||||
|
||||
expect(pair.isLocked).toBe(false);
|
||||
expect(pair.address).toBe('FLiSDPCcJ6auZUGXALLj6jpahcP6adVFDBUQznPXUQ7yoqH');
|
||||
});
|
||||
});
|
||||
|
||||
describe('version 3 JSON (base64)', (): void => {
|
||||
const PAIR = '{"address":"FLiSDPCcJ6auZUGXALLj6jpahcP6adVFDBUQznPXUQ7yoqH","encoded":"ILjSgYaGvq1zaCz/kx+aqfLaHBjLXz0Qsmr6RnkOVU4AgAAAAQAAAAgAAAB5R2hm5kgXyc0NQYFxvMU4zCdjB+ugs/ibEooqCvuudbaeKn3Ee47NkCqU1ecOJV+eeaVn4W4dRvIpj5kGmQOGsewR+MiQ/B0G9NFh7JXV0qcPlk2QMNW1/mbJrTO4miqL448BSkP7ZOhUV6HFUpMt3B9HwjiRLN8RORcFp0ID/Azs4Jl/xOpXNzbgQGIffWgCIKTxN9N1ku6tdlG4","encoding":{"content":["pkcs8","sr25519"],"type":["scrypt","xsalsa20-poly1305"],"version":"3"},"meta":{"genesisHash":"0xb0a8d493285c2df73290dfb7e61f870f17b41801197a149ca93654499ea3dafe","name":"version3","tags":[],"whenCreated":1595277797639,"whenEdited":1595278378596}}';
|
||||
const PASS3 = 'version3';
|
||||
let keyring: Keyring;
|
||||
|
||||
beforeEach((): void => {
|
||||
keyring = new Keyring({ ss58Format: 2 });
|
||||
});
|
||||
|
||||
it('can decode from a version 3 JSON file', (): void => {
|
||||
const pair = keyring.addFromJson(JSON.parse(PAIR));
|
||||
|
||||
pair.decodePkcs8(PASS3);
|
||||
|
||||
expect(pair.isLocked).toBe(false);
|
||||
expect(pair.address).toBe('FLiSDPCcJ6auZUGXALLj6jpahcP6adVFDBUQznPXUQ7yoqH');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,19 +1,14 @@
|
||||
// Copyright 2017-2019 @polkadot/keyring authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
// Copyright 2017-2021 @polkadot/keyring authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { assertSingletonPackage } from '@polkadot/util';
|
||||
import { decodeAddress, encodeAddress, setAddressPrefix } from '@polkadot/util-crypto';
|
||||
import './detectPackage';
|
||||
|
||||
import Keyring from './keyring';
|
||||
import { Keyring } from './keyring';
|
||||
|
||||
assertSingletonPackage('@polkadot/keyring');
|
||||
export { decodeAddress, encodeAddress, setSS58Format } from '@polkadot/util-crypto';
|
||||
|
||||
export { packageInfo } from './packageInfo';
|
||||
|
||||
export default Keyring;
|
||||
|
||||
export {
|
||||
Keyring,
|
||||
decodeAddress,
|
||||
encodeAddress,
|
||||
setAddressPrefix
|
||||
};
|
||||
export { Keyring };
|
||||
|
||||
+119
-58
@@ -1,16 +1,23 @@
|
||||
// Copyright 2017-2019 @polkadot/keyring authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
// Copyright 2017-2021 @polkadot/keyring authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { KeypairType } from '@polkadot/util-crypto/types';
|
||||
import { KeyringInstance, KeyringPair, KeyringPair$Json, KeyringPair$Meta, KeyringOptions } from './types';
|
||||
import type { EncryptedJsonEncoding } from '@polkadot/util-crypto/json/types';
|
||||
import type { Keypair, KeypairType } from '@polkadot/util-crypto/types';
|
||||
import type { KeyringInstance, KeyringOptions, KeyringPair, KeyringPair$Json, KeyringPair$Meta } from './types';
|
||||
|
||||
import { assert, hexToU8a, isNumber, isHex, stringToU8a } from '@polkadot/util';
|
||||
import { decodeAddress, encodeAddress, keyExtractSuri, keyFromPath, naclKeypairFromSeed as naclFromSeed, schnorrkelKeypairFromSeed as schnorrkelFromSeed, mnemonicToMiniSecret, setAddressPrefix } from '@polkadot/util-crypto';
|
||||
import { assert, hexToU8a, isHex, isUndefined, stringToU8a } from '@polkadot/util';
|
||||
import { base64Decode, decodeAddress, encodeAddress, ethereumEncode, hdEthereum, keyExtractSuri, keyFromPath, mnemonicToLegacySeed, mnemonicToMiniSecret, naclKeypairFromSeed as naclFromSeed, schnorrkelKeypairFromSeed as schnorrkelFromSeed, secp256k1KeypairFromSeed as secp256k1FromSeed } from '@polkadot/util-crypto';
|
||||
|
||||
import { DEV_PHRASE } from './defaults';
|
||||
import createPair from './pair';
|
||||
import Pairs from './pairs';
|
||||
import { createPair } from './pair';
|
||||
import { Pairs } from './pairs';
|
||||
|
||||
const keypairFromSeed = {
|
||||
ecdsa: (seed: Uint8Array): Keypair => secp256k1FromSeed(seed),
|
||||
ed25519: (seed: Uint8Array): Keypair => naclFromSeed(seed),
|
||||
ethereum: (seed: Uint8Array): Keypair => secp256k1FromSeed(seed),
|
||||
sr25519: (seed: Uint8Array): Keypair => schnorrkelFromSeed(seed)
|
||||
};
|
||||
|
||||
/**
|
||||
* # @polkadot/keyring
|
||||
@@ -28,26 +35,23 @@ import Pairs from './pairs';
|
||||
* lookup of a pair for a given account address or public key using `getPair`. JSON metadata associated with
|
||||
* an account may be obtained using `toJson` accompanied by the account passphrase.
|
||||
*/
|
||||
export default class Keyring implements KeyringInstance {
|
||||
private _pairs: Pairs;
|
||||
export class Keyring implements KeyringInstance {
|
||||
readonly #pairs: Pairs;
|
||||
|
||||
private _type: KeypairType;
|
||||
readonly #type: KeypairType;
|
||||
|
||||
#ss58?: number;
|
||||
|
||||
public decodeAddress = decodeAddress;
|
||||
|
||||
public encodeAddress = encodeAddress;
|
||||
|
||||
public setAddressPrefix = setAddressPrefix;
|
||||
|
||||
public constructor (options: KeyringOptions = {}) {
|
||||
constructor (options: KeyringOptions = {}) {
|
||||
options.type = options.type || 'ed25519';
|
||||
|
||||
assert(options && ['ed25519', 'sr25519'].includes(options.type || 'undefined'), `Expected a keyring type of either 'ed25519' or 'sr25519', found '${options.type}`);
|
||||
assert(options && ['ecdsa', 'ethereum', 'ed25519', 'sr25519'].includes(options.type || 'undefined'), `Expected a keyring type of either 'ed25519', 'sr25519', 'ethereum' or 'ecdsa', found '${options.type}`);
|
||||
|
||||
this._pairs = new Pairs();
|
||||
this._type = options.type;
|
||||
|
||||
setAddressPrefix(isNumber(options.addressPrefix) ? options.addressPrefix : 42);
|
||||
this.#pairs = new Pairs();
|
||||
this.#ss58 = options.ss58Format;
|
||||
this.#type = options.type;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -65,10 +69,10 @@ export default class Keyring implements KeyringInstance {
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Returns the type of the keyring, either ed25519 of sr25519
|
||||
* @description Returns the type of the keyring, ed25519, sr25519 or ecdsa
|
||||
*/
|
||||
public get type (): KeypairType {
|
||||
return this._type;
|
||||
return this.#type;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -76,7 +80,7 @@ export default class Keyring implements KeyringInstance {
|
||||
* @summary Stores an account, given a keyring pair, as a Key/Value (public key, pair) in Keyring Pair Dictionary
|
||||
*/
|
||||
public addPair (pair: KeyringPair): KeyringPair {
|
||||
return this._pairs.add(pair);
|
||||
return this.#pairs.add(pair);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -87,10 +91,10 @@ export default class Keyring implements KeyringInstance {
|
||||
* of an account backup), and then generates a keyring pair from them that it passes to
|
||||
* `addPair` to stores in a keyring pair dictionary the public key of the generated pair as a key and the pair as the associated value.
|
||||
*/
|
||||
public addFromAddress (address: string | Uint8Array, meta: KeyringPair$Meta = {}, encoded: Uint8Array | null = null, type: KeypairType = this.type, ignoreChecksum?: boolean): KeyringPair {
|
||||
public addFromAddress (address: string | Uint8Array, meta: KeyringPair$Meta = {}, encoded: Uint8Array | null = null, type: KeypairType = this.type, ignoreChecksum?: boolean, encType?: EncryptedJsonEncoding[]): KeyringPair {
|
||||
const publicKey = this.decodeAddress(address, ignoreChecksum);
|
||||
|
||||
return this.addPair(createPair(type, { publicKey, secretKey: new Uint8Array(64) }, meta, encoded));
|
||||
return this.addPair(createPair({ toSS58: this.encodeAddress, type }, { publicKey, secretKey: new Uint8Array() }, meta, encoded, encType));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -100,12 +104,8 @@ export default class Keyring implements KeyringInstance {
|
||||
* of an account backup), and then generates a keyring pair from it that it passes to
|
||||
* `addPair` to stores in a keyring pair dictionary the public key of the generated pair as a key and the pair as the associated value.
|
||||
*/
|
||||
public addFromJson ({ address, encoded, encoding: { content, version }, meta }: KeyringPair$Json, ignoreChecksum?: boolean): KeyringPair {
|
||||
const type = version === '0' || !Array.isArray(content)
|
||||
? this.type
|
||||
: content[1];
|
||||
|
||||
return this.addFromAddress(address, meta, hexToU8a(encoded), type, ignoreChecksum);
|
||||
public addFromJson (json: KeyringPair$Json, ignoreChecksum?: boolean): KeyringPair {
|
||||
return this.addPair(this.createFromJson(json, ignoreChecksum));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -120,6 +120,16 @@ export default class Keyring implements KeyringInstance {
|
||||
return this.addFromUri(mnemonic, meta, type);
|
||||
}
|
||||
|
||||
/**
|
||||
* @name addFromPair
|
||||
* @summary Stores an account created from an explicit publicKey/secreteKey combination
|
||||
*/
|
||||
public addFromPair (pair: Keypair, meta: KeyringPair$Meta = {}, type: KeypairType = this.type): KeyringPair {
|
||||
return this.addPair(
|
||||
this.createFromPair(pair, meta, type)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @name addFromSeed
|
||||
* @summary Stores an account, given seed data, as a Key/Value (public key, pair) in Keyring Pair Dictionary
|
||||
@@ -128,11 +138,9 @@ export default class Keyring implements KeyringInstance {
|
||||
* `addPair` to store in a keyring pair dictionary the public key of the generated pair as a key and the pair as the associated value.
|
||||
*/
|
||||
public addFromSeed (seed: Uint8Array, meta: KeyringPair$Meta = {}, type: KeypairType = this.type): KeyringPair {
|
||||
const keypair = type === 'sr25519'
|
||||
? schnorrkelFromSeed(seed)
|
||||
: naclFromSeed(seed);
|
||||
|
||||
return this.addPair(createPair(type, keypair, meta, null));
|
||||
return this.addPair(
|
||||
createPair({ toSS58: this.encodeAddress, type }, keypairFromSeed[type](seed), meta, null)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -146,9 +154,44 @@ export default class Keyring implements KeyringInstance {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @name createFromJson
|
||||
* @description Creates a pair from a JSON keyfile
|
||||
*/
|
||||
public createFromJson ({ address, encoded, encoding: { content, type, version }, meta }: KeyringPair$Json, ignoreChecksum?: boolean): KeyringPair {
|
||||
assert(version !== '3' || content[0] === 'pkcs8', () => `Unable to decode non-pkcs8 type, [${content.join(',')}] found}`);
|
||||
|
||||
const cryptoType = version === '0' || !Array.isArray(content)
|
||||
? this.type
|
||||
: content[1];
|
||||
const encType = !Array.isArray(type)
|
||||
? [type]
|
||||
: type;
|
||||
|
||||
assert(['ed25519', 'sr25519', 'ecdsa', 'ethereum'].includes(cryptoType), `Unknown crypto type ${cryptoType}`);
|
||||
|
||||
// Here the address and publicKey are 32 bytes and isomorphic. This is why the address field needs to be the public key for ethereum type pairs
|
||||
const publicKey = isHex(address)
|
||||
? hexToU8a(address)
|
||||
: this.decodeAddress(address, ignoreChecksum);
|
||||
const decoded = isHex(encoded)
|
||||
? hexToU8a(encoded)
|
||||
: base64Decode(encoded);
|
||||
|
||||
return createPair({ toSS58: this.encodeAddress, type: cryptoType as KeypairType }, { publicKey, secretKey: new Uint8Array() }, meta, decoded, encType);
|
||||
}
|
||||
|
||||
/**
|
||||
* @name createFromPair
|
||||
* @summary Creates a pair from an explicit publicKey/secreteKey combination
|
||||
*/
|
||||
public createFromPair (pair: Keypair, meta: KeyringPair$Meta = {}, type: KeypairType = this.type): KeyringPair {
|
||||
return createPair({ toSS58: this.encodeAddress, type }, pair, meta, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* @name createFromUri
|
||||
* @summry Creates a Keypair from an suri
|
||||
* @summary Creates a Keypair from an suri
|
||||
* @description This creates a pair from the suri, but does not add it to the keyring
|
||||
*/
|
||||
public createFromUri (_suri: string, meta: KeyringPair$Meta = {}, type: KeypairType = this.type): KeyringPair {
|
||||
@@ -156,21 +199,20 @@ export default class Keyring implements KeyringInstance {
|
||||
const suri = _suri.startsWith('//')
|
||||
? `${DEV_PHRASE}${_suri}`
|
||||
: _suri;
|
||||
const { password, phrase, path } = keyExtractSuri(suri);
|
||||
let seed;
|
||||
const { derivePath, password, path, phrase } = keyExtractSuri(suri);
|
||||
let seed: Uint8Array;
|
||||
const isPhraseHex = isHex(phrase, 256);
|
||||
|
||||
if (isHex(phrase, 256)) {
|
||||
if (isPhraseHex) {
|
||||
seed = hexToU8a(phrase);
|
||||
} else {
|
||||
const str = phrase as string;
|
||||
const str = phrase;
|
||||
const parts = str.split(' ');
|
||||
|
||||
if ([12, 15, 18, 21, 24].includes(parts.length)) {
|
||||
// FIXME This keeps compat with older versions, but breaks compat with subkey
|
||||
// seed = type === 'sr25519'
|
||||
// ? mnemonicToMiniSecret(phrase, password)
|
||||
// : mnemonicToSeed(phrase, password);
|
||||
seed = mnemonicToMiniSecret(phrase, password);
|
||||
seed = type === 'ethereum'
|
||||
? mnemonicToLegacySeed(phrase, '', false, 64)
|
||||
: mnemonicToMiniSecret(phrase, password);
|
||||
} else {
|
||||
assert(str.length <= 32, 'specified phrase is not a valid mnemonic and is invalid as a raw seed at > 32 bytes');
|
||||
|
||||
@@ -178,12 +220,23 @@ export default class Keyring implements KeyringInstance {
|
||||
}
|
||||
}
|
||||
|
||||
const keypair = type === 'sr25519'
|
||||
? schnorrkelFromSeed(seed)
|
||||
: naclFromSeed(seed);
|
||||
const derived = keyFromPath(keypair, path, type);
|
||||
const derived = type === 'ethereum'
|
||||
? isPhraseHex
|
||||
? keypairFromSeed[type](seed) // for eth, if the private key is provided as suri, it must be derived only once
|
||||
: hdEthereum(seed, derivePath.substring(1))
|
||||
: keyFromPath(keypairFromSeed[type](seed), path, type);
|
||||
|
||||
return createPair(type, derived, meta, null);
|
||||
return createPair({ toSS58: this.encodeAddress, type }, derived, meta, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* @name encodeAddress
|
||||
* @description Encodes the input into an ss58 representation
|
||||
*/
|
||||
public encodeAddress = (address: Uint8Array | string, ss58Format?: number): string => {
|
||||
return this.type === 'ethereum'
|
||||
? ethereumEncode(address)
|
||||
: encodeAddress(address, isUndefined(ss58Format) ? this.#ss58 : ss58Format);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -193,7 +246,7 @@ export default class Keyring implements KeyringInstance {
|
||||
* a key lookup using the provided account address or public key (after decoding it).
|
||||
*/
|
||||
public getPair (address: string | Uint8Array): KeyringPair {
|
||||
return this._pairs.get(address);
|
||||
return this.#pairs.get(address);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -202,7 +255,7 @@ export default class Keyring implements KeyringInstance {
|
||||
* @description Returns an array list of all the keyring pair values that are stored in the keyring pair dictionary.
|
||||
*/
|
||||
public getPairs (): KeyringPair[] {
|
||||
return this._pairs.all();
|
||||
return this.#pairs.all();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -211,7 +264,7 @@ export default class Keyring implements KeyringInstance {
|
||||
* @description Returns an array list of all the public keys associated with each of the keyring pair values that are stored in the keyring pair dictionary.
|
||||
*/
|
||||
public getPublicKeys (): Uint8Array[] {
|
||||
return this._pairs
|
||||
return this.#pairs
|
||||
.all()
|
||||
.map(({ publicKey }): Uint8Array =>
|
||||
publicKey
|
||||
@@ -223,7 +276,15 @@ export default class Keyring implements KeyringInstance {
|
||||
* @description Deletes the provided input address or public key from the stored Keyring Pair Dictionary.
|
||||
*/
|
||||
public removePair (address: string | Uint8Array): void {
|
||||
this._pairs.remove(address);
|
||||
this.#pairs.remove(address);
|
||||
}
|
||||
|
||||
/**
|
||||
* @name setSS58Format;
|
||||
* @description Sets the ss58 format for the keyring
|
||||
*/
|
||||
public setSS58Format (ss58: number): void {
|
||||
this.#ss58 = ss58;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -235,6 +296,6 @@ export default class Keyring implements KeyringInstance {
|
||||
* may backup their account to a JSON file that contains this information.
|
||||
*/
|
||||
public toJson (address: string | Uint8Array, passphrase?: string): KeyringPair$Json {
|
||||
return this._pairs.get(address).toJson(passphrase);
|
||||
return this.#pairs.get(address).toJson(passphrase);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
// Copyright 2017-2021 @polkadot/keyring authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Auto-generated by @polkadot/dev, do not edit
|
||||
|
||||
export const packageInfo = { name: '@polkadot/keyring', version: '6.0.3' };
|
||||
@@ -1,10 +1,9 @@
|
||||
// Copyright 2017-2019 @polkadot/keyring authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
// Copyright 2017-2021 @polkadot/keyring authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import testingPairs from '../testingPairs';
|
||||
import { createTestPairs } from '../testingPairs';
|
||||
|
||||
const keyring = testingPairs({ type: 'ed25519' }, false);
|
||||
const keyring = createTestPairs({ type: 'ed25519' }, false);
|
||||
|
||||
describe('decode', (): void => {
|
||||
it('fails when no data provided', (): void => {
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
// Copyright 2017-2019 @polkadot/keyring authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
// Copyright 2017-2021 @polkadot/keyring authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { assert, stringToU8a, u8aFixLength } from '@polkadot/util';
|
||||
import { naclDecrypt } from '@polkadot/util-crypto';
|
||||
import { PairInfo } from './types';
|
||||
import type { EncryptedJsonEncoding } from '@polkadot/util-crypto/json/types';
|
||||
import type { PairInfo } from './types';
|
||||
|
||||
import { NONCE_LENGTH, PKCS8_DIVIDER, PKCS8_HEADER, PUB_LENGTH, SEC_LENGTH, SEED_LENGTH } from './defaults';
|
||||
import { assert, isUndefined, u8aEq } from '@polkadot/util';
|
||||
import { jsonDecryptData } from '@polkadot/util-crypto';
|
||||
|
||||
import { PKCS8_DIVIDER, PKCS8_HEADER, PUB_LENGTH, SEC_LENGTH, SEED_LENGTH } from './defaults';
|
||||
|
||||
const SEED_OFFSET = PKCS8_HEADER.length;
|
||||
|
||||
@@ -14,39 +15,30 @@ type DecodeResult = PairInfo & {
|
||||
secretKey: Uint8Array;
|
||||
};
|
||||
|
||||
export default function decode (passphrase?: string, _encrypted?: Uint8Array | null): DecodeResult {
|
||||
assert(_encrypted, 'No encrypted data available to decode');
|
||||
export function decodePair (passphrase?: string, encrypted?: Uint8Array | null, _encType?: EncryptedJsonEncoding | EncryptedJsonEncoding[]): DecodeResult {
|
||||
const encType = Array.isArray(_encType) || isUndefined(_encType)
|
||||
? _encType
|
||||
: [_encType];
|
||||
const decrypted = jsonDecryptData(encrypted, passphrase, encType);
|
||||
const header = decrypted.subarray(0, PKCS8_HEADER.length);
|
||||
|
||||
const encrypted = (_encrypted as Uint8Array);
|
||||
const encoded = passphrase
|
||||
? (naclDecrypt(
|
||||
encrypted.subarray(NONCE_LENGTH),
|
||||
encrypted.subarray(0, NONCE_LENGTH),
|
||||
u8aFixLength(stringToU8a(passphrase), 256, true)
|
||||
) as Uint8Array)
|
||||
: encrypted;
|
||||
assert(u8aEq(header, PKCS8_HEADER), 'Invalid Pkcs8 header found in body');
|
||||
|
||||
assert(encoded, 'Unable to unencrypt using the supplied passphrase');
|
||||
|
||||
const header = encoded.subarray(0, PKCS8_HEADER.length);
|
||||
|
||||
assert(header.toString() === PKCS8_HEADER.toString(), 'Invalid Pkcs8 header found in body');
|
||||
|
||||
let secretKey = encoded.subarray(SEED_OFFSET, SEED_OFFSET + SEC_LENGTH);
|
||||
let secretKey = decrypted.subarray(SEED_OFFSET, SEED_OFFSET + SEC_LENGTH);
|
||||
let divOffset = SEED_OFFSET + SEC_LENGTH;
|
||||
let divider = encoded.subarray(divOffset, divOffset + PKCS8_DIVIDER.length);
|
||||
let divider = decrypted.subarray(divOffset, divOffset + PKCS8_DIVIDER.length);
|
||||
|
||||
// old-style, we have the seed here
|
||||
if (divider.toString() !== PKCS8_DIVIDER.toString()) {
|
||||
if (!u8aEq(divider, PKCS8_DIVIDER)) {
|
||||
divOffset = SEED_OFFSET + SEED_LENGTH;
|
||||
secretKey = encoded.subarray(SEED_OFFSET, divOffset);
|
||||
divider = encoded.subarray(divOffset, divOffset + PKCS8_DIVIDER.length);
|
||||
secretKey = decrypted.subarray(SEED_OFFSET, divOffset);
|
||||
divider = decrypted.subarray(divOffset, divOffset + PKCS8_DIVIDER.length);
|
||||
|
||||
assert(u8aEq(divider, PKCS8_DIVIDER), 'Invalid Pkcs8 divider found in body');
|
||||
}
|
||||
|
||||
assert(divider.toString() === PKCS8_DIVIDER.toString(), 'Invalid Pkcs8 divider found in body');
|
||||
|
||||
const pubOffset = divOffset + PKCS8_DIVIDER.length;
|
||||
const publicKey = encoded.subarray(pubOffset, pubOffset + PUB_LENGTH);
|
||||
const publicKey = decrypted.subarray(pubOffset, pubOffset + PUB_LENGTH);
|
||||
|
||||
return {
|
||||
publicKey,
|
||||
|
||||
@@ -1,19 +1,9 @@
|
||||
// Copyright 2017-2019 @polkadot/keyring authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
// Copyright 2017-2021 @polkadot/keyring authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
const NONCE_LENGTH = 24;
|
||||
const PKCS8_DIVIDER = new Uint8Array([161, 35, 3, 33, 0]);
|
||||
const PKCS8_HEADER = new Uint8Array([48, 83, 2, 1, 1, 48, 5, 6, 3, 43, 101, 112, 4, 34, 4, 32]);
|
||||
const PUB_LENGTH = 32;
|
||||
const SEC_LENGTH = 64;
|
||||
const SEED_LENGTH = 32;
|
||||
|
||||
export {
|
||||
NONCE_LENGTH,
|
||||
PKCS8_DIVIDER,
|
||||
PKCS8_HEADER,
|
||||
PUB_LENGTH,
|
||||
SEC_LENGTH,
|
||||
SEED_LENGTH
|
||||
};
|
||||
export const PKCS8_DIVIDER = new Uint8Array([161, 35, 3, 33, 0]);
|
||||
export const PKCS8_HEADER = new Uint8Array([48, 83, 2, 1, 1, 48, 5, 6, 3, 43, 101, 112, 4, 34, 4, 32]);
|
||||
export const PUB_LENGTH = 32;
|
||||
export const SALT_LENGTH = 32;
|
||||
export const SEC_LENGTH = 64;
|
||||
export const SEED_LENGTH = 32;
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
// Copyright 2017-2019 @polkadot/keyring authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
// Copyright 2017-2021 @polkadot/keyring authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import testingPairs from '../testingPairs';
|
||||
import { NONCE_LENGTH, SCRYPT_LENGTH } from '@polkadot/util-crypto/json/constants';
|
||||
|
||||
import { createTestPairs } from '../testingPairs';
|
||||
import { PKCS8_DIVIDER, PKCS8_HEADER, PUB_LENGTH, SEC_LENGTH } from './defaults';
|
||||
|
||||
const PKCS8_LENGTH = PKCS8_DIVIDER.length + PKCS8_HEADER.length + PUB_LENGTH + SEC_LENGTH;
|
||||
const ENCODED_LENGTH = 157;
|
||||
const ENCODED_LENGTH = 16 + PKCS8_LENGTH + NONCE_LENGTH + SCRYPT_LENGTH;
|
||||
|
||||
const keyring = testingPairs({ type: 'ed25519' }, false);
|
||||
const keyring = createTestPairs({ type: 'ed25519' }, false);
|
||||
|
||||
describe('encode', (): void => {
|
||||
it('returns PKCS8 when no passphrase supplied', (): void => {
|
||||
|
||||
@@ -1,20 +1,19 @@
|
||||
// Copyright 2017-2019 @polkadot/keyring authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
// Copyright 2017-2021 @polkadot/keyring authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { PairInfo } from './types';
|
||||
import type { PairInfo } from './types';
|
||||
|
||||
import { stringToU8a, u8aConcat, u8aFixLength, assert } from '@polkadot/util';
|
||||
import { naclEncrypt } from '@polkadot/util-crypto';
|
||||
import { assert, u8aConcat } from '@polkadot/util';
|
||||
import { naclEncrypt, scryptEncode, scryptToU8a } from '@polkadot/util-crypto';
|
||||
|
||||
import { PKCS8_DIVIDER, PKCS8_HEADER } from './defaults';
|
||||
|
||||
export default function encode ({ publicKey, secretKey }: PairInfo, passphrase?: string): Uint8Array {
|
||||
export function encodePair ({ publicKey, secretKey }: PairInfo, passphrase?: string): Uint8Array {
|
||||
assert(secretKey, 'Expected a valid secretKey to be passed to encode');
|
||||
|
||||
const encoded = u8aConcat(
|
||||
PKCS8_HEADER,
|
||||
secretKey as Uint8Array,
|
||||
secretKey,
|
||||
PKCS8_DIVIDER,
|
||||
publicKey
|
||||
);
|
||||
@@ -23,7 +22,8 @@ export default function encode ({ publicKey, secretKey }: PairInfo, passphrase?:
|
||||
return encoded;
|
||||
}
|
||||
|
||||
const { encrypted, nonce } = naclEncrypt(encoded, u8aFixLength(stringToU8a(passphrase), 256, true));
|
||||
const { params, password, salt } = scryptEncode(passphrase);
|
||||
const { encrypted, nonce } = naclEncrypt(encoded, password.subarray(0, 32));
|
||||
|
||||
return u8aConcat(nonce, encrypted);
|
||||
return u8aConcat(scryptToU8a(salt, params), nonce, encrypted);
|
||||
}
|
||||
|
||||
@@ -1,15 +1,20 @@
|
||||
// Copyright 2017-2019 @polkadot/keyring authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
// Copyright 2017-2021 @polkadot/keyring authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { setAddressPrefix } from '@polkadot/util-crypto';
|
||||
import { hexToU8a, u8aToHex } from '@polkadot/util';
|
||||
import { cryptoWaitReady, encodeAddress as toSS58, setSS58Format } from '@polkadot/util-crypto';
|
||||
|
||||
import testingPairs from '../testingPairs';
|
||||
import createPair from '.';
|
||||
import { PAIRSSR25519 } from '../testing';
|
||||
import { createTestPairs } from '../testingPairs';
|
||||
import { createPair } from '.';
|
||||
|
||||
const keyring = testingPairs({ type: 'ed25519' }, false);
|
||||
const keyring = createTestPairs({ type: 'ed25519' }, false);
|
||||
|
||||
describe('pair', (): void => {
|
||||
beforeEach(async (): Promise<void> => {
|
||||
await cryptoWaitReady();
|
||||
});
|
||||
|
||||
const SIGNATURE = new Uint8Array([80, 191, 198, 147, 225, 207, 75, 88, 126, 39, 129, 109, 191, 38, 72, 181, 75, 254, 81, 143, 244, 79, 237, 38, 236, 141, 28, 252, 134, 26, 169, 234, 79, 33, 153, 158, 151, 34, 175, 188, 235, 20, 35, 135, 83, 120, 139, 211, 233, 130, 1, 208, 201, 215, 73, 80, 56, 98, 185, 196, 11, 8, 193, 14]);
|
||||
|
||||
it('has a publicKey', (): void => {
|
||||
@@ -18,6 +23,11 @@ describe('pair', (): void => {
|
||||
).toEqual(
|
||||
new Uint8Array([209, 114, 167, 76, 218, 76, 134, 89, 18, 195, 43, 160, 168, 10, 87, 174, 105, 171, 174, 65, 14, 92, 203, 89, 222, 232, 78, 47, 68, 50, 219, 79])
|
||||
);
|
||||
expect(
|
||||
keyring.alice.addressRaw
|
||||
).toEqual(
|
||||
new Uint8Array([209, 114, 167, 76, 218, 76, 134, 89, 18, 195, 43, 160, 168, 10, 87, 174, 105, 171, 174, 65, 14, 92, 203, 89, 222, 232, 78, 47, 68, 50, 219, 79])
|
||||
);
|
||||
});
|
||||
|
||||
it('allows signing', (): void => {
|
||||
@@ -32,20 +42,56 @@ describe('pair', (): void => {
|
||||
expect(
|
||||
keyring.alice.verify(
|
||||
new Uint8Array([0x61, 0x62, 0x63, 0x64]),
|
||||
SIGNATURE
|
||||
SIGNATURE,
|
||||
keyring.alice.publicKey
|
||||
)
|
||||
).toEqual(true);
|
||||
});
|
||||
|
||||
it('fails a correctly signed message (signer changed)', (): void => {
|
||||
expect(
|
||||
keyring.alice.verify(
|
||||
new Uint8Array([0x61, 0x62, 0x63, 0x64, 0x65]),
|
||||
SIGNATURE,
|
||||
keyring.bob.publicKey
|
||||
)
|
||||
).toEqual(false);
|
||||
});
|
||||
|
||||
it('fails a correctly signed message (message changed)', (): void => {
|
||||
expect(
|
||||
keyring.alice.verify(
|
||||
new Uint8Array([0x61, 0x62, 0x63, 0x64, 0x65]),
|
||||
SIGNATURE
|
||||
SIGNATURE,
|
||||
keyring.alice.publicKey
|
||||
)
|
||||
).toEqual(false);
|
||||
});
|
||||
|
||||
it('allows vrf sign and verify', (): void => {
|
||||
const message = new Uint8Array([0x61, 0x62, 0x63, 0x64, 0x65]);
|
||||
|
||||
expect(
|
||||
keyring.alice.vrfVerify(
|
||||
message,
|
||||
keyring.alice.vrfSign(message),
|
||||
keyring.alice.publicKey
|
||||
)
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
it('fails vrf sign and verify (publicKey changed)', (): void => {
|
||||
const message = new Uint8Array([0x61, 0x62, 0x63, 0x64, 0x65]);
|
||||
|
||||
expect(
|
||||
keyring.alice.vrfVerify(
|
||||
message,
|
||||
keyring.alice.vrfSign(message),
|
||||
keyring.bob.publicKey
|
||||
)
|
||||
).toBe(false);
|
||||
});
|
||||
|
||||
it('allows setting/getting of meta', (): void => {
|
||||
keyring.bob.setMeta({ foo: 'bar', something: 'else' });
|
||||
|
||||
@@ -57,24 +103,82 @@ describe('pair', (): void => {
|
||||
});
|
||||
|
||||
it('allows encoding of address with different prefixes', (): void => {
|
||||
expect(keyring.alice.address).toEqual(
|
||||
'5GoKvZWG5ZPYL1WUovuHW3zJBWBP5eT8CbqjdRY4Q6iMaQua'
|
||||
);
|
||||
expect(keyring.alice.address).toEqual('5GoKvZWG5ZPYL1WUovuHW3zJBWBP5eT8CbqjdRY4Q6iMaQua');
|
||||
|
||||
setAddressPrefix(68);
|
||||
setSS58Format(255);
|
||||
|
||||
expect(keyring.alice.address).toEqual(
|
||||
'7sGUeMak588SPY2YMmmuKUuLz7u2WQpf74F9dCFtSLB2td9d'
|
||||
);
|
||||
expect(keyring.alice.address).toEqual('yGHU8YKprxHbHdEv7oUK4rzMZXtsdhcXVG2CAMyC9WhzhjH2k');
|
||||
|
||||
setSS58Format(42);
|
||||
});
|
||||
|
||||
it('allows getting public key after decoding', (): void => {
|
||||
const PASS = 'testing';
|
||||
const encoded = keyring.alice.encodePkcs8(PASS);
|
||||
|
||||
const pair = createPair('sr25519', { publicKey: keyring.alice.publicKey });
|
||||
const pair = createPair({ toSS58, type: 'sr25519' }, { publicKey: keyring.alice.publicKey });
|
||||
|
||||
pair.decodePkcs8(PASS, encoded);
|
||||
|
||||
expect(pair.isLocked).toEqual(false);
|
||||
});
|
||||
|
||||
it('allows derivation on the pair', (): void => {
|
||||
const alice = createPair({ toSS58, type: 'sr25519' }, { publicKey: PAIRSSR25519[0].publicKey, secretKey: PAIRSSR25519[0].secretKey }, {});
|
||||
const stash = alice.derive('//stash');
|
||||
const soft = alice.derive('//funding/0');
|
||||
|
||||
expect(stash.publicKey).toEqual(PAIRSSR25519[1].publicKey);
|
||||
expect(soft.address).toEqual('5ECQNn7UueWHPFda5qUi4fTmTtyCnPvGnuoyVVSj5CboJh9J');
|
||||
});
|
||||
|
||||
it('fails to sign when locked', (): void => {
|
||||
const pair = createPair({ toSS58, type: 'sr25519' }, { publicKey: keyring.alice.publicKey });
|
||||
|
||||
expect(pair.isLocked).toEqual(true);
|
||||
expect((): Uint8Array =>
|
||||
pair.sign(new Uint8Array([0]))
|
||||
).toThrow('Cannot sign with a locked key pair');
|
||||
});
|
||||
|
||||
describe('ethereum', (): void => {
|
||||
const PUBLICDERIVED = new Uint8Array([
|
||||
3, 129, 53, 27, 27, 70, 210, 96,
|
||||
43, 9, 146, 187, 93, 85, 49, 249,
|
||||
193, 105, 107, 8, 18, 254, 178, 83,
|
||||
75, 104, 132, 173, 196, 126, 46, 29,
|
||||
139
|
||||
]);
|
||||
const SECRETDERIVED = new Uint8Array([
|
||||
7, 13, 195, 17, 115, 0, 1, 25,
|
||||
24, 226, 107, 2, 23, 105, 69, 204,
|
||||
21, 195, 213, 72, 207, 73, 253, 132,
|
||||
24, 217, 127, 147, 175, 105, 158, 70
|
||||
]);
|
||||
|
||||
it('has a valid address from a known public', (): void => {
|
||||
const pair = createPair({ toSS58, type: 'ethereum' }, { publicKey: hexToU8a('0x03b9dc646dd71118e5f7fda681ad9eca36eb3ee96f344f582fbe7b5bcdebb13077') });
|
||||
|
||||
expect(pair.address).toEqual('0x4119b2e6c3Cb618F4f0B93ac77f9BeeC7FF02887');
|
||||
expect(pair.addressRaw).toEqual(hexToU8a('0x4119b2e6c3Cb618F4f0B93ac77f9BeeC7FF02887'));
|
||||
});
|
||||
|
||||
it('converts to json', (): void => {
|
||||
const pair = createPair({ toSS58, type: 'ethereum' }, { publicKey: PUBLICDERIVED, secretKey: SECRETDERIVED });
|
||||
const json = pair.toJson('password');
|
||||
|
||||
expect(json.encoding).toEqual({
|
||||
content: ['pkcs8', 'ethereum'],
|
||||
type: ['scrypt', 'xsalsa20-poly1305'],
|
||||
version: '3'
|
||||
});
|
||||
expect(json.address).toEqual(u8aToHex(PUBLICDERIVED));
|
||||
});
|
||||
|
||||
it('has Gerald as test address for Ethereum type parachains', (): void => {
|
||||
const keyringEthereum = createTestPairs({ type: 'ethereum' }, false);
|
||||
|
||||
expect(keyringEthereum.Gerald.address).toEqual('0x6Be02d1d3665660d22FF9624b7BE0551ee1Ac91b');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user