Skip to content

Commit

Permalink
Merge pull request #579 from liteflow-labs/dev
Browse files Browse the repository at this point in the history
Release v3.4.3
  • Loading branch information
ismailToyran authored Feb 20, 2024
2 parents be3d3d0 + 589cac7 commit 5e04c87
Show file tree
Hide file tree
Showing 55 changed files with 263 additions and 479 deletions.
2 changes: 1 addition & 1 deletion components/Cart/ItemSummary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const CartItemSummary: FC<Props> = ({ chainId, cartItems }) => {

const orderedCartItems = useOrderByKey(
offerIds,
data?.offerOpenSales?.nodes,
data?.listings?.nodes,
(offers) => offers.id,
)

Expand Down
2 changes: 1 addition & 1 deletion components/Cart/Step/Selection.gql
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
query FetchCartItems($offerIds: [UUID!]!) {
offerOpenSales(filter: { id: { in: $offerIds } }) {
listings(condition: { ids: $offerIds, status: [ACTIVE, EXPIRED] }) {
nodes {
id
type
Expand Down
6 changes: 3 additions & 3 deletions components/Cart/Step/Selection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,14 @@ const CartStepSelection: FC<Props> = ({ onSubmit }) => {

const offers = useMemo(
() =>
(data?.offerOpenSales?.nodes || []).reduce(
(data?.listings?.nodes || []).reduce(
(prev, x) => ({ ...prev, [x.id]: x }),
{} as Record<
string,
NonNullable<FetchCartItemsQuery['offerOpenSales']>['nodes'][number]
NonNullable<FetchCartItemsQuery['listings']>['nodes'][number]
>,
),
[data?.offerOpenSales?.nodes],
[data?.listings?.nodes],
)

const nonExpiredSelectedCartItems = useMemo(
Expand Down
16 changes: 3 additions & 13 deletions components/Filter/FilterBy/Collection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,7 @@ import useTranslation from 'next-translate/useTranslation'
import { FC, useCallback, useMemo, useState } from 'react'
import { UseFormReturn } from 'react-hook-form'
import { concatToQuery } from '../../../concat'
import {
CollectionFilter,
StringFilter,
useSearchCollectionQuery,
} from '../../../graphql'
import { useSearchCollectionQuery } from '../../../graphql'
import { Filter } from '../../../hooks/useAssetFilterFromQuery'
import { formatError } from '../../../utils'
import CollectionListItem from '../../Collection/ListItem'
Expand Down Expand Up @@ -53,14 +49,8 @@ const FilterByCollection: FC<Props> = ({
variables: {
offset: 0, // the offset change must be done when calling the fetchMore function to concat queries' results
limit: PAGINATION_LIMIT,
filter: {
name: {
includesInsensitive: filterResult.collectionSearch || '',
} as StringFilter,
...(filterResult.chains.length
? { chainId: { in: filterResult.chains } }
: {}),
} as CollectionFilter,
chainIds: filterResult.chains,
search: filterResult.collectionSearch || null,
},
notifyOnNetworkStatusChange: true,
})
Expand Down
14 changes: 3 additions & 11 deletions components/Filter/FilterBy/Trait.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,7 @@ import SearchInput from 'components/SearchInput'
import useTranslation from 'next-translate/useTranslation'
import { FC, useCallback, useState } from 'react'
import { UseFormReturn } from 'react-hook-form'
import {
CollectionTraitFilter,
StringFilter,
useFetchCollectionTraitsQuery,
} from '../../../graphql'
import { useFetchCollectionTraitsQuery } from '../../../graphql'
import { Filter } from '../../../hooks/useAssetFilterFromQuery'
import { formatError } from '../../../utils'

Expand Down Expand Up @@ -56,11 +52,7 @@ const FilterByTrait: FC<Props> = ({
chainId: collection.chainId,
offset: 0, // the offset change must be done when calling the fetchMore function to concat queries' results
limit: PAGINATION_LIMIT,
filter: {
type: {
includesInsensitive: filterResult.propertySearch || '',
} as StringFilter,
} as CollectionTraitFilter,
search: filterResult.propertySearch || null,
},
notifyOnNetworkStatusChange: true,
})
Expand Down Expand Up @@ -199,7 +191,7 @@ const FilterByTrait: FC<Props> = ({
defaultValue={
filterResult?.traits?.find(
(trait) => trait.type === type,
)?.values
)?.values || undefined
}
>
<Stack spacing={1}>
Expand Down
12 changes: 6 additions & 6 deletions components/History/HistoryList.gql
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ query FetchAssetHistory(
$tokenId: String!
$limit: Int!
$offset: Int!
$filter: [AssetHistoryAction!]
$actions: [AssetHistoryAction!]
) {
assetHistories(
filter: {
chainId: { equalTo: $chainId }
collectionAddress: { equalTo: $collectionAddress }
tokenId: { equalTo: $tokenId }
action: { in: $filter }
condition: {
chainId: $chainId
collectionAddress: $collectionAddress
tokenId: $tokenId
actions: $actions
}
orderBy: DATE_DESC
first: $limit
Expand Down
2 changes: 1 addition & 1 deletion components/History/HistoryList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ const HistoryList: FC<IProps> = ({ chainId, collectionAddress, tokenId }) => {
tokenId,
limit: LIMIT,
offset,
filter,
actions: filter,
},
})
const histories = historyData?.assetHistories?.nodes
Expand Down
17 changes: 7 additions & 10 deletions components/HomeSection/Assets.gql
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
query FetchDefaultAssetIds($limit: Int!) {
assets(
filter: { quantity: { greaterThan: "0" } }
orderBy: CREATED_AT_DESC
first: $limit
) {
assets(orderBy: CREATED_AT_DESC, first: $limit) {
nodes {
chainId
collectionAddress
Expand All @@ -12,11 +8,12 @@ query FetchDefaultAssetIds($limit: Int!) {
}
}

query FetchAssets($limit: Int!, $filter: [AssetFilter!]!, $address: Address) {
assets(
filter: { quantity: { greaterThan: "0" }, and: $filter }
first: $limit
) {
query FetchAssets(
$limit: Int!
$ids: [AssetIdsCondition!]!
$address: Address
) {
assets(condition: { ids: $ids }, first: $limit) {
nodes {
chainId
collectionAddress
Expand Down
33 changes: 15 additions & 18 deletions components/HomeSection/Assets.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import useTranslation from 'next-translate/useTranslation'
import { FC, useMemo } from 'react'
import invariant from 'ts-invariant'
import {
AssetFilter,
useFetchAssetsQuery,
useFetchDefaultAssetIdsQuery,
} from '../../graphql'
Expand Down Expand Up @@ -67,23 +66,21 @@ const AssetsHomeSection: FC<Props> = ({ date }) => {
const assetsQuery = useFetchAssetsQuery({
variables: {
limit: PAGINATION_LIMIT,
filter: {
or: (assetIds || [])
.map((x) => x.split('-'))
.map(([chainId, collectionAddress, tokenId]) => {
invariant(
chainId !== undefined &&
collectionAddress !== undefined &&
tokenId !== undefined,
'invalid collection',
)
return {
collectionAddress: { equalTo: collectionAddress.toLowerCase() },
chainId: { equalTo: parseInt(chainId, 10) },
tokenId: { equalTo: tokenId },
}
}),
} as AssetFilter,
ids: (assetIds || [])
.map((x) => x.split('-'))
.map(([chainId, collectionAddress, tokenId]) => {
invariant(
chainId !== undefined &&
collectionAddress !== undefined &&
tokenId !== undefined,
'invalid collection',
)
return {
collectionAddress: collectionAddress.toLowerCase(),
chainId: parseInt(chainId, 10),
tokenId: tokenId,
}
}),
address: address || '',
},
skip: assetIds === undefined,
Expand Down
8 changes: 6 additions & 2 deletions components/HomeSection/Collections.gql
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
query FetchCollections($filter: CollectionFilter!, $limit: Int!) {
collections(filter: $filter, first: $limit, orderBy: TOTAL_VOLUME_DESC) {
query FetchCollections($ids: [CollectionIdsCondition!]!, $limit: Int!) {
collections(
condition: { ids: $ids }
first: $limit
orderBy: TOTAL_VOLUME_DESC
) {
nodes {
chainId
address
Expand Down
26 changes: 10 additions & 16 deletions components/HomeSection/Collections.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,7 @@ import { useOrderByKey } from 'hooks/useOrderByKey'
import useTranslation from 'next-translate/useTranslation'
import { FC } from 'react'
import invariant from 'ts-invariant'
import {
CollectionFilter,
FetchCollectionsQuery,
useFetchCollectionsQuery,
} from '../../graphql'
import { FetchCollectionsQuery, useFetchCollectionsQuery } from '../../graphql'
import useEnvironment from '../../hooks/useEnvironment'
import useHandleQueryError from '../../hooks/useHandleQueryError'
import HomeGridSection from './Grid'
Expand All @@ -19,17 +15,15 @@ const CollectionsHomeSection: FC<Props> = () => {
const { t } = useTranslation('templates')
const collectionsQuery = useFetchCollectionsQuery({
variables: {
filter: {
or: HOME_COLLECTIONS.map((x) => x.split('-')).map(
([chainId, collectionAddress]) => {
invariant(chainId && collectionAddress, 'invalid collection')
return {
address: { equalTo: collectionAddress.toLowerCase() },
chainId: { equalTo: parseInt(chainId, 10) },
}
},
),
} as CollectionFilter,
ids: HOME_COLLECTIONS.map((x) => x.split('-')).map(
([chainId, collectionAddress]) => {
invariant(chainId && collectionAddress, 'invalid collection')
return {
address: collectionAddress.toLowerCase(),
chainId: parseInt(chainId, 10),
}
},
),
limit: PAGINATION_LIMIT,
},
skip: !HOME_COLLECTIONS.length,
Expand Down
9 changes: 2 additions & 7 deletions components/HomeSection/Featured.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,7 @@ import useEnvironment from '../../hooks/useEnvironment'
import Slider from '../Slider/Slider'
import TokenHeader from './FeaturedToken'

type Props = {
date: Date
}

const FeaturedHomeSection: FC<Props> = ({ date }) => {
const FeaturedHomeSection: FC = () => {
const { FEATURED_TOKEN } = useEnvironment()

const featuredAssets = useMemo(
Expand All @@ -28,12 +24,11 @@ const FeaturedHomeSection: FC<Props> = ({ date }) => {
chainId={parseInt(chainId, 10)}
collectionAddress={collectionAddress.toLowerCase()}
tokenId={tokenId}
date={date}
/>
)
},
),
[FEATURED_TOKEN, date],
[FEATURED_TOKEN],
)

if (FEATURED_TOKEN.length === 0) return null
Expand Down
27 changes: 13 additions & 14 deletions components/HomeSection/FeaturedToken.gql
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ query FetchFeaturedToken(
$chainId: Int!
$collectionAddress: Address!
$tokenId: String!
$now: Datetime!
$address: Address
) {
asset(
Expand Down Expand Up @@ -50,10 +49,10 @@ query FetchFeaturedToken(
}
}
ownerships(
filter: {
chainId: { equalTo: $chainId }
collectionAddress: { equalTo: $collectionAddress }
tokenId: { equalTo: $tokenId }
condition: {
chainId: $chainId
collectionAddress: $collectionAddress
tokenId: $tokenId
}
orderBy: [
QUANTITY_DESC
Expand All @@ -76,13 +75,13 @@ query FetchFeaturedToken(
}
}
}
sales: offerOpenSales(
sales: listings(
orderBy: [UNIT_PRICE_IN_REF_ASC, CREATED_AT_ASC]
filter: {
chainId: { equalTo: $chainId }
collectionAddress: { equalTo: $collectionAddress }
tokenId: { equalTo: $tokenId }
expiredAt: { greaterThan: $now }
condition: {
chainId: $chainId
collectionAddress: $collectionAddress
tokenId: $tokenId
status: ACTIVE
} # TODO: implement pagination. when implementing pagination, find a way to get availableQuantity of all sales
) {
nodes {
Expand Down Expand Up @@ -112,9 +111,9 @@ query FetchFeaturedToken(
}
currencies(
orderBy: CREATED_AT_ASC
filter: {
chainId: { equalTo: $chainId }
address: { isNull: false } # keep only non-native currency. Cannot create bid with native currency.
condition: {
chainId: $chainId
onlyToken: true # keep only non-native currency. Cannot create bid with native currency.
}
) {
nodes {
Expand Down
13 changes: 2 additions & 11 deletions components/HomeSection/FeaturedToken.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,19 @@ import TokenMedia from '../Token/Media'
import TokenMetadata from '../Token/Metadata'

export type Props = {
date: Date
chainId: number
collectionAddress: string
tokenId: string
}

const FeaturedToken: FC<Props> = ({
date,
chainId,
collectionAddress,
tokenId,
}) => {
const FeaturedToken: FC<Props> = ({ chainId, collectionAddress, tokenId }) => {
const { address } = useAccount()

const fetchFeaturedTokenQuery = useFetchFeaturedTokenQuery({
variables: {
chainId,
collectionAddress,
tokenId,
now: date,
address: address || '',
},
})
Expand All @@ -52,9 +45,7 @@ const FeaturedToken: FC<Props> = ({
const media = useDetectAssetMedia(asset)

const refresh = useCallback(async () => {
await fetchFeaturedTokenQuery.refetch({
now: new Date(),
})
await fetchFeaturedTokenQuery.refetch()
}, [fetchFeaturedTokenQuery])

useCart({ onCheckout: fetchFeaturedTokenQuery.refetch })
Expand Down
2 changes: 1 addition & 1 deletion components/HomeSection/Users.gql
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
query FetchUsers($limit: Int!, $userIds: [Address!]!) {
users: accounts(filter: { address: { in: $userIds } }, first: $limit) {
users: accounts(condition: { addresses: $userIds }, first: $limit) {
nodes {
username
address
Expand Down
2 changes: 1 addition & 1 deletion components/Offer/Form/Checkout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ type FormData = {
}

type Props = {
offer: NonNullable<CheckoutQuery['offer']>
offer: NonNullable<CheckoutQuery['listing']>
onPurchased: () => void
multiple?: boolean
}
Expand Down
Loading

0 comments on commit 5e04c87

Please sign in to comment.