Skip to content

feat(core-sdk): add signMetaTxCreateOfferAndCommit to meta-tx handler and mixin#1012

Merged
levalleux-ludo merged 4 commits intomainfrom
copilot/add-sign-metatx-create-offer-and-commit
Mar 12, 2026
Merged

feat(core-sdk): add signMetaTxCreateOfferAndCommit to meta-tx handler and mixin#1012
levalleux-ludo merged 4 commits intomainfrom
copilot/add-sign-metatx-create-offer-and-commit

Conversation

Copy link
Contributor

Copilot AI commented Mar 11, 2026

  • Plan created
  • Add FullOfferArgs to imports and add encodeCreateOfferAndCommit import in packages/core-sdk/src/meta-tx/handler.ts
  • Add signMetaTxCreateOfferAndCommit function to packages/core-sdk/src/meta-tx/handler.ts
  • Add signMetaTxCreateOfferAndCommit method to packages/core-sdk/src/meta-tx/mixin.ts
  • Add e2e tests for signMetaTxCreateOfferAndCommit in e2e/tests/meta-tx.test.ts:
    • native exchange token buyer-initiated offer (seller calls createOfferAndCommit via meta-tx, sellerDeposit=0)
    • non-native exchange token buyer-initiated offer (seller calls createOfferAndCommit via meta-tx, sellerDeposit=0)
    • native exchange token seller-initiated offer (buyer calls createOfferAndCommit via meta-tx, price=0)
    • non-native exchange token seller-initiated offer (buyer calls createOfferAndCommit via meta-tx, ERC20 pre-approval)
  • Fix buyer-initiated tests: add quantityAvailable: 1 (required for buyer-initiated offers)
  • Fix seller-initiated tests: skip depositFunds in buildFullOfferArgs when amount is zero to avoid "ZeroDepositNotAllowed" error
  • Fix native seller-initiated test: add buyerCancelPenalty: "0" since buyerCancelPenalty must be ≤ price (which is 0)
Original prompt

This section details on the original issue you should resolve

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

  • in packages\core-sdk\src\meta-tx\mixin.ts, create the method signMetaTxCreateOfferAndCommit using the model of signMetaTxCreateOffer(), calling the function just added at the previous step
  • in e2e\tests\meta-tx.test.ts, add some test case for signMetaTxCreateOfferAndCommit (if needed use the "create offer and commit" test cases from e2e\tests\core-sdk.test.ts as inspiration to create the context required for the signMetaTxCreateOfferAndCommit to work). Test cases should include both cases: buyer initiated offer (seller calls createOfferAndCommit) and seller initiated offer (buyer calls createOfferAndCommit). To make it simpler, set sellerDeposit and drFeeAmount to 0 in the offer data, so that the seller doesn't have to deposit any funds prior to the commit. Test cases should also include both native token offer and non-native token (ERC20) offer</issue_description>

<agent_instructions>look at pull request #1006 for inspiration and some directives</agent_instructions>

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


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@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.

… and mixin

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

@copilot fix the errors got in the e2e test:

  • test "#signMetaTxCreateOfferAndCommit() › native exchange token buyer-initiated offer"
    • this test is failing with the error "ValidationError: Quantity must be 1 for buyer initiated offers". You need to specify expllicitely a quantity of 1 when creating the buyer initiated offer
  • test "#signMetaTxCreateOfferAndCommit() › non-native exchange token buyer-initiated offer"
  • same error "ValidationError: Quantity must be 1 for buyer initiated offers".
  • test "#signMetaTxCreateOfferAndCommit() › native exchange token seller-initiated offer"
    • the depositFunds transaction fails with error "ZeroDepositNotAllowed". If the amount is 0, the depositFunds() method shall not be called (it is useless in that case anyway)
  • test "#signMetaTxCreateOfferAndCommit() › non-native exchange token seller-initiated offer"
  • same as before: the depositFunds transaction fails with error "ZeroDepositNotAllowed".

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

