UNPKG

@netvote/elections-solidity

Version:
1,179 lines 48.9 kB
{ "contractName": "NoRemovalBytes32Set", "abi": [ { "constant": true, "inputs": [ { "name": "self", "type": "NoRemovalBytes32Set.SetData storage" } ], "name": "size", "outputs": [ { "name": "", "type": "uint256" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": true, "inputs": [ { "name": "self", "type": "NoRemovalBytes32Set.SetData storage" }, { "name": "index", "type": "uint256" } ], "name": "getAt", "outputs": [ { "name": "", "type": "bytes32" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": true, "inputs": [ { "name": "self", "type": "NoRemovalBytes32Set.SetData storage" }, { "name": "b", "type": "bytes32" } ], "name": "contains", "outputs": [ { "name": "", "type": "bool" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": false, "inputs": [ { "name": "self", "type": "NoRemovalBytes32Set.SetData storage" }, { "name": "b", "type": "bytes32" } ], "name": "put", "outputs": [], "payable": false, "stateMutability": "nonpayable", "type": "function" } ], "bytecode": "0x6060604052341561000f57600080fd5b6101d88061001e6000396000f3006060604052600436106100615763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166366b26fbf81146100665780637a3d376c14610083578063bd4a0da114610091578063bda02f00146100b3575b600080fd5b6100716004356100c3565b60405190815260200160405180910390f35b6100716004356024356100ca565b61009f6004356024356100f1565b604051901515815260200160405180910390f35b6100c1600435602435610107565b005b6001015490565b600082600101828154811015156100dd57fe5b906000526020600020900154905092915050565b6000908152602091909152604090205460ff1690565b60008181526020839052604090205460ff16151561015e576000818152602083905260409020805460ff1916600190811790915582810180549091810161014e8382610162565b5060009182526020909120018190555b5050565b8154818355818115116101865760008381526020902061018691810190830161018b565b505050565b6101a991905b808211156101a55760008155600101610191565b5090565b905600a165627a7a723058200f70b92effb57345ba47146bb84c247495269be2abddd3437ec22f603d65ac9b0029", "deployedBytecode": "0x6060604052600436106100615763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166366b26fbf81146100665780637a3d376c14610083578063bd4a0da114610091578063bda02f00146100b3575b600080fd5b6100716004356100c3565b60405190815260200160405180910390f35b6100716004356024356100ca565b61009f6004356024356100f1565b604051901515815260200160405180910390f35b6100c1600435602435610107565b005b6001015490565b600082600101828154811015156100dd57fe5b906000526020600020900154905092915050565b6000908152602091909152604090205460ff1690565b60008181526020839052604090205460ff16151561015e576000818152602083905260409020805460ff1916600190811790915582810180549091810161014e8382610162565b5060009182526020909120018190555b5050565b8154818355818115116101865760008381526020902061018691810190830161018b565b505050565b6101a991905b808211156101a55760008155600101610191565b5090565b905600a165627a7a723058200f70b92effb57345ba47146bb84c247495269be2abddd3437ec22f603d65ac9b0029", "sourceMap": "1013:703:14:-;;;;;;;;;;;;;;;;;", "deployedSourceMap": "1013:703:14:-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;1415:113;;;;;;;;;;;;;;;;;;;;;1149:129;;;;;;;;1284:125;;;;;;;;;;;;;;;;;;;;;;;;;1534:180;;;;;;;;;;1415:113;1502:12;;:19;;1415:113::o;1149:129::-;1226:7;1252:4;:12;;1265:5;1252:19;;;;;;;;;;;;;;;;;;;1245:26;;1149:129;;;;:::o;1284:125::-;1360:4;1383:19;;;;;;;;;;;;;;;1284:125::o;1534:180::-;1602:16;:19;;;;;;;;;;;;;1601:20;1597:111;;;1637:16;:19;;;;;;;;;;:26;;-1:-1:-1;;1637:26:14;1659:4;1637:26;;;;;;1677:12;;;:20;;:12;;:20;;;:12;:20;;:::i;:::-;-1:-1:-1;1677:20:14;;;;;;;;;;;;1597:111;1534:180;;:::o;1013:703::-;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;;;:::o;:::-;;;;;;;;;;;;;;;;;;;;;;;;:::o", "source": "// ------------------------------------------------------------------------------\n// This file is part of netvote.\n//\n// netvote is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// netvote is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with solidity. If not, see <http://www.gnu.org/licenses/>\n//\n// (c) 2017 netvote contributors.\n//------------------------------------------------------------------------------\n\npragma solidity ^0.4.17;\n\n\n/**\n * @title NoRemovalBytes32Set\n * @dev iterable map of bytes32 that has no way to remove (cheaper bookkeeping)\n */\nlibrary NoRemovalBytes32Set {\n\n struct SetData {\n mapping(bytes32 => bool) entryExists;\n bytes32[] entries;\n }\n\n function getAt(SetData storage self, uint256 index) public constant returns (bytes32) {\n return self.entries[index];\n }\n\n function contains(SetData storage self, bytes32 b) public constant returns (bool) {\n return self.entryExists[b];\n }\n\n function size(SetData storage self) public constant returns (uint256) {\n return self.entries.length;\n }\n\n function put(SetData storage self, bytes32 b) public {\n if (!self.entryExists[b]) {\n self.entryExists[b] = true;\n self.entries.push(b);\n }\n }\n}", "sourcePath": "/Users/slanders/netvote/elections-solidity/contracts/lib/NoRemovalBytes32Set.sol", "ast": { "attributes": { "absolutePath": "/Users/slanders/netvote/elections-solidity/contracts/lib/NoRemovalBytes32Set.sol", "exportedSymbols": { "NoRemovalBytes32Set": [ 2008 ] } }, "children": [ { "attributes": { "literals": [ "solidity", "^", "0.4", ".17" ] }, "id": 1926, "name": "PragmaDirective", "src": "868:24:14" }, { "attributes": { "baseContracts": [ null ], "contractDependencies": [ null ], "contractKind": "library", "documentation": "@title NoRemovalBytes32Set\n@dev iterable map of bytes32 that has no way to remove (cheaper bookkeeping)", "fullyImplemented": true, "linearizedBaseContracts": [ 2008 ], "name": "NoRemovalBytes32Set", "scope": 2009 }, "children": [ { "attributes": { "canonicalName": "NoRemovalBytes32Set.SetData", "name": "SetData", "scope": 2008, "visibility": "public" }, "children": [ { "attributes": { "constant": false, "name": "entryExists", "scope": 1934, "stateVariable": false, "storageLocation": "default", "type": "mapping(bytes32 => bool)", "value": null, "visibility": "internal" }, "children": [ { "attributes": { "type": "mapping(bytes32 => bool)" }, "children": [ { "attributes": { "name": "bytes32", "type": "bytes32" }, "id": 1927, "name": "ElementaryTypeName", "src": "1081:7:14" }, { "attributes": { "name": "bool", "type": "bool" }, "id": 1928, "name": "ElementaryTypeName", "src": "1092:4:14" } ], "id": 1929, "name": "Mapping", "src": "1073:24:14" } ], "id": 1930, "name": "VariableDeclaration", "src": "1073:36:14" }, { "attributes": { "constant": false, "name": "entries", "scope": 1934, "stateVariable": false, "storageLocation": "default", "type": "bytes32[] storage pointer", "value": null, "visibility": "internal" }, "children": [ { "attributes": { "length": null, "type": "bytes32[] storage pointer" }, "children": [ { "attributes": { "name": "bytes32", "type": "bytes32" }, "id": 1931, "name": "ElementaryTypeName", "src": "1119:7:14" } ], "id": 1932, "name": "ArrayTypeName", "src": "1119:9:14" } ], "id": 1933, "name": "VariableDeclaration", "src": "1119:17:14" } ], "id": 1934, "name": "StructDefinition", "src": "1048:95:14" }, { "attributes": { "constant": true, "implemented": true, "isConstructor": false, "modifiers": [ null ], "name": "getAt", "payable": false, "scope": 2008, "stateMutability": "view", "superFunction": null, "visibility": "public" }, "children": [ { "children": [ { "attributes": { "constant": false, "name": "self", "scope": 1949, "stateVariable": false, "storageLocation": "storage", "type": "struct NoRemovalBytes32Set.SetData storage pointer", "value": null, "visibility": "internal" }, "children": [ { "attributes": { "contractScope": null, "name": "SetData", "referencedDeclaration": 1934, "type": "struct NoRemovalBytes32Set.SetData storage pointer" }, "id": 1935, "name": "UserDefinedTypeName", "src": "1164:7:14" } ], "id": 1936, "name": "VariableDeclaration", "src": "1164:20:14" }, { "attributes": { "constant": false, "name": "index", "scope": 1949, "stateVariable": false, "storageLocation": "default", "type": "uint256", "value": null, "visibility": "internal" }, "children": [ { "attributes": { "name": "uint256", "type": "uint256" }, "id": 1937, "name": "ElementaryTypeName", "src": "1186:7:14" } ], "id": 1938, "name": "VariableDeclaration", "src": "1186:13:14" } ], "id": 1939, "name": "ParameterList", "src": "1163:37:14" }, { "children": [ { "attributes": { "constant": false, "name": "", "scope": 1949, "stateVariable": false, "storageLocation": "default", "type": "bytes32", "value": null, "visibility": "internal" }, "children": [ { "attributes": { "name": "bytes32", "type": "bytes32" }, "id": 1940, "name": "ElementaryTypeName", "src": "1226:7:14" } ], "id": 1941, "name": "VariableDeclaration", "src": "1226:7:14" } ], "id": 1942, "name": "ParameterList", "src": "1225:9:14" }, { "children": [ { "attributes": { "functionReturnParameters": 1942 }, "children": [ { "attributes": { "argumentTypes": null, "isConstant": false, "isLValue": true, "isPure": false, "lValueRequested": false, "type": "bytes32" }, "children": [ { "attributes": { "argumentTypes": null, "isConstant": false, "isLValue": true, "isPure": false, "lValueRequested": false, "member_name": "entries", "referencedDeclaration": 1933, "type": "bytes32[] storage ref" }, "children": [ { "attributes": { "argumentTypes": null, "overloadedDeclarations": [ null ], "referencedDeclaration": 1936, "type": "struct NoRemovalBytes32Set.SetData storage pointer", "value": "self" }, "id": 1943, "name": "Identifier", "src": "1252:4:14" } ], "id": 1944, "name": "MemberAccess", "src": "1252:12:14" }, { "attributes": { "argumentTypes": null, "overloadedDeclarations": [ null ], "referencedDeclaration": 1938, "type": "uint256", "value": "index" }, "id": 1945, "name": "Identifier", "src": "1265:5:14" } ], "id": 1946, "name": "IndexAccess", "src": "1252:19:14" } ], "id": 1947, "name": "Return", "src": "1245:26:14" } ], "id": 1948, "name": "Block", "src": "1235:43:14" } ], "id": 1949, "name": "FunctionDefinition", "src": "1149:129:14" }, { "attributes": { "constant": true, "implemented": true, "isConstructor": false, "modifiers": [ null ], "name": "contains", "payable": false, "scope": 2008, "stateMutability": "view", "superFunction": null, "visibility": "public" }, "children": [ { "children": [ { "attributes": { "constant": false, "name": "self", "scope": 1964, "stateVariable": false, "storageLocation": "storage", "type": "struct NoRemovalBytes32Set.SetData storage pointer", "value": null, "visibility": "internal" }, "children": [ { "attributes": { "contractScope": null, "name": "SetData", "referencedDeclaration": 1934, "type": "struct NoRemovalBytes32Set.SetData storage pointer" }, "id": 1950, "name": "UserDefinedTypeName", "src": "1302:7:14" } ], "id": 1951, "name": "VariableDeclaration", "src": "1302:20:14" }, { "attributes": { "constant": false, "name": "b", "scope": 1964, "stateVariable": false, "storageLocation": "default", "type": "bytes32", "value": null, "visibility": "internal" }, "children": [ { "attributes": { "name": "bytes32", "type": "bytes32" }, "id": 1952, "name": "ElementaryTypeName", "src": "1324:7:14" } ], "id": 1953, "name": "VariableDeclaration", "src": "1324:9:14" } ], "id": 1954, "name": "ParameterList", "src": "1301:33:14" }, { "children": [ { "attributes": { "constant": false, "name": "", "scope": 1964, "stateVariable": false, "storageLocation": "default", "type": "bool", "value": null, "visibility": "internal" }, "children": [ { "attributes": { "name": "bool", "type": "bool" }, "id": 1955, "name": "ElementaryTypeName", "src": "1360:4:14" } ], "id": 1956, "name": "VariableDeclaration", "src": "1360:4:14" } ], "id": 1957, "name": "ParameterList", "src": "1359:6:14" }, { "children": [ { "attributes": { "functionReturnParameters": 1957 }, "children": [ { "attributes": { "argumentTypes": null, "isConstant": false, "isLValue": true, "isPure": false, "lValueRequested": false, "type": "bool" }, "children": [ { "attributes": { "argumentTypes": null, "isConstant": false, "isLValue": true, "isPure": false, "lValueRequested": false, "member_name": "entryExists", "referencedDeclaration": 1930, "type": "mapping(bytes32 => bool)" }, "children": [ { "attributes": { "argumentTypes": null, "overloadedDeclarations": [ null ], "referencedDeclaration": 1951, "type": "struct NoRemovalBytes32Set.SetData storage pointer", "value": "self" }, "id": 1958, "name": "Identifier", "src": "1383:4:14" } ], "id": 1959, "name": "MemberAccess", "src": "1383:16:14" }, { "attributes": { "argumentTypes": null, "overloadedDeclarations": [ null ], "referencedDeclaration": 1953, "type": "bytes32", "value": "b" }, "id": 1960, "name": "Identifier", "src": "1400:1:14" } ], "id": 1961, "name": "IndexAccess", "src": "1383:19:14" } ], "id": 1962, "name": "Return", "src": "1376:26:14" } ], "id": 1963, "name": "Block", "src": "1366:43:14" } ], "id": 1964, "name": "FunctionDefinition", "src": "1284:125:14" }, { "attributes": { "constant": true, "implemented": true, "isConstructor": false, "modifiers": [ null ], "name": "size", "payable": false, "scope": 2008, "stateMutability": "view", "superFunction": null, "visibility": "public" }, "children": [ { "children": [ { "attributes": { "constant": false, "name": "self", "scope": 1976, "stateVariable": false, "storageLocation": "storage", "type": "struct NoRemovalBytes32Set.SetData storage pointer", "value": null, "visibility": "internal" }, "children": [ { "attributes": { "contractScope": null, "name": "SetData", "referencedDeclaration": 1934, "type": "struct NoRemovalBytes32Set.SetData storage pointer" }, "id": 1965, "name": "UserDefinedTypeName", "src": "1429:7:14" } ], "id": 1966, "name": "VariableDeclaration", "src": "1429:20:14" } ], "id": 1967, "name": "ParameterList", "src": "1428:22:14" }, { "children": [ { "attributes": { "constant": false, "name": "", "scope": 1976, "stateVariable": false, "storageLocation": "default", "type": "uint256", "value": null, "visibility": "internal" }, "children": [ { "attributes": { "name": "uint256", "type": "uint256" }, "id": 1968, "name": "ElementaryTypeName", "src": "1476:7:14" } ], "id": 1969, "name": "VariableDeclaration", "src": "1476:7:14" } ], "id": 1970, "name": "ParameterList", "src": "1475:9:14" }, { "children": [ { "attributes": { "functionReturnParameters": 1970 }, "children": [ { "attributes": { "argumentTypes": null, "isConstant": false, "isLValue": true, "isPure": false, "lValueRequested": false, "member_name": "length", "referencedDeclaration": null, "type": "uint256" }, "children": [ { "attributes": { "argumentTypes": null, "isConstant": false, "isLValue": true, "isPure": false, "lValueRequested": false, "member_name": "entries", "referencedDeclaration": 1933, "type": "bytes32[] storage ref" }, "children": [ { "attributes": { "argumentTypes": null, "overloadedDeclarations": [ null ], "referencedDeclaration": 1966, "type": "struct NoRemovalBytes32Set.SetData storage pointer", "value": "self" }, "id": 1971, "name": "Identifier", "src": "1502:4:14" } ], "id": 1972, "name": "MemberAccess", "src": "1502:12:14" } ], "id": 1973, "name": "MemberAccess", "src": "1502:19:14" } ], "id": 1974, "name": "Return", "src": "1495:26:14" } ], "id": 1975, "name": "Block", "src": "1485:43:14" } ], "id": 1976, "name": "FunctionDefinition", "src": "1415:113:14" }, { "attributes": { "constant": false, "implemented": true, "isConstructor": false, "modifiers": [ null ], "name": "put", "payable": false, "scope": 2008, "stateMutability": "nonpayable", "superFunction": null, "visibility": "public" }, "children": [ { "children": [ { "attributes": { "constant": false, "name": "self", "scope": 2007, "stateVariable": false, "storageLocation": "storage", "type": "struct NoRemovalBytes32Set.SetData storage pointer", "value": null, "visibility": "internal" }, "children": [ { "attributes": { "contractScope": null, "name": "SetData", "referencedDeclaration": 1934, "type": "struct NoRemovalBytes32Set.SetData storage pointer" }, "id": 1977, "name": "UserDefinedTypeName", "src": "1547:7:14" } ], "id": 1978, "name": "VariableDeclaration", "src": "1547:20:14" }, { "attributes": { "constant": false, "name": "b", "scope": 2007, "stateVariable": false, "storageLocation": "default", "type": "bytes32", "value": null, "visibility": "internal" }, "children": [ { "attributes": { "name": "bytes32", "type": "bytes32" }, "id": 1979, "name": "ElementaryTypeName", "src": "1569:7:14" } ], "id": 1980, "name": "VariableDeclaration", "src": "1569:9:14" } ], "id": 1981, "name": "ParameterList", "src": "1546:33:14" }, { "attributes": { "parameters": [ null ] }, "children": [], "id": 1982, "name": "ParameterList", "src": "1587:0:14" }, { "children": [ { "attributes": { "falseBody": null }, "children": [ { "attributes": { "argumentTypes": null, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "operator": "!", "prefix": true, "type": "bool" }, "children": [ { "attributes": { "argumentTypes": null, "isConstant": false, "isLValue": true, "isPure": false, "lValueRequested": false, "type": "bool" }, "children": [ { "attributes": { "argumentTypes": null, "isConstant": false, "isLValue": true, "isPure": false, "lValueRequested": false, "member_name": "entryExists", "referencedDeclaration": 1930, "type": "mapping(bytes32 => bool)" }, "children": [ { "attributes": { "argumentTypes": null, "overloadedDeclarations": [ null ], "referencedDeclaration": 1978, "type": "struct NoRemovalBytes32Set.SetData storage pointer", "value": "self" }, "id": 1983, "name": "Identifier", "src": "1602:4:14" } ], "id": 1984, "name": "MemberAccess", "src": "1602:16:14" }, { "attributes": { "argumentTypes": null, "overloadedDeclarations": [ null ], "referencedDeclaration": 1980, "type": "bytes32", "value": "b" }, "id": 1985, "name": "Identifier", "src": "1619:1:14" } ], "id": 1986, "name": "IndexAccess", "src": "1602:19:14" } ], "id": 1987, "name": "UnaryOperation", "src": "1601:20:14" }, { "children": [ { "children": [ { "attributes": { "argumentTypes": null, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "operator": "=", "type": "bool" }, "children": [ { "attributes": { "argumentTypes": null, "isConstant": false, "isLValue": true, "isPure": false, "lValueRequested": true, "type": "bool" }, "children": [ { "attributes": { "argumentTypes": null, "isConstant": false, "isLValue": true, "isPure": false, "lValueRequested": false, "member_name": "entryExists", "referencedDeclaration": 1930, "type": "mapping(bytes32 => bool)" }, "children": [ { "attributes": { "argumentTypes": null, "overloadedDeclarations": [ null ], "referencedDeclaration": 1978, "type": "struct NoRemovalBytes32Set.SetData storage pointer", "value": "self" }, "id": 1988, "name": "Identifier", "src": "1637:4:14" } ], "id": 1991, "name": "MemberAccess", "src": "1637:16:14" }, { "attributes": { "argumentTypes": null, "overloadedDeclarations": [ null ], "referencedDeclaration": 1980, "type": "bytes32", "value": "b" }, "id": 1990, "name": "Identifier", "src": "1654:1:14" } ], "id": 1992, "name": "IndexAccess", "src": "1637:19:14" }, { "attributes": { "argumentTypes": null, "hexvalue": "74727565", "isConstant": false, "isLValue": false, "isPure": true, "lValueRequested": false, "subdenomination": null, "token": "bool", "type": "bool", "value": "true" }, "id": 1993, "name": "Literal", "src": "1659:4:14" } ], "id": 1994, "name": "Assignment", "src": "1637:26:14" } ], "id": 1995, "name": "ExpressionStatement", "src": "1637:26:14" }, { "children": [ { "attributes": { "argumentTypes": null, "isConstant": false, "isLValue": false, "isPure": false, "isStructConstructorCall": false, "lValueRequested": false, "names": [ null ], "type": "uint256", "type_conversion": false }, "children": [ { "attributes": { "argumentTypes": [ { "typeIdentifier": "t_bytes32", "typeString": "bytes32" } ], "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "member_name": "push", "referencedDeclaration": null, "type": "function (bytes32) returns (uint256)" }, "children": [ { "attributes": { "argumentTypes": null, "isConstant": false, "isLValue": true, "isPure": false, "lValueRequested": false, "member_name": "entries", "referencedDeclaration": 1933, "type": "bytes32[] storage ref" }, "children": [ { "attributes": { "argumentTypes": null, "overloadedDeclarations": [ null ], "referencedDeclaration": 1978, "type": "struct NoRemovalBytes32Set.SetData storage pointer", "value": "self" }, "id": 1996, "name": "Identifier", "src": "1677:4:14" } ], "id": 1999, "name": "MemberAccess", "src": "1677:12:14" } ], "id": 2000, "name": "MemberAccess", "src": "1677:17:14" }, { "attributes": { "argumentTypes": null, "overloadedDeclarations": [ null ], "referencedDeclaration": 1980, "type": "bytes32", "value": "b" }, "id": 2001, "name": "Identifier", "src": "1695:1:14" } ], "id": 2002, "name": "FunctionCall", "src": "1677:20:14" } ], "id": 2003, "name": "ExpressionStatement", "src": "1677:20:14" } ], "id": 2004, "name": "Block", "src": "1623:85:14" } ], "id": 2005, "name": "IfStatement", "src": "1597:111:14" } ], "id": 2006, "name": "Block", "src": "1587:127:14" } ], "id": 2007, "name": "FunctionDefinition", "src": "1534:180:14" } ], "id": 2008, "name": "ContractDefinition", "src": "1013:703:14" } ], "id": 2009, "name": "SourceUnit", "src": "868:848:14" }, "compiler": { "name": "solc", "version": "0.4.18+commit.9cf6e910.Emscripten.clang" }, "networks": { "3": { "events": {}, "links": {}, "address": "0x486f7a37b62c7247beabbc1f9d451da04a9c585a" } }, "schemaVersion": "1.0.1", "updatedAt": "2018-03-26T15:58:05.149Z" }