{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import {constants, Address} from '@unique-nft/utils/index'\nexport {constants}\n\nimport type {ethers as _Ethers, Signer} from 'ethers'\ntype Ethers = typeof _Ethers\ntype SignerOrProvider = Signer | _Ethers.providers.Provider\n\nimport type {\n  CollectionHelpers,\n  ContractHelpers,\n  UniqueNFT,\n  UniqueFungible,\n  UniqueRefungible,\n  UniqueRefungibleToken,\n} from '../dist/ethers'\n\nexport type {\n  CollectionHelpers,\n  ContractHelpers,\n  UniqueNFT,\n  UniqueFungible,\n  UniqueRefungible,\n  UniqueRefungibleToken,\n}\n\nconst getEthers = async (ethers?: Ethers): Promise<Ethers> => {\n  if (ethers) return ethers\n  return (await import('ethers')).ethers\n}\n\n\nconst collectionIdOrAddressToAddress = (collectionIdOrAddress: number | string): string => {\n  return typeof collectionIdOrAddress === 'string'\n    ? collectionIdOrAddress\n    : Address.collection.idToAddress(collectionIdOrAddress)\n}\n\nexport type RefungibleTokenCollectionAndTokenId = {\n  collectionIdOrAddress: number | string\n  tokenId: number\n}\nconst tokenIdOrAddressToAddress = (tokenIdOrAddress: RefungibleTokenCollectionAndTokenId | string): string => {\n  if (typeof tokenIdOrAddress === 'string') {\n    return tokenIdOrAddress\n  }\n  const collectionId = typeof tokenIdOrAddress.collectionIdOrAddress === 'number'\n    ? tokenIdOrAddress.collectionIdOrAddress\n    : Address.collection.addressToId(tokenIdOrAddress.collectionIdOrAddress)\n\n  return Address.nesting.idsToAddress(collectionId, tokenIdOrAddress.tokenId)\n}\n\n\n\nexport const CollectionHelpersFactory = async (signerOrProvider: SignerOrProvider, ethers?: Ethers) => {\n  const ethersLib = await getEthers(ethers)\n\n  return new ethersLib.Contract(\n    constants.STATIC_ADDRESSES.collectionHelpers,\n    (await import('../dist/abi/CollectionHelpers.json')).default,\n    signerOrProvider\n  ) as CollectionHelpers\n}\n\nexport const ContractHelpersFactory = async (signerOrProvider: SignerOrProvider, ethers?: Ethers) => {\n  const ethersLib = await getEthers(ethers)\n\n  return new ethersLib.Contract(\n    constants.STATIC_ADDRESSES.contractHelpers,\n    (await import('../dist/abi/ContractHelpers.json')).default,\n    signerOrProvider\n  ) as ContractHelpers\n}\n\nexport const UniqueNFTFactory = async (collectionIdOrAddress: number | string, signerOrProvider: SignerOrProvider, ethers?: Ethers) => {\n  const ethersLib = await getEthers(ethers)\n\n  return new ethersLib.Contract(\n    collectionIdOrAddressToAddress(collectionIdOrAddress),\n    (await import('../dist/abi/UniqueNFT.json')).default,\n    signerOrProvider\n  ) as UniqueNFT\n}\n\nexport const UniqueFungibleFactory = async (collectionIdOrAddress: number | string, signerOrProvider: SignerOrProvider, ethers?: Ethers) => {\n  const ethersLib = await getEthers(ethers)\n\n  return new ethersLib.Contract(\n    collectionIdOrAddressToAddress(collectionIdOrAddress),\n    (await import('../dist/abi/UniqueFungible.json')).default,\n    signerOrProvider\n  ) as UniqueFungible\n}\n\nexport const UniqueRefungibleFactory = async (collectionIdOrAddress: number | string, signerOrProvider: SignerOrProvider, ethers?: Ethers) => {\n  const ethersLib = await getEthers(ethers)\n\n  return new ethersLib.Contract(\n    collectionIdOrAddressToAddress(collectionIdOrAddress),\n    (await import('../dist/abi/UniqueRefungible.json')).default,\n    signerOrProvider\n  ) as UniqueFungible\n}\n\nexport const UniqueRefungibleTokenFactory = async (tokenIdOrAddress: RefungibleTokenCollectionAndTokenId | string, signerOrProvider: SignerOrProvider, ethers?: Ethers) => {\n  const ethersLib = await getEthers(ethers)\n\n  const address = tokenIdOrAddressToAddress(tokenIdOrAddress)\n\n  return new ethersLib.Contract(\n    collectionIdOrAddressToAddress(address),\n    (await import('../dist/abi/UniqueRefungible.json')).default,\n    signerOrProvider\n  ) as UniqueFungible\n}\n"],"mappings":";AAAA,SAAQ,WAAW,eAAc;AAyBjC,IAAM,YAAY,OAAO,WAAqC;AAC5D,MAAI;AAAQ,WAAO;AACnB,UAAQ,MAAM,OAAO,WAAW;AAClC;AAGA,IAAM,iCAAiC,CAAC,0BAAmD;AAC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