on master help sign in
Misc Maybe/Result cleanup in AcceptTransfer.
commit67f6d2b05b071eecc20643e3cbe3c6e5f58d8999 authorJared Tobin <jared@jtobin.io> dateTue 26 Feb 2019, 05:13 (8 years ago) parent0dcd5e8
1 file changed+17−16
src/views/AcceptTransfer.js+17−16
src/views/AcceptTransfer.js+17−16
@@ -1,4 +1,4 @@
1−import Maybe from 'folktale/maybe'
1+import { Just, Nothing } from 'folktale/maybe'
22import React from 'react'
33import { Row, Col, H1, H3, P, Warning } from '../components/Base'
44import { InnerLabel, AddressInput, ShowBlockie, Anchor } from '../components/Base'
@@ -41,15 +41,15 @@ class AcceptTransfer extends React.Component {
4141
4242 this.state = {
4343 receivingAddress: receivingAddress,
44− txn: Maybe.Nothing(),
45− txError: Maybe.Nothing(),
44+ txn: Nothing(),
45+ txError: Nothing(),
4646 incomingPoint: incomingPoint,
4747 userApproval: false,
4848 nonce: '',
4949 gasPrice: '5',
5050 chainId: '',
5151 gasLimit: '600000',
52− stx: Maybe.Nothing(),
52+ stx: Nothing(),
5353 }
5454 this.handleAddressInput = this.handleAddressInput.bind(this)
5555 // Transaction
@@ -188,7 +188,7 @@ class AcceptTransfer extends React.Component {
188188 handleClearStx() {
189189 this.setState({
190190 userApproval: false,
191− stx: Maybe.Nothing(),
191+ stx: Nothing(),
192192 })
193193 }
194194
@@ -197,8 +197,8 @@ class AcceptTransfer extends React.Component {
197197 handleClearTxn() {
198198 this.setState({
199199 userApproval: false,
200− txn: Maybe.Nothing(),
201− stx: Maybe.Nothing(),
200+ txn: Nothing(),
201+ stx: Nothing(),
202202 })
203203 }
204204
@@ -207,8 +207,8 @@ class AcceptTransfer extends React.Component {
207207 handleClearTransaction() {
208208 this.setState({
209209 userApproval: false,
210− txn: Maybe.Nothing(),
211− stx: Maybe.Nothing(),
210+ txn: Nothing(),
211+ stx: Nothing(),
212212 })
213213 }
214214
@@ -223,8 +223,7 @@ class AcceptTransfer extends React.Component {
223223 props.pushRoute(ROUTE_NAMES.SENT_TRANSACTION)
224224 })
225225 .catch(err => {
226− // Note that value.value is due to wrapped Maybe.Just + Result.Error
227− this.setState({ txError: Maybe.Just(err.value.value) })
226+ this.setState({ txError: err.map(val => val.merge()) })
228227 })
229228 }
230229
@@ -247,7 +246,7 @@ class AcceptTransfer extends React.Component {
247246
248247 const owner = props.pointCache[validPoint].owner
249248
250− return Maybe.Just(azimuth.ecliptic.transferFrom(
249+ return Just(azimuth.ecliptic.transferFrom(
251250 validContracts,
252251 owner,
253252 state.receivingAddress,
@@ -260,9 +259,11 @@ class AcceptTransfer extends React.Component {
260259 const { state, props } = this
261260 const validAddress = isValidAddress(state.receivingAddress)
262261 const canGenerate = validAddress === true
263− const canSign = !Maybe.Nothing.hasInstance(state.txn)
264− const canApprove = !Maybe.Nothing.hasInstance(state.stx)
265− const canSend = !Maybe.Nothing.hasInstance(state.stx) && state.userApproval === true
262+ const canSign = Just.hasInstance(state.txn)
263+ const canApprove = Just.hasInstance(state.stx)
264+ const canSend =
265+ Just.hasInstance(state.stx)
266+ && state.userApproval === true
266267
267268 const esvisible =
268269 props.networkType === NETWORK_NAMES.ROPSTEN ||
@@ -339,7 +340,7 @@ class AcceptTransfer extends React.Component {
339340 handleSubmit={this.handleSubmit} />
340341
341342 {
342− Maybe.Nothing.hasInstance(state.txError)
343+ Nothing.hasInstance(state.txError)
343344 ? ''
344345 : <Warning className={'mt-8'}>
345346 <H3 style={{marginTop: 0, paddingTop: 0}}>