UNPKG

hardlydifficult-eth

Version:

A collection of reusable contracts and Javascript helpers for Ethereum.

851 lines 34.8 kB
{ "contractName": "Clone2Probe", "abi": [], "metadata": "{\"compiler\":{\"version\":\"0.6.10+commit.00c0fcaf\"},\"language\":\"Solidity\",\"output\":{\"abi\":[],\"devdoc\":{\"methods\":{}},\"userdoc\":{\"methods\":{}}},\"settings\":{\"compilationTarget\":{\"project:/contracts/proxies/Clone2Probe.sol\":\"Clone2Probe\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":2000000},\"remappings\":[]},\"sources\":{\"project:/contracts/proxies/Clone2Probe.sol\":{\"keccak256\":\"0x2ed892746cadebdf1c4810f648ad3d65b15581a7078cdb1d9e1e9e6475bef238\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://bd836231a996d826f9843bfacc0090cbc8c904ce4261637d574e9f657ded1e2e\",\"dweb:/ipfs/QmY94D7LXRPKstwpUF73K4HxEQbuz1gLgWG5uM6oSjTRUC\"]}},\"version\":1}", "bytecode": "0x60566023600b82828239805160001a607314601657fe5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea2646970667358221220d6ce131681b8bc3f32adc2f5c001d752d307183e2f9474369183c145f9f78a6b64736f6c634300060a0033", "deployedBytecode": "0x73000000000000000000000000000000000000000030146080604052600080fdfea2646970667358221220d6ce131681b8bc3f32adc2f5c001d752d307183e2f9474369183c145f9f78a6b64736f6c634300060a0033", "immutableReferences": {}, "sourceMap": "177:1010:19:-:0;;;;;;;;;;;;;;;;;;;;;;;;;", "deployedSourceMap": "177:1010:19:-:0;;;;;;;;", "source": "// SPDX-License-Identifier: MIT\npragma solidity ^0.6.0;\n\n\n// https://github.com/OpenZeppelin/openzeppelin-sdk/blob/master/packages/lib/contracts/upgradeability/ProxyFactory.sol\nlibrary Clone2Probe\n{\n function getClone2Address(\n address target,\n bytes32 salt\n ) internal view\n returns (address cloneAddress)\n {\n // solium-disable-next-line\n assembly\n {\n let pointer := mload(0x40)\n\n // Create the bytecode for deployment based on the Minimal Proxy Standard (EIP-1167)\n mstore(pointer, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000)\n mstore(add(pointer, 0x14), shl(96, target))\n mstore(add(pointer, 0x28), 0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000)\n\n // Calculate the hash\n let contractCodeHash := keccak256(pointer, 0x37)\n\n // 0xff\n mstore(pointer, 0xff00000000000000000000000000000000000000000000000000000000000000)\n // this (byte 1 - 21)\n mstore(add(pointer, 0x1), shl(96, address()))\n\n // salt\n mstore(add(pointer, 0x15), salt)\n\n // hash\n mstore(add(pointer, 0x35), contractCodeHash)\n\n cloneAddress := keccak256(pointer, 0x55)\n }\n }\n}\n", "sourcePath": "/home/circleci/repo/contracts/proxies/Clone2Probe.sol", "ast": { "absolutePath": "project:/contracts/proxies/Clone2Probe.sol", "exportedSymbols": { "Clone2Probe": [ 3769 ] }, "id": 3770, "license": "MIT", "nodeType": "SourceUnit", "nodes": [ { "id": 3757, "literals": [ "solidity", "^", "0.6", ".0" ], "nodeType": "PragmaDirective", "src": "32:23:19" }, { "abstract": false, "baseContracts": [], "contractDependencies": [], "contractKind": "library", "documentation": null, "fullyImplemented": true, "id": 3769, "linearizedBaseContracts": [ 3769 ], "name": "Clone2Probe", "nodeType": "ContractDefinition", "nodes": [ { "body": { "id": 3767, "nodeType": "Block", "src": "320:865:19", "statements": [ { "AST": { "nodeType": "YulBlock", "src": "371:810:19", "statements": [ { "nodeType": "YulVariableDeclaration", "src": "379:26:19", "value": { "arguments": [ { "kind": "number", "nodeType": "YulLiteral", "src": "400:4:19", "type": "", "value": "0x40" } ], "functionName": { "name": "mload", "nodeType": "YulIdentifier", "src": "394:5:19" }, "nodeType": "YulFunctionCall", "src": "394:11:19" }, "variables": [ { "name": "pointer", "nodeType": "YulTypedName", "src": "383:7:19", "type": "" } ] }, { "expression": { "arguments": [ { "name": "pointer", "nodeType": "YulIdentifier", "src": "511:7:19" }, { "kind": "number", "nodeType": "YulLiteral", "src": "520:66:19", "type": "", "value": "0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000" } ], "functionName": { "name": "mstore", "nodeType": "YulIdentifier", "src": "504:6:19" }, "nodeType": "YulFunctionCall", "src": "504:83:19" }, "nodeType": "YulExpressionStatement", "src": "504:83:19" }, { "expression": { "arguments": [ { "arguments": [ { "name": "pointer", "nodeType": "YulIdentifier", "src": "605:7:19" }, { "kind": "number", "nodeType": "YulLiteral", "src": "614:4:19", "type": "", "value": "0x14" } ], "functionName": { "name": "add", "nodeType": "YulIdentifier", "src": "601:3:19" }, "nodeType": "YulFunctionCall", "src": "601:18:19" }, { "arguments": [ { "kind": "number", "nodeType": "YulLiteral", "src": "625:2:19", "type": "", "value": "96" }, { "name": "target", "nodeType": "YulIdentifier", "src": "629:6:19" } ], "functionName": { "name": "shl", "nodeType": "YulIdentifier", "src": "621:3:19" }, "nodeType": "YulFunctionCall", "src": "621:15:19" } ], "functionName": { "name": "mstore", "nodeType": "YulIdentifier", "src": "594:6:19" }, "nodeType": "YulFunctionCall", "src": "594:43:19" }, "nodeType": "YulExpressionStatement", "src": "594:43:19" }, { "expression": { "arguments": [ { "arguments": [ { "name": "pointer", "nodeType": "YulIdentifier", "src": "655:7:19" }, { "kind": "number", "nodeType": "YulLiteral", "src": "664:4:19", "type": "", "value": "0x28" } ], "functionName": { "name": "add", "nodeType": "YulIdentifier", "src": "651:3:19" }, "nodeType": "YulFunctionCall", "src": "651:18:19" }, { "kind": "number", "nodeType": "YulLiteral", "src": "671:66:19", "type": "", "value": "0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000" } ], "functionName": { "name": "mstore", "nodeType": "YulIdentifier", "src": "644:6:19" }, "nodeType": "YulFunctionCall", "src": "644:94:19" }, "nodeType": "YulExpressionStatement", "src": "644:94:19" }, { "nodeType": "YulVariableDeclaration", "src": "774:48:19", "value": { "arguments": [ { "name": "pointer", "nodeType": "YulIdentifier", "src": "808:7:19" }, { "kind": "number", "nodeType": "YulLiteral", "src": "817:4:19", "type": "", "value": "0x37" } ], "functionName": { "name": "keccak256", "nodeType": "YulIdentifier", "src": "798:9:19" }, "nodeType": "YulFunctionCall", "src": "798:24:19" }, "variables": [ { "name": "contractCodeHash", "nodeType": "YulTypedName", "src": "778:16:19", "type": "" } ] }, { "expression": { "arguments": [ { "name": "pointer", "nodeType": "YulIdentifier", "src": "851:7:19" }, { "kind": "number", "nodeType": "YulLiteral", "src": "860:66:19", "type": "", "value": "0xff00000000000000000000000000000000000000000000000000000000000000" } ], "functionName": { "name": "mstore", "nodeType": "YulIdentifier", "src": "844:6:19" }, "nodeType": "YulFunctionCall", "src": "844:83:19" }, "nodeType": "YulExpressionStatement", "src": "844:83:19" }, { "expression": { "arguments": [ { "arguments": [ { "name": "pointer", "nodeType": "YulIdentifier", "src": "973:7:19" }, { "kind": "number", "nodeType": "YulLiteral", "src": "982:3:19", "type": "", "value": "0x1" } ], "functionName": { "name": "add", "nodeType": "YulIdentifier", "src": "969:3:19" }, "nodeType": "YulFunctionCall", "src": "969:17:19" }, { "arguments": [ { "kind": "number", "nodeType": "YulLiteral", "src": "992:2:19", "type": "", "value": "96" }, { "arguments": [], "functionName": { "name": "address", "nodeType": "YulIdentifier", "src": "996:7:19" }, "nodeType": "YulFunctionCall", "src": "996:9:19" } ], "functionName": { "name": "shl", "nodeType": "YulIdentifier", "src": "988:3:19" }, "nodeType": "YulFunctionCall", "src": "988:18:19" } ], "functionName": { "name": "mstore", "nodeType": "YulIdentifier", "src": "962:6:19" }, "nodeType": "YulFunctionCall", "src": "962:45:19" }, "nodeType": "YulExpressionStatement", "src": "962:45:19" }, { "expression": { "arguments": [ { "arguments": [ { "name": "pointer", "nodeType": "YulIdentifier", "src": "1040:7:19" }, { "kind": "number", "nodeType": "YulLiteral", "src": "1049:4:19", "type": "", "value": "0x15" } ], "functionName": { "name": "add", "nodeType": "YulIdentifier", "src": "1036:3:19" }, "nodeType": "YulFunctionCall", "src": "1036:18:19" }, { "name": "salt", "nodeType": "YulIdentifier", "src": "1056:4:19" } ], "functionName": { "name": "mstore", "nodeType": "YulIdentifier", "src": "1029:6:19" }, "nodeType": "YulFunctionCall", "src": "1029:32:19" }, "nodeType": "YulExpressionStatement", "src": "1029:32:19" }, { "expression": { "arguments": [ { "arguments": [ { "name": "pointer", "nodeType": "YulIdentifier", "src": "1094:7:19" }, { "kind": "number", "nodeType": "YulLiteral", "src": "1103:4:19", "type": "", "value": "0x35" } ], "functionName": { "name": "add", "nodeType": "YulIdentifier", "src": "1090:3:19" }, "nodeType": "YulFunctionCall", "src": "1090:18:19" }, { "name": "contractCodeHash", "nodeType": "YulIdentifier", "src": "1110:16:19" } ], "functionName": { "name": "mstore", "nodeType": "YulIdentifier", "src": "1083:6:19" }, "nodeType": "YulFunctionCall", "src": "1083:44:19" }, "nodeType": "YulExpressionStatement", "src": "1083:44:19" }, { "nodeType": "YulAssignment", "src": "1135:40:19", "value": { "arguments": [ { "name": "pointer", "nodeType": "YulIdentifier", "src": "1161:7:19" }, { "kind": "number", "nodeType": "YulLiteral", "src": "1170:4:19", "type": "", "value": "0x55" } ], "functionName": { "name": "keccak256", "nodeType": "YulIdentifier", "src": "1151:9:19" }, "nodeType": "YulFunctionCall", "src": "1151:24:19" }, "variableNames": [ { "name": "cloneAddress", "nodeType": "YulIdentifier", "src": "1135:12:19" } ] } ] }, "evmVersion": "istanbul", "externalReferences": [ { "declaration": 3764, "isOffset": false, "isSlot": false, "src": "1135:12:19", "valueSize": 1 }, { "declaration": 3761, "isOffset": false, "isSlot": false, "src": "1056:4:19", "valueSize": 1 }, { "declaration": 3759, "isOffset": false, "isSlot": false, "src": "629:6:19", "valueSize": 1 } ], "id": 3766, "nodeType": "InlineAssembly", "src": "358:823:19" } ] }, "documentation": null, "id": 3768, "implemented": true, "kind": "function", "modifiers": [], "name": "getClone2Address", "nodeType": "FunctionDefinition", "overrides": null, "parameters": { "id": 3762, "nodeType": "ParameterList", "parameters": [ { "constant": false, "id": 3759, "mutability": "mutable", "name": "target", "nodeType": "VariableDeclaration", "overrides": null, "scope": 3768, "src": "232:14:19", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" }, "typeName": { "id": 3758, "name": "address", "nodeType": "ElementaryTypeName", "src": "232:7:19", "stateMutability": "nonpayable", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" } }, "value": null, "visibility": "internal" }, { "constant": false, "id": 3761, "mutability": "mutable", "name": "salt", "nodeType": "VariableDeclaration", "overrides": null, "scope": 3768, "src": "252:12:19", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_bytes32", "typeString": "bytes32" }, "typeName": { "id": 3760, "name": "bytes32", "nodeType": "ElementaryTypeName", "src": "252:7:19", "typeDescriptions": { "typeIdentifier": "t_bytes32", "typeString": "bytes32" } }, "value": null, "visibility": "internal" } ], "src": "226:42:19" }, "returnParameters": { "id": 3765, "nodeType": "ParameterList", "parameters": [ { "constant": false, "id": 3764, "mutability": "mutable", "name": "cloneAddress", "nodeType": "VariableDeclaration", "overrides": null, "scope": 3768, "src": "296:20:19", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" }, "typeName": { "id": 3763, "name": "address", "nodeType": "ElementaryTypeName", "src": "296:7:19", "stateMutability": "nonpayable", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" } }, "value": null, "visibility": "internal" } ], "src": "295:22:19" }, "scope": 3769, "src": "201:984:19", "stateMutability": "view", "virtual": false, "visibility": "internal" } ], "scope": 3770, "src": "177:1010:19" } ], "src": "32:1156:19" }, "legacyAST": { "attributes": { "absolutePath": "project:/contracts/proxies/Clone2Probe.sol", "exportedSymbols": { "Clone2Probe": [ 3769 ] }, "license": "MIT" }, "children": [ { "attributes": { "literals": [ "solidity", "^", "0.6", ".0" ] }, "id": 3757, "name": "PragmaDirective", "src": "32:23:19" }, { "attributes": { "abstract": false, "baseContracts": [ null ], "contractDependencies": [ null ], "contractKind": "library", "documentation": null, "fullyImplemented": true, "linearizedBaseContracts": [ 3769 ], "name": "Clone2Probe", "scope": 3770 }, "children": [ { "attributes": { "documentation": null, "implemented": true, "isConstructor": false, "kind": "function", "modifiers": [ null ], "name": "getClone2Address", "overrides": null, "scope": 3769, "stateMutability": "view", "virtual": false, "visibility": "internal" }, "children": [ { "children": [ { "attributes": { "constant": false, "mutability": "mutable", "name": "target", "overrides": null, "scope": 3768, "stateVariable": false, "storageLocation": "default", "type": "address", "value": null, "visibility": "internal" }, "children": [ { "attributes": { "name": "address", "stateMutability": "nonpayable", "type": "address" }, "id": 3758, "name": "ElementaryTypeName", "src": "232:7:19" } ], "id": 3759, "name": "VariableDeclaration", "src": "232:14:19" }, { "attributes": { "constant": false, "mutability": "mutable", "name": "salt", "overrides": null, "scope": 3768, "stateVariable": false, "storageLocation": "default", "type": "bytes32", "value": null, "visibility": "internal" }, "children": [ { "attributes": { "name": "bytes32", "type": "bytes32" }, "id": 3760, "name": "ElementaryTypeName", "src": "252:7:19" } ], "id": 3761, "name": "VariableDeclaration", "src": "252:12:19" } ], "id": 3762, "name": "ParameterList", "src": "226:42:19" }, { "children": [ { "attributes": { "constant": false, "mutability": "mutable", "name": "cloneAddress", "overrides": null, "scope": 3768, "stateVariable": false, "storageLocation": "default", "type": "address", "value": null, "visibility": "internal" }, "children": [ { "attributes": { "name": "address", "stateMutability": "nonpayable", "type": "address" }, "id": 3763, "name": "ElementaryTypeName", "src": "296:7:19" } ], "id": 3764, "name": "VariableDeclaration", "src": "296:20:19" } ], "id": 3765, "name": "ParameterList", "src": "295:22:19" }, { "children": [ { "attributes": { "evmVersion": "istanbul", "externalReferences": [ { "declaration": 3764, "isOffset": false, "isSlot": false, "src": "1135:12:19", "valueSize": 1 }, { "declaration": 3761, "isOffset": false, "isSlot": false, "src": "1056:4:19", "valueSize": 1 }, { "declaration": 3759, "isOffset": false, "isSlot": false, "src": "629:6:19", "valueSize": 1 } ], "operations": "{\n let pointer := mload(0x40)\n mstore(pointer, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000)\n mstore(add(pointer, 0x14), shl(96, target))\n mstore(add(pointer, 0x28), 0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000)\n let contractCodeHash := keccak256(pointer, 0x37)\n mstore(pointer, 0xff00000000000000000000000000000000000000000000000000000000000000)\n mstore(add(pointer, 0x1), shl(96, address()))\n mstore(add(pointer, 0x15), salt)\n mstore(add(pointer, 0x35), contractCodeHash)\n cloneAddress := keccak256(pointer, 0x55)\n}" }, "children": [], "id": 3766, "name": "InlineAssembly", "src": "358:823:19" } ], "id": 3767, "name": "Block", "src": "320:865:19" } ], "id": 3768, "name": "FunctionDefinition", "src": "201:984:19" } ], "id": 3769, "name": "ContractDefinition", "src": "177:1010:19" } ], "id": 3770, "name": "SourceUnit", "src": "32:1156:19" }, "compiler": { "name": "solc", "version": "0.6.10+commit.00c0fcaf.Emscripten.clang" }, "networks": {}, "schemaVersion": "3.4.1", "updatedAt": "2021-07-08T17:04:13.867Z", "devdoc": { "methods": {} }, "userdoc": { "methods": {} } }