{"version":3,"file":"name-lookup.cjs","sourceRoot":"","sources":["../../../src/types/handlers/name-lookup.ts"],"names":[],"mappings":"","sourcesContent":["import type { CaipChainId, NonEmptyArray } from '@metamask/utils';\n\ntype BaseOnNameLookupArgs = {\n  chainId: CaipChainId;\n};\n\n/**\n * The arguments for a domain lookup.\n *\n * @property domain - The human-readable domain name that is to be resolved.\n */\nexport type DomainLookupArgs = BaseOnNameLookupArgs & {\n  domain: string;\n  address?: never;\n};\n\n/**\n * The arguments for an address lookup.\n *\n * @property address - The address that is to be resolved.\n */\nexport type AddressLookupArgs = BaseOnNameLookupArgs & {\n  address: string;\n  domain?: never;\n};\n\n/**\n * The address resolution object.\n *\n * @property protocol - The protocol that resolved the domain.\n * @property resolvedAddress - The resolved address.\n */\nexport type AddressResolution = {\n  protocol: string;\n  resolvedAddress: string;\n  domainName: string;\n};\n\n/**\n * The domain resolution object.\n *\n * @property protocol - The protocol that resolved the address.\n * @property resolvedDomain - The resolved domain.\n */\nexport type DomainResolution = {\n  protocol: string;\n  resolvedDomain: string;\n};\n\n/**\n * The result of a domain lookup.\n *\n * @property resolvedAddress - The resolved address.\n */\nexport type DomainLookupResult = {\n  resolvedAddresses: NonEmptyArray<AddressResolution>;\n  resolvedDomains?: never;\n};\n\n/**\n * The result of an address lookup.\n *\n * @property resolvedDomain - The resolved domain name.\n */\nexport type AddressLookupResult = {\n  resolvedDomains: NonEmptyArray<DomainResolution>;\n  resolvedAddresses?: never;\n};\n\n/**\n * The `onNameLookup` handler, which is called when MetaMask needs to resolve an\n * address or domain.\n *\n * Note that using this handler requires the `endowment:name-lookup` permission.\n *\n * @param args - The request arguments.\n * @param args.chainId - The CAIP-2 {@link CaipChainId} of the network the\n * transaction is being submitted to.\n * @param args.domain - The human-readable address that is to be resolved. This\n * is mutually exclusive with `args.address`.\n * @param args.address - The address that is to be resolved. This is mutually\n * exclusive with `args.domain`.\n * @returns The resolved domain or address from the lookup. Must be either\n * {@link AddressLookupResult}, {@link DomainLookupResult}, or `null` if the\n * address or domain could not be resolved.\n */\nexport type OnNameLookupHandler = (\n  args: AddressLookupArgs | DomainLookupArgs,\n) => Promise<AddressLookupResult | DomainLookupResult | null>;\n"]}