Socket
Socket
Sign inDemoInstall

@project-serum/anchor

Package Overview
Dependencies
67
Maintainers
5
Versions
73
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.20.1 to 0.21.0

.rollup.cache/home/armaniferrante/Documents/code/src/github.com/project-serum/anchor/ts/types/src/coder/dex/accounts.d.ts

2

.rollup.cache/home/armaniferrante/Documents/code/src/github.com/project-serum/anchor/ts/types/src/coder/common.d.ts

@@ -1,5 +0,3 @@

/// <reference types="node" />
import { Idl, IdlTypeDef } from "../idl.js";
export declare function accountSize(idl: Idl, idlAccount: IdlTypeDef): number;
export declare function sighash(nameSpace: string, ixName: string): Buffer;
//# sourceMappingURL=common.d.ts.map

@@ -1,4 +0,1 @@

import { Buffer } from "buffer";
import { snakeCase } from "snake-case";
import { sha256 } from "js-sha256";
import { IdlError } from "../error.js";

@@ -69,2 +66,5 @@ export function accountSize(idl, idlAccount) {

}
if ("coption" in ty) {
return 4 + typeSize(idl, ty.coption);
}
if ("defined" in ty) {

@@ -86,9 +86,2 @@ const filtered = (_b = (_a = idl.types) === null || _a === void 0 ? void 0 : _a.filter((t) => t.name === ty.defined)) !== null && _b !== void 0 ? _b : [];

}
// Not technically sighash, since we don't include the arguments, as Rust
// doesn't allow function overloading.
export function sighash(nameSpace, ixName) {
let name = snakeCase(ixName);
let preimage = `${nameSpace}:${name}`;
return Buffer.from(sha256.digest(preimage)).slice(0, 8);
}
//# sourceMappingURL=common.js.map
/// <reference types="node" />
import { Idl } from "../idl.js";
import { InstructionCoder } from "./instruction.js";
import { AccountsCoder } from "./accounts.js";
import { EventCoder } from "./event.js";
import { StateCoder } from "./state.js";
export { accountSize } from "./common.js";
export { InstructionCoder } from "./instruction.js";
export { AccountsCoder, ACCOUNT_DISCRIMINATOR_SIZE } from "./accounts.js";
export { EventCoder, eventDiscriminator } from "./event.js";
export { StateCoder, stateDiscriminator } from "./state.js";
import { IdlEvent, IdlTypeDef } from "../idl.js";
import { Event } from "../program/event.js";
export * from "./borsh/index.js";
export * from "./spl-token/index.js";
/**
* Coder provides a facade for encoding and decoding all IDL related objects.
*/
export default class Coder<A extends string = string> {
export interface Coder {
/**

@@ -23,3 +17,3 @@ * Instruction coder.

*/
readonly accounts: AccountsCoder<A>;
readonly accounts: AccountsCoder;
/**

@@ -33,5 +27,21 @@ * Coder for state structs.

readonly events: EventCoder;
constructor(idl: Idl);
sighash(nameSpace: string, ixName: string): Buffer;
}
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;
}
//# sourceMappingURL=index.d.ts.map

@@ -1,27 +0,3 @@

import { InstructionCoder } from "./instruction.js";
import { AccountsCoder } from "./accounts.js";
import { EventCoder } from "./event.js";
import { StateCoder } from "./state.js";
import { sighash } from "./common.js";
export { accountSize } from "./common.js";
export { InstructionCoder } from "./instruction.js";
export { AccountsCoder, ACCOUNT_DISCRIMINATOR_SIZE } from "./accounts.js";
export { EventCoder, eventDiscriminator } from "./event.js";
export { StateCoder, stateDiscriminator } from "./state.js";
/**
* Coder provides a facade for encoding and decoding all IDL related objects.
*/
export default class Coder {
constructor(idl) {
this.instruction = new InstructionCoder(idl);
this.accounts = new AccountsCoder(idl);
this.events = new EventCoder(idl);
if (idl.state) {
this.state = new StateCoder(idl);
}
}
sighash(nameSpace, ixName) {
return sighash(nameSpace, ixName);
}
}
export * from "./borsh/index.js";
export * from "./spl-token/index.js";
//# sourceMappingURL=index.js.map

@@ -42,3 +42,3 @@ import BN from "bn.js";

if (src === null || src === undefined) {
return this.discriminator.encode(0, b, offset);
return this.layout.span + this.discriminator.encode(0, b, offset);
}

@@ -49,3 +49,3 @@ this.discriminator.encode(1, b, offset);

decode(b, offset = 0) {
const discriminator = b[offset];
const discriminator = this.discriminator.decode(b, offset);
if (discriminator === 0) {

@@ -57,13 +57,6 @@ return null;

}
throw new Error("Invalid option " + this.property);
throw new Error("Invalid coption " + this.property);
}
getSpan(b, offset = 0) {
const discriminator = b[offset];
if (discriminator === 0) {
return 1;
}
else if (discriminator === 1) {
return this.layout.getSpan(b, offset + 4) + 4;
}
throw new Error("Invalid option " + this.property);
return this.layout.getSpan(b, offset + 4) + 4;
}

@@ -70,0 +63,0 @@ }

@@ -43,3 +43,9 @@ /// <reference types="node" />

isSigner: boolean;
pda?: IdlPda;
};
export declare type IdlPda = {
seeds: IdlSeed[];
programId?: IdlSeed;
};
export declare type IdlSeed = any;
export declare type IdlAccounts = {

@@ -67,3 +73,3 @@ name: string;

declare type IdlTypeDefStruct = Array<IdlField>;
export declare type IdlType = "bool" | "u8" | "i8" | "u16" | "i16" | "u32" | "i32" | "u64" | "i64" | "u128" | "i128" | "bytes" | "string" | "publicKey" | IdlTypeDefined | IdlTypeOption | IdlTypeVec | IdlTypeArray;
export declare type IdlType = "bool" | "u8" | "i8" | "u16" | "i16" | "u32" | "i32" | "u64" | "i64" | "u128" | "i128" | "bytes" | "string" | "publicKey" | IdlTypeDefined | IdlTypeOption | IdlTypeCOption | IdlTypeVec | IdlTypeArray;
export declare type IdlTypeDefined = {

@@ -75,2 +81,5 @@ defined: string;

};
export declare type IdlTypeCOption = {
coption: IdlType;
};
export declare type IdlTypeVec = {

@@ -77,0 +86,0 @@ vec: IdlType;

@@ -0,12 +1,15 @@

import NodeWallet from "./nodewallet";
export { default as BN } from "bn.js";
export * as web3 from "@solana/web3.js";
export { default as Provider, getProvider, setProvider } from "./provider.js";
export { default as Coder, InstructionCoder, EventCoder, StateCoder, AccountsCoder, } from "./coder/index.js";
export * from "./error.js";
export { Instruction } from "./coder/instruction.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 declare const workspace: any;
export declare const Wallet: import("./nodewallet").default;
export declare class Wallet extends NodeWallet {
}
//# sourceMappingURL=index.d.ts.map

@@ -0,1 +1,2 @@

import NodeWallet from "./nodewallet";
import { isBrowser } from "./utils/common.js";

@@ -5,6 +6,7 @@ export { default as BN } from "bn.js";

export { default as Provider, getProvider, setProvider } from "./provider.js";
export { default as Coder, InstructionCoder, EventCoder, StateCoder, AccountsCoder, } from "./coder/index.js";
export * from "./error.js";
export * from "./coder/index.js";
export * as utils from "./utils/index.js";
export * from "./program/index.js";
export * from "./spl/index.js";
if (!isBrowser) {

@@ -11,0 +13,0 @@ exports.workspace = require("./workspace.js").default;

import { PublicKey } from "@solana/web3.js";
import { IdlEvent, IdlEventField } from "../idl.js";
import Coder from "../coder/index.js";
import { Coder } from "../coder/index.js";
import { DecodeType } from "./namespace/types.js";

@@ -5,0 +5,0 @@ import Provider from "../provider.js";

@@ -29,3 +29,2 @@ import * as assert from "assert";

if (logs.err) {
console.error(logs);
return;

@@ -32,0 +31,0 @@ }

import { PublicKey } 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 } from "./namespace/index.js";
import { Coder } from "../coder/index.js";
import { RpcNamespace, InstructionNamespace, TransactionNamespace, AccountNamespace, StateClient, SimulateNamespace, MethodsNamespace } from "./namespace/index.js";
import { Address } from "./common.js";

@@ -192,2 +192,7 @@ export * from "./common.js";

/**
* 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>;
/**
* Address of the program.

@@ -222,3 +227,3 @@ */

*/
constructor(idl: IDL, programId: Address, provider?: Provider);
constructor(idl: IDL, programId: Address, provider?: Provider, coder?: Coder);
/**

@@ -225,0 +230,0 @@ * Generates a Program client by fetching the IDL from the network.

import { inflate } from "pako";
import { getProvider } from "../provider.js";
import { idlAddress, decodeIdlAccount } from "../idl.js";
import Coder from "../coder/index.js";
import { BorshCoder } from "../coder/index.js";
import NamespaceFactory from "./namespace/index.js";

@@ -46,3 +46,3 @@ import { utf8 } from "../utils/bytes/index.js";

*/
constructor(idl, programId, provider) {
constructor(idl, programId, provider, coder) {
programId = translateAddress(programId);

@@ -56,6 +56,6 @@ if (!provider) {

this._programId = programId;
this._coder = new Coder(idl);
this._coder = coder !== null && coder !== void 0 ? coder : new BorshCoder(idl);
this._events = new EventManager(this._programId, provider, this._coder);
// Dynamic namespaces.
const [rpc, instruction, transaction, account, simulate, state,] = NamespaceFactory.build(idl, this._coder, programId, provider);
const [rpc, instruction, transaction, account, simulate, methods, state,] = NamespaceFactory.build(idl, this._coder, programId, provider);
this.rpc = rpc;

@@ -66,2 +66,3 @@ this.instruction = instruction;

this.simulate = simulate;
this.methods = methods;
this.state = state;

@@ -68,0 +69,0 @@ }

@@ -6,3 +6,3 @@ /// <reference types="node" />

import { Idl, IdlTypeDef } from "../../idl.js";
import Coder from "../../coder/index.js";
import { Coder } from "../../coder/index.js";
import { Address } from "../common.js";

@@ -9,0 +9,0 @@ import { AllAccountsMap, IdlTypes, TypeDef } from "./types.js";

@@ -1,8 +0,6 @@

import { Buffer } from "buffer";
import camelCase from "camelcase";
import EventEmitter from "eventemitter3";
import bs58 from "bs58";
import { SystemProgram, } from "@solana/web3.js";
import { getProvider } from "../../provider.js";
import Coder, { ACCOUNT_DISCRIMINATOR_SIZE, accountSize, AccountsCoder, } from "../../coder/index.js";
import { BorshCoder } from "../../coder/index.js";
import { translateAddress } from "../common.js";

@@ -24,9 +22,7 @@ import * as pubkeyUtil from "../../utils/pubkey.js";

constructor(idl, idlAccount, programId, provider, coder) {
var _a;
this._idlAccount = idlAccount;
this._programId = programId;
this._provider = provider !== null && provider !== void 0 ? provider : getProvider();
this._coder = coder !== null && coder !== void 0 ? coder : new Coder(idl);
this._size =
ACCOUNT_DISCRIMINATOR_SIZE + ((_a = accountSize(idl, idlAccount)) !== null && _a !== void 0 ? _a : 0);
this._coder = coder !== null && coder !== void 0 ? coder : new BorshCoder(idl);
this._size = this._coder.accounts.size(idlAccount);
}

@@ -67,7 +63,2 @@ /**

}
// Assert the account discriminator is correct.
const discriminator = AccountsCoder.accountDiscriminator(this._idlAccount.name);
if (discriminator.compare(accountInfo.data.slice(0, 8))) {
throw new Error("Invalid account discriminator");
}
return this._coder.accounts.decode(this._idlAccount.name, accountInfo.data);

@@ -95,3 +86,2 @@ }

const accounts = await rpcUtil.getMultipleAccounts(this._provider.connection, addresses.map((address) => translateAddress(address)), commitment);
const discriminator = AccountsCoder.accountDiscriminator(this._idlAccount.name);
// Decode accounts where discriminator is correct, null otherwise

@@ -102,5 +92,2 @@ return accounts.map((account) => {

}
if (discriminator.compare(account === null || account === void 0 ? void 0 : account.account.data.slice(0, 8))) {
return null;
}
return this._coder.accounts.decode(this._idlAccount.name, account === null || account === void 0 ? void 0 : account.account.data);

@@ -124,3 +111,2 @@ });

async all(filters) {
const discriminator = AccountsCoder.accountDiscriminator(this._idlAccount.name);
let resp = await this._provider.connection.getProgramAccounts(this._programId, {

@@ -130,8 +116,3 @@ commitment: this._provider.connection.commitment,

{
memcmp: {
offset: 0,
bytes: bs58.encode(filters instanceof Buffer
? Buffer.concat([discriminator, filters])
: discriminator),
},
memcmp: this.coder.accounts.memcmp(this._idlAccount.name, filters instanceof Buffer ? filters : undefined),
},

@@ -138,0 +119,0 @@ ...(Array.isArray(filters) ? filters : []),

import { PublicKey } from "@solana/web3.js";
import Coder from "../../coder/index.js";
import { Coder } from "../../coder/index.js";
import Provider from "../../provider.js";

@@ -11,2 +11,3 @@ import { Idl } from "../../idl.js";

import { SimulateNamespace } from "./simulate.js";
import { MethodsNamespace } from "./methods";
export { StateClient } from "./state.js";

@@ -19,2 +20,3 @@ export { InstructionNamespace, InstructionFn } from "./instruction.js";

export { IdlAccounts, IdlTypes } from "./types.js";
export { MethodsBuilderFactory, MethodsNamespace } from "./methods";
export default class NamespaceFactory {

@@ -30,2 +32,3 @@ /**

SimulateNamespace<IDL>,
MethodsNamespace<IDL>,
StateClient<IDL> | undefined

@@ -32,0 +35,0 @@ ];

@@ -9,5 +9,7 @@ import camelCase from "camelcase";

import { parseIdlErrors } from "../common.js";
import { MethodsBuilderFactory } from "./methods";
// Re-exports.
export { StateClient } from "./state.js";
export { AccountClient } from "./account.js";
export { MethodsBuilderFactory } from "./methods";
export default class NamespaceFactory {

@@ -22,3 +24,7 @@ /**

const simulate = {};
const methods = {};
const idlErrors = parseIdlErrors(idl);
const account = idl.accounts
? AccountFactory.build(idl, coder, programId, provider)
: {};
const state = StateFactory.build(idl, coder, programId, provider);

@@ -30,2 +36,3 @@ idl.instructions.forEach((idlIx) => {

const simulateItem = SimulateFactory.build(idlIx, txItem, idlErrors, provider, coder, programId, idl);
const methodItem = MethodsBuilderFactory.build(provider, programId, idlIx, ixItem, txItem, rpcItem, simulateItem, account);
const name = camelCase(idlIx.name);

@@ -36,6 +43,4 @@ instruction[name] = ixItem;

simulate[name] = simulateItem;
methods[name] = methodItem;
});
const account = idl.accounts
? AccountFactory.build(idl, coder, programId, provider)
: {};
return [

@@ -47,2 +52,3 @@ rpc,

simulate,
methods,
state,

@@ -49,0 +55,0 @@ ];

@@ -5,3 +5,3 @@ import { PublicKey } from "@solana/web3.js";

import { Event } from "../event.js";
import Coder from "../../coder/index.js";
import { Coder } from "../../coder/index.js";
import { Idl, IdlEvent } from "../../idl.js";

@@ -55,3 +55,3 @@ import { AllInstructions, IdlTypes, InstructionContextFn, MakeInstructionsNamespace } from "./types";

export declare type SimulateFn<IDL extends Idl = Idl, I extends AllInstructions<IDL> = AllInstructions<IDL>> = InstructionContextFn<IDL, I, Promise<SimulateResponse<NullableEvents<IDL>, IdlTypes<IDL>>>>;
declare type SimulateResponse<E extends IdlEvent, Defined> = {
export declare type SimulateResponse<E extends IdlEvent, Defined> = {
events: readonly Event<E, Defined>[];

@@ -58,0 +58,0 @@ raw: readonly string[];

@@ -5,3 +5,3 @@ import EventEmitter from "eventemitter3";

import { Idl, IdlInstruction, IdlTypeDef } from "../../idl.js";
import Coder from "../../coder/index.js";
import { Coder } from "../../coder/index.js";
import { RpcNamespace, InstructionNamespace, TransactionNamespace } from "./index.js";

@@ -8,0 +8,0 @@ import { IdlTypes, TypeDef } from "./types.js";

@@ -5,3 +5,3 @@ import EventEmitter from "eventemitter3";

import { getProvider } from "../../provider.js";
import Coder, { stateDiscriminator } from "../../coder/index.js";
import { BorshCoder, stateDiscriminator } from "../../coder/index.js";
import { validateAccounts, parseIdlErrors } from "../common.js";

@@ -34,3 +34,3 @@ import { findProgramAddressSync, createWithSeedSync, } from "../../utils/pubkey.js";

*/
coder = new Coder(idl)) {
coder = new BorshCoder(idl)) {
this.provider = provider;

@@ -37,0 +37,0 @@ this.coder = coder;

@@ -45,2 +45,5 @@ import { PublicKey } from "@solana/web3.js";

};
export declare type MakeMethodsNamespace<IDL extends Idl, I extends IdlInstruction> = {
[M in keyof InstructionMap<I>]: MethodsFn<IDL, InstructionMap<I>[M], any>;
};
export declare type InstructionContextFn<IDL extends Idl, I extends AllInstructions<IDL>, Ret> = (...args: InstructionContextFnArgs<IDL, I>) => Ret;

@@ -51,5 +54,7 @@ export declare type InstructionContextFnArgs<IDL extends Idl, I extends IDL["instructions"][number]> = [

];
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;
} & {

@@ -67,2 +72,4 @@ [K in "u8" | "i8" | "u16" | "i16" | "u32" | "i32"]: number;

} ? Defined[T["option"]["defined"]] | null : T extends {
option: keyof TypeMap;
} ? TypeMap[T["option"]] : T extends {
vec: keyof TypeMap;

@@ -69,0 +76,0 @@ } ? TypeMap[T["vec"]][] : T extends {

import { Program } from "../program/index.js";
import Provider from "../provider.js";
import { SplTokenCoder } from "../coder/spl-token/index.js";
export declare function program(provider?: Provider): Program<SplToken>;
export declare function coder(): SplTokenCoder;
/**

@@ -5,0 +7,0 @@ * SplToken IDL.

@@ -6,4 +6,7 @@ import { PublicKey } from "@solana/web3.js";

export function program(provider) {
return new Program(IDL, TOKEN_PROGRAM_ID, provider, new SplTokenCoder(IDL));
return new Program(IDL, TOKEN_PROGRAM_ID, provider, coder());
}
export function coder() {
return new SplTokenCoder(IDL);
}
export const IDL = {

@@ -10,0 +13,0 @@ version: "0.1.0",

@@ -1,2 +0,2 @@

const _AVAILABLE_FEATURES = new Set(["anchor-deprecated-state"]);
const _AVAILABLE_FEATURES = new Set(["anchor-deprecated-state", "debug-logs"]);
const _FEATURES = new Map();

@@ -3,0 +3,0 @@ export function set(key) {

@@ -7,2 +7,3 @@ export * as sha256 from "./sha256.js";

export * as features from "./features.js";
export * as registry from "./registry.js";
//# sourceMappingURL=index.d.ts.map

@@ -7,2 +7,3 @@ export * as sha256 from "./sha256.js";

export * as features from "./features.js";
export * as registry from "./registry.js";
//# sourceMappingURL=index.js.map
import { PublicKey } from "@solana/web3.js";
export declare const TOKEN_PROGRAM_ID: PublicKey;
export declare const ASSOCIATED_PROGRAM_ID: PublicKey;
export declare function associatedAddress({ mint, owner, }: {

@@ -3,0 +5,0 @@ mint: PublicKey;

import { PublicKey } from "@solana/web3.js";
const TOKEN_PROGRAM_ID = new PublicKey("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA");
const ASSOCIATED_PROGRAM_ID = new PublicKey("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL");
export const TOKEN_PROGRAM_ID = new PublicKey("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA");
export const ASSOCIATED_PROGRAM_ID = new PublicKey("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL");
export async function associatedAddress({ mint, owner, }) {

@@ -5,0 +5,0 @@ return (await PublicKey.findProgramAddress([owner.toBuffer(), TOKEN_PROGRAM_ID.toBuffer(), mint.toBuffer()], ASSOCIATED_PROGRAM_ID))[0];

@@ -1,5 +0,3 @@

/// <reference types="node" />
import { Idl, IdlTypeDef } from "../idl.js";
export declare function accountSize(idl: Idl, idlAccount: IdlTypeDef): number;
export declare function sighash(nameSpace: string, ixName: string): Buffer;
//# sourceMappingURL=common.d.ts.map
/// <reference types="node" />
import { Idl } from "../idl.js";
import { InstructionCoder } from "./instruction.js";
import { AccountsCoder } from "./accounts.js";
import { EventCoder } from "./event.js";
import { StateCoder } from "./state.js";
export { accountSize } from "./common.js";
export { InstructionCoder } from "./instruction.js";
export { AccountsCoder, ACCOUNT_DISCRIMINATOR_SIZE } from "./accounts.js";
export { EventCoder, eventDiscriminator } from "./event.js";
export { StateCoder, stateDiscriminator } from "./state.js";
import { IdlEvent, IdlTypeDef } from "../idl.js";
import { Event } from "../program/event.js";
export * from "./borsh/index.js";
export * from "./spl-token/index.js";
/**
* Coder provides a facade for encoding and decoding all IDL related objects.
*/
export default class Coder<A extends string = string> {
export interface Coder {
/**

@@ -23,3 +17,3 @@ * Instruction coder.

*/
readonly accounts: AccountsCoder<A>;
readonly accounts: AccountsCoder;
/**

@@ -33,5 +27,21 @@ * Coder for state structs.

readonly events: EventCoder;
constructor(idl: Idl);
sighash(nameSpace: string, ixName: string): Buffer;
}
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;
}
//# sourceMappingURL=index.d.ts.map

@@ -43,3 +43,9 @@ /// <reference types="node" />

isSigner: boolean;
pda?: IdlPda;
};
export declare type IdlPda = {
seeds: IdlSeed[];
programId?: IdlSeed;
};
export declare type IdlSeed = any;
export declare type IdlAccounts = {

@@ -67,3 +73,3 @@ name: string;

declare type IdlTypeDefStruct = Array<IdlField>;
export declare type IdlType = "bool" | "u8" | "i8" | "u16" | "i16" | "u32" | "i32" | "u64" | "i64" | "u128" | "i128" | "bytes" | "string" | "publicKey" | IdlTypeDefined | IdlTypeOption | IdlTypeVec | IdlTypeArray;
export declare type IdlType = "bool" | "u8" | "i8" | "u16" | "i16" | "u32" | "i32" | "u64" | "i64" | "u128" | "i128" | "bytes" | "string" | "publicKey" | IdlTypeDefined | IdlTypeOption | IdlTypeCOption | IdlTypeVec | IdlTypeArray;
export declare type IdlTypeDefined = {

@@ -75,2 +81,5 @@ defined: string;

};
export declare type IdlTypeCOption = {
coption: IdlType;
};
export declare type IdlTypeVec = {

@@ -77,0 +86,0 @@ vec: IdlType;

@@ -0,12 +1,15 @@

import NodeWallet from "./nodewallet";
export { default as BN } from "bn.js";
export * as web3 from "@solana/web3.js";
export { default as Provider, getProvider, setProvider } from "./provider.js";
export { default as Coder, InstructionCoder, EventCoder, StateCoder, AccountsCoder, } from "./coder/index.js";
export * from "./error.js";
export { Instruction } from "./coder/instruction.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 declare const workspace: any;
export declare const Wallet: import("./nodewallet").default;
export declare class Wallet extends NodeWallet {
}
//# sourceMappingURL=index.d.ts.map
import { PublicKey } from "@solana/web3.js";
import { IdlEvent, IdlEventField } from "../idl.js";
import Coder from "../coder/index.js";
import { Coder } from "../coder/index.js";
import { DecodeType } from "./namespace/types.js";

@@ -5,0 +5,0 @@ import Provider from "../provider.js";

import { PublicKey } 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 } from "./namespace/index.js";
import { Coder } from "../coder/index.js";
import { RpcNamespace, InstructionNamespace, TransactionNamespace, AccountNamespace, StateClient, SimulateNamespace, MethodsNamespace } from "./namespace/index.js";
import { Address } from "./common.js";

@@ -192,2 +192,7 @@ export * from "./common.js";

/**
* 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>;
/**
* Address of the program.

@@ -222,3 +227,3 @@ */

*/
constructor(idl: IDL, programId: Address, provider?: Provider);
constructor(idl: IDL, programId: Address, provider?: Provider, coder?: Coder);
/**

@@ -225,0 +230,0 @@ * Generates a Program client by fetching the IDL from the network.

@@ -6,3 +6,3 @@ /// <reference types="node" />

import { Idl, IdlTypeDef } from "../../idl.js";
import Coder from "../../coder/index.js";
import { Coder } from "../../coder/index.js";
import { Address } from "../common.js";

@@ -9,0 +9,0 @@ import { AllAccountsMap, IdlTypes, TypeDef } from "./types.js";

import { PublicKey } from "@solana/web3.js";
import Coder from "../../coder/index.js";
import { Coder } from "../../coder/index.js";
import Provider from "../../provider.js";

@@ -11,2 +11,3 @@ import { Idl } from "../../idl.js";

import { SimulateNamespace } from "./simulate.js";
import { MethodsNamespace } from "./methods";
export { StateClient } from "./state.js";

@@ -19,2 +20,3 @@ export { InstructionNamespace, InstructionFn } from "./instruction.js";

export { IdlAccounts, IdlTypes } from "./types.js";
export { MethodsBuilderFactory, MethodsNamespace } from "./methods";
export default class NamespaceFactory {

@@ -30,2 +32,3 @@ /**

SimulateNamespace<IDL>,
MethodsNamespace<IDL>,
StateClient<IDL> | undefined

@@ -32,0 +35,0 @@ ];

@@ -5,3 +5,3 @@ import { PublicKey } from "@solana/web3.js";

import { Event } from "../event.js";
import Coder from "../../coder/index.js";
import { Coder } from "../../coder/index.js";
import { Idl, IdlEvent } from "../../idl.js";

@@ -55,3 +55,3 @@ import { AllInstructions, IdlTypes, InstructionContextFn, MakeInstructionsNamespace } from "./types";

export declare type SimulateFn<IDL extends Idl = Idl, I extends AllInstructions<IDL> = AllInstructions<IDL>> = InstructionContextFn<IDL, I, Promise<SimulateResponse<NullableEvents<IDL>, IdlTypes<IDL>>>>;
declare type SimulateResponse<E extends IdlEvent, Defined> = {
export declare type SimulateResponse<E extends IdlEvent, Defined> = {
events: readonly Event<E, Defined>[];

@@ -58,0 +58,0 @@ raw: readonly string[];

@@ -5,3 +5,3 @@ import EventEmitter from "eventemitter3";

import { Idl, IdlInstruction, IdlTypeDef } from "../../idl.js";
import Coder from "../../coder/index.js";
import { Coder } from "../../coder/index.js";
import { RpcNamespace, InstructionNamespace, TransactionNamespace } from "./index.js";

@@ -8,0 +8,0 @@ import { IdlTypes, TypeDef } from "./types.js";

@@ -45,2 +45,5 @@ import { PublicKey } from "@solana/web3.js";

};
export declare type MakeMethodsNamespace<IDL extends Idl, I extends IdlInstruction> = {
[M in keyof InstructionMap<I>]: MethodsFn<IDL, InstructionMap<I>[M], any>;
};
export declare type InstructionContextFn<IDL extends Idl, I extends AllInstructions<IDL>, Ret> = (...args: InstructionContextFnArgs<IDL, I>) => Ret;

@@ -51,5 +54,7 @@ export declare type InstructionContextFnArgs<IDL extends Idl, I extends IDL["instructions"][number]> = [

];
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;
} & {

@@ -67,2 +72,4 @@ [K in "u8" | "i8" | "u16" | "i16" | "u32" | "i32"]: number;

} ? Defined[T["option"]["defined"]] | null : T extends {
option: keyof TypeMap;
} ? TypeMap[T["option"]] : T extends {
vec: keyof TypeMap;

@@ -69,0 +76,0 @@ } ? TypeMap[T["vec"]][] : T extends {

@@ -7,2 +7,3 @@ export * as sha256 from "./sha256.js";

export * as features from "./features.js";
export * as registry from "./registry.js";
//# sourceMappingURL=index.d.ts.map
import { PublicKey } from "@solana/web3.js";
export declare const TOKEN_PROGRAM_ID: PublicKey;
export declare const ASSOCIATED_PROGRAM_ID: PublicKey;
export declare function associatedAddress({ mint, owner, }: {

@@ -3,0 +5,0 @@ mint: PublicKey;

@@ -1,5 +0,3 @@

/// <reference types="node" />
import { Idl, IdlTypeDef } from "../idl.js";
export declare function accountSize(idl: Idl, idlAccount: IdlTypeDef): number;
export declare function sighash(nameSpace: string, ixName: string): Buffer;
//# sourceMappingURL=common.d.ts.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.sighash = exports.accountSize = void 0;
const buffer_1 = require("buffer");
const snake_case_1 = require("snake-case");
const js_sha256_1 = require("js-sha256");
exports.accountSize = void 0;
const error_js_1 = require("../error.js");

@@ -73,2 +70,5 @@ function accountSize(idl, idlAccount) {

}
if ("coption" in ty) {
return 4 + typeSize(idl, ty.coption);
}
if ("defined" in ty) {

@@ -90,10 +90,2 @@ const filtered = (_b = (_a = idl.types) === null || _a === void 0 ? void 0 : _a.filter((t) => t.name === ty.defined)) !== null && _b !== void 0 ? _b : [];

}
// Not technically sighash, since we don't include the arguments, as Rust
// doesn't allow function overloading.
function sighash(nameSpace, ixName) {
let name = (0, snake_case_1.snakeCase)(ixName);
let preimage = `${nameSpace}:${name}`;
return buffer_1.Buffer.from(js_sha256_1.sha256.digest(preimage)).slice(0, 8);
}
exports.sighash = sighash;
//# sourceMappingURL=common.js.map
/// <reference types="node" />
import { Idl } from "../idl.js";
import { InstructionCoder } from "./instruction.js";
import { AccountsCoder } from "./accounts.js";
import { EventCoder } from "./event.js";
import { StateCoder } from "./state.js";
export { accountSize } from "./common.js";
export { InstructionCoder } from "./instruction.js";
export { AccountsCoder, ACCOUNT_DISCRIMINATOR_SIZE } from "./accounts.js";
export { EventCoder, eventDiscriminator } from "./event.js";
export { StateCoder, stateDiscriminator } from "./state.js";
import { IdlEvent, IdlTypeDef } from "../idl.js";
import { Event } from "../program/event.js";
export * from "./borsh/index.js";
export * from "./spl-token/index.js";
/**
* Coder provides a facade for encoding and decoding all IDL related objects.
*/
export default class Coder<A extends string = string> {
export interface Coder {
/**

@@ -23,3 +17,3 @@ * Instruction coder.

*/
readonly accounts: AccountsCoder<A>;
readonly accounts: AccountsCoder;
/**

@@ -33,5 +27,21 @@ * Coder for state structs.

readonly events: EventCoder;
constructor(idl: Idl);
sighash(nameSpace: string, ixName: string): Buffer;
}
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;
}
//# sourceMappingURL=index.d.ts.map
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.stateDiscriminator = exports.StateCoder = exports.eventDiscriminator = exports.EventCoder = exports.ACCOUNT_DISCRIMINATOR_SIZE = exports.AccountsCoder = exports.InstructionCoder = exports.accountSize = void 0;
const instruction_js_1 = require("./instruction.js");
const accounts_js_1 = require("./accounts.js");
const event_js_1 = require("./event.js");
const state_js_1 = require("./state.js");
const common_js_1 = require("./common.js");
var common_js_2 = require("./common.js");
Object.defineProperty(exports, "accountSize", { enumerable: true, get: function () { return common_js_2.accountSize; } });
var instruction_js_2 = require("./instruction.js");
Object.defineProperty(exports, "InstructionCoder", { enumerable: true, get: function () { return instruction_js_2.InstructionCoder; } });
var accounts_js_2 = require("./accounts.js");
Object.defineProperty(exports, "AccountsCoder", { enumerable: true, get: function () { return accounts_js_2.AccountsCoder; } });
Object.defineProperty(exports, "ACCOUNT_DISCRIMINATOR_SIZE", { enumerable: true, get: function () { return accounts_js_2.ACCOUNT_DISCRIMINATOR_SIZE; } });
var event_js_2 = require("./event.js");
Object.defineProperty(exports, "EventCoder", { enumerable: true, get: function () { return event_js_2.EventCoder; } });
Object.defineProperty(exports, "eventDiscriminator", { enumerable: true, get: function () { return event_js_2.eventDiscriminator; } });
var state_js_2 = require("./state.js");
Object.defineProperty(exports, "StateCoder", { enumerable: true, get: function () { return state_js_2.StateCoder; } });
Object.defineProperty(exports, "stateDiscriminator", { enumerable: true, get: function () { return state_js_2.stateDiscriminator; } });
/**
* Coder provides a facade for encoding and decoding all IDL related objects.
*/
class Coder {
constructor(idl) {
this.instruction = new instruction_js_1.InstructionCoder(idl);
this.accounts = new accounts_js_1.AccountsCoder(idl);
this.events = new event_js_1.EventCoder(idl);
if (idl.state) {
this.state = new state_js_1.StateCoder(idl);
}
}
sighash(nameSpace, ixName) {
return (0, common_js_1.sighash)(nameSpace, ixName);
}
}
exports.default = Coder;
__exportStar(require("./borsh/index.js"), exports);
__exportStar(require("./spl-token/index.js"), exports);
//# sourceMappingURL=index.js.map

@@ -43,3 +43,9 @@ /// <reference types="node" />

isSigner: boolean;
pda?: IdlPda;
};
export declare type IdlPda = {
seeds: IdlSeed[];
programId?: IdlSeed;
};
export declare type IdlSeed = any;
export declare type IdlAccounts = {

@@ -67,3 +73,3 @@ name: string;

declare type IdlTypeDefStruct = Array<IdlField>;
export declare type IdlType = "bool" | "u8" | "i8" | "u16" | "i16" | "u32" | "i32" | "u64" | "i64" | "u128" | "i128" | "bytes" | "string" | "publicKey" | IdlTypeDefined | IdlTypeOption | IdlTypeVec | IdlTypeArray;
export declare type IdlType = "bool" | "u8" | "i8" | "u16" | "i16" | "u32" | "i32" | "u64" | "i64" | "u128" | "i128" | "bytes" | "string" | "publicKey" | IdlTypeDefined | IdlTypeOption | IdlTypeCOption | IdlTypeVec | IdlTypeArray;
export declare type IdlTypeDefined = {

@@ -75,2 +81,5 @@ defined: string;

};
export declare type IdlTypeCOption = {
coption: IdlType;
};
export declare type IdlTypeVec = {

@@ -77,0 +86,0 @@ vec: IdlType;

@@ -0,12 +1,15 @@

import NodeWallet from "./nodewallet";
export { default as BN } from "bn.js";
export * as web3 from "@solana/web3.js";
export { default as Provider, getProvider, setProvider } from "./provider.js";
export { default as Coder, InstructionCoder, EventCoder, StateCoder, AccountsCoder, } from "./coder/index.js";
export * from "./error.js";
export { Instruction } from "./coder/instruction.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 declare const workspace: any;
export declare const Wallet: import("./nodewallet").default;
export declare class Wallet extends NodeWallet {
}
//# sourceMappingURL=index.d.ts.map

@@ -28,3 +28,4 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.utils = exports.AccountsCoder = exports.StateCoder = exports.EventCoder = exports.InstructionCoder = exports.Coder = exports.setProvider = exports.getProvider = exports.Provider = exports.web3 = exports.BN = void 0;
exports.utils = exports.setProvider = exports.getProvider = exports.Provider = exports.web3 = exports.BN = void 0;
const nodewallet_1 = __importDefault(require("./nodewallet"));
const common_js_1 = require("./utils/common.js");

@@ -38,11 +39,7 @@ var bn_js_1 = require("bn.js");

Object.defineProperty(exports, "setProvider", { enumerable: true, get: function () { return provider_js_1.setProvider; } });
var index_js_1 = require("./coder/index.js");
Object.defineProperty(exports, "Coder", { enumerable: true, get: function () { return __importDefault(index_js_1).default; } });
Object.defineProperty(exports, "InstructionCoder", { enumerable: true, get: function () { return index_js_1.InstructionCoder; } });
Object.defineProperty(exports, "EventCoder", { enumerable: true, get: function () { return index_js_1.EventCoder; } });
Object.defineProperty(exports, "StateCoder", { enumerable: true, get: function () { return index_js_1.StateCoder; } });
Object.defineProperty(exports, "AccountsCoder", { enumerable: true, get: function () { return index_js_1.AccountsCoder; } });
__exportStar(require("./error.js"), exports);
__exportStar(require("./coder/index.js"), exports);
exports.utils = __importStar(require("./utils/index.js"));
__exportStar(require("./program/index.js"), exports);
__exportStar(require("./spl/index.js"), exports);
if (!common_js_1.isBrowser) {

@@ -49,0 +46,0 @@ exports.workspace = require("./workspace.js").default;

import { PublicKey } from "@solana/web3.js";
import { IdlEvent, IdlEventField } from "../idl.js";
import Coder from "../coder/index.js";
import { Coder } from "../coder/index.js";
import { DecodeType } from "./namespace/types.js";

@@ -5,0 +5,0 @@ import Provider from "../provider.js";

@@ -51,3 +51,2 @@ "use strict";

if (logs.err) {
console.error(logs);
return;

@@ -54,0 +53,0 @@ }

import { PublicKey } 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 } from "./namespace/index.js";
import { Coder } from "../coder/index.js";
import { RpcNamespace, InstructionNamespace, TransactionNamespace, AccountNamespace, StateClient, SimulateNamespace, MethodsNamespace } from "./namespace/index.js";
import { Address } from "./common.js";

@@ -192,2 +192,7 @@ export * from "./common.js";

/**
* 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>;
/**
* Address of the program.

@@ -222,3 +227,3 @@ */

*/
constructor(idl: IDL, programId: Address, provider?: Provider);
constructor(idl: IDL, programId: Address, provider?: Provider, coder?: Coder);
/**

@@ -225,0 +230,0 @@ * Generates a Program client by fetching the IDL from the network.

@@ -20,3 +20,3 @@ "use strict";

const idl_js_1 = require("../idl.js");
const index_js_1 = __importDefault(require("../coder/index.js"));
const index_js_1 = require("../coder/index.js");
const index_js_2 = __importDefault(require("./namespace/index.js"));

@@ -63,3 +63,3 @@ const index_js_3 = require("../utils/bytes/index.js");

*/
constructor(idl, programId, provider) {
constructor(idl, programId, provider, coder) {
programId = (0, common_js_1.translateAddress)(programId);

@@ -73,6 +73,6 @@ if (!provider) {

this._programId = programId;
this._coder = new index_js_1.default(idl);
this._coder = coder !== null && coder !== void 0 ? coder : new index_js_1.BorshCoder(idl);
this._events = new event_js_1.EventManager(this._programId, provider, this._coder);
// Dynamic namespaces.
const [rpc, instruction, transaction, account, simulate, state,] = index_js_2.default.build(idl, this._coder, programId, provider);
const [rpc, instruction, transaction, account, simulate, methods, state,] = index_js_2.default.build(idl, this._coder, programId, provider);
this.rpc = rpc;

@@ -83,2 +83,3 @@ this.instruction = instruction;

this.simulate = simulate;
this.methods = methods;
this.state = state;

@@ -85,0 +86,0 @@ }

@@ -6,3 +6,3 @@ /// <reference types="node" />

import { Idl, IdlTypeDef } from "../../idl.js";
import Coder from "../../coder/index.js";
import { Coder } from "../../coder/index.js";
import { Address } from "../common.js";

@@ -9,0 +9,0 @@ import { AllAccountsMap, IdlTypes, TypeDef } from "./types.js";

@@ -26,9 +26,7 @@ "use strict";

exports.AccountClient = void 0;
const buffer_1 = require("buffer");
const camelcase_1 = __importDefault(require("camelcase"));
const eventemitter3_1 = __importDefault(require("eventemitter3"));
const bs58_1 = __importDefault(require("bs58"));
const web3_js_1 = require("@solana/web3.js");
const provider_js_1 = require("../../provider.js");
const index_js_1 = __importStar(require("../../coder/index.js"));
const index_js_1 = require("../../coder/index.js");
const common_js_1 = require("../common.js");

@@ -51,9 +49,7 @@ const pubkeyUtil = __importStar(require("../../utils/pubkey.js"));

constructor(idl, idlAccount, programId, provider, coder) {
var _a;
this._idlAccount = idlAccount;
this._programId = programId;
this._provider = provider !== null && provider !== void 0 ? provider : (0, provider_js_1.getProvider)();
this._coder = coder !== null && coder !== void 0 ? coder : new index_js_1.default(idl);
this._size =
index_js_1.ACCOUNT_DISCRIMINATOR_SIZE + ((_a = (0, index_js_1.accountSize)(idl, idlAccount)) !== null && _a !== void 0 ? _a : 0);
this._coder = coder !== null && coder !== void 0 ? coder : new index_js_1.BorshCoder(idl);
this._size = this._coder.accounts.size(idlAccount);
}

@@ -94,7 +90,2 @@ /**

}
// Assert the account discriminator is correct.
const discriminator = index_js_1.AccountsCoder.accountDiscriminator(this._idlAccount.name);
if (discriminator.compare(accountInfo.data.slice(0, 8))) {
throw new Error("Invalid account discriminator");
}
return this._coder.accounts.decode(this._idlAccount.name, accountInfo.data);

@@ -122,3 +113,2 @@ }

const accounts = await rpcUtil.getMultipleAccounts(this._provider.connection, addresses.map((address) => (0, common_js_1.translateAddress)(address)), commitment);
const discriminator = index_js_1.AccountsCoder.accountDiscriminator(this._idlAccount.name);
// Decode accounts where discriminator is correct, null otherwise

@@ -129,5 +119,2 @@ return accounts.map((account) => {

}
if (discriminator.compare(account === null || account === void 0 ? void 0 : account.account.data.slice(0, 8))) {
return null;
}
return this._coder.accounts.decode(this._idlAccount.name, account === null || account === void 0 ? void 0 : account.account.data);

@@ -151,3 +138,2 @@ });

async all(filters) {
const discriminator = index_js_1.AccountsCoder.accountDiscriminator(this._idlAccount.name);
let resp = await this._provider.connection.getProgramAccounts(this._programId, {

@@ -157,8 +143,3 @@ commitment: this._provider.connection.commitment,

{
memcmp: {
offset: 0,
bytes: bs58_1.default.encode(filters instanceof buffer_1.Buffer
? buffer_1.Buffer.concat([discriminator, filters])
: discriminator),
},
memcmp: this.coder.accounts.memcmp(this._idlAccount.name, filters instanceof Buffer ? filters : undefined),
},

@@ -165,0 +146,0 @@ ...(Array.isArray(filters) ? filters : []),

import { PublicKey } from "@solana/web3.js";
import Coder from "../../coder/index.js";
import { Coder } from "../../coder/index.js";
import Provider from "../../provider.js";

@@ -11,2 +11,3 @@ import { Idl } from "../../idl.js";

import { SimulateNamespace } from "./simulate.js";
import { MethodsNamespace } from "./methods";
export { StateClient } from "./state.js";

@@ -19,2 +20,3 @@ export { InstructionNamespace, InstructionFn } from "./instruction.js";

export { IdlAccounts, IdlTypes } from "./types.js";
export { MethodsBuilderFactory, MethodsNamespace } from "./methods";
export default class NamespaceFactory {

@@ -30,2 +32,3 @@ /**

SimulateNamespace<IDL>,
MethodsNamespace<IDL>,
StateClient<IDL> | undefined

@@ -32,0 +35,0 @@ ];

@@ -6,3 +6,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.AccountClient = exports.StateClient = void 0;
exports.MethodsBuilderFactory = exports.AccountClient = exports.StateClient = void 0;
const camelcase_1 = __importDefault(require("camelcase"));

@@ -16,2 +16,3 @@ const state_js_1 = __importDefault(require("./state.js"));

const common_js_1 = require("../common.js");
const methods_1 = require("./methods");
// Re-exports.

@@ -22,2 +23,4 @@ var state_js_2 = require("./state.js");

Object.defineProperty(exports, "AccountClient", { enumerable: true, get: function () { return account_js_2.AccountClient; } });
var methods_2 = require("./methods");
Object.defineProperty(exports, "MethodsBuilderFactory", { enumerable: true, get: function () { return methods_2.MethodsBuilderFactory; } });
class NamespaceFactory {

@@ -32,3 +35,7 @@ /**

const simulate = {};
const methods = {};
const idlErrors = (0, common_js_1.parseIdlErrors)(idl);
const account = idl.accounts
? account_js_1.default.build(idl, coder, programId, provider)
: {};
const state = state_js_1.default.build(idl, coder, programId, provider);

@@ -40,2 +47,3 @@ idl.instructions.forEach((idlIx) => {

const simulateItem = simulate_js_1.default.build(idlIx, txItem, idlErrors, provider, coder, programId, idl);
const methodItem = methods_1.MethodsBuilderFactory.build(provider, programId, idlIx, ixItem, txItem, rpcItem, simulateItem, account);
const name = (0, camelcase_1.default)(idlIx.name);

@@ -46,6 +54,4 @@ instruction[name] = ixItem;

simulate[name] = simulateItem;
methods[name] = methodItem;
});
const account = idl.accounts
? account_js_1.default.build(idl, coder, programId, provider)
: {};
return [

@@ -57,2 +63,3 @@ rpc,

simulate,
methods,
state,

@@ -59,0 +66,0 @@ ];

@@ -5,3 +5,3 @@ import { PublicKey } from "@solana/web3.js";

import { Event } from "../event.js";
import Coder from "../../coder/index.js";
import { Coder } from "../../coder/index.js";
import { Idl, IdlEvent } from "../../idl.js";

@@ -55,3 +55,3 @@ import { AllInstructions, IdlTypes, InstructionContextFn, MakeInstructionsNamespace } from "./types";

export declare type SimulateFn<IDL extends Idl = Idl, I extends AllInstructions<IDL> = AllInstructions<IDL>> = InstructionContextFn<IDL, I, Promise<SimulateResponse<NullableEvents<IDL>, IdlTypes<IDL>>>>;
declare type SimulateResponse<E extends IdlEvent, Defined> = {
export declare type SimulateResponse<E extends IdlEvent, Defined> = {
events: readonly Event<E, Defined>[];

@@ -58,0 +58,0 @@ raw: readonly string[];

@@ -5,3 +5,3 @@ import EventEmitter from "eventemitter3";

import { Idl, IdlInstruction, IdlTypeDef } from "../../idl.js";
import Coder from "../../coder/index.js";
import { Coder } from "../../coder/index.js";
import { RpcNamespace, InstructionNamespace, TransactionNamespace } from "./index.js";

@@ -8,0 +8,0 @@ import { IdlTypes, TypeDef } from "./types.js";

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {

@@ -30,3 +11,3 @@ return (mod && mod.__esModule) ? mod : { "default": mod };

const provider_js_1 = require("../../provider.js");
const index_js_1 = __importStar(require("../../coder/index.js"));
const index_js_1 = require("../../coder/index.js");
const common_js_1 = require("../common.js");

@@ -60,3 +41,3 @@ const pubkey_js_1 = require("../../utils/pubkey.js");

*/
coder = new index_js_1.default(idl)) {
coder = new index_js_1.BorshCoder(idl)) {
this.provider = provider;

@@ -63,0 +44,0 @@ this.coder = coder;

@@ -45,2 +45,5 @@ import { PublicKey } from "@solana/web3.js";

};
export declare type MakeMethodsNamespace<IDL extends Idl, I extends IdlInstruction> = {
[M in keyof InstructionMap<I>]: MethodsFn<IDL, InstructionMap<I>[M], any>;
};
export declare type InstructionContextFn<IDL extends Idl, I extends AllInstructions<IDL>, Ret> = (...args: InstructionContextFnArgs<IDL, I>) => Ret;

@@ -51,5 +54,7 @@ export declare type InstructionContextFnArgs<IDL extends Idl, I extends IDL["instructions"][number]> = [

];
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;
} & {

@@ -67,2 +72,4 @@ [K in "u8" | "i8" | "u16" | "i16" | "u32" | "i32"]: number;

} ? Defined[T["option"]["defined"]] | null : T extends {
option: keyof TypeMap;
} ? TypeMap[T["option"]] : T extends {
vec: keyof TypeMap;

@@ -69,0 +76,0 @@ } ? TypeMap[T["vec"]][] : T extends {

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isSet = exports.set = void 0;
const _AVAILABLE_FEATURES = new Set(["anchor-deprecated-state"]);
const _AVAILABLE_FEATURES = new Set(["anchor-deprecated-state", "debug-logs"]);
const _FEATURES = new Map();

@@ -6,0 +6,0 @@ function set(key) {

@@ -7,2 +7,3 @@ export * as sha256 from "./sha256.js";

export * as features from "./features.js";
export * as registry from "./registry.js";
//# sourceMappingURL=index.d.ts.map

@@ -22,3 +22,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.features = exports.token = exports.bytes = exports.publicKey = exports.rpc = exports.sha256 = void 0;
exports.registry = exports.features = exports.token = exports.bytes = exports.publicKey = exports.rpc = exports.sha256 = void 0;
exports.sha256 = __importStar(require("./sha256.js"));

@@ -30,2 +30,3 @@ exports.rpc = __importStar(require("./rpc.js"));

exports.features = __importStar(require("./features.js"));
exports.registry = __importStar(require("./registry.js"));
//# sourceMappingURL=index.js.map
import { PublicKey } from "@solana/web3.js";
export declare const TOKEN_PROGRAM_ID: PublicKey;
export declare const ASSOCIATED_PROGRAM_ID: PublicKey;
export declare function associatedAddress({ mint, owner, }: {

@@ -3,0 +5,0 @@ mint: PublicKey;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.associatedAddress = void 0;
exports.associatedAddress = exports.ASSOCIATED_PROGRAM_ID = exports.TOKEN_PROGRAM_ID = void 0;
const web3_js_1 = require("@solana/web3.js");
const TOKEN_PROGRAM_ID = new web3_js_1.PublicKey("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA");
const ASSOCIATED_PROGRAM_ID = new web3_js_1.PublicKey("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL");
exports.TOKEN_PROGRAM_ID = new web3_js_1.PublicKey("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA");
exports.ASSOCIATED_PROGRAM_ID = new web3_js_1.PublicKey("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL");
async function associatedAddress({ mint, owner, }) {
return (await web3_js_1.PublicKey.findProgramAddress([owner.toBuffer(), TOKEN_PROGRAM_ID.toBuffer(), mint.toBuffer()], ASSOCIATED_PROGRAM_ID))[0];
return (await web3_js_1.PublicKey.findProgramAddress([owner.toBuffer(), exports.TOKEN_PROGRAM_ID.toBuffer(), mint.toBuffer()], exports.ASSOCIATED_PROGRAM_ID))[0];
}
exports.associatedAddress = associatedAddress;
//# sourceMappingURL=token.js.map

@@ -1,5 +0,3 @@

/// <reference types="node" />
import { Idl, IdlTypeDef } from "../idl.js";
export declare function accountSize(idl: Idl, idlAccount: IdlTypeDef): number;
export declare function sighash(nameSpace: string, ixName: string): Buffer;
//# sourceMappingURL=common.d.ts.map

@@ -1,4 +0,1 @@

import { Buffer } from "buffer";
import { snakeCase } from "snake-case";
import { sha256 } from "js-sha256";
import { IdlError } from "../error.js";

@@ -69,2 +66,5 @@ export function accountSize(idl, idlAccount) {

}
if ("coption" in ty) {
return 4 + typeSize(idl, ty.coption);
}
if ("defined" in ty) {

@@ -86,9 +86,2 @@ const filtered = (_b = (_a = idl.types) === null || _a === void 0 ? void 0 : _a.filter((t) => t.name === ty.defined)) !== null && _b !== void 0 ? _b : [];

}
// Not technically sighash, since we don't include the arguments, as Rust
// doesn't allow function overloading.
export function sighash(nameSpace, ixName) {
let name = snakeCase(ixName);
let preimage = `${nameSpace}:${name}`;
return Buffer.from(sha256.digest(preimage)).slice(0, 8);
}
//# sourceMappingURL=common.js.map
/// <reference types="node" />
import { Idl } from "../idl.js";
import { InstructionCoder } from "./instruction.js";
import { AccountsCoder } from "./accounts.js";
import { EventCoder } from "./event.js";
import { StateCoder } from "./state.js";
export { accountSize } from "./common.js";
export { InstructionCoder } from "./instruction.js";
export { AccountsCoder, ACCOUNT_DISCRIMINATOR_SIZE } from "./accounts.js";
export { EventCoder, eventDiscriminator } from "./event.js";
export { StateCoder, stateDiscriminator } from "./state.js";
import { IdlEvent, IdlTypeDef } from "../idl.js";
import { Event } from "../program/event.js";
export * from "./borsh/index.js";
export * from "./spl-token/index.js";
/**
* Coder provides a facade for encoding and decoding all IDL related objects.
*/
export default class Coder<A extends string = string> {
export interface Coder {
/**

@@ -23,3 +17,3 @@ * Instruction coder.

*/
readonly accounts: AccountsCoder<A>;
readonly accounts: AccountsCoder;
/**

@@ -33,5 +27,21 @@ * Coder for state structs.

readonly events: EventCoder;
constructor(idl: Idl);
sighash(nameSpace: string, ixName: string): Buffer;
}
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;
}
//# sourceMappingURL=index.d.ts.map

@@ -1,27 +0,3 @@

import { InstructionCoder } from "./instruction.js";
import { AccountsCoder } from "./accounts.js";
import { EventCoder } from "./event.js";
import { StateCoder } from "./state.js";
import { sighash } from "./common.js";
export { accountSize } from "./common.js";
export { InstructionCoder } from "./instruction.js";
export { AccountsCoder, ACCOUNT_DISCRIMINATOR_SIZE } from "./accounts.js";
export { EventCoder, eventDiscriminator } from "./event.js";
export { StateCoder, stateDiscriminator } from "./state.js";
/**
* Coder provides a facade for encoding and decoding all IDL related objects.
*/
export default class Coder {
constructor(idl) {
this.instruction = new InstructionCoder(idl);
this.accounts = new AccountsCoder(idl);
this.events = new EventCoder(idl);
if (idl.state) {
this.state = new StateCoder(idl);
}
}
sighash(nameSpace, ixName) {
return sighash(nameSpace, ixName);
}
}
export * from "./borsh/index.js";
export * from "./spl-token/index.js";
//# sourceMappingURL=index.js.map

@@ -43,3 +43,9 @@ /// <reference types="node" />

isSigner: boolean;
pda?: IdlPda;
};
export declare type IdlPda = {
seeds: IdlSeed[];
programId?: IdlSeed;
};
export declare type IdlSeed = any;
export declare type IdlAccounts = {

@@ -67,3 +73,3 @@ name: string;

declare type IdlTypeDefStruct = Array<IdlField>;
export declare type IdlType = "bool" | "u8" | "i8" | "u16" | "i16" | "u32" | "i32" | "u64" | "i64" | "u128" | "i128" | "bytes" | "string" | "publicKey" | IdlTypeDefined | IdlTypeOption | IdlTypeVec | IdlTypeArray;
export declare type IdlType = "bool" | "u8" | "i8" | "u16" | "i16" | "u32" | "i32" | "u64" | "i64" | "u128" | "i128" | "bytes" | "string" | "publicKey" | IdlTypeDefined | IdlTypeOption | IdlTypeCOption | IdlTypeVec | IdlTypeArray;
export declare type IdlTypeDefined = {

@@ -75,2 +81,5 @@ defined: string;

};
export declare type IdlTypeCOption = {
coption: IdlType;
};
export declare type IdlTypeVec = {

@@ -77,0 +86,0 @@ vec: IdlType;

@@ -0,12 +1,15 @@

import NodeWallet from "./nodewallet";
export { default as BN } from "bn.js";
export * as web3 from "@solana/web3.js";
export { default as Provider, getProvider, setProvider } from "./provider.js";
export { default as Coder, InstructionCoder, EventCoder, StateCoder, AccountsCoder, } from "./coder/index.js";
export * from "./error.js";
export { Instruction } from "./coder/instruction.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 declare const workspace: any;
export declare const Wallet: import("./nodewallet").default;
export declare class Wallet extends NodeWallet {
}
//# sourceMappingURL=index.d.ts.map

@@ -0,1 +1,2 @@

import NodeWallet from "./nodewallet";
import { isBrowser } from "./utils/common.js";

@@ -5,6 +6,7 @@ export { default as BN } from "bn.js";

export { default as Provider, getProvider, setProvider } from "./provider.js";
export { default as Coder, InstructionCoder, EventCoder, StateCoder, AccountsCoder, } from "./coder/index.js";
export * from "./error.js";
export * from "./coder/index.js";
export * as utils from "./utils/index.js";
export * from "./program/index.js";
export * from "./spl/index.js";
if (!isBrowser) {

@@ -11,0 +13,0 @@ exports.workspace = require("./workspace.js").default;

import { PublicKey } from "@solana/web3.js";
import { IdlEvent, IdlEventField } from "../idl.js";
import Coder from "../coder/index.js";
import { Coder } from "../coder/index.js";
import { DecodeType } from "./namespace/types.js";

@@ -5,0 +5,0 @@ import Provider from "../provider.js";

@@ -29,3 +29,2 @@ import * as assert from "assert";

if (logs.err) {
console.error(logs);
return;

@@ -32,0 +31,0 @@ }

import { PublicKey } 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 } from "./namespace/index.js";
import { Coder } from "../coder/index.js";
import { RpcNamespace, InstructionNamespace, TransactionNamespace, AccountNamespace, StateClient, SimulateNamespace, MethodsNamespace } from "./namespace/index.js";
import { Address } from "./common.js";

@@ -192,2 +192,7 @@ export * from "./common.js";

/**
* 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>;
/**
* Address of the program.

@@ -222,3 +227,3 @@ */

*/
constructor(idl: IDL, programId: Address, provider?: Provider);
constructor(idl: IDL, programId: Address, provider?: Provider, coder?: Coder);
/**

@@ -225,0 +230,0 @@ * Generates a Program client by fetching the IDL from the network.

import { inflate } from "pako";
import { getProvider } from "../provider.js";
import { idlAddress, decodeIdlAccount } from "../idl.js";
import Coder from "../coder/index.js";
import { BorshCoder } from "../coder/index.js";
import NamespaceFactory from "./namespace/index.js";

@@ -46,3 +46,3 @@ import { utf8 } from "../utils/bytes/index.js";

*/
constructor(idl, programId, provider) {
constructor(idl, programId, provider, coder) {
programId = translateAddress(programId);

@@ -56,6 +56,6 @@ if (!provider) {

this._programId = programId;
this._coder = new Coder(idl);
this._coder = coder !== null && coder !== void 0 ? coder : new BorshCoder(idl);
this._events = new EventManager(this._programId, provider, this._coder);
// Dynamic namespaces.
const [rpc, instruction, transaction, account, simulate, state,] = NamespaceFactory.build(idl, this._coder, programId, provider);
const [rpc, instruction, transaction, account, simulate, methods, state,] = NamespaceFactory.build(idl, this._coder, programId, provider);
this.rpc = rpc;

@@ -66,2 +66,3 @@ this.instruction = instruction;

this.simulate = simulate;
this.methods = methods;
this.state = state;

@@ -68,0 +69,0 @@ }

@@ -6,3 +6,3 @@ /// <reference types="node" />

import { Idl, IdlTypeDef } from "../../idl.js";
import Coder from "../../coder/index.js";
import { Coder } from "../../coder/index.js";
import { Address } from "../common.js";

@@ -9,0 +9,0 @@ import { AllAccountsMap, IdlTypes, TypeDef } from "./types.js";

@@ -1,8 +0,6 @@

import { Buffer } from "buffer";
import camelCase from "camelcase";
import EventEmitter from "eventemitter3";
import bs58 from "bs58";
import { SystemProgram, } from "@solana/web3.js";
import { getProvider } from "../../provider.js";
import Coder, { ACCOUNT_DISCRIMINATOR_SIZE, accountSize, AccountsCoder, } from "../../coder/index.js";
import { BorshCoder } from "../../coder/index.js";
import { translateAddress } from "../common.js";

@@ -24,9 +22,7 @@ import * as pubkeyUtil from "../../utils/pubkey.js";

constructor(idl, idlAccount, programId, provider, coder) {
var _a;
this._idlAccount = idlAccount;
this._programId = programId;
this._provider = provider !== null && provider !== void 0 ? provider : getProvider();
this._coder = coder !== null && coder !== void 0 ? coder : new Coder(idl);
this._size =
ACCOUNT_DISCRIMINATOR_SIZE + ((_a = accountSize(idl, idlAccount)) !== null && _a !== void 0 ? _a : 0);
this._coder = coder !== null && coder !== void 0 ? coder : new BorshCoder(idl);
this._size = this._coder.accounts.size(idlAccount);
}

@@ -67,7 +63,2 @@ /**

}
// Assert the account discriminator is correct.
const discriminator = AccountsCoder.accountDiscriminator(this._idlAccount.name);
if (discriminator.compare(accountInfo.data.slice(0, 8))) {
throw new Error("Invalid account discriminator");
}
return this._coder.accounts.decode(this._idlAccount.name, accountInfo.data);

@@ -95,3 +86,2 @@ }

const accounts = await rpcUtil.getMultipleAccounts(this._provider.connection, addresses.map((address) => translateAddress(address)), commitment);
const discriminator = AccountsCoder.accountDiscriminator(this._idlAccount.name);
// Decode accounts where discriminator is correct, null otherwise

@@ -102,5 +92,2 @@ return accounts.map((account) => {

}
if (discriminator.compare(account === null || account === void 0 ? void 0 : account.account.data.slice(0, 8))) {
return null;
}
return this._coder.accounts.decode(this._idlAccount.name, account === null || account === void 0 ? void 0 : account.account.data);

@@ -124,3 +111,2 @@ });

async all(filters) {
const discriminator = AccountsCoder.accountDiscriminator(this._idlAccount.name);
let resp = await this._provider.connection.getProgramAccounts(this._programId, {

@@ -130,8 +116,3 @@ commitment: this._provider.connection.commitment,

{
memcmp: {
offset: 0,
bytes: bs58.encode(filters instanceof Buffer
? Buffer.concat([discriminator, filters])
: discriminator),
},
memcmp: this.coder.accounts.memcmp(this._idlAccount.name, filters instanceof Buffer ? filters : undefined),
},

@@ -138,0 +119,0 @@ ...(Array.isArray(filters) ? filters : []),

import { PublicKey } from "@solana/web3.js";
import Coder from "../../coder/index.js";
import { Coder } from "../../coder/index.js";
import Provider from "../../provider.js";

@@ -11,2 +11,3 @@ import { Idl } from "../../idl.js";

import { SimulateNamespace } from "./simulate.js";
import { MethodsNamespace } from "./methods";
export { StateClient } from "./state.js";

@@ -19,2 +20,3 @@ export { InstructionNamespace, InstructionFn } from "./instruction.js";

export { IdlAccounts, IdlTypes } from "./types.js";
export { MethodsBuilderFactory, MethodsNamespace } from "./methods";
export default class NamespaceFactory {

@@ -30,2 +32,3 @@ /**

SimulateNamespace<IDL>,
MethodsNamespace<IDL>,
StateClient<IDL> | undefined

@@ -32,0 +35,0 @@ ];

@@ -9,5 +9,7 @@ import camelCase from "camelcase";

import { parseIdlErrors } from "../common.js";
import { MethodsBuilderFactory } from "./methods";
// Re-exports.
export { StateClient } from "./state.js";
export { AccountClient } from "./account.js";
export { MethodsBuilderFactory } from "./methods";
export default class NamespaceFactory {

@@ -22,3 +24,7 @@ /**

const simulate = {};
const methods = {};
const idlErrors = parseIdlErrors(idl);
const account = idl.accounts
? AccountFactory.build(idl, coder, programId, provider)
: {};
const state = StateFactory.build(idl, coder, programId, provider);

@@ -30,2 +36,3 @@ idl.instructions.forEach((idlIx) => {

const simulateItem = SimulateFactory.build(idlIx, txItem, idlErrors, provider, coder, programId, idl);
const methodItem = MethodsBuilderFactory.build(provider, programId, idlIx, ixItem, txItem, rpcItem, simulateItem, account);
const name = camelCase(idlIx.name);

@@ -36,6 +43,4 @@ instruction[name] = ixItem;

simulate[name] = simulateItem;
methods[name] = methodItem;
});
const account = idl.accounts
? AccountFactory.build(idl, coder, programId, provider)
: {};
return [

@@ -47,2 +52,3 @@ rpc,

simulate,
methods,
state,

@@ -49,0 +55,0 @@ ];

@@ -5,3 +5,3 @@ import { PublicKey } from "@solana/web3.js";

import { Event } from "../event.js";
import Coder from "../../coder/index.js";
import { Coder } from "../../coder/index.js";
import { Idl, IdlEvent } from "../../idl.js";

@@ -55,3 +55,3 @@ import { AllInstructions, IdlTypes, InstructionContextFn, MakeInstructionsNamespace } from "./types";

export declare type SimulateFn<IDL extends Idl = Idl, I extends AllInstructions<IDL> = AllInstructions<IDL>> = InstructionContextFn<IDL, I, Promise<SimulateResponse<NullableEvents<IDL>, IdlTypes<IDL>>>>;
declare type SimulateResponse<E extends IdlEvent, Defined> = {
export declare type SimulateResponse<E extends IdlEvent, Defined> = {
events: readonly Event<E, Defined>[];

@@ -58,0 +58,0 @@ raw: readonly string[];

@@ -5,3 +5,3 @@ import EventEmitter from "eventemitter3";

import { Idl, IdlInstruction, IdlTypeDef } from "../../idl.js";
import Coder from "../../coder/index.js";
import { Coder } from "../../coder/index.js";
import { RpcNamespace, InstructionNamespace, TransactionNamespace } from "./index.js";

@@ -8,0 +8,0 @@ import { IdlTypes, TypeDef } from "./types.js";

@@ -5,3 +5,3 @@ import EventEmitter from "eventemitter3";

import { getProvider } from "../../provider.js";
import Coder, { stateDiscriminator } from "../../coder/index.js";
import { BorshCoder, stateDiscriminator } from "../../coder/index.js";
import { validateAccounts, parseIdlErrors } from "../common.js";

@@ -34,3 +34,3 @@ import { findProgramAddressSync, createWithSeedSync, } from "../../utils/pubkey.js";

*/
coder = new Coder(idl)) {
coder = new BorshCoder(idl)) {
this.provider = provider;

@@ -37,0 +37,0 @@ this.coder = coder;

@@ -45,2 +45,5 @@ import { PublicKey } from "@solana/web3.js";

};
export declare type MakeMethodsNamespace<IDL extends Idl, I extends IdlInstruction> = {
[M in keyof InstructionMap<I>]: MethodsFn<IDL, InstructionMap<I>[M], any>;
};
export declare type InstructionContextFn<IDL extends Idl, I extends AllInstructions<IDL>, Ret> = (...args: InstructionContextFnArgs<IDL, I>) => Ret;

@@ -51,5 +54,7 @@ export declare type InstructionContextFnArgs<IDL extends Idl, I extends IDL["instructions"][number]> = [

];
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;
} & {

@@ -67,2 +72,4 @@ [K in "u8" | "i8" | "u16" | "i16" | "u32" | "i32"]: number;

} ? Defined[T["option"]["defined"]] | null : T extends {
option: keyof TypeMap;
} ? TypeMap[T["option"]] : T extends {
vec: keyof TypeMap;

@@ -69,0 +76,0 @@ } ? TypeMap[T["vec"]][] : T extends {

@@ -1,2 +0,2 @@

const _AVAILABLE_FEATURES = new Set(["anchor-deprecated-state"]);
const _AVAILABLE_FEATURES = new Set(["anchor-deprecated-state", "debug-logs"]);
const _FEATURES = new Map();

@@ -3,0 +3,0 @@ export function set(key) {

@@ -7,2 +7,3 @@ export * as sha256 from "./sha256.js";

export * as features from "./features.js";
export * as registry from "./registry.js";
//# sourceMappingURL=index.d.ts.map

@@ -7,2 +7,3 @@ export * as sha256 from "./sha256.js";

export * as features from "./features.js";
export * as registry from "./registry.js";
//# sourceMappingURL=index.js.map
import { PublicKey } from "@solana/web3.js";
export declare const TOKEN_PROGRAM_ID: PublicKey;
export declare const ASSOCIATED_PROGRAM_ID: PublicKey;
export declare function associatedAddress({ mint, owner, }: {

@@ -3,0 +5,0 @@ mint: PublicKey;

import { PublicKey } from "@solana/web3.js";
const TOKEN_PROGRAM_ID = new PublicKey("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA");
const ASSOCIATED_PROGRAM_ID = new PublicKey("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL");
export const TOKEN_PROGRAM_ID = new PublicKey("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA");
export const ASSOCIATED_PROGRAM_ID = new PublicKey("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL");
export async function associatedAddress({ mint, owner, }) {

@@ -5,0 +5,0 @@ return (await PublicKey.findProgramAddress([owner.toBuffer(), TOKEN_PROGRAM_ID.toBuffer(), mint.toBuffer()], ASSOCIATED_PROGRAM_ID))[0];

{
"name": "@project-serum/anchor",
"version": "0.20.1",
"version": "0.21.0",
"description": "Anchor client",

@@ -36,3 +36,3 @@ "module": "./dist/esm/index.js",

"dependencies": {
"@project-serum/borsh": "^0.2.2",
"@project-serum/borsh": "^0.2.4",
"@solana/web3.js": "^1.17.0",

@@ -44,2 +44,3 @@ "base64-js": "^1.5.1",

"camelcase": "^5.3.1",
"cross-fetch": "^3.1.5",
"crypto-hash": "^1.3.0",

@@ -46,0 +47,0 @@ "eventemitter3": "^4.0.7",

@@ -1,4 +0,1 @@

import { Buffer } from "buffer";
import { snakeCase } from "snake-case";
import { sha256 } from "js-sha256";
import { Idl, IdlField, IdlTypeDef, IdlEnumVariant, IdlType } from "../idl.js";

@@ -73,2 +70,5 @@ import { IdlError } from "../error.js";

}
if ("coption" in ty) {
return 4 + typeSize(idl, ty.coption);
}
if ("defined" in ty) {

@@ -91,9 +91,1 @@ const filtered = idl.types?.filter((t) => t.name === ty.defined) ?? [];

}
// Not technically sighash, since we don't include the arguments, as Rust
// doesn't allow function overloading.
export function sighash(nameSpace: string, ixName: string): Buffer {
let name = snakeCase(ixName);
let preimage = `${nameSpace}:${name}`;
return Buffer.from(sha256.digest(preimage)).slice(0, 8);
}

@@ -1,13 +0,6 @@

import { Idl } from "../idl.js";
import { InstructionCoder } from "./instruction.js";
import { AccountsCoder } from "./accounts.js";
import { EventCoder } from "./event.js";
import { StateCoder } from "./state.js";
import { sighash } from "./common.js";
import { IdlEvent, IdlTypeDef } from "../idl.js";
import { Event } from "../program/event.js";
export { accountSize } from "./common.js";
export { InstructionCoder } from "./instruction.js";
export { AccountsCoder, ACCOUNT_DISCRIMINATOR_SIZE } from "./accounts.js";
export { EventCoder, eventDiscriminator } from "./event.js";
export { StateCoder, stateDiscriminator } from "./state.js";
export * from "./borsh/index.js";
export * from "./spl-token/index.js";

@@ -17,3 +10,3 @@ /**

*/
export default class Coder<A extends string = string> {
export interface Coder {
/**

@@ -27,3 +20,3 @@ * Instruction coder.

*/
readonly accounts: AccountsCoder<A>;
readonly accounts: AccountsCoder;

@@ -39,15 +32,26 @@ /**

readonly events: EventCoder;
}
constructor(idl: Idl) {
this.instruction = new InstructionCoder(idl);
this.accounts = new AccountsCoder(idl);
this.events = new EventCoder(idl);
if (idl.state) {
this.state = new StateCoder(idl);
}
}
export interface StateCoder {
encode<T = any>(name: string, account: T): Promise<Buffer>;
decode<T = any>(ix: Buffer): T;
}
public sighash(nameSpace: string, ixName: string): Buffer {
return sighash(nameSpace, ixName);
}
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;
}

@@ -53,4 +53,12 @@ import { Buffer } from "buffer";

isSigner: boolean;
pda?: IdlPda;
};
export type IdlPda = {
seeds: IdlSeed[];
programId?: IdlSeed;
};
export type IdlSeed = any; // TODO
// A nested/recursive version of IdlAccount.

@@ -103,2 +111,3 @@ export type IdlAccounts = {

| IdlTypeOption
| IdlTypeCOption
| IdlTypeVec

@@ -116,2 +125,6 @@ | IdlTypeArray;

export type IdlTypeCOption = {
coption: IdlType;
};
export type IdlTypeVec = {

@@ -118,0 +131,0 @@ vec: IdlType;

@@ -0,1 +1,2 @@

import NodeWallet from "./nodewallet";
import { isBrowser } from "./utils/common.js";

@@ -6,19 +7,12 @@

export { default as Provider, getProvider, setProvider } from "./provider.js";
export {
default as Coder,
InstructionCoder,
EventCoder,
StateCoder,
AccountsCoder,
} from "./coder/index.js";
export * from "./error.js";
export { Instruction } from "./coder/instruction.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 declare const workspace: any;
export declare const Wallet: import("./nodewallet").default;
export declare class Wallet extends NodeWallet {}

@@ -25,0 +19,0 @@ if (!isBrowser) {

import { PublicKey } from "@solana/web3.js";
import * as assert from "assert";
import { IdlEvent, IdlEventField } from "../idl.js";
import Coder from "../coder/index.js";
import { Coder } from "../coder/index.js";
import { DecodeType } from "./namespace/types.js";

@@ -98,3 +98,2 @@ import Provider from "../provider.js";

if (logs.err) {
console.error(logs);
return;

@@ -101,0 +100,0 @@ }

@@ -5,3 +5,3 @@ import { inflate } from "pako";

import { Idl, idlAddress, decodeIdlAccount } from "../idl.js";
import Coder from "../coder/index.js";
import { Coder, BorshCoder } from "../coder/index.js";
import NamespaceFactory, {

@@ -14,2 +14,3 @@ RpcNamespace,

SimulateNamespace,
MethodsNamespace,
} from "./namespace/index.js";

@@ -212,2 +213,8 @@ import { utf8 } from "../utils/bytes/index.js";

/**
* 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>;
/**
* Address of the program.

@@ -255,3 +262,8 @@ */

*/
public constructor(idl: IDL, programId: Address, provider?: Provider) {
public constructor(
idl: IDL,
programId: Address,
provider?: Provider,
coder?: Coder
) {
programId = translateAddress(programId);

@@ -267,3 +279,3 @@

this._programId = programId;
this._coder = new Coder(idl);
this._coder = coder ?? new BorshCoder(idl);
this._events = new EventManager(this._programId, provider, this._coder);

@@ -278,2 +290,3 @@

simulate,
methods,
state,

@@ -286,2 +299,3 @@ ] = NamespaceFactory.build(idl, this._coder, programId, provider);

this.simulate = simulate;
this.methods = methods;
this.state = state;

@@ -288,0 +302,0 @@ }

@@ -1,5 +0,3 @@

import { Buffer } from "buffer";
import camelCase from "camelcase";
import EventEmitter from "eventemitter3";
import bs58 from "bs58";
import {

@@ -16,7 +14,3 @@ Signer,

import { Idl, IdlTypeDef } from "../../idl.js";
import Coder, {
ACCOUNT_DISCRIMINATOR_SIZE,
accountSize,
AccountsCoder,
} from "../../coder/index.js";
import { Coder, BorshCoder } from "../../coder/index.js";
import { Subscription, Address, translateAddress } from "../common.js";

@@ -130,5 +124,4 @@ import { AllAccountsMap, IdlTypes, TypeDef } from "./types.js";

this._provider = provider ?? getProvider();
this._coder = coder ?? new Coder(idl);
this._size =
ACCOUNT_DISCRIMINATOR_SIZE + (accountSize(idl, idlAccount) ?? 0);
this._coder = coder ?? new BorshCoder(idl);
this._size = this._coder.accounts.size(idlAccount);
}

@@ -149,11 +142,2 @@

}
// Assert the account discriminator is correct.
const discriminator = AccountsCoder.accountDiscriminator(
this._idlAccount.name
);
if (discriminator.compare(accountInfo.data.slice(0, 8))) {
throw new Error("Invalid account discriminator");
}
return this._coder.accounts.decode<T>(

@@ -194,5 +178,2 @@ this._idlAccount.name,

const discriminator = AccountsCoder.accountDiscriminator(
this._idlAccount.name
);
// Decode accounts where discriminator is correct, null otherwise

@@ -203,5 +184,2 @@ return accounts.map((account) => {

}
if (discriminator.compare(account?.account.data.slice(0, 8))) {
return null;
}
return this._coder.accounts.decode(

@@ -231,6 +209,2 @@ this._idlAccount.name,

): Promise<ProgramAccount<T>[]> {
const discriminator = AccountsCoder.accountDiscriminator(
this._idlAccount.name
);
let resp = await this._provider.connection.getProgramAccounts(

@@ -242,10 +216,6 @@ this._programId,

{
memcmp: {
offset: 0,
bytes: bs58.encode(
filters instanceof Buffer
? Buffer.concat([discriminator, filters])
: discriminator
),
},
memcmp: this.coder.accounts.memcmp(
this._idlAccount.name,
filters instanceof Buffer ? filters : undefined
),
},

@@ -252,0 +222,0 @@ ...(Array.isArray(filters) ? filters : []),

import camelCase from "camelcase";
import { PublicKey } from "@solana/web3.js";
import Coder from "../../coder/index.js";
import { Coder } from "../../coder/index.js";
import Provider from "../../provider.js";
import { Idl, IdlInstruction } from "../../idl.js";
import { Idl } from "../../idl.js";
import StateFactory, { StateClient } from "./state.js";

@@ -14,2 +14,3 @@ import InstructionFactory, { InstructionNamespace } from "./instruction.js";

import { AllInstructions } from "./types.js";
import { MethodsBuilderFactory, MethodsNamespace } from "./methods";

@@ -24,2 +25,3 @@ // Re-exports.

export { IdlAccounts, IdlTypes } from "./types.js";
export { MethodsBuilderFactory, MethodsNamespace } from "./methods";

@@ -41,2 +43,3 @@ export default class NamespaceFactory {

SimulateNamespace<IDL>,
MethodsNamespace<IDL>,
StateClient<IDL> | undefined

@@ -48,5 +51,10 @@ ] {

const simulate: SimulateNamespace = {};
const methods: MethodsNamespace = {};
const idlErrors = parseIdlErrors(idl);
const account: AccountNamespace<IDL> = idl.accounts
? AccountFactory.build(idl, coder, programId, provider)
: ({} as AccountNamespace<IDL>);
const state = StateFactory.build(idl, coder, programId, provider);

@@ -71,2 +79,12 @@

);
const methodItem = MethodsBuilderFactory.build(
provider,
programId,
idlIx,
ixItem,
txItem,
rpcItem,
simulateItem,
account
);

@@ -79,8 +97,5 @@ const name = camelCase(idlIx.name);

simulate[name] = simulateItem;
methods[name] = methodItem;
});
const account: AccountNamespace<IDL> = idl.accounts
? AccountFactory.build(idl, coder, programId, provider)
: ({} as AccountNamespace<IDL>);
return [

@@ -92,2 +107,3 @@ rpc as RpcNamespace<IDL>,

simulate as SimulateNamespace<IDL>,
methods as MethodsNamespace<IDL>,
state,

@@ -94,0 +110,0 @@ ];

@@ -10,3 +10,3 @@ import {

import { EventParser, Event } from "../event.js";
import Coder from "../../coder/index.js";
import { Coder } from "../../coder/index.js";
import { Idl, IdlEvent } from "../../idl.js";

@@ -138,5 +138,5 @@ import { ProgramError } from "../../error.js";

type SimulateResponse<E extends IdlEvent, Defined> = {
export type SimulateResponse<E extends IdlEvent, Defined> = {
events: readonly Event<E, Defined>[];
raw: readonly string[];
};

@@ -11,3 +11,3 @@ import EventEmitter from "eventemitter3";

import { Idl, IdlInstruction, IdlStateMethod, IdlTypeDef } from "../../idl.js";
import Coder, { stateDiscriminator } from "../../coder/index.js";
import { BorshCoder, Coder, stateDiscriminator } from "../../coder/index.js";
import {

@@ -91,3 +91,3 @@ RpcNamespace,

*/
public readonly coder: Coder = new Coder(idl)
public readonly coder: Coder = new BorshCoder(idl)
) {

@@ -94,0 +94,0 @@ this._idl = idl;

@@ -68,2 +68,6 @@ import { PublicKey } from "@solana/web3.js";

export type MakeMethodsNamespace<IDL extends Idl, I extends IdlInstruction> = {
[M in keyof InstructionMap<I>]: MethodsFn<IDL, InstructionMap<I>[M], any>;
};
export type InstructionContextFn<

@@ -83,5 +87,12 @@ IDL extends Idl,

export type MethodsFn<
IDL extends Idl,
I extends IDL["instructions"][number],
Ret
> = (...args: ArgsTuple<I["args"], IdlTypes<IDL>>) => Ret;
type TypeMap = {
publicKey: PublicKey;
bool: boolean;
string: string;
} & {

@@ -100,2 +111,4 @@ [K in "u8" | "i8" | "u16" | "i16" | "u32" | "i32"]: number;

? Defined[T["option"]["defined"]] | null
: T extends { option: keyof TypeMap }
? TypeMap[T["option"]]
: T extends { vec: keyof TypeMap }

@@ -102,0 +115,0 @@ ? TypeMap[T["vec"]][]

@@ -1,2 +0,2 @@

const _AVAILABLE_FEATURES = new Set(["anchor-deprecated-state"]);
const _AVAILABLE_FEATURES = new Set(["anchor-deprecated-state", "debug-logs"]);

@@ -3,0 +3,0 @@ const _FEATURES = new Map();

@@ -7,1 +7,2 @@ export * as sha256 from "./sha256.js";

export * as features from "./features.js";
export * as registry from "./registry.js";
import { PublicKey } from "@solana/web3.js";
const TOKEN_PROGRAM_ID = new PublicKey(
export const TOKEN_PROGRAM_ID = new PublicKey(
"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"
);
const ASSOCIATED_PROGRAM_ID = new PublicKey(
export const ASSOCIATED_PROGRAM_ID = new PublicKey(
"ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"

@@ -8,0 +8,0 @@ );

import { PublicKey } from "@solana/web3.js";
import { EventParser } from "../src/program/event";
import { Coder } from "../src";
import { BorshCoder } from "../src";

@@ -25,3 +25,3 @@ describe("Events", () => {

};
const coder = new Coder(idl);
const coder = new BorshCoder(idl);
const programId = PublicKey.default;

@@ -28,0 +28,0 @@ const eventParser = new EventParser(programId, coder);

import TransactionFactory from "../src/program/namespace/transaction";
import InstructionFactory from "../src/program/namespace/instruction";
import { Coder } from "../src";
import { BorshCoder } from "../src";
import { PublicKey, TransactionInstruction } from "@solana/web3.js";

@@ -30,3 +30,3 @@

it("should add pre instructions before method ix", async () => {
const coder = new Coder(idl);
const coder = new BorshCoder(idl);
const programId = PublicKey.default;

@@ -45,3 +45,3 @@ const ixItem = InstructionFactory.build(

it("should add post instructions after method ix", async () => {
const coder = new Coder(idl);
const coder = new BorshCoder(idl);
const programId = PublicKey.default;

@@ -60,3 +60,3 @@ const ixItem = InstructionFactory.build(

it("should throw error if both preInstructions and instructions are used", async () => {
const coder = new Coder(idl);
const coder = new BorshCoder(idl);
const programId = PublicKey.default;

@@ -63,0 +63,0 @@ const ixItem = InstructionFactory.build(

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc