Skip to content

Commit

Permalink
refactor: add deplyment script
Browse files Browse the repository at this point in the history
  • Loading branch information
daopunk committed Dec 1, 2024
1 parent 7bc9ac4 commit 006d86e
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 10 deletions.
54 changes: 48 additions & 6 deletions script/Common.sol
Original file line number Diff line number Diff line change
@@ -1,12 +1,23 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.23;

// import {IERC20} from '@oz/token/ERC20/IERC20.sol';
import {IBuildersManager} from 'contracts/BuildersManager.sol';
import {TransparentUpgradeableProxy} from '@oz/proxy/transparent/TransparentUpgradeableProxy.sol';
import {BuildersManager, IBuildersManager} from 'contracts/BuildersManager.sol';
import {Script} from 'forge-std/Script.sol';
// solhint-disable-next-line
import 'script/Registry.sol';

address constant EAS = address(0x420);
address constant BUILDERS_DOLLAR = address(0x421);

struct DeploymentParams {
address token; // BuildersDollar token address
address eas; // Ethereum Attestation Service address
string name; // Contract name for EIP712
string version; // Contract version for EIP712
IBuildersManager.BuilderManagerSettings settings; // Settings struct
}

/**
* @title Common Contract
* @author Breadchain
Expand All @@ -16,17 +27,48 @@ import 'script/Registry.sol';
contract Common is Script {
IBuildersManager public builderManager;

// @notice Deployer address will be the owner of the proxy
address public deployer;

/// @notice Deployment parameters for each chain
// mapping(uint256 _chainId => DeploymentParams _params) internal _deploymentParams;
mapping(uint256 _chainId => DeploymentParams _settings) internal _deploymentParams;

function setUp() public virtual {
// Optimism
// _deploymentParams[10] = DeploymentParams('Hello, Optimism!', IERC20(OPTIMISM_DAI));
_deploymentParams[10] = DeploymentParams({
token: BUILDERS_DOLLAR, // Replace with actual BuildersDollar address
eas: EAS, // Replace with actual EAS address
name: 'BuildersManager',
version: '1',
settings: IBuildersManager.BuilderManagerSettings({
cycleLength: 7 days,
lastClaimedTimestamp: uint64(block.timestamp),
currentSeasonExpiry: uint64(block.timestamp + 180 days),
seasonDuration: 365 days,
minVouches: 3,
optimismFoundationAttesters: new address[](0) // Replace with actual attesters
})
});
}

function _deployContracts() internal {
// DeploymentParams memory _params = _deploymentParams[block.chainid];
DeploymentParams memory _settings = _deploymentParams[block.chainid];

address token = _settings.token;
address eas = _settings.eas;
string memory name = _settings.name;
string memory version = _settings.version;
IBuildersManager.BuilderManagerSettings memory settings = _settings.settings;

// builderManager = new BuildersManager(_params.greeting, _params.token);
address _implementation = address(new BuildersManager());
builderManager = BuildersManager(
address(
new TransparentUpgradeableProxy(
_implementation,
deployer,
abi.encodeWithSelector(IBuildersManager.initialize.selector, token, eas, name, version, settings)
)
)
);
}
}
5 changes: 3 additions & 2 deletions script/Deploy.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ import {Common} from 'script/Common.sol';

contract Deploy is Common {
function run() public {
vm.startBroadcast();
uint256 _deployerPk = uint256(vm.envBytes32('OPTIMISM_DEPLOYER_PK'));
deployer = vm.addr(_deployerPk);

vm.startBroadcast();
_deployContracts();

vm.stopBroadcast();
}
}
4 changes: 2 additions & 2 deletions test/integration/IntegrationBase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ contract IntegrationBase is Common, Test {

function setUp() public virtual override {
super.setUp();
deployer = owner;
vm.createSelectFork(vm.rpcUrl('gnosis'));
vm.startPrank(owner);

vm.startPrank(owner);
_deployContracts();

vm.stopPrank();
}
}

0 comments on commit 006d86e

Please sign in to comment.