@quicknode/sdk 0.0.4 → 0.2.0

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/README.md CHANGED
@@ -24,7 +24,7 @@ client.nft
24
24
  .then((response) => console.log(response));
25
25
  ```
26
26
 
27
- Full example implementation [here](https://github.com/user/repo/blob/branch/other_file.md).
27
+ Full example implementation [here](https://github.com/quiknode-labs/qn-oss/tree/main/packages/apps/examples/nft-sdk)
28
28
 
29
29
  ## Providing a config object to the client
30
30
 
@@ -50,11 +50,11 @@ const client = new QuickNodeSDK({
50
50
 
51
51
  ### nft.getNFTsByWalletENS
52
52
 
53
- | Argument | Values | Optional | Example |
54
- | -------- | ------ | -------- | ---------------------------- |
55
- | ensName | string | ❌ | vitalik.eth |
56
- | first | number | ✅ | 10 |
57
- | after | string | ✅ | YXJyYXljb25uZWN0aW9uOjUwNQ== |
53
+ | Argument | Values | Optional | Description | Example |
54
+ | -------- | ------ | -------- | ------------------------------- | --------------------------- |
55
+ | ensName | string | ❌ | Wallet ENS address | vitalik.eth |
56
+ | first | number | ✅ | Number of results to return | 10 |
57
+ | after | string | ✅ | Return results after end cursor | YXJyYXljb25uZWN0aW9uOjUwNQ= |
58
58
 
59
59
  ```ts
60
60
  import { QuickNodeSDK } from '@quicknode/sdk';
@@ -65,18 +65,17 @@ client.nft
65
65
  .getNFTsByWalletENS({
66
66
  ensName: 'vitalik.eth',
67
67
  first: 5,
68
- after: 'YXJyYXljb25uZWN0aW9uOjUwNQ==',
69
68
  })
70
69
  .then((response) => console.log(response));
71
70
  ```
72
71
 
73
72
  ### nft.getNFTsByWalletAddress
74
73
 
75
- | Argument | Values | Optional | Example |
76
- | -------- | ------ | -------- | ------------------------------------------ |
77
- | address | string | ❌ | 0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045 |
78
- | first | number | ✅ | 10 |
79
- | after | string | ✅ | YXJyYXljb25uZWN0aW9uOjUwNQ== |
74
+ | Argument | Values | Optional | Description | Example |
75
+ | -------- | ------ | -------- | ------------------------------- | ------------------------------------------ |
76
+ | address | string | ❌ | Wallet address | 0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045 |
77
+ | first | number | ✅ | Number of results to return | 10 |
78
+ | after | string | ✅ | Return results after end cursor | YXJyYXljb25uZWN0aW9uOjUwNQ= |
80
79
 
81
80
  ```ts
82
81
  import { QuickNodeSDK } from '@quicknode/sdk';
@@ -87,11 +86,79 @@ client.nft
87
86
  .getNFTsByWalletAddress({
88
87
  address: '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045',
89
88
  first: 5,
90
- after: 'YXJyYXljb25uZWN0aW9uOjUwNQ==',
91
89
  })
92
90
  .then((response) => console.log(response));
