import { PublicKey } from '@solana/web3.js'; import { Coder, Program, Provider } from '@staratlas/anchor'; import { AnchorTypes, ExtractArrayType, ListenProgram, ListenProgramStatic, ProgramMethods, generateErrorMap, staticImplements, } from '@staratlas/data-source'; import { CraftableItem } from './craftableItem'; import { CraftingFacility } from './craftingFacility'; import { CraftingProcess } from './craftingProcess'; import { CraftingDomain } from './domain'; import { IDL as CRAFTING_IDL, Crafting as CraftingIDL } from './idl/crafting'; import { Recipe } from './recipe'; import { RecipeCategory } from './recipeCategory'; export { IDL as CRAFTING_IDL } from './idl/crafting'; export type { Crafting as CraftingIDL } from './idl/crafting'; export type CraftingAccountsArray = ExtractArrayType< CraftingIDL['accounts'] >['name']; export type CraftingTypesArray = ExtractArrayType['name']; export const craftingErrorMap = generateErrorMap(CRAFTING_IDL); export type CraftingIDLProgram = ProgramMethods; export type CraftingCoder = Coder; export type CraftingTypes = AnchorTypes; export type CraftingIDLAccounts = CraftingTypes['Accounts']; export type CraftableItemAccount = CraftingIDLAccounts['craftableItem']; export type CraftingFacilityAccount = CraftingIDLAccounts['craftingFacility']; export type CraftingProcessAccount = CraftingIDLAccounts['craftingProcess']; export type CraftingDomainAccount = CraftingIDLAccounts['domain']; export type RecipeCategoryAccount = CraftingIDLAccounts['recipeCategory']; export type RecipeAccount = CraftingIDLAccounts['recipe']; export type CraftingAccounts = { craftableItem: CraftableItem; craftingFacility: CraftingFacility; craftingProcess: CraftingProcess; domain: CraftingDomain; recipe: Recipe; recipeCategory: RecipeCategory; }; // Instruction Contexts export type CraftingInstructions = CraftingTypes['Instructions']; export type RegisterCraftableItemIx = CraftingInstructions['registerCraftableItem']; export type DrainCraftableItemBankIx = CraftingInstructions['drainCraftableItemBank']; export type CreateCraftingProcessIx = CraftingInstructions['createCraftingProcess']; export type LegitimizeRecipeIngredientIx = CraftingInstructions['legitimizeRecipeIngredient']; // Instruction Specific Accounts export type RegisterCraftableItemIxInput = RegisterCraftableItemIx['args'][1]; export type DrainCraftableItemBankIxInput = DrainCraftableItemBankIx['args'][1]; export type CreateCraftingProcessInput = CreateCraftingProcessIx['args'][1]; export type LegitimizeRecipeIngredientInput = LegitimizeRecipeIngredientIx['args'][1]; @staticImplements< ListenProgramStatic >() export class CraftingProgram extends ListenProgram< CraftingAccounts, CraftingIDL > { constructor(program: CraftingIDLProgram) { super(program, { craftableItem: CraftableItem, craftingFacility: CraftingFacility, craftingProcess: CraftingProcess, domain: CraftingDomain, recipe: Recipe, recipeCategory: RecipeCategory, }); } static buildProgram( programId: PublicKey, provider?: Provider, coder?: Coder, ): CraftingIDLProgram { return new Program(CRAFTING_IDL, programId, provider, coder); } }