push dist

This commit is contained in:
Faiyam Rahman 2022-08-16 19:31:55 -07:00
parent f298a8eb7c
commit f09a81d720
676 changed files with 28691 additions and 1 deletions

1
.gitignore vendored
View File

@ -1,6 +1,5 @@
bin/
node_modules/
dist/
.idea/
target/
*~

8
package.json Normal file
View File

@ -0,0 +1,8 @@
{
"name": "@blockworks-foundation/anchor",
"version": "0.25.0",
"description": "Anchor client",
"module": "./ts/dist/esm/index.js",
"main": "./ts/dist/cjs/index.js",
"browser": "./ts/dist/browser/index.js"
}

7640
ts/dist/browser/index.js vendored Normal file

File diff suppressed because it is too large Load Diff

1
ts/dist/browser/index.js.map vendored Normal file

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,34 @@
/// <reference types="node" />
import { Buffer } from "buffer";
import { Idl, IdlTypeDef } from "../../idl.js";
import { AccountsCoder } from "../index.js";
/**
* Number of bytes of the account discriminator.
*/
export declare const ACCOUNT_DISCRIMINATOR_SIZE = 8;
/**
* Encodes and decodes account objects.
*/
export declare class BorshAccountsCoder<A extends string = string> implements AccountsCoder {
/**
* Maps account type identifier to a layout.
*/
private accountLayouts;
/**
* IDL whose acconts will be coded.
*/
private idl;
constructor(idl: Idl);
encode<T = any>(accountName: A, account: T): Promise<Buffer>;
decode<T = any>(accountName: A, data: Buffer): T;
decodeUnchecked<T = any>(accountName: A, ix: Buffer): T;
memcmp(accountName: A, appendData?: Buffer): any;
size(idlAccount: IdlTypeDef): number;
/**
* Calculates and returns a unique 8 byte discriminator prepended to all anchor accounts.
*
* @param name The name of the account to calculate the discriminator.
*/
static accountDiscriminator(name: string): Buffer;
}
//# sourceMappingURL=accounts.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"accounts.d.ts","sourceRoot":"","sources":["../../../../src/coder/borsh/accounts.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAIhC,OAAO,EAAE,GAAG,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE/C,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAG5C;;GAEG;AACH,eAAO,MAAM,0BAA0B,IAAI,CAAC;AAE5C;;GAEG;AACH,qBAAa,kBAAkB,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,CACvD,YAAW,aAAa;IAExB;;OAEG;IACH,OAAO,CAAC,cAAc,CAAiB;IAEvC;;OAEG;IACH,OAAO,CAAC,GAAG,CAAM;gBAEE,GAAG,EAAE,GAAG;IAad,MAAM,CAAC,CAAC,GAAG,GAAG,EAAE,WAAW,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC;IAYlE,MAAM,CAAC,CAAC,GAAG,GAAG,EAAE,WAAW,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,GAAG,CAAC;IAShD,eAAe,CAAC,CAAC,GAAG,GAAG,EAAE,WAAW,EAAE,CAAC,EAAE,EAAE,EAAE,MAAM,GAAG,CAAC;IAUvD,MAAM,CAAC,WAAW,EAAE,CAAC,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,GAAG;IAUhD,IAAI,CAAC,UAAU,EAAE,UAAU,GAAG,MAAM;IAM3C;;;;OAIG;WACW,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;CAKzD"}

View File

@ -0,0 +1,19 @@
/// <reference types="node" />
import { Buffer } from "buffer";
import { Idl, IdlEvent } from "../../idl.js";
import { Event } from "../../program/event.js";
import { EventCoder } from "../index.js";
export declare class BorshEventCoder implements EventCoder {
/**
* Maps account type identifier to a layout.
*/
private layouts;
/**
* Maps base64 encoded event discriminator to event name.
*/
private discriminators;
constructor(idl: Idl);
decode<E extends IdlEvent = IdlEvent, T = Record<string, never>>(log: string): Event<E, T> | null;
}
export declare function eventDiscriminator(name: string): Buffer;
//# sourceMappingURL=event.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"event.d.ts","sourceRoot":"","sources":["../../../../src/coder/borsh/event.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAIhC,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAc,MAAM,cAAc,CAAC;AACzD,OAAO,EAAE,KAAK,EAAa,MAAM,wBAAwB,CAAC;AAE1D,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,qBAAa,eAAgB,YAAW,UAAU;IAChD;;OAEG;IACH,OAAO,CAAC,OAAO,CAAsB;IAErC;;OAEG;IACH,OAAO,CAAC,cAAc,CAAsB;gBAEzB,GAAG,EAAE,GAAG;IA6BpB,MAAM,CAAC,CAAC,SAAS,QAAQ,GAAG,QAAQ,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,EACpE,GAAG,EAAE,MAAM,GACV,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,IAAI;CA0BtB;AAED,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEvD"}

View File

@ -0,0 +1,9 @@
import { Layout } from "buffer-layout";
import { IdlField, IdlTypeDef } from "../../idl.js";
export declare class IdlCoder {
static fieldLayout(field: {
name?: string;
} & Pick<IdlField, "type">, types?: IdlTypeDef[]): Layout;
static typeDefLayout(typeDef: IdlTypeDef, types?: IdlTypeDef[], name?: string): Layout;
}
//# sourceMappingURL=idl.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"idl.d.ts","sourceRoot":"","sources":["../../../../src/coder/borsh/idl.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAEvC,OAAO,EAAE,QAAQ,EAAE,UAAU,EAA2B,MAAM,cAAc,CAAC;AAG7E,qBAAa,QAAQ;WACL,WAAW,CACvB,KAAK,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC,QAAQ,EAAE,MAAM,CAAC,EACjD,KAAK,CAAC,EAAE,UAAU,EAAE,GACnB,MAAM;WAwGK,aAAa,CACzB,OAAO,EAAE,UAAU,EACnB,KAAK,GAAE,UAAU,EAAO,EACxB,IAAI,CAAC,EAAE,MAAM,GACZ,MAAM;CAqCV"}

View File

@ -0,0 +1,39 @@
import { Idl } from "../../idl.js";
import { BorshInstructionCoder } from "./instruction.js";
import { BorshAccountsCoder } from "./accounts.js";
import { BorshEventCoder } from "./event.js";
import { BorshStateCoder } from "./state.js";
import { BorshTypesCoder } from "./types.js";
import { Coder } from "../index.js";
export { BorshInstructionCoder } from "./instruction.js";
export { BorshAccountsCoder, ACCOUNT_DISCRIMINATOR_SIZE } from "./accounts.js";
export { BorshEventCoder, eventDiscriminator } from "./event.js";
export { BorshStateCoder, stateDiscriminator } from "./state.js";
/**
* BorshCoder is the default Coder for Anchor programs implementing the
* borsh based serialization interface.
*/
export declare class BorshCoder<A extends string = string, T extends string = string> implements Coder {
/**
* Instruction coder.
*/
readonly instruction: BorshInstructionCoder;
/**
* Account coder.
*/
readonly accounts: BorshAccountsCoder<A>;
/**
* Coder for state structs.
*/
readonly state: BorshStateCoder;
/**
* Coder for events.
*/
readonly events: BorshEventCoder;
/**
* Coder for user-defined types.
*/
readonly types: BorshTypesCoder<T>;
constructor(idl: Idl);
}
//# sourceMappingURL=index.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/coder/borsh/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AACnC,OAAO,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAEpC,OAAO,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,EAAE,kBAAkB,EAAE,0BAA0B,EAAE,MAAM,eAAe,CAAC;AAC/E,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AACjE,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAEjE;;;GAGG;AACH,qBAAa,UAAU,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,EAAE,CAAC,SAAS,MAAM,GAAG,MAAM,CAC1E,YAAW,KAAK;IAEhB;;OAEG;IACH,QAAQ,CAAC,WAAW,EAAE,qBAAqB,CAAC;IAE5C;;OAEG;IACH,QAAQ,CAAC,QAAQ,EAAE,kBAAkB,CAAC,CAAC,CAAC,CAAC;IAEzC;;OAEG;IACH,QAAQ,CAAC,KAAK,EAAE,eAAe,CAAC;IAEhC;;OAEG;IACH,QAAQ,CAAC,MAAM,EAAE,eAAe,CAAC;IAEjC;;OAEG;IACH,QAAQ,CAAC,KAAK,EAAE,eAAe,CAAC,CAAC,CAAC,CAAC;gBAEvB,GAAG,EAAE,GAAG;CASrB"}

View File

@ -0,0 +1,59 @@
/// <reference types="node" />
import { Buffer } from "buffer";
import { AccountMeta, PublicKey } from "@solana/web3.js";
import { Idl } from "../../idl.js";
import { InstructionCoder } from "../index.js";
/**
* Namespace for state method function signatures.
*/
export declare const SIGHASH_STATE_NAMESPACE = "state";
/**
* Namespace for global instruction function signatures (i.e. functions
* that aren't namespaced by the state or any of its trait implementations).
*/
export declare const SIGHASH_GLOBAL_NAMESPACE = "global";
/**
* Encodes and decodes program instructions.
*/
export declare class BorshInstructionCoder implements InstructionCoder {
private idl;
private ixLayout;
private sighashLayouts;
constructor(idl: Idl);
/**
* Encodes a program instruction.
*/
encode(ixName: string, ix: any): Buffer;
/**
* Encodes a program state instruction.
*/
encodeState(ixName: string, ix: any): Buffer;
private _encode;
private static parseIxLayout;
/**
* Decodes a program instruction.
*/
decode(ix: Buffer | string, encoding?: "hex" | "base58"): Instruction | null;
/**
* Returns a formatted table of all the fields in the given instruction data.
*/
format(ix: Instruction, accountMetas: AccountMeta[]): InstructionDisplay | null;
}
export declare type Instruction = {
name: string;
data: Object;
};
export declare type InstructionDisplay = {
args: {
name: string;
type: string;
data: string;
}[];
accounts: {
name?: string;
pubkey: PublicKey;
isSigner: boolean;
isWritable: boolean;
}[];
};
//# sourceMappingURL=instruction.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"instruction.d.ts","sourceRoot":"","sources":["../../../../src/coder/borsh/instruction.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAMhC,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,EACL,GAAG,EAYJ,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/C;;GAEG;AACH,eAAO,MAAM,uBAAuB,UAAU,CAAC;AAC/C;;;GAGG;AACH,eAAO,MAAM,wBAAwB,WAAW,CAAC;AAEjD;;GAEG;AACH,qBAAa,qBAAsB,YAAW,gBAAgB;IAOzC,OAAO,CAAC,GAAG;IAL9B,OAAO,CAAC,QAAQ,CAAsB;IAGtC,OAAO,CAAC,cAAc,CAAgD;gBAE3C,GAAG,EAAE,GAAG;IAyBnC;;OAEG;IACI,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,GAAG,GAAG,MAAM;IAI9C;;OAEG;IACI,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,GAAG,GAAG,MAAM;IAInD,OAAO,CAAC,OAAO;IAYf,OAAO,CAAC,MAAM,CAAC,aAAa;IA6B5B;;OAEG;IACI,MAAM,CACX,EAAE,EAAE,MAAM,GAAG,MAAM,EACnB,QAAQ,GAAE,KAAK,GAAG,QAAgB,GACjC,WAAW,GAAG,IAAI;IAgBrB;;OAEG;IACI,MAAM,CACX,EAAE,EAAE,WAAW,EACf,YAAY,EAAE,WAAW,EAAE,GAC1B,kBAAkB,GAAG,IAAI;CAG7B;AAED,oBAAY,WAAW,GAAG;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,oBAAY,kBAAkB,GAAG;IAC/B,IAAI,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IACrD,QAAQ,EAAE;QACR,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,SAAS,CAAC;QAClB,QAAQ,EAAE,OAAO,CAAC;QAClB,UAAU,EAAE,OAAO,CAAC;KACrB,EAAE,CAAC;CACL,CAAC"}

View File

@ -0,0 +1,11 @@
/// <reference types="node" />
import { Buffer } from "buffer";
import { Idl } from "../../idl.js";
export declare class BorshStateCoder {
private layout;
constructor(idl: Idl);
encode<T = any>(name: string, account: T): Promise<Buffer>;
decode<T = any>(ix: Buffer): T;
}
export declare function stateDiscriminator(name: string): Promise<Buffer>;
//# sourceMappingURL=state.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../../../../src/coder/borsh/state.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAGhC,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AAInC,qBAAa,eAAe;IAC1B,OAAO,CAAC,MAAM,CAAS;gBAEJ,GAAG,EAAE,GAAG;IAOd,MAAM,CAAC,CAAC,GAAG,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC;IAUhE,MAAM,CAAC,CAAC,GAAG,GAAG,EAAE,EAAE,EAAE,MAAM,GAAG,CAAC;CAKtC;AAGD,wBAAsB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAGtE"}

View File

@ -0,0 +1,21 @@
/// <reference types="node" />
import { Buffer } from "buffer";
import { Idl } from "../../idl.js";
import { TypesCoder } from "../index.js";
/**
* Encodes and decodes user-defined types.
*/
export declare class BorshTypesCoder<N extends string = string> implements TypesCoder {
/**
* Maps type name to a layout.
*/
private typeLayouts;
/**
* IDL whose types will be coded.
*/
private idl;
constructor(idl: Idl);
encode<T = any>(typeName: N, type: T): Buffer;
decode<T = any>(typeName: N, typeData: Buffer): T;
}
//# sourceMappingURL=types.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/coder/borsh/types.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AAEnC,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC;;GAEG;AACH,qBAAa,eAAe,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,CAAE,YAAW,UAAU;IAC3E;;OAEG;IACH,OAAO,CAAC,WAAW,CAAiB;IAEpC;;OAEG;IACH,OAAO,CAAC,GAAG,CAAM;gBAEE,GAAG,EAAE,GAAG;IAapB,MAAM,CAAC,CAAC,GAAG,GAAG,EAAE,QAAQ,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,GAAG,MAAM;IAW7C,MAAM,CAAC,CAAC,GAAG,GAAG,EAAE,QAAQ,EAAE,CAAC,EAAE,QAAQ,EAAE,MAAM,GAAG,CAAC;CAOzD"}

View File

@ -0,0 +1,3 @@
import { Idl, IdlTypeDef } from "../idl.js";
export declare function accountSize(idl: Idl, idlAccount: IdlTypeDef): number;
//# sourceMappingURL=common.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../src/coder/common.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAY,UAAU,EAA2B,MAAM,WAAW,CAAC;AAG/E,wBAAgB,WAAW,CAAC,GAAG,EAAE,GAAG,EAAE,UAAU,EAAE,UAAU,GAAG,MAAM,CAyBpE"}

