nft-did-resolver
Version:
DID Resolver for the NFT method
72 lines • 2.16 kB
TypeScript
import type { ResolverRegistry } from 'did-resolver';
import type { CeramicApi } from '@ceramicnetwork/common';
import { AssetId } from 'caip';
export declare function didToCaip(id: string): AssetId;
export declare type ChainConfig = {
blocks: string;
skew: number;
assets: Record<string, string>;
};
/**
* When passing in a custom subgraph url, it must conform to the same standards as
* represented by the included ERC721 and ERC1155 subgraphs
* Example:
* ```
* const customConfig = {
* ceramic: ceramicClient,
* chains: {
* "eip155:1": {
* "blocks": "https://api.thegraph.com/subgraphs/name/yyong1010/ethereumblocks",
* "skew": 15000, // in milliseconds
* "assets": {
* "erc1155": "https://api.thegraph.com/subgraphs/name/amxx/eip1155-subgraph",
* "erc721": "https://api.thegraph.com/subgraphs/name/touchain/erc721track",
* }
* }
* }
* }
* ```
*/
export declare type NftResolverConfig = {
ceramic: CeramicApi;
chains: Record<string, ChainConfig>;
};
/**
* Convert AssetId to did:nft URL, including timestamp, if present.
* @param assetId - NFT Asset
* @param timestamp - JS Time as unix timestamp.
*/
export declare function caipToDid(assetId: AssetId, timestamp?: number): string;
/**
* Params for `createNftDidUrl` function.
*/
export declare type NftDidUrlParams = {
/**
* CAIP-10 Chain ID. For example: `eip155:1`
*/
chainId: string;
/**
* Token namespace: `erc721` or `erc1155`
*/
namespace: string;
/**
* Token contract address
*/
contract: string;
/**
* Token ID
*/
tokenId: string;
/**
* Unix timestamp for `versionTime` DID URL query param. Helps to find NFT owners at particular point in time.
*/
timestamp?: number;
};
/**
* Convert NFT asset id to NFT DID URL. Can include timestamp (as unix timestamp) if provided.
*/
export declare function createNftDidUrl(params: NftDidUrlParams): string;
export declare function getResolver(config: Partial<NftResolverConfig> & Required<{
ceramic: CeramicApi;
}>): ResolverRegistry;
//# sourceMappingURL=index.d.ts.map