Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle includeInactive in ViewService#auctions #1047

Merged
merged 10 commits into from
May 8, 2024

Conversation

jessepinho
Copy link
Contributor

@jessepinho jessepinho commented May 7, 2024

AuctionsRequests have an includeInactive property that was not yet supported by our auctions implementation. This PR adds support for that property by A) keeping track of auctions' sequence numbers to determine whether they're active, and B) filtering out inactive auctions unless includeInactive is true.

In this PR

  • Add a seqNum column to the AUCTIONS table (to mimic the state column in core's implementation)
  • Upsert the seqNum in the block processor when we encounter a Dutch auction-related action.
  • Add support for includeInactive in the ViewService#auctions RPC method.
  • Bump the IndexedDB version number.

Relates to #980 (but doesn't close it yet, since queryLatestState is not yet supported)

@jessepinho jessepinho force-pushed the jessepinho/auctions-rpc-include-inactive-web-980 branch from 4f3b3de to fa75d5c Compare May 7, 2024 01:33
@jessepinho jessepinho force-pushed the jessepinho/auctions-rpc-include-inactive-web-980 branch from 9a4e5f1 to c59b57c Compare May 7, 2024 16:27
@jessepinho jessepinho changed the title WIP: Handle includeInactive in ViewService#auctions Handle includeInactive in ViewService#auctions May 7, 2024
@jessepinho jessepinho marked this pull request as ready for review May 7, 2024 16:33
// Always a sequence number of 1 when ending a Dutch auction
const seqNum = 1n;

const metadata = getAuctionNftMetadata(action.value.auctionId, seqNum);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

won't this request metadata for closed auctions since it's passing in seqNum of 1? Shouldn't it pass seqNum of 0 for active auctions, and only after save the metadata and update the auction sequence number? Or does it not matter here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@TalDerei

won't this request metadata for closed auctions since it's passing in seqNum of 1?

Correct — although it's not exactly requesting the metadata, but rather generating it. (getAuctioNftMetadata() calls a WASM function under the hood that generates metadata for an asset that doesn't exist yet.)

Shouldn't it pass seqNum of 0 for active auctions, and only after save the metadata and update the auction sequence number?

Hm — we could request the NFT metadata for the open auction, and the modify its sequence number. But that feels a bit messy to me — if the algorithm for generating NFT metadata changes in the future such that closed-auction NFTs have different metadata than open-auction NFTs, this would break. Easier to just generate it from scratch for each auction state.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah was thinking about that, I think generating the metadata is the right design choice here.

Copy link
Contributor

@TalDerei TalDerei May 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

requesting

wrong word choice here 😅

@@ -33,6 +33,8 @@ const getBech32mAuctionId = (
return captureGroups.auctionId;
};

const isInactive = (seqNum?: bigint) => (seqNum === undefined ? false : seqNum > 0n);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why would the sequence number ever be undefined?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made it optional since value (used on line 61 below) may have an undefined seqNum property if we haven't saved it yet for some reason.

@TalDerei TalDerei self-requested a review May 8, 2024 18:02
jessepinho added 2 commits May 8, 2024 11:27
* Support queryLatestState

* Simplify

* Remove unused method

* Change method signature

* Rework a bit

* Remove unused import

* Account for the fullnode returning a DutchAuction, not a DutchAuctionState

* Fix type name check
* Build UI to end an auction

* Fix layout issue

* Tweak symbols

* Reload auctions after scheduling or ending an auction

* Save auction metadata when ending an auction

* Rename helper
@jessepinho jessepinho merged commit fea6900 into main May 8, 2024
6 checks passed
@jessepinho jessepinho deleted the jessepinho/auctions-rpc-include-inactive-web-980 branch May 8, 2024 18:40
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