Skip to content

Commit

Permalink
forge fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
mdehoog committed Oct 22, 2024
1 parent 0f82aaa commit ba94bcd
Show file tree
Hide file tree
Showing 37 changed files with 475 additions and 655 deletions.
9 changes: 4 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,10 @@ jobs:
run: |
forge --version
# TODO reformat and enable in separate PR
# - name: Run Forge fmt
# run: |
# forge fmt --check
# id: fmt
- name: Run Forge fmt
run: |
forge fmt --check
id: fmt

- name: Install dependencies
run: |
Expand Down
15 changes: 7 additions & 8 deletions script/deploy/Utils.sol
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ contract Utils is Script {
address l1FeeVaultRecipient;
uint256 l2BlockTime;
uint256 l2ChainId;
uint64 l2GenesisBlockGasLimit;
uint64 l2GenesisBlockGasLimit;
address l2OutputOracleChallenger;
address l2OutputOracleProposer;
uint256 l2OutputOracleStartingBlockNumber;
Expand Down Expand Up @@ -59,7 +59,7 @@ contract Utils is Script {
address SequencerFeeVault;
}

function getDeployBedrockConfig() external view returns(DeployBedrockConfig memory) {
function getDeployBedrockConfig() external view returns (DeployBedrockConfig memory) {
string memory root = vm.projectRoot();
string memory path = string.concat(root, "/inputs/foundry-config.json");
string memory json = vm.readFile(path);
Expand All @@ -84,7 +84,7 @@ contract Utils is Script {
}

function writeAddressesFile(AddressesConfig memory cfg) external {
string memory json= "";
string memory json = "";

// Proxy contract addresses
vm.serializeAddress(json, "ProxyAdmin", cfg.ProxyAdmin);
Expand All @@ -96,7 +96,7 @@ contract Utils is Script {
vm.serializeAddress(json, "OptimismMintableERC20FactoryProxy", cfg.OptimismMintableERC20FactoryProxy);
vm.serializeAddress(json, "L1ERC721BridgeProxy", cfg.L1ERC721BridgeProxy);
vm.serializeAddress(json, "SystemConfigProxy", cfg.SystemConfigProxy);

string memory finalJson = vm.serializeAddress(json, "SystemDictatorProxy", cfg.SystemDictatorProxy);

finalJson.write(string.concat("unsorted.json"));
Expand All @@ -115,10 +115,9 @@ contract Utils is Script {
vm.serializeAddress(json, "L2ToL1MessagePasser", cfg.L2ToL1MessagePasser);
vm.serializeAddress(json, "SequencerFeeVault", cfg.SequencerFeeVault);
vm.serializeAddress(json, "OptimismMintableERC20Factory", cfg.OptimismMintableERC20Factory);
string memory finalJson = vm.serializeAddress(
json, "OptimismMintableERC721Factory", cfg.OptimismMintableERC721Factory
);
string memory finalJson =
vm.serializeAddress(json, "OptimismMintableERC721Factory", cfg.OptimismMintableERC721Factory);

finalJson.write(string.concat("unsortedl2Impls.json"));
}
}
}
21 changes: 7 additions & 14 deletions script/deploy/l1/SetGasLimitBuilder.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,8 @@
pragma solidity 0.8.15;

import {SystemConfig} from "@eth-optimism-bedrock/src/L1/SystemConfig.sol";
import {
MultisigBuilder,
IMulticall3,
IGnosisSafe,
Simulation
} from "../../universal/MultisigBuilder.sol";
import { Vm } from "forge-std/Vm.sol";
import {MultisigBuilder, IMulticall3, IGnosisSafe, Simulation} from "../../universal/MultisigBuilder.sol";
import {Vm} from "forge-std/Vm.sol";

abstract contract SetGasLimitBuilder is MultisigBuilder {
address internal SYSTEM_CONFIG_OWNER = vm.envAddress("SYSTEM_CONFIG_OWNER");
Expand All @@ -19,20 +14,18 @@ abstract contract SetGasLimitBuilder is MultisigBuilder {
* Virtual Functions
* -----------------------------------------------------------
*/
function _fromGasLimit() internal view virtual returns (uint64);

function _fromGasLimit() internal virtual view returns (uint64);
function _toGasLimit() internal view virtual returns (uint64);

function _toGasLimit() internal virtual view returns (uint64);

function _nonceOffset() internal virtual view returns (uint64);
function _nonceOffset() internal view virtual returns (uint64);

/**
* -----------------------------------------------------------
* Implemented Functions
* -----------------------------------------------------------
*/

function _postCheck() internal override view {
function _postCheck() internal view override {
assert(SystemConfig(L1_SYSTEM_CONFIG).gasLimit() == _toGasLimit());
}

Expand Down Expand Up @@ -63,7 +56,7 @@ abstract contract SetGasLimitBuilder is MultisigBuilder {
Simulation.StorageOverride[] memory _storageOverrides = new Simulation.StorageOverride[](1);
_storageOverrides[0] = Simulation.StorageOverride({
key: 0x0000000000000000000000000000000000000000000000000000000000000068, // slot of gas limit
value: bytes32(uint(_fromGasLimit()))
value: bytes32(uint256(_fromGasLimit()))
});
_stateOverrides[0] = Simulation.StateOverride({contractAddress: L1_SYSTEM_CONFIG, overrides: _storageOverrides});
return _stateOverrides;
Expand Down
10 changes: 6 additions & 4 deletions script/deploy/l1/tests/DeployTestTokenContracts.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import "forge-std/console.sol";
import "forge-std/Script.sol";

import {ERC20PresetMinterPauser} from "@openzeppelin/contracts/token/ERC20/presets/ERC20PresetMinterPauser.sol";
import {ERC721PresetMinterPauserAutoId} from "@openzeppelin/contracts/token/ERC721/presets/ERC721PresetMinterPauserAutoId.sol";
import {ERC721PresetMinterPauserAutoId} from
"@openzeppelin/contracts/token/ERC721/presets/ERC721PresetMinterPauserAutoId.sol";

// Deploys test token contracts on L1 to test Base Mainnet's bridging functionality
contract DeployTestTokenContracts is Script {
Expand All @@ -14,13 +15,14 @@ contract DeployTestTokenContracts is Script {
ERC20PresetMinterPauser erc20 = new ERC20PresetMinterPauser("L1 TEST ERC20", "L1T20");
console.log("TEST ERC20 deployed to: %s", address(erc20));

ERC721PresetMinterPauserAutoId erc721 = new ERC721PresetMinterPauserAutoId("L1 TEST ERC721", "L1T721", "not applicable");
ERC721PresetMinterPauserAutoId erc721 =
new ERC721PresetMinterPauserAutoId("L1 TEST ERC721", "L1T721", "not applicable");
console.log("TEST ERC721 deployed to: %s", address(erc721));

erc20.mint(_tester, 1_000_000 ether);
erc721.mint(_tester);
console.log("Minting to tester complete");

vm.stopBroadcast();
}
}
19 changes: 4 additions & 15 deletions script/deploy/l1/tests/TestDeposits.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import "forge-std/console.sol";
import "forge-std/Script.sol";

import {ERC20PresetMinterPauser} from "@openzeppelin/contracts/token/ERC20/presets/ERC20PresetMinterPauser.sol";
import {ERC721PresetMinterPauserAutoId} from "@openzeppelin/contracts/token/ERC721/presets/ERC721PresetMinterPauserAutoId.sol";
import {ERC721PresetMinterPauserAutoId} from
"@openzeppelin/contracts/token/ERC721/presets/ERC721PresetMinterPauserAutoId.sol";

import {L1StandardBridge} from "@eth-optimism-bedrock/src/L1/L1StandardBridge.sol";
import {L1ERC721Bridge} from "@eth-optimism-bedrock/src/L1/L1ERC721Bridge.sol";
Expand All @@ -27,23 +28,11 @@ contract DeployTestContracts is Script {

console.log("Approvals to bridge contracts complete");

L1StandardBridge(_l1StandardBirdge).depositERC20(
_l1erc20,
_l2erc20,
1_000_000 ether,
200_000,
bytes("")
);
L1StandardBridge(_l1StandardBirdge).depositERC20(_l1erc20, _l2erc20, 1_000_000 ether, 200_000, bytes(""));

console.log("L1StandardBridge erc20 deposit complete");

L1ERC721Bridge(_l1erc721Bridge).bridgeERC721(
_l1erc721,
_l2erc721,
0,
200_000,
bytes("")
);
L1ERC721Bridge(_l1erc721Bridge).bridgeERC721(_l1erc721, _l2erc721, 0, 200_000, bytes(""));

console.log("L1ERC721Bridge erc721 deposit complete");
}
Expand Down
20 changes: 5 additions & 15 deletions script/deploy/l2/tests/DeployTestTokenContracts.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,14 @@ import {OptimismMintableERC721Factory} from "@eth-optimism-bedrock/src/universal

// Deploys test token contracts on L2 to test Base Mainnet functionality
contract DeployTestTokenContracts is Script {
function run(
address _tester,
address _l1erc20,
address _l1erc721
) public {
function run(address _tester, address _l1erc20, address _l1erc721) public {
vm.startBroadcast(_tester);
address erc20 = OptimismMintableERC20Factory(Predeploys.OPTIMISM_MINTABLE_ERC20_FACTORY).createOptimismMintableERC20(
_l1erc20,
"L2 TEST ERC20",
"L2T20"
);
address erc20 = OptimismMintableERC20Factory(Predeploys.OPTIMISM_MINTABLE_ERC20_FACTORY)
.createOptimismMintableERC20(_l1erc20, "L2 TEST ERC20", "L2T20");
console.log("Bridged erc20 deployed to: %s", address(erc20));

address erc721 = OptimismMintableERC721Factory(payable(Predeploys.OPTIMISM_MINTABLE_ERC721_FACTORY)).createOptimismMintableERC721(
_l1erc721,
"L2 TEST ERC721",
"L1T721"
);
address erc721 = OptimismMintableERC721Factory(payable(Predeploys.OPTIMISM_MINTABLE_ERC721_FACTORY))
.createOptimismMintableERC721(_l1erc721, "L2 TEST ERC721", "L1T721");
console.log("Bridged erc721 deployed to: %s", address(erc721));

vm.stopBroadcast();
Expand Down
22 changes: 3 additions & 19 deletions script/deploy/l2/tests/TestWithdraw.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,12 @@ import {L2ERC721Bridge} from "@eth-optimism-bedrock/src/L2/L2ERC721Bridge.sol";

// Withdraws tokens from L2 to L1 to test Base Mainnet's bridging functionality
contract TestWithdraw is Script {
function run(
address _tester,
address _l2erc20,
address _l1erc721,
address _l2erc721
) public {
function run(address _tester, address _l2erc20, address _l1erc721, address _l2erc721) public {
vm.startBroadcast(_tester);
L2StandardBridge(payable(Predeploys.L2_STANDARD_BRIDGE)).withdraw(
_l2erc20,
10_000 ether,
200_000,
bytes("")
);
L2StandardBridge(payable(Predeploys.L2_STANDARD_BRIDGE)).withdraw(_l2erc20, 10_000 ether, 200_000, bytes(""));
console.log("erc20 withdrawal initiated");

L2ERC721Bridge(payable(Predeploys.L2_ERC721_BRIDGE)).bridgeERC721(
_l2erc721,
_l1erc721,
0,
200_000,
bytes("")
);
L2ERC721Bridge(payable(Predeploys.L2_ERC721_BRIDGE)).bridgeERC721(_l2erc721, _l1erc721, 0, 200_000, bytes(""));
console.log("erc721 withdrawal initiated");

vm.stopBroadcast();
Expand Down
51 changes: 9 additions & 42 deletions script/universal/IGnosisSafe.sol
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,7 @@ interface IGnosisSafe {
function approveHash(bytes32 hashToApprove) external;
function approvedHashes(address, bytes32) external view returns (uint256);
function changeThreshold(uint256 _threshold) external;
function checkNSignatures(
bytes32 dataHash,
bytes memory data,
bytes memory signatures,
uint256 requiredSignatures
)
function checkNSignatures(bytes32 dataHash, bytes memory data, bytes memory signatures, uint256 requiredSignatures)
external
view;
function checkSignatures(bytes32 dataHash, bytes memory data, bytes memory signatures) external view;
Expand All @@ -58,10 +53,7 @@ interface IGnosisSafe {
address gasToken,
address refundReceiver,
uint256 _nonce
)
external
view
returns (bytes memory);
) external view returns (bytes memory);
function execTransaction(
address to,
uint256 value,
Expand All @@ -73,31 +65,15 @@ interface IGnosisSafe {
address gasToken,
address refundReceiver,
bytes memory signatures
)
external
payable
returns (bool success);
function execTransactionFromModule(
address to,
uint256 value,
bytes memory data,
Enum.Operation operation
)
) external payable returns (bool success);
function execTransactionFromModule(address to, uint256 value, bytes memory data, Enum.Operation operation)
external
returns (bool success);
function execTransactionFromModuleReturnData(
address to,
uint256 value,
bytes memory data,
Enum.Operation operation
)
function execTransactionFromModuleReturnData(address to, uint256 value, bytes memory data, Enum.Operation operation)
external
returns (bool success, bytes memory returnData);
function getChainId() external view returns (uint256);
function getModulesPaginated(
address start,
uint256 pageSize
)
function getModulesPaginated(address start, uint256 pageSize)
external
view
returns (address[] memory array, address next);
Expand All @@ -115,20 +91,12 @@ interface IGnosisSafe {
address gasToken,
address refundReceiver,
uint256 _nonce
)
external
view
returns (bytes32);
) external view returns (bytes32);
function isModuleEnabled(address module) external view returns (bool);
function isOwner(address owner) external view returns (bool);
function nonce() external view returns (uint256);
function removeOwner(address prevOwner, address owner, uint256 _threshold) external;
function requiredTxGas(
address to,
uint256 value,
bytes memory data,
Enum.Operation operation
)
function requiredTxGas(address to, uint256 value, bytes memory data, Enum.Operation operation)
external
returns (uint256);
function setFallbackHandler(address handler) external;
Expand All @@ -142,8 +110,7 @@ interface IGnosisSafe {
address paymentToken,
uint256 payment,
address paymentReceiver
)
external;
) external;
function signedMessages(bytes32) external view returns (uint256);
function simulateAndRevert(address targetContract, bytes memory calldataPayload) external;
function swapOwner(address prevOwner, address oldOwner, address newOwner) external;
Expand Down
Loading

0 comments on commit ba94bcd

Please sign in to comment.