UNPKG

@etherspot/contracts

Version:

Etherspot Solidity contracts

848 lines 28.5 kB
{ "id": "64abd42f36b9c7d30a785bf4920dac7c", "_format": "hh-sol-build-info-1", "solcVersion": "0.8.4", "solcLongVersion": "0.8.4+commit.c7e474f2", "input": { "language": "Solidity", "sources": { "DiamondReentrancyGuard_flat.sol": { "content": "// SPDX-License-Identifier: MIT\n// File: common/helpers/DiamondReentrancyGuard.sol\n\npragma solidity 0.8.4;\n\n/// @title Reentrancy Guard\n/// @notice Abstract contract to provide protection against reentrancy\nabstract contract ReentrancyGuard {\n //////////////////////////////////////////////////////////////\n ////////////////////////// Storage ///////////////////////////\n //////////////////////////////////////////////////////////////\n\n bytes32 private constant NAMESPACE =\n keccak256(\"io.etherspot.helpers.reentrancyguard\");\n\n //////////////////////////////////////////////////////////////\n ////////////////////////// Structs ///////////////////////////\n //////////////////////////////////////////////////////////////\n\n struct ReentrancyStorage {\n uint256 status;\n }\n\n //////////////////////////////////////////////////////////////\n ////////////////////////// Errors ////////////////////////////\n //////////////////////////////////////////////////////////////\n\n error ReentrancyError();\n\n //////////////////////////////////////////////////////////////\n ///////////////////////// Constants //////////////////////////\n //////////////////////////////////////////////////////////////\n\n uint256 private constant _NOT_ENTERED = 0;\n uint256 private constant _ENTERED = 1;\n\n //////////////////////////////////////////////////////////////\n ///////////////////////// Modifiers ///////////////////////////\n //////////////////////////////////////////////////////////////\n\n modifier nonReentrant() {\n ReentrancyStorage storage s = reentrancyStorage();\n if (s.status == _ENTERED) revert ReentrancyError();\n s.status = _ENTERED;\n _;\n s.status = _NOT_ENTERED;\n }\n\n //////////////////////////////////////////////////////////////\n ////////////////////// Private Functions /////////////////////\n //////////////////////////////////////////////////////////////\n\n /// @dev fetch local storage\n function reentrancyStorage()\n private\n pure\n returns (ReentrancyStorage storage data)\n {\n bytes32 position = NAMESPACE;\n // solhint-disable-next-line no-inline-assembly\n assembly {\n data.slot := position\n }\n }\n}\n" } }, "settings": { "optimizer": { "enabled": false, "runs": 200 }, "outputSelection": { "*": { "": [ "ast" ], "*": [ "abi", "metadata", "devdoc", "userdoc", "storageLayout", "evm.legacyAssembly", "evm.bytecode", "evm.deployedBytecode", "evm.methodIdentifiers", "evm.gasEstimates", "evm.assembly" ] } } } }, "output": { "contracts": { "DiamondReentrancyGuard_flat.sol": { "ReentrancyGuard": { "abi": [ { "inputs": [], "name": "ReentrancyError", "type": "error" } ], "devdoc": { "kind": "dev", "methods": {}, "title": "Reentrancy Guard", "version": 1 }, "evm": { "assembly": "", "bytecode": { "generatedSources": [], "linkReferences": {}, "object": "", "opcodes": "", "sourceMap": "" }, "deployedBytecode": { "generatedSources": [], "immutableReferences": {}, "linkReferences": {}, "object": "", "opcodes": "", "sourceMap": "" }, "gasEstimates": null, "legacyAssembly": null, "methodIdentifiers": {} }, "metadata": "{\"compiler\":{\"version\":\"0.8.4+commit.c7e474f2\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[],\"name\":\"ReentrancyError\",\"type\":\"error\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{},\"title\":\"Reentrancy Guard\",\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"notice\":\"Abstract contract to provide protection against reentrancy\",\"version\":1}},\"settings\":{\"compilationTarget\":{\"DiamondReentrancyGuard_flat.sol\":\"ReentrancyGuard\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":false,\"runs\":200},\"remappings\":[]},\"sources\":{\"DiamondReentrancyGuard_flat.sol\":{\"keccak256\":\"0x253afc37df1b9da8e66b3c5d939ed953cbc34a18f65fa4e7448584cdc85bfbeb\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://29360ccddf81fe5efad4576a3c1f5878e2dd9a4ec5a9e56c6ef491496ac07099\",\"dweb:/ipfs/QmeMZrJo7jcWwQqFXCU3frX63VgeZLEKTyjtnxDNE9BNtx\"]}},\"version\":1}", "storageLayout": { "storage": [], "types": null }, "userdoc": { "kind": "user", "methods": {}, "notice": "Abstract contract to provide protection against reentrancy", "version": 1 } } } }, "sources": { "DiamondReentrancyGuard_flat.sol": { "ast": { "absolutePath": "DiamondReentrancyGuard_flat.sol", "exportedSymbols": { "ReentrancyGuard": [ 62 ] }, "id": 63, "license": "MIT", "nodeType": "SourceUnit", "nodes": [ { "id": 1, "literals": [ "solidity", "0.8", ".4" ], "nodeType": "PragmaDirective", "src": "84:22:0" }, { "abstract": true, "baseContracts": [], "contractDependencies": [], "contractKind": "contract", "documentation": { "id": 2, "nodeType": "StructuredDocumentation", "src": "108:99:0", "text": "@title Reentrancy Guard\n @notice Abstract contract to provide protection against reentrancy" }, "fullyImplemented": true, "id": 62, "linearizedBaseContracts": [ 62 ], "name": "ReentrancyGuard", "nameLocation": "225:15:0", "nodeType": "ContractDefinition", "nodes": [ { "constant": true, "id": 7, "mutability": "constant", "name": "NAMESPACE", "nameLocation": "474:9:0", "nodeType": "VariableDeclaration", "scope": 62, "src": "449:94:0", "stateVariable": true, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_bytes32", "typeString": "bytes32" }, "typeName": { "id": 3, "name": "bytes32", "nodeType": "ElementaryTypeName", "src": "449:7:0", "typeDescriptions": { "typeIdentifier": "t_bytes32", "typeString": "bytes32" } }, "value": { "arguments": [ { "hexValue": "696f2e657468657273706f742e68656c706572732e7265656e7472616e63796775617264", "id": 5, "isConstant": false, "isLValue": false, "isPure": true, "kind": "string", "lValueRequested": false, "nodeType": "Literal", "src": "504:38:0", "typeDescriptions": { "typeIdentifier": "t_stringliteral_c59b5acc5a6673a6c49ca2de898f87adbd9fdfdff36f689476b1c9e0c50964b4", "typeString": "literal_string \"io.etherspot.helpers.reentrancyguard\"" }, "value": "io.etherspot.helpers.reentrancyguard" } ], "expression": { "argumentTypes": [ { "typeIdentifier": "t_stringliteral_c59b5acc5a6673a6c49ca2de898f87adbd9fdfdff36f689476b1c9e0c50964b4", "typeString": "literal_string \"io.etherspot.helpers.reentrancyguard\"" } ], "id": 4, "name": "keccak256", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 4294967288, "src": "494:9:0", "typeDescriptions": { "typeIdentifier": "t_function_keccak256_pure$_t_bytes_memory_ptr_$returns$_t_bytes32_$", "typeString": "function (bytes memory) pure returns (bytes32)" } }, "id": 6, "isConstant": false, "isLValue": false, "isPure": true, "kind": "functionCall", "lValueRequested": false, "names": [], "nodeType": "FunctionCall", "src": "494:49:0", "tryCall": false, "typeDescriptions": { "typeIdentifier": "t_bytes32", "typeString": "bytes32" } }, "visibility": "private" }, { "canonicalName": "ReentrancyGuard.ReentrancyStorage", "id": 10, "members": [ { "constant": false, "id": 9, "mutability": "mutable", "name": "status", "nameLocation": "795:6:0", "nodeType": "VariableDeclaration", "scope": 10, "src": "787:14:0", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "typeName": { "id": 8, "name": "uint256", "nodeType": "ElementaryTypeName", "src": "787:7:0", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "visibility": "internal" } ], "name": "ReentrancyStorage", "nameLocation": "759:17:0", "nodeType": "StructDefinition", "scope": 62, "src": "752:56:0", "visibility": "public" }, { "id": 12, "name": "ReentrancyError", "nameLocation": "1022:15:0", "nodeType": "ErrorDefinition", "parameters": { "id": 11, "nodeType": "ParameterList", "parameters": [], "src": "1037:2:0" }, "src": "1016:24:0" }, { "constant": true, "id": 15, "mutability": "constant", "name": "_NOT_ENTERED", "nameLocation": "1273:12:0", "nodeType": "VariableDeclaration", "scope": 62, "src": "1248:41:0", "stateVariable": true, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "typeName": { "id": 13, "name": "uint256", "nodeType": "ElementaryTypeName", "src": "1248:7:0", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "value": { "hexValue": "30", "id": 14, "isConstant": false, "isLValue": false, "isPure": true, "kind": "number", "lValueRequested": false, "nodeType": "Literal", "src": "1288:1:0", "typeDescriptions": { "typeIdentifier": "t_rational_0_by_1", "typeString": "int_const 0" }, "value": "0" }, "visibility": "private" }, { "constant": true, "id": 18, "mutability": "constant", "name": "_ENTERED", "nameLocation": "1320:8:0", "nodeType": "VariableDeclaration", "scope": 62, "src": "1295:37:0", "stateVariable": true, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "typeName": { "id": 16, "name": "uint256", "nodeType": "ElementaryTypeName", "src": "1295:7:0", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "value": { "hexValue": "31", "id": 17, "isConstant": false, "isLValue": false, "isPure": true, "kind": "number", "lValueRequested": false, "nodeType": "Literal", "src": "1331:1:0", "typeDescriptions": { "typeIdentifier": "t_rational_1_by_1", "typeString": "int_const 1" }, "value": "1" }, "visibility": "private" }, { "body": { "id": 47, "nodeType": "Block", "src": "1566:199:0", "statements": [ { "assignments": [ 22 ], "declarations": [ { "constant": false, "id": 22, "mutability": "mutable", "name": "s", "nameLocation": "1602:1:0", "nodeType": "VariableDeclaration", "scope": 47, "src": "1576:27:0", "stateVariable": false, "storageLocation": "storage", "typeDescriptions": { "typeIdentifier": "t_struct$_ReentrancyStorage_$10_storage_ptr", "typeString": "struct ReentrancyGuard.ReentrancyStorage" }, "typeName": { "id": 21, "nodeType": "UserDefinedTypeName", "pathNode": { "id": 20, "name": "ReentrancyStorage", "nodeType": "IdentifierPath", "referencedDeclaration": 10, "src": "1576:17:0" }, "referencedDeclaration": 10, "src": "1576:17:0", "typeDescriptions": { "typeIdentifier": "t_struct$_ReentrancyStorage_$10_storage_ptr", "typeString": "struct ReentrancyGuard.ReentrancyStorage" } }, "visibility": "internal" } ], "id": 25, "initialValue": { "arguments": [], "expression": { "argumentTypes": [], "id": 23, "name": "reentrancyStorage", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 61, "src": "1606:17:0", "typeDescriptions": { "typeIdentifier": "t_function_internal_pure$__$returns$_t_struct$_ReentrancyStorage_$10_storage_ptr_$", "typeString": "function () pure returns (struct ReentrancyGuard.ReentrancyStorage storage pointer)" } }, "id": 24, "isConstant": false, "isLValue": false, "isPure": false, "kind": "functionCall", "lValueRequested": false, "names": [], "nodeType": "FunctionCall", "src": "1606:19:0", "tryCall": false, "typeDescriptions": { "typeIdentifier": "t_struct$_ReentrancyStorage_$10_storage_ptr", "typeString": "struct ReentrancyGuard.ReentrancyStorage storage pointer" } }, "nodeType": "VariableDeclarationStatement", "src": "1576:49:0" }, { "condition": { "commonType": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "id": 29, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "leftExpression": { "expression": { "id": 26, "name": "s", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 22, "src": "1639:1:0", "typeDescriptions": { "typeIdentifier": "t_struct$_ReentrancyStorage_$10_storage_ptr", "typeString": "struct ReentrancyGuard.ReentrancyStorage storage pointer" } }, "id": 27, "isConstant": false, "isLValue": true, "isPure": false, "lValueRequested": false, "memberName": "status", "nodeType": "MemberAccess", "referencedDeclaration": 9, "src": "1639:8:0", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "nodeType": "BinaryOperation", "operator": "==", "rightExpression": { "id": 28, "name": "_ENTERED", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 18, "src": "1651:8:0", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "src": "1639:20:0", "typeDescriptions": { "typeIdentifier": "t_bool", "typeString": "bool" } }, "id": 33, "nodeType": "IfStatement", "src": "1635:50:0", "trueBody": { "errorCall": { "arguments": [], "expression": { "argumentTypes": [], "id": 30, "name": "ReentrancyError", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 12, "src": "1668:15:0", "typeDescriptions": { "typeIdentifier": "t_function_error_pure$__$returns$__$", "typeString": "function () pure" } }, "id": 31, "isConstant": false, "isLValue": false, "isPure": false, "kind": "functionCall", "lValueRequested": false, "names": [], "nodeType": "FunctionCall", "src": "1668:17:0", "tryCall": false, "typeDescriptions": { "typeIdentifier": "t_tuple$__$", "typeString": "tuple()" } }, "id": 32, "nodeType": "RevertStatement", "src": "1661:24:0" } }, { "expression": { "id": 38, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "leftHandSide": { "expression": { "id": 34, "name": "s", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 22, "src": "1695:1:0", "typeDescriptions": { "typeIdentifier": "t_struct$_ReentrancyStorage_$10_storage_ptr", "typeString": "struct ReentrancyGuard.ReentrancyStorage storage pointer" } }, "id": 36, "isConstant": false, "isLValue": true, "isPure": false, "lValueRequested": true, "memberName": "status", "nodeType": "MemberAccess", "referencedDeclaration": 9, "src": "1695:8:0", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "nodeType": "Assignment", "operator": "=", "rightHandSide": { "id": 37, "name": "_ENTERED", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 18, "src": "1706:8:0", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "src": "1695:19:0", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "id": 39, "nodeType": "ExpressionStatement", "src": "1695:19:0" }, { "id": 40, "nodeType": "PlaceholderStatement", "src": "1724:1:0" }, { "expression": { "id": 45, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "leftHandSide": { "expression": { "id": 41, "name": "s", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 22, "src": "1735:1:0", "typeDescriptions": { "typeIdentifier": "t_struct$_ReentrancyStorage_$10_storage_ptr", "typeString": "struct ReentrancyGuard.ReentrancyStorage storage pointer" } }, "id": 43, "isConstant": false, "isLValue": true, "isPure": false, "lValueRequested": true, "memberName": "status", "nodeType": "MemberAccess", "referencedDeclaration": 9, "src": "1735:8:0", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "nodeType": "Assignment", "operator": "=", "rightHandSide": { "id": 44, "name": "_NOT_ENTERED", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 15, "src": "1746:12:0", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "src": "1735:23:0", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "id": 46, "nodeType": "ExpressionStatement", "src": "1735:23:0" } ] }, "id": 48, "name": "nonReentrant", "nameLocation": "1551:12:0", "nodeType": "ModifierDefinition", "parameters": { "id": 19, "nodeType": "ParameterList", "parameters": [], "src": "1563:2:0" }, "src": "1542:223:0", "virtual": false, "visibility": "internal" }, { "body": { "id": 60, "nodeType": "Block", "src": "2117:164:0", "statements": [ { "assignments": [ 56 ], "declarations": [ { "constant": false, "id": 56, "mutability": "mutable", "name": "position", "nameLocation": "2135:8:0", "nodeType": "VariableDeclaration", "scope": 60, "src": "2127:16:0", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_bytes32", "typeString": "bytes32" }, "typeName": { "id": 55, "name": "bytes32", "nodeType": "ElementaryTypeName", "src": "2127:7:0", "typeDescriptions": { "typeIdentifier": "t_bytes32", "typeString": "bytes32" } }, "visibility": "internal" } ], "id": 58, "initialValue": { "id": 57, "name": "NAMESPACE", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 7, "src": "2146:9:0", "typeDescriptions": { "typeIdentifier": "t_bytes32", "typeString": "bytes32" } }, "nodeType": "VariableDeclarationStatement", "src": "2127:28:0" }, { "AST": { "nodeType": "YulBlock", "src": "2230:45:0", "statements": [ { "nodeType": "YulAssignment", "src": "2244:21:0", "value": { "name": "position", "nodeType": "YulIdentifier", "src": "2257:8:0" }, "variableNames": [ { "name": "data.slot", "nodeType": "YulIdentifier", "src": "2244:9:0" } ] } ] }, "evmVersion": "istanbul", "externalReferences": [ { "declaration": 53, "isOffset": false, "isSlot": true, "src": "2244:9:0", "suffix": "slot", "valueSize": 1 }, { "declaration": 56, "isOffset": false, "isSlot": false, "src": "2257:8:0", "valueSize": 1 } ], "id": 59, "nodeType": "InlineAssembly", "src": "2221:54:0" } ] }, "documentation": { "id": 49, "nodeType": "StructuredDocumentation", "src": "1973:28:0", "text": "@dev fetch local storage" }, "id": 61, "implemented": true, "kind": "function", "modifiers": [], "name": "reentrancyStorage", "nameLocation": "2015:17:0", "nodeType": "FunctionDefinition", "parameters": { "id": 50, "nodeType": "ParameterList", "parameters": [], "src": "2032:2:0" }, "returnParameters": { "id": 54, "nodeType": "ParameterList", "parameters": [ { "constant": false, "id": 53, "mutability": "mutable", "name": "data", "nameLocation": "2107:4:0", "nodeType": "VariableDeclaration", "scope": 61, "src": "2081:30:0", "stateVariable": false, "storageLocation": "storage", "typeDescriptions": { "typeIdentifier": "t_struct$_ReentrancyStorage_$10_storage_ptr", "typeString": "struct ReentrancyGuard.ReentrancyStorage" }, "typeName": { "id": 52, "nodeType": "UserDefinedTypeName", "pathNode": { "id": 51, "name": "ReentrancyStorage", "nodeType": "IdentifierPath", "referencedDeclaration": 10, "src": "2081:17:0" }, "referencedDeclaration": 10, "src": "2081:17:0", "typeDescriptions": { "typeIdentifier": "t_struct$_ReentrancyStorage_$10_storage_ptr", "typeString": "struct ReentrancyGuard.ReentrancyStorage" } }, "visibility": "internal" } ], "src": "2080:32:0" }, "scope": 62, "src": "2006:275:0", "stateMutability": "pure", "virtual": false, "visibility": "private" } ], "scope": 63, "src": "207:2076:0", "usedErrors": [ 12 ] } ], "src": "84:2200:0" }, "id": 0 } } } }