feat: add support for order-filtering as stream combinators#230
Merged
Conversation
prestwich
approved these changes
May 6, 2026
| } | ||
|
|
||
| /// Match orders that have at least one [`Output`] paying `token`. | ||
| pub fn has_output_token(token: Address) -> impl Fn(&SignedOrder) -> bool { |
Member
There was a problem hiding this comment.
this could be ambiguous if tokens on host and RU share an address. should we do a (chain_id, address) tuple here maybe?
Member
There was a problem hiding this comment.
slept on this. in extreme edge cases, an attacker can create this confusion. This should be caught downstream by additional filler quoting and pricing processes, but still better to do defense in depth here I think
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.

[Claude Code]
Description
Adds stream combinators for filtering
SignedOrderstreams insignet-orders, plus a small supporting helper onSignedOrderitself.OrderStreamExttrait withfilter_orders, implemented for anyStream<Item = Result<SignedOrder, E>>.Erritems pass through unchanged; onlyOkitems are tested against the predicate. The predicate isFnMut, so stateful filtering (e.g. dedup byorder_hash) is supported.stream::predicatesmodule with ready-made predicate constructors:not_expired_at,has_output_chain,has_output_token,has_output_recipient,has_input_token,with_owner. Each returnsimpl Fn(&SignedOrder) -> booland composes via boolean operators in a closure.SignedOrder::is_expired_at(timestamp)onsignet-types, factored out ofvalidateso the deadline check has a single source of truth and can be reused bynot_expired_at. Boundary semantics are unchanged (timestamp == deadlineis not expired;U256deadlines saturate tou64::MAX).tokio(withmacros,rt) as a[dev-dependencies]entry onsignet-ordersfor the new#[tokio::test]s.Test plan
cargo t -p signet-orders- new stream/predicate tests passcargo t -p signet-types- existingvalidatebehavior preservedcargo clippy -p signet-orders --all-features --all-targetscargo clippy -p signet-orders --no-default-features --all-targetscargo +nightly fmt -- --checkRUSTDOCFLAGS="-D warnings" cargo doc -p signet-orders --no-deps- verifies thepredicatesmodule-level doctest compiles