@@ -43,100 +43,35 @@ class IssueChild extends React.Component {
4343 ]
4444
4545 this.state = {
46− txError: Nothing(),
4746 receivingAddress: '',
4847 issuingPoint: issuingPoint,
4948 desiredPoint: '',
5049 isAvailable: Nothing(), // use Nothing to allow attempt when offline
51− userApproval: false,
52− nonce: '',
53− gasPrice: '5',
54− showGasDetails: false,
55− chainId: '',
56− gasLimit: '600000',
57− txn: Nothing(),
58− stx: Nothing(),
5950 suggestions: suggestions,
6051 }
6152
6253 this.handlePointInput = this.handlePointInput.bind(this)
6354 this.handleAddressInput = this.handleAddressInput.bind(this)
6455 this.handleConfirmAvailability = this.handleConfirmAvailability.bind(this)
65− this.handleCreateUnsignedTxn = this.handleCreateUnsignedTxn.bind(this)
66− this.handleSubmit = this.handleSubmit.bind(this)
67− this.handleSetUserApproval = this.handleSetUserApproval.bind(this)
68− this.handleSetTxn = this.handleSetTxn.bind(this)
69− this.handleSetStx = this.handleSetStx.bind(this)
70− this.handleSetNonce = this.handleSetNonce.bind(this)
71− this.handleSetChainId = this.handleSetChainId.bind(this)
72− this.handleSetGasPrice = this.handleSetGasPrice.bind(this)
73− this.handleSetGasLimit = this.handleSetGasLimit.bind(this)
74− this.toggleGasDetails = this.toggleGasDetails.bind(this)
56+ this.createUnsignedTxn = this.createUnsignedTxn.bind(this)
57+ this.statelessRef = React.createRef();
7558 }
7659
77− toggleGasDetails() {
78− this.setState({
79− showGasDetails: !this.state.showGasDetails
80− })
81− }
82−
83− componentDidMount() {
84− const { props } = this
85−
86− const addr = props.wallet.matchWith({
87− Just: wal => addressFromSecp256k1Public(wal.value.publicKey),
88− Nothing: () => {
89− throw BRIDGE_ERROR.MISSING_WALLET
90− }
91− })
92−
93− props.web3.matchWith({
94− Nothing: () => {},
95− Just: (w3) => {
96− const validWeb3 = w3.value
97−
98− const getTxMetadata = [
99− validWeb3.eth.getTransactionCount(addr),
100− validWeb3.eth.net.getId(),
101− validWeb3.eth.getGasPrice()
102− ]
103−
104− Promise.all(getTxMetadata).then(r => {
105− const txMetadata = {
106− nonce: r[0],
107− chainId: r[1],
108− gasPrice: fromWei(r[2], 'gwei'),
109− }
110−
111− this.setState({...txMetadata})
112−
113− })
114− }
115− })
116−
117− }
118−
119−
120−
12160 handleAddressInput = (receivingAddress) => {
12261 this.setState({ receivingAddress })
123− this.handleClearTxn()
62+ this.statelessRef.current.clearTxn()
12463 }
12564
126−
127−
12865 handlePointInput(desiredPoint) {
12966 if (desiredPoint.length < 15) {
13067 this.setState({
13168 desiredPoint,
13269 isAvailable: Nothing()
13370 })
134− this.handleClearTxn()
71+ this.statelessRef.current.clearTxn()
13572 }
13673 }
13774
138−
139−
14075 handleConfirmAvailability() {
14176 this.confirmPointAvailability().then(r => {
14277 this.setState({
@@ -146,106 +81,6 @@ class IssueChild extends React.Component {
14681
14782 }
14883
149−
150−
151− handleCreateUnsignedTxn() {
152− const txn = this.createUnsignedTxn()
153− this.setState({ txn })
154− }
155−
156−
157− handleSetUserApproval(){
158− const {state} = this
159− this.setState({ userApproval: !state.userApproval })
160− }
161−
162−
163−
164− handleSetTxn(txn){
165− this.setState({ txn })
166− }
167−
168−
169−
170− handleSetStx(stx){
171− this.setState({
172− stx,
173− userApproval: false,
174− })
175− }
176−
177−
178−
179− handleSetNonce(nonce){
180− this.setState({ nonce })
181− this.handleClearStx()
182− }
183−
184−
185−
186− handleSetChainId(chainId){
187− this.setState({ chainId })
188− this.handleClearStx()
189− }
190−
191−
192−
193− handleSetGasPrice(gasPrice){
194− this.setState({ gasPrice })
195− this.handleClearStx()
196− }
197−
198−
199−
200− handleSetGasLimit(gasLimit){
201− this.setState({ gasLimit })
202− this.handleClearStx()
203− }
204−
205−
206−
207− handleClearStx() {
208− this.setState({
209− userApproval: false,
210− stx: Nothing(),
211− })
212− }
213−
214−
215−
216− handleClearTxn() {
217− this.setState({
218− userApproval: false,
219− txn: Nothing(),
220− stx: Nothing(),
221− })
222− }
223−
224−
225−
226− handleClearTransaction() {
227− this.setState({
228− userApproval: false,
229− txn: Nothing(),
230− stx: Nothing(),
231− })
232− }
233−
234−
235−
236− handleSubmit(){
237− const { props, state } = this
238− sendSignedTransaction(props.web3.value, state.stx)
239− .then(sent => {
240− props.setTxnHashCursor(sent)
241− props.popRoute()
242− props.pushRoute(ROUTE_NAMES.SENT_TRANSACTION)
243− })
244− .catch(err => {
245− this.setState({ txError: err.map(val => val.merge()) })
246− })
247− }
248−
24984 async confirmPointAvailability() {
25085 const { contracts } = this.props
25186 const { desiredPoint } = this.state
@@ -307,8 +142,6 @@ class IssueChild extends React.Component {
307142 return Just(txn)
308143 }
309144
310−
311−
312145 buttonTriState() {
313146 const a = this.state.isAvailable
314147 if (Nothing.hasInstance(a)) return 'blue'
@@ -316,8 +149,6 @@ class IssueChild extends React.Component {
316149 if (a.value === true) return 'green'
317150 }
318151
319−
320−
321152 buttonTriStateText() {
322153 const a = this.state.isAvailable
323154 if (Nothing.hasInstance(a)) return 'Confirm Availablility'
@@ -343,7 +174,6 @@ class IssueChild extends React.Component {
343174 return vpatp && vchild
344175 }
345176
346−
347177 render() {
348178 const { props, state } = this
349179
@@ -362,12 +192,6 @@ class IssueChild extends React.Component {
362192 }
363193 })
364194
365− const canSign = Just.hasInstance(state.txn)
366− const canApprove = Just.hasInstance(state.stx)
367− const canSend =
368− Just.hasInstance(state.stx)
369− && state.userApproval === true
370−
371195 const esvisible =
372196 props.networkType === NETWORK_NAMES.ROPSTEN ||
373197 props.networkType === NETWORK_NAMES.MAINNET
@@ -480,46 +304,13 @@ class IssueChild extends React.Component {
480304 walletType={props.walletType}
481305 walletHdPath={props.walletHdPath}
482306 networkType={props.networkType}
483− // Tx
484− txn={state.txn}
485− stx={state.stx}
486− // Tx details
487− nonce={state.nonce}
488− gasPrice={state.gasPrice}
489− showGasDetails={state.showGasDetails}
490− toggleGasDetails={this.toggleGasDetails}
491− chainId={state.chainId}
492− gasLimit={state.gasLimit}
493− // Checks
494− userApproval={state.userApproval}
495− canGenerate={ canGenerate }
496− canSign={ canSign }
497− canApprove={ canApprove }
498− canSend={ canSend }
499− // Methods
500− createUnsignedTxn={this.handleCreateUnsignedTxn}
501− setUserApproval={this.handleSetUserApproval}
502− setTxn={this.handleSetTxn}
503− setStx={this.handleSetStx}
504− setNonce={this.handleSetNonce}
505− setChainId={this.handleSetChainId}
506− setGasPrice={this.handleSetGasPrice}
507− setGasLimit={this.handleSetGasLimit}
508− handleSubmit={this.handleSubmit} />
509−
510− {
511− Nothing.hasInstance(state.txError)
512− ? ''
513− : <Warning className={'mt-8'}>
514− <H3 style={{marginTop: 0, paddingTop: 0}}>
515− {
516− 'There was an error sending your transaction.'
517− }
518− </H3>
519− { state.txError.value }
520− </Warning>
521− }
522−
307+ setTxnHashCursor={props.setTxnHashCursor}
308+ popRoute={props.popRoute}
309+ pushRoute={props.pushRoute}
310+ // Other
311+ canGenerate={canGenerate}
312+ createUnsignedTxn={this.createUnsignedTxn}
313+ ref={this.statelessRef} />
523314 </Col>
524315 </Row>
525316 )