Skip to content

Commit 1ace8d7

Browse files
committed
🐗 Add deployment script for MinimumDepositController (#554)
1 parent a736c0e commit 1ace8d7

File tree

7 files changed

+116
-5
lines changed

7 files changed

+116
-5
lines changed

contracts/MinimumDepositController/IDepositController.sol renamed to contracts/MinimumDepositController/IMinimumDepositController.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {DepositAllowed} from "../carbon/interfaces/IDepositController.sol";
1010
* @title Contract for managing deposit related settings
1111
* @dev Used by TrancheVault contract
1212
*/
13-
interface IDepositController {
13+
interface IMinimumDepositController {
1414
/**
1515
* @notice Event emitted when new ceiling is set
1616
* @param newCeiling New ceiling value

contracts/MinimumDepositController/MinimumDepositController.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ import {Initializable} from "@openzeppelin/contracts/proxy/utils/Initializable.s
77
import {AccessControlEnumerable} from "@openzeppelin/contracts/access/AccessControlEnumerable.sol";
88
import {ILenderVerifier, Status, DepositAllowed} from "../carbon/interfaces/IDepositController.sol";
99
import {ITrancheVault} from "../carbon/interfaces/ITrancheVault.sol";
10-
import {IDepositController} from "./IDepositController.sol";
10+
import {IMinimumDepositController} from "./IMinimumDepositController.sol";
1111

1212
uint256 constant BASIS_PRECISION = 10000;
1313

14-
contract MinimumDepositController is IDepositController, Initializable, AccessControlEnumerable {
14+
contract MinimumDepositController is IMinimumDepositController, Initializable, AccessControlEnumerable {
1515
/// @dev Manager role used for access control
1616
bytes32 public constant MANAGER_ROLE = keccak256("MANAGER_ROLE");
1717
ILenderVerifier public lenderVerifier;

deployments-optimism_goerli.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"optimism_goerli": {
3+
"minimumDepositController": {
4+
"txHash": "0x162d7b478390cc8444a7b8564f770e13b67d596bb071a84785945f0afea61f23",
5+
"address": "0xb7DaEb7232795C7e59A8CC2fb0e6A1CEe43DBD5F",
6+
"multisig": false
7+
}
8+
}
9+
}

package.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66
"preinstall": "npx only-allow pnpm",
77
"build:hardhat": "hardhat compile",
88
"build:typechain": "typechain --target ethers-v5 --out-dir build/types 'build/*.json'",
9-
"build": "pnpm clean && pnpm build:hardhat && pnpm build:typechain",
9+
"build:mars": "pnpm exec mars",
10+
"build:save-canary": "bash ./scripts/saveCanary.sh",
11+
"build": "pnpm clean && pnpm build:hardhat && pnpm build:typechain && pnpm build:save-canary && pnpm build:mars",
1012
"clean": "rm -rf ./build && hardhat clean",
1113
"lint:prettier": "prettier './{contracts,test,features}/**/*.{ts,sol}' --cache",
1214
"lint:sol": "solhint 'contracts/**/*.sol'",
@@ -15,7 +17,8 @@
1517
"lint": "pnpm run lint:sol && pnpm run lint:prettier --check --loglevel error && pnpm run lint:ts",
1618
"test:unit": "mocha 'test/**/*.test.ts'",
1719
"test": "pnpm test:unit",
18-
"test:ci": "pnpm run test"
20+
"test:ci": "pnpm run test",
21+
"deploy:contracts": "bash ./scripts/guardedRun.sh"
1922
},
2023
"prettier": "prettier-config-archblock/contracts.json",
2124
"dependencies": {
@@ -34,6 +37,7 @@
3437
"@types/node": "^17.0.12",
3538
"chai": "^4.3.6",
3639
"eslint-config-archblock": "workspace:*",
40+
"ethereum-mars": "0.2.6-dev.eb75a27",
3741
"ethereum-waffle": "4.0.7",
3842
"ethers": "^5.7.1",
3943
"hardhat": "^2.11.2",

scripts/deploy.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { MinimumDepositController } from '../build/artifacts'
2+
import { contract, deploy } from 'ethereum-mars'
3+
4+
export function deployContract() {
5+
const minimumDepositController = contract(MinimumDepositController)
6+
return { minimumDepositController }
7+
}
8+
9+
deploy({ verify: true }, deployContract)

scripts/guardedRun.sh

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
#!/bin/bash
2+
set -eu
3+
4+
# Setting Infura or Alchemy key to use for convenience here
5+
#export INFURA_KEY="f88abc181a4a45a6bc47bdda05a94944"
6+
export ALCHEMY_KEY="fbS06B9gi4kYSsliFu_Hj5gamIShXt9I"
7+
8+
# Example usage:
9+
# $ scripts/deployment/guardedRun.sh --network goerli --dry-run
10+
# PRIVATE_KEY=0x123..64
11+
12+
network='mainnet'
13+
args="$@"
14+
dry_run='false'
15+
force='false'
16+
17+
while [[ "$@" ]]; do
18+
case "$1" in
19+
--network)
20+
if [ "$2" ]; then
21+
network="$2"
22+
shift 1
23+
fi
24+
;;
25+
--dry-run)
26+
dry_run='true'
27+
;;
28+
--force)
29+
force='true'
30+
;;
31+
-?)
32+
# ignore
33+
;;
34+
esac
35+
shift 1
36+
done
37+
38+
# Setting Etherscan key to use for convenience here
39+
if [[ $network == optimism* ]]; then
40+
export ETHERSCAN_KEY="RPKYAHCE6R2YI7TRV51WS5N8R885RRNXG3" # Use for Optimism & optimistic testnets
41+
else
42+
export ETHERSCAN_KEY="XQPPJGFR4J3I6PEISYEG4JPETFZ2EF56EX" # Use for Ethereum & testnets
43+
fi
44+
45+
if [[ "${dry_run}" == 'false' ]]; then
46+
if [[ "$(git status --porcelain)" ]]; then
47+
echo "Error: git working directory must be empty to run deploy script."
48+
exit 1
49+
fi
50+
51+
if [[ "$(git log --pretty=format:'%H' -n 1)" != "$(cat ./build/canary.hash)" ]]; then
52+
echo "Error: Build canary does not match current commit hash. Please run pnpm run build."
53+
exit 1
54+
fi
55+
fi
56+
57+
# Skip prompt if PRIVATE_KEY variable already exists
58+
if [[ -z "${PRIVATE_KEY:-}" ]]; then
59+
# Prompt the user for a PRIVATE_KEY without echoing to bash output.
60+
# Then export PRIVATE_KEY to an environment variable that won't get
61+
# leaked to bash history.
62+
#
63+
# WARNING: environment variables are still leaked to the process table
64+
# while a process is running, and hence visible in a call to `ps -E`.
65+
echo "Enter a private key (0x{64 hex chars}) for contract deployment,"
66+
echo "or leave blank if performing a dry run without authorization."
67+
read -s -p "PRIVATE_KEY=" PRIVATE_KEY
68+
export PRIVATE_KEY
69+
fi
70+
71+
# Log file name
72+
network_log="-${network}"
73+
dry_run_log=''
74+
if [[ "${dry_run}" == 'true' ]]; then
75+
dry_run_log='-dry-run'
76+
fi
77+
timestamp_log="-$(date +%s)"
78+
79+
ts-node ./scripts/deploy.ts \
80+
--waffle-config ./waffle.json \
81+
${args} \
82+
--out-file "deployments-${network}.json" \
83+
--log "./cache/deploy${network_log}${dry_run_log}${timestamp_log}.log"

scripts/saveCanary.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/bash
2+
3+
if [[ -z "$(git status --porcelain)" ]]; then
4+
echo "Build canary stored in ./build/canary.hash"
5+
git log --pretty=format:'%H' -n 1 > ./build/canary.hash
6+
fi

0 commit comments

Comments
 (0)