93
91
  ```
94
92
 
93
+ ### nft.getNFTsByContractAddress
94
+
95
+ | Argument | Values | Optional | Description | Example |
96
+ | -------- | ------ | -------- | ------------------------------- | ------------------------------------------ |
97
+ | address | string | ❌ | Contract address of NFT | 0x2106C00Ac7dA0A3430aE667879139E832307AeAa |
98
+ | first | number | ✅ | Number of results to return | 10 |
99
+ | after | string | ✅ | Return results after end cursor | YXJyYXljb25uZWN0aW9uOjUwNQ= |
100
+
101
+ ```ts
102
+ import { QuickNodeSDK } from '@quicknode/sdk';
103
+
104
+ const client = new QuickNodeSDK();
105
+
106
+ client.nft
107
+ .getNFTsByContractAddress({
108
+ address: '0x2106C00Ac7dA0A3430aE667879139E832307AeAa',
109
+ first: 5,
110
+ })
111
+ .then((response) => console.log(response));
112
+ ```
113
+
114
+ ### nft.getCollectionDetails
115
+
116
+ | Argument | Values | Optional | Description | Example |
117
+ | -------- | ------ | -------- | ----------------------- | ------------------------------------------ |
118
+ | address | string | ❌ | Contract address of NFT | 0x2106C00Ac7dA0A3430aE667879139E832307AeAa |
119
+
120
+ ```ts
121
+ import { QuickNodeSDK } from '@quicknode/sdk';
122
+
123
+ const client = new QuickNodeSDK();
124
+
125
+ client.nft
126
+ .getCollectionDetails({
127
+ address: '0x2106C00Ac7dA0A3430aE667879139E832307AeAa',
128
+ })
129
+ .then((response) => console.log(response));
130
+ ```
131
+
132
+ ## Pagination
133
+
134
+ For functions that support pagination, use the `first` property to specify the amount of results to return.
135
+
136
+ The returned `data.tokensPageInfo.endCursor` property in the response can be used to access subsequent results. This value can be passed in to the `after` property and will return the results after that `endCursor`.
137
+
138
+ `hasNextPage` can be used to determine the end of the results, where it will be `false`.
139
+
140
+ For example, if a response contains:
141
+
142
+ ```
143
+ "data: {
144
+ "tokensPageInfo": {
145
+ "hasNextPage": true,
146
+ "endCursor": 'YXJyYXljb25uZWN0aW9uOlk='
147
+ }
148
+ }
149
+ }
150
+ ```
151
+
152
+ calling the following will get the next page of results
153
+
154
+ ```typescript
155
+ client.nft.getNFTsByWalletENS({
156
+ ensName: 'vitalik.eth',
157
+ first: 5,
158
+ after: 'YXJyYXljb25uZWN0aW9uOlk=', // from data.tokensPageInfo.endCursor in response
159
+ });
160
+ ```
161
+
95
162
  # Contributing corner
96
163
 
97
164
  ## Building
package/package.json CHANGED
@@ -6,7 +6,7 @@
6
6
  "directory": "packages/libs/api/sdk"
7
7
  },
8
8
  "license": "MIT",
9
- "version": "0.0.4",
9
+ "version": "0.2.0",
10
10
  "main": "./src/index.js",
11
11
  "module": "./src/index.esm.js",
12
12
  "types": "./src/index.d.ts",
package/src/index.esm.js CHANGED
@@ -7976,6 +7976,68 @@ const getWalletENSNFTsRawQuery = gql `
7976
7976
  }
