@metamask/snaps-sdk
Version:
A library containing the core functionality for building MetaMask Snaps
309 lines • 13.6 kB
text/typescript
import type { Infer } from "@metamask/superstruct";
import type { CaipAssetTypeOrId } from "@metamask/utils";
export declare const FungibleAssetUnitStruct: import("@metamask/superstruct").Struct<{
decimals: number;
symbol?: string | undefined;
name?: string | undefined;
}, {
name: import("@metamask/superstruct").Struct<string | undefined, null>;
symbol: import("@metamask/superstruct").Struct<string | undefined, null>;
decimals: import("@metamask/superstruct").Struct<number, null>;
}>;
/**
* A unit of a fungible asset, which can be used to represent
* different denominations of the asset.
*
* @property name - The name of the unit, if available.
* @property symbol - The symbol of the unit, if available.
* @property decimals - The number of decimal places for the unit.
*/
export type FungibleAssetUnit = Infer<typeof FungibleAssetUnitStruct>;
export declare const AssetIconUrlStruct: import("@metamask/superstruct").Struct<string, null>;
/**
* A struct representing the metadata for a fungible asset.
*
* @property name - The name of the asset, if available.
* @property symbol - The symbol of the asset, if available.
* @property fungible - Indicates that this is a fungible asset. This is always `
* true` for fungible assets.
* @property iconUrl - The URL of the asset's icon, which can be a base64 SVG or a remote HTTPS URL.
* @property units - An array of units for the asset, each represented by {@link FungibleAssetUnitStruct}.
*/
export declare const FungibleAssetMetadataStruct: import("@metamask/superstruct").Struct<{
fungible: true;
iconUrl: string;
units: {
decimals: number;
symbol?: string | undefined;
name?: string | undefined;
}[];
symbol?: string | undefined;
name?: string | undefined;
}, {
name: import("@metamask/superstruct").Struct<string | undefined, null>;
symbol: import("@metamask/superstruct").Struct<string | undefined, null>;
fungible: import("@metamask/superstruct").Struct<true, true>;
iconUrl: import("@metamask/superstruct").Struct<string, null>;
units: import("@metamask/superstruct").Struct<{
decimals: number;
symbol?: string | undefined;
name?: string | undefined;
}[], import("@metamask/superstruct").Struct<{
decimals: number;
symbol?: string | undefined;
name?: string | undefined;
}, {
name: import("@metamask/superstruct").Struct<string | undefined, null>;
symbol: import("@metamask/superstruct").Struct<string | undefined, null>;
decimals: import("@metamask/superstruct").Struct<number, null>;
}>>;
}>;
/**
* A collection of non-fungible assets, which can be used to group
* assets that share a common theme or creator.
*
* @property name - The name of the collection.
* @property address - The CAIP-10 account ID of the collection's creator.
* @property symbol - The symbol of the collection.
* @property tokenCount - The number of tokens in the collection, if available.
* @property creator - The CAIP-10 account ID of the collection's creator, if
* available.
* @property imageUrl - The URL of the collection's image.
*/
export declare const NonFungibleAssetCollectionStruct: import("@metamask/superstruct").Struct<{
symbol: string;
name: string;
address: `${string}:${string}:${string}`;
tokenCount?: number | undefined;
creator?: `${string}:${string}:${string}` | undefined;
imageUrl?: string | undefined;
}, {
name: import("@metamask/superstruct").Struct<string, null>;
address: import("@metamask/superstruct").Struct<`${string}:${string}:${string}`, null>;
symbol: import("@metamask/superstruct").Struct<string, null>;
tokenCount: import("@metamask/superstruct").Struct<number | undefined, null>;
creator: import("@metamask/superstruct").Struct<`${string}:${string}:${string}` | undefined, null>;
imageUrl: import("@metamask/superstruct").Struct<string | undefined, null>;
}>;
/**
* A collection of non-fungible assets, which can be used to group
* assets that share a common theme or creator.
*
* @property name - The name of the collection.
* @property address - The CAIP-10 account ID of the collection's creator.
* @property symbol - The symbol of the collection.
* @property tokenCount - The number of tokens in the collection, if available.
* @property creator - The CAIP-10 account ID of the collection's creator, if
* available.
* @property imageUrl - The URL of the collection's image.
*/
export type NonFungibleAssetCollection = Infer<typeof NonFungibleAssetCollectionStruct>;
/**
* A struct representing the metadata for a non-fungible asset.
*
* @property fungible - Indicates that this is a non-fungible asset.
* This is always `false` for non-fungible assets.
* @property name - The name of the asset, if available.
* @property symbol - The symbol of the asset, if available.
* @property imageUrl - The URL of the asset's image, which can be a base64 SVG or a remote HTTPS URL.
* @property description - A description of the asset, if available.
* @property acquiredAt - The timestamp when the asset was acquired, if available.
* @property isPossibleSpam - Indicates if the asset is possibly spam, if available.
* @property attributes - Additional attributes of the asset, represented as a record of string keys and
* string or number values.
* @property collection - The collection the asset belongs to, if available. See {@link NonFungibleAssetCollectionStruct}.
*/
export declare const NonFungibleAssetMetadataStruct: import("@metamask/superstruct").Struct<{
fungible: false;
symbol?: string | undefined;
description?: string | undefined;
name?: string | undefined;
imageUrl?: string | undefined;
acquiredAt?: number | undefined;
isPossibleSpam?: boolean | undefined;
attributes?: Record<string, string | number> | undefined;
collection?: {
symbol: string;
name: string;
address: `${string}:${string}:${string}`;
tokenCount?: number | undefined;
creator?: `${string}:${string}:${string}` | undefined;
imageUrl?: string | undefined;
} | undefined;
}, {
fungible: import("@metamask/superstruct").Struct<false, false>;
name: import("@metamask/superstruct").Struct<string | undefined, null>;
symbol: import("@metamask/superstruct").Struct<string | undefined, null>;
imageUrl: import("@metamask/superstruct").Struct<string | undefined, null>;
description: import("@metamask/superstruct").Struct<string | undefined, null>;
acquiredAt: import("@metamask/superstruct").Struct<number | undefined, null>;
isPossibleSpam: import("@metamask/superstruct").Struct<boolean | undefined, null>;
attributes: import("@metamask/superstruct").Struct<Record<string, string | number> | undefined, null>;
collection: import("@metamask/superstruct").Struct<{
symbol: string;
name: string;
address: `${string}:${string}:${string}`;
tokenCount?: number | undefined;
creator?: `${string}:${string}:${string}` | undefined;
imageUrl?: string | undefined;
} | undefined, {
name: import("@metamask/superstruct").Struct<string, null>;
address: import("@metamask/superstruct").Struct<`${string}:${string}:${string}`, null>;
symbol: import("@metamask/superstruct").Struct<string, null>;
tokenCount: import("@metamask/superstruct").Struct<number | undefined, null>;
creator: import("@metamask/superstruct").Struct<`${string}:${string}:${string}` | undefined, null>;
imageUrl: import("@metamask/superstruct").Struct<string | undefined, null>;
}>;
}>;
/**
* A struct representing the metadata for an asset, which can be either
* {@link FungibleAssetMetadataStruct} or {@link NonFungibleAssetMetadataStruct}.
*/
export declare const AssetMetadataStruct: import("@metamask/superstruct").Struct<{
fungible: true;
iconUrl: string;
units: {
decimals: number;
symbol?: string | undefined;
name?: string | undefined;
}[];
symbol?: string | undefined;
name?: string | undefined;
} | {
fungible: false;
symbol?: string | undefined;
description?: string | undefined;
name?: string | undefined;
imageUrl?: string | undefined;
acquiredAt?: number | undefined;
isPossibleSpam?: boolean | undefined;
attributes?: Record<string, string | number> | undefined;
collection?: {
symbol: string;
name: string;
address: `${string}:${string}:${string}`;
tokenCount?: number | undefined;
creator?: `${string}:${string}:${string}` | undefined;
imageUrl?: string | undefined;
} | undefined;
}, null>;
/**
* A struct representing the response of the `onAssetsLookup` method.
*
* @property assets - An object containing a mapping between the CAIP-19 key and a metadata object or null.
*/
export declare const OnAssetsLookupResponseStruct: import("@metamask/superstruct").Struct<{
assets: Record<`${string}:${string}/${string}:${string}` | `${string}:${string}/${string}:${string}/${string}`, {
fungible: true;
iconUrl: string;
units: {
decimals: number;
symbol?: string | undefined;
name?: string | undefined;
}[];
symbol?: string | undefined;
name?: string | undefined;
} | {
fungible: false;
symbol?: string | undefined;
description?: string | undefined;
name?: string | undefined;
imageUrl?: string | undefined;
acquiredAt?: number | undefined;
isPossibleSpam?: boolean | undefined;
attributes?: Record<string, string | number> | undefined;
collection?: {
symbol: string;
name: string;
address: `${string}:${string}:${string}`;
tokenCount?: number | undefined;
creator?: `${string}:${string}:${string}` | undefined;
imageUrl?: string | undefined;
} | undefined;
} | null>;
}, {
assets: import("@metamask/superstruct").Struct<Record<`${string}:${string}/${string}:${string}` | `${string}:${string}/${string}:${string}/${string}`, {
fungible: true;
iconUrl: string;
units: {
decimals: number;
symbol?: string | undefined;
name?: string | undefined;
}[];
symbol?: string | undefined;
name?: string | undefined;
} | {
fungible: false;
symbol?: string | undefined;
description?: string | undefined;
name?: string | undefined;
imageUrl?: string | undefined;
acquiredAt?: number | undefined;
isPossibleSpam?: boolean | undefined;
attributes?: Record<string, string | number> | undefined;
collection?: {
symbol: string;
name: string;
address: `${string}:${string}:${string}`;
tokenCount?: number | undefined;
creator?: `${string}:${string}:${string}` | undefined;
imageUrl?: string | undefined;
} | undefined;
} | null>, null>;
}>;
/**
* The metadata for an asset, which can be either fungible or non-fungible.
*
*/
export type AssetMetadata = Infer<typeof AssetMetadataStruct>;
/**
* The metadata for a fungible asset.
*
* @property fungible - Indicates that this is a fungible asset.
* This is always `true` for fungible assets.
* @property name - The name of the asset.
* @property symbol - The symbol of the asset.
* @property iconUrl - The URL of the asset's icon.
* @property units - An array of units for the asset, each represented by {@link FungibleAssetUnit}.
*/
export type FungibleAssetMetadata = Infer<typeof FungibleAssetMetadataStruct>;
/**
* The metadata for a non-fungible asset.
*
* @property fungible - Indicates that this is a non-fungible asset.
* This is always `false` for non-fungible assets.
* @property name - The name of the asset.
* @property symbol - The symbol of the asset.
* @property imageUrl - The URL of the asset's image.
* @property description - A description of the asset.
* @property acquiredAt - The timestamp when the asset was acquired, if available.
* @property isPossibleSpam - Indicates if the asset is possibly spam, if available.
* @property attributes - Additional attributes of the asset, represented as a record of string keys and
* string or number values.
* @property collection - The collection the asset belongs to, if available. See {@link NonFungibleAssetCollection}.
*/
export type NonFungibleAssetMetadata = Infer<typeof NonFungibleAssetMetadataStruct>;
/**
* The arguments for the `onAssetsLookup` handler.
*
* @property assets - An array of CAIP-19 asset types to look up.
*/
export type OnAssetsLookupArguments = {
assets: CaipAssetTypeOrId[];
};
/**
* The `onAssetsLookup` handler. This is called by MetaMask when querying about specific assets on specific chains.
*
* @returns The metadata about each asset. See
* {@link OnAssetsLookupResponse}.
*/
export type OnAssetsLookupHandler = (args: OnAssetsLookupArguments) => Promise<OnAssetsLookupResponse>;
/**
* The response from the query, containing metadata about each requested asset.
*
* @property assets - An object containing a mapping between the CAIP-19 key and a metadata object or null.
*/
export type OnAssetsLookupResponse = {
assets: Record<CaipAssetTypeOrId, AssetMetadata | null>;
};
//# sourceMappingURL=assets-lookup.d.cts.map