Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: fix imports and silence linter warnings for script files #118

Merged
merged 3 commits into from
Jan 22, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions script/deploy/Utils.sol
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.15;

import "forge-std/Script.sol";
import "forge-std/StdJson.sol";
import {Script} from "forge-std/Script.sol";
import {stdJson} from "forge-std/StdJson.sol";

contract Utils is Script {
using stdJson for string;
Expand Down
2 changes: 1 addition & 1 deletion script/deploy/l1/RollbackGasLimit.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.15;

import "./SetGasLimitBuilder.sol";
import {SetGasLimitBuilder} from "./SetGasLimitBuilder.sol";

contract RollbackGasLimit is SetGasLimitBuilder {
function _fromGasLimit() internal view override returns (uint64) {
Expand Down
1 change: 1 addition & 0 deletions script/deploy/l1/SetGasLimitBuilder.sol
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ abstract contract SetGasLimitBuilder is MultisigBuilder {
key: 0x0000000000000000000000000000000000000000000000000000000000000068, // slot of gas limit
value: bytes32(uint256(_fromGasLimit()))
});
// solhint-disable-next-line max-line-length
_stateOverrides[0] = Simulation.StateOverride({contractAddress: L1_SYSTEM_CONFIG, overrides: _storageOverrides});
return _stateOverrides;
}
Expand Down
2 changes: 1 addition & 1 deletion script/deploy/l1/UpgradeGasLimit.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.15;

import "./SetGasLimitBuilder.sol";
import {SetGasLimitBuilder} from "./SetGasLimitBuilder.sol";

contract UpgradeGasLimit is SetGasLimitBuilder {
function _fromGasLimit() internal view override returns (uint64) {
Expand Down
8 changes: 6 additions & 2 deletions script/deploy/l1/tests/DeployTestTokenContracts.s.sol
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.15;

import "forge-std/console.sol";
import "forge-std/Script.sol";
// solhint-disable-next-line no-console
import {console} from "forge-std/console.sol";
import {Script} from "forge-std/Script.sol";

import {ERC20PresetMinterPauser} from "@openzeppelin/contracts/token/ERC20/presets/ERC20PresetMinterPauser.sol";
import {ERC721PresetMinterPauserAutoId} from
Expand All @@ -13,14 +14,17 @@ contract DeployTestTokenContracts is Script {
function run(address _tester) public {
vm.startBroadcast(_tester);
ERC20PresetMinterPauser erc20 = new ERC20PresetMinterPauser("L1 TEST ERC20", "L1T20");
// solhint-disable-next-line no-console
console.log("TEST ERC20 deployed to: %s", address(erc20));

ERC721PresetMinterPauserAutoId erc721 =
new ERC721PresetMinterPauserAutoId("L1 TEST ERC721", "L1T721", "not applicable");
// solhint-disable-next-line no-console
console.log("TEST ERC721 deployed to: %s", address(erc721));

erc20.mint(_tester, 1_000_000 ether);
erc721.mint(_tester);
// solhint-disable-next-line no-console
console.log("Minting to tester complete");

vm.stopBroadcast();
Expand Down
8 changes: 6 additions & 2 deletions script/deploy/l1/tests/TestDeposits.s.sol
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.15;

import "forge-std/console.sol";
import "forge-std/Script.sol";
// solhint-disable-next-line no-console
import {console} from "forge-std/console.sol";
import {Script} from "forge-std/Script.sol";

import {ERC20PresetMinterPauser} from "@openzeppelin/contracts/token/ERC20/presets/ERC20PresetMinterPauser.sol";
import {ERC721PresetMinterPauserAutoId} from
Expand All @@ -26,14 +27,17 @@ contract DeployTestContracts is Script {
ERC20PresetMinterPauser(_l1erc20).approve(_l1StandardBirdge, 1_000_000 ether);
ERC721PresetMinterPauserAutoId(_l1erc721).approve(_l1erc721Bridge, 0);

// solhint-disable-next-line no-console
console.log("Approvals to bridge contracts complete");

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

// solhint-disable-next-line no-console
console.log("L1StandardBridge erc20 deposit complete");

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

// solhint-disable-next-line no-console
console.log("L1ERC721Bridge erc721 deposit complete");
}
}
7 changes: 5 additions & 2 deletions script/deploy/l2/tests/DeployTestTokenContracts.s.sol
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.15;

import "forge-std/console.sol";
import "forge-std/Script.sol";
// solhint-disable-next-line no-console
import {console} from "forge-std/console.sol";
import {Script} from "forge-std/Script.sol";

import {Predeploys} from "@eth-optimism-bedrock/src/libraries/Predeploys.sol";
import {OptimismMintableERC20Factory} from "@eth-optimism-bedrock/src/universal/OptimismMintableERC20Factory.sol";
Expand All @@ -14,10 +15,12 @@ contract DeployTestTokenContracts is Script {
vm.startBroadcast(_tester);
address erc20 = OptimismMintableERC20Factory(Predeploys.OPTIMISM_MINTABLE_ERC20_FACTORY)
.createOptimismMintableERC20(_l1erc20, "L2 TEST ERC20", "L2T20");
// solhint-disable-next-line no-console
console.log("Bridged erc20 deployed to: %s", address(erc20));

address erc721 = OptimismMintableERC721Factory(payable(Predeploys.OPTIMISM_MINTABLE_ERC721_FACTORY))
.createOptimismMintableERC721(_l1erc721, "L2 TEST ERC721", "L1T721");
// solhint-disable-next-line no-console
console.log("Bridged erc721 deployed to: %s", address(erc721));

vm.stopBroadcast();
Expand Down
7 changes: 5 additions & 2 deletions script/deploy/l2/tests/TestWithdraw.s.sol
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.15;

import "forge-std/console.sol";
import "forge-std/Script.sol";
// solhint-disable-next-line no-console
import {console} from "forge-std/console.sol";
import {Script} from "forge-std/Script.sol";

import {Predeploys} from "@eth-optimism-bedrock/src/libraries/Predeploys.sol";
import {L2StandardBridge} from "@eth-optimism-bedrock/src/L2/L2StandardBridge.sol";
Expand All @@ -13,9 +14,11 @@ contract TestWithdraw is Script {
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(""));
// solhint-disable-next-line no-console
console.log("erc20 withdrawal initiated");

L2ERC721Bridge(payable(Predeploys.L2_ERC721_BRIDGE)).bridgeERC721(_l2erc721, _l1erc721, 0, 200_000, bytes(""));
// solhint-disable-next-line no-console
console.log("erc721 withdrawal initiated");

vm.stopBroadcast();
Expand Down
7 changes: 6 additions & 1 deletion script/universal/DoubleNestedMultisigBuilder.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.15;

import "./NestedMultisigBase.sol";
import {IMulticall3} from "forge-std/interfaces/IMulticall3.sol";
import {Vm} from "forge-std/Vm.sol";

import {IGnosisSafe} from "./IGnosisSafe.sol";
import {NestedMultisigBase} from "./NestedMultisigBase.sol";
import {Simulation} from "./Simulation.sol";

/**
* @title DoubleNestedMultisigBuilder
Expand Down
20 changes: 17 additions & 3 deletions script/universal/MultisigBase.sol
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.15;

import {Vm} from "forge-std/Vm.sol";
import {console} from "forge-std/console.sol";
import {CommonBase} from "forge-std/Base.sol";
// solhint-disable-next-line no-console
import {console} from "forge-std/console.sol";
import {IMulticall3} from "forge-std/interfaces/IMulticall3.sol";
import {Vm} from "forge-std/Vm.sol";

import {IGnosisSafe, Enum} from "./IGnosisSafe.sol";
import {Simulation} from "./Simulation.sol";
import {Signatures} from "./Signatures.sol";
import {Simulation} from "./Simulation.sol";

abstract contract MultisigBase is CommonBase {
bytes32 internal constant SAFE_NONCE_SLOT = bytes32(uint256(5));
Expand Down Expand Up @@ -52,6 +54,7 @@ abstract contract MultisigBase is CommonBase {

// print if any override
if (nonce != safeNonce) {
// solhint-disable-next-line no-console
console.log("Overriding nonce for safe %s: %d -> %d", _safe, safeNonce, nonce);
}
}
Expand All @@ -63,19 +66,30 @@ abstract contract MultisigBase is CommonBase {

emit DataToSign(txData);

// solhint-disable-next-line no-console
console.log("---\nIf submitting onchain, call Safe.approveHash on %s with the following hash:", _safe);
// solhint-disable-next-line no-console
console.logBytes32(hash);

// solhint-disable-next-line no-console
console.log("---\nData to sign:");
// solhint-disable-next-line no-console
console.log("vvvvvvvv");
// solhint-disable-next-line no-console
console.logBytes(txData);
// solhint-disable-next-line no-console
console.log("^^^^^^^^\n");

// solhint-disable-next-line no-console
console.log("########## IMPORTANT ##########");
// solhint-disable-next-line no-console
console.log(
// solhint-disable-next-line max-line-length
"Please make sure that the 'Data to sign' displayed above matches what you see in the simulation and on your hardware wallet."
);
// solhint-disable-next-line no-console
console.log("This is a critical step that must not be skipped.");
// solhint-disable-next-line no-console
console.log("###############################");
}

Expand Down
9 changes: 7 additions & 2 deletions script/universal/MultisigBuilder.sol
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.15;

import "./MultisigBase.sol";

// solhint-disable-next-line no-console
import {console} from "forge-std/console.sol";
import {IMulticall3} from "forge-std/interfaces/IMulticall3.sol";
import {Vm} from "forge-std/Vm.sol";

import {IGnosisSafe} from "./IGnosisSafe.sol";
import {MultisigBase} from "./MultisigBase.sol";
import {Signatures} from "./Signatures.sol";
import {Simulation} from "./Simulation.sol";

/**
* @title MultisigBuilder
* @notice Modeled from Optimism's SafeBuilder, but using signatures instead of approvals.
Expand Down Expand Up @@ -129,6 +133,7 @@ abstract contract MultisigBuilder is MultisigBase {
*/
function nonce() public view {
IGnosisSafe safe = IGnosisSafe(_ownerSafe());
// solhint-disable-next-line no-console
console.log("Nonce:", safe.nonce());
}

Expand Down
15 changes: 14 additions & 1 deletion script/universal/NestedMultisigBase.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.15;

import "./MultisigBase.sol";
// solhint-disable-next-line no-console
import {console} from "forge-std/console.sol";
import {IMulticall3} from "forge-std/interfaces/IMulticall3.sol";
import {Vm} from "forge-std/Vm.sol";

import {IGnosisSafe} from "./IGnosisSafe.sol";
import {MultisigBase} from "./MultisigBase.sol";
import {Signatures} from "./Signatures.sol";
import {Simulation} from "./Simulation.sol";

abstract contract NestedMultisigBase is MultisigBase {
/**
Expand Down Expand Up @@ -47,7 +55,9 @@ abstract contract NestedMultisigBase is MultisigBase {
{
bytes32 hash = _getTransactionHash(_safe, _calls);

// solhint-disable-next-line no-console
console.log("---\nNested hash:");
// solhint-disable-next-line no-console
console.logBytes32(hash);

return IMulticall3.Call3({
Expand All @@ -68,7 +78,9 @@ abstract contract NestedMultisigBase is MultisigBase {
Simulation.StateOverride[] memory overrides = _overrides(_signerSafe, _safe);

bytes memory txData = abi.encodeCall(IMulticall3.aggregate3, (calls));
// solhint-disable-next-line no-console
console.log("---\nSimulation link:");
// solhint-disable-next-line max-line-length
Simulation.logSimulationLink({_to: MULTICALL3_ADDRESS, _data: txData, _from: msg.sender, _overrides: overrides});

// Forge simulation of the data logged in the link. If the simulation fails
Expand Down Expand Up @@ -106,6 +118,7 @@ abstract contract NestedMultisigBase is MultisigBase {
calls[0] = IMulticall3.Call3({target: _signerSafe, allowFailure: false, callData: approveHashExec});

// simulate the final state changes tx, so that signer can verify the final results
// solhint-disable-next-line max-line-length
bytes memory finalExec = _execTransationCalldata(_safe, _data, Signatures.genPrevalidatedSignature(_signerSafe));
calls[1] = IMulticall3.Call3({target: _safe, allowFailure: false, callData: finalExec});

Expand Down
14 changes: 12 additions & 2 deletions script/universal/NestedMultisigBuilder.sol
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.15;

import "./MultisigBase.sol";

// solhint-disable-next-line no-console
import {console} from "forge-std/console.sol";
import {IMulticall3} from "forge-std/interfaces/IMulticall3.sol";
import {Vm} from "forge-std/Vm.sol";

import {IGnosisSafe} from "./IGnosisSafe.sol";
import {MultisigBase} from "./MultisigBase.sol";
import {Signatures} from "./Signatures.sol";
import {Simulation} from "./Simulation.sol";

/**
* @title NestedMultisigBuilder
Expand Down Expand Up @@ -145,7 +150,9 @@ abstract contract NestedMultisigBuilder is MultisigBase {
{
bytes32 hash = _getTransactionHash(_safe, _calls);

// solhint-disable-next-line no-console
console.log("---\nNested hash:");
// solhint-disable-next-line no-console
console.logBytes32(hash);

return IMulticall3.Call3({
Expand All @@ -166,7 +173,9 @@ abstract contract NestedMultisigBuilder is MultisigBase {
Simulation.StateOverride[] memory overrides = _overrides(_signerSafe, _safe);

bytes memory txData = abi.encodeCall(IMulticall3.aggregate3, (calls));
// solhint-disable-next-line no-console
console.log("---\nSimulation link:");
// solhint-disable-next-line max-line-length
Simulation.logSimulationLink({_to: MULTICALL3_ADDRESS, _data: txData, _from: msg.sender, _overrides: overrides});

// Forge simulation of the data logged in the link. If the simulation fails
Expand Down Expand Up @@ -204,6 +213,7 @@ abstract contract NestedMultisigBuilder is MultisigBase {
calls[0] = IMulticall3.Call3({target: _signerSafe, allowFailure: false, callData: approveHashExec});

// simulate the final state changes tx, so that signer can verify the final results
// solhint-disable-next-line max-line-length
bytes memory finalExec = _execTransationCalldata(_safe, _data, Signatures.genPrevalidatedSignature(_signerSafe));
calls[1] = IMulticall3.Call3({target: _safe, allowFailure: false, callData: finalExec});

Expand Down
Loading
Loading