@prosopo/scripts 0.1.18 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (133) hide show
  1. package/dist/cli/index.d.ts +2 -0
  2. package/dist/cli/index.d.ts.map +1 -0
  3. package/dist/cli/index.js +145 -0
  4. package/dist/cli/index.js.map +1 -0
  5. package/dist/contract/deploy/dapp.d.ts +3 -0
  6. package/dist/contract/deploy/dapp.d.ts.map +1 -0
  7. package/dist/contract/deploy/dapp.js +41 -0
  8. package/dist/contract/deploy/dapp.js.map +1 -0
  9. package/dist/contract/deploy/index.d.ts +3 -0
  10. package/dist/contract/deploy/index.d.ts.map +1 -0
  11. package/dist/contract/deploy/index.js +16 -0
  12. package/dist/contract/deploy/index.js.map +1 -0
  13. package/dist/contract/deploy/protocol.d.ts +3 -0
  14. package/dist/contract/deploy/protocol.d.ts.map +1 -0
  15. package/dist/contract/deploy/protocol.js +53 -0
  16. package/dist/contract/deploy/protocol.js.map +1 -0
  17. package/dist/contract/import.d.ts +4 -0
  18. package/dist/contract/import.d.ts.map +1 -0
  19. package/dist/contract/import.js +21 -0
  20. package/dist/contract/import.js.map +1 -0
  21. package/dist/contract/index.d.ts +3 -0
  22. package/dist/contract/index.d.ts.map +1 -0
  23. package/dist/contract/index.js +16 -0
  24. package/dist/contract/index.js.map +1 -0
  25. package/dist/index.d.ts +5 -0
  26. package/dist/index.d.ts.map +1 -0
  27. package/dist/index.js +18 -0
  28. package/dist/index.js.map +1 -0
  29. package/dist/scripts/addCopyrightNotice.d.ts +2 -0
  30. package/dist/scripts/addCopyrightNotice.d.ts.map +1 -0
  31. package/dist/scripts/addCopyrightNotice.js +104 -0
  32. package/dist/scripts/addCopyrightNotice.js.map +1 -0
  33. package/dist/scripts/bytesToHex.d.ts +2 -0
  34. package/dist/scripts/bytesToHex.d.ts.map +1 -0
  35. package/dist/scripts/bytesToHex.js +22 -0
  36. package/dist/scripts/bytesToHex.js.map +1 -0
  37. package/dist/scripts/convertAccount.d.ts +2 -0
  38. package/dist/scripts/convertAccount.d.ts.map +1 -0
  39. package/dist/scripts/convertAccount.js +38 -0
  40. package/dist/scripts/convertAccount.js.map +1 -0
  41. package/dist/scripts/encodeDecode.d.ts +2 -0
  42. package/dist/scripts/encodeDecode.d.ts.map +1 -0
  43. package/dist/scripts/encodeDecode.js +65 -0
  44. package/dist/scripts/encodeDecode.js.map +1 -0
  45. package/dist/scripts/generateMnemonic.d.ts +2 -0
  46. package/dist/scripts/generateMnemonic.d.ts.map +1 -0
  47. package/dist/scripts/generateMnemonic.js +28 -0
  48. package/dist/scripts/generateMnemonic.js.map +1 -0
  49. package/dist/scripts/getBalance.d.ts +2 -0
  50. package/dist/scripts/getBalance.d.ts.map +1 -0
  51. package/dist/scripts/getBalance.js +15 -0
  52. package/dist/scripts/getBalance.js.map +1 -0
  53. package/dist/scripts/getBlock.d.ts +2 -0
  54. package/dist/scripts/getBlock.d.ts.map +1 -0
  55. package/dist/scripts/getBlock.js +32 -0
  56. package/dist/scripts/getBlock.js.map +1 -0
  57. package/dist/scripts/getContractInfoOf.d.ts +2 -0
  58. package/dist/scripts/getContractInfoOf.d.ts.map +1 -0
  59. package/dist/scripts/getContractInfoOf.js +53 -0
  60. package/dist/scripts/getContractInfoOf.js.map +1 -0
  61. package/dist/scripts/getExistentialDeposit.d.ts +2 -0
  62. package/dist/scripts/getExistentialDeposit.d.ts.map +1 -0
  63. package/dist/scripts/getExistentialDeposit.js +39 -0
  64. package/dist/scripts/getExistentialDeposit.js.map +1 -0
  65. package/dist/scripts/getRandomProvider.d.ts +2 -0
  66. package/dist/scripts/getRandomProvider.d.ts.map +1 -0
  67. package/dist/scripts/getRandomProvider.js +38 -0
  68. package/dist/scripts/getRandomProvider.js.map +1 -0
  69. package/dist/scripts/getStorage.d.ts +2 -0
  70. package/dist/scripts/getStorage.d.ts.map +1 -0
  71. package/dist/scripts/getStorage.js +36 -0
  72. package/dist/scripts/getStorage.js.map +1 -0
  73. package/dist/scripts/getValidators.d.ts +2 -0
  74. package/dist/scripts/getValidators.d.ts.map +1 -0
  75. package/dist/scripts/getValidators.js +32 -0
  76. package/dist/scripts/getValidators.js.map +1 -0
  77. package/dist/scripts/hash.d.ts +2 -0
  78. package/dist/scripts/hash.d.ts.map +1 -0
  79. package/dist/scripts/hash.js +56 -0
  80. package/dist/scripts/hash.js.map +1 -0
  81. package/dist/scripts/hexToBytes.d.ts +2 -0
  82. package/dist/scripts/hexToBytes.d.ts.map +1 -0
  83. package/dist/scripts/hexToBytes.js +19 -0
  84. package/dist/scripts/hexToBytes.js.map +1 -0
  85. package/dist/scripts/mnemonicFromSeed.d.ts +2 -0
  86. package/dist/scripts/mnemonicFromSeed.d.ts.map +1 -0
  87. package/dist/scripts/mnemonicFromSeed.js +30 -0
  88. package/dist/scripts/mnemonicFromSeed.js.map +1 -0
  89. package/dist/scripts/populateTxAndSign.d.ts +2 -0
  90. package/dist/scripts/populateTxAndSign.d.ts.map +1 -0
  91. package/dist/scripts/populateTxAndSign.js +65 -0
  92. package/dist/scripts/populateTxAndSign.js.map +1 -0
  93. package/dist/scripts/sendFunds.d.ts +2 -0
  94. package/dist/scripts/sendFunds.d.ts.map +1 -0
  95. package/dist/scripts/sendFunds.js +33 -0
  96. package/dist/scripts/sendFunds.js.map +1 -0
  97. package/dist/setup/dapp.d.ts +4 -0
  98. package/dist/setup/dapp.d.ts.map +1 -0
  99. package/dist/setup/dapp.js +35 -0
  100. package/dist/setup/dapp.js.map +1 -0
  101. package/dist/setup/funds.d.ts +23 -0
  102. package/dist/setup/funds.d.ts.map +1 -0
  103. package/dist/setup/funds.js +102 -0
  104. package/dist/setup/funds.js.map +1 -0
  105. package/dist/setup/index.d.ts +5 -0
  106. package/dist/setup/index.d.ts.map +1 -0
  107. package/dist/setup/index.js +18 -0
  108. package/dist/setup/index.js.map +1 -0
  109. package/dist/setup/provider.d.ts +5 -0
  110. package/dist/setup/provider.d.ts.map +1 -0
  111. package/dist/setup/provider.js +84 -0
  112. package/dist/setup/provider.js.map +1 -0
  113. package/dist/setup/setup.d.ts +2 -0
  114. package/dist/setup/setup.d.ts.map +1 -0
  115. package/dist/setup/setup.js +151 -0
  116. package/dist/setup/setup.js.map +1 -0
  117. package/dist/util/exec.d.ts +10 -0
  118. package/dist/util/exec.d.ts.map +1 -0
  119. package/dist/util/exec.js +58 -0
  120. package/dist/util/exec.js.map +1 -0
  121. package/dist/util/index.d.ts +4 -0
  122. package/dist/util/index.d.ts.map +1 -0
  123. package/dist/util/index.js +17 -0
  124. package/dist/util/index.js.map +1 -0
  125. package/dist/util/loadContractFiles.d.ts +4 -0
  126. package/dist/util/loadContractFiles.d.ts.map +1 -0
  127. package/dist/util/loadContractFiles.js +54 -0
  128. package/dist/util/loadContractFiles.js.map +1 -0
  129. package/dist/util/updateEnv.d.ts +4 -0
  130. package/dist/util/updateEnv.d.ts.map +1 -0
  131. package/dist/util/updateEnv.js +45 -0
  132. package/dist/util/updateEnv.js.map +1 -0
  133. package/package.json +20 -20
