This package contains the scripts and configuration for setting up a development environment for Prosopo.
git clone https://github.com/prosopo/captcha
cd captcha
npm i
npm run build:all
docker compose --file docker/docker-compose.development.yml up -d
cp demos/client-example-server/env.development demos/client-example-server/.env.development
cp demos/client-example/env.development demos/client-example/.env.development
cp dev/scripts/env.development .env.development
cp dev/scripts/env.development dev/scripts/.env.development
cp dev/scripts/env.development packages/cli/.env.development
cp dev/scripts/env.development packages/procaptcha-bundle/.env.development
npm run setup:all
In different terminals run
npm run start:server
npm run start:provider
npm run start:demo
Go to http://localhost:9230 in your browser.
Setup your containers by running the following command from the root of the scripts repository.
docker compose --file ./docker/docker-compose.development.yml up -d
Install the node modules by running the following command from the root of the captcha workspace.
npm i
Build all packages by running the following command from the root of the captcha workspace.
npm run build:all
If you want to deploy the Procaptcha protocol contract, you can do so by running the following command from the root of the captcha workspace. Any .env files will be updated with the new contract addresses.
npm run deploy_protocol
npm run setup
Alternatively, run npm setup:all
to run both of the above commands.
You must have a valid env file in ./dev/scripts/
for these commands to work. You can use the
file ./dev/scripts/env.development
as a template.
Providers are the nodes in the network that supply CAPTCHA. Run the following command from the root of the captcha workspace to register a Provider and a Dapp in the Protocol contract and start the Provider API.
npm run setup && npm run start:provider
The Protocol contract must exist on the substrate node for the setup script to run.
Run all the tests using the following command from the root of the captcha workspace.
npm run test
The development scripts package contains a CLI tool that can be used for various development tasks.
From the root of the captcha
workspace run:
npm run deploy_protocol
This is shorthand for the following command:
npm run -w @prosopo/scripts cli deploy_protocol --update_env
Specify the current working directory if you are running from a different location.
npm run -w @prosopo/scripts cli deploy_protocol --update_env --cwd $(pwd)
The default environment is development
. To deploy to a different environment, set the NODE_ENV
environment variable.
NODE_ENV=test npm run -w @prosopo/scripts cli deploy_protocol --update_env
TODO
npm run setup
...
...
Maintenance script to fund dapps in contract that are not Active
.
npm run -w @prosopo/scripts -- cli fund_dapps
By default, the current .env
setup will be used as the --transfer-to
network.
Transfer dapps and providers from one contract to another
Options:
--help Show help [boolean]
--version Show version number [boolean]
--transfer-from The name of the network and the contract address to tran
sfer from `{ network, address }` [string] [required]
--transfer-to The name of the network and the contract address to tran
sfer to `{ network, address }` [string]
--transfer-providers Whether to transfer providers or not
[boolean] [required] [default: false]
--transfer-dapps Whether to transfer dapps or not
[boolean] [required] [default: false]
From the root of the workspace run:
npm run -w @prosopo/scripts -- cli transfer_contract --transfer-from '{"network":"rococo", "address":"..."}' --transfer-dapps=true --transfer-providers=true
From the root of the workspace run:
npm run -w @prosopo/scripts -- cli --version