7977
7977
  `;
7978
7978
 
7979
+ const getContractAddressNFTsRawQuery = gql `
7980
+ query ContractNFTs($address: String!, $first: Int, $after: String) {
7981
+ contract(address: $address) {
7982
+ address
7983
+ isVerified
7984
+ tokenStandard
7985
+ tokens(first: $first, after: $after) {
7986
+ pageInfo {
7987
+ hasNextPage
7988
+ endCursor
7989
+ }
7990
+ edges {
7991
+ node {
7992
+ tokenId
7993
+ images {
7994
+ url
7995
+ }
7996
+ ... on ERC721Token {
7997
+ contract {
7998
+ address # Included key field for caching
7999
+ }
8000
+ }
8001
+ }
8002
+ }
8003
+ }
8004
+ ... on ERC721Contract {
8005
+ circulatingSupply
8006
+ name
8007
+ symbol
8008
+ }
8009
+ }
8010
+ }
8011
+ `;
8012
+
8013
+ const getCollectionDetailsRawQuery = gql `
8014
+ query CollectionDetails($address: String!) {
8015
+ contract(address: $address) {
8016
+ ... on ERC721Contract {
8017
+ address
8018
+ isVerified
8019
+ tokenStandard
8020
+ attributes {
8021
+ name
8022
+ rarity
8023
+ value
8024
+ valueCount
8025
+ }
8026
+ circulatingSupply
8027
+ name
8028
+ stats {
8029
+ average
8030
+ ceiling
8031
+ floor
8032
+ totalSales
8033
+ volume
8034
+ }
8035
+ symbol
8036
+ }
8037
+ }
8038
+ }
8039
+ `;
8040
+
7979
8041
  class NFTQueries {
7980
8042
  constructor(client) {
7981
8043
  this.client = client;
@@ -7996,6 +8058,22 @@ class NFTQueries {
7996
8058
  });
7997
8059
  });
7998
8060
  }
8061
+ getNFTsByContractAddress(variables) {
8062
+ return __awaiter(this, void 0, void 0, function* () {
8063
+ return yield this.client.query({
8064
+ query: getContractAddressNFTsRawQuery,
8065
+ variables,
8066
+ });
8067
+ });
8068
+ }
8069
+ getCollectionDetails(variables) {
8070
+ return __awaiter(this, void 0, void 0, function* () {
8071
+ return yield this.client.query({
8072
+ query: getCollectionDetailsRawQuery,
8073
+ variables,
8074
+ });
8075
+ });
8076
+ }
7999
8077
  }
8000
8078
 
8001
8079
  /**
@@ -8121,4 +8199,4 @@ class QuickNodeSDK {
8121
8199
  }
8122
8200
  }
8123
8201
 
8124
- export { QuickNodeSDK, QuickNodeSDK as default, getWalletAddressNFTsRawQuery, getWalletENSNFTsRawQuery };
8202
+ export { QuickNodeSDK, QuickNodeSDK as default, getContractAddressNFTsRawQuery, getWalletAddressNFTsRawQuery, getWalletENSNFTsRawQuery };
package/src/index.js CHANGED
@@ -7984,6 +7984,68 @@ const getWalletENSNFTsRawQuery = gql `
7984
7984
  }
