Skip to content

Commit

Permalink
Merge pull request #10 from metaplex-foundation/nhan/core-types
Browse files Browse the repository at this point in the history
add types for core assets
  • Loading branch information
nhanphan authored Jun 18, 2024
2 parents 3d2a59a + d699eb0 commit 4a9b8ef
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 2 deletions.
4 changes: 4 additions & 0 deletions clients/js/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ Examples are provided [here](#examples) and you can learn more about this libra
> **Note**
> The plugin can be used with any RPC that supports the Metaplex DAS API specification. You might need to contact your RPC provider to "enable" the Metaplex DAS API on your endpoint.
## Working with `mpl-core`

Core assets and collections are also indexed by DAS. It is recommended to use this package in conjunction with the [mpl-core-das](http://github.com/metaplex-foundation/mpl-core-das) if you are working with Core assets.

## Methods

> 💡 You can test each method of the API using the [OpenRPC playground](https://playground.open-rpc.org/?url=https://raw.githubusercontent.com/metaplex-foundation/digital-asset-standard-api/main/specification/metaplex-das-api.json).
Expand Down
2 changes: 1 addition & 1 deletion clients/js/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@metaplex-foundation/digital-asset-standard-api",
"version": "1.0.4-alpha.0",
"version": "1.0.4-alpha.2",
"description": "Open-source specification for interacting with digital assets on Solana",
"main": "dist/src/index.js",
"types": "dist/src/index.d.ts",
Expand Down
48 changes: 47 additions & 1 deletion clients/js/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,50 @@ export type DasApiAsset = {
* Indicates whether the asset is burnt or not.
*/
burnt: boolean;
} & DasApiCoreAssetFields;

/**
* Optional fields on an asset if the interface is for Core (i.e. interface is 'MplCoreAsset' or 'MplCoreCollection')
* It is recommended to use the mpl-core-das package along with this one to convert the types
* to be consistent with mpl-core (e.g. AssetV1)
*/
export type DasApiCoreAssetFields = {
/**
* Plugins active on the asset or collection
*/
plugins?: Record<string, any>;
/**
* External plugins active on the asset or collection
*/
external_plugins?: Record<string, any>[];
/**
* Plugins on the asset/collection that were unknown at the time of indexing.
* Contact your DAS provider to update their core indexing version if this field is being populated.
* If you have an up-to-date version of mpl-core-das installed, that library will also try to deserialize the plugin
*/
unknown_plugins?: Record<string, any>[];
/**
* External plugin adapters on the asset/collection that were unknown at the time of indexing.
* Contact your DAS provider to update their core indexing version if this field is being populated.
* If you have an up-to-date version of mpl-core-das installed, that library will also try to deserialize the plugin
*/
unknown_external_plugins?: Record<string, any>[];
/**
* Additional fields that are indexed for Core assets or collections
*/
mpl_core_info?: {
/**
* Number of assets minted to this collection
* Only applicable for collections
*/
num_minted?: number;
/**
* Current number of assets in this collection
* Only applicable for collections
*/
current_size?: number;
plugins_json_version: number;
};
};

/**
Expand Down Expand Up @@ -296,7 +340,9 @@ export type DasApiAssetInterface =
| 'Custom'
| 'Identity'
| 'Executable'
| 'ProgrammableNFT';
| 'ProgrammableNFT'
| 'MplCoreAsset'
| 'MplCoreCollection';

export type DasApiAssetContent = {
json_uri: string;
Expand Down

0 comments on commit 4a9b8ef

Please sign in to comment.