on master help sign in
- SetProxy goes through with no modifications!
e421877Chris Johnson
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'
2import React from 'react'
2import React from 'react'
3
3
4import { Code, H3 } from './Base'
4import { Code, H3 } from './Base'
@@ -38,7 +38,8 @@ class StatelessTransaction extends React.Component {
38 this.handleSubmit = this.handleSubmit.bind(this)
38 this.handleSubmit = this.handleSubmit.bind(this)
39 this.handleSetUserApproval = this.handleSetUserApproval.bind(this)
39 this.handleSetUserApproval = this.handleSetUserApproval.bind(this)
40 this.handleSetTxn = this.handleSetTxn.bind(this)
40 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)
42 this.handleSetNonce = this.handleSetNonce.bind(this)
43 this.handleSetNonce = this.handleSetNonce.bind(this)
43 this.handleSetChainId = this.handleSetChainId.bind(this)
44 this.handleSetChainId = this.handleSetChainId.bind(this)
44 this.handleSetGasPrice = this.handleSetGasPrice.bind(this)
45 this.handleSetGasPrice = this.handleSetGasPrice.bind(this)
@@ -90,7 +91,8 @@ class StatelessTransaction extends React.Component {
90 props.pushRoute(ROUTE_NAMES.SENT_TRANSACTION)
91 props.pushRoute(ROUTE_NAMES.SENT_TRANSACTION)
91 })
92 })
92 .catch(err => {
93 .catch(err => {
94+ console.log('err = ', err)
93− this.setState({ txError: err.map(val => val.merge()) })
95+ // this.setState({ txError: err.map(val => val.merge()) })
94 })
96 })
95 }
97 }
96
98
@@ -105,7 +107,7 @@ class StatelessTransaction extends React.Component {
105 })
107 })
106 }
108 }
107
109
108− handleSetStx(stx){
110+ setStx(stx){
109 this.setState({
111 this.setState({
110 stx,
112 stx,
111 userApproval: false,
113 userApproval: false,
@@ -124,8 +126,8 @@ class StatelessTransaction extends React.Component {
124 handleClearTxn() {
126 handleClearTxn() {
125 this.setState({
127 this.setState({
126 userApproval: false,
128 userApproval: false,
127− txn: Maybe.Nothing(),
129+ txn: Nothing(),
128− stx: Maybe.Nothing(),
130+ stx: Nothing(),
129 })
131 })
130 }
132 }
131
133
@@ -156,7 +158,7 @@ class StatelessTransaction extends React.Component {
156 handleClearStx() {
158 handleClearStx() {
157 this.setState({
159 this.setState({
158 userApproval: false,
160 userApproval: false,
159− stx: Maybe.Nothing(),
161+ stx: Nothing(),
160 })
162 })
161 }
163 }
162
164
@@ -173,17 +175,19 @@ class StatelessTransaction extends React.Component {
173 }
175 }
174
176
175 render() {
177 render() {
176− const { web3, createUnsignedTxn, canGenerate } = this.props
178+ const { web3, canGenerate } = this.props
177− const { gasPrice, gasLimit, nonce, chainId, txn, stx, userApproval } = this.state
179+ const { gasPrice, gasLimit, nonce, chainId,
180+ txn, stx, userApproval } = this.state
178
181
179− const { setNonce, setChainId, setGasLimit, setGasPrice, handleSubmit } = this
182+ const { setNonce, setChainId, setGasLimit, setGasPrice,
180− const { showGasDetails, toggleGasDetails, setUserApproval, sendTxn } = this
183+ handleSubmit, showGasDetails, toggleGasDetails, handleSetUserApproval,
184+ sendTxn, handleCreateUnsignedTxn } = this
181
185
182 const { state } = this
186 const { state } = this
183
187
184− const canSign = Maybe.Just.hasInstance(state.txn)
188+ const canSign = Just.hasInstance(state.txn)
185− const canApprove = Maybe.Just.hasInstance(state.stx)
189+ const canApprove = Just.hasInstance(state.stx)
186− const canSend = Maybe.Just.hasInstance(state.stx) && state.userApproval === true
190+ const canSend = Just.hasInstance(state.stx) && state.userApproval === true
187
191
188 const generateButtonColor =
192 const generateButtonColor =
189 Nothing.hasInstance(txn)
193 Nothing.hasInstance(txn)
@@ -201,7 +205,7 @@ class StatelessTransaction extends React.Component {
201 disabled={ !canGenerate }
205 disabled={ !canGenerate }
202 prop-color={ generateButtonColor }
206 prop-color={ generateButtonColor }
203 prop-size={ 'lg wide' }
207 prop-size={ 'lg wide' }
204− onClick={ createUnsignedTxn }
208+ onClick={ handleCreateUnsignedTxn }
205 >
209 >
206 { 'Generate Transaction' }
210 { 'Generate Transaction' }
207 </Button>
211 </Button>
@@ -319,7 +323,7 @@ class StatelessTransaction extends React.Component {
319 className={ 'mt-8' }
323 className={ 'mt-8' }
320 prop-size={ 'lg wide' }
324 prop-size={ 'lg wide' }
321 prop-color={ signerButtonColor }
325 prop-color={ signerButtonColor }
322− onClick={ () => signTransaction(this.props) }
326+ onClick={ () => signTransaction({...this.props, ...this.state, setStx: this.setStx}) }
323 >
327 >
324 { 'Sign Transaction' }
328 { 'Sign Transaction' }
325 </Button>
329 </Button>
@@ -341,7 +345,7 @@ class StatelessTransaction extends React.Component {
341 <CheckboxButton
345 <CheckboxButton
342 className={ 'mt-8' }
346 className={ 'mt-8' }
343 disabled={ !canApprove }
347 disabled={ !canApprove }
344− onClick={ setUserApproval }
348+ onClick={ handleSetUserApproval }
345 state={ userApproval }
349 state={ userApproval }
346 >
350 >
347 <div>
351 <div>
@@ -371,7 +375,7 @@ class StatelessTransaction extends React.Component {
371 </React.Fragment>
375 </React.Fragment>
372 })
376 })
373
377
374− const txnErrorDialogue = Maybe.Nothing.hasInstance(state.txError)
378+ const txnErrorDialogue = Nothing.hasInstance(state.txError)
375 ? ''
379 ? ''
376 : <Warning className={'mt-8'}>
380 : <Warning className={'mt-8'}>
377 <H3 style={{marginTop: 0, paddingTop: 0}}>
381 <H3 style={{marginTop: 0, paddingTop: 0}}>
src/bridge/views/SetProxy.js+16−1
@@ -48,10 +48,20 @@ class SetProxy extends React.Component {
48 issuingPoint: issuingPoint,
48 issuingPoint: issuingPoint,
49 }
49 }
50
50
51+ this.statelessRef = React.createRef();
51 this.handleAddressInput = this.handleAddressInput.bind(this)
52 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()
52 }
60 }
53
61
54 createUnsignedTxn(proxyAddress) {
62 createUnsignedTxn(proxyAddress) {
63+ console.log('creatingTxn')
64+
55 const { state, props } = this
65 const { state, props } = this
56
66
57 const validContracts = props.contracts.matchWith({
67 const validContracts = props.contracts.matchWith({
@@ -153,7 +163,12 @@ class SetProxy extends React.Component {
153 walletType={props.walletType}
163 walletType={props.walletType}
154 walletHdPath={props.walletHdPath}
164 walletHdPath={props.walletHdPath}
155 networkType={props.networkType}
165 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}
157 canGenerate={ canGenerate } />
172 canGenerate={ canGenerate } />
158 </Col>
173 </Col>
159 </Row>
174 </Row>