Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deployment script minor tweaks #723

Merged
merged 5 commits into from
Jan 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/testnet-deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ jobs:

- name: Run deployment tool
working-directory: ./contracts
run: ./deploy liquity-testnet --debug --verify
run: ./deploy liquity-testnet --debug --verify --skip-confirmation
timeout-minutes: 10
env:
DEPLOYER: ${{ secrets.DEPLOYER }}
Expand Down
1 change: 1 addition & 0 deletions contracts/fork
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ deploy() {
--rpc-url "$E2E_RPC_URL"
--chain-id "$FORK_CHAIN_ID"
--deployer "$DEPLOYER"
--skip-confirmation
# --verify
# --verifier sourcify
# --verifier-url "http://localhost:$sourcify_port"
Expand Down
35 changes: 33 additions & 2 deletions contracts/utils/deploy-cli.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { $, chalk, echo, fs, minimist } from "zx";
import { privateKeyToAccount } from "viem/accounts";
import { $, chalk, echo, fs, minimist, question } from "zx";

const HELP = `
deploy - deploy the Liquity contracts.
Expand Down Expand Up @@ -37,6 +38,7 @@ Options:
--rpc-url <RPC_URL> RPC URL to use.
--salt <SALT> Use keccak256(bytes(SALT)) as CREATE2
salt instead of block timestamp.
--skip-confirmation Run non-interactively (skip confirmation).
--slow Only send a transaction after the previous
one has been confirmed.
--unlocked Used when the deployer account is unlocked
Expand Down Expand Up @@ -77,6 +79,7 @@ const argv = minimist(process.argv.slice(2), {
"ledger-path",
"mode",
"salt",
"skip-confirmation",
"rpc-url",
"verifier",
"verifier-url",
Expand Down Expand Up @@ -176,7 +179,12 @@ export async function main() {
}
}

let deployerAddress: string;

if (options.deployer.startsWith("0x") && options.deployer.length === 42) {
// DEPLOYER is an address
deployerAddress = options.deployer;

if (options.unlocked) {
forgeArgs.push("--unlocked");
} else {
Expand All @@ -187,13 +195,17 @@ export async function main() {
forgeArgs.push(options.ledgerPath);
}
}
} else {
// DEPLOYER is a private key, get its address
deployerAddress = privateKeyToAccount(options.deployer).address;
}

echo`
Deploying Liquity contracts with the following settings:

CHAIN_ID: ${options.chainId}
DEPLOYER: ${options.deployer}
MODE: ${options.mode}
DEPLOYER (address): ${deployerAddress}
DEPLOYMENT_MODE: ${options.mode}
SALT: ${options.salt ? options.salt : chalk.yellow("block.timestamp will be used !!")}
ETHERSCAN_API_KEY: ${options.etherscanApiKey && "(secret)"}
Expand All @@ -206,6 +218,23 @@ Deploying Liquity contracts with the following settings:
VERIFIER_URL: ${options.verifierUrl}
`;

// User confirmation
if (!options.skipConfirmation) {
for (;;) {
const answer = (await question("Does that look good? (y/N) ")).toLowerCase();

if (answer === "y") {
echo("");
break;
}

if (answer === "" || answer === "n") {
echo("Deployment aborted.");
process.exit(1);
}
}
}

process.env.DEPLOYER = options.deployer;
process.env.DEPLOYMENT_MODE = options.mode;
process.env.SALT = options.salt;
Expand Down Expand Up @@ -353,6 +382,7 @@ async function parseArgs() {
openDemoTroves: argv["open-demo-troves"],
rpcUrl: argv["rpc-url"],
dryRun: argv["dry-run"],
skipConfirmation: argv["skip-confirmation"],
slow: argv["slow"],
unlocked: argv["unlocked"],
verify: argv["verify"],
Expand All @@ -375,6 +405,7 @@ async function parseArgs() {
options.openDemoTroves = parseBool(options.openDemoTroves, process.env.OPEN_DEMO_TROVES);
options.rpcUrl ??= process.env.RPC_URL;
options.salt ??= process.env.SALT;
options.skipConfirmation = parseBool(options.skipConfirmation, process.env.SKIP_CONFIRMATION);
options.slow = parseBool(options.slow, process.env.SLOW);
options.unlocked = parseBool(options.unlocked, process.env.UNLOCKED);
options.useTestnetPricefeeds = parseBool(options.useTestnetPricefeeds, process.env.USE_TESTNET_PRICEFEEDS);
Expand Down
Loading