{"version":3,"sources":["../../src/types/contracts.ts"],"sourcesContent":["/**\n * Defines types for smart contract interactions.\n *\n * @remarks\n * This module provides comprehensive type definitions for Vana protocol\n * smart contracts including contract names, deployment information, and\n * advanced TypeScript utility types for type-safe contract interactions.\n *\n * @category Types\n * @module types/contracts\n */\n\nimport type { Abi, Address, Hash, GetContractReturnType } from \"viem\";\n\n/**\n * Enumerates all supported Vana protocol contract names.\n *\n * @remarks\n * Use these names with `getContractController()` to get typed contract\n * instances. Each name corresponds to a specific protocol contract with\n * its own ABI and functionality.\n *\n * @category Contracts\n */\nexport type VanaContractName =\n  | \"DataPortabilityPermissions\"\n  | \"DataPortabilityServers\"\n  | \"DataPortabilityGrantees\"\n  | \"DataRegistry\"\n  | \"ComputeEngine\"\n  | \"TeePoolPhala\"\n  | \"DataRefinerRegistry\"\n  | \"QueryEngine\"\n  | \"ComputeInstructionRegistry\"\n  | \"TeePoolEphemeralStandard\"\n  | \"TeePoolPersistentStandard\"\n  | \"TeePoolPersistentGpu\"\n  | \"TeePoolDedicatedStandard\"\n  | \"TeePoolDedicatedGpu\"\n  | \"VanaEpoch\"\n  | \"DLPRegistry\"\n  | \"DLPRegistryTreasury\"\n  | \"VanaPoolStaking\"\n  | \"VanaPoolEntity\"\n  | \"VanaPoolTreasury\"\n  | \"DAT\"\n  | \"DATFactory\"\n  | \"DATPausable\"\n  | \"DATVotes\";\n\n/**\n * Provides contract deployment information with typed ABI.\n *\n * @remarks\n * Contains the minimum information needed to interact with a\n * deployed contract: its address and ABI.\n *\n * @typeParam TAbi - The contract's ABI type for full type safety\n *\n * @category Contracts\n */\nexport interface ContractInfo<TAbi extends Abi = Abi> {\n  /** The contract's deployed address */\n  address: Address;\n  /** The contract's ABI */\n  abi: TAbi;\n}\n\n/**\n * Tracks contract deployment metadata.\n *\n * @remarks\n * Records when and how a contract was deployed to the blockchain,\n * useful for verification and debugging.\n *\n * @category Contracts\n */\nexport interface ContractDeployment {\n  /** The contract's deployed address */\n  address: Address;\n  /** Block number where contract was deployed */\n  blockNumber: bigint;\n  /** Transaction hash of deployment */\n  transactionHash: Hash;\n}\n\n/**\n * Represents a fully typed contract instance.\n *\n * @remarks\n * Alias for viem's GetContractReturnType, providing a contract\n * instance with all methods fully typed based on the ABI.\n *\n * @typeParam TAbi - The contract's ABI type\n *\n * @category Contracts\n */\nexport type VanaContractInstance<TAbi extends Abi = Abi> =\n  GetContractReturnType<TAbi>;\n\n/**\n * Maps contract addresses by chain ID and contract name.\n *\n * @remarks\n * Hierarchical mapping structure for multi-chain contract deployments.\n * Used internally for address resolution across different networks.\n *\n * @category Contracts\n */\nexport type ContractAddresses = {\n  [chainId: number]: {\n    [contractName in VanaContractName]?: Address;\n  };\n};\n\n/**\n * Extracts typed parameters for a contract method from its ABI.\n *\n * @remarks\n * Advanced utility type that provides type-safe parameter extraction\n * from contract ABIs. Maps Solidity types to TypeScript types automatically.\n *\n * @typeParam TAbi - The contract's ABI type\n * @typeParam TFunctionName - The name of the function to extract parameters for\n *\n * @internal\n */\nexport type ContractMethodParams<\n  TAbi extends Abi,\n  TFunctionName extends string,\n> = TAbi extends readonly unknown[]\n  ? TAbi[number] extends {\n      name: TFunctionName;\n      type: \"function\";\n      inputs: infer TInputs;\n    }\n    ? TInputs extends readonly unknown[]\n      ? {\n          [K in keyof TInputs]: TInputs[K] extends {\n            name: infer TName;\n            type: infer TType;\n          }\n            ? TName extends string\n              ? TType extends \"address\"\n                ? Address\n                : TType extends \"uint256\"\n                  ? bigint\n                  : TType extends \"string\"\n                    ? string\n                    : TType extends \"bool\"\n                      ? boolean\n                      : TType extends \"bytes32\"\n                        ? Hash\n                        : unknown\n              : never\n            : never;\n        }\n      : never\n    : never\n  : never;\n\n/**\n * Extracts typed return values for a contract method from its ABI.\n *\n * @remarks\n * Advanced utility type that provides type-safe return type extraction\n * from contract ABIs. Handles single values and tuples appropriately.\n *\n * @typeParam TAbi - The contract's ABI type\n * @typeParam TFunctionName - The name of the function to extract return type for\n *\n * @internal\n */\nexport type ContractMethodReturnType<\n  TAbi extends Abi,\n  TFunctionName extends string,\n> = TAbi extends readonly unknown[]\n  ? TAbi[number] extends {\n      name: TFunctionName;\n      type: \"function\";\n      outputs: infer TOutputs;\n    }\n    ? TOutputs extends readonly unknown[]\n      ? TOutputs[\"length\"] extends 1\n        ? TOutputs[0] extends { type: infer TType }\n          ? TType extends \"address\"\n            ? Address\n            : TType extends \"uint256\"\n              ? bigint\n              : TType extends \"string\"\n                ? string\n                : TType extends \"bool\"\n                  ? boolean\n                  : TType extends \"bytes32\"\n                    ? Hash\n                    : unknown\n          : unknown\n        : {\n            [K in keyof TOutputs]: TOutputs[K] extends {\n              name: infer TName;\n              type: infer TType;\n            }\n              ? TName extends string\n                ? TType extends \"address\"\n                  ? Address\n                  : TType extends \"uint256\"\n                    ? bigint\n                    : TType extends \"string\"\n                      ? string\n                      : TType extends \"bool\"\n                        ? boolean\n                        : TType extends \"bytes32\"\n                          ? Hash\n                          : unknown\n                : never\n              : never;\n          }\n      : never\n    : never\n  : never;\n"],"mappings":";;;;;;;;;;;;;;AAAA;AAAA;","names":[]}