View File

@ -0,0 +1,54 @@
/// <reference types="node" />
import { IdlEvent, IdlTypeDef } from "../idl.js";
import { Event } from "../program/event.js";
export * from "./borsh/index.js";
export * from "./spl-token/index.js";
export * from "./system/index.js";
/**
* Coder provides a facade for encoding and decoding all IDL related objects.
*/
export interface Coder<A extends string = string, T extends string = string> {
/**
* Instruction coder.
*/
readonly instruction: InstructionCoder;
/**
* Account coder.
*/
readonly accounts: AccountsCoder<A>;
/**
* Coder for state structs.
*/
readonly state: StateCoder;
/**
* Coder for events.
*/
readonly events: EventCoder;
/**
* Coder for user-defined types.
*/
readonly types: TypesCoder<T>;
}
export interface StateCoder {
encode<T = any>(name: string, account: T): Promise<Buffer>;
decode<T = any>(ix: Buffer): T;
}
export interface AccountsCoder<A extends string = string> {
encode<T = any>(accountName: A, account: T): Promise<Buffer>;
decode<T = any>(accountName: A, ix: Buffer): T;
decodeUnchecked<T = any>(accountName: A, ix: Buffer): T;
memcmp(accountName: A, appendData?: Buffer): any;
size(idlAccount: IdlTypeDef): number;
}
export interface InstructionCoder {
encode(ixName: string, ix: any): Buffer;
encodeState(ixName: string, ix: any): Buffer;
}
export interface EventCoder {
decode<E extends IdlEvent = IdlEvent, T = Record<string, string>>(log: string): Event<E, T> | null;
}
export interface TypesCoder<N extends string = string> {
encode<T = any>(typeName: N, type: T): Buffer;
decode<T = any>(typeName: N, typeData: Buffer): T;
}
//# sourceMappingURL=index.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/coder/index.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACjD,OAAO,EAAE,KAAK,EAAE,MAAM,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ACjD,IAAI,CAAC,UAAU,EAAE,UAAU,GAAG,MAAM,CAAC;CACtC;AAED,MAAM,WAAW,gBAAgB;IAC/B,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,GAAG,GAAG,MAAM,CAAC;IACxC,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,GAAG,GAAG,MAAM,CAAC;CAC9C;AAED,MAAM,WAAW,UAAU;IACzB,MAAM,CAAC,CAAC,SAAS,QAAQ,GAAG,QAAQ,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAC9D,GAAG,EAAE,MAAM,GACV,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC;CACvB;AAED,MAAM,WAAW,UAAU,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM;IACnD,MAAM,CAAC,CAAC,GAAG,GAAG,EAAE,QAAQ,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,GAAG,MAAM,CAAC;IAC9C,MAAM,CAAC,CAAC,GAAG,GAAG,EAAE,QAAQ,EAAE,CAAC,EAAE,QAAQ,EAAE,MAAM,GAAG,CAAC,CAAC;CACnD"}

View File

@ -0,0 +1,13 @@
/// <reference types="node" />
import { AccountsCoder } from "../index.js";
import { Idl, IdlTypeDef } from "../../idl.js";
export declare class SplAssociatedTokenAccountsCoder<A extends string = string> implements AccountsCoder {
private idl;
constructor(idl: Idl);
encode<T = any>(accountName: A, account: T): Promise<Buffer>;
decode<T = any>(accountName: A, ix: Buffer): T;
decodeUnchecked<T = any>(accountName: A, ix: Buffer): T;
memcmp(accountName: A, _appendData?: Buffer): any;
size(idlAccount: IdlTypeDef): number;
}
//# sourceMappingURL=accounts.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"accounts.d.ts","sourceRoot":"","sources":["../../../../src/coder/spl-associated-token/accounts.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,GAAG,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAG/C,qBAAa,+BAA+B,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,CACpE,YAAW,aAAa;IAEZ,OAAO,CAAC,GAAG;gBAAH,GAAG,EAAE,GAAG;IAEf,MAAM,CAAC,CAAC,GAAG,GAAG,EAAE,WAAW,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC;IAQlE,MAAM,CAAC,CAAC,GAAG,GAAG,EAAE,WAAW,EAAE,CAAC,EAAE,EAAE,EAAE,MAAM,GAAG,CAAC;IAI9C,eAAe,CAAC,CAAC,GAAG,GAAG,EAAE,WAAW,EAAE,CAAC,EAAE,EAAE,EAAE,MAAM,GAAG,CAAC;IASvD,MAAM,CAAC,WAAW,EAAE,CAAC,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,GAAG;IAQjD,IAAI,CAAC,UAAU,EAAE,UAAU,GAAG,MAAM;CAG5C"}

View File

@ -0,0 +1,9 @@
import { EventCoder } from "../index.js";
import { Idl } from "../../idl.js";
import { Event } from "../../program/event";
import { IdlEvent } from "../../idl";
export declare class SplAssociatedTokenEventsCoder implements EventCoder {
constructor(_idl: Idl);
decode<E extends IdlEvent = IdlEvent, T = Record<string, string>>(_log: string): Event<E, T> | null;
}
//# sourceMappingURL=events.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../../../src/coder/spl-associated-token/events.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AACnC,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAErC,qBAAa,6BAA8B,YAAW,UAAU;gBAClD,IAAI,EAAE,GAAG;IAErB,MAAM,CAAC,CAAC,SAAS,QAAQ,GAAG,QAAQ,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAC9D,IAAI,EAAE,MAAM,GACX,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,IAAI;CAGtB"}

View File

@ -0,0 +1,19 @@
import { Idl } from "../../idl.js";
import { Coder } from "../index.js";
import { SplAssociatedTokenInstructionCoder } from "./instruction.js";
import { SplAssociatedTokenStateCoder } from "./state.js";
import { SplAssociatedTokenAccountsCoder } from "./accounts.js";
import { SplAssociatedTokenEventsCoder } from "./events.js";
import { SplAssociatedTokenTypesCoder } from "./types.js";
/**
* Coder for the SPL token program.
*/
export declare class SplAssociatedTokenCoder implements Coder {
readonly instruction: SplAssociatedTokenInstructionCoder;
readonly accounts: SplAssociatedTokenAccountsCoder;
readonly state: SplAssociatedTokenStateCoder;
readonly events: SplAssociatedTokenEventsCoder;
readonly types: SplAssociatedTokenTypesCoder;
constructor(idl: Idl);
}
//# sourceMappingURL=index.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/coder/spl-associated-token/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AACnC,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,kCAAkC,EAAE,MAAM,kBAAkB,CAAC;AACtE,OAAO,EAAE,4BAA4B,EAAE,MAAM,YAAY,CAAC;AAC1D,OAAO,EAAE,+BAA+B,EAAE,MAAM,eAAe,CAAC;AAChE,OAAO,EAAE,6BAA6B,EAAE,MAAM,aAAa,CAAC;AAC5D,OAAO,EAAE,4BAA4B,EAAE,MAAM,YAAY,CAAC;AAE1D;;GAEG;AACH,qBAAa,uBAAwB,YAAW,KAAK;IACnD,QAAQ,CAAC,WAAW,EAAE,kCAAkC,CAAC;IACzD,QAAQ,CAAC,QAAQ,EAAE,+BAA+B,CAAC;IACnD,QAAQ,CAAC,KAAK,EAAE,4BAA4B,CAAC;IAC7C,QAAQ,CAAC,MAAM,EAAE,6BAA6B,CAAC;IAC/C,QAAQ,CAAC,KAAK,EAAE,4BAA4B,CAAC;gBAEjC,GAAG,EAAE,GAAG;CAOrB"}

View File

@ -0,0 +1,9 @@
/// <reference types="node" />
import { Idl } from "../../idl.js";
import { InstructionCoder } from "../index.js";
export declare class SplAssociatedTokenInstructionCoder implements InstructionCoder {
constructor(_: Idl);
encode(ixName: string, _: any): Buffer;
encodeState(_ixName: string, _ix: any): Buffer;
}
//# sourceMappingURL=instruction.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"instruction.d.ts","sourceRoot":"","sources":["../../../../src/coder/spl-associated-token/instruction.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AACnC,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/C,qBAAa,kCAAmC,YAAW,gBAAgB;gBAC7D,CAAC,EAAE,GAAG;IAElB,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,EAAE,GAAG,GAAG,MAAM;IAWtC,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,GAAG,MAAM;CAG/C"}

View File

@ -0,0 +1,9 @@
/// <reference types="node" />
import { StateCoder } from "../index.js";
import { Idl } from "../../idl";
export declare class SplAssociatedTokenStateCoder implements StateCoder {
constructor(_idl: Idl);
encode<T = any>(_name: string, _account: T): Promise<Buffer>;
decode<T = any>(_ix: Buffer): T;
}
//# sourceMappingURL=state.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../../../../src/coder/spl-associated-token/state.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAEhC,qBAAa,4BAA6B,YAAW,UAAU;gBACjD,IAAI,EAAE,GAAG;IAErB,MAAM,CAAC,CAAC,GAAG,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC;IAG5D,MAAM,CAAC,CAAC,GAAG,GAAG,EAAE,GAAG,EAAE,MAAM,GAAG,CAAC;CAGhC"}

View File

@ -0,0 +1,9 @@
/// <reference types="node" />
import { TypesCoder } from "../index.js";
import { Idl } from "../../idl.js";
export declare class SplAssociatedTokenTypesCoder implements TypesCoder {
constructor(_idl: Idl);
encode<T = any>(_name: string, _type: T): Buffer;
decode<T = any>(_name: string, _typeData: Buffer): T;
}
//# sourceMappingURL=types.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/coder/spl-associated-token/types.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AAEnC,qBAAa,4BAA6B,YAAW,UAAU;gBACjD,IAAI,EAAE,GAAG;IAErB,MAAM,CAAC,CAAC,GAAG,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,MAAM;IAGhD,MAAM,CAAC,CAAC,GAAG,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,CAAC;CAGrD"}

View File

@ -0,0 +1,13 @@
/// <reference types="node" />
import { AccountsCoder } from "../index.js";
import { Idl, IdlTypeDef } from "../../idl.js";
export declare class SplTokenAccountsCoder<A extends string = string> implements AccountsCoder {
private idl;
constructor(idl: Idl);
encode<T = any>(accountName: A, account: T): Promise<Buffer>;
decode<T = any>(accountName: A, ix: Buffer): T;
decodeUnchecked<T = any>(accountName: A, ix: Buffer): T;
memcmp(accountName: A, _appendData?: Buffer): any;
size(idlAccount: IdlTypeDef): number;
}
//# sourceMappingURL=accounts.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"accounts.d.ts","sourceRoot":"","sources":["../../../../src/coder/spl-token/accounts.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,GAAG,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAG/C,qBAAa,qBAAqB,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,CAC1D,YAAW,aAAa;IAEZ,OAAO,CAAC,GAAG;gBAAH,GAAG,EAAE,GAAG;IAEf,MAAM,CAAC,CAAC,GAAG,GAAG,EAAE,WAAW,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC;IAkBlE,MAAM,CAAC,CAAC,GAAG,GAAG,EAAE,WAAW,EAAE,CAAC,EAAE,EAAE,EAAE,MAAM,GAAG,CAAC;IAI9C,eAAe,CAAC,CAAC,GAAG,GAAG,EAAE,WAAW,EAAE,CAAC,EAAE,EAAE,EAAE,MAAM,GAAG,CAAC;IAevD,MAAM,CAAC,WAAW,EAAE,CAAC,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,GAAG;IAkBjD,IAAI,CAAC,UAAU,EAAE,UAAU,GAAG,MAAM;CAG5C"}

View File

@ -0,0 +1,27 @@
/// <reference types="node" />
import BN from "bn.js";
import { Layout } from "buffer-layout";
import { PublicKey } from "@solana/web3.js";
export declare function uint64(property?: string): Layout<u64 | null>;
export declare function bool(property?: string): Layout<boolean>;
export declare function publicKey(property?: string): Layout<PublicKey>;
export declare function coption<T>(layout: Layout<T>, property?: string): Layout<T | null>;
export declare class COptionLayout<T> extends Layout<T | null> {
layout: Layout<T>;
discriminator: Layout<number>;
constructor(layout: Layout<T>, property?: string);
encode(src: T | null, b: Buffer, offset?: number): number;
decode(b: Buffer, offset?: number): T | null;
getSpan(b: Buffer, offset?: number): number;
}
export declare class u64 extends BN {
/**
* Convert to Buffer representation
*/
toBuffer(): Buffer;
/**
* Construct a u64 from Buffer representation
*/
static fromBuffer(buffer: Buffer): u64;
}
//# sourceMappingURL=buffer-layout.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"buffer-layout.d.ts","sourceRoot":"","sources":["../../../../src/coder/spl-token/buffer-layout.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,OAAO,CAAC;AAEvB,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACvC,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,wBAAgB,MAAM,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC,GAAG,GAAG,IAAI,CAAC,CAO5D;AAED,wBAAgB,IAAI,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,CAEvD;AAED,wBAAgB,SAAS,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC,SAAS,CAAC,CAO9D;AAED,wBAAgB,OAAO,CAAC,CAAC,EACvB,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,EACjB,QAAQ,CAAC,EAAE,MAAM,GAChB,MAAM,CAAC,CAAC,GAAG,IAAI,CAAC,CAElB;AAgCD,qBAAa,aAAa,CAAC,CAAC,CAAE,SAAQ,MAAM,CAAC,CAAC,GAAG,IAAI,CAAC;IACpD,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;gBAElB,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,EAAE,MAAM;IAMhD,MAAM,CAAC,GAAG,EAAE,CAAC,GAAG,IAAI,EAAE,CAAC,EAAE,MAAM,EAAE,MAAM,SAAI,GAAG,MAAM;IAQpD,MAAM,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,SAAI,GAAG,CAAC,GAAG,IAAI;IAUvC,OAAO,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,SAAI,GAAG,MAAM;CAGvC;AAeD,qBAAa,GAAI,SAAQ,EAAE;IACzB;;OAEG;IACH,QAAQ,IAAI,MAAM;IAelB;;OAEG;IACH,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,GAAG;CAYvC"}

View File

