You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Feb 9, 2024. It is now read-only.
Define a good design pattern to handle status messages then create helper functions to make it easy.
const tx = useContractTx(...) sets a variable that can use a signAndSend() functions to initiate a wallet signature and contract transaction like this tx.signAndSend(...args).
We can then track the status with tx.status, which will change from 'NONE', to 'PENDING_SIGNATURE', to 'IN_BLOCK', etc. It is very common to set a button to disabled and change the title if a transaction status is not 'NONE' or 'FINALIZED'.
Suggestion
We should create a helper function that returns a formatted string. e.g.
where toStatusName(flipTx) will return "Please sign the transaction to flip!"` for 'PENDING_SIGNATURE', then "Flipping..." when the status is 'IN_BLOCK', etc. Messages should be customizable and allow for 18n.
Do we provide defaults? Can a user define generic ones such as "Pending signature" for 'PENDING_SIGNATURE' status?
Motivation
Simplify a very common use case.
Use Cases
Building a UI for any contract transaction.
The text was updated successfully, but these errors were encountered:
DoubleOTheven
changed the title
Add helper functions for displaying Transaction status of a contract
Add helper functions to easily display customized messages for a contract transaction
Mar 30, 2023
Feature Request
Define a good design pattern to handle status messages then create helper functions to make it easy.
const tx = useContractTx(...)
sets a variable that can use asignAndSend()
functions to initiate a wallet signature and contract transaction like thistx.signAndSend(...args)
.We can then track the status with
tx.status
, which will change from 'NONE', to 'PENDING_SIGNATURE', to 'IN_BLOCK', etc. It is very common to set a button to disabled and change the title if a transaction status is not 'NONE' or 'FINALIZED'.Suggestion
We should create a helper function that returns a formatted string. e.g.
where
toStatusName(flipTx)
will return "Please sign the transaction to flip!"` for 'PENDING_SIGNATURE', then "Flipping..." when the status is 'IN_BLOCK', etc. Messages should be customizable and allow for 18n.Do we provide defaults? Can a user define generic ones such as "Pending signature" for 'PENDING_SIGNATURE' status?
Motivation
Simplify a very common use case.
Use Cases
Building a UI for any contract transaction.
The text was updated successfully, but these errors were encountered: