Rollback to babel6 and removed unneeded files
This commit is contained in:
parent
a655a0bbf5
commit
78ad988661
|
@ -1,16 +1,12 @@
|
|||
{
|
||||
"plugins": [
|
||||
"@babel/plugin-proposal-object-rest-spread",
|
||||
["@babel/plugin-proposal-decorators", { "legacy": true }],
|
||||
"@babel/plugin-proposal-function-sent",
|
||||
"@babel/plugin-proposal-export-namespace-from",
|
||||
"@babel/plugin-proposal-numeric-separator",
|
||||
"@babel/plugin-proposal-throw-expressions",
|
||||
["@babel/plugin-proposal-class-properties", { "loose": false }]
|
||||
],
|
||||
|
||||
"ignore": [
|
||||
"config/",
|
||||
"node_modules"
|
||||
]
|
||||
}
|
||||
"plugins": [
|
||||
"transform-object-rest-spread"
|
||||
],
|
||||
"presets": [
|
||||
"stage-2"
|
||||
],
|
||||
"ignore": [
|
||||
"config/",
|
||||
"node_modules"
|
||||
]
|
||||
}
|
|
@ -1,65 +0,0 @@
|
|||
import EmbarkJS from 'Embark/EmbarkJS';
|
||||
import React from 'react';
|
||||
import web3 from 'Embark/web3';
|
||||
|
||||
class AccountBalance extends React.Component {
|
||||
|
||||
constructor(props) {
|
||||
super(props);
|
||||
|
||||
this.state = {
|
||||
eth: 0,
|
||||
rnd: 0
|
||||
};
|
||||
}
|
||||
|
||||
componentDidMount(){
|
||||
EmbarkJS.onReady(err => {
|
||||
if(!err) this.updateBalances();
|
||||
});
|
||||
}
|
||||
|
||||
updateBalances(ev){
|
||||
if(ev) ev.preventDefault();
|
||||
|
||||
}
|
||||
|
||||
sendEther(ev){
|
||||
ev.preventDefault();
|
||||
|
||||
web3.eth.sendTransaction({to: this.props.address, value: web3.utils.toWei('1', 'ether')})
|
||||
.then(() => {
|
||||
this.updateBalances();
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
generateTokens(ev){
|
||||
ev.preventDefault();
|
||||
|
||||
this.props.RND.methods.generateTokens(this.props.address, web3.utils.toWei('500', 'ether'))
|
||||
.send({gas: 1000000})
|
||||
.then(() => {
|
||||
this.updateBalances();
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
render(){
|
||||
const rnd = 1;
|
||||
const eth =2;
|
||||
|
||||
return <div>
|
||||
<h3>{this.props.name}</h3>
|
||||
<small>{this.props.address}</small>
|
||||
<p><b>RDN</b><br /><small>{rnd}</small></p>
|
||||
<p><b>ETH</b><br /><small>{eth}</small></p>
|
||||
<a href="#" onClick={(ev) => this.updateBalances(ev)}>Update balances</a><br />
|
||||
<a href="#" onClick={(ev) => this.generateTokens(ev)}>Generate Tokens</a><br />
|
||||
<a href="#" onClick={(ev) => this.sendEther(ev)}>Send 1 Ether</a><br />
|
||||
|
||||
</div>;
|
||||
}
|
||||
}
|
||||
|
||||
export default AccountBalance;
|
|
@ -1,269 +0,0 @@
|
|||
import {Alert, Button, Col, ControlLabel, Form, FormControl, Grid, HelpBlock, InputGroup, Row} from 'react-bootstrap';
|
||||
import AccountBalance from './accountBalance';
|
||||
import React from 'react';
|
||||
import Web3 from 'web3';
|
||||
|
||||
class CallGasRelayed extends React.Component {
|
||||
|
||||
constructor(props) {
|
||||
super(props);
|
||||
|
||||
this.state = {
|
||||
account: '',
|
||||
address: this.props.IdentityGasRelay.options.address,
|
||||
topic: '0x4964656e',
|
||||
to: '0x0000000000000000000000000000000000000000',
|
||||
value: 0,
|
||||
data: '0x00',
|
||||
nonce: 0,
|
||||
gasPrice: 0,
|
||||
gasLimit: 0,
|
||||
gasToken: "0x0000000000000000000000000000000000000000",
|
||||
signature: '',
|
||||
symKey: '0xd0d905c1c62b810b787141430417caf2b3f54cffadb395b7bb39fdeb8f17266b',
|
||||
kid: null,
|
||||
skid: null,
|
||||
msgSent: '',
|
||||
payload: '',
|
||||
messages: [],
|
||||
web3W: null,
|
||||
errorMessage: ''
|
||||
};
|
||||
}
|
||||
|
||||
componentDidMount(){
|
||||
__embarkContext.execWhenReady(async () => {
|
||||
|
||||
let web3W = new Web3('ws://localhost:8546');
|
||||
|
||||
let accounts = await this.props.web3.eth.getAccounts();
|
||||
this.setState({
|
||||
account: accounts[0]
|
||||
});
|
||||
|
||||
let _skid = await web3W.shh.addSymKey(this.state.symKey);
|
||||
let _kid = await web3W.shh.newKeyPair();
|
||||
|
||||
this.setState({
|
||||
kid: _kid,
|
||||
skid: _skid,
|
||||
whisper: web3W
|
||||
});
|
||||
|
||||
web3W.shh.subscribe('messages', {
|
||||
"privateKeyID": _kid,
|
||||
"ttl": 20,
|
||||
"minPow": 0.8,
|
||||
"powTime": 1000
|
||||
}, (error, message, subscription) => {
|
||||
if(error) {
|
||||
console.log(error);
|
||||
this.setState({errorMessage: error.message});
|
||||
} else {
|
||||
this.state.messages.push(this.props.web3.utils.hexToAscii(message.payload));
|
||||
this.setState({messages: this.state.messages});
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
handleChange(e, name){
|
||||
const newState = {};
|
||||
newState[name] = e.target.value;
|
||||
this.setState(newState);
|
||||
}
|
||||
|
||||
sendMessage(e){
|
||||
e.preventDefault();
|
||||
|
||||
this.setState({
|
||||
messages: [],
|
||||
errorMessage: ''
|
||||
});
|
||||
|
||||
try {
|
||||
let jsonAbi = this.props.IdentityGasRelay._jsonInterface.filter(x => x.name == "callGasRelayed")[0];
|
||||
let funCall = this.props.web3.eth.abi.encodeFunctionCall(jsonAbi, [
|
||||
this.state.to,
|
||||
this.state.value,
|
||||
this.state.data,
|
||||
this.state.nonce,
|
||||
this.state.gasPrice,
|
||||
this.state.gasLimit,
|
||||
this.state.gasToken,
|
||||
this.state.signature
|
||||
]);
|
||||
let msgObj = {
|
||||
symKeyID: this.state.skid,
|
||||
sig: this.state.kid,
|
||||
ttl: 1000,
|
||||
powTarget: 1,
|
||||
powTime: 10,
|
||||
topic: this.state.topic,
|
||||
payload: this.props.web3.utils.toHex({
|
||||
'address': this.state.address,
|
||||
'encodedFunctionCall': funCall
|
||||
})
|
||||
};
|
||||
|
||||
console.log(msgObj);
|
||||
|
||||
this.props.web3.shh.post(msgObj)
|
||||
.then((err, result) => {
|
||||
console.log(result);
|
||||
console.log(err);
|
||||
this.setState({msgSent: result, payload: msgObj.payload});
|
||||
});
|
||||
} catch(error){
|
||||
console.error(error);
|
||||
this.setState({errorMessage: error.message});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
async sign(ev){
|
||||
ev.preventDefault();
|
||||
|
||||
this.setState({
|
||||
msgSent: false,
|
||||
payload: '',
|
||||
messages: [],
|
||||
errorMessage: ''
|
||||
});
|
||||
|
||||
try {
|
||||
let message = await this.props.IdentityGasRelay.methods.callGasRelayHash(
|
||||
this.state.to,
|
||||
this.state.value,
|
||||
this.props.web3.utils.soliditySha3({t: 'bytes', v: this.state.data}),
|
||||
this.state.nonce,
|
||||
this.state.gasPrice,
|
||||
this.state.gasLimit,
|
||||
this.state.gasToken
|
||||
).call();
|
||||
|
||||
let accounts = await this.props.web3.eth.getAccounts();
|
||||
let _signature = await this.props.web3.eth.sign(message, accounts[0]);
|
||||
|
||||
this.setState({signature: _signature});
|
||||
} catch(error){
|
||||
console.error(error);
|
||||
this.setState({errorMessage: error.message});
|
||||
}
|
||||
}
|
||||
|
||||
render(){
|
||||
return (<Grid>
|
||||
{
|
||||
this.state.errorMessage != '' && <React.Fragment><Alert bsStyle="danger">{this.state.errorMessage}</Alert></React.Fragment>
|
||||
}
|
||||
<Form>
|
||||
<Row>
|
||||
<Col md={3}>
|
||||
<AccountBalance name="Identity" address={this.state.address} web3={this.props.web3} RND={this.props.RND} />
|
||||
</Col>
|
||||
<Col md={3}>
|
||||
<AccountBalance name="To" address={this.state.to} web3={this.props.web3} RND={this.props.RND} />
|
||||
</Col>
|
||||
<Col md={3}>
|
||||
<AccountBalance name="Gas Relayer Node" address={this.state.account} web3={this.props.web3} RND={this.props.RND} />
|
||||
</Col>
|
||||
</Row>
|
||||
<Row>
|
||||
<Col md={9}>
|
||||
<ControlLabel>Identity Address</ControlLabel>
|
||||
<InputGroup>
|
||||
<InputGroup.Addon>0x</InputGroup.Addon>
|
||||
<FormControl type="text" placeholder="Address" defaultValue={this.state.address} onChange={(ev) => this.handleChange(ev, 'address')} />
|
||||
</InputGroup>
|
||||
</Col>
|
||||
</Row>
|
||||
<Row>
|
||||
<Col md={4}>
|
||||
<ControlLabel>To</ControlLabel>
|
||||
<InputGroup>
|
||||
<InputGroup.Addon>0x</InputGroup.Addon>
|
||||
<FormControl type="text" defaultValue={this.state.to} onChange={(ev) => this.handleChange(ev, 'to')} />
|
||||
</InputGroup>
|
||||
</Col>
|
||||
<Col md={1}>
|
||||
<ControlLabel>Value</ControlLabel>
|
||||
<FormControl type="string" defaultValue={this.state.value} onChange={(ev) => this.handleChange(ev, 'value')} />
|
||||
</Col>
|
||||
<Col md={4}>
|
||||
<ControlLabel>Data</ControlLabel>
|
||||
<InputGroup>
|
||||
<InputGroup.Addon>0x</InputGroup.Addon>
|
||||
<FormControl type="string" defaultValue={this.state.data} onChange={(ev) => this.handleChange(ev, 'data')} />
|
||||
</InputGroup>
|
||||
</Col>
|
||||
</Row>
|
||||
<Row>
|
||||
<Col md={1}>
|
||||
<ControlLabel>Nonce</ControlLabel>
|
||||
<FormControl type="string" defaultValue={this.state.nonce} onChange={(ev) => this.handleChange(ev, 'nonce')} />
|
||||
</Col>
|
||||
<Col md={1}>
|
||||
<ControlLabel>Gas Price in Tokens</ControlLabel>
|
||||
<FormControl type="string" defaultValue={this.state.gasPrice} onChange={(ev) => this.handleChange(ev, 'gasPrice')} />
|
||||
</Col>
|
||||
<Col md={1}>
|
||||
<ControlLabel>Gas Limit in Ether</ControlLabel>
|
||||
<FormControl type="string" defaultValue={this.state.gasLimit} onChange={(ev) => this.handleChange(ev, 'gasLimit')} />
|
||||
</Col>
|
||||
<Col md={6}>
|
||||
<ControlLabel>Gas Token</ControlLabel>
|
||||
<InputGroup>
|
||||
<InputGroup.Addon>0x</InputGroup.Addon>
|
||||
<FormControl type="text" defaultValue={this.state.gasToken} onChange={(ev) => this.handleChange(ev, 'gasToken')} />
|
||||
</InputGroup>
|
||||
<HelpBlock>RND: {this.props.RND.options.address}</HelpBlock>
|
||||
<HelpBlock>ETH: 0x0000000000000000000000000000000000000000</HelpBlock>
|
||||
</Col>
|
||||
</Row>
|
||||
<Row>
|
||||
<Col md={4}>
|
||||
<Button bsStyle="primary" onClick={(ev) => this.sign(ev)}>1. Sign Message</Button>
|
||||
</Col>
|
||||
<Col md={5}>
|
||||
<b>Signature: </b>{this.state.signature}
|
||||
</Col>
|
||||
</Row>
|
||||
<Row>
|
||||
<Col md={7}>
|
||||
<ControlLabel>Symmetric Key</ControlLabel>
|
||||
<InputGroup>
|
||||
<InputGroup.Addon>0x</InputGroup.Addon>
|
||||
<FormControl type="text" placeholder="Sym Key" defaultValue={this.state.symKey} />
|
||||
</InputGroup>
|
||||
</Col>
|
||||
<Col md={2}>
|
||||
<ControlLabel>Topic</ControlLabel>
|
||||
<InputGroup>
|
||||
<InputGroup.Addon>0x</InputGroup.Addon>
|
||||
<FormControl type="text" readOnly={true} defaultValue={this.state.topic} onChange={(ev) => this.handleChange(ev, 'topic')} />
|
||||
</InputGroup>
|
||||
</Col>
|
||||
</Row>
|
||||
<Row>
|
||||
<Col md={4}>
|
||||
<Button bsStyle="primary" disabled={this.state.signature == ""} onClick={(ev) => this.sendMessage(ev)}>2. Send via whisper</Button>
|
||||
</Col>
|
||||
<Col md={5}>
|
||||
{this.state.msgSent}
|
||||
</Col>
|
||||
</Row>
|
||||
|
||||
<Row>
|
||||
<h3>Whisper Messages</h3>
|
||||
{
|
||||
this.state.messages.map((msg, i) => <p key={i}>{msg}</p>)
|
||||
}
|
||||
</Row>
|
||||
</Form>
|
||||
</Grid>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default CallGasRelayed;
|
|
@ -1,49 +0,0 @@
|
|||
|
||||
div {
|
||||
margin: 15px;
|
||||
}
|
||||
|
||||
.logs {
|
||||
background-color: black;
|
||||
font-size: 14px;
|
||||
color: white;
|
||||
font-weight: bold;
|
||||
padding: 10px;
|
||||
border-radius: 8px;
|
||||
}
|
||||
|
||||
.tab-content {
|
||||
border-left: 1px solid #ddd;
|
||||
border-right: 1px solid #ddd;
|
||||
border-bottom: 1px solid #ddd;
|
||||
padding: 10px;
|
||||
margin: 0px;
|
||||
}
|
||||
|
||||
.nav-tabs {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.status-offline {
|
||||
vertical-align: middle;
|
||||
margin-left: 5px;
|
||||
margin-top: 4px;
|
||||
width: 12px;
|
||||
height: 12px;
|
||||
background: red;
|
||||
-moz-border-radius: 10px;
|
||||
-webkit-border-radius: 10px;
|
||||
border-radius: 10px;
|
||||
}
|
||||
|
||||
.status-online {
|
||||
vertical-align: middle;
|
||||
margin-left: 5px;
|
||||
margin-top: 4px;
|
||||
width: 12px;
|
||||
height: 12px;
|
||||
background: mediumseagreen;
|
||||
-moz-border-radius: 10px;
|
||||
-webkit-border-radius: 10px;
|
||||
border-radius: 10px;
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
<html>
|
||||
<head>
|
||||
<title>Identity Gas Relay</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/relayer-test.js"></script>
|
||||
</body>
|
||||
</html>
|
|
@ -1,42 +0,0 @@
|
|||
import './relayer-test.css';
|
||||
import {Tab, Tabs} from 'react-bootstrap';
|
||||
import ApproveAndCallGasRelayed from './components/approveandcallgasrelayed';
|
||||
import CallGasRelayed from './components/callgasrelayed1';
|
||||
import IdentityGasRelay from 'Embark/contracts/IdentityGasRelay';
|
||||
import RND from 'Embark/contracts/STT';
|
||||
import React from 'react';
|
||||
import ReactDOM from 'react-dom';
|
||||
import web3 from 'Embark/web3';
|
||||
|
||||
class App extends React.Component {
|
||||
|
||||
constructor(props) {
|
||||
super(props);
|
||||
|
||||
window['RND'] = RND;
|
||||
window['IdentityGasRelay'] = IdentityGasRelay;
|
||||
}
|
||||
|
||||
_renderStatus(title, available){
|
||||
let className = available ? 'pull-right status-online' : 'pull-right status-offline';
|
||||
return <React.Fragment>
|
||||
{title}
|
||||
<span className={className}></span>
|
||||
</React.Fragment>;
|
||||
}
|
||||
|
||||
render(){
|
||||
return (<div><h3>IdentityGasRelay - Usage Example</h3>
|
||||
<Tabs defaultActiveKey={1} id="uncontrolled-tab-example">
|
||||
<Tab eventKey={1} title="callGasRelayed">
|
||||
<CallGasRelayed IdentityGasRelay={IdentityGasRelay} RND={RND} web3={web3} />
|
||||
</Tab>
|
||||
<Tab eventKey={2} title="approveAndCallGasRelayed">
|
||||
<ApproveAndCallGasRelayed IdentityGasRelay={IdentityGasRelay} RND={RND} web3={web3} />
|
||||
</Tab>
|
||||
</Tabs>
|
||||
</div>);
|
||||
}
|
||||
}
|
||||
|
||||
ReactDOM.render(<App></App>, document.getElementById('app'));
|
|
@ -1,8 +1,6 @@
|
|||
{
|
||||
"contracts": ["contracts/**"],
|
||||
"app": {
|
||||
"js/relayer-test.js": ["app/relayer-test.js"],
|
||||
"relayer-test.html": "app/relayer-test.html",
|
||||
"js/dapp.js": ["app/dapp.js"],
|
||||
"dapp.html": "app/dapp.html",
|
||||
"css/dapp.css": ["app/css/**"],
|
||||
|
|
|
@ -16,17 +16,8 @@
|
|||
},
|
||||
"homepage": "https://github.com/status-im/contracts#readme",
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.0.0-beta.56",
|
||||
"@babel/plugin-proposal-class-properties": "^7.0.0-beta.56",
|
||||
"@babel/plugin-proposal-decorators": "^7.0.0-beta.56",
|
||||
"@babel/plugin-proposal-export-namespace-from": "^7.0.0-beta.56",
|
||||
"@babel/plugin-proposal-function-sent": "^7.0.0-beta.56",
|
||||
"@babel/plugin-proposal-numeric-separator": "^7.0.0-beta.56",
|
||||
"@babel/plugin-proposal-object-rest-spread": "^7.0.0-beta.56",
|
||||
"@babel/plugin-proposal-throw-expressions": "^7.0.0-beta.56",
|
||||
"@babel/plugin-syntax-class-properties": "^7.0.0-beta.56",
|
||||
"@babel/preset-stage-0": "^7.0.0-beta.56",
|
||||
"babel-eslint": "^8.2.6",
|
||||
"babel-plugin-transform-object-rest-spread": "^6.26.0",
|
||||
"babel-preset-stage-2": "^6.24.1",
|
||||
"eslint": "^4.19.1",
|
||||
"eslint-config-standard": "^11.0.0",
|
||||
|
@ -43,6 +34,7 @@
|
|||
"react": "^16.4.2",
|
||||
"react-blockies": "^1.3.0",
|
||||
"react-bootstrap": "^0.32.1",
|
||||
"react-dom": "^16.4.2"
|
||||
"react-dom": "^16.4.2",
|
||||
"web3": "^1.0.0-beta.35"
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue