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
058d69d1
Unverified
Commit
058d69d1
authored
Oct 04, 2023
by
Mark Tyneway
Committed by
GitHub
Oct 04, 2023
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #7486 from tarunkhasnavis/develop
Create deployment scripts for auth modules
parents
46676124
2c1dc3da
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
138 additions
and
2 deletions
+138
-2
optimism-goerli.json
...acts-bedrock/periphery-deploy-config/optimism-goerli.json
+8
-2
DeployPeriphery.s.sol
packages/contracts-bedrock/scripts/DeployPeriphery.s.sol
+111
-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 @
058d69d1
{
"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"
,
"faucetOnchainAuthModuleTtl"
:
86400
,
"faucetOnchainAuthModuleAmount"
:
1000000000000000000
,
"faucetOffchainAuthModuleAdmin"
:
"0x8F0EBDaA1cF7106bE861753B0f9F5c0250fE0819"
,
"faucetOffchainAuthModuleTtl"
:
86400
,
"faucetOffchainAuthModuleAmount"
:
50000000000000000
}
packages/contracts-bedrock/scripts/DeployPeriphery.s.sol
View file @
058d69d1
...
...
@@ -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,111 @@ 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.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.isModuleEnabled(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.faucetOnchainAuthModuleTtl(),
amount: cfg.faucetOnchainAuthModuleAmount()
});
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.isModuleEnabled(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.faucetOffchainAuthModuleTtl(),
amount: cfg.faucetOffchainAuthModuleAmount()
});
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 @
058d69d1
...
...
@@ -28,6 +28,12 @@ contract PeripheryDeployConfig is Script {
uint256 public faucetGelatoBalanceV1DripInterval;
uint256 public faucetGelatoBalanceV1Value;
uint256 public faucetGelatoThreshold;
address public faucetOnchainAuthModuleAdmin;
uint256 public faucetOnchainAuthModuleTtl;
uint256 public faucetOnchainAuthModuleAmount;
address public faucetOffchainAuthModuleAdmin;
uint256 public faucetOffchainAuthModuleTtl;
uint256 public faucetOffchainAuthModuleAmount;
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");
faucetOnchainAuthModuleTtl = stdJson.readUint(_json, "$.faucetOnchainAuthModuleTtl");
faucetOnchainAuthModuleAmount = stdJson.readUint(_json, "$.faucetOnchainAuthModuleAmount");
faucetOffchainAuthModuleAdmin = stdJson.readAddress(_json, "$.faucetOffchainAuthModuleAdmin");
faucetOffchainAuthModuleTtl = stdJson.readUint(_json, "$.faucetOffchainAuthModuleTtl");
faucetOffchainAuthModuleAmount = stdJson.readUint(_json, "$.faucetOffchainAuthModuleAmount");
}
}
packages/contracts-bedrock/src/periphery/faucet/Faucet.sol
View file @
058d69d1
...
...
@@ -124,4 +124,11 @@ contract Faucet {
emit Drip(config.name, _auth.id, config.amount, _params.recipient);
}
/// @notice Returns the enable value of a given auth module.
/// @param _module module to check.
/// @return bool enabled status of auth modulew.
function isModuleEnabled(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