update to embark 4.0.1

This commit is contained in:
Ricardo Guilherme Schmidt 2019-03-28 20:10:02 -03:00
parent f8662ebc54
commit 6481de087b
No known key found for this signature in database
GPG Key ID: BFB3F5C8ED618A94
20 changed files with 212 additions and 217 deletions

View File

@ -1,3 +0,0 @@
{
"presets": ["@babel/preset-env"]
}

View File

@ -1,9 +0,0 @@
{
"extends": "airbnb",
"plugins": [
"react"
],
"rules": {
"react/prop-types": 0
}
}

10
.gitignore vendored
View File

@ -4,9 +4,16 @@ __pycache__/
*$py.class
# embark
.embark/
.embark
chains.json
.password
flattenedContracts
embarkArtifacts
config/livenet/password
config/production/password
dist
embarkArtifacts
# egg-related
viper.egg-info/
@ -40,3 +47,4 @@ package-lock.json
# other
.vs/
bin/
.trash/

View File

@ -1,19 +1,15 @@
# status.im contracts
Requires https://github.com/creationix/nvm
# status.im bootstrap contracts
Requires embark 4.0.1. Recommended use of https://github.com/creationix/nvm
Usage:
```
nvm install v8.9.4
nvm use v8.9.4
nvm install v10.15
nvm use v10.15
npm install -g embark
git clone https://github.com/status-im/contracts.git
cd contracts
git checkout bootstrap
npm install
embark simulator
embark test
embark run
```
| Contract | Deploy | Test | UI |
| -------------------------------------- | ------ | ---- | --- |
| token/TestToken | Yes | Yes | Yes |
| token/ERC20Token | No | Yes | Yes |

View File

@ -1,18 +1,8 @@
.navbar {
}
.accounts {
float: right;
margin-right: 17px;
font-family: monospace;
div {
margin: 15px;
}
.identicon {
border-radius: 50%;
}
.logs {
background-color: black;
font-size: 14px;
@ -59,5 +49,9 @@
}
input.form-control {
margin: 5px;
}
margin-right: 5px;
}
.alert-result {
margin-left: 0;
}

View File