7985
7985
  `;
7986
7986
 
7987
+ const getContractAddressNFTsRawQuery = gql `
7988
+ query ContractNFTs($address: String!, $first: Int, $after: String) {
7989
+ contract(address: $address) {
7990
+ address
7991
+ isVerified
7992
+ tokenStandard
7993
+ tokens(first: $first, after: $after) {
7994
+ pageInfo {
7995
+ hasNextPage
7996
+ endCursor
7997
+ }
7998
+ edges {
7999
+ node {
8000
+ tokenId
8001
+ images {
8002
+ url
8003
+ }
8004
+ ... on ERC721Token {
8005
+ contract {
8006
+ address # Included key field for caching
8007
+ }
8008
+ }
8009
+ }
8010
+ }
8011
+ }
8012
+ ... on ERC721Contract {
8013
+ circulatingSupply
8014
+ name
8015
+ symbol
8016
+ }
8017
+ }
8018
+ }
8019
+ `;
8020
+
8021
+ const getCollectionDetailsRawQuery = gql `
8022
+ query CollectionDetails($address: String!) {
8023
+ contract(address: $address) {
8024
+ ... on ERC721Contract {
8025
+ address
8026
+ isVerified
8027
+ tokenStandard
8028
+ attributes {
8029
+ name
8030
+ rarity
8031
+ value
8032
+ valueCount
8033
+ }
8034
+ circulatingSupply
8035
+ name
8036
+ stats {
8037
+ average
8038
+ ceiling
8039
+ floor
8040
+ totalSales
8041
+ volume
8042
+ }
8043
+ symbol
8044
+ }
8045
+ }
8046
+ }
8047
+ `;
8048
+
7987
8049
  class NFTQueries {
7988
8050
  constructor(client) {
7989
8051
  this.client = client;
@@ -8004,6 +8066,22 @@ class NFTQueries {
8004
8066
  });
8005
8067
  });
8006
8068
  }
8069
+ getNFTsByContractAddress(variables) {
8070
+ return __awaiter(this, void 0, void 0, function* () {
8071
+ return yield this.client.query({
8072
+ query: getContractAddressNFTsRawQuery,
8073
+ variables,
8074
+ });
8075
+ });
8076
+ }
8077
+ getCollectionDetails(variables) {
8078
+ return __awaiter(this, void 0, void 0, function* () {
8079
+ return yield this.client.query({
8080
+ query: getCollectionDetailsRawQuery,
8081
+ variables,
8082
+ });
8083
+ });
8084
+ }
8007
8085
  }
8008
8086
 
8009
8087
  /**
@@ -8131,5 +8209,6 @@ class QuickNodeSDK {
8131
8209
 
8132
8210
  exports.QuickNodeSDK = QuickNodeSDK;
8133
8211
  exports["default"] = QuickNodeSDK;
8212
+ exports.getContractAddressNFTsRawQuery = getContractAddressNFTsRawQuery;
8134
8213
  exports.getWalletAddressNFTsRawQuery = getWalletAddressNFTsRawQuery;
8135
8214
  exports.getWalletENSNFTsRawQuery = getWalletENSNFTsRawQuery;
@@ -0,0 +1,4 @@
1
+ export declare const getCollectionDetailsRawQuery: import("graphql/language/ast").DocumentNode;
2
+ export interface CollectionDetailsQueryVariables {
3
+ address: string;
4
+ }
@@ -0,0 +1,5 @@
1
+ import { PaginationArgs } from '../../../types';
2
+ export declare const getContractAddressNFTsRawQuery: import("graphql/language/ast").DocumentNode;
3
+ export interface ContractAddressNFTsQueryVariables extends PaginationArgs {
4
+ address: string;
5
+ }
@@ -1,2 +1,3 @@
1
1
  export * from './getNFTsByWalletAddress/getNFTsByWalletAddress';
2
2
  export * from './getNFTsByWalletENS/getNFTsByWalletENS';
3
+ export * from './getNFTsByContractAddress/getNFTsByContractAddress';
@@ -2,10 +2,14 @@ import { ApolloQueryResult } from '@apollo/client';
2
2
  import { CustomApolloClient } from '../../client/customApolloClient';
3
3
  import { WalletAddressNFTsQueryVariables } from './getNFTsByWalletAddress/getNFTsByWalletAddress';
4
4
  import { WalletENSNFTsQueryVariables } from './getNFTsByWalletENS/getNFTsByWalletENS';
5
- import { WalletNFTsQueryResponse } from './sharedTypes';
5
+ import { ContractAddressNFTsQueryVariables } from './getNFTsByContractAddress/getNFTsByContractAddress';
6
+ import { CollectionDetailsQueryVariables } from './getCollectionDetails/getCollectionDetails';
7
+ import { ContractNFTsQueryResponse, WalletNFTsQueryResponse, CollectionDetailsQueryResponse } from './sharedTypes';
6
8
  export declare class NFTQueries {
7
9
  private client;
8
10
  constructor(client: CustomApolloClient);
9
11
  getNFTsByWalletAddress(variables: WalletAddressNFTsQueryVariables): Promise<ApolloQueryResult<WalletNFTsQueryResponse>>;
10
12
  getNFTsByWalletENS(variables: WalletENSNFTsQueryVariables): Promise<ApolloQueryResult<WalletNFTsQueryResponse>>;
13
+ getNFTsByContractAddress(variables: ContractAddressNFTsQueryVariables): Promise<ApolloQueryResult<ContractNFTsQueryResponse>>;
14
+ getCollectionDetails(variables: CollectionDetailsQueryVariables): Promise<ApolloQueryResult<CollectionDetailsQueryResponse>>;
11
15
  }