@metamask/keyring-api
Version:
MetaMask Keyring API
109 lines • 2.79 kB
text/typescript
import type { Infer } from "@metamask/superstruct";
/**
* Fungible asset amount struct.
*/
export declare const FungibleAssetAmountStruct: import("@metamask/superstruct").Struct<{
unit: string;
amount: string;
}, {
/**
* Asset unit.
*/
unit: import("@metamask/superstruct").Struct<string, null>;
/**
* Asset amount.
*/
amount: import("@metamask/superstruct").Struct<string, null>;
}>;
/**
* Fungible asset struct.
*/
export declare const FungibleAssetStruct: import("@metamask/superstruct").Struct<{
unit: string;
type: `${string}:${string}/${string}:${string}`;
amount: string;
fungible: true;
}, {
/**
* Asset unit.
*/
unit: import("@metamask/superstruct").Struct<string, null>;
/**
* Asset amount.
*/
amount: import("@metamask/superstruct").Struct<string, null>;
/**
* It is a fungible asset.
*/
fungible: import("@metamask/superstruct").Struct<true, true>;
/**
* Asset type (CAIP-19).
*/
type: import("@metamask/superstruct").Struct<`${string}:${string}/${string}:${string}`, null>;
}>;
/**
* Non-fungible asset struct.
*/
export declare const NonFungibleAssetStruct: import("@metamask/superstruct").Struct<{
id: `${string}:${string}/${string}:${string}/${string}`;
fungible: false;
}, {
/**
* It is a non-fungible asset.
*/
fungible: import("@metamask/superstruct").Struct<false, false>;
/**
* Asset ID (CAIP-19).
*/
id: import("@metamask/superstruct").Struct<`${string}:${string}/${string}:${string}/${string}`, null>;
}>;
/**
* Asset struct. This represents a fungible or non-fungible asset. Fungible
* assets include an amount and a unit in addition to the asset type. While
* non-fungible assets include only an asset ID.
*
* See {@link NonFungibleAssetStruct} and {@link FungibleAssetStruct}.
*
* All assets have a `fungible` property that is used to tag the union and
* allow the following pattern:
*
* ```ts
* if (asset.fungible) {
* // Use asset.type
* } else {
* // Use asset.id
* }
* ```
*
* @example
* ```ts
* {
* fungible: true,
* type: 'eip155:1/slip44:60',
* unit: 'ETH',
* amount: '0.01',
* }
* ```
*
* @example
* ```ts
* {
* fungible: false,
* id: 'eip155:1/erc721:0x06012c8cf97BEaD5deAe237070F9587f8E7A266d/771769',
* }
* ```
*/
export declare const AssetStruct: import("@metamask/superstruct").Struct<{
unit: string;
type: `${string}:${string}/${string}:${string}`;
amount: string;
fungible: true;
} | {
id: `${string}:${string}/${string}:${string}/${string}`;
fungible: false;
}, null>;
/**
* Asset type {@see AssetStruct}.
*/
export type Asset = Infer<typeof AssetStruct>;
//# sourceMappingURL=asset.d.mts.map