generated from defi-wonderland/solidity-foundry-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: script commands and arbitrary scripts
- Loading branch information
excaliborr
committed
Aug 1, 2024
1 parent
e63941d
commit 76aa5a8
Showing
6 changed files
with
105 additions
and
1 deletion.
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
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 |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity 0.8.25; | ||
|
||
import {Script} from 'forge-std/Script.sol'; | ||
import {console} from 'forge-std/Test.sol'; | ||
import {IL1OpUSDCFactory} from 'interfaces/IL1OpUSDCFactory.sol'; | ||
import {USDCInitTxs} from 'src/contracts/utils/USDCInitTxs.sol'; | ||
|
||
contract Deploy is Script { | ||
uint32 public constant MIN_GAS_LIMIT_DEPLOY = 9_000_000; | ||
IL1OpUSDCFactory public immutable L1_FACTORY = IL1OpUSDCFactory(vm.envAddress('L1_FACTORY_MAINNET')); | ||
address public immutable BRIDGED_USDC_IMPLEMENTATION = vm.envAddress('BRIDGED_USDC_IMPLEMENTATION'); | ||
address public immutable L1_MESSENGER = vm.envAddress('CUSTOM_L1_MESSENGER'); | ||
string public CHAIN_NAME = vm.envString('CHAIN_NAME'); | ||
address public owner = vm.rememberKey(vm.envUint('MAINNET_PK')); | ||
|
||
function run() public { | ||
vm.createSelectFork(vm.rpcUrl(vm.envString('MAINNET_RPC'))); | ||
vm.startBroadcast(owner); | ||
|
||
// NOTE: We have these hardcoded to default values, if used in product you will need to change them | ||
bytes[] memory _usdcInitTxs = new bytes[](3); | ||
_usdcInitTxs[0] = USDCInitTxs.INITIALIZEV2; | ||
_usdcInitTxs[1] = USDCInitTxs.INITIALIZEV2_1; | ||
_usdcInitTxs[2] = USDCInitTxs.INITIALIZEV2_2; | ||
|
||
IL1OpUSDCFactory.L2Deployments memory _l2Deployments = IL1OpUSDCFactory.L2Deployments({ | ||
l2AdapterOwner: owner, | ||
usdcImplAddr: BRIDGED_USDC_IMPLEMENTATION, | ||
usdcInitTxs: _usdcInitTxs, | ||
minGasLimitDeploy: MIN_GAS_LIMIT_DEPLOY | ||
}); | ||
|
||
// Deploy the L2 contracts | ||
(address _l1Adapter, address _l2Factory, address _l2Adapter) = | ||
L1_FACTORY.deploy(L1_MESSENGER, owner, CHAIN_NAME, _l2Deployments); | ||
vm.stopBroadcast(); | ||
|
||
/// NOTE: Hardcode the `L1_ADAPTER_BASE` and `L2_ADAPTER_BASE` addresses inside the `.env` file | ||
console.log('L1 Adapter:', _l1Adapter); | ||
console.log('L2 Factory:', _l2Factory); | ||
console.log('L2 Adapter:', _l2Adapter); | ||
} | ||
} |
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,22 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity 0.8.25; | ||
|
||
import {Script} from 'forge-std/Script.sol'; | ||
import {IL1OpUSDCBridgeAdapter} from 'interfaces/IL1OpUSDCBridgeAdapter.sol'; | ||
|
||
contract MigrateToNative is Script { | ||
uint32 public constant MIN_GAS_LIMIT_RECEIVE_L2 = 100_000; | ||
uint32 public constant MIN_GAS_LIMIT_SET_BURN_AMOUNT_L2 = 100_000; | ||
IL1OpUSDCBridgeAdapter public immutable L1_ADAPTER = IL1OpUSDCBridgeAdapter(vm.envAddress('L1_ADAPTER')); | ||
|
||
address public owner = vm.rememberKey(vm.envUint('MAINNET_OWNER_PK')); | ||
address public roleCaller = vm.envAddress('ROLE_CALLER'); | ||
address public burnCaller = vm.envAddress('BURN_CALLER'); | ||
|
||
function run() public { | ||
vm.createSelectFork(vm.rpcUrl(vm.envString('MAINNET_RPC'))); | ||
vm.startBroadcast(owner); | ||
L1_ADAPTER.migrateToNative(roleCaller, burnCaller, MIN_GAS_LIMIT_RECEIVE_L2, MIN_GAS_LIMIT_SET_BURN_AMOUNT_L2); | ||
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,27 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity 0.8.25; | ||
|
||
import {Script} from 'forge-std/Script.sol'; | ||
import {console} from 'forge-std/Test.sol'; | ||
import {IL1OpUSDCFactory} from 'interfaces/IL1OpUSDCFactory.sol'; | ||
|
||
import {IOpUSDCBridgeAdapter} from 'interfaces/IOpUSDCBridgeAdapter.sol'; | ||
import {IUSDC} from 'interfaces/external/IUSDC.sol'; | ||
import {USDCInitTxs} from 'src/contracts/utils/USDCInitTxs.sol'; | ||
|
||
contract Bridge is Script { | ||
address public constant L1_MESSENGER = 0x58Cc85b8D04EA49cC6DBd3CbFFd00B4B8D6cb3ef; | ||
uint32 public constant MIN_GAS_LIMIT_DEPLOY = 9_000_000; | ||
string public constant CHAIN_NAME = 'Optimism Sepolia'; | ||
IOpUSDCBridgeAdapter public immutable ADAPTER = IOpUSDCBridgeAdapter(0xF6277eD38fB97e0383927dc04fDEE397cd94124e); | ||
IUSDC public immutable USDC = IUSDC(0xF3dD0c89cf78C46A4150238e8A50285e1f4b5407); | ||
|
||
address public owner = vm.rememberKey(vm.envUint('SEPOLIA_PK')); | ||
|
||
function run() public { | ||
vm.startBroadcast(owner); | ||
uint256 _balanceOf = USDC.balanceOf(owner); | ||
ADAPTER.sendMessage(owner, _balanceOf, 200_000); | ||
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