@ -0,0 +1,9 @@
import { EventCoder } from "../index.js";
import { Idl } from "../../idl.js";
import { Event } from "../../program/event";
import { IdlEvent } from "../../idl";
export declare class SplTokenEventsCoder implements EventCoder {
constructor(_idl: Idl);
decode<E extends IdlEvent = IdlEvent, T = Record<string, string>>(_log: string): Event<E, T> | null;
}
//# sourceMappingURL=events.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../../../src/coder/spl-token/events.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AACnC,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAErC,qBAAa,mBAAoB,YAAW,UAAU;gBACxC,IAAI,EAAE,GAAG;IAErB,MAAM,CAAC,CAAC,SAAS,QAAQ,GAAG,QAAQ,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAC9D,IAAI,EAAE,MAAM,GACX,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,IAAI;CAGtB"}

View File

@ -0,0 +1,19 @@
import { Idl } from "../../idl.js";
import { Coder } from "../index.js";
import { SplTokenInstructionCoder } from "./instruction.js";
import { SplTokenStateCoder } from "./state.js";
import { SplTokenAccountsCoder } from "./accounts.js";
import { SplTokenEventsCoder } from "./events.js";
import { SplTokenTypesCoder } from "./types.js";
/**
* Coder for the SPL token program.
*/
export declare class SplTokenCoder implements Coder {
readonly instruction: SplTokenInstructionCoder;
readonly accounts: SplTokenAccountsCoder;
readonly state: SplTokenStateCoder;
readonly events: SplTokenEventsCoder;
readonly types: SplTokenTypesCoder;
constructor(idl: Idl);
}
//# sourceMappingURL=index.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/coder/spl-token/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AACnC,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,wBAAwB,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAEhD;;GAEG;AACH,qBAAa,aAAc,YAAW,KAAK;IACzC,QAAQ,CAAC,WAAW,EAAE,wBAAwB,CAAC;IAC/C,QAAQ,CAAC,QAAQ,EAAE,qBAAqB,CAAC;IACzC,QAAQ,CAAC,KAAK,EAAE,kBAAkB,CAAC;IACnC,QAAQ,CAAC,MAAM,EAAE,mBAAmB,CAAC;IACrC,QAAQ,CAAC,KAAK,EAAE,kBAAkB,CAAC;gBAEvB,GAAG,EAAE,GAAG;CAOrB"}

View File

@ -0,0 +1,9 @@
/// <reference types="node" />
import { InstructionCoder } from "../index.js";
import { Idl } from "../../idl.js";
export declare class SplTokenInstructionCoder implements InstructionCoder {
constructor(_: Idl);
encode(ixName: string, ix: any): Buffer;
encodeState(_ixName: string, _ix: any): Buffer;
}
//# sourceMappingURL=instruction.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"instruction.d.ts","sourceRoot":"","sources":["../../../../src/coder/spl-token/instruction.ts"],"names":[],"mappings":";AAGA,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AAEnC,qBAAa,wBAAyB,YAAW,gBAAgB;gBACnD,CAAC,EAAE,GAAG;IAElB,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,GAAG,GAAG,MAAM;IAuEvC,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,GAAG,MAAM;CAG/C"}

View File

@ -0,0 +1,9 @@
/// <reference types="node" />
import { StateCoder } from "../index.js";
import { Idl } from "../../idl";
export declare class SplTokenStateCoder implements StateCoder {
constructor(_idl: Idl);
encode<T = any>(_name: string, _account: T): Promise<Buffer>;
decode<T = any>(_ix: Buffer): T;
}
//# sourceMappingURL=state.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../../../../src/coder/spl-token/state.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAEhC,qBAAa,kBAAmB,YAAW,UAAU;gBACvC,IAAI,EAAE,GAAG;IAErB,MAAM,CAAC,CAAC,GAAG,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC;IAG5D,MAAM,CAAC,CAAC,GAAG,GAAG,EAAE,GAAG,EAAE,MAAM,GAAG,CAAC;CAGhC"}

View File

@ -0,0 +1,9 @@
/// <reference types="node" />
import { TypesCoder } from "../index.js";
import { Idl } from "../../idl.js";
export declare class SplTokenTypesCoder implements TypesCoder {
constructor(_idl: Idl);
encode<T = any>(_name: string, _type: T): Buffer;
decode<T = any>(_name: string, _typeData: Buffer): T;
}
//# sourceMappingURL=types.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/coder/spl-token/types.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AAEnC,qBAAa,kBAAmB,YAAW,UAAU;gBACvC,IAAI,EAAE,GAAG;IAErB,MAAM,CAAC,CAAC,GAAG,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,MAAM;IAGhD,MAAM,CAAC,CAAC,GAAG,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,CAAC;CAGrD"}

View File

@ -0,0 +1,13 @@
/// <reference types="node" />
import { AccountsCoder } from "../index.js";
import { Idl, IdlTypeDef } from "../../idl.js";
export declare class SystemAccountsCoder<A extends string = string> implements AccountsCoder {
private idl;
constructor(idl: Idl);
encode<T = any>(accountName: A, account: T): Promise<Buffer>;
decode<T = any>(accountName: A, ix: Buffer): T;
decodeUnchecked<T = any>(accountName: A, ix: Buffer): T;
memcmp(accountName: A, _appendData?: Buffer): any;
size(idlAccount: IdlTypeDef): number;
}
//# sourceMappingURL=accounts.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"accounts.d.ts","sourceRoot":"","sources":["../../../../src/coder/system/accounts.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,GAAG,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAK/C,qBAAa,mBAAmB,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,CACxD,YAAW,aAAa;IAEZ,OAAO,CAAC,GAAG;gBAAH,GAAG,EAAE,GAAG;IAEf,MAAM,CAAC,CAAC,GAAG,GAAG,EAAE,WAAW,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC;IAalE,MAAM,CAAC,CAAC,GAAG,GAAG,EAAE,WAAW,EAAE,CAAC,EAAE,EAAE,EAAE,MAAM,GAAG,CAAC;IAI9C,eAAe,CAAC,CAAC,GAAG,GAAG,EAAE,WAAW,EAAE,CAAC,EAAE,EAAE,EAAE,MAAM,GAAG,CAAC;IAYvD,MAAM,CAAC,WAAW,EAAE,CAAC,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,GAAG;IAajD,IAAI,CAAC,UAAU,EAAE,UAAU,GAAG,MAAM;CAG5C"}

View File

@ -0,0 +1,9 @@
import { EventCoder } from "../index.js";
import { Idl } from "../../idl.js";
import { Event } from "../../program/event";
import { IdlEvent } from "../../idl";
export declare class SystemEventsCoder implements EventCoder {
constructor(_idl: Idl);
decode<E extends IdlEvent = IdlEvent, T = Record<string, string>>(_log: string): Event<E, T> | null;
}
//# sourceMappingURL=events.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../../../src/coder/system/events.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AACnC,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAErC,qBAAa,iBAAkB,YAAW,UAAU;gBACtC,IAAI,EAAE,GAAG;IAErB,MAAM,CAAC,CAAC,SAAS,QAAQ,GAAG,QAAQ,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAC9D,IAAI,EAAE,MAAM,GACX,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,IAAI;CAGtB"}

View File

@ -0,0 +1,19 @@
import { Idl } from "../../idl.js";
import { Coder } from "../index.js";
import { SystemInstructionCoder } from "./instruction.js";
import { SystemStateCoder } from "./state.js";
import { SystemAccountsCoder } from "./accounts.js";
import { SystemEventsCoder } from "./events.js";
import { SystemTypesCoder } from "./types.js";
/**
* Coder for the System program.
*/
export declare class SystemCoder implements Coder {
readonly instruction: SystemInstructionCoder;
readonly accounts: SystemAccountsCoder;
readonly state: SystemStateCoder;
readonly events: SystemEventsCoder;
readonly types: SystemTypesCoder;
constructor(idl: Idl);
}
//# sourceMappingURL=index.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/coder/system/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AACnC,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAE9C;;GAEG;AACH,qBAAa,WAAY,YAAW,KAAK;IACvC,QAAQ,CAAC,WAAW,EAAE,sBAAsB,CAAC;IAC7C,QAAQ,CAAC,QAAQ,EAAE,mBAAmB,CAAC;IACvC,QAAQ,CAAC,KAAK,EAAE,gBAAgB,CAAC;IACjC,QAAQ,CAAC,MAAM,EAAE,iBAAiB,CAAC;IACnC,QAAQ,CAAC,KAAK,EAAE,gBAAgB,CAAC;gBAErB,GAAG,EAAE,GAAG;CAOrB"}

View File

@ -0,0 +1,9 @@
/// <reference types="node" />
import { Idl } from "../../idl.js";
import { InstructionCoder } from "../index.js";
export declare class SystemInstructionCoder implements InstructionCoder {
constructor(_: Idl);
encode(ixName: string, ix: any): Buffer;
encodeState(_ixName: string, _ix: any): Buffer;
}
//# sourceMappingURL=instruction.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"instruction.d.ts","sourceRoot":"","sources":["../../../../src/coder/system/instruction.ts"],"names":[],"mappings":";AAGA,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AACnC,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/C,qBAAa,sBAAuB,YAAW,gBAAgB;gBAEjD,CAAC,EAAE,GAAG;IAElB,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,GAAG,GAAG,MAAM;IA4CvC,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,GAAG,MAAM;CAG/C"}

View File

@ -0,0 +1,9 @@
/// <reference types="node" />
import { StateCoder } from "../index.js";
import { Idl } from "../../idl";
export declare class SystemStateCoder implements StateCoder {
constructor(_idl: Idl);
encode<T = any>(_name: string, _account: T): Promise<Buffer>;
decode<T = any>(_ix: Buffer): T;
}
//# sourceMappingURL=state.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../../../../src/coder/system/state.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAEhC,qBAAa,gBAAiB,YAAW,UAAU;gBAErC,IAAI,EAAE,GAAG;IAErB,MAAM,CAAC,CAAC,GAAG,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC;IAG5D,MAAM,CAAC,CAAC,GAAG,GAAG,EAAE,GAAG,EAAE,MAAM,GAAG,CAAC;CAGhC"}

View File

@ -0,0 +1,9 @@
/// <reference types="node" />
import { TypesCoder } from "../index.js";
import { Idl } from "../../idl.js";
export declare class SystemTypesCoder implements TypesCoder {
constructor(_idl: Idl);
encode<T = any>(_name: string, _type: T): Buffer;
decode<T = any>(_name: string, _typeData: Buffer): T;
}
//# sourceMappingURL=types.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/coder/system/types.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AAEnC,qBAAa,gBAAiB,YAAW,UAAU;gBACrC,IAAI,EAAE,GAAG;IAErB,MAAM,CAAC,CAAC,GAAG,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,MAAM;IAGhD,MAAM,CAAC,CAAC,GAAG,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,CAAC;CAGrD"}

108
ts/dist/browser/types/src/error.d.ts vendored Normal file
View File

@ -0,0 +1,108 @@
import { PublicKey } from "@solana/web3.js";
export declare class IdlError extends Error {
constructor(message: string);
}
interface ErrorCode {
code: string;
number: number;
}
interface FileLine {
file: string;
line: number;
}
declare type Origin = string | FileLine;
declare type ComparedAccountNames = [string, string];
declare type ComparedPublicKeys = [PublicKey, PublicKey];
declare type ComparedValues = ComparedAccountNames | ComparedPublicKeys;
export declare class ProgramErrorStack {
readonly stack: PublicKey[];
constructor(stack: PublicKey[]);
static parse(logs: string[]): ProgramErrorStack;
}
export declare class AnchorError extends Error {
readonly errorLogs: string[];
readonly logs: string[];
readonly error: {
errorCode: ErrorCode;
errorMessage: string;
comparedValues?: ComparedValues;
origin?: Origin;
};
private readonly _programErrorStack;
constructor(errorCode: ErrorCode, errorMessage: string, errorLogs: string[], logs: string[], origin?: Origin, comparedValues?: ComparedValues);
static parse(logs: string[]): AnchorError | null;
get program(): PublicKey;
get programErrorStack(): PublicKey[];
toString(): string;
}
export declare class ProgramError extends Error {
readonly code: number;
readonly msg: string;
readonly logs?: string[] | undefined;
private readonly _programErrorStack?;
constructor(code: number, msg: string, logs?: string[] | undefined);
static parse(err: any, idlErrors: Map<number, string>): ProgramError | null;
get program(): PublicKey | undefined;
get programErrorStack(): PublicKey[] | undefined;
toString(): string;
}
export declare function translateError(err: any, idlErrors: Map<number, string>): any;
export declare const LangErrorCode: {
InstructionMissing: number;
InstructionFallbackNotFound: number;
InstructionDidNotDeserialize: number;
InstructionDidNotSerialize: number;
IdlInstructionStub: number;
IdlInstructionInvalidProgram: number;
ConstraintMut: number;
ConstraintHasOne: number;
ConstraintSigner: number;
ConstraintRaw: number;
ConstraintOwner: number;
ConstraintRentExempt: number;
ConstraintSeeds: number;
ConstraintExecutable: number;
ConstraintState: number;
ConstraintAssociated: number;
ConstraintAssociatedInit: number;
ConstraintClose: number;
ConstraintAddress: number;
ConstraintZero: number;
ConstraintTokenMint: number;
ConstraintTokenOwner: number;
ConstraintMintMintAuthority: number;
ConstraintMintFreezeAuthority: number;
ConstraintMintDecimals: number;
ConstraintSpace: number;
RequireViolated: number;
RequireEqViolated: number;
RequireKeysEqViolated: number;
RequireNeqViolated: number;
RequireKeysNeqViolated: number;
RequireGtViolated: number;
RequireGteViolated: number;
AccountDiscriminatorAlreadySet: number;
AccountDiscriminatorNotFound: number;
AccountDiscriminatorMismatch: number;
AccountDidNotDeserialize: number;
AccountDidNotSerialize: number;
AccountNotEnoughKeys: number;
AccountNotMutable: number;
AccountOwnedByWrongProgram: number;
InvalidProgramId: number;
InvalidProgramExecutable: number;
AccountNotSigner: number;
AccountNotSystemOwned: number;
AccountNotInitialized: number;
AccountNotProgramData: number;
AccountNotAssociatedTokenAccount: number;
AccountSysvarMismatch: number;
AccountReallocExceedsLimit: number;
AccountDuplicateReallocs: number;
StateInvalidAddress: number;
DeclaredProgramIdMismatch: number;
Deprecated: number;
};
export declare const LangErrorMessage: Map<number, string>;
export {};
//# sourceMappingURL=error.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../../src/error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAG5C,qBAAa,QAAS,SAAQ,KAAK;gBACrB,OAAO,EAAE,MAAM;CAI5B;AAED,UAAU,SAAS;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,UAAU,QAAQ;IAChB,IAAI,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CAAC;IALhB,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAAC,CAAoB;gBAG7C,IAAI,EAAE,MAAM,EACZ,GAAG,EAAE,MAAM,EACX,IAAI,CAAC,sBAAU;WAQZ,KAAK,CACjB,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAC7B,YAAY,GAAG,IAAI;IA2CtB,IAAI,OAAO,IAAI,SAAS,GAAG,SAAS,CAInC;IAED,IAAI,iBAAiB,IAAI,SAAS,EAAE,GAAG,SAAS,CAE/C;IAEM,QAAQ,IAAI,MAAM;CAG1B;AAED,wBAAgB,cAAc,CAAC,GAAG,EAAE,GAAG,EAAE,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,OAmCtE;AAED,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsEzB,CAAC;AAEF,eAAO,MAAM,gBAAgB,qBA0J3B,CAAC"}

123
ts/dist/browser/types/src/idl.d.ts vendored Normal file
View File

@ -0,0 +1,123 @@
/// <reference types="node" />
import { Buffer } from "buffer";
import { PublicKey } from "@solana/web3.js";
export declare type Idl = {
version: string;
name: string;
docs?: string[];
instructions: IdlInstruction[];
state?: IdlState;
accounts?: IdlAccountDef[];
types?: IdlTypeDef[];
events?: IdlEvent[];
errors?: IdlErrorCode[];
constants?: IdlConstant[];
metadata?: IdlMetadata;
};
export declare type IdlMetadata = any;
export declare type IdlConstant = {
name: string;
type: IdlType;
value: string;
};
export declare type IdlEvent = {
name: string;
fields: IdlEventField[];
};
export declare type IdlEventField = {
name: string;
type: IdlType;
index: boolean;
};
export declare type IdlInstruction = {
name: string;
docs?: string[];
accounts: IdlAccountItem[];
args: IdlField[];
returns?: IdlType;
};
export declare type IdlState = {
struct: IdlTypeDef;
methods: IdlStateMethod[];
};
export declare type IdlStateMethod = IdlInstruction;
export declare type IdlAccountItem = IdlAccount | IdlAccounts;
export declare type IdlAccount = {
name: string;
isMut: boolean;
isSigner: boolean;
docs?: string[];
pda?: IdlPda;
};
export declare type IdlPda = {
seeds: IdlSeed[];
programId?: IdlSeed;
};
export declare type IdlSeed = any;
export declare type IdlAccounts = {
name: string;
docs?: string[];
accounts: IdlAccountItem[];
};
export declare type IdlField = {
name: string;
docs?: string[];
type: IdlType;
};
export declare type IdlTypeDef = {
name: string;
docs?: string[];
type: IdlTypeDefTy;
};
export declare type IdlAccountDef = {
name: string;
docs?: string[];
type: IdlTypeDefTyStruct;
};
export declare type IdlTypeDefTyStruct = {
kind: "struct";
fields: IdlTypeDefStruct;
};
export declare type IdlTypeDefTyEnum = {
kind: "enum";
variants: IdlEnumVariant[];
};
export declare type IdlTypeDefTy = IdlTypeDefTyEnum | IdlTypeDefTyStruct;
export declare type IdlTypeDefStruct = Array<IdlField>;
export declare type IdlType = "bool" | "u8" | "i8" | "u16" | "i16" | "u32" | "i32" | "f32" | "u64" | "i64" | "f64" | "u128" | "i128" | "bytes" | "string" | "publicKey" | IdlTypeDefined | IdlTypeOption | IdlTypeCOption | IdlTypeVec | IdlTypeArray;
export declare type IdlTypeDefined = {
defined: string;
};
export declare type IdlTypeOption = {
option: IdlType;
};
export declare type IdlTypeCOption = {
coption: IdlType;
};
export declare type IdlTypeVec = {
vec: IdlType;
};
export declare type IdlTypeArray = {
array: [idlType: IdlType, size: number];
};
export declare type IdlEnumVariant = {
name: string;
fields?: IdlEnumFields;
};
export declare type IdlEnumFields = IdlEnumFieldsNamed | IdlEnumFieldsTuple;
export declare type IdlEnumFieldsNamed = IdlField[];
export declare type IdlEnumFieldsTuple = IdlType[];
export declare type IdlErrorCode = {
code: number;
name: string;
msg?: string;
};
export declare function idlAddress(programId: PublicKey): Promise<PublicKey>;
export declare function seed(): string;
export interface IdlProgramAccount {
authority: PublicKey;
data: Buffer;
}
export declare function decodeIdlAccount(data: Buffer): IdlProgramAccount;
export declare function encodeIdlAccount(acc: IdlProgramAccount): Bu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AI,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;CACd,CAAC;AAGF,wBAAsB,UAAU,CAAC,SAAS,EAAE,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC,CAGzE;AAGD,wBAAgB,IAAI,IAAI,MAAM,CAE7B;AAGD,MAAM,WAAW,iBAAiB;IAChC,SAAS,EAAE,SAAS,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;CACd;AAOD,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,iBAAiB,CAEhE;AAED,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,iBAAiB,GAAG,MAAM,CAI/D"}

16
ts/dist/browser/types/src/index.d.ts vendored Normal file
View File

@ -0,0 +1,16 @@
import NodeWallet from "./nodewallet";
export { default as BN } from "bn.js";
export * as web3 from "@solana/web3.js";
export { default as Provider, getProvider, setProvider, AnchorProvider, } from "./provider.js";
export * from "./error.js";
export { Instruction } from "./coder/borsh/instruction.js";
export { Idl } from "./idl.js";
export * from "./coder/index.js";
export * as utils from "./utils/index.js";
export * from "./program/index.js";
export * from "./spl/index.js";
export * from "./native/index.js";
export declare const workspace: any;
export declare class Wallet extends NodeWallet {
}
//# sourceMappingURL=index.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,cAAc,CAAC;AAGtC,OAAO,EAAE,OAAO,IAAI,EAAE,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAC;AACxC,OAAO,EACL,OAAO,IAAI,QAAQ,EACnB,WAAW,EACX,WAAW,EACX,cAAc,GACf,MAAM,eAAe,CAAC;AACvB,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAC3D,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAC/B,cAAc,kBAAkB,CAAC;AACjC,OAAO,KAAK,KAAK,MAAM,kBAAkB,CAAC;AAC1C,cAAc,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAElC,MAAM,CAAC,OAAO,CAAC,MAAM,SAAS,EAAE,GAAG,CAAC;AACpC,MAAM,CAAC,OAAO,OAAO,MAAO,SAAQ,UAAU;CAAG"}

View File

@ -0,0 +1,7 @@
import { Program, Provider } from "../index.js";
import { SystemProgram } from "./system.js";
export { SystemProgram } from "./system.js";
export declare class Native {
static system(provider?: Provider): Program<SystemProgram>;
}
//# sourceMappingURL=index.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/native/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAA4B,aAAa,EAAE,MAAM,aAAa,CAAC;AAEtE,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,qBAAa,MAAM;WACH,MAAM,CAAC,QAAQ,CAAC,EAAE,QAAQ,GAAG,OAAO,CAAC,aAAa,CAAC;CAGlE"}

View File

@ -0,0 +1,391 @@
import { Program } from "../program/index.js";
import Provider from "../provider.js";
import { SystemCoder } from "../coder/system/index.js";
export declare function program(provider?: Provider): Program<SystemProgram>;
export declare function coder(): SystemCoder;
/**
* System IDL.
*/
export declare type SystemProgram = {
version: "0.1.0";
name: "system_program";
instructions: [
{
name: "createAccount";
accounts: [
{
name: "from";
isMut: true;
isSigner: true;
},
{
name: "to";
isMut: true;
isSigner: true;
}
];
args: [
{
name: "lamports";
type: "u64";
},
{
name: "space";
type: "u64";
},
{
name: "owner";
type: "publicKey";
}
];
},
{
name: "assign";
accounts: [
{
name: "pubkey";
isMut: true;
isSigner: true;
}
];
args: [
{
name: "owner";
type: "publicKey";
}
];
},
{
name: "transfer";
accounts: [
{
name: "from";
isMut: true;
isSigner: true;
},
{
name: "to";
isMut: true;
isSigner: false;
}
];
args: [
{
name: "lamports";
type: "u64";
}
];
},
{
name: "createAccountWithSeed";
accounts: [
{
name: "from";
isMut: true;
isSigner: true;
},
{
name: "to";
isMut: true;
isSigner: false;
},
{
name: "base";
isMut: false;
isSigner: true;
}
];
args: [
{
name: "base";
type: "publicKey";
},
{
name: "seed";
type: "string";
},
{
name: "lamports";
type: "u64";
},
{
name: "space";
type: "u64";
},
{
name: "owner";
type: "publicKey";
}
];
},
{
name: "advanceNonceAccount";
accounts: [
{
name: "nonce";
isMut: true;
isSigner: false;
},
{
name: "recentBlockhashes";
isMut: false;
isSigner: false;
},
{
name: "authorized";
isMut: false;
isSigner: true;
}
];
args: [
{
name: "authorized";
type: "publicKey";
}
];
},
{
name: "withdrawNonceAccount";
accounts: [
{
name: "nonce";
isMut: true;
isSigner: false;
},
{
name: "to";
isMut: true;
isSigner: false;
},
{
name: "recentBlockhashes";
isMut: false;
isSigner: false;
},
{
name: "rent";
isMut: false;
isSigner: false;
},
{
name: "authorized";
isMut: false;
isSigner: true;
}
];
args: [
{
name: "lamports";
type: "u64";
}
];
},
{
name: "initializeNonceAccount";
accounts: [
{
name: "nonce";
isMut: true;
isSigner: true;
},
{
name: "recentBlockhashes";
isMut: false;
isSigner: false;
},
{
name: "rent";
isMut: false;
isSigner: false;
}
];
args: [
{
name: "authorized";
type: "publicKey";
}
];
},
{
name: "authorizeNonceAccount";
accounts: [
{
name: "nonce";
isMut: true;
isSigner: false;
},
{
name: "authorized";
isMut: false;
isSigner: true;
}
];
args: [
{
name: "authorized";
type: "publicKey";
}
];
},
{
name: "allocate";
accounts: [
{
name: "pubkey";
isMut: true;
isSigner: true;
}
];
args: [
{
name: "space";
type: "u64";
}
];
},
{
name: "allocateWithSeed";
accounts: [
{
name: "account";
isMut: true;
isSigner: false;
},
{
name: "base";
isMut: false;
isSigner: true;
}
];
args: [
{
name: "base";
type: "publicKey";
},
{
name: "seed";
type: "string";
},
{
name: "space";
type: "u64";
},
{
name: "owner";
type: "publicKey";
}
];
},
{
name: "assignWithSeed";
accounts: [
{
name: "account";
isMut: true;
isSigner: false;
},
{
name: "base";
isMut: false;
isSigner: true;
}
];
args: [
{
name: "base";
type: "publicKey";
},
{
name: "seed";
type: "string";
},
{
name: "owner";
type: "publicKey";
}
];
},
{
name: "transferWithSeed";
accounts: [
{
name: "from";
isMut: true;
isSigner: false;
},
{
name: "base";
isMut: false;
isSigner: true;
},
{
name: "to";
isMut: true;
isSigner: false;
}
];
args: [
{
name: "lamports";
type: "u64";
},
{
name: "seed";
type: "string";
},
{
name: "owner";
type: "publicKey";
}
];
}
];
accounts: [
{
name: "nonce";
type: {
kind: "struct";
fields: [
{
name: "version";
type: "u32";
},
{
name: "state";
type: "u32";
},
{
name: "authorizedPubkey";
type: "publicKey";
},
{
name: "nonce";
type: "publicKey";
},
{
name: "feeCalculator";
type: {
defined: "FeeCalculator";
};
}
];
};
}
];
types: [
{
name: "FeeCalculator";
type: {
kind: "struct";
fields: [
{
name: "lamportsPerSignature";
type: "u64";
}
];
};
}
];
};
export declare const IDL: SystemProgram;
//# sourceMappingURL=system.d.ts.map

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,14 @@
import { Keypair, PublicKey, Transaction } from "@solana/web3.js";
import { Wallet } from "./provider";
/**
* Node only wallet.
*/
export default class NodeWallet implements Wallet {
readonly payer: Keypair;
constructor(payer: Keypair);
static local(): NodeWallet | never;
signTransaction(tx: Transaction): Promise<Transaction>;
signAllTransactions(txs: Transaction[]): Promise<Transaction[]>;
get publicKey(): PublicKey;
}
//# sourceMappingURL=nodewallet.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"nodewallet.d.ts","sourceRoot":"","sources":["../../src/nodewallet.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAClE,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAEpC;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,UAAW,YAAW,MAAM;IACnC,QAAQ,CAAC,KAAK,EAAE,OAAO;gBAAd,KAAK,EAAE,OAAO;IAEnC,MAAM,CAAC,KAAK,IAAI,UAAU,GAAG,KAAK;IAsB5B,eAAe,CAAC,EAAE,EAAE,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC;IAKtD,mBAAmB,CAAC,GAAG,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC;IAOrE,IAAI,SAAS,IAAI,SAAS,CAEzB;CACF"}

View File

@ -0,0 +1,41 @@
import { PublicKey } from "@solana/web3.js";
import { Idl } from "../idl.js";
import { AllInstructions } from "./namespace/types.js";
import Provider from "../provider.js";
import { AccountNamespace } from "./namespace/account.js";
export declare class AccountsResolver<IDL extends Idl, I extends AllInstructions<IDL>> {
private _args;
private _accounts;
private _provider;
private _programId;
private _idlIx;
static readonly CONST_ACCOUNTS: {
associatedTokenProgram: PublicKey;
rent: PublicKey;
systemProgram: PublicKey;
tokenProgram: PublicKey;
};
private _accountStore;
constructor(_args: Array<any>, _accounts: {
[name: string]: PublicKey;
}, _provider: Provider, _programId: PublicKey, _idlIx: AllInstructions<IDL>, _accountNamespace: AccountNamespace<IDL>);
resolve(): Promise<void>;
private autoPopulatePda;
private parseProgramId;
private toBuffer;
private toBufferConst;
private toBufferArg;
private argValue;
private toBufferAccount;
private accountValue;
private parseAccountValue;
private toBufferValue;
}
export declare class AccountStore<IDL extends Idl> {
private _provider;
private _accounts;
private _cache;
constructor(_provider: Provider, _accounts: AccountNamespace<IDL>);
fetchAccount<T = any>(name: string, publicKey: PublicKey): Promise<T>;
}
//# sourceMappingURL=accounts-resolver.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"accounts-resolver.d.ts","sourceRoot":"","sources":["../../../src/program/accounts-resolver.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAqC,MAAM,iBAAiB,CAAC;AAC/E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AAC,CAAC,CAAC;CAmBd"}