Copilot AI commented Mar 11, 2026

@copilot fix the errors got in the e2e test:

  • test "#signMetaTxCreateOfferAndCommit() › native exchange token buyer-initiated offer"
    • this test is failing with the error "Val...

Fixed in commit 48cf6e6:

  1. Buyer-initiated offer tests ("Quantity must be 1"): Added quantityAvailable: 1 to the offerParams override in both native and ERC20 buyer-initiated tests.

  2. Seller-initiated offer tests ("ZeroDepositNotAllowed"): Added a zero-check in buildFullOfferArgs (utils.ts) to skip the depositFunds call when creatorDepositFunds is 0 — calling depositFunds(0) is both invalid and unnecessary.

@levalleux-ludo
Copy link
Member

@copilot the e2e test "#signMetaTxCreateOfferAndCommit() › native exchange token seller-initiated offer" is failing with error "ValidationError: buyerCancelPenalty has to be less than or equal price". The most convenient fix is to set the buyerCancelPenalty to 0 when creating the offer for that test case

… 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 "#signMetaTxCreateOfferAndCommit() › native exchange token seller-initiated offer" is failing with error "ValidationError: buyerCancelPenalty has to be less t...

Fixed in commit f77b029 — added buyerCancelPenalty: "0" to the offerParams for the native seller-initiated offer test, since buyerCancelPenalty must be ≤ price (which is "0").

@codecov
Copy link

codecov bot commented Mar 11, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.96%. Comparing base (d4b6208) to head (f77b029).
⚠️ Report is 4 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1012      +/-   ##
==========================================
+ Coverage   90.95%   90.96%   +0.01%     
==========================================
  Files         179      179              
  Lines        7288     7297       +9     
  Branches     1366     1366              
==========================================
+ Hits         6629     6638       +9     
  Misses        659      659              
Flag Coverage Δ
common 92.59% <ø> (ø)
core-sdk 56.43% <22.22%> (-0.05%) ⬇️
e2e 85.79% <100.00%> (+0.01%) ⬆️
eth-connect-sdk 95.06% <ø> (ø)
ethers-sdk 74.45% <ø> (ø)
ipfs-storage 91.75% <ø> (ø)
metadata 94.70% <ø> (ø)
unittests 60.72% <22.22%> (-0.05%) ⬇️

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 12, 2026 06:13
Copilot AI review requested due to automatic review settings March 12, 2026 06:13
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 a new Core SDK meta-transaction signing flow for createOfferAndCommit, enabling relayed execution for both buyer-initiated and seller-initiated offers (native + ERC20), with supporting e2e coverage.

Changes:

  • Added signMetaTxCreateOfferAndCommit to the meta-tx handler and exposed it via the Core SDK meta-tx mixin.
  • Updated e2e utilities to avoid attempting zero-amount deposits (prevents ZeroDepositNotAllowed).
  • Added e2e tests covering signMetaTxCreateOfferAndCommit across native/ERC20 and buyer-/seller-initiated scenarios.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
packages/core-sdk/src/meta-tx/handler.ts Adds signMetaTxCreateOfferAndCommit (validation, metadata storage, and meta-tx signature generation).
packages/core-sdk/src/meta-tx/mixin.ts Exposes signMetaTxCreateOfferAndCommit on MetaTxMixin for SDK consumers.
e2e/tests/utils.ts Skips depositFunds when the calculated deposit is zero to avoid a protocol revert.
e2e/tests/meta-tx.test.ts Adds e2e coverage for relayed createOfferAndCommit meta-tx signing/execution for native + ERC20 in both initiation modes.

@levalleux-ludo levalleux-ludo merged commit ead2a8b into main Mar 12, 2026
15 of 18 checks passed
@levalleux-ludo levalleux-ludo deleted the copilot/add-sign-metatx-create-offer-and-commit branch March 12, 2026 09:35
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 createOfferAndCommit

4 participants