{"version":3,"file":"Mint.cjs","sources":["../../../../../src/plugins/tokenModule/models/Mint.ts"],"sourcesContent":["import type { PublicKey } from '@solana/web3.js';\n\nimport { MintAccount } from '../accounts';\nimport { WRAPPED_SOL_MINT } from '../constants';\nimport { amount, SplTokenCurrency, SplTokenAmount } from '../../../types';\nimport { Option } from '../../../utils/types';\nimport { assert } from '../../../utils/assert';\n\n/**\n * This model represents a mint account.\n *\n * @group Models\n */\nexport type Mint = {\n  /** A model identifier to distinguish models in the SDK. */\n  readonly model: 'mint';\n\n  /** The address of the mint account. */\n  readonly address: PublicKey;\n\n  /**\n   * The address of the authority that is allowed\n   * to mint new tokens to token accounts.\n   *\n   * When `null`, no authority is ever allowed to mint new tokens.\n   */\n  readonly mintAuthorityAddress: Option<PublicKey>;\n\n  /**\n   * The address of the authority that is allowed\n   * to freeze token accounts.\n   *\n   * When `null`, no authority is ever allowed to freeze token accounts.\n   */\n  readonly freezeAuthorityAddress: Option<PublicKey>;\n\n  /**\n   * The number of decimal points used to define token amounts.\n   */\n  readonly decimals: number;\n\n  /**\n   * The current supply of tokens across all token accounts.\n   */\n  readonly supply: SplTokenAmount;\n\n  /**\n   * Helper boolean to determine whether this mint account is the\n   * mint account that wraps SOL as an SPL token.\n   */\n  readonly isWrappedSol: boolean;\n\n  /**\n   * A currency object that can be used to create amounts\n   * representing the tokens of this mint account.\n   *\n   * For instance, here's how you can transform an amount of token\n   * in basis points into an `Amount` object.\n   *\n   * ```ts\n   * const tokenBasisPoints = 1000;\n   * const tokensAsAmount = amount(tokenBasisPoints, mint.currency);\n   * ```\n   */\n  readonly currency: SplTokenCurrency;\n};\n\n/** @group Model Helpers */\nexport const isMint = (value: any): value is Mint =>\n  typeof value === 'object' && value.model === 'mint';\n\n/** @group Model Helpers */\nexport function assertMint(value: any): asserts value is Mint {\n  assert(isMint(value), 'Expected Mint model');\n}\n\n/** @group Model Helpers */\nexport const toMint = (account: MintAccount): Mint => {\n  const isWrappedSol = account.publicKey.equals(WRAPPED_SOL_MINT);\n  const currency: SplTokenCurrency = {\n    symbol: isWrappedSol ? 'SOL' : 'Token',\n    decimals: account.data.decimals,\n    namespace: 'spl-token',\n  };\n\n  return {\n    model: 'mint',\n    address: account.publicKey,\n    mintAuthorityAddress: account.data.mintAuthorityOption\n      ? account.data.mintAuthority\n      : null,\n    freezeAuthorityAddress: account.data.freezeAuthorityOption\n      ? account.data.freezeAuthority\n      : null,\n    decimals: account.data.decimals,\n    supply: amount(account.data.supply.toString(), currency),\n    isWrappedSol,\n    currency,\n  };\n};\n"],"names":["isMint","value","_typeof","model","assertMint","assert","toMint","account","isWrappedSol","publicKey","equals","WRAPPED_SOL_MINT","currency","symbol","decimals","data","namespace","address","mintAuthorityAddress","mintAuthorityOption","mintAuthority","freezeAuthorityAddress","freezeAuthorityOption","freezeAuthority","supply","amount","toString"],"mappings":";;;;;;;;;AAQA;AACA;AACA;AACA;AACA;;AAuDA;IACaA,MAAM,GAAG,SAATA,MAAMA,CAAIC,KAAU,EAAA;EAAA,OAC/BC,mCAAA,CAAOD,KAAK,CAAK,KAAA,QAAQ,IAAIA,KAAK,CAACE,KAAK,KAAK,MAAM,CAAA;AAAA,EAAA;;AAErD;AACO,SAASC,UAAUA,CAACH,KAAU,EAAyB;AAC5DI,EAAAA,aAAM,CAACL,MAAM,CAACC,KAAK,CAAC,EAAE,qBAAqB,CAAC,CAAA;AAC9C,CAAA;;AAEA;IACaK,MAAM,GAAG,SAATA,MAAMA,CAAIC,OAAoB,EAAW;EACpD,IAAMC,YAAY,GAAGD,OAAO,CAACE,SAAS,CAACC,MAAM,CAACC,0BAAgB,CAAC,CAAA;AAC/D,EAAA,IAAMC,QAA0B,GAAG;AACjCC,IAAAA,MAAM,EAAEL,YAAY,GAAG,KAAK,GAAG,OAAO;AACtCM,IAAAA,QAAQ,EAAEP,OAAO,CAACQ,IAAI,CAACD,QAAQ;AAC/BE,IAAAA,SAAS,EAAE,WAAA;GACZ,CAAA;EAED,OAAO;AACLb,IAAAA,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