View File

@ -0,0 +1,20 @@
import EventEmitter from "eventemitter3";
import { PublicKey } from "@solana/web3.js";
import { Idl, IdlInstruction, IdlAccountItem, IdlStateMethod } from "../idl.js";
import { Accounts } from "./context.js";
export declare type Subscription = {
listener: number;
ee: EventEmitter;
};
export declare function parseIdlErrors(idl: Idl): Map<number, string>;
export declare function toInstruction(idlIx: IdlInstruction | IdlStateMethod, ...args: any[]): {
[key: string]: any;
};
export declare function validateAccounts(ixAccounts: IdlAccountItem[], accounts?: Accounts): void;
export declare function translateAddress(address: Address): PublicKey;
/**
* An address to identify an account on chain. Can be a [[PublicKey]],
* or Base 58 encoded string.
*/
export declare type Address = PublicKey | string;
//# sourceMappingURL=common.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../src/program/common.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,GAAG,EAAE,cAAc,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAChF,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAExC,oBAAY,YAAY,GAAG;IACzB,QAAQ,EAAE,MAAM,CAAC;IACjB,EAAE,EAAE,YAAY,CAAC;CAClB,CAAC;AAEF,wBAAgB,cAAc,CAAC,GAAG,EAAE,GAAG,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAS5D;AAGD,wBAAgB,aAAa,CAC3B,KAAK,EAAE,cAAc,GAAG,cAAc,EACtC,GAAG,IAAI,EAAE,GAAG,EAAE;;EAaf;AAGD,wBAAgB,gBAAgB,CAC9B,UAAU,EAAE,cAAc,EAAE,EAC5B,QAAQ,GAAE,QAAa,QAWxB;AAGD,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,OAAO,GAAG,SAAS,CAE5D;AAED;;;GAGG;AACH,oBAAY,OAAO,GAAG,SAAS,GAAG,MAAM,CAAC"}

View File

@ -0,0 +1,59 @@
import { AccountMeta, Signer, ConfirmOptions, TransactionInstruction } from "@solana/web3.js";
import { Address } from "./common.js";
import { IdlAccountItem, IdlAccounts, IdlInstruction } from "../idl.js";
/**
* Context provides all non-argument inputs for generating Anchor transactions.
*/
export declare type Context<A extends Accounts = Accounts> = {
/**
* Accounts used in the instruction context.
*/
accounts?: A;
/**
* All accounts to pass into an instruction *after* the main `accounts`.
* This can be used for optional or otherwise unknown accounts.
*/
remainingAccounts?: AccountMeta[];
/**
* Accounts that must sign a given transaction.
*/
signers?: Array<Signer>;
/**
* @deprecated use preInstructions instead.
* Instructions to run *before* a given method. Often this is used, for
* example to create accounts prior to executing a method.
*/
instructions?: TransactionInstruction[];
/**
* Instructions to run *before* a given method. Often this is used, for
* example to create accounts prior to executing a method.
*/
preInstructions?: TransactionInstruction[];
/**
* Instructions to run *after* a given method. Often this is used, for
* example to close accounts after executing a method.
*/
postInstructions?: TransactionInstruction[];
/**
* Commitment parameters to use for a transaction.
*/
options?: ConfirmOptions;
};
/**
* A set of accounts mapping one-to-one to the program's accounts struct, i.e.,
* the type deriving `#[derive(Accounts)]`.
*
* The name of each field should match the name for that account in the IDL.
*
* If multiple accounts are nested in the rust program, then they should be
* nested here.
*/
export declare type Accounts<A extends IdlAccountItem = IdlAccountItem> = {
[N in A["name"]]: Account<A & {
name: N;
}>;
};
declare type Account<A extends IdlAccountItem> = A extends IdlAccounts ? Accounts<A["accounts"][number]> : Address;
export declare function splitArgsAndCtx(idlIx: IdlInstruction, args: any[]): [any[], Context];
export {};
//# sourceMappingURL=context.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../src/program/context.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,MAAM,EACN,cAAc,EACd,sBAAsB,EACvB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAExE;;GAEG;AACH,oBAAY,OAAO,CAAC,CAAC,SAAS,QAAQ,GAAG,QAAQ,IAAI;IACnD;;OAEG;IACH,QAAQ,CAAC,EAAE,CAAC,CAAC;IAEb;;;OAGG;IACH,iBAAiB,CAAC,EAAE,WAAW,EAAE,CAAC;IAElC;;OAEG;IACH,OAAO,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAExB;;;;OAIG;IACH,YAAY,CAAC,EAAE,sBAAsB,EAAE,CAAC;IAExC;;;OAGG;IACH,eAAe,CAAC,EAAE,sBAAsB,EAAE,CAAC;IAE3C;;;OAGG;IACH,gBAAgB,CAAC,EAAE,sBAAsB,EAAE,CAAC;IAE5C;;OAEG;IACH,OAAO,CAAC,EAAE,cAAc,CAAC;CAC1B,CAAC;AAEF;;;;;;;;GAQG;AACH,oBAAY,QAAQ,CAAC,CAAC,SAAS,cAAc,GAAG,cAAc,IAAI;KAC/D,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC,CAAC,GAAG;QAAE,IAAI,EAAE,CAAC,CAAA;KAAE,CAAC;CAC3C,CAAC;AAEF,aAAK,OAAO,CAAC,CAAC,SAAS,cAAc,IAAI,CAAC,SAAS,WAAW,GAC1D,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,MAAM,CAAC,CAAC,GAC/B,OAAO,CAAC;AAEZ,wBAAgB,eAAe,CAC7B,KAAK,EAAE,cAAc,EACrB,IAAI,EAAE,GAAG,EAAE,GACV,CAAC,GAAG,EAAE,EAAE,OAAO,CAAC,CAgBlB"}

View File

@ -0,0 +1,57 @@
import { PublicKey } from "@solana/web3.js";
import { IdlEvent, IdlEventField } from "../idl.js";
import { Coder } from "../coder/index.js";
import { DecodeType } from "./namespace/types.js";
import Provider from "../provider.js";
export declare type Event<E extends IdlEvent = IdlEvent, Defined = Record<string, never>> = {
name: E["name"];
data: EventData<E["fields"][number], Defined>;
};
export declare type EventData<T extends IdlEventField, Defined> = {
[N in T["name"]]: DecodeType<(T & {
name: N;
})["type"], Defined>;
};
export declare class EventManager {
/**
* Program ID for event subscriptions.
*/
private _programId;
/**
* Network and wallet provider.
*/
private _provider;
/**
* Event parser to handle onLogs callbacks.
*/
private _eventParser;
/**
* Maps event listener id to [event-name, callback].
*/
private _eventCallbacks;
/**
* Maps event name to all listeners for the event.
*/
private _eventListeners;
/**
* The next listener id to allocate.
*/
private _listenerIdCount;
/**
* The subscription id from the connection onLogs subscription.
*/
private _onLogsSubscriptionId;
constructor(programId: PublicKey, provider: Provider, coder: Coder);
addEventListener(eventName: string, callback: (event: any, slot: number, signature: string) => void): number;
removeEventListener(listener: number): Promise<void>;
}
export declare class EventParser {
private coder;
private programId;
constructor(programId: PublicKey, coder: Coder);
parseLogs(logs: string[]): Generator<Event<IdlEvent, Record<string, never>>, void, unknown>;
private handleLog;
private handleProgramLog;
private handleSystemLog;
}
//# sourceMappingURL=event.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"event.d.ts","sourceRoot":"","sources":["../../../src/program/event.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AACpD,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,QAAQ,MAAM,gBAAgB,CAAC;AAQtC,oBAAY,KAAK,CACf,CAAC,SAAS,QAAQ,GAAG,QAAQ,EAC7B,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,IAC7B;IACF,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC;IAChB,IAAI,EAAE,SAAS,CAAC,CAAC,CAAC,QA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ey } from "@solana/web3.js";
import Provider from "../provider.js";
import { Idl } from "../idl.js";
import { Coder } from "../coder/index.js";
import { RpcNamespace, InstructionNamespace, TransactionNamespace, AccountNamespace, StateClient, SimulateNamespace, MethodsNamespace, ViewNamespace } from "./namespace/index.js";
import { Address } from "./common.js";
export * from "./common.js";
export * from "./context.js";
export * from "./event.js";
export * from "./namespace/index.js";
/**
* ## Program
*
* Program provides the IDL deserialized client representation of an Anchor
* program.
*
* This API is the one stop shop for all things related to communicating with
* on-chain programs. Among other things, one can send transactions, fetch
* deserialized accounts, decode instruction data, subscribe to account
* changes, and listen to events.
*
* In addition to field accessors and methods, the object provides a set of
* dynamically generated properties, also known as namespaces, that
* map one-to-one to program methods and accounts. These namespaces generally
* can be used as follows:
*
* ## Usage
*
* ```javascript
* program.<namespace>.<program-specific-method>
* ```
*
* API specifics are namespace dependent. The examples used in the documentation
* below will refer to the two counter examples found
* [here](https://github.com/coral-xyz/anchor#examples).
*/
export declare class Program<IDL extends Idl = Idl> {
/**
* Async methods to send signed transactions to *non*-state methods on the
* program, returning a [[TransactionSignature]].
*
* ## Usage
*
* ```javascript
* rpc.<method>(...args, ctx);
* ```
*
* ## Parameters
*
* 1. `args` - The positional arguments for the program. The type and number
* of these arguments depend on the program being used.
* 2. `ctx` - [[Context]] non-argument parameters to pass to the method.
* Always the last parameter in the method call.
*
* ## Example
*
* To send a transaction invoking the `increment` method above,
*
* ```javascript
* const txSignature = await program.rpc.increment({
* accounts: {
* counter,
* authority,
* },
* });
* ```
* @deprecated
* Use program.methods.<method>(...args).rpc() instead
*/
readonly rpc: RpcNamespace<IDL>;
/**
* The namespace provides handles to an [[AccountClient]] object for each
* account in the program.
*
* ## Usage
*
* ```javascript
* program.account.<account-client>
* ```
*
* ## Example
*
* To fetch a `Counter` account from the above example,
*
* ```javascript
* const counter = await program.account.counter.fetch(address);
* ```
*
* For the full API, see the [[AccountClient]] reference.
*/
readonly account: AccountNamespace<IDL>;
/**
* The namespace provides functions to build [[TransactionInstruction]]
* objects for each method of a program.
*
* ## Usage
*
* ```javascript
* program.instruction.<method>(...args, ctx);
* ```
*
* ## Parameters
*
* 1. `args` - The positional arguments for the program. The type and number
* of these arguments depend on the program being used.
* 2. `ctx` - [[Context]] non-argument parameters to pass to the method.
* Always the last parameter in the method call.
*
* ## Example
*
* To create an instruction for the `increment` method above,
*
* ```javascript
* const tx = await program.instruction.increment({
* accounts: {
* counter,
* },
* });
* ```
* @deprecated
*/
readonly instruction: InstructionNamespace<IDL>;
/**
* The namespace provides functions to build [[Transaction]] objects for each
* method of a program.
*
* ## Usage
*
* ```javascript
* program.transaction.<method>(...args, ctx);
* ```
*
* ## Parameters
*
* 1. `args` - The positional arguments for the program. The type and number
* of these arguments depend on the program being used.
* 2. `ctx` - [[Context]] non-argument parameters to pass to the method.
* Always the last parameter in the method call.
*
* ## Example
*
* To create an instruction for the `increment` method above,
*
* ```javascript
* const tx = await program.transaction.increment({
* accounts: {
* counter,
* },
* });
* ```
* @deprecated
*/
readonly transaction: TransactionNamespace<IDL>;
/**
* The namespace provides functions to simulate transactions for each method
* of a program, returning a list of deserialized events *and* raw program
* logs.
*
* One can use this to read data calculated from a program on chain, by
* emitting an event in the program and reading the emitted event client side
* via the `simulate` namespace.
*
* ## simulate
*
* ```javascript
* program.simulate.<method>(...args, ctx);
* ```
*
* ## Parameters
*
* 1. `args` - The positional arguments for the program. The type and number
* of these arguments depend on the program being used.
* 2. `ctx` - [[Context]] non-argument parameters to pass to the method.
* Always the last parameter in the method call.
*
* ## Example
*
* To simulate the `increment` method above,
*
* ```javascript
* const events = await program.simulate.increment({
* accounts: {
* counter,
* },
* });
* ```
* @deprecated
*/
readonly simulate: SimulateNamespace<IDL>;
/**
* A client for the program state. Similar to the base [[Program]] client,
* one can use this to send transactions and read accounts for the state
* abstraction.
*/
readonly state?: StateClient<IDL>;
/**
* The namespace provides a builder API for all APIs on the program.
* This is an alternative to using namespace the other namespaces..
*/
readonly methods: MethodsNamespace<IDL>;
readonly views?: ViewNamespace<IDL>;
/**
* Address of the program.
*/
get programId(): PublicKey;
private _programId;
/**
* IDL defining the program's interface.
*/
get idl(): IDL;
private _idl;
/**
* Coder for serializing requests.
*/
get coder(): Coder;
private _coder;
/**
* Wallet and network provider.
*/
get provider(): Provider;
private _provider;
/**
* Handles event subscriptions.
*/
private _events;
/**
* @param idl The interface definition.
* @param programId The on-chain address of the program.
* @param provider The network and wallet context to use. If not provided
* then uses [[getProvider]].
*/
constructor(idl: IDL, programId: Address, provider?: Provider, coder?: Coder);
/**
* Generates a Program client by fetching the IDL from the network.
*
* In order to use this method, an IDL must have been previously initialized
* via the anchor CLI's `anchor idl init` command.
*
* @param programId The on-chain address of the program.
* @param provider The network and wallet context.
*/
static at<IDL extends Idl = Idl>(address: Address, provider?: Provider): Promise<Program<IDL>>;
/**
* Fetches an idl from the blockchain.
*
* In order to use this method, an IDL must have been previously initialized
* via the anchor CLI's `anchor idl init` command.
*
* @param programId The on-chain address of the program.
* @param provider The network and wallet context.
*/
static fetchIdl<IDL extends Idl = Idl>(address: Address, provider?: Provider): Promise<IDL | null>;
/**
* Invokes the given callback every time the given event is emitted.
*
* @param eventName The PascalCase name of the event, provided by the IDL.
* @param callback The function to invoke whenever the event is emitted from
* program logs.
*/
addEventListener(eventName: string, callback: (event: any, slot: number, signature: string) => void): number;
/**
* Unsubscribes from the given eventName.
*/
removeEventListener(listener: number): Promise<void>;
}
//# sourceMappingURL=index.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/program/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,QAAyB,MAAM,gBAAgB,CAAC;AACvD,OAAO,EAAE,GAAG,EAAgC,MAAM,WAAW,CAAC;AAC9D,OAAO,EAAE,KAAK,EAAc,MAAM,mBAAmB,CAAC;AACtD,OAAyB,EACvB,YAAY,EACZ,oBAAoB,EACpB,oBAAoB,EAC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G,CAEpB;IACD,OAAO,CAAC,IAAI,CAAM;IAElB;;OAEG;IACH,IAAW,KAAK,IAAI,KAAK,CAExB;IACD,OAAO,CAAC,MAAM,CAAQ;IAEtB;;OAEG;IACH,IAAW,QAAQ,IAAI,QAAQ,CAE9B;IACD,OAAO,CAAC,SAAS,CAAW;IAE5B;;OAEG;IACH,OAAO,CAAC,OAAO,CAAe;IAE9B;;;;;OAKG;gBAED,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,OAAO,EAClB,QAAQ,CAAC,EAAE,QAAQ,EACnB,KAAK,CAAC,EAAE,KAAK;IAoCf;;;;;;;;OAQG;WACiB,EAAE,CAAC,GAAG,SAAS,GAAG,GAAG,GAAG,EAC1C,OAAO,EAAE,OAAO,EAChB,QAAQ,CAAC,EAAE,QAAQ,GAClB,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IAWxB;;;;;;;;OAQG;WACiB,QAAQ,CAAC,GAAG,SAAS,GAAG,GAAG,GAAG,EAChD,OAAO,EAAE,OAAO,EAChB,QAAQ,CAAC,EAAE,QAAQ,GAClB,OAAO,CAAC,GAAG,GAAG,IAAI,CAAC;IAetB;;;;;;OAMG;IACI,gBAAgB,CACrB,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,KAAK,IAAI,GAC9D,MAAM;IAIT;;OAEG;IACU,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAGlE"}

View File

@ -0,0 +1,132 @@
/// <reference types="node" />
import EventEmitter from "eventemitter3";
import { Signer, PublicKey, TransactionInstruction, Commitment, GetProgramAccountsFilter, AccountInfo } from "@solana/web3.js";
import Provider from "../../provider.js";
import { Idl, IdlAccountDef } from "../../idl.js";
import { Coder } from "../../coder/index.js";
import { Address } from "../common.js";
import { AllAccountsMap, IdlTypes, TypeDef } from "./types.js";
export default class AccountFactory {
static build<IDL extends Idl>(idl: IDL, coder: Coder, programId: PublicKey, provider?: Provider): AccountNamespace<IDL>;
}
declare type NullableIdlAccount<IDL extends Idl> = IDL["accounts"] extends undefined ? IdlAccountDef : NonNullable<IDL["accounts"]>[number];
/**
* The namespace provides handles to an [[AccountClient]] object for each
* account in a program.
*
* ## Usage
*
* ```javascript
* account.<account-client>
* ```
*
* ## Example
*
* To fetch a `Counter` account from the above example,
*
* ```javascript
* const counter = await program.account.counter.fetch(address);
* ```
*
* For the full API, see the [[AccountClient]] reference.
*/
export declare type AccountNamespace<IDL extends Idl = Idl> = {
[M in keyof AllAccountsMap<IDL>]: AccountClient<IDL>;
};
export declare class AccountClient<IDL extends Idl = Idl, A extends NullableIdlAccount<IDL> = IDL["accounts"] extends undefined ? IdlAccountDef : NonNullable<IDL["accounts"]>[number], T = TypeDef<A, IdlTypes<IDL>>> {
/**
* Returns the number of bytes in this account.
*/
get size(): number;
private _size;
/**
* Returns the program ID owning all accounts.
*/
get programId(): PublicKey;
private _programId;
/**
* Returns the client's wallet and network provider.
*/
get provider(): Provider;
private _provider;
/**
* Returns the coder.
*/
get coder(): Coder;
private _coder;
private _idlAccount;
constructor(idl: IDL, idlAccount: A, programId: PublicKey, provider?: Provider, coder?: Coder);
/**
* Returns a deserialized account, returning null if it doesn't exist.
*
* @param address The address of the account to fetch.
*/
fetchNullable(address: Address, commitment?: Commitment): Promise<T | null>;
/**
* Returns a deserialized account.
*
* @param address The address of the account to fetch.
*/
fetch(address: Address, commitment?: Commitment): Promise<T>;
/**
* Returns multiple deserialized accounts.
* Accounts not found or with wrong discriminator are returned as null.
*
* @param addresses The addresses of the accounts to fetch.
*/
fetchMultiple(addresses: Address[], commitment?: Commitment): Promise<(Object | null)[]>;
/**
* Returns all instances of this account type for the program.
*
* @param filters User-provided filters to narrow the results from `connection.getProgramAccounts`.
*
* When filters are not defined this method returns all
* the account instances.
*
* When filters are of type `Buffer`, the filters are appended
* after the discriminator.
*
* When filters are of type `GetProgramAccountsFilter[]`,
* filters are appended after the discriminator filter.
*/
all(filters?: Buffer | GetProgramAccountsFilter[]): Promise<ProgramAccount<T>[]>;
/**
* Returns an `EventEmitter` emitting a "change" event whenever the account
* changes.
*/
subscribe(address: Address, commitment?: Commitment): EventEmitter;
/**
* Unsubscribes from the account at the given address.
*/
unsubscribe(address: Address): Promise<void>;
/**
* Returns an instruction for creating this account.
*/
createInstruction(signer: Signer, sizeOverride?: number): Promise<TransactionInstruction>;
/**
* @deprecated since version 14.0.
*
* Function returning the associated account. Args are keys to associate.
* Order matters.
*/
associated(...args: Array<PublicKey | Buffer>): Promise<T>;
/**
* @deprecated since version 14.0.
*
* Function returning the associated address. Args are keys to associate.
* Order matters.
*/
associatedAddress(...args: Array<PublicKey | Buffer>): Promise<PublicKey>;
getAccountInfo(address: Address, commitment?: Commitment): Promise<AccountInfo<Buffer> | null>;
}
/**
* @hidden
*
* Deserialized account owned by a program.
*/
export declare type ProgramAccount<T = any> = {
publicKey: PublicKey;
account: T;
};
export {};
//# sourceMappingURL=account.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"account.d.ts","sourceRoot":"","sources":["../../../../src/program/namespace/account.ts"],"names":[],"mappings":";AACA,OAAO,YAAY,MAAM,eAAe,CAAC;AACzC,OAAO,EACL,MAAM,EACN,SAAS,EAET,sBAAsB,EACtB,UAAU,EACV,wBAAwB,EACxB,WAAW,EACZ,MAAM,iBAAiB,CAAC;AACzB,OAAO,QAAyB,MAAM,mBAAmB,CAAC;AAC1D,OAAO,EAAE,GAAG,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,EAAE,KAAK,EAAc,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAgB,OAAO,EAAoB,MAAM,cAAc,CAAC;AACvE,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAI/D,MAAM,CAAC,OAAO,OAAO,cAAc;WACnB,KAAK,CAAC,GAAG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GAIG;AACH,oBAAY,cAAc,CAAC,CAAC,GAAG,GAAG,IAAI;IACpC,SAAS,EAAE,SAAS,CAAC;IACrB,OAAO,EAAE,CAAC,CAAC;CACZ,CAAC"}

View File

@ -0,0 +1,37 @@
import { PublicKey } from "@solana/web3.js";
import { Coder } from "../../coder/index.js";
import Provider from "../../provider.js";
import { Idl } from "../../idl.js";
import { StateClient } from "./state.js";
import { InstructionNamespace } from "./instruction.js";
import { TransactionNamespace } from "./transaction.js";
import { RpcNamespace } from "./rpc.js";
import { AccountNamespace } from "./account.js";
import { SimulateNamespace } from "./simulate.js";
import { MethodsNamespace } from "./methods";
import { ViewNamespace } from "./views";
export { StateClient } from "./state.js";
export { InstructionNamespace, InstructionFn } from "./instruction.js";
export { TransactionNamespace, TransactionFn } from "./transaction.js";
export { RpcNamespace, RpcFn } from "./rpc.js";
export { AccountNamespace, AccountClient, ProgramAccount } from "./account.js";
export { SimulateNamespace, SimulateFn } from "./simulate.js";
export { IdlAccounts, IdlTypes } from "./types.js";
export { MethodsBuilderFactory, MethodsNamespace } from "./methods";
export { ViewNamespace, ViewFn } from "./views";
export default class NamespaceFactory {
/**
* Generates all namespaces for a given program.
*/
static build<IDL extends Idl>(idl: IDL, coder: Coder, programId: PublicKey, provider: Provider): [
RpcNamespace<IDL>,
InstructionNamespace<IDL>,
TransactionNamespace<IDL>,
AccountNamespace<IDL>,
SimulateNamespace<IDL>,
MethodsNamespace<IDL>,
StateClient<IDL> | undefined,
ViewNamespace<IDL> | undefined
];
}
//# sourceMappingURL=index.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/program/namespace/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAC7C,OAAO,QAAQ,MAAM,mBAAmB,CAAC;AACzC,OAAO,EAAE,GAAG,EAAE,MAAM,c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,GAAG,CAAC;QACzB,oBAAoB,CAAC,GAAG,CAAC;QACzB,gBAAgB,CAAC,GAAG,CAAC;QACrB,iBAAiB,CAAC,GAAG,CAAC;QACtB,gBAAgB,CAAC,GAAG,CAAC;QACrB,WAAW,CAAC,GAAG,CAAC,GAAG,SAAS;QAC5B,aAAa,CAAC,GAAG,CAAC,GAAG,SAAS;KAC/B;CAoEF"}

View File

@ -0,0 +1,58 @@
/// <reference types="node" />
import { AccountMeta, PublicKey, TransactionInstruction } from "@solana/web3.js";
import { Idl, IdlAccountItem, IdlInstruction } from "../../idl.js";
import { Accounts } from "../context.js";
import { AllInstructions, AllInstructionsMap, InstructionContextFn, MakeInstructionsNamespace } from "./types.js";
export default class InstructionNamespaceFactory {
static build<IDL extends Idl, I extends AllInstructions<IDL>>(idlIx: I, encodeFn: InstructionEncodeFn<I>, programId: PublicKey): InstructionFn<IDL, I>;
static accountsArray(ctx: Accounts | undefined, accounts: readonly IdlAccountItem[], ixName?: string): AccountMeta[];
}
/**
* The namespace provides functions to build [[TransactionInstruction]]
* objects for each method of a program.
*
* ## Usage
*
* ```javascript
* instruction.<method>(...args, ctx);
* ```
*
* ## Parameters
*
* 1. `args` - The positional arguments for the program. The type and number
* of these arguments depend on the program being used.
* 2. `ctx` - [[Context]] non-argument parameters to pass to the method.
* Always the last parameter in the method call.
*
* ## Example
*
* To create an instruction for the `increment` method above,
*
* ```javascript
* const tx = await program.instruction.increment({
* accounts: {
* counter,
* },
* });
* ```
*/
export declare type InstructionNamespace<IDL extends Idl = Idl, I extends IdlInstruction = IDL["instructions"][number]> = MakeInstructionsNamespace<IDL, I, TransactionInstruction, {
[M in keyof AllInstructionsMap<IDL>]: {
accounts: (ctx: Accounts<AllInstructionsMap<IDL>[M]["accounts"][number]>) => unknown;
};
}>;
/**
* Function to create a `TransactionInstruction` generated from an IDL.
* Additionally it provides an `accounts` utility method, returning a list
* of ordered accounts for the instruction.
*/
export declare type InstructionFn<IDL extends Idl = Idl, I extends AllInstructions<IDL> = AllInstructions<IDL>> = InstructionContextFn<IDL, I, TransactionInstruction> & IxProps<Accounts<I["accounts"][number]>>;
declare type IxProps<A extends Accounts> = {
/**
* Returns an ordered list of accounts associated with the instruction.
*/
accounts: (ctx: A) => AccountMeta[];
};
export declare type InstructionEncodeFn<I extends IdlInstruction = IdlInstruction> = (ixName: I["name"], ix: any) => Buffer;
export {};
//# sourceMappingURL=instruction.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"instruction.d.ts","sourceRoot":"","sources":["../../../../src/program/namespace/instruction.ts"],"names":[],"mappings":";AAAA,OAAO,EACL,WAAW,EACX,SAAS,EACT,sBAAsB,EACvB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,GAAG,EAEH,cAAc,EAEd,cAAc,EACf,MAAM,cAAc,CAAC;AAQtB,OAAO,EAAE,QAAQ,EAAmB,MAAM,eAAe,CAAC;AAE1D,OAAO,EACL,eAAe,EACf,kBAAkB,EAClB,oBAAoB,EAEpB,yBAAyB,EAC1B,MAAM,YAAY,CAAC;AAEpB,MAAM,CAAC,OAAO,OAAO,2BAA2B;WAChC,KAAK,CAAC,GAAG,SAAS,GAAG,EAAE,CAAC,SAAS,eAAe,CAAC,GAAG,CAAC,EACjE,KAAK,EAAE,CAAC,EACR,QAAQ,EAAE,mBAAmB,CAAC,CAAC,CAAC,EAChC,SAAS,EAAE,SAAS,GACnB,aAAa,CAAC,GAAG,EAAE,CAAC,CAAC;WAyCV,aAAa,CACzB,GAAG,EAAE,QAAQ,GAAG,SAAS,EACzB,QAAQ,EAAE,SAAS,cAAc,EAAE,EACnC,MAAM,CAAC,EAAE,MAAM,GACd,WAAW,EAAE;CAwCjB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,oBAAY,oBAAoB,CAC9B,GAAG,SAAS,GAAG,GAAG,GAAG,EACrB,CAAC,SAAS,cAAc,GAAG,GAAG,CAAC,cAAc,CAAC,CAAC,MAAM,CAAC,IACpD,yBAAyB,CAC3B,GAAG,EACH,CAAC,EACD,sBAAsB,EACtB;KACG,CAAC,IAAI,MAAM,kBAAkB,CAAC,GAAG,CAAC,GAAG;QACpC,QAAQ,EAAE,CACR,GAAG,EAAE,QAAQ,CAAC,kBAAkB,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,MAAM,CAAC,CAAC,KAC1D,OAAO,CAAC;KACd;CACF,CACF,CAAC;AAEF;;;;GAIG;AACH,oBAAY,aAAa,CACvB,GAAG,SAAS,GAAG,GAAG,GAAG,EACrB,CAAC,SAAS,eAAe,CAAC,GAAG,CAAC,GAAG,eAAe,CAAC,GAAG,CAAC,IACnD,oBAAoB,CAAC,GAAG,EAAE,CAAC,EAAE,sBAAsB,CAAC,GACtD,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;AAE3C,aAAK,OAAO,CAAC,CAAC,SAAS,QAAQ,IAAI;IACjC;;OAEG;IACH,QAAQ,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,WAAW,EAAE,CAAC;CACrC,CAAC;AAEF,oBAAY,mBAAmB,CAAC,CAAC,SAAS,cAAc,GAAG,cAAc,IAAI,CAC3E,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC,EACjB,EAAE,EAAE,GAAG,KACJ,MAAM,CAAC"}

