Skip to content

Commit

Permalink
Merge pull request #5 from BreadchainCoop/bagel-refactor
Browse files Browse the repository at this point in the history
Bagel refactor
  • Loading branch information
bagelface authored Jan 9, 2025
2 parents 60e4792 + ee54c69 commit ce8a774
Show file tree
Hide file tree
Showing 24 changed files with 1,198 additions and 1,109 deletions.
2 changes: 1 addition & 1 deletion foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ multiline_func_header = 'params_first_multi'
sort_imports = true

[profile.default]
solc_version = '0.8.23'
solc_version = '0.8.28'
libs = ['node_modules', 'lib']
optimizer_runs = 10_000

Expand Down
48 changes: 25 additions & 23 deletions script/Common.sol
Original file line number Diff line number Diff line change
@@ -1,40 +1,42 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.23;
pragma solidity 0.8.28;

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

import {SavingCircles} from '../src/contracts/SavingCircles.sol';

/**
* @title Common Contract
* @author Breadchain
* @notice This contract is used to deploy the Greeter contract
* @notice This contract is used to deploy an upgradeable Saving Circles contract
* @dev This contract is intended for use in Scripts and Integration Tests
*/
contract Common is Script {
struct DeploymentParams {
string greeting;
IERC20 token;
}

IGreeter public greeter;
function setUp() public virtual {}

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

function setUp() public virtual {
// Optimism
_deploymentParams[10] = DeploymentParams('Hello, Optimism!', IERC20(OPTIMISM_DAI));
function _deploySavingCircles() internal returns (SavingCircles) {
return new SavingCircles();
}

// Gnosis
_deploymentParams[100] = DeploymentParams('Hello, Gnosis!', IERC20(GNOSIS_BREAD));
function _deployProxyAdmin(address _admin) internal returns (ProxyAdmin) {
return new ProxyAdmin(_admin);
}

function _deployContracts() internal {
DeploymentParams memory _params = _deploymentParams[block.chainid];
function _deployTransparentProxy(
address _implementation,
address _proxyAdmin,
bytes memory _initData
) internal returns (TransparentUpgradeableProxy) {
return new TransparentUpgradeableProxy(_implementation, _proxyAdmin, _initData);
}

greeter = new Greeter(_params.greeting, _params.token);
function _deployContracts(address _admin) internal returns (TransparentUpgradeableProxy) {
return _deployTransparentProxy(
address(_deploySavingCircles()),
address(_deployProxyAdmin(_admin)),
abi.encodeWithSelector(SavingCircles.initialize.selector, _admin)
);
}
}
6 changes: 3 additions & 3 deletions script/Deploy.sol
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.23;
pragma solidity 0.8.28;

import {Common} from 'script/Common.sol';

contract Deploy is Common {
function run() public {
function run(address _admin) public {
vm.startBroadcast();

_deployContracts();
_deployContracts(_admin);

vm.stopBroadcast();
}
Expand Down
30 changes: 0 additions & 30 deletions script/DeploySavingsCircle.s.sol

This file was deleted.

2 changes: 1 addition & 1 deletion script/Registry.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.23;
pragma solidity 0.8.28;

/// @dev Example of addresses that may be stored in the Registry for use throughout the repository

Expand Down
2 changes: 1 addition & 1 deletion src/contracts/Greeter.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.23;
pragma solidity 0.8.28;

import {IERC20} from '@openzeppelin/token/ERC20/IERC20.sol';
import {IGreeter} from 'interfaces/IGreeter.sol';
Expand Down
Loading

0 comments on commit ce8a774

Please sign in to comment.