Skip to content

feat: add signMetaTxCommitToBuyerOffer to meta-tx handler and mixin#1006

Merged
levalleux-ludo merged 5 commits intomainfrom
copilot/add-sign-metatrx-commit-to-buyer-offer
Mar 11, 2026
Merged

feat: add signMetaTxCommitToBuyerOffer to meta-tx handler and mixin#1006
levalleux-ludo merged 5 commits intomainfrom
copilot/add-sign-metatrx-commit-to-buyer-offer

Conversation

Copy link
Contributor

Copilot AI commented Mar 10, 2026

  • Add signMetaTxCommitToBuyerOffer function to packages/core-sdk/src/meta-tx/handler.ts
  • Add signMetaTxCommitToBuyerOffer method to packages/core-sdk/src/meta-tx/mixin.ts
  • Add e2e test case in e2e/tests/meta-tx.test.ts: "native exchange token buyer-initiated offer"
  • Fix e2e test: set sellerDeposit: "0" and drFeeAmount: "0" for native token so meta-tx relayer doesn't need to forward ETH value (InsufficientValueReceived fix)
  • Add e2e test case: "non-native exchange token buyer-initiated offer" using MOCK_ERC20_ADDRESS
  • Fix ERC20 test: call ensureMintedAndAllowedTokens for both fresh buyer/seller wallets before calling depositFunds (fresh wallets have 0 ERC20 balance, causing ERC20: transfer amount exceeds balance)
Original prompt

This section details on the original issue you should resolve

<issue_title>missing method to sign metaTx for commitToBuyerOffer</issue_title>
<issue_description>- in packages\core-sdk\src\meta-tx\handler.ts, create the function signMetaTxCommitToBuyerOffer(...) using the model of signMetaTxCommitToOffer(), adapting the parameters according to those required for commitToBuyerOffer (in packages\core-sdk\src\exchanges\handler.ts)

  • in packages\core-sdk\src\meta-tx\mixin.ts, create the method signMetaTxCommitToBuyerOffer using the model of signMetaTxCommitToOffer(), calling the function just added at the previous step
  • in e2e\tests\meta-tx.test.ts, add some test case for signMetaTxCommitToBuyerOffer (if needed use the buyer initiated test cases from e2e\tests\core-sdk-offers.test.ts as inspiration to create the context required for the signMetaTxCommitToBuyerOffer to work)</issue_description>

Comments on the Issue (you are @copilot in this section)


🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

…ests

Co-authored-by: levalleux-ludo <7184124+levalleux-ludo@users.noreply.github.com>
Copilot AI changed the title [WIP] Add method to sign metaTx for commitToBuyerOffer Add signMetaTxCommitToBuyerOffer to meta-tx handler and mixin Mar 10, 2026
@levalleux-ludo levalleux-ludo changed the title Add signMetaTxCommitToBuyerOffer to meta-tx handler and mixin feat: add signMetaTxCommitToBuyerOffer to meta-tx handler and mixin Mar 11, 2026
@levalleux-ludo
Copy link
Member

@copilot the e2e test "native exchange token buyer-initiated offer" is failing.
In the logs, I can see the error coming back from the on-chain protocol is "InsufficientValueReceived()"
Transaction data shows the called contract method is "executeMetaTransaction(address,string,bytes,uint256,bytes)" (="0x7fb34d54"). Later in the data I can see the function signature (called via a meta-transaction is "commitToBuyerOffer(uint256,(uint256,(address[],uint256[]),address))" = "60900f5e").

I understand that the protocol expect the fees (sellerDeposit + drFeeAmount) to be transfered in native currency (ETH) as value in the transaction itself, which can't be done with a meta-transaction (because the transaction is relayed and sent on-chain by another wallet than the signer). To make the test working, you have to ensure both the offer's sellerDeposit and the drFeeAmount are explicitely set to 0. Which also means that the seller doesn't need to call depositFunds prior to committing to the offer.

…Offer e2e test

Meta-tx relayers cannot forward ETH value, so commitToBuyerOffer with a
non-zero sellerDeposit would fail with InsufficientValueReceived(). Set
both sellerDeposit and drFeeAmount to 0 so no ETH transfer is needed.

Co-authored-by: levalleux-ludo <7184124+levalleux-ludo@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Mar 11, 2026

@copilot the e2e test "native exchange token buyer-initiated offer" is failing.
In the logs, I can see the error coming back from the on-chain protocol is "InsufficientValueReceive...

Fixed in 885d8df. The test now uses sellerDeposit: "0" on the offer and feeAmount: "0" on the dispute resolver, so no ETH value needs to be forwarded by the relayer and no depositFunds call is required for the seller.

