Persisting newly-broadcast transactions locally #1712
Replies: 3 comments 11 replies
-
Might it be cleanest for the UX and code alike to introduce a new “Submitted” state for all transactions that have received a We could show submitted transactions immediately and indefinitely since this remains an accurate representation (they are indeed submitted), without getting into any limbo that could result from (over-) eagerly representing them as pending. If a submitted transaction hasn’t been seen in the mempool for awhile, we could optionally flag as “Looks like this transaction is having problems” and the like, as progressive enhancements. |
Beta Was this translation helpful? Give feedback.
-
Using optimistic updates with react-query might be helpful to implement something like this. There are built-in handlers for |
Beta Was this translation helpful? Give feedback.
-
This is a great write up @kyranjamie! I generally agree, and it's important to think through how this might work in the wallet. I agree with @markmhx on how there should be a new state of In my mind this is really a shift of where or how we're constructing data. Currently we basically rely exactly on the endpoint to construct the shape of our state, eg we fetch a paginated list of transaction activity and then display it. I think if we shift that and instead have the basic building block of our "activity" be an array of txids, then we no longer need to rely on the shape of data coming from the transaction array api endpoint. To illustrate: currently
my suggestion
With this, we'd end up with kind of user experience:
We'd also be able to use these raw transactions to subtract balance and calculate nonces better. DIdn't mean to get too into the weeds! Let me know if I can explain anything differently or expand on anything. |
Beta Was this translation helpful? Give feedback.
-
Opening this discussion to house everyone's thoughts regarding the wallet functionality where, newly-broadcast, or pending, transactions are persisted on the client.
We've discussed this verbally in the UserX team. @diwakergupta floated the idea on Discord as well.
This functionality improves:
On the face of it, it seems obvious. And in some capacity, I think we'll need this behaviour. Though, I have concerns there are cases where the wallet, and the actual state of the chain, might diverge. Resulting in us displaying confusing or wrong information.
Questions
POST /v2/transactions
returns a200
response?I built this functionality in the desktop wallet pre the existence of the
/mempool
endpoint. But ended up removing it. It was a complex implementation, and not necessary if the mempool displays the current state "pending txs". I'd like to understand better to what extent we can rely on the mempool to be accurate. Prior to this current issue, it's worked pretty well. I haven't seen wallet issues related to our reliance on the mempool.Regarding slow UX: To avoid a post-broadcast transactionless UI (where's the tx I just sent?!), the desktop wallet waits (with a timeout) for it first to appear in the mempool while the transaction is still "Sending...". This slows down the experience a little, but usually it takes no more than a couple of seconds. It'd be great to do it 2 seconds faster, but how much time/effort/implementation complexity is that worth?
While caching pending txs might help us in some instances of network instability, such as a tx never entering mempool, couldn't the same instability prevent us from ever knowing what to do with said transaction, and make the experience worse?
Consider that our implementation must:
(We also have the ambition to simplify our state mgmt set up, before starting work that might further complicate it)
This is simply to say given that its a non-trivial feature to build, we should consider the value it adds, and its implementation, before jumping into development.
cc/ people who might have input/be able to answer questions @aulneau @lgalabru @zone117x @wileyj @jcnelson @kantai
Beta Was this translation helpful? Give feedback.
All reactions