@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,2 @@
1
+ export declare function processArgs(args: string[]): Promise<void>;
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":"AA8BA,wBAAsB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,iBAiJ/C"}
@@ -0,0 +1,145 @@
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 { deployDapp, deployProtocol } from '../contract/deploy/index.js';
16
+ import { exec } from '../util/index.js';
17
+ import { getLogLevel } from '@prosopo/common';
18
+ import { hideBin } from 'yargs/helpers';
19
+ import { importContract } from '../contract/index.js';
20
+ import { loadEnv } from '@prosopo/cli';
21
+ import { setup } from '../setup/index.js';
22
+ import { updateEnvFiles } from '../util/index.js';
23
+ import fs from 'fs';
24
+ import path from 'path';
25
+ import yargs from 'yargs';
26
+ const rootDir = path.resolve('.');
27
+ loadEnv(rootDir);
28
+ export async function processArgs(args) {
29
+ const parsed = await yargs(hideBin(args)).option('logLevel', {
30
+ describe: 'set log level',
31
+ choices: Object.keys(LogLevel.enum),
32
+ }).argv;
33
+ const log = getLogger(getLogLevel(parsed.logLevel), 'CLI');
34
+ await yargs(hideBin(args))
35
+ .usage('Usage: $0 [global options] <command> [options]')
36
+ .command('deploy_protocol', 'Deploy the prosopo protocol contract', (yargs) => yargs
37
+ .option('update_env', {
38
+ type: 'boolean',
39
+ demand: false,
40
+ desc: 'Update env files with the new contract address',
41
+ default: false,
42
+ })
43
+ .option('deployer', {
44
+ type: 'string',
45
+ demand: false,
46
+ desc: `The account prefix that will deploy the contract. Specifying PROVIDER will cause the
47
+ script to look for PROVIDER_JSON in the env file. Specifying DEPLOYER will cause the script to
48
+ look for DEPLOYER_JSON in the env file. Defaults to undefined.`,
49
+ default: undefined,
50
+ }), async (argv) => {
51
+ if (!process.env.CAPTCHA_WASM_PATH || !process.env.CAPTCHA_ABI_PATH) {
52
+ throw new Error('Missing protocol wasm or json path');
53
+ }
54
+ const protocolContractAddress = await deployProtocol(process.env.CAPTCHA_WASM_PATH, process.env.CAPTCHA_ABI_PATH, argv.deployer);
55
+ log.info('contract address', protocolContractAddress);
56
+ if (argv.update_env) {
57
+ await updateEnvFiles([
58
+ 'PROTOCOL_CONTRACT_ADDRESS',
59
+ 'REACT_APP_PROSOPO_CONTRACT_ADDRESS',
60
+ 'NEXT_PUBLIC_PROSOPO_CONTRACT_ADDRESS',
61
+ ], protocolContractAddress.toString(), log);
62
+ }
63
+ }, [])
64
+ .command('deploy_dapp', 'Deploy the prosopo dapp example contract', (yargs) => yargs.option('update_env', {
65
+ type: 'boolean',
66
+ demand: false,
67
+ desc: 'Update env files with the new contract address',
68
+ default: false,
69
+ }), async (argv) => {
70
+ const dappContractAddress = await deployDapp();
71
+ log.info('contract address', dappContractAddress);
72
+ if (argv.update_env) {
73
+ await updateEnvFiles(['DAPP_SITE_KEY', 'REACT_APP_DAPP_SITE_KEY', 'NEXT_PUBLIC_DAPP_SITE_KEY', 'PROSOPO_SITE_KEY'], dappContractAddress.toString(), log);
74
+ }
75
+ }, [])
76
+ .command({
77
+ command: 'setup',
78
+ describe: 'Setup the development environment by registering a provider, staking, loading a data set and then registering a dapp and staking.',
79
+ builder: (yargs) => yargs.option('force', {
80
+ type: 'boolean',
81
+ demand: false,
82
+ desc: 'Force provider re-registration and dataset setup',
83
+ }),
84
+ handler: async (argv) => {
85
+ log.info('Running setup scripts');
86
+ await setup(argv.force);
87
+ },
88
+ })
89
+ .command({
90
+ command: 'import_contract',
91
+ describe: 'Import a contract into the contract package.',
92
+ builder: (yargs) => yargs
93
+ .option('in', {
94
+ type: 'string',
95
+ demand: true,
96
+ desc: "The path to the contract's abi",
97
+ })
98
+ .option('out', {
99
+ type: 'string',
100
+ demand: true,
101
+ desc: 'The path to the output directory',
102
+ }),
103
+ handler: async (argv) => {
104
+ const abiPath = path.resolve(argv.in);
105
+ const cwd = path.resolve('.');
106
+ if (!fs.existsSync(abiPath)) {
107
+ throw new Error(`abiPath ${abiPath} does not exist. The command is running relative to ${cwd}`);
108
+ }
109
+ const outPath = path.resolve(argv.out);
110
+ // pass in relative path as typechain will resolve it relative to the cwd
111
+ await importContract(argv.in, argv.out);
112
+ },
113
+ })
114
+ .command({
115
+ command: 'import_all_contracts',
116
+ describe: 'Update all contracts into the contract package.',
117
+ builder: (yargs) => yargs,
118
+ handler: async (argv) => {
119
+ const contracts = ['captcha', 'proxy'];
120
+ for (const contract of contracts) {
121
+ const inDir = `../protocol/target/ink/${contract}`;
122
+ const outDir = `../packages/contract/src/typechain/${contract}`;
123
+ await exec(`mkdir -p ${outDir}`);
124
+ await exec(`mkdir -p ${inDir}`);
125
+ // console.log(`${outDir}`)
126
+ // console.log(`${inDir}`)
127
+ await exec(`node dist/cli/index.js import_contract --in=${inDir} --out=${outDir}`);
128
+ // console.log(`${path.resolve('../packages/contract/src/typechain/captcha/types-arguments')}`)
129
+ // console.log(`${path.resolve('../packages/types/src/contract/typechain/captcha/types-arguments')}`)
130
+ await exec(`mkdir -p ../packages/types/src/contract/typechain/captcha`);
131
+ await exec(`cp -rv ../packages/contract/src/typechain/captcha/types-arguments ../packages/types/src/contract/typechain/captcha`);
132
+ await exec(`cp -rv ../packages/contract/src/typechain/captcha/types-returns ../packages/types/src/contract/typechain/captcha`);
133
+ }
134
+ },
135
+ }).argv;
136
+ }
137
+ processArgs(process.argv)
138
+ .then(() => {
139
+ process.exit(0);
140
+ })
141
+ .catch((error) => {
142
+ console.error(error);
143
+ process.exit(1);
144
+ });
145
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cli/index.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,QAAQ,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AACrD,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAA;AACxE,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAA;AACvC,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAC7C,OAAO,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aces';
2
+ export declare function run(): Promise<AccountId>;
3
+ //# sourceMappingURL=dapp.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dapp.d.ts","sourceRoot":"","sources":["../../../src/contract/deploy/dapp.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,SAAS,EAAe,MAAM,4BAA4B,CAAA;AAoBnE,wBAAsB,GAAG,IAAI,OAAO,CAAC,SAAS,CAAC,CAU9C"}
@@ -0,0 +1,41 @@
1
+ import { AbiJSON, Wasm } from '../../util/index.js';
2
+ import { ContractDeployer } from '@prosopo/contract';
3
+ import { ProviderEnvironment } from '@prosopo/env';
4
+ import { defaultConfig, getPairType, getSs58Format } from '@prosopo/cli';
5
+ import { getPair } from '@prosopo/common';
6
+ import { loadEnv } from '@prosopo/cli';
7
+ import { randomAsHex } from '@polkadot/util-crypto';
8
+ import path from 'path';
9
+ async function deploy(wasm, abi) {
10
+ const pairType = getPairType();
11
+ const ss58Format = getSs58Format();
12
+ const pair = await getPair(pairType, ss58Format, '//Alice');
13
+ const env = new ProviderEnvironment(pair, defaultConfig());
14
+ await env.isReady();
15
+ // initialSupply, faucetAmount, prosopoAccount, humanThreshold, recencyThreshold
16
+ const params = ['1000000000000000', 1000, process.env.PROTOCOL_CONTRACT_ADDRESS, 50, 1000000];
17
+ const deployer = new ContractDeployer(env.getApi(), abi, wasm, env.pair, params, 0, 0, randomAsHex());
18
+ return await deployer.deploy();
19
+ }
20
+ export async function run() {
21
+ const wasm = await Wasm(path.resolve(process.env.DAPP_WASM_PATH || '.'));
22
+ const abi = await AbiJSON(path.resolve(process.env.DAPP_ABI_PATH || '.'));
23
+ const deployResult = await deploy(wasm, abi);
24
+ const instantiateEvent = deployResult.events.find((event) => event.event.section === 'contracts' && event.event.method === 'Instantiated');
25
+ console.log('instantiateEvent', instantiateEvent?.toHuman());
26
+ return (instantiateEvent?.event.data)['contract'].toString();
27
+ }
28
+ // run the script if the main process is running this file
29
+ if (typeof require !== 'undefined' && require.main === module) {
30
+ loadEnv(path.resolve('../..'));
31
+ run()
32
+ .then((deployResult) => {
33
+ console.log('Deployed with address', deployResult);
34
+ process.exit(0);
35
+ })
36
+ .catch((e) => {
37
+ console.error(e);
38
+ process.exit(1);
39
+ });
40
+ }
41
+ //# sourceMappingURL=dapp.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dapp.js","sourceRoot":"","sources":["../../../src/contract/deploy/dapp.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAA;AAEnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAA;AACpD,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAA;AAClD,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AACxE,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAA;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AACtC,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AACnD,OAAO,IAAI,MAAM,MAAM,CAAA;AAEvB,KAAK,UAAU,MAAM,CAAC,IAAgB,EAAE,GAAQ;IAC5C,MAAM,QAAQ,GAAG,WAAW,EAAE,CAAA;IAC9B,MAAM,UAAU,GAAG,aAAa,EAAE,CAAA;IAClC,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC,QAAQ,EAAE,UAAU,EAAE,SAAS,CAAC,CAAA;IAC3D,MAAM,GAAG,GAAG,IAAI,mBAAmB,CAAC,IAAI,EAAE,aAAa,EAAE,CAAC,CAAA;IAC1D,MAAM,GAAG,CAAC,OAAO,EAAE,CAAA;IACnB,gFAAgF;IAChF,MAAM,MAAM,GAAG,CAAC,kBAAkB,EAAE,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC,yBAAyB,EAAE,EAAE,EAAE,OAAO,CAAC,CAAA;IAC7F,MAAM,QAAQ,GAAG,IAAI,gBAAgB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AAC,CAAA;QAClD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IACnB,CAAC,CAAC;SACD,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE;QACT,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;QAChB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IACnB,CAAC,CAAC,CAAA;CACT"}
@@ -0,0 +1,3 @@
1
+ export { run as deployProtocol } from './protocol.js';
2
+ export { run as deployDapp } from './dapp.js';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/contract/deploy/index.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,GAAG,IAAI,cAAc,EAAE,MAAM,eAAe,CAAA;AACrD,OAAO,EAAE,GAAG,IAAI,UAAU,EAAE,MAAM,WAAW,CAAA"}
@@ -0,0 +1,16 @@
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
+ export { run as deployProtocol } from './protocol.js';
15
+ export { run as deployDapp } from './dapp.js';
16
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/contract/deploy/index.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,GAAG,IAAI,cAAc,EAAE,MAAM,eAAe,CAAA;AACrD,OAAO,EAAE,GAAG,IAAI,UAAU,EAAE,MAAM,WAAW,CAAA"}
@@ -0,0 +1,3 @@
1
+ import { AccountId } from '@polkadot/types/interfaces';
2
+ export declare function run(wasmPath: string, abiPath: string, deployer?: string): Promise<AccountId>;
3
+ //# sourceMappingURL=protocol.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../../../src/contract/deploy/protocol.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,SAAS,EAAe,MAAM,4BAA4B,CAAA;AA6BnE,wBAAsB,GAAG,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC,CAYlG"}
@@ -0,0 +1,53 @@
1
+ import { AbiJSON, Wasm } from '../../util/index.js';
2
+ import { ContractDeployer } from '@prosopo/contract';
3
+ import { LogLevel, getLogger, reverseHexString } from '@prosopo/common';
4
+ import { ProviderEnvironment } from '@prosopo/env';
5
+ import { defaultConfig, getPairType, getSecret, getSs58Format } from '@prosopo/cli';
6
+ import { getPair } from '@prosopo/common';
7
+ import { loadEnv } from '@prosopo/cli';
8
+ import { randomAsHex } from '@polkadot/util-crypto';
9
+ import path from 'path';
10
+ const log = getLogger(LogLevel.enum.info, 'dev.deploy');
11
+ async function deploy(wasm, abi, deployerPrefix) {
12
+ const pairType = getPairType();
13
+ const ss58Format = getSs58Format();
14
+ const secret = deployerPrefix ? getSecret(deployerPrefix) : '//Alice';
15
+ const pair = await getPair(pairType, ss58Format, secret);
16
+ const config = defaultConfig();
17
+ const env = new ProviderEnvironment(pair, config);
18
+ await env.isReady();
19
+ log.debug(reverseHexString(env.getApi().createType('u16', 10).toHex().toString()), 'max_user_history_len');
20
+ log.debug(reverseHexString(env.getApi().createType('BlockNumber', 32).toHex().toString()), 'max_user_history_age');
21
+ log.debug(reverseHexString(env.getApi().createType('u16', 1).toHex().toString()), 'min_num_active_providers');
22
+ const params = [];
23
+ const deployer = new ContractDeployer(env.getApi(), abi, wasm, env.pair, params, 0, 0, randomAsHex());
24
+ return await deployer.deploy();
25
+ }
26
+ export async function run(wasmPath, abiPath, deployer) {
27
+ log.info('WASM Path', wasmPath);
28
+ log.info('ABI Path', abiPath);
29
+ const wasm = await Wasm(path.resolve(wasmPath));
30
+ const abi = await AbiJSON(path.resolve(abiPath));
31
+ const deployResult = await deploy(wasm, abi, deployer);
32
+ const instantiateEvent = deployResult.events.find((event) => event.event.section === 'contracts' && event.event.method === 'Instantiated');
33
+ log.info('instantiateEvent', instantiateEvent?.toHuman());
34
+ return (instantiateEvent?.event.data)['contract'].toString();
35
+ }
36
+ // run the script if the main process is running this file
37
+ if (typeof require !== 'undefined' && require.main === module) {
38
+ log.info('Loading env from', path.resolve('.'));
39
+ loadEnv(path.resolve('.'));
40
+ if (!process.env.CAPTCHA_WASM_PATH || !process.env.CAPTCHA_ABI_PATH) {
41
+ throw new Error('Missing protocol wasm or abi path');
42
+ }
43
+ run(process.env.CAPTCHA_WASM_PATH, process.env.CAPTCHA_ABI_PATH)
44
+ .then((deployResult) => {
45
+ log.info('Deployed with address', deployResult);
46
+ process.exit(0);
47
+ })
48
+ .catch((e) => {
49
+ console.error(e);
50
+ process.exit(1);
51
+ });
52
+ }
53
+ //# sourceMappingURL=protocol.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"protocol.js","sourceRoot":"","sources":["../../../src/contract/deploy/protocol.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAA;AAEnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAA;AACpD,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AACvE,OA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CAAC,CAAA;IACzD,OAAO,CAAC,gBAAgB,EAAE,KAAK,CAAC,IAAY,CAAA,CAAC,UAAU,CAAC,CAAC,QAAQ,EAAE,CAAA;AACvE,CAAC;AACD,0DAA0D;AAC1D,IAAI,OAAO,OAAO,KAAK,WAAW,IAAI,OAAO,CAAC,IAAI,KAAK,MAAM,EAAE;IAC3D,GAAG,CAAC,IAAI,CAAC,kBAAkB,EAAE,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAA;IAC/C,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAA;IAC1B,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,iBAAiB,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,gBAAgB,EAAE;QACjE,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAA;KACvD;IACD,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,iBAAiB,EAAE,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC;SAC3D,IAAI,CAAC,CAAC,YAAY,EAAE,EAAE;QACnB,GAAG,CAAC,IAAI,CAAC,uBAAuB,EAAE,YAAY,CAAC,CAAA;QAC/C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IACnB,CAAC,CAAC;SACD,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE;QACT,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;QAChB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IACnB,CAAC,CAAC,CAAA;CACT"}
@@ -0,0 +1,4 @@
1
+ import { ExecOutput } from '../util/index.js';
2
+ declare function importContract(relPathToABIs: string, relPathToOutput: string): Promise<ExecOutput>;
3
+ export default importContract;
4
+ //# sourceMappingURL=import.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"import.d.ts","sourceRoot":"","sources":["../../src/contract/import.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,UAAU,EAAQ,MAAM,kBAAkB,CAAA;AAEnD,iBAAe,cAAc,CAAC,aAAa,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAIjG;AAED,eAAe,cAAc,CAAA"}
@@ -0,0 +1,21 @@
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 { exec } from '../util/index.js';
15
+ async function importContract(relPathToABIs, relPathToOutput) {
16
+ //TODO import typechain when it's working https://github.com/Brushfam/typechain-polkadot/issues/73
17
+ const cmd = `npx @727-ventures/typechain-polkadot --in ${relPathToABIs} --out ${relPathToOutput}`;
18
+ return exec(cmd);
19
+ }
20
+ export default importContract;
21
+ //# sourceMappingURL=import.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"import.js","sourceRoot":"","sources":["../../src/contract/import.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,EAAc,IAAI,EAAE,MAAM,kBAAkB,CAAA;AAEnD,KAAK,UAAU,cAAc,CAAC,aAAqB,EAAE,eAAuB;IACxE,kGAAkG;IAClG,MAAM,GAAG,GAAG,6CAA6C,aAAa,UAAU,eAAe,EAAE,CAAA;IACjG,OAAO,IAAI,CAAC,GAAG,CAAC,CAAA;AACpB,CAAC;AAED,eAAe,cAAc,CAAA"}
@@ -0,0 +1,3 @@
1
+ export { default as importContract } from './import.js';
2
+ export * from './deploy/index.js';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/contract/index.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,aAAa,CAAA;AACvD,cAAc,mBAAmB,CAAA"}
@@ -0,0 +1,16 @@
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
+ export { default as importContract } from './import.js';
15
+ export * from './deploy/index.js';
16
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/contract/index.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,OAAO,IAAI,cAAc,EAAE,MAAM,aAAa,CAAA;AACvD,cAAc,mBAAmB,CAAA"}
@@ -0,0 +1,5 @@
1
+ export * from './setup/index.js';
2
+ export * from './util/index.js';
3
+ export * from './cli/index.js';
4
+ export * from './contract/index.js';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAaA,cAAc,kBAAkB,CAAA;AAChC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,qBAAqB,CAAA"}
package/dist/index.js ADDED
@@ -0,0 +1,18 @@
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
+ export * from './setup/index.js';
15
+ export * from './util/index.js';
16
+ export * from './cli/index.js';
17
+ export * from './contract/index.js';
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.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,cAAc,kBAAkB,CAAA;AAChC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,qBAAqB,CAAA"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=addCopyrightNotice.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"addCopyrightNotice.d.ts","sourceRoot":"","sources":["../../src/scripts/addCopyrightNotice.ts"],"names":[],"mappings":""}
@@ -0,0 +1,104 @@
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 { glob } from 'glob';
16
+ import fs from 'fs';
17
+ const searchPaths = [
18
+ '../**/*.ts',
19
+ '../../**/*.ts',
20
+ '../../../**/*.ts',
21
+ '../**/*.tsx',
22
+ '../../**/*.tsx',
23
+ '../../../**/*.tsx',
24
+ '../**/*.rs',
25
+ '../../**/*.rs',
26
+ '../../../**/*.rs',
27
+ '../../../**/**/*.rs',
28
+ '../../../**/**/**/*.rs',
29
+ ];
30
+ const files = glob.sync(searchPaths, {
31
+ cwd: __dirname,
32
+ absolute: true,
33
+ ignore: [
34
+ 'node_modules/**',
35
+ 'node_modules/**',
36
+ '../../**/node_modules/**',
37
+ '../node_modules/**',
38
+ '../../node_modules/**',
39
+ '../../../node_modules/**',
40
+ '**/dist/**',
41
+ '**/**/dist/**',
42
+ '../../dist/**',
43
+ '../../../packages/**/node_modules/**',
44
+ '../../../demos/**/node_modules/**',
45
+ '../../../packages/**/dist/**',
46
+ '../../../demos/**/dist/**',
47
+ ],
48
+ });
49
+ console.log('Modding:\n', JSON.stringify(files, null, 4));
50
+ const header = `// Copyright 2021-2023 Prosopo (UK) Ltd.
51
+ //
52
+ // Licensed under the Apache License, Version 2.0 (the "License");
53
+ // you may not use this file except in compliance with the License.
54
+ // You may obtain a copy of the License at
55
+ //
56
+ // http://www.apache.org/licenses/LICENSE-2.0
57
+ //
58
+ // Unless required by applicable law or agreed to in writing, software
59
+ // distributed under the License is distributed on an "AS IS" BASIS,
60
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
61
+ // See the License for the specific language governing permissions and
62
+ // limitations under the License.`;
63
+ // for each file, check if file starts with // Copyright (C) Prosopo (UK) Ltd.
64
+ for (const file of files) {
65
+ if (fs.lstatSync(file).isFile()) {
66
+ //check if file is a file, not a directory
67
+ const fileContents = fs.readFileSync(file, 'utf8');
68
+ const lines = fileContents.split('\n');
69
+ if (at(lines, 0).startsWith('// Copyright')) {
70
+ //remove the old license and replace with the new one
71
+ // find the line containing `// along with Prosopo Procaptcha. If not, see <http://www.gnu.org/licenses/>.` and take the lines array from there
72
+ let count = 0;
73
+ let line = at(lines, count);
74
+ let lineStartsWithSlashes = line.startsWith('//');
75
+ while (lineStartsWithSlashes) {
76
+ lineStartsWithSlashes = line.startsWith('//');
77
+ if (lineStartsWithSlashes) {
78
+ line = at(lines, ++count);
79
+ }
80
+ }
81
+ if (!line.startsWith('//')) {
82
+ count = count - 1;
83
+ line = at(lines, count);
84
+ }
85
+ if (line.endsWith('If not, see <http://www.gnu.org/licenses/>.') ||
86
+ line.endsWith('// limitations under the License.')) {
87
+ const newFileContents = `${header}\n${lines.slice(count + 1).join('\n')}`;
88
+ if (newFileContents !== fileContents) {
89
+ //console.log(newFileContents)
90
+ fs.writeFileSync(file, newFileContents);
91
+ console.log('File Updated:', file);
92
+ }
93
+ }
94
+ }
95
+ else {
96
+ // if it doesn't, add it
97
+ const newFileContents = `${header}\n${fileContents}`;
98
+ //console.log(newFileContents)
99
+ fs.writeFileSync(file, newFileContents);
100
+ console.log('File Updated:', file);
101
+ }
102
+ }
103
+ }
104
+ //# sourceMappingURL=addCopyrightNotice.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"addCopyrightNotice.js","sourceRoot":"","sources":["../../src/scripts/addCopyrightNotice.ts"],"names":[],"mappings":"AAAA,wCAAwC;AACxC,EAAE;AACF,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,iDAAiD;AACjD,EAAE;AACF,sEAAsE;AACtE,oEAAoE;A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J;CACJ"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=bytesToHex.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bytesToHex.d.ts","sourceRoot":"","sources":["../../src/scripts/bytesToHex.ts"],"names":[],"mappings":""}
@@ -0,0 +1,22 @@
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
+ const arg = at(process.argv.slice(2), 0).trim();
16
+ console.log(`arg : ${arg}`);
17
+ const byteArray = arg.split(',').map((x) => parseInt(x));
18
+ const hex = Array.from(byteArray, function (byte) {
19
+ return ('0' + (byte & 0xff).toString(16)).slice(-2);
20
+ }).join('');
21
+ console.log(hex);
22
+ //# sourceMappingURL=bytesToHex.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bytesToHex.js","sourceRoot":"","sources":["../../src/scripts/bytesToHex.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,EAAE,EAAE,MAAM,eAAe,CAAA;AAElC,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,MAAM,SAAS,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAA;AAExD,MAAM,GAAG,GAAG,KAAK,CAAC,IAAI,CAAC,SAAS,EAAE,UAAU,IAAI;IAC5C,OAAO,CAAC,GAAG,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAA;AACvD,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;AAEX,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=convertAccount.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"convertAccount.d.ts","sourceRoot":"","sources":["../../src/scripts/convertAccount.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 { at } from '@prosopo/util';
15
+ import { decodeAddress, encodeAddress } from '@polkadot/keyring';
16
+ import { hexToU8a, isHex, u8aToHex } from '@polkadot/util';
17
+ import { isAddress } from '@polkadot/util-crypto';
18
+ const ss58Format = 42;
19
+ const arg = at(process.argv.slice(2), 0).trim();
20
+ let bytes = undefined;
21
+ let hex = undefined;
22
+ let ss58 = undefined;
23
+ if (isAddress(arg)) {
24
+ bytes = decodeAddress(arg);
25
+ }
26
+ else if (isHex(arg)) {
27
+ bytes = hexToU8a(arg);
28
+ }
29
+ else {
30
+ // must be byte array in json format
31
+ bytes = new Uint8Array(JSON.parse(arg));
32
+ }
33
+ hex = hex || u8aToHex(bytes);
34
+ ss58 = ss58 || encodeAddress(hex, ss58Format);
35
+ console.log(`bytes: [${bytes}]`);
36
+ console.log(`hex: ${hex}`);
37
+ console.log(`ss58: ${ss58}`);
38
+ //# sourceMappingURL=convertAccount.js.map