diff --git a/test-dapp/.babelrc b/test-dapp/.babelrc index a8ab51a..ba9c7aa 100644 --- a/test-dapp/.babelrc +++ b/test-dapp/.babelrc @@ -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" - ] - } \ No newline at end of file + "plugins": [ + "transform-object-rest-spread" + ], + "presets": [ + "stage-2" + ], + "ignore": [ + "config/", + "node_modules" + ] +} \ No newline at end of file diff --git a/test-dapp/app/components/accountBalance.js b/test-dapp/app/components/accountBalance.js deleted file mode 100644 index c572497..0000000 --- a/test-dapp/app/components/accountBalance.js +++ /dev/null @@ -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
-

{this.props.name}

- {this.props.address} -

RDN
{rnd}

-

ETH
{eth}

- this.updateBalances(ev)}>Update balances
- this.generateTokens(ev)}>Generate Tokens
- this.sendEther(ev)}>Send 1 Ether
- -
; - } -} - -export default AccountBalance; diff --git a/test-dapp/app/components/callgasrelayed1.js b/test-dapp/app/components/callgasrelayed1.js deleted file mode 100644 index 1401751..0000000 --- a/test-dapp/app/components/callgasrelayed1.js +++ /dev/null @@ -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 ( - { - this.state.errorMessage != '' && {this.state.errorMessage} - } -
- - - - - - - - - - - - - - Identity Address - - 0x - this.handleChange(ev, 'address')} /> - - - - - - To - - 0x - this.handleChange(ev, 'to')} /> - - - - Value - this.handleChange(ev, 'value')} /> - - - Data - - 0x - this.handleChange(ev, 'data')} /> - - - - - - Nonce - this.handleChange(ev, 'nonce')} /> - - - Gas Price in Tokens - this.handleChange(ev, 'gasPrice')} /> - - - Gas Limit in Ether - this.handleChange(ev, 'gasLimit')} /> - - - Gas Token - - 0x - this.handleChange(ev, 'gasToken')} /> - - RND: {this.props.RND.options.address} - ETH: 0x0000000000000000000000000000000000000000 - - - - - - - - Signature: {this.state.signature} - - - - - Symmetric Key - - 0x - - - - - Topic - - 0x - this.handleChange(ev, 'topic')} /> - - - - - - - - - {this.state.msgSent} - - - - -

Whisper Messages

- { - this.state.messages.map((msg, i) =>

{msg}

) - } -
-
-
- ); - } - } - -export default CallGasRelayed; diff --git a/test-dapp/app/relayer-test.css b/test-dapp/app/relayer-test.css deleted file mode 100644 index e0043e3..0000000 --- a/test-dapp/app/relayer-test.css +++ /dev/null @@ -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; -} diff --git a/test-dapp/app/relayer-test.html b/test-dapp/app/relayer-test.html deleted file mode 100644 index 0222ce9..0000000 --- a/test-dapp/app/relayer-test.html +++ /dev/null @@ -1,12 +0,0 @@ - - - Identity Gas Relay - - - - -
-
- - - diff --git a/test-dapp/app/relayer-test.js b/test-dapp/app/relayer-test.js deleted file mode 100644 index 7ce2a1d..0000000 --- a/test-dapp/app/relayer-test.js +++ /dev/null @@ -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 - {title} - - ; - } - - render(){ - return (

IdentityGasRelay - Usage Example

- - - - - - - - -
); - } -} - -ReactDOM.render(, document.getElementById('app')); diff --git a/test-dapp/embark.json b/test-dapp/embark.json index 8f712d4..64433f2 100644 --- a/test-dapp/embark.json +++ b/test-dapp/embark.json @@ -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/**"], diff --git a/test-dapp/package.json b/test-dapp/package.json index 28ecc3e..fddb19d 100644 --- a/test-dapp/package.json +++ b/test-dapp/package.json @@ -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" } }