import { PublicKey } from "@solana/web3.js"; import type { BlockassetProject } from "../../idl"; import idl from "../../idl/project.json"; export const PROJECT_ADDRESS = new PublicKey( "prjzeH8Jr5cbwMbzP8BykkRnW88MQ9pcRbqkvL74ewK" ); export const WRAPPED_SOL_MINT = new PublicKey( "So11111111111111111111111111111111111111112" ); export const METADATA_PROGRAM_ID = new PublicKey( "metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s" ); export const TOKEN_AUTH_RULES_ID = new PublicKey( "auth9SigNpDKz4sJJ1DfCTuZrZNSAgh9sFD3rboVmgg" ); export const PROJECT_IDL = idl; export const PROJECT_PREFIX = "project"; export const IDENTIFIER_PREFIX = "identifier"; export type PROJECT_PROGRAM = BlockassetProject; // Utility type to extract a specific type from the IDL types array by name type ExtractIdlType = Extract< T[number], { name: N } >["type"]; // Utility type to convert snake_case to camelCase (handles Anchor's automatic conversion) type SnakeToCamel = S extends `${infer T}_${infer U}` ? `${T}${Capitalize>}` : S; // Utility type to convert IDL field types to TypeScript types type IdlTypeToTS = T extends | "u8" | "u16" | "u32" | "u64" | "i8" | "i16" | "i32" | "i64" ? number : T extends "bool" ? boolean : T extends "string" ? string : T extends "pubkey" ? PublicKey : T extends { vec: infer U } ? IdlTypeToTS[] : T extends { option: infer U } ? IdlTypeToTS | null : never; // Utility type to convert IDL struct fields to TypeScript object with camelCase field names type IdlStructToTS = T extends { kind: "struct"; fields: infer F } ? F extends readonly any[] ? { [K in F[number] as SnakeToCamel]: IdlTypeToTS; } : never : never; // Extract the project type from IDL and convert to TypeScript export type ProjectData = IdlStructToTS< ExtractIdlType >; // Extract the identifier type from IDL and convert to TypeScript export type IdentifierData = IdlStructToTS< ExtractIdlType >;