Skip to content

Commit

Permalink
Added npm scripts for Gnosis contracts deployment, updated README
Browse files Browse the repository at this point in the history
  • Loading branch information
u-hubar committed Nov 23, 2023
1 parent b2647eb commit 5944824
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 29 deletions.
94 changes: 65 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,31 +43,21 @@ This project utilizes a variety of NPM scripts to run various tasks and processe

- `clean`: Removes the cache and artifacts folders generated by Hardhat.
- `compile:size`: Compiles the smart contracts and analyzes the size of the compiled contracts using the hardhat-contract-sizer plugin.
- `compile`: Compiles the smart contracts using the Hardhat CLI.
- `coverage`: Generates a code coverage report for the smart contracts using the solidity-coverage plugin.
- `deploy:localhost`: Deploys the smart contracts to a local network.
- `deploy:otp_alphanet`, `deploy:otp_devnet`, `deploy:otp_testnet`, and `deploy:otp_mainnet`: Deploy the smart contracts to specific networks (alphanet, devnet, testnet, or mainnet).
- `dev`: Runs a local development node with Hardhat and automatically deploys all contracts.
- `compile`: Compiles the smart contracts with specific configuration using `hardhat.node.config.ts`.
- `coverage`: Generates a code coverage report for the smart contracts with specific network and coverage settings.
- `deploy:v1:gno_chiado`, `deploy:v1:gno_mainnet`, `deploy:v1:localhost`, `deploy:v1:otp_alphanet`, `deploy:v1:otp_devnet`, `deploy:v1:otp_mainnet`, `deploy:v1:otp_testnet`, and `deploy:v1`: Deploy version 1 of the smart contracts to various networks including Gnosis Chiado, Hardhat, OriginTrail Parachain Alphanet, OriginTrail Parachain Devnet, OriginTrail Parachain Testnet, and OriginTrail Parachain Mainnet.
- `deploy:v2:gno_chiado`, `deploy:v2:gno_mainnet`, `deploy:v2:localhost`, `deploy:v2:otp_alphanet`, `deploy:v2:otp_devnet`, `deploy:v2:otp_mainnet`, `deploy:v2:otp_testnet`, and `deploy:v2`: Similar to the v1 deploy scripts, these deploy version 2 of the smart contracts to the respective networks.
- `dev:v1`, `dev:v2`, and `dev`: Run local development nodes with Hardhat for different versions of contracts.
- `export-abi`: Updates ABI files according to the current state of the smart contracts.
- `format:fix`: Automatically fixes code formatting issues for JSON, JavaScript, TypeScript, and Solidity files using Prettier.
- `format`: Checks code formatting for JSON, JavaScript, TypeScript, and Solidity files using Prettier.
- `generate-evm-account`: Generates a new Ethereum account using the scripts/generate_evm_account.ts script.
- `generate-otp-account`: Generates a new OriginTrail account using the scripts/generate_otp_account.ts script.
- `lint:fix`: Automatically fixes linting issues for both Solidity and TypeScript files.
- `lint`: Executes linters for both Solidity and TypeScript files.
- `mint-test-tokens`: Mints test tokens on the local - development network using the scripts/mint_test_tokens.ts script.
- `prepare`: Sets up the Husky Git hooks and generates TypeChain typings for the smart contracts.
- `slither:reentrancy`: Executes the Slither static analysis tool with a focus on reentrancy vulnerabilities in the smart contracts.
- `slither`: Runs the Slither static analysis tool on the smart contracts.
- `test:fulltrace`: Runs the test suite with full stack traces enabled for easier debugging.
- `test:gas:fulltrace`: Executes tests with gas usage reporting and full stack traces enabled.
- `test:gas:trace`: Runs tests with gas usage reporting and stack traces enabled.
- `test:gas`: Runs tests with gas usage reporting enabled, using the hardhat-gas-reporter plugin.
- `test:integration`: Executes only the integration tests.
- `test:unit`: Executes only the unit tests.
- `test`: Execute all tests for the smart contracts.
- `format`: Checks code formatting for the same file types.
- `generate-evm-account` and `generate-otp-account`: Generate new Ethereum and OriginTrail accounts, respectively.
- `lint:fix`, `lint:sol:fix`, `lint:ts:fix`, `lint:sol`, `lint:ts`, and `lint`: Provide various linting functionalities for Solidity and TypeScript files, including fixing issues.
- `mint-test-tokens`: Mints test tokens on the local development network.
- `prepare`: Sets up Husky Git hooks and generates TypeChain typings for the smart contracts.
- `slither:reentrancy` and `slither`: Run Slither static analysis with a focus on reentrancy vulnerabilities, and a general analysis, respectively.
- `test:fulltrace`, `test:gas:fulltrace`, `test:gas:trace`, `test:gas`, `test:integration`, `test:trace`, `test:unit`, `test:v1:integration`, `test:v1:unit`, `test:v1`, `test:v2:integration`, `test:v2:unit`, `test:v2`, and `test`: A comprehensive suite of test scripts for different scenarios, including full trace, gas usage, integration, and unit tests for different versions.
- `typechain`: Generates TypeChain typings for the smart contracts.
- `test:trace`: Executes tests with stack trace enabled for easier debugging.

