@zoralabs/coins-sdk 0.0.2-sdkalpha.3 → 0.0.2-sdkalpha.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/README.md +448 -18
- package/dist/actions/getOnchainCoinDetails.d.ts +3 -2
- package/dist/actions/getOnchainCoinDetails.d.ts.map +1 -1
- package/dist/api/api-key.d.ts +9 -0
- package/dist/api/api-key.d.ts.map +1 -0
- package/dist/api/explore.d.ts +347 -0
- package/dist/api/explore.d.ts.map +1 -0
- package/dist/api/index.d.ts +4 -0
- package/dist/api/index.d.ts.map +1 -0
- package/dist/api/queries.d.ts +345 -0
- package/dist/api/queries.d.ts.map +1 -0
- package/dist/client/sdk.gen.d.ts +240 -27
- package/dist/client/sdk.gen.d.ts.map +1 -1
- package/dist/client/types.gen.d.ts +362 -32
- package/dist/client/types.gen.d.ts.map +1 -1
- package/dist/index.cjs +104 -41
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +5 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +94 -44
- package/dist/index.js.map +1 -1
- package/dist/utils/genericPublicClient.d.ts +3 -0
- package/dist/utils/genericPublicClient.d.ts.map +1 -0
- package/dist/utils/validateClientNetwork.d.ts +1 -1
- package/dist/utils/validateClientNetwork.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/actions/getOnchainCoinDetails.ts +2 -2
- package/src/api/api-key.ts +15 -0
- package/src/api/explore.ts +55 -0
- package/src/api/index.ts +8 -0
- package/src/api/queries.ts +60 -0
- package/src/client/sdk.gen.ts +109 -32
- package/src/client/types.gen.ts +529 -178
- package/src/index.ts +16 -6
- package/src/utils/genericPublicClient.ts +5 -0
- package/src/utils/validateClientNetwork.ts +16 -12
- package/dist/client/explore.d.ts +0 -271
- package/dist/client/explore.d.ts.map +0 -1
- package/src/client/explore.ts +0 -55
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -6,25 +6,34 @@ This SDK is based off of viem v2 and exposes both functions to get the viem call
|
|
|
6
6
|
|
|
7
7
|
Devs can input their addresses in `platformReferrer` and `traderReferrer` fields to earn trade and create referral fees for their platform.
|
|
8
8
|
|
|
9
|
-
This prerelease SDK has
|
|
9
|
+
This prerelease SDK has two main categories of functionality: Onchain Actions and Queries.
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
All the SDK functions are accessible from the main export (for example: `import {createCoin, getCoin} from "@zoralabs/coins-sdk"`).
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
- `coin`: The coin contract address.
|
|
15
|
-
- `user`: The user address to check balance for. (Optional)
|
|
16
|
-
- `publicClient`: The viem public client instance.
|
|
13
|
+
## Table of Contents
|
|
17
14
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
15
|
+
### Onchain Actions
|
|
16
|
+
- [createCoin](#1-createcoin-creates-a-new-coin-with-the-given-parameters-to-trade)
|
|
17
|
+
- [tradeCoin](#2-tradecoin-buys-or-sells-an-existing-coin)
|
|
18
|
+
- [updateCoinURI](#3-updatecoinuri-updates-the-uri-for-an-existing-coin)
|
|
19
|
+
|
|
20
|
+
### Queries
|
|
21
|
+
- [getOnchainCoinDetails](#1-getonchaincoindetails-gets-details-for-the-given-coin-from-the-blockchain)
|
|
22
|
+
- [API Key](#2-api-key)
|
|
23
|
+
- [Cursor Pagination](#cursor-pagination)
|
|
24
|
+
- [API Queries](#3-api-queries)
|
|
25
|
+
- [Explore Queries](#4-explore-queries)
|
|
26
|
+
- [getCoin](#getcoin-get-details-for-a-specific-coin)
|
|
27
|
+
- [getCoins](#getcoins-get-details-for-multiple-coins)
|
|
28
|
+
- [getCoinComments](#getcoincomments-get-comments-for-a-coin)
|
|
29
|
+
- [getProfile](#getprofile-get-profile-information)
|
|
30
|
+
- [getProfileOwned](#getprofileowned-get-coins-owned-by-a-profile)
|
|
31
|
+
|
|
32
|
+
## Onchain Actions
|
|
33
|
+
|
|
34
|
+
These are functions that interact directly with the blockchain and require transaction signing.
|
|
26
35
|
|
|
27
|
-
|
|
36
|
+
### 1. `createCoin`: Creates a new coin with the given parameters to trade.
|
|
28
37
|
|
|
29
38
|
**Key Parameters:**
|
|
30
39
|
- `name`: The name of the new coin.
|
|
@@ -66,7 +75,7 @@ This prerelease SDK has 3 core features: `createCoin`, `tradeCoin`, and `getCoin
|
|
|
66
75
|
// the receipt can be parsed from `getCoinCreateFromLogs(receipt.logs)`
|
|
67
76
|
```
|
|
68
77
|
|
|
69
|
-
|
|
78
|
+
### 2. `tradeCoin`: Buys or sells an existing coin.
|
|
70
79
|
|
|
71
80
|
**Key Parameters:**
|
|
72
81
|
- `direction`: The trade direction, either 'buy' or 'sell'.
|
|
@@ -94,7 +103,7 @@ This prerelease SDK has 3 core features: `createCoin`, `tradeCoin`, and `getCoin
|
|
|
94
103
|
```
|
|
95
104
|
|
|
96
105
|
**Lower Level Call Method with WAGMI:**
|
|
97
|
-
Use the `tradeCoinCall` function to get the contract call parameters and then use WAGMI's `useContractWrite` hook.
|
|
106
|
+
Use the `tradeCoinCall` function to get the contract call parameters and then use WAGMI's `useContractWrite` hook.
|
|
98
107
|
|
|
99
108
|
```typescript
|
|
100
109
|
const tradeParams = {
|
|
@@ -107,6 +116,427 @@ This prerelease SDK has 3 core features: `createCoin`, `tradeCoin`, and `getCoin
|
|
|
107
116
|
};
|
|
108
117
|
|
|
109
118
|
const { config } = tradeCoinCall(tradeParams);
|
|
110
|
-
const { write
|
|
119
|
+
const { write } = useContractWrite(config);
|
|
120
|
+
|
|
121
|
+
write(); // Execute the contract write
|
|
111
122
|
// the receipt can be parsed from `getTradeFromLogs(receipt.logs)`
|
|
112
123
|
```
|
|
124
|
+
|
|
125
|
+
### 3. `updateCoinURI`: Updates the URI for an existing coin.
|
|
126
|
+
|
|
127
|
+
**Key Parameters:**
|
|
128
|
+
- `coin`: The coin contract address.
|
|
129
|
+
- `newURI`: The new URI for the coin metadata (must start with "ipfs://").
|
|
130
|
+
|
|
131
|
+
**Usage:**
|
|
132
|
+
```typescript
|
|
133
|
+
const updateParams = {
|
|
134
|
+
coin: "0xCoinAddress",
|
|
135
|
+
newURI: "ipfs://new-metadata-uri",
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
const result = await updateCoinURI(updateParams, walletClient, publicClient);
|
|
139
|
+
console.log(result);
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
**Lower Level Call Method with WAGMI:**
|
|
143
|
+
```typescript
|
|
144
|
+
const updateParams = {
|
|
145
|
+
coin: "0xCoinAddress",
|
|
146
|
+
newURI: "ipfs://new-metadata-uri",
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
const { config } = updateCoinURICall(updateParams);
|
|
150
|
+
const { write } = useContractWrite(config);
|
|
151
|
+
|
|
152
|
+
write(); // Execute the contract write
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
## Onchain Queries
|
|
156
|
+
|
|
157
|
+
These are functions that read data from the blockchain or API without requiring transaction signing.
|
|
158
|
+
|
|
159
|
+
### 1. `getOnchainCoinDetails`: Gets details for the given coin from the blockchain.
|
|
160
|
+
|
|
161
|
+
This query retrieves the most up-to-date coin information directly from the blockchain.
|
|
162
|
+
It is strongly recommended to use the other API queries to fetch this information if possible.
|
|
163
|
+
|
|
164
|
+
**Key Parameters:**
|
|
165
|
+
- `coin`: The coin contract address.
|
|
166
|
+
- `user`: The user address to check balance for. (Optional)
|
|
167
|
+
- `publicClient`: The viem public client instance.
|
|
168
|
+
|
|
169
|
+
**Return Value:**
|
|
170
|
+
- `balance`: The user's balance of the coin.
|
|
171
|
+
- `marketCap`: The market cap of the coin.
|
|
172
|
+
- `liquidity`: The liquidity of the coin.
|
|
173
|
+
- `pool`: Pool address.
|
|
174
|
+
- `poolState`: Current state of the UniswapV3 pool.
|
|
175
|
+
- `owners`: List of owners for the coin.
|
|
176
|
+
- `payoutRecipient`: The payout recipient address.
|
|
177
|
+
|
|
178
|
+
### 2. API Queries
|
|
179
|
+
|
|
180
|
+
These functions interact with the Zora API to fetch additional data:
|
|
181
|
+
|
|
182
|
+
#### API Key
|
|
183
|
+
|
|
184
|
+
To get a higher rate limit and fully use the zora API, an API key is required.
|
|
185
|
+
|
|
186
|
+
To set the API key, you can use the `setApiKey` function which will apply your API key to all requests.
|
|
187
|
+
|
|
188
|
+
```typescript
|
|
189
|
+
setApiKey("your-api-key");
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
Please DM the Zora team to get the API key.
|
|
193
|
+
|
|
194
|
+
These queries allow non-api-key access for reasonable development usage.
|
|
195
|
+
|
|
196
|
+
#### Cursor Pagination
|
|
197
|
+
|
|
198
|
+
Many queries support cursor-based pagination using the `after` parameter. To paginate through results:
|
|
199
|
+
|
|
200
|
+
1. Make your initial query without an `after` parameter
|
|
201
|
+
2. From the response, get the `endCursor` from the `pageInfo` object
|
|
202
|
+
3. Pass this `endCursor` as the `after` parameter in your next query
|
|
203
|
+
|
|
204
|
+
**Example:**
|
|
205
|
+
```typescript
|
|
206
|
+
// First page
|
|
207
|
+
const firstPage = await getTopGainers({
|
|
208
|
+
count: 10
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
// Get the cursor for the next page
|
|
212
|
+
const nextCursor = firstPage.exploreList?.pageInfo?.endCursor;
|
|
213
|
+
|
|
214
|
+
// Fetch next page using the cursor
|
|
215
|
+
if (nextCursor) {
|
|
216
|
+
const nextPage = await getTopGainers({
|
|
217
|
+
count: 10,
|
|
218
|
+
after: nextCursor
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
**Complete Pagination Example:**
|
|
224
|
+
```typescript
|
|
225
|
+
async function fetchAllTopGainers() {
|
|
226
|
+
const allResults = [];
|
|
227
|
+
let hasNextPage = true;
|
|
228
|
+
let cursor: string | undefined;
|
|
229
|
+
|
|
230
|
+
while (hasNextPage) {
|
|
231
|
+
const response = await getTopGainers({
|
|
232
|
+
count: 10,
|
|
233
|
+
after: cursor
|
|
234
|
+
});
|
|
235
|
+
|
|
236
|
+
const { edges, pageInfo } = response.exploreList || {};
|
|
237
|
+
|
|
238
|
+
if (edges) {
|
|
239
|
+
allResults.push(...edges.map(edge => edge.node));
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
hasNextPage = pageInfo?.hasNextPage || false;
|
|
243
|
+
cursor = pageInfo?.endCursor;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
return allResults;
|
|
247
|
+
}
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
This pagination pattern works for all queries that return `pageInfo` with `endCursor` and `hasNextPage`, including:
|
|
251
|
+
- All explore queries
|
|
252
|
+
- `getCoinComments`
|
|
253
|
+
- `getProfileOwned`
|
|
254
|
+
|
|
255
|
+
#### `getCoin`: Get details for a specific coin
|
|
256
|
+
**Parameters:**
|
|
257
|
+
- `address`: The coin contract address
|
|
258
|
+
- `chain`: (Optional) The chain ID
|
|
259
|
+
|
|
260
|
+
**Returns:**
|
|
261
|
+
```typescript
|
|
262
|
+
{
|
|
263
|
+
zora20Token?: {
|
|
264
|
+
id?: string;
|
|
265
|
+
name?: string;
|
|
266
|
+
description?: string;
|
|
267
|
+
address?: string;
|
|
268
|
+
symbol?: string;
|
|
269
|
+
totalSupply?: string;
|
|
270
|
+
totalVolume?: string;
|
|
271
|
+
volume24h?: string;
|
|
272
|
+
createdAt?: string;
|
|
273
|
+
creatorAddress?: string;
|
|
274
|
+
creatorEarnings?: Array<{
|
|
275
|
+
amount?: {
|
|
276
|
+
currency?: { address?: string };
|
|
277
|
+
amountRaw?: string;
|
|
278
|
+
amountDecimal?: number;
|
|
279
|
+
};
|
|
280
|
+
amountUsd?: string;
|
|
281
|
+
}>;
|
|
282
|
+
marketCap?: string;
|
|
283
|
+
marketCapDelta24h?: string;
|
|
284
|
+
chainId?: number;
|
|
285
|
+
creatorProfile?: string;
|
|
286
|
+
handle?: string;
|
|
287
|
+
avatar?: {
|
|
288
|
+
previewImage?: string;
|
|
289
|
+
blurhash?: string;
|
|
290
|
+
small?: string;
|
|
291
|
+
};
|
|
292
|
+
media?: {
|
|
293
|
+
mimeType?: string;
|
|
294
|
+
originalUri?: string;
|
|
295
|
+
format?: string;
|
|
296
|
+
previewImage?: string;
|
|
297
|
+
medium?: string;
|
|
298
|
+
blurhash?: string;
|
|
299
|
+
};
|
|
300
|
+
transfers?: { count?: number };
|
|
301
|
+
uniqueHolders?: number;
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
#### `getCoins`: Get details for multiple coins
|
|
307
|
+
**Parameters:**
|
|
308
|
+
- `coins`: Array of coin objects with:
|
|
309
|
+
- `chainId`: (Optional) The chain ID
|
|
310
|
+
- `collectionAddress`: The coin contract address
|
|
311
|
+
|
|
312
|
+
**Returns:** Array of coin details in the same format as `getCoin`
|
|
313
|
+
|
|
314
|
+
#### `getCoinComments`: Get comments for a coin
|
|
315
|
+
**Parameters:**
|
|
316
|
+
- `address`: The coin contract address
|
|
317
|
+
- `chain`: (Optional) The chain ID
|
|
318
|
+
- `after`: (Optional) Pagination cursor
|
|
319
|
+
- `count`: (Optional) Number of comments to return
|
|
320
|
+
|
|
321
|
+
**Returns:**
|
|
322
|
+
```typescript
|
|
323
|
+
{
|
|
324
|
+
zora20Token?: {
|
|
325
|
+
zoraComments?: {
|
|
326
|
+
pageInfo?: {
|
|
327
|
+
endCursor?: string;
|
|
328
|
+
hasNextPage?: boolean;
|
|
329
|
+
};
|
|
330
|
+
count?: number;
|
|
331
|
+
edges?: Array<{
|
|
332
|
+
node?: string;
|
|
333
|
+
txHash?: string;
|
|
334
|
+
comment?: string;
|
|
335
|
+
userAddress?: string;
|
|
336
|
+
timestamp?: number;
|
|
337
|
+
userProfile?: string;
|
|
338
|
+
id?: string;
|
|
339
|
+
handle?: string;
|
|
340
|
+
avatar?: {
|
|
341
|
+
previewImage?: string;
|
|
342
|
+
blurhash?: string;
|
|
343
|
+
small?: string;
|
|
344
|
+
};
|
|
345
|
+
replies?: {
|
|
346
|
+
count?: number;
|
|
347
|
+
edges?: Array<{
|
|
348
|
+
node?: {
|
|
349
|
+
txHash?: string;
|
|
350
|
+
comment?: string;
|
|
351
|
+
userAddress?: string;
|
|
352
|
+
timestamp?: number;
|
|
353
|
+
userProfile?: string;
|
|
354
|
+
id?: string;
|
|
355
|
+
handle?: string;
|
|
356
|
+
avatar?: {
|
|
357
|
+
previewImage?: string;
|
|
358
|
+
blurhash?: string;
|
|
359
|
+
small?: string;
|
|
360
|
+
};
|
|
361
|
+
};
|
|
362
|
+
}>;
|
|
363
|
+
};
|
|
364
|
+
}>;
|
|
365
|
+
};
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
```
|
|
369
|
+
|
|
370
|
+
#### `getProfile`: Get profile information
|
|
371
|
+
**Parameters:**
|
|
372
|
+
- `identifier`: The profile identifier (username, handle, or address)
|
|
373
|
+
|
|
374
|
+
**Returns:**
|
|
375
|
+
```typescript
|
|
376
|
+
{
|
|
377
|
+
profile?: string;
|
|
378
|
+
id?: string;
|
|
379
|
+
handle?: string;
|
|
380
|
+
avatar?: {
|
|
381
|
+
small?: string;
|
|
382
|
+
medium?: string;
|
|
383
|
+
blurhash?: string;
|
|
384
|
+
};
|
|
385
|
+
username?: string;
|
|
386
|
+
displayName?: string;
|
|
387
|
+
bio?: string;
|
|
388
|
+
website?: string;
|
|
389
|
+
publicWallet?: {
|
|
390
|
+
walletAddress?: string;
|
|
391
|
+
};
|
|
392
|
+
linkedWallets?: {
|
|
393
|
+
edges?: Array<{
|
|
394
|
+
node?: {
|
|
395
|
+
walletType?: "PRIVY" | "EXTERNAL" | "SMART_WALLET";
|
|
396
|
+
walletAddress?: string;
|
|
397
|
+
};
|
|
398
|
+
}>;
|
|
399
|
+
};
|
|
400
|
+
}
|
|
401
|
+
```
|
|
402
|
+
|
|
403
|
+
#### `getProfileOwned`: Get coins owned by a profile
|
|
404
|
+
**Parameters:**
|
|
405
|
+
- `identifier`: The profile identifier (username, handle, or address)
|
|
406
|
+
- `count`: (Optional) Number of items to return
|
|
407
|
+
- `after`: (Optional) Pagination cursor
|
|
408
|
+
- `chainIds`: (Optional) Array of chain IDs to filter by
|
|
409
|
+
|
|
410
|
+
**Returns:**
|
|
411
|
+
```typescript
|
|
412
|
+
{
|
|
413
|
+
profile?: string;
|
|
414
|
+
id?: string;
|
|
415
|
+
handle?: string;
|
|
416
|
+
avatar?: {
|
|
417
|
+
previewImage?: string;
|
|
418
|
+
blurhash?: string;
|
|
419
|
+
small?: string;
|
|
420
|
+
};
|
|
421
|
+
coinBalances?: {
|
|
422
|
+
count?: number;
|
|
423
|
+
edges?: Array<{
|
|
424
|
+
node?: {
|
|
425
|
+
balance?: string;
|
|
426
|
+
id?: string;
|
|
427
|
+
coin?: {
|
|
428
|
+
// Same coin details as getCoin
|
|
429
|
+
};
|
|
430
|
+
};
|
|
431
|
+
}>;
|
|
432
|
+
pageInfo?: {
|
|
433
|
+
hasNextPage?: boolean;
|
|
434
|
+
endCursor?: string;
|
|
435
|
+
};
|
|
436
|
+
};
|
|
437
|
+
}
|
|
438
|
+
```
|
|
439
|
+
|
|
440
|
+
### 3. Explore Queries
|
|
441
|
+
|
|
442
|
+
These functions fetch curated lists of coins. All explore queries share the same parameters and return type:
|
|
443
|
+
|
|
444
|
+
**Parameters:**
|
|
445
|
+
- `count`: (Optional) Number of items to return
|
|
446
|
+
- `after`: (Optional) Pagination cursor
|
|
447
|
+
|
|
448
|
+
**Returns:**
|
|
449
|
+
```typescript
|
|
450
|
+
{
|
|
451
|
+
exploreList?: {
|
|
452
|
+
edges?: Array<{
|
|
453
|
+
node?: {
|
|
454
|
+
// Same coin details as getCoin
|
|
455
|
+
};
|
|
456
|
+
cursor?: string;
|
|
457
|
+
}>;
|
|
458
|
+
pageInfo?: {
|
|
459
|
+
endCursor?: string;
|
|
460
|
+
hasNextPage?: boolean;
|
|
461
|
+
};
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
```
|
|
465
|
+
|
|
466
|
+
Available explore queries:
|
|
467
|
+
- `getTopGainers`: Get top gaining coins
|
|
468
|
+
- `getTopVolume24h`: Get coins with highest 24h volume
|
|
469
|
+
- `getMostValuable`: Get most valuable coins
|
|
470
|
+
- `getNew`: Get newly created coins
|
|
471
|
+
- `getLastTraded`: Get recently traded coins
|
|
472
|
+
- `getLastTradedUnique`: Get recently traded unique coins
|
|
473
|
+
|
|
474
|
+
**Usage Example:**
|
|
475
|
+
```typescript
|
|
476
|
+
const topGainers = await getTopGainers({
|
|
477
|
+
count: 10,
|
|
478
|
+
after: "cursor"
|
|
479
|
+
});
|
|
480
|
+
const newCoins = await getNew({
|
|
481
|
+
count: 20
|
|
482
|
+
});
|
|
483
|
+
```
|
|
484
|
+
|
|
485
|
+
### 4. Cursor Pagination
|
|
486
|
+
|
|
487
|
+
Many queries support cursor-based pagination using the `after` parameter. To paginate through results:
|
|
488
|
+
|
|
489
|
+
1. Make your initial query without an `after` parameter
|
|
490
|
+
2. From the response, get the `endCursor` from the `pageInfo` object
|
|
491
|
+
3. Pass this `endCursor` as the `after` parameter in your next query
|
|
492
|
+
|
|
493
|
+
**Example:**
|
|
494
|
+
```typescript
|
|
495
|
+
// First page
|
|
496
|
+
const firstPage = await getTopGainers({
|
|
497
|
+
count: 10
|
|
498
|
+
});
|
|
499
|
+
|
|
500
|
+
// Get the cursor for the next page
|
|
501
|
+
const nextCursor = firstPage.exploreList?.pageInfo?.endCursor;
|
|
502
|
+
|
|
503
|
+
// Fetch next page using the cursor
|
|
504
|
+
if (nextCursor) {
|
|
505
|
+
const nextPage = await getTopGainers({
|
|
506
|
+
count: 10,
|
|
507
|
+
after: nextCursor
|
|
508
|
+
});
|
|
509
|
+
}
|
|
510
|
+
```
|
|
511
|
+
|
|
512
|
+
**Complete Pagination Example:**
|
|
513
|
+
```typescript
|
|
514
|
+
async function fetchAllTopGainers() {
|
|
515
|
+
const allResults = [];
|
|
516
|
+
let hasNextPage = true;
|
|
517
|
+
let cursor: string | undefined;
|
|
518
|
+
|
|
519
|
+
while (hasNextPage) {
|
|
520
|
+
const response = await getTopGainers({
|
|
521
|
+
count: 10,
|
|
522
|
+
after: cursor
|
|
523
|
+
});
|
|
524
|
+
|
|
525
|
+
const { edges, pageInfo } = response.exploreList || {};
|
|
526
|
+
|
|
527
|
+
if (edges) {
|
|
528
|
+
allResults.push(...edges.map(edge => edge.node));
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
hasNextPage = pageInfo?.hasNextPage || false;
|
|
532
|
+
cursor = pageInfo?.endCursor;
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
return allResults;
|
|
536
|
+
}
|
|
537
|
+
```
|
|
538
|
+
|
|
539
|
+
This pagination pattern works for all queries that return `pageInfo` with `endCursor` and `hasNextPage`, including:
|
|
540
|
+
- All explore queries
|
|
541
|
+
- `getCoinComments`
|
|
542
|
+
- `getProfileOwned`
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { GenericPublicClient } from "src/utils/genericPublicClient";
|
|
2
|
+
import { Address } from "viem";
|
|
2
3
|
type Slot0Result = {
|
|
3
4
|
sqrtPriceX96: bigint;
|
|
4
5
|
tick: number;
|
|
@@ -45,7 +46,7 @@ export type OnchainCoinDetails = {
|
|
|
45
46
|
export declare function getOnchainCoinDetails({ coin, user, publicClient, }: {
|
|
46
47
|
coin: Address;
|
|
47
48
|
user?: Address;
|
|
48
|
-
publicClient:
|
|
49
|
+
publicClient: GenericPublicClient;
|
|
49
50
|
}): Promise<OnchainCoinDetails>;
|
|
50
51
|
export {};
|
|
51
52
|
//# sourceMappingURL=getOnchainCoinDetails.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getOnchainCoinDetails.d.ts","sourceRoot":"","sources":["../../src/actions/getOnchainCoinDetails.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"getOnchainCoinDetails.d.ts","sourceRoot":"","sources":["../../src/actions/getOnchainCoinDetails.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AAEpE,OAAO,EACL,OAAO,EAKR,MAAM,MAAM,CAAC;AAEd,KAAK,WAAW,GAAG;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,gBAAgB,EAAE,MAAM,CAAC;IACzB,sBAAsB,EAAE,MAAM,CAAC;IAC/B,0BAA0B,EAAE,MAAM,CAAC;IACnC,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,OAAO,CAAC;CACnB,CAAC;AAEF,KAAK,aAAa,GAAG;IACnB,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF;;;;;;;;;;GAUG;AACH,MAAM,MAAM,kBAAkB,GAAG;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,aAAa,CAAC;IACzB,SAAS,EAAE,aAAa,CAAC;IACzB,IAAI,EAAE,OAAO,CAAC;IACd,SAAS,EAAE,WAAW,CAAC;IACvB,MAAM,EAAE,SAAS,OAAO,EAAE,CAAC;IAC3B,eAAe,EAAE,OAAO,CAAC;CAC1B,CAAC;AAEF;;;;;;;GAOG;AACH,wBAAsB,qBAAqB,CAAC,EAC1C,IAAI,EACJ,IAAkB,EAClB,YAAY,GACb,EAAE;IACD,IAAI,EAAE,OAAO,CAAC;IACd,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,YAAY,EAAE,mBAAmB,CAAC;CACnC,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAmH9B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api-key.d.ts","sourceRoot":"","sources":["../../src/api/api-key.ts"],"names":[],"mappings":"AACA,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,QAEpC;AAED,wBAAgB,aAAa;;;;;;EAS5B"}
|