Skip to content

Commit 2c1adae

Browse files
MET-685: Add new parameters
2 parents 9ab5a34 + 02d2580 commit 2c1adae

10 files changed

+1117
-226
lines changed

clients/js/src/decorator.ts

+202-177
Large diffs are not rendered by default.

clients/js/src/types.ts

+127-20
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,38 @@ import { Nullable, PublicKey } from '@metaplex-foundation/umi';
44
// RPC input. //
55
// ---------------------------------------- //
66

7+
/**
8+
* Display options for asset queries
9+
*/
10+
export type DisplayOptions = {
11+
/**
12+
* Whether to show unverified collections
13+
*/
14+
showUnverifiedCollections?: boolean;
15+
/**
16+
* Whether to show collection metadata
17+
*/
18+
showCollectionMetadata?: boolean;
19+
/**
20+
* Whether to show fungible assets
21+
*/
22+
showFungible?: boolean;
23+
/**
24+
* Whether to show inscription data
25+
*/
26+
showInscription?: boolean;
27+
};
28+
729
export type GetAssetsByAuthorityRpcInput = {
830
/**
931
* The address of the authority of the assets.
1032
*/
1133
authority: PublicKey;
34+
35+
/**
36+
* Display options for the query
37+
*/
38+
displayOptions?: DisplayOptions;
1239
} & Pagination;
1340

