From cb90c88770d19c16b04125f718bdd32d6324144f Mon Sep 17 00:00:00 2001 From: Nicolas Mahe Date: Wed, 10 Jan 2024 10:41:38 +0700 Subject: [PATCH 01/58] add config for neon EVM --- environment.ts | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/environment.ts b/environment.ts index af27992f..97b62988 100644 --- a/environment.ts +++ b/environment.ts @@ -228,7 +228,7 @@ const getEnvironment = async (): Promise => { url: 'https://phoenix.lightlink.io', }, }, - } as Chain, + }, { name: 'LightLink Pegasus Testnet', network: 'lightlink-pegasus', @@ -259,7 +259,38 @@ const getEnvironment = async (): Promise => { url: 'https://pegasus.lightlink.io', }, }, - } as Chain, + }, + { + id: 245022926, + network: 'neonDevnet', + name: 'Neon EVM DevNet', + nativeCurrency: { + name: 'NEON', + symbol: 'NEON', + decimals: 18, + }, + rpcUrls: { + default: { + http: ['https://devnet.neonevm.org'], + }, + public: { + http: ['https://devnet.neonevm.org'], + }, + }, + blockExplorers: { + default: { + name: 'Neonscan', + url: 'https://neonscan.org', + }, + }, + contracts: { + multicall3: { + address: '0xca11bde05977b3631167028862be2a173976ca11', + blockCreated: 205206112, + }, + }, + testnet: true, + }, ], WALLET_CONNECT_PROJECT_ID: process.env.NEXT_PUBLIC_WALLET_CONNECT_PROJECT_ID, From a72d53630bb5e99c6011d915ef57c0fc84ad6b31 Mon Sep 17 00:00:00 2001 From: Nicolas Mahe Date: Wed, 10 Jan 2024 11:44:03 +0700 Subject: [PATCH 02/58] fix block explorer url --- environment.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/environment.ts b/environment.ts index 97b62988..4f20e6cb 100644 --- a/environment.ts +++ b/environment.ts @@ -280,7 +280,7 @@ const getEnvironment = async (): Promise => { blockExplorers: { default: { name: 'Neonscan', - url: 'https://neonscan.org', + url: 'https://devnet.neonscan.org', }, }, contracts: { From 48c0fb8991b4ae779c553983e1598feb4180b176 Mon Sep 17 00:00:00 2001 From: Nicolas Mahe Date: Tue, 16 Jan 2024 12:39:02 +0700 Subject: [PATCH 03/58] add neon evm config --- environment.ts | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/environment.ts b/environment.ts index 4f20e6cb..b108b806 100644 --- a/environment.ts +++ b/environment.ts @@ -260,6 +260,37 @@ const getEnvironment = async (): Promise => { }, }, }, + { + id: 245022934, + network: 'neonMainnet', + name: 'Neon EVM MainNet', + nativeCurrency: { + name: 'NEON', + symbol: 'NEON', + decimals: 18, + }, + rpcUrls: { + default: { + http: ['https://neon-proxy-mainnet.solana.p2p.org'], + }, + public: { + http: ['https://neon-proxy-mainnet.solana.p2p.org'], + }, + }, + blockExplorers: { + default: { + name: 'Neonscan', + url: 'https://neonscan.org', + }, + }, + contracts: { + multicall3: { + address: '0xca11bde05977b3631167028862be2a173976ca11', + blockCreated: 206545524, + }, + }, + testnet: false, + }, { id: 245022926, network: 'neonDevnet', From c645cd314db10083525a7faa55e17900098cb88d Mon Sep 17 00:00:00 2001 From: Nicolas Mahe Date: Mon, 22 Jan 2024 11:45:00 +0700 Subject: [PATCH 04/58] add arbitrum sepolia chain --- environment.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/environment.ts b/environment.ts index af27992f..7f7c030f 100644 --- a/environment.ts +++ b/environment.ts @@ -10,6 +10,7 @@ import { mainnet as ethereumMainnet, polygon, polygonMumbai, + arbitrumSepolia, } from 'wagmi/chains' type RemoteConfig = { @@ -199,6 +200,7 @@ const getEnvironment = async (): Promise => { bsc, polygon, polygonMumbai, + arbitrumSepolia, { name: 'LightLink Phoenix', network: 'lightlink-phoenix', From 6141956c413f7b926ac0dba0cc22cb26358fdd39 Mon Sep 17 00:00:00 2001 From: Nicolas Mahe Date: Mon, 22 Jan 2024 11:45:59 +0700 Subject: [PATCH 05/58] add arbitrum chain --- environment.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/environment.ts b/environment.ts index 7f7c030f..32a90cca 100644 --- a/environment.ts +++ b/environment.ts @@ -10,6 +10,7 @@ import { mainnet as ethereumMainnet, polygon, polygonMumbai, + arbitrum, arbitrumSepolia, } from 'wagmi/chains' @@ -200,6 +201,7 @@ const getEnvironment = async (): Promise => { bsc, polygon, polygonMumbai, + arbitrum, arbitrumSepolia, { name: 'LightLink Phoenix', From 00a16464466891f4357608ea88a27bd7f86ec2a0 Mon Sep 17 00:00:00 2001 From: Nicolas Mahe Date: Tue, 23 Jan 2024 14:55:27 +0700 Subject: [PATCH 06/58] add .graphqlrc.yml file --- .graphqlrc.yml | 1 + 1 file changed, 1 insertion(+) create mode 100644 .graphqlrc.yml diff --git a/.graphqlrc.yml b/.graphqlrc.yml new file mode 100644 index 00000000..6079733b --- /dev/null +++ b/.graphqlrc.yml @@ -0,0 +1 @@ +schema: './node_modules/@nft/api-graphql/schema.graphql' From 8d8647d4b3bf39c23a0b71cb81cc26576356c036 Mon Sep 17 00:00:00 2001 From: Nicolas Mahe Date: Tue, 23 Jan 2024 15:01:10 +0700 Subject: [PATCH 07/58] fix compatibility with graphql-eslint --- .eslintrc.gql.js | 4 ---- .graphqlrc.yml | 1 + 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/.eslintrc.gql.js b/.eslintrc.gql.js index ea90eb02..df2ce9bf 100644 --- a/.eslintrc.gql.js +++ b/.eslintrc.gql.js @@ -1,10 +1,6 @@ module.exports = { root: true, parser: '@graphql-eslint/eslint-plugin', - parserOptions: { - schema: 'node_modules/@nft/api-graphql/schema.graphql', - operations: '**/*.gql', - }, plugins: ['@graphql-eslint/eslint-plugin'], extends: ['plugin:@graphql-eslint/operations-recommended'], rules: { diff --git a/.graphqlrc.yml b/.graphqlrc.yml index 6079733b..67482421 100644 --- a/.graphqlrc.yml +++ b/.graphqlrc.yml @@ -1 +1,2 @@ schema: './node_modules/@nft/api-graphql/schema.graphql' +documents: '{components,pages}/**/*.{graphql,gql}' From 5882162d11b83bc80272ed59b8af6577898fe6a0 Mon Sep 17 00:00:00 2001 From: Nicolas Mahe Date: Tue, 23 Jan 2024 15:22:15 +0700 Subject: [PATCH 08/58] display deleted data in AssetHistory --- components/History/HistoryList.gql | 2 ++ 1 file changed, 2 insertions(+) diff --git a/components/History/HistoryList.gql b/components/History/HistoryList.gql index bc90533a..9497ca5e 100644 --- a/components/History/HistoryList.gql +++ b/components/History/HistoryList.gql @@ -19,6 +19,8 @@ query FetchAssetHistory( orderBy: DATE_DESC first: $limit offset: $offset + includeWhenAssetDeleted: YES + includeWhenCurrencyDeleted: YES ) { pageInfo { hasNextPage From 6c0efa2d3fc9dc5bc3b5733538e9fd906d8c54a8 Mon Sep 17 00:00:00 2001 From: Nicolas Mahe Date: Tue, 23 Jan 2024 15:24:15 +0700 Subject: [PATCH 09/58] display trades of deleted asset, collection and currency in pages users / trades / purchased and sold --- pages/users/[id]/trades/purchased.gql | 3 +++ pages/users/[id]/trades/sold.gql | 3 +++ 2 files changed, 6 insertions(+) diff --git a/pages/users/[id]/trades/purchased.gql b/pages/users/[id]/trades/purchased.gql index 74240afb..ab319cf3 100644 --- a/pages/users/[id]/trades/purchased.gql +++ b/pages/users/[id]/trades/purchased.gql @@ -9,6 +9,9 @@ query FetchUserTradePurchased( first: $limit offset: $offset filter: { buyerAddress: { equalTo: $address } } + includeWhenAssetDeleted: YES + includeWhenCollectionDeleted: YES + includeWhenCurrencyDeleted: YES ) { pageInfo { hasNextPage diff --git a/pages/users/[id]/trades/sold.gql b/pages/users/[id]/trades/sold.gql index 6db426ca..f48e924c 100644 --- a/pages/users/[id]/trades/sold.gql +++ b/pages/users/[id]/trades/sold.gql @@ -9,6 +9,9 @@ query FetchUserTradeSold( first: $limit offset: $offset filter: { sellerAddress: { equalTo: $address } } + includeWhenAssetDeleted: YES + includeWhenCollectionDeleted: YES + includeWhenCurrencyDeleted: YES ) { pageInfo { hasNextPage From 5a9daa9d06d16d33249578b1a7b00328babb6b20 Mon Sep 17 00:00:00 2001 From: Nicolas Mahe Date: Tue, 23 Jan 2024 15:36:07 +0700 Subject: [PATCH 10/58] display notifications of deleted collection and trades --- layouts/navbar.gql | 6 +++++- pages/notification.gql | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/layouts/navbar.gql b/layouts/navbar.gql index 200d4666..5612a034 100644 --- a/layouts/navbar.gql +++ b/layouts/navbar.gql @@ -3,7 +3,11 @@ query NavbarAccount($account: Address!, $lastNotification: Datetime!) { address name image - notifications(filter: { createdAt: { greaterThan: $lastNotification } }) { + notifications( + filter: { createdAt: { greaterThan: $lastNotification } } + includeWhenCollectionDeleted: YES + includeWhenTradeDeleted: YES + ) { totalCount } } diff --git a/pages/notification.gql b/pages/notification.gql index 05f7b6d5..ea45cfb3 100644 --- a/pages/notification.gql +++ b/pages/notification.gql @@ -17,6 +17,8 @@ query GetNotifications($address: Address!, $cursor: Cursor) { first: 12 orderBy: CREATED_AT_DESC after: $cursor + includeWhenCollectionDeleted: YES + includeWhenTradeDeleted: YES ) { pageInfo { hasNextPage From 587eb407faee5332264cf10d161ee2caf3c38419 Mon Sep 17 00:00:00 2001 From: Nicolas Mahe Date: Tue, 23 Jan 2024 15:38:55 +0700 Subject: [PATCH 11/58] display 404 if asset is deleted on pages tokens --- pages/tokens/[id]/bid.gql | 1 + pages/tokens/[id]/bid.tsx | 2 +- pages/tokens/[id]/index.gql | 1 + pages/tokens/[id]/index.tsx | 2 +- pages/tokens/[id]/offer.gql | 1 + pages/tokens/[id]/offer.tsx | 2 +- 6 files changed, 6 insertions(+), 3 deletions(-) diff --git a/pages/tokens/[id]/bid.gql b/pages/tokens/[id]/bid.gql index 7c57559f..079992c8 100644 --- a/pages/tokens/[id]/bid.gql +++ b/pages/tokens/[id]/bid.gql @@ -11,6 +11,7 @@ query BidOnAsset( tokenId: $tokenId ) { id + deletedAt chainId collectionAddress tokenId diff --git a/pages/tokens/[id]/bid.tsx b/pages/tokens/[id]/bid.tsx index 40ca3d0b..a32e0f14 100644 --- a/pages/tokens/[id]/bid.tsx +++ b/pages/tokens/[id]/bid.tsx @@ -52,7 +52,7 @@ const BidPage: NextPage = ({ now }) => { await push(`/tokens/${assetId}`) }, [toast, t, push, assetId]) - if (asset === null) return + if (asset === null || asset?.deletedAt) return return ( = ({ now: nowProp }) => { [refresh, refreshAsset, toast], ) - if (asset === null) return + if (asset === null || asset?.deletedAt) return return ( = ({ now }) => { await push(`/tokens/${assetId}`) }, [toast, t, push, assetId]) - if (asset === null) return + if (asset === null || asset?.deletedAt) return return ( Date: Tue, 23 Jan 2024 15:42:27 +0700 Subject: [PATCH 12/58] display 404 if collection is deleted on collection pages --- pages/collection/[chainId]/[id]/index.gql | 1 + pages/collection/[chainId]/[id]/index.tsx | 3 ++- pages/create/[chainId]/[collectionAddress].gql | 1 + pages/create/[chainId]/[collectionAddress].tsx | 3 ++- 4 files changed, 6 insertions(+), 2 deletions(-) diff --git a/pages/collection/[chainId]/[id]/index.gql b/pages/collection/[chainId]/[id]/index.gql index 02374262..ed1ef3dd 100644 --- a/pages/collection/[chainId]/[id]/index.gql +++ b/pages/collection/[chainId]/[id]/index.gql @@ -2,6 +2,7 @@ query FetchCollectionDetails($collectionAddress: Address!, $chainId: Int!) { collection(address: $collectionAddress, chainId: $chainId) { address chainId + deletedAt cover image name diff --git a/pages/collection/[chainId]/[id]/index.tsx b/pages/collection/[chainId]/[id]/index.tsx index 5f846722..d1ca0e6b 100644 --- a/pages/collection/[chainId]/[id]/index.tsx +++ b/pages/collection/[chainId]/[id]/index.tsx @@ -148,7 +148,8 @@ const CollectionPage: FC = ({ now }) => { const { changeLimit } = usePaginate() - if (collection === null) return + if (collection === null || collection?.deletedAt) + return return ( { [push, t, toast], ) - if (collection === null) return + if (collection === null || collection?.deletedAt) + return return ( Date: Tue, 23 Jan 2024 15:47:15 +0700 Subject: [PATCH 13/58] display 404 if asset or currency is deleted on checkout page --- pages/checkout/[id].gql | 2 ++ pages/checkout/[id].tsx | 7 ++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/pages/checkout/[id].gql b/pages/checkout/[id].gql index fbbb4baf..39ca76b5 100644 --- a/pages/checkout/[id].gql +++ b/pages/checkout/[id].gql @@ -22,6 +22,7 @@ query Checkout($id: UUID!) { id decimals symbol + deletedAt } } } @@ -39,6 +40,7 @@ query FetchAssetForCheckout( tokenId: $tokenId ) { id + deletedAt chainId collectionAddress tokenId diff --git a/pages/checkout/[id].tsx b/pages/checkout/[id].tsx index 92b6fb7d..aa4ac106 100644 --- a/pages/checkout/[id].tsx +++ b/pages/checkout/[id].tsx @@ -74,7 +74,12 @@ const CheckoutPage: NextPage = ({ now }) => { await push(`/tokens/${asset.id}`) }, [asset, toast, t, push]) - if (offer === null || asset === null) { + if ( + offer === null || + asset === null || + asset?.deletedAt || + offer?.currency.deletedAt + ) { return } return ( From 3c2e34c6827a7e2e524057f1549ed717a3cd485f Mon Sep 17 00:00:00 2001 From: Nicolas Mahe Date: Tue, 23 Jan 2024 16:01:13 +0700 Subject: [PATCH 14/58] disable links and button on users pages --- pages/users/[id]/bids/placed.gql | 3 ++ pages/users/[id]/bids/placed.tsx | 12 +++++-- pages/users/[id]/bids/received.gql | 4 +++ pages/users/[id]/bids/received.tsx | 46 +++++++++++++++------------ pages/users/[id]/offers.gql | 4 +++ pages/users/[id]/offers.tsx | 10 ++++-- pages/users/[id]/trades/purchased.gql | 1 + pages/users/[id]/trades/purchased.tsx | 6 +++- pages/users/[id]/trades/sold.gql | 1 + pages/users/[id]/trades/sold.tsx | 6 +++- 10 files changed, 67 insertions(+), 26 deletions(-) diff --git a/pages/users/[id]/bids/placed.gql b/pages/users/[id]/bids/placed.gql index 65e96561..c9e7052d 100644 --- a/pages/users/[id]/bids/placed.gql +++ b/pages/users/[id]/bids/placed.gql @@ -14,6 +14,8 @@ query FetchUserBidsPlaced( signature: { isNull: false } makerAddress: { equalTo: $address } } + includeWhenAssetDeleted: YES + includeWhenCurrencyDeleted: YES ) { pageInfo { hasNextPage @@ -49,6 +51,7 @@ query FetchUserBidsPlaced( name image imageMimetype + deletedAt } } } diff --git a/pages/users/[id]/bids/placed.tsx b/pages/users/[id]/bids/placed.tsx index 8a27b0e2..a4710481 100644 --- a/pages/users/[id]/bids/placed.tsx +++ b/pages/users/[id]/bids/placed.tsx @@ -163,7 +163,11 @@ const BidPlacedPage: NextPage = () => { { ) : ( + !item.asset.deletedAt && ( // only display new button if asset is not deleted + + ) )} )} From f093b67a86b9ce6fec012ec07a22f96b23e4ae77 Mon Sep 17 00:00:00 2001 From: Nicolas Mahe Date: Wed, 24 Jan 2024 08:50:12 +0700 Subject: [PATCH 18/58] Update .graphqlrc.yml Co-authored-by: ismail Toyran <33982052+ismailToyran@users.noreply.github.com> --- .graphqlrc.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.graphqlrc.yml b/.graphqlrc.yml index 67482421..f04bf4a7 100644 --- a/.graphqlrc.yml +++ b/.graphqlrc.yml @@ -1,2 +1,2 @@ schema: './node_modules/@nft/api-graphql/schema.graphql' -documents: '{components,pages}/**/*.{graphql,gql}' +documents: '{components,hooks,pages}/**/*.{graphql,gql}' From 3503f1019df8cb5ebe27efe49aa1a723a866b910 Mon Sep 17 00:00:00 2001 From: Nicolas Mahe Date: Wed, 24 Jan 2024 09:38:25 +0700 Subject: [PATCH 19/58] properly disable link when asset is deleted --- pages/users/[id]/bids/placed.tsx | 7 +++---- pages/users/[id]/bids/received.tsx | 7 +++---- pages/users/[id]/offers.tsx | 7 +++---- pages/users/[id]/trades/purchased.tsx | 7 +++---- pages/users/[id]/trades/sold.tsx | 7 +++---- 5 files changed, 15 insertions(+), 20 deletions(-) diff --git a/pages/users/[id]/bids/placed.tsx b/pages/users/[id]/bids/placed.tsx index 5c22a606..540888bb 100644 --- a/pages/users/[id]/bids/placed.tsx +++ b/pages/users/[id]/bids/placed.tsx @@ -163,10 +163,9 @@ const BidPlacedPage: NextPage = () => { diff --git a/pages/users/[id]/bids/received.tsx b/pages/users/[id]/bids/received.tsx index 3076968c..4fa0a910 100644 --- a/pages/users/[id]/bids/received.tsx +++ b/pages/users/[id]/bids/received.tsx @@ -172,10 +172,9 @@ const BidReceivedPage: NextPage = ({ now }) => { diff --git a/pages/users/[id]/offers.tsx b/pages/users/[id]/offers.tsx index 9199917b..e90da259 100644 --- a/pages/users/[id]/offers.tsx +++ b/pages/users/[id]/offers.tsx @@ -134,10 +134,9 @@ const FixedPricePage: NextPage = () => { diff --git a/pages/users/[id]/trades/purchased.tsx b/pages/users/[id]/trades/purchased.tsx index b3d9d1bc..658d45c7 100644 --- a/pages/users/[id]/trades/purchased.tsx +++ b/pages/users/[id]/trades/purchased.tsx @@ -173,10 +173,9 @@ const TradePurchasedPage: NextPage = () => { {item.asset ? ( diff --git a/pages/users/[id]/trades/sold.tsx b/pages/users/[id]/trades/sold.tsx index b61a095d..3a13cfbc 100644 --- a/pages/users/[id]/trades/sold.tsx +++ b/pages/users/[id]/trades/sold.tsx @@ -165,10 +165,9 @@ const TradeSoldPage: NextPage = () => { {item.asset ? ( From 489099099f83065a37d4a824ac83af46b98d95ba Mon Sep 17 00:00:00 2001 From: Nicolas Mahe Date: Wed, 24 Jan 2024 10:45:42 +0700 Subject: [PATCH 20/58] fix lint --- environment.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/environment.ts b/environment.ts index 32a90cca..46dc51a9 100644 --- a/environment.ts +++ b/environment.ts @@ -3,6 +3,8 @@ import { LRUCache } from 'lru-cache' import { createContext } from 'react' import invariant from 'ts-invariant' import { + arbitrum, + arbitrumSepolia, bsc, bscTestnet, Chain, @@ -10,8 +12,6 @@ import { mainnet as ethereumMainnet, polygon, polygonMumbai, - arbitrum, - arbitrumSepolia, } from 'wagmi/chains' type RemoteConfig = { From 45afb3798eee078bc83281004aa27b4be56c721e Mon Sep 17 00:00:00 2001 From: Nicolas Mahe Date: Wed, 24 Jan 2024 14:50:19 +0700 Subject: [PATCH 21/58] use neon chain config from wagmi --- environment.ts | 66 +++----------------------------------------------- 1 file changed, 4 insertions(+), 62 deletions(-) diff --git a/environment.ts b/environment.ts index b108b806..fbbb27e5 100644 --- a/environment.ts +++ b/environment.ts @@ -8,6 +8,8 @@ import { Chain, goerli as ethereumGoerli, mainnet as ethereumMainnet, + neonDevnet, + neonMainnet, polygon, polygonMumbai, } from 'wagmi/chains' @@ -199,6 +201,8 @@ const getEnvironment = async (): Promise => { bsc, polygon, polygonMumbai, + neonMainnet, + neonDevnet, { name: 'LightLink Phoenix', network: 'lightlink-phoenix', @@ -260,68 +264,6 @@ const getEnvironment = async (): Promise => { }, }, }, - { - id: 245022934, - network: 'neonMainnet', - name: 'Neon EVM MainNet', - nativeCurrency: { - name: 'NEON', - symbol: 'NEON', - decimals: 18, - }, - rpcUrls: { - default: { - http: ['https://neon-proxy-mainnet.solana.p2p.org'], - }, - public: { - http: ['https://neon-proxy-mainnet.solana.p2p.org'], - }, - }, - blockExplorers: { - default: { - name: 'Neonscan', - url: 'https://neonscan.org', - }, - }, - contracts: { - multicall3: { - address: '0xca11bde05977b3631167028862be2a173976ca11', - blockCreated: 206545524, - }, - }, - testnet: false, - }, - { - id: 245022926, - network: 'neonDevnet', - name: 'Neon EVM DevNet', - nativeCurrency: { - name: 'NEON', - symbol: 'NEON', - decimals: 18, - }, - rpcUrls: { - default: { - http: ['https://devnet.neonevm.org'], - }, - public: { - http: ['https://devnet.neonevm.org'], - }, - }, - blockExplorers: { - default: { - name: 'Neonscan', - url: 'https://devnet.neonscan.org', - }, - }, - contracts: { - multicall3: { - address: '0xca11bde05977b3631167028862be2a173976ca11', - blockCreated: 205206112, - }, - }, - testnet: true, - }, ], WALLET_CONNECT_PROJECT_ID: process.env.NEXT_PUBLIC_WALLET_CONNECT_PROJECT_ID, From 4ed1956af2084f246df46328fc3334b6258e45ba Mon Sep 17 00:00:00 2001 From: Nicolas Mahe Date: Wed, 24 Jan 2024 14:52:36 +0700 Subject: [PATCH 22/58] add neon evm icons --- public/chains/245022926.svg | 3 +++ public/chains/245022934.svg | 3 +++ 2 files changed, 6 insertions(+) create mode 100644 public/chains/245022926.svg create mode 100644 public/chains/245022934.svg diff --git a/public/chains/245022926.svg b/public/chains/245022926.svg new file mode 100644 index 00000000..6eb40c4f --- /dev/null +++ b/public/chains/245022926.svg @@ -0,0 +1,3 @@ + + + diff --git a/public/chains/245022934.svg b/public/chains/245022934.svg new file mode 100644 index 00000000..79d5bfca --- /dev/null +++ b/public/chains/245022934.svg @@ -0,0 +1,3 @@ + + + From f4512002078860ff67ea073a82d654f4110ae4ad Mon Sep 17 00:00:00 2001 From: Nicolas Mahe Date: Wed, 24 Jan 2024 14:57:23 +0700 Subject: [PATCH 23/58] add arbitrum icon --- public/chains/42161.svg | 38 ++++++++++++++++++++++++++++++++++++++ public/chains/421614.svg | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 76 insertions(+) create mode 100644 public/chains/42161.svg create mode 100644 public/chains/421614.svg diff --git a/public/chains/42161.svg b/public/chains/42161.svg new file mode 100644 index 00000000..dd17407f --- /dev/null +++ b/public/chains/42161.svg @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/public/chains/421614.svg b/public/chains/421614.svg new file mode 100644 index 00000000..dd17407f --- /dev/null +++ b/public/chains/421614.svg @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 4207b88b2b43fc3eea62829a01054684422c895e Mon Sep 17 00:00:00 2001 From: Nicolas Mahe Date: Wed, 24 Jan 2024 16:00:24 +0700 Subject: [PATCH 24/58] replace pointerEvents with a new condition param on Link component --- components/Link/Link.tsx | 6 ++++-- pages/users/[id]/bids/placed.tsx | 4 +--- pages/users/[id]/bids/received.tsx | 4 +--- pages/users/[id]/offers.tsx | 4 +--- pages/users/[id]/trades/purchased.tsx | 4 +--- pages/users/[id]/trades/sold.tsx | 4 +--- 6 files changed, 9 insertions(+), 17 deletions(-) diff --git a/components/Link/Link.tsx b/components/Link/Link.tsx index 1ccd2fdf..4c8dab56 100644 --- a/components/Link/Link.tsx +++ b/components/Link/Link.tsx @@ -1,4 +1,4 @@ -import { Link as ChakraLink, Flex, LinkProps } from '@chakra-ui/react' +import { Box, Link as ChakraLink, Flex, LinkProps } from '@chakra-ui/react' import { HiOutlineExternalLink } from '@react-icons/all-files/hi/HiOutlineExternalLink' import NextLink, { LinkProps as NextLinkProps } from 'next/link' import { forwardRef } from 'react' @@ -6,13 +6,15 @@ import { forwardRef } from 'react' type IProps = Omit & Omit & { externalIcon?: boolean + condition?: boolean } & ( | { isExternal: true; href: LinkProps['href'] } | { isExternal?: false; href: NextLinkProps['href'] } ) const Link = forwardRef(function Link(props, ref) { - const { children, href, isExternal, externalIcon, ...rest } = props + const { children, href, isExternal, externalIcon, condition, ...rest } = props + if (condition === false) return {children} if (isExternal) { return ( { = ({ now }) => { { { { Date: Wed, 24 Jan 2024 16:04:55 +0700 Subject: [PATCH 25/58] display only trades related to offers in pages users / trades --- pages/users/[id]/trades/purchased.gql | 2 +- pages/users/[id]/trades/sold.gql | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pages/users/[id]/trades/purchased.gql b/pages/users/[id]/trades/purchased.gql index b19ee759..379f57a1 100644 --- a/pages/users/[id]/trades/purchased.gql +++ b/pages/users/[id]/trades/purchased.gql @@ -8,7 +8,7 @@ query FetchUserTradePurchased( orderBy: $orderBy first: $limit offset: $offset - filter: { buyerAddress: { equalTo: $address } } + filter: { buyerAddress: { equalTo: $address }, offerExists: true } includeWhenAssetDeleted: YES includeWhenCollectionDeleted: YES includeWhenCurrencyDeleted: YES diff --git a/pages/users/[id]/trades/sold.gql b/pages/users/[id]/trades/sold.gql index 3de1258f..393e10d3 100644 --- a/pages/users/[id]/trades/sold.gql +++ b/pages/users/[id]/trades/sold.gql @@ -8,7 +8,7 @@ query FetchUserTradeSold( orderBy: $orderBy first: $limit offset: $offset - filter: { sellerAddress: { equalTo: $address } } + filter: { sellerAddress: { equalTo: $address }, offerExists: true } includeWhenAssetDeleted: YES includeWhenCollectionDeleted: YES includeWhenCurrencyDeleted: YES From ae0e0fddd4f8152094cd29e42b797e40d3ee4c63 Mon Sep 17 00:00:00 2001 From: Nicolas Mahe Date: Thu, 25 Jan 2024 14:39:49 +0700 Subject: [PATCH 26/58] update nft libs to latest --- package-lock.json | 28 ++++++++++++++-------------- package.json | 4 ++-- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/package-lock.json b/package-lock.json index 87693320..9abe47f6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -20,7 +20,7 @@ "@magiclabs/wagmi-connector": "^1.1.5", "@metamask/jazzicon": "^2.0.0", "@nft/chat": "^0.2.0", - "@nft/webhook": "^1.0.0-beta.49", + "@nft/webhook": "^1.0.0-beta.51", "@rainbow-me/rainbowkit": "^1.3.3", "@react-icons/all-files": "^4.1.0", "@uiw/react-markdown-preview": "^5.0.7", @@ -55,7 +55,7 @@ "@graphql-codegen/typescript-react-apollo": "^4.1.0", "@graphql-eslint/eslint-plugin": "^3.20.1", "@next/bundle-analyzer": "^14.0.4", - "@nft/api-graphql": "^1.0.0-beta.49", + "@nft/api-graphql": "^1.0.0-beta.51", "@types/nodemailer": "^6.4.14", "@types/nprogress": "^0.2.3", "@types/react": "^18.2.48", @@ -6724,9 +6724,9 @@ } }, "node_modules/@nft/api-graphql": { - "version": "1.0.0-beta.49", - "resolved": "https://registry.npmjs.org/@nft/api-graphql/-/api-graphql-1.0.0-beta.49.tgz", - "integrity": "sha512-WXvaU3HcHjD0hS2PZnKOcn5SMQtbzByAXbbo4k9VpXGzOe0ZIfmKDG4SGszBoASka7OTezQUqpQzY6eAXoQvnA==", + "version": "1.0.0-beta.51", + "resolved": "https://registry.npmjs.org/@nft/api-graphql/-/api-graphql-1.0.0-beta.51.tgz", + "integrity": "sha512-IBpOGh0Xmu6CFQZqYTwVAahut/WiphjcsDT82td8xSpmwsE0AADIxZ97OP4cclDGBVVhX7bSvsQFge5HxCzxyA==", "dev": true }, "node_modules/@nft/chat": { @@ -6753,9 +6753,9 @@ } }, "node_modules/@nft/webhook": { - "version": "1.0.0-beta.49", - "resolved": "https://registry.npmjs.org/@nft/webhook/-/webhook-1.0.0-beta.49.tgz", - "integrity": "sha512-aoc4OZ1oWZ2Nc/k95cBuX9kgvIwaWSjAYOAatZB/dTVvjdz/VEoa54VLhi9XQR5lZfpbMbFOeXnGxR1BIWf82Q==", + "version": "1.0.0-beta.51", + "resolved": "https://registry.npmjs.org/@nft/webhook/-/webhook-1.0.0-beta.51.tgz", + "integrity": "sha512-gX9Rj+wBga2uGQ6yfY3ZcHu0dh5VSVMcfUcfZg5ObkeupJSvLBB7R42dY4DKz0CzfQVMtNnsu1J03gnmE8VCMQ==", "dependencies": { "raw-body": "^2.5.1", "ts-invariant": "^0.9.4" @@ -26699,9 +26699,9 @@ "optional": true }, "@nft/api-graphql": { - "version": "1.0.0-beta.49", - "resolved": "https://registry.npmjs.org/@nft/api-graphql/-/api-graphql-1.0.0-beta.49.tgz", - "integrity": "sha512-WXvaU3HcHjD0hS2PZnKOcn5SMQtbzByAXbbo4k9VpXGzOe0ZIfmKDG4SGszBoASka7OTezQUqpQzY6eAXoQvnA==", + "version": "1.0.0-beta.51", + "resolved": "https://registry.npmjs.org/@nft/api-graphql/-/api-graphql-1.0.0-beta.51.tgz", + "integrity": "sha512-IBpOGh0Xmu6CFQZqYTwVAahut/WiphjcsDT82td8xSpmwsE0AADIxZ97OP4cclDGBVVhX7bSvsQFge5HxCzxyA==", "dev": true }, "@nft/chat": { @@ -26724,9 +26724,9 @@ } }, "@nft/webhook": { - "version": "1.0.0-beta.49", - "resolved": "https://registry.npmjs.org/@nft/webhook/-/webhook-1.0.0-beta.49.tgz", - "integrity": "sha512-aoc4OZ1oWZ2Nc/k95cBuX9kgvIwaWSjAYOAatZB/dTVvjdz/VEoa54VLhi9XQR5lZfpbMbFOeXnGxR1BIWf82Q==", + "version": "1.0.0-beta.51", + "resolved": "https://registry.npmjs.org/@nft/webhook/-/webhook-1.0.0-beta.51.tgz", + "integrity": "sha512-gX9Rj+wBga2uGQ6yfY3ZcHu0dh5VSVMcfUcfZg5ObkeupJSvLBB7R42dY4DKz0CzfQVMtNnsu1J03gnmE8VCMQ==", "requires": { "raw-body": "^2.5.1", "ts-invariant": "^0.9.4" diff --git a/package.json b/package.json index f023de59..f4718778 100644 --- a/package.json +++ b/package.json @@ -28,7 +28,7 @@ "@magiclabs/wagmi-connector": "^1.1.5", "@metamask/jazzicon": "^2.0.0", "@nft/chat": "^0.2.0", - "@nft/webhook": "^1.0.0-beta.49", + "@nft/webhook": "^1.0.0-beta.51", "@rainbow-me/rainbowkit": "^1.3.3", "@react-icons/all-files": "^4.1.0", "@uiw/react-markdown-preview": "^5.0.7", @@ -63,7 +63,7 @@ "@graphql-codegen/typescript-react-apollo": "^4.1.0", "@graphql-eslint/eslint-plugin": "^3.20.1", "@next/bundle-analyzer": "^14.0.4", - "@nft/api-graphql": "^1.0.0-beta.49", + "@nft/api-graphql": "^1.0.0-beta.51", "@types/nodemailer": "^6.4.14", "@types/nprogress": "^0.2.3", "@types/react": "^18.2.48", From e3a891b1326a373a22f7c06473146b9a23e265e5 Mon Sep 17 00:00:00 2001 From: Nicolas Mahe Date: Thu, 25 Jan 2024 14:40:11 +0700 Subject: [PATCH 27/58] update filters in users / trades pages --- pages/users/[id]/trades/purchased.gql | 8 +++++++- pages/users/[id]/trades/sold.gql | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/pages/users/[id]/trades/purchased.gql b/pages/users/[id]/trades/purchased.gql index 379f57a1..c8cb4fe6 100644 --- a/pages/users/[id]/trades/purchased.gql +++ b/pages/users/[id]/trades/purchased.gql @@ -8,7 +8,13 @@ query FetchUserTradePurchased( orderBy: $orderBy first: $limit offset: $offset - filter: { buyerAddress: { equalTo: $address }, offerExists: true } + filter: { + buyerAddress: { equalTo: $address } + or: [ + { deletedAt: { isNull: true } } # include trades not deleted + { deletedAt: { isNull: false }, offerExists: true } # include trades deleted but related to an offer + ] + } includeWhenAssetDeleted: YES includeWhenCollectionDeleted: YES includeWhenCurrencyDeleted: YES diff --git a/pages/users/[id]/trades/sold.gql b/pages/users/[id]/trades/sold.gql index 393e10d3..4752327b 100644 --- a/pages/users/[id]/trades/sold.gql +++ b/pages/users/[id]/trades/sold.gql @@ -8,7 +8,13 @@ query FetchUserTradeSold( orderBy: $orderBy first: $limit offset: $offset - filter: { sellerAddress: { equalTo: $address }, offerExists: true } + filter: { + sellerAddress: { equalTo: $address } + or: [ + { deletedAt: { isNull: true } } # include trades not deleted + { deletedAt: { isNull: false }, offerExists: true } # include trades deleted but related to an offer + ] + } includeWhenAssetDeleted: YES includeWhenCollectionDeleted: YES includeWhenCurrencyDeleted: YES From 99284a185978736448d089fb8909d68f3117fcc6 Mon Sep 17 00:00:00 2001 From: ismailToyran Date: Fri, 26 Jan 2024 13:14:04 +0300 Subject: [PATCH 28/58] Feature / Homepage banners added --- components/HomeSection/Banner.tsx | 63 +++++++++++++++++++++++++++++++ components/MarkdownViewer.tsx | 9 ++++- environment.ts | 39 +++++++++++++++++++ pages/index.tsx | 2 + 4 files changed, 111 insertions(+), 2 deletions(-) create mode 100644 components/HomeSection/Banner.tsx diff --git a/components/HomeSection/Banner.tsx b/components/HomeSection/Banner.tsx new file mode 100644 index 00000000..4ca0c589 --- /dev/null +++ b/components/HomeSection/Banner.tsx @@ -0,0 +1,63 @@ +import { Box, Button, Flex, Heading, VStack } from '@chakra-ui/react' +import Link from '../../components/Link/Link' +import MarkdownViewer from '../../components/MarkdownViewer' +import useEnvironment from '../../hooks/useEnvironment' +import Image from '../Image/Image' +import Slider from '../Slider/Slider' + +const BannerHomeSection = () => { + const { HOME_BANNERS } = useEnvironment() + + if (HOME_BANNERS.length === 0) return null + return ( + 1 ? Slider : 'div'}> + {HOME_BANNERS.map((banner) => ( + + {banner.title} + + + {banner.title} + {banner.content && ( + + + + )} + + {banner.button && ( + + )} + + + ))} + + ) +} + +export default BannerHomeSection diff --git a/components/MarkdownViewer.tsx b/components/MarkdownViewer.tsx index 011f16f3..a78ad200 100644 --- a/components/MarkdownViewer.tsx +++ b/components/MarkdownViewer.tsx @@ -22,7 +22,11 @@ const MDPreview = dynamic( }, ) -const MarkdownViewer: FC = ({ source, ...props }) => { +const MarkdownViewer: FC = ({ + noTruncate, + source, + ...props +}) => { const { t } = useTranslation('components') const { colorMode } = useColorMode() const [isMultiline, setMultiline] = useState(false) @@ -30,6 +34,7 @@ const MarkdownViewer: FC = ({ source, ...props }) => { const invisibleRef = useRef(null) useEffect(() => { + if (noTruncate) return setOpen(true) const element = invisibleRef.current const ONE_LINE_HEIGHT = 24 if ( @@ -40,7 +45,7 @@ const MarkdownViewer: FC = ({ source, ...props }) => { ) { setMultiline(true) } - }, [source]) + }, [noTruncate, source]) return ( diff --git a/environment.ts b/environment.ts index af27992f..354607cb 100644 --- a/environment.ts +++ b/environment.ts @@ -24,6 +24,17 @@ type RemoteConfig = { FAVICON: string BRAND_COLOR: string + HOME_BANNERS: { + image: string + title: string + content?: string + textColor?: string + button: { + text: string + href: string + isExternal?: boolean + } + }[] FEATURED_TOKEN: string[] HOME_COLLECTIONS: string[] HOME_USERS: string[] @@ -95,6 +106,33 @@ export type Environment = { * Home page configuration */ + // List of banners to be displayed on the homepage + HOME_BANNERS: { + // URL of the image to display + image: string + + // Title of the banner + title: string + + // (Optional) Content of the banner + content?: string + + // (Optional) Text color of the banner + textColor?: string + + // Button to display on the banner + button: { + // Text of the button + text: string + + // URL to redirect to when the button is clicked + href: string + + // (Optional) Whether the URL is external or not (default: false) + isExternal?: boolean + } + }[] + // Ordered list of tokens to be highlighted on the homepage with the following format: [chainId]-[contractAddress]-[tokenId] FEATURED_TOKEN: string[] @@ -266,6 +304,7 @@ const getEnvironment = async (): Promise => { MAGIC_API_KEY: process.env.NEXT_PUBLIC_MAGIC_API_KEY, ALCHEMY_API_KEY: process.env.NEXT_PUBLIC_ALCHEMY_API_KEY, // Home page configuration + HOME_BANNERS: metadata.HOME_BANNERS || [], FEATURED_TOKEN: metadata.FEATURED_TOKEN || [], HOME_COLLECTIONS: metadata.HOME_COLLECTIONS || [], HOME_USERS: metadata.HOME_USERS || [], diff --git a/pages/index.tsx b/pages/index.tsx index 91bbd094..c7f0f446 100644 --- a/pages/index.tsx +++ b/pages/index.tsx @@ -1,5 +1,6 @@ import { Stack } from '@chakra-ui/react' import AssetsHomeSection from 'components/HomeSection/Assets' +import BannerHomeSection from 'components/HomeSection/Banner' import CollectionsHomeSection from 'components/HomeSection/Collections' import FeaturedHomeSection from 'components/HomeSection/Featured' import ResourcesHomeSection from 'components/HomeSection/Resources' @@ -21,6 +22,7 @@ const HomePage: NextPage = ({ now }) => { + From e5e7fcef8049556fa098395ccde86b3006fb9b28 Mon Sep 17 00:00:00 2001 From: ismailToyran Date: Tue, 30 Jan 2024 19:20:47 +0300 Subject: [PATCH 29/58] Add bg and priority to image --- components/HomeSection/Banner.tsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/components/HomeSection/Banner.tsx b/components/HomeSection/Banner.tsx index 4ca0c589..e2938408 100644 --- a/components/HomeSection/Banner.tsx +++ b/components/HomeSection/Banner.tsx @@ -18,6 +18,7 @@ const BannerHomeSection = () => { alignItems="center" h="500px" flex="0 0 100%" + bg="gray.100" > { fill sizes="(min-width: 80em) 1216px, 100vw" objectFit="cover" + priority /> Date: Tue, 30 Jan 2024 20:10:36 +0300 Subject: [PATCH 30/58] Add maker address to gql queries --- components/HomeSection/Assets.gql | 3 +++ pages/checkout/[id].gql | 3 +++ pages/collection/[chainId]/[id]/index.gql | 3 +++ pages/explore/explore.gql | 3 +++ pages/tokens/[id]/bid.gql | 3 +++ pages/tokens/[id]/offer.gql | 3 +++ 6 files changed, 18 insertions(+) diff --git a/components/HomeSection/Assets.gql b/components/HomeSection/Assets.gql index f1f99f4b..91dd237f 100644 --- a/components/HomeSection/Assets.gql +++ b/components/HomeSection/Assets.gql @@ -83,6 +83,9 @@ query FetchAssets( decimals symbol } + maker { + address + } } } } diff --git a/pages/checkout/[id].gql b/pages/checkout/[id].gql index 2f8bb361..0665fa36 100644 --- a/pages/checkout/[id].gql +++ b/pages/checkout/[id].gql @@ -63,6 +63,9 @@ query Checkout($id: UUID!, $address: Address, $now: Datetime!) { decimals symbol } + maker { + address + } } } } diff --git a/pages/collection/[chainId]/[id]/index.gql b/pages/collection/[chainId]/[id]/index.gql index ed1ef3dd..c5cc3e2c 100644 --- a/pages/collection/[chainId]/[id]/index.gql +++ b/pages/collection/[chainId]/[id]/index.gql @@ -136,6 +136,9 @@ query FetchCollectionAssets( decimals symbol } + maker { + address + } } } } diff --git a/pages/explore/explore.gql b/pages/explore/explore.gql index 891322c7..570b68ff 100644 --- a/pages/explore/explore.gql +++ b/pages/explore/explore.gql @@ -68,6 +68,9 @@ query FetchAllERC721And1155( decimals symbol } + maker { + address + } } } creator { diff --git a/pages/tokens/[id]/bid.gql b/pages/tokens/[id]/bid.gql index 079992c8..633db930 100644 --- a/pages/tokens/[id]/bid.gql +++ b/pages/tokens/[id]/bid.gql @@ -70,6 +70,9 @@ query BidOnAsset( decimals symbol } + maker { + address + } } } ownerships(first: 1) { diff --git a/pages/tokens/[id]/offer.gql b/pages/tokens/[id]/offer.gql index f2af14da..5806d4e9 100644 --- a/pages/tokens/[id]/offer.gql +++ b/pages/tokens/[id]/offer.gql @@ -65,6 +65,9 @@ query OfferForAsset( decimals symbol } + maker { + address + } } } creator { From a4f2979c26187a2c51519f04e56dbc950f0c8b9a Mon Sep 17 00:00:00 2001 From: ismailToyran Date: Tue, 30 Jan 2024 20:11:03 +0300 Subject: [PATCH 31/58] Refactor CardFooter and Card components for fixedPrice sale --- components/Sales/Direct/CardFooter.tsx | 16 +++++++++++++--- components/Token/Card.tsx | 4 +++- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/components/Sales/Direct/CardFooter.tsx b/components/Sales/Direct/CardFooter.tsx index de10bc27..dfd7f07f 100644 --- a/components/Sales/Direct/CardFooter.tsx +++ b/components/Sales/Direct/CardFooter.tsx @@ -1,6 +1,8 @@ import { Divider, Flex, HStack, Text } from '@chakra-ui/react' import useTranslation from 'next-translate/useTranslation' import { FC, useMemo } from 'react' +import useAccount from '../../../hooks/useAccount' +import { isSameAddress } from '../../../utils' import AddToCartButton from '../../Button/AddToCart' import Link from '../../Link/Link' import Price from '../../Price/Price' @@ -13,10 +15,12 @@ type Props = { decimals: number symbol: string } + maker: { + address: string + } } numberOfSales: number hasMultiCurrency: boolean - isOwner: boolean showButton?: boolean } @@ -24,10 +28,16 @@ const SaleDirectCardFooter: FC = ({ sale, numberOfSales, hasMultiCurrency, - isOwner, showButton = true, }) => { const { t } = useTranslation('components') + const { address } = useAccount() + + const isOwner = useMemo( + () => (address ? isSameAddress(sale.maker.address, address) : false), + [address, sale.maker], + ) + const chip = useMemo(() => { switch (numberOfSales) { case 0: @@ -94,7 +104,7 @@ const SaleDirectCardFooter: FC = ({ : chip} - {showButton && ( + {showButton && address && ( <> = ({ asset }) => { sale={sale} numberOfSales={numberOfSales} hasMultiCurrency={hasMultiCurrency} - isOwner={isOwner} showButton={isHovered} /> ) From 3c0001aebdcbcbb5907e52f7c34c3ccebb00364d Mon Sep 17 00:00:00 2001 From: ismailToyran Date: Tue, 30 Jan 2024 20:16:45 +0300 Subject: [PATCH 32/58] Fix missing query --- pages/users/[id]/assetDetail.gql | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pages/users/[id]/assetDetail.gql b/pages/users/[id]/assetDetail.gql index 2061f65a..cda3dd4a 100644 --- a/pages/users/[id]/assetDetail.gql +++ b/pages/users/[id]/assetDetail.gql @@ -48,6 +48,9 @@ fragment AssetDetail on Asset { decimals symbol } + maker { + address + } } } creator { From 67fe1c8827a24661ef7afb7371fd7f62522898fd Mon Sep 17 00:00:00 2001 From: ismailToyran Date: Tue, 30 Jan 2024 20:19:22 +0300 Subject: [PATCH 33/58] Add comment --- components/Sales/Direct/CardFooter.tsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/components/Sales/Direct/CardFooter.tsx b/components/Sales/Direct/CardFooter.tsx index dfd7f07f..f523d7ed 100644 --- a/components/Sales/Direct/CardFooter.tsx +++ b/components/Sales/Direct/CardFooter.tsx @@ -33,6 +33,8 @@ const SaleDirectCardFooter: FC = ({ const { t } = useTranslation('components') const { address } = useAccount() + // TODO: we should have a modal if there is more than one sale like we have on detail page + // issue is tracked on https://github.com/liteflow-labs/starter-kit/issues/529 for this modal improvement const isOwner = useMemo( () => (address ? isSameAddress(sale.maker.address, address) : false), [address, sale.maker], From 926b6424c32d018fdc71e3a20eefd33324543bc5 Mon Sep 17 00:00:00 2001 From: ismailToyran Date: Wed, 31 Jan 2024 10:44:57 +0300 Subject: [PATCH 34/58] Refactor conditional statement in Banner.tsx --- components/HomeSection/Banner.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/HomeSection/Banner.tsx b/components/HomeSection/Banner.tsx index e2938408..d0382741 100644 --- a/components/HomeSection/Banner.tsx +++ b/components/HomeSection/Banner.tsx @@ -8,7 +8,7 @@ import Slider from '../Slider/Slider' const BannerHomeSection = () => { const { HOME_BANNERS } = useEnvironment() - if (HOME_BANNERS.length === 0) return null + if (!HOME_BANNERS.length) return null return ( 1 ? Slider : 'div'}> {HOME_BANNERS.map((banner) => ( From a5118c9ca3e032866cb460673242f116b98e985a Mon Sep 17 00:00:00 2001 From: ismailToyran Date: Wed, 31 Jan 2024 10:47:14 +0300 Subject: [PATCH 35/58] Refactor conditional statement in Banner.tsx --- components/HomeSection/Banner.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/HomeSection/Banner.tsx b/components/HomeSection/Banner.tsx index d0382741..f9e202f2 100644 --- a/components/HomeSection/Banner.tsx +++ b/components/HomeSection/Banner.tsx @@ -8,7 +8,7 @@ import Slider from '../Slider/Slider' const BannerHomeSection = () => { const { HOME_BANNERS } = useEnvironment() - if (!HOME_BANNERS.length) return null + if (!HOME_BANNERS.length || HOME_BANNERS.length === 0) return null return ( 1 ? Slider : 'div'}> {HOME_BANNERS.map((banner) => ( From fae99ac90a12d179295ac7f7159f245c1b6db884 Mon Sep 17 00:00:00 2001 From: ismailToyran Date: Wed, 31 Jan 2024 11:24:58 +0300 Subject: [PATCH 36/58] Fix / Cart approve button text --- components/Cart/Step/Transaction.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/Cart/Step/Transaction.tsx b/components/Cart/Step/Transaction.tsx index a31cdad0..b3cdf163 100644 --- a/components/Cart/Step/Transaction.tsx +++ b/components/Cart/Step/Transaction.tsx @@ -32,7 +32,7 @@ import useSigner from '../../../hooks/useSigner' import ConnectButtonWithNetworkSwitch from '../../Button/ConnectWithNetworkSwitch' import List, { ListItem } from '../../List/List' import BatchPurchaseModal from '../../Modal/BatchPurchase' -import Price, { formatPrice } from '../../Price/Price' +import Price from '../../Price/Price' import CartItemSummary from '../ItemSummary' type Props = { @@ -190,7 +190,7 @@ const CartStepTransaction: FC = ({ isLoading={approvalLoading[item.currency.id] || false} > {t('cart.step.transaction.button.approve', { - value: formatPrice(item.amount, item.currency), + value: item.currency.symbol, })} ) : balances[item.currency.id] && From 68b6012d6201745cf95f122a3124791c4f246d07 Mon Sep 17 00:00:00 2001 From: ismailToyran Date: Wed, 31 Jan 2024 20:20:57 +0300 Subject: [PATCH 37/58] Add signature modal and signature functionality --- components/Modal/Signature.tsx | 52 ++++++++++++++++++++++++++++++++++ hooks/useAccount.ts | 23 ++++++++------- locales/en/components.json | 6 ++++ locales/es-mx/components.json | 6 ++++ locales/ja/components.json | 6 ++++ locales/zh-cn/components.json | 6 ++++ pages/_app.tsx | 39 +++++++++++++++++++++---- 7 files changed, 123 insertions(+), 15 deletions(-) create mode 100644 components/Modal/Signature.tsx diff --git a/components/Modal/Signature.tsx b/components/Modal/Signature.tsx new file mode 100644 index 00000000..56022b1f --- /dev/null +++ b/components/Modal/Signature.tsx @@ -0,0 +1,52 @@ +import { + Button, + Heading, + Icon, + Modal, + ModalBody, + ModalCloseButton, + ModalContent, + ModalFooter, + ModalHeader, + ModalOverlay, + Text, +} from '@chakra-ui/react' +import { FaFileSignature } from '@react-icons/all-files/fa/FaFileSignature' +import useTranslation from 'next-translate/useTranslation' +import { FC } from 'react' + +type Props = { + isOpen: boolean + onClose: () => void + onSignature: () => void +} + +const SignatureModal: FC = ({ isOpen, onClose, onSignature }) => { + const { t } = useTranslation('components') + return ( + + + + + + {t('modal.signature.title')} + + + + + + {t('modal.signature.sub-title')} + {t('modal.signature.description')} + + + {/* TODO: add loader */} + + + + + ) +} + +export default SignatureModal diff --git a/hooks/useAccount.ts b/hooks/useAccount.ts index 31b50267..d87a93d9 100644 --- a/hooks/useAccount.ts +++ b/hooks/useAccount.ts @@ -1,6 +1,6 @@ import { useAuthenticate, useIsLoggedIn } from '@liteflow/react' import { JwtPayload, jwtDecode } from 'jwt-decode' -import { useCallback, useEffect, useMemo } from 'react' +import { useCallback, useMemo } from 'react' import { useCookies } from 'react-cookie' import { Connector, useAccount as useWagmiAccount } from 'wagmi' import { walletClientToSigner } from './useSigner' @@ -12,6 +12,7 @@ type AccountDetail = { jwtToken: string | null logout: () => Promise login: (connector: Connector) => Promise + signature: (connector: Connector) => Promise } export const COOKIE_JWT_TOKEN = 'jwt-token' @@ -57,14 +58,6 @@ export default function useAccount(): AccountDetail { [isLoggedInWhileReconnect, isLoggedInToAPI], ) - // Reconnect based on the token and mark as logged in - useEffect(() => { - if (isLoggedInToAPI) return - if (!isReconnecting) return - if (!jwt) return - setAuthenticationToken(jwt.token) - }, [isLoggedInToAPI, isReconnecting, jwt, setAuthenticationToken]) - const login = useCallback( async (connector: Connector) => { const wallet = await connector.getWalletClient() @@ -73,6 +66,14 @@ export default function useAccount(): AccountDetail { if (jwt && currentAddress === jwt.address) { return setAuthenticationToken(jwt.token) } + }, + [jwt, setAuthenticationToken], + ) + + const signature = useCallback( + async (connector: Connector) => { + const wallet = await connector.getWalletClient() + const signer = walletClientToSigner(wallet) const { jwtToken } = await authenticate(signer) const newJwt = jwtDecode(jwtToken) @@ -86,7 +87,7 @@ export default function useAccount(): AccountDetail { : {}), }) }, - [jwt, authenticate, setAuthenticationToken, setCookie], + [authenticate, setCookie], ) // Server side @@ -98,6 +99,7 @@ export default function useAccount(): AccountDetail { isConnected: !!jwt, logout, login, + signature, } } @@ -108,5 +110,6 @@ export default function useAccount(): AccountDetail { isConnected, logout, login, + signature, } } diff --git a/locales/en/components.json b/locales/en/components.json index f01a4ec8..92d1703d 100644 --- a/locales/en/components.json +++ b/locales/en/components.json @@ -475,6 +475,12 @@ "title": "Sign in with your wallet", "description": "Connect with one of the following options.", "alternative": "Or sign in with" + }, + "signature": { + "title": "Signature", + "sub-title": "Verify your account", + "description": "To complete the connection, you must sign a message in your wallet to verify that you are the owner of this account.", + "action": "Send message" } }, "back": "Go back", diff --git a/locales/es-mx/components.json b/locales/es-mx/components.json index 9410f455..3971ced8 100644 --- a/locales/es-mx/components.json +++ b/locales/es-mx/components.json @@ -475,6 +475,12 @@ "title": "Inicia sesión con tu Wallet", "description": "Conéctate con alguna de las siguientes opciones:", "alternative": "O inicia sesión con:" + }, + "signature": { + "title": "Signature", + "sub-title": "Verify your account", + "description": "To complete the connection, you must sign a message in your wallet to verify that you are the owner of this account.", + "action": "Send message" } }, "back": "Volver", diff --git a/locales/ja/components.json b/locales/ja/components.json index 1e6fb175..69897be5 100644 --- a/locales/ja/components.json +++ b/locales/ja/components.json @@ -475,6 +475,12 @@ "title": "ウォレットでサインインする", "description": "次のいずれかのオプションを使用して接続します。", "alternative": "または、" + }, + "signature": { + "title": "Signature", + "sub-title": "Verify your account", + "description": "To complete the connection, you must sign a message in your wallet to verify that you are the owner of this account.", + "action": "Send message" } }, "back": "戻る", diff --git a/locales/zh-cn/components.json b/locales/zh-cn/components.json index 097fb1b4..54cd161e 100644 --- a/locales/zh-cn/components.json +++ b/locales/zh-cn/components.json @@ -475,6 +475,12 @@ "title": "使用钱包登录", "description": "使用以下选项之一进行连接。", "alternative": "或使用" + }, + "signature": { + "title": "Signature", + "sub-title": "Verify your account", + "description": "To complete the connection, you must sign a message in your wallet to verify that you are the owner of this account.", + "action": "Send message" } }, "back": "返回", diff --git a/pages/_app.tsx b/pages/_app.tsx index 26c9752f..48a43fc3 100644 --- a/pages/_app.tsx +++ b/pages/_app.tsx @@ -1,7 +1,7 @@ import { ApolloProvider } from '@apollo/client' import Bugsnag from '@bugsnag/js' import BugsnagPluginReact from '@bugsnag/plugin-react' -import { Box, ChakraProvider } from '@chakra-ui/react' +import { Box, ChakraProvider, useDisclosure } from '@chakra-ui/react' import { LiteflowProvider } from '@liteflow/react' import { RainbowKitProvider, lightTheme } from '@rainbow-me/rainbowkit' import '@rainbow-me/rainbowkit/styles.css' @@ -18,11 +18,12 @@ import React, { Fragment, JSX, PropsWithChildren, + useCallback, useEffect, useMemo, useState, } from 'react' -import { Cookies, CookiesProvider } from 'react-cookie' +import { Cookies, CookiesProvider, useCookies } from 'react-cookie' import { WagmiConfig, useDisconnect, @@ -31,6 +32,7 @@ import { import getClient from '../client' import CartContext from '../components/CartContext' import Footer from '../components/Footer/Footer' +import SignatureModal from '../components/Modal/Signature' import Navbar from '../components/Navbar/Navbar' import connectors from '../connectors' import getEnvironment, { Environment, EnvironmentContext } from '../environment' @@ -125,14 +127,18 @@ function AccountProvider({ onError, }: PropsWithChildren<{ onError: (code: number) => void }>) { const { LITEFLOW_API_KEY, BASE_URL } = useEnvironment() - const { login, jwtToken, logout } = useAccount() + const { jwtToken, login, logout, signature } = useAccount() const { disconnect } = useDisconnect() + const { isOpen, onOpen, onClose } = useDisclosure() + const [cookies] = useCookies([COOKIE_JWT_TOKEN]) const { connector } = useWagmiAccount({ async onConnect({ connector }) { if (!connector) return try { await login(connector) + // jwtToken from useAccount is null on refresh, so we need to check the cookies + if (!cookies[COOKIE_JWT_TOKEN]) onOpen() } catch (e: any) { disconnect() } @@ -142,6 +148,17 @@ function AccountProvider({ }, }) + const onSignature = useCallback(async () => { + if (!connector) return + try { + await signature(connector) + } catch (e: any) { + disconnect() + } finally { + onClose() + } + }, [connector, disconnect, onClose, signature]) + // handle change of account useEffect(() => { if (!connector) return @@ -150,7 +167,7 @@ function AccountProvider({ return () => { connector.off('change', handleLogin) } - }, [connector, login]) + }, [connector, login, onError, onOpen]) const client = useMemo( // The client needs to be reset when the jwtToken changes but only on the client as the server will @@ -166,7 +183,19 @@ function AccountProvider({ [jwtToken, onError, LITEFLOW_API_KEY, BASE_URL], ) - return {children} + return ( + <> + {children} + { + onClose() + disconnect() + }} + onSignature={onSignature} + /> + + ) } export type MyAppProps = { From bd7093f2814e0c14cfa9941fc41a4719c928a06c Mon Sep 17 00:00:00 2001 From: Nicolas Mahe Date: Thu, 1 Feb 2024 12:43:42 +0700 Subject: [PATCH 38/58] remove unlockedContent from FetchCartItems query --- components/Cart/Step/Selection.gql | 4 ---- 1 file changed, 4 deletions(-) diff --git a/components/Cart/Step/Selection.gql b/components/Cart/Step/Selection.gql index b3a14fbb..7c70a2cb 100644 --- a/components/Cart/Step/Selection.gql +++ b/components/Cart/Step/Selection.gql @@ -34,10 +34,6 @@ query FetchCartItems($offerIds: [UUID!]!) { name image imageMimetype - unlockedContent { - url - mimetype - } animationUrl animationMimetype } From a0d16d8c83337db764e9d433b09db13ab39757d7 Mon Sep 17 00:00:00 2001 From: Nicolas Mahe Date: Thu, 1 Feb 2024 12:47:40 +0700 Subject: [PATCH 39/58] Replace deprecated valuePerTenThousand in useFees query --- components/Offer/Summary.tsx | 4 ++-- components/Sales/Direct/Form.tsx | 4 ++-- hooks/useFees.gql | 3 ++- hooks/useFees.ts | 9 +++++---- 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/components/Offer/Summary.tsx b/components/Offer/Summary.tsx index df4e7806..4df406ca 100644 --- a/components/Offer/Summary.tsx +++ b/components/Offer/Summary.tsx @@ -12,7 +12,7 @@ type Props = { isSingle: boolean price: BigNumber quantity: BigNumber - feesOnTopPerTenThousand?: number | undefined + feesOnTopPerTenThousand?: BigNumber | undefined noFees?: boolean } @@ -66,7 +66,7 @@ const Summary: FC = ({ ) : ( {t('offer.summary.fees', { - value: feesOnTopPerTenThousand / 100, + value: feesOnTopPerTenThousand.div(100).toString(), })} = ({ asset, currencies, onCreated }) => { ) : ( {t('sales.direct.form.fees', { - value: feesPerTenThousand / 100, + value: feesPerTenThousand.div(100).toString(), })} = ({ asset, currencies, onCreated }) => { ) : ( {t('sales.direct.form.total-fees', { - value: feesPerTenThousand / 100, + value: feesPerTenThousand.div(100).toString(), })} (data?.orderFees || previousData?.orderFees)?.valuePerTenThousand, - [data?.orderFees, previousData?.orderFees], - ) + const feesPerTenThousand = useMemo(() => { + const value = (data?.orderFees || previousData?.orderFees)?.value + if (value === undefined) return undefined + return BigNumber.from(value) // TODO: take into account orderFees.precision + }, [data?.orderFees, previousData?.orderFees]) return { feesPerTenThousand, From e7202b03c09d9cdd055f88a86b0e2d8942cf5def Mon Sep 17 00:00:00 2001 From: Nicolas Mahe Date: Thu, 1 Feb 2024 12:50:15 +0700 Subject: [PATCH 40/58] flatten asset history query --- components/History/HistoryList.gql | 86 ++++++++++++++---------------- components/History/HistoryList.tsx | 10 ++-- 2 files changed, 45 insertions(+), 51 deletions(-) diff --git a/components/History/HistoryList.gql b/components/History/HistoryList.gql index 9497ca5e..ca11dcbe 100644 --- a/components/History/HistoryList.gql +++ b/components/History/HistoryList.gql @@ -6,55 +6,51 @@ query FetchAssetHistory( $offset: Int! $filter: [AssetHistoryAction!] ) { - asset( - chainId: $chainId - collectionAddress: $collectionAddress - tokenId: $tokenId + assetHistories( + filter: { + chainId: { equalTo: $chainId } + collectionAddress: { equalTo: $collectionAddress } + tokenId: { equalTo: $tokenId } + action: { in: $filter } + } + orderBy: DATE_DESC + first: $limit + offset: $offset + includeWhenAssetDeleted: YES + includeWhenCurrencyDeleted: YES ) { - chainId - collectionAddress - tokenId - histories( - filter: { action: { in: $filter } } - orderBy: DATE_DESC - first: $limit - offset: $offset - includeWhenAssetDeleted: YES - includeWhenCurrencyDeleted: YES - ) { - pageInfo { - hasNextPage - hasPreviousPage - } - nodes { - action - date - unitPrice - quantity - fromAddress - from { - address - name - image - verification { - status - } - } - toAddress - to { - address - name - image - verification { - status - } + pageInfo { + hasNextPage + hasPreviousPage + } + nodes { + action + date + unitPrice + quantity + fromAddress + from { + address + name + image + verification { + status } - transactionHash - currency { - decimals - symbol + } + toAddress + to { + address + name + image + verification { + status } } + transactionHash + currency { + decimals + symbol + } } } } diff --git a/components/History/HistoryList.tsx b/components/History/HistoryList.tsx index 9cde8cf3..72ee147e 100644 --- a/components/History/HistoryList.tsx +++ b/components/History/HistoryList.tsx @@ -57,12 +57,10 @@ const HistoryList: FC = ({ chainId, collectionAddress, tokenId }) => { filter, }, }) - const histories = historyData?.asset?.histories.nodes + const histories = historyData?.assetHistories?.nodes const ListItem = ( - history: NonNullable< - FetchAssetHistoryQuery['asset'] - >['histories']['nodes'][0], + history: NonNullable['nodes'][0], i: number, ) => { switch (history.action) { @@ -140,9 +138,9 @@ const HistoryList: FC = ({ chainId, collectionAddress, tokenId }) => { Date: Thu, 1 Feb 2024 12:55:07 +0700 Subject: [PATCH 41/58] Flatten FetchCollectionTraits query --- components/Filter/FilterBy/Trait.tsx | 24 ++++++-------- hooks/useFetchCollectionTraits.gql | 48 ++++++++++++++-------------- 2 files changed, 33 insertions(+), 39 deletions(-) diff --git a/components/Filter/FilterBy/Trait.tsx b/components/Filter/FilterBy/Trait.tsx index 9452817b..782df787 100644 --- a/components/Filter/FilterBy/Trait.tsx +++ b/components/Filter/FilterBy/Trait.tsx @@ -65,8 +65,8 @@ const FilterByTrait: FC = ({ notifyOnNetworkStatusChange: true, }) - const traitsData = data?.collection?.traitsOfCollection.nodes - const hasNextPage = data?.collection?.traitsOfCollection.pageInfo.hasNextPage + const traitsData = data?.collectionTraits?.nodes + const hasNextPage = data?.collectionTraits?.pageInfo.hasNextPage const loadMore = useCallback(async () => { const newOffset = offset + PAGINATION_LIMIT @@ -76,22 +76,16 @@ const FilterByTrait: FC = ({ // Cannot use concatToQuery function because of nested cache // Nested cache comes from the shape of FetchCollectionTraits query above updateQuery: (prevResult, { fetchMoreResult }) => { - if ( - !fetchMoreResult || - !fetchMoreResult.collection?.traitsOfCollection - ) + if (!fetchMoreResult || !fetchMoreResult.collectionTraits) return prevResult return { ...fetchMoreResult, - collection: { - ...fetchMoreResult.collection, - traitsOfCollection: { - ...fetchMoreResult.collection.traitsOfCollection, - nodes: [ - ...(prevResult?.collection?.traitsOfCollection.nodes || []), - ...fetchMoreResult.collection.traitsOfCollection.nodes, - ], - }, + collectionTraits: { + ...fetchMoreResult.collectionTraits, + nodes: [ + ...(prevResult?.collectionTraits?.nodes || []), + ...fetchMoreResult.collectionTraits.nodes, + ], }, } }, diff --git a/hooks/useFetchCollectionTraits.gql b/hooks/useFetchCollectionTraits.gql index bed95bfe..a37ab5c6 100644 --- a/hooks/useFetchCollectionTraits.gql +++ b/hooks/useFetchCollectionTraits.gql @@ -1,33 +1,33 @@ query FetchCollectionTraits( $chainId: Int! $address: Address! - $filter: CollectionTraitFilter! + $filter: [CollectionTraitFilter!] $limit: Int! $offset: Int! ) { - collection(chainId: $chainId, address: $address) { - chainId - address - traitsOfCollection( - orderBy: [TYPE_ASC] - first: $limit - filter: $filter - offset: $offset - ) { - pageInfo { - hasNextPage - } - nodes { - type - numberOfValues - values( - first: 50 # TODO: implement pagination - orderBy: [NUMBER_OF_ASSETS_DESC, VALUE_ASC] - ) { - nodes { - value - numberOfAssets - } + collectionTraits( + orderBy: [TYPE_ASC] + first: $limit + filter: { + chainId: { equalTo: $chainId } + collectionAddress: { equalTo: $address } + and: $filter + } + offset: $offset + ) { + pageInfo { + hasNextPage + } + nodes { + type + numberOfValues + values( + first: 50 # TODO: implement pagination + orderBy: [NUMBER_OF_ASSETS_DESC, VALUE_ASC] + ) { + nodes { + value + numberOfAssets } } } From 00e5778e952a0b2ad0bad86754eaaee019721cf0 Mon Sep 17 00:00:00 2001 From: Nicolas Mahe Date: Thu, 1 Feb 2024 13:06:03 +0700 Subject: [PATCH 42/58] Replace cursor by offset in GetNotifications query --- pages/notification.gql | 7 +++---- pages/notification.tsx | 17 ++++++++++------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/pages/notification.gql b/pages/notification.gql index ea45cfb3..861add0d 100644 --- a/pages/notification.gql +++ b/pages/notification.gql @@ -1,4 +1,4 @@ -query GetNotifications($address: Address!, $cursor: Cursor) { +query GetNotifications($address: Address!, $limit: Int!, $offset: Int!) { notifications( filter: { accountAddress: { equalTo: $address } @@ -14,15 +14,14 @@ query GetNotifications($address: Address!, $cursor: Cursor) { ] } } - first: 12 + first: $limit orderBy: CREATED_AT_DESC - after: $cursor + offset: $offset includeWhenCollectionDeleted: YES includeWhenTradeDeleted: YES ) { pageInfo { hasNextPage - endCursor } nodes { id diff --git a/pages/notification.tsx b/pages/notification.tsx index bc8bae2c..fc1982d2 100644 --- a/pages/notification.tsx +++ b/pages/notification.tsx @@ -12,7 +12,7 @@ import { import { FaBell } from '@react-icons/all-files/fa/FaBell' import { NextPage } from 'next' import useTranslation from 'next-translate/useTranslation' -import { useCallback, useEffect } from 'react' +import { useCallback, useEffect, useState } from 'react' import { useCookies } from 'react-cookie' import Empty from '../components/Empty/Empty' import Head from '../components/Head' @@ -25,12 +25,15 @@ import useLoginRedirect from '../hooks/useLoginRedirect' import SmallLayout from '../layouts/small' import { formatError } from '../utils' +const PAGINATION_LIMIT = 12 + const NotificationPage: NextPage = ({}) => { const { t } = useTranslation('templates') const toast = useToast() const { address } = useAccount() useLoginRedirect() const [_, setCookies] = useCookies() + const [offset, setOffset] = useState(0) const { data: notificationData, @@ -38,7 +41,8 @@ const NotificationPage: NextPage = ({}) => { networkStatus, } = useGetNotificationsQuery({ variables: { - cursor: null, + offset: 0, // the offset change must be done when calling the fetchMore function to concat queries' results + limit: PAGINATION_LIMIT, address: address || '', }, notifyOnNetworkStatusChange: true, @@ -47,23 +51,22 @@ const NotificationPage: NextPage = ({}) => { const notifications = notificationData?.notifications?.nodes const hasNextPage = notificationData?.notifications?.pageInfo.hasNextPage - const endCursor = notificationData?.notifications?.pageInfo.endCursor const loadMore = useCallback(async () => { + const newOffset = offset + PAGINATION_LIMIT try { await fetchMore({ - variables: { - cursor: endCursor, - }, + variables: { offset: newOffset }, updateQuery: concatToQuery('notifications'), }) + setOffset(newOffset) } catch (e) { toast({ title: formatError(e), status: 'error', }) } - }, [endCursor, fetchMore, toast]) + }, [fetchMore, offset, toast]) useEffect(() => { if (!address) return From 5ff742f470c1173b7338e50edbe3f8ca43f5c174 Mon Sep 17 00:00:00 2001 From: Nicolas Mahe Date: Thu, 1 Feb 2024 13:08:03 +0700 Subject: [PATCH 43/58] Remove filter on deprecated `isImported` in `FetchExploreUsers` query --- pages/explore/users.gql | 4 ++-- pages/explore/users.tsx | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pages/explore/users.gql b/pages/explore/users.gql index 23b00099..242c8076 100644 --- a/pages/explore/users.gql +++ b/pages/explore/users.gql @@ -2,13 +2,13 @@ query FetchExploreUsers( $limit: Int! $offset: Int! $orderBy: [AccountsOrderBy!] - $filter: [AccountFilter!] + $filter: AccountFilter ) { users: accounts( first: $limit offset: $offset orderBy: $orderBy - filter: { isImported: { equalTo: false }, and: $filter } + filter: $filter ) { pageInfo { hasNextPage diff --git a/pages/explore/users.tsx b/pages/explore/users.tsx index 029475b2..8e99d505 100644 --- a/pages/explore/users.tsx +++ b/pages/explore/users.tsx @@ -55,7 +55,7 @@ const UsersPage: NextPage = () => { limit, offset, orderBy, - filter: search ? searchFilter(search) : [], + filter: search ? searchFilter(search) : null, }, }) From 5070a3fb4f12d5e97abd1e9408a7b026fb086b6d Mon Sep 17 00:00:00 2001 From: Nicolas Mahe Date: Thu, 1 Feb 2024 13:14:27 +0700 Subject: [PATCH 44/58] fix --- pages/explore/users.gql | 4 ++-- pages/explore/users.tsx | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pages/explore/users.gql b/pages/explore/users.gql index 242c8076..bf8e09f1 100644 --- a/pages/explore/users.gql +++ b/pages/explore/users.gql @@ -2,13 +2,13 @@ query FetchExploreUsers( $limit: Int! $offset: Int! $orderBy: [AccountsOrderBy!] - $filter: AccountFilter + $filter: [AccountFilter!] ) { users: accounts( first: $limit offset: $offset orderBy: $orderBy - filter: $filter + filter: { and: $filter } ) { pageInfo { hasNextPage diff --git a/pages/explore/users.tsx b/pages/explore/users.tsx index 8e99d505..029475b2 100644 --- a/pages/explore/users.tsx +++ b/pages/explore/users.tsx @@ -55,7 +55,7 @@ const UsersPage: NextPage = () => { limit, offset, orderBy, - filter: search ? searchFilter(search) : null, + filter: search ? searchFilter(search) : [], }, }) From 08bf1407a4ec0d16655f02f6fb1179c17891c648 Mon Sep 17 00:00:00 2001 From: Nicolas Mahe Date: Thu, 1 Feb 2024 13:27:55 +0700 Subject: [PATCH 45/58] Flatten collection in asset filter --- hooks/useAssetFilterFromQuery.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/hooks/useAssetFilterFromQuery.ts b/hooks/useAssetFilterFromQuery.ts index 807d6acc..0c9d8d21 100644 --- a/hooks/useAssetFilterFromQuery.ts +++ b/hooks/useAssetFilterFromQuery.ts @@ -67,10 +67,8 @@ const traitFilter = (traits: TraitFilter[]): AssetFilter => const collectionFilter = (collection: string): AssetFilter => { const [chainId, address] = collection.split('-') return { - collection: { - chainId: { equalTo: chainId && parseInt(chainId, 10) }, - address: { equalTo: address }, - }, + chainId: { equalTo: chainId && parseInt(chainId, 10) }, + collectionAddress: { equalTo: address }, } as AssetFilter } From 30fba54a75b7a49e0f0af7e7303a83d732c78630 Mon Sep 17 00:00:00 2001 From: Nicolas Mahe Date: Thu, 1 Feb 2024 15:32:07 +0700 Subject: [PATCH 46/58] Remove assigning taker when creating offer. This is deprecated by the API. --- components/Offer/Form/Bid.tsx | 9 --------- pages/tokens/[id]/bid.gql | 5 ----- 2 files changed, 14 deletions(-) diff --git a/components/Offer/Form/Bid.tsx b/components/Offer/Form/Bid.tsx index c011aa1f..a5129aac 100644 --- a/components/Offer/Form/Bid.tsx +++ b/components/Offer/Form/Bid.tsx @@ -81,10 +81,6 @@ const OfferFormBid: FC = ({ asset, currencies, onCreated }) => { () => asset.collection.standard === 'ERC1155', [asset.collection.standard], ) - const ownerAddress = useMemo( - () => asset.ownerships.nodes[0]?.ownerAddress, - [asset.ownerships.nodes], - ) const defaultExpirationValue = useMemo( () => @@ -171,11 +167,6 @@ const OfferFormBid: FC = ({ asset, currencies, onCreated }) => { chain: asset.chainId, collection: toAddress(asset.collectionAddress), token: asset.tokenId, - taker: isMultiple - ? undefined // Keep the bid open for anyone that can fill it - : ownerAddress - ? toAddress(ownerAddress) - : undefined, expiredAt: new Date(expiredAt), }) diff --git a/pages/tokens/[id]/bid.gql b/pages/tokens/[id]/bid.gql index 633db930..4f38a8a7 100644 --- a/pages/tokens/[id]/bid.gql +++ b/pages/tokens/[id]/bid.gql @@ -75,11 +75,6 @@ query BidOnAsset( } } } - ownerships(first: 1) { - nodes { - ownerAddress - } - } } currencies( orderBy: CREATED_AT_ASC From 12e979bb80b442ece29cd31265e8a672e42cb9b7 Mon Sep 17 00:00:00 2001 From: Nicolas Mahe Date: Thu, 1 Feb 2024 16:19:31 +0700 Subject: [PATCH 47/58] Flatten bids and sales in FetchAsset query --- components/Sales/Detail.tsx | 45 +++++++------ components/Token/Header.tsx | 3 +- components/Token/Metadata.tsx | 10 +-- pages/tokens/[id]/index.gql | 122 ++++++++++++++++++---------------- pages/tokens/[id]/index.tsx | 13 ++-- 5 files changed, 104 insertions(+), 89 deletions(-) diff --git a/components/Sales/Detail.tsx b/components/Sales/Detail.tsx index 6b903880..08b07470 100644 --- a/components/Sales/Detail.tsx +++ b/components/Sales/Detail.tsx @@ -19,28 +19,28 @@ export type Props = { owned: { quantity: string } | null - sales: { - nodes: { + } + sales: { + nodes: { + id: string + unitPrice: string + expiredAt: Date + availableQuantity: string + maker: { + address: string + image: string | null + name: string | null + verification: { + status: AccountVerificationStatus + } | null + } + currency: { id: string - unitPrice: string - expiredAt: Date - availableQuantity: string - maker: { - address: string - image: string | null - name: string | null - verification: { - status: AccountVerificationStatus - } | null - } - currency: { - id: string - decimals: number - image: string - symbol: string - } - }[] - } + decimals: number + image: string + symbol: string + } + }[] } currencies: { chainId: number @@ -54,6 +54,7 @@ export type Props = { const SaleDetail: FC = ({ asset, + sales, currencies, isHomepage, onOfferCanceled, @@ -73,7 +74,7 @@ const SaleDetail: FC = ({ () => asset.collection.standard === 'ERC721', [asset.collection.standard], ) - const directSales = asset.sales.nodes + const directSales = sales.nodes return ( diff --git a/components/Token/Header.tsx b/components/Token/Header.tsx index 7de4e788..c5cafeac 100644 --- a/components/Token/Header.tsx +++ b/components/Token/Header.tsx @@ -84,9 +84,10 @@ const TokenHeader: FC = ({ {asset.name} - + = ({ asset }) => { +const TokenMetadata: FC = ({ asset, sales }) => { const { t } = useTranslation('components') const isOpenCollection = asset.collection.mintType === 'PUBLIC' const numberOfOwners = asset.ownerships.totalCount - const saleSupply = BigNumber.from(asset.sales.totalAvailableQuantitySum) + const saleSupply = BigNumber.from(sales.totalAvailableQuantitySum) const totalSupply = BigNumber.from(asset.quantity) const owners = asset.ownerships.nodes diff --git a/pages/tokens/[id]/index.gql b/pages/tokens/[id]/index.gql index 26e28ad4..99b67003 100644 --- a/pages/tokens/[id]/index.gql +++ b/pages/tokens/[id]/index.gql @@ -51,38 +51,6 @@ query FetchAsset( status } } - bids( - orderBy: [UNIT_PRICE_IN_REF_DESC, CREATED_AT_ASC] - filter: { expiredAt: { greaterThan: $now } } - first: 100 # TODO: implement pagination - ) { - nodes { - id - createdAt - expiredAt - availableQuantity - taker { - address - } - maker { - address - name - image - verification { - status - } - } - unitPrice - amount - currency { - image - name - id - decimals - symbol - } - } - } owned: ownership(ownerAddress: $address) { quantity } @@ -108,34 +76,76 @@ query FetchAsset( } } } - sales( - orderBy: [UNIT_PRICE_IN_REF_ASC, CREATED_AT_ASC] - filter: { expiredAt: { greaterThan: $now } } - first: 100 # TODO: implement pagination - ) { - nodes { - id - unitPrice - expiredAt - availableQuantity - currency { - image - name - id - decimals - symbol + } + bids: offerOpenBuys( + orderBy: [UNIT_PRICE_IN_REF_DESC, CREATED_AT_ASC] + filter: { + chainId: { equalTo: $chainId } + collectionAddress: { equalTo: $collectionAddress } + tokenId: { equalTo: $tokenId } + expiredAt: { greaterThan: $now } + } + first: 100 # TODO: implement pagination + ) { + nodes { + id + createdAt + expiredAt + availableQuantity + taker { + address + } + maker { + address + name + image + verification { + status } - maker { - image - address - name - verification { - status - } + } + unitPrice + amount + currency { + image + name + id + decimals + symbol + } + } + } + sales: offerOpenSales( + orderBy: [UNIT_PRICE_IN_REF_ASC, CREATED_AT_ASC] + filter: { + chainId: { equalTo: $chainId } + collectionAddress: { equalTo: $collectionAddress } + tokenId: { equalTo: $tokenId } + expiredAt: { greaterThan: $now } + } + first: 100 # TODO: implement pagination + ) { + nodes { + id + unitPrice + expiredAt + availableQuantity + currency { + image + name + id + decimals + symbol + } + maker { + image + address + name + verification { + status } } - totalAvailableQuantitySum } + totalAvailableQuantitySum } currencies( orderBy: CREATED_AT_ASC diff --git a/pages/tokens/[id]/index.tsx b/pages/tokens/[id]/index.tsx index fbb7712b..36df4895 100644 --- a/pages/tokens/[id]/index.tsx +++ b/pages/tokens/[id]/index.tsx @@ -85,6 +85,8 @@ const DetailPage: NextPage = ({ now: nowProp }) => { }, }) const asset = data?.asset + const sales = data?.sales + const bids = data?.bids const media = useDetectAssetMedia(asset) @@ -225,12 +227,12 @@ const DetailPage: NextPage = ({ now: nowProp }) => { )} - {!asset ? ( + {!asset || !sales ? ( ) : ( - + )} - {!asset || !data?.currencies?.nodes ? ( + {!asset || !sales || !data?.currencies?.nodes ? ( <> @@ -238,6 +240,7 @@ const DetailPage: NextPage = ({ now: nowProp }) => { ) : ( = ({ now: nowProp }) => { )} - {asset && ( + {asset && bids && ( <> {asset.description && ( @@ -383,7 +386,7 @@ const DetailPage: NextPage = ({ now: nowProp }) => { {(!query.filter || query.filter === AssetTabs.bids) && ( Date: Thu, 1 Feb 2024 13:07:06 +0300 Subject: [PATCH 48/58] Update signature function name in useAccount hook --- hooks/useAccount.ts | 8 ++++---- pages/_app.tsx | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/hooks/useAccount.ts b/hooks/useAccount.ts index d87a93d9..e7c9ae7b 100644 --- a/hooks/useAccount.ts +++ b/hooks/useAccount.ts @@ -12,7 +12,7 @@ type AccountDetail = { jwtToken: string | null logout: () => Promise login: (connector: Connector) => Promise - signature: (connector: Connector) => Promise + sign: (connector: Connector) => Promise } export const COOKIE_JWT_TOKEN = 'jwt-token' @@ -70,7 +70,7 @@ export default function useAccount(): AccountDetail { [jwt, setAuthenticationToken], ) - const signature = useCallback( + const sign = useCallback( async (connector: Connector) => { const wallet = await connector.getWalletClient() const signer = walletClientToSigner(wallet) @@ -99,7 +99,7 @@ export default function useAccount(): AccountDetail { isConnected: !!jwt, logout, login, - signature, + sign, } } @@ -110,6 +110,6 @@ export default function useAccount(): AccountDetail { isConnected, logout, login, - signature, + sign, } } diff --git a/pages/_app.tsx b/pages/_app.tsx index 48a43fc3..b3f69997 100644 --- a/pages/_app.tsx +++ b/pages/_app.tsx @@ -127,7 +127,7 @@ function AccountProvider({ onError, }: PropsWithChildren<{ onError: (code: number) => void }>) { const { LITEFLOW_API_KEY, BASE_URL } = useEnvironment() - const { jwtToken, login, logout, signature } = useAccount() + const { jwtToken, login, logout, sign } = useAccount() const { disconnect } = useDisconnect() const { isOpen, onOpen, onClose } = useDisclosure() const [cookies] = useCookies([COOKIE_JWT_TOKEN]) @@ -151,13 +151,13 @@ function AccountProvider({ const onSignature = useCallback(async () => { if (!connector) return try { - await signature(connector) + await sign(connector) } catch (e: any) { disconnect() } finally { onClose() } - }, [connector, disconnect, onClose, signature]) + }, [connector, disconnect, onClose, sign]) // handle change of account useEffect(() => { From e4aa9e1c12e34fa27cb894e793f6989db96702a2 Mon Sep 17 00:00:00 2001 From: ismailToyran Date: Thu, 1 Feb 2024 13:13:25 +0300 Subject: [PATCH 49/58] Rename SignatureModal component and update AccountProvider --- components/Modal/{Signature.tsx => Sign.tsx} | 36 ++++++++++++++++---- pages/_app.tsx | 25 ++------------ 2 files changed, 33 insertions(+), 28 deletions(-) rename components/Modal/{Signature.tsx => Sign.tsx} (60%) diff --git a/components/Modal/Signature.tsx b/components/Modal/Sign.tsx similarity index 60% rename from components/Modal/Signature.tsx rename to components/Modal/Sign.tsx index 56022b1f..930c8642 100644 --- a/components/Modal/Signature.tsx +++ b/components/Modal/Sign.tsx @@ -13,18 +13,42 @@ import { } from '@chakra-ui/react' import { FaFileSignature } from '@react-icons/all-files/fa/FaFileSignature' import useTranslation from 'next-translate/useTranslation' -import { FC } from 'react' +import { FC, useCallback } from 'react' +import { Connector, useDisconnect } from 'wagmi' +import useAccount from '../../hooks/useAccount' type Props = { + connector?: Connector isOpen: boolean onClose: () => void - onSignature: () => void } -const SignatureModal: FC = ({ isOpen, onClose, onSignature }) => { +const SignModal: FC = ({ connector, isOpen, onClose }) => { const { t } = useTranslation('components') + const { sign } = useAccount() + const { disconnect } = useDisconnect() + + const onSign = useCallback(async () => { + if (!connector) return + try { + await sign(connector) + } catch (e: any) { + disconnect() + } finally { + onClose() + } + }, [connector, disconnect, onClose, sign]) + return ( - + { + onClose() + disconnect() + }} + isCentered + size="sm" + > @@ -40,7 +64,7 @@ const SignatureModal: FC = ({ isOpen, onClose, onSignature }) => { {/* TODO: add loader */} - @@ -49,4 +73,4 @@ const SignatureModal: FC = ({ isOpen, onClose, onSignature }) => { ) } -export default SignatureModal +export default SignModal diff --git a/pages/_app.tsx b/pages/_app.tsx index b3f69997..a38dd2c5 100644 --- a/pages/_app.tsx +++ b/pages/_app.tsx @@ -18,7 +18,6 @@ import React, { Fragment, JSX, PropsWithChildren, - useCallback, useEffect, useMemo, useState, @@ -32,7 +31,7 @@ import { import getClient from '../client' import CartContext from '../components/CartContext' import Footer from '../components/Footer/Footer' -import SignatureModal from '../components/Modal/Signature' +import SignModal from '../components/Modal/Sign' import Navbar from '../components/Navbar/Navbar' import connectors from '../connectors' import getEnvironment, { Environment, EnvironmentContext } from '../environment' @@ -127,7 +126,7 @@ function AccountProvider({ onError, }: PropsWithChildren<{ onError: (code: number) => void }>) { const { LITEFLOW_API_KEY, BASE_URL } = useEnvironment() - const { jwtToken, login, logout, sign } = useAccount() + const { jwtToken, login, logout } = useAccount() const { disconnect } = useDisconnect() const { isOpen, onOpen, onClose } = useDisclosure() const [cookies] = useCookies([COOKIE_JWT_TOKEN]) @@ -148,17 +147,6 @@ function AccountProvider({ }, }) - const onSignature = useCallback(async () => { - if (!connector) return - try { - await sign(connector) - } catch (e: any) { - disconnect() - } finally { - onClose() - } - }, [connector, disconnect, onClose, sign]) - // handle change of account useEffect(() => { if (!connector) return @@ -186,14 +174,7 @@ function AccountProvider({ return ( <> {children} - { - onClose() - disconnect() - }} - onSignature={onSignature} - /> + ) } From eb8f1d80bb8d5aa407fced9608bd26d37eacda29 Mon Sep 17 00:00:00 2001 From: ismailToyran Date: Thu, 1 Feb 2024 13:13:55 +0300 Subject: [PATCH 50/58] Remove TODO comment for loader in SignModal component --- components/Modal/Sign.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/components/Modal/Sign.tsx b/components/Modal/Sign.tsx index 930c8642..1542ec5c 100644 --- a/components/Modal/Sign.tsx +++ b/components/Modal/Sign.tsx @@ -63,7 +63,6 @@ const SignModal: FC = ({ connector, isOpen, onClose }) => { {t('modal.signature.description')} - {/* TODO: add loader */} From c856d4dbd8d0289d34b04a9fe7eac5d4ae05d31d Mon Sep 17 00:00:00 2001 From: ismailToyran Date: Thu, 1 Feb 2024 13:21:16 +0300 Subject: [PATCH 51/58] Refactor handleLogin function in _app.tsx --- pages/_app.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pages/_app.tsx b/pages/_app.tsx index a38dd2c5..08a91ca1 100644 --- a/pages/_app.tsx +++ b/pages/_app.tsx @@ -150,7 +150,9 @@ function AccountProvider({ // handle change of account useEffect(() => { if (!connector) return - const handleLogin = () => login(connector) + const handleLogin = () => { + login(connector).then(onOpen).catch(onError) + } connector.on('change', handleLogin) return () => { connector.off('change', handleLogin) From a751c107189923e9e2bc9a57ddf47ba13546a61c Mon Sep 17 00:00:00 2001 From: ismailToyran Date: Thu, 1 Feb 2024 13:30:32 +0300 Subject: [PATCH 52/58] Add loader to sign button --- components/Modal/Sign.tsx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/components/Modal/Sign.tsx b/components/Modal/Sign.tsx index 1542ec5c..befa44ac 100644 --- a/components/Modal/Sign.tsx +++ b/components/Modal/Sign.tsx @@ -13,7 +13,7 @@ import { } from '@chakra-ui/react' import { FaFileSignature } from '@react-icons/all-files/fa/FaFileSignature' import useTranslation from 'next-translate/useTranslation' -import { FC, useCallback } from 'react' +import { FC, useCallback, useState } from 'react' import { Connector, useDisconnect } from 'wagmi' import useAccount from '../../hooks/useAccount' @@ -27,15 +27,18 @@ const SignModal: FC = ({ connector, isOpen, onClose }) => { const { t } = useTranslation('components') const { sign } = useAccount() const { disconnect } = useDisconnect() + const [isLoading, setLoading] = useState(false) const onSign = useCallback(async () => { if (!connector) return + setLoading(true) try { await sign(connector) } catch (e: any) { disconnect() } finally { onClose() + setLoading(false) } }, [connector, disconnect, onClose, sign]) @@ -63,7 +66,7 @@ const SignModal: FC = ({ connector, isOpen, onClose }) => { {t('modal.signature.description')} - From 779bb65b95249aaaddd0c26b56238e1d87299b8a Mon Sep 17 00:00:00 2001 From: Nicolas Mahe Date: Thu, 1 Feb 2024 21:31:42 +0700 Subject: [PATCH 53/58] flatten notifications in NavbarAccount --- components/Navbar/Navbar.tsx | 8 +++++++- layouts/navbar.gql | 15 +++++++++------ 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/components/Navbar/Navbar.tsx b/components/Navbar/Navbar.tsx index 2ef1ccac..8dc6eaf4 100644 --- a/components/Navbar/Navbar.tsx +++ b/components/Navbar/Navbar.tsx @@ -340,6 +340,7 @@ const Navbar: FC<{ const { openConnectModal } = useConnectModal() const { items: cartItems } = useCart() const lastNotification = cookies[`lastNotification-${address}`] + const { data: accountData, refetch, @@ -351,10 +352,15 @@ const Navbar: FC<{ }, skip: !isLoggedIn && !address, }) + const account = isLoggedIn ? accountData?.account || previousAccountData?.account : undefined + const notifications = isLoggedIn + ? accountData?.notifications || previousAccountData?.notifications + : undefined + useEffect(() => { if (!isReady) return if (!query.search) return formValues.setValue('search', '') @@ -496,7 +502,7 @@ const Navbar: FC<{ > - {account.notifications.totalCount > 0 && ( + {notifications && notifications.totalCount > 0 && ( Date: Fri, 2 Feb 2024 08:47:05 +0700 Subject: [PATCH 54/58] Use bestBid resolver on asset instead of bids connection --- components/HomeSection/Assets.gql | 24 +++++++------------ components/HomeSection/Featured.gql | 24 +++++++------------ components/Sales/Open/CardFooter.tsx | 16 ++++++------- components/Token/Card.tsx | 17 ++++++------- pages/checkout/[id].gql | 24 +++++++------------ pages/collection/[chainId]/[id]/index.gql | 24 +++++++------------ .../create/[chainId]/[collectionAddress].tsx | 2 +- pages/explore/explore.gql | 24 +++++++------------ pages/tokens/[id]/bid.gql | 24 +++++++------------ pages/tokens/[id]/offer.gql | 24 +++++++------------ pages/users/[id]/assetDetail.gql | 24 +++++++------------ 11 files changed, 87 insertions(+), 140 deletions(-) diff --git a/components/HomeSection/Assets.gql b/components/HomeSection/Assets.gql index 91dd237f..52bc9d76 100644 --- a/components/HomeSection/Assets.gql +++ b/components/HomeSection/Assets.gql @@ -49,21 +49,15 @@ query FetchAssets( owned: ownership(ownerAddress: $address) { quantity } - bestBid: bids( - orderBy: [UNIT_PRICE_IN_REF_DESC, CREATED_AT_ASC] - filter: { expiredAt: { greaterThan: $now } } - first: 1 - ) { - nodes { - unitPrice - amount - currency { - image - name - id - decimals - symbol - } + bestBid { + unitPrice + amount + currency { + image + name + id + decimals + symbol } } firstSale: sales( diff --git a/components/HomeSection/Featured.gql b/components/HomeSection/Featured.gql index eaa9ed13..dea12f1b 100644 --- a/components/HomeSection/Featured.gql +++ b/components/HomeSection/Featured.gql @@ -55,21 +55,15 @@ query FetchFeaturedAssets( } } } - bestBid: bids( - orderBy: [UNIT_PRICE_IN_REF_DESC, CREATED_AT_ASC] - filter: { expiredAt: { greaterThan: $now } } - first: 1 - ) { - nodes { - unitPrice - amount - currency { - image - name - id - decimals - symbol - } + bestBid { + unitPrice + amount + currency { + image + name + id + decimals + symbol } } sales( diff --git a/components/Sales/Open/CardFooter.tsx b/components/Sales/Open/CardFooter.tsx index 2f87308d..f343491e 100644 --- a/components/Sales/Open/CardFooter.tsx +++ b/components/Sales/Open/CardFooter.tsx @@ -6,15 +6,13 @@ import Price from '../../Price/Price' type Props = { assetId: string - bestBid: - | { - unitPrice: string - currency: { - decimals: number - symbol: string - } - } - | undefined + bestBid: { + unitPrice: string + currency: { + decimals: number + symbol: string + } + } | null isOwner: boolean showButton?: boolean } diff --git a/components/Token/Card.tsx b/components/Token/Card.tsx index 18cdc117..cb687d66 100644 --- a/components/Token/Card.tsx +++ b/components/Token/Card.tsx @@ -53,14 +53,12 @@ export type Props = { } | null quantity: string bestBid: { - nodes: { - unitPrice: string - currency: { - decimals: number - symbol: string - } - }[] - } + unitPrice: string + currency: { + decimals: number + symbol: string + } + } | null firstSale: | { totalCount: number @@ -92,8 +90,7 @@ const TokenCard: FC = ({ asset }) => { const media = useDetectAssetMedia(asset) const sale = asset.firstSale?.nodes[0] - const bestBid = - asset.bestBid?.nodes?.length > 0 ? asset.bestBid.nodes[0] : undefined + const bestBid = asset.bestBid const numberOfSales = asset.firstSale?.totalCount || 0 const hasMultiCurrency = asset.firstSale?.totalCurrencyDistinctCount ? asset.firstSale.totalCurrencyDistinctCount > 1 diff --git a/pages/checkout/[id].gql b/pages/checkout/[id].gql index 0665fa36..f774c779 100644 --- a/pages/checkout/[id].gql +++ b/pages/checkout/[id].gql @@ -29,21 +29,15 @@ query Checkout($id: UUID!, $address: Address, $now: Datetime!) { quantity } quantity - bestBid: bids( - orderBy: [UNIT_PRICE_IN_REF_DESC, CREATED_AT_ASC] - filter: { expiredAt: { greaterThan: $now } } - first: 1 - ) { - nodes { - unitPrice - amount - currency { - image - name - id - decimals - symbol - } + bestBid { + unitPrice + amount + currency { + image + name + id + decimals + symbol } } firstSale: sales( diff --git a/pages/collection/[chainId]/[id]/index.gql b/pages/collection/[chainId]/[id]/index.gql index c5cc3e2c..f99fa81e 100644 --- a/pages/collection/[chainId]/[id]/index.gql +++ b/pages/collection/[chainId]/[id]/index.gql @@ -103,21 +103,15 @@ query FetchCollectionAssets( quantity } quantity - bestBid: bids( - orderBy: [UNIT_PRICE_IN_REF_DESC, CREATED_AT_ASC] - filter: { expiredAt: { greaterThan: $now } } - first: 1 - ) { - nodes { - unitPrice - amount - currency { - image - name - id - decimals - symbol - } + bestBid { + unitPrice + amount + currency { + image + name + id + decimals + symbol } } firstSale: sales( diff --git a/pages/create/[chainId]/[collectionAddress].tsx b/pages/create/[chainId]/[collectionAddress].tsx index f984bdcf..9c548318 100644 --- a/pages/create/[chainId]/[collectionAddress].tsx +++ b/pages/create/[chainId]/[collectionAddress].tsx @@ -137,7 +137,7 @@ const CreatePage: NextPage = () => { asset={{ ...asset, creator, - bestBid: { nodes: [] }, + bestBid: null, firstSale: undefined, }} /> diff --git a/pages/explore/explore.gql b/pages/explore/explore.gql index 570b68ff..f8626885 100644 --- a/pages/explore/explore.gql +++ b/pages/explore/explore.gql @@ -34,21 +34,15 @@ query FetchAllERC721And1155( quantity } quantity - bestBid: bids( - orderBy: [UNIT_PRICE_IN_REF_DESC, CREATED_AT_ASC] - filter: { expiredAt: { greaterThan: $now } } - first: 1 - ) { - nodes { - unitPrice - amount - currency { - image - name - id - decimals - symbol - } + bestBid { + unitPrice + amount + currency { + image + name + id + decimals + symbol } } firstSale: sales( diff --git a/pages/tokens/[id]/bid.gql b/pages/tokens/[id]/bid.gql index 4f38a8a7..06c0fd85 100644 --- a/pages/tokens/[id]/bid.gql +++ b/pages/tokens/[id]/bid.gql @@ -36,21 +36,15 @@ query BidOnAsset( owned: ownership(ownerAddress: $address) { quantity } - bestBid: bids( - orderBy: [UNIT_PRICE_IN_REF_DESC, CREATED_AT_ASC] - filter: { expiredAt: { greaterThan: $now } } - first: 1 - ) { - nodes { - unitPrice - amount - currency { - image - name - id - decimals - symbol - } + bestBid { + unitPrice + amount + currency { + image + name + id + decimals + symbol } } firstSale: sales( diff --git a/pages/tokens/[id]/offer.gql b/pages/tokens/[id]/offer.gql index 5806d4e9..969d6331 100644 --- a/pages/tokens/[id]/offer.gql +++ b/pages/tokens/[id]/offer.gql @@ -31,21 +31,15 @@ query OfferForAsset( quantity } quantity - bestBid: bids( - orderBy: [UNIT_PRICE_IN_REF_DESC, CREATED_AT_ASC] - filter: { expiredAt: { greaterThan: $now } } - first: 1 - ) { - nodes { - unitPrice - amount - currency { - image - name - id - decimals - symbol - } + bestBid { + unitPrice + amount + currency { + image + name + id + decimals + symbol } } firstSale: sales( diff --git a/pages/users/[id]/assetDetail.gql b/pages/users/[id]/assetDetail.gql index cda3dd4a..1a28a27c 100644 --- a/pages/users/[id]/assetDetail.gql +++ b/pages/users/[id]/assetDetail.gql @@ -15,21 +15,15 @@ fragment AssetDetail on Asset { imageMimetype animationUrl animationMimetype - bestBid: bids( - orderBy: [UNIT_PRICE_IN_REF_DESC, CREATED_AT_ASC] - filter: { expiredAt: { greaterThan: $now } } - first: 1 - ) { - nodes { - unitPrice - amount - currency { - image - name - id - decimals - symbol - } + bestBid { + unitPrice + amount + currency { + image + name + id + decimals + symbol } } firstSale: sales( From 7c9fe506ea4f90c71d1dc9c5e0ff8c4c3f9ec295 Mon Sep 17 00:00:00 2001 From: Nicolas Mahe Date: Fri, 2 Feb 2024 12:38:11 +0700 Subject: [PATCH 55/58] Flatten `ownerships` in `fetchAsset` query --- components/Token/Header.tsx | 6 ++++- components/Token/Metadata.tsx | 38 +++++++++++++-------------- components/Token/Owners/Modal.tsx | 39 +++++++++++++--------------- pages/tokens/[id]/index.gql | 43 +++++++++++++++++-------------- pages/tokens/[id]/index.tsx | 9 +++++-- 5 files changed, 73 insertions(+), 62 deletions(-) diff --git a/components/Token/Header.tsx b/components/Token/Header.tsx index c5cafeac..62183f4c 100644 --- a/components/Token/Header.tsx +++ b/components/Token/Header.tsx @@ -84,7 +84,11 @@ const TokenHeader: FC = ({ {asset.name} - + = ({ asset, sales }) => { +const TokenMetadata: FC = ({ asset, sales, ownerships }) => { const { t } = useTranslation('components') const isOpenCollection = asset.collection.mintType === 'PUBLIC' - const numberOfOwners = asset.ownerships.totalCount + const numberOfOwners = ownerships.totalCount const saleSupply = BigNumber.from(sales.totalAvailableQuantitySum) const totalSupply = BigNumber.from(asset.quantity) - const owners = asset.ownerships.nodes + const owners = ownerships.nodes return ( @@ -81,7 +81,7 @@ const TokenMetadata: FC = ({ asset, sales }) => { {t('token.metadata.owners')} - + )} {asset.collection.standard === 'ERC721' && ( diff --git a/components/Token/Owners/Modal.tsx b/components/Token/Owners/Modal.tsx index 399203e3..2e6ed96b 100644 --- a/components/Token/Owners/Modal.tsx +++ b/components/Token/Owners/Modal.tsx @@ -29,27 +29,27 @@ export type Props = { chainId: number collectionAddress: string tokenId: string - ownerships: { - totalCount: number - nodes: { - ownerAddress: string - quantity: string - owner: { - address: string - name: string | null - image: string | null - verification: { - status: AccountVerificationStatus - } | null - } - }[] - } + } + ownerships: { + totalCount: number + nodes: { + ownerAddress: string + quantity: string + owner: { + address: string + name: string | null + image: string | null + verification: { + status: AccountVerificationStatus + } | null + } + }[] } } const OwnerPaginationLimit = 8 -const OwnersModal: FC = ({ asset }) => { +const OwnersModal: FC = ({ asset, ownerships }) => { const { t } = useTranslation('components') const { isOpen, onOpen, onClose } = useDisclosure() const [page, setPage] = useState(1) @@ -76,10 +76,7 @@ const OwnersModal: FC = ({ asset }) => { return ( <> - + = ({ asset }) => { px={2.5} > - {asset.ownerships.totalCount} + {ownerships.totalCount} diff --git a/pages/tokens/[id]/index.gql b/pages/tokens/[id]/index.gql index 99b67003..03971762 100644 --- a/pages/tokens/[id]/index.gql +++ b/pages/tokens/[id]/index.gql @@ -54,25 +54,30 @@ query FetchAsset( owned: ownership(ownerAddress: $address) { quantity } - ownerships( - orderBy: [ - QUANTITY_DESC - ACCOUNT_BY_OWNER_ADDRESS__NAME_ASC - OWNER_ADDRESS_ASC - ] - first: 5 - ) { - totalCount - nodes { - ownerAddress - quantity - owner { - address - name - image - verification { - status - } + } + ownerships( + filter: { + chainId: { equalTo: $chainId } + collectionAddress: { equalTo: $collectionAddress } + tokenId: { equalTo: $tokenId } + } + orderBy: [ + QUANTITY_DESC + ACCOUNT_BY_OWNER_ADDRESS__NAME_ASC + OWNER_ADDRESS_ASC + ] + first: 5 + ) { + totalCount + nodes { + ownerAddress + quantity + owner { + address + name + image + verification { + status } } } diff --git a/pages/tokens/[id]/index.tsx b/pages/tokens/[id]/index.tsx index 36df4895..7b9d52e6 100644 --- a/pages/tokens/[id]/index.tsx +++ b/pages/tokens/[id]/index.tsx @@ -87,6 +87,7 @@ const DetailPage: NextPage = ({ now: nowProp }) => { const asset = data?.asset const sales = data?.sales const bids = data?.bids + const ownerships = data?.ownerships const media = useDetectAssetMedia(asset) @@ -227,10 +228,14 @@ const DetailPage: NextPage = ({ now: nowProp }) => { )} - {!asset || !sales ? ( + {!asset || !sales || !ownerships ? ( ) : ( - + )} {!asset || !sales || !data?.currencies?.nodes ? ( <> From 2f647556187c54d7f02266c83763ed8bd44ff8de Mon Sep 17 00:00:00 2001 From: Nicolas Mahe Date: Fri, 2 Feb 2024 14:53:22 +0700 Subject: [PATCH 56/58] Use custom sales resolvers on asset instead of sales connection --- components/HomeSection/Assets.gql | 33 +++++++--------- components/HomeSection/Assets.tsx | 1 - components/Token/Card.tsx | 38 ++++++++----------- pages/checkout/[id].gql | 34 +++++++---------- pages/checkout/[id].tsx | 8 +--- pages/collection/[chainId]/[id]/index.gql | 32 +++++++--------- pages/collection/[chainId]/[id]/index.tsx | 1 - .../create/[chainId]/[collectionAddress].tsx | 4 +- pages/explore/explore.gql | 33 +++++++--------- pages/explore/explore.tsx | 1 - pages/tokens/[id]/bid.gql | 33 +++++++--------- pages/tokens/[id]/bid.tsx | 8 +--- pages/tokens/[id]/offer.gql | 33 +++++++--------- pages/tokens/[id]/offer.tsx | 5 +-- pages/users/[id]/assetDetail.gql | 31 +++++++-------- pages/users/[id]/created.gql | 1 - pages/users/[id]/created.tsx | 8 +--- pages/users/[id]/owned.gql | 1 - pages/users/[id]/owned.tsx | 8 +--- 19 files changed, 116 insertions(+), 197 deletions(-) diff --git a/components/HomeSection/Assets.gql b/components/HomeSection/Assets.gql index 52bc9d76..b6341f9e 100644 --- a/components/HomeSection/Assets.gql +++ b/components/HomeSection/Assets.gql @@ -14,7 +14,6 @@ query FetchDefaultAssetIds($limit: Int!) { } query FetchAssets( - $now: Datetime! $limit: Int! $assetIds: [String!]! $address: Address @@ -60,28 +59,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 { + id + unitPrice + currency { + image + name id - unitPrice - currency { - image - name - id - decimals - symbol - } - maker { - address - } + decimals + symbol + } + maker { + address } } + totalSalesCount + totalSalesCurrencyDistinctCount } } } diff --git a/components/HomeSection/Assets.tsx b/components/HomeSection/Assets.tsx index 69756f49..c1f9970f 100644 --- a/components/HomeSection/Assets.tsx +++ b/components/HomeSection/Assets.tsx @@ -62,7 +62,6 @@ const AssetsHomeSection: FC = ({ date }) => { const assetsQuery = useFetchAssetsQuery({ variables: { - now: date, limit: PAGINATION_LIMIT, assetIds: assetIds || [], address: address || '', diff --git a/components/Token/Card.tsx b/components/Token/Card.tsx index cb687d66..c2624cff 100644 --- a/components/Token/Card.tsx +++ b/components/Token/Card.tsx @@ -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 } } @@ -89,12 +85,10 @@ const TokenCard: FC = ({ 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], diff --git a/pages/checkout/[id].gql b/pages/checkout/[id].gql index f774c779..da974753 100644 --- a/pages/checkout/[id].gql +++ b/pages/checkout/[id].gql @@ -1,4 +1,4 @@ -query Checkout($id: UUID!, $address: Address, $now: Datetime!) { +query Checkout($id: UUID!, $address: Address) { offer(id: $id) { id type @@ -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 { + id + unitPrice + currency { + image + name id - unitPrice - currency { - image - name - id - decimals - symbol - } - maker { - address - } + decimals + symbol + } + maker { + address } } + totalSalesCount + totalSalesCurrencyDistinctCount } maker { address diff --git a/pages/checkout/[id].tsx b/pages/checkout/[id].tsx index e320e8e9..a58efd00 100644 --- a/pages/checkout/[id].tsx +++ b/pages/checkout/[id].tsx @@ -28,11 +28,7 @@ import useRequiredQueryParamSingle from '../../hooks/useRequiredQueryParamSingle import SmallLayout from '../../layouts/small' import Error from '../_error' -type Props = { - now: string -} - -const CheckoutPage: NextPage = ({ now }) => { +const CheckoutPage: NextPage = () => { const { t } = useTranslation('templates') const { back, push } = useRouter() const toast = useToast() @@ -40,12 +36,10 @@ const CheckoutPage: NextPage = ({ now }) => { const { address } = useAccount() - const date = useMemo(() => new Date(now), [now]) const { data: offerData } = useCheckoutQuery({ variables: { id: offerId, address: address || '', - now: date, }, }) const offer = offerData?.offer diff --git a/pages/collection/[chainId]/[id]/index.gql b/pages/collection/[chainId]/[id]/index.gql index f99fa81e..7d3cd77c 100644 --- a/pages/collection/[chainId]/[id]/index.gql +++ b/pages/collection/[chainId]/[id]/index.gql @@ -50,7 +50,6 @@ query FetchCollectionMetrics($collectionAddress: Address!, $chainId: Int!) { query FetchCollectionAssets( $currentAccount: Address! - $now: Datetime! $offset: Int! $limit: Int! $chainId: Int! @@ -114,27 +113,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 } } } diff --git a/pages/collection/[chainId]/[id]/index.tsx b/pages/collection/[chainId]/[id]/index.tsx index d1ca0e6b..c29ce308 100644 --- a/pages/collection/[chainId]/[id]/index.tsx +++ b/pages/collection/[chainId]/[id]/index.tsx @@ -91,7 +91,6 @@ const CollectionPage: FC = ({ now }) => { const { data: assetData } = useFetchCollectionAssetsQuery({ variables: { collectionAddress, - now: date, currentAccount: address || '', limit, offset, diff --git a/pages/create/[chainId]/[collectionAddress].tsx b/pages/create/[chainId]/[collectionAddress].tsx index 9c548318..1f77c6a5 100644 --- a/pages/create/[chainId]/[collectionAddress].tsx +++ b/pages/create/[chainId]/[collectionAddress].tsx @@ -138,7 +138,9 @@ const CreatePage: NextPage = () => { ...asset, creator, bestBid: null, - firstSale: undefined, + firstSale: null, + totalSalesCount: 0, + totalSalesCurrencyDistinctCount: 0, }} /> )} diff --git a/pages/explore/explore.gql b/pages/explore/explore.gql index f8626885..dc40412b 100644 --- a/pages/explore/explore.gql +++ b/pages/explore/explore.gql @@ -1,5 +1,4 @@ query FetchAllERC721And1155( - $now: Datetime! $address: Address $limit: Int! $offset: Int! @@ -45,28 +44,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 diff --git a/pages/explore/explore.tsx b/pages/explore/explore.tsx index 2c8664bc..b3d2ad00 100644 --- a/pages/explore/explore.tsx +++ b/pages/explore/explore.tsx @@ -59,7 +59,6 @@ const ExplorePage: NextPage = ({ now }) => { const { page, limit, offset } = usePaginateQuery() const { data: assetsData, refetch } = useFetchAllErc721And1155Query({ variables: { - now: date, address: address || '', limit, offset, diff --git a/pages/tokens/[id]/bid.gql b/pages/tokens/[id]/bid.gql index 06c0fd85..1ac1e149 100644 --- a/pages/tokens/[id]/bid.gql +++ b/pages/tokens/[id]/bid.gql @@ -3,7 +3,6 @@ query BidOnAsset( $collectionAddress: Address! $tokenId: String! $address: Address - $now: Datetime! ) { asset( chainId: $chainId @@ -47,28 +46,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 diff --git a/pages/tokens/[id]/bid.tsx b/pages/tokens/[id]/bid.tsx index a32e0f14..d339589b 100644 --- a/pages/tokens/[id]/bid.tsx +++ b/pages/tokens/[id]/bid.tsx @@ -16,11 +16,7 @@ import useRequiredQueryParamSingle from '../../../hooks/useRequiredQueryParamSin import SmallLayout from '../../../layouts/small' import Error from '../../_error' -type Props = { - now: string -} - -const BidPage: NextPage = ({ now }) => { +const BidPage: NextPage = () => { const { t } = useTranslation('templates') const { back, push } = useRouter() const toast = useToast() @@ -32,13 +28,11 @@ const BidPage: NextPage = ({ now }) => { ) invariant(chainId && collectionAddress && tokenId, 'Invalid asset id') - const date = useMemo(() => new Date(now), [now]) const { data } = useBidOnAssetQuery({ variables: { chainId: parseInt(chainId, 10), collectionAddress: collectionAddress, tokenId: tokenId, - now: date, address: address || '', }, }) diff --git a/pages/tokens/[id]/offer.gql b/pages/tokens/[id]/offer.gql index 969d6331..8938a913 100644 --- a/pages/tokens/[id]/offer.gql +++ b/pages/tokens/[id]/offer.gql @@ -3,7 +3,6 @@ query OfferForAsset( $collectionAddress: Address! $tokenId: String! $address: Address - $now: Datetime! ) { asset( chainId: $chainId @@ -42,28 +41,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 diff --git a/pages/tokens/[id]/offer.tsx b/pages/tokens/[id]/offer.tsx index c19b282b..ee5fbeba 100644 --- a/pages/tokens/[id]/offer.tsx +++ b/pages/tokens/[id]/offer.tsx @@ -19,7 +19,6 @@ import Error from '../../_error' type Props = { assetId: string - now: string currentAccount: string | null meta: { title: string @@ -28,7 +27,7 @@ type Props = { } } -const OfferPage: NextPage = ({ now }) => { +const OfferPage: NextPage = () => { const { t } = useTranslation('templates') const { back, push } = useRouter() const toast = useToast() @@ -41,13 +40,11 @@ const OfferPage: NextPage = ({ now }) => { ) invariant(chainId && collectionAddress && tokenId, 'Invalid asset id') - const date = useMemo(() => new Date(now), [now]) const { data } = useOfferForAssetQuery({ variables: { chainId: parseInt(chainId, 10), collectionAddress: collectionAddress, tokenId: tokenId, - now: date, address: address || '', }, }) diff --git a/pages/users/[id]/assetDetail.gql b/pages/users/[id]/assetDetail.gql index 1a28a27c..a3e4b851 100644 --- a/pages/users/[id]/assetDetail.gql +++ b/pages/users/[id]/assetDetail.gql @@ -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 diff --git a/pages/users/[id]/created.gql b/pages/users/[id]/created.gql index 70b349a9..4da36c6f 100644 --- a/pages/users/[id]/created.gql +++ b/pages/users/[id]/created.gql @@ -1,7 +1,6 @@ query FetchCreatedAssets( $address: Address! $currentAddress: Address! - $now: Datetime! $limit: Int! $offset: Int! $orderBy: [AssetsOrderBy!] diff --git a/pages/users/[id]/created.tsx b/pages/users/[id]/created.tsx index 3d4380f3..94fe4b6a 100644 --- a/pages/users/[id]/created.tsx +++ b/pages/users/[id]/created.tsx @@ -13,11 +13,7 @@ import usePaginateQuery from '../../../hooks/usePaginateQuery' import useRequiredQueryParamSingle from '../../../hooks/useRequiredQueryParamSingle' import LargeLayout from '../../../layouts/large' -type Props = { - now: string -} - -const CreatedPage: NextPage = ({ now }) => { +const CreatedPage: NextPage = () => { const { PAGINATION_LIMIT, BASE_URL } = useEnvironment() const { t } = useTranslation('templates') const { pathname, replace, query } = useRouter() @@ -27,7 +23,6 @@ const CreatedPage: NextPage = ({ now }) => { const { address } = useAccount() const userAddress = useRequiredQueryParamSingle('id') - const date = useMemo(() => new Date(now), [now]) const { data } = useFetchCreatedAssetsQuery({ variables: { address: userAddress, @@ -35,7 +30,6 @@ const CreatedPage: NextPage = ({ now }) => { limit, offset, orderBy, - now: date, }, }) diff --git a/pages/users/[id]/owned.gql b/pages/users/[id]/owned.gql index 03fb39b0..d1347fda 100644 --- a/pages/users/[id]/owned.gql +++ b/pages/users/[id]/owned.gql @@ -1,7 +1,6 @@ query FetchOwnedAssets( $address: Address! $currentAddress: Address! - $now: Datetime! $limit: Int! $offset: Int! $orderBy: [OwnershipsOrderBy!] diff --git a/pages/users/[id]/owned.tsx b/pages/users/[id]/owned.tsx index 9952f4ea..42a284de 100644 --- a/pages/users/[id]/owned.tsx +++ b/pages/users/[id]/owned.tsx @@ -18,11 +18,7 @@ import usePaginateQuery from '../../../hooks/usePaginateQuery' import useRequiredQueryParamSingle from '../../../hooks/useRequiredQueryParamSingle' import LargeLayout from '../../../layouts/large' -type Props = { - now: string -} - -const OwnedPage: NextPage = ({ now }) => { +const OwnedPage: NextPage = () => { const { PAGINATION_LIMIT, BASE_URL } = useEnvironment() const { t } = useTranslation('templates') const { pathname, replace, query } = useRouter() @@ -32,7 +28,6 @@ const OwnedPage: NextPage = ({ now }) => { const { address } = useAccount() const userAddress = useRequiredQueryParamSingle('id') - const date = useMemo(() => new Date(now), [now]) const { data, refetch } = useFetchOwnedAssetsQuery({ variables: { address: userAddress, @@ -40,7 +35,6 @@ const OwnedPage: NextPage = ({ now }) => { limit, offset, orderBy, - now: date, }, }) From a31a0e1b3cf52da4b52da0b4ac1faaf8826a7b81 Mon Sep 17 00:00:00 2001 From: Nicolas Mahe Date: Fri, 2 Feb 2024 16:25:21 +0700 Subject: [PATCH 57/58] update lib to prerelease --- package-lock.json | 14 +++++++------- package.json | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/package-lock.json b/package-lock.json index 9abe47f6..d238a1de 100644 --- a/package-lock.json +++ b/package-lock.json @@ -55,7 +55,7 @@ "@graphql-codegen/typescript-react-apollo": "^4.1.0", "@graphql-eslint/eslint-plugin": "^3.20.1", "@next/bundle-analyzer": "^14.0.4", - "@nft/api-graphql": "^1.0.0-beta.51", + "@nft/api-graphql": "^1.0.0-beta.52-prerelease-3", "@types/nodemailer": "^6.4.14", "@types/nprogress": "^0.2.3", "@types/react": "^18.2.48", @@ -6724,9 +6724,9 @@ } }, "node_modules/@nft/api-graphql": { - "version": "1.0.0-beta.51", - "resolved": "https://registry.npmjs.org/@nft/api-graphql/-/api-graphql-1.0.0-beta.51.tgz", - "integrity": "sha512-IBpOGh0Xmu6CFQZqYTwVAahut/WiphjcsDT82td8xSpmwsE0AADIxZ97OP4cclDGBVVhX7bSvsQFge5HxCzxyA==", + "version": "1.0.0-beta.52-prerelease-3", + "resolved": "https://registry.npmjs.org/@nft/api-graphql/-/api-graphql-1.0.0-beta.52-prerelease-3.tgz", + "integrity": "sha512-FCYJOEb3V9GdM/6AIlJi/AS31Ia6/MnDpq3SxnofDsEhPD8IppRVmBKf0j8hejdL/CHVsNZwnRKsYsGTleVaGA==", "dev": true }, "node_modules/@nft/chat": { @@ -26699,9 +26699,9 @@ "optional": true }, "@nft/api-graphql": { - "version": "1.0.0-beta.51", - "resolved": "https://registry.npmjs.org/@nft/api-graphql/-/api-graphql-1.0.0-beta.51.tgz", - "integrity": "sha512-IBpOGh0Xmu6CFQZqYTwVAahut/WiphjcsDT82td8xSpmwsE0AADIxZ97OP4cclDGBVVhX7bSvsQFge5HxCzxyA==", + "version": "1.0.0-beta.52-prerelease-3", + "resolved": "https://registry.npmjs.org/@nft/api-graphql/-/api-graphql-1.0.0-beta.52-prerelease-3.tgz", + "integrity": "sha512-FCYJOEb3V9GdM/6AIlJi/AS31Ia6/MnDpq3SxnofDsEhPD8IppRVmBKf0j8hejdL/CHVsNZwnRKsYsGTleVaGA==", "dev": true }, "@nft/chat": { diff --git a/package.json b/package.json index f4718778..acdcd019 100644 --- a/package.json +++ b/package.json @@ -63,7 +63,7 @@ "@graphql-codegen/typescript-react-apollo": "^4.1.0", "@graphql-eslint/eslint-plugin": "^3.20.1", "@next/bundle-analyzer": "^14.0.4", - "@nft/api-graphql": "^1.0.0-beta.51", + "@nft/api-graphql": "^1.0.0-beta.52-prerelease-3", "@types/nodemailer": "^6.4.14", "@types/nprogress": "^0.2.3", "@types/react": "^18.2.48", From 838e6863fe3599458b31d9114a8bcf415219583b Mon Sep 17 00:00:00 2001 From: Nicolas Mahe Date: Fri, 2 Feb 2024 16:27:03 +0700 Subject: [PATCH 58/58] fix lint --- components/HomeSection/Assets.gql | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/components/HomeSection/Assets.gql b/components/HomeSection/Assets.gql index b6341f9e..ff20deae 100644 --- a/components/HomeSection/Assets.gql +++ b/components/HomeSection/Assets.gql @@ -13,11 +13,7 @@ query FetchDefaultAssetIds($limit: Int!) { } } -query FetchAssets( - $limit: Int! - $assetIds: [String!]! - $address: Address -) { +query FetchAssets($limit: Int!, $assetIds: [String!]!, $address: Address) { assets( filter: { quantity: { greaterThan: "0" }, id: { in: $assetIds } } first: $limit