UNPKG

@kamino-finance/scope-sdk

Version:
55 lines (44 loc) 1.17 kB
import { address, Address } from "@solana/kit" // 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 "@coral-xyz/borsh" import { borshAddress } from "../utils" export interface HashFields { data: Array<number> } export interface HashJSON { data: Array<number> } export class Hash { readonly data: Array<number> constructor(fields: HashFields) { this.data = fields.data } static layout(property?: string) { return borsh.struct([borsh.array(borsh.u8(), 32, "data")], property) } // eslint-disable-next-line @typescript-eslint/no-explicit-any static fromDecoded(obj: any) { return new Hash({ data: obj.data, }) } static toEncodable(fields: HashFields) { return { data: fields.data, } } toJSON(): HashJSON { return { data: this.data, } } static fromJSON(obj: HashJSON): Hash { return new Hash({ data: obj.data, }) } toEncodable() { return Hash.toEncodable(this) } }