Skip to content

Commit

Permalink
fix: wrong logic in broadcast
Browse files Browse the repository at this point in the history
  • Loading branch information
nlecoufl committed Feb 26, 2025
1 parent ac349df commit 4f0d23b
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion scripts/utils/Base.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ abstract contract BaseScript is Script {
/// @dev The address of the transaction broadcaster.
address internal broadcaster;

/// @dev The private key of the transaction broadcaster.
uint256 internal broadcasterPrivateKey;

/// @dev Used to derive the broadcaster's address if $DEPLOYER_ADDRESS is not defined.
string internal mnemonic;

Expand All @@ -33,6 +36,7 @@ abstract contract BaseScript is Script {
uint256 privateKey = vm.envOr({ name: "DEPLOYER_PRIVATE_KEY", defaultValue: uint256(0) });
if (privateKey != 0) {
broadcaster = vm.addr(privateKey);
broadcasterPrivateKey = privateKey;
} else {
address from = vm.envOr({ name: "DEPLOYER_ADDRESS", defaultValue: address(0) });
if (from != address(0)) {
Expand All @@ -45,7 +49,11 @@ abstract contract BaseScript is Script {
}

modifier broadcast() {
vm.startBroadcast(broadcaster);
if (broadcasterPrivateKey != 0) {
vm.startBroadcast(broadcasterPrivateKey);
} else {
vm.startBroadcast(broadcaster);
}
_;
vm.stopBroadcast();
}
Expand Down

0 comments on commit 4f0d23b

Please sign in to comment.