@prosopo/scripts 3.1.34 → 3.1.95
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.
- package/.turbo/turbo-build$colon$cjs.log +7 -3
- package/.turbo/turbo-build$colon$tsc.log +83 -0
- package/.turbo/turbo-build.log +14 -6
- package/CHANGELOG.md +748 -0
- package/README.md +25 -131
- package/dist/cjs/cli/index.cjs +3 -3
- package/dist/cjs/scripts/setVersion.cjs +3 -3
- package/dist/cjs/setup/setup.cjs +3 -2
- package/dist/cli/index.d.ts +2 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +1 -1
- package/dist/cli/index.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js.map +1 -0
- package/dist/scripts/bytesToHex.d.ts +2 -0
- package/dist/scripts/bytesToHex.d.ts.map +1 -0
- package/dist/scripts/bytesToHex.js +7 -0
- package/dist/scripts/bytesToHex.js.map +1 -0
- package/dist/scripts/convertAccount.d.ts +2 -0
- package/dist/scripts/convertAccount.d.ts.map +1 -0
- package/dist/scripts/convertAccount.js +24 -0
- package/dist/scripts/convertAccount.js.map +1 -0
- package/dist/scripts/encodeDecode.d.ts +2 -0
- package/dist/scripts/encodeDecode.d.ts.map +1 -0
- package/dist/scripts/encodeDecode.js +108 -0
- package/dist/scripts/encodeDecode.js.map +1 -0
- package/dist/scripts/findUnused.d.ts +2 -0
- package/dist/scripts/findUnused.d.ts.map +1 -0
- package/dist/scripts/findUnused.js +80 -0
- package/dist/scripts/findUnused.js.map +1 -0
- package/dist/scripts/generateMnemonic.d.ts +2 -0
- package/dist/scripts/generateMnemonic.d.ts.map +1 -0
- package/dist/scripts/generateMnemonic.js +26 -0
- package/dist/scripts/generateMnemonic.js.map +1 -0
- package/dist/scripts/hash.d.ts +2 -0
- package/dist/scripts/hash.d.ts.map +1 -0
- package/dist/scripts/hash.js +41 -0
- package/dist/scripts/hash.js.map +1 -0
- package/dist/scripts/hexToBytes.d.ts +2 -0
- package/dist/scripts/hexToBytes.d.ts.map +1 -0
- package/dist/scripts/hexToBytes.js +6 -0
- package/dist/scripts/hexToBytes.js.map +1 -0
- package/dist/scripts/mnemonicToAddr.d.ts +2 -0
- package/dist/scripts/mnemonicToAddr.d.ts.map +1 -0
- package/dist/scripts/mnemonicToAddr.js +14 -0
- package/dist/scripts/mnemonicToAddr.js.map +1 -0
- package/dist/scripts/providerApiSign.d.ts +2 -0
- package/dist/scripts/providerApiSign.d.ts.map +1 -0
- package/dist/scripts/providerApiSign.js +9 -0
- package/dist/scripts/providerApiSign.js.map +1 -0
- package/dist/scripts/setVersion.d.ts +2 -0
- package/dist/scripts/setVersion.d.ts.map +1 -0
- package/dist/scripts/setVersion.js +1 -1
- package/dist/scripts/setVersion.js.map +1 -0
- package/dist/scripts/sign.d.ts +2 -0
- package/dist/scripts/sign.d.ts.map +1 -0
- package/dist/scripts/sign.js +41 -0
- package/dist/scripts/sign.js.map +1 -0
- package/dist/scripts/testImport.d.ts +2 -0
- package/dist/scripts/testImport.d.ts.map +1 -0
- package/dist/scripts/testImport.js +13 -0
- package/dist/scripts/testImport.js.map +1 -0
- package/dist/setup/index.d.ts +3 -0
- package/dist/setup/index.d.ts.map +1 -0
- package/dist/setup/index.js.map +1 -0
- package/dist/setup/provider.d.ts +3 -0
- package/dist/setup/provider.d.ts.map +1 -0
- package/dist/setup/provider.js.map +1 -0
- package/dist/setup/setup.d.ts +3 -0
- package/dist/setup/setup.d.ts.map +1 -0
- package/dist/setup/setup.js +3 -2
- package/dist/setup/setup.js.map +1 -0
- package/dist/setup/site.d.ts +4 -0
- package/dist/setup/site.d.ts.map +1 -0
- package/dist/setup/site.js.map +1 -0
- package/dist/util/exec.d.ts +10 -0
- package/dist/util/exec.d.ts.map +1 -0
- package/dist/util/exec.js.map +1 -0
- package/dist/util/fluxLogDappDetails.d.ts +2 -0
- package/dist/util/fluxLogDappDetails.d.ts.map +1 -0
- package/dist/util/fluxLogDappDetails.js.map +1 -0
- package/dist/util/index.d.ts +4 -0
- package/dist/util/index.d.ts.map +1 -0
- package/dist/util/index.js.map +1 -0
- package/dist/util/updateEnv.d.ts +5 -0
- package/dist/util/updateEnv.d.ts.map +1 -0
- package/dist/util/updateEnv.js.map +1 -0
- package/dist/workspace/dist/index.js +2 -1
- package/dist/workspace/dist/projectInfo.js +41 -0
- package/env.production +32 -0
- package/env.staging +2 -1
- package/package.json +23 -16
- package/tsconfig.cjs.json +56 -0
- package/tsconfig.types.json +9 -0
- package/vite.cjs.config.ts +1 -1
- package/vite.esm.config.ts +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Prosopo Dev Scripts Package
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Scripts and configuration for setting up a Prosopo development environment.
|
|
4
4
|
|
|
5
5
|
## Prerequisites
|
|
6
6
|
|
|
@@ -27,183 +27,77 @@ cp dev/scripts/env.development packages/procaptcha-bundle/.env.development
|
|
|
27
27
|
npm run setup:all
|
|
28
28
|
```
|
|
29
29
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
#### Terminal 1
|
|
30
|
+
Then start services in separate terminals:
|
|
33
31
|
|
|
34
32
|
```bash
|
|
33
|
+
# Terminal 1 - Example server
|
|
35
34
|
npm run start:server
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
#### Terminal 2
|
|
39
35
|
|
|
40
|
-
|
|
36
|
+
# Terminal 2 - Provider API
|
|
41
37
|
npm run start:provider
|
|
42
|
-
```
|
|
43
38
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
```bash
|
|
39
|
+
# Terminal 3 - Demo app
|
|
47
40
|
npm run start:demo
|
|
48
41
|
```
|
|
49
42
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
### In-depth
|
|
53
|
-
|
|
54
|
-
#### Set up Containers
|
|
43
|
+
### Step by Step
|
|
55
44
|
|
|
56
|
-
|
|
57
|
-
the [scripts](https://github.com/prosopo/scripts) repository.
|
|
45
|
+
#### 1. Start Containers
|
|
58
46
|
|
|
59
47
|
```bash
|
|
60
48
|
docker compose --file ./docker/docker-compose.development.yml up -d
|
|
61
49
|
```
|
|
62
50
|
|
|
63
|
-
#### Install
|
|
64
|
-
|
|
65
|
-
Install the node modules by running the following command from the root of the captcha workspace.
|
|
51
|
+
#### 2. Install Dependencies
|
|
66
52
|
|
|
67
53
|
```bash
|
|
68
54
|
npm i
|
|
69
55
|
```
|
|
70
56
|
|
|
71
|
-
#### Build
|
|
72
|
-
|
|
73
|
-
Build all packages by running the following command from the root of the captcha workspace.
|
|
57
|
+
#### 3. Build All Packages
|
|
74
58
|
|
|
75
59
|
```bash
|
|
76
60
|
npm run build:all
|
|
77
61
|
```
|
|
78
62
|
|
|
79
|
-
####
|
|
80
|
-
|
|
81
|
-
If you want to deploy the Procaptcha protocol contract, you can do so by running the following command from the root
|
|
82
|
-
of the captcha workspace. Any .env files will be updated with the new contract addresses.
|
|
83
|
-
|
|
84
|
-
```bash
|
|
85
|
-
npm run deploy_protocol
|
|
86
|
-
npm run setup
|
|
87
|
-
```
|
|
63
|
+
#### 4. Configure Environment
|
|
88
64
|
|
|
89
|
-
|
|
65
|
+
Copy the template env files. You can use `./dev/scripts/env.development` as a base.
|
|
90
66
|
|
|
91
|
-
|
|
67
|
+
#### 5. Run Setup
|
|
92
68
|
|
|
93
|
-
|
|
94
|
-
file `./dev/scripts/env.development` as a template.
|
|
69
|
+
Registers a provider, loads a dataset, and registers site keys:
|
|
95
70
|
|
|
96
|
-
|
|
71
|
+
```bash
|
|
72
|
+
npm run setup:all
|
|
73
|
+
```
|
|
97
74
|
|
|
98
|
-
|
|
99
|
-
workspace to register a Provider and a Dapp in the Protocol contract and start the Provider API.
|
|
75
|
+
#### 6. Start Services
|
|
100
76
|
|
|
101
77
|
```bash
|
|
102
|
-
npm run
|
|
78
|
+
npm run start:provider
|
|
103
79
|
```
|
|
104
80
|
|
|
105
|
-
The **Protocol** contract **must** exist on the substrate node for the setup script to run.
|
|
106
|
-
|
|
107
81
|
## Testing
|
|
108
82
|
|
|
109
|
-
### Run tests
|
|
110
|
-
|
|
111
|
-
Run all the tests using the following command from the root of the captcha workspace.
|
|
112
|
-
|
|
113
83
|
```bash
|
|
114
84
|
npm run test
|
|
115
85
|
```
|
|
116
86
|
|
|
117
87
|
## CLI
|
|
118
88
|
|
|
119
|
-
The
|
|
120
|
-
|
|
121
|
-
### Deploy Protocol Contract
|
|
122
|
-
|
|
123
|
-
From the root of the `captcha` workspace run:
|
|
124
|
-
|
|
125
|
-
```bash
|
|
126
|
-
npm run deploy_protocol
|
|
127
|
-
```
|
|
128
|
-
|
|
129
|
-
This is shorthand for the following command:
|
|
130
|
-
|
|
131
|
-
```bash
|
|
132
|
-
npm run -w @prosopo/scripts cli deploy_protocol --update_env
|
|
133
|
-
```
|
|
134
|
-
|
|
135
|
-
Specify the current working directory if you are running from a different location.
|
|
136
|
-
|
|
137
|
-
```bash
|
|
138
|
-
npm run -w @prosopo/scripts cli deploy_protocol --update_env --cwd $(pwd)
|
|
139
|
-
```
|
|
140
|
-
|
|
141
|
-
The default environment is `development`. To deploy to a different environment, set the `NODE_ENV` environment variable.
|
|
142
|
-
|
|
143
|
-
```bash
|
|
144
|
-
NODE_ENV=test npm run -w @prosopo/scripts cli deploy_protocol --update_env
|
|
145
|
-
```
|
|
146
|
-
|
|
147
|
-
### Create env files
|
|
148
|
-
|
|
149
|
-
TODO
|
|
150
|
-
|
|
151
|
-
### Setup the Protocol Contract
|
|
89
|
+
The dev scripts CLI provides development utilities:
|
|
152
90
|
|
|
153
91
|
```bash
|
|
92
|
+
# Run the setup (register provider, load dataset, register site keys)
|
|
154
93
|
npm run setup
|
|
155
|
-
```
|
|
156
|
-
|
|
157
|
-
### Import Contracts using Typechain
|
|
158
|
-
|
|
159
|
-
```bash
|
|
160
|
-
...
|
|
161
|
-
```
|
|
162
|
-
|
|
163
|
-
### Import All Contracts
|
|
164
94
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
```
|
|
95
|
+
# Create env files from templates
|
|
96
|
+
npm run -w @prosopo/scripts -- cli create_env_files
|
|
168
97
|
|
|
169
|
-
|
|
98
|
+
# Encode/decode Procaptcha tokens
|
|
99
|
+
npm run -w @prosopo/scripts -- cli token
|
|
170
100
|
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
```bash
|
|
174
|
-
npm run -w @prosopo/scripts -- cli fund_dapps
|
|
175
|
-
```
|
|
176
|
-
|
|
177
|
-
### Transfer Contract between networks
|
|
178
|
-
|
|
179
|
-
By default, the current `.env` setup will be used as the `--transfer-to` network.
|
|
180
|
-
|
|
181
|
-
```bash
|
|
182
|
-
Transfer dapps and providers from one contract to another
|
|
183
|
-
|
|
184
|
-
Options:
|
|
185
|
-
--help Show help [boolean]
|
|
186
|
-
--version Show version number [boolean]
|
|
187
|
-
--transfer-from The name of the network and the contract address to tran
|
|
188
|
-
sfer from `{ network, address }` [string] [required]
|
|
189
|
-
--transfer-to The name of the network and the contract address to tran
|
|
190
|
-
sfer to `{ network, address }` [string]
|
|
191
|
-
--transfer-providers Whether to transfer providers or not
|
|
192
|
-
[boolean] [required] [default: false]
|
|
193
|
-
--transfer-dapps Whether to transfer dapps or not
|
|
194
|
-
[boolean] [required] [default: false]
|
|
195
|
-
```
|
|
196
|
-
|
|
197
|
-
From the root of the workspace run:
|
|
198
|
-
|
|
199
|
-
```bash
|
|
200
|
-
npm run -w @prosopo/scripts -- cli transfer_contract --transfer-from '{"network":"rococo", "address":"..."}' --transfer-dapps=true --transfer-providers=true
|
|
201
|
-
```
|
|
202
|
-
|
|
203
|
-
### Display Version
|
|
204
|
-
|
|
205
|
-
From the root of the workspace run:
|
|
206
|
-
|
|
207
|
-
```bash
|
|
101
|
+
# Display version
|
|
208
102
|
npm run -w @prosopo/scripts -- cli --version
|
|
209
103
|
```
|
package/dist/cjs/cli/index.cjs
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const path = require("node:path");
|
|
4
4
|
const util = require("@polkadot/util");
|
|
5
|
-
const common = require("@prosopo/common");
|
|
6
5
|
const dotenv = require("@prosopo/dotenv");
|
|
6
|
+
const logger = require("@prosopo/logger");
|
|
7
7
|
const types = require("@prosopo/types");
|
|
8
8
|
const workspace = require("@prosopo/workspace");
|
|
9
9
|
const yargs = require("yargs");
|
|
@@ -18,9 +18,9 @@ dotenv.loadEnv(rootDir);
|
|
|
18
18
|
async function processArgs(args) {
|
|
19
19
|
const parsed = await yargs(helpers.hideBin(args)).option("logLevel", {
|
|
20
20
|
describe: "set log level",
|
|
21
|
-
choices: Object.keys(
|
|
21
|
+
choices: Object.keys(logger.LogLevel.enum)
|
|
22
22
|
}).argv;
|
|
23
|
-
const log =
|
|
23
|
+
const log = logger.getLogger(logger.parseLogLevel(parsed.logLevel), "CLI");
|
|
24
24
|
await yargs(helpers.hideBin(args)).usage("Usage: $0 [global options] <command> [options]").command(
|
|
25
25
|
"create_env_files",
|
|
26
26
|
"Copies the env.xyz files to .env.xyz",
|
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
const fs = require("node:fs");
|
|
3
3
|
const path = require("node:path");
|
|
4
4
|
const toml = require("@iarna/toml");
|
|
5
|
-
const common = require("@prosopo/common");
|
|
6
5
|
const dotenv = require("@prosopo/dotenv");
|
|
6
|
+
const logger = require("@prosopo/logger");
|
|
7
7
|
const workspace = require("@prosopo/workspace");
|
|
8
8
|
dotenv.loadEnv();
|
|
9
|
-
const logLevel =
|
|
10
|
-
const log =
|
|
9
|
+
const logLevel = logger.parseLogLevel(process.env.PROSOPO_LOG_LEVEL);
|
|
10
|
+
const log = logger.getLogger(logLevel, "setVersion");
|
|
11
11
|
log.info(() => ({ data: { logLevel } }));
|
|
12
12
|
const parseVersion = (version) => {
|
|
13
13
|
try {
|
package/dist/cjs/setup/setup.cjs
CHANGED
|
@@ -6,13 +6,14 @@ const common = require("@prosopo/common");
|
|
|
6
6
|
const dotenv = require("@prosopo/dotenv");
|
|
7
7
|
const env = require("@prosopo/env");
|
|
8
8
|
const keyring = require("@prosopo/keyring");
|
|
9
|
+
const logger$1 = require("@prosopo/logger");
|
|
9
10
|
const util = require("@prosopo/util");
|
|
10
11
|
const fse = require("fs-extra");
|
|
11
12
|
require("../util/index.cjs");
|
|
12
13
|
const provider = require("./provider.cjs");
|
|
13
14
|
const site = require("./site.cjs");
|
|
14
15
|
const updateEnv = require("../util/updateEnv.cjs");
|
|
15
|
-
const logger =
|
|
16
|
+
const logger = logger$1.getLogger(logger$1.LogLevel.enum.info, "setup");
|
|
16
17
|
const __dirname$1 = path.resolve();
|
|
17
18
|
function getRootDir() {
|
|
18
19
|
const rootDir = process.env.PROSOPO_ROOT_DIR || path.resolve(__dirname$1, "../..");
|
|
@@ -27,7 +28,7 @@ function getDatasetFilePath() {
|
|
|
27
28
|
function getDefaultProvider() {
|
|
28
29
|
const host = process.env.PROSOPO_PROVIDER_HOST || "localhost";
|
|
29
30
|
return {
|
|
30
|
-
url: process.env.PROSOPO_API_PORT ? `
|
|
31
|
+
url: process.env.PROSOPO_API_PORT ? `https://${host}:${process.env.PROSOPO_API_PORT}` : `https://${host}:9229`,
|
|
31
32
|
datasetFile: getDatasetFilePath(),
|
|
32
33
|
address: process.env.PROSOPO_PROVIDER_ADDRESS || "",
|
|
33
34
|
secret: cli.getSecret(),
|
|
@@ -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,iBA8E/C"}
|
package/dist/cli/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
2
|
import { isHex } from "@polkadot/util";
|
|
3
|
-
import { LogLevel, getLogger, parseLogLevel } from "@prosopo/common";
|
|
4
3
|
import { loadEnv, getEnv } from "@prosopo/dotenv";
|
|
4
|
+
import { LogLevel, getLogger, parseLogLevel } from "@prosopo/logger";
|
|
5
5
|
import { encodeProcaptchaOutput, decodeProcaptchaOutput } from "@prosopo/types";
|
|
6
6
|
import "../workspace/dist/index.js";
|
|
7
7
|
import yargs from "yargs";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":"AAcA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACvC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,sBAAsB,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AAChF,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,UAAU,MAAM,0BAA0B,CAAC;AAClD,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;AAElC,OAAO,CAAC,OAAO,CAAC,CAAC;AAEjB,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,IAAc;IAC/C,MAAM,MAAM,GAAG,MAAM,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,UAAU,EAAE;QAC5D,QAAQ,EAAE,eAAe;QACzB,OAAO,EAAE,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,I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,CAAC,CAAC,CAAC;YACL,CAAC;QACF,CAAC;KACD,CAAC,CAAC,IAAI,CAAC;AACV,CAAC;AACD,WAAW,CAAC,OAAO,CAAC,IAAI,CAAC;KACvB,IAAI,CAAC,GAAG,EAAE;IACV,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AACjB,CAAC,CAAC;KACD,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;IAChB,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IACrB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AACjB,CAAC,CAAC,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAaA,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAaA,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bytesToHex.d.ts","sourceRoot":"","sources":["../../src/scripts/bytesToHex.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { at } from "@prosopo/util";
|
|
2
|
+
const arg = at(process.argv.slice(2), 0).trim();
|
|
3
|
+
console.log(`arg : ${arg}`);
|
|
4
|
+
const byteArray = arg.split(",").map((x) => Number.parseInt(x));
|
|
5
|
+
const hex = Array.from(byteArray, (byte) => `0${(byte & 0xff).toString(16)}`.slice(-2)).join("");
|
|
6
|
+
console.log(hex);
|
|
7
|
+
//# sourceMappingURL=bytesToHex.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bytesToHex.js","sourceRoot":"","sources":["../../src/scripts/bytesToHex.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,EAAE,EAAE,MAAM,eAAe,CAAC;AAEnC,MAAM,GAAG,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;AAChD,OAAO,CAAC,GAAG,CAAC,kBAAkB,GAAG,EAAE,CAAC,CAAC;AAErC,MAAM,SAAS,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;AAEhE,MAAM,GAAG,GAAG,KAAK,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC,IAAI,EAAE,EAAE,CAC1C,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAC1C,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AAEX,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"convertAccount.d.ts","sourceRoot":"","sources":["../../src/scripts/convertAccount.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { hexToU8a, isHex, u8aToHex } from "@polkadot/util";
|
|
2
|
+
import { isAddress } from "@polkadot/util-crypto";
|
|
3
|
+
import { at } from "@prosopo/util";
|
|
4
|
+
import { decodeAddress, encodeAddress } from "@prosopo/util-crypto";
|
|
5
|
+
const ss58Format = 42;
|
|
6
|
+
const arg = at(process.argv.slice(2), 0).trim();
|
|
7
|
+
let bytes = undefined;
|
|
8
|
+
let hex = undefined;
|
|
9
|
+
let ss58 = undefined;
|
|
10
|
+
if (isAddress(arg)) {
|
|
11
|
+
bytes = decodeAddress(arg);
|
|
12
|
+
}
|
|
13
|
+
else if (isHex(arg)) {
|
|
14
|
+
bytes = hexToU8a(arg);
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
bytes = new Uint8Array(JSON.parse(arg));
|
|
18
|
+
}
|
|
19
|
+
hex = hex || u8aToHex(bytes);
|
|
20
|
+
ss58 = ss58 || encodeAddress(hex, ss58Format);
|
|
21
|
+
console.log(`bytes: [${bytes}]`);
|
|
22
|
+
console.log(`hex: ${hex}`);
|
|
23
|
+
console.log(`ss58: ${ss58}`);
|
|
24
|
+
//# sourceMappingURL=convertAccount.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"convertAccount.js","sourceRoot":"","sources":["../../src/scripts/convertAccount.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC3D,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAclD,OAAO,EAAE,EAAE,EAAE,MAAM,eAAe,CAAC;AACnC,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAEpE,MAAM,UAAU,GAAG,EAAE,CAAC;AAEtB,MAAM,GAAG,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;AAEhD,IAAI,KAAK,GAA2B,SAAS,CAAC;AAC9C,IAAI,GAAG,GAAuB,SAAS,CAAC;AACxC,IAAI,IAAI,GAAuB,SAAS,CAAC;AAEzC,IAAI,SAAS,CAAC,GAAG,CAAC,EAAE,CAAC;IACpB,KAAK,GAAG,aAAa,CAAC,GAAG,CAAC,CAAC;AAC5B,CAAC;KAAM,IAAI,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC;IACvB,KAAK,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC;AACvB,CAAC;KAAM,CAAC;IAEP,KAAK,GAAG,IAAI,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;AACzC,CAAC;AAED,GAAG,GAAG,GAAG,IAAI,QAAQ,CAAC,KAAK,CAAC,CAAC;AAC7B,IAAI,GAAG,IAAI,IAAI,aAAa,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC;AAE9C,OAAO,CAAC,GAAG,CAAC,WAAW,KAAK,GAAG,CAAC,CAAC;AACjC,OAAO,CAAC,GAAG,CAAC,QAAQ,GAAG,EAAE,CAAC,CAAC;AAC3B,OAAO,CAAC,GAAG,CAAC,SAAS,IAAI,EAAE,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"encodeDecode.d.ts","sourceRoot":"","sources":["../../src/scripts/encodeDecode.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { BN, hexToNumber, hexToString, hexToU8a, isHex, stringToHex, u8aToHex, u8aToString, } from "@polkadot/util";
|
|
2
|
+
import { blake2AsHex, isAddress } from "@polkadot/util-crypto";
|
|
3
|
+
import { at, consoleTableWithWrapping } from "@prosopo/util";
|
|
4
|
+
import { decodeAddress, encodeAddress } from "@prosopo/util-crypto";
|
|
5
|
+
function isJSON(arg) {
|
|
6
|
+
try {
|
|
7
|
+
JSON.parse(arg);
|
|
8
|
+
return true;
|
|
9
|
+
}
|
|
10
|
+
catch (e) {
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
function isBN(arg) {
|
|
15
|
+
try {
|
|
16
|
+
new BN(`0x${arg}`);
|
|
17
|
+
return true;
|
|
18
|
+
}
|
|
19
|
+
catch (e) {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
function main() {
|
|
24
|
+
const ss58Format = process.env.PROSOPO_SS58_FORMAT
|
|
25
|
+
? Number.parseInt(process.env.PROSOPO_SS58_FORMAT)
|
|
26
|
+
: 42;
|
|
27
|
+
const arg = at(process.argv.slice(2), 0).trim();
|
|
28
|
+
const argIsHex = isHex(arg);
|
|
29
|
+
const argIsAddress = isAddress(arg, false, ss58Format);
|
|
30
|
+
const output = [];
|
|
31
|
+
output.push({ name: "arg", value: arg });
|
|
32
|
+
output.push({ name: "length", value: arg.length.toString() });
|
|
33
|
+
output.push({ name: "argIsAddress", value: argIsAddress.toString() });
|
|
34
|
+
output.push({ name: "argIsHex", value: argIsHex.toString() });
|
|
35
|
+
if (argIsAddress) {
|
|
36
|
+
try {
|
|
37
|
+
const encodedAddress = encodeAddress(decodeAddress(arg, false, ss58Format), ss58Format);
|
|
38
|
+
const decodedAddress = decodeAddress(encodedAddress, false, ss58Format);
|
|
39
|
+
if (encodedAddress === arg) {
|
|
40
|
+
const hexAddress = u8aToHex(decodedAddress);
|
|
41
|
+
output.push({ name: "Hex address", value: hexAddress });
|
|
42
|
+
output.push({
|
|
43
|
+
name: "Address bytes",
|
|
44
|
+
value: decodedAddress.toString(),
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
output.push({ name: "Encoded address", value: encodedAddress });
|
|
49
|
+
output.push({
|
|
50
|
+
name: "Address as hex",
|
|
51
|
+
value: u8aToHex(decodeAddress(encodedAddress)),
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
catch (e) {
|
|
56
|
+
output.push({
|
|
57
|
+
name: "Failure encoding/decoding address",
|
|
58
|
+
value: `FAIL - ${e}`,
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
if (argIsHex) {
|
|
63
|
+
output.push({ name: "Decoding hex to string", value: hexToString(arg) });
|
|
64
|
+
try {
|
|
65
|
+
output.push({
|
|
66
|
+
name: "Decoding hex to number",
|
|
67
|
+
value: hexToNumber(arg).toString(),
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
catch (e) {
|
|
71
|
+
output.push({ name: "Decoding hex to number", value: `FAIL - ${e}` });
|
|
72
|
+
}
|
|
73
|
+
output.push({
|
|
74
|
+
name: "Decoding string to hex to u8a",
|
|
75
|
+
value: hexToU8a(stringToHex(arg)).toString(),
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
output.push({
|
|
80
|
+
name: "Hashing string using blake2AsHex",
|
|
81
|
+
value: blake2AsHex(arg),
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
if (isJSON(arg)) {
|
|
85
|
+
const u8aMaybe = JSON.parse(arg);
|
|
86
|
+
output.push({ name: "Found JSON", value: u8aMaybe });
|
|
87
|
+
const padded = new Uint8Array(new Uint8ClampedArray(u8aMaybe));
|
|
88
|
+
padded.set(u8aMaybe);
|
|
89
|
+
output.push({ name: "uint8array", value: padded.toString() });
|
|
90
|
+
const hex = u8aToHex(padded);
|
|
91
|
+
output.push({ name: "u8aToHex", value: u8aToHex(padded) });
|
|
92
|
+
output.push({
|
|
93
|
+
name: "encodeAddress(_, ss58Format)",
|
|
94
|
+
value: encodeAddress(hex, ss58Format),
|
|
95
|
+
});
|
|
96
|
+
output.push({ name: "u8aToString", value: u8aToString(padded) });
|
|
97
|
+
output.push({ name: "stringToHex", value: stringToHex(arg) });
|
|
98
|
+
}
|
|
99
|
+
if (isBN(arg)) {
|
|
100
|
+
output.push({ name: "BN", value: new BN(arg).toString() });
|
|
101
|
+
}
|
|
102
|
+
console.log("\nTABLE OUTPUT\n");
|
|
103
|
+
consoleTableWithWrapping(output);
|
|
104
|
+
console.log("\nJSON OUTPUT\n");
|
|
105
|
+
console.log(JSON.stringify(output, null, 4));
|
|
106
|
+
}
|
|
107
|
+
main();
|
|
108
|
+
//# sourceMappingURL=encodeDecode.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"encodeDecode.js","sourceRoot":"","sources":["../../src/scripts/encodeDecode.ts"],"names":[],"mappings":"AAaA,OAAO,EACN,EAAE,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0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"findUnused.d.ts","sourceRoot":"","sources":["../../src/scripts/findUnused.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { Languages } from "@prosopo/locale";
|
|
2
|
+
const REPO_DIR = "/home/chris/dev/prosopo/captcha-private/captcha";
|
|
3
|
+
import fs from "node:fs";
|
|
4
|
+
import { getRootDir } from "@prosopo/workspace";
|
|
5
|
+
import fg from "fast-glob";
|
|
6
|
+
import json from "../../../../packages/locale/src/locales/en/translation.json" with {
|
|
7
|
+
type: "json"
|
|
8
|
+
};
|
|
9
|
+
const findUsedKeys = (jsonPath, projectPath, usedKeys = []) => {
|
|
10
|
+
const keys = Object.keys(json).reduce((acc, section) => {
|
|
11
|
+
if (typeof json[section] !== "object")
|
|
12
|
+
return acc;
|
|
13
|
+
const sectionKeys = Object.keys(json[section]).map((key) => `${section}.${key}`);
|
|
14
|
+
return acc.concat(sectionKeys);
|
|
15
|
+
}, []);
|
|
16
|
+
console.log("projectPath", projectPath);
|
|
17
|
+
const searchPaths = ["**/*.ts", "**/*.tsx", "**/*.js", "**/*.jsx"];
|
|
18
|
+
const currentPath = getRootDir();
|
|
19
|
+
const files = fg
|
|
20
|
+
.sync(searchPaths, {
|
|
21
|
+
cwd: currentPath,
|
|
22
|
+
absolute: true,
|
|
23
|
+
ignore: [
|
|
24
|
+
"**/node_modules/**",
|
|
25
|
+
"**/cargo-cache/**",
|
|
26
|
+
"**/dist/**",
|
|
27
|
+
"**/target/**",
|
|
28
|
+
"**/coverage/**",
|
|
29
|
+
"**/vite.cjs.config.ts.timestamp*",
|
|
30
|
+
"**/js_bundles_host_temp/**",
|
|
31
|
+
"**/client-bundle-example/src/assets/**",
|
|
32
|
+
"**/next-env.d.ts/**",
|
|
33
|
+
],
|
|
34
|
+
})
|
|
35
|
+
.filter((file) => fs.lstatSync(file).isFile());
|
|
36
|
+
for (const file of files) {
|
|
37
|
+
console.log(file);
|
|
38
|
+
if (file === "node_modules")
|
|
39
|
+
return;
|
|
40
|
+
const filePath = file;
|
|
41
|
+
const stat = fs.statSync(filePath);
|
|
42
|
+
if (stat.isDirectory()) {
|
|
43
|
+
usedKeys = findUsedKeys(jsonPath, filePath, usedKeys);
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
const content = fs.readFileSync(filePath, "utf8");
|
|
47
|
+
for (const key of keys) {
|
|
48
|
+
if (usedKeys.includes(key))
|
|
49
|
+
continue;
|
|
50
|
+
if (content.indexOf(key) !== -1) {
|
|
51
|
+
usedKeys.push(key);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return usedKeys;
|
|
57
|
+
};
|
|
58
|
+
const removeUnusedKeys = (jsonPath, projectPath) => {
|
|
59
|
+
const usedKeys = findUsedKeys(json, "/home/dev/chris/prosopo/captcha-private/captcha");
|
|
60
|
+
const unusedKeys = Object.keys(json)
|
|
61
|
+
.reduce((acc, section) => {
|
|
62
|
+
if (typeof json[section] !== "object")
|
|
63
|
+
return acc;
|
|
64
|
+
const sectionKeys = Object.keys(json[section]).map((key) => `${section}.${key}`);
|
|
65
|
+
return acc.concat(sectionKeys);
|
|
66
|
+
}, [])
|
|
67
|
+
.filter((key) => !usedKeys.includes(key));
|
|
68
|
+
console.info("Unused keys:", Array.from(new Set(unusedKeys)));
|
|
69
|
+
for (const lang of Object.values(Languages)) {
|
|
70
|
+
const langJsonPath = jsonPath.replace("en", lang);
|
|
71
|
+
const langJson = JSON.parse(fs.readFileSync(langJsonPath, "utf8"));
|
|
72
|
+
for (const key of unusedKeys) {
|
|
73
|
+
const [section, keyName] = key.split(".");
|
|
74
|
+
delete langJson[section][keyName];
|
|
75
|
+
}
|
|
76
|
+
fs.writeFileSync(langJsonPath, JSON.stringify(langJson, null, 2));
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
removeUnusedKeys(`${REPO_DIR}/packages/locale/src/locales/en/translation.json`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,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;IACnE,CAAC;AACF,CAAC,CAAC;AAEF,gBAAgB,CACf,GAAG,QAAQ,kDAAkD,EAC7D,QAAQ,CACR,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generateMnemonic.d.ts","sourceRoot":"","sources":["../../src/scripts/generateMnemonic.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { loadEnv } from "@prosopo/dotenv";
|
|
2
|
+
import { generateMnemonic } from "@prosopo/keyring";
|
|
3
|
+
import { getLogger, parseLogLevel } from "@prosopo/logger";
|
|
4
|
+
import { updateEnvFile } from "../setup/index.js";
|
|
5
|
+
loadEnv();
|
|
6
|
+
const logger = getLogger(parseLogLevel(process.env.PROSOPO_LOG_LEVEL), import.meta.url);
|
|
7
|
+
async function mnemonic(addToEnv) {
|
|
8
|
+
const [mnemonic, address] = await generateMnemonic();
|
|
9
|
+
logger.info(() => ({ data: { address }, msg: "Address generated" }));
|
|
10
|
+
logger.info(() => ({ data: { mnemonic }, msg: "Mnemonic generated" }));
|
|
11
|
+
if (addToEnv) {
|
|
12
|
+
await updateEnvFile({
|
|
13
|
+
PROSOPO_PROVIDER_MNEMONIC: `"${mnemonic}"`,
|
|
14
|
+
PROSOPO_PROVIDER_ADDRESS: address,
|
|
15
|
+
PROSOPO_ADMIN_MNEMONIC: `"${mnemonic}"`,
|
|
16
|
+
PROSOPO_ADMIN_ADDRESS: address,
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
mnemonic(process.argv.includes("--env"))
|
|
21
|
+
.then(() => process.exit(0))
|
|
22
|
+
.catch((e) => {
|
|
23
|
+
console.error(e);
|
|
24
|
+
process.exit(1);
|
|
25
|
+
});
|
|
26
|
+
//# sourceMappingURL=generateMnemonic.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generateMnem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