/**
 * Blockchain Contract Types
 * 
 * This file provides type-safe interfaces for smart contracts.
 * In production, these should be generated from compiled contracts using typechain.
 * 
 * To generate types:
 * 1. Compile contracts: cd blockchain && pnpm compile
 * 2. Generate types: cd blockchain && pnpm generate:types
 * 3. Import from: import { ResourceProvisioning } from '../types/contracts'
 */

// Resource Type enum matching smart contract
export enum ResourceType {
  VM = 0,
  CONTAINER = 1,
  STORAGE = 2,
  NETWORK = 3,
  SERVICE = 4,
}

// Resource struct matching smart contract
export interface BlockchainResource {
  resourceId: string
  region: string
  datacenter: string
  resourceType: ResourceType
  provisionedAt: bigint
  provisionedBy: string
  active: boolean
  metadata: string
}

// Event types
export interface ResourceProvisionedEvent {
  resourceId: string
  region: string
  resourceType: ResourceType
  provisionedBy: string
  timestamp: bigint
}

export interface ResourceDeprovisionedEvent {
  resourceId: string
  deprovisionedBy: string
  timestamp: bigint
}

/**
 * Try to import generated types, fallback to manual definitions
 */
let ResourceProvisioningContract: any = null
let IdentityManagementContract: any = null

try {
  // Try to import generated types
  const generatedTypes = require('../types/contracts')
  ResourceProvisioningContract = generatedTypes.ResourceProvisioning
  IdentityManagementContract = generatedTypes.IdentityManagement
} catch (error) {
  // Types not generated yet - using manual definitions
  // This is expected until contracts are compiled and types are generated
}

export { ResourceProvisioningContract, IdentityManagementContract }

