import { PublicKey } from '@solana/web3.js'; import { BinaryReader, BinaryWriter } from 'borsh'; export const extendBorsh = () => { (BinaryReader.prototype as any).readPubkey = function () { const reader = this as unknown as BinaryReader; const array = reader.readFixedArray(32); return new PublicKey(array); }; (BinaryWriter.prototype as any).writePubkey = function (value: PublicKey) { const writer = this as unknown as BinaryWriter; writer.writeFixedArray(value.toBuffer()); }; }; extendBorsh();