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 ResponseFields { id: BN foreignSender: types.ForeignAddrFields status: types.StatusKind } export interface ResponseJSON { id: string foreignSender: types.ForeignAddrJSON status: types.StatusJSON } export class Response { readonly id: BN readonly foreignSender: types.ForeignAddr readonly status: types.StatusKind constructor(fields: ResponseFields) { this.id = fields.id this.foreignSender = new types.ForeignAddr({ ...fields.foreignSender }) this.status = fields.status } static layout(property?: string) { return borsh.struct( [ borsh.u64("id"), types.ForeignAddr.layout("foreignSender"), types.Status.layout("status"), ], property ) } // eslint-disable-next-line @typescript-eslint/no-explicit-any static fromDecoded(obj: any) { return new Response({ id: obj.id, foreignSender: types.ForeignAddr.fromDecoded(obj.foreignSender), status: types.Status.fromDecoded(obj.status), }) } static toEncodable(fields: ResponseFields) { return { id: fields.id, foreignSender: types.ForeignAddr.toEncodable(fields.foreignSender), status: fields.status.toEncodable(), } } toJSON(): ResponseJSON { return { id: this.id.toString(), foreignSender: this.foreignSender.toJSON(), status: this.status.toJSON(), } } static fromJSON(obj: ResponseJSON): Response { return new Response({ id: new BN(obj.id), foreignSender: types.ForeignAddr.fromJSON(obj.foreignSender), status: types.Status.fromJSON(obj.status), }) } toEncodable() { return Response.toEncodable(this) } }