Skip to content

sendCalls in executeQuote if the wallet supports it#229

Merged
dohaki merged 2 commits intoacross-protocol:masterfrom
azf20:feat/eip-5792
Jun 25, 2025
Merged

sendCalls in executeQuote if the wallet supports it#229
dohaki merged 2 commits intoacross-protocol:masterfrom
azf20:feat/eip-5792

Conversation

@azf20
Copy link
Copy Markdown
Contributor

@azf20 azf20 commented Jun 16, 2025

EIP-5792 introduces a new wallet_sendCalls RPC method which allows a dapp to request multiple calls to be executed in a single transaction (e.g. for smart accounts enabled by EIP-7702). This PR adds sendCalls support to executeQuote where:

  • An approval is required to execute the quote
  • The wallet supports EIP-5792 (based on wallet_getCapabilities)

The goal of this PR is

In some cases the user might need to agree to upgrade their EOA to a smart account - if they reject this request, the quote will fallback to the existing two-step flow.

This was end-to-end tested using the example dapp (approve + deposit, fill)

Notes:

  • This updates the viem dev & peer dependency requirements
  • Currently the "preparation" encodes the deposit call.data, because dataSuffix is not yet supported by Viem (PR is merged but unreleased).
  • There is also commented out code which simulates the calls, but the relevant RPC endpoint eth_simulateV1 is not widely supported so this was removed - wallets necessarily simulate transactions when processing sendCalls, but happy to discuss this shortcut.
  • There is a bit of duplicated code in the post deposit phase (parsing the deposit, detecting the fill), I took that approach for clarity's sake but it might be preferable to merge the logic (once the deposit receipt is received, the logic is identical).
  • I didn't currently change the progress updates - we could make dedicated stages, but these might break backwards compatibility for integrators. I did think adding a general "confirmationPending" step might be helpful but left as is for now.

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Jun 16, 2025

🦋 Changeset detected

Latest commit: 3508a7f

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@across-protocol/app-sdk Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel
Copy link
Copy Markdown

vercel bot commented Jun 16, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
toolkit-example ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 24, 2025 9:46am

Copy link
Copy Markdown
Collaborator

@dohaki dohaki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First of all, thanks for this great PR! And sorry for the delay of reviewing this. We currently don't have a very streamlined process in place to run our CI for forked PRs.

I left some remarks that are related to a failing e2e test and the commented out code. Let me know what you think.


onProgressHandler(currentTransactionProgress);

// Check if wallet supports atomic transactions
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice to have a flag that disables the flow via getCapabilities, something like disableWalletCapabilites. Background is that we have some e2e test that use local Anvil forks which don't seem to support wallet_* RPC requests. See here.

So we could use this flag to not use the capabilities flow in the tests.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for flagging, can definitely make it opt in but i might also try to make it so we can test e2e, i think we could take a similar approach to viem's unit test for sendCalls https://github.com/wevm/viem/blob/feat%2Fcalls-data-suffix/src%2Factions%2Fwallet%2FsendCalls.test.ts

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will take a look at viem's test setup as well. Thanks for flagging this

// Simulate both approval and deposit calls
const { calls } = await prepareAtomicTx({
walletClient,
// publicClient: originClient, #TODO: uncomment this when more public RPCs support eth_simulateV1
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Somewhat related to my comment above. But wdyt of making this whole flow opt-in for now? Consumers of the library should then make sure that if they want their users to use this feature, they use RPC providers that rupport eth_simulateV1. We could then remove the inline comments and just throw with a respective error message if the provider doesn't support the call.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense, will update!

error?: Error;
};

export async function prepareAtomicTx(
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NIT: Based on the naming, I would assume that this function can prepare any atomic tx. A more concise naming like prepareAtomicApproveDepositTx could make sense.

@azf20
Copy link
Copy Markdown
Contributor Author

azf20 commented Jun 20, 2025

Thanks for the review! Will push updates soon

@azf20
Copy link
Copy Markdown
Contributor Author

azf20 commented Jun 24, 2025

I updated:

  • atomic is opt-in
  • renamed the atomic function to be more specific
  • simulation success isn't required currently (open to discuss this further, but checking quite a few sites most use public rpcs which don't support simulateV1 - we could make this configurable too, but also don't want to overcomplicate things)

@dohaki dohaki self-requested a review June 24, 2025 11:36
Copy link
Copy Markdown
Collaborator

@dohaki dohaki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good! I ran the test here https://github.com/across-protocol/toolkit/actions/runs/15849154219/job/44678376316?pr=230 and they succeed. So this is good to go.

@azf20
Copy link
Copy Markdown
Contributor Author

azf20 commented Jun 24, 2025

Great thanks so much! When do you think it will be merged and released? (working on something that will use this at the moment)

@dohaki dohaki merged commit 284e24d into across-protocol:master Jun 25, 2025
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants