fix: BootstrapVWAPPhase2.s.sol hardcodes .secret file dependency (#769)
Check PRIVATE_KEY env var first in BootstrapVWAPPhase2.s.sol, DeployBase.sol, and BaseDeploy.sol; fall back to .secret seed-phrase file when unset. This allows CI/CD environments to inject keys via environment variables while preserving the existing local .secret workflow unchanged. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
331fe65384
commit
9632693b8a
3 changed files with 23 additions and 6 deletions
|
|
@ -5,8 +5,11 @@ import "forge-std/Script.sol";
|
||||||
contract BaseDeploy is Script {
|
contract BaseDeploy is Script {
|
||||||
function run() public view {
|
function run() public view {
|
||||||
// Base data
|
// Base data
|
||||||
string memory seedPhrase = vm.readFile(".secret");
|
uint256 privateKey = vm.envOr("PRIVATE_KEY", uint256(0));
|
||||||
uint256 privateKey = vm.deriveKey(seedPhrase, 0);
|
if (privateKey == 0) {
|
||||||
|
string memory seedPhrase = vm.readFile(".secret");
|
||||||
|
privateKey = vm.deriveKey(seedPhrase, 0);
|
||||||
|
}
|
||||||
address sender = vm.addr(privateKey);
|
address sender = vm.addr(privateKey);
|
||||||
console.log(sender);
|
console.log(sender);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,14 @@ import "forge-std/Script.sol";
|
||||||
*
|
*
|
||||||
* Usage:
|
* Usage:
|
||||||
* export LM_ADDRESS=<deployed LiquidityManager address>
|
* export LM_ADDRESS=<deployed LiquidityManager address>
|
||||||
|
*
|
||||||
|
* # Option A — env-var key (CI/CD):
|
||||||
|
* export PRIVATE_KEY=0x<hex-private-key>
|
||||||
|
* forge script script/BootstrapVWAPPhase2.s.sol --tc BootstrapVWAPPhase2 \
|
||||||
|
* --fork-url $BASE_RPC --broadcast
|
||||||
|
*
|
||||||
|
* # Option B — .secret seed-phrase file (local):
|
||||||
|
* echo "<seed phrase>" > .secret
|
||||||
* forge script script/BootstrapVWAPPhase2.s.sol --tc BootstrapVWAPPhase2 \
|
* forge script script/BootstrapVWAPPhase2.s.sol --tc BootstrapVWAPPhase2 \
|
||||||
* --fork-url $BASE_RPC --broadcast
|
* --fork-url $BASE_RPC --broadcast
|
||||||
*/
|
*/
|
||||||
|
|
@ -28,8 +36,11 @@ contract BootstrapVWAPPhase2 is Script {
|
||||||
address lmAddress = vm.envAddress("LM_ADDRESS");
|
address lmAddress = vm.envAddress("LM_ADDRESS");
|
||||||
LiquidityManager lm = LiquidityManager(payable(lmAddress));
|
LiquidityManager lm = LiquidityManager(payable(lmAddress));
|
||||||
|
|
||||||
string memory seedPhrase = vm.readFile(".secret");
|
uint256 privateKey = vm.envOr("PRIVATE_KEY", uint256(0));
|
||||||
uint256 privateKey = vm.deriveKey(seedPhrase, 0);
|
if (privateKey == 0) {
|
||||||
|
string memory seedPhrase = vm.readFile(".secret");
|
||||||
|
privateKey = vm.deriveKey(seedPhrase, 0);
|
||||||
|
}
|
||||||
vm.startBroadcast(privateKey);
|
vm.startBroadcast(privateKey);
|
||||||
|
|
||||||
console.log("Running VWAP bootstrap phase 2 on LiquidityManager:", lmAddress);
|
console.log("Running VWAP bootstrap phase 2 on LiquidityManager:", lmAddress);
|
||||||
|
|
|
||||||
|
|
@ -37,8 +37,11 @@ contract DeployBase is Script {
|
||||||
IUniswapV3Pool public pool;
|
IUniswapV3Pool public pool;
|
||||||
|
|
||||||
function run() public {
|
function run() public {
|
||||||
string memory seedPhrase = vm.readFile(".secret");
|
uint256 privateKey = vm.envOr("PRIVATE_KEY", uint256(0));
|
||||||
uint256 privateKey = vm.deriveKey(seedPhrase, 0);
|
if (privateKey == 0) {
|
||||||
|
string memory seedPhrase = vm.readFile(".secret");
|
||||||
|
privateKey = vm.deriveKey(seedPhrase, 0);
|
||||||
|
}
|
||||||
vm.startBroadcast(privateKey);
|
vm.startBroadcast(privateKey);
|
||||||
address sender = vm.addr(privateKey);
|
address sender = vm.addr(privateKey);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue