@metaplex-foundation/digital-asset-standard-api
Advanced tools
Comparing version 1.0.5 to 1.0.6
import { PublicKey, RpcInterface } from '@metaplex-foundation/umi'; | ||
import { GetAssetProofRpcResponse, GetAssetsByAuthorityRpcInput, GetAssetsByCreatorRpcInput, GetAssetsByGroupRpcInput, GetAssetsByOwnerRpcInput, DasApiAsset, DasApiAssetList, SearchAssetsRpcInput, GetAssetSignaturesRpcResponse, GetAssetProofsRpcResponse } from './types'; | ||
import { GetAssetProofRpcResponse, GetAssetsByAuthorityRpcInput, GetAssetsByCreatorRpcInput, GetAssetsByGroupRpcInput, GetAssetsByOwnerRpcInput, DasApiAsset, DasApiAssetList, SearchAssetsRpcInput, GetAssetSignaturesRpcResponse, GetAssetProofsRpcResponse, GetAssetSignaturesRpcInput } from './types'; | ||
export interface DasApiInterface { | ||
@@ -11,5 +11,5 @@ /** | ||
/** | ||
* Return the metadata information of a compressed/standard asset. | ||
* Return the metadata information of multiple compressed/standard assets. | ||
* | ||
* @param assetId the id of the asset to fetch | ||
* @param assetIds Array of the ids of the assets to fetch | ||
*/ | ||
@@ -24,5 +24,5 @@ getAssets(assetIds: PublicKey[]): Promise<DasApiAsset[]>; | ||
/** | ||
* Return the merkle tree proof information for a compressed asset. | ||
* Return the merkle tree proof information for multiple compressed assets. | ||
* | ||
* @param assetId the id of the asset to fetch the proof for | ||
* @param assetIds array of the ids of the assets to fetch the proofs for | ||
*/ | ||
@@ -63,6 +63,6 @@ getAssetProofs(assetIds: PublicKey[]): Promise<GetAssetProofsRpcResponse>; | ||
* | ||
* @param assetId the id of the asset to fetch the signatures for | ||
* @param input the input parameters for the RPC call | ||
*/ | ||
getAssetSignatures(assetId: PublicKey): Promise<GetAssetSignaturesRpcResponse>; | ||
getAssetSignatures(input: GetAssetSignaturesRpcInput): Promise<GetAssetSignaturesRpcResponse>; | ||
} | ||
export declare const createDasApiDecorator: (rpc: RpcInterface) => RpcInterface & DasApiInterface; |
@@ -14,3 +14,5 @@ "use strict"; | ||
getAssets: async (assetIds) => { | ||
const assets = await rpc.call('getAssets', [assetIds]); | ||
const assets = await rpc.call('getAssets', [ | ||
assetIds, | ||
]); | ||
if (!assets) | ||
@@ -138,6 +140,20 @@ throw new errors_1.DasApiError(`No assets found: ${assetIds}`); | ||
}, | ||
getAssetSignatures: async (assetId) => { | ||
const signatures = await rpc.call('getAssetSignaturesV2', [assetId]); | ||
if (!signatures) | ||
throw new errors_1.DasApiError(`No signatures found for asset: ${assetId}`); | ||
getAssetSignatures: async (input) => { | ||
const signatures = await rpc.call('getAssetSignaturesV2', [ | ||
'assetId' in input ? input.assetId : null, | ||
input.limit ?? null, | ||
input.page ?? null, | ||
input.before ?? null, | ||
input.after ?? null, | ||
'tree' in input ? input.tree : null, | ||
'tree' in input ? input.leaf_index : null, | ||
input.cursor ?? null, | ||
input.sort_direction ?? null, | ||
]); | ||
if (!signatures) { | ||
const identifier = 'assetId' in input | ||
? `asset: ${input.assetId}` | ||
: `tree: ${input.tree}, leaf_index: ${input.leaf_index}`; | ||
throw new errors_1.DasApiError(`No signatures found for ${identifier}`); | ||
} | ||
return signatures; | ||
@@ -144,0 +160,0 @@ }, |
import { RpcInterface, UmiPlugin } from '@metaplex-foundation/umi'; | ||
import { DasApiInterface } from './decorator'; | ||
export declare const dasApi: () => UmiPlugin; | ||
declare module '@metaplex-foundation/umi' { | ||
declare module '@metaplex-foundation/umi/dist/types/Umi' { | ||
interface Umi { | ||
@@ -6,0 +6,0 @@ rpc: RpcInterface & DasApiInterface; |
@@ -1,3 +0,3 @@ | ||
import { Nullable, PublicKey, TransactionSignature } from '@metaplex-foundation/umi'; | ||
export declare type GetAssetsByAuthorityRpcInput = { | ||
import { Nullable, PublicKey } from '@metaplex-foundation/umi'; | ||
export type GetAssetsByAuthorityRpcInput = { | ||
/** | ||
@@ -8,3 +8,3 @@ * The address of the authority of the assets. | ||
} & Pagination; | ||
export declare type GetAssetsByCreatorRpcInput = { | ||
export type GetAssetsByCreatorRpcInput = { | ||
/** | ||
@@ -19,3 +19,3 @@ * The address of the creator of the assets. | ||
} & Pagination; | ||
export declare type GetAssetsByGroupRpcInput = { | ||
export type GetAssetsByGroupRpcInput = { | ||
/** | ||
@@ -30,3 +30,3 @@ * The key of the group (e.g., `"collection"`). | ||
} & Pagination; | ||
export declare type GetAssetsByOwnerRpcInput = { | ||
export type GetAssetsByOwnerRpcInput = { | ||
/** | ||
@@ -37,3 +37,3 @@ * The address of the owner of the assets. | ||
} & Pagination; | ||
export declare type SearchAssetsRpcInput = { | ||
export type SearchAssetsRpcInput = { | ||
/** | ||
@@ -123,3 +123,3 @@ * Indicates whether the search criteria should be inverted or not. | ||
*/ | ||
export declare type DasApiAsset = { | ||
export type DasApiAsset = { | ||
/** | ||
@@ -177,2 +177,45 @@ * The asset interface. | ||
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; | ||
}; | ||
}; | ||
@@ -182,3 +225,3 @@ /** | ||
*/ | ||
export declare type DasApiAssetList = { | ||
export type DasApiAssetList = { | ||
/** | ||
@@ -206,3 +249,3 @@ * total number of assets in the list. | ||
*/ | ||
declare type Pagination = { | ||
type Pagination = { | ||
/** | ||
@@ -232,8 +275,8 @@ * Sorting criteria. | ||
*/ | ||
declare type DasApiParamAssetSortBy = { | ||
sortBy: 'created' | 'updated' | 'recent_action' | 'none'; | ||
type DasApiParamAssetSortBy = { | ||
sortBy: 'created' | 'updated' | 'recent_action' | 'id' | 'none'; | ||
sortDirection: 'asc' | 'desc'; | ||
}; | ||
export declare type DasApiAssetInterface = 'V1_NFT' | 'V1_PRINT' | 'LEGACY_NFT' | 'V2_NFT' | 'FungibleAsset' | 'Custom' | 'Identity' | 'Executable' | 'ProgrammableNFT'; | ||
export declare type DasApiAssetContent = { | ||
export type DasApiAssetInterface = 'V1_NFT' | 'V1_PRINT' | 'LEGACY_NFT' | 'V2_NFT' | 'FungibleAsset' | 'Custom' | 'Identity' | 'Executable' | 'ProgrammableNFT' | 'MplCoreAsset' | 'MplCoreCollection'; | ||
export type DasApiAssetContent = { | ||
json_uri: string; | ||
@@ -250,7 +293,7 @@ files?: Array<{ | ||
}; | ||
export declare type DasApiAssetAuthority = { | ||
export type DasApiAssetAuthority = { | ||
address: PublicKey; | ||
scopes: DasApiAuthorityScope[]; | ||
}; | ||
export declare type DasApiAssetCompression = { | ||
export type DasApiAssetCompression = { | ||
eligible: boolean; | ||
@@ -265,3 +308,3 @@ compressed: boolean; | ||
}; | ||
export declare type DasApiAssetOwnership = { | ||
export type DasApiAssetOwnership = { | ||
frozen: boolean; | ||
@@ -273,3 +316,3 @@ delegated: boolean; | ||
}; | ||
export declare type DasApiAssetSupply = { | ||
export type DasApiAssetSupply = { | ||
print_max_supply: number; | ||
@@ -279,3 +322,3 @@ print_current_supply: number; | ||
}; | ||
export declare type DasApiAssetRoyalty = { | ||
export type DasApiAssetRoyalty = { | ||
royalty_model: 'creators' | 'fanout' | 'single'; | ||
@@ -288,3 +331,3 @@ target: PublicKey | null; | ||
}; | ||
export declare type DasApiAssetCreator = { | ||
export type DasApiAssetCreator = { | ||
address: PublicKey; | ||
@@ -294,9 +337,9 @@ share: number; | ||
}; | ||
export declare type DasApiPropGroupKey = 'collection'; | ||
export declare type DasApiAssetGrouping = { | ||
export type DasApiPropGroupKey = 'collection'; | ||
export type DasApiAssetGrouping = { | ||
group_key: DasApiPropGroupKey; | ||
group_value: string; | ||
}; | ||
export declare type DasApiAuthorityScope = 'full' | 'royalty' | 'metadata' | 'extension'; | ||
export declare type DasApiMetadata = { | ||
export type DasApiAuthorityScope = 'full' | 'royalty' | 'metadata' | 'extension'; | ||
export type DasApiMetadata = { | ||
name: string; | ||
@@ -313,3 +356,3 @@ symbol: string; | ||
}; | ||
export declare type DasApiUses = { | ||
export type DasApiUses = { | ||
use_method: 'burn' | 'multiple' | 'single'; | ||
@@ -319,3 +362,3 @@ remaining: number; | ||
}; | ||
export declare type GetAssetProofRpcResponse = { | ||
export type GetAssetProofRpcResponse = { | ||
root: PublicKey; | ||
@@ -327,5 +370,53 @@ proof: PublicKey[]; | ||
}; | ||
export declare type GetAssetProofsRpcResponse = Record<PublicKey, GetAssetProofRpcResponse>; | ||
export declare type GetAssetSignaturesRpcResponse = { | ||
export type GetAssetProofsRpcResponse = Record<PublicKey, GetAssetProofRpcResponse>; | ||
export type GetAssetSignaturesRpcInput = { | ||
/** | ||
* The maximum number of assets to retrieve. | ||
*/ | ||
limit?: Nullable<number>; | ||
/** | ||
* The page number of the signatures. | ||
*/ | ||
page?: Nullable<number>; | ||
/** | ||
* Retrieve signatures before the specified `ID` value. | ||
*/ | ||
before?: Nullable<string>; | ||
/** | ||
* Retrieve signatures after the specified `ID` value. | ||
*/ | ||
after?: Nullable<string>; | ||
/** | ||
* | ||
*/ | ||
cursor?: Nullable<string>; | ||
/** | ||
* The sort direction. | ||
*/ | ||
sort_direction?: Nullable<'asc' | 'desc'>; | ||
} & ({ | ||
/** | ||
* The Asset ID to retrieve signatures for. | ||
*/ | ||
assetId: PublicKey; | ||
tree?: never; | ||
leaf_index?: never; | ||
} | { | ||
/** | ||
* The tree ID to retrieve signatures for. | ||
*/ | ||
tree: PublicKey; | ||
/** | ||
* The leaf index to retrieve signatures for. | ||
*/ | ||
leaf_index: number; | ||
assetId?: never; | ||
}); | ||
export type DasApiTransactionSignature = { | ||
signature: string; | ||
instruction: string; | ||
slot: number; | ||
}; | ||
export type GetAssetSignaturesRpcResponse = { | ||
/** | ||
* total number of signatures in the list. | ||
@@ -340,11 +431,13 @@ */ | ||
limit: number; | ||
before: string; | ||
after: string; | ||
/** | ||
* The page number of the signatures. | ||
*/ | ||
page: number; | ||
page?: number; | ||
/** | ||
* List of individual signatures. | ||
*/ | ||
signatures: TransactionSignature[]; | ||
items: DasApiTransactionSignature[]; | ||
}; | ||
export {}; |
{ | ||
"name": "@metaplex-foundation/digital-asset-standard-api", | ||
"version": "1.0.5", | ||
"version": "1.0.6", | ||
"description": "Open-source specification for interacting with digital assets on Solana", | ||
@@ -66,3 +66,3 @@ "main": "dist/src/index.js", | ||
"build:docs": "typedoc", | ||
"test": "ava", | ||
"test": "ava -s", | ||
"lint": "eslint --ext js,ts,tsx src", | ||
@@ -69,0 +69,0 @@ "lint:fix": "eslint --fix --ext js,ts,tsx src", |
Sorry, the diff of this file is not supported yet
47425
707