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 TransferNativeDataFields { batchId: number amount: BN fee: BN targetAddress: Array targetChain: number } export interface TransferNativeDataJSON { batchId: number amount: string fee: string targetAddress: Array targetChain: number } export class TransferNativeData { readonly batchId: number readonly amount: BN readonly fee: BN readonly targetAddress: Array readonly targetChain: number constructor(fields: TransferNativeDataFields) { this.batchId = fields.batchId this.amount = fields.amount this.fee = fields.fee this.targetAddress = fields.targetAddress this.targetChain = fields.targetChain } static layout(property?: string) { return borsh.struct( [ borsh.u32("batchId"), borsh.u64("amount"), borsh.u64("fee"), borsh.array(borsh.u8(), 32, "targetAddress"), borsh.u16("targetChain"), ], property ) } // eslint-disable-next-line @typescript-eslint/no-explicit-any static fromDecoded(obj: any) { return new TransferNativeData({ batchId: obj.batchId, amount: obj.amount, fee: obj.fee, targetAddress: obj.targetAddress, targetChain: obj.targetChain, }) } static toEncodable(fields: TransferNativeDataFields) { return { batchId: fields.batchId, amount: fields.amount, fee: fields.fee, targetAddress: fields.targetAddress, targetChain: fields.targetChain, } } toJSON(): TransferNativeDataJSON { return { batchId: this.batchId, amount: this.amount.toString(), fee: this.fee.toString(), targetAddress: this.targetAddress, targetChain: this.targetChain, } } static fromJSON(obj: TransferNativeDataJSON): TransferNativeData { return new TransferNativeData({ batchId: obj.batchId, amount: new BN(obj.amount), fee: new BN(obj.fee), targetAddress: obj.targetAddress, targetChain: obj.targetChain, }) } toEncodable() { return TransferNativeData.toEncodable(this) } }