@levalleux-ludo
Copy link
Member

@copilot please add another test case in the e2e test called "non-native exchange token buyer-initiated offer", where the offer exchangeToken is an ERC20 token (MOCK_ERC20_ADDRESS as done for the other tests)

…rOffer

Co-authored-by: levalleux-ludo <7184124+levalleux-ludo@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Mar 11, 2026

@copilot please add another test case in the e2e test called "non-native exchange token buyer-initiated offer", where the offer exchangeToken is an ERC20 token (MOCK_ERC20_ADDRESS as done for the othe...

Added in ec348e4. The new test creates a dispute resolver with an ERC20 (MOCK_ERC20_ADDRESS) fee, the buyer approves and deposits the offer price in ERC20, the seller approves and deposits the drFeeAmount in ERC20 into the protocol, then signs and relays the meta-tx. Unlike the native-token case, non-zero fees work fine here because the protocol pulls ERC20 funds from the pre-deposited protocol balance (no ETH transaction value needed).

@levalleux-ludo
Copy link
Member

levalleux-ludo commented Mar 11, 2026

@copilot the e2e test "non-native exchange token buyer-initiated offer" is failing in the github action (https://github.com/bosonprotocol/core-components/actions/runs/22948373517/job/66616167890#step:10:634).
The reason is that 'ERC20: transfer amount exceeds balance' when the contract method "depositFunds(uint256,address,uint256)" is called (code: "0xa07fcc70" in the transaction data).
That means the wallet's balance is lower than the amount to deposit. I'm not sure if the error happens when the buyer is call depositFunds or the seller.
Both should have a sufficient balance of the exchange token to support deposit. A helper method should allow to fund the buyer and seller wallet prior to the rest of the test

…tive buyer offer test

Co-authored-by: levalleux-ludo <7184124+levalleux-ludo@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Mar 11, 2026

@copilot the e2e test "non-native exchange token buyer-initiated offer" is failing in the github action (https://github.com/bosonprotocol/core-components/actions/runs/22948373517/job...

Fixed in 72a683d. The fresh wallets from initSellerAndBuyerSDKs start with zero ERC20 balance. Added ensureMintedAndAllowedTokens([buyerFundedWallet, sellerFundedWallet], undefined, false) after wallet creation to mint tokens before the depositFunds calls.

@codecov
Copy link

codecov bot commented Mar 11, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.95%. Comparing base (030f8f3) to head (72a683d).
⚠️ Report is 4 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1006      +/-   ##
==========================================
+ Coverage   87.92%   90.95%   +3.03%     
==========================================
  Files         172      179       +7     
  Lines        7270     7288      +18     
  Branches     1366     1366              
==========================================
+ Hits         6392     6629     +237     
+ Misses        878      659     -219     
Flag Coverage Δ
common 92.59% <ø> (ø)
core-sdk 56.48% <28.57%> (?)
e2e 85.78% <100.00%> (+0.01%) ⬆️
eth-connect-sdk 95.06% <ø> (ø)
ethers-sdk 74.45% <ø> (ø)
ipfs-storage 91.75% <ø> (?)
metadata 94.70% <ø> (ø)
unittests 60.77% <28.57%> (-24.59%) ⬇️

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.

@levalleux-ludo levalleux-ludo marked this pull request as ready for review March 11, 2026 14:35
Copilot AI review requested due to automatic review settings March 11, 2026 14:35
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

Adds CoreSDK support for signing/relaying commitToBuyerOffer meta-transactions, plus e2e coverage for buyer-initiated offers using both native and ERC20 exchange tokens.

Changes:

  • Added signMetaTxCommitToBuyerOffer signer in packages/core-sdk/src/meta-tx/handler.ts.
  • Exposed signMetaTxCommitToBuyerOffer on the CoreSDK meta-tx mixin.
  • Added e2e tests covering buyer-initiated offers for native and ERC20 exchange tokens (including setup fixes for fresh wallets / relayer value constraints).

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
packages/core-sdk/src/meta-tx/mixin.ts Exposes signMetaTxCommitToBuyerOffer on the SDK mixin.
packages/core-sdk/src/meta-tx/handler.ts Implements the meta-tx signing helper for commitToBuyerOffer.
e2e/tests/meta-tx.test.ts Adds e2e tests validating relayed commitToBuyerOffer flows for native/ERC20 exchange tokens.

@levalleux-ludo levalleux-ludo merged commit d4b6208 into main Mar 11, 2026
15 of 18 checks passed
@levalleux-ludo levalleux-ludo deleted the copilot/add-sign-metatrx-commit-to-buyer-offer branch March 11, 2026 14:47
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.

missing method to sign metaTx for commitToBuyerOffer

4 participants