These scripts can be run using the `npm run <script-name>` command. For example, to compile the smart contracts, you can run:

Expand All @@ -79,6 +69,8 @@ npm run compile
Hardhat has plenty of other useful commands, extended by the installed plugins. Here's a brief description of the most useful tasks:

- `decode`: Decodes encoded ABI data (e.g. input data of transaction).
- `encode_selector`: Calculates EVM function/event/error selector (sighash).
- `encode_data`: Encodes data needed for low-level contract calls.

These tasks can be run using the `npx hardhat <task-name>` command. For example, to decode input data, you can run:

Expand All @@ -101,19 +93,63 @@ EVM_PRIVATE_KEY_OTP_DEVNET='<0x_ethereum_private_key>'
ACCOUNT_WITH_OTP_URI_OTP_DEVNET='<substrate_account_uri>'
```

Devnet deployment command
<br/>

OriginTrail Parachain Devnet (v1 contracts)
```sh
npm run deploy:v1:otp_devnet
```
or (v2 contracts)
```sh
npm run deploy:v2:otp_devnet
```

<br/>

OriginTrail Parachain Testnet (v1 contracts)
```sh
npm run deploy:v1:otp_testnet
```
or (v2 contracts)
```sh
npm run deploy:v2:otp_testnet
```

<br/>

OriginTrail Parachain Mainnet (v1 contracts)
```sh
npm run deploy:v1:otp_mainnet
```
or (v2 contracts)
```sh
npm run deploy:v2:otp_mainnet
```

<br/>

Gnosis Chiado (v1 contracts)
```sh
npm run deploy:v1:gno_chiado
```
or (v2 contracts)
```sh
npm run deploy:otp_devnet
npm run deploy:v2:gno_chiado
```
Testnet deployment command

<br/>

Gnosis Mainnet (v1 contracts)
```sh
npm run deploy:otp_testnet
npm run deploy:v1:gno_mainnet
```
Mainnet deployment command
or (v2 contracts)
```sh
npm run deploy:otp_mainnet
npm run deploy:v2:gno_mainnet
```

### Redeploy contract on parachain
<br/>

### Redeploy contract

In order to redeploy desired contract, set `deployed` to `false` in `deployments/<network>_contracts.json`.
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,16 @@
"compile:size": "hardhat size-contracts",
"compile": "hardhat compile --config hardhat.node.config.ts",
"coverage": "cross-env COVERAGE_REPORT=true HARDHAT_DEPLOY_FIXTURE=true hardhat coverage --network hardhat --solcoverjs ./.solcover.js --temp artifacts --testfiles './test/**/*.test.ts'",
"deploy:v1:gno_chiado": "hardhat deploy --network gno_chiado --tags v1",
"deploy:v1:gno_mainnet": "hardhat deploy --network gno_mainnet --tags v1",
"deploy:v1:localhost": "hardhat deploy --network hardhat --tags v1",
"deploy:v1:otp_alphanet": "hardhat deploy --network otp_alphanet --tags v1",
"deploy:v1:otp_devnet": "hardhat deploy --network otp_devnet --tags v1",
"deploy:v1:otp_mainnet": "hardhat deploy --network otp_mainnet --tags v1",
"deploy:v1:otp_testnet": "hardhat deploy --network otp_testnet --tags v1",
"deploy:v1": "hardhat deploy --tags v1",
"deploy:v2:gno_chiado": "hardhat deploy --network gno_chiado --tags v1,v2",
"deploy:v2:gno_mainnet": "hardhat deploy --network gno_mainnet --tags v1,v2",
"deploy:v2:localhost": "hardhat deploy --network hardhat --tags v1,v2",
"deploy:v2:otp_alphanet": "hardhat deploy --network otp_alphanet --tags v1,v2",
"deploy:v2:otp_devnet": "hardhat deploy --network otp_devnet --tags v1,v2",
Expand Down

0 comments on commit 5944824

Please sign in to comment.