-
-
Notifications
You must be signed in to change notification settings - Fork 654
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Broadcast Tx #304
Merged
Merged
Broadcast Tx #304
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
8fa842a
create MVP of broadcast TX component
dternyak c11e450
add broadcastTx to routes and tab options
dternyak 90062e1
Update BroadcastTx path to /pushTx
dternyak 5e904fc
- add sanitizeHex and padLeftEven functions from V3
dternyak 3e09520
- Move decodeTransaction logic out of ConfirmationModal.
dternyak 4bb8bc5
Simplify ConfirmationModal:
dternyak a7ad257
- Don't map node state (child component grabs from state)
dternyak 296f697
correct tab to path.
dternyak 5ed10c4
1. Integrate Confirmation Modal
dternyak 42c5e43
disable tslint error. EthTx expect a Data type object, but a string i…
dternyak 4b0d936
adjust type definition to match allowed string input. Remove tslint d…
dternyak c88aa9f
fix tslint errors
dternyak b902792
Merge branch 'develop' into broadcast-tx
dternyak d70aed9
Merge branch 'develop' into broadcast-tx
dternyak c9d5589
add textarea valid/invalid stlying based on disabled status
dternyak 86a1066
Merge branch 'broadcast-tx' of https://github.com/MyEtherWallet/MyEth…
dternyak 661fa10
Merge branch 'develop' of https://github.com/MyEtherWallet/MyEtherWal…
dternyak 904b5c6
remove unused imports
dternyak 8ae85e7
cleanup / address PR comments
dternyak 70fe6cd
Address PR comments
dternyak File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
@import "common/sass/variables"; | ||
|
||
.BroadcastTx { | ||
&-title { | ||
margin: $space auto $space * 2.5; | ||
} | ||
} |
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,140 @@ | ||
import React, { Component } from 'react'; | ||
import { connect } from 'react-redux'; | ||
import { AppState } from 'reducers'; | ||
import TabSection from 'containers/TabSection'; | ||
import { translateRaw } from 'translations'; | ||
import { broadcastTx as dBroadcastTx, TBroadcastTx } from 'actions/wallet'; | ||
import { QRCode } from 'components/ui'; | ||
import './index.scss'; | ||
import { | ||
BroadcastTransactionStatus, | ||
getTransactionFields | ||
} from 'libs/transaction'; | ||
import EthTx from 'ethereumjs-tx'; | ||
import { ConfirmationModal } from 'containers/Tabs/SendTransaction/components'; | ||
import classnames from 'classnames'; | ||
|
||
interface Props { | ||
broadcastTx: TBroadcastTx; | ||
transactions: BroadcastTransactionStatus[]; | ||
} | ||
|
||
interface State { | ||
signedTx: string; | ||
showConfirmationModal: boolean; | ||
disabled: boolean; | ||
} | ||
|
||
const initialState: State = { | ||
showConfirmationModal: false, | ||
signedTx: '', | ||
disabled: true | ||
}; | ||
|
||
class BroadcastTx extends Component<Props, State> { | ||
public state = initialState; | ||
|
||
public ensureValidSignedTxInputOnUpdate() { | ||
try { | ||
const tx = new EthTx(this.state.signedTx); | ||
getTransactionFields(tx); | ||
if (this.state.disabled) { | ||
this.setState({ disabled: false }); | ||
} | ||
} catch (e) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. TS lets you do |
||
if (!this.state.disabled) { | ||
this.setState({ disabled: true }); | ||
} | ||
} | ||
} | ||
|
||
public componentDidUpdate() { | ||
this.ensureValidSignedTxInputOnUpdate(); | ||
} | ||
|
||
public render() { | ||
const { signedTx, disabled, showConfirmationModal } = this.state; | ||
|
||
const inputClasses = classnames({ | ||
'form-control': true, | ||
'is-valid': !disabled, | ||
'is-invalid': disabled | ||
}); | ||
|
||
return ( | ||
<TabSection> | ||
<div className="Tab-content-pane row block text-center"> | ||
<div className="col-md-6"> | ||
<div className="col-md-12 BroadcastTx-title"> | ||
<h2>Broadcast Signed Transaction</h2> | ||
</div> | ||
<p> | ||
Paste a signed transaction and press the "SEND TRANSACTION" | ||
button. | ||
</p> | ||
<label>{translateRaw('SEND_signed')}</label> | ||
<textarea | ||
className={inputClasses} | ||
rows={7} | ||
value={signedTx} | ||
onChange={this.handleChange} | ||
/> | ||
<button | ||
className="btn btn-primary" | ||
disabled={disabled || signedTx === ''} | ||
onClick={this.handleBroadcastTx} | ||
> | ||
{translateRaw('SEND_trans')} | ||
</button> | ||
</div> | ||
|
||
<div className="col-md-6" style={{ marginTop: '70px' }}> | ||
<div | ||
className="qr-code text-center" | ||
style={{ | ||
maxWidth: '15rem', | ||
margin: '1rem auto', | ||
width: '100%' | ||
}} | ||
> | ||
{signedTx && <QRCode data={signedTx} />} | ||
</div> | ||
</div> | ||
</div> | ||
{showConfirmationModal && ( | ||
<ConfirmationModal | ||
signedTx={signedTx} | ||
onClose={this.handleClose} | ||
onConfirm={this.handleConfirm} | ||
/> | ||
)} | ||
</TabSection> | ||
); | ||
} | ||
|
||
public handleClose = () => { | ||
this.setState({ showConfirmationModal: false }); | ||
}; | ||
|
||
public handleBroadcastTx = () => { | ||
this.setState({ showConfirmationModal: true }); | ||
}; | ||
|
||
public handleConfirm = () => { | ||
this.props.broadcastTx(this.state.signedTx); | ||
}; | ||
|
||
protected handleChange = event => { | ||
this.setState({ signedTx: event.target.value }); | ||
}; | ||
} | ||
|
||
function mapStateToProps(state: AppState) { | ||
return { | ||
transactions: state.wallet.transactions | ||
}; | ||
} | ||
|
||
export default connect(mapStateToProps, { broadcastTx: dBroadcastTx })( | ||
BroadcastTx | ||
); |
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there a reason for naming this
pushTx
instead of the format ofbroadcast-tx
like thesend-transaction
route?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, to match etherscan.