This repository has been archived by the owner on May 24, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from parity-js/am-send-tx
Signer
- Loading branch information
Showing
19 changed files
with
337 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// Copyright 2015-2018 Parity Technologies (UK) Ltd. | ||
// This file is part of Parity. | ||
// | ||
// SPDX-License-Identifier: MIT | ||
|
||
import React, { Component } from 'react'; | ||
import { Route } from 'react-router-dom'; | ||
|
||
import SignerDetails from './SignerDetails'; | ||
import SignerList from './SignerList'; | ||
|
||
class Signer extends Component { | ||
render () { | ||
return ( | ||
<div> | ||
<SignerList /> | ||
<hr /> | ||
<Route path='/signer/:requestId' component={SignerDetails} /> | ||
</div> | ||
); | ||
} | ||
} | ||
|
||
export default Signer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
// Copyright 2015-2018 Parity Technologies (UK) Ltd. | ||
// This file is part of Parity. | ||
// | ||
// SPDX-License-Identifier: MIT | ||
|
||
import React, { Component } from 'react'; | ||
import { fromWei } from '@parity/api/lib/util/wei'; | ||
import { inject, observer } from 'mobx-react'; | ||
|
||
@inject('signerStore') | ||
@observer | ||
class SignerDetails extends Component { | ||
state = { | ||
password: '' | ||
}; | ||
|
||
handleAccept = () => { | ||
const { | ||
match: { | ||
params: { requestId } | ||
}, | ||
signerStore | ||
} = this.props; | ||
const { password } = this.state; | ||
signerStore.acceptRequest(requestId, password); | ||
}; | ||
|
||
handleChangePassword = ({ target: { value } }) => { | ||
this.setState({ password: value }); | ||
}; | ||
|
||
handleReject = () => { | ||
const { | ||
match: { | ||
params: { requestId } | ||
}, | ||
signerStore | ||
} = this.props; | ||
signerStore.rejectRequest(requestId); | ||
}; | ||
|
||
handleSubmit = e => { | ||
e.preventDefault(); | ||
}; | ||
|
||
render () { | ||
const { | ||
match: { | ||
params: { requestId } | ||
}, | ||
signerStore: { requests } | ||
} = this.props; | ||
const { password } = this.state; | ||
const request = requests[requestId]; | ||
|
||
if (!request) { | ||
// This happens after we accept/reject a request | ||
return null; | ||
} | ||
|
||
const transaction = request.payload.sendTransaction; | ||
|
||
return ( | ||
<form onSubmit={this.handleSubmit}> | ||
<h3>Request number {requestId}</h3> | ||
<p>From: {transaction.from}</p> | ||
<p>To: {transaction.to}</p> | ||
<p>Amount: {+fromWei(transaction.value)}ETH</p> | ||
<p>Gas: {+transaction.gas}</p> | ||
<label> | ||
Enter your password to confirm:<br /> | ||
<input | ||
onChange={this.handleChangePassword} | ||
required | ||
type='password' | ||
value={password} | ||
/> | ||
</label> | ||
<br /> | ||
<button onClick={this.handleAccept}>Accept</button>{' '} | ||
<button onClick={this.handleReject}>Reject (no pw needed)</button> | ||
<br /> | ||
<em style={{ fontSize: 10 }}> | ||
@brian, for now for errors look in console, e.g. when nothing happens | ||
when you click on Accept | ||
</em> | ||
</form> | ||
); | ||
} | ||
} | ||
|
||
export default SignerDetails; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// Copyright 2015-2018 Parity Technologies (UK) Ltd. | ||
// This file is part of Parity. | ||
// | ||
// SPDX-License-Identifier: MIT | ||
|
||
import SignerDetails from './SignerDetails'; | ||
|
||
export default SignerDetails; |
Oops, something went wrong.