Skip to content

Commit

Permalink
Add a CLI tool to deploy the contracts using Foundry (#86)
Browse files Browse the repository at this point in the history
`deploy` can be launched with `--help` to see its documentation:

```
$ ./deploy --help

deploy - deploy the Liquity contracts.

Usage:
  ./deploy [NETWORK_PRESET] [OPTIONS]

Arguments:
  NETWORK_PRESET  A network preset, which is a shorthand for setting certain options
                  such as the chain ID and RPC URL. Options take precedence over
                  network presets. Available presets:
                  - local: Deploy to a local network
                  - mainnet: Deploy to the Ethereum mainnet
                  - tenderly-devnet: Deploy to a Tenderly devnet
                  - liquity-testnet: Deploy to the Liquity v2 testnet


Options:
  --chain-id <CHAIN_ID>                    Chain ID to deploy to.
  --deployer <DEPLOYER>                    Address or private key to deploy with.
                                           Requires a Ledger if an address is used.
  --ledger-path <LEDGER_PATH>              HD path to use with the Ledger (only used
                                           when DEPLOYER is an address).
  --etherscan-api-key <ETHERSCAN_API_KEY>  Etherscan API key to verify the contracts
                                           (required when verifying with Etherscan).
  --help, -h                               Show this help message.
  --open-demo-troves                       Open demo troves after deployment (local
                                           only).
  --rpc-url <RPC_URL>                      RPC URL to use.
  --verify                                 Verify contracts after deployment.
  --verifier <VERIFIER>                    Verification provider to use.
                                           Possible values: etherscan, sourcify.
  --verifier-url <VERIFIER_URL>            The verifier URL, if using a custom
                                           provider.

Note: options can also be set via corresponding environment variables,
e.g. --chain-id can be set via CHAIN_ID instead. Parameters take precedence over variables.
```
  • Loading branch information
bpierre authored Apr 9, 2024
1 parent 8807eae commit f260960
Show file tree
Hide file tree
Showing 9 changed files with 992 additions and 100 deletions.
37 changes: 34 additions & 3 deletions .github/workflows/contracts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@ on:

jobs:
test-foundry:
strategy:
fail-fast: true

name: Foundry tests
runs-on: ubuntu-latest
steps:
Expand All @@ -48,6 +45,40 @@ jobs:
forge test -vvv
id: test

deploy:
name: Deploy contracts to Liquity v2 Testnet
runs-on: ubuntu-latest
steps:
- name: Git checkout
uses: actions/checkout@v4
with:
submodules: recursive

- name: Install pnpm
uses: pnpm/action-setup@v3.0.0
with:
version: 8

- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version-file: '.node-version'
cache: 'pnpm'
cache-dependency-path: 'contracts/pnpm-lock.yaml'

- name: Install dependencies
run: pnpm install

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly

- name: Run deployment tool
run: ./deploy liquity-testnet --verify
env:
DEPLOYER: ${{ secrets.DEPLOYER }}

console-logs:
name: Check we didn’t forget to remove console imports
runs-on: ubuntu-latest
Expand Down
1 change: 1 addition & 0 deletions contracts/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ out/
# Ignores development broadcast logs
!/broadcast
/broadcast/*/31337/
/broadcast/*/1337/
/broadcast/**/dry-run/

# Docs
Expand Down
8 changes: 8 additions & 0 deletions contracts/deploy
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env -S npx tsx

require("./utils/deploy-cli").main().catch(({ message }) => {
console.error("");
console.error(` Error: ${message}`);
console.error("");
process.exit(1);
});
4 changes: 3 additions & 1 deletion contracts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@
"hardhat-gas-reporter": "^1.0.8",
"solidity-coverage": "^0.8.8",
"ts-node": ">=8.0.0",
"tsx": "^4.7.1",
"typechain": "^8.1.0",
"typescript": ">=4.5.0"
"typescript": ">=4.5.0",
"zx": "^7.2.3"
}
}
Loading

0 comments on commit f260960

Please sign in to comment.