Replies: 4 comments 3 replies
-
Wondering if a mix of the two above interfaces might be best for wagmi: export interface TransactionState {
[chainId: number]: {
[txHash: string]: TransactionDetails
}
}
export interface TransactionDetails {
transaction: TransactionResponse
submittedAt: number
receipt?: TransactionReceipt
lastCheckedBlockNumber?: number
transactionName?: string
originalTransaction?: TransactionResponse
} Advantages of this to me are:
Thoughts? Being able to pass a value that would be used as Here's an example of how this might work within import { useContractWrite } from 'wagmi'
function App() {
const { data, isError, isLoading, write } = useContractWrite(
{
addressOrName: '0xecb504d39723b0be0e3a9aa33d646642d1051ee1',
contractInterface: wagmigotchiABI,
},
'feed',
{
args: [],
transactionName: 'Feeds wagmigotchi!'
},
)
} |
Beta Was this translation helpful? Give feedback.
-
Yo @nickbytes – this sounds amazing! I think this would really lift up wagmi's game. 💪 Feels like this will slot in easily into wagmi 0.3 too as this is pretty reliant on local storage & key-specific caching. My 2c on the deets
Yes, sounds great! This will be built into wagmi 0.3 & that version also has an advantage that the consumer can also choose which storage mechanism they want to use. My only concern from a UX perspective is that a user may get confused as to why their transactions are not persisting across browsers/devices. Maybe we will need to communicate this in the docs (maybe the interface needs to state that it is transactions performed on the current browser? idk). I wonder if we should provide a way for a consumer to have the ability to persist to a remote DB or something, in case they want the ability to persist transaction history across browsers/devices for a user. I think this is a separate discussion though, and should come after an initial cut of this hook.
Makes sense to me, this will be trivial in 0.3 too as we cache most hooks on
Yessss 😍🥰
Makes sense!
Yeah absolutely.
For some use-cases such as: RainbowKit, Uniswap & dapps that want to scope and humanize transactions – this absolutely makes sense. But I also think that the case to display historical transactions would also make sense. In fact, I think that the implementation of historical txn's would be a bit different (defining human names for txns is obvs non-trivial) to the functionality we want to achieve here, so maybe there should be a separation between "local transactions" (this proposal) & "remote transactions" (full txn history). I feel like the terminology "local transactions" may feel a bit better, as the transactions are scoped to the app (and persisted in localstorage). I wonder if this hook should be named Everything else looks pretty sweet though! 🤝 |
Beta Was this translation helpful? Give feedback.
-
With the release of rainbowkit it looks like they have their own internal transaction context which you can add to by using the Just wondering if there's any plan for a |
Beta Was this translation helpful? Give feedback.
-
Realised I didn't tag @tmm for visibility of that reply. Whoops. |
Beta Was this translation helpful? Give feedback.
-
Hi there! We've been using wagmi to build RainbowKit (to be released soon!) at Rainbow. One proposal we'd like to make is for the addition of a
useTransactions
hook. We'd love feedback from the community on how this might be useful for others besides ourselves and how people think this hook may fit into wagmi.Motivation
In order to provide the best experience for users, developers need to be able to easily show pending transactions and basic transaction history within their dapps.
Prior Art and API inspiration
useDapp
useDapp has an implementation of
useTransactions
: https://usedapp-docs.netlify.app/docs/core#usetransactionsuseDapps' interface for transactions is the following:
I think there are some nice advantages to this approach. First, it utilizes Ethers types for
TransactionResponse
andTransactionReceipt
. Ethers is already a dependency of wagmi, so that's great. Secondly, it provides a (minimal) way for dapps to describe transactions through thetransactionName
property.Uniswap's interface
uniswap-interface – Uniswap's interface is a better-in-class example of how transactions should be handled by dapps and something we should strive to democratize for the community. Code reference here.
Uniswap uses the following as types for their transactions:
Subtle differences between Uniswap and useDapp, but I like that Uniswap's interface allows their developers to customize transactions for their application (
TransactionInfo
) and I also like theTransactionState
data structure wheretxHash
's are used as the key.If you have any other open source examples, please share.
Basic Example
Details
clearTransactions
)useContract
hook would need an option (default behavior?) to calladdTransaction
from theuseTransaction
hook.Feedback
What are your thoughts on this? What are good examples of libraries/dapps using transaction history? What else would you like to see?
We're happy to contribute more at Rainbow.
Beta Was this translation helpful? Give feedback.
All reactions