diff --git a/website/next-env.d.ts b/website/next-env.d.ts index 4f11a03dc6cc..a4a7b3f5cfa2 100644 --- a/website/next-env.d.ts +++ b/website/next-env.d.ts @@ -2,4 +2,4 @@ /// // NOTE: This file should not be edited -// see https://nextjs.org/docs/basic-features/typescript for more information. +// see https://nextjs.org/docs/pages/building-your-application/configuring/typescript for more information. diff --git a/website/pages/en/cookbook/enums.mdx b/website/pages/en/cookbook/enums.mdx index d401cc56a757..fd636b010997 100644 --- a/website/pages/en/cookbook/enums.mdx +++ b/website/pages/en/cookbook/enums.mdx @@ -78,20 +78,26 @@ export function getMarketplaceName(marketplace: Marketplace): string { ## Best Practices for Using Enums - **Consistent Naming:** Use clear, descriptive names for enum values to improve readability. -- **Centralized Management:** Keep enums in a single file for easier updates and management. -- **Documentation:** Add comments to enum definitions for better context. +- **Centralized Management:** Keep enums in a single file for consistency. This makes enums easier to update and ensures they are the single source of truth. +- **Documentation:** Add comments to enum to clarify their purpose and usage. -## Sample Queries +## Using Enums in Queries -### Query 1: Account With The Highest NFT Marketplace Interactions +Enums in queries help you improve data quality and make your results easier to interpret. They function as filters and response elements, ensuring consistency and reducing errors in marketplace values. -The goal of this query is to: +**Specifics** -- Find the account that has interacted with the most unique marketplaces -- Obtain detailed information about the marketplace interactions -- Determine total spending amount and NFT transactions +- **Filtering with Enums:** Enums provide clear filters, allowing you to confidently include or exclude specific marketplaces. +- **Enums in Responses:** Enums guarantee that only recognized marketplace names are returned, making the results standardized and accurate. -This query can be valuable for assessing an account's activity and involvement in the NFT marketplace ecosystem. +### Sample Queries + +#### Query 1: Account With The Highest NFT Marketplace Interactions + +This query does the following: + +- It finds the account with the highest unique NFT marketplace interactions, which is great for analyzing cross-marketplace activity. +- The marketplaces field uses the marketplace enum, ensuring consistent and validated marketplace values in the response. ```gql { @@ -102,25 +108,15 @@ This query can be valuable for assessing an account's activity and involvement i totalSpent uniqueMarketplacesCount marketplaces { - marketplace - } - sent(first: 5) { - ...id - tokenId - value - txHash - } - received(first: 5) { - id - tokenId - value - txHash + marketplace # This field returns the enum value representing the marketplace } } } ``` -### Return +#### Returns + +This response provides account details and a list of unique marketplace interactions with enum values for standardized clarity: ```gql { @@ -129,8 +125,8 @@ This query can be valuable for assessing an account's activity and involvement i { "id": "0xb3abc96cb9a61576c03c955d75b703a890a14aa0", "sendCount": "44", - "receiveCount": "42", - "totalSpent": "917500000000000000", + "receiveCount": "44", + "totalSpent": "1197500000000000000", "uniqueMarketplacesCount": "7", "marketplaces": [ { @@ -154,70 +150,6 @@ This query can be valuable for assessing an account's activity and involvement i { "marketplace": "NFTX" } - ], - "sent": [ - { - "id": "0x0008e69a698db8da6c4118ab44c140f0e19d553359a3ee2e5c294f55d94fc235-0xc4", - "tokenId": "7702", - "value": "1800000000000000000", - "txHash": "0x0008e69a698db8da6c4118ab44c140f0e19d553359a3ee2e5c294f55d94fc235" - }, - { - "id": "0x2d0bcb70a84672c6ae96940721e8b421c223d5e48999d1d5ae2e2dbb9e24f812-0xab", - "tokenId": "3848", - "value": "550000000000000000", - "txHash": "0x2d0bcb70a84672c6ae96940721e8b421c223d5e48999d1d5ae2e2dbb9e24f812" - }, - { - "id": "0x16b9f7234e254ce19804fb0bc3c8a66a0531a9c4a2655db808eec9960c057e81-0x207", - "tokenId": "9670", - "value": "1500000000000000000", - "txHash": "0x16b9f7234e254ce19804fb0bc3c8a66a0531a9c4a2655db808eec9960c057e81" - }, - { - "id": "0x1a091ab78f78c96513f53d2fab670da37f9d8815f9a5807a2117ac1221210a6b-0x142", - "tokenId": "8935", - "value": "3273900000000000000", - "txHash": "0x1a091ab78f78c96513f53d2fab670da37f9d8815f9a5807a2117ac1221210a6b" - }, - { - "id": "0x22e5331383c441c6083230f22795ae467024bff001055ede835d11ebbb8a0d30-0x134", - "tokenId": "8555", - "value": "2000000000000000000", - "txHash": "0x22e5331383c441c6083230f22795ae467024bff001055ede835d11ebbb8a0d30" - } - ], - "received": [ - { - "id": "0x018613dc9de37f2af7c7be354aa05820c841ce043d50631f716729d4dc4525bc-0x3e", - "tokenId": "8555", - "value": "98000000000000000", - "txHash": "0x018613dc9de37f2af7c7be354aa05820c841ce043d50631f716729d4dc4525bc" - }, - { - "id": "0x6404355c5fd3514dac25cb72e8f041eb39bf325f8c895369b0c8b6f1e42d00cb-0x7", - "tokenId": "9670", - "value": "95000000000000000", - "txHash": "0x6404355c5fd3514dac25cb72e8f041eb39bf325f8c895369b0c8b6f1e42d00cb" - }, - { - "id": "0x787fa58c36e234ab78aa551faedb61d0e9f8433d068a1d6575ff45bbd97af74e-0x3c", - "tokenId": "8935", - "value": "90000000000000000", - "txHash": "0x787fa58c36e234ab78aa551faedb61d0e9f8433d068a1d6575ff45bbd97af74e" - }, - { - "id": "0xd618817c15aa703a97b98eabea17e4b37a4d7e509665eafd18814bc3d5675c1b-0x1c4", - "tokenId": "7702", - "value": "95000000000000000", - "txHash": "0xd618817c15aa703a97b98eabea17e4b37a4d7e509665eafd18814bc3d5675c1b" - }, - { - "id": "0xffe41bb24b8882a9883f5d5aae710f606f854772af1dd2171b7729d8c953c358-0x115", - "tokenId": "3848", - "value": "0", - "txHash": "0xffe41bb24b8882a9883f5d5aae710f606f854772af1dd2171b7729d8c953c358" - } ] } ] @@ -225,159 +157,83 @@ This query can be valuable for assessing an account's activity and involvement i } ``` -### Query 2: Accounts That Engaged with the Most Unique Marketplaces +#### Query 2: Most Active Marketplace for CryptoCoven transactions -This query retrieves the top 5 accounts that have interacted with the most unique marketplaces. The marketplace field retrieves a list of interactions for each account. +This query does the following: -```graphql +- It identifies the marketplace with the highest volume of CryptoCoven transactions. +- It uses the marketplace enum to ensure that only valid marketplace types appear in the response, adding reliability and consistency to your data. + +```gql { - accounts(first: 5, orderBy: uniqueMarketplacesCount, orderDirection: desc) { - id - uniqueMarketplacesCount - marketplaces { - marketplace - } + marketplaceInteractions(first: 1, orderBy: transactionCount, orderDirection: desc) { + marketplace + transactionCount } } ``` -### Return +#### Result 2 + +The expected response includes the marketplace and the corresponding transaction count, using the enum to indicate the marketplace type: ```gql { "data": { - "accounts": [ + "marketplaceInteractions": [ { - "id": "0xb3abc96cb9a61576c03c955d75b703a890a14aa0", - "uniqueMarketplacesCount": "7", - "marketplaces": [ - { - "marketplace": "OpenSeaV1" - }, - { - "marketplace": "OpenSeaV2" - }, - { - "marketplace": "GenieSwap" - }, - { - "marketplace": "CryptoCoven" - }, - { - "marketplace": "Unknown" - }, - { - "marketplace": "LooksRare" - }, - { - "marketplace": "NFTX" - } - ] - }, + "marketplace": "Unknown", + "transactionCount": "222" + } + ] + } +} +``` + +#### Query 3: Marketplace Interactions with High Transaction Counts + +This query does the following: + +- It retrieves the top four marketplaces with over 100 transactions, excluding "Unknown" marketplaces. +- It uses enums as filters to ensure that only valid marketplace types are included, increasing accuracy. + +```gql +{ + marketplaceInteractions( + first: 4 + orderBy: transactionCount + orderDirection: desc + where: { transactionCount_gt: "100", marketplace_not: "Unknown" } + ) { + marketplace + transactionCount + } +} +``` + +#### Result 3 + +Expected output includes the marketplaces that meet the criteria, each represented by an enum value: + +```gql +{ + "data": { + "marketplaceInteractions": [ { - "id": "0x77bb41b3a80982e19daae2cfe94403afcc613489", - "uniqueMarketplacesCount": "7", - "marketplaces": [ - { - "marketplace": "OpenSeaV1" - }, - { - "marketplace": "OpenSeaV2" - }, - { - "marketplace": "GenieSwap" - }, - { - "marketplace": "CryptoCoven" - }, - { - "marketplace": "Unknown" - }, - { - "marketplace": "LooksRare" - }, - { - "marketplace": "OxProtocolV2" - } - ] + "marketplace": "NFTX", + "transactionCount": "201" }, { - "id": "0x66349e79e99ae4d661a5ebb5474759508d392da4", - "uniqueMarketplacesCount": "7", - "marketplaces": [ - { - "marketplace": "OpenSeaV1" - }, - { - "marketplace": "OpenSeaV2" - }, - { - "marketplace": "GenieSwap" - }, - { - "marketplace": "CryptoCoven" - }, - { - "marketplace": "Unknown" - }, - { - "marketplace": "SeaPort" - }, - { - "marketplace": "LooksRare" - } - ] + "marketplace": "OpenSeaV1", + "transactionCount": "148" }, { - "id": "0x2d0a51e142bf3f156a978175c05ec74a25bb4e4f", - "uniqueMarketplacesCount": "7", - "marketplaces": [ - { - "marketplace": "OpenSeaV1" - }, - { - "marketplace": "OpenSeaV2" - }, - { - "marketplace": "GenieSwap" - }, - { - "marketplace": "CryptoCoven" - }, - { - "marketplace": "Unknown" - }, - { - "marketplace": "SeaPort" - }, - { - "marketplace": "LooksRare" - } - ] + "marketplace": "CryptoCoven", + "transactionCount": "117" }, { - "id": "0xfb29cc23d5d7b705a0ab93d7a7cad6a01e52be94", - "uniqueMarketplacesCount": "6", - "marketplaces": [ - { - "marketplace": "OpenSeaV1" - }, - { - "marketplace": "OpenSeaV2" - }, - { - "marketplace": "CryptoCoven" - }, - { - "marketplace": "Unknown" - }, - { - "marketplace": "LooksRare" - }, - { - "marketplace": "NFTX" - } - ] + "marketplace": "OpenSeaV1", + "transactionCount": "111" } ] }