Skip to content

Conversation

@madisoncarter1234
Copy link
Contributor

Bug

In src/orders/privateListings.ts, the constructPrivateListingCounterOrder function filters payment items but doesn't check if the result is empty. Lines 37, 59-61 then access paymentItems[0] which would be undefined and crash.

How it happens

  1. Filter removes all consideration items going to the private sale recipient (line 26-29)
  2. If ALL items go to the recipient, paymentItems is empty
  3. Line 31 check: paymentItems.every(...) returns true for empty arrays (vacuous truth)
  4. Lines 37, 59-61 access paymentItems[0] which is undefined → crash

Fix

Added explicit length check after filtering. Now throws a descriptive error instead of crashing with undefined access.

This prevents runtime errors in edge case scenarios with malformed private listings.

Prevents undefined access error when constructing private listing counter
orders. If paymentItems array is empty after filtering, accessing
paymentItems[0] on lines 37, 59-61 would crash.

Added check to throw descriptive error if no payment items are found.
ryanio added a commit that referenced this pull request Nov 28, 2025
Fixes SDK crash when fulfilling zero-payment private listings (e.g., rewards claims).

Problem:
- constructPrivateListingCounterOrder crashes when paymentItems is empty
- fulfillPrivateOrder crashes accessing counterOrder.parameters.offer[0]

Solution (mirrors backend behavior in os2-core Seaport.kt):
- Allow empty payment items in constructPrivateListingCounterOrder
- Return counter order with offer: [] for zero-payment listings
- Add computePrivateListingValue() to calculate ETH value from original order
- Use computed value instead of counter order's offer[0].startAmount

This enables fulfillment of zero-payment private listings used for rewards
claims via REWARDS_PRIVATE_LISTING_CLAIM_WALLET.

Closes #1832
@ryanio
Copy link
Collaborator

ryanio commented Nov 28, 2025

thank you! went with an approach that allows fulfilling of zero payment item private orders (we use these types of orders for rewards when people earn NFTs, so is still nice to support)

@ryanio ryanio closed this Nov 28, 2025
ryanio added a commit that referenced this pull request Nov 28, 2025
Fixes SDK crash when fulfilling zero-payment private listings (e.g., rewards claims).

Problem:
- constructPrivateListingCounterOrder crashes when paymentItems is empty
- fulfillPrivateOrder crashes accessing counterOrder.parameters.offer[0]

Solution (mirrors backend behavior in os2-core Seaport.kt):
- Allow empty payment items in constructPrivateListingCounterOrder
- Return counter order with offer: [] for zero-payment listings
- Add computePrivateListingValue() to calculate ETH value from original order
- Use computed value instead of counter order's offer[0].startAmount

This enables fulfillment of zero-payment private listings used for rewards
claims via REWARDS_PRIVATE_LISTING_CLAIM_WALLET.

Closes #1832
ryanio added a commit that referenced this pull request Nov 28, 2025
Fixes SDK crash when fulfilling zero-payment private listings (e.g., rewards claims).

Problem:
- constructPrivateListingCounterOrder crashes when paymentItems is empty
- fulfillPrivateOrder crashes accessing counterOrder.parameters.offer[0]

Solution (mirrors backend behavior in os2-core Seaport.kt):
- Allow empty payment items in constructPrivateListingCounterOrder
- Return counter order with offer: [] for zero-payment listings
- Add computePrivateListingValue() to calculate ETH value from original order
- Use computed value instead of counter order's offer[0].startAmount

This enables fulfillment of zero-payment private listings used for rewards
claims via REWARDS_PRIVATE_LISTING_CLAIM_WALLET.

Closes #1832
ryanio added a commit that referenced this pull request Nov 28, 2025
Fixes SDK crash when fulfilling zero-payment private listings (e.g., rewards claims).

Problem:
- constructPrivateListingCounterOrder crashes when paymentItems is empty
- fulfillPrivateOrder crashes accessing counterOrder.parameters.offer[0]

Solution (mirrors backend behavior in os2-core Seaport.kt):
- Allow empty payment items in constructPrivateListingCounterOrder
- Return counter order with offer: [] for zero-payment listings
- Add computePrivateListingValue() to calculate ETH value from original order
- Use computed value instead of counter order's offer[0].startAmount

This enables fulfillment of zero-payment private listings used for rewards
claims via REWARDS_PRIVATE_LISTING_CLAIM_WALLET.

Closes #1832
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.

2 participants