@@ -0,0 +1 @@
1
+ {"version":3,"file":"convertAccount.js","sourceRoot":"","sources":["../../src/scripts/convertAccount.ts"],"names":[],"mappings":"AAAA,wCAAwC;AACxC,EAAE;AACF,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,iDAAiD;AACjD,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AACjC,OAAO,EAAE,EAAE,EAAE,MAAM,eAAe,CAAA;AAClC,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AAChE,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAC1D,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AAEjD,MAAM,UAAU,GAAG,EAAE,CAAA;AAErB,MAAM,GAAG,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAA;AAE/C,IAAI,KAAK,GAA2B,SAAS,CAAA;AAC7C,IAAI,GAAG,GAAuB,SAAS,CAAA;AACvC,IAAI,IAAI,GAAuB,SAAS,CAAA;AAExC,IAAI,SAAS,CAAC,GAAG,CAAC,EAAE;IAChB,KAAK,GAAG,aAAa,CAAC,GAAG,CAAC,CAAA;CAC7B;KAAM,IAAI,KAAK,CAAC,GAAG,CAAC,EAAE;IACnB,KAAK,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAA;CACxB;KAAM;IACH,oCAAoC;IACpC,KAAK,GAAG,IAAI,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAA;CAC1C;AAED,GAAG,GAAG,GAAG,IAAI,QAAQ,CAAC,KAAK,CAAC,CAAA;AAC5B,IAAI,GAAG,IAAI,IAAI,aAAa,CAAC,GAAG,EAAE,UAAU,CAAC,CAAA;AAE7C,OAAO,CAAC,GAAG,CAAC,WAAW,KAAK,GAAG,CAAC,CAAA;AAChC,OAAO,CAAC,GAAG,CAAC,QAAQ,GAAG,EAAE,CAAC,CAAA;AAC1B,OAAO,CAAC,GAAG,CAAC,SAAS,IAAI,EAAE,CAAC,CAAA"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=encodeDecode.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"encodeDecode.d.ts","sourceRoot":"","sources":["../../src/scripts/encodeDecode.ts"],"names":[],"mappings":""}
@@ -0,0 +1,65 @@
1
+ // Copyright 2021-2023 Prosopo (UK) Ltd.
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+ import { at } from '@prosopo/util';
15
+ import { blake2AsHex, isAddress } from '@polkadot/util-crypto';
16
+ import { decodeAddress, encodeAddress } from '@polkadot/keyring';
17
+ import { hexToNumber, hexToString, hexToU8a, isHex, stringToHex, u8aToHex } from '@polkadot/util';
18
+ const ss58Format = 42;
19
+ const arg = at(process.argv.slice(2), 0).trim();
20
+ const argIsHex = isHex(arg);
21
+ const argIsAddress = isAddress(arg, false, ss58Format);
22
+ console.log(`arg : ${arg}`);
23
+ console.log(`arg length : ${arg.length}`);
24
+ console.log(`argIsAddress : ${argIsAddress}`);
25
+ console.log(`argIsHex : ${argIsHex}`);
26
+ if (argIsAddress) {
27
+ try {
28
+ const encodedAddress = encodeAddress(decodeAddress(arg, false, ss58Format), ss58Format);
29
+ const decodedAddress = decodeAddress(encodedAddress, false, ss58Format);
30
+ if (encodedAddress === arg) {
31
+ const hexAddress = u8aToHex(decodedAddress);
32
+ console.log(`Hex address ${hexAddress}`);
33
+ console.log(`Address bytes ${decodedAddress}`);
34
+ }
35
+ else {
36
+ console.log(`Encoded address ${encodedAddress}`);
37
+ console.log(`Address as hex ${u8aToHex(decodeAddress(encodedAddress))}`);
38
+ }
39
+ }
40
+ catch (e) {
41
+ console.log(`Address encoding/decoding failed: ${e}`);
42
+ }
43
+ }
44
+ if (argIsHex) {
45
+ console.log(`Decoding hex ${arg} to string`);
46
+ console.log(hexToString(arg));
47
+ console.log(`Decoding hex ${arg} to number`);
48
+ console.log(hexToNumber(arg));
49
+ console.log(`Uint8Array ${hexToU8a(stringToHex(arg))}`);
50
+ }
51
+ else {
52
+ console.log(`Hashing string ${arg} using blake2AsHex`);
53
+ console.log(blake2AsHex(arg));
54
+ }
55
+ try {
56
+ const u8a = new Uint8Array(JSON.parse(arg));
57
+ console.log(`Found uint8array ${u8a}`);
58
+ const hex = u8aToHex(u8a);
59
+ console.log(`Hex version ${hex}`);
60
+ console.log(`Encoded address ${encodeAddress(hex, ss58Format)}`);
61
+ }
62
+ catch (e) {
63
+ console.log(`Not a uint8array ${e}`);
64
+ }
65
+ //# sourceMappingURL=encodeDecode.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"encodeDecode.js","sourceRoot":"","sources":["../../src/scripts/encodeDecode.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=generateMnemonic.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generateMnemonic.d.ts","sourceRoot":"","sources":["../../src/scripts/generateMnemonic.ts"],"names":[],"mappings":""}
@@ -0,0 +1,28 @@
1
+ // Copyright 2021-2023 Prosopo (UK) Ltd.
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+ import { LogLevel, getLogger } from '@prosopo/common';
15
+ import { generateMnemonic } from '@prosopo/contract';
16
+ const logger = getLogger(LogLevel.enum.info, 'generateMnemonic');
17
+ async function mnemonic() {
18
+ const [mnemonic, address] = await generateMnemonic();
19
+ logger.debug(`Address: ${address}`);
20
+ logger.debug(`Mnemonic: ${mnemonic}`);
21
+ }
22
+ mnemonic()
23
+ .then(() => process.exit(0))
24
+ .catch((e) => {
25
+ console.error(e);
26
+ process.exit(1);
27
+ });
28
+ //# sourceMappingURL=generateMnemonic.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generateMnemonic.js","sourceRoot":"","sources":["../../src/scripts/generateMnemonic.ts"],"names":[],"mappings":"AAAA,wCAAwC;AACxC,EAAE;AACF,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,iDAAiD;AACjD,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAA;AAEpD,MAAM,MAAM,GAAG,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,kBAAkB,CAAC,CAAA;AAEhE,KAAK,UAAU,QAAQ;IACnB,MAAM,CAAC,QAAQ,EAAE,OAAO,CAAC,GAAG,MAAM,gBAAgB,EAAE,CAAA;IACpD,MAAM,CAAC,KAAK,CAAC,YAAY,OAAO,EAAE,CAAC,CAAA;IACnC,MAAM,CAAC,KAAK,CAAC,aAAa,QAAQ,EAAE,CAAC,CAAA;AACzC,CAAC;AAED,QAAQ,EAAE;KACL,IAAI,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;KAC3B,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE;IACT,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;IAChB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;AACnB,CAAC,CAAC,CAAA"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=getBalance.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getBalance.d.ts","sourceRoot":"","sources":["../../src/scripts/getBalance.ts"],"names":[],"mappings":""}
@@ -0,0 +1,15 @@
1
+ export {};
2
+ // Copyright 2021-2023 Prosopo (UK) Ltd.
3
+ //
4
+ // Licensed under the Apache License, Version 2.0 (the "License");
5
+ // you may not use this file except in compliance with the License.
6
+ // You may obtain a copy of the License at
7
+ //
8
+ // http://www.apache.org/licenses/LICENSE-2.0
9
+ //
10
+ // Unless required by applicable law or agreed to in writing, software
11
+ // distributed under the License is distributed on an "AS IS" BASIS,
12
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ // See the License for the specific language governing permissions and
14
+ // limitations under the License.
15
+ //# sourceMappingURL=getBalance.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getBalance.js","sourceRoot":"","sources":["../../src/scripts/getBalance.ts"],"names":[],"mappings":";AAAA,wCAAwC;AACxC,EAAE;AACF,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,iDAAiD;AACjD,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=getBlock.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getBlock.d.ts","sourceRoot":"","sources":["../../src/scripts/getBlock.ts"],"names":[],"mappings":""}
@@ -0,0 +1,32 @@
1
+ // Copyright 2021-2023 Prosopo (UK) Ltd.
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+ import { ApiPromise, WsProvider } from '@polkadot/api';
15
+ import { at } from '@prosopo/util';
16
+ async function run(blockNumber) {
17
+ // Construct
18
+ const provider = 'ws://localhost:9944';
19
+ const wsProvider = new WsProvider(provider);
20
+ const api = await ApiPromise.create({ provider: wsProvider });
21
+ // Do something
22
+ const blockHash = await api.rpc.chain.getBlockHash(blockNumber);
23
+ const block = await api.rpc.chain.getBlock(blockHash);
24
+ console.log(JSON.stringify(block.toJSON(), null, 2));
25
+ }
26
+ run(at(process.argv.slice(2), 0))
27
+ .then(() => process.exit(0))
28
+ .catch((error) => {
29
+ console.error(error);
30
+ process.exit(-1);
31
+ });
32
+ //# sourceMappingURL=getBlock.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getBlock.js","sourceRoot":"","sources":["../../src/scripts/getBlock.ts"],"names":[],"mappings":"AAAA,wCAAwC;AACxC,EAAE;AACF,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,iDAAiD;AACjD,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AACjC,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AACtD,OAAO,EAAE,EAAE,EAAE,MAAM,eAAe,CAAA;AAElC,KAAK,UAAU,GAAG,CAAC,WAA4B;IAC3C,YAAY;IACZ,MAAM,QAAQ,GAAG,qBAAqB,CAAA;IACtC,MAAM,UAAU,GAAG,IAAI,UAAU,CAAC,QAAQ,CAAC,CAAA;IAC3C,MAAM,GAAG,GAAG,MAAM,UAAU,CAAC,MAAM,CAAC,EAAE,QAAQ,EAAE,UAAU,EAAE,CAAC,CAAA;IAE7D,eAAe;IACf,MAAM,SAAS,GAAG,MAAM,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,YAAY,CAAC,WAAW,CAAC,CAAA;IAE/D,MAAM,KAAK,GAAG,MAAM,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAA;IACrD,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,MAAM,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAA;AACxD,CAAC;AAED,GAAG,CAAC,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;KAC5B,IAAI,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;KAC3B,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;IACb,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;IACpB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAA;AACpB,CAAC,CAAC,CAAA"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=getContractInfoOf.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getContractInfoOf.d.ts","sourceRoot":"","sources":["../../src/scripts/getContractInfoOf.ts"],"names":[],"mappings":""}
@@ -0,0 +1,53 @@
1
+ // Copyright 2021-2023 Prosopo (UK) Ltd.
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+ import { ApiPromise, WsProvider } from '@polkadot/api';
15
+ import { get } from '@prosopo/util';
16
+ import { hideBin } from 'yargs/helpers';
17
+ import yargs from 'yargs';
18
+ const providers = {
19
+ local: { endpoint: 'ws://substrate-node:9944' },
20
+ polkadot: { endpoint: 'wss://rpc.polkadot.io' },
21
+ rococo: { endpoint: 'wss://rococo-contracts-rpc.polkadot.io:443' },
22
+ };
23
+ async function getContractInfoOf(contractAddress, provider) {
24
+ const wsProvider = new WsProvider(get(providers, provider).endpoint);
25
+ const api = await ApiPromise.create({ provider: wsProvider });
26
+ return await api.query.contracts.contractInfoOf(contractAddress);
27
+ }
28
+ async function run(argv) {
29
+ const parsed = await yargs(hideBin(argv))
30
+ .usage('Usage: [options]')
31
+ .option('contract', {
32
+ type: 'string',
33
+ demand: true,
34
+ desc: 'The contract to get the info of',
35
+ })
36
+ .option('network', {
37
+ type: 'string',
38
+ demand: false,
39
+ desc: 'The network to use',
40
+ })
41
+ .parse();
42
+ return await getContractInfoOf(parsed.contract, parsed.network ? parsed.network : 'development');
43
+ }
44
+ run(process.argv.slice(2))
45
+ .then((result) => {
46
+ console.log(result.toHuman());
47
+ process.exit();
48
+ })
49
+ .catch((error) => {
50
+ console.error(error);
51
+ process.exit(1);
52
+ });
53
+ //# sourceMappingURL=getContractInfoOf.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getContractInfoOf.js","sourceRoot":"","sources":["../../src/scripts/getContractInfoOf.ts"],"names":[],"mappings":"AAAA,wCAAwC;AACxC,EAAE;AACF,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,iDAAiD;AACjD,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AACjC,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAEtD,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAA;AACnC,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,MAAM,SAAS,GAAG;IACd,KAAK,EAAE,EAAE,QAAQ,EAAE,0BAA0B,EAAE;IAC/C,QAAQ,EAAE,EAAE,QAAQ,EAAE,uBAAuB,EAAE;IAC/C,MAAM,EAAE,EAAE,QAAQ,EAAE,4CAA4C,EAAE;CACrE,CAAA;AAED,KAAK,UAAU,iBAAiB,CAAC,eAAuB,EAAE,QAAgB;IACtE,MAAM,UAAU,GAAG,IAAI,UAAU,CAAC,GAAG,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC,QAAQ,CAAC,CAAA;IACpE,MAAM,GAAG,GAAG,MAAM,UAAU,CAAC,MAAM,CAAC,EAAE,QAAQ,EAAE,UAAU,EAAE,CAAC,CAAA;IAC7D,OAAO,MAAM,GAAG,CAAC,KAAK,CAAC,SAAS,CAAC,cAAc,CAAC,eAAe,CAAC,CAAA;AACpE,CAAC;AAED,KAAK,UAAU,GAAG,CAAC,IAAc;IAC7B,MAAM,MAAM,GAAG,MAAM,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;SACpC,KAAK,CAAC,mBAAmB,CAAC;SAC1B,MAAM,CAAC,UAAU,EAAE;QAChB,IAAI,EAAE,QAAQ;QACd,MAAM,EAAE,IAAI;QACZ,IAAI,EAAE,iCAAiC;KAC1C,CAAC;SACD,MAAM,CAAC,SAAS,EAAE;QACf,IAAI,EAAE,QAAQ;QACd,MAAM,EAAE,KAAK;QACb,IAAI,EAAE,oBAAoB;KAC7B,CAAC;SACD,KAAK,EAAE,CAAA;IACZ,OAAO,MAAM,iBAAiB,CAAC,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,aAAa,CAAC,CAAA;AACpG,CAAC;AACD,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;KACrB,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE;IACb,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC,CAAA;IAC7B,OAAO,CAAC,IAAI,EAAE,CAAA;AAClB,CAAC,CAAC;KACD,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;IACb,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;IACpB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;AACnB,CAAC,CAAC,CAAA"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=getExistentialDeposit.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getExistentialDeposit.d.ts","sourceRoot":"","sources":["../../src/scripts/getExistentialDeposit.ts"],"names":[],"mappings":""}
@@ -0,0 +1,39 @@
1
+ // Copyright 2021-2023 Prosopo (UK) Ltd.
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+ import { ApiPromise, WsProvider } from '@polkadot/api';
15
+ import { oneUnit } from '@prosopo/contract';
16
+ async function run() {
17
+ // Construct
18
+ const provider = 'ws://localhost:9944';
19
+ // const provider = 'wss://shiden.public.blastapi.io'
20
+ const wsProvider = new WsProvider(provider);
21
+ const api = await ApiPromise.create({ provider: wsProvider });
22
+ // Do something
23
+ const existentialDeposit = await api.consts.balances.existentialDeposit;
24
+ const unit = await oneUnit(api);
25
+ const chainDecimals = api.registry.chainDecimals;
26
+ console.log('Chain decimal places:', chainDecimals);
27
+ console.log('One Unit:', unit.toString());
28
+ console.log('Existential Deposit:', existentialDeposit.toNumber());
29
+ console.log('Existential Deposit in UNITs:', existentialDeposit.div(unit).toNumber(), 'UNIT');
30
+ console.log('Existential Deposit Hex:', existentialDeposit.toHex?.());
31
+ return existentialDeposit;
32
+ }
33
+ run()
34
+ .then(() => process.exit(0))
35
+ .catch((error) => {
36
+ console.error(error);
37
+ process.exit(-1);
38
+ });
39
+ //# sourceMappingURL=getExistentialDeposit.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getExistentialDeposit.js","sourceRoot":"","sources":["../../src/scripts/getExistentialDeposit.ts"],"names":[],"mappings":"AAAA,wCAAwC;AACxC,EAAE;AACF,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,iDAAiD;AACjD,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AACjC,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AACtD,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAA;AAC3C,KAAK,UAAU,GAAG;IACd,YAAY;IACZ,MAAM,QAAQ,GAAG,qBAAqB,CAAA;IACtC,qDAAqD;IACrD,MAAM,UAAU,GAAG,IAAI,UAAU,CAAC,QAAQ,CAAC,CAAA;IAC3C,MAAM,GAAG,GAAG,MAAM,UAAU,CAAC,MAAM,CAAC,EAAE,QAAQ,EAAE,UAAU,EAAE,CAAC,CAAA;IAE7D,eAAe;IACf,MAAM,kBAAkB,GAAG,MAAM,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,kBAAkB,CAAA;IACvE,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,CAAA;IAC/B,MAAM,aAAa,GAAG,GAAG,CAAC,QAAQ,CAAC,aAAa,CAAA;IAChD,OAAO,CAAC,GAAG,CAAC,uBAAuB,EAAE,aAAa,CAAC,CAAA;IACnD,OAAO,CAAC,GAAG,CAAC,WAAW,EAAE,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAA;IACzC,OAAO,CAAC,GAAG,CAAC,sBAAsB,EAAE,kBAAkB,CAAC,QAAQ,EAAE,CAAC,CAAA;IAClE,OAAO,CAAC,GAAG,CAAC,+BAA+B,EAAE,kBAAkB,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE,MAAM,CAAC,CAAA;IAC7F,OAAO,CAAC,GAAG,CAAC,0BAA0B,EAAE,kBAAkB,CAAC,KAAK,EAAE,EAAE,CAAC,CAAA;IACrE,OAAO,kBAAkB,CAAA;AAC7B,CAAC;AAED,GAAG,EAAE;KACA,IAAI,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;KAC3B,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;IACb,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;IACpB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAA;AACpB,CAAC,CAAC,CAAA"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=getRandomProvider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getRandomProvider.d.ts","sourceRoot":"","sources":["../../src/scripts/getRandomProvider.ts"],"names":[],"mappings":""}
@@ -0,0 +1,38 @@
1
+ // Copyright 2021-2023 Prosopo (UK) Ltd.
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+ import { ProviderEnvironment } from '@prosopo/env';
15
+ import { Tasks } from '@prosopo/provider';
16
+ import { defaultConfig, getPairType, getSs58Format } from '@prosopo/cli';
17
+ import { generateMnemonic } from '@prosopo/contract';
18
+ import { getPair } from '@prosopo/common';
19
+ import dotenv from 'dotenv';
20
+ dotenv.config();
21
+ async function main() {
22
+ const pair = await getPair(getPairType(), getSs58Format(), '//Alice');
23
+ const env = new ProviderEnvironment(pair, defaultConfig());
24
+ await env.isReady();
25
+ const tasks = new Tasks(env);
26
+ const [mnemonic, address] = (await generateMnemonic(env.keyring)) || ['', ''];
27
+ const dappContractAccount = process.env.DAPP_SITE_KEY || '';
28
+ const provider = (await tasks.contract.query.getRandomActiveProvider(address, dappContractAccount)).value
29
+ .unwrap()
30
+ .unwrap();
31
+ console.log(provider);
32
+ process.exit();
33
+ }
34
+ main().catch((error) => {
35
+ console.error(error);
36
+ process.exit();
37
+ });
38
+ //# sourceMappingURL=getRandomProvider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getRandomProvider.js","sourceRoot":"","sources":["../../src/scripts/getRandomProvider.ts"],"names":[],"mappings":"AAAA,wCAAwC;AACxC,EAAE;AACF,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,iDAAiD;AACjD,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AACjC,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAA;AAClD,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AACzC,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AACxE,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAA;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAA;AACzC,OAAO,MAAM,MAAM,QAAQ,CAAA;AAE3B,MAAM,CAAC,MAAM,EAAE,CAAA;AAEf,KAAK,UAAU,IAAI;IACf,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC,WAAW,EAAE,EAAE,aAAa,EAAE,EAAE,SAAS,CAAC,CAAA;IACrE,MAAM,GAAG,GAAG,IAAI,mBAAmB,CAAC,IAAI,EAAE,aAAa,EAAE,CAAC,CAAA;IAC1D,MAAM,GAAG,CAAC,OAAO,EAAE,CAAA;IACnB,MAAM,KAAK,GAAG,IAAI,KAAK,CAAC,GAAG,CAAC,CAAA;IAC5B,MAAM,CAAC,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,MAAM,gBAAgB,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,CAAC,CAAA;IAC7E,MAAM,mBAAmB,GAAG,OAAO,CAAC,GAAG,CAAC,aAAa,IAAI,EAAE,CAAA;IAC3D,MAAM,QAAQ,GAAG,CAAC,MAAM,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,uBAAuB,CAAC,OAAO,EAAE,mBAAmB,CAAC,CAAC,CAAC,KAAK;SACpG,MAAM,EAAE;SACR,MAAM,EAAE,CAAA;IACb,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;IACrB,OAAO,CAAC,IAAI,EAAE,CAAA;AAClB,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;IACnB,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;IACpB,OAAO,CAAC,IAAI,EAAE,CAAA;AAClB,CAAC,CAAC,CAAA"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=getStorage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getStorage.d.ts","sourceRoot":"","sources":["../../src/scripts/getStorage.ts"],"names":[],"mappings":""}
@@ -0,0 +1,36 @@
1
+ // Copyright 2021-2023 Prosopo (UK) Ltd.
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+ import { ProviderEnvironment } from '@prosopo/env';
15
+ import { Tasks } from '@prosopo/provider';
16
+ import { defaultConfig, getPairType, getSs58Format } from '@prosopo/cli';
17
+ import { get } from '@prosopo/util';
18
+ import { getPair } from '@prosopo/common';
19
+ import dotenv from 'dotenv';
20
+ dotenv.config();
21
+ async function main() {
22
+ const pair = await getPair(getPairType(), getSs58Format(), '//Alice');
23
+ const env = new ProviderEnvironment(pair, defaultConfig());
24
+ await env.isReady();
25
+ const tasks = new Tasks(env);
26
+ const contract = tasks.contract;
27
+ const fn = get(contract, 'dappAccounts');
28
+ const dappAccounts = await fn();
29
+ console.log(dappAccounts.toHuman());
30
+ process.exit();
31
+ }
32
+ main().catch((error) => {
33
+ console.error(error);
34
+ process.exit();
35
+ });
36
+ //# sourceMappingURL=getStorage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getStorage.js","sourceRoot":"","sources":["../../src/scripts/getStorage.ts"],"names":[],"mappings":"AAAA,wCAAwC;AACxC,EAAE;AACF,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,iDAAiD;AACjD,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AACjC,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAA;AAClD,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AACzC,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AACxE,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAA;AACnC,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAA;AACzC,OAAO,MAAM,MAAM,QAAQ,CAAA;AAE3B,MAAM,CAAC,MAAM,EAAE,CAAA;AAEf,KAAK,UAAU,IAAI;IACf,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC,WAAW,EAAE,EAAE,aAAa,EAAE,EAAE,SAAS,CAAC,CAAA;IACrE,MAAM,GAAG,GAAG,IAAI,mBAAmB,CAAC,IAAI,EAAE,aAAa,EAAE,CAAC,CAAA;IAC1D,MAAM,GAAG,CAAC,OAAO,EAAE,CAAA;IACnB,MAAM,KAAK,GAAG,IAAI,KAAK,CAAC,GAAG,CAAC,CAAA;IAC5B,MAAM,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAAA;IAC/B,MAAM,EAAE,GAAQ,GAAG,CAAC,QAAQ,EAAE,cAAc,CAAC,CAAA;IAC7C,MAAM,YAAY,GAAG,MAAM,EAAE,EAAE,CAAA;IAC/B,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,OAAO,EAAE,CAAC,CAAA;IACnC,OAAO,CAAC,IAAI,EAAE,CAAA;AAClB,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;IACnB,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;IACpB,OAAO,CAAC,IAAI,EAAE,CAAA;AAClB,CAAC,CAAC,CAAA"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=getValidators.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getValidators.d.ts","sourceRoot":"","sources":["../../src/scripts/getValidators.ts"],"names":[],"mappings":""}
@@ -0,0 +1,32 @@
1
+ // Copyright 2021-2023 Prosopo (UK) Ltd.
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+ import { ApiPromise, WsProvider } from '@polkadot/api';
15
+ import { get } from '@prosopo/util';
16
+ const providers = {
17
+ kusama: { endpoint: 'wss://kusama-rpc.polkadot.io/' },
18
+ polkadot: { endpoint: 'wss://rpc.polkadot.io' },
19
+ };
20
+ async function run() {
21
+ // Construct
22
+ for (const provider in providers) {
23
+ const wsProvider = new WsProvider(get(providers, provider).endpoint);
24
+ const api = await ApiPromise.create({ provider: wsProvider });
25
+ // Do something
26
+ const validators = await api.query.staking.validators.keys();
27
+ console.log(`${validators.length} validators on ${provider}`);
28
+ }
29
+ process.exit();
30
+ }
31
+ run();
32
+ //# sourceMappingURL=getValidators.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getValidators.js","sourceRoot":"","sources":["../../src/scripts/getValidators.ts"],"names":[],"mappings":"AAAA,wCAAwC;AACxC,EAAE;AACF,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,iDAAiD;AACjD,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AACjC,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AACtD,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAA;AAEnC,MAAM,SAAS,GAAG;IACd,MAAM,EAAE,EAAE,QAAQ,EAAE,+BAA+B,EAAE;IACrD,QAAQ,EAAE,EAAE,QAAQ,EAAE,uBAAuB,EAAE;CAClD,CAAA;AAED,KAAK,UAAU,GAAG;IACd,YAAY;IACZ,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE;QAC9B,MAAM,UAAU,GAAG,IAAI,UAAU,CAAC,GAAG,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC,QAAQ,CAAC,CAAA;QACpE,MAAM,GAAG,GAAG,MAAM,UAAU,CAAC,MAAM,CAAC,EAAE,QAAQ,EAAE,UAAU,EAAE,CAAC,CAAA;QAE7D,eAAe;QACf,MAAM,UAAU,GAAG,MAAM,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,IAAI,EAAE,CAAA;QAC5D,OAAO,CAAC,GAAG,CAAC,GAAG,UAAU,CAAC,MAAM,kBAAkB,QAAQ,EAAE,CAAC,CAAA;KAChE;IACD,OAAO,CAAC,IAAI,EAAE,CAAA;AAClB,CAAC;AAED,GAAG,EAAE,CAAA"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=hash.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hash.d.ts","sourceRoot":"","sources":["../../src/scripts/hash.ts"],"names":[],"mappings":""}
@@ -0,0 +1,56 @@
1
+ // Copyright 2021-2023 Prosopo (UK) Ltd.
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+ import { blake2AsHex, blake2AsU8a, keccakAsHex, keccakAsU8a } from '@polkadot/util-crypto';
15
+ import { decodeAddress, encodeAddress } from '@polkadot/keyring';
16
+ import { get } from '@prosopo/util';
17
+ import { hexToBn, hexToString, hexToU8a, isHex, stringToHex, stringToU8a, u8aToBn, u8aToFloat, u8aToHex, u8aToString, } from '@polkadot/util';
18
+ function main() {
19
+ const fns = {
20
+ arg: (arg) => arg,
21
+ isHex,
22
+ hexToString,
23
+ hexToU8a,
24
+ hexToBn,
25
+ stringToHex,
26
+ stringToU8a,
27
+ blake2AsHex,
28
+ blake2AsU8a,
29
+ keccakAsHex,
30
+ keccakAsU8a,
31
+ decodeAddress,
32
+ encodeAddress,
33
+ u8aToHex,
34
+ u8aToBn,
35
+ u8aToFloat,
36
+ u8aToString,
37
+ jsonParse: JSON.parse,
38
+ jsonStringify: JSON.stringify,
39
+ };
40
+ const arg = process.argv.slice(2)[0];
41
+ const max = Object.keys(fns).reduce((max, key) => Math.max(max, key.length), 0);
42
+ for (const fnName in fns) {
43
+ const fn = get(fns, fnName);
44
+ let result = '';
45
+ try {
46
+ result = fn(arg);
47
+ }
48
+ catch (e) {
49
+ // ignore
50
+ }
51
+ // https://stackoverflow.com/questions/9781218/how-to-change-node-jss-console-font-color
52
+ console.log(`\x1b[40m\x1b[33m${fnName.padEnd(max + 1, ' ')}:\x1b[37m ${result}`);
53
+ }
54
+ }
55
+ main();
56
+ //# sourceMappingURL=hash.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hash.js","sourceRoot":"","sources":["../../src/scripts/hash.ts"],"names":[],"mappings":"AAAA,wCAAwC;AACxC,EAAE;AACF,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,iDAAiD;AACjD,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AACjC,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AAC1F,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AAChE,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAA;AACnC,OAAO,EACH,OAAO,EACP,WAAW,EACX,QAAQ,EACR,KAAK,EACL,WAAW,EACX,WAAW,EACX,OAAO,EACP,UAAU,EACV,QAAQ,EACR,WAAW,GACd,MAAM,gBAAgB,CAAA;AAEvB,SAAS,IAAI;IACT,MAAM,GAAG,GAEL;QACA,GAAG,EAAE,CAAC,GAAQ,EAAE,EAAE,CAAC,GAAG;QACtB,KAAK;QACL,WAAW;QACX,QAAQ;QACR,OAAO;QACP,WAAW;QACX,WAAW;QACX,WAAW;QACX,WAAW;QACX,WAAW;QACX,WAAW;QACX,aAAa;QACb,aAAa;QACb,QAAQ;QACR,OAAO;QACP,UAAU;QACV,WAAW;QACX,SAAS,EAAE,IAAI,CAAC,KAAK;QACrB,aAAa,EAAE,IAAI,CAAC,SAAS;KAChC,CAAA;IAED,MAAM,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;IAEpC,MAAM,GAAG,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAA;IAC/E,KAAK,MAAM,MAAM,IAAI,GAAG,EAAE;QACtB,MAAM,EAAE,GAAG,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC,CAAA;QAC3B,IAAI,MAAM,GAAG,EAAE,CAAA;QACf,IAAI;YACA,MAAM,GAAG,EAAE,CAAC,GAAG,CAAC,CAAA;SACnB;QAAC,OAAO,CAAC,EAAE;YACR,SAAS;SACZ;QACD,wFAAwF;QACxF,OAAO,CAAC,GAAG,CAAC,mBAAmB,MAAM,CAAC,MAAM,CAAC,GAAG,GAAG,CAAC,EAAE,GAAG,CAAC,aAAa,MAAM,EAAE,CAAC,CAAA;KACnF;AACL,CAAC;AAED,IAAI,EAAE,CAAA"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=hexToBytes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hexToBytes.d.ts","sourceRoot":"","sources":["../../src/scripts/hexToBytes.ts"],"names":[],"mappings":""}
@@ -0,0 +1,19 @@
1
+ // Copyright 2021-2023 Prosopo (UK) Ltd.
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+ import { at } from '@prosopo/util';
15
+ import { hexToU8a } from '@polkadot/util';
16
+ const arg = at(process.argv.slice(2), 0).trim();
17
+ console.log(`arg : ${arg}`);
18
+ console.log(hexToU8a(arg));
19
+ //# sourceMappingURL=hexToBytes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hexToBytes.js","sourceRoot":"","sources":["../../src/scripts/hexToBytes.ts"],"names":[],"mappings":"AAAA,wCAAwC;AACxC,EAAE;AACF,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,iDAAiD;AACjD,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AACjC,OAAO,EAAE,EAAE,EAAE,MAAM,eAAe,CAAA;AAClC,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAEzC,MAAM,GAAG,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAA;AAC/C,OAAO,CAAC,GAAG,CAAC,kBAAkB,GAAG,EAAE,CAAC,CAAA;AAEpC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAA"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=mnemonicFromSeed.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mnemonicFromSeed.d.ts","sourceRoot":"","sources":["../../src/scripts/mnemonicFromSeed.ts"],"names":[],"mappings":""}
@@ -0,0 +1,30 @@
1
+ // Copyright 2021-2023 Prosopo (UK) Ltd.
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+ import { Keyring } from '@polkadot/keyring';
15
+ import { entropyToMnemonic } from '@polkadot/util-crypto/mnemonic/bip39';
16
+ import { hexToU8a } from '@polkadot/util';
17
+ async function mnemonic() {
18
+ const keyring = new Keyring({ type: 'ed25519', ss58Format: 5 });
19
+ const u8Entropy = hexToU8a('0x7723670fb49be71c81598c2245ae19d1f1685f032f3e98d160b648f23241f41e');
20
+ const mnemonic = entropyToMnemonic(u8Entropy);
21
+ console.log(`Mnemonic: ${mnemonic}`);
22
+ const account = keyring.addFromMnemonic(mnemonic);
23
+ console.log(`Address: ${account.address}`);
24
+ const account2 = keyring.addFromSeed(hexToU8a('0x7723670fb49be71c81598c2245ae19d1f1685f032f3e98d160b648f23241f41e'));
25
+ console.log(`Address: ${account2.address}`);
26
+ const ss58Format = 5;
27
+ }
28
+ mnemonic();
29
+ //0x7723670fb49be71c81598c2245ae19d1f1685f032f3e98d160b648f23241f41e
30
+ //# sourceMappingURL=mnemonicFromSeed.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mnemonicFromSeed.js","sourceRoot":"","sources":["../../src/scripts/mnemonicFromSeed.ts"],"names":[],"mappings":"AAAA,wCAAwC;AACxC,EAAE;AACF,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,iDAAiD;AACjD,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAA;AAC3C,OAAO,EAAE,iBAAiB,EAAE,MAAM,sCAAsC,CAAA;AACxE,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAEzC,KAAK,UAAU,QAAQ;IACnB,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,UAAU,EAAE,CAAC,EAAE,CAAC,CAAA;IAC/D,MAAM,SAAS,GAAG,QAAQ,CAAC,oEAAoE,CAAC,CAAA;IAChG,MAAM,QAAQ,GAAG,iBAAiB,CAAC,SAAS,CAAC,CAAA;IAC7C,OAAO,CAAC,GAAG,CAAC,aAAa,QAAQ,EAAE,CAAC,CAAA;IACpC,MAAM,OAAO,GAAG,OAAO,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAA;IACjD,OAAO,CAAC,GAAG,CAAC,YAAY,OAAO,CAAC,OAAO,EAAE,CAAC,CAAA;IAC1C,MAAM,QAAQ,GAAG,OAAO,CAAC,WAAW,CAAC,QAAQ,CAAC,oEAAoE,CAAC,CAAC,CAAA;IACpH,OAAO,CAAC,GAAG,CAAC,YAAY,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAA;IAC3C,MAAM,UAAU,GAAG,CAAC,CAAA;AACxB,CAAC;AAED,QAAQ,EAAE,CAAA;AAEV,oEAAoE"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=populateTxAndSign.d.ts.map