{"version":3,"file":"contract.mjs","names":[],"sources":["../../src/commands/contract.ts"],"sourcesContent":["/** Get contract info (supports ENS) */\nimport { defineCommand } from \"citty\";\nimport type { ContractInfo } from \"../core/types.js\";\nimport { failCommand, print, reportCommandError, withSelectedProvider } from \"./shared.js\";\n\nfunction renderContract(providerName: string, info: Readonly<ContractInfo>): void {\n  print(`[${providerName}] Contract ${info.address}`);\n  print(`  Verified: ${info.isVerified}`);\n  if (info.name) print(`  Name: ${info.name}`);\n  if (info.compilerVersion) print(`  Compiler: ${info.compilerVersion}`);\n  if (info.isProxy) print(`  Proxy → ${info.implementationAddress}`);\n  if (info.isToken) print(`  Token standard: ${info.tokenStandard ?? \"ERC-20 (inferred)\"}`);\n  if (info.creator) print(`  Creator: ${info.creator}`);\n}\n\nexport default defineCommand({\n  meta: {\n    name: \"contract\",\n    description: \"Get smart contract info (supports ENS)\",\n  },\n  args: {\n    address: {\n      type: \"positional\",\n      description: \"Contract address or ENS name\",\n      required: true,\n    },\n    chain: {\n      type: \"string\",\n      alias: \"c\",\n      description: \"Chain\",\n    },\n    provider: {\n      type: \"string\",\n      alias: \"p\",\n      description: \"Provider\",\n    },\n  },\n  async run({ args }) {\n    try {\n      const { resolveInput } = await import(\"../core/input.js\");\n      await withSelectedProvider(\n        args.chain as string | undefined,\n        args.provider as string | undefined,\n        \"contractInfo\",\n        async (selected) => {\n          const getContractInfo = selected.provider.getContractInfo?.bind(selected.provider);\n          if (!selected.provider.capabilities.contractInfo || !getContractInfo) {\n            failCommand(`Provider \"${selected.name}\" does not support contract info`);\n          }\n          const { address } = await resolveInput(args.address as string, selected.chain);\n          const info = await getContractInfo(address, selected.chain);\n          renderContract(selected.name, info);\n        },\n      );\n    } catch (error) {\n      reportCommandError(error);\n    }\n  },\n});\n"],"mappings":";;AAKA,SAAS,eAAe,cAAsB,MAAoC;CAChF,MAAM,IAAI,aAAa,aAAa,KAAK,SAAS;CAClD,MAAM,eAAe,KAAK,YAAY;CACtC,IAAI,KAAK,MAAM,MAAM,WAAW,KAAK,MAAM;CAC3C,IAAI,KAAK,iBAAiB,MAAM,eAAe,KAAK,iBAAiB;CACrE,IAAI,KAAK,SAAS,MAAM,aAAa,KAAK,uBAAuB;CACjE,IAAI,KAAK,SAAS,MAAM,qBAAqB,KAAK,iBAAiB,qBAAqB;CACxF,IAAI,KAAK,SAAS,MAAM,cAAc,KAAK,SAAS;AACtD;AAEA,IAAA,mBAAe,cAAc;CAC3B,MAAM;EACJ,MAAM;EACN,aAAa;CACf;CACA,MAAM;EACJ,SAAS;GACP,MAAM;GACN,aAAa;GACb,UAAU;EACZ;EACA,OAAO;GACL,MAAM;GACN,OAAO;GACP,aAAa;EACf;EACA,UAAU;GACR,MAAM;GACN,OAAO;GACP,aAAa;EACf;CACF;CACA,MAAM,IAAI,EAAE,QAAQ;EAClB,IAAI;GACF,MAAM,EAAE,iBAAiB,MAAM,OAAO,cAAmB,CAAA,MAAA,MAAA,EAAA,aAAA;GACzD,MAAM,qBACJ,KAAK,OACL,KAAK,UACL,gBACA,OAAO,aAAa;IAClB,MAAM,kBAAkB,SAAS,SAAS,iBAAiB,KAAK,SAAS,QAAQ;IACjF,IAAI,CAAC,SAAS,SAAS,aAAa,gBAAgB,CAAC,iBACnD,YAAY,aAAa,SAAS,KAAK,iCAAiC;IAE1E,MAAM,EAAE,YAAY,MAAM,aAAa,KAAK,SAAmB,SAAS,KAAK;IAC7E,MAAM,OAAO,MAAM,gBAAgB,SAAS,SAAS,KAAK;IAC1D,eAAe,SAAS,MAAM,IAAI;GACpC,CACF;EACF,SAAS,OAAO;GACd,mBAAmB,KAAK;EAC1B;CACF;AACF,CAAC"}