diff --git a/Lesson2/README.md b/Lesson2/README.md new file mode 100644 index 000000000..1fdc5b30b --- /dev/null +++ b/Lesson2/README.md @@ -0,0 +1,16 @@ +## 硅谷live以太坊智能合约频道官方地址 + +### 第二课《智能合约设计进阶-多员工薪酬系统》 + +目录结构 +
| +
|--orgin 课程初始代码 +
| +
|--assignment 课程作业提交代码 +
+### 本节知识点 +第2课:智能合约设计进阶-多员工薪酬系统 +- 动态静态数组的不同 +- 函数输入参数检查 revert +- 循环与遍历的安全性 +- 程序运行错误检查和容错:assert与require diff --git a/Lesson2/assignment/README.md b/Lesson2/assignment/README.md new file mode 100644 index 000000000..a1fa2d047 --- /dev/null +++ b/Lesson2/assignment/README.md @@ -0,0 +1,10 @@ +## 硅谷live以太坊智能合约 第二课作业 +这里是同学提交作业的目录 + +### 第二课:课后作业 +完成今天的智能合约添加100ETH到合约中 +- 加入十个员工,每个员工的薪水都是1ETH +每次加入一个员工后调用calculateRunway这个函数,并且记录消耗的gas是多少?Gas变化么?如果有 为什么? +- 如何优化calculateRunway这个函数来减少gas的消耗? +提交:智能合约代码,gas变化的记录,calculateRunway函数的优化 + diff --git a/Lesson2/assignment/yours.sol b/Lesson2/assignment/yours.sol new file mode 100644 index 000000000..dfdb2c486 --- /dev/null +++ b/Lesson2/assignment/yours.sol @@ -0,0 +1 @@ +/*作业请提交在这个目录下*/ diff --git a/Lesson2/orgin/README.md b/Lesson2/orgin/README.md new file mode 100644 index 000000000..0309d947c --- /dev/null +++ b/Lesson2/orgin/README.md @@ -0,0 +1,3 @@ +## 硅谷live以太坊智能合约 第二课《智能合约设计进阶-多员工薪酬系统》 + +这里是每一课的初始代码,有需要的同学可以参考 diff --git a/Lesson2/orgin/payroll.sol b/Lesson2/orgin/payroll.sol new file mode 100644 index 000000000..62e380e4c --- /dev/null +++ b/Lesson2/orgin/payroll.sol @@ -0,0 +1,50 @@ +pragma solidity ^0.4.14; + +contract Payroll { + struct Employee { + address id; + uint salary; + uint lastPayday; + } + + uint constant payDuration = 10 seconds; + + address owner; + Employee[] employees; + + function Payroll() { + owner = msg.sender; + } + + function _partialPaid(Employee employee) private { + } + + function _findEmployee(address employeeId) private returns (Employee, uint) { + } + + function addEmployee(address employeeId, uint salary) { + } + + function removeEmployee(address employeeId) { + } + + function updateEmployee(address employeeId, uint salary) { + } + + function addFund() payable returns (uint) { + } + + function calculateRunway() returns (uint) { + uint totalSalary = 0; + for (uint i = 0; i < employees.length; i++) { + totalSalary += employees[i].salary; + } + return this.balance / totalSalary; + } + + function hasEnoughFund() returns (bool) { + } + + function getPaid() { + } +} diff --git a/Lesson3/README.md b/Lesson3/README.md new file mode 100644 index 000000000..ba26ced65 --- /dev/null +++ b/Lesson3/README.md @@ -0,0 +1,16 @@ +## 硅谷live以太坊智能合约频道官方地址 + +### 第三课《智能合约后端优化和产品化》 + +目录结构 +
| +
|--orgin 课程初始代码 +
| +
|--assignment 课程作业提交代码 +
+### 本节知识点 +第3课:智能合约后端优化和产品化 +- 如何通过数据结构优化降低合约执行成本 +- 合约的继承 +- 巧用modifier +- 以太坊函数库的使用和基本介绍 diff --git a/Lesson3/assignment/README.md b/Lesson3/assignment/README.md new file mode 100644 index 000000000..01011eb46 --- /dev/null +++ b/Lesson3/assignment/README.md @@ -0,0 +1,14 @@ +## 硅谷live以太坊智能合约 第三课作业 +这里是同学提交作业的目录 + +### 第三课:课后作业 +- 第一题:完成今天所开发的合约产品化内容,使用Remix调用每一个函数,提交函数调用截图 +- 第二题:增加 changePaymentAddress 函数,更改员工的薪水支付地址,思考一下能否使用modifier整合某个功能 +- 第三题(加分题):自学C3 Linearization, 求以下 contract Z 的继承线 +- contract O +- contract A is O +- contract B is O +- contract C is O +- contract K1 is A, B +- contract K2 is A, C +- contract Z is K1, K2 diff --git a/Lesson3/assignment/shotcut.zip b/Lesson3/assignment/shotcut.zip new file mode 100644 index 000000000..208c43a13 Binary files /dev/null and b/Lesson3/assignment/shotcut.zip differ diff --git a/Lesson3/assignment/yours.sol b/Lesson3/assignment/yours.sol new file mode 100644 index 000000000..c326c1d31 --- /dev/null +++ b/Lesson3/assignment/yours.sol @@ -0,0 +1,94 @@ +/*作业请提交在这个目录下*/ +pragma solidity ^0.4.14; + +contract Payroll { + struct Employee { + address id; + uint salary; + uint lastPayday; + } + + uint constant payDuration = 10 seconds; + uint totalSalary = 0; + + address owner; + mapping (address => Employee) private employees; + + modifier onlyOwner() { + require(owner == msg.sender); + _; + } + + modifier onlySelf(address employeeId) { + require(employeeId == msg.sender); + _; + } + + function Payroll() public{ + owner = msg.sender; + } + + function _partialPaid(Employee employee) private { + uint amount = (now - employee.lastPayday) / payDuration * employee.salary; + employee.id.transfer(amount); + } + + function addEmployee(address employeeId, uint salary) public onlyOwner { + var employee = employees[employeeId]; + assert(employee.id == 0x0); + employees[employeeId] = Employee(employeeId, salary, now); + totalSalary += salary * 1 ether; + } + + function removeEmployee(address employeeId) public onlyOwner { + var employee = employees[employeeId]; + assert(employee.id != 0x0); + _partialPaid(employees[employeeId]); + delete employees[employeeId]; + totalSalary -= employees[employeeId].salary * 1 ether; + } + + function updateEmployee(address employeeId, uint salary) public onlyOwner { + var employee = employees[employeeId]; + assert(employee.id != 0x0); + _partialPaid(employee); + totalSalary -= employees[employeeId].salary; + employees[employeeId].salary = salary * 1 ether; + employees[employeeId].lastPayday = now; + totalSalary += salary * 1 ether; + } + + function addFund() payable public returns (uint) { + return this.balance; + } + + function calculateRunway() public view returns (uint) { + assert(totalSalary > 0); + return this.balance / totalSalary; + } + + function hasEnoughFund() public view returns (bool) { + return calculateRunway() > 0; + } + + function checkEmployee(address employeeId) public view returns (uint salary, uint lastPayday) { + var employee = employees[employeeId]; + salary = employee.salary; + lastPayday = lastPayday; + } + + function getPaid() public { + var employee = employees[msg.sender]; + assert(employee.id != 0x0); + uint nextPayday = employees[msg.sender].lastPayday + payDuration; + assert(nextPayday < now); + employees[msg.sender].lastPayday = nextPayday; + employee.id.transfer(employees[msg.sender].salary); + } + + function changePaymentAddress(address EmployeeId, address newAddress) public onlySelf(EmployeeId){ + var employee = employees[msg.sender]; + assert(employee.id != 0x0); + employees[msg.sender].id = newAddress; + } +} diff --git a/Lesson3/orgin/README.md b/Lesson3/orgin/README.md new file mode 100644 index 000000000..6106ea195 --- /dev/null +++ b/Lesson3/orgin/README.md @@ -0,0 +1,3 @@ +## 硅谷live以太坊智能合约 第三课 + +这里是每一课的初始代码,有需要的同学可以参考 diff --git a/Lesson3/orgin/payroll.sol b/Lesson3/orgin/payroll.sol new file mode 100644 index 000000000..e69de29bb diff --git a/Lesson4/README.md b/Lesson4/README.md new file mode 100644 index 000000000..34bf0bb82 --- /dev/null +++ b/Lesson4/README.md @@ -0,0 +1,16 @@ +## 硅谷live以太坊智能合约频道官方地址 + +### 第四课《使用Truffle架构进行前后端交互,测试,部署》 + +目录结构 +
| +
|--orgin 课程初始代码 +
| +
|--assignment 课程作业提交代码 +
+### 本节知识点 +第4课:使用Truffle架构进行前后端交互,测试,部署 +- 为什么要用Truffle,Truffle的基本概念 +- Truffle 的command line 功能 +- 初始化项目与Truffle项目目录结构 +- 编译部署合约到testrpc diff --git a/Lesson4/assignment/build/contracts/Migrations.json b/Lesson4/assignment/build/contracts/Migrations.json new file mode 100644 index 000000000..56292d3c4 --- /dev/null +++ b/Lesson4/assignment/build/contracts/Migrations.json @@ -0,0 +1,821 @@ +{ + "contractName": "Migrations", + "abi": [ + { + "constant": false, + "inputs": [ + { + "name": "new_address", + "type": "address" + } + ], + "name": "upgrade", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "last_completed_migration", + "outputs": [ + { + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "owner", + "outputs": [ + { + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "name": "completed", + "type": "uint256" + } + ], + "name": "setCompleted", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "constructor" + } + ], + "bytecode": "0x6060604052341561000f57600080fd5b336000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506102db8061005e6000396000f300606060405260043610610062576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680630900f01014610067578063445df0ac146100a05780638da5cb5b146100c9578063fdacd5761461011e575b600080fd5b341561007257600080fd5b61009e600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610141565b005b34156100ab57600080fd5b6100b3610224565b6040518082815260200191505060405180910390f35b34156100d457600080fd5b6100dc61022a565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b341561012957600080fd5b61013f600480803590602001909190505061024f565b005b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415610220578190508073ffffffffffffffffffffffffffffffffffffffff1663fdacd5766001546040518263ffffffff167c010000000000000000000000000000000000000000000000000000000002815260040180828152602001915050600060405180830381600087803b151561020b57600080fd5b6102c65a03f1151561021c57600080fd5b5050505b5050565b60015481565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614156102ac57806001819055505b505600a165627a7a723058208228f4b077cbe40800d0023a70f25c181e7d78b5bffee2592e867a8ee0c5dd110029", + "deployedBytecode": "0x606060405260043610610062576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680630900f01014610067578063445df0ac146100a05780638da5cb5b146100c9578063fdacd5761461011e575b600080fd5b341561007257600080fd5b61009e600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610141565b005b34156100ab57600080fd5b6100b3610224565b6040518082815260200191505060405180910390f35b34156100d457600080fd5b6100dc61022a565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b341561012957600080fd5b61013f600480803590602001909190505061024f565b005b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415610220578190508073ffffffffffffffffffffffffffffffffffffffff1663fdacd5766001546040518263ffffffff167c010000000000000000000000000000000000000000000000000000000002815260040180828152602001915050600060405180830381600087803b151561020b57600080fd5b6102c65a03f1151561021c57600080fd5b5050505b5050565b60015481565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614156102ac57806001819055505b505600a165627a7a723058208228f4b077cbe40800d0023a70f25c181e7d78b5bffee2592e867a8ee0c5dd110029", + "sourceMap": "26:488:0:-;;;178:58;;;;;;;;221:10;213:5;;:18;;;;;;;;;;;;;;;;;;26:488;;;;;;", + "deployedSourceMap": "26:488:0:-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;347:165;;;;;;;;;;;;;;;;;;;;;;;;;;;;74:36;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;50:20;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;240:103;;;;;;;;;;;;;;;;;;;;;;;;;;347:165;409:19;161:5;;;;;;;;;;;147:19;;:10;:19;;;143:26;;;442:11;409:45;;460:8;:21;;;482:24;;460:47;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;143:26;347:165;;:::o;74:36::-;;;;:::o;50:20::-;;;;;;;;;;;;;:::o;240:103::-;161:5;;;;;;;;;;;147:19;;:10;:19;;;143:26;;;329:9;302:24;:36;;;;143:26;240:103;:::o", + "source": "pragma solidity ^0.4.17;\n\ncontract Migrations {\n address public owner;\n uint public last_completed_migration;\n\n modifier restricted() {\n if (msg.sender == owner) _;\n }\n\n function Migrations() public {\n owner = msg.sender;\n }\n\n function setCompleted(uint completed) public restricted {\n last_completed_migration = completed;\n }\n\n function upgrade(address new_address) public restricted {\n Migrations upgraded = Migrations(new_address);\n upgraded.setCompleted(last_completed_migration);\n }\n}\n", + "sourcePath": "/Users/lichenxi/github/guigulive-operation/Lesson4/assignment/contracts/Migrations.sol", + "ast": { + "attributes": { + "absolutePath": "/Users/lichenxi/github/guigulive-operation/Lesson4/assignment/contracts/Migrations.sol", + "exportedSymbols": { + "Migrations": [ + 56 + ] + } + }, + "children": [ + { + "attributes": { + "literals": [ + "solidity", + "^", + "0.4", + ".17" + ] + }, + "id": 1, + "name": "PragmaDirective", + "src": "0:24:0" + }, + { + "attributes": { + "baseContracts": [ + null + ], + "contractDependencies": [ + null + ], + "contractKind": "contract", + "documentation": null, + "fullyImplemented": true, + "linearizedBaseContracts": [ + 56 + ], + "name": "Migrations", + "scope": 57 + }, + "children": [ + { + "attributes": { + "constant": false, + "name": "owner", + "scope": 56, + "stateVariable": true, + "storageLocation": "default", + "type": "address", + "value": null, + "visibility": "public" + }, + "children": [ + { + "attributes": { + "name": "address", + "type": "address" + }, + "id": 2, + "name": "ElementaryTypeName", + "src": "50:7:0" + } + ], + "id": 3, + "name": "VariableDeclaration", + "src": "50:20:0" + }, + { + "attributes": { + "constant": false, + "name": "last_completed_migration", + "scope": 56, + "stateVariable": true, + "storageLocation": "default", + "type": "uint256", + "value": null, + "visibility": "public" + }, + "children": [ + { + "attributes": { + "name": "uint", + "type": "uint256" + }, + "id": 4, + "name": "ElementaryTypeName", + "src": "74:4:0" + } + ], + "id": 5, + "name": "VariableDeclaration", + "src": "74:36:0" + }, + { + "attributes": { + "name": "restricted", + "visibility": "internal" + }, + "children": [ + { + "attributes": { + "parameters": [ + null + ] + }, + "children": [], + "id": 6, + "name": "ParameterList", + "src": "134:2:0" + }, + { + "children": [ + { + "attributes": { + "falseBody": null + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_address", + "typeString": "address" + }, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "operator": "==", + "type": "bool" + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "member_name": "sender", + "referencedDeclaration": null, + "type": "address" + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 429, + "type": "msg", + "value": "msg" + }, + "id": 7, + "name": "Identifier", + "src": "147:3:0" + } + ], + "id": 8, + "name": "MemberAccess", + "src": "147:10:0" + }, + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 3, + "type": "address", + "value": "owner" + }, + "id": 9, + "name": "Identifier", + "src": "161:5:0" + } + ], + "id": 10, + "name": "BinaryOperation", + "src": "147:19:0" + }, + { + "id": 11, + "name": "PlaceholderStatement", + "src": "168:1:0" + } + ], + "id": 12, + "name": "IfStatement", + "src": "143:26:0" + } + ], + "id": 13, + "name": "Block", + "src": "137:37:0" + } + ], + "id": 14, + "name": "ModifierDefinition", + "src": "115:59:0" + }, + { + "attributes": { + "constant": false, + "implemented": true, + "isConstructor": true, + "modifiers": [ + null + ], + "name": "Migrations", + "payable": false, + "scope": 56, + "stateMutability": "nonpayable", + "superFunction": null, + "visibility": "public" + }, + "children": [ + { + "attributes": { + "parameters": [ + null + ] + }, + "children": [], + "id": 15, + "name": "ParameterList", + "src": "197:2:0" + }, + { + "attributes": { + "parameters": [ + null + ] + }, + "children": [], + "id": 16, + "name": "ParameterList", + "src": "207:0:0" + }, + { + "children": [ + { + "children": [ + { + "attributes": { + "argumentTypes": null, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "operator": "=", + "type": "address" + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 3, + "type": "address", + "value": "owner" + }, + "id": 17, + "name": "Identifier", + "src": "213:5: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": 429, + "type": "msg", + "value": "msg" + }, + "id": 18, + "name": "Identifier", + "src": "221:3:0" + } + ], + "id": 19, + "name": "MemberAccess", + "src": "221:10:0" + } + ], + "id": 20, + "name": "Assignment", + "src": "213:18:0" + } + ], + "id": 21, + "name": "ExpressionStatement", + "src": "213:18:0" + } + ], + "id": 22, + "name": "Block", + "src": "207:29:0" + } + ], + "id": 23, + "name": "FunctionDefinition", + "src": "178:58:0" + }, + { + "attributes": { + "constant": false, + "implemented": true, + "isConstructor": false, + "name": "setCompleted", + "payable": false, + "scope": 56, + "stateMutability": "nonpayable", + "superFunction": null, + "visibility": "public" + }, + "children": [ + { + "children": [ + { + "attributes": { + "constant": false, + "name": "completed", + "scope": 35, + "stateVariable": false, + "storageLocation": "default", + "type": "uint256", + "value": null, + "visibility": "internal" + }, + "children": [ + { + "attributes": { + "name": "uint", + "type": "uint256" + }, + "id": 24, + "name": "ElementaryTypeName", + "src": "262:4:0" + } + ], + "id": 25, + "name": "VariableDeclaration", + "src": "262:14:0" + } + ], + "id": 26, + "name": "ParameterList", + "src": "261:16:0" + }, + { + "attributes": { + "parameters": [ + null + ] + }, + "children": [], + "id": 29, + "name": "ParameterList", + "src": "296:0:0" + }, + { + "attributes": { + "arguments": [ + null + ] + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 14, + "type": "modifier ()", + "value": "restricted" + }, + "id": 27, + "name": "Identifier", + "src": "285:10:0" + } + ], + "id": 28, + "name": "ModifierInvocation", + "src": "285:10:0" + }, + { + "children": [ + { + "children": [ + { + "attributes": { + "argumentTypes": null, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "operator": "=", + "type": "uint256" + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 5, + "type": "uint256", + "value": "last_completed_migration" + }, + "id": 30, + "name": "Identifier", + "src": "302:24:0" + }, + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 25, + "type": "uint256", + "value": "completed" + }, + "id": 31, + "name": "Identifier", + "src": "329:9:0" + } + ], + "id": 32, + "name": "Assignment", + "src": "302:36:0" + } + ], + "id": 33, + "name": "ExpressionStatement", + "src": "302:36:0" + } + ], + "id": 34, + "name": "Block", + "src": "296:47:0" + } + ], + "id": 35, + "name": "FunctionDefinition", + "src": "240:103:0" + }, + { + "attributes": { + "constant": false, + "implemented": true, + "isConstructor": false, + "name": "upgrade", + "payable": false, + "scope": 56, + "stateMutability": "nonpayable", + "superFunction": null, + "visibility": "public" + }, + "children": [ + { + "children": [ + { + "attributes": { + "constant": false, + "name": "new_address", + "scope": 55, + "stateVariable": false, + "storageLocation": "default", + "type": "address", + "value": null, + "visibility": "internal" + }, + "children": [ + { + "attributes": { + "name": "address", + "type": "address" + }, + "id": 36, + "name": "ElementaryTypeName", + "src": "364:7:0" + } + ], + "id": 37, + "name": "VariableDeclaration", + "src": "364:19:0" + } + ], + "id": 38, + "name": "ParameterList", + "src": "363:21:0" + }, + { + "attributes": { + "parameters": [ + null + ] + }, + "children": [], + "id": 41, + "name": "ParameterList", + "src": "403:0:0" + }, + { + "attributes": { + "arguments": [ + null + ] + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 14, + "type": "modifier ()", + "value": "restricted" + }, + "id": 39, + "name": "Identifier", + "src": "392:10:0" + } + ], + "id": 40, + "name": "ModifierInvocation", + "src": "392:10:0" + }, + { + "children": [ + { + "attributes": { + "assignments": [ + 43 + ] + }, + "children": [ + { + "attributes": { + "constant": false, + "name": "upgraded", + "scope": 55, + "stateVariable": false, + "storageLocation": "default", + "type": "contract Migrations", + "value": null, + "visibility": "internal" + }, + "children": [ + { + "attributes": { + "contractScope": null, + "name": "Migrations", + "referencedDeclaration": 56, + "type": "contract Migrations" + }, + "id": 42, + "name": "UserDefinedTypeName", + "src": "409:10:0" + } + ], + "id": 43, + "name": "VariableDeclaration", + "src": "409:19:0" + }, + { + "attributes": { + "argumentTypes": null, + "isConstant": false, + "isLValue": false, + "isPure": false, + "isStructConstructorCall": false, + "lValueRequested": false, + "names": [ + null + ], + "type": "contract Migrations", + "type_conversion": true + }, + "children": [ + { + "attributes": { + "argumentTypes": [ + { + "typeIdentifier": "t_address", + "typeString": "address" + } + ], + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 56, + "type": "type(contract Migrations)", + "value": "Migrations" + }, + "id": 44, + "name": "Identifier", + "src": "431:10:0" + }, + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 37, + "type": "address", + "value": "new_address" + }, + "id": 45, + "name": "Identifier", + "src": "442:11:0" + } + ], + "id": 46, + "name": "FunctionCall", + "src": "431:23:0" + } + ], + "id": 47, + "name": "VariableDeclarationStatement", + "src": "409:45: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_uint256", + "typeString": "uint256" + } + ], + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "member_name": "setCompleted", + "referencedDeclaration": 35, + "type": "function (uint256) external" + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 43, + "type": "contract Migrations", + "value": "upgraded" + }, + "id": 48, + "name": "Identifier", + "src": "460:8:0" + } + ], + "id": 50, + "name": "MemberAccess", + "src": "460:21:0" + }, + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 5, + "type": "uint256", + "value": "last_completed_migration" + }, + "id": 51, + "name": "Identifier", + "src": "482:24:0" + } + ], + "id": 52, + "name": "FunctionCall", + "src": "460:47:0" + } + ], + "id": 53, + "name": "ExpressionStatement", + "src": "460:47:0" + } + ], + "id": 54, + "name": "Block", + "src": "403:109:0" + } + ], + "id": 55, + "name": "FunctionDefinition", + "src": "347:165:0" + } + ], + "id": 56, + "name": "ContractDefinition", + "src": "26:488:0" + } + ], + "id": 57, + "name": "SourceUnit", + "src": "0:515:0" + }, + "compiler": { + "name": "solc", + "version": "0.4.18+commit.9cf6e910.Emscripten.clang" + }, + "networks": {}, + "schemaVersion": "1.0.1", + "updatedAt": "2018-01-29T01:03:36.159Z" +} \ No newline at end of file diff --git a/Lesson4/assignment/build/contracts/Payroll.json b/Lesson4/assignment/build/contracts/Payroll.json new file mode 100644 index 000000000..59d68360c --- /dev/null +++ b/Lesson4/assignment/build/contracts/Payroll.json @@ -0,0 +1,5211 @@ +{ + "contractName": "Payroll", + "abi": [ + { + "constant": true, + "inputs": [], + "name": "hasEnoughFund", + "outputs": [ + { + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "calculateRunway", + "outputs": [ + { + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "name": "employeeId", + "type": "address" + }, + { + "name": "salary", + "type": "uint256" + } + ], + "name": "updateEmployee", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "name": "employeeId", + "type": "address" + } + ], + "name": "checkEmployee", + "outputs": [ + { + "name": "salary", + "type": "uint256" + }, + { + "name": "lastPayday", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [], + "name": "addFund", + "outputs": [ + { + "name": "", + "type": "uint256" + } + ], + "payable": true, + "stateMutability": "payable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "name": "EmployeeId", + "type": "address" + }, + { + "name": "newAddress", + "type": "address" + } + ], + "name": "changePaymentAddress", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [], + "name": "getPaid", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "name": "employeeId", + "type": "address" + } + ], + "name": "removeEmployee", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "name": "employeeId", + "type": "address" + }, + { + "name": "salary", + "type": "uint256" + } + ], + "name": "addEmployee", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "constructor" + } + ], + "bytecode": "0x606060405260008055341561001357600080fd5b33600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550610db4806100636000396000f300606060405260043610610099576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806323fed09e1461009e5780634ec19512146100cb5780635e91d8ec146100f45780637cf562b714610136578063a2f09dfa1461018a578063bc456c42146101a8578063cf41d6f814610200578063d108177a14610215578063e7fd9a131461024e575b600080fd5b34156100a957600080fd5b6100b1610290565b604051808215151515815260200191505060405180910390f35b34156100d657600080fd5b6100de6102a1565b6040518082815260200191505060405180910390f35b34156100ff57600080fd5b610134600480803573ffffffffffffffffffffffffffffffffffffffff169060200190919080359060200190919050506102da565b005b341561014157600080fd5b61016d600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610546565b604051808381526020018281526020019250505060405180910390f35b61019261059c565b6040518082815260200191505060405180910390f35b34156101b357600080fd5b6101fe600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff169060200190919050506105bb565b005b341561020b57600080fd5b610213610707565b005b341561022057600080fd5b61024c600480803573ffffffffffffffffffffffffffffffffffffffff169060200190919050506108d6565b005b341561025957600080fd5b61028e600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050610b51565b005b60008061029b6102a1565b11905090565b6000806000541115156102b057fe5b6000543073ffffffffffffffffffffffffffffffffffffffff16318115156102d457fe5b04905090565b60003373ffffffffffffffffffffffffffffffffffffffff16600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614151561033857600080fd5b600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020905060008160000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16141515156103c057fe5b61043f81606060405190810160405290816000820160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200160018201548152602001600282015481525050610d23565b600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600101546000808282540392505081905550670de0b6b3a76400008202600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206001018190555042600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060020181905550670de0b6b3a764000082026000808282540192505081905550505050565b6000806000600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002090508060010154925081915050915091565b60003073ffffffffffffffffffffffffffffffffffffffff1631905090565b6000823373ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415156105f857600080fd5b600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020915060008260000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161415151561068057fe5b82600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050505050565b600080600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020915060008260000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161415151561079257fe5b600a600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206002015401905042811015156107e557fe5b80600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600201819055508160000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600101549081150290604051600060405180830381858888f1935050505015156108d257600080fd5b5050565b60003373ffffffffffffffffffffffffffffffffffffffff16600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614151561093457600080fd5b600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020905060008160000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16141515156109bc57fe5b610a79600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020606060405190810160405290816000820160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200160018201548152602001600282015481525050610d23565b600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600080820160006101000a81549073ffffffffffffffffffffffffffffffffffffffff0219169055600182016000905560028201600090555050670de0b6b3a7640000600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600101540260008082825403925050819055505050565b60003373ffffffffffffffffffffffffffffffffffffffff16600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16141515610baf57600080fd5b600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020905060008160000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16141515610c3657fe5b6060604051908101604052808473ffffffffffffffffffffffffffffffffffffffff16815260200183815260200142815250600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008201518160000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506020820151816001015560408201518160020155905050670de0b6b3a764000082026000808282540192505081905550505050565b60008160200151600a83604001514203811515610d3c57fe5b04029050816000015173ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f193505050501515610d8457600080fd5b50505600a165627a7a72305820d03d9faa194544e3c12bf1a629823d30f73438e2ab90cced2b66f3aabaa205860029", + "deployedBytecode": "0x606060405260043610610099576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806323fed09e1461009e5780634ec19512146100cb5780635e91d8ec146100f45780637cf562b714610136578063a2f09dfa1461018a578063bc456c42146101a8578063cf41d6f814610200578063d108177a14610215578063e7fd9a131461024e575b600080fd5b34156100a957600080fd5b6100b1610290565b604051808215151515815260200191505060405180910390f35b34156100d657600080fd5b6100de6102a1565b6040518082815260200191505060405180910390f35b34156100ff57600080fd5b610134600480803573ffffffffffffffffffffffffffffffffffffffff169060200190919080359060200190919050506102da565b005b341561014157600080fd5b61016d600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610546565b604051808381526020018281526020019250505060405180910390f35b61019261059c565b6040518082815260200191505060405180910390f35b34156101b357600080fd5b6101fe600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff169060200190919050506105bb565b005b341561020b57600080fd5b610213610707565b005b341561022057600080fd5b61024c600480803573ffffffffffffffffffffffffffffffffffffffff169060200190919050506108d6565b005b341561025957600080fd5b61028e600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050610b51565b005b60008061029b6102a1565b11905090565b6000806000541115156102b057fe5b6000543073ffffffffffffffffffffffffffffffffffffffff16318115156102d457fe5b04905090565b60003373ffffffffffffffffffffffffffffffffffffffff16600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614151561033857600080fd5b600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020905060008160000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16141515156103c057fe5b61043f81606060405190810160405290816000820160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200160018201548152602001600282015481525050610d23565b600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600101546000808282540392505081905550670de0b6b3a76400008202600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206001018190555042600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060020181905550670de0b6b3a764000082026000808282540192505081905550505050565b6000806000600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002090508060010154925081915050915091565b60003073ffffffffffffffffffffffffffffffffffffffff1631905090565b6000823373ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415156105f857600080fd5b600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020915060008260000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161415151561068057fe5b82600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050505050565b600080600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020915060008260000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161415151561079257fe5b600a600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206002015401905042811015156107e557fe5b80600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600201819055508160000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600101549081150290604051600060405180830381858888f1935050505015156108d257600080fd5b5050565b60003373ffffffffffffffffffffffffffffffffffffffff16600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614151561093457600080fd5b600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020905060008160000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16141515156109bc57fe5b610a79600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020606060405190810160405290816000820160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200160018201548152602001600282015481525050610d23565b600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600080820160006101000a81549073ffffffffffffffffffffffffffffffffffffffff0219169055600182016000905560028201600090555050670de0b6b3a7640000600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600101540260008082825403925050819055505050565b60003373ffffffffffffffffffffffffffffffffffffffff16600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16141515610baf57600080fd5b600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020905060008160000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16141515610c3657fe5b6060604051908101604052808473ffffffffffffffffffffffffffffffffffffffff16815260200183815260200142815250600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008201518160000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506020820151816001015560408201518160020155905050670de0b6b3a764000082026000808282540192505081905550505050565b60008160200151600a83604001514203811515610d3c57fe5b04029050816000015173ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f193505050501515610d8457600080fd5b50505600a165627a7a72305820d03d9faa194544e3c12bf1a629823d30f73438e2ab90cced2b66f3aabaa205860029", + "sourceMap": "64:2801:1:-;;;249:1;230:20;;522:60;;;;;;;;565:10;557:5;;:18;;;;;;;;;;;;;;;;;;64:2801;;;;;;", + "deployedSourceMap": "64:2801:1:-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;1971:95;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;1824:137;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;1341:380;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2076:214;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;1731:83;;;;;;;;;;;;;;;;;;;;;;;2636:227;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2300:326;;;;;;;;;;;;;;1045:286;;;;;;;;;;;;;;;;;;;;;;;;;;;;775:260;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;1971:95;2017:4;2058:1;2038:17;:15;:17::i;:::-;:21;2031:28;;1971:95;:::o;1824:137::-;1872:4;1909:1;1895:11;;:15;1888:23;;;;;;1943:11;;1928:4;:12;;;:26;;;;;;;;1921:33;;1824:137;:::o;1341:380::-;1423:12;378:10;369:19;;:5;;;;;;;;;;;:19;;;361:28;;;;;;;;1438:9;:21;1448:10;1438:21;;;;;;;;;;;;;;;1423:36;;1489:3;1474:8;:11;;;;;;;;;;;;:18;;;;1467:26;;;;;;1501:22;1514:8;1501:22;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:12;:22::i;:::-;1546:9;:21;1556:10;1546:21;;;;;;;;;;;;;;;:28;;;1531:11;;:43;;;;;;;;;;;1622:7;1613:6;:16;1582:9;:21;1592:10;1582:21;;;;;;;;;;;;;;;:28;;:47;;;;1672:3;1637:9;:21;1647:10;1637:21;;;;;;;;;;;;;;;:32;;:38;;;;1707:7;1698:6;:16;1683:11;;:31;;;;;;;;;;;1341:380;;;:::o;2076:214::-;2140:11;2153:15;2180:12;2195:9;:21;2205:10;2195:21;;;;;;;;;;;;;;;2180:36;;2235:8;:15;;;2226:24;;2273:10;2260:23;;2076:214;;;;:::o;1731:83::-;1774:4;1795;:12;;;1788:19;;1731:83;:::o;2636:227::-;2741:12;2722:10;487;473:24;;:10;:24;;;465:33;;;;;;;;2756:9;:21;2766:10;2756:21;;;;;;;;;;;;;;;2741:36;;2807:3;2792:8;:11;;;;;;;;;;;;:18;;;;2785:26;;;;;;2846:10;2819:9;:21;2829:10;2819:21;;;;;;;;;;;;;;;:24;;;:37;;;;;;;;;;;;;;;;;;2636:227;;;;:::o;2300:326::-;2334:12;2412:15;2349:9;:21;2359:10;2349:21;;;;;;;;;;;;;;;2334:36;;2400:3;2385:8;:11;;;;;;;;;;;;:18;;;;2378:26;;;;;;214:10;2430:9;:21;2440:10;2430:21;;;;;;;;;;;;;;;:32;;;:46;2412:64;;2504:3;2491:10;:16;2484:24;;;;;;2551:10;2516:9;:21;2526:10;2516:21;;;;;;;;;;;;;;;:32;;:45;;;;2569:8;:11;;;;;;;;;;;;:20;;:50;2590:9;:21;2600:10;2590:21;;;;;;;;;;;;;;;:28;;;2569:50;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2300:326;;:::o;1045:286::-;1114:12;378:10;369:19;;:5;;;;;;;;;;;:19;;;361:28;;;;;;;;1129:9;:21;1139:10;1129:21;;;;;;;;;;;;;;;1114:36;;1180:3;1165:8;:11;;;;;;;;;;;;:18;;;;1158:26;;;;;;1192:35;1205:9;:21;1215:10;1205:21;;;;;;;;;;;;;;;1192:35;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:12;:35::i;:::-;1242:9;:21;1252:10;1242:21;;;;;;;;;;;;;;;;1235:28;;;;;;;;;;;;;;;;;;;;;;;;;;;;;1317:7;1286:9;:21;1296:10;1286:21;;;;;;;;;;;;;;;:28;;;:38;1271:11;;:53;;;;;;;;;;;1045:286;;:::o;775:260::-;854:12;378:10;369:19;;:5;;;;;;;;;;;:19;;;361:28;;;;;;;;869:9;:21;879:10;869:21;;;;;;;;;;;;;;;854:36;;920:3;905:8;:11;;;;;;;;;;;;:18;;;898:26;;;;;;956:33;;;;;;;;;965:10;956:33;;;;;;977:6;956:33;;;;985:3;956:33;;;932:9;:21;942:10;932:21;;;;;;;;;;;;;;;:57;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;1021:7;1012:6;:16;997:11;;:31;;;;;;;;;;;775:260;;;:::o;592:173::-;649:11;707:8;:15;;;214:10;670:8;:19;;;664:3;:25;663:41;;;;;;;;:59;649:73;;730:8;:11;;;:20;;:28;751:6;730:28;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;592:173;;:::o", + "source": "/*作业请提交在这个目录下*/\npragma solidity ^0.4.14;\n\ncontract Payroll {\n struct Employee {\n address id;\n uint salary;\n uint lastPayday;\n }\n \n uint constant payDuration = 10 seconds;\n uint totalSalary = 0;\n\n address owner;\n mapping (address => Employee) private employees;\n\n modifier onlyOwner() {\n require(owner == msg.sender);\n _;\n }\n \n modifier onlySelf(address employeeId) {\n require(employeeId == msg.sender);\n _;\n }\n\n function Payroll() public{\n owner = msg.sender;\n }\n \n function _partialPaid(Employee employee) private {\n uint amount = (now - employee.lastPayday) / payDuration * employee.salary;\n employee.id.transfer(amount);\n }\n \n function addEmployee(address employeeId, uint salary) public onlyOwner {\n var employee = employees[employeeId];\n assert(employee.id == 0x0);\n employees[employeeId] = Employee(employeeId, salary, now);\n totalSalary += salary * 1 ether;\n }\n \n function removeEmployee(address employeeId) public onlyOwner {\n var employee = employees[employeeId];\n assert(employee.id != 0x0);\n _partialPaid(employees[employeeId]);\n delete employees[employeeId];\n totalSalary -= employees[employeeId].salary * 1 ether;\n }\n \n function updateEmployee(address employeeId, uint salary) public onlyOwner {\n var employee = employees[employeeId];\n assert(employee.id != 0x0);\n _partialPaid(employee);\n totalSalary -= employees[employeeId].salary;\n employees[employeeId].salary = salary * 1 ether;\n employees[employeeId].lastPayday = now;\n totalSalary += salary * 1 ether;\n }\n \n function addFund() payable public returns (uint) {\n return this.balance;\n }\n \n function calculateRunway() public view returns (uint) {\n assert(totalSalary > 0);\n return this.balance / totalSalary;\n }\n \n function hasEnoughFund() public view returns (bool) {\n return calculateRunway() > 0;\n }\n \n function checkEmployee(address employeeId) public view returns (uint salary, uint lastPayday) {\n var employee = employees[employeeId];\n salary = employee.salary;\n lastPayday = lastPayday;\n }\n \n function getPaid() public {\n var employee = employees[msg.sender];\n assert(employee.id != 0x0);\n uint nextPayday = employees[msg.sender].lastPayday + payDuration;\n assert(nextPayday < now);\n employees[msg.sender].lastPayday = nextPayday;\n employee.id.transfer(employees[msg.sender].salary);\n }\n \n function changePaymentAddress(address EmployeeId, address newAddress) public onlySelf(EmployeeId){\n var employee = employees[msg.sender];\n assert(employee.id != 0x0);\n employees[msg.sender].id = newAddress;\n }\n}\n", + "sourcePath": "/Users/lichenxi/github/guigulive-operation/Lesson4/assignment/contracts/Payroll.sol", + "ast": { + "attributes": { + "absolutePath": "/Users/lichenxi/github/guigulive-operation/Lesson4/assignment/contracts/Payroll.sol", + "exportedSymbols": { + "Payroll": [ + 417 + ] + } + }, + "children": [ + { + "attributes": { + "literals": [ + "solidity", + "^", + "0.4", + ".14" + ] + }, + "id": 58, + "name": "PragmaDirective", + "src": "38:24:1" + }, + { + "attributes": { + "baseContracts": [ + null + ], + "contractDependencies": [ + null + ], + "contractKind": "contract", + "documentation": null, + "fullyImplemented": true, + "linearizedBaseContracts": [ + 417 + ], + "name": "Payroll", + "scope": 418 + }, + "children": [ + { + "attributes": { + "canonicalName": "Payroll.Employee", + "name": "Employee", + "scope": 417, + "visibility": "public" + }, + "children": [ + { + "attributes": { + "constant": false, + "name": "id", + "scope": 65, + "stateVariable": false, + "storageLocation": "default", + "type": "address", + "value": null, + "visibility": "internal" + }, + "children": [ + { + "attributes": { + "name": "address", + "type": "address" + }, + "id": 59, + "name": "ElementaryTypeName", + "src": "113:7:1" + } + ], + "id": 60, + "name": "VariableDeclaration", + "src": "113:10:1" + }, + { + "attributes": { + "constant": false, + "name": "salary", + "scope": 65, + "stateVariable": false, + "storageLocation": "default", + "type": "uint256", + "value": null, + "visibility": "internal" + }, + "children": [ + { + "attributes": { + "name": "uint", + "type": "uint256" + }, + "id": 61, + "name": "ElementaryTypeName", + "src": "133:4:1" + } + ], + "id": 62, + "name": "VariableDeclaration", + "src": "133:11:1" + }, + { + "attributes": { + "constant": false, + "name": "lastPayday", + "scope": 65, + "stateVariable": false, + "storageLocation": "default", + "type": "uint256", + "value": null, + "visibility": "internal" + }, + "children": [ + { + "attributes": { + "name": "uint", + "type": "uint256" + }, + "id": 63, + "name": "ElementaryTypeName", + "src": "154:4:1" + } + ], + "id": 64, + "name": "VariableDeclaration", + "src": "154:15:1" + } + ], + "id": 65, + "name": "StructDefinition", + "src": "87:89:1" + }, + { + "attributes": { + "constant": true, + "name": "payDuration", + "scope": 417, + "stateVariable": true, + "storageLocation": "default", + "type": "uint256", + "visibility": "internal" + }, + "children": [ + { + "attributes": { + "name": "uint", + "type": "uint256" + }, + "id": 66, + "name": "ElementaryTypeName", + "src": "186:4:1" + }, + { + "attributes": { + "argumentTypes": null, + "hexvalue": "3130", + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "subdenomination": "seconds", + "token": "number", + "type": "int_const 10", + "value": "10" + }, + "id": 67, + "name": "Literal", + "src": "214:10:1" + } + ], + "id": 68, + "name": "VariableDeclaration", + "src": "186:38:1" + }, + { + "attributes": { + "constant": false, + "name": "totalSalary", + "scope": 417, + "stateVariable": true, + "storageLocation": "default", + "type": "uint256", + "visibility": "internal" + }, + "children": [ + { + "attributes": { + "name": "uint", + "type": "uint256" + }, + "id": 69, + "name": "ElementaryTypeName", + "src": "230:4:1" + }, + { + "attributes": { + "argumentTypes": null, + "hexvalue": "30", + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "subdenomination": null, + "token": "number", + "type": "int_const 0", + "value": "0" + }, + "id": 70, + "name": "Literal", + "src": "249:1:1" + } + ], + "id": 71, + "name": "VariableDeclaration", + "src": "230:20:1" + }, + { + "attributes": { + "constant": false, + "name": "owner", + "scope": 417, + "stateVariable": true, + "storageLocation": "default", + "type": "address", + "value": null, + "visibility": "internal" + }, + "children": [ + { + "attributes": { + "name": "address", + "type": "address" + }, + "id": 72, + "name": "ElementaryTypeName", + "src": "257:7:1" + } + ], + "id": 73, + "name": "VariableDeclaration", + "src": "257:13:1" + }, + { + "attributes": { + "constant": false, + "name": "employees", + "scope": 417, + "stateVariable": true, + "storageLocation": "default", + "type": "mapping(address => struct Payroll.Employee storage ref)", + "value": null, + "visibility": "private" + }, + "children": [ + { + "attributes": { + "type": "mapping(address => struct Payroll.Employee storage ref)" + }, + "children": [ + { + "attributes": { + "name": "address", + "type": "address" + }, + "id": 74, + "name": "ElementaryTypeName", + "src": "285:7:1" + }, + { + "attributes": { + "contractScope": null, + "name": "Employee", + "referencedDeclaration": 65, + "type": "struct Payroll.Employee storage pointer" + }, + "id": 75, + "name": "UserDefinedTypeName", + "src": "296:8:1" + } + ], + "id": 76, + "name": "Mapping", + "src": "276:29:1" + } + ], + "id": 77, + "name": "VariableDeclaration", + "src": "276:47:1" + }, + { + "attributes": { + "name": "onlyOwner", + "visibility": "internal" + }, + "children": [ + { + "attributes": { + "parameters": [ + null + ] + }, + "children": [], + "id": 78, + "name": "ParameterList", + "src": "348:2:1" + }, + { + "children": [ + { + "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_bool", + "typeString": "bool" + } + ], + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 432, + "type": "function (bool) pure", + "value": "require" + }, + "id": 79, + "name": "Identifier", + "src": "361:7:1" + }, + { + "attributes": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_address", + "typeString": "address" + }, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "operator": "==", + "type": "bool" + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 73, + "type": "address", + "value": "owner" + }, + "id": 80, + "name": "Identifier", + "src": "369:5:1" + }, + { + "attributes": { + "argumentTypes": null, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "member_name": "sender", + "referencedDeclaration": null, + "type": "address" + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 429, + "type": "msg", + "value": "msg" + }, + "id": 81, + "name": "Identifier", + "src": "378:3:1" + } + ], + "id": 82, + "name": "MemberAccess", + "src": "378:10:1" + } + ], + "id": 83, + "name": "BinaryOperation", + "src": "369:19:1" + } + ], + "id": 84, + "name": "FunctionCall", + "src": "361:28:1" + } + ], + "id": 85, + "name": "ExpressionStatement", + "src": "361:28:1" + }, + { + "id": 86, + "name": "PlaceholderStatement", + "src": "399:1:1" + } + ], + "id": 87, + "name": "Block", + "src": "351:56:1" + } + ], + "id": 88, + "name": "ModifierDefinition", + "src": "330:77:1" + }, + { + "attributes": { + "name": "onlySelf", + "visibility": "internal" + }, + "children": [ + { + "children": [ + { + "attributes": { + "constant": false, + "name": "employeeId", + "scope": 101, + "stateVariable": false, + "storageLocation": "default", + "type": "address", + "value": null, + "visibility": "internal" + }, + "children": [ + { + "attributes": { + "name": "address", + "type": "address" + }, + "id": 89, + "name": "ElementaryTypeName", + "src": "435:7:1" + } + ], + "id": 90, + "name": "VariableDeclaration", + "src": "435:18:1" + } + ], + "id": 91, + "name": "ParameterList", + "src": "434:20:1" + }, + { + "children": [ + { + "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_bool", + "typeString": "bool" + } + ], + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 432, + "type": "function (bool) pure", + "value": "require" + }, + "id": 92, + "name": "Identifier", + "src": "465:7:1" + }, + { + "attributes": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_address", + "typeString": "address" + }, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "operator": "==", + "type": "bool" + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 90, + "type": "address", + "value": "employeeId" + }, + "id": 93, + "name": "Identifier", + "src": "473:10:1" + }, + { + "attributes": { + "argumentTypes": null, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "member_name": "sender", + "referencedDeclaration": null, + "type": "address" + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 429, + "type": "msg", + "value": "msg" + }, + "id": 94, + "name": "Identifier", + "src": "487:3:1" + } + ], + "id": 95, + "name": "MemberAccess", + "src": "487:10:1" + } + ], + "id": 96, + "name": "BinaryOperation", + "src": "473:24:1" + } + ], + "id": 97, + "name": "FunctionCall", + "src": "465:33:1" + } + ], + "id": 98, + "name": "ExpressionStatement", + "src": "465:33:1" + }, + { + "id": 99, + "name": "PlaceholderStatement", + "src": "508:1:1" + } + ], + "id": 100, + "name": "Block", + "src": "455:61:1" + } + ], + "id": 101, + "name": "ModifierDefinition", + "src": "417:99:1" + }, + { + "attributes": { + "constant": false, + "implemented": true, + "isConstructor": true, + "modifiers": [ + null + ], + "name": "Payroll", + "payable": false, + "scope": 417, + "stateMutability": "nonpayable", + "superFunction": null, + "visibility": "public" + }, + "children": [ + { + "attributes": { + "parameters": [ + null + ] + }, + "children": [], + "id": 102, + "name": "ParameterList", + "src": "538:2:1" + }, + { + "attributes": { + "parameters": [ + null + ] + }, + "children": [], + "id": 103, + "name": "ParameterList", + "src": "547:0:1" + }, + { + "children": [ + { + "children": [ + { + "attributes": { + "argumentTypes": null, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "operator": "=", + "type": "address" + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 73, + "type": "address", + "value": "owner" + }, + "id": 104, + "name": "Identifier", + "src": "557:5:1" + }, + { + "attributes": { + "argumentTypes": null, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "member_name": "sender", + "referencedDeclaration": null, + "type": "address" + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 429, + "type": "msg", + "value": "msg" + }, + "id": 105, + "name": "Identifier", + "src": "565:3:1" + } + ], + "id": 106, + "name": "MemberAccess", + "src": "565:10:1" + } + ], + "id": 107, + "name": "Assignment", + "src": "557:18:1" + } + ], + "id": 108, + "name": "ExpressionStatement", + "src": "557:18:1" + } + ], + "id": 109, + "name": "Block", + "src": "547:35:1" + } + ], + "id": 110, + "name": "FunctionDefinition", + "src": "522:60:1" + }, + { + "attributes": { + "constant": false, + "implemented": true, + "isConstructor": false, + "modifiers": [ + null + ], + "name": "_partialPaid", + "payable": false, + "scope": 417, + "stateMutability": "nonpayable", + "superFunction": null, + "visibility": "private" + }, + "children": [ + { + "children": [ + { + "attributes": { + "constant": false, + "name": "employee", + "scope": 137, + "stateVariable": false, + "storageLocation": "default", + "type": "struct Payroll.Employee memory", + "value": null, + "visibility": "internal" + }, + "children": [ + { + "attributes": { + "contractScope": null, + "name": "Employee", + "referencedDeclaration": 65, + "type": "struct Payroll.Employee storage pointer" + }, + "id": 111, + "name": "UserDefinedTypeName", + "src": "614:8:1" + } + ], + "id": 112, + "name": "VariableDeclaration", + "src": "614:17:1" + } + ], + "id": 113, + "name": "ParameterList", + "src": "613:19:1" + }, + { + "attributes": { + "parameters": [ + null + ] + }, + "children": [], + "id": 114, + "name": "ParameterList", + "src": "641:0:1" + }, + { + "children": [ + { + "attributes": { + "assignments": [ + 116 + ] + }, + "children": [ + { + "attributes": { + "constant": false, + "name": "amount", + "scope": 137, + "stateVariable": false, + "storageLocation": "default", + "type": "uint256", + "value": null, + "visibility": "internal" + }, + "children": [ + { + "attributes": { + "name": "uint", + "type": "uint256" + }, + "id": 115, + "name": "ElementaryTypeName", + "src": "649:4:1" + } + ], + "id": 116, + "name": "VariableDeclaration", + "src": "649:11:1" + }, + { + "attributes": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "operator": "*", + "type": "uint256" + }, + "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, + "isInlineArray": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "type": "uint256" + }, + "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, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 431, + "type": "uint256", + "value": "now" + }, + "id": 117, + "name": "Identifier", + "src": "664:3:1" + }, + { + "attributes": { + "argumentTypes": null, + "isConstant": false, + "isLValue": true, + "isPure": false, + "lValueRequested": false, + "member_name": "lastPayday", + "referencedDeclaration": 64, + "type": "uint256" + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 112, + "type": "struct Payroll.Employee memory", + "value": "employee" + }, + "id": 118, + "name": "Identifier", + "src": "670:8:1" + } + ], + "id": 119, + "name": "MemberAccess", + "src": "670:19:1" + } + ], + "id": 120, + "name": "BinaryOperation", + "src": "664:25:1" + } + ], + "id": 121, + "name": "TupleExpression", + "src": "663:27:1" + }, + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 68, + "type": "uint256", + "value": "payDuration" + }, + "id": 122, + "name": "Identifier", + "src": "693:11:1" + } + ], + "id": 123, + "name": "BinaryOperation", + "src": "663:41:1" + }, + { + "attributes": { + "argumentTypes": null, + "isConstant": false, + "isLValue": true, + "isPure": false, + "lValueRequested": false, + "member_name": "salary", + "referencedDeclaration": 62, + "type": "uint256" + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 112, + "type": "struct Payroll.Employee memory", + "value": "employee" + }, + "id": 124, + "name": "Identifier", + "src": "707:8:1" + } + ], + "id": 125, + "name": "MemberAccess", + "src": "707:15:1" + } + ], + "id": 126, + "name": "BinaryOperation", + "src": "663:59:1" + } + ], + "id": 127, + "name": "VariableDeclarationStatement", + "src": "649:73:1" + }, + { + "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_uint256", + "typeString": "uint256" + } + ], + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "member_name": "transfer", + "referencedDeclaration": null, + "type": "function (uint256)" + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "isConstant": false, + "isLValue": true, + "isPure": false, + "lValueRequested": false, + "member_name": "id", + "referencedDeclaration": 60, + "type": "address" + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 112, + "type": "struct Payroll.Employee memory", + "value": "employee" + }, + "id": 128, + "name": "Identifier", + "src": "730:8:1" + } + ], + "id": 131, + "name": "MemberAccess", + "src": "730:11:1" + } + ], + "id": 132, + "name": "MemberAccess", + "src": "730:20:1" + }, + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 116, + "type": "uint256", + "value": "amount" + }, + "id": 133, + "name": "Identifier", + "src": "751:6:1" + } + ], + "id": 134, + "name": "FunctionCall", + "src": "730:28:1" + } + ], + "id": 135, + "name": "ExpressionStatement", + "src": "730:28:1" + } + ], + "id": 136, + "name": "Block", + "src": "641:124:1" + } + ], + "id": 137, + "name": "FunctionDefinition", + "src": "592:173:1" + }, + { + "attributes": { + "constant": false, + "implemented": true, + "isConstructor": false, + "name": "addEmployee", + "payable": false, + "scope": 417, + "stateMutability": "nonpayable", + "superFunction": null, + "visibility": "public" + }, + "children": [ + { + "children": [ + { + "attributes": { + "constant": false, + "name": "employeeId", + "scope": 175, + "stateVariable": false, + "storageLocation": "default", + "type": "address", + "value": null, + "visibility": "internal" + }, + "children": [ + { + "attributes": { + "name": "address", + "type": "address" + }, + "id": 138, + "name": "ElementaryTypeName", + "src": "796:7:1" + } + ], + "id": 139, + "name": "VariableDeclaration", + "src": "796:18:1" + }, + { + "attributes": { + "constant": false, + "name": "salary", + "scope": 175, + "stateVariable": false, + "storageLocation": "default", + "type": "uint256", + "value": null, + "visibility": "internal" + }, + "children": [ + { + "attributes": { + "name": "uint", + "type": "uint256" + }, + "id": 140, + "name": "ElementaryTypeName", + "src": "816:4:1" + } + ], + "id": 141, + "name": "VariableDeclaration", + "src": "816:11:1" + } + ], + "id": 142, + "name": "ParameterList", + "src": "795:33:1" + }, + { + "attributes": { + "parameters": [ + null + ] + }, + "children": [], + "id": 145, + "name": "ParameterList", + "src": "846:0:1" + }, + { + "attributes": { + "arguments": [ + null + ] + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 88, + "type": "modifier ()", + "value": "onlyOwner" + }, + "id": 143, + "name": "Identifier", + "src": "836:9:1" + } + ], + "id": 144, + "name": "ModifierInvocation", + "src": "836:9:1" + }, + { + "children": [ + { + "attributes": { + "assignments": [ + 146 + ] + }, + "children": [ + { + "attributes": { + "constant": false, + "name": "employee", + "scope": 175, + "stateVariable": false, + "storageLocation": "default", + "type": "struct Payroll.Employee storage pointer", + "typeName": null, + "value": null, + "visibility": "internal" + }, + "children": [], + "id": 146, + "name": "VariableDeclaration", + "src": "854:12:1" + }, + { + "attributes": { + "argumentTypes": null, + "isConstant": false, + "isLValue": true, + "isPure": false, + "lValueRequested": false, + "type": "struct Payroll.Employee storage ref" + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 77, + "type": "mapping(address => struct Payroll.Employee storage ref)", + "value": "employees" + }, + "id": 147, + "name": "Identifier", + "src": "869:9:1" + }, + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 139, + "type": "address", + "value": "employeeId" + }, + "id": 148, + "name": "Identifier", + "src": "879:10:1" + } + ], + "id": 149, + "name": "IndexAccess", + "src": "869:21:1" + } + ], + "id": 150, + "name": "VariableDeclarationStatement", + "src": "854:36:1" + }, + { + "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_bool", + "typeString": "bool" + } + ], + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 420, + "type": "function (bool) pure", + "value": "assert" + }, + "id": 151, + "name": "Identifier", + "src": "898:6:1" + }, + { + "attributes": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_address", + "typeString": "address" + }, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "operator": "==", + "type": "bool" + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "isConstant": false, + "isLValue": true, + "isPure": false, + "lValueRequested": false, + "member_name": "id", + "referencedDeclaration": 60, + "type": "address" + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 146, + "type": "struct Payroll.Employee storage pointer", + "value": "employee" + }, + "id": 152, + "name": "Identifier", + "src": "905:8:1" + } + ], + "id": 153, + "name": "MemberAccess", + "src": "905:11:1" + }, + { + "attributes": { + "argumentTypes": null, + "hexvalue": "307830", + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "subdenomination": null, + "token": "number", + "type": "int_const 0", + "value": "0x0" + }, + "id": 154, + "name": "Literal", + "src": "920:3:1" + } + ], + "id": 155, + "name": "BinaryOperation", + "src": "905:18:1" + } + ], + "id": 156, + "name": "FunctionCall", + "src": "898:26:1" + } + ], + "id": 157, + "name": "ExpressionStatement", + "src": "898:26:1" + }, + { + "children": [ + { + "attributes": { + "argumentTypes": null, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "operator": "=", + "type": "struct Payroll.Employee storage ref" + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "isConstant": false, + "isLValue": true, + "isPure": false, + "lValueRequested": true, + "type": "struct Payroll.Employee storage ref" + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 77, + "type": "mapping(address => struct Payroll.Employee storage ref)", + "value": "employees" + }, + "id": 158, + "name": "Identifier", + "src": "932:9:1" + }, + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 139, + "type": "address", + "value": "employeeId" + }, + "id": 159, + "name": "Identifier", + "src": "942:10:1" + } + ], + "id": 160, + "name": "IndexAccess", + "src": "932:21:1" + }, + { + "attributes": { + "argumentTypes": null, + "isConstant": false, + "isLValue": false, + "isPure": false, + "isStructConstructorCall": true, + "lValueRequested": false, + "names": [ + null + ], + "type": "struct Payroll.Employee memory", + "type_conversion": false + }, + "children": [ + { + "attributes": { + "argumentTypes": [ + { + "typeIdentifier": "t_address", + "typeString": "address" + }, + { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + ], + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 65, + "type": "type(struct Payroll.Employee storage pointer)", + "value": "Employee" + }, + "id": 161, + "name": "Identifier", + "src": "956:8:1" + }, + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 139, + "type": "address", + "value": "employeeId" + }, + "id": 162, + "name": "Identifier", + "src": "965:10:1" + }, + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 141, + "type": "uint256", + "value": "salary" + }, + "id": 163, + "name": "Identifier", + "src": "977:6:1" + }, + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 431, + "type": "uint256", + "value": "now" + }, + "id": 164, + "name": "Identifier", + "src": "985:3:1" + } + ], + "id": 165, + "name": "FunctionCall", + "src": "956:33:1" + } + ], + "id": 166, + "name": "Assignment", + "src": "932:57:1" + } + ], + "id": 167, + "name": "ExpressionStatement", + "src": "932:57:1" + }, + { + "children": [ + { + "attributes": { + "argumentTypes": null, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "operator": "+=", + "type": "uint256" + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 71, + "type": "uint256", + "value": "totalSalary" + }, + "id": 168, + "name": "Identifier", + "src": "997:11:1" + }, + { + "attributes": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "operator": "*", + "type": "uint256" + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 141, + "type": "uint256", + "value": "salary" + }, + "id": 169, + "name": "Identifier", + "src": "1012:6:1" + }, + { + "attributes": { + "argumentTypes": null, + "hexvalue": "31", + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "subdenomination": "ether", + "token": "number", + "type": "int_const 1000000000000000000", + "value": "1" + }, + "id": 170, + "name": "Literal", + "src": "1021:7:1" + } + ], + "id": 171, + "name": "BinaryOperation", + "src": "1012:16:1" + } + ], + "id": 172, + "name": "Assignment", + "src": "997:31:1" + } + ], + "id": 173, + "name": "ExpressionStatement", + "src": "997:31:1" + } + ], + "id": 174, + "name": "Block", + "src": "846:189:1" + } + ], + "id": 175, + "name": "FunctionDefinition", + "src": "775:260:1" + }, + { + "attributes": { + "constant": false, + "implemented": true, + "isConstructor": false, + "name": "removeEmployee", + "payable": false, + "scope": 417, + "stateMutability": "nonpayable", + "superFunction": null, + "visibility": "public" + }, + "children": [ + { + "children": [ + { + "attributes": { + "constant": false, + "name": "employeeId", + "scope": 215, + "stateVariable": false, + "storageLocation": "default", + "type": "address", + "value": null, + "visibility": "internal" + }, + "children": [ + { + "attributes": { + "name": "address", + "type": "address" + }, + "id": 176, + "name": "ElementaryTypeName", + "src": "1069:7:1" + } + ], + "id": 177, + "name": "VariableDeclaration", + "src": "1069:18:1" + } + ], + "id": 178, + "name": "ParameterList", + "src": "1068:20:1" + }, + { + "attributes": { + "parameters": [ + null + ] + }, + "children": [], + "id": 181, + "name": "ParameterList", + "src": "1106:0:1" + }, + { + "attributes": { + "arguments": [ + null + ] + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 88, + "type": "modifier ()", + "value": "onlyOwner" + }, + "id": 179, + "name": "Identifier", + "src": "1096:9:1" + } + ], + "id": 180, + "name": "ModifierInvocation", + "src": "1096:9:1" + }, + { + "children": [ + { + "attributes": { + "assignments": [ + 182 + ] + }, + "children": [ + { + "attributes": { + "constant": false, + "name": "employee", + "scope": 215, + "stateVariable": false, + "storageLocation": "default", + "type": "struct Payroll.Employee storage pointer", + "typeName": null, + "value": null, + "visibility": "internal" + }, + "children": [], + "id": 182, + "name": "VariableDeclaration", + "src": "1114:12:1" + }, + { + "attributes": { + "argumentTypes": null, + "isConstant": false, + "isLValue": true, + "isPure": false, + "lValueRequested": false, + "type": "struct Payroll.Employee storage ref" + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 77, + "type": "mapping(address => struct Payroll.Employee storage ref)", + "value": "employees" + }, + "id": 183, + "name": "Identifier", + "src": "1129:9:1" + }, + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 177, + "type": "address", + "value": "employeeId" + }, + "id": 184, + "name": "Identifier", + "src": "1139:10:1" + } + ], + "id": 185, + "name": "IndexAccess", + "src": "1129:21:1" + } + ], + "id": 186, + "name": "VariableDeclarationStatement", + "src": "1114:36:1" + }, + { + "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_bool", + "typeString": "bool" + } + ], + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 420, + "type": "function (bool) pure", + "value": "assert" + }, + "id": 187, + "name": "Identifier", + "src": "1158:6:1" + }, + { + "attributes": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_address", + "typeString": "address" + }, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "operator": "!=", + "type": "bool" + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "isConstant": false, + "isLValue": true, + "isPure": false, + "lValueRequested": false, + "member_name": "id", + "referencedDeclaration": 60, + "type": "address" + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 182, + "type": "struct Payroll.Employee storage pointer", + "value": "employee" + }, + "id": 188, + "name": "Identifier", + "src": "1165:8:1" + } + ], + "id": 189, + "name": "MemberAccess", + "src": "1165:11:1" + }, + { + "attributes": { + "argumentTypes": null, + "hexvalue": "307830", + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "subdenomination": null, + "token": "number", + "type": "int_const 0", + "value": "0x0" + }, + "id": 190, + "name": "Literal", + "src": "1180:3:1" + } + ], + "id": 191, + "name": "BinaryOperation", + "src": "1165:18:1" + } + ], + "id": 192, + "name": "FunctionCall", + "src": "1158:26:1" + } + ], + "id": 193, + "name": "ExpressionStatement", + "src": "1158:26:1" + }, + { + "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_struct$_Employee_$65_storage", + "typeString": "struct Payroll.Employee storage ref" + } + ], + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 137, + "type": "function (struct Payroll.Employee memory)", + "value": "_partialPaid" + }, + "id": 194, + "name": "Identifier", + "src": "1192:12:1" + }, + { + "attributes": { + "argumentTypes": null, + "isConstant": false, + "isLValue": true, + "isPure": false, + "lValueRequested": false, + "type": "struct Payroll.Employee storage ref" + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 77, + "type": "mapping(address => struct Payroll.Employee storage ref)", + "value": "employees" + }, + "id": 195, + "name": "Identifier", + "src": "1205:9:1" + }, + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 177, + "type": "address", + "value": "employeeId" + }, + "id": 196, + "name": "Identifier", + "src": "1215:10:1" + } + ], + "id": 197, + "name": "IndexAccess", + "src": "1205:21:1" + } + ], + "id": 198, + "name": "FunctionCall", + "src": "1192:35:1" + } + ], + "id": 199, + "name": "ExpressionStatement", + "src": "1192:35:1" + }, + { + "children": [ + { + "attributes": { + "argumentTypes": null, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "operator": "delete", + "prefix": true, + "type": "tuple()" + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "isConstant": false, + "isLValue": true, + "isPure": false, + "lValueRequested": true, + "type": "struct Payroll.Employee storage ref" + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 77, + "type": "mapping(address => struct Payroll.Employee storage ref)", + "value": "employees" + }, + "id": 200, + "name": "Identifier", + "src": "1242:9:1" + }, + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 177, + "type": "address", + "value": "employeeId" + }, + "id": 201, + "name": "Identifier", + "src": "1252:10:1" + } + ], + "id": 202, + "name": "IndexAccess", + "src": "1242:21:1" + } + ], + "id": 203, + "name": "UnaryOperation", + "src": "1235:28:1" + } + ], + "id": 204, + "name": "ExpressionStatement", + "src": "1235:28:1" + }, + { + "children": [ + { + "attributes": { + "argumentTypes": null, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "operator": "-=", + "type": "uint256" + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 71, + "type": "uint256", + "value": "totalSalary" + }, + "id": 205, + "name": "Identifier", + "src": "1271:11:1" + }, + { + "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": true, + "isPure": false, + "lValueRequested": false, + "member_name": "salary", + "referencedDeclaration": 62, + "type": "uint256" + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "isConstant": false, + "isLValue": true, + "isPure": false, + "lValueRequested": false, + "type": "struct Payroll.Employee storage ref" + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 77, + "type": "mapping(address => struct Payroll.Employee storage ref)", + "value": "employees" + }, + "id": 206, + "name": "Identifier", + "src": "1286:9:1" + }, + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 177, + "type": "address", + "value": "employeeId" + }, + "id": 207, + "name": "Identifier", + "src": "1296:10:1" + } + ], + "id": 208, + "name": "IndexAccess", + "src": "1286:21:1" + } + ], + "id": 209, + "name": "MemberAccess", + "src": "1286:28:1" + }, + { + "attributes": { + "argumentTypes": null, + "hexvalue": "31", + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "subdenomination": "ether", + "token": "number", + "type": "int_const 1000000000000000000", + "value": "1" + }, + "id": 210, + "name": "Literal", + "src": "1317:7:1" + } + ], + "id": 211, + "name": "BinaryOperation", + "src": "1286:38:1" + } + ], + "id": 212, + "name": "Assignment", + "src": "1271:53:1" + } + ], + "id": 213, + "name": "ExpressionStatement", + "src": "1271:53:1" + } + ], + "id": 214, + "name": "Block", + "src": "1106:225:1" + } + ], + "id": 215, + "name": "FunctionDefinition", + "src": "1045:286:1" + }, + { + "attributes": { + "constant": false, + "implemented": true, + "isConstructor": false, + "name": "updateEmployee", + "payable": false, + "scope": 417, + "stateMutability": "nonpayable", + "superFunction": null, + "visibility": "public" + }, + "children": [ + { + "children": [ + { + "attributes": { + "constant": false, + "name": "employeeId", + "scope": 270, + "stateVariable": false, + "storageLocation": "default", + "type": "address", + "value": null, + "visibility": "internal" + }, + "children": [ + { + "attributes": { + "name": "address", + "type": "address" + }, + "id": 216, + "name": "ElementaryTypeName", + "src": "1365:7:1" + } + ], + "id": 217, + "name": "VariableDeclaration", + "src": "1365:18:1" + }, + { + "attributes": { + "constant": false, + "name": "salary", + "scope": 270, + "stateVariable": false, + "storageLocation": "default", + "type": "uint256", + "value": null, + "visibility": "internal" + }, + "children": [ + { + "attributes": { + "name": "uint", + "type": "uint256" + }, + "id": 218, + "name": "ElementaryTypeName", + "src": "1385:4:1" + } + ], + "id": 219, + "name": "VariableDeclaration", + "src": "1385:11:1" + } + ], + "id": 220, + "name": "ParameterList", + "src": "1364:33:1" + }, + { + "attributes": { + "parameters": [ + null + ] + }, + "children": [], + "id": 223, + "name": "ParameterList", + "src": "1415:0:1" + }, + { + "attributes": { + "arguments": [ + null + ] + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 88, + "type": "modifier ()", + "value": "onlyOwner" + }, + "id": 221, + "name": "Identifier", + "src": "1405:9:1" + } + ], + "id": 222, + "name": "ModifierInvocation", + "src": "1405:9:1" + }, + { + "children": [ + { + "attributes": { + "assignments": [ + 224 + ] + }, + "children": [ + { + "attributes": { + "constant": false, + "name": "employee", + "scope": 270, + "stateVariable": false, + "storageLocation": "default", + "type": "struct Payroll.Employee storage pointer", + "typeName": null, + "value": null, + "visibility": "internal" + }, + "children": [], + "id": 224, + "name": "VariableDeclaration", + "src": "1423:12:1" + }, + { + "attributes": { + "argumentTypes": null, + "isConstant": false, + "isLValue": true, + "isPure": false, + "lValueRequested": false, + "type": "struct Payroll.Employee storage ref" + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 77, + "type": "mapping(address => struct Payroll.Employee storage ref)", + "value": "employees" + }, + "id": 225, + "name": "Identifier", + "src": "1438:9:1" + }, + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 217, + "type": "address", + "value": "employeeId" + }, + "id": 226, + "name": "Identifier", + "src": "1448:10:1" + } + ], + "id": 227, + "name": "IndexAccess", + "src": "1438:21:1" + } + ], + "id": 228, + "name": "VariableDeclarationStatement", + "src": "1423:36:1" + }, + { + "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_bool", + "typeString": "bool" + } + ], + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 420, + "type": "function (bool) pure", + "value": "assert" + }, + "id": 229, + "name": "Identifier", + "src": "1467:6:1" + }, + { + "attributes": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_address", + "typeString": "address" + }, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "operator": "!=", + "type": "bool" + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "isConstant": false, + "isLValue": true, + "isPure": false, + "lValueRequested": false, + "member_name": "id", + "referencedDeclaration": 60, + "type": "address" + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 224, + "type": "struct Payroll.Employee storage pointer", + "value": "employee" + }, + "id": 230, + "name": "Identifier", + "src": "1474:8:1" + } + ], + "id": 231, + "name": "MemberAccess", + "src": "1474:11:1" + }, + { + "attributes": { + "argumentTypes": null, + "hexvalue": "307830", + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "subdenomination": null, + "token": "number", + "type": "int_const 0", + "value": "0x0" + }, + "id": 232, + "name": "Literal", + "src": "1489:3:1" + } + ], + "id": 233, + "name": "BinaryOperation", + "src": "1474:18:1" + } + ], + "id": 234, + "name": "FunctionCall", + "src": "1467:26:1" + } + ], + "id": 235, + "name": "ExpressionStatement", + "src": "1467:26:1" + }, + { + "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_struct$_Employee_$65_storage_ptr", + "typeString": "struct Payroll.Employee storage pointer" + } + ], + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 137, + "type": "function (struct Payroll.Employee memory)", + "value": "_partialPaid" + }, + "id": 236, + "name": "Identifier", + "src": "1501:12:1" + }, + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 224, + "type": "struct Payroll.Employee storage pointer", + "value": "employee" + }, + "id": 237, + "name": "Identifier", + "src": "1514:8:1" + } + ], + "id": 238, + "name": "FunctionCall", + "src": "1501:22:1" + } + ], + "id": 239, + "name": "ExpressionStatement", + "src": "1501:22:1" + }, + { + "children": [ + { + "attributes": { + "argumentTypes": null, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "operator": "-=", + "type": "uint256" + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 71, + "type": "uint256", + "value": "totalSalary" + }, + "id": 240, + "name": "Identifier", + "src": "1531:11:1" + }, + { + "attributes": { + "argumentTypes": null, + "isConstant": false, + "isLValue": true, + "isPure": false, + "lValueRequested": false, + "member_name": "salary", + "referencedDeclaration": 62, + "type": "uint256" + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "isConstant": false, + "isLValue": true, + "isPure": false, + "lValueRequested": false, + "type": "struct Payroll.Employee storage ref" + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 77, + "type": "mapping(address => struct Payroll.Employee storage ref)", + "value": "employees" + }, + "id": 241, + "name": "Identifier", + "src": "1546:9:1" + }, + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 217, + "type": "address", + "value": "employeeId" + }, + "id": 242, + "name": "Identifier", + "src": "1556:10:1" + } + ], + "id": 243, + "name": "IndexAccess", + "src": "1546:21:1" + } + ], + "id": 244, + "name": "MemberAccess", + "src": "1546:28:1" + } + ], + "id": 245, + "name": "Assignment", + "src": "1531:43:1" + } + ], + "id": 246, + "name": "ExpressionStatement", + "src": "1531:43:1" + }, + { + "children": [ + { + "attributes": { + "argumentTypes": null, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "operator": "=", + "type": "uint256" + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "isConstant": false, + "isLValue": true, + "isPure": false, + "lValueRequested": true, + "member_name": "salary", + "referencedDeclaration": 62, + "type": "uint256" + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "isConstant": false, + "isLValue": true, + "isPure": false, + "lValueRequested": false, + "type": "struct Payroll.Employee storage ref" + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 77, + "type": "mapping(address => struct Payroll.Employee storage ref)", + "value": "employees" + }, + "id": 247, + "name": "Identifier", + "src": "1582:9:1" + }, + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 217, + "type": "address", + "value": "employeeId" + }, + "id": 248, + "name": "Identifier", + "src": "1592:10:1" + } + ], + "id": 249, + "name": "IndexAccess", + "src": "1582:21:1" + } + ], + "id": 250, + "name": "MemberAccess", + "src": "1582:28:1" + }, + { + "attributes": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "operator": "*", + "type": "uint256" + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 219, + "type": "uint256", + "value": "salary" + }, + "id": 251, + "name": "Identifier", + "src": "1613:6:1" + }, + { + "attributes": { + "argumentTypes": null, + "hexvalue": "31", + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "subdenomination": "ether", + "token": "number", + "type": "int_const 1000000000000000000", + "value": "1" + }, + "id": 252, + "name": "Literal", + "src": "1622:7:1" + } + ], + "id": 253, + "name": "BinaryOperation", + "src": "1613:16:1" + } + ], + "id": 254, + "name": "Assignment", + "src": "1582:47:1" + } + ], + "id": 255, + "name": "ExpressionStatement", + "src": "1582:47:1" + }, + { + "children": [ + { + "attributes": { + "argumentTypes": null, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "operator": "=", + "type": "uint256" + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "isConstant": false, + "isLValue": true, + "isPure": false, + "lValueRequested": true, + "member_name": "lastPayday", + "referencedDeclaration": 64, + "type": "uint256" + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "isConstant": false, + "isLValue": true, + "isPure": false, + "lValueRequested": false, + "type": "struct Payroll.Employee storage ref" + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 77, + "type": "mapping(address => struct Payroll.Employee storage ref)", + "value": "employees" + }, + "id": 256, + "name": "Identifier", + "src": "1637:9:1" + }, + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 217, + "type": "address", + "value": "employeeId" + }, + "id": 257, + "name": "Identifier", + "src": "1647:10:1" + } + ], + "id": 258, + "name": "IndexAccess", + "src": "1637:21:1" + } + ], + "id": 259, + "name": "MemberAccess", + "src": "1637:32:1" + }, + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 431, + "type": "uint256", + "value": "now" + }, + "id": 260, + "name": "Identifier", + "src": "1672:3:1" + } + ], + "id": 261, + "name": "Assignment", + "src": "1637:38:1" + } + ], + "id": 262, + "name": "ExpressionStatement", + "src": "1637:38:1" + }, + { + "children": [ + { + "attributes": { + "argumentTypes": null, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "operator": "+=", + "type": "uint256" + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 71, + "type": "uint256", + "value": "totalSalary" + }, + "id": 263, + "name": "Identifier", + "src": "1683:11:1" + }, + { + "attributes": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "operator": "*", + "type": "uint256" + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 219, + "type": "uint256", + "value": "salary" + }, + "id": 264, + "name": "Identifier", + "src": "1698:6:1" + }, + { + "attributes": { + "argumentTypes": null, + "hexvalue": "31", + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "subdenomination": "ether", + "token": "number", + "type": "int_const 1000000000000000000", + "value": "1" + }, + "id": 265, + "name": "Literal", + "src": "1707:7:1" + } + ], + "id": 266, + "name": "BinaryOperation", + "src": "1698:16:1" + } + ], + "id": 267, + "name": "Assignment", + "src": "1683:31:1" + } + ], + "id": 268, + "name": "ExpressionStatement", + "src": "1683:31:1" + } + ], + "id": 269, + "name": "Block", + "src": "1415:306:1" + } + ], + "id": 270, + "name": "FunctionDefinition", + "src": "1341:380:1" + }, + { + "attributes": { + "constant": false, + "implemented": true, + "isConstructor": false, + "modifiers": [ + null + ], + "name": "addFund", + "payable": true, + "scope": 417, + "stateMutability": "payable", + "superFunction": null, + "visibility": "public" + }, + "children": [ + { + "attributes": { + "parameters": [ + null + ] + }, + "children": [], + "id": 271, + "name": "ParameterList", + "src": "1747:2:1" + }, + { + "children": [ + { + "attributes": { + "constant": false, + "name": "", + "scope": 279, + "stateVariable": false, + "storageLocation": "default", + "type": "uint256", + "value": null, + "visibility": "internal" + }, + "children": [ + { + "attributes": { + "name": "uint", + "type": "uint256" + }, + "id": 272, + "name": "ElementaryTypeName", + "src": "1774:4:1" + } + ], + "id": 273, + "name": "VariableDeclaration", + "src": "1774:4:1" + } + ], + "id": 274, + "name": "ParameterList", + "src": "1773:6:1" + }, + { + "children": [ + { + "attributes": { + "functionReturnParameters": 274 + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "member_name": "balance", + "referencedDeclaration": null, + "type": "uint256" + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 442, + "type": "contract Payroll", + "value": "this" + }, + "id": 275, + "name": "Identifier", + "src": "1795:4:1" + } + ], + "id": 276, + "name": "MemberAccess", + "src": "1795:12:1" + } + ], + "id": 277, + "name": "Return", + "src": "1788:19:1" + } + ], + "id": 278, + "name": "Block", + "src": "1780:34:1" + } + ], + "id": 279, + "name": "FunctionDefinition", + "src": "1731:83:1" + }, + { + "attributes": { + "constant": true, + "implemented": true, + "isConstructor": false, + "modifiers": [ + null + ], + "name": "calculateRunway", + "payable": false, + "scope": 417, + "stateMutability": "view", + "superFunction": null, + "visibility": "public" + }, + "children": [ + { + "attributes": { + "parameters": [ + null + ] + }, + "children": [], + "id": 280, + "name": "ParameterList", + "src": "1848:2:1" + }, + { + "children": [ + { + "attributes": { + "constant": false, + "name": "", + "scope": 296, + "stateVariable": false, + "storageLocation": "default", + "type": "uint256", + "value": null, + "visibility": "internal" + }, + "children": [ + { + "attributes": { + "name": "uint", + "type": "uint256" + }, + "id": 281, + "name": "ElementaryTypeName", + "src": "1872:4:1" + } + ], + "id": 282, + "name": "VariableDeclaration", + "src": "1872:4:1" + } + ], + "id": 283, + "name": "ParameterList", + "src": "1871:6:1" + }, + { + "children": [ + { + "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_bool", + "typeString": "bool" + } + ], + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 420, + "type": "function (bool) pure", + "value": "assert" + }, + "id": 284, + "name": "Identifier", + "src": "1888:6:1" + }, + { + "attributes": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "operator": ">", + "type": "bool" + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 71, + "type": "uint256", + "value": "totalSalary" + }, + "id": 285, + "name": "Identifier", + "src": "1895:11:1" + }, + { + "attributes": { + "argumentTypes": null, + "hexvalue": "30", + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "subdenomination": null, + "token": "number", + "type": "int_const 0", + "value": "0" + }, + "id": 286, + "name": "Literal", + "src": "1909:1:1" + } + ], + "id": 287, + "name": "BinaryOperation", + "src": "1895:15:1" + } + ], + "id": 288, + "name": "FunctionCall", + "src": "1888:23:1" + } + ], + "id": 289, + "name": "ExpressionStatement", + "src": "1888:23:1" + }, + { + "attributes": { + "functionReturnParameters": 283 + }, + "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, + "lValueRequested": false, + "member_name": "balance", + "referencedDeclaration": null, + "type": "uint256" + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 442, + "type": "contract Payroll", + "value": "this" + }, + "id": 290, + "name": "Identifier", + "src": "1928:4:1" + } + ], + "id": 291, + "name": "MemberAccess", + "src": "1928:12:1" + }, + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 71, + "type": "uint256", + "value": "totalSalary" + }, + "id": 292, + "name": "Identifier", + "src": "1943:11:1" + } + ], + "id": 293, + "name": "BinaryOperation", + "src": "1928:26:1" + } + ], + "id": 294, + "name": "Return", + "src": "1921:33:1" + } + ], + "id": 295, + "name": "Block", + "src": "1878:83:1" + } + ], + "id": 296, + "name": "FunctionDefinition", + "src": "1824:137:1" + }, + { + "attributes": { + "constant": true, + "implemented": true, + "isConstructor": false, + "modifiers": [ + null + ], + "name": "hasEnoughFund", + "payable": false, + "scope": 417, + "stateMutability": "view", + "superFunction": null, + "visibility": "public" + }, + "children": [ + { + "attributes": { + "parameters": [ + null + ] + }, + "children": [], + "id": 297, + "name": "ParameterList", + "src": "1993:2:1" + }, + { + "children": [ + { + "attributes": { + "constant": false, + "name": "", + "scope": 307, + "stateVariable": false, + "storageLocation": "default", + "type": "bool", + "value": null, + "visibility": "internal" + }, + "children": [ + { + "attributes": { + "name": "bool", + "type": "bool" + }, + "id": 298, + "name": "ElementaryTypeName", + "src": "2017:4:1" + } + ], + "id": 299, + "name": "VariableDeclaration", + "src": "2017:4:1" + } + ], + "id": 300, + "name": "ParameterList", + "src": "2016:6:1" + }, + { + "children": [ + { + "attributes": { + "functionReturnParameters": 300 + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "operator": ">", + "type": "bool" + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "arguments": [ + null + ], + "isConstant": false, + "isLValue": false, + "isPure": false, + "isStructConstructorCall": false, + "lValueRequested": false, + "names": [ + null + ], + "type": "uint256", + "type_conversion": false + }, + "children": [ + { + "attributes": { + "argumentTypes": [ + null + ], + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 296, + "type": "function () view returns (uint256)", + "value": "calculateRunway" + }, + "id": 301, + "name": "Identifier", + "src": "2038:15:1" + } + ], + "id": 302, + "name": "FunctionCall", + "src": "2038:17:1" + }, + { + "attributes": { + "argumentTypes": null, + "hexvalue": "30", + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "subdenomination": null, + "token": "number", + "type": "int_const 0", + "value": "0" + }, + "id": 303, + "name": "Literal", + "src": "2058:1:1" + } + ], + "id": 304, + "name": "BinaryOperation", + "src": "2038:21:1" + } + ], + "id": 305, + "name": "Return", + "src": "2031:28:1" + } + ], + "id": 306, + "name": "Block", + "src": "2023:43:1" + } + ], + "id": 307, + "name": "FunctionDefinition", + "src": "1971:95:1" + }, + { + "attributes": { + "constant": true, + "implemented": true, + "isConstructor": false, + "modifiers": [ + null + ], + "name": "checkEmployee", + "payable": false, + "scope": 417, + "stateMutability": "view", + "superFunction": null, + "visibility": "public" + }, + "children": [ + { + "children": [ + { + "attributes": { + "constant": false, + "name": "employeeId", + "scope": 331, + "stateVariable": false, + "storageLocation": "default", + "type": "address", + "value": null, + "visibility": "internal" + }, + "children": [ + { + "attributes": { + "name": "address", + "type": "address" + }, + "id": 308, + "name": "ElementaryTypeName", + "src": "2099:7:1" + } + ], + "id": 309, + "name": "VariableDeclaration", + "src": "2099:18:1" + } + ], + "id": 310, + "name": "ParameterList", + "src": "2098:20:1" + }, + { + "children": [ + { + "attributes": { + "constant": false, + "name": "salary", + "scope": 331, + "stateVariable": false, + "storageLocation": "default", + "type": "uint256", + "value": null, + "visibility": "internal" + }, + "children": [ + { + "attributes": { + "name": "uint", + "type": "uint256" + }, + "id": 311, + "name": "ElementaryTypeName", + "src": "2140:4:1" + } + ], + "id": 312, + "name": "VariableDeclaration", + "src": "2140:11:1" + }, + { + "attributes": { + "constant": false, + "name": "lastPayday", + "scope": 331, + "stateVariable": false, + "storageLocation": "default", + "type": "uint256", + "value": null, + "visibility": "internal" + }, + "children": [ + { + "attributes": { + "name": "uint", + "type": "uint256" + }, + "id": 313, + "name": "ElementaryTypeName", + "src": "2153:4:1" + } + ], + "id": 314, + "name": "VariableDeclaration", + "src": "2153:15:1" + } + ], + "id": 315, + "name": "ParameterList", + "src": "2139:30:1" + }, + { + "children": [ + { + "attributes": { + "assignments": [ + 316 + ] + }, + "children": [ + { + "attributes": { + "constant": false, + "name": "employee", + "scope": 331, + "stateVariable": false, + "storageLocation": "default", + "type": "struct Payroll.Employee storage pointer", + "typeName": null, + "value": null, + "visibility": "internal" + }, + "children": [], + "id": 316, + "name": "VariableDeclaration", + "src": "2180:12:1" + }, + { + "attributes": { + "argumentTypes": null, + "isConstant": false, + "isLValue": true, + "isPure": false, + "lValueRequested": false, + "type": "struct Payroll.Employee storage ref" + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 77, + "type": "mapping(address => struct Payroll.Employee storage ref)", + "value": "employees" + }, + "id": 317, + "name": "Identifier", + "src": "2195:9:1" + }, + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 309, + "type": "address", + "value": "employeeId" + }, + "id": 318, + "name": "Identifier", + "src": "2205:10:1" + } + ], + "id": 319, + "name": "IndexAccess", + "src": "2195:21:1" + } + ], + "id": 320, + "name": "VariableDeclarationStatement", + "src": "2180:36:1" + }, + { + "children": [ + { + "attributes": { + "argumentTypes": null, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "operator": "=", + "type": "uint256" + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 312, + "type": "uint256", + "value": "salary" + }, + "id": 321, + "name": "Identifier", + "src": "2226:6:1" + }, + { + "attributes": { + "argumentTypes": null, + "isConstant": false, + "isLValue": true, + "isPure": false, + "lValueRequested": false, + "member_name": "salary", + "referencedDeclaration": 62, + "type": "uint256" + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 316, + "type": "struct Payroll.Employee storage pointer", + "value": "employee" + }, + "id": 322, + "name": "Identifier", + "src": "2235:8:1" + } + ], + "id": 323, + "name": "MemberAccess", + "src": "2235:15:1" + } + ], + "id": 324, + "name": "Assignment", + "src": "2226:24:1" + } + ], + "id": 325, + "name": "ExpressionStatement", + "src": "2226:24:1" + }, + { + "children": [ + { + "attributes": { + "argumentTypes": null, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "operator": "=", + "type": "uint256" + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 314, + "type": "uint256", + "value": "lastPayday" + }, + "id": 326, + "name": "Identifier", + "src": "2260:10:1" + }, + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 314, + "type": "uint256", + "value": "lastPayday" + }, + "id": 327, + "name": "Identifier", + "src": "2273:10:1" + } + ], + "id": 328, + "name": "Assignment", + "src": "2260:23:1" + } + ], + "id": 329, + "name": "ExpressionStatement", + "src": "2260:23:1" + } + ], + "id": 330, + "name": "Block", + "src": "2170:120:1" + } + ], + "id": 331, + "name": "FunctionDefinition", + "src": "2076:214:1" + }, + { + "attributes": { + "constant": false, + "implemented": true, + "isConstructor": false, + "modifiers": [ + null + ], + "name": "getPaid", + "payable": false, + "scope": 417, + "stateMutability": "nonpayable", + "superFunction": null, + "visibility": "public" + }, + "children": [ + { + "attributes": { + "parameters": [ + null + ] + }, + "children": [], + "id": 332, + "name": "ParameterList", + "src": "2316:2:1" + }, + { + "attributes": { + "parameters": [ + null + ] + }, + "children": [], + "id": 333, + "name": "ParameterList", + "src": "2326:0:1" + }, + { + "children": [ + { + "attributes": { + "assignments": [ + 334 + ] + }, + "children": [ + { + "attributes": { + "constant": false, + "name": "employee", + "scope": 384, + "stateVariable": false, + "storageLocation": "default", + "type": "struct Payroll.Employee storage pointer", + "typeName": null, + "value": null, + "visibility": "internal" + }, + "children": [], + "id": 334, + "name": "VariableDeclaration", + "src": "2334:12:1" + }, + { + "attributes": { + "argumentTypes": null, + "isConstant": false, + "isLValue": true, + "isPure": false, + "lValueRequested": false, + "type": "struct Payroll.Employee storage ref" + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 77, + "type": "mapping(address => struct Payroll.Employee storage ref)", + "value": "employees" + }, + "id": 335, + "name": "Identifier", + "src": "2349:9:1" + }, + { + "attributes": { + "argumentTypes": null, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "member_name": "sender", + "referencedDeclaration": null, + "type": "address" + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 429, + "type": "msg", + "value": "msg" + }, + "id": 336, + "name": "Identifier", + "src": "2359:3:1" + } + ], + "id": 337, + "name": "MemberAccess", + "src": "2359:10:1" + } + ], + "id": 338, + "name": "IndexAccess", + "src": "2349:21:1" + } + ], + "id": 339, + "name": "VariableDeclarationStatement", + "src": "2334:36:1" + }, + { + "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_bool", + "typeString": "bool" + } + ], + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 420, + "type": "function (bool) pure", + "value": "assert" + }, + "id": 340, + "name": "Identifier", + "src": "2378:6:1" + }, + { + "attributes": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_address", + "typeString": "address" + }, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "operator": "!=", + "type": "bool" + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "isConstant": false, + "isLValue": true, + "isPure": false, + "lValueRequested": false, + "member_name": "id", + "referencedDeclaration": 60, + "type": "address" + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 334, + "type": "struct Payroll.Employee storage pointer", + "value": "employee" + }, + "id": 341, + "name": "Identifier", + "src": "2385:8:1" + } + ], + "id": 342, + "name": "MemberAccess", + "src": "2385:11:1" + }, + { + "attributes": { + "argumentTypes": null, + "hexvalue": "307830", + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "subdenomination": null, + "token": "number", + "type": "int_const 0", + "value": "0x0" + }, + "id": 343, + "name": "Literal", + "src": "2400:3:1" + } + ], + "id": 344, + "name": "BinaryOperation", + "src": "2385:18:1" + } + ], + "id": 345, + "name": "FunctionCall", + "src": "2378:26:1" + } + ], + "id": 346, + "name": "ExpressionStatement", + "src": "2378:26:1" + }, + { + "attributes": { + "assignments": [ + 348 + ] + }, + "children": [ + { + "attributes": { + "constant": false, + "name": "nextPayday", + "scope": 384, + "stateVariable": false, + "storageLocation": "default", + "type": "uint256", + "value": null, + "visibility": "internal" + }, + "children": [ + { + "attributes": { + "name": "uint", + "type": "uint256" + }, + "id": 347, + "name": "ElementaryTypeName", + "src": "2412:4:1" + } + ], + "id": 348, + "name": "VariableDeclaration", + "src": "2412:15:1" + }, + { + "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": true, + "isPure": false, + "lValueRequested": false, + "member_name": "lastPayday", + "referencedDeclaration": 64, + "type": "uint256" + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "isConstant": false, + "isLValue": true, + "isPure": false, + "lValueRequested": false, + "type": "struct Payroll.Employee storage ref" + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 77, + "type": "mapping(address => struct Payroll.Employee storage ref)", + "value": "employees" + }, + "id": 349, + "name": "Identifier", + "src": "2430:9:1" + }, + { + "attributes": { + "argumentTypes": null, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "member_name": "sender", + "referencedDeclaration": null, + "type": "address" + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 429, + "type": "msg", + "value": "msg" + }, + "id": 350, + "name": "Identifier", + "src": "2440:3:1" + } + ], + "id": 351, + "name": "MemberAccess", + "src": "2440:10:1" + } + ], + "id": 352, + "name": "IndexAccess", + "src": "2430:21:1" + } + ], + "id": 353, + "name": "MemberAccess", + "src": "2430:32:1" + }, + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 68, + "type": "uint256", + "value": "payDuration" + }, + "id": 354, + "name": "Identifier", + "src": "2465:11:1" + } + ], + "id": 355, + "name": "BinaryOperation", + "src": "2430:46:1" + } + ], + "id": 356, + "name": "VariableDeclarationStatement", + "src": "2412:64:1" + }, + { + "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_bool", + "typeString": "bool" + } + ], + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 420, + "type": "function (bool) pure", + "value": "assert" + }, + "id": 357, + "name": "Identifier", + "src": "2484:6:1" + }, + { + "attributes": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "operator": "<", + "type": "bool" + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 348, + "type": "uint256", + "value": "nextPayday" + }, + "id": 358, + "name": "Identifier", + "src": "2491:10:1" + }, + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 431, + "type": "uint256", + "value": "now" + }, + "id": 359, + "name": "Identifier", + "src": "2504:3:1" + } + ], + "id": 360, + "name": "BinaryOperation", + "src": "2491:16:1" + } + ], + "id": 361, + "name": "FunctionCall", + "src": "2484:24:1" + } + ], + "id": 362, + "name": "ExpressionStatement", + "src": "2484:24:1" + }, + { + "children": [ + { + "attributes": { + "argumentTypes": null, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "operator": "=", + "type": "uint256" + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "isConstant": false, + "isLValue": true, + "isPure": false, + "lValueRequested": true, + "member_name": "lastPayday", + "referencedDeclaration": 64, + "type": "uint256" + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "isConstant": false, + "isLValue": true, + "isPure": false, + "lValueRequested": false, + "type": "struct Payroll.Employee storage ref" + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 77, + "type": "mapping(address => struct Payroll.Employee storage ref)", + "value": "employees" + }, + "id": 363, + "name": "Identifier", + "src": "2516:9:1" + }, + { + "attributes": { + "argumentTypes": null, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "member_name": "sender", + "referencedDeclaration": null, + "type": "address" + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 429, + "type": "msg", + "value": "msg" + }, + "id": 364, + "name": "Identifier", + "src": "2526:3:1" + } + ], + "id": 365, + "name": "MemberAccess", + "src": "2526:10:1" + } + ], + "id": 366, + "name": "IndexAccess", + "src": "2516:21:1" + } + ], + "id": 367, + "name": "MemberAccess", + "src": "2516:32:1" + }, + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 348, + "type": "uint256", + "value": "nextPayday" + }, + "id": 368, + "name": "Identifier", + "src": "2551:10:1" + } + ], + "id": 369, + "name": "Assignment", + "src": "2516:45:1" + } + ], + "id": 370, + "name": "ExpressionStatement", + "src": "2516:45:1" + }, + { + "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_uint256", + "typeString": "uint256" + } + ], + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "member_name": "transfer", + "referencedDeclaration": null, + "type": "function (uint256)" + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "isConstant": false, + "isLValue": true, + "isPure": false, + "lValueRequested": false, + "member_name": "id", + "referencedDeclaration": 60, + "type": "address" + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 334, + "type": "struct Payroll.Employee storage pointer", + "value": "employee" + }, + "id": 371, + "name": "Identifier", + "src": "2569:8:1" + } + ], + "id": 374, + "name": "MemberAccess", + "src": "2569:11:1" + } + ], + "id": 375, + "name": "MemberAccess", + "src": "2569:20:1" + }, + { + "attributes": { + "argumentTypes": null, + "isConstant": false, + "isLValue": true, + "isPure": false, + "lValueRequested": false, + "member_name": "salary", + "referencedDeclaration": 62, + "type": "uint256" + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "isConstant": false, + "isLValue": true, + "isPure": false, + "lValueRequested": false, + "type": "struct Payroll.Employee storage ref" + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 77, + "type": "mapping(address => struct Payroll.Employee storage ref)", + "value": "employees" + }, + "id": 376, + "name": "Identifier", + "src": "2590:9:1" + }, + { + "attributes": { + "argumentTypes": null, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "member_name": "sender", + "referencedDeclaration": null, + "type": "address" + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 429, + "type": "msg", + "value": "msg" + }, + "id": 377, + "name": "Identifier", + "src": "2600:3:1" + } + ], + "id": 378, + "name": "MemberAccess", + "src": "2600:10:1" + } + ], + "id": 379, + "name": "IndexAccess", + "src": "2590:21:1" + } + ], + "id": 380, + "name": "MemberAccess", + "src": "2590:28:1" + } + ], + "id": 381, + "name": "FunctionCall", + "src": "2569:50:1" + } + ], + "id": 382, + "name": "ExpressionStatement", + "src": "2569:50:1" + } + ], + "id": 383, + "name": "Block", + "src": "2326:300:1" + } + ], + "id": 384, + "name": "FunctionDefinition", + "src": "2300:326:1" + }, + { + "attributes": { + "constant": false, + "implemented": true, + "isConstructor": false, + "name": "changePaymentAddress", + "payable": false, + "scope": 417, + "stateMutability": "nonpayable", + "superFunction": null, + "visibility": "public" + }, + "children": [ + { + "children": [ + { + "attributes": { + "constant": false, + "name": "EmployeeId", + "scope": 416, + "stateVariable": false, + "storageLocation": "default", + "type": "address", + "value": null, + "visibility": "internal" + }, + "children": [ + { + "attributes": { + "name": "address", + "type": "address" + }, + "id": 385, + "name": "ElementaryTypeName", + "src": "2666:7:1" + } + ], + "id": 386, + "name": "VariableDeclaration", + "src": "2666:18:1" + }, + { + "attributes": { + "constant": false, + "name": "newAddress", + "scope": 416, + "stateVariable": false, + "storageLocation": "default", + "type": "address", + "value": null, + "visibility": "internal" + }, + "children": [ + { + "attributes": { + "name": "address", + "type": "address" + }, + "id": 387, + "name": "ElementaryTypeName", + "src": "2686:7:1" + } + ], + "id": 388, + "name": "VariableDeclaration", + "src": "2686:18:1" + } + ], + "id": 389, + "name": "ParameterList", + "src": "2665:40:1" + }, + { + "attributes": { + "parameters": [ + null + ] + }, + "children": [], + "id": 393, + "name": "ParameterList", + "src": "2733:0:1" + }, + { + "children": [ + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 101, + "type": "modifier (address)", + "value": "onlySelf" + }, + "id": 390, + "name": "Identifier", + "src": "2713:8:1" + }, + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 386, + "type": "address", + "value": "EmployeeId" + }, + "id": 391, + "name": "Identifier", + "src": "2722:10:1" + } + ], + "id": 392, + "name": "ModifierInvocation", + "src": "2713:20:1" + }, + { + "children": [ + { + "attributes": { + "assignments": [ + 394 + ] + }, + "children": [ + { + "attributes": { + "constant": false, + "name": "employee", + "scope": 416, + "stateVariable": false, + "storageLocation": "default", + "type": "struct Payroll.Employee storage pointer", + "typeName": null, + "value": null, + "visibility": "internal" + }, + "children": [], + "id": 394, + "name": "VariableDeclaration", + "src": "2741:12:1" + }, + { + "attributes": { + "argumentTypes": null, + "isConstant": false, + "isLValue": true, + "isPure": false, + "lValueRequested": false, + "type": "struct Payroll.Employee storage ref" + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 77, + "type": "mapping(address => struct Payroll.Employee storage ref)", + "value": "employees" + }, + "id": 395, + "name": "Identifier", + "src": "2756:9:1" + }, + { + "attributes": { + "argumentTypes": null, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "member_name": "sender", + "referencedDeclaration": null, + "type": "address" + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 429, + "type": "msg", + "value": "msg" + }, + "id": 396, + "name": "Identifier", + "src": "2766:3:1" + } + ], + "id": 397, + "name": "MemberAccess", + "src": "2766:10:1" + } + ], + "id": 398, + "name": "IndexAccess", + "src": "2756:21:1" + } + ], + "id": 399, + "name": "VariableDeclarationStatement", + "src": "2741:36:1" + }, + { + "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_bool", + "typeString": "bool" + } + ], + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 420, + "type": "function (bool) pure", + "value": "assert" + }, + "id": 400, + "name": "Identifier", + "src": "2785:6:1" + }, + { + "attributes": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_address", + "typeString": "address" + }, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "operator": "!=", + "type": "bool" + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "isConstant": false, + "isLValue": true, + "isPure": false, + "lValueRequested": false, + "member_name": "id", + "referencedDeclaration": 60, + "type": "address" + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 394, + "type": "struct Payroll.Employee storage pointer", + "value": "employee" + }, + "id": 401, + "name": "Identifier", + "src": "2792:8:1" + } + ], + "id": 402, + "name": "MemberAccess", + "src": "2792:11:1" + }, + { + "attributes": { + "argumentTypes": null, + "hexvalue": "307830", + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "subdenomination": null, + "token": "number", + "type": "int_const 0", + "value": "0x0" + }, + "id": 403, + "name": "Literal", + "src": "2807:3:1" + } + ], + "id": 404, + "name": "BinaryOperation", + "src": "2792:18:1" + } + ], + "id": 405, + "name": "FunctionCall", + "src": "2785:26:1" + } + ], + "id": 406, + "name": "ExpressionStatement", + "src": "2785:26:1" + }, + { + "children": [ + { + "attributes": { + "argumentTypes": null, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "operator": "=", + "type": "address" + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "isConstant": false, + "isLValue": true, + "isPure": false, + "lValueRequested": true, + "member_name": "id", + "referencedDeclaration": 60, + "type": "address" + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "isConstant": false, + "isLValue": true, + "isPure": false, + "lValueRequested": false, + "type": "struct Payroll.Employee storage ref" + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 77, + "type": "mapping(address => struct Payroll.Employee storage ref)", + "value": "employees" + }, + "id": 407, + "name": "Identifier", + "src": "2819:9:1" + }, + { + "attributes": { + "argumentTypes": null, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "member_name": "sender", + "referencedDeclaration": null, + "type": "address" + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 429, + "type": "msg", + "value": "msg" + }, + "id": 408, + "name": "Identifier", + "src": "2829:3:1" + } + ], + "id": 409, + "name": "MemberAccess", + "src": "2829:10:1" + } + ], + "id": 410, + "name": "IndexAccess", + "src": "2819:21:1" + } + ], + "id": 411, + "name": "MemberAccess", + "src": "2819:24:1" + }, + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 388, + "type": "address", + "value": "newAddress" + }, + "id": 412, + "name": "Identifier", + "src": "2846:10:1" + } + ], + "id": 413, + "name": "Assignment", + "src": "2819:37:1" + } + ], + "id": 414, + "name": "ExpressionStatement", + "src": "2819:37:1" + } + ], + "id": 415, + "name": "Block", + "src": "2733:130:1" + } + ], + "id": 416, + "name": "FunctionDefinition", + "src": "2636:227:1" + } + ], + "id": 417, + "name": "ContractDefinition", + "src": "64:2801:1" + } + ], + "id": 418, + "name": "SourceUnit", + "src": "38:2828:1" + }, + "compiler": { + "name": "solc", + "version": "0.4.18+commit.9cf6e910.Emscripten.clang" + }, + "networks": {}, + "schemaVersion": "1.0.1", + "updatedAt": "2018-01-29T01:03:36.159Z" +} \ No newline at end of file diff --git a/Lesson4/assignment/contracts/Migrations.sol b/Lesson4/assignment/contracts/Migrations.sol new file mode 100644 index 000000000..f170cb4fa --- /dev/null +++ b/Lesson4/assignment/contracts/Migrations.sol @@ -0,0 +1,23 @@ +pragma solidity ^0.4.17; + +contract Migrations { + address public owner; + uint public last_completed_migration; + + modifier restricted() { + if (msg.sender == owner) _; + } + + function Migrations() public { + owner = msg.sender; + } + + function setCompleted(uint completed) public restricted { + last_completed_migration = completed; + } + + function upgrade(address new_address) public restricted { + Migrations upgraded = Migrations(new_address); + upgraded.setCompleted(last_completed_migration); + } +} diff --git a/Lesson4/assignment/contracts/Payroll.sol b/Lesson4/assignment/contracts/Payroll.sol new file mode 100644 index 000000000..8a0b39f09 --- /dev/null +++ b/Lesson4/assignment/contracts/Payroll.sol @@ -0,0 +1,94 @@ +/*作业请提交在这个目录下*/ +pragma solidity ^0.4.14; + +contract Payroll { + struct Employee { + address id; + uint salary; + uint lastPayday; + } + + uint constant payDuration = 10 seconds; + uint totalSalary = 0; + + address owner; + mapping (address => Employee) private employees; + + modifier onlyOwner() { + require(owner == msg.sender); + _; + } + + modifier onlySelf(address employeeId) { + require(employeeId == msg.sender); + _; + } + + function Payroll() public { + owner = msg.sender; + } + + function _partialPaid(Employee employee) private { + uint amount = (now - employee.lastPayday) / payDuration * employee.salary; + employee.id.transfer(amount); + } + + function addEmployee(address employeeId, uint salary) public onlyOwner { + var employee = employees[employeeId]; + assert(employee.id == 0x0); + employees[employeeId] = Employee(employeeId, salary, now); + totalSalary += salary * 1 ether; + } + + function removeEmployee(address employeeId) public onlyOwner { + var employee = employees[employeeId]; + assert(employee.id != 0x0); + _partialPaid(employees[employeeId]); + delete employees[employeeId]; + totalSalary -= employees[employeeId].salary * 1 ether; + } + + function updateEmployee(address employeeId, uint salary) public onlyOwner { + var employee = employees[employeeId]; + assert(employee.id != 0x0); + _partialPaid(employee); + totalSalary -= employees[employeeId].salary; + employees[employeeId].salary = salary * 1 ether; + employees[employeeId].lastPayday = now; + totalSalary += salary * 1 ether; + } + + function addFund() payable public returns (uint) { + return this.balance; + } + + function calculateRunway() public view returns (uint) { + assert(totalSalary > 0); + return this.balance / totalSalary; + } + + function hasEnoughFund() public view returns (bool) { + return calculateRunway() > 0; + } + + function checkEmployee(address employeeId) public view returns (uint salary, uint lastPayday) { + var employee = employees[employeeId]; + salary = employee.salary; + lastPayday = lastPayday; + } + + function getPaid() public { + var employee = employees[msg.sender]; + assert(employee.id != 0x0); + uint nextPayday = employees[msg.sender].lastPayday + payDuration; + assert(nextPayday < now); + employees[msg.sender].lastPayday = nextPayday; + employee.id.transfer(employees[msg.sender].salary); + } + + function changePaymentAddress(address EmployeeId, address newAddress) public onlySelf(EmployeeId){ + var employee = employees[msg.sender]; + assert(employee.id != 0x0); + employees[msg.sender].id = newAddress; + } +} diff --git a/Lesson4/assignment/migrations/1_initial_migration.js b/Lesson4/assignment/migrations/1_initial_migration.js new file mode 100644 index 000000000..4d5f3f9b0 --- /dev/null +++ b/Lesson4/assignment/migrations/1_initial_migration.js @@ -0,0 +1,5 @@ +var Migrations = artifacts.require("./Migrations.sol"); + +module.exports = function(deployer) { + deployer.deploy(Migrations); +}; diff --git a/Lesson4/assignment/package-lock.json b/Lesson4/assignment/package-lock.json new file mode 100644 index 000000000..48e341a09 --- /dev/null +++ b/Lesson4/assignment/package-lock.json @@ -0,0 +1,3 @@ +{ + "lockfileVersion": 1 +} diff --git a/Lesson4/assignment/test/TestPayroll.sol b/Lesson4/assignment/test/TestPayroll.sol new file mode 100644 index 000000000..23e7c280d --- /dev/null +++ b/Lesson4/assignment/test/TestPayroll.sol @@ -0,0 +1,25 @@ +pragma solidity ^0.4.2; + +import "truffle/Assert.sol"; +import "truffle/DeployedAddresses.sol"; +import "../contracts/Payroll.sol"; + +contract TestPayroll { + Payroll payroll = Payroll(DeployedAddresses.Payroll()); + address e = 0xb1b669fc2d2a6e2e0574704e6e569dd0bb97f6ee; + uint salary = 10; + + function testAddEmployee() public { + payroll.addEmployee(e, salary); + var (sal, lastPayday) = payroll.checkEmployee(e); + Assert.equal(sal, salary, "It should store 10"); + Assert.notEqual(lastPayday, 0, "It should store 10"); + } + + function testRemoveEmployee() public { + payroll.removeEmployee(e); + var (sal, lastPayday) = payroll.checkEmployee(e); + Assert.equal(sal, 0, "It should store 0"); + Assert.equal(lastPayday, 0, "It should store 10"); + } +} diff --git a/Lesson4/assignment/truffle-config.js b/Lesson4/assignment/truffle-config.js new file mode 100644 index 000000000..a6330d6d5 --- /dev/null +++ b/Lesson4/assignment/truffle-config.js @@ -0,0 +1,4 @@ +module.exports = { + // See + // to customize your Truffle configuration! +}; diff --git a/Lesson4/assignment/truffle.js b/Lesson4/assignment/truffle.js new file mode 100644 index 000000000..fe90faf7c --- /dev/null +++ b/Lesson4/assignment/truffle.js @@ -0,0 +1,11 @@ +module.exports = { + // See + // to customize your Truffle configuration! + networks: { + development: { + host: "localhost", + port: 8545, + network_id: "*" // 匹配任何network id + } + } +}; diff --git a/Lesson4/orgin/README.md b/Lesson4/orgin/README.md new file mode 100644 index 000000000..c27ba052f --- /dev/null +++ b/Lesson4/orgin/README.md @@ -0,0 +1,3 @@ +## 硅谷live以太坊智能合约 第四课 + +这里是每一课的初始代码,有需要的同学可以参考 diff --git a/Lesson4/orgin/payroll.sol b/Lesson4/orgin/payroll.sol new file mode 100644 index 000000000..8b1378917 --- /dev/null +++ b/Lesson4/orgin/payroll.sol @@ -0,0 +1 @@ + diff --git a/Lesson5/README.md b/Lesson5/README.md new file mode 100644 index 000000000..0d3ed1d1e --- /dev/null +++ b/Lesson5/README.md @@ -0,0 +1,13 @@ +## 硅谷live以太坊智能合约频道官方地址 + +### 第五课 + +目录结构 +
| +
|--orgin 课程初始代码 +
| +
|--assignment 课程作业提交代码 +
+ +### 本节知识点 + diff --git a/Lesson5/assignment/LICENSE b/Lesson5/assignment/LICENSE new file mode 100644 index 000000000..8dada3eda --- /dev/null +++ b/Lesson5/assignment/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "{}" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright {yyyy} {name of copyright owner} + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/Lesson5/assignment/README.md b/Lesson5/assignment/README.md new file mode 100644 index 000000000..7c98c0387 --- /dev/null +++ b/Lesson5/assignment/README.md @@ -0,0 +1,13 @@ +# payroll + +A payroll system developed with React and Solidty for Ethereum Blockchain platform. + +## Get Started + +1. Install dependencies `npm install -g truffle ethereumjs-testrpc` +1. Install [Metamask](https://metamask.io/) +1. Run `testrpc` +1. Add first account in testrpc to Metamask by importing private key +1. Run `truffle compile` in the project directory +1. `truffle migrate` +1. `npm run start` diff --git a/Lesson5/assignment/box-img-lg.png b/Lesson5/assignment/box-img-lg.png new file mode 100644 index 000000000..60c19962a Binary files /dev/null and b/Lesson5/assignment/box-img-lg.png differ diff --git a/Lesson5/assignment/box-img-sm.png b/Lesson5/assignment/box-img-sm.png new file mode 100644 index 000000000..466e7097e Binary files /dev/null and b/Lesson5/assignment/box-img-sm.png differ diff --git a/Lesson5/assignment/config/env.js b/Lesson5/assignment/config/env.js new file mode 100644 index 000000000..5d0ab7b79 --- /dev/null +++ b/Lesson5/assignment/config/env.js @@ -0,0 +1,28 @@ +// Grab NODE_ENV and REACT_APP_* environment variables and prepare them to be +// injected into the application via DefinePlugin in Webpack configuration. + +var REACT_APP = /^REACT_APP_/i; + +function getClientEnvironment(publicUrl) { + var processEnv = Object + .keys(process.env) + .filter(key => REACT_APP.test(key)) + .reduce((env, key) => { + env[key] = JSON.stringify(process.env[key]); + return env; + }, { + // Useful for determining whether we’re running in production mode. + // Most importantly, it switches React into the correct mode. + 'NODE_ENV': JSON.stringify( + process.env.NODE_ENV || 'development' + ), + // Useful for resolving the correct path to static assets in `public`. + // For example, . + // This should only be used as an escape hatch. Normally you would put + // images into the `src` and `import` them in code to get their paths. + 'PUBLIC_URL': JSON.stringify(publicUrl) + }); + return {'process.env': processEnv}; +} + +module.exports = getClientEnvironment; diff --git a/Lesson5/assignment/config/jest/cssTransform.js b/Lesson5/assignment/config/jest/cssTransform.js new file mode 100644 index 000000000..aa17d127a --- /dev/null +++ b/Lesson5/assignment/config/jest/cssTransform.js @@ -0,0 +1,12 @@ +// This is a custom Jest transformer turning style imports into empty objects. +// http://facebook.github.io/jest/docs/tutorial-webpack.html + +module.exports = { + process() { + return 'module.exports = {};'; + }, + getCacheKey(fileData, filename) { + // The output is always the same. + return 'cssTransform'; + }, +}; diff --git a/Lesson5/assignment/config/jest/fileTransform.js b/Lesson5/assignment/config/jest/fileTransform.js new file mode 100644 index 000000000..927eb305a --- /dev/null +++ b/Lesson5/assignment/config/jest/fileTransform.js @@ -0,0 +1,10 @@ +const path = require('path'); + +// This is a custom Jest transformer turning file imports into filenames. +// http://facebook.github.io/jest/docs/tutorial-webpack.html + +module.exports = { + process(src, filename) { + return 'module.exports = ' + JSON.stringify(path.basename(filename)) + ';'; + }, +}; diff --git a/Lesson5/assignment/config/paths.js b/Lesson5/assignment/config/paths.js new file mode 100644 index 000000000..96c3dfb11 --- /dev/null +++ b/Lesson5/assignment/config/paths.js @@ -0,0 +1,46 @@ +var path = require('path'); +var fs = require('fs'); + +// Make sure any symlinks in the project folder are resolved: +// https://github.com/facebookincubator/create-react-app/issues/637 +var appDirectory = fs.realpathSync(process.cwd()); +function resolveApp(relativePath) { + return path.resolve(appDirectory, relativePath); +} + +// We support resolving modules according to `NODE_PATH`. +// This lets you use absolute paths in imports inside large monorepos: +// https://github.com/facebookincubator/create-react-app/issues/253. + +// It works similar to `NODE_PATH` in Node itself: +// https://nodejs.org/api/modules.html#modules_loading_from_the_global_folders + +// We will export `nodePaths` as an array of absolute paths. +// It will then be used by Webpack configs. +// Jest doesn’t need this because it already handles `NODE_PATH` out of the box. + +// Note that unlike in Node, only *relative* paths from `NODE_PATH` are honored. +// Otherwise, we risk importing Node.js core modules into an app instead of Webpack shims. +// https://github.com/facebookincubator/create-react-app/issues/1023#issuecomment-265344421 + +var nodePaths = (process.env.NODE_PATH || '') + .split(process.platform === 'win32' ? ';' : ':') + .filter(Boolean) + .filter(folder => !path.isAbsolute(folder)) + .map(resolveApp); + +// config after eject: we're in ./config/ +module.exports = { + // Changed from build to build_webpack so smart contract compilations are not overwritten. + appBuild: resolveApp('build_webpack'), + appPublic: resolveApp('public'), + appHtml: resolveApp('public/index.html'), + appIndexJs: resolveApp('src/index.js'), + appPackageJson: resolveApp('package.json'), + appSrc: resolveApp('src'), + yarnLockFile: resolveApp('yarn.lock'), + testsSetup: resolveApp('src/setupTests.js'), + appNodeModules: resolveApp('node_modules'), + ownNodeModules: resolveApp('node_modules'), + nodePaths: nodePaths +}; diff --git a/Lesson5/assignment/config/polyfills.js b/Lesson5/assignment/config/polyfills.js new file mode 100644 index 000000000..7e601502b --- /dev/null +++ b/Lesson5/assignment/config/polyfills.js @@ -0,0 +1,14 @@ +if (typeof Promise === 'undefined') { + // Rejection tracking prevents a common issue where React gets into an + // inconsistent state due to an error, but it gets swallowed by a Promise, + // and the user has no idea what causes React's erratic future behavior. + require('promise/lib/rejection-tracking').enable(); + window.Promise = require('promise/lib/es6-extensions.js'); +} + +// fetch() polyfill for making API calls. +require('whatwg-fetch'); + +// Object.assign() is commonly used with React. +// It will use the native implementation if it's present and isn't buggy. +Object.assign = require('object-assign'); diff --git a/Lesson5/assignment/config/webpack.config.dev.js b/Lesson5/assignment/config/webpack.config.dev.js new file mode 100644 index 000000000..821743a2e --- /dev/null +++ b/Lesson5/assignment/config/webpack.config.dev.js @@ -0,0 +1,242 @@ +var autoprefixer = require('autoprefixer'); +var webpack = require('webpack'); +var HtmlWebpackPlugin = require('html-webpack-plugin'); +var CaseSensitivePathsPlugin = require('case-sensitive-paths-webpack-plugin'); +var InterpolateHtmlPlugin = require('react-dev-utils/InterpolateHtmlPlugin'); +var WatchMissingNodeModulesPlugin = require('react-dev-utils/WatchMissingNodeModulesPlugin'); +var getClientEnvironment = require('./env'); +var paths = require('./paths'); + + + +// Webpack uses `publicPath` to determine where the app is being served from. +// In development, we always serve from the root. This makes config easier. +var publicPath = '/'; +// `publicUrl` is just like `publicPath`, but we will provide it to our app +// as %PUBLIC_URL% in `index.html` and `process.env.PUBLIC_URL` in JavaScript. +// Omit trailing slash as %PUBLIC_PATH%/xyz looks better than %PUBLIC_PATH%xyz. +var publicUrl = ''; +// Get environment variables to inject into our app. +var env = getClientEnvironment(publicUrl); + +// This is the development configuration. +// It is focused on developer experience and fast rebuilds. +// The production configuration is different and lives in a separate file. +module.exports = { + // You may want 'eval' instead if you prefer to see the compiled output in DevTools. + // See the discussion in https://github.com/facebookincubator/create-react-app/issues/343. + devtool: 'cheap-module-source-map', + // These are the "entry points" to our application. + // This means they will be the "root" imports that are included in JS bundle. + // The first two entry points enable "hot" CSS and auto-refreshes for JS. + entry: [ + // Include an alternative client for WebpackDevServer. A client's job is to + // connect to WebpackDevServer by a socket and get notified about changes. + // When you save a file, the client will either apply hot updates (in case + // of CSS changes), or refresh the page (in case of JS changes). When you + // make a syntax error, this client will display a syntax error overlay. + // Note: instead of the default WebpackDevServer client, we use a custom one + // to bring better experience for Create React App users. You can replace + // the line below with these two lines if you prefer the stock client: + // require.resolve('webpack-dev-server/client') + '?/', + // require.resolve('webpack/hot/dev-server'), + require.resolve('react-dev-utils/webpackHotDevClient'), + // We ship a few polyfills by default: + require.resolve('./polyfills'), + // Finally, this is your app's code: + paths.appIndexJs + // We include the app code last so that if there is a runtime error during + // initialization, it doesn't blow up the WebpackDevServer client, and + // changing JS code would still trigger a refresh. + ], + output: { + // Next line is not used in dev but WebpackDevServer crashes without it: + path: paths.appBuild, + // Add /* filename */ comments to generated require()s in the output. + pathinfo: true, + // This does not produce a real file. It's just the virtual path that is + // served by WebpackDevServer in development. This is the JS bundle + // containing code from all our entry points, and the Webpack runtime. + filename: 'static/js/bundle.js', + // This is the URL that app is served from. We use "/" in development. + publicPath: publicPath + }, + resolve: { + // This allows you to set a fallback for where Webpack should look for modules. + // We read `NODE_PATH` environment variable in `paths.js` and pass paths here. + // We use `fallback` instead of `root` because we want `node_modules` to "win" + // if there any conflicts. This matches Node resolution mechanism. + // https://github.com/facebookincubator/create-react-app/issues/253 + fallback: paths.nodePaths, + // These are the reasonable defaults supported by the Node ecosystem. + // We also include JSX as a common component filename extension to support + // some tools, although we do not recommend using it, see: + // https://github.com/facebookincubator/create-react-app/issues/290 + extensions: ['.js', '.json', '.jsx', ''], + alias: { + // Support React Native Web + // https://www.smashingmagazine.com/2016/08/a-glimpse-into-the-future-with-react-native-for-web/ + 'react-native': 'react-native-web' + } + }, + + module: { + // First, run the linter. + // It's important to do this before Babel processes the JS. + preLoaders: [ + { + test: /\.(js|jsx)$/, + loader: 'eslint', + include: paths.appSrc, + } + ], + loaders: [ + // Default loader: load all assets that are not handled + // by other loaders with the url loader. + // Note: This list needs to be updated with every change of extensions + // the other loaders match. + // E.g., when adding a loader for a new supported file extension, + // we need to add the supported extension to this loader too. + // Add one new line in `exclude` for each loader. + // + // "file" loader makes sure those assets get served by WebpackDevServer. + // When you `import` an asset, you get its (virtual) filename. + // In production, they would get copied to the `build` folder. + // "url" loader works like "file" loader except that it embeds assets + // smaller than specified limit in bytes as data URLs to avoid requests. + // A missing `test` is equivalent to a match. + { + exclude: [ + /\.html$/, + /\.(js|jsx)$/, + /\.css$/, + /\.json$/, + /\.woff$/, + /\.woff2$/, + /\.(ttf|svg|eot)$/ + ], + loader: 'url', + query: { + limit: 10000, + name: 'static/media/[name].[hash:8].[ext]' + } + }, + // Process JS with Babel. + { + test: /\.(js|jsx)$/, + include: paths.appSrc, + loader: 'babel', + query: { + + // This is a feature of `babel-loader` for webpack (not Babel itself). + // It enables caching results in ./node_modules/.cache/babel-loader/ + // directory for faster rebuilds. + cacheDirectory: true + } + }, + // "postcss" loader applies autoprefixer to our CSS. + // "css" loader resolves paths in CSS and adds assets as dependencies. + // "style" loader turns CSS into JS modules that inject