import { Form , FormInstance } from 'antd' ; import { Governance , Realm } from '@solana/spl-governance' ; import { TransactionInstruction } from '@solana/web3.js' ; import React , { useState } from 'react' ; import { formDefaults } from '../../../../tools/forms' ; import { InstructionSelector , InstructionType } from './instructionSelector' ; import { SplTokenMintToForm } from './splTokenMintToForm' ; import { getGovernanceInstructions , GovernanceInstructionForm , } from './governanceInstructionForm' ; import { ProgramAccount } from '@solana/spl-governance' ; export const MintInstructionsForm = ( { form , realm , governance , onCreateInstruction , coreInstructions , } ) => { const [ instruction , setInstruction ] = useState < InstructionType | undefined > ( ) ; let instructions = [ InstructionType . SplTokenMintTo , ... coreInstructions , ... getGovernanceInstructions ( realm , governance ) , ] ; if ( ! instruction ) { setInstruction ( instructions [ 0 ] ) ; return null ; } return ( < Form { ... formDefaults } initialValues = { { instructionType : instruction } } > < InstructionSelector instructions = { instructions } onChange = { setInstruction } > < /InstructionSelector> { instruction === InstructionType . SplTokenMintTo && ( < SplTokenMintToForm form = { form } governance = { governance } onCreateInstruction = { onCreateInstruction } > < /SplTokenMintToForm>)} < GovernanceInstructionForm form = { form } realm = { realm } governance = { governance } onCreateInstruction = { onCreateInstruction } instruction = { instruction } > < /GovernanceInstructionForm> < /Form>); } ;