-
Notifications
You must be signed in to change notification settings - Fork 139
Support multiple contract calls #1676
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
base: main
Are you sure you want to change the base?
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1676 +/- ##
==========================================
+ Coverage 82.00% 82.12% +0.12%
==========================================
Files 22 22
Lines 1006 1024 +18
Branches 190 197 +7
==========================================
+ Hits 825 841 +16
- Misses 164 166 +2
Partials 17 17
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds support for executing multiple contract calls atomically within a single command. A new CallContracts command type is introduced that complements the existing CallContract functionality, allowing agents to execute a sequence of external contract calls that will all revert if any individual call fails.
Changes:
- Added
CallContractscommand kind to execute multiple contract calls atomically - Modified
AgentExecutor.callContractsignature to acceptCallContractParamsstruct instead of individual parameters - Updated
SnowbridgeL1Adaptorto pull tokens from caller viasafeTransferFrominstead of relying on pre-funding
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| contracts/test/mocks/HelloWorld.sol | Added consumeToken function to test ERC20 token transfers in multi-call scenarios |
| contracts/test/GatewayV2.t.sol | Added comprehensive tests for CallContracts including success and atomicity-on-failure scenarios |
| contracts/src/v2/Types.sol | Added CallContracts constant to CommandKind library |
| contracts/src/v2/Handlers.sol | Refactored callContract handler and added new callContracts handler |
| contracts/src/l2-integration/SnowbridgeL1Adaptor.sol | Changed from pre-funding model to pull-based token transfers with refund logic |
| contracts/src/Gateway.sol | Added v2_handleCallContracts handler and dispatch logic, plus minor formatting improvements |
| contracts/src/AgentExecutor.sol | Refactored callContract to accept struct parameter and added callContracts loop implementation |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| ); | ||
| } | ||
| } | ||
|
|
Copilot
AI
Jan 18, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extra blank line should be removed for consistency with the rest of the codebase.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Context
It is a common pattern to compose multiple contract calls that execute sequentially and atomically. This PR introduces a separate command type and enhances AgentExecutor to support this behavior. The legacy single-contract call is retained solely for backward compatibility.
In addition, this PR further hardens the L1 adapter based on the new execution model. It also makes it easier to compose the two-step L2 transfer into a single atomic call:
The agent approves the L1 adapter to use the asset.
The agent then calls the L1 adapter, which pulls the asset and uses it to deposit into Across’s SpokePool contract.
Todo
A companion PR in the Polkadot SDK is still required.