Skip to content

Commit

Permalink
feat: add admin map in BaseScript
Browse files Browse the repository at this point in the history
refactor: use forge toString function
  • Loading branch information
andreivladbrg committed Jan 19, 2025
1 parent 383cb4c commit fb0459f
Showing 1 changed file with 27 additions and 4 deletions.
31 changes: 27 additions & 4 deletions script/Base.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,15 @@ import { stdJson } from "forge-std/src/StdJson.sol";
abstract contract BaseScript is Script {
using stdJson for string;

/// @dev The salt used for deterministic deployments.
bytes32 internal immutable SALT;
/// @dev The address of the default Sablier admin.
address internal constant DEFAULT_SABLIER_ADMIN = 0xb1bEF51ebCA01EB12001a639bDBbFF6eEcA12B9F;

/// @dev Included to enable compilation of the script without a $MNEMONIC environment variable.
string internal constant TEST_MNEMONIC = "test test test test test test test test test test test junk";

/// @dev Admin address mapped by the chain Id.
mapping(uint256 chainId => address admin) internal adminMap;

/// @dev The address of the transaction broadcaster.
address internal broadcaster;

Expand All @@ -37,8 +40,13 @@ abstract contract BaseScript is Script {
(broadcaster,) = deriveRememberKey({ mnemonic: mnemonic, index: 0 });
}

// Construct the salt for deterministic deployments.
SALT = constructCreate2Salt();
// Populate the admin map.
populateAdminMap();

// If there is no admin set for a specific chain, use the default Sablier admin.
if (adminMap[block.chainid] == address(0)) {
adminMap[block.chainid] = DEFAULT_SABLIER_ADMIN;
}
}

modifier broadcast() {
Expand All @@ -65,4 +73,19 @@ abstract contract BaseScript is Script {
string memory json = vm.readFile("package.json");
return json.readString(".version");
}

/// @dev Populates the admin map. The reason the chain IDs configured for the admin map do not match the other
/// maps is that we only have multisigs for the chains listed below, otherwise, the default admin is used.​
function populateAdminMap() internal {
adminMap[42_161] = 0xF34E41a6f6Ce5A45559B1D3Ee92E141a3De96376; // Arbitrum
adminMap[43_114] = 0x4735517616373c5137dE8bcCDc887637B8ac85Ce; // Avalanche
adminMap[8453] = 0x83A6fA8c04420B3F9C7A4CF1c040b63Fbbc89B66; // Base
adminMap[56] = 0x6666cA940D2f4B65883b454b7Bc7EEB039f64fa3; // BNB
adminMap[100] = 0x72ACB57fa6a8fa768bE44Db453B1CDBa8B12A399; // Gnosis
adminMap[1] = 0x79Fb3e81aAc012c08501f41296CCC145a1E15844; // Mainnet
adminMap[59_144] = 0x72dCfa0483d5Ef91562817C6f20E8Ce07A81319D; // Linea
adminMap[10] = 0x43c76FE8Aec91F63EbEfb4f5d2a4ba88ef880350; // Optimism
adminMap[137] = 0x40A518C5B9c1d3D6d62Ba789501CE4D526C9d9C6; // Polygon
adminMap[534_352] = 0x0F7Ad835235Ede685180A5c611111610813457a9; // Scroll
}
}

0 comments on commit fb0459f

Please sign in to comment.