Skip to content

Commit

Permalink
feat: broadcaster through environment (#108)
Browse files Browse the repository at this point in the history
  • Loading branch information
nlecoufl authored Feb 25, 2025
1 parent f8f3194 commit ac349df
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
Binary file modified bun.lockb
Binary file not shown.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"url": "https://github.com/AngleProtocol/merkl-contracts/issues"
},
"devDependencies": {
"@angleprotocol/sdk": "2.38.4",
"@angleprotocol/sdk": "2.40.17",
"@openzeppelin/contracts": "^4.9.0",
"@openzeppelin/contracts-upgradeable": "4.9.0",
"prettier": "^2.0.0",
Expand Down
18 changes: 12 additions & 6 deletions scripts/utils/Base.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,24 @@ abstract contract BaseScript is Script {

/// @dev Initializes the transaction broadcaster like this:
///
/// - If $PRIVATE_KEY is defined, use it to set the broadcaster.
/// - If $DEPLOYER_ADDRESS is defined, use it.
/// - Otherwise, derive the broadcaster address from $MNEMONIC.
/// - If $MNEMONIC is not defined, default to a test mnemonic.
///
/// The use case for $DEPLOYER_ADDRESS is to specify the broadcaster key and its address via the command line.
/// The use case for $PRIVATE_KEY or $DEPLOYER_ADDRESS is to specify the broadcaster key via environment variable or the command line respectively.
constructor() {
address from = vm.envOr({ name: "DEPLOYER_ADDRESS", defaultValue: address(0) });
if (from != address(0)) {
broadcaster = from;
uint256 privateKey = vm.envOr({ name: "DEPLOYER_PRIVATE_KEY", defaultValue: uint256(0) });
if (privateKey != 0) {
broadcaster = vm.addr(privateKey);
} else {
mnemonic = vm.envOr({ name: "MNEMONIC", defaultValue: TEST_MNEMONIC });
(broadcaster, ) = deriveRememberKey({ mnemonic: mnemonic, index: 0 });
address from = vm.envOr({ name: "DEPLOYER_ADDRESS", defaultValue: address(0) });
if (from != address(0)) {
broadcaster = from;
} else {
mnemonic = vm.envOr({ name: "MNEMONIC", defaultValue: TEST_MNEMONIC });
(broadcaster, ) = deriveRememberKey({ mnemonic: mnemonic, index: 0 });
}
}
}

Expand Down

0 comments on commit ac349df

Please sign in to comment.