diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 208f60c3c..b02b4ea8f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -41,7 +41,4 @@ jobs: with: path: "**/node_modules" key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }} - - run: yarn - - run: yarn build - - run: yarn hardhat codesize --contractname GnosisSafe - - run: yarn benchmark + - run: (yarn && yarn build && yarn hardhat codesize --contractname GnosisSafe && yarn benchmark) || echo "Benchmark failed" diff --git a/README.md b/README.md index 94ece429b..44489abe4 100644 --- a/README.md +++ b/README.md @@ -60,6 +60,7 @@ yarn hardhat --network etherscan-verify Documentation ------------- - [Safe developer portal](http://docs.gnosis.io/safe) +- [Error codes](docs/error_codes.md) - [Coding guidelines](docs/guidelines.md) Audits/ Formal Verification diff --git a/contracts/GnosisSafe.sol b/contracts/GnosisSafe.sol index 04a2f1a16..1af9b00f9 100644 --- a/contracts/GnosisSafe.sol +++ b/contracts/GnosisSafe.sol @@ -21,7 +21,6 @@ contract GnosisSafe using GnosisSafeMath for uint256; - string public constant NAME = "Gnosis Safe"; string public constant VERSION = "1.2.0"; // keccak256( @@ -117,7 +116,7 @@ contract GnosisSafe function execTransaction( address to, uint256 value, - bytes memory data, + bytes calldata data, Enum.Operation operation, uint256 safeTxGas, uint256 baseGas, @@ -155,7 +154,7 @@ contract GnosisSafe } // We require some gas to emit the events (at least 2500) after the execution and some to perform code until the execution (500) // We also include the 1/64 in the check that is not send along with a call to counteract potential shortings because of EIP-150 - require(gasleft() >= (safeTxGas * 64 / 63).max(safeTxGas + 2500) + 500, "Not enough gas to execute safe transaction"); + require(gasleft() >= (safeTxGas * 64 / 63).max(safeTxGas + 2500) + 500, "GS010"); // Use scope here to limit variable lifetime and prevent `stack too deep` errors { uint256 gasUsed = gasleft(); @@ -189,10 +188,10 @@ contract GnosisSafe // For ETH we will only adjust the gas price to not be higher than the actual used gas price payment = gasUsed.add(baseGas).mul(gasPrice < tx.gasprice ? gasPrice : tx.gasprice); // solium-disable-next-line security/no-send - require(receiver.send(payment), "Could not pay gas costs with ether"); + require(receiver.send(payment), "GS011"); } else { payment = gasUsed.add(baseGas).mul(gasPrice); - require(transferToken(gasToken, receiver, payment), "Could not pay gas costs with token"); + require(transferToken(gasToken, receiver, payment), "GS012"); } } @@ -209,9 +208,9 @@ contract GnosisSafe // Load threshold to avoid multiple storage loads uint256 _threshold = threshold; // Check that a threshold is set - require(_threshold > 0, "Threshold needs to be defined!"); + require(_threshold > 0, "GS001"); // Check that the provided signature data is not too short - require(signatures.length >= _threshold.mul(65), "Signatures data too short"); + require(signatures.length >= _threshold.mul(65), "GS020"); // There cannot be an owner with address 0. address lastOwner = address(0); address currentOwner; @@ -229,10 +228,10 @@ contract GnosisSafe // Check that signature data pointer (s) is not pointing inside the static part of the signatures bytes // This check is not completely accurate, since it is possible that more signatures than the threshold are send. // Here we only check that the pointer is not pointing inside the part that is being processed - require(uint256(s) >= _threshold.mul(65), "Invalid contract signature location: inside static part"); + require(uint256(s) >= _threshold.mul(65), "GS021"); // Check that signature data pointer (s) is in bounds (points to the length of data -> 32 bytes) - require(uint256(s).add(32) <= signatures.length, "Invalid contract signature location: length not present"); + require(uint256(s).add(32) <= signatures.length, "GS022"); // Check if the contract signature is in bounds: start of data is s + 32 and end is start + signature length uint256 contractSignatureLen; @@ -240,7 +239,7 @@ contract GnosisSafe assembly { contractSignatureLen := mload(add(add(signatures, s), 0x20)) } - require(uint256(s).add(32).add(contractSignatureLen) <= signatures.length, "Invalid contract signature location: data not complete"); + require(uint256(s).add(32).add(contractSignatureLen) <= signatures.length, "GS023"); // Check signature bytes memory contractSignature; @@ -249,13 +248,13 @@ contract GnosisSafe // The signature data for contract signatures is appended to the concatenated signatures and the offset is stored in s contractSignature := add(add(signatures, s), 0x20) } - require(ISignatureValidator(currentOwner).isValidSignature(data, contractSignature) == EIP1271_MAGIC_VALUE, "Invalid contract signature provided"); + require(ISignatureValidator(currentOwner).isValidSignature(data, contractSignature) == EIP1271_MAGIC_VALUE, "GS024"); // If v is 1 then it is an approved hash } else if (v == 1) { // When handling approved hashes the address of the approver is encoded into r currentOwner = address(uint160(uint256(r))); // Hashes are automatically approved by the sender of the message or when they have been pre-approved via a separate transaction - require(msg.sender == currentOwner || approvedHashes[currentOwner][dataHash] != 0, "Hash has not been approved"); + require(msg.sender == currentOwner || approvedHashes[currentOwner][dataHash] != 0, "GS025"); } else if (v > 30) { // To support eth_sign and similar we adjust v and hash the messageHash with the Ethereum message prefix before applying ecrecover currentOwner = ecrecover(keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", dataHash)), v - 4, r, s); @@ -265,7 +264,7 @@ contract GnosisSafe } require ( currentOwner > lastOwner && owners[currentOwner] != address(0) && currentOwner != SENTINEL_OWNERS, - "Invalid owner provided" + "GS026" ); lastOwner = currentOwner; } @@ -300,7 +299,7 @@ contract GnosisSafe function approveHash(bytes32 hashToApprove) external { - require(owners[msg.sender] != address(0), "Only owners can approve a hash"); + require(owners[msg.sender] != address(0), "GS030"); approvedHashes[msg.sender][hashToApprove] = 1; emit ApproveHash(hashToApprove, msg.sender); } @@ -366,7 +365,7 @@ contract GnosisSafe function encodeTransactionData( address to, uint256 value, - bytes memory data, + bytes calldata data, Enum.Operation operation, uint256 safeTxGas, uint256 baseGas, @@ -400,7 +399,7 @@ contract GnosisSafe function getTransactionHash( address to, uint256 value, - bytes memory data, + bytes calldata data, Enum.Operation operation, uint256 safeTxGas, uint256 baseGas, diff --git a/contracts/accessors/SimulateTxAccessor.sol b/contracts/accessors/SimulateTxAccessor.sol index 56ceb412a..eb0785ca8 100644 --- a/contracts/accessors/SimulateTxAccessor.sol +++ b/contracts/accessors/SimulateTxAccessor.sol @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: LGPL-3.0-only pragma solidity >=0.7.0 <0.9.0; import "../base/Executor.sol"; @@ -9,7 +10,7 @@ contract SimulateTxAccessor is Executor { bytes32 constant private GUARD_VALUE = keccak256("simulate_tx_accessor.guard.bytes32"); bytes32 guard; - constructor() public { + constructor() { guard = GUARD_VALUE; } diff --git a/contracts/base/ModuleManager.sol b/contracts/base/ModuleManager.sol index fadbca88a..6727f859f 100644 --- a/contracts/base/ModuleManager.sol +++ b/contracts/base/ModuleManager.sol @@ -22,11 +22,11 @@ contract ModuleManager is SelfAuthorized, Executor { function setupModules(address to, bytes memory data) internal { - require(modules[SENTINEL_MODULES] == address(0), "Modules have already been initialized"); + require(modules[SENTINEL_MODULES] == address(0), "GS100"); modules[SENTINEL_MODULES] = SENTINEL_MODULES; if (to != address(0)) // Setup has to complete successfully or transaction fails. - require(execute(to, 0, data, Enum.Operation.DelegateCall, gasleft()), "Could not finish initialization"); + require(execute(to, 0, data, Enum.Operation.DelegateCall, gasleft()), "GS000"); } /// @dev Allows to add a module to the whitelist. @@ -38,9 +38,9 @@ contract ModuleManager is SelfAuthorized, Executor { authorized { // Module address cannot be null or sentinel. - require(module != address(0) && module != SENTINEL_MODULES, "Invalid module address provided"); + require(module != address(0) && module != SENTINEL_MODULES, "GS101"); // Module cannot be added twice. - require(modules[module] == address(0), "Module has already been added"); + require(modules[module] == address(0), "GS102"); modules[module] = modules[SENTINEL_MODULES]; modules[SENTINEL_MODULES] = module; emit EnabledModule(module); @@ -56,8 +56,8 @@ contract ModuleManager is SelfAuthorized, Executor { authorized { // Validate module address and check that it corresponds to module index. - require(module != address(0) && module != SENTINEL_MODULES, "Invalid module address provided"); - require(modules[prevModule] == module, "Invalid prevModule, module pair provided"); + require(module != address(0) && module != SENTINEL_MODULES, "GS101"); + require(modules[prevModule] == module, "GS103"); modules[prevModule] = modules[module]; modules[module] = address(0); emit DisabledModule(module); @@ -73,7 +73,7 @@ contract ModuleManager is SelfAuthorized, Executor { returns (bool success) { // Only whitelisted modules are allowed. - require(msg.sender != SENTINEL_MODULES && modules[msg.sender] != address(0), "Method can only be called from an enabled module"); + require(msg.sender != SENTINEL_MODULES && modules[msg.sender] != address(0), "GS104"); // Execute transaction without further confirmations. success = execute(to, value, data, operation, gasleft()); if (success) emit ExecutionFromModuleSuccess(msg.sender); diff --git a/contracts/base/OwnerManager.sol b/contracts/base/OwnerManager.sol index 50e3b07cc..08d3a95e7 100644 --- a/contracts/base/OwnerManager.sol +++ b/contracts/base/OwnerManager.sol @@ -25,19 +25,19 @@ contract OwnerManager is SelfAuthorized { { // Threshold can only be 0 at initialization. // Check ensures that setup function can only be called once. - require(threshold == 0, "Owners have already been setup"); + require(threshold == 0, "GS200"); // Validate that threshold is smaller than number of added owners. - require(_threshold <= _owners.length, "Threshold cannot exceed owner count"); + require(_threshold <= _owners.length, "GS201"); // There has to be at least one Safe owner. - require(_threshold >= 1, "Threshold needs to be greater than 0"); + require(_threshold >= 1, "GS202"); // Initializing Safe owners. address currentOwner = SENTINEL_OWNERS; for (uint256 i = 0; i < _owners.length; i++) { // Owner address cannot be null. address owner = _owners[i]; - require(owner != address(0) && owner != SENTINEL_OWNERS && owner != address(this) && currentOwner != owner, "Invalid owner address provided"); + require(owner != address(0) && owner != SENTINEL_OWNERS && owner != address(this) && currentOwner != owner, "GS203"); // No duplicate owners allowed. - require(owners[owner] == address(0), "Duplicate owner address provided"); + require(owners[owner] == address(0), "GS204"); owners[currentOwner] = owner; currentOwner = owner; } @@ -56,9 +56,9 @@ contract OwnerManager is SelfAuthorized { authorized { // Owner address cannot be null, the sentinel or the Safe itself. - require(owner != address(0) && owner != SENTINEL_OWNERS && owner != address(this), "Invalid owner address provided"); + require(owner != address(0) && owner != SENTINEL_OWNERS && owner != address(this), "GS203"); // No duplicate owners allowed. - require(owners[owner] == address(0), "Address is already an owner"); + require(owners[owner] == address(0), "GS204"); owners[owner] = owners[SENTINEL_OWNERS]; owners[SENTINEL_OWNERS] = owner; ownerCount++; @@ -79,10 +79,10 @@ contract OwnerManager is SelfAuthorized { authorized { // Only allow to remove an owner, if threshold can still be reached. - require(ownerCount - 1 >= _threshold, "New owner count needs to be larger than new threshold"); + require(ownerCount - 1 >= _threshold, "GS201"); // Validate owner address and check that it corresponds to owner index. - require(owner != address(0) && owner != SENTINEL_OWNERS, "Invalid owner address provided"); - require(owners[prevOwner] == owner, "Invalid prevOwner, owner pair provided"); + require(owner != address(0) && owner != SENTINEL_OWNERS, "GS203"); + require(owners[prevOwner] == owner, "GS205"); owners[prevOwner] = owners[owner]; owners[owner] = address(0); ownerCount--; @@ -103,12 +103,12 @@ contract OwnerManager is SelfAuthorized { authorized { // Owner address cannot be null, the sentinel or the Safe itself. - require(newOwner != address(0) && newOwner != SENTINEL_OWNERS && newOwner != address(this), "Invalid owner address provided"); + require(newOwner != address(0) && newOwner != SENTINEL_OWNERS && newOwner != address(this), "GS203"); // No duplicate owners allowed. - require(owners[newOwner] == address(0), "Address is already an owner"); + require(owners[newOwner] == address(0), "GS204"); // Validate oldOwner address and check that it corresponds to owner index. - require(oldOwner != address(0) && oldOwner != SENTINEL_OWNERS, "Invalid owner address provided"); - require(owners[prevOwner] == oldOwner, "Invalid prevOwner, owner pair provided"); + require(oldOwner != address(0) && oldOwner != SENTINEL_OWNERS, "GS203"); + require(owners[prevOwner] == oldOwner, "GS205"); owners[newOwner] = owners[oldOwner]; owners[prevOwner] = newOwner; owners[oldOwner] = address(0); @@ -125,9 +125,9 @@ contract OwnerManager is SelfAuthorized { authorized { // Validate that threshold is smaller than number of owners. - require(_threshold <= ownerCount, "Threshold cannot exceed owner count"); + require(_threshold <= ownerCount, "GS201"); // There has to be at least one Safe owner. - require(_threshold >= 1, "Threshold needs to be greater than 0"); + require(_threshold >= 1, "GS202"); threshold = _threshold; emit ChangedThreshold(threshold); } diff --git a/contracts/common/SecuredTokenTransfer.sol b/contracts/common/SecuredTokenTransfer.sol index 2301f9383..d0774a466 100644 --- a/contracts/common/SecuredTokenTransfer.sol +++ b/contracts/common/SecuredTokenTransfer.sol @@ -18,7 +18,8 @@ contract SecuredTokenTransfer { internal returns (bool transferred) { - bytes memory data = abi.encodeWithSignature("transfer(address,uint256)", receiver, amount); + // 0xa9059cbb - keccack("transfer(address,uint256)") + bytes memory data = abi.encodeWithSelector(0xa9059cbb, receiver, amount); // solium-disable-next-line security/no-inline-assembly assembly { let success := call(sub(gas(), 10000), token, 0, add(data, 0x20), mload(data), 0, 0) diff --git a/contracts/common/SelfAuthorized.sol b/contracts/common/SelfAuthorized.sol index 9ad203e0a..8c88af51f 100644 --- a/contracts/common/SelfAuthorized.sol +++ b/contracts/common/SelfAuthorized.sol @@ -6,7 +6,7 @@ pragma solidity >=0.7.0 <0.9.0; /// @author Richard Meissner - contract SelfAuthorized { function requireSelfCall() private view { - require(msg.sender == address(this), "Method can only be called from this contract"); + require(msg.sender == address(this), "GS031"); } modifier authorized() { diff --git a/contracts/common/StorageAccessible.sol b/contracts/common/StorageAccessible.sol index 457c6524f..5ca910be4 100644 --- a/contracts/common/StorageAccessible.sol +++ b/contracts/common/StorageAccessible.sol @@ -4,10 +4,6 @@ pragma solidity >=0.7.0 <0.9.0; /// @title StorageAccessible - generic base contract that allows callers to access all internal storage. /// @notice Adjusted version of https://github.com/gnosis/util-contracts/blob/3db1e531cb243a48ea91c60a800d537c1000612a/contracts/StorageAccessible.sol contract StorageAccessible { - bytes4 internal constant SIMULATE_DELEGATECALL_INTERNAL_SELECTOR = bytes4( - keccak256("simulateDelegatecallInternal(address,bytes)") - ); - /** * @dev Reads `length` bytes of storage in the currents contract * @param offset - the offset in the current contract's storage in words to start reading from @@ -29,31 +25,6 @@ contract StorageAccessible { return result; } - /** - * @dev Performs a delegetecall on a targetContract in the context of self. - * Internally reverts execution to avoid side effects (making it static). Catches revert and returns encoded result as bytes. - * @param targetContract Address of the contract containing the code to execute. - * @param calldataPayload Calldata that should be sent to the target contract (encoded method name and arguments). - */ - function simulateDelegatecall( - address targetContract, - bytes memory calldataPayload - ) public returns (bytes memory) { - bytes memory innerCall = abi.encodeWithSelector( - SIMULATE_DELEGATECALL_INTERNAL_SELECTOR, - targetContract, - calldataPayload - ); - (, bytes memory response) = address(this).call(innerCall); - bool innerSuccess = response[response.length - 1] == 0x01; - setLength(response, response.length - 1); - if (innerSuccess) { - return response; - } else { - revertWith(response); - } - } - /** * @dev Performs a delegetecall on a targetContract in the context of self. * Internally reverts execution to avoid side effects (making it static). Returns encoded result as revert message @@ -61,27 +32,17 @@ contract StorageAccessible { * @param targetContract Address of the contract containing the code to execute. * @param calldataPayload Calldata that should be sent to the target contract (encoded method name and arguments). */ - function simulateDelegatecallInternal( + function simulate( address targetContract, - bytes memory calldataPayload - ) public returns (bytes memory) { + bytes calldata calldataPayload + ) external returns (bytes memory) { (bool success, bytes memory response) = targetContract.delegatecall( calldataPayload ); - revertWith(abi.encodePacked(response, success)); - } - - function revertWith(bytes memory response) internal pure { - // solium-disable-next-line security/no-inline-assembly - assembly { - revert(add(response, 0x20), mload(response)) - } - } - - function setLength(bytes memory buffer, uint256 length) internal pure { + bytes memory responseWithStatus = abi.encodePacked(response, success); // solium-disable-next-line security/no-inline-assembly assembly { - mstore(buffer, length) + revert(add(responseWithStatus, 0x20), mload(responseWithStatus)) } } } \ No newline at end of file diff --git a/contracts/handler/CompatibilityFallbackHandler.sol b/contracts/handler/CompatibilityFallbackHandler.sol index 9242fc115..145c72eb2 100644 --- a/contracts/handler/CompatibilityFallbackHandler.sol +++ b/contracts/handler/CompatibilityFallbackHandler.sol @@ -9,6 +9,8 @@ import "../GnosisSafe.sol"; /// @title Compatibility Fallback Handler - fallback handler to provider compatibility between pre 1.3.0 and 1.3.0+ Safe contracts /// @author Richard Meissner - contract CompatibilityFallbackHandler is DefaultCallbackHandler, ISignatureValidator { + bytes4 internal constant SIMULATE_SELECTOR = bytes4(keccak256("simulate(address,bytes)")); + address internal constant SENTINEL_MODULES = address(0x1); bytes4 internal constant UPDATED_MAGIC_VALUE = 0x1626ba7e; @@ -67,4 +69,43 @@ contract CompatibilityFallbackHandler is DefaultCallbackHandler, ISignatureValid (address[] memory array,) = safe.getModulesPaginated(SENTINEL_MODULES, 10); return array; } + + /** + * @dev Performs a delegetecall on a targetContract in the context of self. + * Internally reverts execution to avoid side effects (making it static). Catches revert and returns encoded result as bytes. + * @param targetContract Address of the contract containing the code to execute. + * @param calldataPayload Calldata that should be sent to the target contract (encoded method name and arguments). + */ + function simulateDelegatecall( + address targetContract, + bytes calldata calldataPayload + ) external returns (bytes memory response) { + bytes memory innerCall = abi.encodeWithSelector( + SIMULATE_SELECTOR, + targetContract, + calldataPayload + ); + (, response) = address(msg.sender).call(innerCall); + bool innerSuccess = response[response.length - 1] == 0x01; + setLength(response, response.length - 1); + if (innerSuccess) { + return response; + } else { + revertWith(response); + } + } + + function revertWith(bytes memory response) internal pure { + // solium-disable-next-line security/no-inline-assembly + assembly { + revert(add(response, 0x20), mload(response)) + } + } + + function setLength(bytes memory buffer, uint256 length) internal pure { + // solium-disable-next-line security/no-inline-assembly + assembly { + mstore(buffer, length) + } + } } \ No newline at end of file diff --git a/contracts/proxies/GnosisSafeProxy.sol b/contracts/proxies/GnosisSafeProxy.sol index fb17455db..589b15063 100644 --- a/contracts/proxies/GnosisSafeProxy.sol +++ b/contracts/proxies/GnosisSafeProxy.sol @@ -18,9 +18,7 @@ contract GnosisSafeProxy { /// @dev Constructor function sets address of singleton contract. /// @param _singleton Singleton address. - constructor(address _singleton) - public - { + constructor(address _singleton) { require(_singleton != address(0), "Invalid singleton address provided"); singleton = _singleton; } diff --git a/contracts/test/TestHandler.sol b/contracts/test/TestHandler.sol index 0a5792d52..3434666a2 100644 --- a/contracts/test/TestHandler.sol +++ b/contracts/test/TestHandler.sol @@ -3,7 +3,7 @@ pragma solidity >=0.7.0 <0.9.0; import "../handler/HandlerContext.sol"; contract TestHandler is HandlerContext { - function dudududu() external returns (address sender, address manager) { + function dudududu() external view returns (address sender, address manager) { return (_msgSender(), _manager()); } } diff --git a/deployments/rinkeby/GnosisSafe.json b/deployments/rinkeby/GnosisSafe.json index 79d5cb563..8d6fd37db 100644 --- a/deployments/rinkeby/GnosisSafe.json +++ b/deployments/rinkeby/GnosisSafe.json @@ -1003,15 +1003,15 @@ "args": [], "solcInputHash": "e13af873df760e6463a87a0cc0932f40", "metadata": "{\"compiler\":{\"version\":\"0.5.17+commit.d19bba13\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"}],\"name\":\"AddedOwner\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"approvedHash\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"}],\"name\":\"ApproveHash\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"masterCopy\",\"type\":\"address\"}],\"name\":\"ChangedMasterCopy\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"threshold\",\"type\":\"uint256\"}],\"name\":\"ChangedThreshold\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"module\",\"type\":\"address\"}],\"name\":\"DisabledModule\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"module\",\"type\":\"address\"}],\"name\":\"EnabledModule\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"txHash\",\"type\":\"bytes32\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"payment\",\"type\":\"uint256\"}],\"name\":\"ExecutionFailure\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"module\",\"type\":\"address\"}],\"name\":\"ExecutionFromModuleFailure\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"module\",\"type\":\"address\"}],\"name\":\"ExecutionFromModuleSuccess\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"txHash\",\"type\":\"bytes32\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"payment\",\"type\":\"uint256\"}],\"name\":\"ExecutionSuccess\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"}],\"name\":\"RemovedOwner\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"msgHash\",\"type\":\"bytes32\"}],\"name\":\"SignMsg\",\"type\":\"event\"},{\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"fallback\"},{\"constant\":true,\"inputs\":[],\"name\":\"NAME\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"VERSION\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_threshold\",\"type\":\"uint256\"}],\"name\":\"addOwnerWithThreshold\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"hashToApprove\",\"type\":\"bytes32\"}],\"name\":\"approveHash\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"name\":\"approvedHashes\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"address\",\"name\":\"_masterCopy\",\"type\":\"address\"}],\"name\":\"changeMasterCopy\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_threshold\",\"type\":\"uint256\"}],\"name\":\"changeThreshold\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"address\",\"name\":\"prevModule\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"module\",\"type\":\"address\"}],\"name\":\"disableModule\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"domainSeparator\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"address\",\"name\":\"module\",\"type\":\"address\"}],\"name\":\"enableModule\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"},{\"internalType\":\"enum Enum.Operation\",\"name\":\"operation\",\"type\":\"uint8\"},{\"internalType\":\"uint256\",\"name\":\"safeTxGas\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"baseGas\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"gasPrice\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"gasToken\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"refundReceiver\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_nonce\",\"type\":\"uint256\"}],\"name\":\"encodeTransactionData\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"},{\"internalType\":\"enum Enum.Operation\",\"name\":\"operation\",\"type\":\"uint8\"},{\"internalType\":\"uint256\",\"name\":\"safeTxGas\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"baseGas\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"gasPrice\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"gasToken\",\"type\":\"address\"},{\"internalType\":\"address payable\",\"name\":\"refundReceiver\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"signatures\",\"type\":\"bytes\"}],\"name\":\"execTransaction\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"success\",\"type\":\"bool\"}],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"},{\"internalType\":\"enum Enum.Operation\",\"name\":\"operation\",\"type\":\"uint8\"}],\"name\":\"execTransactionFromModule\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"success\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"},{\"internalType\":\"enum Enum.Operation\",\"name\":\"operation\",\"type\":\"uint8\"}],\"name\":\"execTransactionFromModuleReturnData\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"success\",\"type\":\"bool\"},{\"internalType\":\"bytes\",\"name\":\"returnData\",\"type\":\"bytes\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"message\",\"type\":\"bytes\"}],\"name\":\"getMessageHash\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"getModules\",\"outputs\":[{\"internalType\":\"address[]\",\"name\":\"\",\"type\":\"address[]\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"internalType\":\"address\",\"name\":\"start\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"pageSize\",\"type\":\"uint256\"}],\"name\":\"getModulesPaginated\",\"outputs\":[{\"internalType\":\"address[]\",\"name\":\"array\",\"type\":\"address[]\"},{\"internalType\":\"address\",\"name\":\"next\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"getOwners\",\"outputs\":[{\"internalType\":\"address[]\",\"name\":\"\",\"type\":\"address[]\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"getThreshold\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"},{\"internalType\":\"enum Enum.Operation\",\"name\":\"operation\",\"type\":\"uint8\"},{\"internalType\":\"uint256\",\"name\":\"safeTxGas\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"baseGas\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"gasPrice\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"gasToken\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"refundReceiver\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_nonce\",\"type\":\"uint256\"}],\"name\":\"getTransactionHash\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"internalType\":\"address\",\"name\":\"module\",\"type\":\"address\"}],\"name\":\"isModuleEnabled\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"}],\"name\":\"isOwner\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"_data\",\"type\":\"bytes\"},{\"internalType\":\"bytes\",\"name\":\"_signature\",\"type\":\"bytes\"}],\"name\":\"isValidSignature\",\"outputs\":[{\"internalType\":\"bytes4\",\"name\":\"\",\"type\":\"bytes4\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"nonce\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"address\",\"name\":\"prevOwner\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_threshold\",\"type\":\"uint256\"}],\"name\":\"removeOwner\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"},{\"internalType\":\"enum Enum.Operation\",\"name\":\"operation\",\"type\":\"uint8\"}],\"name\":\"requiredTxGas\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"address\",\"name\":\"handler\",\"type\":\"address\"}],\"name\":\"setFallbackHandler\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"address[]\",\"name\":\"_owners\",\"type\":\"address[]\"},{\"internalType\":\"uint256\",\"name\":\"_threshold\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"},{\"internalType\":\"address\",\"name\":\"fallbackHandler\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"paymentToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"payment\",\"type\":\"uint256\"},{\"internalType\":\"address payable\",\"name\":\"paymentReceiver\",\"type\":\"address\"}],\"name\":\"setup\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"_data\",\"type\":\"bytes\"}],\"name\":\"signMessage\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"name\":\"signedMessages\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"address\",\"name\":\"prevOwner\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"oldOwner\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"swapOwner\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"author\":\"Stefan George - Richard Meissner - Ricardo Guilherme Schmidt - (Status Research & Development GmbH) - Gas Token Payment\",\"methods\":{\"addOwnerWithThreshold(address,uint256)\":{\"details\":\"Allows to add a new owner to the Safe and update the threshold at the same time. This can only be done via a Safe transaction.\",\"params\":{\"_threshold\":\"New threshold.\",\"owner\":\"New owner address.\"}},\"approveHash(bytes32)\":{\"details\":\"Marks a hash as approved. This can be used to validate a hash that is used by a signature.\",\"params\":{\"hashToApprove\":\"The hash that should be marked as approved for signatures that are verified by this contract.\"}},\"changeMasterCopy(address)\":{\"details\":\"Allows to upgrade the contract. This can only be done via a Safe transaction.\",\"params\":{\"_masterCopy\":\"New contract address.\"}},\"changeThreshold(uint256)\":{\"details\":\"Allows to update the number of required confirmations by Safe owners. This can only be done via a Safe transaction.\",\"params\":{\"_threshold\":\"New threshold.\"}},\"disableModule(address,address)\":{\"details\":\"Allows to remove a module from the whitelist. This can only be done via a Safe transaction.\",\"params\":{\"module\":\"Module to be removed.\",\"prevModule\":\"Module that pointed to the module to be removed in the linked list\"}},\"enableModule(address)\":{\"details\":\"Allows to add a module to the whitelist. This can only be done via a Safe transaction.\",\"params\":{\"module\":\"Module to be whitelisted.\"}},\"encodeTransactionData(address,uint256,bytes,uint8,uint256,uint256,uint256,address,address,uint256)\":{\"details\":\"Returns the bytes that are hashed to be signed by owners.\",\"params\":{\"_nonce\":\"Transaction nonce.\",\"baseGas\":\"Gas costs for that are independent of the transaction execution(e.g. base transaction fee, signature check, payment of the refund)\",\"data\":\"Data payload.\",\"gasPrice\":\"Maximum gas price that should be used for this transaction.\",\"gasToken\":\"Token address (or 0 if ETH) that is used for the payment.\",\"operation\":\"Operation type.\",\"refundReceiver\":\"Address of receiver of gas payment (or 0 if tx.origin).\",\"safeTxGas\":\"Gas that should be used for the safe transaction.\",\"to\":\"Destination address.\",\"value\":\"Ether value.\"},\"return\":\"Transaction hash bytes.\"},\"execTransaction(address,uint256,bytes,uint8,uint256,uint256,uint256,address,address,bytes)\":{\"details\":\"Allows to execute a Safe transaction confirmed by required number of owners and then pays the account that submitted the transaction. Note: The fees are always transfered, even if the user transaction fails.\",\"params\":{\"baseGas\":\"Gas costs that are independent of the transaction execution(e.g. base transaction fee, signature check, payment of the refund)\",\"data\":\"Data payload of Safe transaction.\",\"gasPrice\":\"Gas price that should be used for the payment calculation.\",\"gasToken\":\"Token address (or 0 if ETH) that is used for the payment.\",\"operation\":\"Operation type of Safe transaction.\",\"refundReceiver\":\"Address of receiver of gas payment (or 0 if tx.origin).\",\"safeTxGas\":\"Gas that should be used for the Safe transaction.\",\"signatures\":\"Packed signature data ({bytes32 r}{bytes32 s}{uint8 v})\",\"to\":\"Destination address of Safe transaction.\",\"value\":\"Ether value of Safe transaction.\"}},\"execTransactionFromModule(address,uint256,bytes,uint8)\":{\"details\":\"Allows a Module to execute a Safe transaction without any further confirmations.\",\"params\":{\"data\":\"Data payload of module transaction.\",\"operation\":\"Operation type of module transaction.\",\"to\":\"Destination address of module transaction.\",\"value\":\"Ether value of module transaction.\"}},\"execTransactionFromModuleReturnData(address,uint256,bytes,uint8)\":{\"details\":\"Allows a Module to execute a Safe transaction without any further confirmations and return data\",\"params\":{\"data\":\"Data payload of module transaction.\",\"operation\":\"Operation type of module transaction.\",\"to\":\"Destination address of module transaction.\",\"value\":\"Ether value of module transaction.\"}},\"getMessageHash(bytes)\":{\"details\":\"Returns hash of a message that can be signed by owners.\",\"params\":{\"message\":\"Message that should be hashed\"},\"return\":\"Message hash.\"},\"getModules()\":{\"details\":\"Returns array of first 10 modules.\",\"return\":\"Array of modules.\"},\"getModulesPaginated(address,uint256)\":{\"details\":\"Returns array of modules.\",\"params\":{\"pageSize\":\"Maximum number of modules that should be returned.\",\"start\":\"Start of the page.\"},\"return\":\"Array of modules.\"},\"getOwners()\":{\"details\":\"Returns array of owners.\",\"return\":\"Array of Safe owners.\"},\"getTransactionHash(address,uint256,bytes,uint8,uint256,uint256,uint256,address,address,uint256)\":{\"details\":\"Returns hash to be signed by owners.\",\"params\":{\"_nonce\":\"Transaction nonce.\",\"baseGas\":\"Gas costs for data used to trigger the safe transaction.\",\"data\":\"Data payload.\",\"gasPrice\":\"Maximum gas price that should be used for this transaction.\",\"gasToken\":\"Token address (or 0 if ETH) that is used for the payment.\",\"operation\":\"Operation type.\",\"refundReceiver\":\"Address of receiver of gas payment (or 0 if tx.origin).\",\"safeTxGas\":\"Fas that should be used for the safe transaction.\",\"to\":\"Destination address.\",\"value\":\"Ether value.\"},\"return\":\"Transaction hash.\"},\"isModuleEnabled(address)\":{\"details\":\"Returns if an module is enabled\",\"return\":\"True if the module is enabled\"},\"isValidSignature(bytes,bytes)\":{\"details\":\"Should return whether the signature provided is valid for the provided data. The save does not implement the interface since `checkSignatures` is not a view method. The method will not perform any state changes (see parameters of `checkSignatures`)\",\"params\":{\"_data\":\"Arbitrary length data signed on the behalf of address(this)\",\"_signature\":\"Signature byte array associated with _data\"},\"return\":\"a bool upon valid or invalid signature with corresponding _data\"},\"removeOwner(address,address,uint256)\":{\"details\":\"Allows to remove an owner from the Safe and update the threshold at the same time. This can only be done via a Safe transaction.\",\"params\":{\"_threshold\":\"New threshold.\",\"owner\":\"Owner address to be removed.\",\"prevOwner\":\"Owner that pointed to the owner to be removed in the linked list\"}},\"requiredTxGas(address,uint256,bytes,uint8)\":{\"details\":\"Allows to estimate a Safe transaction. This method is only meant for estimation purpose, therefore two different protection mechanism against execution in a transaction have been made: 1.) The method can only be called from the safe itself 2.) The response is returned with a revert When estimating set `from` to the address of the safe. Since the `estimateGas` function includes refunds, call this method to get an estimated of the costs that are deducted from the safe with `execTransaction`\",\"params\":{\"data\":\"Data payload of Safe transaction.\",\"operation\":\"Operation type of Safe transaction.\",\"to\":\"Destination address of Safe transaction.\",\"value\":\"Ether value of Safe transaction.\"},\"return\":\"Estimate without refunds and overhead fees (base transaction and payload data gas costs).\"},\"setFallbackHandler(address)\":{\"details\":\"Allows to add a contract to handle fallback calls. Only fallback calls without value and with data will be forwarded. This can only be done via a Safe transaction.\",\"params\":{\"handler\":\"contract to handle fallbacks calls.\"}},\"setup(address[],uint256,address,bytes,address,address,uint256,address)\":{\"details\":\"Setup function sets initial storage of contract.\",\"params\":{\"_owners\":\"List of Safe owners.\",\"_threshold\":\"Number of required confirmations for a Safe transaction.\",\"data\":\"Data payload for optional delegate call.\",\"fallbackHandler\":\"Handler for fallback calls to this contract\",\"payment\":\"Value that should be paid\",\"paymentReceiver\":\"Adddress that should receive the payment (or 0 if tx.origin)\",\"paymentToken\":\"Token that should be used for the payment (0 is ETH)\",\"to\":\"Contract address for optional delegate call.\"}},\"signMessage(bytes)\":{\"details\":\"Marks a message as signed, so that it can be used with EIP-1271\",\"params\":{\"_data\":\"Arbitrary length data that should be marked as signed on the behalf of address(this)\"}},\"swapOwner(address,address,address)\":{\"details\":\"Allows to swap/replace an owner from the Safe with another address. This can only be done via a Safe transaction.\",\"params\":{\"newOwner\":\"New owner address.\",\"oldOwner\":\"Owner address to be replaced.\",\"prevOwner\":\"Owner that pointed to the owner to be replaced in the linked list\"}}},\"title\":\"Gnosis Safe - A multisignature wallet with support for confirmations using signed messages based on ERC191.\"},\"userdoc\":{\"methods\":{\"addOwnerWithThreshold(address,uint256)\":{\"notice\":\"Adds the owner `owner` to the Safe and updates the threshold to `_threshold`.\"},\"changeThreshold(uint256)\":{\"notice\":\"Changes the threshold of the Safe to `_threshold`.\"},\"disableModule(address,address)\":{\"notice\":\"Disables the module `module` for the Safe.\"},\"enableModule(address)\":{\"notice\":\"Enables the module `module` for the Safe.\"},\"isValidSignature(bytes,bytes)\":{\"notice\":\"Implementation of ISignatureValidator (see `interfaces/ISignatureValidator.sol`)\"},\"removeOwner(address,address,uint256)\":{\"notice\":\"Removes the owner `owner` from the Safe and updates the threshold to `_threshold`.\"},\"signMessage(bytes)\":{\"notice\":\"Marks a message (`_data`) as signed.\"},\"swapOwner(address,address,address)\":{\"notice\":\"Replaces the owner `oldOwner` in the Safe with `newOwner`.\"}}}},\"settings\":{\"compilationTarget\":{\"contracts/GnosisSafe.sol\":\"GnosisSafe\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"useLiteralContent\":true},\"optimizer\":{\"enabled\":false,\"runs\":200},\"remappings\":[]},\"sources\":{\"contracts/GnosisSafe.sol\":{\"content\":\"// SPDX-License-Identifier: LGPL-3.0-only -pragma solidity >=0.7.0 <0.9.0;\\nimport \\\"./base/ModuleManager.sol\\\";\\nimport \\\"./base/OwnerManager.sol\\\";\\nimport \\\"./base/FallbackManager.sol\\\";\\nimport \\\"./common/MasterCopy.sol\\\";\\nimport \\\"./common/SignatureDecoder.sol\\\";\\nimport \\\"./common/SecuredTokenTransfer.sol\\\";\\nimport \\\"./interfaces/ISignatureValidator.sol\\\";\\nimport \\\"./external/GnosisSafeMath.sol\\\";\\n\\n/// @title Gnosis Safe - A multisignature wallet with support for confirmations using signed messages based on ERC191.\\n/// @author Stefan George - \\n/// @author Richard Meissner - \\n/// @author Ricardo Guilherme Schmidt - (Status Research & Development GmbH) - Gas Token Payment\\ncontract GnosisSafe\\n is MasterCopy, ModuleManager, OwnerManager, SignatureDecoder, SecuredTokenTransfer, ISignatureValidatorConstants, FallbackManager {\\n\\n using GnosisSafeMath for uint256;\\n\\n string public constant NAME = \\\"Gnosis Safe\\\";\\n string public constant VERSION = \\\"1.2.0\\\";\\n\\n //keccak256(\\n // \\\"EIP712Domain(address verifyingContract)\\\"\\n //);\\n bytes32 private constant DOMAIN_SEPARATOR_TYPEHASH = 0x035aff83d86937d35b32e04f0ddc6ff469290eef2f1b692d8a815c89404d4749;\\n\\n //keccak256(\\n // \\\"SafeTx(address to,uint256 value,bytes data,uint8 operation,uint256 safeTxGas,uint256 baseGas,uint256 gasPrice,address gasToken,address refundReceiver,uint256 nonce)\\\"\\n //);\\n bytes32 private constant SAFE_TX_TYPEHASH = 0xbb8310d486368db6bd6f849402fdd73ad53d316b5a4b2644ad6efe0f941286d8;\\n\\n //keccak256(\\n // \\\"SafeMessage(bytes message)\\\"\\n //);\\n bytes32 private constant SAFE_MSG_TYPEHASH = 0x60b3cbf8b4a223d68d641b3b6ddf9a298e7f33710cf3d3a9d1146b5a6150fbca;\\n\\n event ApproveHash(\\n bytes32 indexed approvedHash,\\n address indexed owner\\n );\\n event SignMsg(\\n bytes32 indexed msgHash\\n );\\n event ExecutionFailure(\\n bytes32 txHash, uint256 payment\\n );\\n event ExecutionSuccess(\\n bytes32 txHash, uint256 payment\\n );\\n\\n uint256 public nonce;\\n bytes32 public domainSeparator;\\n // Mapping to keep track of all message hashes that have been approve by ALL REQUIRED owners\\n mapping(bytes32 => uint256) public signedMessages;\\n // Mapping to keep track of all hashes (message or transaction) that have been approve by ANY owners\\n mapping(address => mapping(bytes32 => uint256)) public approvedHashes;\\n\\n // This constructor ensures that this contract can only be used as a master copy for Proxy contracts\\n constructor() public {\\n // By setting the threshold it is not possible to call setup anymore,\\n // so we create a Safe with 0 owners and threshold 1.\\n // This is an unusable Safe, perfect for the mastercopy\\n threshold = 1;\\n }\\n\\n /// @dev Setup function sets initial storage of contract.\\n /// @param _owners List of Safe owners.\\n /// @param _threshold Number of required confirmations for a Safe transaction.\\n /// @param to Contract address for optional delegate call.\\n /// @param data Data payload for optional delegate call.\\n /// @param fallbackHandler Handler for fallback calls to this contract\\n /// @param paymentToken Token that should be used for the payment (0 is ETH)\\n /// @param payment Value that should be paid\\n /// @param paymentReceiver Adddress that should receive the payment (or 0 if tx.origin)\\n function setup(\\n address[] calldata _owners,\\n uint256 _threshold,\\n address to,\\n bytes calldata data,\\n address fallbackHandler,\\n address paymentToken,\\n uint256 payment,\\n address payable paymentReceiver\\n )\\n external\\n {\\n require(domainSeparator == 0, \\\"Domain Separator already set!\\\");\\n domainSeparator = keccak256(abi.encode(DOMAIN_SEPARATOR_TYPEHASH, this));\\n setupOwners(_owners, _threshold);\\n if (fallbackHandler != address(0)) internalSetFallbackHandler(fallbackHandler);\\n // As setupOwners can only be called if the contract has not been initialized we don't need a check for setupModules\\n setupModules(to, data);\\n\\n if (payment > 0) {\\n // To avoid running into issues with EIP-170 we reuse the handlePayment function (to avoid adjusting code of that has been verified we do not adjust the method itself)\\n // baseGas = 0, gasPrice = 1 and gas = payment => amount = (payment + 0) * 1 = payment\\n handlePayment(payment, 0, 1, paymentToken, paymentReceiver);\\n }\\n }\\n\\n /// @dev Allows to execute a Safe transaction confirmed by required number of owners and then pays the account that submitted the transaction.\\n /// Note: The fees are always transfered, even if the user transaction fails.\\n /// @param to Destination address of Safe transaction.\\n /// @param value Ether value of Safe transaction.\\n /// @param data Data payload of Safe transaction.\\n /// @param operation Operation type of Safe transaction.\\n /// @param safeTxGas Gas that should be used for the Safe transaction.\\n /// @param baseGas Gas costs that are independent of the transaction execution(e.g. base transaction fee, signature check, payment of the refund)\\n /// @param gasPrice Gas price that should be used for the payment calculation.\\n /// @param gasToken Token address (or 0 if ETH) that is used for the payment.\\n /// @param refundReceiver Address of receiver of gas payment (or 0 if tx.origin).\\n /// @param signatures Packed signature data ({bytes32 r}{bytes32 s}{uint8 v})\\n function execTransaction(\\n address to,\\n uint256 value,\\n bytes calldata data,\\n Enum.Operation operation,\\n uint256 safeTxGas,\\n uint256 baseGas,\\n uint256 gasPrice,\\n address gasToken,\\n address payable refundReceiver,\\n bytes calldata signatures\\n )\\n external\\n payable\\n returns (bool success)\\n {\\n bytes32 txHash;\\n // Use scope here to limit variable lifetime and prevent `stack too deep` errors\\n {\\n bytes memory txHashData = encodeTransactionData(\\n to, value, data, operation, // Transaction info\\n safeTxGas, baseGas, gasPrice, gasToken, refundReceiver, // Payment info\\n nonce\\n );\\n // Increase nonce and execute transaction.\\n nonce++;\\n txHash = keccak256(txHashData);\\n checkSignatures(txHash, txHashData, signatures, true);\\n }\\n // We require some gas to emit the events (at least 2500) after the execution and some to perform code until the execution (500)\\n // We also include the 1/64 in the check that is not send along with a call to counteract potential shortings because of EIP-150\\n require(gasleft() >= (safeTxGas * 64 / 63).max(safeTxGas + 2500) + 500, \\\"Not enough gas to execute safe transaction\\\");\\n // Use scope here to limit variable lifetime and prevent `stack too deep` errors\\n {\\n uint256 gasUsed = gasleft();\\n // If the gasPrice is 0 we assume that nearly all available gas can be used (it is always more than safeTxGas)\\n // We only substract 2500 (compared to the 3000 before) to ensure that the amount passed is still higher than safeTxGas\\n success = execute(to, value, data, operation, gasPrice == 0 ? (gasleft() - 2500) : safeTxGas);\\n gasUsed = gasUsed.sub(gasleft());\\n // We transfer the calculated tx costs to the tx.origin to avoid sending it to intermediate contracts that have made calls\\n uint256 payment = 0;\\n if (gasPrice > 0) {\\n payment = handlePayment(gasUsed, baseGas, gasPrice, gasToken, refundReceiver);\\n }\\n if (success) emit ExecutionSuccess(txHash, payment);\\n else emit ExecutionFailure(txHash, payment);\\n }\\n }\\n\\n function handlePayment(\\n uint256 gasUsed,\\n uint256 baseGas,\\n uint256 gasPrice,\\n address gasToken,\\n address payable refundReceiver\\n )\\n private\\n returns (uint256 payment)\\n {\\n // solium-disable-next-line security/no-tx-origin\\n address payable receiver = refundReceiver == address(0) ? tx.origin : refundReceiver;\\n if (gasToken == address(0)) {\\n // For ETH we will only adjust the gas price to not be higher than the actual used gas price\\n payment = gasUsed.add(baseGas).mul(gasPrice < tx.gasprice ? gasPrice : tx.gasprice);\\n // solium-disable-next-line security/no-send\\n require(receiver.send(payment), \\\"Could not pay gas costs with ether\\\");\\n } else {\\n payment = gasUsed.add(baseGas).mul(gasPrice);\\n require(transferToken(gasToken, receiver, payment), \\\"Could not pay gas costs with token\\\");\\n }\\n }\\n\\n /**\\n * @dev Checks whether the signature provided is valid for the provided data, hash. Will revert otherwise.\\n * @param dataHash Hash of the data (could be either a message hash or transaction hash)\\n * @param data That should be signed (this is passed to an external validator contract)\\n * @param signatures Signature data that should be verified. Can be ECDSA signature, contract signature (EIP-1271) or approved hash.\\n * @param consumeHash Indicates that in case of an approved hash the storage can be freed to save gas\\n */\\n function checkSignatures(bytes32 dataHash, bytes memory data, bytes memory signatures, bool consumeHash)\\n internal\\n {\\n // Load threshold to avoid multiple storage loads\\n uint256 _threshold = threshold;\\n // Check that a threshold is set\\n require(_threshold > 0, \\\"Threshold needs to be defined!\\\");\\n // Check that the provided signature data is not too short\\n require(signatures.length >= _threshold.mul(65), \\\"Signatures data too short\\\");\\n // There cannot be an owner with address 0.\\n address lastOwner = address(0);\\n address currentOwner;\\n uint8 v;\\n bytes32 r;\\n bytes32 s;\\n uint256 i;\\n for (i = 0; i < _threshold; i++) {\\n (v, r, s) = signatureSplit(signatures, i);\\n // If v is 0 then it is a contract signature\\n if (v == 0) {\\n // When handling contract signatures the address of the contract is encoded into r\\n currentOwner = address(uint256(r));\\n\\n // Check that signature data pointer (s) is not pointing inside the static part of the signatures bytes\\n // This check is not completely accurate, since it is possible that more signatures than the threshold are send.\\n // Here we only check that the pointer is not pointing inside the part that is being processed\\n require(uint256(s) >= _threshold.mul(65), \\\"Invalid contract signature location: inside static part\\\");\\n\\n // Check that signature data pointer (s) is in bounds (points to the length of data -> 32 bytes)\\n require(uint256(s).add(32) <= signatures.length, \\\"Invalid contract signature location: length not present\\\");\\n\\n // Check if the contract signature is in bounds: start of data is s + 32 and end is start + signature length\\n uint256 contractSignatureLen;\\n // solium-disable-next-line security/no-inline-assembly\\n assembly {\\n contractSignatureLen := mload(add(add(signatures, s), 0x20))\\n }\\n require(uint256(s).add(32).add(contractSignatureLen) <= signatures.length, \\\"Invalid contract signature location: data not complete\\\");\\n\\n // Check signature\\n bytes memory contractSignature;\\n // solium-disable-next-line security/no-inline-assembly\\n assembly {\\n // The signature data for contract signatures is appended to the concatenated signatures and the offset is stored in s\\n contractSignature := add(add(signatures, s), 0x20)\\n }\\n require(ISignatureValidator(currentOwner).isValidSignature(data, contractSignature) == EIP1271_MAGIC_VALUE, \\\"Invalid contract signature provided\\\");\\n // If v is 1 then it is an approved hash\\n } else if (v == 1) {\\n // When handling approved hashes the address of the approver is encoded into r\\n currentOwner = address(uint256(r));\\n // Hashes are automatically approved by the sender of the message or when they have been pre-approved via a separate transaction\\n require(msg.sender == currentOwner || approvedHashes[currentOwner][dataHash] != 0, \\\"Hash has not been approved\\\");\\n // Hash has been marked for consumption. If this hash was pre-approved free storage\\n if (consumeHash && msg.sender != currentOwner) {\\n approvedHashes[currentOwner][dataHash] = 0;\\n }\\n } else if (v > 30) {\\n // To support eth_sign and similar we adjust v and hash the messageHash with the Ethereum message prefix before applying ecrecover\\n currentOwner = ecrecover(keccak256(abi.encodePacked(\\\"\\\\x19Ethereum Signed Message:\\\\n32\\\", dataHash)), v - 4, r, s);\\n } else {\\n // Use ecrecover with the messageHash for EOA signatures\\n currentOwner = ecrecover(dataHash, v, r, s);\\n }\\n require (\\n currentOwner > lastOwner && owners[currentOwner] != address(0) && currentOwner != SENTINEL_OWNERS,\\n \\\"Invalid owner provided\\\"\\n );\\n lastOwner = currentOwner;\\n }\\n }\\n\\n /// @dev Allows to estimate a Safe transaction.\\n /// This method is only meant for estimation purpose, therefore two different protection mechanism against execution in a transaction have been made:\\n /// 1.) The method can only be called from the safe itself\\n /// 2.) The response is returned with a revert\\n /// When estimating set `from` to the address of the safe.\\n /// Since the `estimateGas` function includes refunds, call this method to get an estimated of the costs that are deducted from the safe with `execTransaction`\\n /// @param to Destination address of Safe transaction.\\n /// @param value Ether value of Safe transaction.\\n /// @param data Data payload of Safe transaction.\\n /// @param operation Operation type of Safe transaction.\\n /// @return Estimate without refunds and overhead fees (base transaction and payload data gas costs).\\n function requiredTxGas(address to, uint256 value, bytes calldata data, Enum.Operation operation)\\n external\\n authorized\\n returns (uint256)\\n {\\n uint256 startGas = gasleft();\\n // We don't provide an error message here, as we use it to return the estimate\\n // solium-disable-next-line error-reason\\n require(execute(to, value, data, operation, gasleft()));\\n uint256 requiredGas = startGas - gasleft();\\n // Convert response to string and return via error message\\n revert(string(abi.encodePacked(requiredGas)));\\n }\\n\\n /**\\n * @dev Marks a hash as approved. This can be used to validate a hash that is used by a signature.\\n * @param hashToApprove The hash that should be marked as approved for signatures that are verified by this contract.\\n */\\n function approveHash(bytes32 hashToApprove)\\n external\\n {\\n require(owners[msg.sender] != address(0), \\\"Only owners can approve a hash\\\");\\n approvedHashes[msg.sender][hashToApprove] = 1;\\n emit ApproveHash(hashToApprove, msg.sender);\\n }\\n\\n /**\\n * @dev Marks a message as signed, so that it can be used with EIP-1271\\n * @notice Marks a message (`_data`) as signed.\\n * @param _data Arbitrary length data that should be marked as signed on the behalf of address(this)\\n */\\n function signMessage(bytes calldata _data)\\n external\\n authorized\\n {\\n bytes32 msgHash = getMessageHash(_data);\\n signedMessages[msgHash] = 1;\\n emit SignMsg(msgHash);\\n }\\n\\n /**\\n * Implementation of ISignatureValidator (see `interfaces/ISignatureValidator.sol`)\\n * @dev Should return whether the signature provided is valid for the provided data.\\n * The save does not implement the interface since `checkSignatures` is not a view method.\\n * The method will not perform any state changes (see parameters of `checkSignatures`)\\n * @param _data Arbitrary length data signed on the behalf of address(this)\\n * @param _signature Signature byte array associated with _data\\n * @return a bool upon valid or invalid signature with corresponding _data\\n */\\n function isValidSignature(bytes calldata _data, bytes calldata _signature)\\n external\\n returns (bytes4)\\n {\\n bytes32 messageHash = getMessageHash(_data);\\n if (_signature.length == 0) {\\n require(signedMessages[messageHash] != 0, \\\"Hash not approved\\\");\\n } else {\\n // consumeHash needs to be false, as the state should not be changed\\n checkSignatures(messageHash, _data, _signature, false);\\n }\\n return EIP1271_MAGIC_VALUE;\\n }\\n\\n /// @dev Returns hash of a message that can be signed by owners.\\n /// @param message Message that should be hashed\\n /// @return Message hash.\\n function getMessageHash(\\n bytes memory message\\n )\\n public\\n view\\n returns (bytes32)\\n {\\n bytes32 safeMessageHash = keccak256(\\n abi.encode(SAFE_MSG_TYPEHASH, keccak256(message))\\n );\\n return keccak256(\\n abi.encodePacked(byte(0x19), byte(0x01), domainSeparator, safeMessageHash)\\n );\\n }\\n\\n /// @dev Returns the bytes that are hashed to be signed by owners.\\n /// @param to Destination address.\\n /// @param value Ether value.\\n /// @param data Data payload.\\n /// @param operation Operation type.\\n /// @param safeTxGas Gas that should be used for the safe transaction.\\n /// @param baseGas Gas costs for that are independent of the transaction execution(e.g. base transaction fee, signature check, payment of the refund)\\n /// @param gasPrice Maximum gas price that should be used for this transaction.\\n /// @param gasToken Token address (or 0 if ETH) that is used for the payment.\\n /// @param refundReceiver Address of receiver of gas payment (or 0 if tx.origin).\\n /// @param _nonce Transaction nonce.\\n /// @return Transaction hash bytes.\\n function encodeTransactionData(\\n address to,\\n uint256 value,\\n bytes memory data,\\n Enum.Operation operation,\\n uint256 safeTxGas,\\n uint256 baseGas,\\n uint256 gasPrice,\\n address gasToken,\\n address refundReceiver,\\n uint256 _nonce\\n )\\n public\\n view\\n returns (bytes memory)\\n {\\n bytes32 safeTxHash = keccak256(\\n abi.encode(SAFE_TX_TYPEHASH, to, value, keccak256(data), operation, safeTxGas, baseGas, gasPrice, gasToken, refundReceiver, _nonce)\\n );\\n return abi.encodePacked(byte(0x19), byte(0x01), domainSeparator, safeTxHash);\\n }\\n\\n /// @dev Returns hash to be signed by owners.\\n /// @param to Destination address.\\n /// @param value Ether value.\\n /// @param data Data payload.\\n /// @param operation Operation type.\\n /// @param safeTxGas Fas that should be used for the safe transaction.\\n /// @param baseGas Gas costs for data used to trigger the safe transaction.\\n /// @param gasPrice Maximum gas price that should be used for this transaction.\\n /// @param gasToken Token address (or 0 if ETH) that is used for the payment.\\n /// @param refundReceiver Address of receiver of gas payment (or 0 if tx.origin).\\n /// @param _nonce Transaction nonce.\\n /// @return Transaction hash.\\n function getTransactionHash(\\n address to,\\n uint256 value,\\n bytes memory data,\\n Enum.Operation operation,\\n uint256 safeTxGas,\\n uint256 baseGas,\\n uint256 gasPrice,\\n address gasToken,\\n address refundReceiver,\\n uint256 _nonce\\n )\\n public\\n view\\n returns (bytes32)\\n {\\n return keccak256(encodeTransactionData(to, value, data, operation, safeTxGas, baseGas, gasPrice, gasToken, refundReceiver, _nonce));\\n }\\n}\\n\",\"keccak256\":\"0x0eadc5815fa051e47c15d65933983e788d66b079fdfc675f1f65a2eaa3299131\"},\"contracts/base/Executor.sol\":{\"content\":\"// SPDX-License-Identifier: LGPL-3.0-only +pragma solidity >=0.7.0 <0.9.0;\\nimport \\\"./base/ModuleManager.sol\\\";\\nimport \\\"./base/OwnerManager.sol\\\";\\nimport \\\"./base/FallbackManager.sol\\\";\\nimport \\\"./common/MasterCopy.sol\\\";\\nimport \\\"./common/SignatureDecoder.sol\\\";\\nimport \\\"./common/SecuredTokenTransfer.sol\\\";\\nimport \\\"./interfaces/ISignatureValidator.sol\\\";\\nimport \\\"./external/GnosisSafeMath.sol\\\";\\n\\n/// @title Gnosis Safe - A multisignature wallet with support for confirmations using signed messages based on ERC191.\\n/// @author Stefan George - \\n/// @author Richard Meissner - \\n/// @author Ricardo Guilherme Schmidt - (Status Research & Development GmbH) - Gas Token Payment\\ncontract GnosisSafe\\n is MasterCopy, ModuleManager, OwnerManager, SignatureDecoder, SecuredTokenTransfer, ISignatureValidatorConstants, FallbackManager {\\n\\n using GnosisSafeMath for uint256;\\n\\n string public constant NAME = \\\"Gnosis Safe\\\";\\n string public constant VERSION = \\\"1.2.0\\\";\\n\\n //keccak256(\\n // \\\"EIP712Domain(address verifyingContract)\\\"\\n //);\\n bytes32 private constant DOMAIN_SEPARATOR_TYPEHASH = 0x035aff83d86937d35b32e04f0ddc6ff469290eef2f1b692d8a815c89404d4749;\\n\\n //keccak256(\\n // \\\"SafeTx(address to,uint256 value,bytes data,uint8 operation,uint256 safeTxGas,uint256 baseGas,uint256 gasPrice,address gasToken,address refundReceiver,uint256 nonce)\\\"\\n //);\\n bytes32 private constant SAFE_TX_TYPEHASH = 0xbb8310d486368db6bd6f849402fdd73ad53d316b5a4b2644ad6efe0f941286d8;\\n\\n //keccak256(\\n // \\\"SafeMessage(bytes message)\\\"\\n //);\\n bytes32 private constant SAFE_MSG_TYPEHASH = 0x60b3cbf8b4a223d68d641b3b6ddf9a298e7f33710cf3d3a9d1146b5a6150fbca;\\n\\n event ApproveHash(\\n bytes32 indexed approvedHash,\\n address indexed owner\\n );\\n event SignMsg(\\n bytes32 indexed msgHash\\n );\\n event ExecutionFailure(\\n bytes32 txHash, uint256 payment\\n );\\n event ExecutionSuccess(\\n bytes32 txHash, uint256 payment\\n );\\n\\n uint256 public nonce;\\n bytes32 public domainSeparator;\\n // Mapping to keep track of all message hashes that have been approve by ALL REQUIRED owners\\n mapping(bytes32 => uint256) public signedMessages;\\n // Mapping to keep track of all hashes (message or transaction) that have been approve by ANY owners\\n mapping(address => mapping(bytes32 => uint256)) public approvedHashes;\\n\\n // This constructor ensures that this contract can only be used as a master copy for Proxy contracts\\n constructor() public {\\n // By setting the threshold it is not possible to call setup anymore,\\n // so we create a Safe with 0 owners and threshold 1.\\n // This is an unusable Safe, perfect for the mastercopy\\n threshold = 1;\\n }\\n\\n /// @dev Setup function sets initial storage of contract.\\n /// @param _owners List of Safe owners.\\n /// @param _threshold Number of required confirmations for a Safe transaction.\\n /// @param to Contract address for optional delegate call.\\n /// @param data Data payload for optional delegate call.\\n /// @param fallbackHandler Handler for fallback calls to this contract\\n /// @param paymentToken Token that should be used for the payment (0 is ETH)\\n /// @param payment Value that should be paid\\n /// @param paymentReceiver Adddress that should receive the payment (or 0 if tx.origin)\\n function setup(\\n address[] calldata _owners,\\n uint256 _threshold,\\n address to,\\n bytes calldata data,\\n address fallbackHandler,\\n address paymentToken,\\n uint256 payment,\\n address payable paymentReceiver\\n )\\n external\\n {\\n require(domainSeparator == 0, \\\"Domain Separator already set!\\\");\\n domainSeparator = keccak256(abi.encode(DOMAIN_SEPARATOR_TYPEHASH, this));\\n setupOwners(_owners, _threshold);\\n if (fallbackHandler != address(0)) internalSetFallbackHandler(fallbackHandler);\\n // As setupOwners can only be called if the contract has not been initialized we don't need a check for setupModules\\n setupModules(to, data);\\n\\n if (payment > 0) {\\n // To avoid running into issues with EIP-170 we reuse the handlePayment function (to avoid adjusting code of that has been verified we do not adjust the method itself)\\n // baseGas = 0, gasPrice = 1 and gas = payment => amount = (payment + 0) * 1 = payment\\n handlePayment(payment, 0, 1, paymentToken, paymentReceiver);\\n }\\n }\\n\\n /// @dev Allows to execute a Safe transaction confirmed by required number of owners and then pays the account that submitted the transaction.\\n /// Note: The fees are always transfered, even if the user transaction fails.\\n /// @param to Destination address of Safe transaction.\\n /// @param value Ether value of Safe transaction.\\n /// @param data Data payload of Safe transaction.\\n /// @param operation Operation type of Safe transaction.\\n /// @param safeTxGas Gas that should be used for the Safe transaction.\\n /// @param baseGas Gas costs that are independent of the transaction execution(e.g. base transaction fee, signature check, payment of the refund)\\n /// @param gasPrice Gas price that should be used for the payment calculation.\\n /// @param gasToken Token address (or 0 if ETH) that is used for the payment.\\n /// @param refundReceiver Address of receiver of gas payment (or 0 if tx.origin).\\n /// @param signatures Packed signature data ({bytes32 r}{bytes32 s}{uint8 v})\\n function execTransaction(\\n address to,\\n uint256 value,\\n bytes calldata data,\\n Enum.Operation operation,\\n uint256 safeTxGas,\\n uint256 baseGas,\\n uint256 gasPrice,\\n address gasToken,\\n address payable refundReceiver,\\n bytes calldata signatures\\n )\\n external\\n payable\\n returns (bool success)\\n {\\n bytes32 txHash;\\n // Use scope here to limit variable lifetime and prevent `stack too deep` errors\\n {\\n bytes memory txHashData = encodeTransactionData(\\n to, value, data, operation, // Transaction info\\n safeTxGas, baseGas, gasPrice, gasToken, refundReceiver, // Payment info\\n nonce\\n );\\n // Increase nonce and execute transaction.\\n nonce++;\\n txHash = keccak256(txHashData);\\n checkSignatures(txHash, txHashData, signatures, true);\\n }\\n // We require some gas to emit the events (at least 2500) after the execution and some to perform code until the execution (500)\\n // We also include the 1/64 in the check that is not send along with a call to counteract potential shortings because of EIP-150\\n require(gasleft() >= (safeTxGas * 64 / 63).max(safeTxGas + 2500) + 500, \\\"GS010\\\");\\n // Use scope here to limit variable lifetime and prevent `stack too deep` errors\\n {\\n uint256 gasUsed = gasleft();\\n // If the gasPrice is 0 we assume that nearly all available gas can be used (it is always more than safeTxGas)\\n // We only substract 2500 (compared to the 3000 before) to ensure that the amount passed is still higher than safeTxGas\\n success = execute(to, value, data, operation, gasPrice == 0 ? (gasleft() - 2500) : safeTxGas);\\n gasUsed = gasUsed.sub(gasleft());\\n // We transfer the calculated tx costs to the tx.origin to avoid sending it to intermediate contracts that have made calls\\n uint256 payment = 0;\\n if (gasPrice > 0) {\\n payment = handlePayment(gasUsed, baseGas, gasPrice, gasToken, refundReceiver);\\n }\\n if (success) emit ExecutionSuccess(txHash, payment);\\n else emit ExecutionFailure(txHash, payment);\\n }\\n }\\n\\n function handlePayment(\\n uint256 gasUsed,\\n uint256 baseGas,\\n uint256 gasPrice,\\n address gasToken,\\n address payable refundReceiver\\n )\\n private\\n returns (uint256 payment)\\n {\\n // solium-disable-next-line security/no-tx-origin\\n address payable receiver = refundReceiver == address(0) ? tx.origin : refundReceiver;\\n if (gasToken == address(0)) {\\n // For ETH we will only adjust the gas price to not be higher than the actual used gas price\\n payment = gasUsed.add(baseGas).mul(gasPrice < tx.gasprice ? gasPrice : tx.gasprice);\\n // solium-disable-next-line security/no-send\\n require(receiver.send(payment), \\\"GS011\\\");\\n } else {\\n payment = gasUsed.add(baseGas).mul(gasPrice);\\n require(transferToken(gasToken, receiver, payment), \\\"GS012\\\");\\n }\\n }\\n\\n /**\\n * @dev Checks whether the signature provided is valid for the provided data, hash. Will revert otherwise.\\n * @param dataHash Hash of the data (could be either a message hash or transaction hash)\\n * @param data That should be signed (this is passed to an external validator contract)\\n * @param signatures Signature data that should be verified. Can be ECDSA signature, contract signature (EIP-1271) or approved hash.\\n * @param consumeHash Indicates that in case of an approved hash the storage can be freed to save gas\\n */\\n function checkSignatures(bytes32 dataHash, bytes memory data, bytes memory signatures, bool consumeHash)\\n internal\\n {\\n // Load threshold to avoid multiple storage loads\\n uint256 _threshold = threshold;\\n // Check that a threshold is set\\n require(_threshold > 0, \\\"GS001\\\");\\n // Check that the provided signature data is not too short\\n require(signatures.length >= _threshold.mul(65), \\\"GS020\\\");\\n // There cannot be an owner with address 0.\\n address lastOwner = address(0);\\n address currentOwner;\\n uint8 v;\\n bytes32 r;\\n bytes32 s;\\n uint256 i;\\n for (i = 0; i < _threshold; i++) {\\n (v, r, s) = signatureSplit(signatures, i);\\n // If v is 0 then it is a contract signature\\n if (v == 0) {\\n // When handling contract signatures the address of the contract is encoded into r\\n currentOwner = address(uint256(r));\\n\\n // Check that signature data pointer (s) is not pointing inside the static part of the signatures bytes\\n // This check is not completely accurate, since it is possible that more signatures than the threshold are send.\\n // Here we only check that the pointer is not pointing inside the part that is being processed\\n require(uint256(s) >= _threshold.mul(65), \\\"GS021\\\");\\n\\n // Check that signature data pointer (s) is in bounds (points to the length of data -> 32 bytes)\\n require(uint256(s).add(32) <= signatures.length, \\\"GS022\\\");\\n\\n // Check if the contract signature is in bounds: start of data is s + 32 and end is start + signature length\\n uint256 contractSignatureLen;\\n // solium-disable-next-line security/no-inline-assembly\\n assembly {\\n contractSignatureLen := mload(add(add(signatures, s), 0x20))\\n }\\n require(uint256(s).add(32).add(contractSignatureLen) <= signatures.length, \\\"GS023\\\");\\n\\n // Check signature\\n bytes memory contractSignature;\\n // solium-disable-next-line security/no-inline-assembly\\n assembly {\\n // The signature data for contract signatures is appended to the concatenated signatures and the offset is stored in s\\n contractSignature := add(add(signatures, s), 0x20)\\n }\\n require(ISignatureValidator(currentOwner).isValidSignature(data, contractSignature) == EIP1271_MAGIC_VALUE, \\\"GS024\\\");\\n // If v is 1 then it is an approved hash\\n } else if (v == 1) {\\n // When handling approved hashes the address of the approver is encoded into r\\n currentOwner = address(uint256(r));\\n // Hashes are automatically approved by the sender of the message or when they have been pre-approved via a separate transaction\\n require(msg.sender == currentOwner || approvedHashes[currentOwner][dataHash] != 0, \\\"GS025\\\");\\n // Hash has been marked for consumption. If this hash was pre-approved free storage\\n if (consumeHash && msg.sender != currentOwner) {\\n approvedHashes[currentOwner][dataHash] = 0;\\n }\\n } else if (v > 30) {\\n // To support eth_sign and similar we adjust v and hash the messageHash with the Ethereum message prefix before applying ecrecover\\n currentOwner = ecrecover(keccak256(abi.encodePacked(\\\"\\\\x19Ethereum Signed Message:\\\\n32\\\", dataHash)), v - 4, r, s);\\n } else {\\n // Use ecrecover with the messageHash for EOA signatures\\n currentOwner = ecrecover(dataHash, v, r, s);\\n }\\n require (\\n currentOwner > lastOwner && owners[currentOwner] != address(0) && currentOwner != SENTINEL_OWNERS,\\n \\\"GS026\\\"\\n );\\n lastOwner = currentOwner;\\n }\\n }\\n\\n /// @dev Allows to estimate a Safe transaction.\\n /// This method is only meant for estimation purpose, therefore two different protection mechanism against execution in a transaction have been made:\\n /// 1.) The method can only be called from the safe itself\\n /// 2.) The response is returned with a revert\\n /// When estimating set `from` to the address of the safe.\\n /// Since the `estimateGas` function includes refunds, call this method to get an estimated of the costs that are deducted from the safe with `execTransaction`\\n /// @param to Destination address of Safe transaction.\\n /// @param value Ether value of Safe transaction.\\n /// @param data Data payload of Safe transaction.\\n /// @param operation Operation type of Safe transaction.\\n /// @return Estimate without refunds and overhead fees (base transaction and payload data gas costs).\\n function requiredTxGas(address to, uint256 value, bytes calldata data, Enum.Operation operation)\\n external\\n authorized\\n returns (uint256)\\n {\\n uint256 startGas = gasleft();\\n // We don't provide an error message here, as we use it to return the estimate\\n // solium-disable-next-line error-reason\\n require(execute(to, value, data, operation, gasleft()));\\n uint256 requiredGas = startGas - gasleft();\\n // Convert response to string and return via error message\\n revert(string(abi.encodePacked(requiredGas)));\\n }\\n\\n /**\\n * @dev Marks a hash as approved. This can be used to validate a hash that is used by a signature.\\n * @param hashToApprove The hash that should be marked as approved for signatures that are verified by this contract.\\n */\\n function approveHash(bytes32 hashToApprove)\\n external\\n {\\n require(owners[msg.sender] != address(0), \\\"GS030\\\");\\n approvedHashes[msg.sender][hashToApprove] = 1;\\n emit ApproveHash(hashToApprove, msg.sender);\\n }\\n\\n /**\\n * @dev Marks a message as signed, so that it can be used with EIP-1271\\n * @notice Marks a message (`_data`) as signed.\\n * @param _data Arbitrary length data that should be marked as signed on the behalf of address(this)\\n */\\n function signMessage(bytes calldata _data)\\n external\\n authorized\\n {\\n bytes32 msgHash = getMessageHash(_data);\\n signedMessages[msgHash] = 1;\\n emit SignMsg(msgHash);\\n }\\n\\n /**\\n * Implementation of ISignatureValidator (see `interfaces/ISignatureValidator.sol`)\\n * @dev Should return whether the signature provided is valid for the provided data.\\n * The save does not implement the interface since `checkSignatures` is not a view method.\\n * The method will not perform any state changes (see parameters of `checkSignatures`)\\n * @param _data Arbitrary length data signed on the behalf of address(this)\\n * @param _signature Signature byte array associated with _data\\n * @return a bool upon valid or invalid signature with corresponding _data\\n */\\n function isValidSignature(bytes calldata _data, bytes calldata _signature)\\n external\\n returns (bytes4)\\n {\\n bytes32 messageHash = getMessageHash(_data);\\n if (_signature.length == 0) {\\n require(signedMessages[messageHash] != 0, \\\"Hash not approved\\\");\\n } else {\\n // consumeHash needs to be false, as the state should not be changed\\n checkSignatures(messageHash, _data, _signature, false);\\n }\\n return EIP1271_MAGIC_VALUE;\\n }\\n\\n /// @dev Returns hash of a message that can be signed by owners.\\n /// @param message Message that should be hashed\\n /// @return Message hash.\\n function getMessageHash(\\n bytes memory message\\n )\\n public\\n view\\n returns (bytes32)\\n {\\n bytes32 safeMessageHash = keccak256(\\n abi.encode(SAFE_MSG_TYPEHASH, keccak256(message))\\n );\\n return keccak256(\\n abi.encodePacked(byte(0x19), byte(0x01), domainSeparator, safeMessageHash)\\n );\\n }\\n\\n /// @dev Returns the bytes that are hashed to be signed by owners.\\n /// @param to Destination address.\\n /// @param value Ether value.\\n /// @param data Data payload.\\n /// @param operation Operation type.\\n /// @param safeTxGas Gas that should be used for the safe transaction.\\n /// @param baseGas Gas costs for that are independent of the transaction execution(e.g. base transaction fee, signature check, payment of the refund)\\n /// @param gasPrice Maximum gas price that should be used for this transaction.\\n /// @param gasToken Token address (or 0 if ETH) that is used for the payment.\\n /// @param refundReceiver Address of receiver of gas payment (or 0 if tx.origin).\\n /// @param _nonce Transaction nonce.\\n /// @return Transaction hash bytes.\\n function encodeTransactionData(\\n address to,\\n uint256 value,\\n bytes memory data,\\n Enum.Operation operation,\\n uint256 safeTxGas,\\n uint256 baseGas,\\n uint256 gasPrice,\\n address gasToken,\\n address refundReceiver,\\n uint256 _nonce\\n )\\n public\\n view\\n returns (bytes memory)\\n {\\n bytes32 safeTxHash = keccak256(\\n abi.encode(SAFE_TX_TYPEHASH, to, value, keccak256(data), operation, safeTxGas, baseGas, gasPrice, gasToken, refundReceiver, _nonce)\\n );\\n return abi.encodePacked(byte(0x19), byte(0x01), domainSeparator, safeTxHash);\\n }\\n\\n /// @dev Returns hash to be signed by owners.\\n /// @param to Destination address.\\n /// @param value Ether value.\\n /// @param data Data payload.\\n /// @param operation Operation type.\\n /// @param safeTxGas Fas that should be used for the safe transaction.\\n /// @param baseGas Gas costs for data used to trigger the safe transaction.\\n /// @param gasPrice Maximum gas price that should be used for this transaction.\\n /// @param gasToken Token address (or 0 if ETH) that is used for the payment.\\n /// @param refundReceiver Address of receiver of gas payment (or 0 if tx.origin).\\n /// @param _nonce Transaction nonce.\\n /// @return Transaction hash.\\n function getTransactionHash(\\n address to,\\n uint256 value,\\n bytes memory data,\\n Enum.Operation operation,\\n uint256 safeTxGas,\\n uint256 baseGas,\\n uint256 gasPrice,\\n address gasToken,\\n address refundReceiver,\\n uint256 _nonce\\n )\\n public\\n view\\n returns (bytes32)\\n {\\n return keccak256(encodeTransactionData(to, value, data, operation, safeTxGas, baseGas, gasPrice, gasToken, refundReceiver, _nonce));\\n }\\n}\\n\",\"keccak256\":\"0x0eadc5815fa051e47c15d65933983e788d66b079fdfc675f1f65a2eaa3299131\"},\"contracts/base/Executor.sol\":{\"content\":\"// SPDX-License-Identifier: LGPL-3.0-only pragma solidity >=0.7.0 <0.9.0;\\nimport \\\"../common/Enum.sol\\\";\\n\\n\\n/// @title Executor - A contract that can execute transactions\\n/// @author Richard Meissner - \\ncontract Executor {\\n\\n function execute(address to, uint256 value, bytes memory data, Enum.Operation operation, uint256 txGas)\\n internal\\n returns (bool success)\\n {\\n if (operation == Enum.Operation.Call)\\n success = executeCall(to, value, data, txGas);\\n else if (operation == Enum.Operation.DelegateCall)\\n success = executeDelegateCall(to, data, txGas);\\n else\\n success = false;\\n }\\n\\n function executeCall(address to, uint256 value, bytes memory data, uint256 txGas)\\n internal\\n returns (bool success)\\n {\\n // solium-disable-next-line security/no-inline-assembly\\n assembly {\\n success := call(txGas, to, value, add(data, 0x20), mload(data), 0, 0)\\n }\\n }\\n\\n function executeDelegateCall(address to, bytes memory data, uint256 txGas)\\n internal\\n returns (bool success)\\n {\\n // solium-disable-next-line security/no-inline-assembly\\n assembly {\\n success := delegatecall(txGas, to, add(data, 0x20), mload(data), 0, 0)\\n }\\n }\\n}\\n\",\"keccak256\":\"0x0b7ce8c3f97a7227627ee4f8a77959aa044f6abf2f67bdf6f62ccb8905d5d1dc\"},\"contracts/base/FallbackManager.sol\":{\"content\":\"// SPDX-License-Identifier: LGPL-3.0-only pragma solidity >=0.7.0 <0.9.0;\\n\\nimport \\\"../common/SelfAuthorized.sol\\\";\\n\\n/// @title Fallback Manager - A contract that manages fallback calls made to this contract\\n/// @author Richard Meissner - \\ncontract FallbackManager is SelfAuthorized {\\n\\n // keccak256(\\\"fallback_manager.handler.address\\\")\\n bytes32 internal constant FALLBACK_HANDLER_STORAGE_SLOT = 0x6c9a6c4a39284e37ed1cf53d337577d14212a4870fb976a4366c693b939918d5;\\n\\n function internalSetFallbackHandler(address handler) internal {\\n bytes32 slot = FALLBACK_HANDLER_STORAGE_SLOT;\\n // solium-disable-next-line security/no-inline-assembly\\n assembly {\\n sstore(slot, handler)\\n }\\n }\\n\\n /// @dev Allows to add a contract to handle fallback calls.\\n /// Only fallback calls without value and with data will be forwarded.\\n /// This can only be done via a Safe transaction.\\n /// @param handler contract to handle fallbacks calls.\\n function setFallbackHandler(address handler)\\n public\\n authorized\\n {\\n internalSetFallbackHandler(handler);\\n }\\n\\n function ()\\n external\\n payable\\n {\\n // Only calls without value and with data will be forwarded\\n if (msg.value > 0 || msg.data.length == 0) {\\n return;\\n }\\n bytes32 slot = FALLBACK_HANDLER_STORAGE_SLOT;\\n address handler;\\n // solium-disable-next-line security/no-inline-assembly\\n assembly {\\n handler := sload(slot)\\n }\\n\\n if (handler != address(0)) {\\n // solium-disable-next-line security/no-inline-assembly\\n assembly {\\n calldatacopy(0, 0, calldatasize())\\n let success := call(gas, handler, 0, 0, calldatasize(), 0, 0)\\n returndatacopy(0, 0, returndatasize())\\n if eq(success, 0) { revert(0, returndatasize()) }\\n return(0, returndatasize())\\n }\\n }\\n }\\n}\",\"keccak256\":\"0x99ff669da87d2496bcc5c9c8412793c4d08aeff7160d51918515677e22154e01\"},\"contracts/base/ModuleManager.sol\":{\"content\":\"// SPDX-License-Identifier: LGPL-3.0-only -pragma solidity >=0.7.0 <0.9.0;\\nimport \\\"../common/Enum.sol\\\";\\nimport \\\"../common/SelfAuthorized.sol\\\";\\nimport \\\"./Executor.sol\\\";\\n\\n\\n/// @title Module Manager - A contract that manages modules that can execute transactions via this contract\\n/// @author Stefan George - \\n/// @author Richard Meissner - \\ncontract ModuleManager is SelfAuthorized, Executor {\\n\\n event EnabledModule(address module);\\n event DisabledModule(address module);\\n event ExecutionFromModuleSuccess(address indexed module);\\n event ExecutionFromModuleFailure(address indexed module);\\n\\n address internal constant SENTINEL_MODULES = address(0x1);\\n\\n mapping (address => address) internal modules;\\n\\n function setupModules(address to, bytes memory data)\\n internal\\n {\\n require(modules[SENTINEL_MODULES] == address(0), \\\"Modules have already been initialized\\\");\\n modules[SENTINEL_MODULES] = SENTINEL_MODULES;\\n if (to != address(0))\\n // Setup has to complete successfully or transaction fails.\\n require(executeDelegateCall(to, data, gasleft()), \\\"Could not finish initialization\\\");\\n }\\n\\n /// @dev Allows to add a module to the whitelist.\\n /// This can only be done via a Safe transaction.\\n /// @notice Enables the module `module` for the Safe.\\n /// @param module Module to be whitelisted.\\n function enableModule(address module)\\n public\\n authorized\\n {\\n // Module address cannot be null or sentinel.\\n require(module != address(0) && module != SENTINEL_MODULES, \\\"Invalid module address provided\\\");\\n // Module cannot be added twice.\\n require(modules[module] == address(0), \\\"Module has already been added\\\");\\n modules[module] = modules[SENTINEL_MODULES];\\n modules[SENTINEL_MODULES] = module;\\n emit EnabledModule(module);\\n }\\n\\n /// @dev Allows to remove a module from the whitelist.\\n /// This can only be done via a Safe transaction.\\n /// @notice Disables the module `module` for the Safe.\\n /// @param prevModule Module that pointed to the module to be removed in the linked list\\n /// @param module Module to be removed.\\n function disableModule(address prevModule, address module)\\n public\\n authorized\\n {\\n // Validate module address and check that it corresponds to module index.\\n require(module != address(0) && module != SENTINEL_MODULES, \\\"Invalid module address provided\\\");\\n require(modules[prevModule] == module, \\\"Invalid prevModule, module pair provided\\\");\\n modules[prevModule] = modules[module];\\n modules[module] = address(0);\\n emit DisabledModule(module);\\n }\\n\\n /// @dev Allows a Module to execute a Safe transaction without any further confirmations.\\n /// @param to Destination address of module transaction.\\n /// @param value Ether value of module transaction.\\n /// @param data Data payload of module transaction.\\n /// @param operation Operation type of module transaction.\\n function execTransactionFromModule(address to, uint256 value, bytes memory data, Enum.Operation operation)\\n public\\n returns (bool success)\\n {\\n // Only whitelisted modules are allowed.\\n require(msg.sender != SENTINEL_MODULES && modules[msg.sender] != address(0), \\\"Method can only be called from an enabled module\\\");\\n // Execute transaction without further confirmations.\\n success = execute(to, value, data, operation, gasleft());\\n if (success) emit ExecutionFromModuleSuccess(msg.sender);\\n else emit ExecutionFromModuleFailure(msg.sender);\\n }\\n\\n /// @dev Allows a Module to execute a Safe transaction without any further confirmations and return data\\n /// @param to Destination address of module transaction.\\n /// @param value Ether value of module transaction.\\n /// @param data Data payload of module transaction.\\n /// @param operation Operation type of module transaction.\\n function execTransactionFromModuleReturnData(address to, uint256 value, bytes memory data, Enum.Operation operation)\\n public\\n returns (bool success, bytes memory returnData)\\n {\\n success = execTransactionFromModule(to, value, data, operation);\\n // solium-disable-next-line security/no-inline-assembly\\n assembly {\\n // Load free memory location\\n let ptr := mload(0x40)\\n // We allocate memory for the return data by setting the free memory location to\\n // current free memory location + data size + 32 bytes for data size value\\n mstore(0x40, add(ptr, add(returndatasize(), 0x20)))\\n // Store the size\\n mstore(ptr, returndatasize())\\n // Store the data\\n returndatacopy(add(ptr, 0x20), 0, returndatasize())\\n // Point the return data to the correct memory location\\n returnData := ptr\\n }\\n }\\n\\n /// @dev Returns if an module is enabled\\n /// @return True if the module is enabled\\n function isModuleEnabled(address module)\\n public\\n view\\n returns (bool)\\n {\\n return SENTINEL_MODULES != module && modules[module] != address(0);\\n }\\n\\n /// @dev Returns array of first 10 modules.\\n /// @return Array of modules.\\n function getModules()\\n public\\n view\\n returns (address[] memory)\\n {\\n (address[] memory array,) = getModulesPaginated(SENTINEL_MODULES, 10);\\n return array;\\n }\\n\\n /// @dev Returns array of modules.\\n /// @param start Start of the page.\\n /// @param pageSize Maximum number of modules that should be returned.\\n /// @return Array of modules.\\n function getModulesPaginated(address start, uint256 pageSize)\\n public\\n view\\n returns (address[] memory array, address next)\\n {\\n // Init array with max page size\\n array = new address[](pageSize);\\n\\n // Populate return array\\n uint256 moduleCount = 0;\\n address currentModule = modules[start];\\n while(currentModule != address(0x0) && currentModule != SENTINEL_MODULES && moduleCount < pageSize) {\\n array[moduleCount] = currentModule;\\n currentModule = modules[currentModule];\\n moduleCount++;\\n }\\n next = currentModule;\\n // Set correct size of returned array\\n // solium-disable-next-line security/no-inline-assembly\\n assembly {\\n mstore(array, moduleCount)\\n }\\n }\\n}\\n\",\"keccak256\":\"0xba00a1d50f9cdc658edf3038baf24113d4f7b797352b3ad0b58c98e798534d48\"},\"contracts/base/OwnerManager.sol\":{\"content\":\"// SPDX-License-Identifier: LGPL-3.0-only -pragma solidity >=0.7.0 <0.9.0;\\nimport \\\"../common/SelfAuthorized.sol\\\";\\n\\n/// @title OwnerManager - Manages a set of owners and a threshold to perform actions.\\n/// @author Stefan George - \\n/// @author Richard Meissner - \\ncontract OwnerManager is SelfAuthorized {\\n\\n event AddedOwner(address owner);\\n event RemovedOwner(address owner);\\n event ChangedThreshold(uint256 threshold);\\n\\n address internal constant SENTINEL_OWNERS = address(0x1);\\n\\n mapping(address => address) internal owners;\\n uint256 ownerCount;\\n uint256 internal threshold;\\n\\n /// @dev Setup function sets initial storage of contract.\\n /// @param _owners List of Safe owners.\\n /// @param _threshold Number of required confirmations for a Safe transaction.\\n function setupOwners(address[] memory _owners, uint256 _threshold)\\n internal\\n {\\n // Threshold can only be 0 at initialization.\\n // Check ensures that setup function can only be called once.\\n require(threshold == 0, \\\"Owners have already been setup\\\");\\n // Validate that threshold is smaller than number of added owners.\\n require(_threshold <= _owners.length, \\\"Threshold cannot exceed owner count\\\");\\n // There has to be at least one Safe owner.\\n require(_threshold >= 1, \\\"Threshold needs to be greater than 0\\\");\\n // Initializing Safe owners.\\n address currentOwner = SENTINEL_OWNERS;\\n for (uint256 i = 0; i < _owners.length; i++) {\\n // Owner address cannot be null.\\n address owner = _owners[i];\\n require(owner != address(0) && owner != SENTINEL_OWNERS, \\\"Invalid owner address provided\\\");\\n // No duplicate owners allowed.\\n require(owners[owner] == address(0), \\\"Duplicate owner address provided\\\");\\n owners[currentOwner] = owner;\\n currentOwner = owner;\\n }\\n owners[currentOwner] = SENTINEL_OWNERS;\\n ownerCount = _owners.length;\\n threshold = _threshold;\\n }\\n\\n /// @dev Allows to add a new owner to the Safe and update the threshold at the same time.\\n /// This can only be done via a Safe transaction.\\n /// @notice Adds the owner `owner` to the Safe and updates the threshold to `_threshold`.\\n /// @param owner New owner address.\\n /// @param _threshold New threshold.\\n function addOwnerWithThreshold(address owner, uint256 _threshold)\\n public\\n authorized\\n {\\n // Owner address cannot be null.\\n require(owner != address(0) && owner != SENTINEL_OWNERS, \\\"Invalid owner address provided\\\");\\n // No duplicate owners allowed.\\n require(owners[owner] == address(0), \\\"Address is already an owner\\\");\\n owners[owner] = owners[SENTINEL_OWNERS];\\n owners[SENTINEL_OWNERS] = owner;\\n ownerCount++;\\n emit AddedOwner(owner);\\n // Change threshold if threshold was changed.\\n if (threshold != _threshold)\\n changeThreshold(_threshold);\\n }\\n\\n /// @dev Allows to remove an owner from the Safe and update the threshold at the same time.\\n /// This can only be done via a Safe transaction.\\n /// @notice Removes the owner `owner` from the Safe and updates the threshold to `_threshold`.\\n /// @param prevOwner Owner that pointed to the owner to be removed in the linked list\\n /// @param owner Owner address to be removed.\\n /// @param _threshold New threshold.\\n function removeOwner(address prevOwner, address owner, uint256 _threshold)\\n public\\n authorized\\n {\\n // Only allow to remove an owner, if threshold can still be reached.\\n require(ownerCount - 1 >= _threshold, \\\"New owner count needs to be larger than new threshold\\\");\\n // Validate owner address and check that it corresponds to owner index.\\n require(owner != address(0) && owner != SENTINEL_OWNERS, \\\"Invalid owner address provided\\\");\\n require(owners[prevOwner] == owner, \\\"Invalid prevOwner, owner pair provided\\\");\\n owners[prevOwner] = owners[owner];\\n owners[owner] = address(0);\\n ownerCount--;\\n emit RemovedOwner(owner);\\n // Change threshold if threshold was changed.\\n if (threshold != _threshold)\\n changeThreshold(_threshold);\\n }\\n\\n /// @dev Allows to swap/replace an owner from the Safe with another address.\\n /// This can only be done via a Safe transaction.\\n /// @notice Replaces the owner `oldOwner` in the Safe with `newOwner`.\\n /// @param prevOwner Owner that pointed to the owner to be replaced in the linked list\\n /// @param oldOwner Owner address to be replaced.\\n /// @param newOwner New owner address.\\n function swapOwner(address prevOwner, address oldOwner, address newOwner)\\n public\\n authorized\\n {\\n // Owner address cannot be null.\\n require(newOwner != address(0) && newOwner != SENTINEL_OWNERS, \\\"Invalid owner address provided\\\");\\n // No duplicate owners allowed.\\n require(owners[newOwner] == address(0), \\\"Address is already an owner\\\");\\n // Validate oldOwner address and check that it corresponds to owner index.\\n require(oldOwner != address(0) && oldOwner != SENTINEL_OWNERS, \\\"Invalid owner address provided\\\");\\n require(owners[prevOwner] == oldOwner, \\\"Invalid prevOwner, owner pair provided\\\");\\n owners[newOwner] = owners[oldOwner];\\n owners[prevOwner] = newOwner;\\n owners[oldOwner] = address(0);\\n emit RemovedOwner(oldOwner);\\n emit AddedOwner(newOwner);\\n }\\n\\n /// @dev Allows to update the number of required confirmations by Safe owners.\\n /// This can only be done via a Safe transaction.\\n /// @notice Changes the threshold of the Safe to `_threshold`.\\n /// @param _threshold New threshold.\\n function changeThreshold(uint256 _threshold)\\n public\\n authorized\\n {\\n // Validate that threshold is smaller than number of owners.\\n require(_threshold <= ownerCount, \\\"Threshold cannot exceed owner count\\\");\\n // There has to be at least one Safe owner.\\n require(_threshold >= 1, \\\"Threshold needs to be greater than 0\\\");\\n threshold = _threshold;\\n emit ChangedThreshold(threshold);\\n }\\n\\n function getThreshold()\\n public\\n view\\n returns (uint256)\\n {\\n return threshold;\\n }\\n\\n function isOwner(address owner)\\n public\\n view\\n returns (bool)\\n {\\n return owner != SENTINEL_OWNERS && owners[owner] != address(0);\\n }\\n\\n /// @dev Returns array of owners.\\n /// @return Array of Safe owners.\\n function getOwners()\\n public\\n view\\n returns (address[] memory)\\n {\\n address[] memory array = new address[](ownerCount);\\n\\n // populate return array\\n uint256 index = 0;\\n address currentOwner = owners[SENTINEL_OWNERS];\\n while(currentOwner != SENTINEL_OWNERS) {\\n array[index] = currentOwner;\\n currentOwner = owners[currentOwner];\\n index ++;\\n }\\n return array;\\n }\\n}\\n\",\"keccak256\":\"0xf1f1a07407270de1dd20679a91e2d562b9cdef714fb88ee1b0132558a3837853\"},\"contracts/common/Enum.sol\":{\"content\":\"// SPDX-License-Identifier: LGPL-3.0-only +pragma solidity >=0.7.0 <0.9.0;\\nimport \\\"../common/Enum.sol\\\";\\nimport \\\"../common/SelfAuthorized.sol\\\";\\nimport \\\"./Executor.sol\\\";\\n\\n\\n/// @title Module Manager - A contract that manages modules that can execute transactions via this contract\\n/// @author Stefan George - \\n/// @author Richard Meissner - \\ncontract ModuleManager is SelfAuthorized, Executor {\\n\\n event EnabledModule(address module);\\n event DisabledModule(address module);\\n event ExecutionFromModuleSuccess(address indexed module);\\n event ExecutionFromModuleFailure(address indexed module);\\n\\n address internal constant SENTINEL_MODULES = address(0x1);\\n\\n mapping (address => address) internal modules;\\n\\n function setupModules(address to, bytes memory data)\\n internal\\n {\\n require(modules[SENTINEL_MODULES] == address(0), \\\"GS100\\\");\\n modules[SENTINEL_MODULES] = SENTINEL_MODULES;\\n if (to != address(0))\\n // Setup has to complete successfully or transaction fails.\\n require(executeDelegateCall(to, data, gasleft()), \\\"Could not finish initialization\\\");\\n }\\n\\n /// @dev Allows to add a module to the whitelist.\\n /// This can only be done via a Safe transaction.\\n /// @notice Enables the module `module` for the Safe.\\n /// @param module Module to be whitelisted.\\n function enableModule(address module)\\n public\\n authorized\\n {\\n // Module address cannot be null or sentinel.\\n require(module != address(0) && module != SENTINEL_MODULES, \\\"GS101\\\");\\n // Module cannot be added twice.\\n require(modules[module] == address(0), \\\"GS102\\\");\\n modules[module] = modules[SENTINEL_MODULES];\\n modules[SENTINEL_MODULES] = module;\\n emit EnabledModule(module);\\n }\\n\\n /// @dev Allows to remove a module from the whitelist.\\n /// This can only be done via a Safe transaction.\\n /// @notice Disables the module `module` for the Safe.\\n /// @param prevModule Module that pointed to the module to be removed in the linked list\\n /// @param module Module to be removed.\\n function disableModule(address prevModule, address module)\\n public\\n authorized\\n {\\n // Validate module address and check that it corresponds to module index.\\n require(module != address(0) && module != SENTINEL_MODULES, \\\"GS101\\\");\\n require(modules[prevModule] == module, \\\"GS103\\\");\\n modules[prevModule] = modules[module];\\n modules[module] = address(0);\\n emit DisabledModule(module);\\n }\\n\\n /// @dev Allows a Module to execute a Safe transaction without any further confirmations.\\n /// @param to Destination address of module transaction.\\n /// @param value Ether value of module transaction.\\n /// @param data Data payload of module transaction.\\n /// @param operation Operation type of module transaction.\\n function execTransactionFromModule(address to, uint256 value, bytes memory data, Enum.Operation operation)\\n public\\n returns (bool success)\\n {\\n // Only whitelisted modules are allowed.\\n require(msg.sender != SENTINEL_MODULES && modules[msg.sender] != address(0), \\\"GS104\\\");\\n // Execute transaction without further confirmations.\\n success = execute(to, value, data, operation, gasleft());\\n if (success) emit ExecutionFromModuleSuccess(msg.sender);\\n else emit ExecutionFromModuleFailure(msg.sender);\\n }\\n\\n /// @dev Allows a Module to execute a Safe transaction without any further confirmations and return data\\n /// @param to Destination address of module transaction.\\n /// @param value Ether value of module transaction.\\n /// @param data Data payload of module transaction.\\n /// @param operation Operation type of module transaction.\\n function execTransactionFromModuleReturnData(address to, uint256 value, bytes memory data, Enum.Operation operation)\\n public\\n returns (bool success, bytes memory returnData)\\n {\\n success = execTransactionFromModule(to, value, data, operation);\\n // solium-disable-next-line security/no-inline-assembly\\n assembly {\\n // Load free memory location\\n let ptr := mload(0x40)\\n // We allocate memory for the return data by setting the free memory location to\\n // current free memory location + data size + 32 bytes for data size value\\n mstore(0x40, add(ptr, add(returndatasize(), 0x20)))\\n // Store the size\\n mstore(ptr, returndatasize())\\n // Store the data\\n returndatacopy(add(ptr, 0x20), 0, returndatasize())\\n // Point the return data to the correct memory location\\n returnData := ptr\\n }\\n }\\n\\n /// @dev Returns if an module is enabled\\n /// @return True if the module is enabled\\n function isModuleEnabled(address module)\\n public\\n view\\n returns (bool)\\n {\\n return SENTINEL_MODULES != module && modules[module] != address(0);\\n }\\n\\n /// @dev Returns array of first 10 modules.\\n /// @return Array of modules.\\n function getModules()\\n public\\n view\\n returns (address[] memory)\\n {\\n (address[] memory array,) = getModulesPaginated(SENTINEL_MODULES, 10);\\n return array;\\n }\\n\\n /// @dev Returns array of modules.\\n /// @param start Start of the page.\\n /// @param pageSize Maximum number of modules that should be returned.\\n /// @return Array of modules.\\n function getModulesPaginated(address start, uint256 pageSize)\\n public\\n view\\n returns (address[] memory array, address next)\\n {\\n // Init array with max page size\\n array = new address[](pageSize);\\n\\n // Populate return array\\n uint256 moduleCount = 0;\\n address currentModule = modules[start];\\n while(currentModule != address(0x0) && currentModule != SENTINEL_MODULES && moduleCount < pageSize) {\\n array[moduleCount] = currentModule;\\n currentModule = modules[currentModule];\\n moduleCount++;\\n }\\n next = currentModule;\\n // Set correct size of returned array\\n // solium-disable-next-line security/no-inline-assembly\\n assembly {\\n mstore(array, moduleCount)\\n }\\n }\\n}\\n\",\"keccak256\":\"0xba00a1d50f9cdc658edf3038baf24113d4f7b797352b3ad0b58c98e798534d48\"},\"contracts/base/OwnerManager.sol\":{\"content\":\"// SPDX-License-Identifier: LGPL-3.0-only +pragma solidity >=0.7.0 <0.9.0;\\nimport \\\"../common/SelfAuthorized.sol\\\";\\n\\n/// @title OwnerManager - Manages a set of owners and a threshold to perform actions.\\n/// @author Stefan George - \\n/// @author Richard Meissner - \\ncontract OwnerManager is SelfAuthorized {\\n\\n event AddedOwner(address owner);\\n event RemovedOwner(address owner);\\n event ChangedThreshold(uint256 threshold);\\n\\n address internal constant SENTINEL_OWNERS = address(0x1);\\n\\n mapping(address => address) internal owners;\\n uint256 ownerCount;\\n uint256 internal threshold;\\n\\n /// @dev Setup function sets initial storage of contract.\\n /// @param _owners List of Safe owners.\\n /// @param _threshold Number of required confirmations for a Safe transaction.\\n function setupOwners(address[] memory _owners, uint256 _threshold)\\n internal\\n {\\n // Threshold can only be 0 at initialization.\\n // Check ensures that setup function can only be called once.\\n require(threshold == 0, \\\"GS200\\\");\\n // Validate that threshold is smaller than number of added owners.\\n require(_threshold <= _owners.length, \\\"GS201\\\");\\n // There has to be at least one Safe owner.\\n require(_threshold >= 1, \\\"GS202\\\");\\n // Initializing Safe owners.\\n address currentOwner = SENTINEL_OWNERS;\\n for (uint256 i = 0; i < _owners.length; i++) {\\n // Owner address cannot be null.\\n address owner = _owners[i];\\n require(owner != address(0) && owner != SENTINEL_OWNERS, \\\"GS203\\\");\\n // No duplicate owners allowed.\\n require(owners[owner] == address(0), \\\"Duplicate owner address provided\\\");\\n owners[currentOwner] = owner;\\n currentOwner = owner;\\n }\\n owners[currentOwner] = SENTINEL_OWNERS;\\n ownerCount = _owners.length;\\n threshold = _threshold;\\n }\\n\\n /// @dev Allows to add a new owner to the Safe and update the threshold at the same time.\\n /// This can only be done via a Safe transaction.\\n /// @notice Adds the owner `owner` to the Safe and updates the threshold to `_threshold`.\\n /// @param owner New owner address.\\n /// @param _threshold New threshold.\\n function addOwnerWithThreshold(address owner, uint256 _threshold)\\n public\\n authorized\\n {\\n // Owner address cannot be null.\\n require(owner != address(0) && owner != SENTINEL_OWNERS, \\\"GS203\\\");\\n // No duplicate owners allowed.\\n require(owners[owner] == address(0), \\\"GS204\\\");\\n owners[owner] = owners[SENTINEL_OWNERS];\\n owners[SENTINEL_OWNERS] = owner;\\n ownerCount++;\\n emit AddedOwner(owner);\\n // Change threshold if threshold was changed.\\n if (threshold != _threshold)\\n changeThreshold(_threshold);\\n }\\n\\n /// @dev Allows to remove an owner from the Safe and update the threshold at the same time.\\n /// This can only be done via a Safe transaction.\\n /// @notice Removes the owner `owner` from the Safe and updates the threshold to `_threshold`.\\n /// @param prevOwner Owner that pointed to the owner to be removed in the linked list\\n /// @param owner Owner address to be removed.\\n /// @param _threshold New threshold.\\n function removeOwner(address prevOwner, address owner, uint256 _threshold)\\n public\\n authorized\\n {\\n // Only allow to remove an owner, if threshold can still be reached.\\n require(ownerCount - 1 >= _threshold, \\\"New owner count needs to be larger than new threshold\\\");\\n // Validate owner address and check that it corresponds to owner index.\\n require(owner != address(0) && owner != SENTINEL_OWNERS, \\\"GS203\\\");\\n require(owners[prevOwner] == owner, \\\"GS205\\\");\\n owners[prevOwner] = owners[owner];\\n owners[owner] = address(0);\\n ownerCount--;\\n emit RemovedOwner(owner);\\n // Change threshold if threshold was changed.\\n if (threshold != _threshold)\\n changeThreshold(_threshold);\\n }\\n\\n /// @dev Allows to swap/replace an owner from the Safe with another address.\\n /// This can only be done via a Safe transaction.\\n /// @notice Replaces the owner `oldOwner` in the Safe with `newOwner`.\\n /// @param prevOwner Owner that pointed to the owner to be replaced in the linked list\\n /// @param oldOwner Owner address to be replaced.\\n /// @param newOwner New owner address.\\n function swapOwner(address prevOwner, address oldOwner, address newOwner)\\n public\\n authorized\\n {\\n // Owner address cannot be null.\\n require(newOwner != address(0) && newOwner != SENTINEL_OWNERS, \\\"GS203\\\");\\n // No duplicate owners allowed.\\n require(owners[newOwner] == address(0), \\\"GS204\\\");\\n // Validate oldOwner address and check that it corresponds to owner index.\\n require(oldOwner != address(0) && oldOwner != SENTINEL_OWNERS, \\\"GS203\\\");\\n require(owners[prevOwner] == oldOwner, \\\"GS205\\\");\\n owners[newOwner] = owners[oldOwner];\\n owners[prevOwner] = newOwner;\\n owners[oldOwner] = address(0);\\n emit RemovedOwner(oldOwner);\\n emit AddedOwner(newOwner);\\n }\\n\\n /// @dev Allows to update the number of required confirmations by Safe owners.\\n /// This can only be done via a Safe transaction.\\n /// @notice Changes the threshold of the Safe to `_threshold`.\\n /// @param _threshold New threshold.\\n function changeThreshold(uint256 _threshold)\\n public\\n authorized\\n {\\n // Validate that threshold is smaller than number of owners.\\n require(_threshold <= ownerCount, \\\"GS201\\\");\\n // There has to be at least one Safe owner.\\n require(_threshold >= 1, \\\"GS202\\\");\\n threshold = _threshold;\\n emit ChangedThreshold(threshold);\\n }\\n\\n function getThreshold()\\n public\\n view\\n returns (uint256)\\n {\\n return threshold;\\n }\\n\\n function isOwner(address owner)\\n public\\n view\\n returns (bool)\\n {\\n return owner != SENTINEL_OWNERS && owners[owner] != address(0);\\n }\\n\\n /// @dev Returns array of owners.\\n /// @return Array of Safe owners.\\n function getOwners()\\n public\\n view\\n returns (address[] memory)\\n {\\n address[] memory array = new address[](ownerCount);\\n\\n // populate return array\\n uint256 index = 0;\\n address currentOwner = owners[SENTINEL_OWNERS];\\n while(currentOwner != SENTINEL_OWNERS) {\\n array[index] = currentOwner;\\n currentOwner = owners[currentOwner];\\n index ++;\\n }\\n return array;\\n }\\n}\\n\",\"keccak256\":\"0xf1f1a07407270de1dd20679a91e2d562b9cdef714fb88ee1b0132558a3837853\"},\"contracts/common/Enum.sol\":{\"content\":\"// SPDX-License-Identifier: LGPL-3.0-only pragma solidity >=0.7.0 <0.9.0;\\n\\n\\n/// @title Enum - Collection of enums\\n/// @author Richard Meissner - \\ncontract Enum {\\n enum Operation {\\n Call,\\n DelegateCall\\n }\\n}\\n\",\"keccak256\":\"0x0c8238de688ccbdd5d936d6aed09f92c9f302f538fbbc2e507d10e7d8d385c06\"},\"contracts/common/MasterCopy.sol\":{\"content\":\"// SPDX-License-Identifier: LGPL-3.0-only pragma solidity >=0.7.0 <0.9.0;\\nimport \\\"./SelfAuthorized.sol\\\";\\n\\n\\n/// @title MasterCopy - Base for master copy contracts (should always be first super contract)\\n/// This contract is tightly coupled to our proxy contract (see `proxies/GnosisSafeProxy.sol`)\\n/// @author Richard Meissner - \\ncontract MasterCopy is SelfAuthorized {\\n\\n event ChangedMasterCopy(address masterCopy);\\n\\n // masterCopy always needs to be first declared variable, to ensure that it is at the same location as in the Proxy contract.\\n // It should also always be ensured that the address is stored alone (uses a full word)\\n address private masterCopy;\\n\\n /// @dev Allows to upgrade the contract. This can only be done via a Safe transaction.\\n /// @param _masterCopy New contract address.\\n function changeMasterCopy(address _masterCopy)\\n public\\n authorized\\n {\\n // Master copy address cannot be null.\\n require(_masterCopy != address(0), \\\"Invalid master copy address provided\\\");\\n masterCopy = _masterCopy;\\n emit ChangedMasterCopy(_masterCopy);\\n }\\n}\\n\",\"keccak256\":\"0xba0a7cc50f3bca7e96cddb7b758ffbc907400ccc264cc0464ce922fdada45d06\"},\"contracts/common/SecuredTokenTransfer.sol\":{\"content\":\"// SPDX-License-Identifier: LGPL-3.0-only pragma solidity >=0.7.0 <0.9.0;\\n\\n\\n/// @title SecuredTokenTransfer - Secure token transfer\\n/// @author Richard Meissner - \\ncontract SecuredTokenTransfer {\\n\\n /// @dev Transfers a token and returns if it was a success\\n /// @param token Token that should be transferred\\n /// @param receiver Receiver to whom the token should be transferred\\n /// @param amount The amount of tokens that should be transferred\\n function transferToken (\\n address token,\\n address receiver,\\n uint256 amount\\n )\\n internal\\n returns (bool transferred)\\n {\\n bytes memory data = abi.encodeWithSignature(\\\"transfer(address,uint256)\\\", receiver, amount);\\n // solium-disable-next-line security/no-inline-assembly\\n assembly {\\n let success := call(sub(gas, 10000), token, 0, add(data, 0x20), mload(data), 0, 0)\\n let ptr := mload(0x40)\\n mstore(0x40, add(ptr, returndatasize()))\\n returndatacopy(ptr, 0, returndatasize())\\n switch returndatasize()\\n case 0 { transferred := success }\\n case 0x20 { transferred := iszero(or(iszero(success), iszero(mload(ptr)))) }\\n default { transferred := 0 }\\n }\\n }\\n}\\n\",\"keccak256\":\"0x9ad9ce6bbac4650c08b5f15cd65980c306f9e9525b8a85ff2e47a143e99a5e2f\"},\"contracts/common/SelfAuthorized.sol\":{\"content\":\"// SPDX-License-Identifier: LGPL-3.0-only -pragma solidity >=0.7.0 <0.9.0;\\n\\n\\n/// @title SelfAuthorized - authorizes current contract to perform actions\\n/// @author Richard Meissner - \\ncontract SelfAuthorized {\\n modifier requireSelfCall() {\\n require(msg.sender == address(this), \\\"Method can only be called from this contract\\\");\\n _;\\n }\\n}\\n\",\"keccak256\":\"0x9bb332fbb392be18eaed643a7d4de906134d8dcc1e1789ffc225f12a59ca82cc\"},\"contracts/common/SignatureDecoder.sol\":{\"content\":\"// SPDX-License-Identifier: LGPL-3.0-only +pragma solidity >=0.7.0 <0.9.0;\\n\\n\\n/// @title SelfAuthorized - authorizes current contract to perform actions\\n/// @author Richard Meissner - \\ncontract SelfAuthorized {\\n modifier requireSelfCall() {\\n require(msg.sender == address(this), \\\"GS031\\\");\\n _;\\n }\\n}\\n\",\"keccak256\":\"0x9bb332fbb392be18eaed643a7d4de906134d8dcc1e1789ffc225f12a59ca82cc\"},\"contracts/common/SignatureDecoder.sol\":{\"content\":\"// SPDX-License-Identifier: LGPL-3.0-only pragma solidity >=0.7.0 <0.9.0;\\n\\n\\n/// @title SignatureDecoder - Decodes signatures that a encoded as bytes\\n/// @author Ricardo Guilherme Schmidt (Status Research & Development GmbH)\\n/// @author Richard Meissner - \\ncontract SignatureDecoder {\\n\\n /// @dev divides bytes signature into `uint8 v, bytes32 r, bytes32 s`.\\n /// @notice Make sure to peform a bounds check for @param pos, to avoid out of bounds access on @param signatures\\n /// @param pos which signature to read. A prior bounds check of this parameter should be performed, to avoid out of bounds access\\n /// @param signatures concatenated rsv signatures\\n function signatureSplit(bytes memory signatures, uint256 pos)\\n internal\\n pure\\n returns (uint8 v, bytes32 r, bytes32 s)\\n {\\n // The signature format is a compact form of:\\n // {bytes32 r}{bytes32 s}{uint8 v}\\n // Compact means, uint8 is not padded to 32 bytes.\\n // solium-disable-next-line security/no-inline-assembly\\n assembly {\\n let signaturePos := mul(0x41, pos)\\n r := mload(add(signatures, add(signaturePos, 0x20)))\\n s := mload(add(signatures, add(signaturePos, 0x40)))\\n // Here we are loading the last 32 bytes, including 31 bytes\\n // of 's'. There is no 'mload8' to do this.\\n //\\n // 'byte' is not working due to the Solidity parser, so lets\\n // use the second best option, 'and'\\n v := and(mload(add(signatures, add(signaturePos, 0x41))), 0xff)\\n }\\n }\\n}\\n\",\"keccak256\":\"0xfe4ec85bf931b33b52b42f7eceede3500d61ffa1eccfafcc6918639a052114f3\"},\"contracts/external/GnosisSafeMath.sol\":{\"content\":\"// SPDX-License-Identifier: LGPL-3.0-only pragma solidity >=0.7.0 <0.9.0;\\n\\n/**\\n * @title GnosisSafeMath\\n * @dev Math operations with safety checks that revert on error\\n * Renamed from SafeMath to GnosisSafeMath to avoid conflicts\\n * TODO: remove once open zeppelin update to solc 0.5.0\\n */\\nlibrary GnosisSafeMath {\\n\\n /**\\n * @dev Multiplies two numbers, reverts on overflow.\\n */\\n function mul(uint256 a, uint256 b) internal pure returns (uint256) {\\n // Gas optimization: this is cheaper than requiring 'a' not being zero, but the\\n // benefit is lost if 'b' is also tested.\\n // See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522\\n if (a == 0) {\\n return 0;\\n }\\n\\n uint256 c = a * b;\\n require(c / a == b);\\n\\n return c;\\n }\\n\\n /**\\n * @dev Subtracts two numbers, reverts on overflow (i.e. if subtrahend is greater than minuend).\\n */\\n function sub(uint256 a, uint256 b) internal pure returns (uint256) {\\n require(b <= a);\\n uint256 c = a - b;\\n\\n return c;\\n }\\n\\n /**\\n * @dev Adds two numbers, reverts on overflow.\\n */\\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\\n uint256 c = a + b;\\n require(c >= a);\\n\\n return c;\\n }\\n\\n\\n /**\\n * @dev Returns the largest of two numbers.\\n */\\n function max(uint256 a, uint256 b) internal pure returns (uint256) {\\n return a >= b ? a : b;\\n }\\n}\",\"keccak256\":\"0xfaaf0db0c77394968547612e6907b5259d4fb69959181f3c2468240466b35b8c\"},\"contracts/interfaces/ISignatureValidator.sol\":{\"content\":\"// SPDX-License-Identifier: LGPL-3.0-only pragma solidity >=0.7.0 <0.9.0;\\n\\ncontract ISignatureValidatorConstants {\\n // bytes4(keccak256(\\\"isValidSignature(bytes,bytes)\\\")\\n bytes4 constant internal EIP1271_MAGIC_VALUE = 0x20c13b0b;\\n}\\n\\ncontract ISignatureValidator is ISignatureValidatorConstants {\\n\\n /**\\n * @dev Should return whether the signature provided is valid for the provided data\\n * @param _data Arbitrary length data signed on the behalf of address(this)\\n * @param _signature Signature byte array associated with _data\\n *\\n * MUST return the bytes4 magic value 0x20c13b0b when function passes.\\n * MUST NOT modify state (using STATICCALL for solc < 0.5, view modifier for solc > 0.5)\\n * MUST allow external calls\\n */\\n function isValidSignature(\\n bytes memory _data,\\n bytes memory _signature)\\n public\\n view\\n returns (bytes4);\\n}\",\"keccak256\":\"0x70f1e830299ef161681a557b332b058d58c1faa32ff59faf11a73b28773332fe\"}},\"version\":1}", diff --git a/deployments/rinkeby/solcInputs/e13af873df760e6463a87a0cc0932f40.json b/deployments/rinkeby/solcInputs/e13af873df760e6463a87a0cc0932f40.json index a4c753f7a..c3edc41d2 100644 --- a/deployments/rinkeby/solcInputs/e13af873df760e6463a87a0cc0932f40.json +++ b/deployments/rinkeby/solcInputs/e13af873df760e6463a87a0cc0932f40.json @@ -11,19 +11,19 @@ pragma solidity >=0.7.0 <0.9.0;\n\n\n/// @title Enum - Collection of enums\n/// }, "contracts/base/ModuleManager.sol": { "content": "// SPDX-License-Identifier: LGPL-3.0-only -pragma solidity >=0.7.0 <0.9.0;\nimport \"../common/Enum.sol\";\nimport \"../common/SelfAuthorized.sol\";\nimport \"./Executor.sol\";\n\n\n/// @title Module Manager - A contract that manages modules that can execute transactions via this contract\n/// @author Stefan George - \n/// @author Richard Meissner - \ncontract ModuleManager is SelfAuthorized, Executor {\n\n event EnabledModule(address module);\n event DisabledModule(address module);\n event ExecutionFromModuleSuccess(address indexed module);\n event ExecutionFromModuleFailure(address indexed module);\n\n address internal constant SENTINEL_MODULES = address(0x1);\n\n mapping (address => address) internal modules;\n\n function setupModules(address to, bytes memory data)\n internal\n {\n require(modules[SENTINEL_MODULES] == address(0), \"Modules have already been initialized\");\n modules[SENTINEL_MODULES] = SENTINEL_MODULES;\n if (to != address(0))\n // Setup has to complete successfully or transaction fails.\n require(executeDelegateCall(to, data, gasleft()), \"Could not finish initialization\");\n }\n\n /// @dev Allows to add a module to the whitelist.\n /// This can only be done via a Safe transaction.\n /// @notice Enables the module `module` for the Safe.\n /// @param module Module to be whitelisted.\n function enableModule(address module)\n public\n authorized\n {\n // Module address cannot be null or sentinel.\n require(module != address(0) && module != SENTINEL_MODULES, \"Invalid module address provided\");\n // Module cannot be added twice.\n require(modules[module] == address(0), \"Module has already been added\");\n modules[module] = modules[SENTINEL_MODULES];\n modules[SENTINEL_MODULES] = module;\n emit EnabledModule(module);\n }\n\n /// @dev Allows to remove a module from the whitelist.\n /// This can only be done via a Safe transaction.\n /// @notice Disables the module `module` for the Safe.\n /// @param prevModule Module that pointed to the module to be removed in the linked list\n /// @param module Module to be removed.\n function disableModule(address prevModule, address module)\n public\n authorized\n {\n // Validate module address and check that it corresponds to module index.\n require(module != address(0) && module != SENTINEL_MODULES, \"Invalid module address provided\");\n require(modules[prevModule] == module, \"Invalid prevModule, module pair provided\");\n modules[prevModule] = modules[module];\n modules[module] = address(0);\n emit DisabledModule(module);\n }\n\n /// @dev Allows a Module to execute a Safe transaction without any further confirmations.\n /// @param to Destination address of module transaction.\n /// @param value Ether value of module transaction.\n /// @param data Data payload of module transaction.\n /// @param operation Operation type of module transaction.\n function execTransactionFromModule(address to, uint256 value, bytes memory data, Enum.Operation operation)\n public\n returns (bool success)\n {\n // Only whitelisted modules are allowed.\n require(msg.sender != SENTINEL_MODULES && modules[msg.sender] != address(0), \"Method can only be called from an enabled module\");\n // Execute transaction without further confirmations.\n success = execute(to, value, data, operation, gasleft());\n if (success) emit ExecutionFromModuleSuccess(msg.sender);\n else emit ExecutionFromModuleFailure(msg.sender);\n }\n\n /// @dev Allows a Module to execute a Safe transaction without any further confirmations and return data\n /// @param to Destination address of module transaction.\n /// @param value Ether value of module transaction.\n /// @param data Data payload of module transaction.\n /// @param operation Operation type of module transaction.\n function execTransactionFromModuleReturnData(address to, uint256 value, bytes memory data, Enum.Operation operation)\n public\n returns (bool success, bytes memory returnData)\n {\n success = execTransactionFromModule(to, value, data, operation);\n // solium-disable-next-line security/no-inline-assembly\n assembly {\n // Load free memory location\n let ptr := mload(0x40)\n // We allocate memory for the return data by setting the free memory location to\n // current free memory location + data size + 32 bytes for data size value\n mstore(0x40, add(ptr, add(returndatasize(), 0x20)))\n // Store the size\n mstore(ptr, returndatasize())\n // Store the data\n returndatacopy(add(ptr, 0x20), 0, returndatasize())\n // Point the return data to the correct memory location\n returnData := ptr\n }\n }\n\n /// @dev Returns if an module is enabled\n /// @return True if the module is enabled\n function isModuleEnabled(address module)\n public\n view\n returns (bool)\n {\n return SENTINEL_MODULES != module && modules[module] != address(0);\n }\n\n /// @dev Returns array of first 10 modules.\n /// @return Array of modules.\n function getModules()\n public\n view\n returns (address[] memory)\n {\n (address[] memory array,) = getModulesPaginated(SENTINEL_MODULES, 10);\n return array;\n }\n\n /// @dev Returns array of modules.\n /// @param start Start of the page.\n /// @param pageSize Maximum number of modules that should be returned.\n /// @return Array of modules.\n function getModulesPaginated(address start, uint256 pageSize)\n public\n view\n returns (address[] memory array, address next)\n {\n // Init array with max page size\n array = new address[](pageSize);\n\n // Populate return array\n uint256 moduleCount = 0;\n address currentModule = modules[start];\n while(currentModule != address(0x0) && currentModule != SENTINEL_MODULES && moduleCount < pageSize) {\n array[moduleCount] = currentModule;\n currentModule = modules[currentModule];\n moduleCount++;\n }\n next = currentModule;\n // Set correct size of returned array\n // solium-disable-next-line security/no-inline-assembly\n assembly {\n mstore(array, moduleCount)\n }\n }\n}\n" +pragma solidity >=0.7.0 <0.9.0;\nimport \"../common/Enum.sol\";\nimport \"../common/SelfAuthorized.sol\";\nimport \"./Executor.sol\";\n\n\n/// @title Module Manager - A contract that manages modules that can execute transactions via this contract\n/// @author Stefan George - \n/// @author Richard Meissner - \ncontract ModuleManager is SelfAuthorized, Executor {\n\n event EnabledModule(address module);\n event DisabledModule(address module);\n event ExecutionFromModuleSuccess(address indexed module);\n event ExecutionFromModuleFailure(address indexed module);\n\n address internal constant SENTINEL_MODULES = address(0x1);\n\n mapping (address => address) internal modules;\n\n function setupModules(address to, bytes memory data)\n internal\n {\n require(modules[SENTINEL_MODULES] == address(0), \"GS100\");\n modules[SENTINEL_MODULES] = SENTINEL_MODULES;\n if (to != address(0))\n // Setup has to complete successfully or transaction fails.\n require(executeDelegateCall(to, data, gasleft()), \"Could not finish initialization\");\n }\n\n /// @dev Allows to add a module to the whitelist.\n /// This can only be done via a Safe transaction.\n /// @notice Enables the module `module` for the Safe.\n /// @param module Module to be whitelisted.\n function enableModule(address module)\n public\n authorized\n {\n // Module address cannot be null or sentinel.\n require(module != address(0) && module != SENTINEL_MODULES, \"GS101\");\n // Module cannot be added twice.\n require(modules[module] == address(0), \"GS102\");\n modules[module] = modules[SENTINEL_MODULES];\n modules[SENTINEL_MODULES] = module;\n emit EnabledModule(module);\n }\n\n /// @dev Allows to remove a module from the whitelist.\n /// This can only be done via a Safe transaction.\n /// @notice Disables the module `module` for the Safe.\n /// @param prevModule Module that pointed to the module to be removed in the linked list\n /// @param module Module to be removed.\n function disableModule(address prevModule, address module)\n public\n authorized\n {\n // Validate module address and check that it corresponds to module index.\n require(module != address(0) && module != SENTINEL_MODULES, \"GS101\");\n require(modules[prevModule] == module, \"GS103\");\n modules[prevModule] = modules[module];\n modules[module] = address(0);\n emit DisabledModule(module);\n }\n\n /// @dev Allows a Module to execute a Safe transaction without any further confirmations.\n /// @param to Destination address of module transaction.\n /// @param value Ether value of module transaction.\n /// @param data Data payload of module transaction.\n /// @param operation Operation type of module transaction.\n function execTransactionFromModule(address to, uint256 value, bytes memory data, Enum.Operation operation)\n public\n returns (bool success)\n {\n // Only whitelisted modules are allowed.\n require(msg.sender != SENTINEL_MODULES && modules[msg.sender] != address(0), \"GS104\");\n // Execute transaction without further confirmations.\n success = execute(to, value, data, operation, gasleft());\n if (success) emit ExecutionFromModuleSuccess(msg.sender);\n else emit ExecutionFromModuleFailure(msg.sender);\n }\n\n /// @dev Allows a Module to execute a Safe transaction without any further confirmations and return data\n /// @param to Destination address of module transaction.\n /// @param value Ether value of module transaction.\n /// @param data Data payload of module transaction.\n /// @param operation Operation type of module transaction.\n function execTransactionFromModuleReturnData(address to, uint256 value, bytes memory data, Enum.Operation operation)\n public\n returns (bool success, bytes memory returnData)\n {\n success = execTransactionFromModule(to, value, data, operation);\n // solium-disable-next-line security/no-inline-assembly\n assembly {\n // Load free memory location\n let ptr := mload(0x40)\n // We allocate memory for the return data by setting the free memory location to\n // current free memory location + data size + 32 bytes for data size value\n mstore(0x40, add(ptr, add(returndatasize(), 0x20)))\n // Store the size\n mstore(ptr, returndatasize())\n // Store the data\n returndatacopy(add(ptr, 0x20), 0, returndatasize())\n // Point the return data to the correct memory location\n returnData := ptr\n }\n }\n\n /// @dev Returns if an module is enabled\n /// @return True if the module is enabled\n function isModuleEnabled(address module)\n public\n view\n returns (bool)\n {\n return SENTINEL_MODULES != module && modules[module] != address(0);\n }\n\n /// @dev Returns array of first 10 modules.\n /// @return Array of modules.\n function getModules()\n public\n view\n returns (address[] memory)\n {\n (address[] memory array,) = getModulesPaginated(SENTINEL_MODULES, 10);\n return array;\n }\n\n /// @dev Returns array of modules.\n /// @param start Start of the page.\n /// @param pageSize Maximum number of modules that should be returned.\n /// @return Array of modules.\n function getModulesPaginated(address start, uint256 pageSize)\n public\n view\n returns (address[] memory array, address next)\n {\n // Init array with max page size\n array = new address[](pageSize);\n\n // Populate return array\n uint256 moduleCount = 0;\n address currentModule = modules[start];\n while(currentModule != address(0x0) && currentModule != SENTINEL_MODULES && moduleCount < pageSize) {\n array[moduleCount] = currentModule;\n currentModule = modules[currentModule];\n moduleCount++;\n }\n next = currentModule;\n // Set correct size of returned array\n // solium-disable-next-line security/no-inline-assembly\n assembly {\n mstore(array, moduleCount)\n }\n }\n}\n" }, "contracts/common/SelfAuthorized.sol": { "content": "// SPDX-License-Identifier: LGPL-3.0-only -pragma solidity >=0.7.0 <0.9.0;\n\n\n/// @title SelfAuthorized - authorizes current contract to perform actions\n/// @author Richard Meissner - \ncontract SelfAuthorized {\n modifier requireSelfCall() {\n require(msg.sender == address(this), \"Method can only be called from this contract\");\n _;\n }\n}\n" +pragma solidity >=0.7.0 <0.9.0;\n\n\n/// @title SelfAuthorized - authorizes current contract to perform actions\n/// @author Richard Meissner - \ncontract SelfAuthorized {\n modifier requireSelfCall() {\n require(msg.sender == address(this), \"GS031\");\n _;\n }\n}\n" }, "contracts/GnosisSafe.sol": { "content": "// SPDX-License-Identifier: LGPL-3.0-only -pragma solidity >=0.7.0 <0.9.0;\nimport \"./base/ModuleManager.sol\";\nimport \"./base/OwnerManager.sol\";\nimport \"./base/FallbackManager.sol\";\nimport \"./common/MasterCopy.sol\";\nimport \"./common/SignatureDecoder.sol\";\nimport \"./common/SecuredTokenTransfer.sol\";\nimport \"./interfaces/ISignatureValidator.sol\";\nimport \"./external/GnosisSafeMath.sol\";\n\n/// @title Gnosis Safe - A multisignature wallet with support for confirmations using signed messages based on ERC191.\n/// @author Stefan George - \n/// @author Richard Meissner - \n/// @author Ricardo Guilherme Schmidt - (Status Research & Development GmbH) - Gas Token Payment\ncontract GnosisSafe\n is MasterCopy, ModuleManager, OwnerManager, SignatureDecoder, SecuredTokenTransfer, ISignatureValidatorConstants, FallbackManager {\n\n using GnosisSafeMath for uint256;\n\n string public constant NAME = \"Gnosis Safe\";\n string public constant VERSION = \"1.2.0\";\n\n //keccak256(\n // \"EIP712Domain(address verifyingContract)\"\n //);\n bytes32 private constant DOMAIN_SEPARATOR_TYPEHASH = 0x035aff83d86937d35b32e04f0ddc6ff469290eef2f1b692d8a815c89404d4749;\n\n //keccak256(\n // \"SafeTx(address to,uint256 value,bytes data,uint8 operation,uint256 safeTxGas,uint256 baseGas,uint256 gasPrice,address gasToken,address refundReceiver,uint256 nonce)\"\n //);\n bytes32 private constant SAFE_TX_TYPEHASH = 0xbb8310d486368db6bd6f849402fdd73ad53d316b5a4b2644ad6efe0f941286d8;\n\n //keccak256(\n // \"SafeMessage(bytes message)\"\n //);\n bytes32 private constant SAFE_MSG_TYPEHASH = 0x60b3cbf8b4a223d68d641b3b6ddf9a298e7f33710cf3d3a9d1146b5a6150fbca;\n\n event ApproveHash(\n bytes32 indexed approvedHash,\n address indexed owner\n );\n event SignMsg(\n bytes32 indexed msgHash\n );\n event ExecutionFailure(\n bytes32 txHash, uint256 payment\n );\n event ExecutionSuccess(\n bytes32 txHash, uint256 payment\n );\n\n uint256 public nonce;\n bytes32 public domainSeparator;\n // Mapping to keep track of all message hashes that have been approve by ALL REQUIRED owners\n mapping(bytes32 => uint256) public signedMessages;\n // Mapping to keep track of all hashes (message or transaction) that have been approve by ANY owners\n mapping(address => mapping(bytes32 => uint256)) public approvedHashes;\n\n // This constructor ensures that this contract can only be used as a master copy for Proxy contracts\n constructor() public {\n // By setting the threshold it is not possible to call setup anymore,\n // so we create a Safe with 0 owners and threshold 1.\n // This is an unusable Safe, perfect for the mastercopy\n threshold = 1;\n }\n\n /// @dev Setup function sets initial storage of contract.\n /// @param _owners List of Safe owners.\n /// @param _threshold Number of required confirmations for a Safe transaction.\n /// @param to Contract address for optional delegate call.\n /// @param data Data payload for optional delegate call.\n /// @param fallbackHandler Handler for fallback calls to this contract\n /// @param paymentToken Token that should be used for the payment (0 is ETH)\n /// @param payment Value that should be paid\n /// @param paymentReceiver Adddress that should receive the payment (or 0 if tx.origin)\n function setup(\n address[] calldata _owners,\n uint256 _threshold,\n address to,\n bytes calldata data,\n address fallbackHandler,\n address paymentToken,\n uint256 payment,\n address payable paymentReceiver\n )\n external\n {\n require(domainSeparator == 0, \"Domain Separator already set!\");\n domainSeparator = keccak256(abi.encode(DOMAIN_SEPARATOR_TYPEHASH, this));\n setupOwners(_owners, _threshold);\n if (fallbackHandler != address(0)) internalSetFallbackHandler(fallbackHandler);\n // As setupOwners can only be called if the contract has not been initialized we don't need a check for setupModules\n setupModules(to, data);\n\n if (payment > 0) {\n // To avoid running into issues with EIP-170 we reuse the handlePayment function (to avoid adjusting code of that has been verified we do not adjust the method itself)\n // baseGas = 0, gasPrice = 1 and gas = payment => amount = (payment + 0) * 1 = payment\n handlePayment(payment, 0, 1, paymentToken, paymentReceiver);\n }\n }\n\n /// @dev Allows to execute a Safe transaction confirmed by required number of owners and then pays the account that submitted the transaction.\n /// Note: The fees are always transfered, even if the user transaction fails.\n /// @param to Destination address of Safe transaction.\n /// @param value Ether value of Safe transaction.\n /// @param data Data payload of Safe transaction.\n /// @param operation Operation type of Safe transaction.\n /// @param safeTxGas Gas that should be used for the Safe transaction.\n /// @param baseGas Gas costs that are independent of the transaction execution(e.g. base transaction fee, signature check, payment of the refund)\n /// @param gasPrice Gas price that should be used for the payment calculation.\n /// @param gasToken Token address (or 0 if ETH) that is used for the payment.\n /// @param refundReceiver Address of receiver of gas payment (or 0 if tx.origin).\n /// @param signatures Packed signature data ({bytes32 r}{bytes32 s}{uint8 v})\n function execTransaction(\n address to,\n uint256 value,\n bytes calldata data,\n Enum.Operation operation,\n uint256 safeTxGas,\n uint256 baseGas,\n uint256 gasPrice,\n address gasToken,\n address payable refundReceiver,\n bytes calldata signatures\n )\n external\n payable\n returns (bool success)\n {\n bytes32 txHash;\n // Use scope here to limit variable lifetime and prevent `stack too deep` errors\n {\n bytes memory txHashData = encodeTransactionData(\n to, value, data, operation, // Transaction info\n safeTxGas, baseGas, gasPrice, gasToken, refundReceiver, // Payment info\n nonce\n );\n // Increase nonce and execute transaction.\n nonce++;\n txHash = keccak256(txHashData);\n checkSignatures(txHash, txHashData, signatures, true);\n }\n // We require some gas to emit the events (at least 2500) after the execution and some to perform code until the execution (500)\n // We also include the 1/64 in the check that is not send along with a call to counteract potential shortings because of EIP-150\n require(gasleft() >= (safeTxGas * 64 / 63).max(safeTxGas + 2500) + 500, \"Not enough gas to execute safe transaction\");\n // Use scope here to limit variable lifetime and prevent `stack too deep` errors\n {\n uint256 gasUsed = gasleft();\n // If the gasPrice is 0 we assume that nearly all available gas can be used (it is always more than safeTxGas)\n // We only substract 2500 (compared to the 3000 before) to ensure that the amount passed is still higher than safeTxGas\n success = execute(to, value, data, operation, gasPrice == 0 ? (gasleft() - 2500) : safeTxGas);\n gasUsed = gasUsed.sub(gasleft());\n // We transfer the calculated tx costs to the tx.origin to avoid sending it to intermediate contracts that have made calls\n uint256 payment = 0;\n if (gasPrice > 0) {\n payment = handlePayment(gasUsed, baseGas, gasPrice, gasToken, refundReceiver);\n }\n if (success) emit ExecutionSuccess(txHash, payment);\n else emit ExecutionFailure(txHash, payment);\n }\n }\n\n function handlePayment(\n uint256 gasUsed,\n uint256 baseGas,\n uint256 gasPrice,\n address gasToken,\n address payable refundReceiver\n )\n private\n returns (uint256 payment)\n {\n // solium-disable-next-line security/no-tx-origin\n address payable receiver = refundReceiver == address(0) ? tx.origin : refundReceiver;\n if (gasToken == address(0)) {\n // For ETH we will only adjust the gas price to not be higher than the actual used gas price\n payment = gasUsed.add(baseGas).mul(gasPrice < tx.gasprice ? gasPrice : tx.gasprice);\n // solium-disable-next-line security/no-send\n require(receiver.send(payment), \"Could not pay gas costs with ether\");\n } else {\n payment = gasUsed.add(baseGas).mul(gasPrice);\n require(transferToken(gasToken, receiver, payment), \"Could not pay gas costs with token\");\n }\n }\n\n /**\n * @dev Checks whether the signature provided is valid for the provided data, hash. Will revert otherwise.\n * @param dataHash Hash of the data (could be either a message hash or transaction hash)\n * @param data That should be signed (this is passed to an external validator contract)\n * @param signatures Signature data that should be verified. Can be ECDSA signature, contract signature (EIP-1271) or approved hash.\n * @param consumeHash Indicates that in case of an approved hash the storage can be freed to save gas\n */\n function checkSignatures(bytes32 dataHash, bytes memory data, bytes memory signatures, bool consumeHash)\n internal\n {\n // Load threshold to avoid multiple storage loads\n uint256 _threshold = threshold;\n // Check that a threshold is set\n require(_threshold > 0, \"Threshold needs to be defined!\");\n // Check that the provided signature data is not too short\n require(signatures.length >= _threshold.mul(65), \"Signatures data too short\");\n // There cannot be an owner with address 0.\n address lastOwner = address(0);\n address currentOwner;\n uint8 v;\n bytes32 r;\n bytes32 s;\n uint256 i;\n for (i = 0; i < _threshold; i++) {\n (v, r, s) = signatureSplit(signatures, i);\n // If v is 0 then it is a contract signature\n if (v == 0) {\n // When handling contract signatures the address of the contract is encoded into r\n currentOwner = address(uint256(r));\n\n // Check that signature data pointer (s) is not pointing inside the static part of the signatures bytes\n // This check is not completely accurate, since it is possible that more signatures than the threshold are send.\n // Here we only check that the pointer is not pointing inside the part that is being processed\n require(uint256(s) >= _threshold.mul(65), \"Invalid contract signature location: inside static part\");\n\n // Check that signature data pointer (s) is in bounds (points to the length of data -> 32 bytes)\n require(uint256(s).add(32) <= signatures.length, \"Invalid contract signature location: length not present\");\n\n // Check if the contract signature is in bounds: start of data is s + 32 and end is start + signature length\n uint256 contractSignatureLen;\n // solium-disable-next-line security/no-inline-assembly\n assembly {\n contractSignatureLen := mload(add(add(signatures, s), 0x20))\n }\n require(uint256(s).add(32).add(contractSignatureLen) <= signatures.length, \"Invalid contract signature location: data not complete\");\n\n // Check signature\n bytes memory contractSignature;\n // solium-disable-next-line security/no-inline-assembly\n assembly {\n // The signature data for contract signatures is appended to the concatenated signatures and the offset is stored in s\n contractSignature := add(add(signatures, s), 0x20)\n }\n require(ISignatureValidator(currentOwner).isValidSignature(data, contractSignature) == EIP1271_MAGIC_VALUE, \"Invalid contract signature provided\");\n // If v is 1 then it is an approved hash\n } else if (v == 1) {\n // When handling approved hashes the address of the approver is encoded into r\n currentOwner = address(uint256(r));\n // Hashes are automatically approved by the sender of the message or when they have been pre-approved via a separate transaction\n require(msg.sender == currentOwner || approvedHashes[currentOwner][dataHash] != 0, \"Hash has not been approved\");\n // Hash has been marked for consumption. If this hash was pre-approved free storage\n if (consumeHash && msg.sender != currentOwner) {\n approvedHashes[currentOwner][dataHash] = 0;\n }\n } else if (v > 30) {\n // To support eth_sign and similar we adjust v and hash the messageHash with the Ethereum message prefix before applying ecrecover\n currentOwner = ecrecover(keccak256(abi.encodePacked(\"\\x19Ethereum Signed Message:\\n32\", dataHash)), v - 4, r, s);\n } else {\n // Use ecrecover with the messageHash for EOA signatures\n currentOwner = ecrecover(dataHash, v, r, s);\n }\n require (\n currentOwner > lastOwner && owners[currentOwner] != address(0) && currentOwner != SENTINEL_OWNERS,\n \"Invalid owner provided\"\n );\n lastOwner = currentOwner;\n }\n }\n\n /// @dev Allows to estimate a Safe transaction.\n /// This method is only meant for estimation purpose, therefore two different protection mechanism against execution in a transaction have been made:\n /// 1.) The method can only be called from the safe itself\n /// 2.) The response is returned with a revert\n /// When estimating set `from` to the address of the safe.\n /// Since the `estimateGas` function includes refunds, call this method to get an estimated of the costs that are deducted from the safe with `execTransaction`\n /// @param to Destination address of Safe transaction.\n /// @param value Ether value of Safe transaction.\n /// @param data Data payload of Safe transaction.\n /// @param operation Operation type of Safe transaction.\n /// @return Estimate without refunds and overhead fees (base transaction and payload data gas costs).\n function requiredTxGas(address to, uint256 value, bytes calldata data, Enum.Operation operation)\n external\n authorized\n returns (uint256)\n {\n uint256 startGas = gasleft();\n // We don't provide an error message here, as we use it to return the estimate\n // solium-disable-next-line error-reason\n require(execute(to, value, data, operation, gasleft()));\n uint256 requiredGas = startGas - gasleft();\n // Convert response to string and return via error message\n revert(string(abi.encodePacked(requiredGas)));\n }\n\n /**\n * @dev Marks a hash as approved. This can be used to validate a hash that is used by a signature.\n * @param hashToApprove The hash that should be marked as approved for signatures that are verified by this contract.\n */\n function approveHash(bytes32 hashToApprove)\n external\n {\n require(owners[msg.sender] != address(0), \"Only owners can approve a hash\");\n approvedHashes[msg.sender][hashToApprove] = 1;\n emit ApproveHash(hashToApprove, msg.sender);\n }\n\n /**\n * @dev Marks a message as signed, so that it can be used with EIP-1271\n * @notice Marks a message (`_data`) as signed.\n * @param _data Arbitrary length data that should be marked as signed on the behalf of address(this)\n */\n function signMessage(bytes calldata _data)\n external\n authorized\n {\n bytes32 msgHash = getMessageHash(_data);\n signedMessages[msgHash] = 1;\n emit SignMsg(msgHash);\n }\n\n /**\n * Implementation of ISignatureValidator (see `interfaces/ISignatureValidator.sol`)\n * @dev Should return whether the signature provided is valid for the provided data.\n * The save does not implement the interface since `checkSignatures` is not a view method.\n * The method will not perform any state changes (see parameters of `checkSignatures`)\n * @param _data Arbitrary length data signed on the behalf of address(this)\n * @param _signature Signature byte array associated with _data\n * @return a bool upon valid or invalid signature with corresponding _data\n */\n function isValidSignature(bytes calldata _data, bytes calldata _signature)\n external\n returns (bytes4)\n {\n bytes32 messageHash = getMessageHash(_data);\n if (_signature.length == 0) {\n require(signedMessages[messageHash] != 0, \"Hash not approved\");\n } else {\n // consumeHash needs to be false, as the state should not be changed\n checkSignatures(messageHash, _data, _signature, false);\n }\n return EIP1271_MAGIC_VALUE;\n }\n\n /// @dev Returns hash of a message that can be signed by owners.\n /// @param message Message that should be hashed\n /// @return Message hash.\n function getMessageHash(\n bytes memory message\n )\n public\n view\n returns (bytes32)\n {\n bytes32 safeMessageHash = keccak256(\n abi.encode(SAFE_MSG_TYPEHASH, keccak256(message))\n );\n return keccak256(\n abi.encodePacked(byte(0x19), byte(0x01), domainSeparator, safeMessageHash)\n );\n }\n\n /// @dev Returns the bytes that are hashed to be signed by owners.\n /// @param to Destination address.\n /// @param value Ether value.\n /// @param data Data payload.\n /// @param operation Operation type.\n /// @param safeTxGas Gas that should be used for the safe transaction.\n /// @param baseGas Gas costs for that are independent of the transaction execution(e.g. base transaction fee, signature check, payment of the refund)\n /// @param gasPrice Maximum gas price that should be used for this transaction.\n /// @param gasToken Token address (or 0 if ETH) that is used for the payment.\n /// @param refundReceiver Address of receiver of gas payment (or 0 if tx.origin).\n /// @param _nonce Transaction nonce.\n /// @return Transaction hash bytes.\n function encodeTransactionData(\n address to,\n uint256 value,\n bytes memory data,\n Enum.Operation operation,\n uint256 safeTxGas,\n uint256 baseGas,\n uint256 gasPrice,\n address gasToken,\n address refundReceiver,\n uint256 _nonce\n )\n public\n view\n returns (bytes memory)\n {\n bytes32 safeTxHash = keccak256(\n abi.encode(SAFE_TX_TYPEHASH, to, value, keccak256(data), operation, safeTxGas, baseGas, gasPrice, gasToken, refundReceiver, _nonce)\n );\n return abi.encodePacked(byte(0x19), byte(0x01), domainSeparator, safeTxHash);\n }\n\n /// @dev Returns hash to be signed by owners.\n /// @param to Destination address.\n /// @param value Ether value.\n /// @param data Data payload.\n /// @param operation Operation type.\n /// @param safeTxGas Fas that should be used for the safe transaction.\n /// @param baseGas Gas costs for data used to trigger the safe transaction.\n /// @param gasPrice Maximum gas price that should be used for this transaction.\n /// @param gasToken Token address (or 0 if ETH) that is used for the payment.\n /// @param refundReceiver Address of receiver of gas payment (or 0 if tx.origin).\n /// @param _nonce Transaction nonce.\n /// @return Transaction hash.\n function getTransactionHash(\n address to,\n uint256 value,\n bytes memory data,\n Enum.Operation operation,\n uint256 safeTxGas,\n uint256 baseGas,\n uint256 gasPrice,\n address gasToken,\n address refundReceiver,\n uint256 _nonce\n )\n public\n view\n returns (bytes32)\n {\n return keccak256(encodeTransactionData(to, value, data, operation, safeTxGas, baseGas, gasPrice, gasToken, refundReceiver, _nonce));\n }\n}\n" +pragma solidity >=0.7.0 <0.9.0;\nimport \"./base/ModuleManager.sol\";\nimport \"./base/OwnerManager.sol\";\nimport \"./base/FallbackManager.sol\";\nimport \"./common/MasterCopy.sol\";\nimport \"./common/SignatureDecoder.sol\";\nimport \"./common/SecuredTokenTransfer.sol\";\nimport \"./interfaces/ISignatureValidator.sol\";\nimport \"./external/GnosisSafeMath.sol\";\n\n/// @title Gnosis Safe - A multisignature wallet with support for confirmations using signed messages based on ERC191.\n/// @author Stefan George - \n/// @author Richard Meissner - \n/// @author Ricardo Guilherme Schmidt - (Status Research & Development GmbH) - Gas Token Payment\ncontract GnosisSafe\n is MasterCopy, ModuleManager, OwnerManager, SignatureDecoder, SecuredTokenTransfer, ISignatureValidatorConstants, FallbackManager {\n\n using GnosisSafeMath for uint256;\n\n string public constant NAME = \"Gnosis Safe\";\n string public constant VERSION = \"1.2.0\";\n\n //keccak256(\n // \"EIP712Domain(address verifyingContract)\"\n //);\n bytes32 private constant DOMAIN_SEPARATOR_TYPEHASH = 0x035aff83d86937d35b32e04f0ddc6ff469290eef2f1b692d8a815c89404d4749;\n\n //keccak256(\n // \"SafeTx(address to,uint256 value,bytes data,uint8 operation,uint256 safeTxGas,uint256 baseGas,uint256 gasPrice,address gasToken,address refundReceiver,uint256 nonce)\"\n //);\n bytes32 private constant SAFE_TX_TYPEHASH = 0xbb8310d486368db6bd6f849402fdd73ad53d316b5a4b2644ad6efe0f941286d8;\n\n //keccak256(\n // \"SafeMessage(bytes message)\"\n //);\n bytes32 private constant SAFE_MSG_TYPEHASH = 0x60b3cbf8b4a223d68d641b3b6ddf9a298e7f33710cf3d3a9d1146b5a6150fbca;\n\n event ApproveHash(\n bytes32 indexed approvedHash,\n address indexed owner\n );\n event SignMsg(\n bytes32 indexed msgHash\n );\n event ExecutionFailure(\n bytes32 txHash, uint256 payment\n );\n event ExecutionSuccess(\n bytes32 txHash, uint256 payment\n );\n\n uint256 public nonce;\n bytes32 public domainSeparator;\n // Mapping to keep track of all message hashes that have been approve by ALL REQUIRED owners\n mapping(bytes32 => uint256) public signedMessages;\n // Mapping to keep track of all hashes (message or transaction) that have been approve by ANY owners\n mapping(address => mapping(bytes32 => uint256)) public approvedHashes;\n\n // This constructor ensures that this contract can only be used as a master copy for Proxy contracts\n constructor() public {\n // By setting the threshold it is not possible to call setup anymore,\n // so we create a Safe with 0 owners and threshold 1.\n // This is an unusable Safe, perfect for the mastercopy\n threshold = 1;\n }\n\n /// @dev Setup function sets initial storage of contract.\n /// @param _owners List of Safe owners.\n /// @param _threshold Number of required confirmations for a Safe transaction.\n /// @param to Contract address for optional delegate call.\n /// @param data Data payload for optional delegate call.\n /// @param fallbackHandler Handler for fallback calls to this contract\n /// @param paymentToken Token that should be used for the payment (0 is ETH)\n /// @param payment Value that should be paid\n /// @param paymentReceiver Adddress that should receive the payment (or 0 if tx.origin)\n function setup(\n address[] calldata _owners,\n uint256 _threshold,\n address to,\n bytes calldata data,\n address fallbackHandler,\n address paymentToken,\n uint256 payment,\n address payable paymentReceiver\n )\n external\n {\n require(domainSeparator == 0, \"Domain Separator already set!\");\n domainSeparator = keccak256(abi.encode(DOMAIN_SEPARATOR_TYPEHASH, this));\n setupOwners(_owners, _threshold);\n if (fallbackHandler != address(0)) internalSetFallbackHandler(fallbackHandler);\n // As setupOwners can only be called if the contract has not been initialized we don't need a check for setupModules\n setupModules(to, data);\n\n if (payment > 0) {\n // To avoid running into issues with EIP-170 we reuse the handlePayment function (to avoid adjusting code of that has been verified we do not adjust the method itself)\n // baseGas = 0, gasPrice = 1 and gas = payment => amount = (payment + 0) * 1 = payment\n handlePayment(payment, 0, 1, paymentToken, paymentReceiver);\n }\n }\n\n /// @dev Allows to execute a Safe transaction confirmed by required number of owners and then pays the account that submitted the transaction.\n /// Note: The fees are always transfered, even if the user transaction fails.\n /// @param to Destination address of Safe transaction.\n /// @param value Ether value of Safe transaction.\n /// @param data Data payload of Safe transaction.\n /// @param operation Operation type of Safe transaction.\n /// @param safeTxGas Gas that should be used for the Safe transaction.\n /// @param baseGas Gas costs that are independent of the transaction execution(e.g. base transaction fee, signature check, payment of the refund)\n /// @param gasPrice Gas price that should be used for the payment calculation.\n /// @param gasToken Token address (or 0 if ETH) that is used for the payment.\n /// @param refundReceiver Address of receiver of gas payment (or 0 if tx.origin).\n /// @param signatures Packed signature data ({bytes32 r}{bytes32 s}{uint8 v})\n function execTransaction(\n address to,\n uint256 value,\n bytes calldata data,\n Enum.Operation operation,\n uint256 safeTxGas,\n uint256 baseGas,\n uint256 gasPrice,\n address gasToken,\n address payable refundReceiver,\n bytes calldata signatures\n )\n external\n payable\n returns (bool success)\n {\n bytes32 txHash;\n // Use scope here to limit variable lifetime and prevent `stack too deep` errors\n {\n bytes memory txHashData = encodeTransactionData(\n to, value, data, operation, // Transaction info\n safeTxGas, baseGas, gasPrice, gasToken, refundReceiver, // Payment info\n nonce\n );\n // Increase nonce and execute transaction.\n nonce++;\n txHash = keccak256(txHashData);\n checkSignatures(txHash, txHashData, signatures, true);\n }\n // We require some gas to emit the events (at least 2500) after the execution and some to perform code until the execution (500)\n // We also include the 1/64 in the check that is not send along with a call to counteract potential shortings because of EIP-150\n require(gasleft() >= (safeTxGas * 64 / 63).max(safeTxGas + 2500) + 500, \"GS010\");\n // Use scope here to limit variable lifetime and prevent `stack too deep` errors\n {\n uint256 gasUsed = gasleft();\n // If the gasPrice is 0 we assume that nearly all available gas can be used (it is always more than safeTxGas)\n // We only substract 2500 (compared to the 3000 before) to ensure that the amount passed is still higher than safeTxGas\n success = execute(to, value, data, operation, gasPrice == 0 ? (gasleft() - 2500) : safeTxGas);\n gasUsed = gasUsed.sub(gasleft());\n // We transfer the calculated tx costs to the tx.origin to avoid sending it to intermediate contracts that have made calls\n uint256 payment = 0;\n if (gasPrice > 0) {\n payment = handlePayment(gasUsed, baseGas, gasPrice, gasToken, refundReceiver);\n }\n if (success) emit ExecutionSuccess(txHash, payment);\n else emit ExecutionFailure(txHash, payment);\n }\n }\n\n function handlePayment(\n uint256 gasUsed,\n uint256 baseGas,\n uint256 gasPrice,\n address gasToken,\n address payable refundReceiver\n )\n private\n returns (uint256 payment)\n {\n // solium-disable-next-line security/no-tx-origin\n address payable receiver = refundReceiver == address(0) ? tx.origin : refundReceiver;\n if (gasToken == address(0)) {\n // For ETH we will only adjust the gas price to not be higher than the actual used gas price\n payment = gasUsed.add(baseGas).mul(gasPrice < tx.gasprice ? gasPrice : tx.gasprice);\n // solium-disable-next-line security/no-send\n require(receiver.send(payment), \"GS011\");\n } else {\n payment = gasUsed.add(baseGas).mul(gasPrice);\n require(transferToken(gasToken, receiver, payment), \"GS012\");\n }\n }\n\n /**\n * @dev Checks whether the signature provided is valid for the provided data, hash. Will revert otherwise.\n * @param dataHash Hash of the data (could be either a message hash or transaction hash)\n * @param data That should be signed (this is passed to an external validator contract)\n * @param signatures Signature data that should be verified. Can be ECDSA signature, contract signature (EIP-1271) or approved hash.\n * @param consumeHash Indicates that in case of an approved hash the storage can be freed to save gas\n */\n function checkSignatures(bytes32 dataHash, bytes memory data, bytes memory signatures, bool consumeHash)\n internal\n {\n // Load threshold to avoid multiple storage loads\n uint256 _threshold = threshold;\n // Check that a threshold is set\n require(_threshold > 0, \"GS001\");\n // Check that the provided signature data is not too short\n require(signatures.length >= _threshold.mul(65), \"GS020\");\n // There cannot be an owner with address 0.\n address lastOwner = address(0);\n address currentOwner;\n uint8 v;\n bytes32 r;\n bytes32 s;\n uint256 i;\n for (i = 0; i < _threshold; i++) {\n (v, r, s) = signatureSplit(signatures, i);\n // If v is 0 then it is a contract signature\n if (v == 0) {\n // When handling contract signatures the address of the contract is encoded into r\n currentOwner = address(uint256(r));\n\n // Check that signature data pointer (s) is not pointing inside the static part of the signatures bytes\n // This check is not completely accurate, since it is possible that more signatures than the threshold are send.\n // Here we only check that the pointer is not pointing inside the part that is being processed\n require(uint256(s) >= _threshold.mul(65), \"GS021\");\n\n // Check that signature data pointer (s) is in bounds (points to the length of data -> 32 bytes)\n require(uint256(s).add(32) <= signatures.length, \"GS022\");\n\n // Check if the contract signature is in bounds: start of data is s + 32 and end is start + signature length\n uint256 contractSignatureLen;\n // solium-disable-next-line security/no-inline-assembly\n assembly {\n contractSignatureLen := mload(add(add(signatures, s), 0x20))\n }\n require(uint256(s).add(32).add(contractSignatureLen) <= signatures.length, \"GS023\");\n\n // Check signature\n bytes memory contractSignature;\n // solium-disable-next-line security/no-inline-assembly\n assembly {\n // The signature data for contract signatures is appended to the concatenated signatures and the offset is stored in s\n contractSignature := add(add(signatures, s), 0x20)\n }\n require(ISignatureValidator(currentOwner).isValidSignature(data, contractSignature) == EIP1271_MAGIC_VALUE, \"GS024\");\n // If v is 1 then it is an approved hash\n } else if (v == 1) {\n // When handling approved hashes the address of the approver is encoded into r\n currentOwner = address(uint256(r));\n // Hashes are automatically approved by the sender of the message or when they have been pre-approved via a separate transaction\n require(msg.sender == currentOwner || approvedHashes[currentOwner][dataHash] != 0, \"GS025\");\n // Hash has been marked for consumption. If this hash was pre-approved free storage\n if (consumeHash && msg.sender != currentOwner) {\n approvedHashes[currentOwner][dataHash] = 0;\n }\n } else if (v > 30) {\n // To support eth_sign and similar we adjust v and hash the messageHash with the Ethereum message prefix before applying ecrecover\n currentOwner = ecrecover(keccak256(abi.encodePacked(\"\\x19Ethereum Signed Message:\\n32\", dataHash)), v - 4, r, s);\n } else {\n // Use ecrecover with the messageHash for EOA signatures\n currentOwner = ecrecover(dataHash, v, r, s);\n }\n require (\n currentOwner > lastOwner && owners[currentOwner] != address(0) && currentOwner != SENTINEL_OWNERS,\n \"GS026\"\n );\n lastOwner = currentOwner;\n }\n }\n\n /// @dev Allows to estimate a Safe transaction.\n /// This method is only meant for estimation purpose, therefore two different protection mechanism against execution in a transaction have been made:\n /// 1.) The method can only be called from the safe itself\n /// 2.) The response is returned with a revert\n /// When estimating set `from` to the address of the safe.\n /// Since the `estimateGas` function includes refunds, call this method to get an estimated of the costs that are deducted from the safe with `execTransaction`\n /// @param to Destination address of Safe transaction.\n /// @param value Ether value of Safe transaction.\n /// @param data Data payload of Safe transaction.\n /// @param operation Operation type of Safe transaction.\n /// @return Estimate without refunds and overhead fees (base transaction and payload data gas costs).\n function requiredTxGas(address to, uint256 value, bytes calldata data, Enum.Operation operation)\n external\n authorized\n returns (uint256)\n {\n uint256 startGas = gasleft();\n // We don't provide an error message here, as we use it to return the estimate\n // solium-disable-next-line error-reason\n require(execute(to, value, data, operation, gasleft()));\n uint256 requiredGas = startGas - gasleft();\n // Convert response to string and return via error message\n revert(string(abi.encodePacked(requiredGas)));\n }\n\n /**\n * @dev Marks a hash as approved. This can be used to validate a hash that is used by a signature.\n * @param hashToApprove The hash that should be marked as approved for signatures that are verified by this contract.\n */\n function approveHash(bytes32 hashToApprove)\n external\n {\n require(owners[msg.sender] != address(0), \"GS030\");\n approvedHashes[msg.sender][hashToApprove] = 1;\n emit ApproveHash(hashToApprove, msg.sender);\n }\n\n /**\n * @dev Marks a message as signed, so that it can be used with EIP-1271\n * @notice Marks a message (`_data`) as signed.\n * @param _data Arbitrary length data that should be marked as signed on the behalf of address(this)\n */\n function signMessage(bytes calldata _data)\n external\n authorized\n {\n bytes32 msgHash = getMessageHash(_data);\n signedMessages[msgHash] = 1;\n emit SignMsg(msgHash);\n }\n\n /**\n * Implementation of ISignatureValidator (see `interfaces/ISignatureValidator.sol`)\n * @dev Should return whether the signature provided is valid for the provided data.\n * The save does not implement the interface since `checkSignatures` is not a view method.\n * The method will not perform any state changes (see parameters of `checkSignatures`)\n * @param _data Arbitrary length data signed on the behalf of address(this)\n * @param _signature Signature byte array associated with _data\n * @return a bool upon valid or invalid signature with corresponding _data\n */\n function isValidSignature(bytes calldata _data, bytes calldata _signature)\n external\n returns (bytes4)\n {\n bytes32 messageHash = getMessageHash(_data);\n if (_signature.length == 0) {\n require(signedMessages[messageHash] != 0, \"Hash not approved\");\n } else {\n // consumeHash needs to be false, as the state should not be changed\n checkSignatures(messageHash, _data, _signature, false);\n }\n return EIP1271_MAGIC_VALUE;\n }\n\n /// @dev Returns hash of a message that can be signed by owners.\n /// @param message Message that should be hashed\n /// @return Message hash.\n function getMessageHash(\n bytes memory message\n )\n public\n view\n returns (bytes32)\n {\n bytes32 safeMessageHash = keccak256(\n abi.encode(SAFE_MSG_TYPEHASH, keccak256(message))\n );\n return keccak256(\n abi.encodePacked(byte(0x19), byte(0x01), domainSeparator, safeMessageHash)\n );\n }\n\n /// @dev Returns the bytes that are hashed to be signed by owners.\n /// @param to Destination address.\n /// @param value Ether value.\n /// @param data Data payload.\n /// @param operation Operation type.\n /// @param safeTxGas Gas that should be used for the safe transaction.\n /// @param baseGas Gas costs for that are independent of the transaction execution(e.g. base transaction fee, signature check, payment of the refund)\n /// @param gasPrice Maximum gas price that should be used for this transaction.\n /// @param gasToken Token address (or 0 if ETH) that is used for the payment.\n /// @param refundReceiver Address of receiver of gas payment (or 0 if tx.origin).\n /// @param _nonce Transaction nonce.\n /// @return Transaction hash bytes.\n function encodeTransactionData(\n address to,\n uint256 value,\n bytes memory data,\n Enum.Operation operation,\n uint256 safeTxGas,\n uint256 baseGas,\n uint256 gasPrice,\n address gasToken,\n address refundReceiver,\n uint256 _nonce\n )\n public\n view\n returns (bytes memory)\n {\n bytes32 safeTxHash = keccak256(\n abi.encode(SAFE_TX_TYPEHASH, to, value, keccak256(data), operation, safeTxGas, baseGas, gasPrice, gasToken, refundReceiver, _nonce)\n );\n return abi.encodePacked(byte(0x19), byte(0x01), domainSeparator, safeTxHash);\n }\n\n /// @dev Returns hash to be signed by owners.\n /// @param to Destination address.\n /// @param value Ether value.\n /// @param data Data payload.\n /// @param operation Operation type.\n /// @param safeTxGas Fas that should be used for the safe transaction.\n /// @param baseGas Gas costs for data used to trigger the safe transaction.\n /// @param gasPrice Maximum gas price that should be used for this transaction.\n /// @param gasToken Token address (or 0 if ETH) that is used for the payment.\n /// @param refundReceiver Address of receiver of gas payment (or 0 if tx.origin).\n /// @param _nonce Transaction nonce.\n /// @return Transaction hash.\n function getTransactionHash(\n address to,\n uint256 value,\n bytes memory data,\n Enum.Operation operation,\n uint256 safeTxGas,\n uint256 baseGas,\n uint256 gasPrice,\n address gasToken,\n address refundReceiver,\n uint256 _nonce\n )\n public\n view\n returns (bytes32)\n {\n return keccak256(encodeTransactionData(to, value, data, operation, safeTxGas, baseGas, gasPrice, gasToken, refundReceiver, _nonce));\n }\n}\n" }, "contracts/base/OwnerManager.sol": { "content": "// SPDX-License-Identifier: LGPL-3.0-only -pragma solidity >=0.7.0 <0.9.0;\nimport \"../common/SelfAuthorized.sol\";\n\n/// @title OwnerManager - Manages a set of owners and a threshold to perform actions.\n/// @author Stefan George - \n/// @author Richard Meissner - \ncontract OwnerManager is SelfAuthorized {\n\n event AddedOwner(address owner);\n event RemovedOwner(address owner);\n event ChangedThreshold(uint256 threshold);\n\n address internal constant SENTINEL_OWNERS = address(0x1);\n\n mapping(address => address) internal owners;\n uint256 ownerCount;\n uint256 internal threshold;\n\n /// @dev Setup function sets initial storage of contract.\n /// @param _owners List of Safe owners.\n /// @param _threshold Number of required confirmations for a Safe transaction.\n function setupOwners(address[] memory _owners, uint256 _threshold)\n internal\n {\n // Threshold can only be 0 at initialization.\n // Check ensures that setup function can only be called once.\n require(threshold == 0, \"Owners have already been setup\");\n // Validate that threshold is smaller than number of added owners.\n require(_threshold <= _owners.length, \"Threshold cannot exceed owner count\");\n // There has to be at least one Safe owner.\n require(_threshold >= 1, \"Threshold needs to be greater than 0\");\n // Initializing Safe owners.\n address currentOwner = SENTINEL_OWNERS;\n for (uint256 i = 0; i < _owners.length; i++) {\n // Owner address cannot be null.\n address owner = _owners[i];\n require(owner != address(0) && owner != SENTINEL_OWNERS, \"Invalid owner address provided\");\n // No duplicate owners allowed.\n require(owners[owner] == address(0), \"Duplicate owner address provided\");\n owners[currentOwner] = owner;\n currentOwner = owner;\n }\n owners[currentOwner] = SENTINEL_OWNERS;\n ownerCount = _owners.length;\n threshold = _threshold;\n }\n\n /// @dev Allows to add a new owner to the Safe and update the threshold at the same time.\n /// This can only be done via a Safe transaction.\n /// @notice Adds the owner `owner` to the Safe and updates the threshold to `_threshold`.\n /// @param owner New owner address.\n /// @param _threshold New threshold.\n function addOwnerWithThreshold(address owner, uint256 _threshold)\n public\n authorized\n {\n // Owner address cannot be null.\n require(owner != address(0) && owner != SENTINEL_OWNERS, \"Invalid owner address provided\");\n // No duplicate owners allowed.\n require(owners[owner] == address(0), \"Address is already an owner\");\n owners[owner] = owners[SENTINEL_OWNERS];\n owners[SENTINEL_OWNERS] = owner;\n ownerCount++;\n emit AddedOwner(owner);\n // Change threshold if threshold was changed.\n if (threshold != _threshold)\n changeThreshold(_threshold);\n }\n\n /// @dev Allows to remove an owner from the Safe and update the threshold at the same time.\n /// This can only be done via a Safe transaction.\n /// @notice Removes the owner `owner` from the Safe and updates the threshold to `_threshold`.\n /// @param prevOwner Owner that pointed to the owner to be removed in the linked list\n /// @param owner Owner address to be removed.\n /// @param _threshold New threshold.\n function removeOwner(address prevOwner, address owner, uint256 _threshold)\n public\n authorized\n {\n // Only allow to remove an owner, if threshold can still be reached.\n require(ownerCount - 1 >= _threshold, \"New owner count needs to be larger than new threshold\");\n // Validate owner address and check that it corresponds to owner index.\n require(owner != address(0) && owner != SENTINEL_OWNERS, \"Invalid owner address provided\");\n require(owners[prevOwner] == owner, \"Invalid prevOwner, owner pair provided\");\n owners[prevOwner] = owners[owner];\n owners[owner] = address(0);\n ownerCount--;\n emit RemovedOwner(owner);\n // Change threshold if threshold was changed.\n if (threshold != _threshold)\n changeThreshold(_threshold);\n }\n\n /// @dev Allows to swap/replace an owner from the Safe with another address.\n /// This can only be done via a Safe transaction.\n /// @notice Replaces the owner `oldOwner` in the Safe with `newOwner`.\n /// @param prevOwner Owner that pointed to the owner to be replaced in the linked list\n /// @param oldOwner Owner address to be replaced.\n /// @param newOwner New owner address.\n function swapOwner(address prevOwner, address oldOwner, address newOwner)\n public\n authorized\n {\n // Owner address cannot be null.\n require(newOwner != address(0) && newOwner != SENTINEL_OWNERS, \"Invalid owner address provided\");\n // No duplicate owners allowed.\n require(owners[newOwner] == address(0), \"Address is already an owner\");\n // Validate oldOwner address and check that it corresponds to owner index.\n require(oldOwner != address(0) && oldOwner != SENTINEL_OWNERS, \"Invalid owner address provided\");\n require(owners[prevOwner] == oldOwner, \"Invalid prevOwner, owner pair provided\");\n owners[newOwner] = owners[oldOwner];\n owners[prevOwner] = newOwner;\n owners[oldOwner] = address(0);\n emit RemovedOwner(oldOwner);\n emit AddedOwner(newOwner);\n }\n\n /// @dev Allows to update the number of required confirmations by Safe owners.\n /// This can only be done via a Safe transaction.\n /// @notice Changes the threshold of the Safe to `_threshold`.\n /// @param _threshold New threshold.\n function changeThreshold(uint256 _threshold)\n public\n authorized\n {\n // Validate that threshold is smaller than number of owners.\n require(_threshold <= ownerCount, \"Threshold cannot exceed owner count\");\n // There has to be at least one Safe owner.\n require(_threshold >= 1, \"Threshold needs to be greater than 0\");\n threshold = _threshold;\n emit ChangedThreshold(threshold);\n }\n\n function getThreshold()\n public\n view\n returns (uint256)\n {\n return threshold;\n }\n\n function isOwner(address owner)\n public\n view\n returns (bool)\n {\n return owner != SENTINEL_OWNERS && owners[owner] != address(0);\n }\n\n /// @dev Returns array of owners.\n /// @return Array of Safe owners.\n function getOwners()\n public\n view\n returns (address[] memory)\n {\n address[] memory array = new address[](ownerCount);\n\n // populate return array\n uint256 index = 0;\n address currentOwner = owners[SENTINEL_OWNERS];\n while(currentOwner != SENTINEL_OWNERS) {\n array[index] = currentOwner;\n currentOwner = owners[currentOwner];\n index ++;\n }\n return array;\n }\n}\n" +pragma solidity >=0.7.0 <0.9.0;\nimport \"../common/SelfAuthorized.sol\";\n\n/// @title OwnerManager - Manages a set of owners and a threshold to perform actions.\n/// @author Stefan George - \n/// @author Richard Meissner - \ncontract OwnerManager is SelfAuthorized {\n\n event AddedOwner(address owner);\n event RemovedOwner(address owner);\n event ChangedThreshold(uint256 threshold);\n\n address internal constant SENTINEL_OWNERS = address(0x1);\n\n mapping(address => address) internal owners;\n uint256 ownerCount;\n uint256 internal threshold;\n\n /// @dev Setup function sets initial storage of contract.\n /// @param _owners List of Safe owners.\n /// @param _threshold Number of required confirmations for a Safe transaction.\n function setupOwners(address[] memory _owners, uint256 _threshold)\n internal\n {\n // Threshold can only be 0 at initialization.\n // Check ensures that setup function can only be called once.\n require(threshold == 0, \"GS200\");\n // Validate that threshold is smaller than number of added owners.\n require(_threshold <= _owners.length, \"GS201\");\n // There has to be at least one Safe owner.\n require(_threshold >= 1, \"GS202\");\n // Initializing Safe owners.\n address currentOwner = SENTINEL_OWNERS;\n for (uint256 i = 0; i < _owners.length; i++) {\n // Owner address cannot be null.\n address owner = _owners[i];\n require(owner != address(0) && owner != SENTINEL_OWNERS, \"GS203\");\n // No duplicate owners allowed.\n require(owners[owner] == address(0), \"Duplicate owner address provided\");\n owners[currentOwner] = owner;\n currentOwner = owner;\n }\n owners[currentOwner] = SENTINEL_OWNERS;\n ownerCount = _owners.length;\n threshold = _threshold;\n }\n\n /// @dev Allows to add a new owner to the Safe and update the threshold at the same time.\n /// This can only be done via a Safe transaction.\n /// @notice Adds the owner `owner` to the Safe and updates the threshold to `_threshold`.\n /// @param owner New owner address.\n /// @param _threshold New threshold.\n function addOwnerWithThreshold(address owner, uint256 _threshold)\n public\n authorized\n {\n // Owner address cannot be null.\n require(owner != address(0) && owner != SENTINEL_OWNERS, \"GS203\");\n // No duplicate owners allowed.\n require(owners[owner] == address(0), \"GS204\");\n owners[owner] = owners[SENTINEL_OWNERS];\n owners[SENTINEL_OWNERS] = owner;\n ownerCount++;\n emit AddedOwner(owner);\n // Change threshold if threshold was changed.\n if (threshold != _threshold)\n changeThreshold(_threshold);\n }\n\n /// @dev Allows to remove an owner from the Safe and update the threshold at the same time.\n /// This can only be done via a Safe transaction.\n /// @notice Removes the owner `owner` from the Safe and updates the threshold to `_threshold`.\n /// @param prevOwner Owner that pointed to the owner to be removed in the linked list\n /// @param owner Owner address to be removed.\n /// @param _threshold New threshold.\n function removeOwner(address prevOwner, address owner, uint256 _threshold)\n public\n authorized\n {\n // Only allow to remove an owner, if threshold can still be reached.\n require(ownerCount - 1 >= _threshold, \"New owner count needs to be larger than new threshold\");\n // Validate owner address and check that it corresponds to owner index.\n require(owner != address(0) && owner != SENTINEL_OWNERS, \"GS203\");\n require(owners[prevOwner] == owner, \"GS205\");\n owners[prevOwner] = owners[owner];\n owners[owner] = address(0);\n ownerCount--;\n emit RemovedOwner(owner);\n // Change threshold if threshold was changed.\n if (threshold != _threshold)\n changeThreshold(_threshold);\n }\n\n /// @dev Allows to swap/replace an owner from the Safe with another address.\n /// This can only be done via a Safe transaction.\n /// @notice Replaces the owner `oldOwner` in the Safe with `newOwner`.\n /// @param prevOwner Owner that pointed to the owner to be replaced in the linked list\n /// @param oldOwner Owner address to be replaced.\n /// @param newOwner New owner address.\n function swapOwner(address prevOwner, address oldOwner, address newOwner)\n public\n authorized\n {\n // Owner address cannot be null.\n require(newOwner != address(0) && newOwner != SENTINEL_OWNERS, \"GS203\");\n // No duplicate owners allowed.\n require(owners[newOwner] == address(0), \"GS204\");\n // Validate oldOwner address and check that it corresponds to owner index.\n require(oldOwner != address(0) && oldOwner != SENTINEL_OWNERS, \"GS203\");\n require(owners[prevOwner] == oldOwner, \"GS205\");\n owners[newOwner] = owners[oldOwner];\n owners[prevOwner] = newOwner;\n owners[oldOwner] = address(0);\n emit RemovedOwner(oldOwner);\n emit AddedOwner(newOwner);\n }\n\n /// @dev Allows to update the number of required confirmations by Safe owners.\n /// This can only be done via a Safe transaction.\n /// @notice Changes the threshold of the Safe to `_threshold`.\n /// @param _threshold New threshold.\n function changeThreshold(uint256 _threshold)\n public\n authorized\n {\n // Validate that threshold is smaller than number of owners.\n require(_threshold <= ownerCount, \"GS201\");\n // There has to be at least one Safe owner.\n require(_threshold >= 1, \"GS202\");\n threshold = _threshold;\n emit ChangedThreshold(threshold);\n }\n\n function getThreshold()\n public\n view\n returns (uint256)\n {\n return threshold;\n }\n\n function isOwner(address owner)\n public\n view\n returns (bool)\n {\n return owner != SENTINEL_OWNERS && owners[owner] != address(0);\n }\n\n /// @dev Returns array of owners.\n /// @return Array of Safe owners.\n function getOwners()\n public\n view\n returns (address[] memory)\n {\n address[] memory array = new address[](ownerCount);\n\n // populate return array\n uint256 index = 0;\n address currentOwner = owners[SENTINEL_OWNERS];\n while(currentOwner != SENTINEL_OWNERS) {\n array[index] = currentOwner;\n currentOwner = owners[currentOwner];\n index ++;\n }\n return array;\n }\n}\n" }, "contracts/base/FallbackManager.sol": { "content": "// SPDX-License-Identifier: LGPL-3.0-only diff --git a/docs/error_codes.md b/docs/error_codes.md new file mode 100644 index 000000000..e096d4f48 --- /dev/null +++ b/docs/error_codes.md @@ -0,0 +1,38 @@ +## Error codes + +### General init related +- `GS000`: `Could not finish initialization` +- `GS001`: `Threshold needs to be defined` + +### General gas related +- `GS010`: `Not enough gas to execute safe transaction` +- `GS011`: `Could not pay gas costs with ether` +- `GS012`: `Could not pay gas costs with token` + +### General signature validation related +- `GS020`: `Signatures data too short` +- `GS021`: `Invalid contract signature location: inside static part` +- `GS022`: `Invalid contract signature location: length not present` +- `GS023`: `Invalid contract signature location: data not complete` +- `GS024`: `Invalid contract signature provided` +- `GS025`: `Hash has not been approved` +- `GS026`: `Invalid owner provided` + +### General auth related +- `GS030`: `Only owners can approve a hash` +- `GS031`: `Method can only be called from this contract` + +### Module management related +- `GS100`: `Modules have already been initialized` +- `GS101`: `Invalid module address provided` +- `GS102`: `Module has already been added` +- `GS103`: `Invalid prevModule, module pair provided` +- `GS104`: `Method can only be called from an enabled module` + +### Owner management related +- `GS200`: `Owners have already been setup` +- `GS201`: `Threshold cannot exceed owner count` +- `GS202`: `Threshold needs to be greater than 0` +- `GS203`: `Invalid owner address provided` +- `GS204`: `Address is already an owner` +- `GS205`: `Invalid prevOwner, owner pair provided` diff --git a/package.json b/package.json index 7c34af310..cf46f9a50 100644 --- a/package.json +++ b/package.json @@ -56,7 +56,7 @@ "eslint-plugin-import": "^2.22.1", "eslint-plugin-no-only-tests": "^2.4.0", "eslint-plugin-prettier": "^3.1.4", - "ethereum-waffle": "^3.2.0", + "ethereum-waffle": "^3.3.0", "hardhat": "^2.0.8", "hardhat-deploy": "^0.7.0-beta.38", "husky": "^5.1.3", @@ -64,7 +64,7 @@ "prettier-plugin-solidity": "^1.0.0-alpha.60", "solhint": "^3.3.2", "solhint-plugin-prettier": "^0.0.5", - "solidity-coverage": "^0.7.13", + "solidity-coverage": "^0.7.16", "ts-node": "^9.1.1", "typescript": "^4.1.3" }, @@ -72,7 +72,7 @@ "@types/yargs": "^15.0.10", "argv": "^0.0.2", "dotenv": "^8.0.0", - "ethers": "^5.0.19", + "ethers": "^5.0.32", "solc": "0.7.6", "yargs": "^16.1.1" }, diff --git a/test/accessors/SimulateTxAccessor.spec.ts b/test/accessors/SimulateTxAccessor.spec.ts index f5fecff67..a1cd6397a 100644 --- a/test/accessors/SimulateTxAccessor.spec.ts +++ b/test/accessors/SimulateTxAccessor.spec.ts @@ -1,7 +1,7 @@ import { expect } from "chai"; import hre, { deployments, waffle } from "hardhat"; import "@nomiclabs/hardhat-ethers"; -import { deployContract, getSimulateTxAccessor, getSafeWithOwners } from "../utils/setup"; +import { deployContract, getSimulateTxAccessor, getSafeWithOwners, getCompatFallbackHandler } from "../utils/setup"; import { buildContractCall } from "../utils/execution"; import { parseEther } from "ethers/lib/utils"; @@ -21,10 +21,14 @@ describe("SimulateTxAccessor", async () => { } }` const interactor = await deployContract(user1, source); + const handler = await getCompatFallbackHandler() + const safe = await getSafeWithOwners([user1.address], 1, handler.address) + const simulator = handler.attach(safe.address) return { - safe: await getSafeWithOwners([user1.address]), + safe, accessor, - interactor + interactor, + simulator } }) @@ -50,10 +54,10 @@ describe("SimulateTxAccessor", async () => { }) it('simulate call', async () => { - const { safe, accessor } = await setupTests() + const { safe, accessor, simulator } = await setupTests() const tx = buildContractCall(safe, "getOwners", [], 0) const simulationData = accessor.interface.encodeFunctionData("simulate", [tx.to, tx.value, tx.data, tx.operation]) - const acccessibleData = await safe.callStatic.simulateDelegatecall(accessor.address, simulationData) + const acccessibleData = await simulator.callStatic.simulateDelegatecall(accessor.address, simulationData) const simulation = accessor.interface.decodeFunctionResult("simulate", acccessibleData) expect( safe.interface.decodeFunctionResult("getOwners", simulation.returnData)[0] @@ -67,12 +71,12 @@ describe("SimulateTxAccessor", async () => { }) it('simulate delegatecall', async () => { - const { safe, accessor, interactor } = await setupTests() + const { safe, accessor, interactor, simulator } = await setupTests() await user1.sendTransaction({to: safe.address, value: parseEther("1")}) const userBalance = await hre.ethers.provider.getBalance(user2.address) const tx = buildContractCall(interactor, "sendAndReturnBalance", [user2.address, parseEther("1")], 0, true) const simulationData = accessor.interface.encodeFunctionData("simulate", [tx.to, tx.value, tx.data, tx.operation]) - const acccessibleData = await safe.callStatic.simulateDelegatecall(accessor.address, simulationData) + const acccessibleData = await simulator.callStatic.simulateDelegatecall(accessor.address, simulationData) const simulation = accessor.interface.decodeFunctionResult("simulate", acccessibleData) expect( interactor.interface.decodeFunctionResult("sendAndReturnBalance", simulation.returnData)[0] @@ -86,10 +90,10 @@ describe("SimulateTxAccessor", async () => { }) it('simulate revert', async () => { - const { safe, accessor, interactor } = await setupTests() + const { safe, accessor, interactor, simulator } = await setupTests() const tx = buildContractCall(interactor, "sendAndReturnBalance", [user2.address, parseEther("1")], 0, true) const simulationData = accessor.interface.encodeFunctionData("simulate", [tx.to, tx.value, tx.data, tx.operation]) - const acccessibleData = await safe.callStatic.simulateDelegatecall(accessor.address, simulationData) + const acccessibleData = await simulator.callStatic.simulateDelegatecall(accessor.address, simulationData) const simulation = accessor.interface.decodeFunctionResult("simulate", acccessibleData) expect(simulation.returnData).to.be.deep.eq("0x08c379a00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000f5472616e73666572206661696c65640000000000000000000000000000000000") expect( diff --git a/test/core/GnosisSafe.Execution.spec.ts b/test/core/GnosisSafe.Execution.spec.ts index 97e34d731..79f62b9d8 100644 --- a/test/core/GnosisSafe.Execution.spec.ts +++ b/test/core/GnosisSafe.Execution.spec.ts @@ -48,7 +48,7 @@ describe("GnosisSafe", async () => { tx.to, tx.value, tx.data, tx.operation, tx.safeTxGas, tx.baseGas, tx.gasPrice, tx.gasToken, tx.refundReceiver, signatureBytes, { gasLimit: 1000000 } ) - ).to.be.revertedWith("Not enough gas to execute safe transaction") + ).to.be.revertedWith("GS010") }) it('should emit event for successful call execution', async () => { diff --git a/test/core/GnosisSafe.Messages.spec.ts b/test/core/GnosisSafe.Messages.spec.ts index 6021ec583..77ba8ad14 100644 --- a/test/core/GnosisSafe.Messages.spec.ts +++ b/test/core/GnosisSafe.Messages.spec.ts @@ -29,7 +29,7 @@ describe("GnosisSafe", async () => { it('can only be called from Safe itself', async () => { const { safe } = await setupTests() - await expect(safe.signMessage("0xbaddad")).to.be.revertedWith("Method can only be called from this contract") + await expect(safe.signMessage("0xbaddad")).to.be.revertedWith("GS031") }) it('should emit event', async () => { diff --git a/test/core/GnosisSafe.ModuleManager.spec.ts b/test/core/GnosisSafe.ModuleManager.spec.ts index cba817d39..bfae5e231 100644 --- a/test/core/GnosisSafe.ModuleManager.spec.ts +++ b/test/core/GnosisSafe.ModuleManager.spec.ts @@ -22,7 +22,7 @@ describe("ModuleManager", async () => { describe("enableModule", async () => { it('can only be called from Safe itself', async () => { const { safe } = await setupTests() - await expect(safe.enableModule(user2.address)).to.be.revertedWith("Method can only be called from this contract") + await expect(safe.enableModule(user2.address)).to.be.revertedWith("GS031") }) it('can not set sentinel', async () => { @@ -86,7 +86,7 @@ describe("ModuleManager", async () => { describe("disableModule", async () => { it('can only be called from Safe itself', async () => { const { safe } = await setupTests() - await expect(safe.disableModule(AddressOne, user2.address)).to.be.revertedWith("Method can only be called from this contract") + await expect(safe.disableModule(AddressOne, user2.address)).to.be.revertedWith("GS031") }) it('can not set sentinel', async () => { @@ -155,13 +155,13 @@ describe("ModuleManager", async () => { it('can not be called from sentinel', async () => { const { safe, mock } = await setupTests() const readOnlySafe = safe.connect(hre.ethers.provider) - await expect(readOnlySafe.callStatic.execTransactionFromModule(mock.address, 0, "0xbaddad", 0, { from: AddressOne })).to.be.revertedWith("Method can only be called from an enabled module") + await expect(readOnlySafe.callStatic.execTransactionFromModule(mock.address, 0, "0xbaddad", 0, { from: AddressOne })).to.be.revertedWith("GS104") }) it('can only be called from enabled module', async () => { const { safe, mock } = await setupTests() const user2Safe = safe.connect(user2) - await expect(user2Safe.execTransactionFromModule(mock.address, 0, "0xbaddad", 0)).to.be.revertedWith("Method can only be called from an enabled module") + await expect(user2Safe.execTransactionFromModule(mock.address, 0, "0xbaddad", 0)).to.be.revertedWith("GS104") }) it('emits event on execution success', async () => { @@ -191,13 +191,13 @@ describe("ModuleManager", async () => { it('can not be called from sentinel', async () => { const { safe, mock } = await setupTests() const readOnlySafe = safe.connect(hre.ethers.provider) - await expect(readOnlySafe.callStatic.execTransactionFromModuleReturnData(mock.address, 0, "0xbaddad", 0, { from: AddressOne })).to.be.revertedWith("Method can only be called from an enabled module") + await expect(readOnlySafe.callStatic.execTransactionFromModuleReturnData(mock.address, 0, "0xbaddad", 0, { from: AddressOne })).to.be.revertedWith("GS104") }) it('can only be called from enabled module', async () => { const { safe, mock } = await setupTests() const user2Safe = safe.connect(user2) - await expect(user2Safe.execTransactionFromModuleReturnData(mock.address, 0, "0xbaddad", 0)).to.be.revertedWith("Method can only be called from an enabled module") + await expect(user2Safe.execTransactionFromModuleReturnData(mock.address, 0, "0xbaddad", 0)).to.be.revertedWith("GS104") }) it('emits event on execution failure', async () => { diff --git a/test/core/GnosisSafe.OwnerManager.spec.ts b/test/core/GnosisSafe.OwnerManager.spec.ts index 3e90d4458..6bce7c3c2 100644 --- a/test/core/GnosisSafe.OwnerManager.spec.ts +++ b/test/core/GnosisSafe.OwnerManager.spec.ts @@ -21,7 +21,7 @@ describe("OwnerManager", async () => { describe("addOwnerWithThreshold", async () => { it('can only be called from Safe itself', async () => { const { safe } = await setupTests() - await expect(safe.addOwnerWithThreshold(user2.address, 1)).to.be.revertedWith("Method can only be called from this contract") + await expect(safe.addOwnerWithThreshold(user2.address, 1)).to.be.revertedWith("GS031") }) it('can not set Safe itself', async () => { @@ -98,7 +98,7 @@ describe("OwnerManager", async () => { describe("removeOwner", async () => { it('can only be called from Safe itself', async () => { const { safe } = await setupTests() - await expect(safe.removeOwner(AddressOne, user2.address, 1)).to.be.revertedWith("Method can only be called from this contract") + await expect(safe.removeOwner(AddressOne, user2.address, 1)).to.be.revertedWith("GS031") }) it('can not remove sentinel', async () => { @@ -207,7 +207,7 @@ describe("OwnerManager", async () => { describe("swapOwner", async () => { it('can only be called from Safe itself', async () => { const { safe } = await setupTests() - await expect(safe.swapOwner(AddressOne, user1.address, user2.address)).to.be.revertedWith("Method can only be called from this contract") + await expect(safe.swapOwner(AddressOne, user1.address, user2.address)).to.be.revertedWith("GS031") }) it('can not swap in Safe itseld', async () => { @@ -299,7 +299,7 @@ describe("OwnerManager", async () => { describe("changeThreshold", async () => { it('can only be called from Safe itself', async () => { const { safe } = await setupTests() - await expect(safe.changeThreshold(1)).to.be.revertedWith("Method can only be called from this contract") + await expect(safe.changeThreshold(1)).to.be.revertedWith("GS031") }) }) }) \ No newline at end of file diff --git a/test/core/GnosisSafe.Setup.spec.ts b/test/core/GnosisSafe.Setup.spec.ts index bcf2f1757..47c3f8988 100644 --- a/test/core/GnosisSafe.Setup.spec.ts +++ b/test/core/GnosisSafe.Setup.spec.ts @@ -40,7 +40,7 @@ describe("GnosisSafe", async () => { await expect( singleton.setup([user1.address, user2.address, user3.address], 2, AddressZero, "0x", AddressZero, AddressZero, 0, AddressZero), - ).to.be.revertedWith("Owners have already been setup") + ).to.be.revertedWith("GS200") }) it('should set domain hash', async () => { @@ -56,63 +56,63 @@ describe("GnosisSafe", async () => { await template.setup([user1.address, user2.address, user3.address], 2, AddressZero, "0x", AddressZero, AddressZero, 0, AddressZero) await expect( template.setup([user1.address, user2.address, user3.address], 2, AddressZero, "0x", AddressZero, AddressZero, 0, AddressZero) - ).to.be.revertedWith("Owners have already been setup") + ).to.be.revertedWith("GS200") }) it('should revert if same owner is included twice', async () => { const { template } = await setupTests() await expect( template.setup([user2.address, user1.address, user2.address], 2, AddressZero, "0x", AddressZero, AddressZero, 0, AddressZero) - ).to.be.revertedWith("Duplicate owner address provided") + ).to.be.revertedWith("GS204") }) it('should revert if 0 address is used as an owner', async () => { const { template } = await setupTests() await expect( template.setup([user2.address, AddressZero], 2, AddressZero, "0x", AddressZero, AddressZero, 0, AddressZero) - ).to.be.revertedWith("Invalid owner address provided") + ).to.be.revertedWith("GS203") }) it('should revert if Safe itself is used as an owner', async () => { const { template } = await setupTests() await expect( template.setup([user2.address, template.address], 2, AddressZero, "0x", AddressZero, AddressZero, 0, AddressZero) - ).to.be.revertedWith("Invalid owner address provided") + ).to.be.revertedWith("GS203") }) it('should revert if sentinel is used as an owner', async () => { const { template } = await setupTests() await expect( template.setup([user2.address, AddressOne], 2, AddressZero, "0x", AddressZero, AddressZero, 0, AddressZero) - ).to.be.revertedWith("Invalid owner address provided") + ).to.be.revertedWith("GS203") }) it('should revert if same owner is included twice one after each other', async () => { const { template } = await setupTests() await expect( template.setup([user2.address, user2.address], 2, AddressZero, "0x", AddressZero, AddressZero, 0, AddressZero) - ).to.be.revertedWith("Invalid owner address provided") + ).to.be.revertedWith("GS203") }) it('should revert if threshold is too high', async () => { const { template } = await setupTests() await expect( template.setup([user1.address, user2.address, user3.address], 4, AddressZero, "0x", AddressZero, AddressZero, 0, AddressZero) - ).to.be.revertedWith("Threshold cannot exceed owner count") + ).to.be.revertedWith("GS201") }) it('should revert if threshold is 0', async () => { const { template } = await setupTests() await expect( template.setup([user1.address, user2.address, user3.address], 0, AddressZero, "0x", AddressZero, AddressZero, 0, AddressZero) - ).to.be.revertedWith("Threshold needs to be greater than 0") + ).to.be.revertedWith("GS202") }) it('should revert if owners are empty', async () => { const { template } = await setupTests() await expect( template.setup([], 0, AddressZero, "0x", AddressZero, AddressZero, 0, AddressZero) - ).to.be.revertedWith("Threshold needs to be greater than 0") + ).to.be.revertedWith("GS202") }) it('should set fallback handler and call sub inititalizer', async () => { @@ -155,7 +155,7 @@ describe("GnosisSafe", async () => { const initData = testIntializer.interface.encodeFunctionData("init", ["0x42baddad"]) await expect( template.setup([user1.address, user2.address, user3.address], 2, testIntializer.address, initData, AddressZero, AddressZero, 0, AddressZero) - ).to.be.revertedWith("Could not finish initialization") + ).to.be.revertedWith("GS000") }) it('should fail if ether payment fails', async () => { @@ -166,7 +166,7 @@ describe("GnosisSafe", async () => { await mock.givenCalldataRevert(transferData) await expect( template.setup([user1.address, user2.address, user3.address], 2, AddressZero, "0x", AddressZero, AddressZero, payment, AddressZero) - ).to.be.revertedWith("Could not pay gas costs with ether") + ).to.be.revertedWith("GS011") }) it('should work with ether payment to deployer', async () => { @@ -205,7 +205,7 @@ describe("GnosisSafe", async () => { await mock.givenCalldataRevert(transferData) await expect( template.setup([user1.address, user2.address, user3.address], 2, AddressZero, "0x", AddressZero, mock.address, payment, AddressZero) - ).to.be.revertedWith("Could not pay gas costs with token") + ).to.be.revertedWith("GS012") }) it('should work with token payment to deployer', async () => { diff --git a/test/core/GnosisSafe.Signatures.spec.ts b/test/core/GnosisSafe.Signatures.spec.ts index 0e6b14f33..b50073f3a 100644 --- a/test/core/GnosisSafe.Signatures.spec.ts +++ b/test/core/GnosisSafe.Signatures.spec.ts @@ -56,7 +56,7 @@ describe("GnosisSafe", async () => { const signerSafe = safe.connect(user2) await expect( signerSafe.approveHash(txHash) - ).to.be.revertedWith("Only owners can approve a hash") + ).to.be.revertedWith("GS030") }) it('approving should emit event', async () => { @@ -76,7 +76,7 @@ describe("GnosisSafe", async () => { "0000000000000000000000000000000000000000000000000000000000000000" // Some data to read await expect( safe.execTransaction(safe.address, 0, "0x", 0, 0, 0, 0, AddressZero, AddressZero, signatures) - ).to.be.revertedWith("Invalid contract signature location: inside static part") + ).to.be.revertedWith("GS021") }) it('should fail if sigantures data is not present', async () => { @@ -86,7 +86,7 @@ describe("GnosisSafe", async () => { await expect( safe.execTransaction(safe.address, 0, "0x", 0, 0, 0, 0, AddressZero, AddressZero, signatures) - ).to.be.revertedWith("Invalid contract signature location: length not present") + ).to.be.revertedWith("GS022") }) it('should fail if sigantures data is too short', async () => { @@ -97,7 +97,7 @@ describe("GnosisSafe", async () => { await expect( safe.execTransaction(safe.address, 0, "0x", 0, 0, 0, 0, AddressZero, AddressZero, signatures) - ).to.be.revertedWith("Invalid contract signature location: data not complete") + ).to.be.revertedWith("GS023") }) it('should be able to use EIP-712 for signature generation', async () => { @@ -117,7 +117,7 @@ describe("GnosisSafe", async () => { const tx = buildSafeTransaction({ to: safe.address, nonce: await safe.nonce() }) await expect( executeTx(safe, tx, [await safeSignTypedData(user1, safe, tx, 1)]) - ).to.be.revertedWith("Invalid owner provided") + ).to.be.revertedWith("GS026") }) it('should be able to use Signed Ethereum Messages for signature generation', async () => { @@ -148,7 +148,7 @@ describe("GnosisSafe", async () => { const tx = buildSafeTransaction({ to: safe.address, nonce: await safe.nonce() }) await expect( executeTx(user2Safe, tx, [await safeApproveHash(user1, safe, tx, true)]) - ).to.be.revertedWith("Hash has not been approved") + ).to.be.revertedWith("GS025") }) it('should be able to use pre approved hashes for signature generation', async () => { @@ -178,7 +178,7 @@ describe("GnosisSafe", async () => { const tx = buildSafeTransaction({ to: safe.address, nonce: await safe.nonce() }) await expect( executeTx(safe, tx, []) - ).to.be.revertedWith("Threshold needs to be defined!") + ).to.be.revertedWith("GS001") }) it('should revert if not the required amount of signature data is provided', async () => { @@ -187,7 +187,7 @@ describe("GnosisSafe", async () => { const tx = buildSafeTransaction({ to: safe.address, nonce: await safe.nonce() }) await expect( executeTx(safe, tx, []) - ).to.be.revertedWith("Signatures data too short") + ).to.be.revertedWith("GS020") }) it('should not be able to use different signature type of same owner', async () => { @@ -196,7 +196,7 @@ describe("GnosisSafe", async () => { const tx = buildSafeTransaction({ to: safe.address, nonce: await safe.nonce() }) await expect( executeTx(safe, tx, [await safeApproveHash(user1, safe, tx), await safeSignTypedData(user1, safe, tx), await safeSignTypedData(user3, safe, tx)]) - ).to.be.revertedWith("Invalid owner provided") + ).to.be.revertedWith("GS026") }) it('should be able to mix all signature types', async () => { @@ -227,7 +227,7 @@ describe("GnosisSafe", async () => { "0000000000000000000000000000000000000000000000000000000000000000" // Some data to read await expect( safe.checkSignatures(txHash, txHashData, signatures) - ).to.be.revertedWith("Invalid contract signature location: inside static part") + ).to.be.revertedWith("GS021") }) it('should fail if sigantures data is not present', async () => { @@ -240,7 +240,7 @@ describe("GnosisSafe", async () => { await expect( safe.checkSignatures(txHash, txHashData, signatures) - ).to.be.revertedWith("Invalid contract signature location: length not present") + ).to.be.revertedWith("GS022") }) it('should fail if sigantures data is too short', async () => { @@ -254,7 +254,7 @@ describe("GnosisSafe", async () => { await expect( safe.checkSignatures(txHash, txHashData, signatures) - ).to.be.revertedWith("Invalid contract signature location: data not complete") + ).to.be.revertedWith("GS023") }) it('should not be able to use different chainId for signing', async () => { @@ -266,7 +266,7 @@ describe("GnosisSafe", async () => { const signatures = buildSignatureBytes([await safeSignTypedData(user1, safe, tx, 1)]) await expect( safe.checkSignatures(txHash, txHashData, signatures) - ).to.be.revertedWith("Invalid owner provided") + ).to.be.revertedWith("GS026") }) it('if not msg.sender on-chain approval is required', async () => { @@ -278,7 +278,7 @@ describe("GnosisSafe", async () => { const signatures = buildSignatureBytes([await safeApproveHash(user1, safe, tx, true)]) await expect( user2Safe.checkSignatures(txHash, txHashData, signatures) - ).to.be.revertedWith("Hash has not been approved") + ).to.be.revertedWith("GS025") }) it('should revert if threshold is not set', async () => { @@ -289,7 +289,7 @@ describe("GnosisSafe", async () => { const txHash = calculateSafeTransactionHash(safe, tx, await chainId()) await expect( safe.checkSignatures(txHash, txHashData, "0x") - ).to.be.revertedWith("Threshold needs to be defined!") + ).to.be.revertedWith("GS001") }) it('should revert if not the required amount of signature data is provided', async () => { @@ -300,7 +300,7 @@ describe("GnosisSafe", async () => { const txHash = calculateSafeTransactionHash(safe, tx, await chainId()) await expect( safe.checkSignatures(txHash, txHashData, "0x") - ).to.be.revertedWith("Signatures data too short") + ).to.be.revertedWith("GS020") }) it('should not be able to use different signature type of same owner', async () => { @@ -316,7 +316,7 @@ describe("GnosisSafe", async () => { ]) await expect( safe.checkSignatures(txHash, txHashData, signatures) - ).to.be.revertedWith("Invalid owner provided") + ).to.be.revertedWith("GS026") }) it('should be able to mix all signature types', async () => { diff --git a/test/core/GnosisSafe.StorageAccessible.spec.ts b/test/core/GnosisSafe.StorageAccessible.spec.ts index b0a4157ed..a43badcd9 100644 --- a/test/core/GnosisSafe.StorageAccessible.spec.ts +++ b/test/core/GnosisSafe.StorageAccessible.spec.ts @@ -1,8 +1,9 @@ import { expect } from "chai"; -import hre, { deployments, waffle } from "hardhat"; +import { deployments, waffle } from "hardhat"; import "@nomiclabs/hardhat-ethers"; -import { deployContract, getSafeSingleton, getDefaultCallbackHandler, getSafeWithOwners } from "../utils/setup"; -import { BigNumber, utils } from "ethers"; +import { getSafeSingleton, getDefaultCallbackHandler, getSafeWithOwners } from "../utils/setup"; +import { utils } from "ethers"; +import { killLibContract } from "../utils/contracts"; describe("StorageAccessible", async () => { @@ -11,38 +12,7 @@ describe("StorageAccessible", async () => { const setupTests = deployments.createFixture(async ({ deployments }) => { await deployments.fixture(); const handler = await getDefaultCallbackHandler() - const source = ` - contract Test { - function killme() public { - selfdestruct(payable(msg.sender)); - } - - function expose() public returns (address handler) { - bytes32 slot = 0x6c9a6c4a39284e37ed1cf53d337577d14212a4870fb976a4366c693b939918d5; - assembly { - handler := sload(slot) - } - } - - function estimate(address to, bytes memory data) public returns (uint256) { - uint256 startGas = gasleft(); - (bool success,) = to.call{ gas: gasleft() }(data); - require(success, "Transaction failed"); - return startGas - gasleft(); - } - - address singleton; - uint256 public value = 0; - function updateAndGet() public returns (uint256) { - value++; - return value; - } - - function trever() public returns (address handler) { - revert("Why are you doing this?"); - } - }` - const killLib = await deployContract(user1, source); + const killLib = await killLibContract(user1); return { safe: await getSafeWithOwners([user1.address, user2.address], 1, handler.address), killLib, @@ -70,73 +40,26 @@ describe("StorageAccessible", async () => { }) }) - describe("simulateDelegatecall", async () => { - - it('should revert changes', async () => { - const { safe, killLib } = await setupTests() - const code = await hre.ethers.provider.getCode(safe.address) - expect( - await safe.callStatic.simulateDelegatecall(killLib.address, killLib.interface.encodeFunctionData("killme")) - ).to.be.eq("0x") - expect( - await hre.ethers.provider.getCode(safe.address) - ).to.be.eq(code) - }) - - it('should return result', async () => { - const { safe, killLib, handler } = await setupTests() - expect( - await safe.callStatic.simulateDelegatecall(killLib.address, killLib.interface.encodeFunctionData("expose")) - ).to.be.eq("0x000000000000000000000000" + handler.address.slice(2).toLowerCase()) - }) - - it('should propagate revert message', async () => { - const { safe, killLib } = await setupTests() - await expect( - safe.callStatic.simulateDelegatecall(killLib.address, killLib.interface.encodeFunctionData("trever")) - ).to.revertedWith("Why are you doing this?") - }) - - it('should simulate transaction', async () => { - const { safe, killLib } = await setupTests() - const estimate = await safe.callStatic.simulateDelegatecall( - killLib.address, - killLib.interface.encodeFunctionData("estimate", [safe.address, "0x"]) - ) - expect(BigNumber.from(estimate).toNumber()).to.be.lte(5000) - }) - - it('should return modified state', async () => { - const { safe, killLib } = await setupTests() - const value = await safe.callStatic.simulateDelegatecall( - killLib.address, - killLib.interface.encodeFunctionData("updateAndGet", []) - ) - expect(BigNumber.from(value).toNumber()).to.be.eq(1) - expect((await killLib.value()).toNumber()).to.be.eq(0) - }) - }) - - describe("simulateDelegatecallInternal", async () => { + describe("simulate", async () => { it('should revert changes', async () => { const { safe, killLib } = await setupTests() await expect( - safe.callStatic.simulateDelegatecallInternal(killLib.address, killLib.interface.encodeFunctionData("killme")) + safe.callStatic.simulate(killLib.address, killLib.interface.encodeFunctionData("killme")) ).to.be.reverted }) it('should revert the revert with message', async () => { const { safe, killLib } = await setupTests() await expect( - safe.callStatic.simulateDelegatecallInternal(killLib.address, killLib.interface.encodeFunctionData("trever")) + safe.callStatic.simulate(killLib.address, killLib.interface.encodeFunctionData("trever")) ).to.revertedWith("Why are you doing this?") }) it('should return estimate in revert', async () => { const { safe, killLib } = await setupTests() await expect( - safe.callStatic.simulateDelegatecallInternal(killLib.address, killLib.interface.encodeFunctionData("estimate", [safe.address, "0x"])) + safe.callStatic.simulate(killLib.address, killLib.interface.encodeFunctionData("estimate", [safe.address, "0x"])) ).to.be.reverted }) }) diff --git a/test/handlers/CompatibilityFallbackHandler.spec.ts b/test/handlers/CompatibilityFallbackHandler.spec.ts index 4d90b5a3a..c857e132e 100644 --- a/test/handlers/CompatibilityFallbackHandler.spec.ts +++ b/test/handlers/CompatibilityFallbackHandler.spec.ts @@ -5,6 +5,8 @@ import { AddressZero } from "@ethersproject/constants"; import { compatFallbackHandlerContract, getCompatFallbackHandler, getSafeWithOwners } from "../utils/setup"; import { buildSignatureBytes, executeContractCallWithSigners, calculateSafeMessageHash, EIP712_SAFE_MESSAGE_TYPE, signHash } from "../utils/execution"; import { chainId } from "../utils/encoding"; +import { BigNumber } from "ethers"; +import { killLibContract } from "../utils/contracts"; describe("CompatibilityFallbackHandler", async () => { @@ -15,10 +17,12 @@ describe("CompatibilityFallbackHandler", async () => { const handler = await getCompatFallbackHandler() const safe = await getSafeWithOwners([user1.address, user2.address], 2, handler.address) const validator = (await compatFallbackHandlerContract()).attach(safe.address) + const killLib = await killLibContract(user1); return { safe, validator, - handler + handler, + killLib } }) @@ -127,8 +131,6 @@ describe("CompatibilityFallbackHandler", async () => { }) }) - - describe("getModules", async () => { it('returns enabled modules', async () => { const { safe, validator } = await setupTests() @@ -145,4 +147,55 @@ describe("CompatibilityFallbackHandler", async () => { ).to.be.deep.equal([user2.address]) }) }) + + + describe("simulateDelegatecall", async () => { + + it.skip('can be called for any Safe', async () => { + }) + + it('should revert changes', async () => { + const { validator, killLib } = await setupTests() + const code = await ethers.provider.getCode(validator.address) + expect( + await validator.callStatic.simulateDelegatecall(killLib.address, killLib.interface.encodeFunctionData("killme")) + ).to.be.eq("0x") + expect( + await ethers.provider.getCode(validator.address) + ).to.be.eq(code) + }) + + it('should return result', async () => { + const { validator, killLib, handler } = await setupTests() + expect( + await validator.callStatic.simulateDelegatecall(killLib.address, killLib.interface.encodeFunctionData("expose")) + ).to.be.eq("0x000000000000000000000000" + handler.address.slice(2).toLowerCase()) + }) + + it('should propagate revert message', async () => { + const { validator, killLib } = await setupTests() + await expect( + validator.callStatic.simulateDelegatecall(killLib.address, killLib.interface.encodeFunctionData("trever")) + ).to.revertedWith("Why are you doing this?") + }) + + it('should simulate transaction', async () => { + const { validator, killLib } = await setupTests() + const estimate = await validator.callStatic.simulateDelegatecall( + killLib.address, + killLib.interface.encodeFunctionData("estimate", [validator.address, "0x"]) + ) + expect(BigNumber.from(estimate).toNumber()).to.be.lte(5000) + }) + + it('should return modified state', async () => { + const { validator, killLib } = await setupTests() + const value = await validator.callStatic.simulateDelegatecall( + killLib.address, + killLib.interface.encodeFunctionData("updateAndGet", []) + ) + expect(BigNumber.from(value).toNumber()).to.be.eq(1) + expect((await killLib.value()).toNumber()).to.be.eq(0) + }) + }) }) \ No newline at end of file diff --git a/test/libraries/Migration.spec.ts b/test/libraries/Migration.spec.ts index 2ce992f52..784316e98 100644 --- a/test/libraries/Migration.spec.ts +++ b/test/libraries/Migration.spec.ts @@ -32,7 +32,7 @@ describe("Migration", async () => { describe("migrate", async () => { it('can only be called from Safe itself', async () => { const { migration } = await setupTests() - await expect(migration.migrate()).to.be.revertedWith("Method can only be called from this contract") + await expect(migration.migrate()).to.be.revertedWith("GS031") }) it.skip('can migrate', async () => { diff --git a/test/utils/contracts.ts b/test/utils/contracts.ts new file mode 100644 index 000000000..1790f8216 --- /dev/null +++ b/test/utils/contracts.ts @@ -0,0 +1,35 @@ +import { Wallet } from "ethers"; +import { deployContract } from "./setup"; + +export const killLibSource = ` +contract Test { + function killme() public { + selfdestruct(payable(msg.sender)); + } + + function expose() public returns (address handler) { + bytes32 slot = 0x6c9a6c4a39284e37ed1cf53d337577d14212a4870fb976a4366c693b939918d5; + assembly { + handler := sload(slot) + } + } + + function estimate(address to, bytes memory data) public returns (uint256) { + uint256 startGas = gasleft(); + (bool success,) = to.call{ gas: gasleft() }(data); + require(success, "Transaction failed"); + return startGas - gasleft(); + } + + address singleton; + uint256 public value = 0; + function updateAndGet() public returns (uint256) { + value++; + return value; + } + + function trever() public returns (address handler) { + revert("Why are you doing this?"); + } +}` +export const killLibContract = async (deployer: Wallet) => { return await deployContract(deployer, killLibSource) }; \ No newline at end of file diff --git a/yarn.lock b/yarn.lock index d1dcd7886..06dfedb41 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3584,7 +3584,7 @@ ethereum-cryptography@^0.1.2, ethereum-cryptography@^0.1.3: secp256k1 "^4.0.1" setimmediate "^1.0.5" -ethereum-waffle@^3.2.0: +ethereum-waffle@^3.3.0: version "3.3.0" resolved "https://registry.yarnpkg.com/ethereum-waffle/-/ethereum-waffle-3.3.0.tgz#166a0cc1d3b2925f117b20ef0951b3fe72e38e79" integrity sha512-4xm3RWAPCu5LlaVxYEg0tG3L7g5ovBw1GY/UebrzZ+OTx22vcPjI+bvelFlGBpkdnO5yOIFXjH2eK59tNAe9IA== @@ -3817,7 +3817,7 @@ ethers@^4.0.32: uuid "2.0.1" xmlhttprequest "1.8.0" -ethers@^5.0.0, ethers@^5.0.1, ethers@^5.0.19, ethers@^5.0.2: +ethers@^5.0.0, ethers@^5.0.1, ethers@^5.0.2, ethers@^5.0.32: version "5.0.32" resolved "https://registry.yarnpkg.com/ethers/-/ethers-5.0.32.tgz#f009970be31d96a589bf0ce597a39c10c7e297a6" integrity sha512-rORfGWR0HsA4pjKMMcWZorw12DHsXqfIAuPVHJsXt+vI24jvXcVqx+rLsSvgOoLdaCMdxiN5qlIq2+4axKG31g== @@ -7962,7 +7962,7 @@ solidity-comments-extractor@^0.0.4: resolved "https://registry.yarnpkg.com/solidity-comments-extractor/-/solidity-comments-extractor-0.0.4.tgz#ce420aef23641ffd0131c7d80ba85b6e1e42147e" integrity sha512-58glBODwXIKMaQ7rfcJOrWtFQMMOK28tJ0/LcB5Xhu7WtAxk4UX2fpgKPuaL41XjMp/y0gAa1MTLqk018wuSzA== -solidity-coverage@^0.7.13: +solidity-coverage@^0.7.16: version "0.7.16" resolved "https://registry.yarnpkg.com/solidity-coverage/-/solidity-coverage-0.7.16.tgz#c8c8c46baa361e2817bbf275116ddd2ec90a55fb" integrity sha512-ttBOStywE6ZOTJmmABSg4b8pwwZfYKG8zxu40Nz+sRF5bQX7JULXWj/XbX0KXps3Fsp8CJXg8P29rH3W54ipxw==