Skip to content

Commit

Permalink
chore(deps): update deps and add privacy fix for metamask
Browse files Browse the repository at this point in the history
  • Loading branch information
Maurice Dalderup authored and Maurice Dalderup committed Sep 26, 2019
1 parent 6ceac20 commit b8aa55b
Show file tree
Hide file tree
Showing 10 changed files with 1,126 additions and 868 deletions.
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@ src/__helpers__/
src/__mocks__/
src/**/__tests__/
jest.setup.js
*.json
src/assets/
1 change: 1 addition & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"rules": {
"react/destructuring-assignment": ["off"],
"linebreak-style": ["off"],
"react/sort-comp": "off",
"prettier/prettier": "error",
"react/forbid-prop-types": [1, { "forbid": ["any"] }]
}
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
},
"devDependencies": {
"babel-cli": "6.26.0",
"babel-eslint": "8.2.6",
"babel-core": "^6.26.3",
"babel-eslint": "8.2.3",
"babel-plugin-transform-class-properties": "6.24.1",
"babel-plugin-transform-function-bind": "6.22.0",
"babel-plugin-transform-object-rest-spread": "6.26.0",
Expand All @@ -43,7 +44,7 @@
"eslint-plugin-react": "7.9.1",
"husky": "0.14.3",
"jest": "23.1.0",
"parcel-bundler": "1.10.0",
"parcel-bundler": "1.12.3",
"prettier": "1.13.5",
"raf": "3.4.0",
"react-test-renderer": "16.8.6"
Expand Down
6 changes: 3 additions & 3 deletions src/assets/contract/contracts/Coin.sol
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ contract Coin {
}

modifier onlyByCreator {
require(msg.sender == adminAddress);
require(msg.sender == adminAddress, "Only admins can call this function");
_;
}

Expand All @@ -37,12 +37,12 @@ contract Coin {
}

function burnCoin(address addr, uint amount) public onlyByCreator{
require((spendableCoins[addr] - amount) >= 0);
require((spendableCoins[addr] - amount) >= 0, "Balance cannot be below 0");
spendableCoins[addr] -= amount;
}

function sendCoin(address receiver, uint amount, string reason) public {
require(assignableCoins[msg.sender] >= amount && receiver != msg.sender && amount <= 3);
require(assignableCoins[msg.sender] >= amount && receiver != msg.sender && amount <= 3, "Can't send coins to yourself");
spendableCoins[receiver] = spendableCoins[receiver] + (amount);
assignableCoins[msg.sender] = assignableCoins[msg.sender] - amount;
emit Transfer(msg.sender, receiver, amount, reason, block.timestamp);
Expand Down
3 changes: 0 additions & 3 deletions src/assets/contract/migrations/1_initial_migration.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,3 @@ module.exports = function(deployer) {
deployer.deploy(Migrations);
deployer.deploy(Coin);
};



3 changes: 0 additions & 3 deletions src/assets/contract/truffle.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,3 @@ module.exports = {
}
}
};



11 changes: 8 additions & 3 deletions src/components/DataDisplay/DataDisplay.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,21 @@ import PropTypes from "prop-types";

const DataDisplay = ({ text, data }) => (
<div style={{ fontSize: "14px", textAlign: "left", margin: "auto" }}>
<pre>{text}{data && JSON.stringify(data, null, 2)}</pre>
<pre>
{text}
{data && JSON.stringify(data, null, 2)}
</pre>
</div>
);

DataDisplay.propTypes = {
data: PropTypes.any
text: PropTypes.string,
data: PropTypes.any // eslint-disable-line
};

DataDisplay.defaultProps = {
data: null
data: null,
text: ""
};

export default DataDisplay;
5 changes: 1 addition & 4 deletions src/components/Routing/Routing.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@ import DefaultRoute from "./DefaultRoute";
// import PrivateRoute from "./PrivateRoute";

// Pages
import {
HomePage,
PageNotFound
} from "../../containers";
import { HomePage, PageNotFound } from "../../containers";

class Routing extends PureComponent {
render() {
Expand Down
20 changes: 10 additions & 10 deletions src/containers/Home/HomePage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ class HomePage extends Component {
super(props);

this.state = {
metaMaskAcc: "0x627306090abaB3A6e1400e9345bC60c78a8BEf57",
otherRandomAcc: "",
metaMaskAcc: "0xBd043c73089D14F0CE6db2518F6B721cCB3c2DC6",
gasCost: 0,
account: {},
contract: {},
Expand All @@ -26,21 +25,14 @@ class HomePage extends Component {
}

async componentDidMount() {
window.ethereum.enable();
this.web3Service = await new Web3Service(CoinContract); // no param, assuming metamask
this.setState({
contract: this.web3Service.getContract(),
account: this.web3Service.createAccount().address
});
}

calculateGas = async userToAdd => {
const { contract } = this.state;
await this.setState({
gasCost: await contract.methods.addUser(userToAdd.value).estimateGas()
});
this.openNotification(`Gas calculated! ${this.state.gasCost}`);
};

addUser = async userToAdd => {
const { contract, metaMaskAcc } = this.state;
await this.setState({
Expand All @@ -53,6 +45,14 @@ class HomePage extends Component {
);
};

calculateGas = async userToAdd => {
const { contract } = this.state;
await this.setState({
gasCost: await contract.methods.addUser(userToAdd.value).estimateGas()
});
this.openNotification(`Gas calculated! ${this.state.gasCost}`);
};

initializeUser = async amountCoins => {
const { account, contract, metaMaskAcc } = this.state;
await this.setState({
Expand Down

0 comments on commit b8aa55b

Please sign in to comment.