Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
nebula
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
exchain
nebula
Commits
41d06234
Commit
41d06234
authored
Sep 29, 2023
by
Tarun Khasnavis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Create deployment scripts for auth modules
parent
78e0b0eb
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
127 additions
and
2 deletions
+127
-2
optimism-goerli.json
...acts-bedrock/periphery-deploy-config/optimism-goerli.json
+8
-2
DeployPeriphery.s.sol
packages/contracts-bedrock/scripts/DeployPeriphery.s.sol
+100
-0
PeripheryDeployConfig.s.sol
...ges/contracts-bedrock/scripts/PeripheryDeployConfig.s.sol
+12
-0
Faucet.sol
packages/contracts-bedrock/src/periphery/faucet/Faucet.sol
+7
-0
No files found.
packages/contracts-bedrock/periphery-deploy-config/optimism-goerli.json
View file @
41d06234
{
"faucetAdmin"
:
"0x
f2C22a95bBA6F35545269183D8d1751a27F047F6
"
,
"faucetAdmin"
:
"0x
8F0EBDaA1cF7106bE861753B0f9F5c0250fE0819
"
,
"faucetDrippieOwner"
:
"0xEa193Fd9565284E7534dDDA15b07B119e7792644"
,
"faucetDripV1Value"
:
20000000000000000000
,
"faucetDripV1Interval"
:
3600
,
...
...
@@ -14,5 +14,11 @@
"faucetGelatoRecipient"
:
"0x789e58a4B08A23a7f60141959C6ABbdC0D0C4Aba"
,
"faucetGelatoBalanceV1DripInterval"
:
86400
,
"faucetGelatoBalanceV1Value"
:
1000000000000000000
,
"faucetGelatoThreshold"
:
100000000000000000
"faucetGelatoThreshold"
:
100000000000000000
,
"faucetOnchainAuthModuleAdmin"
:
"0x8F0EBDaA1cF7106bE861753B0f9F5c0250fE0819"
,
"faucetOnchainAuthModuleAdminDripInterval"
:
86400
,
"faucetOnchainAuthModuleAdminDripValue"
:
1000000000000000000
,
"faucetOffchainAuthModuleAdmin"
:
"0x8F0EBDaA1cF7106bE861753B0f9F5c0250fE0819"
,
"faucetOffchainAuthModuleAdminDripInterval"
:
86400
,
"faucetOffchainAuthModuleAdminDripValue"
:
50000000000000000
}
packages/contracts-bedrock/scripts/DeployPeriphery.s.sol
View file @
41d06234
...
...
@@ -15,6 +15,7 @@ import { CheckGelatoLow } from "src/periphery/drippie/dripchecks/CheckGelatoLow.
import { CheckBalanceHigh } from "src/periphery/drippie/dripchecks/CheckBalanceHigh.sol";
import { CheckBalanceLow } from "src/periphery/drippie/dripchecks/CheckBalanceLow.sol";
import { CheckTrue } from "src/periphery/drippie/dripchecks/CheckTrue.sol";
import { AdminFaucetAuthModule } from "src/periphery/faucet/authmodules/AdminFaucetAuthModule.sol";
/// @title DeployPeriphery
/// @notice Script used to deploy periphery contracts.
...
...
@@ -45,6 +46,7 @@ contract DeployPeriphery is Deployer {
deployImplementations();
initializeFaucet();
installFaucetAuthModulesConfigs();
}
/// @notice Deploy all of the proxies
...
...
@@ -62,6 +64,8 @@ contract DeployPeriphery is Deployer {
deployCheckBalanceLow();
deployCheckBalanceHigh();
deployCheckGelatoLow();
deployOnChainAuthModule();
deployOffChainAuthModule();
}
/// @notice Modifier that wraps a function in broadcasting.
...
...
@@ -403,4 +407,100 @@ contract DeployPeriphery is Deployer {
require(drippie.getDripStatus(dripName) == Drippie.DripStatus.ACTIVE);
}
}
/// @notice deploys the On-Chain Authentication Module
function deployOnChainAuthModule() public broadcast returns (address addr_) {
string memory moduleName = "OnChainAuthModule";
string memory version = "1";
bytes32 salt = keccak256(bytes("OnChainAuthModule"));
bytes32 initCodeHash = keccak256(abi.encodePacked(type(AdminFaucetAuthModule).creationCode, abi.encode(cfg.faucetOnchainAuthModuleAdmin(), moduleName, version)));
address preComputedAddress = computeCreate2Address(salt, initCodeHash);
if (preComputedAddress.code.length > 0) {
console.logBytes32(initCodeHash);
console.log("OnChainAuthModule already deployed at %s", preComputedAddress);
save("OnChainAuthModule", preComputedAddress);
addr_ = preComputedAddress;
} else {
AdminFaucetAuthModule onChainAuthModule = new AdminFaucetAuthModule{ salt: salt }(cfg.faucetOnchainAuthModuleAdmin(), moduleName, version);
require(onChainAuthModule.ADMIN() == cfg.faucetOnchainAuthModuleAdmin());
save("OnChainAuthModule", address(onChainAuthModule));
console.log("OnChainAuthModule deployed at %s", address(onChainAuthModule));
addr_ = address(onChainAuthModule);
}
}
/// @notice deploys the Off-Chain Authentication Module
function deployOffChainAuthModule() public broadcast returns (address addr_) {
string memory moduleName = "OffChainAuthModule";
string memory version = "1";
bytes32 salt = keccak256(bytes("OffChainAuthModule"));
bytes32 initCodeHash = keccak256(abi.encodePacked(type(AdminFaucetAuthModule).creationCode, abi.encode(cfg.faucetOffchainAuthModuleAdmin(), moduleName, version)));
address preComputedAddress = computeCreate2Address(salt, initCodeHash);
if (preComputedAddress.code.length > 0) {
console.logBytes32(initCodeHash);
console.log("OffChainAuthModule already deployed at %s", preComputedAddress);
save("OffChainAuthModule", preComputedAddress);
addr_ = preComputedAddress;
} else {
AdminFaucetAuthModule offChainAuthModule = new AdminFaucetAuthModule{ salt: salt }(cfg.faucetOffchainAuthModuleAdmin(), moduleName, version);
require(offChainAuthModule.ADMIN() == cfg.faucetOffchainAuthModuleAdmin());
save("OffChainAuthModule", address(offChainAuthModule));
console.log("OffChainAuthModule deployed at %s", address(offChainAuthModule));
addr_ = address(offChainAuthModule);
}
}
/// @notice installs the OnChain AuthModule on the Faucet contract.
function installOnChainAuthModule() public broadcast {
string memory moduleName = "OnChainAuthModule";
Faucet faucet = Faucet(mustGetAddress("Faucet"));
AdminFaucetAuthModule onChainAuthModule = AdminFaucetAuthModule(mustGetAddress(moduleName));
if (faucet.getModuleStatus(onChainAuthModule)) {
console.log("%s already installed.", moduleName);
} else {
console.log("Installing %s", moduleName);
Faucet.ModuleConfig memory myModuleConfig = Faucet.ModuleConfig({
name: moduleName,
enabled: true,
ttl: cfg.faucetOnchainAuthModuleAdminDripInterval(),
amount: cfg.faucetOnchainAuthModuleAdminDripValue()
});
faucet.configure(onChainAuthModule, myModuleConfig);
console.log("%s installed successfully", moduleName);
}
}
/// @notice installs the OffChain AuthModule on the Faucet contract.
function installOffChainAuthModule() public broadcast {
string memory moduleName = "OffChainAuthModule";
Faucet faucet = Faucet(mustGetAddress("Faucet"));
AdminFaucetAuthModule offChainAuthModule = AdminFaucetAuthModule(mustGetAddress(moduleName));
if (faucet.getModuleStatus(offChainAuthModule)) {
console.log("%s already installed.", moduleName);
} else {
console.log("Installing %s", moduleName);
Faucet.ModuleConfig memory myModuleConfig = Faucet.ModuleConfig({
name: moduleName,
enabled: true,
ttl: cfg.faucetOffchainAuthModuleAdminDripInterval(),
amount: cfg.faucetOffchainAuthModuleAdminDripValue()
});
faucet.configure(offChainAuthModule, myModuleConfig);
console.log("%s installed successfully", moduleName);
}
}
/// @notice installs all of the auth module in the faucet contract.
function installFaucetAuthModulesConfigs() public {
Faucet faucet = Faucet(mustGetAddress("Faucet"));
console.log("Installing auth modules at %s", address(faucet));
installOnChainAuthModule();
installOffChainAuthModule();
console.log("Faucet Auth Module configs successfully installed");
}
}
packages/contracts-bedrock/scripts/PeripheryDeployConfig.s.sol
View file @
41d06234
...
...
@@ -28,6 +28,12 @@ contract PeripheryDeployConfig is Script {
uint256 public faucetGelatoBalanceV1DripInterval;
uint256 public faucetGelatoBalanceV1Value;
uint256 public faucetGelatoThreshold;
address public faucetOnchainAuthModuleAdmin;
uint256 public faucetOnchainAuthModuleAdminDripInterval;
uint256 public faucetOnchainAuthModuleAdminDripValue;
address public faucetOffchainAuthModuleAdmin;
uint256 public faucetOffchainAuthModuleAdminDripInterval;
uint256 public faucetOffchainAuthModuleAdminDripValue;
constructor(string memory _path) {
console.log("PeripheryDeployConfig: reading file %s", _path);
...
...
@@ -54,5 +60,11 @@ contract PeripheryDeployConfig is Script {
faucetGelatoBalanceV1DripInterval = stdJson.readUint(_json, "$.faucetGelatoBalanceV1DripInterval");
faucetGelatoBalanceV1Value = stdJson.readUint(_json, "$.faucetGelatoBalanceV1Value");
faucetGelatoThreshold = stdJson.readUint(_json, "$.faucetGelatoThreshold");
faucetOnchainAuthModuleAdmin = stdJson.readAddress(_json, "$.faucetOnchainAuthModuleAdmin");
faucetOnchainAuthModuleAdminDripInterval = stdJson.readUint(_json, "$.faucetOnchainAuthModuleAdminDripInterval");
faucetOnchainAuthModuleAdminDripValue = stdJson.readUint(_json, "$.faucetOnchainAuthModuleAdminDripValue");
faucetOffchainAuthModuleAdmin = stdJson.readAddress(_json, "$.faucetOffchainAuthModuleAdmin");
faucetOffchainAuthModuleAdminDripInterval = stdJson.readUint(_json, "$.faucetOffchainAuthModuleAdminDripInterval");
faucetOffchainAuthModuleAdminDripValue = stdJson.readUint(_json, "$.faucetOffchainAuthModuleAdminDripValue");
}
}
packages/contracts-bedrock/src/periphery/faucet/Faucet.sol
View file @
41d06234
...
...
@@ -124,4 +124,11 @@ contract Faucet {
emit Drip(config.name, _auth.id, config.amount, _params.recipient);
}
/// @notice Returns the enable status of a given auth module.
/// @param _module module to check.
/// @return bool enabled status of auth modulew.
function getModuleStatus(IFaucetAuthModule _module) public view returns (bool) {
return modules[_module].enabled;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment