Skip to content

Conversation

@yrong
Copy link
Contributor

@yrong yrong commented Jan 18, 2026

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.

@codecov
Copy link

codecov bot commented Jan 18, 2026

Codecov Report

❌ Patch coverage is 63.88889% with 13 lines in your changes missing coverage. Please review.
✅ Project coverage is 82.12%. Comparing base (d41cfe9) to head (71cbe16).

Files with missing lines Patch % Lines
...ntracts/src/l2-integration/SnowbridgeL1Adaptor.sol 0.00% 13 Missing ⚠️
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              
Flag Coverage Δ
solidity 82.12% <63.88%> (+0.12%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Contributor

Copilot AI left a 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 CallContracts command kind to execute multiple contract calls atomically
  • Modified AgentExecutor.callContract signature to accept CallContractParams struct instead of individual parameters
  • Updated SnowbridgeL1Adaptor to pull tokens from caller via safeTransferFrom instead 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.

);
}
}

Copy link

Copilot AI Jan 18, 2026

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.

Copilot uses AI. Check for mistakes.
yrong and others added 4 commits January 18, 2026 11:45
@yrong yrong changed the title Support multi contract calls Support multiple contract calls Jan 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants