Skip to content

Commit 519559b

Browse files
committed
updating branch with code and context
1 parent 344904b commit 519559b

File tree

2 files changed

+80
-224
lines changed

2 files changed

+80
-224
lines changed

website/next-env.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
/// <reference types="next/image-types/global" />
33

44
// NOTE: This file should not be edited
5-
// see https://nextjs.org/docs/basic-features/typescript for more information.
5+
// see https://nextjs.org/docs/pages/building-your-application/configuring/typescript for more information.

website/pages/en/cookbook/enums.mdx

Lines changed: 79 additions & 223 deletions
Original file line numberDiff line numberDiff line change
@@ -78,20 +78,26 @@ export function getMarketplaceName(marketplace: Marketplace): string {
7878
## Best Practices for Using Enums
7979

8080
- **Consistent Naming:** Use clear, descriptive names for enum values to improve readability.
81-
- **Centralized Management:** Keep enums in a single file for easier updates and management.
82-
- **Documentation:** Add comments to enum definitions for better context.
81+
- **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.
82+
- **Documentation:** Add comments to enum to clarify their purpose and usage.
8383

84-
## Sample Queries
84+
## Using Enums in Queries
8585

86-
### Query 1: Account With The Highest NFT Marketplace Interactions
86+
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.
8787

88-
The goal of this query is to:
88+
**Specifics**
8989

90-
- Find the account that has interacted with the most unique marketplaces
91-
- Obtain detailed information about the marketplace interactions
92-
- Determine total spending amount and NFT transactions
90+
- **Filtering with Enums:** Enums provide clear filters, allowing you to confidently include or exclude specific marketplaces.
91+
- **Enums in Responses:** Enums guarantee that only recognized marketplace names are returned, making the results standardized and accurate.
9392

94-
This query can be valuable for assessing an account's activity and involvement in the NFT marketplace ecosystem.
93+
### Sample Queries
94+
95+
#### Query 1: Account With The Highest NFT Marketplace Interactions
96+
97+
This query does the following:
98+
99+
- It finds the account with the highest unique NFT marketplace interactions, which is great for analyzing cross-marketplace activity.
100+
- The marketplaces field uses the marketplace enum, ensuring consistent and validated marketplace values in the response.
95101

96102
```gql
97103
{
@@ -102,25 +108,15 @@ This query can be valuable for assessing an account's activity and involvement i
102108
totalSpent
103109
uniqueMarketplacesCount
104110
marketplaces {
105-
marketplace
106-
}
107-
sent(first: 5) {
108-
...id
109-
tokenId
110-
value
111-
txHash
112-
}
113-
received(first: 5) {
114-
id
115-
tokenId
116-
value
117-
txHash
111+
marketplace # This field returns the enum value representing the marketplace
118112
}
119113
}
120114
}
121115
```
122116

123-
### Return
117+
#### Returns
118+
119+
This response provides account details and a list of unique marketplace interactions with enum values for standardized clarity:
124120

125121
```gql
126122
{
@@ -129,8 +125,8 @@ This query can be valuable for assessing an account's activity and involvement i
129125
{
130126
"id": "0xb3abc96cb9a61576c03c955d75b703a890a14aa0",
131127
"sendCount": "44",
132-
"receiveCount": "42",
133-
"totalSpent": "917500000000000000",
128+
"receiveCount": "44",
129+
"totalSpent": "1197500000000000000",
134130
"uniqueMarketplacesCount": "7",
135131
"marketplaces": [
136132
{
@@ -154,230 +150,90 @@ This query can be valuable for assessing an account's activity and involvement i
154150
{
155151
"marketplace": "NFTX"
156152
}
157-
],
158-
"sent": [
159-
{
160-
"id": "0x0008e69a698db8da6c4118ab44c140f0e19d553359a3ee2e5c294f55d94fc235-0xc4",
161-
"tokenId": "7702",
162-
"value": "1800000000000000000",
163-
"txHash": "0x0008e69a698db8da6c4118ab44c140f0e19d553359a3ee2e5c294f55d94fc235"
164-
},
165-
{
166-
"id": "0x2d0bcb70a84672c6ae96940721e8b421c223d5e48999d1d5ae2e2dbb9e24f812-0xab",
167-
"tokenId": "3848",
168-
"value": "550000000000000000",
169-
"txHash": "0x2d0bcb70a84672c6ae96940721e8b421c223d5e48999d1d5ae2e2dbb9e24f812"
170-
},
171-
{
172-
"id": "0x16b9f7234e254ce19804fb0bc3c8a66a0531a9c4a2655db808eec9960c057e81-0x207",
173-
"tokenId": "9670",
174-
"value": "1500000000000000000",
175-
"txHash": "0x16b9f7234e254ce19804fb0bc3c8a66a0531a9c4a2655db808eec9960c057e81"
176-
},
177-
{
178-
"id": "0x1a091ab78f78c96513f53d2fab670da37f9d8815f9a5807a2117ac1221210a6b-0x142",
179-
"tokenId": "8935",
180-
"value": "3273900000000000000",
181-
"txHash": "0x1a091ab78f78c96513f53d2fab670da37f9d8815f9a5807a2117ac1221210a6b"
182-
},
183-
{
184-
"id": "0x22e5331383c441c6083230f22795ae467024bff001055ede835d11ebbb8a0d30-0x134",
185-
"tokenId": "8555",
186-
"value": "2000000000000000000",
187-
"txHash": "0x22e5331383c441c6083230f22795ae467024bff001055ede835d11ebbb8a0d30"
188-
}
189-
],
190-
"received": [
191-
{
192-
"id": "0x018613dc9de37f2af7c7be354aa05820c841ce043d50631f716729d4dc4525bc-0x3e",
193-
"tokenId": "8555",
194-
"value": "98000000000000000",
195-
"txHash": "0x018613dc9de37f2af7c7be354aa05820c841ce043d50631f716729d4dc4525bc"
196-
},
197-
{
198-
"id": "0x6404355c5fd3514dac25cb72e8f041eb39bf325f8c895369b0c8b6f1e42d00cb-0x7",
199-
"tokenId": "9670",
200-
"value": "95000000000000000",
201-
"txHash": "0x6404355c5fd3514dac25cb72e8f041eb39bf325f8c895369b0c8b6f1e42d00cb"
202-
},
203-
{
204-
"id": "0x787fa58c36e234ab78aa551faedb61d0e9f8433d068a1d6575ff45bbd97af74e-0x3c",
205-
"tokenId": "8935",
206-
"value": "90000000000000000",
207-
"txHash": "0x787fa58c36e234ab78aa551faedb61d0e9f8433d068a1d6575ff45bbd97af74e"
208-
},
209-
{
210-
"id": "0xd618817c15aa703a97b98eabea17e4b37a4d7e509665eafd18814bc3d5675c1b-0x1c4",
211-
"tokenId": "7702",
212-
"value": "95000000000000000",
213-
"txHash": "0xd618817c15aa703a97b98eabea17e4b37a4d7e509665eafd18814bc3d5675c1b"
214-
},
215-
{
216-
"id": "0xffe41bb24b8882a9883f5d5aae710f606f854772af1dd2171b7729d8c953c358-0x115",
217-
"tokenId": "3848",
218-
"value": "0",
219-
"txHash": "0xffe41bb24b8882a9883f5d5aae710f606f854772af1dd2171b7729d8c953c358"
220-
}
221153
]
222154
}
223155
]
224156
}
225157
}
226158
```
227159

228-
### Query 2: Accounts That Engaged with the Most Unique Marketplaces
160+
#### Query 2: Most Active Marketplace for CryptoCoven transactions
229161

230-
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.
162+
This query does the following:
231163

232-
```graphql
164+
- It identifies the marketplace with the highest volume of CryptoCoven transactions.
165+
- It uses the marketplace enum to ensure that only valid marketplace types appear in the response, adding reliability and consistency to your data.
166+
167+
```gql
233168
{
234-
accounts(first: 5, orderBy: uniqueMarketplacesCount, orderDirection: desc) {
235-
id
236-
uniqueMarketplacesCount
237-
marketplaces {
238-
marketplace
239-
}
169+
marketplaceInteractions(first: 1, orderBy: transactionCount, orderDirection: desc) {
170+
marketplace
171+
transactionCount
240172
}
241173
}
242174
```
243175

244-
### Return
176+
#### Result 2
177+
178+
The expected response includes the marketplace and the corresponding transaction count, using the enum to indicate the marketplace type:
245179

246180
```gql
247181
{
248182
"data": {
249-
"accounts": [
183+
"marketplaceInteractions": [
250184
{
251-
"id": "0xb3abc96cb9a61576c03c955d75b703a890a14aa0",
252-
"uniqueMarketplacesCount": "7",
253-
"marketplaces": [
254-
{
255-
"marketplace": "OpenSeaV1"
256-
},
257-
{
258-
"marketplace": "OpenSeaV2"
259-
},
260-
{
261-
"marketplace": "GenieSwap"
262-
},
263-
{
264-
"marketplace": "CryptoCoven"
265-
},
266-
{
267-
"marketplace": "Unknown"
268-
},
269-
{
270-
"marketplace": "LooksRare"
271-
},
272-
{
273-
"marketplace": "NFTX"
274-
}
275-
]
276-
},
185+
"marketplace": "Unknown",
186+
"transactionCount": "222"
187+
}
188+
]
189+
}
190+
}
191+
```
192+
193+
#### Query 3: Marketplace Interactions with High Transaction Counts
194+
195+
This query does the following:
196+
197+
- It retrieves the top four marketplaces with over 100 transactions, excluding "Unknown" marketplaces.
198+
- It uses enums as filters to ensure that only valid marketplace types are included, increasing accuracy.
199+
200+
```gql
201+
{
202+
marketplaceInteractions(
203+
first: 4
204+
orderBy: transactionCount
205+
orderDirection: desc
206+
where: { transactionCount_gt: "100", marketplace_not: "Unknown" }
207+
) {
208+
marketplace
209+
transactionCount
210+
}
211+
}
212+
```
213+
214+
#### Result 3
215+
216+
Expected output includes the marketplaces that meet the criteria, each represented by an enum value:
217+
218+
```gql
219+
{
220+
"data": {
221+
"marketplaceInteractions": [
277222
{
278-
"id": "0x77bb41b3a80982e19daae2cfe94403afcc613489",
279-
"uniqueMarketplacesCount": "7",
280-
"marketplaces": [
281-
{
282-
"marketplace": "OpenSeaV1"
283-
},
284-
{
285-
"marketplace": "OpenSeaV2"
286-
},
287-
{
288-
"marketplace": "GenieSwap"
289-
},
290-
{
291-
"marketplace": "CryptoCoven"
292-
},
293-
{
294-
"marketplace": "Unknown"
295-
},
296-
{
297-
"marketplace": "LooksRare"
298-
},
299-
{
300-
"marketplace": "OxProtocolV2"
301-
}
302-
]
223+
"marketplace": "NFTX",
224+
"transactionCount": "201"
303225
},
304226
{
305-
"id": "0x66349e79e99ae4d661a5ebb5474759508d392da4",
306-
"uniqueMarketplacesCount": "7",
307-
"marketplaces": [
308-
{
309-
"marketplace": "OpenSeaV1"
310-
},
311-
{
312-
"marketplace": "OpenSeaV2"
313-
},
314-
{
315-
"marketplace": "GenieSwap"
316-
},
317-
{
318-
"marketplace": "CryptoCoven"
319-
},
320-
{
321-
"marketplace": "Unknown"
322-
},
323-
{
324-
"marketplace": "SeaPort"
325-
},
326-
{
327-
"marketplace": "LooksRare"
328-
}
329-
]
227+
"marketplace": "OpenSeaV1",
228+
"transactionCount": "148"
330229
},
331230
{
332-
"id": "0x2d0a51e142bf3f156a978175c05ec74a25bb4e4f",
333-
"uniqueMarketplacesCount": "7",
334-
"marketplaces": [
335-
{
336-
"marketplace": "OpenSeaV1"
337-
},
338-
{
339-
"marketplace": "OpenSeaV2"
340-
},
341-
{
342-
"marketplace": "GenieSwap"
343-
},
344-
{
345-
"marketplace": "CryptoCoven"
346-
},
347-
{
348-
"marketplace": "Unknown"
349-
},
350-
{
351-
"marketplace": "SeaPort"
352-
},
353-
{
354-
"marketplace": "LooksRare"
355-
}
356-
]
231+
"marketplace": "CryptoCoven",
232+
"transactionCount": "117"
357233
},
358234
{
359-
"id": "0xfb29cc23d5d7b705a0ab93d7a7cad6a01e52be94",
360-
"uniqueMarketplacesCount": "6",
361-
"marketplaces": [
362-
{
363-
"marketplace": "OpenSeaV1"
364-
},
365-
{
366-
"marketplace": "OpenSeaV2"
367-
},
368-
{
369-
"marketplace": "CryptoCoven"
370-
},
371-
{
372-
"marketplace": "Unknown"
373-
},
374-
{
375-
"marketplace": "LooksRare"
376-
},
377-
{
378-
"marketplace": "NFTX"
379-
}
380-
]
235+
"marketplace": "OpenSeaV1",
236+
"transactionCount": "111"
381237
}
382238
]
383239
}

0 commit comments

Comments
 (0)