forked from defi-wonderland/solidity-foundry-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
180 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,10 @@ | ||
MAINNET_RPC= | ||
MAINNET_DEPLOYER_NAME= | ||
GNOSIS_RPC='https://rpc.gnosis.gateway.fm' | ||
GNOSIS_DEPLOYER_PK= | ||
|
||
OPTIMISM_RPC= | ||
OPTIMISM_DEPLOYER_PK= | ||
|
||
SEPOLIA_RPC= | ||
SEPOLIA_DEPLOYER_NAME= | ||
SEPOLIA_DEPLOYER_PK= | ||
|
||
ETHERSCAN_API_KEY= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,8 @@ | ||
forge-std/=node_modules/forge-std/src | ||
halmos-cheatcodes=node_modules/halmos-cheatcodes | ||
|
||
@openzeppelin/=node_modules/@openzeppelin/contracts/ | ||
@openzeppelin-upgradeable/=node_modules/@openzeppelin/contracts-upgradeable/ | ||
|
||
contracts/=src/contracts | ||
interfaces/=src/interfaces |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity 0.8.23; | ||
|
||
import {IERC20} from '@openzeppelin/token/ERC20/IERC20.sol'; | ||
import {Greeter, IGreeter} from 'contracts/Greeter.sol'; | ||
import {Script} from 'forge-std/Script.sol'; | ||
// solhint-disable-next-line | ||
import 'script/Registry.sol'; | ||
|
||
/** | ||
* @title Common Contract | ||
* @author Breadchain | ||
* @notice This contract is used to deploy the Greeter 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; | ||
|
||
/// @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)); | ||
|
||
// Gnosis | ||
_deploymentParams[100] = DeploymentParams('Hello, Gnosis!', IERC20(GNOSIS_BREAD)); | ||
} | ||
|
||
function _deployContracts() internal { | ||
DeploymentParams memory _params = _deploymentParams[block.chainid]; | ||
|
||
greeter = new Greeter(_params.greeting, _params.token); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,14 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity 0.8.23; | ||
|
||
import {Greeter} from 'contracts/Greeter.sol'; | ||
import {Script} from 'forge-std/Script.sol'; | ||
import {IERC20} from 'forge-std/interfaces/IERC20.sol'; | ||
|
||
contract Deploy is Script { | ||
struct DeploymentParams { | ||
string greeting; | ||
IERC20 token; | ||
} | ||
|
||
/// @notice Deployment parameters for each chain | ||
mapping(uint256 _chainId => DeploymentParams _params) internal _deploymentParams; | ||
|
||
function setUp() public { | ||
// Mainnet | ||
_deploymentParams[1] = DeploymentParams('Hello, Mainnet!', IERC20(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2)); | ||
|
||
// Sepolia | ||
_deploymentParams[11_155_111] = | ||
DeploymentParams('Hello, Sepolia!', IERC20(0xB4FBF271143F4FBf7B91A5ded31805e42b2208d6)); | ||
} | ||
import {Common} from 'script/Common.sol'; | ||
|
||
contract Deploy is Common { | ||
function run() public { | ||
DeploymentParams memory _params = _deploymentParams[block.chainid]; | ||
|
||
vm.startBroadcast(); | ||
new Greeter(_params.greeting, _params.token); | ||
|
||
_deployContracts(); | ||
|
||
vm.stopBroadcast(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity 0.8.23; | ||
|
||
/// @dev Example of addresses that may be stored in the Registry for use throughout the repository | ||
|
||
// Tokens (Optimism Chain) | ||
address constant OPTIMISM_DAI = 0xDA10009cBd5D07dd0CeCc66161FC93D7c9000da1; | ||
|
||
// Tokens (Gnosis Chain) | ||
address constant GNOSIS_BREAD = 0xa555d5344f6FB6c65da19e403Cb4c1eC4a1a5Ee3; | ||
address constant GNOSIS_XDAI = 0xe91D153E0b41518A2Ce8Dd3D7944Fa863463a97d; | ||
|
||
// Curve Factory (Gnosis Chain) | ||
address constant GNOSIS_CURVE_STABLE_SWAP_FACTORY = 0xbC0797015fcFc47d9C1856639CaE50D0e69FbEE8; | ||
|
||
// Liquidity Pools (Gnosis Chain) | ||
address constant GNOSIS_CURVE_POOL_XDAI_BREAD = 0xf3D8F3dE71657D342db60dd714c8a2aE37Eac6B4; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,29 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity 0.8.23; | ||
|
||
import {Greeter, IGreeter} from 'contracts/Greeter.sol'; | ||
import {IERC20} from '@openzeppelin/token/ERC20/IERC20.sol'; | ||
import {Test} from 'forge-std/Test.sol'; | ||
import {IERC20} from 'forge-std/interfaces/IERC20.sol'; | ||
import {Common} from 'script/Common.sol'; | ||
// solhint-disable-next-line | ||
import 'script/Registry.sol'; | ||
|
||
contract IntegrationBase is Test { | ||
uint256 internal constant _FORK_BLOCK = 18_920_905; | ||
contract IntegrationBase is Common, Test { | ||
uint256 public constant INIT_BALANCE = 1 ether; | ||
|
||
string internal _initialGreeting = 'hola'; | ||
address internal _user = makeAddr('user'); | ||
address internal _owner = makeAddr('owner'); | ||
address internal _daiWhale = 0x42f8CA49E88A8fd8F0bfA2C739e648468b8f9dec; | ||
IERC20 internal _dai = IERC20(0x6B175474E89094C44Da98b954EedeAC495271d0F); | ||
IGreeter internal _greeter; | ||
address public user = makeAddr('user'); | ||
address public owner = makeAddr('owner'); | ||
|
||
function setUp() public { | ||
vm.createSelectFork(vm.rpcUrl('mainnet'), _FORK_BLOCK); | ||
vm.prank(_owner); | ||
_greeter = new Greeter(_initialGreeting, _dai); | ||
IERC20 public bread = IERC20(GNOSIS_BREAD); | ||
|
||
function setUp() public virtual override { | ||
super.setUp(); | ||
vm.createSelectFork(vm.rpcUrl('gnosis')); | ||
vm.startPrank(owner); | ||
|
||
/// @dev deploy contracts methods are located in script/Common.sol | ||
_deployContracts(); | ||
|
||
vm.stopPrank(); | ||
deal(GNOSIS_BREAD, address(greeter), INIT_BALANCE); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters