on master help sign in
- SetProxy goes through with no modifications!
commite421877553cdeb3970c8e3e61b74102c0e951cda authorChris Johnson <chris@cjohnson.io> dateWed 3 Apr 2019, 13:46 (8 years ago) parentd3c70b7
2 files changed+38−19
src/bridge/components/StatelessTransaction.js+22−18 src/bridge/views/SetProxy.js+16−1
src/bridge/components/StatelessTransaction.js+22−18
@@ -1,4 +1,4 @@
1−import { Maybe, Nothing } from 'folktale/maybe'
1+import { Maybe, Nothing, Just } from 'folktale/maybe'
22import React from 'react'
33
44import { Code, H3 } from './Base'
@@ -38,7 +38,8 @@ class StatelessTransaction extends React.Component {
3838 this.handleSubmit = this.handleSubmit.bind(this)
3939 this.handleSetUserApproval = this.handleSetUserApproval.bind(this)
4040 this.handleSetTxn = this.handleSetTxn.bind(this)
41− this.handleSetStx = this.handleSetStx.bind(this)
41+ this.setStx = this.setStx.bind(this)
42+ this.sendTxn = this.sendTxn.bind(this)
4243 this.handleSetNonce = this.handleSetNonce.bind(this)
4344 this.handleSetChainId = this.handleSetChainId.bind(this)
4445 this.handleSetGasPrice = this.handleSetGasPrice.bind(this)
@@ -90,7 +91,8 @@ class StatelessTransaction extends React.Component {
9091 props.pushRoute(ROUTE_NAMES.SENT_TRANSACTION)
9192 })
9293 .catch(err => {
93− this.setState({ txError: err.map(val => val.merge()) })
94+ console.log('err = ', err)
95+ // this.setState({ txError: err.map(val => val.merge()) })
9496 })
9597 }
9698
@@ -105,7 +107,7 @@ class StatelessTransaction extends React.Component {
105107 })
106108 }
107109
108− handleSetStx(stx){
110+ setStx(stx){
109111 this.setState({
110112 stx,
111113 userApproval: false,
@@ -124,8 +126,8 @@ class StatelessTransaction extends React.Component {
124126 handleClearTxn() {
125127 this.setState({
126128 userApproval: false,
127− txn: Maybe.Nothing(),
128− stx: Maybe.Nothing(),
129+ txn: Nothing(),
130+ stx: Nothing(),
129131 })
130132 }
131133
@@ -156,7 +158,7 @@ class StatelessTransaction extends React.Component {
156158 handleClearStx() {
157159 this.setState({
158160 userApproval: false,
159− stx: Maybe.Nothing(),
161+ stx: Nothing(),
160162 })
161163 }
162164
@@ -173,17 +175,19 @@ class StatelessTransaction extends React.Component {
173175 }
174176
175177 render() {
176− const { web3, createUnsignedTxn, canGenerate } = this.props
177− const { gasPrice, gasLimit, nonce, chainId, txn, stx, userApproval } = this.state
178+ const { web3, canGenerate } = this.props
179+ const { gasPrice, gasLimit, nonce, chainId,
180+ txn, stx, userApproval } = this.state
178181
179− const { setNonce, setChainId, setGasLimit, setGasPrice, handleSubmit } = this
180− const { showGasDetails, toggleGasDetails, setUserApproval, sendTxn } = this
182+ const { setNonce, setChainId, setGasLimit, setGasPrice,
183+ handleSubmit, showGasDetails, toggleGasDetails, handleSetUserApproval,
184+ sendTxn, handleCreateUnsignedTxn } = this
181185
182186 const { state } = this
183187
184− const canSign = Maybe.Just.hasInstance(state.txn)
185− const canApprove = Maybe.Just.hasInstance(state.stx)
186− const canSend = Maybe.Just.hasInstance(state.stx) && state.userApproval === true
188+ const canSign = Just.hasInstance(state.txn)
189+ const canApprove = Just.hasInstance(state.stx)
190+ const canSend = Just.hasInstance(state.stx) && state.userApproval === true
187191
188192 const generateButtonColor =
189193 Nothing.hasInstance(txn)
@@ -201,7 +205,7 @@ class StatelessTransaction extends React.Component {
201205 disabled={ !canGenerate }
202206 prop-color={ generateButtonColor }
203207 prop-size={ 'lg wide' }
204− onClick={ createUnsignedTxn }
208+ onClick={ handleCreateUnsignedTxn }
205209 >
206210 { 'Generate Transaction' }
207211 </Button>
@@ -319,7 +323,7 @@ class StatelessTransaction extends React.Component {
319323 className={ 'mt-8' }
320324 prop-size={ 'lg wide' }
321325 prop-color={ signerButtonColor }
322− onClick={ () => signTransaction(this.props) }
326+ onClick={ () => signTransaction({...this.props, ...this.state, setStx: this.setStx}) }
323327 >
324328 { 'Sign Transaction' }
325329 </Button>
@@ -341,7 +345,7 @@ class StatelessTransaction extends React.Component {
341345 <CheckboxButton
342346 className={ 'mt-8' }
343347 disabled={ !canApprove }
344− onClick={ setUserApproval }
348+ onClick={ handleSetUserApproval }
345349 state={ userApproval }
346350 >
347351 <div>
@@ -371,7 +375,7 @@ class StatelessTransaction extends React.Component {
371375 </React.Fragment>
372376 })
373377
374− const txnErrorDialogue = Maybe.Nothing.hasInstance(state.txError)
378+ const txnErrorDialogue = Nothing.hasInstance(state.txError)
375379 ? ''
376380 : <Warning className={'mt-8'}>
377381 <H3 style={{marginTop: 0, paddingTop: 0}}>
src/bridge/views/SetProxy.js+16−1
@@ -48,10 +48,20 @@ class SetProxy extends React.Component {
4848 issuingPoint: issuingPoint,
4949 }
5050
51+ this.statelessRef = React.createRef();
5152 this.handleAddressInput = this.handleAddressInput.bind(this)
53+ this.createUnsignedTxn = this.createUnsignedTxn.bind(this)
54+ }
55+
56+ handleAddressInput(proxyAddress) {
57+ this.setState({ proxyAddress })
58+
59+ this.statelessRef.current.handleClearTxn()
5260 }
5361
5462 createUnsignedTxn(proxyAddress) {
63+ console.log('creatingTxn')
64+
5565 const { state, props } = this
5666
5767 const validContracts = props.contracts.matchWith({
@@ -153,7 +163,12 @@ class SetProxy extends React.Component {
153163 walletType={props.walletType}
154164 walletHdPath={props.walletHdPath}
155165 networkType={props.networkType}
156− // Checks
166+ setTxnHashCursor={props.setTxnHashCursor}
167+ popRoute={props.popRoute}
168+ pushRoute={props.pushRoute}
169+ // Other
170+ ref={this.statelessRef}
171+ createUnsignedTxn={this.createUnsignedTxn}
157172 canGenerate={ canGenerate } />
158173 </Col>
159174 </Row>