mirror of
https://github.com/status-im/snt-gas-relay.git
synced 2025-01-27 14:44:47 +00:00
Merge pull request #4 from status-im/ropsten-test
Simplify testing on Ropsten
This commit is contained in:
commit
98e8c010d3
@ -31,8 +31,8 @@ module.exports = {
|
|||||||
"currency": "USD"
|
"currency": "USD"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"0xd7879e4401c548544196dc0215df449B2a1E23B3": {
|
"0x121a430A73Fc13e2D6d4a9dc3E943de647c30f8f": {
|
||||||
"name": "Status Test Token",
|
"name": "Status Gas Relayer Test Token",
|
||||||
"symbol": "SNT",
|
"symbol": "SNT",
|
||||||
"minAccepted":{
|
"minAccepted":{
|
||||||
"value": 1,
|
"value": 1,
|
||||||
@ -46,7 +46,7 @@ module.exports = {
|
|||||||
"IdentityGasRelay": {
|
"IdentityGasRelay": {
|
||||||
"abiFile": "../abi/IdentityGasRelay.json",
|
"abiFile": "../abi/IdentityGasRelay.json",
|
||||||
"isIdentity": true,
|
"isIdentity": true,
|
||||||
"factoryAddress": "0x7F106A1Bc637AC4AAed3DC72582749c4562D4323",
|
"factoryAddress": "0x89976FeEC7CFDF2DF5194e363FD2a3388e2DC91A",
|
||||||
"kernelVerification": "isKernel(bytes32)",
|
"kernelVerification": "isKernel(bytes32)",
|
||||||
"allowedFunctions": [
|
"allowedFunctions": [
|
||||||
{
|
{
|
||||||
@ -63,7 +63,7 @@ module.exports = {
|
|||||||
"SNTController": {
|
"SNTController": {
|
||||||
"abiFile": "../abi/SNTController.json",
|
"abiFile": "../abi/SNTController.json",
|
||||||
"isIdentity": false,
|
"isIdentity": false,
|
||||||
"address": "0xA77A1014F55157c3119FB3f53E653E42f8fa634c",
|
"address": "0xf558aC91312821B0E1802567BC785355AA811783",
|
||||||
"allowedFunctions": [
|
"allowedFunctions": [
|
||||||
{
|
{
|
||||||
"function":"transferSNT(address,uint256,uint256,uint256,bytes)"
|
"function":"transferSNT(address,uint256,uint256,uint256,bytes)"
|
||||||
|
@ -69,6 +69,10 @@ class Body extends Component {
|
|||||||
|
|
||||||
let relayers = this.state.relayers;
|
let relayers = this.state.relayers;
|
||||||
relayers[msgObj.sig] = msgObj.address;
|
relayers[msgObj.sig] = msgObj.address;
|
||||||
|
|
||||||
|
if(this.state.relayerAddress == '0x0000000000000000000000000000000000000000'){
|
||||||
|
this.setState({relayerAddress: msgObj.address});
|
||||||
|
}
|
||||||
|
|
||||||
this.setState({relayers});
|
this.setState({relayers});
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,8 @@ class Body extends Component {
|
|||||||
kid: null,
|
kid: null,
|
||||||
skid: null,
|
skid: null,
|
||||||
message: '',
|
message: '',
|
||||||
relayers: []
|
relayerAddress: '0x0000000000000000000000000000000000000000',
|
||||||
|
relayers: {}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -43,6 +44,14 @@ class Body extends Component {
|
|||||||
|
|
||||||
const web3js = new Web3('ws://localhost:8546');
|
const web3js = new Web3('ws://localhost:8546');
|
||||||
|
|
||||||
|
|
||||||
|
// Default for devenv
|
||||||
|
web3js.eth.net.getId().then(netId => {
|
||||||
|
if(netId != 1 && netId != 3){
|
||||||
|
this.setState({relayerAddress: config.relayAccount});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
web3js.shh.newKeyPair()
|
web3js.shh.newKeyPair()
|
||||||
.then((kid) => {
|
.then((kid) => {
|
||||||
web3js.shh.addSymKey(config.relaySymKey)
|
web3js.shh.addSymKey(config.relaySymKey)
|
||||||
@ -58,9 +67,14 @@ class Body extends Component {
|
|||||||
if(msgObj.message == Messages.available){
|
if(msgObj.message == Messages.available){
|
||||||
// found a relayer
|
// found a relayer
|
||||||
console.log("Relayer available: " + msgObj.sig);
|
console.log("Relayer available: " + msgObj.sig);
|
||||||
|
|
||||||
let relayers = this.state.relayers;
|
let relayers = this.state.relayers;
|
||||||
relayers.push(msgObj.sig);
|
relayers[msgObj.sig] = msgObj.address;
|
||||||
relayers = relayers.filter((value, index, self) => self.indexOf(value) === index);
|
|
||||||
|
if(this.state.relayerAddress == '0x0000000000000000000000000000000000000000'){
|
||||||
|
this.setState({relayerAddress: msgObj.address});
|
||||||
|
}
|
||||||
|
|
||||||
this.setState({relayers});
|
this.setState({relayers});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -79,7 +93,7 @@ class Body extends Component {
|
|||||||
|
|
||||||
web3.eth.getAccounts()
|
web3.eth.getAccounts()
|
||||||
.then(accounts => {
|
.then(accounts => {
|
||||||
this.setState({walletAddress: accounts[2]});
|
this.setState({walletAddress: accounts[0]});
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
@ -89,6 +103,10 @@ class Body extends Component {
|
|||||||
this.setState({tab});
|
this.setState({tab});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
updateRelayer = (relayer) => {
|
||||||
|
this.setState({relayerAddress: this.state.relayers[relayer]});
|
||||||
|
}
|
||||||
|
|
||||||
updateNonce = (newNonce) => {
|
updateNonce = (newNonce) => {
|
||||||
this.setState({nonce: newNonce});
|
this.setState({nonce: newNonce});
|
||||||
}
|
}
|
||||||
@ -98,18 +116,18 @@ class Body extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
render(){
|
render(){
|
||||||
const {tab, walletAddress, nonce, web3js, message, kid, skid, relayers} = this.state;
|
const {tab, walletAddress, nonce, web3js, message, kid, skid, relayers, relayerAddress} = this.state;
|
||||||
|
|
||||||
return <Fragment>
|
return <Fragment>
|
||||||
<Tabs value={tab} onChange={this.handleChange}>
|
<Tabs value={tab} onChange={this.handleChange}>
|
||||||
<Tab label="Transfer SNT" />
|
<Tab label="Transfer SNT" />
|
||||||
<Tab label="Execute" />
|
<Tab label="Execute" />
|
||||||
</Tabs>
|
</Tabs>
|
||||||
{tab === 0 && <Container><TransferSNT clearMessages={this.clearMessages} web3={web3js} kid={kid} skid={skid} nonce={nonce} relayers={relayers} /></Container>}
|
{tab === 0 && <Container><TransferSNT clearMessages={this.clearMessages} web3={web3js} kid={kid} skid={skid} nonce={nonce} relayers={relayers} updateRelayer={this.updateRelayer} /></Container>}
|
||||||
{tab === 1 && <Container><Execute clearMessages={this.clearMessages} web3={web3js} kid={kid} skid={skid} nonce={nonce} relayers={relayers} /></Container>}
|
{tab === 1 && <Container><Execute clearMessages={this.clearMessages} web3={web3js} kid={kid} skid={skid} nonce={nonce} relayers={relayers} updateRelayer={this.updateRelayer} /></Container>}
|
||||||
<Divider />
|
<Divider />
|
||||||
<Container>
|
<Container>
|
||||||
<Status message={message} nonceUpdateFunction={this.updateNonce} nonce={nonce} walletAddress={walletAddress} />
|
<Status relayerAddress={relayerAddress} message={message} nonceUpdateFunction={this.updateNonce} nonce={nonce} walletAddress={walletAddress} />
|
||||||
</Container>
|
</Container>
|
||||||
</Fragment>;
|
</Fragment>;
|
||||||
}
|
}
|
||||||
|
@ -51,6 +51,9 @@ class Execute extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
handleChange = name => event => {
|
handleChange = name => event => {
|
||||||
|
if(name == 'relayer'){
|
||||||
|
this.props.updateRelayer(event.target.value);
|
||||||
|
}
|
||||||
this.setState({
|
this.setState({
|
||||||
[name]: event.target.value
|
[name]: event.target.value
|
||||||
});
|
});
|
||||||
@ -67,7 +70,7 @@ class Execute extends Component {
|
|||||||
try {
|
try {
|
||||||
const accounts = await web3.eth.getAccounts();
|
const accounts = await web3.eth.getAccounts();
|
||||||
|
|
||||||
const s = new StatusGasRelayer.SNTController(SNTController.options.address, accounts[2])
|
const s = new StatusGasRelayer.SNTController(SNTController.options.address, accounts[0])
|
||||||
.execute(this.state.allowedContract, this.state.data)
|
.execute(this.state.allowedContract, this.state.data)
|
||||||
.setGas(this.state.gasPrice, this.state.gasMinimal);
|
.setGas(this.state.gasPrice, this.state.gasMinimal);
|
||||||
|
|
||||||
@ -104,7 +107,7 @@ class Execute extends Component {
|
|||||||
try {
|
try {
|
||||||
const accounts = await web3.eth.getAccounts();
|
const accounts = await web3.eth.getAccounts();
|
||||||
|
|
||||||
const s = new StatusGasRelayer.AvailableRelayers(Contracts.SNT, SNTController.options.address, accounts[2])
|
const s = new StatusGasRelayer.AvailableRelayers(Contracts.SNT, SNTController.options.address, accounts[0])
|
||||||
.setRelayersSymKeyID(skid)
|
.setRelayersSymKeyID(skid)
|
||||||
.setAsymmetricKeyID(kid)
|
.setAsymmetricKeyID(kid)
|
||||||
.setGas(STT.options.address, this.state.gasPrice);
|
.setGas(STT.options.address, this.state.gasPrice);
|
||||||
@ -124,10 +127,16 @@ class Execute extends Component {
|
|||||||
const {web3, kid} = this.props;
|
const {web3, kid} = this.props;
|
||||||
|
|
||||||
let relayer = this.state.relayer;
|
let relayer = this.state.relayer;
|
||||||
if(relayer == '' && this.props.relayers.length == 1){
|
|
||||||
relayer = this.props.relayers[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
|
let relayers = [];
|
||||||
|
for (var key in this.props.relayers) {
|
||||||
|
if (this.props.relayers.hasOwnProperty(key)) relayers.push(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(relayer == '' && relayers.length == 1){
|
||||||
|
relayer = relayers[0];
|
||||||
|
}
|
||||||
|
|
||||||
this.setState({
|
this.setState({
|
||||||
messagingError: '',
|
messagingError: '',
|
||||||
@ -138,7 +147,7 @@ class Execute extends Component {
|
|||||||
try {
|
try {
|
||||||
const accounts = await web3.eth.getAccounts();
|
const accounts = await web3.eth.getAccounts();
|
||||||
|
|
||||||
const s = new StatusGasRelayer.SNTController(SNTController.options.address, accounts[2])
|
const s = new StatusGasRelayer.SNTController(SNTController.options.address, accounts[0])
|
||||||
.execute(this.state.allowedContract, this.state.data)
|
.execute(this.state.allowedContract, this.state.data)
|
||||||
.setGas(this.state.gasPrice, this.state.gasMinimal)
|
.setGas(this.state.gasPrice, this.state.gasMinimal)
|
||||||
.setRelayer(relayer)
|
.setRelayer(relayer)
|
||||||
@ -156,6 +165,12 @@ class Execute extends Component {
|
|||||||
|
|
||||||
render(){
|
render(){
|
||||||
const {classes} = this.props;
|
const {classes} = this.props;
|
||||||
|
|
||||||
|
let relayers = [];
|
||||||
|
for (var key in this.props.relayers) {
|
||||||
|
if (this.props.relayers.hasOwnProperty(key)) relayers.push(key);
|
||||||
|
}
|
||||||
|
|
||||||
return <div>
|
return <div>
|
||||||
<Card className={classes.card}>
|
<Card className={classes.card}>
|
||||||
<CardContent>
|
<CardContent>
|
||||||
@ -279,12 +294,7 @@ class Execute extends Component {
|
|||||||
native: true
|
native: true
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{
|
{ relayers.length > 0 ? relayers.map((r, i) => <option key={i} value={r}>Relayer #{i+1}: {r}</option>) : <option></option> }
|
||||||
this.props.relayers.length > 0 ?
|
|
||||||
this.props.relayers.map((r, i) => <option key={i} value={r}>Relayer #{i+1}: {r}</option>)
|
|
||||||
:
|
|
||||||
<option></option>
|
|
||||||
}
|
|
||||||
</TextField>
|
</TextField>
|
||||||
<TextField
|
<TextField
|
||||||
id="signature"
|
id="signature"
|
||||||
@ -315,7 +325,8 @@ Execute.propTypes = {
|
|||||||
kid: PropTypes.string,
|
kid: PropTypes.string,
|
||||||
skid: PropTypes.string,
|
skid: PropTypes.string,
|
||||||
clearMessages: PropTypes.func,
|
clearMessages: PropTypes.func,
|
||||||
relayers: PropTypes.array.isRequired
|
updateRelayer: PropTypes.func,
|
||||||
|
relayers: PropTypes.object.isRequired
|
||||||
};
|
};
|
||||||
|
|
||||||
export default withStyles(styles)(Execute);
|
export default withStyles(styles)(Execute);
|
||||||
|
@ -83,13 +83,17 @@ class Status extends Component {
|
|||||||
|
|
||||||
// Default for devenv
|
// Default for devenv
|
||||||
web3.eth.net.getId().then(netId => {
|
web3.eth.net.getId().then(netId => {
|
||||||
this.setState({isDev: netId != 1 && netId != 3});
|
this.setState({isDev: netId != 1});
|
||||||
});
|
});
|
||||||
|
|
||||||
web3.eth.subscribe('newBlockHeaders')
|
this.web3BlockRead();
|
||||||
.on('data', (block) => {
|
}
|
||||||
|
|
||||||
|
web3BlockRead = () => {
|
||||||
|
web3.eth.getBlock('latest').then(block => {
|
||||||
this.setState({block: block.number});
|
this.setState({block: block.number});
|
||||||
this.readChain();
|
this.readChain();
|
||||||
|
setTimeout(this.web3BlockRead, 10000);
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -52,14 +52,15 @@ class Status extends Component {
|
|||||||
constructor(props){
|
constructor(props){
|
||||||
super(props);
|
super(props);
|
||||||
this.state = {
|
this.state = {
|
||||||
|
'isDev': true,
|
||||||
'addressETHBalance': 0,
|
'addressETHBalance': 0,
|
||||||
'addressSTTBalance': 0,
|
'addressSTTBalance': 0,
|
||||||
'relayerAddress': null,
|
|
||||||
'relayerEthBalance': 0,
|
'relayerEthBalance': 0,
|
||||||
'relayerSTTBalance': 0,
|
'relayerSTTBalance': 0,
|
||||||
'block': 0,
|
'block': 0,
|
||||||
'submitState': {
|
'submitState': {
|
||||||
'etherSend': false,
|
'etherSend': false,
|
||||||
|
'changeSNTController': false,
|
||||||
'generateSTT': false
|
'generateSTT': false
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -72,19 +73,25 @@ class Status extends Component {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.setState({
|
|
||||||
relayerAddress: config.relayAccount
|
|
||||||
});
|
|
||||||
|
|
||||||
this.getBlock();
|
this.getBlock();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
getBlock = () => {
|
getBlock = () => {
|
||||||
web3.eth.subscribe('newBlockHeaders')
|
|
||||||
.on('data', (block) => {
|
// Default for devenv
|
||||||
|
web3.eth.net.getId().then(netId => {
|
||||||
|
this.setState({isDev: netId != 1});
|
||||||
|
});
|
||||||
|
|
||||||
|
this.web3BlockRead();
|
||||||
|
}
|
||||||
|
|
||||||
|
web3BlockRead = () => {
|
||||||
|
web3.eth.getBlock('latest').then(block => {
|
||||||
this.setState({block: block.number});
|
this.setState({block: block.number});
|
||||||
this.readChain();
|
this.readChain();
|
||||||
|
setTimeout(this.web3BlockRead, 10000);
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -117,12 +124,12 @@ class Status extends Component {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
web3.eth.getBalance(this.state.relayerAddress)
|
web3.eth.getBalance(this.props.relayerAddress)
|
||||||
.then(relayerEthBalance => {
|
.then(relayerEthBalance => {
|
||||||
this.setState({relayerEthBalance});
|
this.setState({relayerEthBalance});
|
||||||
});
|
});
|
||||||
|
|
||||||
STT.methods.balanceOf(this.state.relayerAddress)
|
STT.methods.balanceOf(this.props.relayerAddress)
|
||||||
.call()
|
.call()
|
||||||
.then(relayerSTTBalance => {
|
.then(relayerSTTBalance => {
|
||||||
this.setState({relayerSTTBalance: web3.utils.fromWei(relayerSTTBalance, 'ether')});
|
this.setState({relayerSTTBalance: web3.utils.fromWei(relayerSTTBalance, 'ether')});
|
||||||
@ -152,6 +159,12 @@ class Status extends Component {
|
|||||||
|
|
||||||
changeSNTController = event => {
|
changeSNTController = event => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
|
||||||
|
let submitState = this.state.submitState;
|
||||||
|
submitState.changeSNTController = true;
|
||||||
|
this.setState({submitState});
|
||||||
|
|
||||||
|
|
||||||
const toSend = STT.methods.changeController(SNTController.options.address);
|
const toSend = STT.methods.changeController(SNTController.options.address);
|
||||||
|
|
||||||
toSend.estimateGas()
|
toSend.estimateGas()
|
||||||
@ -160,6 +173,9 @@ class Status extends Component {
|
|||||||
})
|
})
|
||||||
.then(receipt => {
|
.then(receipt => {
|
||||||
console.log(receipt);
|
console.log(receipt);
|
||||||
|
submitState = this.state.submitState;
|
||||||
|
submitState.changeSNTController = false;
|
||||||
|
this.setState({submitState});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -167,10 +183,10 @@ class Status extends Component {
|
|||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
|
||||||
let submitState = this.state.submitState;
|
let submitState = this.state.submitState;
|
||||||
submitState.etherSend = false;
|
submitState.etherSend = true;
|
||||||
this.setState({submitState});
|
this.setState({submitState});
|
||||||
|
|
||||||
web3.eth.sendTransaction({from: web3.eth.defaultAccount, to: this.state.relayerAddress, value: web3.utils.toWei('1', "ether")})
|
web3.eth.sendTransaction({from: web3.eth.defaultAccount, to: this.props.relayerAddress, value: web3.utils.toWei('1', "ether")})
|
||||||
.then((receipt) => {
|
.then((receipt) => {
|
||||||
console.log(receipt);
|
console.log(receipt);
|
||||||
submitState = this.state.submitState;
|
submitState = this.state.submitState;
|
||||||
@ -180,8 +196,8 @@ class Status extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
render(){
|
render(){
|
||||||
const {classes, walletAddress, nonce} = this.props;
|
const {classes, walletAddress, nonce, relayerAddress} = this.props;
|
||||||
const {addressETHBalance, relayerAddress, relayerEthBalance, addressSTTBalance, relayerSTTBalance, submitState, block} = this.state;
|
const {addressETHBalance, relayerEthBalance, addressSTTBalance, relayerSTTBalance, submitState, block, isDev} = this.state;
|
||||||
|
|
||||||
return <Fragment>
|
return <Fragment>
|
||||||
<Card className={classes.card}>
|
<Card className={classes.card}>
|
||||||
@ -200,14 +216,14 @@ class Status extends Component {
|
|||||||
<Typography variant="display1">
|
<Typography variant="display1">
|
||||||
Address
|
Address
|
||||||
</Typography>
|
</Typography>
|
||||||
<Button className={classes.button} color="primary" aria-label="Generate STT" onClick={this.generateSTT} disabled={submitState.generateSTT}>
|
{ isDev && <Button className={classes.button} color="primary" aria-label="Generate STT" onClick={this.generateSTT} disabled={submitState.generateSTT}>
|
||||||
<AddIcon className={classes.icon} />
|
<AddIcon className={classes.icon} />
|
||||||
1. Generate 5K STT (only on dev)
|
1. Generate 5K STT (only on dev)
|
||||||
</Button>
|
</Button> }
|
||||||
<Button className={classes.button} color="primary" aria-label="Generate STT" onClick={this.changeSNTController}>
|
{ isDev && <Button className={classes.button} color="primary" aria-label="Generate STT" onClick={this.changeSNTController}>
|
||||||
<AddIcon className={classes.icon} />
|
<AddIcon className={classes.icon} />
|
||||||
2. Change SNT Controller
|
2. Change SNT Controller
|
||||||
</Button>
|
</Button> }
|
||||||
</ListItem>
|
</ListItem>
|
||||||
<ListItem className={classes.root}>
|
<ListItem className={classes.root}>
|
||||||
<ListItemIcon>
|
<ListItemIcon>
|
||||||
@ -247,10 +263,10 @@ class Status extends Component {
|
|||||||
<Typography variant="display1">
|
<Typography variant="display1">
|
||||||
Relayer
|
Relayer
|
||||||
</Typography>
|
</Typography>
|
||||||
<Button className={classes.button} color="primary" aria-label="Add ether" onClick={this.sendEther} disabled={submitState.etherSend}>
|
{ isDev && <Button className={classes.button} color="primary" aria-label="Add ether" onClick={this.sendEther} disabled={submitState.etherSend}>
|
||||||
<AddIcon className={classes.icon} />
|
<AddIcon className={classes.icon} />
|
||||||
Send ether
|
Send ether
|
||||||
</Button>
|
</Button> }
|
||||||
</ListItem>
|
</ListItem>
|
||||||
<ListItem className={classes.root}>
|
<ListItem className={classes.root}>
|
||||||
<ListItemIcon>
|
<ListItemIcon>
|
||||||
@ -292,7 +308,8 @@ Status.propTypes = {
|
|||||||
walletAddress: PropTypes.string,
|
walletAddress: PropTypes.string,
|
||||||
nonce: PropTypes.string.isRequired,
|
nonce: PropTypes.string.isRequired,
|
||||||
nonceUpdateFunction: PropTypes.func.isRequired,
|
nonceUpdateFunction: PropTypes.func.isRequired,
|
||||||
message: PropTypes.string
|
message: PropTypes.string,
|
||||||
|
relayerAddress: PropTypes.string
|
||||||
};
|
};
|
||||||
|
|
||||||
export default withStyles(styles)(Status);
|
export default withStyles(styles)(Status);
|
||||||
|
@ -51,6 +51,9 @@ class TransferSNT extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
handleChange = name => event => {
|
handleChange = name => event => {
|
||||||
|
if(name == 'relayer'){
|
||||||
|
this.props.updateRelayer(event.target.value);
|
||||||
|
}
|
||||||
this.setState({
|
this.setState({
|
||||||
[name]: event.target.value
|
[name]: event.target.value
|
||||||
});
|
});
|
||||||
@ -77,7 +80,7 @@ class TransferSNT extends Component {
|
|||||||
try {
|
try {
|
||||||
const accounts = await web3.eth.getAccounts();
|
const accounts = await web3.eth.getAccounts();
|
||||||
|
|
||||||
const s = new StatusGasRelayer.SNTController(SNTController.options.address, accounts[2])
|
const s = new StatusGasRelayer.SNTController(SNTController.options.address, accounts[0])
|
||||||
.transferSNT(this.state.to, this.state.amount)
|
.transferSNT(this.state.to, this.state.amount)
|
||||||
.setGas(this.state.gasPrice);
|
.setGas(this.state.gasPrice);
|
||||||
|
|
||||||
@ -105,7 +108,7 @@ class TransferSNT extends Component {
|
|||||||
try {
|
try {
|
||||||
const accounts = await web3.eth.getAccounts();
|
const accounts = await web3.eth.getAccounts();
|
||||||
|
|
||||||
const s = new StatusGasRelayer.AvailableRelayers(Contracts.SNT, SNTController.options.address, accounts[2])
|
const s = new StatusGasRelayer.AvailableRelayers(Contracts.SNT, SNTController.options.address, accounts[0])
|
||||||
.setRelayersSymKeyID(skid)
|
.setRelayersSymKeyID(skid)
|
||||||
.setAsymmetricKeyID(kid)
|
.setAsymmetricKeyID(kid)
|
||||||
.setGas(STT.options.address, this.state.gasPrice);
|
.setGas(STT.options.address, this.state.gasPrice);
|
||||||
@ -125,9 +128,16 @@ class TransferSNT extends Component {
|
|||||||
const {web3, kid} = this.props;
|
const {web3, kid} = this.props;
|
||||||
|
|
||||||
let relayer = this.state.relayer;
|
let relayer = this.state.relayer;
|
||||||
if(relayer == '' && this.props.relayers.length == 1){
|
|
||||||
relayer = this.props.relayers[0];
|
|
||||||
}
|
let relayers = [];
|
||||||
|
for (var key in this.props.relayers) {
|
||||||
|
if (this.props.relayers.hasOwnProperty(key)) relayers.push(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(relayer == '' && relayers.length == 1){
|
||||||
|
relayer = relayers[0];
|
||||||
|
}
|
||||||
|
|
||||||
this.setState({
|
this.setState({
|
||||||
messagingError: '',
|
messagingError: '',
|
||||||
@ -138,7 +148,7 @@ class TransferSNT extends Component {
|
|||||||
try {
|
try {
|
||||||
const accounts = await web3.eth.getAccounts();
|
const accounts = await web3.eth.getAccounts();
|
||||||
|
|
||||||
const s = new StatusGasRelayer.SNTController(SNTController.options.address, accounts[2])
|
const s = new StatusGasRelayer.SNTController(SNTController.options.address, accounts[0])
|
||||||
.transferSNT(this.state.to, this.state.amount)
|
.transferSNT(this.state.to, this.state.amount)
|
||||||
.setGas(this.state.gasPrice)
|
.setGas(this.state.gasPrice)
|
||||||
.setRelayer(relayer)
|
.setRelayer(relayer)
|
||||||
@ -156,6 +166,12 @@ class TransferSNT extends Component {
|
|||||||
|
|
||||||
render(){
|
render(){
|
||||||
const {classes} = this.props;
|
const {classes} = this.props;
|
||||||
|
|
||||||
|
let relayers = [];
|
||||||
|
for (var key in this.props.relayers) {
|
||||||
|
if (this.props.relayers.hasOwnProperty(key)) relayers.push(key);
|
||||||
|
}
|
||||||
|
|
||||||
return <div>
|
return <div>
|
||||||
<Card className={classes.card}>
|
<Card className={classes.card}>
|
||||||
<CardContent>
|
<CardContent>
|
||||||
@ -270,12 +286,8 @@ class TransferSNT extends Component {
|
|||||||
native: true
|
native: true
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{
|
{ relayers.length > 0 ? relayers.map((r, i) => <option key={i} value={r}>Relayer #{i+1}: {r}</option>) : <option></option> }
|
||||||
this.props.relayers.length > 0 ?
|
|
||||||
this.props.relayers.map((r, i) => <option key={i} value={r}>Relayer #{i+1}: {r}</option>)
|
|
||||||
:
|
|
||||||
<option></option>
|
|
||||||
}
|
|
||||||
</TextField>
|
</TextField>
|
||||||
<TextField
|
<TextField
|
||||||
id="signature"
|
id="signature"
|
||||||
@ -306,7 +318,8 @@ TransferSNT.propTypes = {
|
|||||||
kid: PropTypes.string,
|
kid: PropTypes.string,
|
||||||
skid: PropTypes.string,
|
skid: PropTypes.string,
|
||||||
clearMessages: PropTypes.func,
|
clearMessages: PropTypes.func,
|
||||||
relayers: PropTypes.array.isRequired
|
updateRelayer: PropTypes.func,
|
||||||
|
relayers: PropTypes.object.isRequired
|
||||||
};
|
};
|
||||||
|
|
||||||
export default withStyles(styles)(TransferSNT);
|
export default withStyles(styles)(TransferSNT);
|
||||||
|
@ -51,12 +51,12 @@ module.exports = {
|
|||||||
"IdentityKernel": {"deploy": false},
|
"IdentityKernel": {"deploy": false},
|
||||||
"STT": {
|
"STT": {
|
||||||
"instanceOf": "TestMiniMeToken",
|
"instanceOf": "TestMiniMeToken",
|
||||||
"args":["$MiniMeTokenFactory", "0x0", "0x0", "Status Test Token", 18, "STT", true],
|
"args":["$MiniMeTokenFactory", "0x0", "0x0", "Status Gas Relayer Test Token", 18, "STT", true],
|
||||||
"gasLimit": 4000000
|
"gasLimit": 4000000
|
||||||
},
|
},
|
||||||
"SNTController": {
|
"SNTController": {
|
||||||
"args": ["0x5f803F54679577fC974813E48abF012A243dD439", "$STT"]
|
"args": ["0x5f803F54679577fC974813E48abF012A243dD439", "$STT"]
|
||||||
},
|
},
|
||||||
"IdentityGasRelay": {
|
"IdentityGasRelay": {
|
||||||
"deploy": true,
|
"deploy": true,
|
||||||
"args": [[], [], [], 1, 1, "0x0000000000000000000000000000000000000000"]
|
"args": [[], [], [], 1, 1, "0x0000000000000000000000000000000000000000"]
|
||||||
@ -73,31 +73,32 @@ module.exports = {
|
|||||||
},
|
},
|
||||||
testnet: {
|
testnet: {
|
||||||
contracts: {
|
contracts: {
|
||||||
|
//
|
||||||
"MiniMeTokenFactory": {
|
"MiniMeTokenFactory": {
|
||||||
"address": "0xBda00586BF6D79F22203EeDe046DEcaaf2B771B4"
|
"address": "0xD1A2f3726331d6100E8BcD1484EdF796B0b20cc9"
|
||||||
},
|
},
|
||||||
"STT": {
|
"STT": {
|
||||||
"instanceOf": "TestMiniMeToken",
|
"instanceOf": "TestMiniMeToken",
|
||||||
"address": "0xd7879e4401c548544196dc0215df449B2a1E23B3"
|
"address": "0x121a430A73Fc13e2D6d4a9dc3E943de647c30f8f"
|
||||||
},
|
},
|
||||||
"SNTController": {
|
"SNTController": {
|
||||||
"address": "0xA77A1014F55157c3119FB3f53E653E42f8fa634c"
|
"address": "0xf558aC91312821B0E1802567BC785355AA811783"
|
||||||
},
|
},
|
||||||
"IdentityGasRelay": {
|
"IdentityGasRelay": {
|
||||||
"address": "0xEA60E967BA16Bf4313B5d23b78e44763C8928C67"
|
"address": "0x4b571c5e75E93F53E985b12A3D107318178b9B5F"
|
||||||
},
|
},
|
||||||
"IdentityFactory": {
|
"IdentityFactory": {
|
||||||
"address": "0x7F106A1Bc637AC4AAed3DC72582749c4562D4323"
|
"address": "0x89976FeEC7CFDF2DF5194e363FD2a3388e2DC91A"
|
||||||
},
|
},
|
||||||
"TestContract": {
|
"TestContract": {
|
||||||
"address": "0x1F0C9ebD14Ba43BDD5b43C52EbEfc31066704988"
|
"address": "0xa7aeF1cd3e4a8425D9A1E13B5557908895dCbdBE"
|
||||||
}
|
}
|
||||||
// If needed to deploy contracts again, uncomment the following lines
|
// If needed to deploy contracts again, uncomment the following lines
|
||||||
/*
|
/*
|
||||||
"MiniMeTokenFactory": {"args":[]},
|
"MiniMeTokenFactory": {"args":[]},
|
||||||
"STT": {
|
"STT": {
|
||||||
"instanceOf": "MiniMeToken",
|
"instanceOf": "MiniMeToken",
|
||||||
"args":["$MiniMeTokenFactory", "0x0", "0x0", "Status Test Token", 18, "STT", true],
|
"args":["$MiniMeTokenFactory", "0x0", "0x0", "Status Gas Relayer Test Token", 18, "STT", true],
|
||||||
"gasLimit": 4000000
|
"gasLimit": 4000000
|
||||||
},
|
},
|
||||||
"SNTController": {
|
"SNTController": {
|
||||||
@ -114,9 +115,7 @@ module.exports = {
|
|||||||
},
|
},
|
||||||
"TestContract": {
|
"TestContract": {
|
||||||
"args": ["$STT"]
|
"args": ["$STT"]
|
||||||
}
|
}*/
|
||||||
*/
|
}
|
||||||
},
|
}
|
||||||
accounts: [{privateKey: "71DB9B832BF457B4D812D6D6D673A02A1A2F5F687DBF59A2E41302A43459153C"}]
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
@ -1,5 +1,47 @@
|
|||||||
pragma solidity ^0.4.23;
|
pragma solidity ^0.4.23;
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
INTENTIONALLY INSECURE DO NOT USE IN MAINNET
|
||||||
|
INTENTIONALLY INSECURE DO NOT USE IN MAINNET
|
||||||
|
INTENTIONALLY INSECURE DO NOT USE IN MAINNET
|
||||||
|
INTENTIONALLY INSECURE DO NOT USE IN MAINNET
|
||||||
|
INTENTIONALLY INSECURE DO NOT USE IN MAINNET
|
||||||
|
INTENTIONALLY INSECURE DO NOT USE IN MAINNET
|
||||||
|
INTENTIONALLY INSECURE DO NOT USE IN MAINNET
|
||||||
|
INTENTIONALLY INSECURE DO NOT USE IN MAINNET
|
||||||
|
INTENTIONALLY INSECURE DO NOT USE IN MAINNET
|
||||||
|
INTENTIONALLY INSECURE DO NOT USE IN MAINNET
|
||||||
|
INTENTIONALLY INSECURE DO NOT USE IN MAINNET
|
||||||
|
INTENTIONALLY INSECURE DO NOT USE IN MAINNET
|
||||||
|
INTENTIONALLY INSECURE DO NOT USE IN MAINNET
|
||||||
|
INTENTIONALLY INSECURE DO NOT USE IN MAINNET
|
||||||
|
INTENTIONALLY INSECURE DO NOT USE IN MAINNET
|
||||||
|
INTENTIONALLY INSECURE DO NOT USE IN MAINNET
|
||||||
|
INTENTIONALLY INSECURE DO NOT USE IN MAINNET
|
||||||
|
INTENTIONALLY INSECURE DO NOT USE IN MAINNET
|
||||||
|
INTENTIONALLY INSECURE DO NOT USE IN MAINNET
|
||||||
|
INTENTIONALLY INSECURE DO NOT USE IN MAINNET
|
||||||
|
INTENTIONALLY INSECURE DO NOT USE IN MAINNET
|
||||||
|
INTENTIONALLY INSECURE DO NOT USE IN MAINNET
|
||||||
|
INTENTIONALLY INSECURE DO NOT USE IN MAINNET
|
||||||
|
INTENTIONALLY INSECURE DO NOT USE IN MAINNET
|
||||||
|
INTENTIONALLY INSECURE DO NOT USE IN MAINNET
|
||||||
|
INTENTIONALLY INSECURE DO NOT USE IN MAINNET
|
||||||
|
INTENTIONALLY INSECURE DO NOT USE IN MAINNET
|
||||||
|
INTENTIONALLY INSECURE DO NOT USE IN MAINNET
|
||||||
|
INTENTIONALLY INSECURE DO NOT USE IN MAINNET
|
||||||
|
INTENTIONALLY INSECURE DO NOT USE IN MAINNET
|
||||||
|
INTENTIONALLY INSECURE DO NOT USE IN MAINNET
|
||||||
|
INTENTIONALLY INSECURE DO NOT USE IN MAINNET
|
||||||
|
INTENTIONALLY INSECURE DO NOT USE IN MAINNET
|
||||||
|
INTENTIONALLY INSECURE DO NOT USE IN MAINNET
|
||||||
|
INTENTIONALLY INSECURE DO NOT USE IN MAINNET
|
||||||
|
INTENTIONALLY INSECURE DO NOT USE IN MAINNET
|
||||||
|
INTENTIONALLY INSECURE DO NOT USE IN MAINNET
|
||||||
|
INTENTIONALLY INSECURE DO NOT USE IN MAINNET
|
||||||
|
INTENTIONALLY INSECURE DO NOT USE IN MAINNET
|
||||||
|
*/
|
||||||
/*
|
/*
|
||||||
Copyright 2016, Jordi Baylina
|
Copyright 2016, Jordi Baylina
|
||||||
|
|
||||||
@ -26,7 +68,6 @@ pragma solidity ^0.4.23;
|
|||||||
* @dev It is ERC20 compliant, but still needs to under go further testing.
|
* @dev It is ERC20 compliant, but still needs to under go further testing.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import "../common/Controlled.sol";
|
|
||||||
import "../token/TokenController.sol";
|
import "../token/TokenController.sol";
|
||||||
import "../token/ApproveAndCallFallBack.sol";
|
import "../token/ApproveAndCallFallBack.sol";
|
||||||
import "../token/MiniMeTokenInterface.sol";
|
import "../token/MiniMeTokenInterface.sol";
|
||||||
@ -37,7 +78,7 @@ import "../token/MiniMeTokenFactory.sol";
|
|||||||
* that deploys the contract, so usually this token will be deployed by a
|
* that deploys the contract, so usually this token will be deployed by a
|
||||||
* token controller contract, which Giveth will call a "Campaign"
|
* token controller contract, which Giveth will call a "Campaign"
|
||||||
*/
|
*/
|
||||||
contract TestMiniMeToken is MiniMeTokenInterface, Controlled {
|
contract TestMiniMeToken is MiniMeTokenInterface {
|
||||||
|
|
||||||
string public name; //The Token's name: e.g. DigixDAO Tokens
|
string public name; //The Token's name: e.g. DigixDAO Tokens
|
||||||
uint8 public decimals; //Number of decimals of the smallest unit
|
uint8 public decimals; //Number of decimals of the smallest unit
|
||||||
@ -86,6 +127,20 @@ contract TestMiniMeToken is MiniMeTokenInterface, Controlled {
|
|||||||
// The factory used to create new clone tokens
|
// The factory used to create new clone tokens
|
||||||
MiniMeTokenFactory public tokenFactory;
|
MiniMeTokenFactory public tokenFactory;
|
||||||
|
|
||||||
|
modifier onlyController {
|
||||||
|
require(msg.sender == controller);
|
||||||
|
_;
|
||||||
|
}
|
||||||
|
|
||||||
|
address public controller;
|
||||||
|
|
||||||
|
/// @notice Changes the controller of the contract
|
||||||
|
/// @param _newController The new controller of the contract
|
||||||
|
function changeController(address _newController) public {
|
||||||
|
controller = _newController;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////
|
////////////////
|
||||||
// Constructor
|
// Constructor
|
||||||
////////////////
|
////////////////
|
||||||
@ -116,6 +171,8 @@ contract TestMiniMeToken is MiniMeTokenInterface, Controlled {
|
|||||||
)
|
)
|
||||||
public
|
public
|
||||||
{
|
{
|
||||||
|
controller = msg.sender;
|
||||||
|
|
||||||
tokenFactory = MiniMeTokenFactory(_tokenFactory);
|
tokenFactory = MiniMeTokenFactory(_tokenFactory);
|
||||||
name = _tokenName; // Set the name
|
name = _tokenName; // Set the name
|
||||||
decimals = _decimalUnits; // Set the decimals
|
decimals = _decimalUnits; // Set the decimals
|
||||||
|
Loading…
x
Reference in New Issue
Block a user