@metamask/snaps-sdk
Version:
A library containing the core functionality for building MetaMask Snaps
1 lines • 3.08 kB
Source Map (JSON)
{"version":3,"file":"AssetSelector.mjs","sourceRoot":"","sources":["../../../../src/jsx/components/form/AssetSelector.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,mBAAmB,EAAE,4BAAwB;AAwBtD,MAAM,IAAI,GAAG,eAAe,CAAC;AAE7B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,mBAAmB,CAG9C,IAAI,CAAC,CAAC","sourcesContent":["import type {\n CaipChainId,\n CaipAssetType,\n CaipAccountId,\n} from '@metamask/utils';\n\nimport { createSnapComponent } from '../../component';\n\n/**\n * The props of the {@link AssetSelector} component.\n *\n * @property name - The name of the asset selector. This is used to identify the\n * state in the form data.\n * @property addresses - The addresses of the account to pull the assets from as CAIP-10 Account IDs.\n * Multiple CAIP-10 Account IDs can be provided, but the account address should be the same on all Account IDs.\n * Only non-EIP-155 namespaces are supported for now.\n * @property chainIds - The chain IDs to filter the assets.\n * Only non-EIP-155 namespaces are supported for now.\n * @property value - The selected value of the asset selector.\n * Only non-EIP-155 namespaces are supported for now.\n * @property disabled - Whether the asset selector is disabled.\n */\nexport type AssetSelectorProps = {\n name: string;\n addresses: CaipAccountId[];\n chainIds?: CaipChainId[] | undefined;\n value?: CaipAssetType | undefined;\n disabled?: boolean | undefined;\n};\n\nconst TYPE = 'AssetSelector';\n\n/**\n * An asset selector component, which is used to create an asset selector.\n *\n * @param props - The props of the component.\n * @property addresses - The addresses of the account to pull the assets from as CAIP-10 Account IDs.\n * Multiple CAIP-10 Account IDs can be provided, but the account address should be the same on all Account IDs.\n * Only non-EIP-155 namespaces are supported for now.\n * @param props.chainIds - The chain IDs to filter the assets.\n * Only non-EIP-155 namespaces are supported for now.\n * @param props.value - The selected value of the asset selector.\n * Only non-EIP-155 namespaces are supported for now.\n * @param props.disabled - Whether the asset selector is disabled.\n * @returns An asset selector element.\n * @example\n * <AssetSelector\n * addresses={[\n * 'solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp:7S3P4HxJpyyigGzodYwHtCxZyUQe9JiBMHyRWXArAaKv',\n * 'solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1:7S3P4HxJpyyigGzodYwHtCxZyUQe9JiBMHyRWXArAaKv',\n * ]}\n * value=\"solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp/token:EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v\"\n * />\n * @example\n * <AssetSelector\n * addresses={[\n * 'solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp:7S3P4HxJpyyigGzodYwHtCxZyUQe9JiBMHyRWXArAaKv',\n * 'solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1:7S3P4HxJpyyigGzodYwHtCxZyUQe9JiBMHyRWXArAaKv',\n * ]}\n * chainIds={['solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp']}\n * />\n */\nexport const AssetSelector = createSnapComponent<\n AssetSelectorProps,\n typeof TYPE\n>(TYPE);\n\nexport type AssetSelectorElement = ReturnType<typeof AssetSelector>;\n"]}