From b40e0b8a4795f209b225cef14dc47e94f2eb00df Mon Sep 17 00:00:00 2001 From: MartijnNieuwenhuis <36473925+MartijnNieuwenhuis@users.noreply.github.com> Date: Thu, 23 May 2019 18:00:38 +0200 Subject: [PATCH 1/3] verwachte temperatuur bij geselecteerde datum en locatie --- client/src/App.js | 41 +- client/src/ForeCastWeather.js | 21 + client/src/Weather.js | 11 +- client/src/contracts/Migrations.json | 594 ++++++++++++------------ client/src/contracts/SimpleStorage.json | 18 +- 5 files changed, 362 insertions(+), 323 deletions(-) create mode 100644 client/src/ForeCastWeather.js diff --git a/client/src/App.js b/client/src/App.js index e5afa8b..6183967 100644 --- a/client/src/App.js +++ b/client/src/App.js @@ -2,11 +2,13 @@ import React, { Component } from "react"; import SimpleStorageContract from "./contracts/SimpleStorage.json"; import getWeb3 from "./utils/getWeb3"; import getWeather from "./Weather"; +import getForeCastWeather from "./ForeCastWeather"; import "./App.css"; class App extends Component { - state = { storageValue: 0, web3: null, accounts: null, contract: null, weather: null }; + state = { storageValue: 0, web3: null, accounts: null, contract: null, weather: null, forecastWeather: null, date: null }; + city = "Rotterdam"; componentDidMount = async () => { try { // Get network provider and web3 instance. @@ -21,8 +23,10 @@ class App extends Component { SimpleStorageContract.abi, deployedNetwork && deployedNetwork.address, ); - const weather = await getWeather("Rotterdam"); + const weather = await getWeather(this.city); this.setState({ weather }); + this.state.date = weather[0].dt_txt; + this.state.forecastWeather = await getForeCastWeather(this.state.date, this.city) // Set web3, accounts, and contract to the state, and then proceed with an // example of interacting with the contract's methods. this.setState({ web3, accounts, contract: instance }, this.runExample); @@ -37,8 +41,19 @@ class App extends Component { onChangeCity = async (e) => { let {value} = e.target; + this.city = value; const weather = await getWeather(value); this.setState({ weather }); + const forecastWeather = await getForeCastWeather(this.state.date, this.city); + this.setState({ forecastWeather }); + } + + onChangeDate = async (e) => { + let {value} = e.target; + const date = value; + this.setState({ date }) + const forecastWeather = await getForeCastWeather(date, this.city); + this.setState({ forecastWeather }); } runExample = async () => { @@ -84,23 +99,25 @@ class App extends Component {
- + {this.state.weather.map((weather, index) => { + return + })}
+
+ quoteringen +
-
-

Het is nu

-

{Math.round(this.state.weather.main.temp)} C°

-

in {this.state.weather.name}

-
+
+

Verwachte temperatuur op {this.state.date}

+

{Math.round(this.state.forecastWeather)} C°

+

in {this.city}

+
;
diff --git a/client/src/ForeCastWeather.js b/client/src/ForeCastWeather.js new file mode 100644 index 0000000..b302407 --- /dev/null +++ b/client/src/ForeCastWeather.js @@ -0,0 +1,21 @@ +const getForeWeather = async (date, city) => { + const URL = `http://api.openweathermap.org/data/2.5/forecast?q=${city},nl&units=metric&APPID=55e3d06cfe25b54ec349eae880b98d57`; + + try { + const res = await fetch(`${URL}`); + const data = await res.json(); + const list = data.list.slice(16,40); + for (let index = 0; index < list.length; index++) { + const element = list[index].dt_txt; + if (element === date) { + return list[index].main.temp + } + } + + } catch (error) { + + } + +} + +export default getForeWeather; \ No newline at end of file diff --git a/client/src/Weather.js b/client/src/Weather.js index 28b4280..c75dbdd 100644 --- a/client/src/Weather.js +++ b/client/src/Weather.js @@ -1,15 +1,16 @@ const getWeather = async (city) => { - const URL = `http://api.openweathermap.org/data/2.5/weather?q=${city},nl&units=metric&APPID=55e3d06cfe25b54ec349eae880b98d57`; + const URL = `http://api.openweathermap.org/data/2.5/forecast?q=${city},nl&units=metric&APPID=55e3d06cfe25b54ec349eae880b98d57`; try { const res = await fetch(`${URL}`); const data = await res.json(); - return data; - + + return data.list.slice(16,40); + } catch (error) { - + } - + } export default getWeather; \ No newline at end of file diff --git a/client/src/contracts/Migrations.json b/client/src/contracts/Migrations.json index 1189903..a59f849 100644 --- a/client/src/contracts/Migrations.json +++ b/client/src/contracts/Migrations.json @@ -69,24 +69,24 @@ "signature": "0x0900f010" } ], - "bytecode": "0x608060405234801561001057600080fd5b50336000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550610314806100606000396000f3fe608060405260043610610062576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680630900f01014610067578063445df0ac146100b85780638da5cb5b146100e3578063fdacd5761461013a575b600080fd5b34801561007357600080fd5b506100b66004803603602081101561008a57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610175565b005b3480156100c457600080fd5b506100cd61025d565b6040518082815260200191505060405180910390f35b3480156100ef57600080fd5b506100f8610263565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561014657600080fd5b506101736004803603602081101561015d57600080fd5b8101908080359060200190929190505050610288565b005b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561025a5760008190508073ffffffffffffffffffffffffffffffffffffffff1663fdacd5766001546040518263ffffffff167c010000000000000000000000000000000000000000000000000000000002815260040180828152602001915050600060405180830381600087803b15801561024057600080fd5b505af1158015610254573d6000803e3d6000fd5b50505050505b50565b60015481565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614156102e557806001819055505b5056fea165627a7a72305820e775482d7971207d6ece29108b0542835fbacc6a4ca15b2e316a922b843449c10029", - "deployedBytecode": "0x608060405260043610610062576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680630900f01014610067578063445df0ac146100b85780638da5cb5b146100e3578063fdacd5761461013a575b600080fd5b34801561007357600080fd5b506100b66004803603602081101561008a57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610175565b005b3480156100c457600080fd5b506100cd61025d565b6040518082815260200191505060405180910390f35b3480156100ef57600080fd5b506100f8610263565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561014657600080fd5b506101736004803603602081101561015d57600080fd5b8101908080359060200190929190505050610288565b005b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561025a5760008190508073ffffffffffffffffffffffffffffffffffffffff1663fdacd5766001546040518263ffffffff167c010000000000000000000000000000000000000000000000000000000002815260040180828152602001915050600060405180830381600087803b15801561024057600080fd5b505af1158015610254573d6000803e3d6000fd5b50505050505b50565b60015481565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614156102e557806001819055505b5056fea165627a7a72305820e775482d7971207d6ece29108b0542835fbacc6a4ca15b2e316a922b843449c10029", - "sourceMap": "27:500:1:-;;;187:52;8:9:-1;5:2;;;30:1;27;20:12;5:2;187:52:1;223:10;215:5;;:18;;;;;;;;;;;;;;;;;;27:500;;;;;;", - "deployedSourceMap": "27:500:1:-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;356:168;;8:9:-1;5:2;;;30:1;27;20:12;5:2;356:168:1;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;356:168:1;;;;;;;;;;;;;;;;;;;;;;77:36;;8:9:-1;5:2;;;30:1;27;20:12;5:2;77:36:1;;;;;;;;;;;;;;;;;;;;;;;52:20;;8:9:-1;5:2;;;30:1;27;20:12;5:2;52:20:1;;;;;;;;;;;;;;;;;;;;;;;;;;;245:105;;8:9:-1;5:2;;;30:1;27;20:12;5:2;245:105:1;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;245:105:1;;;;;;;;;;;;;;;;;;;;356:168;167:5;;;;;;;;;;;153:19;;:10;:19;;;149:26;;;419:19;452:11;419:45;;471:8;:21;;;493:24;;471:47;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;471:47:1;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;471:47:1;;;;174:1;149:26;356:168;:::o;77:36::-;;;;:::o;52:20::-;;;;;;;;;;;;;:::o;245:105::-;167:5;;;;;;;;;;;153:19;;:10;:19;;;149:26;;;335:9;308:24;:36;;;;149:26;245:105;:::o", + "bytecode": "0x608060405234801561001057600080fd5b50336000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550610314806100606000396000f3fe608060405260043610610062576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680630900f01014610067578063445df0ac146100b85780638da5cb5b146100e3578063fdacd5761461013a575b600080fd5b34801561007357600080fd5b506100b66004803603602081101561008a57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610175565b005b3480156100c457600080fd5b506100cd61025d565b6040518082815260200191505060405180910390f35b3480156100ef57600080fd5b506100f8610263565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561014657600080fd5b506101736004803603602081101561015d57600080fd5b8101908080359060200190929190505050610288565b005b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561025a5760008190508073ffffffffffffffffffffffffffffffffffffffff1663fdacd5766001546040518263ffffffff167c010000000000000000000000000000000000000000000000000000000002815260040180828152602001915050600060405180830381600087803b15801561024057600080fd5b505af1158015610254573d6000803e3d6000fd5b50505050505b50565b60015481565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614156102e557806001819055505b5056fea165627a7a723058204e4c6697e9186c415ff230deadbfdf49b0eb6211b491210e1da82ab651d1b0780029", + "deployedBytecode": "0x608060405260043610610062576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680630900f01014610067578063445df0ac146100b85780638da5cb5b146100e3578063fdacd5761461013a575b600080fd5b34801561007357600080fd5b506100b66004803603602081101561008a57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610175565b005b3480156100c457600080fd5b506100cd61025d565b6040518082815260200191505060405180910390f35b3480156100ef57600080fd5b506100f8610263565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561014657600080fd5b506101736004803603602081101561015d57600080fd5b8101908080359060200190929190505050610288565b005b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561025a5760008190508073ffffffffffffffffffffffffffffffffffffffff1663fdacd5766001546040518263ffffffff167c010000000000000000000000000000000000000000000000000000000002815260040180828152602001915050600060405180830381600087803b15801561024057600080fd5b505af1158015610254573d6000803e3d6000fd5b50505050505b50565b60015481565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614156102e557806001819055505b5056fea165627a7a723058204e4c6697e9186c415ff230deadbfdf49b0eb6211b491210e1da82ab651d1b0780029", + "sourceMap": "27:500:0:-;;;187:52;8:9:-1;5:2;;;30:1;27;20:12;5:2;187:52:0;223:10;215:5;;:18;;;;;;;;;;;;;;;;;;27:500;;;;;;", + "deployedSourceMap": "27:500:0:-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;356:168;;8:9:-1;5:2;;;30:1;27;20:12;5:2;356:168:0;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;356:168:0;;;;;;;;;;;;;;;;;;;;;;77:36;;8:9:-1;5:2;;;30:1;27;20:12;5:2;77:36:0;;;;;;;;;;;;;;;;;;;;;;;52:20;;8:9:-1;5:2;;;30:1;27;20:12;5:2;52:20:0;;;;;;;;;;;;;;;;;;;;;;;;;;;245:105;;8:9:-1;5:2;;;30:1;27;20:12;5:2;245:105:0;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;245:105:0;;;;;;;;;;;;;;;;;;;;356:168;167:5;;;;;;;;;;;153:19;;:10;:19;;;149:26;;;419:19;452:11;419:45;;471:8;:21;;;493:24;;471:47;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;471:47:0;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;471:47:0;;;;174:1;149:26;356:168;:::o;77:36::-;;;;:::o;52:20::-;;;;;;;;;;;;;:::o;245:105::-;167:5;;;;;;;;;;;153:19;;:10;:19;;;149:26;;;335:9;308:24;:36;;;;149:26;245:105;:::o", "source": "pragma solidity ^0.5.0;\r\n\r\ncontract Migrations {\r\n address public owner;\r\n uint public last_completed_migration;\r\n\r\n modifier restricted() {\r\n if (msg.sender == owner) _;\r\n }\r\n\r\n constructor() public {\r\n owner = msg.sender;\r\n }\r\n\r\n function setCompleted(uint completed) public restricted {\r\n last_completed_migration = completed;\r\n }\r\n\r\n function upgrade(address new_address) public restricted {\r\n Migrations upgraded = Migrations(new_address);\r\n upgraded.setCompleted(last_completed_migration);\r\n }\r\n}\r\n", - "sourcePath": "C:/FILES/react-truffle/contracts/Migrations.sol", + "sourcePath": "C:/Users/marti/OneDrive/Documenten/GitHub/react-truffle/contracts/Migrations.sol", "ast": { - "absolutePath": "/C/FILES/react-truffle/contracts/Migrations.sol", + "absolutePath": "/C/Users/marti/OneDrive/Documenten/GitHub/react-truffle/contracts/Migrations.sol", "exportedSymbols": { "Migrations": [ - 103 + 56 ] }, - "id": 104, + "id": 57, "nodeType": "SourceUnit", "nodes": [ { - "id": 48, + "id": 1, "literals": [ "solidity", "^", @@ -94,7 +94,7 @@ ".0" ], "nodeType": "PragmaDirective", - "src": "0:23:1" + "src": "0:23:0" }, { "baseContracts": [], @@ -102,20 +102,20 @@ "contractKind": "contract", "documentation": null, "fullyImplemented": true, - "id": 103, + "id": 56, "linearizedBaseContracts": [ - 103 + 56 ], "name": "Migrations", "nodeType": "ContractDefinition", "nodes": [ { "constant": false, - "id": 50, + "id": 3, "name": "owner", "nodeType": "VariableDeclaration", - "scope": 103, - "src": "52:20:1", + "scope": 56, + "src": "52:20:0", "stateVariable": true, "storageLocation": "default", "typeDescriptions": { @@ -123,10 +123,10 @@ "typeString": "address" }, "typeName": { - "id": 49, + "id": 2, "name": "address", "nodeType": "ElementaryTypeName", - "src": "52:7:1", + "src": "52:7:0", "stateMutability": "nonpayable", "typeDescriptions": { "typeIdentifier": "t_address", @@ -138,11 +138,11 @@ }, { "constant": false, - "id": 52, + "id": 5, "name": "last_completed_migration", "nodeType": "VariableDeclaration", - "scope": 103, - "src": "77:36:1", + "scope": 56, + "src": "77:36:0", "stateVariable": true, "storageLocation": "default", "typeDescriptions": { @@ -150,10 +150,10 @@ "typeString": "uint256" }, "typeName": { - "id": 51, + "id": 4, "name": "uint", "nodeType": "ElementaryTypeName", - "src": "77:4:1", + "src": "77:4:0", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" @@ -164,9 +164,9 @@ }, { "body": { - "id": 60, + "id": 13, "nodeType": "Block", - "src": "142:39:1", + "src": "142:39:0", "statements": [ { "condition": { @@ -175,7 +175,7 @@ "typeIdentifier": "t_address", "typeString": "address" }, - "id": 57, + "id": 10, "isConstant": false, "isLValue": false, "isPure": false, @@ -184,18 +184,18 @@ "argumentTypes": null, "expression": { "argumentTypes": null, - "id": 54, + "id": 7, "name": "msg", "nodeType": "Identifier", "overloadedDeclarations": [], - "referencedDeclaration": 141, - "src": "153:3:1", + "referencedDeclaration": 439, + "src": "153:3:0", "typeDescriptions": { "typeIdentifier": "t_magic_message", "typeString": "msg" } }, - "id": 55, + "id": 8, "isConstant": false, "isLValue": false, "isPure": false, @@ -203,7 +203,7 @@ "memberName": "sender", "nodeType": "MemberAccess", "referencedDeclaration": null, - "src": "153:10:1", + "src": "153:10:0", "typeDescriptions": { "typeIdentifier": "t_address_payable", "typeString": "address payable" @@ -213,70 +213,70 @@ "operator": "==", "rightExpression": { "argumentTypes": null, - "id": 56, + "id": 9, "name": "owner", "nodeType": "Identifier", "overloadedDeclarations": [], - "referencedDeclaration": 50, - "src": "167:5:1", + "referencedDeclaration": 3, + "src": "167:5:0", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" } }, - "src": "153:19:1", + "src": "153:19:0", "typeDescriptions": { "typeIdentifier": "t_bool", "typeString": "bool" } }, "falseBody": null, - "id": 59, + "id": 12, "nodeType": "IfStatement", - "src": "149:26:1", + "src": "149:26:0", "trueBody": { - "id": 58, + "id": 11, "nodeType": "PlaceholderStatement", - "src": "174:1:1" + "src": "174:1:0" } } ] }, "documentation": null, - "id": 61, + "id": 14, "name": "restricted", "nodeType": "ModifierDefinition", "parameters": { - "id": 53, + "id": 6, "nodeType": "ParameterList", "parameters": [], - "src": "139:2:1" + "src": "139:2:0" }, - "src": "120:61:1", + "src": "120:61:0", "visibility": "internal" }, { "body": { - "id": 69, + "id": 22, "nodeType": "Block", - "src": "208:31:1", + "src": "208:31:0", "statements": [ { "expression": { "argumentTypes": null, - "id": 67, + "id": 20, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "leftHandSide": { "argumentTypes": null, - "id": 64, + "id": 17, "name": "owner", "nodeType": "Identifier", "overloadedDeclarations": [], - "referencedDeclaration": 50, - "src": "215:5:1", + "referencedDeclaration": 3, + "src": "215:5:0", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" @@ -288,18 +288,18 @@ "argumentTypes": null, "expression": { "argumentTypes": null, - "id": 65, + "id": 18, "name": "msg", "nodeType": "Identifier", "overloadedDeclarations": [], - "referencedDeclaration": 141, - "src": "223:3:1", + "referencedDeclaration": 439, + "src": "223:3:0", "typeDescriptions": { "typeIdentifier": "t_magic_message", "typeString": "msg" } }, - "id": 66, + "id": 19, "isConstant": false, "isLValue": false, "isPure": false, @@ -307,71 +307,71 @@ "memberName": "sender", "nodeType": "MemberAccess", "referencedDeclaration": null, - "src": "223:10:1", + "src": "223:10:0", "typeDescriptions": { "typeIdentifier": "t_address_payable", "typeString": "address payable" } }, - "src": "215:18:1", + "src": "215:18:0", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" } }, - "id": 68, + "id": 21, "nodeType": "ExpressionStatement", - "src": "215:18:1" + "src": "215:18:0" } ] }, "documentation": null, - "id": 70, + "id": 23, "implemented": true, "kind": "constructor", "modifiers": [], "name": "", "nodeType": "FunctionDefinition", "parameters": { - "id": 62, + "id": 15, "nodeType": "ParameterList", "parameters": [], - "src": "198:2:1" + "src": "198:2:0" }, "returnParameters": { - "id": 63, + "id": 16, "nodeType": "ParameterList", "parameters": [], - "src": "208:0:1" + "src": "208:0:0" }, - "scope": 103, - "src": "187:52:1", + "scope": 56, + "src": "187:52:0", "stateMutability": "nonpayable", "superFunction": null, "visibility": "public" }, { "body": { - "id": 81, + "id": 34, "nodeType": "Block", - "src": "301:49:1", + "src": "301:49:0", "statements": [ { "expression": { "argumentTypes": null, - "id": 79, + "id": 32, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "leftHandSide": { "argumentTypes": null, - "id": 77, + "id": 30, "name": "last_completed_migration", "nodeType": "Identifier", "overloadedDeclarations": [], - "referencedDeclaration": 52, - "src": "308:24:1", + "referencedDeclaration": 5, + "src": "308:24:0", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" @@ -381,67 +381,67 @@ "operator": "=", "rightHandSide": { "argumentTypes": null, - "id": 78, + "id": 31, "name": "completed", "nodeType": "Identifier", "overloadedDeclarations": [], - "referencedDeclaration": 72, - "src": "335:9:1", + "referencedDeclaration": 25, + "src": "335:9:0", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, - "src": "308:36:1", + "src": "308:36:0", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, - "id": 80, + "id": 33, "nodeType": "ExpressionStatement", - "src": "308:36:1" + "src": "308:36:0" } ] }, "documentation": null, - "id": 82, + "id": 35, "implemented": true, "kind": "function", "modifiers": [ { "arguments": null, - "id": 75, + "id": 28, "modifierName": { "argumentTypes": null, - "id": 74, + "id": 27, "name": "restricted", "nodeType": "Identifier", "overloadedDeclarations": [], - "referencedDeclaration": 61, - "src": "290:10:1", + "referencedDeclaration": 14, + "src": "290:10:0", "typeDescriptions": { "typeIdentifier": "t_modifier$__$", "typeString": "modifier ()" } }, "nodeType": "ModifierInvocation", - "src": "290:10:1" + "src": "290:10:0" } ], "name": "setCompleted", "nodeType": "FunctionDefinition", "parameters": { - "id": 73, + "id": 26, "nodeType": "ParameterList", "parameters": [ { "constant": false, - "id": 72, + "id": 25, "name": "completed", "nodeType": "VariableDeclaration", - "scope": 82, - "src": "267:14:1", + "scope": 35, + "src": "267:14:0", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { @@ -449,10 +449,10 @@ "typeString": "uint256" }, "typeName": { - "id": 71, + "id": 24, "name": "uint", "nodeType": "ElementaryTypeName", - "src": "267:4:1", + "src": "267:4:0", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" @@ -462,53 +462,53 @@ "visibility": "internal" } ], - "src": "266:16:1" + "src": "266:16:0" }, "returnParameters": { - "id": 76, + "id": 29, "nodeType": "ParameterList", "parameters": [], - "src": "301:0:1" + "src": "301:0:0" }, - "scope": 103, - "src": "245:105:1", + "scope": 56, + "src": "245:105:0", "stateMutability": "nonpayable", "superFunction": null, "visibility": "public" }, { "body": { - "id": 101, + "id": 54, "nodeType": "Block", - "src": "412:112:1", + "src": "412:112:0", "statements": [ { "assignments": [ - 90 + 43 ], "declarations": [ { "constant": false, - "id": 90, + "id": 43, "name": "upgraded", "nodeType": "VariableDeclaration", - "scope": 101, - "src": "419:19:1", + "scope": 54, + "src": "419:19:0", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { - "typeIdentifier": "t_contract$_Migrations_$103", + "typeIdentifier": "t_contract$_Migrations_$56", "typeString": "contract Migrations" }, "typeName": { "contractScope": null, - "id": 89, + "id": 42, "name": "Migrations", "nodeType": "UserDefinedTypeName", - "referencedDeclaration": 103, - "src": "419:10:1", + "referencedDeclaration": 56, + "src": "419:10:0", "typeDescriptions": { - "typeIdentifier": "t_contract$_Migrations_$103", + "typeIdentifier": "t_contract$_Migrations_$56", "typeString": "contract Migrations" } }, @@ -516,18 +516,18 @@ "visibility": "internal" } ], - "id": 94, + "id": 47, "initialValue": { "argumentTypes": null, "arguments": [ { "argumentTypes": null, - "id": 92, + "id": 45, "name": "new_address", "nodeType": "Identifier", "overloadedDeclarations": [], - "referencedDeclaration": 84, - "src": "452:11:1", + "referencedDeclaration": 37, + "src": "452:11:0", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" @@ -541,18 +541,18 @@ "typeString": "address" } ], - "id": 91, + "id": 44, "name": "Migrations", "nodeType": "Identifier", "overloadedDeclarations": [], - "referencedDeclaration": 103, - "src": "441:10:1", + "referencedDeclaration": 56, + "src": "441:10:0", "typeDescriptions": { - "typeIdentifier": "t_type$_t_contract$_Migrations_$103_$", + "typeIdentifier": "t_type$_t_contract$_Migrations_$56_$", "typeString": "type(contract Migrations)" } }, - "id": 93, + "id": 46, "isConstant": false, "isLValue": false, "isPure": false, @@ -560,14 +560,14 @@ "lValueRequested": false, "names": [], "nodeType": "FunctionCall", - "src": "441:23:1", + "src": "441:23:0", "typeDescriptions": { - "typeIdentifier": "t_contract$_Migrations_$103", + "typeIdentifier": "t_contract$_Migrations_$56", "typeString": "contract Migrations" } }, "nodeType": "VariableDeclarationStatement", - "src": "419:45:1" + "src": "419:45:0" }, { "expression": { @@ -575,12 +575,12 @@ "arguments": [ { "argumentTypes": null, - "id": 98, + "id": 51, "name": "last_completed_migration", "nodeType": "Identifier", "overloadedDeclarations": [], - "referencedDeclaration": 52, - "src": "493:24:1", + "referencedDeclaration": 5, + "src": "493:24:0", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" @@ -596,32 +596,32 @@ ], "expression": { "argumentTypes": null, - "id": 95, + "id": 48, "name": "upgraded", "nodeType": "Identifier", "overloadedDeclarations": [], - "referencedDeclaration": 90, - "src": "471:8:1", + "referencedDeclaration": 43, + "src": "471:8:0", "typeDescriptions": { - "typeIdentifier": "t_contract$_Migrations_$103", + "typeIdentifier": "t_contract$_Migrations_$56", "typeString": "contract Migrations" } }, - "id": 97, + "id": 50, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "memberName": "setCompleted", "nodeType": "MemberAccess", - "referencedDeclaration": 82, - "src": "471:21:1", + "referencedDeclaration": 35, + "src": "471:21:0", "typeDescriptions": { "typeIdentifier": "t_function_external_nonpayable$_t_uint256_$returns$__$", "typeString": "function (uint256) external" } }, - "id": 99, + "id": 52, "isConstant": false, "isLValue": false, "isPure": false, @@ -629,56 +629,56 @@ "lValueRequested": false, "names": [], "nodeType": "FunctionCall", - "src": "471:47:1", + "src": "471:47:0", "typeDescriptions": { "typeIdentifier": "t_tuple$__$", "typeString": "tuple()" } }, - "id": 100, + "id": 53, "nodeType": "ExpressionStatement", - "src": "471:47:1" + "src": "471:47:0" } ] }, "documentation": null, - "id": 102, + "id": 55, "implemented": true, "kind": "function", "modifiers": [ { "arguments": null, - "id": 87, + "id": 40, "modifierName": { "argumentTypes": null, - "id": 86, + "id": 39, "name": "restricted", "nodeType": "Identifier", "overloadedDeclarations": [], - "referencedDeclaration": 61, - "src": "401:10:1", + "referencedDeclaration": 14, + "src": "401:10:0", "typeDescriptions": { "typeIdentifier": "t_modifier$__$", "typeString": "modifier ()" } }, "nodeType": "ModifierInvocation", - "src": "401:10:1" + "src": "401:10:0" } ], "name": "upgrade", "nodeType": "FunctionDefinition", "parameters": { - "id": 85, + "id": 38, "nodeType": "ParameterList", "parameters": [ { "constant": false, - "id": 84, + "id": 37, "name": "new_address", "nodeType": "VariableDeclaration", - "scope": 102, - "src": "373:19:1", + "scope": 55, + "src": "373:19:0", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { @@ -686,10 +686,10 @@ "typeString": "address" }, "typeName": { - "id": 83, + "id": 36, "name": "address", "nodeType": "ElementaryTypeName", - "src": "373:7:1", + "src": "373:7:0", "stateMutability": "nonpayable", "typeDescriptions": { "typeIdentifier": "t_address", @@ -700,39 +700,39 @@ "visibility": "internal" } ], - "src": "372:21:1" + "src": "372:21:0" }, "returnParameters": { - "id": 88, + "id": 41, "nodeType": "ParameterList", "parameters": [], - "src": "412:0:1" + "src": "412:0:0" }, - "scope": 103, - "src": "356:168:1", + "scope": 56, + "src": "356:168:0", "stateMutability": "nonpayable", "superFunction": null, "visibility": "public" } ], - "scope": 104, - "src": "27:500:1" + "scope": 57, + "src": "27:500:0" } ], - "src": "0:529:1" + "src": "0:529:0" }, "legacyAST": { - "absolutePath": "/C/FILES/react-truffle/contracts/Migrations.sol", + "absolutePath": "/C/Users/marti/OneDrive/Documenten/GitHub/react-truffle/contracts/Migrations.sol", "exportedSymbols": { "Migrations": [ - 103 + 56 ] }, - "id": 104, + "id": 57, "nodeType": "SourceUnit", "nodes": [ { - "id": 48, + "id": 1, "literals": [ "solidity", "^", @@ -740,7 +740,7 @@ ".0" ], "nodeType": "PragmaDirective", - "src": "0:23:1" + "src": "0:23:0" }, { "baseContracts": [], @@ -748,20 +748,20 @@ "contractKind": "contract", "documentation": null, "fullyImplemented": true, - "id": 103, + "id": 56, "linearizedBaseContracts": [ - 103 + 56 ], "name": "Migrations", "nodeType": "ContractDefinition", "nodes": [ { "constant": false, - "id": 50, + "id": 3, "name": "owner", "nodeType": "VariableDeclaration", - "scope": 103, - "src": "52:20:1", + "scope": 56, + "src": "52:20:0", "stateVariable": true, "storageLocation": "default", "typeDescriptions": { @@ -769,10 +769,10 @@ "typeString": "address" }, "typeName": { - "id": 49, + "id": 2, "name": "address", "nodeType": "ElementaryTypeName", - "src": "52:7:1", + "src": "52:7:0", "stateMutability": "nonpayable", "typeDescriptions": { "typeIdentifier": "t_address", @@ -784,11 +784,11 @@ }, { "constant": false, - "id": 52, + "id": 5, "name": "last_completed_migration", "nodeType": "VariableDeclaration", - "scope": 103, - "src": "77:36:1", + "scope": 56, + "src": "77:36:0", "stateVariable": true, "storageLocation": "default", "typeDescriptions": { @@ -796,10 +796,10 @@ "typeString": "uint256" }, "typeName": { - "id": 51, + "id": 4, "name": "uint", "nodeType": "ElementaryTypeName", - "src": "77:4:1", + "src": "77:4:0", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" @@ -810,9 +810,9 @@ }, { "body": { - "id": 60, + "id": 13, "nodeType": "Block", - "src": "142:39:1", + "src": "142:39:0", "statements": [ { "condition": { @@ -821,7 +821,7 @@ "typeIdentifier": "t_address", "typeString": "address" }, - "id": 57, + "id": 10, "isConstant": false, "isLValue": false, "isPure": false, @@ -830,18 +830,18 @@ "argumentTypes": null, "expression": { "argumentTypes": null, - "id": 54, + "id": 7, "name": "msg", "nodeType": "Identifier", "overloadedDeclarations": [], - "referencedDeclaration": 141, - "src": "153:3:1", + "referencedDeclaration": 439, + "src": "153:3:0", "typeDescriptions": { "typeIdentifier": "t_magic_message", "typeString": "msg" } }, - "id": 55, + "id": 8, "isConstant": false, "isLValue": false, "isPure": false, @@ -849,7 +849,7 @@ "memberName": "sender", "nodeType": "MemberAccess", "referencedDeclaration": null, - "src": "153:10:1", + "src": "153:10:0", "typeDescriptions": { "typeIdentifier": "t_address_payable", "typeString": "address payable" @@ -859,70 +859,70 @@ "operator": "==", "rightExpression": { "argumentTypes": null, - "id": 56, + "id": 9, "name": "owner", "nodeType": "Identifier", "overloadedDeclarations": [], - "referencedDeclaration": 50, - "src": "167:5:1", + "referencedDeclaration": 3, + "src": "167:5:0", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" } }, - "src": "153:19:1", + "src": "153:19:0", "typeDescriptions": { "typeIdentifier": "t_bool", "typeString": "bool" } }, "falseBody": null, - "id": 59, + "id": 12, "nodeType": "IfStatement", - "src": "149:26:1", + "src": "149:26:0", "trueBody": { - "id": 58, + "id": 11, "nodeType": "PlaceholderStatement", - "src": "174:1:1" + "src": "174:1:0" } } ] }, "documentation": null, - "id": 61, + "id": 14, "name": "restricted", "nodeType": "ModifierDefinition", "parameters": { - "id": 53, + "id": 6, "nodeType": "ParameterList", "parameters": [], - "src": "139:2:1" + "src": "139:2:0" }, - "src": "120:61:1", + "src": "120:61:0", "visibility": "internal" }, { "body": { - "id": 69, + "id": 22, "nodeType": "Block", - "src": "208:31:1", + "src": "208:31:0", "statements": [ { "expression": { "argumentTypes": null, - "id": 67, + "id": 20, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "leftHandSide": { "argumentTypes": null, - "id": 64, + "id": 17, "name": "owner", "nodeType": "Identifier", "overloadedDeclarations": [], - "referencedDeclaration": 50, - "src": "215:5:1", + "referencedDeclaration": 3, + "src": "215:5:0", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" @@ -934,18 +934,18 @@ "argumentTypes": null, "expression": { "argumentTypes": null, - "id": 65, + "id": 18, "name": "msg", "nodeType": "Identifier", "overloadedDeclarations": [], - "referencedDeclaration": 141, - "src": "223:3:1", + "referencedDeclaration": 439, + "src": "223:3:0", "typeDescriptions": { "typeIdentifier": "t_magic_message", "typeString": "msg" } }, - "id": 66, + "id": 19, "isConstant": false, "isLValue": false, "isPure": false, @@ -953,71 +953,71 @@ "memberName": "sender", "nodeType": "MemberAccess", "referencedDeclaration": null, - "src": "223:10:1", + "src": "223:10:0", "typeDescriptions": { "typeIdentifier": "t_address_payable", "typeString": "address payable" } }, - "src": "215:18:1", + "src": "215:18:0", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" } }, - "id": 68, + "id": 21, "nodeType": "ExpressionStatement", - "src": "215:18:1" + "src": "215:18:0" } ] }, "documentation": null, - "id": 70, + "id": 23, "implemented": true, "kind": "constructor", "modifiers": [], "name": "", "nodeType": "FunctionDefinition", "parameters": { - "id": 62, + "id": 15, "nodeType": "ParameterList", "parameters": [], - "src": "198:2:1" + "src": "198:2:0" }, "returnParameters": { - "id": 63, + "id": 16, "nodeType": "ParameterList", "parameters": [], - "src": "208:0:1" + "src": "208:0:0" }, - "scope": 103, - "src": "187:52:1", + "scope": 56, + "src": "187:52:0", "stateMutability": "nonpayable", "superFunction": null, "visibility": "public" }, { "body": { - "id": 81, + "id": 34, "nodeType": "Block", - "src": "301:49:1", + "src": "301:49:0", "statements": [ { "expression": { "argumentTypes": null, - "id": 79, + "id": 32, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "leftHandSide": { "argumentTypes": null, - "id": 77, + "id": 30, "name": "last_completed_migration", "nodeType": "Identifier", "overloadedDeclarations": [], - "referencedDeclaration": 52, - "src": "308:24:1", + "referencedDeclaration": 5, + "src": "308:24:0", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" @@ -1027,67 +1027,67 @@ "operator": "=", "rightHandSide": { "argumentTypes": null, - "id": 78, + "id": 31, "name": "completed", "nodeType": "Identifier", "overloadedDeclarations": [], - "referencedDeclaration": 72, - "src": "335:9:1", + "referencedDeclaration": 25, + "src": "335:9:0", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, - "src": "308:36:1", + "src": "308:36:0", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, - "id": 80, + "id": 33, "nodeType": "ExpressionStatement", - "src": "308:36:1" + "src": "308:36:0" } ] }, "documentation": null, - "id": 82, + "id": 35, "implemented": true, "kind": "function", "modifiers": [ { "arguments": null, - "id": 75, + "id": 28, "modifierName": { "argumentTypes": null, - "id": 74, + "id": 27, "name": "restricted", "nodeType": "Identifier", "overloadedDeclarations": [], - "referencedDeclaration": 61, - "src": "290:10:1", + "referencedDeclaration": 14, + "src": "290:10:0", "typeDescriptions": { "typeIdentifier": "t_modifier$__$", "typeString": "modifier ()" } }, "nodeType": "ModifierInvocation", - "src": "290:10:1" + "src": "290:10:0" } ], "name": "setCompleted", "nodeType": "FunctionDefinition", "parameters": { - "id": 73, + "id": 26, "nodeType": "ParameterList", "parameters": [ { "constant": false, - "id": 72, + "id": 25, "name": "completed", "nodeType": "VariableDeclaration", - "scope": 82, - "src": "267:14:1", + "scope": 35, + "src": "267:14:0", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { @@ -1095,10 +1095,10 @@ "typeString": "uint256" }, "typeName": { - "id": 71, + "id": 24, "name": "uint", "nodeType": "ElementaryTypeName", - "src": "267:4:1", + "src": "267:4:0", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" @@ -1108,53 +1108,53 @@ "visibility": "internal" } ], - "src": "266:16:1" + "src": "266:16:0" }, "returnParameters": { - "id": 76, + "id": 29, "nodeType": "ParameterList", "parameters": [], - "src": "301:0:1" + "src": "301:0:0" }, - "scope": 103, - "src": "245:105:1", + "scope": 56, + "src": "245:105:0", "stateMutability": "nonpayable", "superFunction": null, "visibility": "public" }, { "body": { - "id": 101, + "id": 54, "nodeType": "Block", - "src": "412:112:1", + "src": "412:112:0", "statements": [ { "assignments": [ - 90 + 43 ], "declarations": [ { "constant": false, - "id": 90, + "id": 43, "name": "upgraded", "nodeType": "VariableDeclaration", - "scope": 101, - "src": "419:19:1", + "scope": 54, + "src": "419:19:0", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { - "typeIdentifier": "t_contract$_Migrations_$103", + "typeIdentifier": "t_contract$_Migrations_$56", "typeString": "contract Migrations" }, "typeName": { "contractScope": null, - "id": 89, + "id": 42, "name": "Migrations", "nodeType": "UserDefinedTypeName", - "referencedDeclaration": 103, - "src": "419:10:1", + "referencedDeclaration": 56, + "src": "419:10:0", "typeDescriptions": { - "typeIdentifier": "t_contract$_Migrations_$103", + "typeIdentifier": "t_contract$_Migrations_$56", "typeString": "contract Migrations" } }, @@ -1162,18 +1162,18 @@ "visibility": "internal" } ], - "id": 94, + "id": 47, "initialValue": { "argumentTypes": null, "arguments": [ { "argumentTypes": null, - "id": 92, + "id": 45, "name": "new_address", "nodeType": "Identifier", "overloadedDeclarations": [], - "referencedDeclaration": 84, - "src": "452:11:1", + "referencedDeclaration": 37, + "src": "452:11:0", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" @@ -1187,18 +1187,18 @@ "typeString": "address" } ], - "id": 91, + "id": 44, "name": "Migrations", "nodeType": "Identifier", "overloadedDeclarations": [], - "referencedDeclaration": 103, - "src": "441:10:1", + "referencedDeclaration": 56, + "src": "441:10:0", "typeDescriptions": { - "typeIdentifier": "t_type$_t_contract$_Migrations_$103_$", + "typeIdentifier": "t_type$_t_contract$_Migrations_$56_$", "typeString": "type(contract Migrations)" } }, - "id": 93, + "id": 46, "isConstant": false, "isLValue": false, "isPure": false, @@ -1206,14 +1206,14 @@ "lValueRequested": false, "names": [], "nodeType": "FunctionCall", - "src": "441:23:1", + "src": "441:23:0", "typeDescriptions": { - "typeIdentifier": "t_contract$_Migrations_$103", + "typeIdentifier": "t_contract$_Migrations_$56", "typeString": "contract Migrations" } }, "nodeType": "VariableDeclarationStatement", - "src": "419:45:1" + "src": "419:45:0" }, { "expression": { @@ -1221,12 +1221,12 @@ "arguments": [ { "argumentTypes": null, - "id": 98, + "id": 51, "name": "last_completed_migration", "nodeType": "Identifier", "overloadedDeclarations": [], - "referencedDeclaration": 52, - "src": "493:24:1", + "referencedDeclaration": 5, + "src": "493:24:0", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" @@ -1242,32 +1242,32 @@ ], "expression": { "argumentTypes": null, - "id": 95, + "id": 48, "name": "upgraded", "nodeType": "Identifier", "overloadedDeclarations": [], - "referencedDeclaration": 90, - "src": "471:8:1", + "referencedDeclaration": 43, + "src": "471:8:0", "typeDescriptions": { - "typeIdentifier": "t_contract$_Migrations_$103", + "typeIdentifier": "t_contract$_Migrations_$56", "typeString": "contract Migrations" } }, - "id": 97, + "id": 50, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "memberName": "setCompleted", "nodeType": "MemberAccess", - "referencedDeclaration": 82, - "src": "471:21:1", + "referencedDeclaration": 35, + "src": "471:21:0", "typeDescriptions": { "typeIdentifier": "t_function_external_nonpayable$_t_uint256_$returns$__$", "typeString": "function (uint256) external" } }, - "id": 99, + "id": 52, "isConstant": false, "isLValue": false, "isPure": false, @@ -1275,56 +1275,56 @@ "lValueRequested": false, "names": [], "nodeType": "FunctionCall", - "src": "471:47:1", + "src": "471:47:0", "typeDescriptions": { "typeIdentifier": "t_tuple$__$", "typeString": "tuple()" } }, - "id": 100, + "id": 53, "nodeType": "ExpressionStatement", - "src": "471:47:1" + "src": "471:47:0" } ] }, "documentation": null, - "id": 102, + "id": 55, "implemented": true, "kind": "function", "modifiers": [ { "arguments": null, - "id": 87, + "id": 40, "modifierName": { "argumentTypes": null, - "id": 86, + "id": 39, "name": "restricted", "nodeType": "Identifier", "overloadedDeclarations": [], - "referencedDeclaration": 61, - "src": "401:10:1", + "referencedDeclaration": 14, + "src": "401:10:0", "typeDescriptions": { "typeIdentifier": "t_modifier$__$", "typeString": "modifier ()" } }, "nodeType": "ModifierInvocation", - "src": "401:10:1" + "src": "401:10:0" } ], "name": "upgrade", "nodeType": "FunctionDefinition", "parameters": { - "id": 85, + "id": 38, "nodeType": "ParameterList", "parameters": [ { "constant": false, - "id": 84, + "id": 37, "name": "new_address", "nodeType": "VariableDeclaration", - "scope": 102, - "src": "373:19:1", + "scope": 55, + "src": "373:19:0", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { @@ -1332,10 +1332,10 @@ "typeString": "address" }, "typeName": { - "id": 83, + "id": 36, "name": "address", "nodeType": "ElementaryTypeName", - "src": "373:7:1", + "src": "373:7:0", "stateMutability": "nonpayable", "typeDescriptions": { "typeIdentifier": "t_address", @@ -1346,26 +1346,26 @@ "visibility": "internal" } ], - "src": "372:21:1" + "src": "372:21:0" }, "returnParameters": { - "id": 88, + "id": 41, "nodeType": "ParameterList", "parameters": [], - "src": "412:0:1" + "src": "412:0:0" }, - "scope": 103, - "src": "356:168:1", + "scope": 56, + "src": "356:168:0", "stateMutability": "nonpayable", "superFunction": null, "visibility": "public" } ], - "scope": 104, - "src": "27:500:1" + "scope": 57, + "src": "27:500:0" } ], - "src": "0:529:1" + "src": "0:529:0" }, "compiler": { "name": "solc", @@ -1375,12 +1375,12 @@ "5777": { "events": {}, "links": {}, - "address": "0xdac87c5ed955901e20Fd44959d73f1706d9965e8", - "transactionHash": "0x5fc1ba4b4eb4f1678a70839807b6a5ae3ca615dc877850066e892d22b88182a6" + "address": "0x642b536984b2aB7B312041c87F5885C9e2e549c7", + "transactionHash": "0x4cfc1bb1cb113df623db43eae48697c6ee1b6f86091832be5767fb4cd509d367" } }, - "schemaVersion": "3.0.5", - "updatedAt": "2019-05-18T18:56:17.977Z", + "schemaVersion": "3.0.3", + "updatedAt": "2019-05-22T21:36:46.976Z", "devdoc": { "methods": {} }, diff --git a/client/src/contracts/SimpleStorage.json b/client/src/contracts/SimpleStorage.json index d0b219e..3799dfd 100644 --- a/client/src/contracts/SimpleStorage.json +++ b/client/src/contracts/SimpleStorage.json @@ -45,14 +45,14 @@ "signature": "0x6d4ce63c" } ], - "bytecode": "0x608060405234801561001057600080fd5b506101d0806100206000396000f3fe60806040526004361061004c576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806360fe47b1146100515780636d4ce63c1461008c575b600080fd5b34801561005d57600080fd5b5061008a6004803603602081101561007457600080fd5b81019080803590602001909291905050506100b7565b005b34801561009857600080fd5b506100a161019b565b6040518082815260200191505060405180910390f35b806000819055507f9e936044bcfeaf5add073a1edb7c513bd9a94b70e3686d735ca7b26a17fb3dea6040518080602001828103825260718152602001807f687474703a2f2f6170692e6f70656e776561746865726d61702e6f72672f646181526020017f74612f322e352f776561746865723f713d446f726472656368742c6e6c26756e81526020017f6974733d6d65747269632641505049443d35356533643036636665323562353481526020017f656333343965616538383062393864353700000000000000000000000000000081525060800191505060405180910390a150565b6000805490509056fea165627a7a72305820e6804c2585076f0c5ee9ec637a86190b5b2c450139a911e72d4c5d130573fe870029", - "deployedBytecode": "0x60806040526004361061004c576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806360fe47b1146100515780636d4ce63c1461008c575b600080fd5b34801561005d57600080fd5b5061008a6004803603602081101561007457600080fd5b81019080803590602001909291905050506100b7565b005b34801561009857600080fd5b506100a161019b565b6040518082815260200191505060405180910390f35b806000819055507f9e936044bcfeaf5add073a1edb7c513bd9a94b70e3686d735ca7b26a17fb3dea6040518080602001828103825260718152602001807f687474703a2f2f6170692e6f70656e776561746865726d61702e6f72672f646181526020017f74612f322e352f776561746865723f713d446f726472656368742c6e6c26756e81526020017f6974733d6d65747269632641505049443d35356533643036636665323562353481526020017f656333343965616538383062393864353700000000000000000000000000000081525060800191505060405180910390a150565b6000805490509056fea165627a7a72305820e6804c2585076f0c5ee9ec637a86190b5b2c450139a911e72d4c5d130573fe870029", + "bytecode": "0x608060405234801561001057600080fd5b506101d0806100206000396000f3fe60806040526004361061004c576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806360fe47b1146100515780636d4ce63c1461008c575b600080fd5b34801561005d57600080fd5b5061008a6004803603602081101561007457600080fd5b81019080803590602001909291905050506100b7565b005b34801561009857600080fd5b506100a161019b565b6040518082815260200191505060405180910390f35b806000819055507f9e936044bcfeaf5add073a1edb7c513bd9a94b70e3686d735ca7b26a17fb3dea6040518080602001828103825260718152602001807f687474703a2f2f6170692e6f70656e776561746865726d61702e6f72672f646181526020017f74612f322e352f776561746865723f713d446f726472656368742c6e6c26756e81526020017f6974733d6d65747269632641505049443d35356533643036636665323562353481526020017f656333343965616538383062393864353700000000000000000000000000000081525060800191505060405180910390a150565b6000805490509056fea165627a7a7230582082867f80500be5c0f25a058fcb907f70aa5c06ccd3c6036a57e742e553490fbb0029", + "deployedBytecode": "0x60806040526004361061004c576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806360fe47b1146100515780636d4ce63c1461008c575b600080fd5b34801561005d57600080fd5b5061008a6004803603602081101561007457600080fd5b81019080803590602001909291905050506100b7565b005b34801561009857600080fd5b506100a161019b565b6040518082815260200191505060405180910390f35b806000819055507f9e936044bcfeaf5add073a1edb7c513bd9a94b70e3686d735ca7b26a17fb3dea6040518080602001828103825260718152602001807f687474703a2f2f6170692e6f70656e776561746865726d61702e6f72672f646181526020017f74612f322e352f776561746865723f713d446f726472656368742c6e6c26756e81526020017f6974733d6d65747269632641505049443d35356533643036636665323562353481526020017f656333343965616538383062393864353700000000000000000000000000000081525060800191505060405180910390a150565b6000805490509056fea165627a7a7230582082867f80500be5c0f25a058fcb907f70aa5c06ccd3c6036a57e742e553490fbb0029", "sourceMap": "27:378:3:-;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;27:378:3;;;;;;;", "deployedSourceMap": "27:378:3:-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;77:195;;8:9:-1;5:2;;;30:1;27;20:12;5:2;77:195:3;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;77:195:3;;;;;;;;;;;;;;;;;;;;278:72;;8:9:-1;5:2;;;30:1;27;20:12;5:2;278:72:3;;;;;;;;;;;;;;;;;;;;;;;77:195;125:1;112:10;:14;;;;138:128;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;77:195;:::o;278:72::-;314:4;334:10;;327:17;;278:72;:::o", "source": "pragma solidity ^0.5.0;\r\n\r\ncontract SimpleStorage {\r\n uint storedData;\r\n\r\n function set(uint x) public {\r\n storedData = x;\r\n emit HTTPRequest(\"http://api.openweathermap.org/data/2.5/weather?q=Dordrecht,nl&units=metric&APPID=55e3d06cfe25b54ec349eae880b98d57\");\r\n }\r\n\r\n function get() public view returns (uint) {\r\n return storedData;\r\n }\r\n\r\n event HTTPRequest(\r\n string url\r\n );\r\n}\r\n", - "sourcePath": "C:/FILES/react-truffle/contracts/SimpleStorage.sol", + "sourcePath": "C:/Users/marti/OneDrive/Documenten/GitHub/react-truffle/contracts/SimpleStorage.sol", "ast": { - "absolutePath": "/C/FILES/react-truffle/contracts/SimpleStorage.sol", + "absolutePath": "/C/Users/marti/OneDrive/Documenten/GitHub/react-truffle/contracts/SimpleStorage.sol", "exportedSymbols": { "SimpleStorage": [ 217 @@ -405,7 +405,7 @@ "src": "0:407:3" }, "legacyAST": { - "absolutePath": "/C/FILES/react-truffle/contracts/SimpleStorage.sol", + "absolutePath": "/C/Users/marti/OneDrive/Documenten/GitHub/react-truffle/contracts/SimpleStorage.sol", "exportedSymbols": { "SimpleStorage": [ 217 @@ -765,12 +765,12 @@ "5777": { "events": {}, "links": {}, - "address": "0x575b930B9eA228b2a4F3b4F9AD8fa6e9381eEFec", - "transactionHash": "0x00233710b2609240c726eef4e875821a8f4f8f971934a89c2f2e4236e3fe15a0" + "address": "0xE76AdD50161882e6fF553cB299055c7d7675F0E4", + "transactionHash": "0xa6ea3cc2801cad479dd72025360c19295db42d951d5653d2321dc3aed9b16d53" } }, - "schemaVersion": "3.0.5", - "updatedAt": "2019-05-18T18:56:17.976Z", + "schemaVersion": "3.0.3", + "updatedAt": "2019-05-22T21:36:46.975Z", "devdoc": { "methods": {} }, From 5a6fb33cdb6b0b722cd83ba2f66a9883d357cdc3 Mon Sep 17 00:00:00 2001 From: MartijnNieuwenhuis <36473925+MartijnNieuwenhuis@users.noreply.github.com> Date: Fri, 24 May 2019 11:18:11 +0200 Subject: [PATCH 2/3] quotering toegevoegd --- client/src/App.js | 29 ++++++++++++++++++++++++----- client/src/Quotering.js | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+), 5 deletions(-) create mode 100644 client/src/Quotering.js diff --git a/client/src/App.js b/client/src/App.js index 6183967..cba130e 100644 --- a/client/src/App.js +++ b/client/src/App.js @@ -3,11 +3,12 @@ import SimpleStorageContract from "./contracts/SimpleStorage.json"; import getWeb3 from "./utils/getWeb3"; import getWeather from "./Weather"; import getForeCastWeather from "./ForeCastWeather"; +import getQuotering from "./Quotering" import "./App.css"; class App extends Component { - state = { storageValue: 0, web3: null, accounts: null, contract: null, weather: null, forecastWeather: null, date: null }; + state = { storageValue: 0, web3: null, accounts: null, contract: null, weather: null, forecastWeather: null, date: null, Quotering: null, bet: null }; city = "Rotterdam"; componentDidMount = async () => { try { @@ -26,7 +27,8 @@ class App extends Component { const weather = await getWeather(this.city); this.setState({ weather }); this.state.date = weather[0].dt_txt; - this.state.forecastWeather = await getForeCastWeather(this.state.date, this.city) + this.state.forecastWeather = await getForeCastWeather(this.state.date, this.city); + this.state.Quotering = await getQuotering(Math.round(this.state.forecastWeather), this.state.bet, this.state.weather, this.state.date) // Set web3, accounts, and contract to the state, and then proceed with an // example of interacting with the contract's methods. this.setState({ web3, accounts, contract: instance }, this.runExample); @@ -46,6 +48,8 @@ class App extends Component { this.setState({ weather }); const forecastWeather = await getForeCastWeather(this.state.date, this.city); this.setState({ forecastWeather }); + const Quotering = await getQuotering(Math.round(forecastWeather), this.state.bet, weather, this.state.date); + this.setState({ Quotering }); } onChangeDate = async (e) => { @@ -54,6 +58,16 @@ class App extends Component { this.setState({ date }) const forecastWeather = await getForeCastWeather(date, this.city); this.setState({ forecastWeather }); + const Quotering = await getQuotering(Math.round(forecastWeather), this.state.bet, this.state.weather, date); + this.setState({ Quotering }); + } + + onChangeTemperatuur = async (e) => { + let {value} = e.target; + const bet = value; + this.setState({ bet }); + const Quotering = await getQuotering(Math.round(this.state.forecastWeather), bet, this.state.weather, this.state.date); + this.setState({ Quotering }); } runExample = async () => { @@ -105,8 +119,13 @@ class App extends Component { })}
-
- quoteringen + +
+ +
+ +
+ {this.state.Quotering.toFixed(2)}
@@ -117,7 +136,7 @@ class App extends Component {

Verwachte temperatuur op {this.state.date}

{Math.round(this.state.forecastWeather)} C°

in {this.city}

-
; +
diff --git a/client/src/Quotering.js b/client/src/Quotering.js new file mode 100644 index 0000000..fc0cf25 --- /dev/null +++ b/client/src/Quotering.js @@ -0,0 +1,39 @@ +const getQuortering = async (forecast, bet, weather, date) => { + try { + if (bet === null){ + return 1.00; + } + let difference = null; + let spanTimeFactor = 1.00; + let differenceFactor = 1.00; + let quoteringFactor = 1.01; + + if (forecast > bet) { + difference = forecast - bet + } else { + difference = bet - forecast + } + + for (let index = 0; index < weather.length; index++) { + const element = weather[index].dt_txt; + if (element === date) { + if (index !== 0) { + spanTimeFactor = index * Math.pow(1.03, index) / index; + } + console.log(spanTimeFactor); + } + } + if (difference !== 0) { + differenceFactor = difference * Math.pow(1.1, difference) / difference; + return quoteringFactor* differenceFactor * spanTimeFactor ; + } else { + return quoteringFactor * spanTimeFactor; + } + + } catch (error) { + + } + +} + +export default getQuortering; \ No newline at end of file From 5182125dff370bc84d86cd7eec6bcf70d258c7bf Mon Sep 17 00:00:00 2001 From: MartijnNieuwenhuis <36473925+MartijnNieuwenhuis@users.noreply.github.com> Date: Mon, 27 May 2019 09:39:07 +0200 Subject: [PATCH 3/3] previewbets laat quotering nog niet zien bij de previewbets --- client/src/App.css | 17 ++++++++ client/src/App.js | 65 ++++++++++++++++++---------- client/src/{Quotering.js => Odds.js} | 13 +++--- client/src/PreviewBet.js | 24 ++++++++++ client/src/PreviewOdds.js | 28 ++++++++++++ 5 files changed, 117 insertions(+), 30 deletions(-) rename client/src/{Quotering.js => Odds.js} (72%) create mode 100644 client/src/PreviewBet.js create mode 100644 client/src/PreviewOdds.js diff --git a/client/src/App.css b/client/src/App.css index dff9a09..3a4709d 100644 --- a/client/src/App.css +++ b/client/src/App.css @@ -1,3 +1,20 @@ .card { padding: 1em; +} + +.quotering { + border-width: 1px; + width: 150px; + border-style: solid; + text-align: center; + font-size: 14px; +} + +.quotering:hover { + background-color: grey; + cursor: pointer; +} + +.checked { + background-color: grey; } \ No newline at end of file diff --git a/client/src/App.js b/client/src/App.js index cba130e..57863af 100644 --- a/client/src/App.js +++ b/client/src/App.js @@ -3,12 +3,14 @@ import SimpleStorageContract from "./contracts/SimpleStorage.json"; import getWeb3 from "./utils/getWeb3"; import getWeather from "./Weather"; import getForeCastWeather from "./ForeCastWeather"; -import getQuotering from "./Quotering" +import getOdds from "./Odds" +import getPreviewBets from "./PreviewBet" +import getPreviewOdds from "./PreviewOdds.js"; import "./App.css"; class App extends Component { - state = { storageValue: 0, web3: null, accounts: null, contract: null, weather: null, forecastWeather: null, date: null, Quotering: null, bet: null }; + state = { storageValue: 0, web3: null, accounts: null, contract: null, weather: null, forecastWeather: null, date: null, odds: null, bet: null, previewBets: null, previewOdds: null }; city = "Rotterdam"; componentDidMount = async () => { try { @@ -28,10 +30,14 @@ class App extends Component { this.setState({ weather }); this.state.date = weather[0].dt_txt; this.state.forecastWeather = await getForeCastWeather(this.state.date, this.city); - this.state.Quotering = await getQuotering(Math.round(this.state.forecastWeather), this.state.bet, this.state.weather, this.state.date) + this.state.odds = await getOdds(Math.round(this.state.forecastWeather), this.state.bet, this.state.weather, this.state.date) + this.state.previewBets = await getPreviewBets(Math.round(this.state.forecastWeather)); + this.state.previewOdds = await getPreviewOdds(this.state.previewBets, this.state.forecastWeather, this.state.weather, this.state.date); + console.log(this.state.previewOdds); + // Set web3, accounts, and contract to the state, and then proceed with an // example of interacting with the contract's methods. - this.setState({ web3, accounts, contract: instance }, this.runExample); + this.setState({ web3, accounts, contract: instance }); } catch (error) { // Catch any errors for any of the above operations. alert( @@ -48,8 +54,10 @@ class App extends Component { this.setState({ weather }); const forecastWeather = await getForeCastWeather(this.state.date, this.city); this.setState({ forecastWeather }); - const Quotering = await getQuotering(Math.round(forecastWeather), this.state.bet, weather, this.state.date); - this.setState({ Quotering }); + const odds = await getOdds(Math.round(forecastWeather), this.state.bet, weather, this.state.date); + this.setState({ odds }); + const previewBets = await getPreviewBets(Math.round(forecastWeather)); + this.setState({ previewBets }); } onChangeDate = async (e) => { @@ -58,31 +66,22 @@ class App extends Component { this.setState({ date }) const forecastWeather = await getForeCastWeather(date, this.city); this.setState({ forecastWeather }); - const Quotering = await getQuotering(Math.round(forecastWeather), this.state.bet, this.state.weather, date); - this.setState({ Quotering }); + const odds = await getOdds(Math.round(forecastWeather), this.state.bet, this.state.weather, date); + this.setState({ odds }); + const previewBets = await getPreviewBets(Math.round(forecastWeather)); + this.setState({ previewBets }); } onChangeTemperatuur = async (e) => { let {value} = e.target; const bet = value; this.setState({ bet }); - const Quotering = await getQuotering(Math.round(this.state.forecastWeather), bet, this.state.weather, this.state.date); - this.setState({ Quotering }); + const odds = await getOdds(Math.round(this.state.forecastWeather), bet, this.state.weather, this.state.date); + this.setState({ odds }); + const previewBets = await getPreviewBets(Math.round(this.state.forecastWeather)); + this.setState({ previewBets }); } - runExample = async () => { - const { accounts, contract } = this.state; - - // Stores a given value, 5 by default. - await contract.methods.set(5).send({ from: accounts[0], gas: 2000000 }); - - // Get the value from the contract to prove it worked. - const response = await contract.methods.get().call(); - - // Update state with the result. - this.setState({ storageValue: response }); - }; - render() { if (!this.state.web3) { return
Loading Web3, accounts, and contract...
; @@ -125,7 +124,25 @@ class App extends Component {
- {this.state.Quotering.toFixed(2)} + {this.state.odds.toFixed(2)} +
+
+
+ + + + {this.state.previewBets.map((previewBets, index) => { + return + })} + + {this.state.previewOdds.map((previewOdds, index) => { + return + })} + + + +
{previewBets} C°
{previewOdds}
+
diff --git a/client/src/Quotering.js b/client/src/Odds.js similarity index 72% rename from client/src/Quotering.js rename to client/src/Odds.js index fc0cf25..c852fdd 100644 --- a/client/src/Quotering.js +++ b/client/src/Odds.js @@ -1,4 +1,4 @@ -const getQuortering = async (forecast, bet, weather, date) => { +const getOdds = async (forecast, bet, weather, date) => { try { if (bet === null){ return 1.00; @@ -6,7 +6,7 @@ const getQuortering = async (forecast, bet, weather, date) => { let difference = null; let spanTimeFactor = 1.00; let differenceFactor = 1.00; - let quoteringFactor = 1.01; + let oddFactor = 1.01; if (forecast > bet) { difference = forecast - bet @@ -20,14 +20,15 @@ const getQuortering = async (forecast, bet, weather, date) => { if (index !== 0) { spanTimeFactor = index * Math.pow(1.03, index) / index; } - console.log(spanTimeFactor); } } if (difference !== 0) { differenceFactor = difference * Math.pow(1.1, difference) / difference; - return quoteringFactor* differenceFactor * spanTimeFactor ; + const diff = oddFactor * differenceFactor * spanTimeFactor + return diff.toFixed(2); } else { - return quoteringFactor * spanTimeFactor; + const diff = oddFactor * spanTimeFactor + return diff.toFixed(2); } } catch (error) { @@ -36,4 +37,4 @@ const getQuortering = async (forecast, bet, weather, date) => { } -export default getQuortering; \ No newline at end of file +export default getOdds; \ No newline at end of file diff --git a/client/src/PreviewBet.js b/client/src/PreviewBet.js new file mode 100644 index 0000000..a939f31 --- /dev/null +++ b/client/src/PreviewBet.js @@ -0,0 +1,24 @@ +const getPreviewBets = async (forecastWeather) => { + function range(start, end, step = 1) { + if (start > end) { + step = -step; + } + + const length = Math.floor(Math.abs((end - start) / step)) + 1; + + return Array.from(Array(length), (x, index) => start + index * step); + } + + try { + const startTemperature = forecastWeather - 2; + const lastTemperature = forecastWeather + 2; + let previewBets = range(startTemperature, lastTemperature); + + return previewBets; + + } catch (error) { + + } +} + +export default getPreviewBets; \ No newline at end of file diff --git a/client/src/PreviewOdds.js b/client/src/PreviewOdds.js new file mode 100644 index 0000000..bc229f8 --- /dev/null +++ b/client/src/PreviewOdds.js @@ -0,0 +1,28 @@ +import getOdds from "./Odds" + +const getPreviewOdds = async (previewBets, forecastWeather, weather, date) => { + + + try { + let items = []; + if (previewBets != null) { + for (let index = 0; index < previewBets.length; index++) { + const result = await getOdds(forecastWeather, previewBets[index], weather, date); + Promise.all([result]).then(function(values) { + setTimeout(() => { + items.push(Number(values[0])); + }); + + }) + } + } + console.log(items) + + return items; + + } catch (error) { + + } +} + +export default getPreviewOdds; \ No newline at end of file