-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathread-nfts.ts
191 lines (183 loc) · 5.1 KB
/
read-nfts.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
import { RPC_HOST } from "./constants";
// https://docs.helius.xyz/compression-and-das-api/digital-asset-standard-das-api/get-asset-proof
export const getAssetProof = async (id: string) => {
const response = await fetch(RPC_HOST, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
jsonrpc: "2.0",
id: "my-id",
method: "getAssetProof",
params: {
id,
},
}),
});
const { result } = await response.json();
console.log("Assets Proof: ", result);
return result;
};
// https://docs.helius.xyz/compression-and-das-api/digital-asset-standard-das-api/get-assets-by-owner
export const getAssetsByOwner = async (ownerAddress: string) => {
const response = await fetch(RPC_HOST, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
jsonrpc: "2.0",
id: "my-id",
method: "getAssetsByOwner",
params: {
ownerAddress,
page: 1, // Starts at 1
limit: 1000,
},
}),
});
const { result } = await response.json();
console.log("Assets by Owner: ", result.items);
};
// https://docs.helius.xyz/compression-and-das-api/digital-asset-standard-das-api/get-assets-by-authority
export const getAssetsByAuthority = async (authorityAddress: string) => {
const response = await fetch(RPC_HOST, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
jsonrpc: "2.0",
id: "my-id",
method: "getAssetsByAuthority",
params: {
authorityAddress,
page: 1, // Starts at 1
limit: 1000,
},
}),
});
const { result } = await response.json();
console.log("Assets by Authority: ", result.items);
return result;
};
// https://docs.helius.xyz/compression-and-das-api/digital-asset-standard-das-api/get-assets-by-creator
export const getAssetsByCreator = async (creatorAddress: string) => {
const response = await fetch(RPC_HOST, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
jsonrpc: "2.0",
id: "my-id",
method: "getAssetsByCreator",
params: {
creatorAddress,
onlyVerified: true,
page: 1, // Starts at 1
limit: 1000,
},
}),
});
const { result } = await response.json();
console.log("Assets by Creator: ", result.items);
return result;
};
// https://docs.helius.xyz/compression-and-das-api/digital-asset-standard-das-api/get-asset
export const getAssets = async (mintAddresses: string[]) => {
let batch = mintAddresses.map((e, i) => ({
jsonrpc: "2.0",
id: `my-id-${i}`,
method: "getAsset",
params: {
id: e,
},
}));
const response = await fetch(RPC_HOST, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify(batch),
});
const result = await response.json();
console.log("Assets: ", result);
return result;
};
// https://docs.helius.xyz/compression-and-das-api/digital-asset-standard-das-api/get-assets-by-group
export const getAssetsByGroup = async (collectionMint: string) => {
const response = await fetch(RPC_HOST, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
jsonrpc: "2.0",
id: "my-id",
method: "getAssetsByGroup",
params: {
groupKey: "collection",
groupValue: collectionMint,
page: 1, // Starts at 1
limit: 1000,
},
}),
});
const { result } = await response.json();
console.log("Assets by Group: ", result.items);
return result.items;
};
// https://docs.helius.xyz/compression-and-das-api/digital-asset-standard-das-api/search-assets
export const searchAssets = async (ownerAddress: string) => {
const response = await fetch(RPC_HOST, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
jsonrpc: "2.0",
id: "my-id",
method: "searchAssets",
params: {
ownerAddress,
compressed: true,
page: 1, // Starts at 1
limit: 1000,
},
}),
});
const { result } = await response.json();
console.log("Search Assets: ", result);
return result;
};
// https://docs.helius.xyz/compression-and-das-api/digital-asset-standard-das-api/search-assets
export const searchAssetsByGrouping = async (
ownerAddress: string,
grouping: string[]
) => {
const response = await fetch(RPC_HOST, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
jsonrpc: "2.0",
id: "my-id",
method: "searchAssets",
params: {
// ownerAddress: '2k5AXX4guW9XwRQ1AKCpAuUqgWDpQpwFfpVFh3hnm2Ha',
ownerAddress,
compressed: true,
grouping,
// grouping: ["collection", "DRiP2Pn2K6fuMLKQmt5rZWyHiUZ6WK3GChEySUpHSS4x"],
page: 1, // Starts at 1
limit: 1000,
},
}),
});
const { result } = await response.json();
console.log("Drip Haus Assets: ", result);
return result;
};