1441
export type GetAssetsByCreatorRpcInput = {
@@ -21,6 +48,11 @@ export type GetAssetsByCreatorRpcInput = {
2148
* Indicates whether to retrieve only verified assets or not.
2249
*/
2350
onlyVerified: boolean;
51+
52+
/**
53+
* Display options for the query
54+
*/
55+
displayOptions?: DisplayOptions;
2456
} & Pagination;
2557

2658
export type GetAssetsByGroupRpcInput = {
@@ -33,65 +65,75 @@ export type GetAssetsByGroupRpcInput = {
3365
* The value of the group
3466
*/
3567
groupValue: string;
68+
69+
/**
70+
* Display options for the query
71+
*/
72+
displayOptions?: DisplayOptions;
3673
} & Pagination;
3774

3875
export type GetAssetsByOwnerRpcInput = {
3976
/**
4077
* The address of the owner of the assets.
4178
*/
4279
owner: PublicKey;
80+
81+
/**
82+
* Display options for the query
83+
*/
84+
displayOptions?: DisplayOptions;
4385
} & Pagination;
4486

4587
export type SearchAssetsRpcInput = {
4688
/**
47-
* Indicates whether the search criteria should be inverted or not.
89+
* The address of the authority.
4890
*/
49-
negate?: Nullable<boolean>;
91+
authority?: Nullable<PublicKey>;
5092

5193
/**
52-
* Indicates whether to retrieve all or any asset that matches the search criteria.
94+
* The address of the creator.
5395
*/
54-
conditionType?: Nullable<'all' | 'any'>;
96+
creator?: Nullable<PublicKey>;
5597

5698
/**
57-
* The interface value of the asset.
99+
* Indicates whether the creator must be verified or not.
58100
*/
59-
interface?: Nullable<DasApiAssetInterface>;
101+
creatorVerified?: Nullable<boolean>;
60102

61103
/**
62-
* The value for the JSON URI.
104+
* The grouping (`key`, `value`) pair.
63105
*/
64-
jsonUri?: Nullable<string>;
106+
grouping?: Nullable<[string, string]>;
65107

66108
/**
67-
* The address of the owner.
109+
* The interface value of the asset.
68110
*/
69-
owner?: Nullable<PublicKey>;
111+
interface?: Nullable<DasApiAssetInterface>;
70112

71113
/**
72-
* Type of ownership.
114+
* Indicates whether the search criteria should be inverted or not.
73115
*/
74-
ownerType?: Nullable<'single' | 'token'>;
116+
negate?: Nullable<boolean>;
75117

76118
/**
77-
* The address of the creator.
119+
* The name of the asset.
78120
*/
79-
creator?: Nullable<PublicKey>;
121+
name?: Nullable<string>;
80122

81123
/**
82-
* Indicates whether the creator must be verified or not.
124+
* Indicates whether to retrieve all or any asset that matches the search criteria.
83125
*/
84-
creatorVerified?: Nullable<boolean>;
126+
conditionType?: Nullable<'all' | 'any'>;
85127

86128
/**
87-
* The address of the authority.
129+
* The address of the owner.
88130
*/
89-
authority?: Nullable<PublicKey>;
131+
owner?: Nullable<PublicKey>;
90132

91133
/**
92-
* The grouping (`key`, `value`) pair.
134+
* Type of ownership.
93135
*/
94-
grouping?: Nullable<[string, string]>;
136+
ownerType?: Nullable<'single' | 'token'>;
95137

96138
/**
97139
* The address of the delegate.
@@ -113,6 +155,11 @@ export type SearchAssetsRpcInput = {
113155
*/
114156
supplyMint?: Nullable<PublicKey>;
115157

158+
/**
159+
* The type of token to search for.
160+
*/
161+
tokenType?: Nullable<TokenType>;
162+
116163
/**
117164
* Indicates whether the asset is compressed or not.
118165
*/
@@ -142,8 +189,48 @@ export type SearchAssetsRpcInput = {
142189
* Indicates whether the asset is burnt or not.
143190
*/
144191
burnt?: Nullable<boolean>;
192+
193+
/**
194+
* The value for the JSON URI.
195+
*/
196+
jsonUri?: Nullable<string>;
197+
198+
/**
199+
* Display options for the query
200+
*/
201+
displayOptions?: DisplayOptions;
145202
} & Pagination;
146203

204+
/**
205+
* Input parameters for getAsset RPC call
206+
*/
207+
export type GetAssetRpcInput = {
208+
/**
209+
* The asset ID to fetch
210+
*/
211+
assetId: PublicKey;
212+
213+
/**
214+
* Display options for the query
215+
*/
216+
displayOptions?: DisplayOptions;
217+
};
218+
219+
/**
220+
* Input parameters for getAssets RPC call
221+
*/
222+
export type GetAssetsRpcInput = {
223+
/**
224+
* Array of asset IDs to fetch
225+
*/
226+
assetIds: PublicKey[];
227+
228+
/**
229+
* Display options for the query
230+
*/
231+
displayOptions?: DisplayOptions;
232+
};
233+
147234
// ---------------------------------------- //
148235
// Result types. //
149236
// ---------------------------------------- //
@@ -321,6 +408,11 @@ type Pagination = {
321408
* Retrieve assets after the specified `ID` value.
322409
*/
323410
after?: Nullable<string>;
411+
412+
/**
413+
*
414+
*/
415+
cursor?: Nullable<string>;
324416
};
325417

326418
/**
@@ -337,6 +429,7 @@ export type DasApiAssetInterface =
337429
| 'LEGACY_NFT'
338430
| 'V2_NFT'
339431
| 'FungibleAsset'
432+
| 'FungibleToken'
340433
| 'Custom'
341434
| 'Identity'
342435
| 'Executable'
@@ -407,6 +500,13 @@ export type DasApiPropGroupKey = 'collection';
407500
export type DasApiAssetGrouping = {
408501
group_key: DasApiPropGroupKey;
409502
group_value: string;
503+
verified?: boolean;
504+
collection_metadata?: {
505+
name: string;
506+
symbol: string;
507+
description: string;
508+
image: string;
509+
};
410510
};
411511

412512
export type DasApiAuthorityScope =
@@ -531,3 +631,10 @@ export type GetAssetSignaturesRpcResponse = {
531631
*/
532632
items: DasApiTransactionSignature[];
533633
};
634+
635+
export type TokenType =
636+
| 'Fungible'
637+
| 'NonFungible'
638+
| 'regularNFT'
639+
| 'compressedNFT'
640+
| 'All';

clients/js/test/_setup.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@ export const DAS_API_ENDPOINTS: { name: string; url: string }[] = [];
77
Object.keys(process.env).forEach(function (key) {
88
if (key.startsWith('DAS_API_')) {
99
const name = key.substring('DAS_API_'.length);
10-
const url = process.env[key]!;
11-
DAS_API_ENDPOINTS.push({ name, url });
10+
const url = process.env[key];
11+
if (url) {
12+
DAS_API_ENDPOINTS.push({ name, url });
13+
}
1214
}
1315
});
1416

clients/js/test/getAsset.test.ts

+48-6
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,14 @@ DAS_API_ENDPOINTS.forEach((endpoint) => {
4848
test(`it can fetch a regular asset by ID (${endpoint.name})`, async (t) => {
4949
// Given a minted NFT.
5050
const umi = createUmi(endpoint.url);
51-
const assetId = publicKey('8bFQbnBrzeiYQabEJ1ghy5T7uFpqFzPjUGsVi3SzSMHB');
51+
const assetId = publicKey('Hu9vvgNjVDxRo6F8iTEo6sRJikhqoM2zVswR86WAf4C');
5252

5353
// When we fetch the asset using its ID.
5454
const asset = await umi.rpc.getAsset(assetId);
5555

5656
// Then we expect the following data.
5757
t.like(asset, <DasApiAsset>{
58-
interface: 'ProgrammableNFT',
58+
interface: 'V1_NFT',
5959
id: assetId,
6060
content: {
6161
metadata: {
@@ -66,12 +66,54 @@ DAS_API_ENDPOINTS.forEach((endpoint) => {
6666
t.like(asset.compression, <DasApiAssetCompression>{
6767
compressed: false,
6868
});
69-
t.deepEqual(asset.grouping.length, 1);
69+
t.deepEqual(asset.mutable, true);
70+
t.deepEqual(asset.burnt, false);
71+
});
72+
73+
test(`it can fetch a regular asset by ID not showing unverified collection data using showUnverifiedCollections false (${endpoint.name})`, async (t) => {
74+
// Given a minted NFT.
75+
const umi = createUmi(endpoint.url);
76+
const assetId = publicKey('5smGnzgaMsQ3JV7jWCvSxnRkHjP2dJoi1uczHTx87tji');
77+
78+
// When we fetch the asset using its ID with display options.
79+
await t.throwsAsync(
80+
async () => {
81+
await umi.rpc.getAsset({
82+
assetId,
83+
displayOptions: { showUnverifiedCollections: false },
84+
});
85+
},
86+
{
87+
message: /Asset not found/,
88+
}
89+
);
90+
});
91+
92+
test(`it can fetch a regular asset by ID with unverified collection data using showUnverifiedCollections true (${endpoint.name})`, async (t) => {
93+
// Given a minted NFT.
94+
const umi = createUmi(endpoint.url);
95+
const assetId = publicKey('5smGnzgaMsQ3JV7jWCvSxnRkHjP2dJoi1uczHTx87tji');
96+
97+
// When we fetch the asset using its ID.
98+
const asset = await umi.rpc.getAsset({
99+
assetId,
100+
displayOptions: { showUnverifiedCollections: true },
101+
});
102+
103+
t.like(asset, <DasApiAsset>{
104+
interface: 'V1_NFT',
105+
id: assetId,
106+
content: {
107+
metadata: {
108+
name: 'unverified Azure 55',
109+
},
110+
},
111+
});
112+
t.is(asset.grouping.length, 1);
70113
t.like(asset.grouping[0], {
71114
group_key: 'collection',
72-
group_value: '5RT4e9uHUgG9h13cSc3L4YvkDc9qXSznoLaX4Tx8cpWS',
115+
group_value: '5g2h8NuNNdb2riSuAKC3JJrrJKGJUH9dxM23fqdYgGt2',
116+
verified: false,
73117
});
74-
t.deepEqual(asset.mutable, true);
75-
t.deepEqual(asset.burnt, false);
76118
});
77119
});

0 commit comments

Comments
 (0)