@drift-labs/sdk
Version:
SDK for Drift Protocol
45 lines (44 loc) • 1.46 kB
TypeScript
/// <reference types="node" />
/// <reference types="node" />
import { Buffer } from 'buffer';
import { Idl, BorshEventCoder, BorshInstructionCoder } from '../isomorphic/anchor';
export declare class CustomBorshCoder<A extends string = string, _T extends string = string> {
readonly idl: Idl;
/**
* Instruction coder.
*/
readonly instruction: BorshInstructionCoder;
/**
* Account coder.
*/
readonly accounts: CustomBorshAccountsCoder<A>;
/**
* Coder for events.
*/
readonly events: BorshEventCoder;
/**
* Coder for user-defined types.
*/
readonly types: any;
constructor(idl: Idl);
}
/**
* Custom accounts coder that wraps BorshAccountsCoder to fix encode buffer sizing.
*/
export declare class CustomBorshAccountsCoder<A extends string = string> {
private baseCoder;
private idl;
constructor(idl: Idl);
encode<T = any>(accountName: A, account: T): Promise<Buffer>;
decode<T = any>(accountName: A, data: Buffer): T;
decodeAny<T = any>(data: Buffer): T;
decodeUnchecked<T = any>(accountName: A, ix: Buffer): T;
memcmp(accountName: A, appendData?: Buffer): any;
size(accountName: A | string): number;
/**
* Calculates and returns a unique 8 byte discriminator prepended to all anchor accounts.
*
* @param name The name of the account to get the discriminator of.
*/
static accountDiscriminator(_name: string): Buffer;
}