diff --git a/README.md b/README.md index 9ef83419..e69de29b 100644 --- a/README.md +++ b/README.md @@ -1,46 +0,0 @@ - -# Election - DAPP Tutorial -Build your first decentralized application, or Dapp, on the Ethereum Network with this tutorial! - -**Full Free Video Tutorial:** -https://youtu.be/3681ZYbDSSk - - -Follow the steps below to download, install, and run this project. - -## Dependencies -Install these prerequisites to follow along with the tutorial. See free video tutorial or a full explanation of each prerequisite. -- NPM: https://nodejs.org -- Truffle: https://github.com/trufflesuite/truffle -- Ganache: http://truffleframework.com/ganache/ -- Metamask: https://metamask.io/ - - -## Step 1. Clone the project -`git clone https://github.com/dappuniversity/election` - -## Step 2. Install dependencies -``` -$ cd election -$ npm install -``` -## Step 3. Start Ganache -Open the Ganache GUI client that you downloaded and installed. This will start your local blockchain instance. See free video tutorial for full explanation. - - -## Step 4. Compile & Deploy Election Smart Contract -`$ truffle migrate --reset` -You must migrate the election smart contract each time your restart ganache. - -## Step 5. Configure Metamask -See free video tutorial for full explanation of these steps: -- Unlock Metamask -- Connect metamask to your local Etherum blockchain provided by Ganache. -- Import an account provided by ganache. - -## Step 6. Run the Front End Application -`$ npm run dev` -Visit this URL in your browser: http://localhost:3000 - -If you get stuck, please reference the free video tutorial. - diff --git a/build/contracts/Election.json b/build/contracts/Election.json index b866a1f1..5635d2ef 100644 --- a/build/contracts/Election.json +++ b/build/contracts/Election.json @@ -1,20 +1,6 @@ { "contractName": "Election", "abi": [ - { - "constant": false, - "inputs": [ - { - "name": "_candidateId", - "type": "uint256" - } - ], - "name": "vote", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, { "constant": true, "inputs": [], @@ -92,1378 +78,2534 @@ ], "name": "votedEvent", "type": "event" + }, + { + "constant": false, + "inputs": [ + { + "name": "_candidateId", + "type": "uint256" + } + ], + "name": "vote", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" } ], - "bytecode": "0x6060604052341561000f57600080fd5b6100606040805190810160405280600b81526020017f43616e64696461746520310000000000000000000000000000000000000000008152506100b66401000000000261033c176401000000009004565b6100b16040805190810160405280600b81526020017f43616e64696461746520320000000000000000000000000000000000000000008152506100b66401000000000261033c176401000000009004565b6101d8565b60026000815480929190600101919050555060606040519081016040528060025481526020018281526020016000815250600160006002548152602001908152602001600020600082015181600001556020820151816001019080519060200190610122929190610133565b506040820151816002015590505050565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061017457805160ff19168380011785556101a2565b828001600101855582156101a2579182015b828111156101a1578251825591602001919060010190610186565b5b5090506101af91906101b3565b5090565b6101d591905b808211156101d15760008160009055506001016101b9565b5090565b90565b61048a806101e76000396000f300606060405260043610610062576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680630121b93f146100675780632d35a8a21461008a5780633477ee2e146100b3578063a3ec138d1461017a575b600080fd5b341561007257600080fd5b61008860048080359060200190919050506101cb565b005b341561009557600080fd5b61009d6102ed565b6040518082815260200191505060405180910390f35b34156100be57600080fd5b6100d460048080359060200190919050506102f3565b60405180848152602001806020018381526020018281038252848181546001816001161561010002031660029004815260200191508054600181600116156101000203166002900480156101695780601f1061013e57610100808354040283529160200191610169565b820191906000526020600020905b81548152906001019060200180831161014c57829003601f168201915b505094505050505060405180910390f35b341561018557600080fd5b6101b1600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190505061031c565b604051808215151515815260200191505060405180910390f35b6000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615151561022357600080fd5b60008111801561023557506002548111155b151561024057600080fd5b60016000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055506001600082815260200190815260200160002060020160008154809291906001019190505550807ffff3c900d938d21d0990d786e819f29b8d05c1ef587b462b939609625b684b1660405160405180910390a250565b60025481565b600160205280600052604060002060009150905080600001549080600101908060020154905083565b60006020528060005260406000206000915054906101000a900460ff1681565b600260008154809291906001019190505550606060405190810160405280600254815260200182815260200160008152506001600060025481526020019081526020016000206000820151816000015560208201518160010190805190602001906103a89291906103b9565b506040820151816002015590505050565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106103fa57805160ff1916838001178555610428565b82800160010185558215610428579182015b8281111561042757825182559160200191906001019061040c565b5b5090506104359190610439565b5090565b61045b91905b8082111561045757600081600090555060010161043f565b5090565b905600a165627a7a7230582022e227d0cf70edd8a9fa2aaf0d46f64f57b0f94ce3f9998dcbb65a32de43fb7d0029", - "deployedBytecode": "0x606060405260043610610062576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680630121b93f146100675780632d35a8a21461008a5780633477ee2e146100b3578063a3ec138d1461017a575b600080fd5b341561007257600080fd5b61008860048080359060200190919050506101cb565b005b341561009557600080fd5b61009d6102ed565b6040518082815260200191505060405180910390f35b34156100be57600080fd5b6100d460048080359060200190919050506102f3565b60405180848152602001806020018381526020018281038252848181546001816001161561010002031660029004815260200191508054600181600116156101000203166002900480156101695780601f1061013e57610100808354040283529160200191610169565b820191906000526020600020905b81548152906001019060200180831161014c57829003601f168201915b505094505050505060405180910390f35b341561018557600080fd5b6101b1600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190505061031c565b604051808215151515815260200191505060405180910390f35b6000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615151561022357600080fd5b60008111801561023557506002548111155b151561024057600080fd5b60016000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055506001600082815260200190815260200160002060020160008154809291906001019190505550807ffff3c900d938d21d0990d786e819f29b8d05c1ef587b462b939609625b684b1660405160405180910390a250565b60025481565b600160205280600052604060002060009150905080600001549080600101908060020154905083565b60006020528060005260406000206000915054906101000a900460ff1681565b600260008154809291906001019190505550606060405190810160405280600254815260200182815260200160008152506001600060025481526020019081526020016000206000820151816000015560208201518160010190805190602001906103a89291906103b9565b506040820151816002015590505050565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106103fa57805160ff1916838001178555610428565b82800160010185558215610428579182015b8281111561042757825182559160200191906001019061040c565b5b5090506104359190610439565b5090565b61045b91905b8082111561045757600081600090555060010161043f565b5090565b905600a165627a7a7230582022e227d0cf70edd8a9fa2aaf0d46f64f57b0f94ce3f9998dcbb65a32de43fb7d0029", - "sourceMap": "25:1219:0:-;;;493:109;;;;;;;;531:27;;;;;;;;;;;;;;;;;;;:12;;;;;:27;;;:::i;:::-;568;;;;;;;;;;;;;;;;;;;:12;;;;;:27;;;:::i;:::-;25:1219;;608:156;663:15;;:18;;;;;;;;;;;;;721:36;;;;;;;;;731:15;;721:36;;;;748:5;721:36;;;;755:1;721:36;;;691:10;:27;702:15;;691:27;;;;;;;;;;;:66;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;608:156;:::o;25:1219::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;;:::o;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;:::o;:::-;;;;;;;", - "deployedSourceMap": "25:1219:0:-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;770:472;;;;;;;;;;;;;;;;;;;;;;;;;;375:27;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;295:44;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;204:38;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;770:472;880:6;:18;887:10;880:18;;;;;;;;;;;;;;;;;;;;;;;;;879:19;871:28;;;;;;;;970:1;955:12;:16;:51;;;;;991:15;;975:12;:31;;955:51;947:60;;;;;;;;1078:4;1057:6;:18;1064:10;1057:18;;;;;;;;;;;;;;;;:25;;;;;;;;;;;;;;;;;;1132:10;:24;1143:12;1132:24;;;;;;;;;;;:34;;;:37;;;;;;;;;;;;;1222:12;1211:24;;;;;;;;;;770:472;:::o;375:27::-;;;;:::o;295:44::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::o;204:38::-;;;;;;;;;;;;;;;;;;;;;;:::o;608:156::-;663:15;;:18;;;;;;;;;;;;;721:36;;;;;;;;;731:15;;721:36;;;;748:5;721:36;;;;755:1;721:36;;;691:10;:27;702:15;;691:27;;;;;;;;;;;:66;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;608:156;:::o;-1:-1:-1:-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;;:::o;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;:::o", - "source": "pragma solidity ^0.4.2;\n\ncontract Election {\n // Model a Candidate\n struct Candidate {\n uint id;\n string name;\n uint voteCount;\n }\n\n // Store accounts that have voted\n mapping(address => bool) public voters;\n // Store Candidates\n // Fetch Candidate\n mapping(uint => Candidate) public candidates;\n // Store Candidates Count\n uint public candidatesCount;\n\n // voted event\n event votedEvent (\n uint indexed _candidateId\n );\n\n function Election () public {\n addCandidate(\"Candidate 1\");\n addCandidate(\"Candidate 2\");\n }\n\n function addCandidate (string _name) private {\n candidatesCount ++;\n candidates[candidatesCount] = Candidate(candidatesCount, _name, 0);\n }\n\n function vote (uint _candidateId) public {\n // require that they haven't voted before\n require(!voters[msg.sender]);\n\n // require a valid candidate\n require(_candidateId > 0 && _candidateId <= candidatesCount);\n\n // record that voter has voted\n voters[msg.sender] = true;\n\n // update candidate vote Count\n candidates[_candidateId].voteCount ++;\n\n // trigger voted event\n votedEvent(_candidateId);\n }\n}\n", - "sourcePath": "/Users/gregory/code/election/contracts/Election.sol", + "bytecode": "0x608060405234801561001057600080fd5b5061005e6040805190810160405280600b81526020017f43616e64696461746520310000000000000000000000000000000000000000008152506100b0640100000000026401000000009004565b6100ab6040805190810160405280600b81526020017f43616e64696461746520320000000000000000000000000000000000000000008152506100b0640100000000026401000000009004565b6101d2565b6002600081548092919060010191905055506060604051908101604052806002548152602001828152602001600081525060016000600254815260200190815260200160002060008201518160000155602082015181600101908051906020019061011c92919061012d565b506040820151816002015590505050565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061016e57805160ff191683800117855561019c565b8280016001018555821561019c579182015b8281111561019b578251825591602001919060010190610180565b5b5090506101a991906101ad565b5090565b6101cf91905b808211156101cb5760008160009055506001016101b3565b5090565b90565b610404806101e16000396000f300608060405260043610610062576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680630121b93f146100675780632d35a8a2146100945780633477ee2e146100bf578063a3ec138d14610173575b600080fd5b34801561007357600080fd5b50610092600480360381019080803590602001909291905050506101ce565b005b3480156100a057600080fd5b506100a96102f0565b6040518082815260200191505060405180910390f35b3480156100cb57600080fd5b506100ea600480360381019080803590602001909291905050506102f6565b6040518084815260200180602001838152602001828103825284818151815260200191508051906020019080838360005b8381101561013657808201518184015260208101905061011b565b50505050905090810190601f1680156101635780820380516001836020036101000a031916815260200191505b5094505050505060405180910390f35b34801561017f57600080fd5b506101b4600480360381019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506103b8565b604051808215151515815260200191505060405180910390f35b6000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615151561022657600080fd5b60008111801561023857506002548111155b151561024357600080fd5b60016000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055506001600082815260200190815260200160002060020160008154809291906001019190505550807ffff3c900d938d21d0990d786e819f29b8d05c1ef587b462b939609625b684b1660405160405180910390a250565b60025481565b6001602052806000526040600020600091509050806000015490806001018054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156103a85780601f1061037d576101008083540402835291602001916103a8565b820191906000526020600020905b81548152906001019060200180831161038b57829003601f168201915b5050505050908060020154905083565b60006020528060005260406000206000915054906101000a900460ff16815600a165627a7a72305820944d4d8e2eb05e2f2fca6ca77a098c63812b92c441180b4a8d808ecfc728712c0029", + "deployedBytecode": "0x608060405260043610610062576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680630121b93f146100675780632d35a8a2146100945780633477ee2e146100bf578063a3ec138d14610173575b600080fd5b34801561007357600080fd5b50610092600480360381019080803590602001909291905050506101ce565b005b3480156100a057600080fd5b506100a96102f0565b6040518082815260200191505060405180910390f35b3480156100cb57600080fd5b506100ea600480360381019080803590602001909291905050506102f6565b6040518084815260200180602001838152602001828103825284818151815260200191508051906020019080838360005b8381101561013657808201518184015260208101905061011b565b50505050905090810190601f1680156101635780820380516001836020036101000a031916815260200191505b5094505050505060405180910390f35b34801561017f57600080fd5b506101b4600480360381019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506103b8565b604051808215151515815260200191505060405180910390f35b6000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615151561022657600080fd5b60008111801561023857506002548111155b151561024357600080fd5b60016000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055506001600082815260200190815260200160002060020160008154809291906001019190505550807ffff3c900d938d21d0990d786e819f29b8d05c1ef587b462b939609625b684b1660405160405180910390a250565b60025481565b6001602052806000526040600020600091509050806000015490806001018054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156103a85780601f1061037d576101008083540402835291602001916103a8565b820191906000526020600020905b81548152906001019060200180831161038b57829003601f168201915b5050505050908060020154905083565b60006020528060005260406000206000915054906101000a900460ff16815600a165627a7a72305820944d4d8e2eb05e2f2fca6ca77a098c63812b92c441180b4a8d808ecfc728712c0029", + "sourceMap": "25:1218:0:-;;;493:103;8:9:-1;5:2;;;30:1;27;20:12;5:2;493:103:0;525:27;;;;;;;;;;;;;;;;;;;:12;;;:27;;;:::i;:::-;562;;;;;;;;;;;;;;;;;;;:12;;;:27;;;:::i;:::-;25:1218;;602:156;657:15;;:18;;;;;;;;;;;;;715:36;;;;;;;;;725:15;;715:36;;;;742:5;715:36;;;;749:1;715:36;;;685:10;:27;696:15;;685:27;;;;;;;;;;;:66;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;602:156;:::o;25:1218::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;;:::o;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;:::o;:::-;;;;;;;", + "deployedSourceMap": "25:1218:0:-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;764:477;;8:9:-1;5:2;;;30:1;27;20:12;5:2;764:477:0;;;;;;;;;;;;;;;;;;;;;;;;;;375:27;;8:9:-1;5:2;;;30:1;27;20:12;5:2;375:27:0;;;;;;;;;;;;;;;;;;;;;;;295:44;;8:9:-1;5:2;;;30:1;27;20:12;5:2;295:44:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;23:1:-1;8:100;33:3;30:1;27:10;8:100;;;99:1;94:3;90:11;84:18;80:1;75:3;71:11;64:39;52:2;49:1;45:10;40:15;;8:100;;;12:14;295:44:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;204:38;;8:9:-1;5:2;;;30:1;27;20:12;5:2;204:38:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;764:477;874:6;:18;881:10;874:18;;;;;;;;;;;;;;;;;;;;;;;;;873:19;865:28;;;;;;;;964:1;949:12;:16;:51;;;;;985:15;;969:12;:31;;949:51;941:60;;;;;;;;1072:4;1051:6;:18;1058:10;1051:18;;;;;;;;;;;;;;;;:25;;;;;;;;;;;;;;;;;;1126:10;:24;1137:12;1126:24;;;;;;;;;;;:34;;;:37;;;;;;;;;;;;;1221:12;1210:24;;;;;;;;;;764:477;:::o;375:27::-;;;;:::o;295:44::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::o;204:38::-;;;;;;;;;;;;;;;;;;;;;;:::o", + "source": "pragma solidity 0.4.24;\n\ncontract Election {\n // Model a Candidate\n struct Candidate {\n uint id;\n string name;\n uint voteCount;\n }\n\n // Store accounts that have voted\n mapping(address => bool) public voters;\n // Store Candidates\n // Fetch Candidate\n mapping(uint => Candidate) public candidates;\n // Store Candidates Count\n uint public candidatesCount;\n\n // voted event\n event votedEvent (\n uint indexed _candidateId\n );\n\n constructor () public {\n addCandidate(\"Candidate 1\");\n addCandidate(\"Candidate 2\");\n }\n\n function addCandidate (string _name) private {\n candidatesCount ++;\n candidates[candidatesCount] = Candidate(candidatesCount, _name, 0);\n }\n\n function vote (uint _candidateId) public {\n // require that they haven't voted before\n require(!voters[msg.sender]);\n\n // require a valid candidate\n require(_candidateId > 0 && _candidateId <= candidatesCount);\n\n // record that voter has voted\n voters[msg.sender] = true;\n\n // update candidate vote Count\n candidates[_candidateId].voteCount ++;\n\n // trigger voted event\n emit votedEvent(_candidateId);\n }\n}\n", + "sourcePath": "/Users/adlymousa/Ethereum/election/contracts/Election.sol", "ast": { - "attributes": { - "absolutePath": "/Users/gregory/code/election/contracts/Election.sol", - "exportedSymbols": { - "Election": [ - 95 - ] - } + "absolutePath": "/Users/adlymousa/Ethereum/election/contracts/Election.sol", + "exportedSymbols": { + "Election": [ + 95 + ] }, - "children": [ + "id": 96, + "nodeType": "SourceUnit", + "nodes": [ { - "attributes": { - "literals": [ - "solidity", - "^", - "0.4", - ".2" - ] - }, "id": 1, - "name": "PragmaDirective", + "literals": [ + "solidity", + "0.4", + ".24" + ], + "nodeType": "PragmaDirective", "src": "0:23:0" }, { - "attributes": { - "baseContracts": [ - null - ], - "contractDependencies": [ - null - ], - "contractKind": "contract", - "documentation": null, - "fullyImplemented": true, - "linearizedBaseContracts": [ - 95 - ], - "name": "Election", - "scope": 96 - }, - "children": [ + "baseContracts": [], + "contractDependencies": [], + "contractKind": "contract", + "documentation": null, + "fullyImplemented": true, + "id": 95, + "linearizedBaseContracts": [ + 95 + ], + "name": "Election", + "nodeType": "ContractDefinition", + "nodes": [ { - "attributes": { - "canonicalName": "Election.Candidate", - "name": "Candidate", - "scope": 95, - "visibility": "public" - }, - "children": [ + "canonicalName": "Election.Candidate", + "id": 8, + "members": [ { - "attributes": { - "constant": false, - "name": "id", - "scope": 8, - "stateVariable": false, - "storageLocation": "default", - "type": "uint256", - "value": null, - "visibility": "internal" + "constant": false, + "id": 3, + "name": "id", + "nodeType": "VariableDeclaration", + "scope": 8, + "src": "101:7:0", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" }, - "children": [ - { - "attributes": { - "name": "uint", - "type": "uint256" - }, - "id": 2, - "name": "ElementaryTypeName", - "src": "101:4:0" + "typeName": { + "id": 2, + "name": "uint", + "nodeType": "ElementaryTypeName", + "src": "101:4:0", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" } - ], - "id": 3, - "name": "VariableDeclaration", - "src": "101:7:0" + }, + "value": null, + "visibility": "internal" }, { - "attributes": { - "constant": false, - "name": "name", - "scope": 8, - "stateVariable": false, - "storageLocation": "default", - "type": "string storage pointer", - "value": null, - "visibility": "internal" + "constant": false, + "id": 5, + "name": "name", + "nodeType": "VariableDeclaration", + "scope": 8, + "src": "118:11:0", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_string_storage_ptr", + "typeString": "string" }, - "children": [ - { - "attributes": { - "name": "string", - "type": "string storage pointer" - }, - "id": 4, - "name": "ElementaryTypeName", - "src": "118:6:0" + "typeName": { + "id": 4, + "name": "string", + "nodeType": "ElementaryTypeName", + "src": "118:6:0", + "typeDescriptions": { + "typeIdentifier": "t_string_storage_ptr", + "typeString": "string" } - ], - "id": 5, - "name": "VariableDeclaration", - "src": "118:11:0" + }, + "value": null, + "visibility": "internal" }, { - "attributes": { - "constant": false, - "name": "voteCount", - "scope": 8, - "stateVariable": false, - "storageLocation": "default", - "type": "uint256", - "value": null, - "visibility": "internal" + "constant": false, + "id": 7, + "name": "voteCount", + "nodeType": "VariableDeclaration", + "scope": 8, + "src": "139:14:0", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" }, - "children": [ - { - "attributes": { - "name": "uint", - "type": "uint256" - }, - "id": 6, - "name": "ElementaryTypeName", - "src": "139:4:0" + "typeName": { + "id": 6, + "name": "uint", + "nodeType": "ElementaryTypeName", + "src": "139:4:0", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" } - ], - "id": 7, - "name": "VariableDeclaration", - "src": "139:14:0" + }, + "value": null, + "visibility": "internal" } ], - "id": 8, - "name": "StructDefinition", - "src": "74:86:0" + "name": "Candidate", + "nodeType": "StructDefinition", + "scope": 95, + "src": "74:86:0", + "visibility": "public" }, { - "attributes": { - "constant": false, - "name": "voters", - "scope": 95, - "stateVariable": true, - "storageLocation": "default", - "type": "mapping(address => bool)", - "value": null, - "visibility": "public" + "constant": false, + "id": 12, + "name": "voters", + "nodeType": "VariableDeclaration", + "scope": 95, + "src": "204:38:0", + "stateVariable": true, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_mapping$_t_address_$_t_bool_$", + "typeString": "mapping(address => bool)" }, - "children": [ - { - "attributes": { - "type": "mapping(address => bool)" - }, - "children": [ - { - "attributes": { - "name": "address", - "type": "address" - }, - "id": 9, - "name": "ElementaryTypeName", - "src": "212:7:0" - }, - { - "attributes": { - "name": "bool", - "type": "bool" - }, - "id": 10, - "name": "ElementaryTypeName", - "src": "223:4:0" - } - ], - "id": 11, - "name": "Mapping", - "src": "204:24:0" + "typeName": { + "id": 11, + "keyType": { + "id": 9, + "name": "address", + "nodeType": "ElementaryTypeName", + "src": "212:7:0", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "nodeType": "Mapping", + "src": "204:24:0", + "typeDescriptions": { + "typeIdentifier": "t_mapping$_t_address_$_t_bool_$", + "typeString": "mapping(address => bool)" + }, + "valueType": { + "id": 10, + "name": "bool", + "nodeType": "ElementaryTypeName", + "src": "223:4:0", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } } - ], - "id": 12, - "name": "VariableDeclaration", - "src": "204:38:0" + }, + "value": null, + "visibility": "public" }, { - "attributes": { - "constant": false, - "name": "candidates", - "scope": 95, - "stateVariable": true, - "storageLocation": "default", - "type": "mapping(uint256 => struct Election.Candidate storage ref)", - "value": null, - "visibility": "public" + "constant": false, + "id": 16, + "name": "candidates", + "nodeType": "VariableDeclaration", + "scope": 95, + "src": "295:44:0", + "stateVariable": true, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_mapping$_t_uint256_$_t_struct$_Candidate_$8_storage_$", + "typeString": "mapping(uint256 => struct Election.Candidate)" }, - "children": [ - { - "attributes": { - "type": "mapping(uint256 => struct Election.Candidate storage ref)" - }, - "children": [ - { - "attributes": { - "name": "uint", - "type": "uint256" - }, - "id": 13, - "name": "ElementaryTypeName", - "src": "303:4:0" - }, - { - "attributes": { - "contractScope": null, - "name": "Candidate", - "referencedDeclaration": 8, - "type": "struct Election.Candidate storage pointer" - }, - "id": 14, - "name": "UserDefinedTypeName", - "src": "311:9:0" - } - ], - "id": 15, - "name": "Mapping", - "src": "295:26:0" + "typeName": { + "id": 15, + "keyType": { + "id": 13, + "name": "uint", + "nodeType": "ElementaryTypeName", + "src": "303:4:0", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "Mapping", + "src": "295:26:0", + "typeDescriptions": { + "typeIdentifier": "t_mapping$_t_uint256_$_t_struct$_Candidate_$8_storage_$", + "typeString": "mapping(uint256 => struct Election.Candidate)" + }, + "valueType": { + "contractScope": null, + "id": 14, + "name": "Candidate", + "nodeType": "UserDefinedTypeName", + "referencedDeclaration": 8, + "src": "311:9:0", + "typeDescriptions": { + "typeIdentifier": "t_struct$_Candidate_$8_storage_ptr", + "typeString": "struct Election.Candidate" + } } - ], - "id": 16, - "name": "VariableDeclaration", - "src": "295:44:0" + }, + "value": null, + "visibility": "public" }, { - "attributes": { - "constant": false, - "name": "candidatesCount", - "scope": 95, - "stateVariable": true, - "storageLocation": "default", - "type": "uint256", - "value": null, - "visibility": "public" + "constant": false, + "id": 18, + "name": "candidatesCount", + "nodeType": "VariableDeclaration", + "scope": 95, + "src": "375:27:0", + "stateVariable": true, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" }, - "children": [ - { - "attributes": { - "name": "uint", - "type": "uint256" - }, - "id": 17, - "name": "ElementaryTypeName", - "src": "375:4:0" + "typeName": { + "id": 17, + "name": "uint", + "nodeType": "ElementaryTypeName", + "src": "375:4:0", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" } - ], - "id": 18, - "name": "VariableDeclaration", - "src": "375:27:0" + }, + "value": null, + "visibility": "public" }, { - "attributes": { - "anonymous": false, - "name": "votedEvent" + "anonymous": false, + "documentation": null, + "id": 22, + "name": "votedEvent", + "nodeType": "EventDefinition", + "parameters": { + "id": 21, + "nodeType": "ParameterList", + "parameters": [ + { + "constant": false, + "id": 20, + "indexed": true, + "name": "_candidateId", + "nodeType": "VariableDeclaration", + "scope": 22, + "src": "455:25:0", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "typeName": { + "id": 19, + "name": "uint", + "nodeType": "ElementaryTypeName", + "src": "455:4:0", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "value": null, + "visibility": "internal" + } + ], + "src": "445:41:0" }, - "children": [ - { - "children": [ - { - "attributes": { - "constant": false, - "indexed": true, - "name": "_candidateId", - "scope": 22, - "stateVariable": false, - "storageLocation": "default", - "type": "uint256", - "value": null, - "visibility": "internal" + "src": "428:59:0" + }, + { + "body": { + "id": 33, + "nodeType": "Block", + "src": "515:81:0", + "statements": [ + { + "expression": { + "argumentTypes": null, + "arguments": [ + { + "argumentTypes": null, + "hexValue": "43616e6469646174652031", + "id": 26, + "isConstant": false, + "isLValue": false, + "isPure": true, + "kind": "string", + "lValueRequested": false, + "nodeType": "Literal", + "src": "538:13:0", + "subdenomination": null, + "typeDescriptions": { + "typeIdentifier": "t_stringliteral_41f9dcbd43e9b33194759b5a51b1df9864cdc2b2138ff106f03091eb79861f0c", + "typeString": "literal_string \"Candidate 1\"" + }, + "value": "Candidate 1" + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_stringliteral_41f9dcbd43e9b33194759b5a51b1df9864cdc2b2138ff106f03091eb79861f0c", + "typeString": "literal_string \"Candidate 1\"" + } + ], + "id": 25, + "name": "addCandidate", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 53, + "src": "525:12:0", + "typeDescriptions": { + "typeIdentifier": "t_function_internal_nonpayable$_t_string_memory_ptr_$returns$__$", + "typeString": "function (string memory)" + } }, - "children": [ + "id": 27, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "525:27:0", + "typeDescriptions": { + "typeIdentifier": "t_tuple$__$", + "typeString": "tuple()" + } + }, + "id": 28, + "nodeType": "ExpressionStatement", + "src": "525:27:0" + }, + { + "expression": { + "argumentTypes": null, + "arguments": [ { - "attributes": { - "name": "uint", - "type": "uint256" + "argumentTypes": null, + "hexValue": "43616e6469646174652032", + "id": 30, + "isConstant": false, + "isLValue": false, + "isPure": true, + "kind": "string", + "lValueRequested": false, + "nodeType": "Literal", + "src": "575:13:0", + "subdenomination": null, + "typeDescriptions": { + "typeIdentifier": "t_stringliteral_f1f17440f69835dafba5c9fd0e4caa6c780807a80f8d1745ec7af1408d6cca4a", + "typeString": "literal_string \"Candidate 2\"" }, - "id": 19, - "name": "ElementaryTypeName", - "src": "455:4:0" + "value": "Candidate 2" } ], - "id": 20, - "name": "VariableDeclaration", - "src": "455:25:0" - } - ], - "id": 21, - "name": "ParameterList", - "src": "445:41:0" - } - ], - "id": 22, - "name": "EventDefinition", - "src": "428:59:0" + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_stringliteral_f1f17440f69835dafba5c9fd0e4caa6c780807a80f8d1745ec7af1408d6cca4a", + "typeString": "literal_string \"Candidate 2\"" + } + ], + "id": 29, + "name": "addCandidate", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 53, + "src": "562:12:0", + "typeDescriptions": { + "typeIdentifier": "t_function_internal_nonpayable$_t_string_memory_ptr_$returns$__$", + "typeString": "function (string memory)" + } + }, + "id": 31, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "562:27:0", + "typeDescriptions": { + "typeIdentifier": "t_tuple$__$", + "typeString": "tuple()" + } + }, + "id": 32, + "nodeType": "ExpressionStatement", + "src": "562:27:0" + } + ] + }, + "documentation": null, + "id": 34, + "implemented": true, + "isConstructor": true, + "isDeclaredConst": false, + "modifiers": [], + "name": "", + "nodeType": "FunctionDefinition", + "parameters": { + "id": 23, + "nodeType": "ParameterList", + "parameters": [], + "src": "505:2:0" + }, + "payable": false, + "returnParameters": { + "id": 24, + "nodeType": "ParameterList", + "parameters": [], + "src": "515:0:0" + }, + "scope": 95, + "src": "493:103:0", + "stateMutability": "nonpayable", + "superFunction": null, + "visibility": "public" }, { - "attributes": { - "constant": false, - "implemented": true, - "isConstructor": true, - "modifiers": [ - null - ], - "name": "Election", - "payable": false, - "scope": 95, - "stateMutability": "nonpayable", - "superFunction": null, - "visibility": "public" - }, - "children": [ - { - "attributes": { - "parameters": [ - null - ] - }, - "children": [], - "id": 23, - "name": "ParameterList", - "src": "511:2:0" - }, - { - "attributes": { - "parameters": [ - null - ] + "body": { + "id": 52, + "nodeType": "Block", + "src": "647:111:0", + "statements": [ + { + "expression": { + "argumentTypes": null, + "id": 40, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "nodeType": "UnaryOperation", + "operator": "++", + "prefix": false, + "src": "657:18:0", + "subExpression": { + "argumentTypes": null, + "id": 39, + "name": "candidatesCount", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 18, + "src": "657:15:0", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "id": 41, + "nodeType": "ExpressionStatement", + "src": "657:18:0" }, - "children": [], - "id": 24, - "name": "ParameterList", - "src": "521:0:0" - }, - { - "children": [ - { - "children": [ - { - "attributes": { + { + "expression": { + "argumentTypes": null, + "id": 50, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftHandSide": { + "argumentTypes": null, + "baseExpression": { + "argumentTypes": null, + "id": 42, + "name": "candidates", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 16, + "src": "685:10:0", + "typeDescriptions": { + "typeIdentifier": "t_mapping$_t_uint256_$_t_struct$_Candidate_$8_storage_$", + "typeString": "mapping(uint256 => struct Election.Candidate storage ref)" + } + }, + "id": 44, + "indexExpression": { + "argumentTypes": null, + "id": 43, + "name": "candidatesCount", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 18, + "src": "696:15:0", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "isConstant": false, + "isLValue": true, + "isPure": false, + "lValueRequested": true, + "nodeType": "IndexAccess", + "src": "685:27:0", + "typeDescriptions": { + "typeIdentifier": "t_struct$_Candidate_$8_storage", + "typeString": "struct Election.Candidate storage ref" + } + }, + "nodeType": "Assignment", + "operator": "=", + "rightHandSide": { + "argumentTypes": null, + "arguments": [ + { + "argumentTypes": null, + "id": 46, + "name": "candidatesCount", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 18, + "src": "725:15:0", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + { + "argumentTypes": null, + "id": 47, + "name": "_name", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 36, + "src": "742:5:0", + "typeDescriptions": { + "typeIdentifier": "t_string_memory_ptr", + "typeString": "string memory" + } + }, + { "argumentTypes": null, + "hexValue": "30", + "id": 48, "isConstant": false, "isLValue": false, - "isPure": false, - "isStructConstructorCall": false, + "isPure": true, + "kind": "number", "lValueRequested": false, - "names": [ - null - ], - "type": "tuple()", - "type_conversion": false - }, - "children": [ + "nodeType": "Literal", + "src": "749:1:0", + "subdenomination": null, + "typeDescriptions": { + "typeIdentifier": "t_rational_0_by_1", + "typeString": "int_const 0" + }, + "value": "0" + } + ], + "expression": { + "argumentTypes": [ { - "attributes": { - "argumentTypes": [ - { - "typeIdentifier": "t_stringliteral_41f9dcbd43e9b33194759b5a51b1df9864cdc2b2138ff106f03091eb79861f0c", - "typeString": "literal_string \"Candidate 1\"" - } - ], - "overloadedDeclarations": [ - null - ], - "referencedDeclaration": 53, - "type": "function (string memory)", - "value": "addCandidate" - }, - "id": 25, - "name": "Identifier", - "src": "531:12:0" + "typeIdentifier": "t_uint256", + "typeString": "uint256" }, { - "attributes": { - "argumentTypes": null, - "hexvalue": "43616e6469646174652031", - "isConstant": false, - "isLValue": false, - "isPure": true, - "lValueRequested": false, - "subdenomination": null, - "token": "string", - "type": "literal_string \"Candidate 1\"", - "value": "Candidate 1" - }, - "id": 26, - "name": "Literal", - "src": "544:13:0" + "typeIdentifier": "t_string_memory_ptr", + "typeString": "string memory" + }, + { + "typeIdentifier": "t_rational_0_by_1", + "typeString": "int_const 0" } ], - "id": 27, - "name": "FunctionCall", - "src": "531:27:0" + "id": 45, + "name": "Candidate", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 8, + "src": "715:9:0", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_struct$_Candidate_$8_storage_ptr_$", + "typeString": "type(struct Election.Candidate storage pointer)" + } + }, + "id": 49, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "structConstructorCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "715:36:0", + "typeDescriptions": { + "typeIdentifier": "t_struct$_Candidate_$8_memory", + "typeString": "struct Election.Candidate memory" } - ], - "id": 28, - "name": "ExpressionStatement", - "src": "531:27:0" + }, + "src": "685:66:0", + "typeDescriptions": { + "typeIdentifier": "t_struct$_Candidate_$8_storage", + "typeString": "struct Election.Candidate storage ref" + } + }, + "id": 51, + "nodeType": "ExpressionStatement", + "src": "685:66:0" + } + ] + }, + "documentation": null, + "id": 53, + "implemented": true, + "isConstructor": false, + "isDeclaredConst": false, + "modifiers": [], + "name": "addCandidate", + "nodeType": "FunctionDefinition", + "parameters": { + "id": 37, + "nodeType": "ParameterList", + "parameters": [ + { + "constant": false, + "id": 36, + "name": "_name", + "nodeType": "VariableDeclaration", + "scope": 53, + "src": "625:12:0", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_string_memory_ptr", + "typeString": "string" }, - { - "children": [ + "typeName": { + "id": 35, + "name": "string", + "nodeType": "ElementaryTypeName", + "src": "625:6:0", + "typeDescriptions": { + "typeIdentifier": "t_string_storage_ptr", + "typeString": "string" + } + }, + "value": null, + "visibility": "internal" + } + ], + "src": "624:14:0" + }, + "payable": false, + "returnParameters": { + "id": 38, + "nodeType": "ParameterList", + "parameters": [], + "src": "647:0:0" + }, + "scope": 95, + "src": "602:156:0", + "stateMutability": "nonpayable", + "superFunction": null, + "visibility": "private" + }, + { + "body": { + "id": 93, + "nodeType": "Block", + "src": "805:436:0", + "statements": [ + { + "expression": { + "argumentTypes": null, + "arguments": [ { - "attributes": { + "argumentTypes": null, + "id": 63, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "nodeType": "UnaryOperation", + "operator": "!", + "prefix": true, + "src": "873:19:0", + "subExpression": { "argumentTypes": null, - "isConstant": false, - "isLValue": false, - "isPure": false, - "isStructConstructorCall": false, - "lValueRequested": false, - "names": [ - null - ], - "type": "tuple()", - "type_conversion": false - }, - "children": [ - { - "attributes": { - "argumentTypes": [ - { - "typeIdentifier": "t_stringliteral_f1f17440f69835dafba5c9fd0e4caa6c780807a80f8d1745ec7af1408d6cca4a", - "typeString": "literal_string \"Candidate 2\"" - } - ], - "overloadedDeclarations": [ - null - ], - "referencedDeclaration": 53, - "type": "function (string memory)", - "value": "addCandidate" - }, - "id": 29, - "name": "Identifier", - "src": "568:12:0" + "baseExpression": { + "argumentTypes": null, + "id": 59, + "name": "voters", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 12, + "src": "874:6:0", + "typeDescriptions": { + "typeIdentifier": "t_mapping$_t_address_$_t_bool_$", + "typeString": "mapping(address => bool)" + } }, - { - "attributes": { + "id": 62, + "indexExpression": { + "argumentTypes": null, + "expression": { "argumentTypes": null, - "hexvalue": "43616e6469646174652032", - "isConstant": false, - "isLValue": false, - "isPure": true, - "lValueRequested": false, - "subdenomination": null, - "token": "string", - "type": "literal_string \"Candidate 2\"", - "value": "Candidate 2" + "id": 60, + "name": "msg", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 167, + "src": "881:3:0", + "typeDescriptions": { + "typeIdentifier": "t_magic_message", + "typeString": "msg" + } }, - "id": 30, - "name": "Literal", - "src": "581:13:0" + "id": 61, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "sender", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "881:10:0", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "isConstant": false, + "isLValue": true, + "isPure": false, + "lValueRequested": false, + "nodeType": "IndexAccess", + "src": "874:18:0", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" } - ], - "id": 31, - "name": "FunctionCall", - "src": "568:27:0" - } - ], - "id": 32, - "name": "ExpressionStatement", - "src": "568:27:0" - } - ], - "id": 33, - "name": "Block", - "src": "521:81:0" - } - ], - "id": 34, - "name": "FunctionDefinition", - "src": "493:109:0" - }, - { - "attributes": { - "constant": false, - "implemented": true, - "isConstructor": false, - "modifiers": [ - null - ], - "name": "addCandidate", - "payable": false, - "scope": 95, - "stateMutability": "nonpayable", - "superFunction": null, - "visibility": "private" - }, - "children": [ - { - "children": [ - { - "attributes": { - "constant": false, - "name": "_name", - "scope": 53, - "stateVariable": false, - "storageLocation": "default", - "type": "string memory", - "value": null, - "visibility": "internal" - }, - "children": [ - { - "attributes": { - "name": "string", - "type": "string storage pointer" }, - "id": 35, - "name": "ElementaryTypeName", - "src": "631:6:0" + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } } ], - "id": 36, - "name": "VariableDeclaration", - "src": "631:12:0" - } - ], - "id": 37, - "name": "ParameterList", - "src": "630:14:0" - }, - { - "attributes": { - "parameters": [ - null - ] + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + ], + "id": 58, + "name": "require", + "nodeType": "Identifier", + "overloadedDeclarations": [ + 170, + 171 + ], + "referencedDeclaration": 170, + "src": "865:7:0", + "typeDescriptions": { + "typeIdentifier": "t_function_require_pure$_t_bool_$returns$__$", + "typeString": "function (bool) pure" + } + }, + "id": 64, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "865:28:0", + "typeDescriptions": { + "typeIdentifier": "t_tuple$__$", + "typeString": "tuple()" + } + }, + "id": 65, + "nodeType": "ExpressionStatement", + "src": "865:28:0" }, - "children": [], - "id": 38, - "name": "ParameterList", - "src": "653:0:0" - }, - { - "children": [ - { - "children": [ + { + "expression": { + "argumentTypes": null, + "arguments": [ { - "attributes": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_bool", + "typeString": "bool" + }, + "id": 73, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "id": 69, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, - "operator": "++", - "prefix": false, - "type": "uint256" - }, - "children": [ - { - "attributes": { - "argumentTypes": null, - "overloadedDeclarations": [ - null - ], - "referencedDeclaration": 18, - "type": "uint256", - "value": "candidatesCount" + "leftExpression": { + "argumentTypes": null, + "id": 67, + "name": "_candidateId", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 55, + "src": "949:12:0", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "BinaryOperation", + "operator": ">", + "rightExpression": { + "argumentTypes": null, + "hexValue": "30", + "id": 68, + "isConstant": false, + "isLValue": false, + "isPure": true, + "kind": "number", + "lValueRequested": false, + "nodeType": "Literal", + "src": "964:1:0", + "subdenomination": null, + "typeDescriptions": { + "typeIdentifier": "t_rational_0_by_1", + "typeString": "int_const 0" }, - "id": 39, - "name": "Identifier", - "src": "663:15:0" + "value": "0" + }, + "src": "949:16:0", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" } - ], - "id": 40, - "name": "UnaryOperation", - "src": "663:18:0" - } - ], - "id": 41, - "name": "ExpressionStatement", - "src": "663:18:0" - }, - { - "children": [ - { - "attributes": { + }, + "nodeType": "BinaryOperation", + "operator": "&&", + "rightExpression": { "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "id": 72, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, - "operator": "=", - "type": "struct Election.Candidate storage ref" - }, - "children": [ - { - "attributes": { - "argumentTypes": null, - "isConstant": false, - "isLValue": true, - "isPure": false, - "lValueRequested": true, - "type": "struct Election.Candidate storage ref" - }, - "children": [ - { - "attributes": { - "argumentTypes": null, - "overloadedDeclarations": [ - null - ], - "referencedDeclaration": 16, - "type": "mapping(uint256 => struct Election.Candidate storage ref)", - "value": "candidates" - }, - "id": 42, - "name": "Identifier", - "src": "691:10:0" - }, - { - "attributes": { - "argumentTypes": null, - "overloadedDeclarations": [ - null - ], - "referencedDeclaration": 18, - "type": "uint256", - "value": "candidatesCount" - }, - "id": 43, - "name": "Identifier", - "src": "702:15:0" - } - ], - "id": 44, - "name": "IndexAccess", - "src": "691:27:0" + "leftExpression": { + "argumentTypes": null, + "id": 70, + "name": "_candidateId", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 55, + "src": "969:12:0", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } }, - { - "attributes": { - "argumentTypes": null, - "isConstant": false, - "isLValue": false, - "isPure": false, - "isStructConstructorCall": true, - "lValueRequested": false, - "names": [ - null - ], - "type": "struct Election.Candidate memory", - "type_conversion": false - }, - "children": [ - { - "attributes": { - "argumentTypes": [ - { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - { - "typeIdentifier": "t_string_memory_ptr", - "typeString": "string memory" - }, - { - "typeIdentifier": "t_rational_0_by_1", - "typeString": "int_const 0" - } - ], - "overloadedDeclarations": [ - null - ], - "referencedDeclaration": 8, - "type": "type(struct Election.Candidate storage pointer)", - "value": "Candidate" - }, - "id": 45, - "name": "Identifier", - "src": "721:9:0" - }, - { - "attributes": { - "argumentTypes": null, - "overloadedDeclarations": [ - null - ], - "referencedDeclaration": 18, - "type": "uint256", - "value": "candidatesCount" - }, - "id": 46, - "name": "Identifier", - "src": "731:15:0" - }, - { - "attributes": { - "argumentTypes": null, - "overloadedDeclarations": [ - null - ], - "referencedDeclaration": 36, - "type": "string memory", - "value": "_name" - }, - "id": 47, - "name": "Identifier", - "src": "748:5:0" - }, - { - "attributes": { - "argumentTypes": null, - "hexvalue": "30", - "isConstant": false, - "isLValue": false, - "isPure": true, - "lValueRequested": false, - "subdenomination": null, - "token": "number", - "type": "int_const 0", - "value": "0" - }, - "id": 48, - "name": "Literal", - "src": "755:1:0" - } - ], - "id": 49, - "name": "FunctionCall", - "src": "721:36:0" + "nodeType": "BinaryOperation", + "operator": "<=", + "rightExpression": { + "argumentTypes": null, + "id": 71, + "name": "candidatesCount", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 18, + "src": "985:15:0", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "src": "969:31:0", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" } - ], - "id": 50, - "name": "Assignment", - "src": "691:66:0" + }, + "src": "949:51:0", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } } ], - "id": 51, - "name": "ExpressionStatement", - "src": "691:66:0" + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + ], + "id": 66, + "name": "require", + "nodeType": "Identifier", + "overloadedDeclarations": [ + 170, + 171 + ], + "referencedDeclaration": 170, + "src": "941:7:0", + "typeDescriptions": { + "typeIdentifier": "t_function_require_pure$_t_bool_$returns$__$", + "typeString": "function (bool) pure" + } + }, + "id": 74, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "941:60:0", + "typeDescriptions": { + "typeIdentifier": "t_tuple$__$", + "typeString": "tuple()" + } + }, + "id": 75, + "nodeType": "ExpressionStatement", + "src": "941:60:0" + }, + { + "expression": { + "argumentTypes": null, + "id": 81, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftHandSide": { + "argumentTypes": null, + "baseExpression": { + "argumentTypes": null, + "id": 76, + "name": "voters", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 12, + "src": "1051:6:0", + "typeDescriptions": { + "typeIdentifier": "t_mapping$_t_address_$_t_bool_$", + "typeString": "mapping(address => bool)" + } + }, + "id": 79, + "indexExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 77, + "name": "msg", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 167, + "src": "1058:3:0", + "typeDescriptions": { + "typeIdentifier": "t_magic_message", + "typeString": "msg" + } + }, + "id": 78, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "sender", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "1058:10:0", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "isConstant": false, + "isLValue": true, + "isPure": false, + "lValueRequested": true, + "nodeType": "IndexAccess", + "src": "1051:18:0", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "nodeType": "Assignment", + "operator": "=", + "rightHandSide": { + "argumentTypes": null, + "hexValue": "74727565", + "id": 80, + "isConstant": false, + "isLValue": false, + "isPure": true, + "kind": "bool", + "lValueRequested": false, + "nodeType": "Literal", + "src": "1072:4:0", + "subdenomination": null, + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + }, + "value": "true" + }, + "src": "1051:25:0", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "id": 82, + "nodeType": "ExpressionStatement", + "src": "1051:25:0" + }, + { + "expression": { + "argumentTypes": null, + "id": 87, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "nodeType": "UnaryOperation", + "operator": "++", + "prefix": false, + "src": "1126:37:0", + "subExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "baseExpression": { + "argumentTypes": null, + "id": 83, + "name": "candidates", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 16, + "src": "1126:10:0", + "typeDescriptions": { + "typeIdentifier": "t_mapping$_t_uint256_$_t_struct$_Candidate_$8_storage_$", + "typeString": "mapping(uint256 => struct Election.Candidate storage ref)" + } + }, + "id": 85, + "indexExpression": { + "argumentTypes": null, + "id": 84, + "name": "_candidateId", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 55, + "src": "1137:12:0", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "isConstant": false, + "isLValue": true, + "isPure": false, + "lValueRequested": false, + "nodeType": "IndexAccess", + "src": "1126:24:0", + "typeDescriptions": { + "typeIdentifier": "t_struct$_Candidate_$8_storage", + "typeString": "struct Election.Candidate storage ref" + } + }, + "id": 86, + "isConstant": false, + "isLValue": true, + "isPure": false, + "lValueRequested": true, + "memberName": "voteCount", + "nodeType": "MemberAccess", + "referencedDeclaration": 7, + "src": "1126:34:0", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "id": 88, + "nodeType": "ExpressionStatement", + "src": "1126:37:0" + }, + { + "eventCall": { + "argumentTypes": null, + "arguments": [ + { + "argumentTypes": null, + "id": 90, + "name": "_candidateId", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 55, + "src": "1221:12:0", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + ], + "id": 89, + "name": "votedEvent", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 22, + "src": "1210:10:0", + "typeDescriptions": { + "typeIdentifier": "t_function_event_nonpayable$_t_uint256_$returns$__$", + "typeString": "function (uint256)" + } + }, + "id": 91, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "1210:24:0", + "typeDescriptions": { + "typeIdentifier": "t_tuple$__$", + "typeString": "tuple()" + } + }, + "id": 92, + "nodeType": "EmitStatement", + "src": "1205:29:0" + } + ] + }, + "documentation": null, + "id": 94, + "implemented": true, + "isConstructor": false, + "isDeclaredConst": false, + "modifiers": [], + "name": "vote", + "nodeType": "FunctionDefinition", + "parameters": { + "id": 56, + "nodeType": "ParameterList", + "parameters": [ + { + "constant": false, + "id": 55, + "name": "_candidateId", + "nodeType": "VariableDeclaration", + "scope": 94, + "src": "779:17:0", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "typeName": { + "id": 54, + "name": "uint", + "nodeType": "ElementaryTypeName", + "src": "779:4:0", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "value": null, + "visibility": "internal" + } + ], + "src": "778:19:0" + }, + "payable": false, + "returnParameters": { + "id": 57, + "nodeType": "ParameterList", + "parameters": [], + "src": "805:0:0" + }, + "scope": 95, + "src": "764:477:0", + "stateMutability": "nonpayable", + "superFunction": null, + "visibility": "public" + } + ], + "scope": 96, + "src": "25:1218:0" + } + ], + "src": "0:1244:0" + }, + "legacyAST": { + "absolutePath": "/Users/adlymousa/Ethereum/election/contracts/Election.sol", + "exportedSymbols": { + "Election": [ + 95 + ] + }, + "id": 96, + "nodeType": "SourceUnit", + "nodes": [ + { + "id": 1, + "literals": [ + "solidity", + "0.4", + ".24" + ], + "nodeType": "PragmaDirective", + "src": "0:23:0" + }, + { + "baseContracts": [], + "contractDependencies": [], + "contractKind": "contract", + "documentation": null, + "fullyImplemented": true, + "id": 95, + "linearizedBaseContracts": [ + 95 + ], + "name": "Election", + "nodeType": "ContractDefinition", + "nodes": [ + { + "canonicalName": "Election.Candidate", + "id": 8, + "members": [ + { + "constant": false, + "id": 3, + "name": "id", + "nodeType": "VariableDeclaration", + "scope": 8, + "src": "101:7:0", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "typeName": { + "id": 2, + "name": "uint", + "nodeType": "ElementaryTypeName", + "src": "101:4:0", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" } - ], - "id": 52, - "name": "Block", - "src": "653:111:0" + }, + "value": null, + "visibility": "internal" + }, + { + "constant": false, + "id": 5, + "name": "name", + "nodeType": "VariableDeclaration", + "scope": 8, + "src": "118:11:0", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_string_storage_ptr", + "typeString": "string" + }, + "typeName": { + "id": 4, + "name": "string", + "nodeType": "ElementaryTypeName", + "src": "118:6:0", + "typeDescriptions": { + "typeIdentifier": "t_string_storage_ptr", + "typeString": "string" + } + }, + "value": null, + "visibility": "internal" + }, + { + "constant": false, + "id": 7, + "name": "voteCount", + "nodeType": "VariableDeclaration", + "scope": 8, + "src": "139:14:0", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "typeName": { + "id": 6, + "name": "uint", + "nodeType": "ElementaryTypeName", + "src": "139:4:0", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "value": null, + "visibility": "internal" } ], - "id": 53, - "name": "FunctionDefinition", - "src": "608:156:0" + "name": "Candidate", + "nodeType": "StructDefinition", + "scope": 95, + "src": "74:86:0", + "visibility": "public" }, { - "attributes": { - "constant": false, - "implemented": true, - "isConstructor": false, - "modifiers": [ - null + "constant": false, + "id": 12, + "name": "voters", + "nodeType": "VariableDeclaration", + "scope": 95, + "src": "204:38:0", + "stateVariable": true, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_mapping$_t_address_$_t_bool_$", + "typeString": "mapping(address => bool)" + }, + "typeName": { + "id": 11, + "keyType": { + "id": 9, + "name": "address", + "nodeType": "ElementaryTypeName", + "src": "212:7:0", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "nodeType": "Mapping", + "src": "204:24:0", + "typeDescriptions": { + "typeIdentifier": "t_mapping$_t_address_$_t_bool_$", + "typeString": "mapping(address => bool)" + }, + "valueType": { + "id": 10, + "name": "bool", + "nodeType": "ElementaryTypeName", + "src": "223:4:0", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + } + }, + "value": null, + "visibility": "public" + }, + { + "constant": false, + "id": 16, + "name": "candidates", + "nodeType": "VariableDeclaration", + "scope": 95, + "src": "295:44:0", + "stateVariable": true, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_mapping$_t_uint256_$_t_struct$_Candidate_$8_storage_$", + "typeString": "mapping(uint256 => struct Election.Candidate)" + }, + "typeName": { + "id": 15, + "keyType": { + "id": 13, + "name": "uint", + "nodeType": "ElementaryTypeName", + "src": "303:4:0", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "Mapping", + "src": "295:26:0", + "typeDescriptions": { + "typeIdentifier": "t_mapping$_t_uint256_$_t_struct$_Candidate_$8_storage_$", + "typeString": "mapping(uint256 => struct Election.Candidate)" + }, + "valueType": { + "contractScope": null, + "id": 14, + "name": "Candidate", + "nodeType": "UserDefinedTypeName", + "referencedDeclaration": 8, + "src": "311:9:0", + "typeDescriptions": { + "typeIdentifier": "t_struct$_Candidate_$8_storage_ptr", + "typeString": "struct Election.Candidate" + } + } + }, + "value": null, + "visibility": "public" + }, + { + "constant": false, + "id": 18, + "name": "candidatesCount", + "nodeType": "VariableDeclaration", + "scope": 95, + "src": "375:27:0", + "stateVariable": true, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "typeName": { + "id": 17, + "name": "uint", + "nodeType": "ElementaryTypeName", + "src": "375:4:0", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "value": null, + "visibility": "public" + }, + { + "anonymous": false, + "documentation": null, + "id": 22, + "name": "votedEvent", + "nodeType": "EventDefinition", + "parameters": { + "id": 21, + "nodeType": "ParameterList", + "parameters": [ + { + "constant": false, + "id": 20, + "indexed": true, + "name": "_candidateId", + "nodeType": "VariableDeclaration", + "scope": 22, + "src": "455:25:0", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "typeName": { + "id": 19, + "name": "uint", + "nodeType": "ElementaryTypeName", + "src": "455:4:0", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "value": null, + "visibility": "internal" + } ], - "name": "vote", - "payable": false, - "scope": 95, - "stateMutability": "nonpayable", - "superFunction": null, - "visibility": "public" + "src": "445:41:0" }, - "children": [ - { - "children": [ - { - "attributes": { - "constant": false, - "name": "_candidateId", - "scope": 94, - "stateVariable": false, - "storageLocation": "default", - "type": "uint256", - "value": null, - "visibility": "internal" - }, - "children": [ + "src": "428:59:0" + }, + { + "body": { + "id": 33, + "nodeType": "Block", + "src": "515:81:0", + "statements": [ + { + "expression": { + "argumentTypes": null, + "arguments": [ { - "attributes": { - "name": "uint", - "type": "uint256" + "argumentTypes": null, + "hexValue": "43616e6469646174652031", + "id": 26, + "isConstant": false, + "isLValue": false, + "isPure": true, + "kind": "string", + "lValueRequested": false, + "nodeType": "Literal", + "src": "538:13:0", + "subdenomination": null, + "typeDescriptions": { + "typeIdentifier": "t_stringliteral_41f9dcbd43e9b33194759b5a51b1df9864cdc2b2138ff106f03091eb79861f0c", + "typeString": "literal_string \"Candidate 1\"" }, - "id": 54, - "name": "ElementaryTypeName", - "src": "785:4:0" + "value": "Candidate 1" } ], - "id": 55, - "name": "VariableDeclaration", - "src": "785:17:0" - } - ], - "id": 56, - "name": "ParameterList", - "src": "784:19:0" - }, - { - "attributes": { - "parameters": [ - null - ] + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_stringliteral_41f9dcbd43e9b33194759b5a51b1df9864cdc2b2138ff106f03091eb79861f0c", + "typeString": "literal_string \"Candidate 1\"" + } + ], + "id": 25, + "name": "addCandidate", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 53, + "src": "525:12:0", + "typeDescriptions": { + "typeIdentifier": "t_function_internal_nonpayable$_t_string_memory_ptr_$returns$__$", + "typeString": "function (string memory)" + } + }, + "id": 27, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "525:27:0", + "typeDescriptions": { + "typeIdentifier": "t_tuple$__$", + "typeString": "tuple()" + } + }, + "id": 28, + "nodeType": "ExpressionStatement", + "src": "525:27:0" }, - "children": [], - "id": 57, - "name": "ParameterList", - "src": "811:0:0" - }, - { - "children": [ - { - "children": [ + { + "expression": { + "argumentTypes": null, + "arguments": [ { - "attributes": { + "argumentTypes": null, + "hexValue": "43616e6469646174652032", + "id": 30, + "isConstant": false, + "isLValue": false, + "isPure": true, + "kind": "string", + "lValueRequested": false, + "nodeType": "Literal", + "src": "575:13:0", + "subdenomination": null, + "typeDescriptions": { + "typeIdentifier": "t_stringliteral_f1f17440f69835dafba5c9fd0e4caa6c780807a80f8d1745ec7af1408d6cca4a", + "typeString": "literal_string \"Candidate 2\"" + }, + "value": "Candidate 2" + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_stringliteral_f1f17440f69835dafba5c9fd0e4caa6c780807a80f8d1745ec7af1408d6cca4a", + "typeString": "literal_string \"Candidate 2\"" + } + ], + "id": 29, + "name": "addCandidate", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 53, + "src": "562:12:0", + "typeDescriptions": { + "typeIdentifier": "t_function_internal_nonpayable$_t_string_memory_ptr_$returns$__$", + "typeString": "function (string memory)" + } + }, + "id": 31, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "562:27:0", + "typeDescriptions": { + "typeIdentifier": "t_tuple$__$", + "typeString": "tuple()" + } + }, + "id": 32, + "nodeType": "ExpressionStatement", + "src": "562:27:0" + } + ] + }, + "documentation": null, + "id": 34, + "implemented": true, + "isConstructor": true, + "isDeclaredConst": false, + "modifiers": [], + "name": "", + "nodeType": "FunctionDefinition", + "parameters": { + "id": 23, + "nodeType": "ParameterList", + "parameters": [], + "src": "505:2:0" + }, + "payable": false, + "returnParameters": { + "id": 24, + "nodeType": "ParameterList", + "parameters": [], + "src": "515:0:0" + }, + "scope": 95, + "src": "493:103:0", + "stateMutability": "nonpayable", + "superFunction": null, + "visibility": "public" + }, + { + "body": { + "id": 52, + "nodeType": "Block", + "src": "647:111:0", + "statements": [ + { + "expression": { + "argumentTypes": null, + "id": 40, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "nodeType": "UnaryOperation", + "operator": "++", + "prefix": false, + "src": "657:18:0", + "subExpression": { + "argumentTypes": null, + "id": 39, + "name": "candidatesCount", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 18, + "src": "657:15:0", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "id": 41, + "nodeType": "ExpressionStatement", + "src": "657:18:0" + }, + { + "expression": { + "argumentTypes": null, + "id": 50, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftHandSide": { + "argumentTypes": null, + "baseExpression": { + "argumentTypes": null, + "id": 42, + "name": "candidates", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 16, + "src": "685:10:0", + "typeDescriptions": { + "typeIdentifier": "t_mapping$_t_uint256_$_t_struct$_Candidate_$8_storage_$", + "typeString": "mapping(uint256 => struct Election.Candidate storage ref)" + } + }, + "id": 44, + "indexExpression": { + "argumentTypes": null, + "id": 43, + "name": "candidatesCount", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 18, + "src": "696:15:0", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "isConstant": false, + "isLValue": true, + "isPure": false, + "lValueRequested": true, + "nodeType": "IndexAccess", + "src": "685:27:0", + "typeDescriptions": { + "typeIdentifier": "t_struct$_Candidate_$8_storage", + "typeString": "struct Election.Candidate storage ref" + } + }, + "nodeType": "Assignment", + "operator": "=", + "rightHandSide": { + "argumentTypes": null, + "arguments": [ + { + "argumentTypes": null, + "id": 46, + "name": "candidatesCount", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 18, + "src": "725:15:0", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + { + "argumentTypes": null, + "id": 47, + "name": "_name", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 36, + "src": "742:5:0", + "typeDescriptions": { + "typeIdentifier": "t_string_memory_ptr", + "typeString": "string memory" + } + }, + { "argumentTypes": null, + "hexValue": "30", + "id": 48, "isConstant": false, "isLValue": false, - "isPure": false, - "isStructConstructorCall": false, + "isPure": true, + "kind": "number", "lValueRequested": false, - "names": [ - null - ], - "type": "tuple()", - "type_conversion": false - }, - "children": [ + "nodeType": "Literal", + "src": "749:1:0", + "subdenomination": null, + "typeDescriptions": { + "typeIdentifier": "t_rational_0_by_1", + "typeString": "int_const 0" + }, + "value": "0" + } + ], + "expression": { + "argumentTypes": [ { - "attributes": { - "argumentTypes": [ - { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - ], - "overloadedDeclarations": [ - null - ], - "referencedDeclaration": 110, - "type": "function (bool) pure", - "value": "require" - }, - "id": 58, - "name": "Identifier", - "src": "871:7:0" + "typeIdentifier": "t_uint256", + "typeString": "uint256" }, { - "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, - "overloadedDeclarations": [ - null - ], - "referencedDeclaration": 12, - "type": "mapping(address => bool)", - "value": "voters" - }, - "id": 59, - "name": "Identifier", - "src": "880:6:0" - }, - { - "attributes": { - "argumentTypes": null, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "member_name": "sender", - "referencedDeclaration": null, - "type": "address" - }, - "children": [ - { - "attributes": { - "argumentTypes": null, - "overloadedDeclarations": [ - null - ], - "referencedDeclaration": 107, - "type": "msg", - "value": "msg" - }, - "id": 60, - "name": "Identifier", - "src": "887:3:0" - } - ], - "id": 61, - "name": "MemberAccess", - "src": "887:10:0" - } - ], - "id": 62, - "name": "IndexAccess", - "src": "880:18:0" - } - ], - "id": 63, - "name": "UnaryOperation", - "src": "879:19:0" + "typeIdentifier": "t_string_memory_ptr", + "typeString": "string memory" + }, + { + "typeIdentifier": "t_rational_0_by_1", + "typeString": "int_const 0" } ], - "id": 64, - "name": "FunctionCall", - "src": "871:28:0" + "id": 45, + "name": "Candidate", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 8, + "src": "715:9:0", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_struct$_Candidate_$8_storage_ptr_$", + "typeString": "type(struct Election.Candidate storage pointer)" + } + }, + "id": 49, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "structConstructorCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "715:36:0", + "typeDescriptions": { + "typeIdentifier": "t_struct$_Candidate_$8_memory", + "typeString": "struct Election.Candidate memory" } - ], - "id": 65, - "name": "ExpressionStatement", - "src": "871:28:0" + }, + "src": "685:66:0", + "typeDescriptions": { + "typeIdentifier": "t_struct$_Candidate_$8_storage", + "typeString": "struct Election.Candidate storage ref" + } }, - { - "children": [ + "id": 51, + "nodeType": "ExpressionStatement", + "src": "685:66:0" + } + ] + }, + "documentation": null, + "id": 53, + "implemented": true, + "isConstructor": false, + "isDeclaredConst": false, + "modifiers": [], + "name": "addCandidate", + "nodeType": "FunctionDefinition", + "parameters": { + "id": 37, + "nodeType": "ParameterList", + "parameters": [ + { + "constant": false, + "id": 36, + "name": "_name", + "nodeType": "VariableDeclaration", + "scope": 53, + "src": "625:12:0", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_string_memory_ptr", + "typeString": "string" + }, + "typeName": { + "id": 35, + "name": "string", + "nodeType": "ElementaryTypeName", + "src": "625:6:0", + "typeDescriptions": { + "typeIdentifier": "t_string_storage_ptr", + "typeString": "string" + } + }, + "value": null, + "visibility": "internal" + } + ], + "src": "624:14:0" + }, + "payable": false, + "returnParameters": { + "id": 38, + "nodeType": "ParameterList", + "parameters": [], + "src": "647:0:0" + }, + "scope": 95, + "src": "602:156:0", + "stateMutability": "nonpayable", + "superFunction": null, + "visibility": "private" + }, + { + "body": { + "id": 93, + "nodeType": "Block", + "src": "805:436:0", + "statements": [ + { + "expression": { + "argumentTypes": null, + "arguments": [ { - "attributes": { + "argumentTypes": null, + "id": 63, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "nodeType": "UnaryOperation", + "operator": "!", + "prefix": true, + "src": "873:19:0", + "subExpression": { "argumentTypes": null, - "isConstant": false, - "isLValue": false, - "isPure": false, - "isStructConstructorCall": false, - "lValueRequested": false, - "names": [ - null - ], - "type": "tuple()", - "type_conversion": false - }, - "children": [ - { - "attributes": { - "argumentTypes": [ - { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - ], - "overloadedDeclarations": [ - null - ], - "referencedDeclaration": 110, - "type": "function (bool) pure", - "value": "require" - }, - "id": 66, - "name": "Identifier", - "src": "947:7:0" + "baseExpression": { + "argumentTypes": null, + "id": 59, + "name": "voters", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 12, + "src": "874:6:0", + "typeDescriptions": { + "typeIdentifier": "t_mapping$_t_address_$_t_bool_$", + "typeString": "mapping(address => bool)" + } }, - { - "attributes": { + "id": 62, + "indexExpression": { + "argumentTypes": null, + "expression": { "argumentTypes": null, - "commonType": { - "typeIdentifier": "t_bool", - "typeString": "bool" - }, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "operator": "&&", - "type": "bool" - }, - "children": [ - { - "attributes": { - "argumentTypes": null, - "commonType": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "operator": ">", - "type": "bool" - }, - "children": [ - { - "attributes": { - "argumentTypes": null, - "overloadedDeclarations": [ - null - ], - "referencedDeclaration": 55, - "type": "uint256", - "value": "_candidateId" - }, - "id": 67, - "name": "Identifier", - "src": "955:12:0" - }, - { - "attributes": { - "argumentTypes": null, - "hexvalue": "30", - "isConstant": false, - "isLValue": false, - "isPure": true, - "lValueRequested": false, - "subdenomination": null, - "token": "number", - "type": "int_const 0", - "value": "0" - }, - "id": 68, - "name": "Literal", - "src": "970:1:0" - } - ], - "id": 69, - "name": "BinaryOperation", - "src": "955:16:0" - }, - { - "attributes": { - "argumentTypes": null, - "commonType": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "operator": "<=", - "type": "bool" - }, - "children": [ - { - "attributes": { - "argumentTypes": null, - "overloadedDeclarations": [ - null - ], - "referencedDeclaration": 55, - "type": "uint256", - "value": "_candidateId" - }, - "id": 70, - "name": "Identifier", - "src": "975:12:0" - }, - { - "attributes": { - "argumentTypes": null, - "overloadedDeclarations": [ - null - ], - "referencedDeclaration": 18, - "type": "uint256", - "value": "candidatesCount" - }, - "id": 71, - "name": "Identifier", - "src": "991:15:0" - } - ], - "id": 72, - "name": "BinaryOperation", - "src": "975:31:0" + "id": 60, + "name": "msg", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 167, + "src": "881:3:0", + "typeDescriptions": { + "typeIdentifier": "t_magic_message", + "typeString": "msg" } - ], - "id": 73, - "name": "BinaryOperation", - "src": "955:51:0" + }, + "id": 61, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "sender", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "881:10:0", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "isConstant": false, + "isLValue": true, + "isPure": false, + "lValueRequested": false, + "nodeType": "IndexAccess", + "src": "874:18:0", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" } - ], - "id": 74, - "name": "FunctionCall", - "src": "947:60:0" + }, + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } } ], - "id": 75, - "name": "ExpressionStatement", - "src": "947:60:0" + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + ], + "id": 58, + "name": "require", + "nodeType": "Identifier", + "overloadedDeclarations": [ + 170, + 171 + ], + "referencedDeclaration": 170, + "src": "865:7:0", + "typeDescriptions": { + "typeIdentifier": "t_function_require_pure$_t_bool_$returns$__$", + "typeString": "function (bool) pure" + } + }, + "id": 64, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "865:28:0", + "typeDescriptions": { + "typeIdentifier": "t_tuple$__$", + "typeString": "tuple()" + } }, - { - "children": [ + "id": 65, + "nodeType": "ExpressionStatement", + "src": "865:28:0" + }, + { + "expression": { + "argumentTypes": null, + "arguments": [ { - "attributes": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_bool", + "typeString": "bool" + }, + "id": 73, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "id": 69, "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, - "overloadedDeclarations": [ - null - ], - "referencedDeclaration": 12, - "type": "mapping(address => bool)", - "value": "voters" - }, - "id": 76, - "name": "Identifier", - "src": "1057:6:0" - }, - { - "attributes": { - "argumentTypes": null, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "member_name": "sender", - "referencedDeclaration": null, - "type": "address" - }, - "children": [ - { - "attributes": { - "argumentTypes": null, - "overloadedDeclarations": [ - null - ], - "referencedDeclaration": 107, - "type": "msg", - "value": "msg" - }, - "id": 77, - "name": "Identifier", - "src": "1064:3:0" - } - ], - "id": 78, - "name": "MemberAccess", - "src": "1064:10:0" - } - ], - "id": 79, - "name": "IndexAccess", - "src": "1057:18:0" + "leftExpression": { + "argumentTypes": null, + "id": 67, + "name": "_candidateId", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 55, + "src": "949:12:0", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } }, - { - "attributes": { - "argumentTypes": null, - "hexvalue": "74727565", - "isConstant": false, - "isLValue": false, - "isPure": true, - "lValueRequested": false, - "subdenomination": null, - "token": "bool", - "type": "bool", - "value": "true" + "nodeType": "BinaryOperation", + "operator": ">", + "rightExpression": { + "argumentTypes": null, + "hexValue": "30", + "id": 68, + "isConstant": false, + "isLValue": false, + "isPure": true, + "kind": "number", + "lValueRequested": false, + "nodeType": "Literal", + "src": "964:1:0", + "subdenomination": null, + "typeDescriptions": { + "typeIdentifier": "t_rational_0_by_1", + "typeString": "int_const 0" }, - "id": 80, - "name": "Literal", - "src": "1078:4:0" + "value": "0" + }, + "src": "949:16:0", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" } - ], - "id": 81, - "name": "Assignment", - "src": "1057:25:0" - } - ], - "id": 82, - "name": "ExpressionStatement", - "src": "1057:25:0" - }, - { - "children": [ - { - "attributes": { + }, + "nodeType": "BinaryOperation", + "operator": "&&", + "rightExpression": { "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "id": 72, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, - "operator": "++", - "prefix": false, - "type": "uint256" - }, - "children": [ - { - "attributes": { - "argumentTypes": null, - "isConstant": false, - "isLValue": true, - "isPure": false, - "lValueRequested": true, - "member_name": "voteCount", - "referencedDeclaration": 7, - "type": "uint256" - }, - "children": [ - { - "attributes": { - "argumentTypes": null, - "isConstant": false, - "isLValue": true, - "isPure": false, - "lValueRequested": false, - "type": "struct Election.Candidate storage ref" - }, - "children": [ - { - "attributes": { - "argumentTypes": null, - "overloadedDeclarations": [ - null - ], - "referencedDeclaration": 16, - "type": "mapping(uint256 => struct Election.Candidate storage ref)", - "value": "candidates" - }, - "id": 83, - "name": "Identifier", - "src": "1132:10:0" - }, - { - "attributes": { - "argumentTypes": null, - "overloadedDeclarations": [ - null - ], - "referencedDeclaration": 55, - "type": "uint256", - "value": "_candidateId" - }, - "id": 84, - "name": "Identifier", - "src": "1143:12:0" - } - ], - "id": 85, - "name": "IndexAccess", - "src": "1132:24:0" - } - ], - "id": 86, - "name": "MemberAccess", - "src": "1132:34:0" + "leftExpression": { + "argumentTypes": null, + "id": 70, + "name": "_candidateId", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 55, + "src": "969:12:0", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "BinaryOperation", + "operator": "<=", + "rightExpression": { + "argumentTypes": null, + "id": 71, + "name": "candidatesCount", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 18, + "src": "985:15:0", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "src": "969:31:0", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" } - ], - "id": 87, - "name": "UnaryOperation", - "src": "1132:37:0" + }, + "src": "949:51:0", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } } ], - "id": 88, - "name": "ExpressionStatement", - "src": "1132:37:0" + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + ], + "id": 66, + "name": "require", + "nodeType": "Identifier", + "overloadedDeclarations": [ + 170, + 171 + ], + "referencedDeclaration": 170, + "src": "941:7:0", + "typeDescriptions": { + "typeIdentifier": "t_function_require_pure$_t_bool_$returns$__$", + "typeString": "function (bool) pure" + } + }, + "id": 74, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "941:60:0", + "typeDescriptions": { + "typeIdentifier": "t_tuple$__$", + "typeString": "tuple()" + } }, - { - "children": [ - { - "attributes": { + "id": 75, + "nodeType": "ExpressionStatement", + "src": "941:60:0" + }, + { + "expression": { + "argumentTypes": null, + "id": 81, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftHandSide": { + "argumentTypes": null, + "baseExpression": { + "argumentTypes": null, + "id": 76, + "name": "voters", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 12, + "src": "1051:6:0", + "typeDescriptions": { + "typeIdentifier": "t_mapping$_t_address_$_t_bool_$", + "typeString": "mapping(address => bool)" + } + }, + "id": 79, + "indexExpression": { + "argumentTypes": null, + "expression": { "argumentTypes": null, - "isConstant": false, - "isLValue": false, - "isPure": false, - "isStructConstructorCall": false, - "lValueRequested": false, - "names": [ - null - ], - "type": "tuple()", - "type_conversion": false + "id": 77, + "name": "msg", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 167, + "src": "1058:3:0", + "typeDescriptions": { + "typeIdentifier": "t_magic_message", + "typeString": "msg" + } }, - "children": [ - { - "attributes": { - "argumentTypes": [ - { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - ], - "overloadedDeclarations": [ - null - ], - "referencedDeclaration": 22, - "type": "function (uint256)", - "value": "votedEvent" - }, - "id": 89, - "name": "Identifier", - "src": "1211:10:0" - }, - { - "attributes": { - "argumentTypes": null, - "overloadedDeclarations": [ - null - ], - "referencedDeclaration": 55, - "type": "uint256", - "value": "_candidateId" - }, - "id": 90, - "name": "Identifier", - "src": "1222:12:0" + "id": 78, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "sender", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "1058:10:0", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "isConstant": false, + "isLValue": true, + "isPure": false, + "lValueRequested": true, + "nodeType": "IndexAccess", + "src": "1051:18:0", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "nodeType": "Assignment", + "operator": "=", + "rightHandSide": { + "argumentTypes": null, + "hexValue": "74727565", + "id": 80, + "isConstant": false, + "isLValue": false, + "isPure": true, + "kind": "bool", + "lValueRequested": false, + "nodeType": "Literal", + "src": "1072:4:0", + "subdenomination": null, + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + }, + "value": "true" + }, + "src": "1051:25:0", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "id": 82, + "nodeType": "ExpressionStatement", + "src": "1051:25:0" + }, + { + "expression": { + "argumentTypes": null, + "id": 87, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "nodeType": "UnaryOperation", + "operator": "++", + "prefix": false, + "src": "1126:37:0", + "subExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "baseExpression": { + "argumentTypes": null, + "id": 83, + "name": "candidates", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 16, + "src": "1126:10:0", + "typeDescriptions": { + "typeIdentifier": "t_mapping$_t_uint256_$_t_struct$_Candidate_$8_storage_$", + "typeString": "mapping(uint256 => struct Election.Candidate storage ref)" } - ], - "id": 91, - "name": "FunctionCall", - "src": "1211:24:0" + }, + "id": 85, + "indexExpression": { + "argumentTypes": null, + "id": 84, + "name": "_candidateId", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 55, + "src": "1137:12:0", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "isConstant": false, + "isLValue": true, + "isPure": false, + "lValueRequested": false, + "nodeType": "IndexAccess", + "src": "1126:24:0", + "typeDescriptions": { + "typeIdentifier": "t_struct$_Candidate_$8_storage", + "typeString": "struct Election.Candidate storage ref" + } + }, + "id": 86, + "isConstant": false, + "isLValue": true, + "isPure": false, + "lValueRequested": true, + "memberName": "voteCount", + "nodeType": "MemberAccess", + "referencedDeclaration": 7, + "src": "1126:34:0", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "id": 88, + "nodeType": "ExpressionStatement", + "src": "1126:37:0" + }, + { + "eventCall": { + "argumentTypes": null, + "arguments": [ + { + "argumentTypes": null, + "id": 90, + "name": "_candidateId", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 55, + "src": "1221:12:0", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } } ], - "id": 92, - "name": "ExpressionStatement", - "src": "1211:24:0" - } - ], - "id": 93, - "name": "Block", - "src": "811:431:0" - } - ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + ], + "id": 89, + "name": "votedEvent", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 22, + "src": "1210:10:0", + "typeDescriptions": { + "typeIdentifier": "t_function_event_nonpayable$_t_uint256_$returns$__$", + "typeString": "function (uint256)" + } + }, + "id": 91, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "1210:24:0", + "typeDescriptions": { + "typeIdentifier": "t_tuple$__$", + "typeString": "tuple()" + } + }, + "id": 92, + "nodeType": "EmitStatement", + "src": "1205:29:0" + } + ] + }, + "documentation": null, "id": 94, - "name": "FunctionDefinition", - "src": "770:472:0" + "implemented": true, + "isConstructor": false, + "isDeclaredConst": false, + "modifiers": [], + "name": "vote", + "nodeType": "FunctionDefinition", + "parameters": { + "id": 56, + "nodeType": "ParameterList", + "parameters": [ + { + "constant": false, + "id": 55, + "name": "_candidateId", + "nodeType": "VariableDeclaration", + "scope": 94, + "src": "779:17:0", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "typeName": { + "id": 54, + "name": "uint", + "nodeType": "ElementaryTypeName", + "src": "779:4:0", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "value": null, + "visibility": "internal" + } + ], + "src": "778:19:0" + }, + "payable": false, + "returnParameters": { + "id": 57, + "nodeType": "ParameterList", + "parameters": [], + "src": "805:0:0" + }, + "scope": 95, + "src": "764:477:0", + "stateMutability": "nonpayable", + "superFunction": null, + "visibility": "public" } ], - "id": 95, - "name": "ContractDefinition", - "src": "25:1219:0" + "scope": 96, + "src": "25:1218:0" } ], - "id": 96, - "name": "SourceUnit", - "src": "0:1245:0" + "src": "0:1244:0" }, "compiler": { "name": "solc", - "version": "0.4.18+commit.9cf6e910.Emscripten.clang" + "version": "0.4.24+commit.e67f0147.Emscripten.clang" }, "networks": { "5777": { "events": {}, "links": {}, - "address": "0x30753e4a8aad7f8597332e813735def5dd395028" + "address": "0x4fca8e0433d89d9d129c80ca3727be732ccc2900", + "transactionHash": "0x47e9f59f78128d2bd5131e825d3f9457cae96c71703b6d7673a46a0e7047bc1a" } }, - "schemaVersion": "1.0.1", - "updatedAt": "2018-05-18T14:43:46.963Z" + "schemaVersion": "2.0.1", + "updatedAt": "2018-08-10T01:55:57.786Z" } \ No newline at end of file diff --git a/build/contracts/Migrations.json b/build/contracts/Migrations.json index 56966ff2..b0a51e25 100644 --- a/build/contracts/Migrations.json +++ b/build/contracts/Migrations.json @@ -1,20 +1,6 @@ { "contractName": "Migrations", "abi": [ - { - "constant": false, - "inputs": [ - { - "name": "new_address", - "type": "address" - } - ], - "name": "upgrade", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, { "constant": true, "inputs": [], @@ -43,6 +29,12 @@ "stateMutability": "view", "type": "function" }, + { + "inputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "constructor" + }, { "constant": false, "inputs": [ @@ -58,770 +50,1338 @@ "type": "function" }, { - "inputs": [], + "constant": false, + "inputs": [ + { + "name": "new_address", + "type": "address" + } + ], + "name": "upgrade", + "outputs": [], "payable": false, "stateMutability": "nonpayable", - "type": "constructor" + "type": "function" } ], - "bytecode": "0x6060604052341561000f57600080fd5b336000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506102db8061005e6000396000f300606060405260043610610062576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680630900f01014610067578063445df0ac146100a05780638da5cb5b146100c9578063fdacd5761461011e575b600080fd5b341561007257600080fd5b61009e600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610141565b005b34156100ab57600080fd5b6100b3610224565b6040518082815260200191505060405180910390f35b34156100d457600080fd5b6100dc61022a565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b341561012957600080fd5b61013f600480803590602001909190505061024f565b005b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415610220578190508073ffffffffffffffffffffffffffffffffffffffff1663fdacd5766001546040518263ffffffff167c010000000000000000000000000000000000000000000000000000000002815260040180828152602001915050600060405180830381600087803b151561020b57600080fd5b6102c65a03f1151561021c57600080fd5b5050505b5050565b60015481565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614156102ac57806001819055505b505600a165627a7a72305820311594896802b810c22e6caa55e22c293ba62905cad41f7c9f5cca4dfb3c3b410029", - "deployedBytecode": "0x606060405260043610610062576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680630900f01014610067578063445df0ac146100a05780638da5cb5b146100c9578063fdacd5761461011e575b600080fd5b341561007257600080fd5b61009e600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610141565b005b34156100ab57600080fd5b6100b3610224565b6040518082815260200191505060405180910390f35b34156100d457600080fd5b6100dc61022a565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b341561012957600080fd5b61013f600480803590602001909190505061024f565b005b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415610220578190508073ffffffffffffffffffffffffffffffffffffffff1663fdacd5766001546040518263ffffffff167c010000000000000000000000000000000000000000000000000000000002815260040180828152602001915050600060405180830381600087803b151561020b57600080fd5b6102c65a03f1151561021c57600080fd5b5050505b5050565b60015481565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614156102ac57806001819055505b505600a165627a7a72305820311594896802b810c22e6caa55e22c293ba62905cad41f7c9f5cca4dfb3c3b410029", - "sourceMap": "25:467:1:-;;;177:51;;;;;;;;213:10;205:5;;:18;;;;;;;;;;;;;;;;;;25:467;;;;;;", - "deployedSourceMap": "25:467:1:-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;332:158;;;;;;;;;;;;;;;;;;;;;;;;;;;;73:36;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;49:20;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;232:96;;;;;;;;;;;;;;;;;;;;;;;;;;332:158;387:19;160:5;;;;;;;;;;;146:19;;:10;:19;;;142:26;;;420:11;387:45;;438:8;:21;;;460:24;;438:47;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;142:26;332:158;;:::o;73:36::-;;;;:::o;49:20::-;;;;;;;;;;;;;:::o;232:96::-;160:5;;;;;;;;;;;146:19;;:10;:19;;;142:26;;;314:9;287:24;:36;;;;142:26;232:96;:::o", - "source": "pragma solidity ^0.4.2;\n\ncontract Migrations {\n address public owner;\n uint public last_completed_migration;\n\n modifier restricted() {\n if (msg.sender == owner) _;\n }\n\n function Migrations() {\n owner = msg.sender;\n }\n\n function setCompleted(uint completed) restricted {\n last_completed_migration = completed;\n }\n\n function upgrade(address new_address) restricted {\n Migrations upgraded = Migrations(new_address);\n upgraded.setCompleted(last_completed_migration);\n }\n}\n", - "sourcePath": "/Users/gregory/code/election/contracts/Migrations.sol", + "bytecode": "0x608060405234801561001057600080fd5b50336000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506102f8806100606000396000f300608060405260043610610062576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680630900f01014610067578063445df0ac146100aa5780638da5cb5b146100d5578063fdacd5761461012c575b600080fd5b34801561007357600080fd5b506100a8600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610159565b005b3480156100b657600080fd5b506100bf610241565b6040518082815260200191505060405180910390f35b3480156100e157600080fd5b506100ea610247565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561013857600080fd5b506101576004803603810190808035906020019092919050505061026c565b005b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561023d578190508073ffffffffffffffffffffffffffffffffffffffff1663fdacd5766001546040518263ffffffff167c010000000000000000000000000000000000000000000000000000000002815260040180828152602001915050600060405180830381600087803b15801561022457600080fd5b505af1158015610238573d6000803e3d6000fd5b505050505b5050565b60015481565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614156102c957806001819055505b505600a165627a7a723058208f23b5eee7bd37914b79112b59d25ec1f3633d0045e949e7d4ff4e875297de980029", + "deployedBytecode": "0x608060405260043610610062576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680630900f01014610067578063445df0ac146100aa5780638da5cb5b146100d5578063fdacd5761461012c575b600080fd5b34801561007357600080fd5b506100a8600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610159565b005b3480156100b657600080fd5b506100bf610241565b6040518082815260200191505060405180910390f35b3480156100e157600080fd5b506100ea610247565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561013857600080fd5b506101576004803603810190808035906020019092919050505061026c565b005b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561023d578190508073ffffffffffffffffffffffffffffffffffffffff1663fdacd5766001546040518263ffffffff167c010000000000000000000000000000000000000000000000000000000002815260040180828152602001915050600060405180830381600087803b15801561022457600080fd5b505af1158015610238573d6000803e3d6000fd5b505050505b5050565b60015481565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614156102c957806001819055505b505600a165627a7a723058208f23b5eee7bd37914b79112b59d25ec1f3633d0045e949e7d4ff4e875297de980029", + "sourceMap": "25:459:1:-;;;177:43;8:9:-1;5:2;;;30:1;27;20:12;5:2;177:43:1;205:10;197:5;;:18;;;;;;;;;;;;;;;;;;25:459;;;;;;", + "deployedSourceMap": "25:459:1:-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;324:158;;8:9:-1;5:2;;;30:1;27;20:12;5:2;324:158:1;;;;;;;;;;;;;;;;;;;;;;;;;;;;73:36;;8:9:-1;5:2;;;30:1;27;20:12;5:2;73:36:1;;;;;;;;;;;;;;;;;;;;;;;49:20;;8:9:-1;5:2;;;30:1;27;20:12;5:2;49:20:1;;;;;;;;;;;;;;;;;;;;;;;;;;;224:96;;8:9:-1;5:2;;;30:1;27;20:12;5:2;224:96:1;;;;;;;;;;;;;;;;;;;;;;;;;;324:158;379:19;160:5;;;;;;;;;;;146:19;;:10;:19;;;142:26;;;412:11;379:45;;430:8;:21;;;452:24;;430:47;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;430:47:1;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;430:47:1;;;;142:26;324:158;;:::o;73:36::-;;;;:::o;49:20::-;;;;;;;;;;;;;:::o;224:96::-;160:5;;;;;;;;;;;146:19;;:10;:19;;;142:26;;;306:9;279:24;:36;;;;142:26;224:96;:::o", + "source": "pragma solidity ^0.4.2;\n\ncontract Migrations {\n address public owner;\n uint public last_completed_migration;\n\n modifier restricted() {\n if (msg.sender == owner) _;\n }\n\n constructor() {\n owner = msg.sender;\n }\n\n function setCompleted(uint completed) restricted {\n last_completed_migration = completed;\n }\n\n function upgrade(address new_address) restricted {\n Migrations upgraded = Migrations(new_address);\n upgraded.setCompleted(last_completed_migration);\n }\n}\n", + "sourcePath": "/Users/adlymousa/Ethereum/election/contracts/Migrations.sol", "ast": { - "attributes": { - "absolutePath": "/Users/gregory/code/election/contracts/Migrations.sol", - "exportedSymbols": { - "Migrations": [ - 69 - ] - } + "absolutePath": "/Users/adlymousa/Ethereum/election/contracts/Migrations.sol", + "exportedSymbols": { + "Migrations": [ + 152 + ] }, - "children": [ + "id": 153, + "nodeType": "SourceUnit", + "nodes": [ { - "attributes": { - "literals": [ - "solidity", - "^", - "0.4", - ".2" - ] - }, - "id": 14, - "name": "PragmaDirective", + "id": 97, + "literals": [ + "solidity", + "^", + "0.4", + ".2" + ], + "nodeType": "PragmaDirective", "src": "0:23:1" }, { - "attributes": { - "baseContracts": [ - null - ], - "contractDependencies": [ - null - ], - "contractKind": "contract", - "documentation": null, - "fullyImplemented": true, - "linearizedBaseContracts": [ - 69 - ], - "name": "Migrations", - "scope": 70 - }, - "children": [ + "baseContracts": [], + "contractDependencies": [], + "contractKind": "contract", + "documentation": null, + "fullyImplemented": true, + "id": 152, + "linearizedBaseContracts": [ + 152 + ], + "name": "Migrations", + "nodeType": "ContractDefinition", + "nodes": [ { - "attributes": { - "constant": false, - "name": "owner", - "scope": 69, - "stateVariable": true, - "storageLocation": "default", - "type": "address", - "value": null, - "visibility": "public" + "constant": false, + "id": 99, + "name": "owner", + "nodeType": "VariableDeclaration", + "scope": 152, + "src": "49:20:1", + "stateVariable": true, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" }, - "children": [ - { - "attributes": { - "name": "address", - "type": "address" - }, - "id": 15, - "name": "ElementaryTypeName", - "src": "49:7:1" + "typeName": { + "id": 98, + "name": "address", + "nodeType": "ElementaryTypeName", + "src": "49:7:1", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" } - ], - "id": 16, - "name": "VariableDeclaration", - "src": "49:20:1" + }, + "value": null, + "visibility": "public" }, { - "attributes": { - "constant": false, - "name": "last_completed_migration", - "scope": 69, - "stateVariable": true, - "storageLocation": "default", - "type": "uint256", - "value": null, - "visibility": "public" + "constant": false, + "id": 101, + "name": "last_completed_migration", + "nodeType": "VariableDeclaration", + "scope": 152, + "src": "73:36:1", + "stateVariable": true, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" }, - "children": [ - { - "attributes": { - "name": "uint", - "type": "uint256" - }, - "id": 17, - "name": "ElementaryTypeName", - "src": "73:4:1" + "typeName": { + "id": 100, + "name": "uint", + "nodeType": "ElementaryTypeName", + "src": "73:4:1", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" } - ], - "id": 18, - "name": "VariableDeclaration", - "src": "73:36:1" + }, + "value": null, + "visibility": "public" }, { - "attributes": { - "name": "restricted", - "visibility": "internal" - }, - "children": [ - { - "attributes": { - "parameters": [ - null - ] - }, - "children": [], - "id": 19, - "name": "ParameterList", - "src": "133:2:1" - }, - { - "children": [ - { - "attributes": { - "falseBody": null + "body": { + "id": 109, + "nodeType": "Block", + "src": "136:37:1", + "statements": [ + { + "condition": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_address", + "typeString": "address" }, - "children": [ - { - "attributes": { - "argumentTypes": null, - "commonType": { - "typeIdentifier": "t_address", - "typeString": "address" - }, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "operator": "==", - "type": "bool" - }, - "children": [ - { - "attributes": { - "argumentTypes": null, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "member_name": "sender", - "referencedDeclaration": null, - "type": "address" - }, - "children": [ - { - "attributes": { - "argumentTypes": null, - "overloadedDeclarations": [ - null - ], - "referencedDeclaration": 81, - "type": "msg", - "value": "msg" - }, - "id": 20, - "name": "Identifier", - "src": "146:3:1" - } - ], - "id": 21, - "name": "MemberAccess", - "src": "146:10:1" - }, - { - "attributes": { - "argumentTypes": null, - "overloadedDeclarations": [ - null - ], - "referencedDeclaration": 16, - "type": "address", - "value": "owner" - }, - "id": 22, - "name": "Identifier", - "src": "160:5:1" - } - ], - "id": 23, - "name": "BinaryOperation", - "src": "146:19:1" + "id": 106, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 103, + "name": "msg", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 167, + "src": "146:3:1", + "typeDescriptions": { + "typeIdentifier": "t_magic_message", + "typeString": "msg" + } }, - { - "id": 24, - "name": "PlaceholderStatement", - "src": "167:1:1" + "id": 104, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "sender", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "146:10:1", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" } - ], - "id": 25, - "name": "IfStatement", - "src": "142:26:1" + }, + "nodeType": "BinaryOperation", + "operator": "==", + "rightExpression": { + "argumentTypes": null, + "id": 105, + "name": "owner", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 99, + "src": "160:5:1", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "src": "146:19:1", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "falseBody": null, + "id": 108, + "nodeType": "IfStatement", + "src": "142:26:1", + "trueBody": { + "id": 107, + "nodeType": "PlaceholderStatement", + "src": "167:1:1" } - ], - "id": 26, - "name": "Block", - "src": "136:37:1" - } - ], - "id": 27, - "name": "ModifierDefinition", - "src": "114:59:1" + } + ] + }, + "documentation": null, + "id": 110, + "name": "restricted", + "nodeType": "ModifierDefinition", + "parameters": { + "id": 102, + "nodeType": "ParameterList", + "parameters": [], + "src": "133:2:1" + }, + "src": "114:59:1", + "visibility": "internal" }, { - "attributes": { - "constant": false, - "implemented": true, - "isConstructor": true, - "modifiers": [ - null - ], - "name": "Migrations", - "payable": false, - "scope": 69, - "stateMutability": "nonpayable", - "superFunction": null, - "visibility": "public" + "body": { + "id": 118, + "nodeType": "Block", + "src": "191:29:1", + "statements": [ + { + "expression": { + "argumentTypes": null, + "id": 116, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftHandSide": { + "argumentTypes": null, + "id": 113, + "name": "owner", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 99, + "src": "197:5:1", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "nodeType": "Assignment", + "operator": "=", + "rightHandSide": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 114, + "name": "msg", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 167, + "src": "205:3:1", + "typeDescriptions": { + "typeIdentifier": "t_magic_message", + "typeString": "msg" + } + }, + "id": 115, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "sender", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "205:10:1", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "src": "197:18:1", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "id": 117, + "nodeType": "ExpressionStatement", + "src": "197:18:1" + } + ] }, - "children": [ - { - "attributes": { - "parameters": [ - null - ] - }, - "children": [], - "id": 28, - "name": "ParameterList", - "src": "196:2:1" - }, - { - "attributes": { - "parameters": [ - null - ] - }, - "children": [], - "id": 29, - "name": "ParameterList", - "src": "199:0:1" - }, - { - "children": [ - { - "children": [ - { - "attributes": { - "argumentTypes": null, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "operator": "=", - "type": "address" - }, - "children": [ - { - "attributes": { - "argumentTypes": null, - "overloadedDeclarations": [ - null - ], - "referencedDeclaration": 16, - "type": "address", - "value": "owner" - }, - "id": 30, - "name": "Identifier", - "src": "205:5:1" - }, - { - "attributes": { - "argumentTypes": null, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "member_name": "sender", - "referencedDeclaration": null, - "type": "address" - }, - "children": [ - { - "attributes": { - "argumentTypes": null, - "overloadedDeclarations": [ - null - ], - "referencedDeclaration": 81, - "type": "msg", - "value": "msg" - }, - "id": 31, - "name": "Identifier", - "src": "213:3:1" - } - ], - "id": 32, - "name": "MemberAccess", - "src": "213:10:1" - } - ], - "id": 33, - "name": "Assignment", - "src": "205:18:1" + "documentation": null, + "id": 119, + "implemented": true, + "isConstructor": true, + "isDeclaredConst": false, + "modifiers": [], + "name": "", + "nodeType": "FunctionDefinition", + "parameters": { + "id": 111, + "nodeType": "ParameterList", + "parameters": [], + "src": "188:2:1" + }, + "payable": false, + "returnParameters": { + "id": 112, + "nodeType": "ParameterList", + "parameters": [], + "src": "191:0:1" + }, + "scope": 152, + "src": "177:43:1", + "stateMutability": "nonpayable", + "superFunction": null, + "visibility": "public" + }, + { + "body": { + "id": 130, + "nodeType": "Block", + "src": "273:47:1", + "statements": [ + { + "expression": { + "argumentTypes": null, + "id": 128, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftHandSide": { + "argumentTypes": null, + "id": 126, + "name": "last_completed_migration", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 101, + "src": "279:24:1", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" } - ], - "id": 34, - "name": "ExpressionStatement", - "src": "205:18:1" + }, + "nodeType": "Assignment", + "operator": "=", + "rightHandSide": { + "argumentTypes": null, + "id": 127, + "name": "completed", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 121, + "src": "306:9:1", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "src": "279:36:1", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "id": 129, + "nodeType": "ExpressionStatement", + "src": "279:36:1" + } + ] + }, + "documentation": null, + "id": 131, + "implemented": true, + "isConstructor": false, + "isDeclaredConst": false, + "modifiers": [ + { + "arguments": null, + "id": 124, + "modifierName": { + "argumentTypes": null, + "id": 123, + "name": "restricted", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 110, + "src": "262:10:1", + "typeDescriptions": { + "typeIdentifier": "t_modifier$__$", + "typeString": "modifier ()" } - ], - "id": 35, - "name": "Block", - "src": "199:29:1" + }, + "nodeType": "ModifierInvocation", + "src": "262:10:1" } ], - "id": 36, - "name": "FunctionDefinition", - "src": "177:51:1" + "name": "setCompleted", + "nodeType": "FunctionDefinition", + "parameters": { + "id": 122, + "nodeType": "ParameterList", + "parameters": [ + { + "constant": false, + "id": 121, + "name": "completed", + "nodeType": "VariableDeclaration", + "scope": 131, + "src": "246:14:1", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "typeName": { + "id": 120, + "name": "uint", + "nodeType": "ElementaryTypeName", + "src": "246:4:1", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "value": null, + "visibility": "internal" + } + ], + "src": "245:16:1" + }, + "payable": false, + "returnParameters": { + "id": 125, + "nodeType": "ParameterList", + "parameters": [], + "src": "273:0:1" + }, + "scope": 152, + "src": "224:96:1", + "stateMutability": "nonpayable", + "superFunction": null, + "visibility": "public" }, { - "attributes": { - "constant": false, - "implemented": true, - "isConstructor": false, - "name": "setCompleted", - "payable": false, - "scope": 69, - "stateMutability": "nonpayable", - "superFunction": null, - "visibility": "public" - }, - "children": [ - { - "children": [ - { - "attributes": { + "body": { + "id": 150, + "nodeType": "Block", + "src": "373:109:1", + "statements": [ + { + "assignments": [ + 139 + ], + "declarations": [ + { "constant": false, - "name": "completed", - "scope": 48, + "id": 139, + "name": "upgraded", + "nodeType": "VariableDeclaration", + "scope": 151, + "src": "379:19:1", "stateVariable": false, "storageLocation": "default", - "type": "uint256", + "typeDescriptions": { + "typeIdentifier": "t_contract$_Migrations_$152", + "typeString": "contract Migrations" + }, + "typeName": { + "contractScope": null, + "id": 138, + "name": "Migrations", + "nodeType": "UserDefinedTypeName", + "referencedDeclaration": 152, + "src": "379:10:1", + "typeDescriptions": { + "typeIdentifier": "t_contract$_Migrations_$152", + "typeString": "contract Migrations" + } + }, "value": null, "visibility": "internal" - }, - "children": [ + } + ], + "id": 143, + "initialValue": { + "argumentTypes": null, + "arguments": [ { - "attributes": { - "name": "uint", - "type": "uint256" - }, - "id": 37, - "name": "ElementaryTypeName", - "src": "254:4:1" + "argumentTypes": null, + "id": 141, + "name": "new_address", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 133, + "src": "412:11:1", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } } ], - "id": 38, - "name": "VariableDeclaration", - "src": "254:14:1" - } - ], - "id": 39, - "name": "ParameterList", - "src": "253:16:1" - }, - { - "attributes": { - "parameters": [ - null - ] - }, - "children": [], - "id": 42, - "name": "ParameterList", - "src": "281:0:1" - }, - { - "attributes": { - "arguments": [ - null - ] - }, - "children": [ - { - "attributes": { - "argumentTypes": null, - "overloadedDeclarations": [ - null + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_address", + "typeString": "address" + } ], - "referencedDeclaration": 27, - "type": "modifier ()", - "value": "restricted" + "id": 140, + "name": "Migrations", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 152, + "src": "401:10:1", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_contract$_Migrations_$152_$", + "typeString": "type(contract Migrations)" + } }, - "id": 40, - "name": "Identifier", - "src": "270:10:1" - } - ], - "id": 41, - "name": "ModifierInvocation", - "src": "270:10:1" - }, - { - "children": [ - { - "children": [ + "id": 142, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "typeConversion", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "401:23:1", + "typeDescriptions": { + "typeIdentifier": "t_contract$_Migrations_$152", + "typeString": "contract Migrations" + } + }, + "nodeType": "VariableDeclarationStatement", + "src": "379:45:1" + }, + { + "expression": { + "argumentTypes": null, + "arguments": [ { - "attributes": { - "argumentTypes": null, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "operator": "=", - "type": "uint256" - }, - "children": [ - { - "attributes": { - "argumentTypes": null, - "overloadedDeclarations": [ - null - ], - "referencedDeclaration": 18, - "type": "uint256", - "value": "last_completed_migration" - }, - "id": 43, - "name": "Identifier", - "src": "287:24:1" - }, - { - "attributes": { - "argumentTypes": null, - "overloadedDeclarations": [ - null - ], - "referencedDeclaration": 38, - "type": "uint256", - "value": "completed" - }, - "id": 44, - "name": "Identifier", - "src": "314:9:1" - } - ], - "id": 45, - "name": "Assignment", - "src": "287:36:1" + "argumentTypes": null, + "id": 147, + "name": "last_completed_migration", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 101, + "src": "452:24:1", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } } ], - "id": 46, - "name": "ExpressionStatement", - "src": "287:36:1" + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + ], + "expression": { + "argumentTypes": null, + "id": 144, + "name": "upgraded", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 139, + "src": "430:8:1", + "typeDescriptions": { + "typeIdentifier": "t_contract$_Migrations_$152", + "typeString": "contract Migrations" + } + }, + "id": 146, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "setCompleted", + "nodeType": "MemberAccess", + "referencedDeclaration": 131, + "src": "430:21:1", + "typeDescriptions": { + "typeIdentifier": "t_function_external_nonpayable$_t_uint256_$returns$__$", + "typeString": "function (uint256) external" + } + }, + "id": 148, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "430:47:1", + "typeDescriptions": { + "typeIdentifier": "t_tuple$__$", + "typeString": "tuple()" + } + }, + "id": 149, + "nodeType": "ExpressionStatement", + "src": "430:47:1" + } + ] + }, + "documentation": null, + "id": 151, + "implemented": true, + "isConstructor": false, + "isDeclaredConst": false, + "modifiers": [ + { + "arguments": null, + "id": 136, + "modifierName": { + "argumentTypes": null, + "id": 135, + "name": "restricted", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 110, + "src": "362:10:1", + "typeDescriptions": { + "typeIdentifier": "t_modifier$__$", + "typeString": "modifier ()" } - ], - "id": 47, - "name": "Block", - "src": "281:47:1" + }, + "nodeType": "ModifierInvocation", + "src": "362:10:1" } ], - "id": 48, - "name": "FunctionDefinition", - "src": "232:96:1" + "name": "upgrade", + "nodeType": "FunctionDefinition", + "parameters": { + "id": 134, + "nodeType": "ParameterList", + "parameters": [ + { + "constant": false, + "id": 133, + "name": "new_address", + "nodeType": "VariableDeclaration", + "scope": 151, + "src": "341:19:1", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + }, + "typeName": { + "id": 132, + "name": "address", + "nodeType": "ElementaryTypeName", + "src": "341:7:1", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "value": null, + "visibility": "internal" + } + ], + "src": "340:21:1" + }, + "payable": false, + "returnParameters": { + "id": 137, + "nodeType": "ParameterList", + "parameters": [], + "src": "373:0:1" + }, + "scope": 152, + "src": "324:158:1", + "stateMutability": "nonpayable", + "superFunction": null, + "visibility": "public" + } + ], + "scope": 153, + "src": "25:459:1" + } + ], + "src": "0:485:1" + }, + "legacyAST": { + "absolutePath": "/Users/adlymousa/Ethereum/election/contracts/Migrations.sol", + "exportedSymbols": { + "Migrations": [ + 152 + ] + }, + "id": 153, + "nodeType": "SourceUnit", + "nodes": [ + { + "id": 97, + "literals": [ + "solidity", + "^", + "0.4", + ".2" + ], + "nodeType": "PragmaDirective", + "src": "0:23:1" + }, + { + "baseContracts": [], + "contractDependencies": [], + "contractKind": "contract", + "documentation": null, + "fullyImplemented": true, + "id": 152, + "linearizedBaseContracts": [ + 152 + ], + "name": "Migrations", + "nodeType": "ContractDefinition", + "nodes": [ + { + "constant": false, + "id": 99, + "name": "owner", + "nodeType": "VariableDeclaration", + "scope": 152, + "src": "49:20:1", + "stateVariable": true, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + }, + "typeName": { + "id": 98, + "name": "address", + "nodeType": "ElementaryTypeName", + "src": "49:7:1", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "value": null, + "visibility": "public" + }, + { + "constant": false, + "id": 101, + "name": "last_completed_migration", + "nodeType": "VariableDeclaration", + "scope": 152, + "src": "73:36:1", + "stateVariable": true, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "typeName": { + "id": 100, + "name": "uint", + "nodeType": "ElementaryTypeName", + "src": "73:4:1", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "value": null, + "visibility": "public" + }, + { + "body": { + "id": 109, + "nodeType": "Block", + "src": "136:37:1", + "statements": [ + { + "condition": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_address", + "typeString": "address" + }, + "id": 106, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 103, + "name": "msg", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 167, + "src": "146:3:1", + "typeDescriptions": { + "typeIdentifier": "t_magic_message", + "typeString": "msg" + } + }, + "id": 104, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "sender", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "146:10:1", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "nodeType": "BinaryOperation", + "operator": "==", + "rightExpression": { + "argumentTypes": null, + "id": 105, + "name": "owner", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 99, + "src": "160:5:1", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "src": "146:19:1", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "falseBody": null, + "id": 108, + "nodeType": "IfStatement", + "src": "142:26:1", + "trueBody": { + "id": 107, + "nodeType": "PlaceholderStatement", + "src": "167:1:1" + } + } + ] + }, + "documentation": null, + "id": 110, + "name": "restricted", + "nodeType": "ModifierDefinition", + "parameters": { + "id": 102, + "nodeType": "ParameterList", + "parameters": [], + "src": "133:2:1" + }, + "src": "114:59:1", + "visibility": "internal" + }, + { + "body": { + "id": 118, + "nodeType": "Block", + "src": "191:29:1", + "statements": [ + { + "expression": { + "argumentTypes": null, + "id": 116, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftHandSide": { + "argumentTypes": null, + "id": 113, + "name": "owner", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 99, + "src": "197:5:1", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "nodeType": "Assignment", + "operator": "=", + "rightHandSide": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 114, + "name": "msg", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 167, + "src": "205:3:1", + "typeDescriptions": { + "typeIdentifier": "t_magic_message", + "typeString": "msg" + } + }, + "id": 115, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "sender", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "205:10:1", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "src": "197:18:1", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "id": 117, + "nodeType": "ExpressionStatement", + "src": "197:18:1" + } + ] + }, + "documentation": null, + "id": 119, + "implemented": true, + "isConstructor": true, + "isDeclaredConst": false, + "modifiers": [], + "name": "", + "nodeType": "FunctionDefinition", + "parameters": { + "id": 111, + "nodeType": "ParameterList", + "parameters": [], + "src": "188:2:1" + }, + "payable": false, + "returnParameters": { + "id": 112, + "nodeType": "ParameterList", + "parameters": [], + "src": "191:0:1" + }, + "scope": 152, + "src": "177:43:1", + "stateMutability": "nonpayable", + "superFunction": null, + "visibility": "public" }, { - "attributes": { - "constant": false, - "implemented": true, - "isConstructor": false, - "name": "upgrade", - "payable": false, - "scope": 69, - "stateMutability": "nonpayable", - "superFunction": null, - "visibility": "public" + "body": { + "id": 130, + "nodeType": "Block", + "src": "273:47:1", + "statements": [ + { + "expression": { + "argumentTypes": null, + "id": 128, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftHandSide": { + "argumentTypes": null, + "id": 126, + "name": "last_completed_migration", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 101, + "src": "279:24:1", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "Assignment", + "operator": "=", + "rightHandSide": { + "argumentTypes": null, + "id": 127, + "name": "completed", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 121, + "src": "306:9:1", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "src": "279:36:1", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "id": 129, + "nodeType": "ExpressionStatement", + "src": "279:36:1" + } + ] }, - "children": [ + "documentation": null, + "id": 131, + "implemented": true, + "isConstructor": false, + "isDeclaredConst": false, + "modifiers": [ { - "children": [ - { - "attributes": { + "arguments": null, + "id": 124, + "modifierName": { + "argumentTypes": null, + "id": 123, + "name": "restricted", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 110, + "src": "262:10:1", + "typeDescriptions": { + "typeIdentifier": "t_modifier$__$", + "typeString": "modifier ()" + } + }, + "nodeType": "ModifierInvocation", + "src": "262:10:1" + } + ], + "name": "setCompleted", + "nodeType": "FunctionDefinition", + "parameters": { + "id": 122, + "nodeType": "ParameterList", + "parameters": [ + { + "constant": false, + "id": 121, + "name": "completed", + "nodeType": "VariableDeclaration", + "scope": 131, + "src": "246:14:1", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "typeName": { + "id": 120, + "name": "uint", + "nodeType": "ElementaryTypeName", + "src": "246:4:1", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "value": null, + "visibility": "internal" + } + ], + "src": "245:16:1" + }, + "payable": false, + "returnParameters": { + "id": 125, + "nodeType": "ParameterList", + "parameters": [], + "src": "273:0:1" + }, + "scope": 152, + "src": "224:96:1", + "stateMutability": "nonpayable", + "superFunction": null, + "visibility": "public" + }, + { + "body": { + "id": 150, + "nodeType": "Block", + "src": "373:109:1", + "statements": [ + { + "assignments": [ + 139 + ], + "declarations": [ + { "constant": false, - "name": "new_address", - "scope": 68, + "id": 139, + "name": "upgraded", + "nodeType": "VariableDeclaration", + "scope": 151, + "src": "379:19:1", "stateVariable": false, "storageLocation": "default", - "type": "address", + "typeDescriptions": { + "typeIdentifier": "t_contract$_Migrations_$152", + "typeString": "contract Migrations" + }, + "typeName": { + "contractScope": null, + "id": 138, + "name": "Migrations", + "nodeType": "UserDefinedTypeName", + "referencedDeclaration": 152, + "src": "379:10:1", + "typeDescriptions": { + "typeIdentifier": "t_contract$_Migrations_$152", + "typeString": "contract Migrations" + } + }, "value": null, "visibility": "internal" - }, - "children": [ + } + ], + "id": 143, + "initialValue": { + "argumentTypes": null, + "arguments": [ { - "attributes": { - "name": "address", - "type": "address" - }, - "id": 49, - "name": "ElementaryTypeName", - "src": "349:7:1" + "argumentTypes": null, + "id": 141, + "name": "new_address", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 133, + "src": "412:11:1", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } } ], - "id": 50, - "name": "VariableDeclaration", - "src": "349:19:1" - } - ], - "id": 51, - "name": "ParameterList", - "src": "348:21:1" - }, - { - "attributes": { - "parameters": [ - null - ] - }, - "children": [], - "id": 54, - "name": "ParameterList", - "src": "381:0:1" - }, - { - "attributes": { - "arguments": [ - null - ] - }, - "children": [ - { - "attributes": { - "argumentTypes": null, - "overloadedDeclarations": [ - null + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_address", + "typeString": "address" + } ], - "referencedDeclaration": 27, - "type": "modifier ()", - "value": "restricted" - }, - "id": 52, - "name": "Identifier", - "src": "370:10:1" - } - ], - "id": 53, - "name": "ModifierInvocation", - "src": "370:10:1" - }, - { - "children": [ - { - "attributes": { - "assignments": [ - 56 - ] - }, - "children": [ - { - "attributes": { - "constant": false, - "name": "upgraded", - "scope": 68, - "stateVariable": false, - "storageLocation": "default", - "type": "contract Migrations", - "value": null, - "visibility": "internal" - }, - "children": [ - { - "attributes": { - "contractScope": null, - "name": "Migrations", - "referencedDeclaration": 69, - "type": "contract Migrations" - }, - "id": 55, - "name": "UserDefinedTypeName", - "src": "387:10:1" - } - ], - "id": 56, - "name": "VariableDeclaration", - "src": "387:19:1" - }, - { - "attributes": { - "argumentTypes": null, - "isConstant": false, - "isLValue": false, - "isPure": false, - "isStructConstructorCall": false, - "lValueRequested": false, - "names": [ - null - ], - "type": "contract Migrations", - "type_conversion": true - }, - "children": [ - { - "attributes": { - "argumentTypes": [ - { - "typeIdentifier": "t_address", - "typeString": "address" - } - ], - "overloadedDeclarations": [ - null - ], - "referencedDeclaration": 69, - "type": "type(contract Migrations)", - "value": "Migrations" - }, - "id": 57, - "name": "Identifier", - "src": "409:10:1" - }, - { - "attributes": { - "argumentTypes": null, - "overloadedDeclarations": [ - null - ], - "referencedDeclaration": 50, - "type": "address", - "value": "new_address" - }, - "id": 58, - "name": "Identifier", - "src": "420:11:1" - } - ], - "id": 59, - "name": "FunctionCall", - "src": "409:23:1" + "id": 140, + "name": "Migrations", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 152, + "src": "401:10:1", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_contract$_Migrations_$152_$", + "typeString": "type(contract Migrations)" } - ], - "id": 60, - "name": "VariableDeclarationStatement", - "src": "387:45:1" + }, + "id": 142, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "typeConversion", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "401:23:1", + "typeDescriptions": { + "typeIdentifier": "t_contract$_Migrations_$152", + "typeString": "contract Migrations" + } }, - { - "children": [ + "nodeType": "VariableDeclarationStatement", + "src": "379:45:1" + }, + { + "expression": { + "argumentTypes": null, + "arguments": [ { - "attributes": { - "argumentTypes": null, - "isConstant": false, - "isLValue": false, - "isPure": false, - "isStructConstructorCall": false, - "lValueRequested": false, - "names": [ - null - ], - "type": "tuple()", - "type_conversion": false - }, - "children": [ - { - "attributes": { - "argumentTypes": [ - { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - ], - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "member_name": "setCompleted", - "referencedDeclaration": 48, - "type": "function (uint256) external" - }, - "children": [ - { - "attributes": { - "argumentTypes": null, - "overloadedDeclarations": [ - null - ], - "referencedDeclaration": 56, - "type": "contract Migrations", - "value": "upgraded" - }, - "id": 61, - "name": "Identifier", - "src": "438:8:1" - } - ], - "id": 63, - "name": "MemberAccess", - "src": "438:21:1" - }, - { - "attributes": { - "argumentTypes": null, - "overloadedDeclarations": [ - null - ], - "referencedDeclaration": 18, - "type": "uint256", - "value": "last_completed_migration" - }, - "id": 64, - "name": "Identifier", - "src": "460:24:1" - } - ], - "id": 65, - "name": "FunctionCall", - "src": "438:47:1" + "argumentTypes": null, + "id": 147, + "name": "last_completed_migration", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 101, + "src": "452:24:1", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } } ], - "id": 66, - "name": "ExpressionStatement", - "src": "438:47:1" + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + ], + "expression": { + "argumentTypes": null, + "id": 144, + "name": "upgraded", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 139, + "src": "430:8:1", + "typeDescriptions": { + "typeIdentifier": "t_contract$_Migrations_$152", + "typeString": "contract Migrations" + } + }, + "id": 146, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "setCompleted", + "nodeType": "MemberAccess", + "referencedDeclaration": 131, + "src": "430:21:1", + "typeDescriptions": { + "typeIdentifier": "t_function_external_nonpayable$_t_uint256_$returns$__$", + "typeString": "function (uint256) external" + } + }, + "id": 148, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "430:47:1", + "typeDescriptions": { + "typeIdentifier": "t_tuple$__$", + "typeString": "tuple()" + } + }, + "id": 149, + "nodeType": "ExpressionStatement", + "src": "430:47:1" + } + ] + }, + "documentation": null, + "id": 151, + "implemented": true, + "isConstructor": false, + "isDeclaredConst": false, + "modifiers": [ + { + "arguments": null, + "id": 136, + "modifierName": { + "argumentTypes": null, + "id": 135, + "name": "restricted", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 110, + "src": "362:10:1", + "typeDescriptions": { + "typeIdentifier": "t_modifier$__$", + "typeString": "modifier ()" } - ], - "id": 67, - "name": "Block", - "src": "381:109:1" + }, + "nodeType": "ModifierInvocation", + "src": "362:10:1" } ], - "id": 68, - "name": "FunctionDefinition", - "src": "332:158:1" + "name": "upgrade", + "nodeType": "FunctionDefinition", + "parameters": { + "id": 134, + "nodeType": "ParameterList", + "parameters": [ + { + "constant": false, + "id": 133, + "name": "new_address", + "nodeType": "VariableDeclaration", + "scope": 151, + "src": "341:19:1", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + }, + "typeName": { + "id": 132, + "name": "address", + "nodeType": "ElementaryTypeName", + "src": "341:7:1", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "value": null, + "visibility": "internal" + } + ], + "src": "340:21:1" + }, + "payable": false, + "returnParameters": { + "id": 137, + "nodeType": "ParameterList", + "parameters": [], + "src": "373:0:1" + }, + "scope": 152, + "src": "324:158:1", + "stateMutability": "nonpayable", + "superFunction": null, + "visibility": "public" } ], - "id": 69, - "name": "ContractDefinition", - "src": "25:467:1" + "scope": 153, + "src": "25:459:1" } ], - "id": 70, - "name": "SourceUnit", - "src": "0:493:1" + "src": "0:485:1" }, "compiler": { "name": "solc", - "version": "0.4.18+commit.9cf6e910.Emscripten.clang" + "version": "0.4.24+commit.e67f0147.Emscripten.clang" }, "networks": { "5777": { "events": {}, "links": {}, - "address": "0x9fbda871d559710256a2502a2517b794b482db40" + "address": "0x2dce1d7ce2a5a2e439d54db65d7c64bcd08757e4", + "transactionHash": "0xb16754b5f65c9b962de4914747f054fc0ebd58d55f841d22f36a9fbe375fe5a2" } }, - "schemaVersion": "1.0.1", - "updatedAt": "2018-05-18T14:43:46.964Z" + "schemaVersion": "2.0.1", + "updatedAt": "2018-08-10T01:55:57.788Z" } \ No newline at end of file diff --git a/contracts/Election.sol b/contracts/Election.sol index a71a8276..1a36730f 100644 --- a/contracts/Election.sol +++ b/contracts/Election.sol @@ -1,4 +1,4 @@ -pragma solidity 0.4.20; +pragma solidity 0.4.24; contract Election { // Model a Candidate @@ -21,7 +21,7 @@ contract Election { uint indexed _candidateId ); - function Election () public { + constructor () public { addCandidate("Candidate 1"); addCandidate("Candidate 2"); } @@ -45,6 +45,6 @@ contract Election { candidates[_candidateId].voteCount ++; // trigger voted event - votedEvent(_candidateId); + emit votedEvent(_candidateId); } } diff --git a/contracts/Migrations.sol b/contracts/Migrations.sol index 8d6e9506..474afecc 100644 --- a/contracts/Migrations.sol +++ b/contracts/Migrations.sol @@ -8,7 +8,7 @@ contract Migrations { if (msg.sender == owner) _; } - function Migrations() { + constructor() { owner = msg.sender; }