UNPKG

@gnosis.pm/util-contracts

Version:
832 lines 213 kB
{ "contractName": "StorageAccessible", "abi": [ { "inputs": [], "name": "SIMULATE_DELEGATECALL_INTERNAL_SELECTOR", "outputs": [ { "internalType": "bytes4", "name": "", "type": "bytes4" } ], "stateMutability": "view", "type": "function" }, { "inputs": [ { "internalType": "uint256", "name": "offset", "type": "uint256" }, { "internalType": "uint256", "name": "length", "type": "uint256" } ], "name": "getStorageAt", "outputs": [ { "internalType": "bytes", "name": "", "type": "bytes" } ], "stateMutability": "view", "type": "function" }, { "inputs": [ { "internalType": "address", "name": "targetContract", "type": "address" }, { "internalType": "bytes", "name": "calldataPayload", "type": "bytes" } ], "name": "simulateDelegatecall", "outputs": [ { "internalType": "bytes", "name": "response", "type": "bytes" } ], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [ { "internalType": "address", "name": "targetContract", "type": "address" }, { "internalType": "bytes", "name": "calldataPayload", "type": "bytes" } ], "name": "simulateDelegatecallInternal", "outputs": [ { "internalType": "bytes", "name": "response", "type": "bytes" } ], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [ { "internalType": "bytes", "name": "response", "type": "bytes" } ], "name": "revertWith", "outputs": [], "stateMutability": "pure", "type": "function" }, { "inputs": [ { "internalType": "bytes", "name": "buffer", "type": "bytes" }, { "internalType": "uint256", "name": "length", "type": "uint256" } ], "name": "setLength", "outputs": [], "stateMutability": "pure", "type": "function" } ], "metadata": "{\"compiler\":{\"version\":\"0.7.5+commit.eb77ed08\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[],\"name\":\"SIMULATE_DELEGATECALL_INTERNAL_SELECTOR\",\"outputs\":[{\"internalType\":\"bytes4\",\"name\":\"\",\"type\":\"bytes4\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"offset\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"length\",\"type\":\"uint256\"}],\"name\":\"getStorageAt\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"response\",\"type\":\"bytes\"}],\"name\":\"revertWith\",\"outputs\":[],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"buffer\",\"type\":\"bytes\"},{\"internalType\":\"uint256\",\"name\":\"length\",\"type\":\"uint256\"}],\"name\":\"setLength\",\"outputs\":[],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"targetContract\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"calldataPayload\",\"type\":\"bytes\"}],\"name\":\"simulateDelegatecall\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"response\",\"type\":\"bytes\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"targetContract\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"calldataPayload\",\"type\":\"bytes\"}],\"name\":\"simulateDelegatecallInternal\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"response\",\"type\":\"bytes\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{\"getStorageAt(uint256,uint256)\":{\"details\":\"Reads `length` bytes of storage in the currents contract\",\"params\":{\"length\":\"- the number of words (32 bytes) of data to read\",\"offset\":\"- the offset in the current contract's storage in words to start reading from\"},\"returns\":{\"_0\":\"the bytes that were read.\"}},\"simulateDelegatecall(address,bytes)\":{\"details\":\"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.\",\"params\":{\"calldataPayload\":\"Calldata that should be sent to the target contract (encoded method name and arguments).\",\"targetContract\":\"Address of the contract containing the code to execute.\"}},\"simulateDelegatecallInternal(address,bytes)\":{\"details\":\"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 concatenated with the success flag of the inner call as a last byte.\",\"params\":{\"calldataPayload\":\"Calldata that should be sent to the target contract (encoded method name and arguments).\",\"targetContract\":\"Address of the contract containing the code to execute.\"}}},\"title\":\"StorageAccessible - generic base contract that allows callers to access all internal storage.\",\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"/Users/bensniff/Projects/gnosis/util-contracts/contracts/StorageAccessible.sol\":\"StorageAccessible\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"/Users/bensniff/Projects/gnosis/util-contracts/contracts/StorageAccessible.sol\":{\"keccak256\":\"0xc8b52a0614f7537b65d6db188ffc5b16fd23b71d9174cb29f8020c9bf3ccb333\",\"license\":\"LGPL-3.0-only\",\"urls\":[\"bzz-raw://3445810f14c830c1a10f21df9f67014c0a8c110334431f3ac5d9f296234be505\",\"dweb:/ipfs/QmZefwGQd6A1quZZk78e4eTVRjQSwMwFCXTFNkxAvKDFmw\"]}},\"version\":1}", "bytecode": "0x608060405234801561001057600080fd5b506107b5806100206000396000f3fe608060405234801561001057600080fd5b50600436106100625760003560e01c80633a1b407a1461006757806343218e191461008c57806352b8dfc5146101b55780635624b25b1461025d57806365906ca314610280578063f84436bd14610324575b600080fd5b61006f6103d8565b604080516001600160e01b03199092168252519081900360200190f35b610140600480360360408110156100a257600080fd5b6001600160a01b038235169190810190604081016020820135600160201b8111156100cc57600080fd5b8201836020820111156100de57600080fd5b803590602001918460018302840111600160201b831117156100ff57600080fd5b91908080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152509295506103fc945050505050565b6040805160208082528351818301528351919283929083019185019080838360005b8381101561017a578181015183820152602001610162565b50505050905090810190601f1680156101a75780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b61025b600480360360408110156101cb57600080fd5b810190602081018135600160201b8111156101e557600080fd5b8201836020820111156101f757600080fd5b803590602001918460018302840111600160201b8311171561021857600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929550509135925061052b915050565b005b6101406004803603604081101561027357600080fd5b508035906020013561052f565b61025b6004803603602081101561029657600080fd5b810190602081018135600160201b8111156102b057600080fd5b8201836020820111156102c257600080fd5b803590602001918460018302840111600160201b831117156102e357600080fd5b91908080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152509295506105a4945050505050565b6101406004803603604081101561033a57600080fd5b6001600160a01b038235169190810190604081016020820135600160201b81111561036457600080fd5b82018360208201111561037657600080fd5b803590602001918460018302840111600160201b8311171561039757600080fd5b91908080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152509295506105ac945050505050565b7f43218e198a5f5c70ca65adf1973b6285a79c4d29a39cc2a8bb67b912f447dc6481565b60606000836001600160a01b0316836040518082805190602001908083835b6020831061043a5780518252601f19909201916020918201910161041b565b6001836020036101000a038019825116818451168082178552505050505050905001915050600060405180830381855af49150503d806000811461049a576040519150601f19603f3d011682016040523d82523d6000602084013e61049f565b606091505b50809350819250505061052482826040516020018083805190602001908083835b602083106104df5780518252601f1990920191602091820191016104c0565b6001836020036101000a03801982511681845116808217855250505050505090500182151560f81b8152600101925050506040516020818303038152906040526105a4565b5092915050565b9052565b6060808260200267ffffffffffffffff8111801561054c57600080fd5b506040519080825280601f01601f191660200182016040528015610577576020820181803683370190505b50905060005b8381101561059a578481015460208083028401015260010161057d565b5090505b92915050565b805160208201fd5b6060807f43218e198a5f5c70ca65adf1973b6285a79c4d29a39cc2a8bb67b912f447dc64848460405160240180836001600160a01b0316815260200180602001828103825283818151815260200191508051906020019080838360005b83811015610621578181015183820152602001610609565b50505050905090810190601f16801561064e5780820380516001836020036101000a031916815260200191505b5060408051601f198184030181529181526020820180516001600160e01b03166001600160e01b0319909816979097178752518151919750309688965090945084935091508083835b602083106106b65780518252601f199092019160209182019101610697565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d8060008114610718576040519150601f19603f3d011682016040523d82523d6000602084013e61071d565b606091505b5090508092505060008260018451038151811061073657fe5b602001015160f81c60f81b6001600160f81b031916600160f81b14905061076183600185510361052b565b801561076e57505061059e565b610777836105a4565b50509291505056fea26469706673582212202217fb0630b4d9378ac9c879fd9d3a9717ebd36dbb38c3924392851e9a189fea64736f6c63430007050033", "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106100625760003560e01c80633a1b407a1461006757806343218e191461008c57806352b8dfc5146101b55780635624b25b1461025d57806365906ca314610280578063f84436bd14610324575b600080fd5b61006f6103d8565b604080516001600160e01b03199092168252519081900360200190f35b610140600480360360408110156100a257600080fd5b6001600160a01b038235169190810190604081016020820135600160201b8111156100cc57600080fd5b8201836020820111156100de57600080fd5b803590602001918460018302840111600160201b831117156100ff57600080fd5b91908080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152509295506103fc945050505050565b6040805160208082528351818301528351919283929083019185019080838360005b8381101561017a578181015183820152602001610162565b50505050905090810190601f1680156101a75780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b61025b600480360360408110156101cb57600080fd5b810190602081018135600160201b8111156101e557600080fd5b8201836020820111156101f757600080fd5b803590602001918460018302840111600160201b8311171561021857600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929550509135925061052b915050565b005b6101406004803603604081101561027357600080fd5b508035906020013561052f565b61025b6004803603602081101561029657600080fd5b810190602081018135600160201b8111156102b057600080fd5b8201836020820111156102c257600080fd5b803590602001918460018302840111600160201b831117156102e357600080fd5b91908080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152509295506105a4945050505050565b6101406004803603604081101561033a57600080fd5b6001600160a01b038235169190810190604081016020820135600160201b81111561036457600080fd5b82018360208201111561037657600080fd5b803590602001918460018302840111600160201b8311171561039757600080fd5b91908080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152509295506105ac945050505050565b7f43218e198a5f5c70ca65adf1973b6285a79c4d29a39cc2a8bb67b912f447dc6481565b60606000836001600160a01b0316836040518082805190602001908083835b6020831061043a5780518252601f19909201916020918201910161041b565b6001836020036101000a038019825116818451168082178552505050505050905001915050600060405180830381855af49150503d806000811461049a576040519150601f19603f3d011682016040523d82523d6000602084013e61049f565b606091505b50809350819250505061052482826040516020018083805190602001908083835b602083106104df5780518252601f1990920191602091820191016104c0565b6001836020036101000a03801982511681845116808217855250505050505090500182151560f81b8152600101925050506040516020818303038152906040526105a4565b5092915050565b9052565b6060808260200267ffffffffffffffff8111801561054c57600080fd5b506040519080825280601f01601f191660200182016040528015610577576020820181803683370190505b50905060005b8381101561059a578481015460208083028401015260010161057d565b5090505b92915050565b805160208201fd5b6060807f43218e198a5f5c70ca65adf1973b6285a79c4d29a39cc2a8bb67b912f447dc64848460405160240180836001600160a01b0316815260200180602001828103825283818151815260200191508051906020019080838360005b83811015610621578181015183820152602001610609565b50505050905090810190601f16801561064e5780820380516001836020036101000a031916815260200191505b5060408051601f198184030181529181526020820180516001600160e01b03166001600160e01b0319909816979097178752518151919750309688965090945084935091508083835b602083106106b65780518252601f199092019160209182019101610697565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d8060008114610718576040519150601f19603f3d011682016040523d82523d6000602084013e61071d565b606091505b5090508092505060008260018451038151811061073657fe5b602001015160f81c60f81b6001600160f81b031916600160f81b14905061076183600185510361052b565b801561076e57505061059e565b610777836105a4565b50509291505056fea26469706673582212202217fb0630b4d9378ac9c879fd9d3a9717ebd36dbb38c3924392851e9a189fea64736f6c63430007050033", "immutableReferences": {}, "generatedSources": [], "deployedGeneratedSources": [], "sourceMap": "755:3103:6:-:0;;;;;;;;;;;;;;;;;;;", "deployedSourceMap": "755:3103:6:-:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;788:143;;;:::i;:::-;;;;-1:-1:-1;;;;;;788:143:6;;;;;;;;;;;;;;3220:337;;;;;;;;;;;;;;;;-1:-1:-1;;;;;3220:337:6;;;;;;;;;;;;;;;-1:-1:-1;;;3220:337:6;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;;3220:337:6;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;3220:337:6;;-1:-1:-1;3220:337:6;;-1:-1:-1;;;;;3220:337:6:i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;3717:139;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;;3717:139:6;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;;3717:139:6;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;3717:139:6;;-1:-1:-1;;3717:139:6;;;-1:-1:-1;3717:139:6;;-1:-1:-1;;3717:139:6:i;:::-;;1233:432;;;;;;;;;;;;;;;;-1:-1:-1;1233:432:6;;;;;;;:::i;3563:148::-;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;;3563:148:6;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;;3563:148:6;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;3563:148:6;;-1:-1:-1;3563:148:6;;-1:-1:-1;;;;;3563:148:6:i;2101:618::-;;;;;;;;;;;;;;;;-1:-1:-1;;;;;2101:618:6;;;;;;;;;;;;;;;-1:-1:-1;;;2101:618:6;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;;2101:618:6;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;2101:618:6;;-1:-1:-1;2101:618:6;;-1:-1:-1;;;;;2101:618:6:i;788:143::-;869:56;788:143;:::o;3220:337::-;3350:21;3383:12;3427:14;-1:-1:-1;;;;;3427:27:6;3468:15;3427:66;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;3427:66:6;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;3405:88;;;;;;;;3503:47;3531:8;3541:7;3514:35;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;3514:35:6;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;3503:10;:47::i;:::-;3220:337;;;;;:::o;3717:139::-;3818:22;;3804:46::o;1233:432::-;1332:12;1360:19;1392:6;1401:2;1392:11;1382:22;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;1382:22:6;;1360:44;;1419:13;1414:222;1446:6;1438:5;:14;1414:222;;;1522:18;;;1516:25;1599:4;1588:16;;;1565:40;;;1558:54;1454:7;;1414:222;;;-1:-1:-1;1652:6:6;-1:-1:-1;1233:432:6;;;;;:::o;3563:148::-;3685:8;3679:15;3672:4;3662:8;3658:19;3651:44;2101:618;2223:21;2256:22;869:56;2370:14;2398:15;2281:142;;;;;;-1:-1:-1;;;;;2281:142:6;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;2281:142:6;;;-1:-1:-1;;2281:142:6;;;;;;;;;;;;;;-1:-1:-1;;;;;2281:142:6;-1:-1:-1;;;;;;2281:142:6;;;;;;;;;2448:29;;;2281:142;;-1:-1:-1;2456:4:6;;2281:142;;-1:-1:-1;2448:29:6;;-1:-1:-1;2448:29:6;;-1:-1:-1;2281:142:6;-1:-1:-1;2448:29:6;;2281:142;2448:29;;;;;;;;;;-1:-1:-1;;2448:29:6;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2433:44;;;;;;2487:17;2507:8;2534:1;2516:8;:15;:19;2507:29;;;;;;;;;;;;;;;;-1:-1:-1;;;;;2507:37:6;;2540:4;2507:37;;;2487:57;;2554:40;2564:8;2592:1;2574:8;:15;:19;2554:9;:40::i;:::-;2608:12;2604:109;;;2636:15;;;;2604:109;2682:20;2693:8;2682:10;:20::i;:::-;2101:618;;;;;;:::o", "source": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity ^0.7.0;\n\n/// @title ViewStorageAccessible - Interface on top of StorageAccessible base class to allow simulations from view functions\ninterface ViewStorageAccessible {\n /**\n * @dev Same as `simulateDelegatecall` on StorageAccessible. Marked as view so that it can be called from external contracts\n * that want to run simulations from within view functions. Will revert if the invoked simulation attempts to change state.\n */\n function simulateDelegatecall(\n address targetContract,\n bytes memory calldataPayload\n ) external view returns (bytes memory);\n}\n\n/// @title StorageAccessible - generic base contract that allows callers to access all internal storage.\ncontract StorageAccessible {\n bytes4 public constant SIMULATE_DELEGATECALL_INTERNAL_SELECTOR = bytes4(\n keccak256(\"simulateDelegatecallInternal(address,bytes)\")\n );\n\n /**\n * @dev Reads `length` bytes of storage in the currents contract\n * @param offset - the offset in the current contract's storage in words to start reading from\n * @param length - the number of words (32 bytes) of data to read\n * @return the bytes that were read.\n */\n function getStorageAt(uint256 offset, uint256 length)\n public\n view\n returns (bytes memory)\n {\n bytes memory result = new bytes(length * 32);\n for (uint256 index = 0; index < length; index++) {\n assembly {\n let word := sload(add(offset, index))\n mstore(add(add(result, 0x20), mul(index, 0x20)), word)\n }\n }\n return result;\n }\n\n /**\n * @dev Performs a delegetecall on a targetContract in the context of self.\n * Internally reverts execution to avoid side effects (making it static). Catches revert and returns encoded result as bytes.\n * @param targetContract Address of the contract containing the code to execute.\n * @param calldataPayload Calldata that should be sent to the target contract (encoded method name and arguments).\n */\n function simulateDelegatecall(\n address targetContract,\n bytes memory calldataPayload\n ) public returns (bytes memory response) {\n bytes memory innerCall = abi.encodeWithSelector(\n SIMULATE_DELEGATECALL_INTERNAL_SELECTOR,\n targetContract,\n calldataPayload\n );\n (, response) = address(this).call(innerCall);\n bool innerSuccess = response[response.length - 1] == 0x01;\n setLength(response, response.length - 1);\n if (innerSuccess) {\n return response;\n } else {\n revertWith(response);\n }\n }\n\n /**\n * @dev Performs a delegetecall on a targetContract in the context of self.\n * Internally reverts execution to avoid side effects (making it static). Returns encoded result as revert message\n * concatenated with the success flag of the inner call as a last byte.\n * @param targetContract Address of the contract containing the code to execute.\n * @param calldataPayload Calldata that should be sent to the target contract (encoded method name and arguments).\n */\n function simulateDelegatecallInternal(\n address targetContract,\n bytes memory calldataPayload\n ) public returns (bytes memory response) {\n bool success;\n (success, response) = targetContract.delegatecall(\n calldataPayload\n );\n revertWith(abi.encodePacked(response, success));\n }\n\n function revertWith(bytes memory response) public pure {\n assembly {\n revert(add(response, 0x20), mload(response))\n }\n }\n\n function setLength(bytes memory buffer, uint256 length) public pure {\n assembly {\n mstore(buffer, length)\n }\n }\n}\n", "sourcePath": "/Users/bensniff/Projects/gnosis/util-contracts/contracts/StorageAccessible.sol", "ast": { "absolutePath": "/Users/bensniff/Projects/gnosis/util-contracts/contracts/StorageAccessible.sol", "exportedSymbols": { "StorageAccessible": [ 1833 ], "ViewStorageAccessible": [ 1681 ] }, "id": 1834, "license": "LGPL-3.0-only", "nodeType": "SourceUnit", "nodes": [ { "id": 1669, "literals": [ "solidity", "^", "0.7", ".0" ], "nodeType": "PragmaDirective", "src": "42:23:6" }, { "abstract": false, "baseContracts": [], "contractDependencies": [], "contractKind": "interface", "documentation": { "id": 1670, "nodeType": "StructuredDocumentation", "src": "67:125:6", "text": "@title ViewStorageAccessible - Interface on top of StorageAccessible base class to allow simulations from view functions" }, "fullyImplemented": false, "id": 1681, "linearizedBaseContracts": [ 1681 ], "name": "ViewStorageAccessible", "nodeType": "ContractDefinition", "nodes": [ { "documentation": { "id": 1671, "nodeType": "StructuredDocumentation", "src": "230:268:6", "text": " @dev Same as `simulateDelegatecall` on StorageAccessible. Marked as view so that it can be called from external contracts\n that want to run simulations from within view functions. Will revert if the invoked simulation attempts to change state." }, "functionSelector": "f84436bd", "id": 1680, "implemented": false, "kind": "function", "modifiers": [], "name": "simulateDelegatecall", "nodeType": "FunctionDefinition", "parameters": { "id": 1676, "nodeType": "ParameterList", "parameters": [ { "constant": false, "id": 1673, "mutability": "mutable", "name": "targetContract", "nodeType": "VariableDeclaration", "scope": 1680, "src": "542:22:6", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" }, "typeName": { "id": 1672, "name": "address", "nodeType": "ElementaryTypeName", "src": "542:7:6", "stateMutability": "nonpayable", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" } }, "visibility": "internal" }, { "constant": false, "id": 1675, "mutability": "mutable", "name": "calldataPayload", "nodeType": "VariableDeclaration", "scope": 1680, "src": "574:28:6", "stateVariable": false, "storageLocation": "memory", "typeDescriptions": { "typeIdentifier": "t_bytes_memory_ptr", "typeString": "bytes" }, "typeName": { "id": 1674, "name": "bytes", "nodeType": "ElementaryTypeName", "src": "574:5:6", "typeDescriptions": { "typeIdentifier": "t_bytes_storage_ptr", "typeString": "bytes" } }, "visibility": "internal" } ], "src": "532:76:6" }, "returnParameters": { "id": 1679, "nodeType": "ParameterList", "parameters": [ { "constant": false, "id": 1678, "mutability": "mutable", "name": "", "nodeType": "VariableDeclaration", "scope": 1680, "src": "632:12:6", "stateVariable": false, "storageLocation": "memory", "typeDescriptions": { "typeIdentifier": "t_bytes_memory_ptr", "typeString": "bytes" }, "typeName": { "id": 1677, "name": "bytes", "nodeType": "ElementaryTypeName", "src": "632:5:6", "typeDescriptions": { "typeIdentifier": "t_bytes_storage_ptr", "typeString": "bytes" } }, "visibility": "internal" } ], "src": "631:14:6" }, "scope": 1681, "src": "503:143:6", "stateMutability": "view", "virtual": false, "visibility": "external" } ], "scope": 1834, "src": "192:456:6" }, { "abstract": false, "baseContracts": [], "contractDependencies": [], "contractKind": "contract", "documentation": { "id": 1682, "nodeType": "StructuredDocumentation", "src": "650:105:6", "text": "@title StorageAccessible - generic base contract that allows callers to access all internal storage." }, "fullyImplemented": true, "id": 1833, "linearizedBaseContracts": [ 1833 ], "name": "StorageAccessible", "nodeType": "ContractDefinition", "nodes": [ { "constant": true, "functionSelector": "3a1b407a", "id": 1690, "mutability": "constant", "name": "SIMULATE_DELEGATECALL_INTERNAL_SELECTOR", "nodeType": "VariableDeclaration", "scope": 1833, "src": "788:143:6", "stateVariable": true, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_bytes4", "typeString": "bytes4" }, "typeName": { "id": 1683, "name": "bytes4", "nodeType": "ElementaryTypeName", "src": "788:6:6", "typeDescriptions": { "typeIdentifier": "t_bytes4", "typeString": "bytes4" } }, "value": { "arguments": [ { "arguments": [ { "hexValue": "73696d756c61746544656c656761746563616c6c496e7465726e616c28616464726573732c627974657329", "id": 1687, "isConstant": false, "isLValue": false, "isPure": true, "kind": "string", "lValueRequested": false, "nodeType": "Literal", "src": "879:45:6", "typeDescriptions": { "typeIdentifier": "t_stringliteral_43218e198a5f5c70ca65adf1973b6285a79c4d29a39cc2a8bb67b912f447dc64", "typeString": "literal_string \"simulateDelegatecallInternal(address,bytes)\"" }, "value": "simulateDelegatecallInternal(address,bytes)" } ], "expression": { "argumentTypes": [ { "typeIdentifier": "t_stringliteral_43218e198a5f5c70ca65adf1973b6285a79c4d29a39cc2a8bb67b912f447dc64", "typeString": "literal_string \"simulateDelegatecallInternal(address,bytes)\"" } ], "id": 1686, "name": "keccak256", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": -8, "src": "869:9:6", "typeDescriptions": { "typeIdentifier": "t_function_keccak256_pure$_t_bytes_memory_ptr_$returns$_t_bytes32_$", "typeString": "function (bytes memory) pure returns (bytes32)" } }, "id": 1688, "isConstant": false, "isLValue": false, "isPure": true, "kind": "functionCall", "lValueRequested": false, "names": [], "nodeType": "FunctionCall", "src": "869:56:6", "tryCall": false, "typeDescriptions": { "typeIdentifier": "t_bytes32", "typeString": "bytes32" } } ], "expression": { "argumentTypes": [ { "typeIdentifier": "t_bytes32", "typeString": "bytes32" } ], "id": 1685, "isConstant": false, "isLValue": false, "isPure": true, "lValueRequested": false, "nodeType": "ElementaryTypeNameExpression", "src": "853:6:6", "typeDescriptions": { "typeIdentifier": "t_type$_t_bytes4_$", "typeString": "type(bytes4)" }, "typeName": { "id": 1684, "name": "bytes4", "nodeType": "ElementaryTypeName", "src": "853:6:6", "typeDescriptions": {} } }, "id": 1689, "isConstant": false, "isLValue": false, "isPure": true, "kind": "typeConversion", "lValueRequested": false, "names": [], "nodeType": "FunctionCall", "src": "853:78:6", "tryCall": false, "typeDescriptions": { "typeIdentifier": "t_bytes4", "typeString": "bytes4" } }, "visibility": "public" }, { "body": { "id": 1724, "nodeType": "Block", "src": "1350:315:6", "statements": [ { "assignments": [ 1701 ], "declarations": [ { "constant": false, "id": 1701, "mutability": "mutable", "name": "result", "nodeType": "VariableDeclaration", "scope": 1724, "src": "1360:19:6", "stateVariable": false, "storageLocation": "memory", "typeDescriptions": { "typeIdentifier": "t_bytes_memory_ptr", "typeString": "bytes" }, "typeName": { "id": 1700, "name": "bytes", "nodeType": "ElementaryTypeName", "src": "1360:5:6", "typeDescriptions": { "typeIdentifier": "t_bytes_storage_ptr", "typeString": "bytes" } }, "visibility": "internal" } ], "id": 1708, "initialValue": { "arguments": [ { "commonType": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "id": 1706, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "leftExpression": { "id": 1704, "name": "length", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 1695, "src": "1392:6:6", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "nodeType": "BinaryOperation", "operator": "*", "rightExpression": { "hexValue": "3332", "id": 1705, "isConstant": false, "isLValue": false, "isPure": true, "kind": "number", "lValueRequested": false, "nodeType": "Literal", "src": "1401:2:6", "typeDescriptions": { "typeIdentifier": "t_rational_32_by_1", "typeString": "int_const 32" }, "value": "32" }, "src": "1392:11:6", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } } ], "expression": { "argumentTypes": [ { "typeIdentifier": "t_uint256", "typeString": "uint256" } ], "id": 1703, "isConstant": false, "isLValue": false, "isPure": true, "lValueRequested": false, "nodeType": "NewExpression", "src": "1382:9:6", "typeDescriptions": { "typeIdentifier": "t_function_objectcreation_pure$_t_uint256_$returns$_t_bytes_memory_ptr_$", "typeString": "function (uint256) pure returns (bytes memory)" }, "typeName": { "id": 1702, "name": "bytes", "nodeType": "ElementaryTypeName", "src": "1386:5:6", "typeDescriptions": { "typeIdentifier": "t_bytes_storage_ptr", "typeString": "bytes" } } }, "id": 1707, "isConstant": false, "isLValue": false, "isPure": false, "kind": "functionCall", "lValueRequested": false, "names": [], "nodeType": "FunctionCall", "src": "1382:22:6", "tryCall": false, "typeDescriptions": { "typeIdentifier": "t_bytes_memory_ptr", "typeString": "bytes memory" } }, "nodeType": "VariableDeclarationStatement", "src": "1360:44:6" }, { "body": { "id": 1720, "nodeType": "Block", "src": "1463:173:6", "statements": [ { "AST": { "nodeType": "YulBlock", "src": "1486:140:6", "statements": [ { "nodeType": "YulVariableDeclaration", "src": "1504:37:6", "value": { "arguments": [ { "arguments": [ { "name": "offset", "nodeType": "YulIdentifier", "src": "1526:6:6" }, { "name": "index", "nodeType": "YulIdentifier", "src": "1534:5:6" } ], "functionName": { "name": "add", "nodeType": "YulIdentifier", "src": "1522:3:6" }, "nodeType": "YulFunctionCall", "src": "1522:18:6" } ], "functionName": { "name": "sload", "nodeType": "YulIdentifier", "src": "1516:5:6" }, "nodeType": "YulFunctionCall", "src": "1516:25:6" }, "variables": [ { "name": "word", "nodeType": "YulTypedName", "src": "1508:4:6", "type": "" } ] }, { "expression": { "arguments": [ { "arguments": [ { "arguments": [ { "name": "result", "nodeType": "YulIdentifier", "src": "1573:6:6" }, { "kind": "number", "nodeType": "YulLiteral", "src": "1581:4:6", "type": "", "value": "0x20" } ], "functionName": { "name": "add", "nodeType": "YulIdentifier", "src": "1569:3:6" }, "nodeType": "YulFunctionCall", "src": "1569:17:6" }, { "arguments": [ { "name": "index", "nodeType": "YulIdentifier", "src": "1592:5:6" }, { "kind": "number", "nodeType": "YulLiteral", "src": "1599:4:6", "type": "", "value": "0x20" } ], "functionName": { "name": "mul", "nodeType": "YulIdentifier", "src": "1588:3:6" }, "nodeType": "YulFunctionCall", "src": "1588:16:6" } ], "functionName": { "name": "add", "nodeType": "YulIdentifier", "src": "1565:3:6" }, "nodeType": "YulFunctionCall", "src": "1565:40:6" }, { "name": "word", "nodeType": "YulIdentifier", "src": "1607:4:6" } ], "functionName": { "name": "mstore", "nodeType": "YulIdentifier", "src": "1558:6:6" }, "nodeType": "YulFunctionCall", "src": "1558:54:6" }, "nodeType": "YulExpressionStatement", "src": "1558:54:6" } ] }, "evmVersion": "istanbul", "externalReferences": [ { "declaration": 1710, "isOffset": false, "isSlot": false, "src": "1534:5:6", "valueSize": 1 }, { "declaration": 1710, "isOffset": false, "isSlot": false, "src": "1592:5:6", "valueSize": 1 }, { "declaration": 1693, "isOffset": false, "isSlot": false, "src": "1526:6:6", "valueSize": 1 }, { "declaration": 1701, "isOffset": false, "isSlot": false, "src": "1573:6:6", "valueSize": 1 } ], "id": 1719, "nodeType": "InlineAssembly", "src": "1477:149:6" } ] }, "condition": { "commonType": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "id": 1715, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "leftExpression": { "id": 1713, "name": "index", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 1710, "src": "1438:5:6", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "nodeType": "BinaryOperation", "operator": "<", "rightExpression": { "id": 1714, "name": "length", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 1695, "src": "1446:6:6", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "src": "1438:14:6", "typeDescriptions": { "typeIdentifier": "t_bool", "typeString": "bool" } }, "id": 1721, "initializationExpression": { "assignments": [ 1710 ], "declarations": [ { "constant": false, "id": 1710, "mutability": "mutable", "name": "index", "nodeType": "VariableDeclaration", "scope": 1721, "src": "1419:13:6", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "typeName": { "id": 1709, "name": "uint256", "nodeType": "ElementaryTypeName", "src": "1419:7:6", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "visibility": "internal" } ], "id": 1712, "initialValue": { "hexValue": "30", "id": 1711, "isConstant": false, "isLValue": false, "isPure": true, "kind": "number", "lValueRequested": false, "nodeType": "Literal", "src": "1435:1:6", "typeDescriptions": { "typeIdentifier": "t_rational_0_by_1", "typeString": "int_const 0" }, "value": "0" }, "nodeType": "Varia