-
Notifications
You must be signed in to change notification settings - Fork 2
Feat/shared script utilities #50
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
Changes from all commits
be06f0b
178fb7e
92656c3
967e6e1
dca9297
b88c994
0bccf7b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| { | ||
| "lib/forge-std": { | ||
| "branch": { | ||
| "name": "v1", | ||
| "rev": "1801b0541f4fda118a10798fd3486bb7051c5dd6" | ||
| } | ||
| }, | ||
| "lib/openzeppelin-contracts": { | ||
| "tag": { | ||
| "name": "v5.5.0", | ||
| "rev": "fcbae5394ae8ad52d8e580a3477db99814b9d565" | ||
| } | ||
| }, | ||
| "lib/openzeppelin-contracts-upgradeable": { | ||
| "branch": { | ||
| "name": "release-v5.3", | ||
| "rev": "60b305a8f3ff0c7688f02ac470417b6bbf1c4d27" | ||
| } | ||
| }, | ||
| "lib/safe-utils": { | ||
| "tag": { | ||
| "name": "v0.0.19", | ||
| "rev": "5310d6cd9c9d3146decfa3f8a17ac3edbeb40ca4" | ||
| } | ||
| } | ||
| } |
| +40 −0 | README.md | |
| +14 −0 | foundry.lock | |
| +1 −1 | lib/solidity-http | |
| +3 −0 | remappings.txt | |
| +1 −1 | src/ISafeSmartAccount.sol | |
| +133 −39 | src/Safe.sol | |
| +28 −3 | test/Safe.t.sol |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| // SPDX-License-Identifier: GPL-3.0 | ||
|
|
||
| pragma solidity >=0.8.20 <0.9.0; | ||
|
|
||
| /// @notice Common EVM chain IDs shared across M0 protocol repos. | ||
| library ChainsBase { | ||
| // Mainnet | ||
| uint256 internal constant ETHEREUM = 1; | ||
|
|
||
| // Testnet | ||
| uint256 internal constant ETHEREUM_SEPOLIA = 11155111; | ||
|
|
||
| function isHub(uint256 chainId_) internal pure returns (bool) { | ||
| return chainId_ == ETHEREUM || chainId_ == ETHEREUM_SEPOLIA; | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| // SPDX-License-Identifier: GPL-3.0 | ||
|
|
||
| pragma solidity >=0.8.20 <0.9.0; | ||
|
|
||
| /// @notice Shared deployment constants for M0 protocol repos. | ||
| abstract contract DeployUtils { | ||
| /// @dev Same address for all EVM chains. | ||
| address internal constant _SWAP_FACILITY = 0xB6807116b3B1B321a390594e31ECD6e0076f6278; | ||
| } |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,48 @@ | ||||||||||||||||||||||||||||||
| // SPDX-License-Identifier: UNLICENSED | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| pragma solidity >=0.8.20 <0.9.0; | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| import { | ||||||||||||||||||||||||||||||
| TimelockController | ||||||||||||||||||||||||||||||
| } from "../lib/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts/contracts/governance/TimelockController.sol"; | ||||||||||||||||||||||||||||||
| import { Script } from "../lib/forge-std/src/Script.sol"; | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| abstract contract TimelockBatchBase is Script { | ||||||||||||||||||||||||||||||
| address[] internal _timelockTargets; | ||||||||||||||||||||||||||||||
| uint256[] internal _timelockValues; | ||||||||||||||||||||||||||||||
| bytes[] internal _timelockPayloads; | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| function _addToTimelockBatch(address target_, bytes memory payload_) internal { | ||||||||||||||||||||||||||||||
| _timelockTargets.push(target_); | ||||||||||||||||||||||||||||||
| _timelockValues.push(0); | ||||||||||||||||||||||||||||||
| _timelockPayloads.push(payload_); | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| function _addToTimelockBatch(address target_, uint256 value_, bytes memory payload_) internal { | ||||||||||||||||||||||||||||||
| _timelockTargets.push(target_); | ||||||||||||||||||||||||||||||
| _timelockValues.push(value_); | ||||||||||||||||||||||||||||||
| _timelockPayloads.push(payload_); | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| function _getScheduleBatchCallData( | ||||||||||||||||||||||||||||||
| bytes32 predecessor, | ||||||||||||||||||||||||||||||
| bytes32 salt, | ||||||||||||||||||||||||||||||
| uint256 delay | ||||||||||||||||||||||||||||||
| ) internal view returns (bytes memory) { | ||||||||||||||||||||||||||||||
| return abi.encodeCall( | ||||||||||||||||||||||||||||||
| TimelockController.scheduleBatch, | ||||||||||||||||||||||||||||||
| (_timelockTargets, _timelockValues, _timelockPayloads, predecessor, salt, delay) | ||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| function _simulateBatch(address timelock_) internal { | ||||||||||||||||||||||||||||||
| vm.startPrank(timelock_); | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| for (uint256 i = 0; i < _timelockTargets.length; i++) { | ||||||||||||||||||||||||||||||
| (bool success, ) = _timelockTargets[i].call{ value: _timelockValues[i] }(_timelockPayloads[i]); | ||||||||||||||||||||||||||||||
| require(success, "Simulation failed"); | ||||||||||||||||||||||||||||||
|
Comment on lines
+42
to
+43
|
||||||||||||||||||||||||||||||
| (bool success, ) = _timelockTargets[i].call{ value: _timelockValues[i] }(_timelockPayloads[i]); | |
| require(success, "Simulation failed"); | |
| (bool success, bytes memory returndata) = | |
| _timelockTargets[i].call{ value: _timelockValues[i] }(_timelockPayloads[i]); | |
| if (!success) { | |
| if (returndata.length > 0) { | |
| // Bubble up revert reason from the called contract | |
| assembly { | |
| revert(add(returndata, 32), mload(returndata)) | |
| } | |
| } else { | |
| revert("Simulation failed"); | |
| } | |
| } |
Uh oh!
There was an error while loading. Please reload this page.