feat: Add contract to template, support for latest embark

Add contract as part of the default template.

Add support for latest embark (embarkjs-ipfs, embarkjs-whisper).
This commit is contained in:
emizzle 2019-04-08 12:39:06 +10:00
parent 0198a8825b
commit ceaba14dcd
No known key found for this signature in database
GPG Key ID: 1FD4BAB3C37EE9BA
6 changed files with 16329 additions and 12 deletions

View File

@ -0,0 +1,17 @@
pragma solidity ^0.5.0;
contract SimpleStorage {
uint public storedData;
constructor(uint initialValue) public {
storedData = initialValue;
}
function set(uint x) public {
storedData = x;
}
function get() public view returns (uint retVal) {
return storedData;
}
}

View File

@ -13,7 +13,7 @@
"config": "embarkConfig/",
"versions": {
"web3": "1.0.0-beta",
"solc": "0.4.25",
"solc": "0.5.0",
"ipfs-api": "17.2.4"
},
"plugins": {

View File

@ -53,9 +53,9 @@ module.exports = {
contracts: {
// example:
//SimpleStorage: {
// args: [ 100 ]
//}
SimpleStorage: {
args: [ 100 ]
}
}
},

16287
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -3,10 +3,13 @@
"version": "0.1.0",
"dependencies": {
"@babel/runtime-corejs2": "^7.3.1",
"babel-loader": "^8.0.5",
"embarkjs-connector-web3": "4.0.0",
"embarkjs-ipfs": "4.0.0",
"embarkjs-whisper": "4.0.0",
"react": "^16.8.2",
"react-dom": "^16.8.2",
"react-scripts": "2.1.5",
"embarkjs-connector-web3": "4.0.0-beta.0"
"react-scripts": "2.1.5"
},
"scripts": {
"start": "react-scripts start",

View File

@ -1,8 +1,8 @@
/*global web3*/
import React from 'react';
import EmbarkJS from './embarkArtifacts/embarkjs';
import config from './embarkArtifacts/config/blockchain';
import SimpleStorage from './embarkArtifacts/contracts/SimpleStorage';
class App extends React.Component {
@ -18,16 +18,26 @@ class App extends React.Component {
if (err) {
throw err;
}
this.setState({loading: false});
SimpleStorage.methods.get().call().then((contractVal) => {
this.setState({
loading: false,
contractVal
});
});
});
}
render() {
if (this.state.loading) {
return 'Loading...';
}
return 'Ready!';
if (this.state.loading) {
return 'Loading...';
}
return (
<React.Fragment>
<h3>Value stored in SimpleStorage contract:</h3>
{this.state.contractVal}
</React.Fragment>
);
}
}