on master help sign in
Improve transaction feedback.
f2f9b20Jared Tobin
src/Bridge.js+7−9
@@ -53,7 +53,7 @@ class Bridge extends React.Component {
53 pointCursor: Maybe.Nothing(),
53 pointCursor: Maybe.Nothing(),
54 pointCache: {},
54 pointCache: {},
55 // txn
55 // txn
56− txnCursor: Maybe.Nothing()
56+ txnHashCursor: Maybe.Nothing()
57 }
57 }
58
58
59 this.pushRoute = this.pushRoute.bind(this)
59 this.pushRoute = this.pushRoute.bind(this)
@@ -67,7 +67,7 @@ class Bridge extends React.Component {
67 this.setUrbitWallet = this.setUrbitWallet.bind(this)
67 this.setUrbitWallet = this.setUrbitWallet.bind(this)
68 this.setAuthMnemonic = this.setAuthMnemonic.bind(this)
68 this.setAuthMnemonic = this.setAuthMnemonic.bind(this)
69 this.setPointCursor = this.setPointCursor.bind(this)
69 this.setPointCursor = this.setPointCursor.bind(this)
70− this.setTxnCursor = this.setTxnCursor.bind(this)
70+ this.setTxnHashCursor = this.setTxnHashCursor.bind(this)
71 this.addToPointCache = this.addToPointCache.bind(this)
71 this.addToPointCache = this.addToPointCache.bind(this)
72 }
72 }
73
73
@@ -187,10 +187,8 @@ class Bridge extends React.Component {
187 }))
187 }))
188 }
188 }
189
189
190− setTxnCursor(txn) {
190+ setTxnHashCursor(txnHashCursor) {
191− this.setState({
191+ this.setState({ txnHashCursor })
192− txnCursor: txn
193− })
194 }
192 }
195
193
196 render() {
194 render() {
@@ -204,7 +202,7 @@ class Bridge extends React.Component {
204 authMnemonic,
202 authMnemonic,
205 pointCursor,
203 pointCursor,
206 pointCache,
204 pointCache,
207− txnCursor,
205+ txnHashCursor,
208 web3,
206 web3,
209 contracts
207 contracts
210 } = this.state
208 } = this.state
@@ -253,8 +251,8 @@ class Bridge extends React.Component {
253 pointCursor={ pointCursor }
251 pointCursor={ pointCursor }
254 pointCache={ pointCache }
252 pointCache={ pointCache }
255 // txn
253 // txn
256− setTxnCursor={ this.setTxnCursor }
254+ setTxnHashCursor={ this.setTxnHashCursor }
257− txnCursor={ txnCursor } />
255+ txnHashCursor={ txnHashCursor } />
258
256
259 <div className={'push'} />
257 <div className={'push'} />
260
258
src/lib/txn.js+5−2
@@ -149,9 +149,12 @@ const sendSignedTransaction = (web3, stx) => {
149
149
150 return new Promise((resolve, reject) => {
150 return new Promise((resolve, reject) => {
151 web3.eth.sendSignedTransaction(serializedTx)
151 web3.eth.sendSignedTransaction(serializedTx)
152− .on('receipt', txn =>
152+ .on('transactionHash', hash =>
153− resolve(Just(Ok(txn)))
153+ resolve(Just(Ok(hash)))
154 )
154 )
155+ .on('receipt', txn => {
156+ resolve(Just(Ok(txn.transactionHash)))
157+ })
155 .on('error', err => {
158 .on('error', err => {
156 reject(Just(Error(err.message)))
159 reject(Just(Error(err.message)))
157 })
160 })
src/views/AcceptTransfer.js+1−1
@@ -155,7 +155,7 @@ class AcceptTransfer extends React.Component {
155 const { props, state } = this
155 const { props, state } = this
156 sendSignedTransaction(props.web3.value, state.stx)
156 sendSignedTransaction(props.web3.value, state.stx)
157 .then(sent => {
157 .then(sent => {
158− props.setTxnCursor(sent)
158+ props.setTxnHashCursor(sent)
159 props.popRoute()
159 props.popRoute()
160 props.pushRoute(ROUTE_NAMES.SENT_TRANSACTION)
160 props.pushRoute(ROUTE_NAMES.SENT_TRANSACTION)
161 })
161 })
src/views/CancelTransfer.js+2−3
@@ -161,13 +161,12 @@ class CancelTransfer extends React.Component {
161 const { props, state } = this
161 const { props, state } = this
162 sendSignedTransaction(props.web3.value, state.stx)
162 sendSignedTransaction(props.web3.value, state.stx)
163 .then(sent => {
163 .then(sent => {
164− props.setTxnCursor(sent)
164+ props.setTxnHashCursor(sent)
165 props.popRoute()
165 props.popRoute()
166 props.pushRoute(ROUTE_NAMES.SENT_TRANSACTION)
166 props.pushRoute(ROUTE_NAMES.SENT_TRANSACTION)
167 })
167 })
168 .catch(err => {
168 .catch(err => {
169− // Note that value.value is due to wrapped Maybe.Just + Result.Error
170− this.setState({ txError: Maybe.Just(err.value.value) })
169+ this.setState({ txError: err.map(val => val.merge()) })
171 })
170 })
172 }
171 }
173
172
src/views/CreateGalaxy.js+1−1
@@ -133,7 +133,7 @@ class CreateGalaxy extends React.Component {
133 const { props, state } = this
133 const { props, state } = this
134 sendSignedTransaction(props.web3.value, state.stx)
134 sendSignedTransaction(props.web3.value, state.stx)
135 .then(sent => {
135 .then(sent => {
136− props.setTxnCursor(sent)
136+ props.setTxnHashCursor(sent)
137 props.popRoute()
137 props.popRoute()
138 props.pushRoute(ROUTE_NAMES.SENT_TRANSACTION)
138 props.pushRoute(ROUTE_NAMES.SENT_TRANSACTION)
139 })
139 })
src/views/IssueChild.js+2−3
@@ -235,13 +235,12 @@ class IssueChild extends React.Component {
235 const { props, state } = this
235 const { props, state } = this
236 sendSignedTransaction(props.web3.value, state.stx)
236 sendSignedTransaction(props.web3.value, state.stx)
237 .then(sent => {
237 .then(sent => {
238− props.setTxnCursor(sent)
238+ props.setTxnHashCursor(sent)
239 props.popRoute()
239 props.popRoute()
240 props.pushRoute(ROUTE_NAMES.SENT_TRANSACTION)
240 props.pushRoute(ROUTE_NAMES.SENT_TRANSACTION)
241 })
241 })
242 .catch(err => {
242 .catch(err => {
243− // Note that value.value is due to wrapped Maybe.Just + Result.Error
244− this.setState({ txError: Maybe.Just(err.value.value) })
243+ this.setState({ txError: err.map(val => val.merge()) })
245 })
244 })
246 }
245 }
247
246
src/views/SentTransaction.js+4−5
@@ -3,7 +3,6 @@ import { Row, Col, H1, H3, P, Warning, Anchor } from '../components/Base'
3import { Button } from '../components/Base'
3import { Button } from '../components/Base'
4
4
5import { BRIDGE_ERROR, renderTxnError } from '../lib/error'
5import { BRIDGE_ERROR, renderTxnError } from '../lib/error'
6−
7import { NETWORK_NAMES } from '../lib/network'
6import { NETWORK_NAMES } from '../lib/network'
8
7
9const Success = (props) => {
8const Success = (props) => {
@@ -76,7 +75,7 @@ const Failure = (props) =>
76 </Row>
75 </Row>
77
76
78const SentTransaction = (props) => {
77const SentTransaction = (props) => {
79− const { web3, txnCursor, networkType, popRoute } = props
78+ const { web3, txnHashCursor, networkType, popRoute } = props
80 const { setPointCursor, pointCursor } = props
79 const { setPointCursor, pointCursor } = props
81
80
82 const w3 = web3.matchWith({
81 const w3 = web3.matchWith({
@@ -84,16 +83,16 @@ const SentTransaction = (props) => {
84 Just: res => res.value
83 Just: res => res.value
85 })
84 })
86
85
87− const result = txnCursor.matchWith({
86+ const result = txnHashCursor.matchWith({
88 Nothing: _ => { throw BRIDGE_ERROR.MISSING_TXN },
87 Nothing: _ => { throw BRIDGE_ERROR.MISSING_TXN },
89 Just: res => res.value
88 Just: res => res.value
90 })
89 })
91
90
92 const body = result.matchWith({
91 const body = result.matchWith({
93 Error: message => <Failure web3={ w3 } message={ message.value } />,
92 Error: message => <Failure web3={ w3 } message={ message.value } />,
94− Ok: txn =>
93+ Ok: hash =>
95 <Success
94 <Success
96− hash={ txn.value.transactionHash }
95+ hash={ hash.value }
97 networkType={ networkType }
96 networkType={ networkType }
98 />
97 />
99 })
98 })
src/views/SetKeys.js+2−3
@@ -209,13 +209,12 @@ class SetKeys extends React.Component {
209 const { props, state } = this
209 const { props, state } = this
210 sendSignedTransaction(props.web3.value, state.stx)
210 sendSignedTransaction(props.web3.value, state.stx)
211 .then(sent => {
211 .then(sent => {
212− props.setTxnCursor(sent)
212+ props.setTxnHashCursor(sent)
213 props.popRoute()
213 props.popRoute()
214 props.pushRoute(ROUTE_NAMES.SENT_TRANSACTION)
214 props.pushRoute(ROUTE_NAMES.SENT_TRANSACTION)
215 })
215 })
216 .catch(err => {
216 .catch(err => {
217− // Note that value.value is due to wrapped Maybe.Just + Result.Error
218− this.setState({ txError: Maybe.Just(err.value.value) })
217+ this.setState({ txError: err.map(val => val.merge()) })
219 })
218 })
220 }
219 }
221
220
src/views/SetProxy.js+2−3
@@ -212,13 +212,12 @@ class SetProxy extends React.Component {
212 const { props, state } = this
212 const { props, state } = this
213 sendSignedTransaction(props.web3.value, state.stx)
213 sendSignedTransaction(props.web3.value, state.stx)
214 .then(sent => {
214 .then(sent => {
215− props.setTxnCursor(sent)
215+ props.setTxnHashCursor(sent)
216 props.popRoute()
216 props.popRoute()
217 props.pushRoute(ROUTE_NAMES.SENT_TRANSACTION)
217 props.pushRoute(ROUTE_NAMES.SENT_TRANSACTION)
218 })
218 })
219 .catch(err => {
219 .catch(err => {
220− // Note that value.value is due to wrapped Maybe.Just + Result.Error
221− this.setState({ txError: Maybe.Just(err.value.value) })
220+ this.setState({ txError: err.map(val => val.merge()) })
222 })
221 })
223 }
222 }
224
223
src/views/Transfer.js+2−3
@@ -200,13 +200,12 @@ class Transfer extends React.Component {
200 const { props, state } = this
200 const { props, state } = this
201 sendSignedTransaction(props.web3.value, state.stx)
201 sendSignedTransaction(props.web3.value, state.stx)
202 .then(sent => {
202 .then(sent => {
203− props.setTxnCursor(sent)
203+ props.setTxnHashCursor(sent)
204 props.popRoute()
204 props.popRoute()
205 props.pushRoute(ROUTE_NAMES.SENT_TRANSACTION)
205 props.pushRoute(ROUTE_NAMES.SENT_TRANSACTION)
206 })
206 })
207 .catch(err => {
207 .catch(err => {
208− // Note that value.value is due to wrapped Maybe.Just + Result.Error
209− this.setState({ txError: Maybe.Just(err.value.value) })
208+ this.setState({ txError: err.map(val => val.merge()) })
210 })
209 })
211 }
210 }
212
211