{"version":3,"file":"Program.cjs","sources":["../../src/Program.ts"],"sourcesContent":["import type { PublicKey } from '@metaplex-foundation/umi-public-keys';\nimport type { Cluster } from './Cluster';\nimport type { ProgramError } from './errors';\n\n/**\n * An error that contains Program logs.\n * @category Programs\n */\nexport type ErrorWithLogs = Error & { logs: string[] };\n\n/**\n * An error that contains a Program error code.\n * @category Programs\n */\nexport type ErrorWithCode = Error & { code: number };\n\n/**\n * Whether the given value is an instance of {@link ErrorWithLogs}.\n * @category Programs\n */\nexport const isErrorWithLogs = (error: unknown): error is ErrorWithLogs =>\n  error instanceof Error && 'logs' in error;\n\n/**\n * Defines a Solana Program that can be\n * registered in Umi's program repository.\n *\n * @category Programs\n */\nexport type Program = {\n  /**\n   * A unique name for the Program in camelCase.\n   *\n   * To avoid conflict with other organizations, it is recommended\n   * to prefix the program name with a namespace that is unique to\n   * your organization. For instance, Metaplex programs are prefixed\n   * with `mpl` like so: `mplTokenMetadata` or `mplCandyMachine`.\n   */\n  name: string;\n\n  /**\n   * The public key of the program.\n   */\n  publicKey: PublicKey;\n\n  /**\n   * Retrieves a {@link ProgramError} from a given error code\n   * or `null` if the error code is not recognized.\n   */\n  getErrorFromCode: (code: number, cause?: Error) => ProgramError | null;\n\n  /**\n   * Retrieves a {@link ProgramError} from a given error name\n   * or `null` if the error name is not recognized.\n   */\n  getErrorFromName: (name: string, cause?: Error) => ProgramError | null;\n\n  /**\n   * A method that returns `true` if the program is available on the given cluster.\n   *\n   * If the same program is available on multiple clusters but using different public keys,\n   * multiple Program instances must be registered such that the `isOnCluster` method\n   * returns `true` for the appropriate cluster.\n   */\n  isOnCluster: (cluster: Cluster) => boolean;\n};\n"],"names":["isErrorWithLogs","error","Error"],"mappings":";;;;AAIA;AACA;AACA;AACA;;AAGA;AACA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACO,MAAMA,eAAe,GAAIC,KAAc,IAC5CA,KAAK,YAAYC,KAAK,IAAI,MAAM,IAAID,MAAK;;AAE3C;AACA;AACA;AACA;AACA;AACA;;;;"}