Skip to content

Commit

Permalink
feat: Add filled price to event and fix top collection query for offe…
Browse files Browse the repository at this point in the history
…rs (#1335)

* add filled price to event and fix top collection query for offers

* fix

* fix
  • Loading branch information
justraman authored Oct 7, 2024
1 parent 4661a8e commit d01a4b6
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 1 deletion.
1 change: 1 addition & 0 deletions schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ type MarketplaceListingFilled {
amountFilled: BigInt!
amountRemaining: BigInt!
protocolFee: BigInt!
price: BigInt!
royalty: BigInt!
}

Expand Down
2 changes: 2 additions & 0 deletions src/mappings/marketplace/events/listing_filled.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ function getEvent(
buyer: data.buyer,
amountFilled: data.amountFilled,
amountRemaining: data.amountRemaining,
price: 'price' in data ? (data.price as bigint) : listing.highestPrice,
protocolFee: data.protocolFee,
royalty: data.royalty,
}),
Expand Down Expand Up @@ -162,6 +163,7 @@ export async function listingFilled(
token: listing.type === ListingType.Offer ? listing.takeAssetId.id : listing.makeAssetId.id,
buyer: { id: data.buyer },
amountFilled: data.amountFilled,
price: 'price' in data ? (data.price as bigint) : listing.highestPrice,
amountRemaining: data.amountRemaining,
protocolFee: data.protocolFee,
royalty: data.royalty,
Expand Down
12 changes: 12 additions & 0 deletions src/model/generated/_marketplaceListingFilled.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export class MarketplaceListingFilled {
private _amountFilled!: bigint
private _amountRemaining!: bigint
private _protocolFee!: bigint
private _price!: bigint
private _royalty!: bigint

constructor(props?: Partial<Omit<MarketplaceListingFilled, 'toJSON'>>, json?: any) {
Expand All @@ -20,6 +21,7 @@ export class MarketplaceListingFilled {
this._amountFilled = marshal.bigint.fromJSON(json.amountFilled)
this._amountRemaining = marshal.bigint.fromJSON(json.amountRemaining)
this._protocolFee = marshal.bigint.fromJSON(json.protocolFee)
this._price = marshal.bigint.fromJSON(json.price)
this._royalty = marshal.bigint.fromJSON(json.royalty)
}
}
Expand Down Expand Up @@ -69,6 +71,15 @@ export class MarketplaceListingFilled {
this._protocolFee = value
}

get price(): bigint {
assert(this._price != null, 'uninitialized access')
return this._price
}

set price(value: bigint) {
this._price = value
}

get royalty(): bigint {
assert(this._royalty != null, 'uninitialized access')
return this._royalty
Expand All @@ -86,6 +97,7 @@ export class MarketplaceListingFilled {
amountFilled: marshal.bigint.toJSON(this.amountFilled),
amountRemaining: marshal.bigint.toJSON(this.amountRemaining),
protocolFee: marshal.bigint.toJSON(this.protocolFee),
price: marshal.bigint.toJSON(this.price),
royalty: marshal.bigint.toJSON(this.royalty),
}
}
Expand Down
6 changes: 5 additions & 1 deletion src/server-extension/resolvers/top_collections.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,11 @@ export class TopCollectionResolver {
inBuilder
.from(ListingSale, 'sale')
.innerJoin(Listing, 'listing', 'listing.id = sale.listing')
.innerJoin(Token, 'token', 'listing.make_asset_id_id = token.id')
.innerJoin(
Token,
'token',
"listing.make_asset_id_id = token.id AND listing.make_asset_id_id != '0-0'"
)
.innerJoin(Collection, 'collection', 'token.collection = collection.id')
.leftJoin(ListingStatus, 'status', `listing.id = status.listing AND status.type = 'Finalized'`)
.addGroupBy('collection.id')
Expand Down

0 comments on commit d01a4b6

Please sign in to comment.