@ -1,42 +1,81 @@
import React from 'react';
import { Tabs, Tab } from 'react-bootstrap';
import ReactDOM from 'react-dom';
import {Tabs, Tab} from 'react-bootstrap';
import EmbarkJS from 'Embark/EmbarkJS';
import TestStatusNetworkUI from './components/TestStatusNetwork';
import './dapp.css';
class DApp extends React.Component {
class App extends React.Component {
constructor(props) {
super(props);
this.handleSelect = this.handleSelect.bind(this);
this.state = {
error: null,
activeKey: 1,
whisperEnabled: false,
storageEnabled: false,
blockchainEnabled: false
};
}
componentDidMount(){
componentDidMount() {
EmbarkJS.onReady((err) => {
this.setState({blockchainEnabled: true});
if (err) {
// If err is not null then it means something went wrong connecting to ethereum
// you can use this to ask the user to enable metamask for e.g
return this.setState({error: err.message || err});
}
EmbarkJS.Messages.Providers.whisper.getWhisperVersion((err, _version) => {
if (err) {
return console.log(err);
}
this.setState({whisperEnabled: true});
});
EmbarkJS.Storage.isAvailable().then((result) => {
this.setState({storageEnabled: result});
}).catch(() => {
this.setState({storageEnabled: false});
});
});
}
_renderStatus(title, available) {
let className = available ? 'pull-right status-online' : 'pull-right status-offline';
return <React.Fragment>
{title}
{title}
<span className={className}></span>
</React.Fragment>;
}
render(){
return (
<div>
handleSelect(key) {
this.setState({ activeKey: key });
}
<Tabs defaultActiveKey={1} id="uncontrolled-tab-example">
<Tab eventKey={1} title="TestStatusNetwork">
<TestStatusNetworkUI />
</Tab>
</Tabs>
render() {
const ensEnabled = EmbarkJS.Names.currentNameSystems && EmbarkJS.Names.isAvailable();
if (this.state.error) {
return (<div>
<div>Something went wrong connecting to ethereum. Please make sure you have a node running or are using metamask to connect to the ethereum network:</div>
<div>{this.state.error}</div>
</div>);
}
return (<div>
<h3>Status Network - Test </h3>
<Tabs onSelect={this.handleSelect} activeKey={this.state.activeKey} id="uncontrolled-tab-example">
<Tab eventKey={1} title={this._renderStatus('StatusNetwork', this.state.blockchainEnabled)}>
<TestStatusNetworkUI />
</Tab>
</Tabs>
</div>);
}
}
export default DApp;
ReactDOM.render(<App></App>, document.getElementById('app'));

0
app/images/.gitkeep Normal file
View File

View File

@ -1,12 +1,12 @@
<html>
<head>
<title>Status.im - Contracts</title>
<title>Status Network - Test Demo</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
</head>
<body class="container">
<div id="app">
</div>
<script src="js/index.js" type="text/javascript"></script>
<script src="js/dapp.js"></script>
</body>
</html>

View File

@ -1,9 +0,0 @@
import React from 'react';
import { render } from 'react-dom';
import DApp from './dapp';
import './dapp.css';
render(
<DApp />,
document.getElementById('app')
);

View File

@ -1,61 +1,59 @@
module.exports = {
development: {
default: {
enabled: true,
networkType: "custom", // Can be: testnet, rinkeby, livenet or custom, in which case, it will use the specified networkId
networkId: "1337", // Network id used when networkType is custom
isDev: true, // Uses and ephemeral proof-of-authority network with a pre-funded developer account, mining enabled
genesisBlock: "config/development/genesis.json", // Genesis block to initiate on first creation of a development node
datadir: ".embark/development/datadir", // Data directory for the databases and keystore
mineWhenNeeded: true, // Uses our custom script (if isDev is false) to mine only when needed
nodiscover: true, // Disables the peer discovery mechanism (manual peer addition)
maxpeers: 0, // Maximum number of network peers (network disabled if set to 0) (default: 25)
rpcHost: "localhost", // HTTP-RPC server listening interface (default: "localhost")
rpcPort: 8545, // HTTP-RPC server listening port (default: 8545)
rpcCorsDomain: "auto", // Comma separated list of domains from which to accept cross origin requests (browser enforced)
// When set to "auto", Embark will automatically set the cors to the address of the webserver
proxy: true, // Proxy is used to present meaningful information about transactions
accounts: [
{
nodeAccounts: true,
password: "config/development/.password"
}
],
targetGasLimit: 8000000, // Target gas limit sets the artificial target gas floor for the blocks to mine
wsRPC: true, // Enable the WS-RPC server
wsOrigins: "auto", // Origins from which to accept websockets requests
// When set to "auto", Embark will automatically set the cors to the address of the webserver
wsHost: "localhost", // WS-RPC server listening interface (default: "localhost")
wsPort: 8546, // WS-RPC server listening port (default: 8546)
simulatorBlocktime: 0 // Specify blockTime in seconds for automatic mining. Default is 0 and no auto-mining.
rpcHost: "localhost",
rpcPort: 8545,
rpcCorsDomain: {
auto: true,
additionalCors: []
},
wsRPC: true,
wsOrigins: {
auto: true,
additionalCors: []
},
wsHost: "localhost",
wsPort: 8546
},
development: {
ethereumClientName: "geth",
networkType: "custom",
networkId: 1337,
isDev: true,
datadir: ".embark/development/datadir",
mineWhenNeeded: true,
nodiscover: true,
maxpeers: 0,
proxy: true,
targetGasLimit: 8000000,
simulatorBlocktime: 0
},
testnet: {
enabled: true,
networkType: "testnet",
syncMode: "light",
rpcHost: "localhost",
rpcPort: 8545,
rpcCorsDomain: "http://localhost:8000",
accounts: [
{
nodeAccounts: true,
password: "config/testnet/.password"
}
],
]
},
livenet: {
enabled: false,
networkType: "livenet",
syncMode: "light",
rpcHost: "localhost",
rpcPort: 8545,
rpcCorsDomain: "http://localhost:8000",
wsOrigins: "http://localhost:8000",
accounts: [
{
nodeAccounts: true,
password: "config/livenet/.password"
}
],
},
]
},
rinkeby: {
enabled: true,
networkType: "rinkeby",
@ -70,4 +68,5 @@ module.exports = {
}
],
}
};

View File

@ -1,12 +1,22 @@
module.exports = {
default: {
enabled: true,
provider: "whisper", // Communication provider. Currently, Embark only supports whisper
available_providers: ["whisper"], // Array of available providers
provider: "whisper",
available_providers: ["whisper"],
},
development: {
connection: {
host: "localhost", // Host of the blockchain node
port: 8546, // Port of the blockchain node
type: "ws" // Type of connection (ws or rpc)
host: "localhost",
port: 8546,
type: "ws"
}
},
testnet: {
},
livenet: {
},
rinkeby: {
}
};

View File

@ -1,33 +1,30 @@
module.exports = {
// default applies to all environments
default: {
// Blockchain node to deploy the contracts
deployment: {
host: "localhost", // Host of the blockchain node
port: 8545, // Port of the blockchain node
type: "rpc" // Type of connection (ws or rpc),
host: "localhost",
port: 8546,
type: "ws"
},
// order of connections the dapp should connect to
dappConnection: [
"$WEB3", // uses pre existing web3 object if available (e.g in Mist)
"$WEB3",
"ws://localhost:8546",
"http://localhost:8545"
],
gas: "auto",
strategy: "explicit",
contracts: {
"MiniMeTokenFactory": {
"deploy": true
MiniMeTokenFactory: {
deploy: true
},
"MiniMeToken": {
"deploy": true,
"args":["$MiniMeTokenFactory", "0x0", "0x0", "Status Test Token", 18, "STT", true],
MiniMeToken: {
deploy: true,
args:["$MiniMeTokenFactory", "0x0", "0x0", "Status Test Token", 18, "STT", true],
},
"StatusRoot": {
"instanceOf": "TestStatusNetwork",
"deploy": true,
"args": ["0x0", "$MiniMeToken"],
"onDeploy": [
StatusRoot: {
instanceOf: "TestStatusNetwork",
deploy: true,
args: ["0x0", "$MiniMeToken"],
onDeploy: [
"await MiniMeToken.methods.changeController(StatusRoot.address).send()",
"await StatusRoot.methods.setOpen(true).send()",
]
@ -35,48 +32,37 @@ module.exports = {
}
},
development: {
deployment: {
accounts: [
{
privateKey: "b2ab40d549e67ba67f278781fec03b3a90515ad4d0c898a6326dd958de1e46fa",
balance: "5 ether" // You can set the balance of the account in the dev environment
// Balances are in Wei, but you can specify the unit with its name
}
]
}
},
testnet: {
contracts: {
"MiniMeTokenFactory": {
"deploy": false,
"address": "0x6bFa86A71A7DBc68566d5C741F416e3009804279"
MiniMeTokenFactory: {
deploy: false,
address: "0x6bFa86A71A7DBc68566d5C741F416e3009804279"
},
"MiniMeToken": {
"deploy": false,
"address": "0xc55cF4B03948D7EBc8b9E8BAD92643703811d162"
MiniMeToken: {
deploy: false,
address: "0xc55cF4B03948D7EBc8b9E8BAD92643703811d162"
},
"StatusRoot": {
"instanceOf": "TestStatusNetwork",
"deploy": false,
"address": "0x34358C45FbA99ef9b78cB501584E8cBFa6f85Cef"
StatusRoot: {
instanceOf: "TestStatusNetwork",
deploy: false,
address: "0x34358C45FbA99ef9b78cB501584E8cBFa6f85Cef"
}
}
},
rinkeby: {
contracts: {
"MiniMeTokenFactory": {
"deploy": false,
"address": "0x5bA5C786845CaacD45f5952E1135F4bFB8855469"
MiniMeTokenFactory: {
deploy: false,
address: "0x5bA5C786845CaacD45f5952E1135F4bFB8855469"
},
"MiniMeToken": {
"deploy": false,
"address": "0x43d5adC3B49130A575ae6e4b00dFa4BC55C71621"
MiniMeToken: {
deploy: false,
address: "0x43d5adC3B49130A575ae6e4b00dFa4BC55C71621"
},
"StatusRoot": {
"instanceOf": "TestStatusNetwork",
"deploy": false,
"address": "0xEdEB948dE35C6ac414359f97329fc0b4be70d3f1"
StatusRoot: {
instanceOf: "TestStatusNetwork",
deploy: false,
address: "0xEdEB948dE35C6ac414359f97329fc0b4be70d3f1"
}
}
}

View File

@ -1,18 +0,0 @@
{
"config": {
"homesteadBlock": 1,
"byzantiumBlock": 1,
"daoForkSupport": true
},
"nonce": "0x0000000000000042",
"difficulty": "0x0",
"alloc": {
"0x3333333333333333333333333333333333333333": {"balance": "15000000000000000000"}
},
"mixhash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"coinbase": "0x3333333333333333333333333333333333333333",
"timestamp": "0x00",
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"extraData": "0x",
"gasLimit": "0x7a1200"
}

View File

@ -1,6 +1,23 @@
module.exports = {
default: {
enabled: true,
available_providers: ["ens"],
provider: "ens"
},
development: {
register: {
rootDomain: "eth",
subdomains: {
'embark': '0x1a2f3b98e434c02363f3dac3174af93c1d690914'
}
}
},
testnet: {
},
livenet: {
},
rinkeby: {
}
};
};

4
config/pipeline.js Normal file
View File

@ -0,0 +1,4 @@
module.exports = {
typescript: false,
enabled: true
};

View File

@ -1,5 +1,4 @@
module.exports = {
// default applies to all environments
default: {
enabled: true,
ipfs_bin: "ipfs",
@ -17,16 +16,7 @@ module.exports = {
getUrl: "http://localhost:8080/ipfs/"
}
]
// Configuration to start Swarm in the same terminal as `embark run`
/*,account: {
address: "YOUR_ACCOUNT_ADDRESS", // Address of account accessing Swarm
password: "PATH/TO/PASSWORD/FILE" // File containing the password of the account
},
swarmPath: "PATH/TO/SWARM/EXECUTABLE" // Path to swarm executable (default: swarm)*/
},
// default environment, merges with the settings in default
// assumed to be the intended environment by `embark run`
development: {
enabled: true,
upload: {
@ -37,23 +27,12 @@ module.exports = {
}
},
// merges with the settings in default
// used with "embark run privatenet"
privatenet: {
},
// merges with the settings in default
// used with "embark run testnet"
testnet: {
},
// merges with the settings in default
// used with "embark run livenet"
livenet: {
},
// you can name an environment with specific settings and then specify with
// "embark run custom_name"
//custom_name: {
//}
};
rinkeby: {
}
};

View File

@ -1,5 +1,6 @@
module.exports = {
enabled: true,
host: "localhost",
openBrowser: true,
port: 8000
};
};

View File

@ -55,6 +55,7 @@ contract MessageSigned {
pure
returns (uint8 v, bytes32 r, bytes32 s)
{
require(_signature.length == 65, "Bad signature length");
// The signature format is a compact form of:
// {bytes32 r}{bytes32 s}{uint8 v}
// Compact means, uint8 is not padded to 32 bytes.
@ -68,8 +69,10 @@ contract MessageSigned {
// use the second best option, 'and'
v := and(mload(add(_signature, 65)), 0xff)
}
require(v == 27 || v == 28, "Bad signature");
if (v < 27) {
v += 27;
}
require(v == 27 || v == 28, "Bad signature version");
}
}

View File

@ -2,17 +2,24 @@
"contracts": ["contracts/**"],
"app": {
"js/dapp.js": ["app/dapp.js"],
"js/index.js": ["app/index.js"],
"index.html": "app/index.html",
"images/": ["app/images/**"]
},
},
"buildDir": "dist/",
"config": "config/",
"versions": {
"web3": "1.0.0-beta",
"solc": "0.5.4",
"ipfs-api": "17.2.4",
"p-iteration": "1.1.7"
"ipfs-api": "17.2.4"
},
"plugins": {}
"plugins": {
"embarkjs-connector-web3": {}
},
"options": {
"solc": {
"optimize": true,
"optimize-runs": 200
}
},
"generationDir": "embarkArtifacts"
}

View File

@ -3,9 +3,7 @@
"version": "0.0.1",
"description": "",
"scripts": {
"solidity-coverage": "./node_modules/.bin/solidity-coverage",
"test": "embark test",
"lint": "eslint"
"test": "embark test"
},
"repository": {
"type": "git",
@ -18,16 +16,9 @@
},
"homepage": "https://github.com/status-im/contracts#readme",
"devDependencies": {
"@babel/core": "^7.0.0",
"@babel/preset-env": "^7.2.3"
},
"dependencies": {
"elliptic-curve": "^0.1.0",
"ethereumjs-util": "^5.1.5",
"react": "^16.3.2",
"react-blockies": "^1.4.0",
"react-bootstrap": "0.32.1",
"react-dom": "^16.3.2",
"web3": "^1.0.0-beta.34"
"embarkjs-connector-web3": "^4.0.0",
"react": "16.7.0",
"react-bootstrap": "0.32.4",
"react-dom": "16.7.0"
}
}