import { PublicKey } from "@solana/web3.js" // eslint-disable-line @typescript-eslint/no-unused-vars import BN from "bn.js" // eslint-disable-line @typescript-eslint/no-unused-vars import * as types from "../types" // eslint-disable-line @typescript-eslint/no-unused-vars import * as borsh from "@project-serum/borsh" export interface InputJSON { kind: "Input" } export class Input { readonly discriminator = 0 readonly kind = "Input" toJSON(): InputJSON { return { kind: "Input", } } toEncodable() { return { Input: {}, } } } export interface OutputJSON { kind: "Output" } export class Output { readonly discriminator = 1 readonly kind = "Output" toJSON(): OutputJSON { return { kind: "Output", } } toEncodable() { return { Output: {}, } } } // eslint-disable-next-line @typescript-eslint/no-explicit-any export function fromDecoded(obj: any): types.InputOrOutputKind { if (typeof obj !== "object") { throw new Error("Invalid enum object") } if ("Input" in obj) { return new Input() } if ("Output" in obj) { return new Output() } throw new Error("Invalid enum object") } export function fromJSON( obj: types.InputOrOutputJSON ): types.InputOrOutputKind { switch (obj.kind) { case "Input": { return new Input() } case "Output": { return new Output() } } } export function layout(property?: string) { const ret = borsh.rustEnum([ borsh.struct([], "Input"), borsh.struct([], "Output"), ]) if (property !== undefined) { return ret.replicate(property) } return ret }