View File

@ -0,0 +1,45 @@
import { ConfirmOptions, AccountMeta, Signer, Transaction, TransactionInstruction, TransactionSignature, PublicKey } from "@solana/web3.js";
import { SimulateResponse } from "./simulate.js";
import { TransactionFn } from "./transaction.js";
import { Idl } from "../../idl.js";
import { AllInstructions, MethodsFn, MakeMethodsNamespace, InstructionAccountAddresses } from "./types.js";
import { InstructionFn } from "./instruction.js";
import { RpcFn } from "./rpc.js";
import { SimulateFn } from "./simulate.js";
import { ViewFn } from "./views.js";
import Provider from "../../provider.js";
import { AccountNamespace } from "./account.js";
import { Accounts } from "../context.js";
export declare type MethodsNamespace<IDL extends Idl = Idl, I extends AllInstructions<IDL> = AllInstructions<IDL>> = MakeMethodsNamespace<IDL, I>;
export declare class MethodsBuilderFactory {
static build<IDL extends Idl, I extends AllInstructions<IDL>>(provider: Provider, programId: PublicKey, idlIx: AllInstructions<IDL>, ixFn: InstructionFn<IDL>, txFn: TransactionFn<IDL>, rpcFn: RpcFn<IDL>, simulateFn: SimulateFn<IDL>, viewFn: ViewFn<IDL> | undefined, accountNamespace: AccountNamespace<IDL>): MethodsFn<IDL, I, MethodsBuilder<IDL, I>>;
}
export declare class MethodsBuilder<IDL extends Idl, I extends AllInstructions<IDL>> {
private _args;
private _ixFn;
private _txFn;
private _rpcFn;
private _simulateFn;
private _viewFn;
private readonly _accounts;
private _remainingAccounts;
private _signers;
private _preInstructions;
private _postInstructions;
private _accountsResolver;
private _autoResolveAccounts;
constructor(_args: Array<any>, _ixFn: InstructionFn<IDL>, _txFn: TransactionFn<IDL>, _rpcFn: RpcFn<IDL>, _simulateFn: SimulateFn<IDL>, _viewFn: ViewFn<IDL> | undefined, _provider: Provider, _programId: PublicKey, _idlIx: AllInstructions<IDL>, _accountNamespace: AccountNamespace<IDL>);
pubkeys(): Promise<Partial<InstructionAccountAddresses<IDL, I>>>;
accounts(accounts: Partial<Accounts<I["accounts"][number]>>): MethodsBuilder<IDL, I>;
accountsStrict(accounts: Accounts<I["accounts"][number]>): MethodsBuilder<IDL, I>;
signers(signers: Array<Signer>): MethodsBuilder<IDL, I>;
remainingAccounts(accounts: Array<AccountMeta>): MethodsBuilder<IDL, I>;
preInstructions(ixs: Array<TransactionInstruction>): MethodsBuilder<IDL, I>;
postInstructions(ixs: Array<TransactionInstruction>): MethodsBuilder<IDL, I>;
rpc(options?: ConfirmOptions): Promise<TransactionSignature>;
view(options?: ConfirmOptions): Promise<any>;
simulate(options?: ConfirmOptions): Promise<SimulateResponse<any, any>>;
instruction(): Promise<TransactionInstruction>;
transaction(): Promise<Transaction>;
}
//# sourceMappingURL=methods.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"methods.d.ts","sourceRoot":"","sources":["../../../../src/program/namespace/methods.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,WAAW,EACX,MAAM,EACN,WAAW,EACX,sBAAsB,EACtB,oBAAoB,EACpB,SAAS,EACV,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AACnC,OAAO,EACL,eAAe,EACf,SAAS,EACT,oBAAoB,EACpB,2BAA2B,EAC5B,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AACjC,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AACpC,OAAO,QAAQ,MAAM,mBAAmB,CAAC;AACzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAEhD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC,oBAAY,gBAAgB,CAC1B,GAAG,SAAS,GAAG,GAAG,GAAG,EACrB,CAAC,SAAS,eAAe,CAAC,GAAG,CAAC,GAAG,eAAe,CAAC,GAAG,CAAC,IACnD,oBAAoB,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;AAEjC,qBAAa,qBAAqB;WAClB,KAAK,CAAC,GAAG,SAAS,GAAG,EAAE,CAAC,SAAS,eAAe,CAAC,GAAG,CAAC,EACjE,QAAQ,EAAE,QAAQ,EAClB,SAAS,EAAE,SAAS,EACpB,KAAK,EAAE,eAAe,CAAC,GAAG,CAAC,EAC3B,IAAI,EAAE,aAAa,CAAC,GAAG,CAAC,EACxB,IAAI,EAAE,aAA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2B,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,CAC7C;IAOM,QAAQ,CACb,QAAQ,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,GACjD,cAAc,CAAC,GAAG,EAAE,CAAC,CAAC;IAMlB,cAAc,CACnB,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,MAAM,CAAC,CAAC,GACxC,cAAc,CAAC,GAAG,EAAE,CAAC,CAAC;IAMlB,OAAO,CAAC,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,GAAG,cAAc,CAAC,GAAG,EAAE,CAAC,CAAC;IAKvD,iBAAiB,CACtB,QAAQ,EAAE,KAAK,CAAC,WAAW,CAAC,GAC3B,cAAc,CAAC,GAAG,EAAE,CAAC,CAAC;IAKlB,eAAe,CACpB,GAAG,EAAE,KAAK,CAAC,sBAAsB,CAAC,GACjC,cAAc,CAAC,GAAG,EAAE,CAAC,CAAC;IAKlB,gBAAgB,CACrB,GAAG,EAAE,KAAK,CAAC,sBAAsB,CAAC,GACjC,cAAc,CAAC,GAAG,EAAE,CAAC,CAAC;IAKZ,GAAG,CAAC,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAgB5D,IAAI,CAAC,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,GAAG,CAAC;IAoB5C,QAAQ,CACnB,OAAO,CAAC,EAAE,cAAc,GACvB,OAAO,CAAC,gBAAgB,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;IAgBzB,WAAW,IAAI,OAAO,CAAC,sBAAsB,CAAC;IAe9C,WAAW,IAAI,OAAO,CAAC,WAAW,CAAC;CAcjD"}

View File

@ -0,0 +1,49 @@
import { TransactionSignature } from "@solana/web3.js";
import Provider from "../../provider.js";
import { Idl } from "../../idl.js";
import { TransactionFn } from "./transaction.js";
import { AllInstructions, InstructionContextFn, MakeInstructionsNamespace } from "./types.js";
export default class RpcFactory {
static build<IDL extends Idl, I extends AllInstructions<IDL>>(idlIx: I, txFn: TransactionFn<IDL, I>, idlErrors: Map<number, string>, provider: Provider): RpcFn;
}
/**
* The namespace provides async methods to send signed transactions for each
* *non*-state method on Anchor program.
*
* Keys are method names, values are RPC functions returning a
* [[TransactionInstruction]].
*
* ## Usage
*
* ```javascript
* rpc.<method>(...args, ctx);
* ```
*
* ## Parameters
*
* 1. `args` - The positional arguments for the program. The type and number
* of these arguments depend on the program being used.
* 2. `ctx` - [[Context]] non-argument parameters to pass to the method.
* Always the last parameter in the method call.
* ```
*
* ## Example
*
* To send a transaction invoking the `increment` method above,
*
* ```javascript
* const txSignature = await program.rpc.increment({
* accounts: {
* counter,
* authority,
* },
* });
* ```
*/
export declare type RpcNamespace<IDL extends Idl = Idl, I extends AllInstructions<IDL> = AllInstructions<IDL>> = MakeInstructionsNamespace<IDL, I, Promise<TransactionSignature>>;
/**
* RpcFn is a single RPC method generated from an IDL, sending a transaction
* paid for and signed by the configured provider.
*/
export declare type RpcFn<IDL extends Idl = Idl, I extends AllInstructions<IDL> = AllInstructions<IDL>> = InstructionContextFn<IDL, I, Promise<TransactionSignature>>;
//# sourceMappingURL=rpc.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"rpc.d.ts","sourceRoot":"","sources":["../../../../src/program/namespace/rpc.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AACvD,OAAO,QAAQ,MAAM,mBAAmB,CAAC;AACzC,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AAEnC,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEjD,OAAO,EACL,eAAe,EACf,oBAAoB,EACpB,yBAAyB,EAC1B,MAAM,YAAY,CAAC;AAEpB,MAAM,CAAC,OAAO,OAAO,UAAU;WACf,KAAK,CAAC,GAAG,SAAS,GAAG,EAAE,CAAC,SAAS,eAAe,CAAC,GAAG,CAAC,EACjE,KAAK,EAAE,CAAC,EACR,IAAI,EAAE,aAAa,CAAC,GAAG,EAAE,CAAC,CAAC,EAC3B,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,EAC9B,QAAQ,EAAE,QAAQ,GACjB,KAAK;CAsBT;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,oBAAY,YAAY,CACtB,GAAG,SAAS,GAAG,GAAG,GAAG,EACrB,CAAC,SAAS,eAAe,CAAC,GAAG,CAAC,GAAG,eAAe,CAAC,GAAG,CAAC,IACnD,yBAAyB,CAAC,GAAG,EAAE,CAAC,EAAE,OAAO,CAAC,oBAAoB,CAAC,CAAC,CAAC;AAErE;;;GAGG;AACH,oBAAY,KAAK,CACf,GAAG,SAAS,GAAG,GAAG,GAAG,EACrB,CAAC,SAAS,eAAe,CAAC,GAAG,CAAC,GAAG,eAAe,CAAC,GAAG,CAAC,IACnD,oBAAoB,CAAC,GAAG,EAAE,CAAC,EAAE,OAAO,CAAC,oBAAoB,CAAC,CAAC,CAAC"}

View File

@ -0,0 +1,59 @@
import { PublicKey } from "@solana/web3.js";
import Provider from "../../provider.js";
import { TransactionFn } from "./transaction.js";
import { Event } from "../event.js";
import { Coder } from "../../coder/index.js";
import { Idl, IdlEvent } from "../../idl.js";
import { AllInstructions, IdlTypes, InstructionContextFn, MakeInstructionsNamespace } from "./types";
export default class SimulateFactory {
static build<IDL extends Idl, I extends AllInstructions<IDL>>(idlIx: AllInstructions<IDL>, txFn: TransactionFn<IDL>, idlErrors: Map<number, string>, provider: Provider, coder: Coder, programId: PublicKey, idl: IDL): SimulateFn<IDL, I>;
}
/**
* The namespace provides functions to simulate transactions for each method
* of a program, returning a list of deserialized events *and* raw program
* logs.
*
* One can use this to read data calculated from a program on chain, by
* emitting an event in the program and reading the emitted event client side
* via the `simulate` namespace.
*
* ## Usage
*
* ```javascript
* program.simulate.<method>(...args, ctx);
* ```
*
* ## Parameters
*
* 1. `args` - The positional arguments for the program. The type and number
* of these arguments depend on the program being used.
* 2. `ctx` - [[Context]] non-argument parameters to pass to the method.
* Always the last parameter in the method call.
*
* ## Example
*
* To simulate the `increment` method above,
*
* ```javascript
* const events = await program.simulate.increment({
* accounts: {
* counter,
* },
* });
* ```
*/
export declare type SimulateNamespace<IDL extends Idl = Idl, I extends AllInstructions<IDL> = AllInstructions<IDL>> = MakeInstructionsNamespace<IDL, I, Promise<SimulateResponse<NullableEvents<IDL>, IdlTypes<IDL>>>>;
declare type NullableEvents<IDL extends Idl> = IDL["events"] extends undefined ? IdlEvent : NonNullable<IDL["events"]>[number];
/**
* SimulateFn is a single method generated from an IDL. It simulates a method
* against a cluster configured by the provider, returning a list of all the
* events and raw logs that were emitted during the execution of the
* method.
*/
export declare type SimulateFn<IDL extends Idl = Idl, I extends AllInstructions<IDL> = AllInstructions<IDL>> = InstructionContextFn<IDL, I, Promise<SimulateResponse<NullableEvents<IDL>, IdlTypes<IDL>>>>;
export declare type SimulateResponse<E extends IdlEvent, Defined> = {
events: readonly Event<E, Defined>[];
raw: readonly string[];
};
export {};
//# sourceMappingURL=simulate.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"simulate.d.ts","sourceRoot":"","sources":["../../../../src/program/namespace/simulate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,QAAQ,MAAM,mBAAmB,CAAC;AAGzC,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAe,KAAK,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAC7C,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAE7C,OAAO,EACL,eAAe,EACf,QAAQ,EACR,oBAAoB,EACpB,yBAAyB,EAC1B,MAAM,SAAS,CAAC;AAEjB,MAAM,CAAC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E,OAAO,IAAI;IAC1D,MAAM,EAAE,SAAS,KAAK,CAAC,CAAC,EAAE,OAAO,CAAC,EAAE,CAAC;IACrC,GAAG,EAAE,SAAS,MAAM,EAAE,CAAC;CACxB,CAAC"}

