on master help sign in
Improve transaction feedback.

Instead of waiting for the actual transaction *receipt*, just get the transaction hash as soon as it's available. This axes the insane waiting period that we currently accept when submitting transactions on mainnet. Also cleans up the 'txnCursor' code appropriately, renaming it to 'txnHashCursor'.

commitf2f9b2063f8b9469bd0961b1ac309de20b3aab5f authorJared Tobin <jared@jtobin.io> dateWed 27 Feb 2019, 07:16 (8 years ago) parent6242917
10 files changed+28−33
src/Bridge.js+7−9 src/lib/txn.js+5−2 src/views/AcceptTransfer.js+1−1 src/views/CancelTransfer.js+2−3 src/views/CreateGalaxy.js+1−1 src/views/IssueChild.js+2−3 src/views/SentTransaction.js+4−5 src/views/SetKeys.js+2−3 src/views/SetProxy.js+2−3 src/views/Transfer.js+2−3
src/Bridge.js+7−9
@@ -53,7 +53,7 @@ class Bridge extends React.Component {
5353 pointCursor: Maybe.Nothing(),
5454 pointCache: {},
5555 // txn
56− txnCursor: Maybe.Nothing()
56+ txnHashCursor: Maybe.Nothing()
5757 }
5858
5959 this.pushRoute = this.pushRoute.bind(this)
@@ -67,7 +67,7 @@ class Bridge extends React.Component {
6767 this.setUrbitWallet = this.setUrbitWallet.bind(this)
6868 this.setAuthMnemonic = this.setAuthMnemonic.bind(this)
6969 this.setPointCursor = this.setPointCursor.bind(this)
70− this.setTxnCursor = this.setTxnCursor.bind(this)
70+ this.setTxnHashCursor = this.setTxnHashCursor.bind(this)
7171 this.addToPointCache = this.addToPointCache.bind(this)
7272 }
7373
@@ -187,10 +187,8 @@ class Bridge extends React.Component {
187187 }))
188188 }
189189
190− setTxnCursor(txn) {
191− this.setState({
192− txnCursor: txn
193− })
190+ setTxnHashCursor(txnHashCursor) {
191+ this.setState({ txnHashCursor })
194192 }
195193
196194 render() {
@@ -204,7 +202,7 @@ class Bridge extends React.Component {
204202 authMnemonic,
205203 pointCursor,
206204 pointCache,
207− txnCursor,
205+ txnHashCursor,
208206 web3,
209207 contracts
210208 } = this.state
@@ -253,8 +251,8 @@ class Bridge extends React.Component {
253251 pointCursor={ pointCursor }
254252 pointCache={ pointCache }
255253 // txn
256− setTxnCursor={ this.setTxnCursor }
257− txnCursor={ txnCursor } />
254+ setTxnHashCursor={ this.setTxnHashCursor }
255+ txnHashCursor={ txnHashCursor } />
258256
259257 <div className={'push'} />
260258
src/lib/txn.js+5−2
@@ -149,9 +149,12 @@ const sendSignedTransaction = (web3, stx) => {
149149
150150 return new Promise((resolve, reject) => {
151151 web3.eth.sendSignedTransaction(serializedTx)
152− .on('receipt', txn =>
153− resolve(Just(Ok(txn)))
152+ .on('transactionHash', hash =>
153+ resolve(Just(Ok(hash)))
154154 )
155+ .on('receipt', txn => {
156+ resolve(Just(Ok(txn.transactionHash)))
157+ })
155158 .on('error', err => {
156159 reject(Just(Error(err.message)))
157160 })
src/views/AcceptTransfer.js+1−1
@@ -155,7 +155,7 @@ class AcceptTransfer extends React.Component {
155155 const { props, state } = this
156156 sendSignedTransaction(props.web3.value, state.stx)
157157 .then(sent => {
158− props.setTxnCursor(sent)
158+ props.setTxnHashCursor(sent)
159159 props.popRoute()
160160 props.pushRoute(ROUTE_NAMES.SENT_TRANSACTION)
161161 })
src/views/CancelTransfer.js+2−3
@@ -161,13 +161,12 @@ class CancelTransfer extends React.Component {
161161 const { props, state } = this
162162 sendSignedTransaction(props.web3.value, state.stx)
163163 .then(sent => {
164− props.setTxnCursor(sent)
164+ props.setTxnHashCursor(sent)
165165 props.popRoute()
166166 props.pushRoute(ROUTE_NAMES.SENT_TRANSACTION)
167167 })
168168 .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()) })
171170 })
172171 }
173172
src/views/CreateGalaxy.js+1−1
@@ -133,7 +133,7 @@ class CreateGalaxy extends React.Component {
133133 const { props, state } = this
134134 sendSignedTransaction(props.web3.value, state.stx)
135135 .then(sent => {
136− props.setTxnCursor(sent)
136+ props.setTxnHashCursor(sent)
137137 props.popRoute()
138138 props.pushRoute(ROUTE_NAMES.SENT_TRANSACTION)
139139 })
src/views/IssueChild.js+2−3
@@ -235,13 +235,12 @@ class IssueChild extends React.Component {
235235 const { props, state } = this
236236 sendSignedTransaction(props.web3.value, state.stx)
237237 .then(sent => {
238− props.setTxnCursor(sent)
238+ props.setTxnHashCursor(sent)
239239 props.popRoute()
240240 props.pushRoute(ROUTE_NAMES.SENT_TRANSACTION)
241241 })
242242 .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()) })
245244 })
246245 }
247246
src/views/SentTransaction.js+4−5
@@ -3,7 +3,6 @@ import { Row, Col, H1, H3, P, Warning, Anchor } from '../components/Base'
33import { Button } from '../components/Base'
44
55import { BRIDGE_ERROR, renderTxnError } from '../lib/error'
6−
76import { NETWORK_NAMES } from '../lib/network'
87
98const Success = (props) => {
@@ -76,7 +75,7 @@ const Failure = (props) =>
7675 </Row>
7776
7877const SentTransaction = (props) => {
79− const { web3, txnCursor, networkType, popRoute } = props
78+ const { web3, txnHashCursor, networkType, popRoute } = props
8079 const { setPointCursor, pointCursor } = props
8180
8281 const w3 = web3.matchWith({
@@ -84,16 +83,16 @@ const SentTransaction = (props) => {
8483 Just: res => res.value
8584 })
8685
87− const result = txnCursor.matchWith({
86+ const result = txnHashCursor.matchWith({
8887 Nothing: _ => { throw BRIDGE_ERROR.MISSING_TXN },
8988 Just: res => res.value
9089 })
9190
9291 const body = result.matchWith({
9392 Error: message => <Failure web3={ w3 } message={ message.value } />,
94− Ok: txn =>
93+ Ok: hash =>
9594 <Success
96− hash={ txn.value.transactionHash }
95+ hash={ hash.value }
9796 networkType={ networkType }
9897 />
9998 })
src/views/SetKeys.js+2−3
@@ -209,13 +209,12 @@ class SetKeys extends React.Component {
209209 const { props, state } = this
210210 sendSignedTransaction(props.web3.value, state.stx)
211211 .then(sent => {
212− props.setTxnCursor(sent)
212+ props.setTxnHashCursor(sent)
213213 props.popRoute()
214214 props.pushRoute(ROUTE_NAMES.SENT_TRANSACTION)
215215 })
216216 .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()) })
219218 })
220219 }
221220
src/views/SetProxy.js+2−3
@@ -212,13 +212,12 @@ class SetProxy extends React.Component {
212212 const { props, state } = this
213213 sendSignedTransaction(props.web3.value, state.stx)
214214 .then(sent => {
215− props.setTxnCursor(sent)
215+ props.setTxnHashCursor(sent)
216216 props.popRoute()
217217 props.pushRoute(ROUTE_NAMES.SENT_TRANSACTION)
218218 })
219219 .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()) })
222221 })
223222 }
224223
src/views/Transfer.js+2−3
@@ -200,13 +200,12 @@ class Transfer extends React.Component {
200200 const { props, state } = this
201201 sendSignedTransaction(props.web3.value, state.stx)
202202 .then(sent => {
203− props.setTxnCursor(sent)
203+ props.setTxnHashCursor(sent)
204204 props.popRoute()
205205 props.pushRoute(ROUTE_NAMES.SENT_TRANSACTION)
206206 })
207207 .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()) })
210209 })
211210 }
212211