Repository navigation
fix: reject a zero unitsToFill instead of filling the whole order - #1054
Closed
nftpoetrist wants to merge 1 commit into
Closed
nftpoetrist wants to merge 1 commit into
nftpoetrist wants to merge 1 commit into
Conversation
The fill paths treat a falsy unitsToFill as "not set" and fill what is left of the order, so 0 or 0n bought the entire order. The same zero as the string "0" already threw "Units to fill must be greater than 0" in mapOrderAmountsFromUnitsToFill. Check it once in fulfillOrder and fulfillOrders so every zero is rejected the same way.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1054 +/- ##
==========================================
+ Coverage 98.27% 99.13% +0.85%
==========================================
Files 35 57 +22
Lines 14526 21251 +6725
Branches 660 1206 +546
==========================================
+ Hits 14276 21068 +6792
+ Misses 245 175 -70
- Partials 5 8 +3 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This was referenced Oct 30, 2026
Collaborator
|
Thanks @nftpoetrist. Confirmed on main: Since this adds a throw on input that used to return, it shipped as a minor release, v4.5.0. It was stacked with the other open PRs in #1058 with your commit unchanged, so closing this one in favor of it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
unitsToFillis optional, and leaving it out fills whatever is left of the order. The fill paths tell the two apart by truthiness:unitsToFillis aBigNumberish, so the result depends on how the zero is written:unitsToFillmain"0"mapOrderAmountsFromUnitsToFill, throwsUnits to fill must be greater than 00or0nfulfillOrder: basic or standard route;fulfillOrders: numerator/denominator 1/1)A caller who computes a unit count that comes out at zero buys every unit of the listing instead of getting an error. Measured on
mainwith a partially fillable listing of 10 ERC1155 units for 10 ETH:fulfillOrder({ order, unitsToFill: 0n })built a transaction withvalue10 ETH, and the fulfiller ended up holding all 10 units.Same falsy-zero class as #948 (
value: 0n).Fix
assertUnitsToFillIsPositiveruns at the top offulfillOrderand for each entry infulfillOrders. It throws the existing message for anyunitsToFillthat is set and not greater than zero.= 0defaults are untouched; they mean "not set".This adds a throw on input that previously returned, so it is a minor change.
Test
test/partial-fulfill.spec.ts, on the partially fillable ERC1155 listing:0and0nare rejected byfulfillOrderandfulfillOrders. Onmainthis fails withexpected promise to be rejected with an error including 'Units to fill must be greater than 0' but it was fulfilled with { actions: [ ... ] }."0"is rejected the same way onmainand with the fix. The existing cases with nounitsToFilland withunitsToFill: 2are unchanged.Verified failing-first by reverting only
src/seaport.ts: the number/bigint case fails, the string control passes.npm run lint(check-types + biome) clean,npm test281 passing (279 onmain),npm run coveragegreen.Scope note
Negative values already reached the existing guard and threw; they now throw at the entry point with the same message. Callers in opensea-sdk do not use
fulfillOrderorfulfillOrders(they passunitsToFillas a string to the fulfillment API), so they are unaffected.