From 115ab1b71a80aa93db588881b5edf9af5a8201c7 Mon Sep 17 00:00:00 2001 From: Jonathan Schwartz Date: Thu, 18 Jan 2018 14:07:33 -0500 Subject: [PATCH 1/2] somehow got the fetch user function working? --- build/contracts/CapCoin.json | 2294 ++++++++-------------------- build/contracts/Migrations.json | 4 +- build/contracts/SimpleStorage.json | 2 +- contracts/CapCoin.sol | 5 + src/App.js | 10 +- src/store/user.js | 5 +- 6 files changed, 619 insertions(+), 1701 deletions(-) diff --git a/build/contracts/CapCoin.json b/build/contracts/CapCoin.json index 0d772464..4d22846a 100644 --- a/build/contracts/CapCoin.json +++ b/build/contracts/CapCoin.json @@ -3,21 +3,12 @@ "abi": [ { "constant": true, - "inputs": [ - { - "name": "", - "type": "uint256" - } - ], + "inputs": [], "name": "getUsers", "outputs": [ { "name": "", "type": "address[]" - }, - { - "name": "coinBalance", - "type": "uint256" } ], "payable": false, @@ -36,21 +27,7 @@ "outputs": [ { "name": "", - "type": "address", - "components": [ - { - "name": "name", - "type": "string" - }, - { - "name": "coinBalance", - "type": "uint256" - } - ] - }, - { - "name": "coinBalance", - "type": "uint256" + "type": "address" } ], "payable": false, @@ -66,43 +43,15 @@ } ], "name": "createUser", - "outputs": [ - { - "components": [ - { - "name": "name", - "type": "string" - }, - { - "name": "coinBalance", - "type": "uint256" - } - ], - "name": "", - "type": "tuple" - } - ], + "outputs": [], "payable": false, "stateMutability": "nonpayable", "type": "function" }, { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "name": "", - "type": "address" - }, - { - "indexed": false, - "name": "name", - "type": "string" - } - ], - "name": "getUser", - "type": "function", "constant": true, + "inputs": [], + "name": "getUser", "outputs": [ { "name": "", @@ -114,35 +63,18 @@ } ], "payable": false, - "stateMutability": "view" + "stateMutability": "view", + "type": "function" }, { - "anonymous": false, + "constant": true, "inputs": [ { - "components": [ - { - "name": "name", - "type": "string" - }, - { - "name": "coinBalance", - "type": "uint256" - } - ], - "indexed": false, "name": "", "type": "address" - }, - { - "indexed": false, - "name": "name", - "type": "string" } ], "name": "addressToUser", - "type": "function", - "constant": true, "outputs": [ { "name": "name", @@ -154,7 +86,14 @@ } ], "payable": false, - "stateMutability": "view" + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "constructor" }, { "anonymous": false, @@ -169,18 +108,18 @@ "type": "event" } ], - "bytecode": "0x6060604052620f42406000556000600155341561001b57600080fd5b6107c08061002a6000396000f30060606040526004361061006c576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff168062ce8e3e14610071578063365b98b2146100db578063507ffba51461013e578063832880e71461019b578063edf5388614610230575b600080fd5b341561007c57600080fd5b610084610306565b6040518080602001828103825283818151815260200191508051906020019060200280838360005b838110156100c75780820151818401526020810190506100ac565b505050509050019250505060405180910390f35b34156100e657600080fd5b6100fc600480803590602001909190505061039a565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b341561014957600080fd5b610199600480803590602001908201803590602001908080601f016020809104026020016040519081016040528093929190818152602001838380828437820191505050505050919050506103d9565b005b34156101a657600080fd5b6101ae610545565b6040518080602001838152602001828103825284818151815260200191508051906020019080838360005b838110156101f45780820151818401526020810190506101d9565b50505050905090810190601f1680156102215780820380516001836020036101000a031916815260200191505b50935050505060405180910390f35b341561023b57600080fd5b610267600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610678565b60405180806020018381526020018281038252848181546001816001161561010002031660029004815260200191508054600181600116156101000203166002900480156102f65780601f106102cb576101008083540402835291602001916102f6565b820191906000526020600020905b8154815290600101906020018083116102d957829003601f168201915b5050935050505060405180910390f35b61030e61069b565b600380548060200260200160405190810160405280929190818152602001828054801561039057602002820191906000526020600020905b8160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019060010190808311610346575b5050505050905090565b6003818154811015156103a957fe5b90600052602060002090016000915054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000209050818160000190805190602001906104349291906106af565b5060008160010181905550600160038054806001018281610455919061072f565b9160005260206000209001600033909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050507f66ab3fea2083d9ba15d99b595186fe7fc18e6eba393c0fc056f420e96c3caa44826040518080602001828103825283818151815260200191508051906020019080838360005b838110156105075780820151818401526020810190506104ec565b50505050905090810190601f1680156105345780820380516001836020036101000a031916815260200191505b509250505060405180910390a15050565b61054d61075b565b6000600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600001600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060010154818054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156106695780601f1061063e57610100808354040283529160200191610669565b820191906000526020600020905b81548152906001019060200180831161064c57829003601f168201915b50505050509150915091509091565b600260205280600052604060002060009150905080600001908060010154905082565b602060405190810160405280600081525090565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106106f057805160ff191683800117855561071e565b8280016001018555821561071e579182015b8281111561071d578251825591602001919060010190610702565b5b50905061072b919061076f565b5090565b81548183558181151161075657818360005260206000209182019101610755919061076f565b5b505050565b602060405190810160405280600081525090565b61079191905b8082111561078d576000816000905550600101610775565b5090565b905600a165627a7a72305820347fd3f10962f3e4ed5f1a071efe90ebb62728369e18ffe5dbdfb04c3479ff2c0029", - "deployedBytecode": "0x60606040526004361061006c576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff168062ce8e3e14610071578063365b98b2146100db578063507ffba51461013e578063832880e71461019b578063edf5388614610230575b600080fd5b341561007c57600080fd5b610084610306565b6040518080602001828103825283818151815260200191508051906020019060200280838360005b838110156100c75780820151818401526020810190506100ac565b505050509050019250505060405180910390f35b34156100e657600080fd5b6100fc600480803590602001909190505061039a565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b341561014957600080fd5b610199600480803590602001908201803590602001908080601f016020809104026020016040519081016040528093929190818152602001838380828437820191505050505050919050506103d9565b005b34156101a657600080fd5b6101ae610545565b6040518080602001838152602001828103825284818151815260200191508051906020019080838360005b838110156101f45780820151818401526020810190506101d9565b50505050905090810190601f1680156102215780820380516001836020036101000a031916815260200191505b50935050505060405180910390f35b341561023b57600080fd5b610267600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610678565b60405180806020018381526020018281038252848181546001816001161561010002031660029004815260200191508054600181600116156101000203166002900480156102f65780601f106102cb576101008083540402835291602001916102f6565b820191906000526020600020905b8154815290600101906020018083116102d957829003601f168201915b5050935050505060405180910390f35b61030e61069b565b600380548060200260200160405190810160405280929190818152602001828054801561039057602002820191906000526020600020905b8160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019060010190808311610346575b5050505050905090565b6003818154811015156103a957fe5b90600052602060002090016000915054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000209050818160000190805190602001906104349291906106af565b5060008160010181905550600160038054806001018281610455919061072f565b9160005260206000209001600033909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050507f66ab3fea2083d9ba15d99b595186fe7fc18e6eba393c0fc056f420e96c3caa44826040518080602001828103825283818151815260200191508051906020019080838360005b838110156105075780820151818401526020810190506104ec565b50505050905090810190601f1680156105345780820380516001836020036101000a031916815260200191505b509250505060405180910390a15050565b61054d61075b565b6000600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600001600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060010154818054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156106695780601f1061063e57610100808354040283529160200191610669565b820191906000526020600020905b81548152906001019060200180831161064c57829003601f168201915b50505050509150915091509091565b600260205280600052604060002060009150905080600001908060010154905082565b602060405190810160405280600081525090565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106106f057805160ff191683800117855561071e565b8280016001018555821561071e579182015b8281111561071d578251825591602001919060010190610702565b5b50905061072b919061076f565b5090565b81548183558181151161075657818360005260206000209182019101610755919061076f565b5b505050565b602060405190810160405280600081525090565b61079191905b8082111561078d576000816000905550600101610775565b5090565b905600a165627a7a72305820347fd3f10962f3e4ed5f1a071efe90ebb62728369e18ffe5dbdfb04c3479ff2c0029", - "sourceMap": "26:659:0:-;;;97:7;79:25;;127:1;108:20;;26:659;;;;;;;;;;;;;;", - "deployedSourceMap": "26:659:0:-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;461:75;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;23:1:-1;8:100;33:3;30:1;27:2;8:100;;;99:1;94:3;90;84:5;80:1;75:3;71;64:6;52:2;49:1;45:3;40:15;;8:100;;;12:14;3:109;;;;;;;;;;;;;;;;;243:22:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;270:187;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;540:143;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;23:1:-1;8:100;33:3;30:1;27:2;8:100;;;99:1;94:3;90;84:5;80:1;75:3;71;64:6;52:2;49:1;45:3;40:15;;8:100;;;12:14;3:109;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;193:46:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;461:75;502:9;;:::i;:::-;526:5;519:12;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;461:75;:::o;243:22::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::o;270:187::-;316:8;327:13;:25;341:10;327:25;;;;;;;;;;;;;;;316:36;;371:4;359;:9;;:16;;;;;;;;;;;;:::i;:::-;;400:1;381:4;:16;;:20;;;;432:1;408:5;:22;;;;;;;;;;;:::i;:::-;;;;;;;;;;419:10;408:22;;;;;;;;;;;;;;;;;;;;;;:25;;439:13;447:4;439:13;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;23:1:-1;8:100;33:3;30:1;27:2;8:100;;;99:1;94:3;90;84:5;80:1;75:3;71;64:6;52:2;49:1;45:3;40:15;;8:100;;;12:14;3:109;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;270:187:0;;:::o;540:143::-;580:6;;:::i;:::-;588:4;608:13;:25;622:10;608:25;;;;;;;;;;;;;;;:30;;640:13;:25;654:10;640:25;;;;;;;;;;;;;;;:37;;;600:78;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;540:143;;:::o;193:46::-;;;;;;;;;;;;;;;;;;;;;;;;;;:::o;26:659::-;;;;;;;;;;;;;;;:::o;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;;:::o;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;;;;:::o;:::-;;;;;;;;;;;;;;;:::o;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;:::o", - "source": "pragma solidity ^0.4.18;\n\ncontract CapCoin {\n\n event NewUser(string name);\n\n uint coinSupply = 1000000;\n uint coinsBought = 0;\n\n struct User {\n string name;\n uint coinBalance;\n }\n\n mapping (address => User) public addressToUser;\n address[] public users;\n\n function createUser(string name) public {\n var user = addressToUser[msg.sender];\n\n user.name = name;\n user.coinBalance = 0;\n\n users.push(msg.sender) -1;\n NewUser(name);\n }\n\n function getUsers() public view returns (address[]) {\n return users;\n }\n\n function getUser() public view returns (string, uint) {\n return (addressToUser[msg.sender].name, addressToUser[msg.sender].coinBalance);\n }\n}\n", + "bytecode": "0x6060604052620f42406000556000600155341561001b57600080fd5b60016002819055506107c0806100326000396000f30060606040526004361061006c576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff168062ce8e3e14610071578063365b98b2146100db578063507ffba51461013e578063832880e71461019b578063edf5388614610230575b600080fd5b341561007c57600080fd5b610084610306565b6040518080602001828103825283818151815260200191508051906020019060200280838360005b838110156100c75780820151818401526020810190506100ac565b505050509050019250505060405180910390f35b34156100e657600080fd5b6100fc600480803590602001909190505061039a565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b341561014957600080fd5b610199600480803590602001908201803590602001908080601f016020809104026020016040519081016040528093929190818152602001838380828437820191505050505050919050506103d9565b005b34156101a657600080fd5b6101ae610545565b6040518080602001838152602001828103825284818151815260200191508051906020019080838360005b838110156101f45780820151818401526020810190506101d9565b50505050905090810190601f1680156102215780820380516001836020036101000a031916815260200191505b50935050505060405180910390f35b341561023b57600080fd5b610267600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610678565b60405180806020018381526020018281038252848181546001816001161561010002031660029004815260200191508054600181600116156101000203166002900480156102f65780601f106102cb576101008083540402835291602001916102f6565b820191906000526020600020905b8154815290600101906020018083116102d957829003601f168201915b5050935050505060405180910390f35b61030e61069b565b600480548060200260200160405190810160405280929190818152602001828054801561039057602002820191906000526020600020905b8160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019060010190808311610346575b5050505050905090565b6004818154811015156103a957fe5b90600052602060002090016000915054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000209050818160000190805190602001906104349291906106af565b5060008160010181905550600160048054806001018281610455919061072f565b9160005260206000209001600033909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050507f66ab3fea2083d9ba15d99b595186fe7fc18e6eba393c0fc056f420e96c3caa44826040518080602001828103825283818151815260200191508051906020019080838360005b838110156105075780820151818401526020810190506104ec565b50505050905090810190601f1680156105345780820380516001836020036101000a031916815260200191505b509250505060405180910390a15050565b61054d61075b565b6000600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600001600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060010154818054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156106695780601f1061063e57610100808354040283529160200191610669565b820191906000526020600020905b81548152906001019060200180831161064c57829003601f168201915b50505050509150915091509091565b600360205280600052604060002060009150905080600001908060010154905082565b602060405190810160405280600081525090565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106106f057805160ff191683800117855561071e565b8280016001018555821561071e579182015b8281111561071d578251825591602001919060010190610702565b5b50905061072b919061076f565b5090565b81548183558181151161075657818360005260206000209182019101610755919061076f565b5b505050565b602060405190810160405280600081525090565b61079191905b8082111561078d576000816000905550600101610775565b5090565b905600a165627a7a72305820750e2e996e715d109a9dcaca5bd495e8a5b79862d30471d45c4bc9a1d504383a0029", + "deployedBytecode": "0x60606040526004361061006c576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff168062ce8e3e14610071578063365b98b2146100db578063507ffba51461013e578063832880e71461019b578063edf5388614610230575b600080fd5b341561007c57600080fd5b610084610306565b6040518080602001828103825283818151815260200191508051906020019060200280838360005b838110156100c75780820151818401526020810190506100ac565b505050509050019250505060405180910390f35b34156100e657600080fd5b6100fc600480803590602001909190505061039a565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b341561014957600080fd5b610199600480803590602001908201803590602001908080601f016020809104026020016040519081016040528093929190818152602001838380828437820191505050505050919050506103d9565b005b34156101a657600080fd5b6101ae610545565b6040518080602001838152602001828103825284818151815260200191508051906020019080838360005b838110156101f45780820151818401526020810190506101d9565b50505050905090810190601f1680156102215780820380516001836020036101000a031916815260200191505b50935050505060405180910390f35b341561023b57600080fd5b610267600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610678565b60405180806020018381526020018281038252848181546001816001161561010002031660029004815260200191508054600181600116156101000203166002900480156102f65780601f106102cb576101008083540402835291602001916102f6565b820191906000526020600020905b8154815290600101906020018083116102d957829003601f168201915b5050935050505060405180910390f35b61030e61069b565b600480548060200260200160405190810160405280929190818152602001828054801561039057602002820191906000526020600020905b8160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019060010190808311610346575b5050505050905090565b6004818154811015156103a957fe5b90600052602060002090016000915054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000209050818160000190805190602001906104349291906106af565b5060008160010181905550600160048054806001018281610455919061072f565b9160005260206000209001600033909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050507f66ab3fea2083d9ba15d99b595186fe7fc18e6eba393c0fc056f420e96c3caa44826040518080602001828103825283818151815260200191508051906020019080838360005b838110156105075780820151818401526020810190506104ec565b50505050905090810190601f1680156105345780820380516001836020036101000a031916815260200191505b509250505060405180910390a15050565b61054d61075b565b6000600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600001600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060010154818054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156106695780601f1061063e57610100808354040283529160200191610669565b820191906000526020600020905b81548152906001019060200180831161064c57829003601f168201915b50505050509150915091509091565b600360205280600052604060002060009150905080600001908060010154905082565b602060405190810160405280600081525090565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106106f057805160ff191683800117855561071e565b8280016001018555821561071e579182015b8281111561071d578251825591602001919060010190610702565b5b50905061072b919061076f565b5090565b81548183558181151161075657818360005260206000209182019101610755919061076f565b5b505050565b602060405190810160405280600081525090565b61079191905b8082111561078d576000816000905550600101610775565b5090565b905600a165627a7a72305820750e2e996e715d109a9dcaca5bd495e8a5b79862d30471d45c4bc9a1d504383a0029", + "sourceMap": "26:729:0:-;;;97:7;79:25;;127:1;108:20;;153:46;;;;;;;;193:1;179:11;:15;;;;26:729;;;;;;", + "deployedSourceMap": "26:729:0:-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;531:75;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;23:1:-1;8:100;33:3;30:1;27:2;8:100;;;99:1;94:3;90;84:5;80:1;75:3;71;64:6;52:2;49:1;45:3;40:15;;8:100;;;12:14;3:109;;;;;;;;;;;;;;;;;313:22:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;340:187;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;610:143;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;23:1:-1;8:100;33:3;30:1;27:2;8:100;;;99:1;94:3;90;84:5;80:1;75:3;71;64:6;52:2;49:1;45:3;40:15;;8:100;;;12:14;3:109;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;263:46:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;531:75;572:9;;:::i;:::-;596:5;589:12;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;531:75;:::o;313:22::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::o;340:187::-;386:8;397:13;:25;411:10;397:25;;;;;;;;;;;;;;;386:36;;441:4;429;:9;;:16;;;;;;;;;;;;:::i;:::-;;470:1;451:4;:16;;:20;;;;502:1;478:5;:22;;;;;;;;;;;:::i;:::-;;;;;;;;;;489:10;478:22;;;;;;;;;;;;;;;;;;;;;;:25;;509:13;517:4;509:13;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;23:1:-1;8:100;33:3;30:1;27:2;8:100;;;99:1;94:3;90;84:5;80:1;75:3;71;64:6;52:2;49:1;45:3;40:15;;8:100;;;12:14;3:109;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;340:187:0;;:::o;610:143::-;650:6;;:::i;:::-;658:4;678:13;:25;692:10;678:25;;;;;;;;;;;;;;;:30;;710:13;:25;724:10;710:25;;;;;;;;;;;;;;;:37;;;670:78;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;610:143;;:::o;263:46::-;;;;;;;;;;;;;;;;;;;;;;;;;;:::o;26:729::-;;;;;;;;;;;;;;;:::o;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;;:::o;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;;;;:::o;:::-;;;;;;;;;;;;;;;:::o;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;:::o", + "source": "pragma solidity ^0.4.18;\n\ncontract CapCoin {\n\n event NewUser(string name);\n\n uint coinSupply = 1000000;\n uint coinsBought = 0;\n uint contractNum;\n\n function CapCoin () {\n contractNum = 1;\n }\n\n struct User {\n string name;\n uint coinBalance;\n }\n\n mapping (address => User) public addressToUser;\n address[] public users;\n\n function createUser(string name) public {\n var user = addressToUser[msg.sender];\n\n user.name = name;\n user.coinBalance = 0;\n\n users.push(msg.sender) -1;\n NewUser(name);\n }\n\n function getUsers() public view returns (address[]) {\n return users;\n }\n\n function getUser() public view returns (string, uint) {\n return (addressToUser[msg.sender].name, addressToUser[msg.sender].coinBalance);\n }\n}\n", "sourcePath": "/Users/schwartzz8990/Dropbox/fullstack/capCoin/contracts/CapCoin.sol", "ast": { "attributes": { "absolutePath": "/Users/schwartzz8990/Dropbox/fullstack/capCoin/contracts/CapCoin.sol", "exportedSymbols": { "CapCoin": [ - 90 + 100 ] } }, @@ -210,32 +149,19 @@ "documentation": null, "fullyImplemented": true, "linearizedBaseContracts": [ - 90 + 100 ], "name": "CapCoin", - "scope": 91 + "scope": 101 }, "children": [ { "attributes": { - "constant": false, - "name": "NewUser", - "scope": 43, - "stateVariable": true, - "storageLocation": "default", - "type": "uint256", - "visibility": "internal", - "anonymous": false + "anonymous": false, + "name": "NewUser" }, "children": [ { - "attributes": { - "name": "uint", - "type": "uint256" - }, - "id": 4, - "name": "ParameterList", - "src": "61:13:0", "children": [ { "attributes": { @@ -253,9 +179,7 @@ { "attributes": { "name": "string", - "type": "string storage pointer", - "contractScope": null, - "referencedDeclaration": 16 + "type": "string storage pointer" }, "id": 2, "name": "ElementaryTypeName", @@ -265,52 +189,11 @@ "id": 3, "name": "VariableDeclaration", "src": "62:11:0" - }, - { - "attributes": { - "constant": false, - "indexed": false, - "name": "name", - "scope": 7, - "stateVariable": false, - "storageLocation": "default", - "type": "string memory", - "value": null, - "visibility": "internal" - }, - "children": [ - { - "attributes": { - "name": "string", - "type": "string storage pointer" - }, - "id": 4, - "name": "ElementaryTypeName", - "src": "71:6:0" - } - ], - "id": 5, - "name": "VariableDeclaration", - "src": "71:11:0" } - ] - }, - { - "attributes": { - "argumentTypes": null, - "hexvalue": "31303030303030", - "isConstant": false, - "isLValue": false, - "isPure": true, - "lValueRequested": false, - "subdenomination": null, - "token": "number", - "type": "int_const 1000000", - "value": "1000000" - }, - "id": 3, - "name": "Literal", - "src": "65:7:0" + ], + "id": 4, + "name": "ParameterList", + "src": "61:13:0" } ], "id": 5, @@ -321,7 +204,7 @@ "attributes": { "constant": false, "name": "coinSupply", - "scope": 90, + "scope": 100, "stateVariable": true, "storageLocation": "default", "type": "uint256", @@ -361,52 +244,26 @@ }, { "attributes": { - "canonicalName": "CapCoin.User", - "name": "coinsBought", - "scope": 90, - "visibility": "internal", "constant": false, + "name": "coinsBought", + "scope": 100, "stateVariable": true, "storageLocation": "default", - "type": "uint256" + "type": "uint256", + "visibility": "internal" }, "children": [ { "attributes": { - "constant": false, "name": "uint", - "scope": 12, - "stateVariable": false, - "storageLocation": "default", - "type": "uint256", - "value": null, - "visibility": "internal" + "type": "uint256" }, - "children": [ - { - "attributes": { - "name": "string", - "type": "string storage pointer" - }, - "id": 8, - "name": "ElementaryTypeName", - "src": "177:6:0" - } - ], "id": 9, "name": "ElementaryTypeName", "src": "108:4:0" }, { "attributes": { - "constant": false, - "name": "coinBalance", - "scope": 12, - "stateVariable": false, - "storageLocation": "default", - "type": "int_const 0", - "value": "0", - "visibility": "internal", "argumentTypes": null, "hexvalue": "30", "isConstant": false, @@ -414,19 +271,10 @@ "isPure": true, "lValueRequested": false, "subdenomination": null, - "token": "number" + "token": "number", + "type": "int_const 0", + "value": "0" }, - "children": [ - { - "attributes": { - "name": "uint", - "type": "uint256" - }, - "id": 10, - "name": "ElementaryTypeName", - "src": "194:4:0" - } - ], "id": 10, "name": "Literal", "src": "127:1:0" @@ -439,50 +287,172 @@ { "attributes": { "constant": false, - "name": "User", - "scope": 90, + "name": "contractNum", + "scope": 100, "stateVariable": true, "storageLocation": "default", - "type": "struct CapCoin.User storage ref[] storage ref", + "type": "uint256", "value": null, - "visibility": "public", - "canonicalName": "CapCoin.User" + "visibility": "internal" + }, + "children": [ + { + "attributes": { + "name": "uint", + "type": "uint256" + }, + "id": 12, + "name": "ElementaryTypeName", + "src": "132:4:0" + } + ], + "id": 13, + "name": "VariableDeclaration", + "src": "132:16:0" + }, + { + "attributes": { + "constant": false, + "implemented": true, + "isConstructor": true, + "modifiers": [ + null + ], + "name": "CapCoin", + "payable": false, + "scope": 100, + "stateMutability": "nonpayable", + "superFunction": null, + "visibility": "public" + }, + "children": [ + { + "attributes": { + "parameters": [ + null + ] + }, + "children": [], + "id": 14, + "name": "ParameterList", + "src": "170:2:0" + }, + { + "attributes": { + "parameters": [ + null + ] + }, + "children": [], + "id": 15, + "name": "ParameterList", + "src": "173:0:0" + }, + { + "children": [ + { + "children": [ + { + "attributes": { + "argumentTypes": null, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "operator": "=", + "type": "uint256" + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 13, + "type": "uint256", + "value": "contractNum" + }, + "id": 16, + "name": "Identifier", + "src": "179:11:0" + }, + { + "attributes": { + "argumentTypes": null, + "hexvalue": "31", + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "subdenomination": null, + "token": "number", + "type": "int_const 1", + "value": "1" + }, + "id": 17, + "name": "Literal", + "src": "193:1:0" + } + ], + "id": 18, + "name": "Assignment", + "src": "179:15:0" + } + ], + "id": 19, + "name": "ExpressionStatement", + "src": "179:15:0" + } + ], + "id": 20, + "name": "Block", + "src": "173:26:0" + } + ], + "id": 21, + "name": "FunctionDefinition", + "src": "153:46:0" + }, + { + "attributes": { + "canonicalName": "CapCoin.User", + "name": "User", + "scope": 100, + "visibility": "public" }, "children": [ { "attributes": { - "length": null, - "type": "string storage pointer", "constant": false, "name": "name", - "scope": 16, + "scope": 26, "stateVariable": false, "storageLocation": "default", + "type": "string storage pointer", "value": null, "visibility": "internal" }, "children": [ { "attributes": { - "contractScope": null, "name": "string", - "referencedDeclaration": 12, "type": "string storage pointer" }, - "id": 12, + "id": 22, "name": "ElementaryTypeName", - "src": "151:6:0" + "src": "221:6:0" } ], - "id": 13, + "id": 23, "name": "VariableDeclaration", - "src": "151:11:0" + "src": "221:11:0" }, { "attributes": { "constant": false, "name": "coinBalance", - "scope": 16, + "scope": 26, "stateVariable": false, "storageLocation": "default", "type": "uint256", @@ -495,25 +465,25 @@ "name": "uint", "type": "uint256" }, - "id": 14, + "id": 24, "name": "ElementaryTypeName", - "src": "168:4:0" + "src": "238:4:0" } ], - "id": 15, + "id": 25, "name": "VariableDeclaration", - "src": "168:16:0" + "src": "238:16:0" } ], - "id": 16, + "id": 26, "name": "StructDefinition", - "src": "133:56:0" + "src": "203:56:0" }, { "attributes": { "constant": false, "name": "addressToUser", - "scope": 90, + "scope": 100, "stateVariable": true, "storageLocation": "default", "type": "mapping(address => struct CapCoin.User storage ref)", @@ -523,44 +493,75 @@ "children": [ { "attributes": { - "type": "mapping(address => struct CapCoin.User storage ref)", - "length": null, - "contractScope": null, - "name": "User", - "referencedDeclaration": 18 + "type": "mapping(address => struct CapCoin.User storage ref)" }, "children": [ { "attributes": { "name": "address", - "type": "address", - "contractScope": null, - "referencedDeclaration": 18 + "type": "address" }, - "id": 17, + "id": 27, "name": "ElementaryTypeName", - "src": "202:7:0" + "src": "272:7:0" }, { "attributes": { - "name": "User", - "type": "struct CapCoin.User storage pointer", "contractScope": null, - "referencedDeclaration": 16 + "name": "User", + "referencedDeclaration": 26, + "type": "struct CapCoin.User storage pointer" }, - "id": 18, + "id": 28, "name": "UserDefinedTypeName", - "src": "213:4:0" + "src": "283:4:0" } ], - "id": 19, + "id": 29, "name": "Mapping", - "src": "193:25:0" + "src": "263:25:0" + } + ], + "id": 30, + "name": "VariableDeclaration", + "src": "263:46:0" + }, + { + "attributes": { + "constant": false, + "name": "users", + "scope": 100, + "stateVariable": true, + "storageLocation": "default", + "type": "address[] storage ref", + "value": null, + "visibility": "public" + }, + "children": [ + { + "attributes": { + "length": null, + "type": "address[] storage pointer" + }, + "children": [ + { + "attributes": { + "name": "address", + "type": "address" + }, + "id": 31, + "name": "ElementaryTypeName", + "src": "313:7:0" + } + ], + "id": 32, + "name": "ArrayTypeName", + "src": "313:9:0" } ], - "id": 20, + "id": 33, "name": "VariableDeclaration", - "src": "193:46:0" + "src": "313:22:0" }, { "attributes": { @@ -570,16 +571,12 @@ "modifiers": [ null ], - "name": "users", + "name": "createUser", "payable": false, - "scope": 90, + "scope": 100, "stateMutability": "nonpayable", "superFunction": null, - "visibility": "public", - "stateVariable": true, - "storageLocation": "default", - "type": "address[] storage ref", - "value": null + "visibility": "public" }, "children": [ { @@ -587,15 +584,13 @@ { "attributes": { "constant": false, - "name": "address", - "scope": 42, + "name": "name", + "scope": 70, "stateVariable": false, "storageLocation": "default", - "type": "address", + "type": "string memory", "value": null, - "visibility": "internal", - "contractScope": null, - "referencedDeclaration": 18 + "visibility": "internal" }, "children": [ { @@ -603,32 +598,19 @@ "name": "string", "type": "string storage pointer" }, - "id": 20, + "id": 34, "name": "ElementaryTypeName", - "src": "312:6:0" + "src": "360:6:0" } ], - "id": 21, - "name": "ElementaryTypeName", - "src": "243:7:0" - }, - { - "attributes": { - "name": "address", - "type": "address" - }, - "id": 23, - "name": "ElementaryTypeName", - "src": "247:7:0" + "id": 35, + "name": "VariableDeclaration", + "src": "360:11:0" } ], - "id": 22, - "name": "ArrayTypeName", - "src": "243:9:0", - "attributes": { - "type": "address[] storage pointer", - "length": null - } + "id": 36, + "name": "ParameterList", + "src": "359:13:0" }, { "attributes": { @@ -637,95 +619,59 @@ ] }, "children": [], - "id": 23, + "id": 37, "name": "ParameterList", - "src": "332:0:0" + "src": "380:0:0" }, { "children": [ { "attributes": { "assignments": [ - 25 + 38 ] }, "children": [ { "attributes": { "constant": false, - "name": "id", - "scope": 42, + "name": "user", + "scope": 70, "stateVariable": false, "storageLocation": "default", - "type": "uint256", + "type": "struct CapCoin.User storage pointer", + "typeName": null, "value": null, "visibility": "internal" }, - "children": [ - { - "attributes": { - "name": "uint", - "type": "uint256" - }, - "id": 24, - "name": "ElementaryTypeName", - "src": "338:4:0" - } - ], - "id": 25, + "children": [], + "id": 38, "name": "VariableDeclaration", - "src": "338:7:0" + "src": "386:8:0" }, { "attributes": { "argumentTypes": null, "isConstant": false, - "isLValue": false, + "isLValue": true, "isPure": false, - "isStructConstructorCall": false, "lValueRequested": false, - "names": [ - null - ], - "type": "uint256", - "type_conversion": false + "type": "struct CapCoin.User storage ref" }, "children": [ { "attributes": { - "argumentTypes": [ - { - "typeIdentifier": "t_struct$_User_$12_memory", - "typeString": "struct CapCoin.User memory" - } + "argumentTypes": null, + "overloadedDeclarations": [ + null ], - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "member_name": "push", - "referencedDeclaration": null, - "type": "function (struct CapCoin.User storage ref) returns (uint256)" + "referencedDeclaration": 30, + "type": "mapping(address => struct CapCoin.User storage ref)", + "value": "addressToUser" }, - "children": [ - { - "attributes": { - "argumentTypes": null, - "overloadedDeclarations": [ - null - ], - "referencedDeclaration": 15, - "type": "struct CapCoin.User storage ref[] storage ref", - "value": "users" - }, - "id": 26, - "name": "Identifier", - "src": "348:5:0" - } - ], - "id": 27, - "name": "MemberAccess", - "src": "348:10:0" + "id": 39, + "name": "Identifier", + "src": "397:13:0" }, { "attributes": { @@ -733,83 +679,40 @@ "isConstant": false, "isLValue": false, "isPure": false, - "isStructConstructorCall": true, "lValueRequested": false, - "names": [ - null - ], - "type": "struct CapCoin.User memory", - "type_conversion": false + "member_name": "sender", + "referencedDeclaration": null, + "type": "address" }, "children": [ - { - "attributes": { - "argumentTypes": [ - { - "typeIdentifier": "t_string_memory_ptr", - "typeString": "string memory" - }, - { - "typeIdentifier": "t_rational_0_by_1", - "typeString": "int_const 0" - } - ], - "overloadedDeclarations": [ - null - ], - "referencedDeclaration": 12, - "type": "type(struct CapCoin.User storage pointer)", - "value": "User" - }, - "id": 28, - "name": "Identifier", - "src": "359:4:0" - }, { "attributes": { "argumentTypes": null, "overloadedDeclarations": [ null ], - "referencedDeclaration": 21, - "type": "string memory", - "value": "name" + "referencedDeclaration": 112, + "type": "msg", + "value": "msg" }, - "id": 29, + "id": 40, "name": "Identifier", - "src": "364:4: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": 30, - "name": "Literal", - "src": "370:1:0" + "src": "411:3:0" } ], - "id": 31, - "name": "FunctionCall", - "src": "359:13:0" + "id": 41, + "name": "MemberAccess", + "src": "411:10:0" } ], - "id": 32, - "name": "FunctionCall", - "src": "348:25:0" + "id": 42, + "name": "IndexAccess", + "src": "397:25:0" } ], - "id": 33, + "id": 43, "name": "VariableDeclarationStatement", - "src": "338:35:0" + "src": "386:36:0" }, { "children": [ @@ -821,7 +724,7 @@ "isPure": false, "lValueRequested": false, "operator": "=", - "type": "address" + "type": "string storage ref" }, "children": [ { @@ -831,7 +734,9 @@ "isLValue": true, "isPure": false, "lValueRequested": true, - "type": "address" + "member_name": "name", + "referencedDeclaration": 23, + "type": "string storage ref" }, "children": [ { @@ -840,1099 +745,66 @@ "overloadedDeclarations": [ null ], - "referencedDeclaration": 19, - "type": "mapping(uint256 => address)", - "value": "userToOwner" - }, - "id": 34, - "name": "Identifier", - "src": "379:11:0" - }, - { - "attributes": { - "argumentTypes": null, - "overloadedDeclarations": [ - null - ], - "referencedDeclaration": 25, - "type": "uint256", - "value": "id" + "referencedDeclaration": 38, + "type": "struct CapCoin.User storage pointer", + "value": "user" }, - "id": 35, + "id": 44, "name": "Identifier", - "src": "391:2:0" + "src": "429:4:0" } ], - "id": 36, - "name": "IndexAccess", - "src": "379:15:0" + "id": 46, + "name": "MemberAccess", + "src": "429:9:0" }, { "attributes": { "argumentTypes": null, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "member_name": "sender", - "referencedDeclaration": null, - "type": "address" + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 35, + "type": "string memory", + "value": "name" }, - "children": [ - { - "attributes": { - "argumentTypes": null, - "overloadedDeclarations": [ - null - ], - "referencedDeclaration": 55, - "type": "msg", - "value": "msg" - }, - "id": 37, - "name": "Identifier", - "src": "397:3:0" - } - ], - "id": 38, - "name": "MemberAccess", - "src": "397:10:0" + "id": 47, + "name": "Identifier", + "src": "441:4:0" } ], - "id": 39, + "id": 48, "name": "Assignment", - "src": "379:28:0" + "src": "429:16:0" } ], - "id": 40, + "id": 49, "name": "ExpressionStatement", - "src": "379:28:0" - } - ], - "id": 41, - "name": "Block", - "src": "332:80:0" - } - ], - "id": 23, - "name": "VariableDeclaration", - "src": "243:22:0" - }, - { - "attributes": { - "constant": false, - "implemented": true, - "isConstructor": false, - "modifiers": [ - null - ], - "name": "createUser", - "payable": false, - "scope": 90, - "stateMutability": "nonpayable", - "superFunction": null, - "visibility": "public", - "stateVariable": true, - "storageLocation": "default", - "type": "mapping(address => struct CapCoin.User storage ref)", - "value": null - }, - "children": [ - { - "children": [ + "src": "429:16:0" + }, { - "attributes": { - "constant": false, - "name": "name", - "scope": 60, - "stateVariable": false, - "storageLocation": "default", - "type": "string memory", - "value": null, - "visibility": "internal" - }, "children": [ { "attributes": { - "name": "string", - "type": "string storage pointer" - }, - "id": 24, - "name": "ElementaryTypeName", - "src": "290:6:0" - } - ], - "id": 25, - "name": "VariableDeclaration", - "src": "290:11:0" - }, - { - "attributes": { - "contractScope": null, - "name": "User", - "referencedDeclaration": 18, - "type": "struct CapCoin.User storage pointer" - }, - "id": 25, - "name": "UserDefinedTypeName", - "src": "259:4:0" - } - ], - "id": 26, - "name": "ParameterList", - "src": "289:13:0", - "attributes": { - "type": "mapping(address => struct CapCoin.User storage ref)" - } - }, - { - "attributes": { - "parameters": [ - null - ] - }, - "children": [], - "id": 27, - "name": "ParameterList", - "src": "310:0:0" - }, - { - "children": [ - { - "attributes": { - "assignments": [ - 28 - ] - }, - "children": [ - { - "attributes": { - "constant": false, - "name": "user", - "scope": 60, - "stateVariable": false, - "storageLocation": "default", - "type": "struct CapCoin.User storage pointer", - "value": null, - "visibility": "internal", - "argumentTypes": null, - "isConstant": false, - "isLValue": false, - "isPure": false, - "isStructConstructorCall": false, - "lValueRequested": false, - "names": [ - null - ], - "type_conversion": false, - "typeName": null - }, - "children": [ - { - "attributes": { - "name": "uint", - "type": "uint256", - "argumentTypes": [ - { - "typeIdentifier": "t_string_memory_ptr", - "typeString": "string memory" - } - ], - "overloadedDeclarations": [ - null - ], - "referencedDeclaration": 5, - "value": "NewUser" - }, - "id": 30, - "name": "ElementaryTypeName", - "src": "325:4:0" - }, - { - "attributes": { - "argumentTypes": null, - "overloadedDeclarations": [ - null - ], - "referencedDeclaration": 25, - "type": "string memory", - "value": "name" - }, - "id": 29, - "name": "Identifier", - "src": "527:4:0" - } - ], - "id": 28, - "name": "VariableDeclaration", - "src": "316:8:0" - }, - { - "attributes": { - "argumentTypes": null, - "isConstant": false, - "isLValue": true, - "isPure": false, - "isStructConstructorCall": false, - "lValueRequested": false, - "names": [ - null - ], - "type": "struct CapCoin.User storage ref", - "type_conversion": false - }, - "children": [ - { - "attributes": { - "argumentTypes": null, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "member_name": "push", - "referencedDeclaration": 20, - "type": "mapping(address => struct CapCoin.User storage ref)", - "overloadedDeclarations": [ - null - ], - "value": "addressToUser" - }, - "children": [ - { - "attributes": { - "argumentTypes": null, - "overloadedDeclarations": [ - null - ], - "referencedDeclaration": 21, - "type": "struct CapCoin.User storage ref[] storage ref", - "value": "users" - }, - "id": 32, - "name": "Identifier", - "src": "335:5:0" - } - ], - "id": 29, - "name": "Identifier", - "src": "327:13:0" - }, - { - "attributes": { - "argumentTypes": null, - "isConstant": false, - "isLValue": false, - "isPure": false, - "isStructConstructorCall": true, - "lValueRequested": false, - "names": [ - null - ], - "type": "address", - "type_conversion": false, - "member_name": "sender", - "referencedDeclaration": null - }, - "children": [ - { - "attributes": { - "argumentTypes": null, - "overloadedDeclarations": [ - null - ], - "referencedDeclaration": 102, - "type": "msg", - "value": "msg" - }, - "id": 30, - "name": "Identifier", - "src": "341:3:0" - }, - { - "attributes": { - "argumentTypes": null, - "overloadedDeclarations": [ - null - ], - "referencedDeclaration": 27, - "type": "string memory", - "value": "name" - }, - "id": 35, - "name": "Identifier", - "src": "351:4: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": 36, - "name": "Literal", - "src": "357:1:0" - } - ], - "id": 31, - "name": "MemberAccess", - "src": "341:10:0" - } - ], - "id": 32, - "name": "IndexAccess", - "src": "327:25:0" - } - ], - "id": 33, - "name": "VariableDeclarationStatement", - "src": "316:36:0" - }, - { - "children": [ - { - "attributes": { - "argumentTypes": null, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "operator": "=", - "type": "string storage ref" - }, - "children": [ - { - "attributes": { - "argumentTypes": null, - "isConstant": false, - "isLValue": true, - "isPure": false, - "lValueRequested": true, - "type": "string storage ref", - "member_name": "name", - "referencedDeclaration": 13 - }, - "children": [ - { - "attributes": { - "argumentTypes": null, - "overloadedDeclarations": [ - null - ], - "referencedDeclaration": 28, - "type": "struct CapCoin.User storage pointer", - "value": "user" - }, - "id": 34, - "name": "Identifier", - "src": "359:4:0" - }, - { - "attributes": { - "argumentTypes": null, - "overloadedDeclarations": [ - null - ], - "referencedDeclaration": 31, - "type": "uint256", - "value": "id" - }, - "id": 41, - "name": "Identifier", - "src": "378:2:0" - } - ], - "id": 36, - "name": "MemberAccess", - "src": "359:9:0" - }, - { - "attributes": { - "argumentTypes": null, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "member_name": "sender", - "referencedDeclaration": 25, - "type": "string memory", - "overloadedDeclarations": [ - null - ], - "value": "name" - }, - "children": [ - { - "attributes": { - "argumentTypes": null, - "overloadedDeclarations": [ - null - ], - "referencedDeclaration": 66, - "type": "msg", - "value": "msg" - }, - "id": 43, - "name": "Identifier", - "src": "384:3:0" - } - ], - "id": 37, - "name": "Identifier", - "src": "371:4:0" - } - ], - "id": 38, - "name": "Assignment", - "src": "359:16:0" - } - ], - "id": 39, - "name": "ExpressionStatement", - "src": "359:16:0" - }, - { - "children": [ - { - "attributes": { - "argumentTypes": null, - "isConstant": false, - "isLValue": false, - "isPure": false, - "isStructConstructorCall": false, - "lValueRequested": false, - "names": [ - null - ], - "type": "uint256", - "type_conversion": false, - "operator": "=" - }, - "children": [ - { - "attributes": { - "argumentTypes": null, - "overloadedDeclarations": [ - null - ], - "referencedDeclaration": 15, - "type": "uint256", - "value": "NewUser", - "isConstant": false, - "isLValue": true, - "isPure": false, - "lValueRequested": true, - "member_name": "coinBalance" - }, - "id": 42, - "name": "MemberAccess", - "src": "381:16:0", - "children": [ - { - "attributes": { - "argumentTypes": null, - "overloadedDeclarations": [ - null - ], - "referencedDeclaration": 28, - "type": "struct CapCoin.User storage pointer", - "value": "user" - }, - "id": 40, - "name": "Identifier", - "src": "381:4:0" - } - ] - }, - { - "attributes": { - "argumentTypes": null, - "overloadedDeclarations": [ - null - ], - "referencedDeclaration": 31, - "type": "int_const 0", - "value": "0", - "hexvalue": "30", - "isConstant": false, - "isLValue": false, - "isPure": true, - "lValueRequested": false, - "subdenomination": null, - "token": "number" - }, - "id": 43, - "name": "Literal", - "src": "400:1:0" - }, - { - "attributes": { - "argumentTypes": null, - "overloadedDeclarations": [ - null - ], - "referencedDeclaration": 27, - "type": "string memory", - "value": "name" - }, - "id": 49, - "name": "Identifier", - "src": "412:4:0" - } - ], - "id": 44, - "name": "Assignment", - "src": "381:20:0" - } - ], - "id": 45, - "name": "ExpressionStatement", - "src": "381:20:0" - }, - { - "children": [ - { - "attributes": { - "argumentTypes": null, - "commonType": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "operator": "-", - "type": "uint256" - }, - "children": [ - { - "attributes": { - "argumentTypes": null, - "isConstant": false, - "isLValue": false, - "isPure": false, - "isStructConstructorCall": false, - "lValueRequested": false, - "names": [ - null - ], - "type": "uint256", - "type_conversion": false - }, - "children": [ - { - "attributes": { - "argumentTypes": [ - { - "typeIdentifier": "t_address", - "typeString": "address" - } - ], - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "member_name": "push", - "referencedDeclaration": null, - "type": "function (address) returns (uint256)" - }, - "children": [ - { - "attributes": { - "argumentTypes": null, - "overloadedDeclarations": [ - null - ], - "referencedDeclaration": 23, - "type": "address[] storage ref", - "value": "users" - }, - "id": 46, - "name": "Identifier", - "src": "408:5:0" - } - ], - "id": 48, - "name": "MemberAccess", - "src": "408:10: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": 102, - "type": "msg", - "value": "msg" - }, - "id": 49, - "name": "Identifier", - "src": "419:3:0" - } - ], - "id": 50, - "name": "MemberAccess", - "src": "419:10:0" - } - ], - "id": 51, - "name": "FunctionCall", - "src": "408:22:0" - }, - { - "attributes": { - "argumentTypes": null, - "hexvalue": "31", - "isConstant": false, - "isLValue": false, - "isPure": true, - "lValueRequested": false, - "subdenomination": null, - "token": "number", - "type": "int_const 1", - "value": "1" - }, - "id": 52, - "name": "Literal", - "src": "432:1:0" - } - ], - "id": 53, - "name": "BinaryOperation", - "src": "408:25:0" - } - ], - "id": 54, - "name": "ExpressionStatement", - "src": "408:25:0" - }, - { - "children": [ - { - "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_string_memory_ptr", - "typeString": "string memory" - } - ], - "overloadedDeclarations": [ - null - ], - "referencedDeclaration": 5, - "type": "function (string memory)", - "value": "NewUser" - }, - "id": 55, - "name": "Identifier", - "src": "439:7:0" - }, - { - "attributes": { - "argumentTypes": null, - "overloadedDeclarations": [ - null - ], - "referencedDeclaration": 25, - "type": "string memory", - "value": "name" - }, - "id": 56, - "name": "Identifier", - "src": "447:4:0" - } - ], - "id": 57, - "name": "FunctionCall", - "src": "439:13:0" - } - ], - "id": 58, - "name": "ExpressionStatement", - "src": "439:13:0" - } - ], - "id": 59, - "name": "Block", - "src": "310:147:0" - } - ], - "id": 60, - "name": "FunctionDefinition", - "src": "270:187:0" - }, - { - "attributes": { - "constant": true, - "implemented": true, - "isConstructor": false, - "modifiers": [ - null - ], - "name": "getUsers", - "payable": false, - "scope": 90, - "stateMutability": "view", - "superFunction": null, - "visibility": "public" - }, - "children": [ - { - "children": [ - { - "attributes": { - "constant": false, - "name": "name", - "scope": 59, - "stateVariable": false, - "storageLocation": "default", - "type": "string memory", - "value": null, - "visibility": "internal" - }, - "children": [ - { - "attributes": { - "name": "string", - "type": "string storage pointer" - }, - "id": 28, - "name": "ElementaryTypeName", - "src": "310:6:0" - } - ], - "id": 29, - "name": "VariableDeclaration", - "src": "310:11:0" - } - ], - "id": 61, - "name": "ParameterList", - "src": "478:2:0", - "attributes": { - "parameters": [ - null - ] - } - }, - { - "children": [ - { - "attributes": { - "constant": false, - "name": "", - "scope": 69, - "stateVariable": false, - "storageLocation": "default", - "type": "address[] memory", - "value": null, - "visibility": "internal" - }, - "children": [ - { - "attributes": { - "contractScope": null, - "name": "User", - "referencedDeclaration": 16, - "type": "address[] storage pointer", - "length": null - }, - "id": 63, - "name": "ArrayTypeName", - "src": "502:9:0", - "children": [ - { - "attributes": { - "name": "address", - "type": "address" - }, - "id": 62, - "name": "ElementaryTypeName", - "src": "502:7:0" - } - ] - } - ], - "id": 64, - "name": "VariableDeclaration", - "src": "502:9:0" - } - ], - "id": 65, - "name": "ParameterList", - "src": "501:11:0", - "attributes": { - "parameters": [ - null - ] - } - }, - { - "children": [ - { - "children": [ - { - "attributes": { - "argumentTypes": null, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "operator": "=", - "type": "address[] storage ref", - "overloadedDeclarations": [ - null - ], - "referencedDeclaration": 23, - "value": "users" - }, - "children": [ - { - "attributes": { - "argumentTypes": null, - "overloadedDeclarations": [ - null - ], - "referencedDeclaration": 20, - "type": "struct CapCoin.User storage ref", - "value": "user" - }, - "id": 32, - "name": "Identifier", - "src": "336:4:0" - }, - { - "attributes": { - "argumentTypes": null, - "isConstant": false, - "isLValue": false, - "isPure": false, - "isStructConstructorCall": true, - "lValueRequested": false, - "names": [ - null - ], - "type": "struct CapCoin.User memory", - "type_conversion": false - }, - "children": [ - { - "attributes": { - "argumentTypes": [ - { - "typeIdentifier": "t_string_memory_ptr", - "typeString": "string memory" - }, - { - "typeIdentifier": "t_rational_0_by_1", - "typeString": "int_const 0" - } - ], - "overloadedDeclarations": [ - null - ], - "referencedDeclaration": 18, - "type": "type(struct CapCoin.User storage pointer)", - "value": "User" - }, - "id": 33, - "name": "Identifier", - "src": "343:4:0" - }, - { - "attributes": { - "argumentTypes": null, - "overloadedDeclarations": [ - null - ], - "referencedDeclaration": 29, - "type": "string memory", - "value": "name" - }, - "id": 34, - "name": "Identifier", - "src": "348:4: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": 35, - "name": "Literal", - "src": "354:1:0" - } - ], - "id": 36, - "name": "FunctionCall", - "src": "343:13:0" - } - ], - "id": 66, - "name": "Identifier", - "src": "526:5:0" - } - ], - "id": 67, - "name": "Return", - "src": "519:12:0", - "attributes": { - "functionReturnParameters": 65 - } - }, - { - "children": [ - { - "attributes": { - "argumentTypes": null, - "isConstant": false, - "isLValue": false, - "isPure": false, - "isStructConstructorCall": false, - "lValueRequested": false, - "names": [ - null - ], - "type": "uint256", - "type_conversion": false, - "constant": false, - "name": "id", - "scope": 59, - "stateVariable": false, - "storageLocation": "default", - "value": null, - "visibility": "internal" + "argumentTypes": null, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "operator": "=", + "type": "uint256" }, "children": [ - { - "attributes": { - "argumentTypes": [ - { - "typeIdentifier": "t_struct$_User_$16_storage", - "typeString": "struct CapCoin.User storage ref" - } - ], - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "member_name": "push", - "referencedDeclaration": null, - "type": "uint256", - "name": "uint" - }, - "children": [ - { - "attributes": { - "argumentTypes": null, - "overloadedDeclarations": [ - null - ], - "referencedDeclaration": 21, - "type": "struct CapCoin.User storage ref[] storage ref", - "value": "users" - }, - "id": 39, - "name": "Identifier", - "src": "373:5:0" - } - ], - "id": 39, - "name": "ElementaryTypeName", - "src": "362:4:0" - }, { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], - "referencedDeclaration": 18, - "type": "struct CapCoin.User storage ref", - "value": "user" - }, - "id": 42, - "name": "Identifier", - "src": "384:4:0" - } - ], - "id": 40, - "name": "VariableDeclaration", - "src": "362:7:0" - }, - { - "attributes": { - "argumentTypes": null, - "isConstant": false, - "isLValue": false, - "isPure": false, - "isStructConstructorCall": false, - "lValueRequested": false, - "names": [ - null - ], - "type": "uint256", - "type_conversion": false - }, - "children": [ - { - "attributes": { - "argumentTypes": [ - { - "typeIdentifier": "t_struct$_User_$18_storage", - "typeString": "struct CapCoin.User storage ref" - } - ], "isConstant": false, - "isLValue": false, + "isLValue": true, "isPure": false, - "lValueRequested": false, - "member_name": "push", - "referencedDeclaration": null, - "type": "function (struct CapCoin.User storage ref) returns (uint256)" + "lValueRequested": true, + "member_name": "coinBalance", + "referencedDeclaration": 25, + "type": "uint256" }, "children": [ { @@ -1941,84 +813,113 @@ "overloadedDeclarations": [ null ], - "referencedDeclaration": 23, - "type": "struct CapCoin.User storage ref[] storage ref", - "value": "users" + "referencedDeclaration": 38, + "type": "struct CapCoin.User storage pointer", + "value": "user" }, - "id": 41, + "id": 50, "name": "Identifier", - "src": "372:5:0" + "src": "451:4:0" } ], - "id": 42, + "id": 52, "name": "MemberAccess", - "src": "372:10:0" + "src": "451:16:0" }, { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], - "referencedDeclaration": 20, - "type": "struct CapCoin.User storage ref", - "value": "user" + "hexvalue": "30", + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "subdenomination": null, + "token": "number", + "type": "int_const 0", + "value": "0" }, - "id": 43, - "name": "Identifier", - "src": "383:4:0" + "id": 53, + "name": "Literal", + "src": "470:1:0" } ], - "id": 44, - "name": "FunctionCall", - "src": "372:16:0" + "id": 54, + "name": "Assignment", + "src": "451:20:0" } ], - "id": 45, - "name": "VariableDeclarationStatement", - "src": "362:26:0", - "attributes": { - "assignments": [ - 40 - ] - } + "id": 55, + "name": "ExpressionStatement", + "src": "451:20:0" }, { "children": [ { "attributes": { "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, - "operator": "=", - "type": "struct CapCoin.User storage ref" + "operator": "-", + "type": "uint256" }, "children": [ { "attributes": { "argumentTypes": null, "isConstant": false, - "isLValue": true, + "isLValue": false, "isPure": false, - "lValueRequested": true, - "type": "struct CapCoin.User storage ref" + "isStructConstructorCall": false, + "lValueRequested": false, + "names": [ + null + ], + "type": "uint256", + "type_conversion": false }, "children": [ { "attributes": { - "argumentTypes": null, - "overloadedDeclarations": [ - null + "argumentTypes": [ + { + "typeIdentifier": "t_address", + "typeString": "address" + } ], - "referencedDeclaration": 27, - "type": "mapping(address => struct CapCoin.User storage ref)", - "value": "addressToUser" + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "member_name": "push", + "referencedDeclaration": null, + "type": "function (address) returns (uint256)" }, - "id": 46, - "name": "Identifier", - "src": "394:13:0" + "children": [ + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 33, + "type": "address[] storage ref", + "value": "users" + }, + "id": 56, + "name": "Identifier", + "src": "478:5:0" + } + ], + "id": 58, + "name": "MemberAccess", + "src": "478:10:0" }, { "attributes": { @@ -2038,62 +939,56 @@ "overloadedDeclarations": [ null ], - "referencedDeclaration": 83, + "referencedDeclaration": 112, "type": "msg", "value": "msg" }, - "id": 47, + "id": 59, "name": "Identifier", - "src": "408:3:0" + "src": "489:3:0" } ], - "id": 48, + "id": 60, "name": "MemberAccess", - "src": "408:10:0" + "src": "489:10:0" } ], - "id": 49, - "name": "IndexAccess", - "src": "394:25:0" + "id": 61, + "name": "FunctionCall", + "src": "478:22:0" }, { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], - "referencedDeclaration": 20, - "type": "struct CapCoin.User storage ref", - "value": "user" + "hexvalue": "31", + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "subdenomination": null, + "token": "number", + "type": "int_const 1", + "value": "1" }, - "id": 50, - "name": "Identifier", - "src": "422:4:0" + "id": 62, + "name": "Literal", + "src": "502:1:0" } ], - "id": 51, - "name": "Assignment", - "src": "394:32:0" + "id": 63, + "name": "BinaryOperation", + "src": "478:25:0" } ], - "id": 52, + "id": 64, "name": "ExpressionStatement", - "src": "394:32:0" + "src": "478:25:0" }, { - "attributes": { - "functionReturnParameters": 31 - }, "children": [ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], - "referencedDeclaration": 18, - "type": "tuple()", - "value": "user", "isConstant": false, "isLValue": false, "isPure": false, @@ -2102,19 +997,13 @@ "names": [ null ], + "type": "tuple()", "type_conversion": false }, - "id": 56, - "name": "FunctionCall", - "src": "432:17:0", "children": [ { "attributes": { "argumentTypes": [ - { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, { "typeIdentifier": "t_string_memory_ptr", "typeString": "string memory" @@ -2123,27 +1012,13 @@ "overloadedDeclarations": [ null ], - "referencedDeclaration": 7, - "type": "function (uint256,string memory)", + "referencedDeclaration": 5, + "type": "function (string memory)", "value": "NewUser" }, - "id": 53, - "name": "Identifier", - "src": "432:7:0" - }, - { - "attributes": { - "argumentTypes": null, - "overloadedDeclarations": [ - null - ], - "referencedDeclaration": 40, - "type": "uint256", - "value": "id" - }, - "id": 54, + "id": 65, "name": "Identifier", - "src": "440:2:0" + "src": "509:7:0" }, { "attributes": { @@ -2151,30 +1026,33 @@ "overloadedDeclarations": [ null ], - "referencedDeclaration": 29, + "referencedDeclaration": 35, "type": "string memory", "value": "name" }, - "id": 55, + "id": 66, "name": "Identifier", - "src": "444:4:0" + "src": "517:4:0" } - ] + ], + "id": 67, + "name": "FunctionCall", + "src": "509:13:0" } ], - "id": 57, + "id": 68, "name": "ExpressionStatement", - "src": "432:17:0" + "src": "509:13:0" } ], - "id": 68, + "id": 69, "name": "Block", - "src": "513:23:0" + "src": "380:147:0" } ], - "id": 69, + "id": 70, "name": "FunctionDefinition", - "src": "461:75:0" + "src": "340:187:0" }, { "attributes": { @@ -2184,51 +1062,131 @@ "modifiers": [ null ], - "name": "getUser", + "name": "getUsers", "payable": false, - "scope": 90, + "scope": 100, "stateMutability": "view", "superFunction": null, "visibility": "public" }, "children": [ + { + "attributes": { + "parameters": [ + null + ] + }, + "children": [], + "id": 71, + "name": "ParameterList", + "src": "548:2:0" + }, { "children": [ { "attributes": { "constant": false, - "name": "currentUser", - "scope": 70, + "name": "", + "scope": 79, "stateVariable": false, "storageLocation": "default", - "type": "address", + "type": "address[] memory", "value": null, "visibility": "internal" }, "children": [ { "attributes": { - "name": "address", - "type": "address" + "length": null, + "type": "address[] storage pointer" }, - "id": 56, - "name": "ElementaryTypeName", - "src": "492:7:0" + "children": [ + { + "attributes": { + "name": "address", + "type": "address" + }, + "id": 72, + "name": "ElementaryTypeName", + "src": "572:7:0" + } + ], + "id": 73, + "name": "ArrayTypeName", + "src": "572:9:0" } ], - "id": 57, + "id": 74, "name": "VariableDeclaration", - "src": "492:19:0" + "src": "572:9:0" } ], - "id": 70, + "id": 75, "name": "ParameterList", - "src": "556:2:0", + "src": "571:11:0" + }, + { + "children": [ + { + "attributes": { + "functionReturnParameters": 75 + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 33, + "type": "address[] storage ref", + "value": "users" + }, + "id": 76, + "name": "Identifier", + "src": "596:5:0" + } + ], + "id": 77, + "name": "Return", + "src": "589:12:0" + } + ], + "id": 78, + "name": "Block", + "src": "583:23:0" + } + ], + "id": 79, + "name": "FunctionDefinition", + "src": "531:75:0" + }, + { + "attributes": { + "constant": true, + "implemented": true, + "isConstructor": false, + "modifiers": [ + null + ], + "name": "getUser", + "payable": false, + "scope": 100, + "stateMutability": "view", + "superFunction": null, + "visibility": "public" + }, + "children": [ + { "attributes": { "parameters": [ null ] - } + }, + "children": [], + "id": 80, + "name": "ParameterList", + "src": "626:2:0" }, { "children": [ @@ -2236,7 +1194,7 @@ "attributes": { "constant": false, "name": "", - "scope": 89, + "scope": 99, "stateVariable": false, "storageLocation": "default", "type": "string memory", @@ -2246,25 +1204,23 @@ "children": [ { "attributes": { - "contractScope": null, "name": "string", - "referencedDeclaration": 18, "type": "string storage pointer" }, - "id": 71, + "id": 81, "name": "ElementaryTypeName", - "src": "580:6:0" + "src": "650:6:0" } ], - "id": 72, + "id": 82, "name": "VariableDeclaration", - "src": "580:6:0" + "src": "650:6:0" }, { "attributes": { "constant": false, "name": "", - "scope": 89, + "scope": 99, "stateVariable": false, "storageLocation": "default", "type": "uint256", @@ -2277,37 +1233,36 @@ "name": "uint", "type": "uint256" }, - "id": 73, + "id": 83, "name": "ElementaryTypeName", - "src": "588:4:0" + "src": "658:4:0" } ], - "id": 74, + "id": 84, "name": "VariableDeclaration", - "src": "588:4:0" + "src": "658:4:0" } ], - "id": 75, + "id": 85, "name": "ParameterList", - "src": "579:14:0" + "src": "649:14:0" }, { "children": [ { "attributes": { - "functionReturnParameters": 75 + "functionReturnParameters": 85 }, "children": [ { "attributes": { "argumentTypes": null, "isConstant": false, + "isInlineArray": false, "isLValue": false, "isPure": false, "lValueRequested": false, - "operator": "=", - "type": "tuple(string storage ref,uint256)", - "isInlineArray": false + "type": "tuple(string storage ref,uint256)" }, "children": [ { @@ -2317,32 +1272,20 @@ "isLValue": true, "isPure": false, "lValueRequested": false, - "type": "string storage ref", - "overloadedDeclarations": [ - null - ], - "referencedDeclaration": 13, - "value": "addressToUser", - "member_name": "name" + "member_name": "name", + "referencedDeclaration": 23, + "type": "string storage ref" }, "children": [ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], - "referencedDeclaration": 25, - "type": "struct CapCoin.User storage ref", - "value": "addressToUser", "isConstant": false, "isLValue": true, "isPure": false, - "lValueRequested": false + "lValueRequested": false, + "type": "struct CapCoin.User storage ref" }, - "id": 79, - "name": "IndexAccess", - "src": "608:25:0", "children": [ { "attributes": { @@ -2350,13 +1293,13 @@ "overloadedDeclarations": [ null ], - "referencedDeclaration": 20, + "referencedDeclaration": 30, "type": "mapping(address => struct CapCoin.User storage ref)", "value": "addressToUser" }, - "id": 76, + "id": 86, "name": "Identifier", - "src": "608:13:0" + "src": "678:13:0" }, { "attributes": { @@ -2376,93 +1319,50 @@ "overloadedDeclarations": [ null ], - "referencedDeclaration": 102, + "referencedDeclaration": 112, "type": "msg", "value": "msg" }, - "id": 77, + "id": 87, "name": "Identifier", - "src": "622:3:0" + "src": "692:3:0" } ], - "id": 78, + "id": 88, "name": "MemberAccess", - "src": "622:10: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": 83, - "type": "msg", - "value": "msg" - }, - "id": 63, - "name": "Identifier", - "src": "567:3:0" + "src": "692:10:0" } ], - "id": 64, - "name": "MemberAccess", - "src": "567:10:0" + "id": 89, + "name": "IndexAccess", + "src": "678:25:0" } ], - "id": 80, + "id": 90, "name": "MemberAccess", - "src": "608:30:0" + "src": "678:30:0" }, { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], - "referencedDeclaration": 15, - "type": "uint256", - "value": "user", "isConstant": false, "isLValue": true, "isPure": false, "lValueRequested": false, - "member_name": "coinBalance" + "member_name": "coinBalance", + "referencedDeclaration": 25, + "type": "uint256" }, - "id": 85, - "name": "MemberAccess", - "src": "640:37:0", "children": [ { "attributes": { "argumentTypes": null, - "overloadedDeclarations": [ - null - ], - "referencedDeclaration": 83, - "type": "struct CapCoin.User storage ref", - "value": "msg", "isConstant": false, "isLValue": true, "isPure": false, - "lValueRequested": false + "lValueRequested": false, + "type": "struct CapCoin.User storage ref" }, - "id": 84, - "name": "IndexAccess", - "src": "640:25:0", "children": [ { "attributes": { @@ -2470,13 +1370,13 @@ "overloadedDeclarations": [ null ], - "referencedDeclaration": 20, + "referencedDeclaration": 30, "type": "mapping(address => struct CapCoin.User storage ref)", "value": "addressToUser" }, - "id": 81, + "id": 91, "name": "Identifier", - "src": "640:13:0" + "src": "710:13:0" }, { "attributes": { @@ -2496,52 +1396,58 @@ "overloadedDeclarations": [ null ], - "referencedDeclaration": 102, + "referencedDeclaration": 112, "type": "msg", "value": "msg" }, - "id": 82, + "id": 92, "name": "Identifier", - "src": "654:3:0" + "src": "724:3:0" } ], - "id": 83, + "id": 93, "name": "MemberAccess", - "src": "654:10:0" + "src": "724:10:0" } - ] + ], + "id": 94, + "name": "IndexAccess", + "src": "710:25:0" } - ] + ], + "id": 95, + "name": "MemberAccess", + "src": "710:37:0" } ], - "id": 86, + "id": 96, "name": "TupleExpression", - "src": "607:71:0" + "src": "677:71:0" } ], - "id": 87, + "id": 97, "name": "Return", - "src": "600:78:0" + "src": "670:78:0" } ], - "id": 88, + "id": 98, "name": "Block", - "src": "594:89:0" + "src": "664:89:0" } ], - "id": 89, + "id": 99, "name": "FunctionDefinition", - "src": "540:143:0" + "src": "610:143:0" } ], - "id": 90, + "id": 100, "name": "ContractDefinition", - "src": "26:659:0" + "src": "26:729:0" } ], - "id": 91, + "id": 101, "name": "SourceUnit", - "src": "0:686:0" + "src": "0:756:0" }, "compiler": { "name": "solc", @@ -2551,9 +1457,9 @@ "5777": { "events": {}, "links": {}, - "address": "0xf25186b5081ff5ce73482ad761db0eb0d25abfbf" + "address": "0x8f0483125fcb9aaaefa9209d8e9d7b9c8b9fb90f" } }, "schemaVersion": "1.0.1", - "updatedAt": "2018-01-18T14:33:11.570Z" + "updatedAt": "2018-01-18T19:03:08.780Z" } \ No newline at end of file diff --git a/build/contracts/Migrations.json b/build/contracts/Migrations.json index f374e2ee..67e18b8a 100644 --- a/build/contracts/Migrations.json +++ b/build/contracts/Migrations.json @@ -819,9 +819,9 @@ "5777": { "events": {}, "links": {}, - "address": "0xf12b5dd4ead5f743c6baa640b0216200e89b60da" + "address": "0x345ca3e014aaf5dca488057592ee47305d9b3e10" } }, "schemaVersion": "1.0.1", - "updatedAt": "2018-01-18T14:33:11.577Z" + "updatedAt": "2018-01-18T19:03:08.782Z" } \ No newline at end of file diff --git a/build/contracts/SimpleStorage.json b/build/contracts/SimpleStorage.json index 29215247..a79ceb0b 100644 --- a/build/contracts/SimpleStorage.json +++ b/build/contracts/SimpleStorage.json @@ -344,5 +344,5 @@ } }, "schemaVersion": "1.0.1", - "updatedAt": "2018-01-18T14:33:11.547Z" + "updatedAt": "2018-01-18T19:03:08.779Z" } \ No newline at end of file diff --git a/contracts/CapCoin.sol b/contracts/CapCoin.sol index 36c89c28..897a028d 100644 --- a/contracts/CapCoin.sol +++ b/contracts/CapCoin.sol @@ -6,6 +6,11 @@ contract CapCoin { uint coinSupply = 1000000; uint coinsBought = 0; + uint contractNum; + + function CapCoin () { + contractNum = 1; + } struct User { string name; diff --git a/src/App.js b/src/App.js index 880a3899..f69aba64 100644 --- a/src/App.js +++ b/src/App.js @@ -27,7 +27,7 @@ class App extends Component { await this.props.getWeb3() await this.props.getContract(this.props.web3) await this.props.getAccounts(this.props.web3) - // await this.props.getUser(this.props.web3) + await this.props.findUser(this.props.contract.getUser, this.props.accounts[0]) } render() { @@ -44,6 +44,8 @@ class App extends Component { function mapStateToProps(state){ return { web3: state.web3, + contract: state.contract, + accounts: state.accounts } } @@ -58,8 +60,10 @@ function mapDispatchToProps(dispatch){ getAccounts: function (web3){ return dispatch(fetchAccounts(web3)); }, - getUser: function (web3){ - return dispatch(fetchUser(web3)); + findUser: function (contractFunc, account){ + contractFunc.call({from: account}) + .then(res => console.log(res)) + // return dispatch(fetchUser(web3)); } } } diff --git a/src/store/user.js b/src/store/user.js index be39a8b0..1da1fa27 100644 --- a/src/store/user.js +++ b/src/store/user.js @@ -22,7 +22,10 @@ export const fetchUser = (web3, address) => {} export const addUser = (name, contractFunc, account) => dispatch => contractFunc(name, {from: account}) - .then(res => dispatch(createUser(res.logs[0].args))) + .then(res => { + + console.log(res) + dispatch(createUser(res.logs[0].args))}) .catch(err => console.log(err)) /** From a5799189aa187ea705a9453c53a424fbf0464271 Mon Sep 17 00:00:00 2001 From: Jonathan Schwartz Date: Thu, 18 Jan 2018 15:00:13 -0500 Subject: [PATCH 2/2] correctly fetches the user and adds it to state --- src/App.js | 4 +--- src/store/user.js | 12 +++++++++++- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/App.js b/src/App.js index f69aba64..894bebf2 100644 --- a/src/App.js +++ b/src/App.js @@ -61,9 +61,7 @@ function mapDispatchToProps(dispatch){ return dispatch(fetchAccounts(web3)); }, findUser: function (contractFunc, account){ - contractFunc.call({from: account}) - .then(res => console.log(res)) - // return dispatch(fetchUser(web3)); + return dispatch(fetchUser(contractFunc, account)); } } } diff --git a/src/store/user.js b/src/store/user.js index 1da1fa27..79e8d23a 100644 --- a/src/store/user.js +++ b/src/store/user.js @@ -18,7 +18,17 @@ const createUser = user => ({type: CREATE_USER, user}) * THUNK CREATORS */ -export const fetchUser = (web3, address) => {} +export const fetchUser = (contractFunc, account) => + dispatch => + contractFunc.call({from: account}) + .then(res => { + let user = {} + user.name = res[0]; + user.coinBalance = Number(res[1].toString(10)); + return dispatch(getUser(user)) + }) + .catch(err => console.log(err)) + export const addUser = (name, contractFunc, account) => dispatch => contractFunc(name, {from: account})