Auctions: Precise and safe time conversions (SystemTime→µs), correct U256 topic filtering, clearer errors #132
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.
This patch removes ad-hoc time conversions and establishes a single, correct, and auditable path for turning SystemTime into microseconds across the auctions client. It also ensures event filtering uses the right on-chain width (U256) and tightens error messages so unit mismatches are obvious.
What changed
AuctionClient
:micros_from_system_time(SystemTime) -> u128
micros_u64_from_system_time(SystemTime) -> anyhow::Result<u64>
(overflow-checked)micros_u256_from_system_time(SystemTime) -> U256
fetch_bids_for_deadline
now filters withtopic3(Self::micros_u256_from_system_time(deadline))
submit_bid
now converts the deadline viamicros_u64_from_system_time
replacing the previous inlinetry_into()
Why this is needed
u64
Risk assessment
Notes for reviewers
fn
(notconst fn
) to keep the surface minimal and focused on correctness rather than compile-time evaluation.Checklist
If there’s any preference to move these helpers to a shared time utils module, I can follow up with a separate, mechanical PR.
Cheers!