Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: <Transaction /> should accept an async function in calls prop #1278

Open
mykcryptodev opened this issue Sep 19, 2024 · 0 comments

Comments

@mykcryptodev
Copy link
Contributor

Describe the solution you'd like

I would like the component to accept an async function in the calls prop that resolves to calls.

I would much rather have a component that looks like this:

      <Transaction
        calls={async () => await fetchCalls() as Call[]}
        chainId={{base.id}}
      >
        <TransactionButton>Buy</TransactionButton>
      </Transaction> 

Rather than setup a component such that I need to find a creative way for my calls to be constantly updating in a useMemo or something like that.

Describe alternatives you've considered.

Instead of having my calls prop behave like a promise where I can fetch calls and then return the calls to the transaction button, I need to do extra work to ensure that my calls are memoized and stay updated based on user behavior.

Example: consider the situation where a user controls an input field and based on the amount that they enter, I need to fetch a quote and create calls based on the quote. In the current setup, I need to watch the input field and fire off a query to fetch a quote when the input changes.

If instead I could pass an async function to the transaction component, I could execute the fetch for the quote only once and then return the calls to the transaction component at the time of execution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant