Skip to content

Commit

Permalink
Use custom sales resolvers on asset instead of sales connection
Browse files Browse the repository at this point in the history
  • Loading branch information
NicolasMahe committed Feb 2, 2024
1 parent f1eb165 commit 5cc7300
Show file tree
Hide file tree
Showing 9 changed files with 110 additions and 154 deletions.
32 changes: 13 additions & 19 deletions components/HomeSection/Assets.gql
Original file line number Diff line number Diff line change
Expand Up @@ -60,28 +60,22 @@ query FetchAssets(
symbol
}
}
firstSale: sales(
first: 1
orderBy: [UNIT_PRICE_IN_REF_ASC, CREATED_AT_ASC]
filter: { expiredAt: { greaterThan: $now } }
) {
totalCount
totalCurrencyDistinctCount
nodes {
firstSale {

Check failure on line 63 in components/HomeSection/Assets.gql

View workflow job for this annotation

GitHub Actions / lint

Cannot query field "firstSale" on type "Asset"
id
unitPrice
currency {
image
name
id
unitPrice
currency {
image
name
id
decimals
symbol
}
maker {
address
}
decimals
symbol
}
maker {
address
}
}
totalSalesCount

Check failure on line 77 in components/HomeSection/Assets.gql

View workflow job for this annotation

GitHub Actions / lint

Cannot query field "totalSalesCount" on type "Asset"
totalSalesCurrencyDistinctCount

Check failure on line 78 in components/HomeSection/Assets.gql

View workflow job for this annotation

GitHub Actions / lint

Cannot query field "totalSalesCurrencyDistinctCount" on type "Asset"
}
}
}
38 changes: 16 additions & 22 deletions components/Token/Card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,23 +59,19 @@ export type Props = {
symbol: string
}
} | null
firstSale:
| {
totalCount: number
totalCurrencyDistinctCount: number
nodes: {
id: string
unitPrice: string
currency: {
decimals: number
symbol: string
}
maker: {
address: string
}
}[]
}
| undefined
firstSale: {
id: string
unitPrice: string
currency: {
decimals: number
symbol: string
}
maker: {
address: string
}
} | null
totalSalesCount: number
totalSalesCurrencyDistinctCount: number
}
}

Expand All @@ -89,12 +85,10 @@ const TokenCard: FC<Props> = ({ asset }) => {
const [isHovered, setIsHovered] = useState(false)
const media = useDetectAssetMedia(asset)

const sale = asset.firstSale?.nodes[0]
const sale = asset.firstSale
const bestBid = asset.bestBid
const numberOfSales = asset.firstSale?.totalCount || 0
const hasMultiCurrency = asset.firstSale?.totalCurrencyDistinctCount
? asset.firstSale.totalCurrencyDistinctCount > 1
: false
const numberOfSales = asset.totalSalesCount
const hasMultiCurrency = asset.totalSalesCurrencyDistinctCount > 1
const chainName = useMemo(
() => CHAINS.find((x) => x.id === asset.collection.chainId)?.name,
[asset.collection.chainId, CHAINS],
Expand Down
32 changes: 13 additions & 19 deletions pages/checkout/[id].gql
Original file line number Diff line number Diff line change
Expand Up @@ -40,28 +40,22 @@ query Checkout($id: UUID!, $address: Address, $now: Datetime!) {
symbol
}
}
firstSale: sales(
first: 1
orderBy: [UNIT_PRICE_IN_REF_ASC, CREATED_AT_ASC]
filter: { expiredAt: { greaterThan: $now } }
) {
totalCount
totalCurrencyDistinctCount
nodes {
firstSale {

Check failure on line 43 in pages/checkout/[id].gql

View workflow job for this annotation

GitHub Actions / lint

Cannot query field "firstSale" on type "Asset"
id
unitPrice
currency {
image
name
id
unitPrice
currency {
image
name
id
decimals
symbol
}
maker {
address
}
decimals
symbol
}
maker {
address
}
}
totalSalesCount

Check failure on line 57 in pages/checkout/[id].gql

View workflow job for this annotation

GitHub Actions / lint

Cannot query field "totalSalesCount" on type "Asset"
totalSalesCurrencyDistinctCount
}
maker {
address
Expand Down
31 changes: 13 additions & 18 deletions pages/collection/[chainId]/[id]/index.gql
Original file line number Diff line number Diff line change
Expand Up @@ -114,27 +114,22 @@ query FetchCollectionAssets(
symbol
}
}
firstSale: sales(
first: 1
orderBy: [UNIT_PRICE_IN_REF_ASC, CREATED_AT_ASC]
filter: { expiredAt: { greaterThan: $now } }
) {
totalCount
totalCurrencyDistinctCount
nodes {
firstSale {
id
unitPrice
currency {
image
name
id
unitPrice
currency {
image
id
decimals
symbol
}
maker {
address
}
decimals
symbol
}
maker {
address
}
}
totalSalesCount
totalSalesCurrencyDistinctCount
}
}
}
4 changes: 3 additions & 1 deletion pages/create/[chainId]/[collectionAddress].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,9 @@ const CreatePage: NextPage = () => {
...asset,
creator,
bestBid: null,
firstSale: undefined,
firstSale: null,
totalSalesCount: 0,
totalSalesCurrencyDistinctCount: 0,
}}
/>
)}
Expand Down
32 changes: 13 additions & 19 deletions pages/explore/explore.gql
Original file line number Diff line number Diff line change
Expand Up @@ -45,28 +45,22 @@ query FetchAllERC721And1155(
symbol
}
}
firstSale: sales(
first: 1
orderBy: [UNIT_PRICE_IN_REF_ASC, CREATED_AT_ASC]
filter: { expiredAt: { greaterThan: $now } }
) {
totalCount
totalCurrencyDistinctCount
nodes {
firstSale {
id
unitPrice
currency {
image
name
id
unitPrice
currency {
image
name
id
decimals
symbol
}
maker {
address
}
decimals
symbol
}
maker {
address
}
}
totalSalesCount
totalSalesCurrencyDistinctCount
creator {
address
name
Expand Down
32 changes: 13 additions & 19 deletions pages/tokens/[id]/bid.gql
Original file line number Diff line number Diff line change
Expand Up @@ -47,28 +47,22 @@ query BidOnAsset(
symbol
}
}
firstSale: sales(
first: 1
orderBy: [UNIT_PRICE_IN_REF_ASC, CREATED_AT_ASC]
filter: { expiredAt: { greaterThan: $now } }
) {
totalCount
totalCurrencyDistinctCount
nodes {
firstSale {
id
unitPrice
currency {
image
name
id
unitPrice
currency {
image
name
id
decimals
symbol
}
maker {
address
}
decimals
symbol
}
maker {
address
}
}
totalSalesCount
totalSalesCurrencyDistinctCount
}
currencies(
orderBy: CREATED_AT_ASC
Expand Down
32 changes: 13 additions & 19 deletions pages/tokens/[id]/offer.gql
Original file line number Diff line number Diff line change
Expand Up @@ -42,28 +42,22 @@ query OfferForAsset(
symbol
}
}
firstSale: sales(
first: 1
orderBy: [UNIT_PRICE_IN_REF_ASC, CREATED_AT_ASC]
filter: { expiredAt: { greaterThan: $now } }
) {
totalCount
totalCurrencyDistinctCount
nodes {
firstSale {
id
unitPrice
currency {
image
name
id
unitPrice
currency {
image
name
id
decimals
symbol
}
maker {
address
}
decimals
symbol
}
maker {
address
}
}
totalSalesCount
totalSalesCurrencyDistinctCount
creator {
address
name
Expand Down
31 changes: 13 additions & 18 deletions pages/users/[id]/assetDetail.gql
Original file line number Diff line number Diff line change
Expand Up @@ -26,27 +26,22 @@ fragment AssetDetail on Asset {
symbol
}
}
firstSale: sales(
first: 1
orderBy: [UNIT_PRICE_IN_REF_ASC, CREATED_AT_ASC]
filter: { expiredAt: { greaterThan: $now } }
) {
totalCount
totalCurrencyDistinctCount
nodes {
firstSale {
id
unitPrice
currency {
image
name
id
unitPrice
currency {
image
id
decimals
symbol
}
maker {
address
}
decimals
symbol
}
maker {
address
}
}
totalSalesCount
totalSalesCurrencyDistinctCount
creator {
address
name
Expand Down

0 comments on commit 5cc7300

Please sign in to comment.