View File

@ -0,0 +1,75 @@
import EventEmitter from "eventemitter3";
import { PublicKey, Commitment } from "@solana/web3.js";
import Provider from "../../provider.js";
import { Idl, IdlInstruction, IdlTypeDef } from "../../idl.js";
import { Coder } from "../../coder/index.js";
import { RpcNamespace, InstructionNamespace, TransactionNamespace } from "./index.js";
import { IdlTypes, TypeDef } from "./types.js";
export default class StateFactory {
static build<IDL extends Idl>(idl: IDL, coder: Coder, programId: PublicKey, provider?: Provider): StateClient<IDL> | undefined;
}
declare type NullableMethods<IDL extends Idl> = IDL["state"] extends undefined ? IdlInstruction[] : NonNullable<IDL["state"]>["methods"];
/**
* A client for the program state. Similar to the base [[Program]] client,
* one can use this to send transactions and read accounts for the state
* abstraction.
*/
export declare class StateClient<IDL extends Idl> {
/**
* Returns the client's wallet and network provider.
*/
readonly provider: Provider;
/**
* Returns the coder.
*/
readonly coder: Coder;
/**
* [[RpcNamespace]] for all state methods.
*/
readonly rpc: RpcNamespace<IDL, NullableMethods<IDL>[number]>;
/**
* [[InstructionNamespace]] for all state methods.
*/
readonly instruction: InstructionNamespace<IDL, NullableMethods<IDL>[number]>;
/**
* [[TransactionNamespace]] for all state methods.
*/
readonly transaction: TransactionNamespace<IDL, NullableMethods<IDL>[number]>;
/**
* Returns the program ID owning the state.
*/
get programId(): PublicKey;
private _programId;
private _address;
private _coder;
private _idl;
private _sub;
constructor(idl: IDL, programId: PublicKey,
/**
* Returns the client's wallet and network provider.
*/
provider?: Provider,
/**
* Returns the coder.
*/
coder?: Coder);
/**
* Returns the deserialized state account.
*/
fetch(): Promise<TypeDef<IDL["state"] extends undefined ? IdlTypeDef : NonNullable<IDL["state"]>["struct"], IdlTypes<IDL>>>;
/**
* Returns the state address.
*/
address(): PublicKey;
/**
* Returns an `EventEmitter` with a `"change"` event that's fired whenever
* the state account cahnges.
*/
subscribe(commitment?: Commitment): EventEmitter;
/**
* Unsubscribes to state changes.
*/
unsubscribe(): void;
}
export {};
//# sourceMappingURL=state.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../../../../src/program/namespace/state.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,MAAM,eAAe,CAAC;AAEzC,OAAO,EACL,SAAS,EAET,UAAU,EAEX,MAAM,iBAAiB,CAAC;AACzB,OAAO,QAAyB,MAAM,mBAAmB,CAAC;AAC1D,OAAO,EAAE,GAAG,EAAE,cAAc,EAAkB,UAAU,EAAE,MAAM,cAAc,CAAC;AAC/E,OAAO,EAAc,KAAK,EAAsB,MAAM,sBAAsB,CAAC;AAC7E,OAAO,EACL,YAAY,EACZ,oBAAoB,EACpB,oBAAoB,EACrB,MAAM,YAAY,CAAC;AAUpB,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAE/C,MAAM,CAAC,OAAO,OAAO,YAAY;WACjB,KAAK,CAAC,GAAG,SAAS,GAAG,EACjC,GAAG,EAAE,GAAG,EACR,KAAK,EAAE,KAAK,EACZ,SAAS,EAAE,SAAS,EACpB,QAAQ,CAAC,EAAE,QAAQ,GAClB,WAAW,CAAC,GAAG,CAAC,GAAG,SAAS;CAMhC;AAED,aAAK,eAAe,CAAC,GAAG,SAAS,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,SAAS,SAAS,GAClE,cAAc,EAAE,GAChB,WAAW,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;AAEzC;;;;GAIG;AACH,qBAAa,WAAW,CAAC,GAAG,SAAS,GAAG;IAgCpC;;OAEG;aACa,QAAQ,EAAE,QAAQ;IAClC;;OAEG;aACa,KAAK,EAAE,KAAK;IAtC9B;;OAEG;IACH,QAAQ,CAAC,GAAG,EAAE,YAAY,CAAC,GAAG,EAAE,eAAe,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;IAE9D;;OAEG;IACH,QAAQ,CAAC,WAAW,EAAE,oBAAoB,CAAC,GAAG,EAAE,eAAe,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;IAE9E;;OAEG;IACH,QAAQ,CAAC,WAAW,EAAE,oBAAoB,CAAC,GAAG,EAAE,eAAe,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;IAE9E;;OAEG;IACH,IAAI,SAAS,IAAI,SAAS,CAEzB;IACD,OAAO,CAAC,UAAU,CAAY;IAE9B,OAAO,CAAC,QAAQ,CAAY;IAC5B,OAAO,CAAC,MAAM,CAAQ;IACtB,OAAO,CAAC,IAAI,CAAM;IAClB,OAAO,CAAC,IAAI,CAAsB;gBAGhC,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,SAAS;IACpB;;OAEG;IACa,QAAQ,GAAE,QAAwB;IAClD;;OAEG;IACa,KAAK,GAAE,KAA2B;IAgEpD;;OAEG;IACG,KAAK,IAAI,OAAO,CACpB,OAAO,CACL,GAAG,CAAC,OAAO,CAAC,SAAS,SAAS,GAC1B,UAAU,GACV,WAAW,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,QAAQ,CAAC,EACvC,QAAQ,CAAC,GAAG,CAAC,CACd,CACF;IAkBD;;OAEG;IACH,OAAO,IAAI,SAAS;IAIpB;;;OAGG;IACH,SAAS,CAAC,UAAU,CAAC,EAAE,UAAU,GAAG,YAAY;IAuBhD;;OAEG;IACH,WAAW;CAUZ"}

View File

@ -0,0 +1,42 @@
import { Transaction } from "@solana/web3.js";
import { Idl } from "../../idl.js";
import { InstructionFn } from "./instruction.js";
import { AllInstructions, InstructionContextFn, MakeInstructionsNamespace } from "./types.js";
export default class TransactionFactory {
static build<IDL extends Idl, I extends AllInstructions<IDL>>(idlIx: I, ixFn: InstructionFn<IDL, I>): TransactionFn<IDL, I>;
}
/**
* The namespace provides functions to build [[Transaction]] objects for each
* method of a program.
*
* ## Usage
*
* ```javascript
* program.transaction.<method>(...args, ctx);
* ```
*
* ## Parameters
*
* 1. `args` - The positional arguments for the program. The type and number
* of these arguments depend on the program being used.
* 2. `ctx` - [[Context]] non-argument parameters to pass to the method.
* Always the last parameter in the method call.
*
* ## Example
*
* To create an instruction for the `increment` method above,
*
* ```javascript
* const tx = await program.transaction.increment({
* accounts: {
* counter,
* },
* });
* ```
*/
export declare type TransactionNamespace<IDL extends Idl = Idl, I extends AllInstructions<IDL> = AllInstructions<IDL>> = MakeInstructionsNamespace<IDL, I, Transaction>;
/**
* Tx is a function to create a `Transaction` for a given program instruction.
*/
export declare type TransactionFn<IDL extends Idl = Idl, I extends AllInstructions<IDL> = AllInstructions<IDL>> = InstructionContextFn<IDL, I, Transaction>;
//# sourceMappingURL=transaction.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"transaction.d.ts","sourceRoot":"","sources":["../../../../src/program/namespace/transaction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,GAAG,EAAkB,MAAM,cAAc,CAAC;AAEnD,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EACL,eAAe,EACf,oBAAoB,EACpB,yBAAyB,EAC1B,MAAM,YAAY,CAAC;AAEpB,MAAM,CAAC,OAAO,OAAO,kBAAkB;WACvB,KAAK,CAAC,GAAG,SAAS,GAAG,EAAE,CAAC,SAAS,eAAe,CAAC,GAAG,CAAC,EACjE,KAAK,EAAE,CAAC,EACR,IAAI,EAAE,aAAa,CAAC,GAAG,EAAE,CAAC,CAAC,GAC1B,aAAa,CAAC,GAAG,EAAE,CAAC,CAAC;CAgBzB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,oBAAY,oBAAoB,CAC9B,GAAG,SAAS,GAAG,GAAG,GAAG,EACrB,CAAC,SAAS,eAAe,CAAC,GAAG,CAAC,GAAG,eAAe,CAAC,GAAG,CAAC,IACnD,yBAAyB,CAAC,GAAG,EAAE,CAAC,EAAE,WAAW,CAAC,CAAC;AAEnD;;GAEG;AACH,oBAAY,aAAa,CACvB,GAAG,SAAS,GAAG,GAAG,GAAG,EACrB,CAAC,SAAS,eAAe,CAAC,GAAG,CAAC,GAAG,eAAe,CAAC,GAAG,CAAC,IACnD,oBAAoB,CAAC,GAAG,EAAE,CAAC,EAAE,WAAW,CAAC,CAAC"}

View File

@ -0,0 +1,107 @@
import { PublicKey } from "@solana/web3.js";
import BN from "bn.js";
import { Idl } from "../../";
import { IdlField, IdlInstruction, IdlType, IdlTypeDef, IdlTypeDefTyEnum, IdlTypeDefTyStruct } from "../../idl";
import { Accounts, Context } from "../context";
import { MethodsBuilder } from "./methods";
/**
* All instructions for an IDL.
*/
export declare type AllInstructions<IDL extends Idl> = IDL["instructions"][number];
/**
* Returns a type of instruction name to the IdlInstruction.
*/
export declare type InstructionMap<I extends IdlInstruction> = {
[K in I["name"]]: I & {
name: K;
};
};
/**
* Returns a type of instruction name to the IdlInstruction.
*/
export declare type AllInstructionsMap<IDL extends Idl> = InstructionMap<AllInstructions<IDL>>;
/**
* All accounts for an IDL.
*/
export declare type AllAccounts<IDL extends Idl> = IDL["accounts"] extends undefined ? IdlTypeDef : NonNullable<IDL["accounts"]>[number];
/**
* Returns a type of instruction name to the IdlInstruction.
*/
export declare type AccountMap<I extends IdlTypeDef> = {
[K in I["name"]]: I & {
name: K;
};
};
/**
* Returns a type of instruction name to the IdlInstruction.
*/
export declare type AllAccountsMap<IDL extends Idl> = AccountMap<AllAccounts<IDL>>;
export declare type MakeInstructionsNamespace<IDL extends Idl, I extends IdlInstruction, Ret, Mk extends {
[M in keyof InstructionMap<I>]: unknown;
} = {
[M in keyof InstructionMap<I>]: unknown;
}> = {
[M in keyof InstructionMap<I>]: InstructionContextFn<IDL, InstructionMap<I>[M], Ret> & Mk[M];
};
export declare type MakeMethodsNamespace<IDL extends Idl, I extends IdlInstruction> = {
[M in keyof InstructionMap<I>]: MethodsFn<IDL, InstructionMap<I>[M], MethodsBuilder<IDL, InstructionMap<I>[M]>>;
};
export declare type InstructionContextFn<IDL extends Idl, I extends AllInstructions<IDL>, Ret> = (...args: InstructionContextFnArgs<IDL, I>) => Ret;
export declare type InstructionContextFnArgs<IDL extends Idl, I extends IDL["instructions"][number]> = [
...ArgsTuple<I["args"], IdlTypes<IDL>>,
Context<Accounts<I["accounts"][number]>>
];
export declare type InstructionAccountAddresses<IDL extends Idl, I extends AllInstructions<IDL>> = {
[N in keyof Accounts<I["accounts"][number]>]: PublicKey;
};
export declare type MethodsFn<IDL extends Idl, I extends IDL["instructions"][number], Ret> = (...args: ArgsTuple<I["args"], IdlTypes<IDL>>) => Ret;
declare type TypeMap = {
publicKey: PublicKey;
bool: boolean;
string: string;
} & {
[K in "u8" | "i8" | "u16" | "i16" | "u32" | "i32" | "f32" | "f64"]: number;
} & {
[K in "u64" | "i64" | "u128" | "i128"]: BN;
};
export declare type DecodeType<T extends IdlType, Defined> = T extends keyof TypeMap ? TypeMap[T] : T extends {
defined: keyof Defined;
} ? Defined[T["defined"]] : T extends {
option: {
defined: keyof Defined;
};
} ? Defined[T["option"]["defined"]] | null : T extends {
option: keyof TypeMap;
} ? TypeMap[T["option"]] | null : T extends {
coption: {
defined: keyof Defined;
};
} ? Defined[T["coption"]["defined"]] | null : T extends {
coption: keyof TypeMap;
} ? TypeMap[T["coption"]] | null : T extends {
vec: keyof TypeMap;
} ? TypeMap[T["vec"]][] : T extends {
array: [defined: keyof TypeMap, size: number];
} ? TypeMap[T["array"][0]][] : unknown;
/**
* Tuple of arguments.
*/
declare type ArgsTuple<A extends IdlField[], Defined> = {
[K in keyof A]: A[K] extends IdlField ? DecodeType<A[K]["type"], Defined> : unknown;
} & unknown[];
declare type FieldsOfType<I extends IdlTypeDef> = NonNullable<I["type"] extends IdlTypeDefTyStruct ? I["type"]["fields"] : I["type"] extends IdlTypeDefTyEnum ? I["type"]["variants"][number]["fields"] : any[]>[number];
export declare type TypeDef<I extends IdlTypeDef, Defined> = {
[F in FieldsOfType<I>["name"]]: DecodeType<(FieldsOfType<I> & {
name: F;
})["type"], Defined>;
};
declare type TypeDefDictionary<T extends IdlTypeDef[], Defined> = {
[K in T[number]["name"]]: TypeDef<T[number] & {
name: K;
}, Defined>;
};
export declare type IdlTypes<T extends Idl> = TypeDefDictionary<NonNullable<T["types"]>, Record<string, never>>;
export declare type IdlAccounts<T extends Idl> = TypeDefDictionary<NonNullable<T["accounts"]>, Record<string, never>>;
export declare type IdlErrorInfo<IDL extends Idl> = NonNullable<IDL["errors"]>[number];
export {};
//# sourceMappingURL=types.d.ts.map

File diff suppressed because one or more lines are too long

Some files were not shown because too many files have changed in this diff Show More