diff --git a/clients/js/src/generated/accounts/buffer.ts b/clients/js/src/generated/accounts/buffer.ts
new file mode 100644
index 0000000..0d67973
--- /dev/null
+++ b/clients/js/src/generated/accounts/buffer.ts
@@ -0,0 +1,173 @@
+/**
+ * This code was AUTOGENERATED using the codama library.
+ * Please DO NOT EDIT THIS FILE, instead use visitors
+ * to add features, then rerun codama to update it.
+ *
+ * @see https://github.com/codama-idl/codama
+ */
+
+import {
+ assertAccountExists,
+ assertAccountsExist,
+ combineCodec,
+ decodeAccount,
+ fetchEncodedAccount,
+ fetchEncodedAccounts,
+ getAddressDecoder,
+ getAddressEncoder,
+ getBooleanDecoder,
+ getBooleanEncoder,
+ getBytesDecoder,
+ getBytesEncoder,
+ getOptionDecoder,
+ getOptionEncoder,
+ getStructDecoder,
+ getStructEncoder,
+ getU8Decoder,
+ getU8Encoder,
+ padRightDecoder,
+ padRightEncoder,
+ transformEncoder,
+ type Account,
+ type Address,
+ type Codec,
+ type Decoder,
+ type EncodedAccount,
+ type Encoder,
+ type FetchAccountConfig,
+ type FetchAccountsConfig,
+ type MaybeAccount,
+ type MaybeEncodedAccount,
+ type Option,
+ type OptionOrNullable,
+ type ReadonlyUint8Array,
+} from '@solana/web3.js';
+import {
+ getSeedDecoder,
+ getSeedEncoder,
+ type Seed,
+ type SeedArgs,
+} from '../types';
+
+export type Buffer = {
+ discriminator: number;
+ program: Option
;
+ authority: Option;
+ canonical: boolean;
+ seed: Seed;
+ data: ReadonlyUint8Array;
+};
+
+export type BufferArgs = {
+ program: OptionOrNullable;
+ authority: OptionOrNullable;
+ canonical: boolean;
+ seed: SeedArgs;
+ data: ReadonlyUint8Array;
+};
+
+export function getBufferEncoder(): Encoder {
+ return transformEncoder(
+ getStructEncoder([
+ ['discriminator', getU8Encoder()],
+ [
+ 'program',
+ getOptionEncoder(getAddressEncoder(), {
+ prefix: null,
+ noneValue: 'zeroes',
+ }),
+ ],
+ [
+ 'authority',
+ getOptionEncoder(getAddressEncoder(), {
+ prefix: null,
+ noneValue: 'zeroes',
+ }),
+ ],
+ ['canonical', getBooleanEncoder()],
+ ['seed', padRightEncoder(getSeedEncoder(), 14)],
+ ['data', getBytesEncoder()],
+ ]),
+ (value) => ({ ...value, discriminator: 1 })
+ );
+}
+
+export function getBufferDecoder(): Decoder {
+ return getStructDecoder([
+ ['discriminator', getU8Decoder()],
+ [
+ 'program',
+ getOptionDecoder(getAddressDecoder(), {
+ prefix: null,
+ noneValue: 'zeroes',
+ }),
+ ],
+ [
+ 'authority',
+ getOptionDecoder(getAddressDecoder(), {
+ prefix: null,
+ noneValue: 'zeroes',
+ }),
+ ],
+ ['canonical', getBooleanDecoder()],
+ ['seed', padRightDecoder(getSeedDecoder(), 14)],
+ ['data', getBytesDecoder()],
+ ]);
+}
+
+export function getBufferCodec(): Codec {
+ return combineCodec(getBufferEncoder(), getBufferDecoder());
+}
+
+export function decodeBuffer(
+ encodedAccount: EncodedAccount
+): Account;
+export function decodeBuffer(
+ encodedAccount: MaybeEncodedAccount
+): MaybeAccount;
+export function decodeBuffer(
+ encodedAccount: EncodedAccount | MaybeEncodedAccount
+): Account | MaybeAccount {
+ return decodeAccount(
+ encodedAccount as MaybeEncodedAccount,
+ getBufferDecoder()
+ );
+}
+
+export async function fetchBuffer(
+ rpc: Parameters[0],
+ address: Address,
+ config?: FetchAccountConfig
+): Promise> {
+ const maybeAccount = await fetchMaybeBuffer(rpc, address, config);
+ assertAccountExists(maybeAccount);
+ return maybeAccount;
+}
+
+export async function fetchMaybeBuffer(
+ rpc: Parameters[0],
+ address: Address,
+ config?: FetchAccountConfig
+): Promise> {
+ const maybeAccount = await fetchEncodedAccount(rpc, address, config);
+ return decodeBuffer(maybeAccount);
+}
+
+export async function fetchAllBuffer(
+ rpc: Parameters[0],
+ addresses: Array,
+ config?: FetchAccountsConfig
+): Promise[]> {
+ const maybeAccounts = await fetchAllMaybeBuffer(rpc, addresses, config);
+ assertAccountsExist(maybeAccounts);
+ return maybeAccounts;
+}
+
+export async function fetchAllMaybeBuffer(
+ rpc: Parameters[0],
+ addresses: Array,
+ config?: FetchAccountsConfig
+): Promise[]> {
+ const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config);
+ return maybeAccounts.map((maybeAccount) => decodeBuffer(maybeAccount));
+}
diff --git a/clients/js/src/generated/accounts/index.ts b/clients/js/src/generated/accounts/index.ts
new file mode 100644
index 0000000..2d0538c
--- /dev/null
+++ b/clients/js/src/generated/accounts/index.ts
@@ -0,0 +1,10 @@
+/**
+ * This code was AUTOGENERATED using the codama library.
+ * Please DO NOT EDIT THIS FILE, instead use visitors
+ * to add features, then rerun codama to update it.
+ *
+ * @see https://github.com/codama-idl/codama
+ */
+
+export * from './buffer';
+export * from './metadata';
diff --git a/clients/js/src/generated/accounts/metadata.ts b/clients/js/src/generated/accounts/metadata.ts
new file mode 100644
index 0000000..6509201
--- /dev/null
+++ b/clients/js/src/generated/accounts/metadata.ts
@@ -0,0 +1,203 @@
+/**
+ * This code was AUTOGENERATED using the codama library.
+ * Please DO NOT EDIT THIS FILE, instead use visitors
+ * to add features, then rerun codama to update it.
+ *
+ * @see https://github.com/codama-idl/codama
+ */
+
+import {
+ assertAccountExists,
+ assertAccountsExist,
+ combineCodec,
+ decodeAccount,
+ fetchEncodedAccount,
+ fetchEncodedAccounts,
+ getAddressDecoder,
+ getAddressEncoder,
+ getBooleanDecoder,
+ getBooleanEncoder,
+ getBytesDecoder,
+ getBytesEncoder,
+ getOptionDecoder,
+ getOptionEncoder,
+ getStructDecoder,
+ getStructEncoder,
+ getU32Decoder,
+ getU32Encoder,
+ getU8Decoder,
+ getU8Encoder,
+ padRightDecoder,
+ padRightEncoder,
+ transformEncoder,
+ type Account,
+ type Address,
+ type Codec,
+ type Decoder,
+ type EncodedAccount,
+ type Encoder,
+ type FetchAccountConfig,
+ type FetchAccountsConfig,
+ type MaybeAccount,
+ type MaybeEncodedAccount,
+ type Option,
+ type OptionOrNullable,
+ type ReadonlyUint8Array,
+} from '@solana/web3.js';
+import {
+ getCompressionDecoder,
+ getCompressionEncoder,
+ getDataSourceDecoder,
+ getDataSourceEncoder,
+ getEncodingDecoder,
+ getEncodingEncoder,
+ getFormatDecoder,
+ getFormatEncoder,
+ getSeedDecoder,
+ getSeedEncoder,
+ type Compression,
+ type CompressionArgs,
+ type DataSource,
+ type DataSourceArgs,
+ type Encoding,
+ type EncodingArgs,
+ type Format,
+ type FormatArgs,
+ type Seed,
+ type SeedArgs,
+} from '../types';
+
+export type Metadata = {
+ discriminator: number;
+ program: Address;
+ authority: Option;
+ mutable: boolean;
+ canonical: boolean;
+ seed: Seed;
+ encoding: Encoding;
+ compression: Compression;
+ format: Format;
+ dataSource: DataSource;
+ dataLength: number;
+ data: ReadonlyUint8Array;
+};
+
+export type MetadataArgs = {
+ program: Address;
+ authority: OptionOrNullable;
+ mutable: boolean;
+ canonical: boolean;
+ seed: SeedArgs;
+ encoding: EncodingArgs;
+ compression: CompressionArgs;
+ format: FormatArgs;
+ dataSource: DataSourceArgs;
+ dataLength: number;
+ data: ReadonlyUint8Array;
+};
+
+export function getMetadataEncoder(): Encoder {
+ return transformEncoder(
+ getStructEncoder([
+ ['discriminator', getU8Encoder()],
+ ['program', getAddressEncoder()],
+ [
+ 'authority',
+ getOptionEncoder(getAddressEncoder(), {
+ prefix: null,
+ noneValue: 'zeroes',
+ }),
+ ],
+ ['mutable', getBooleanEncoder()],
+ ['canonical', getBooleanEncoder()],
+ ['seed', getSeedEncoder()],
+ ['encoding', getEncodingEncoder()],
+ ['compression', getCompressionEncoder()],
+ ['format', getFormatEncoder()],
+ ['dataSource', getDataSourceEncoder()],
+ ['dataLength', padRightEncoder(getU32Encoder(), 5)],
+ ['data', getBytesEncoder()],
+ ]),
+ (value) => ({ ...value, discriminator: 2 })
+ );
+}
+
+export function getMetadataDecoder(): Decoder {
+ return getStructDecoder([
+ ['discriminator', getU8Decoder()],
+ ['program', getAddressDecoder()],
+ [
+ 'authority',
+ getOptionDecoder(getAddressDecoder(), {
+ prefix: null,
+ noneValue: 'zeroes',
+ }),
+ ],
+ ['mutable', getBooleanDecoder()],
+ ['canonical', getBooleanDecoder()],
+ ['seed', getSeedDecoder()],
+ ['encoding', getEncodingDecoder()],
+ ['compression', getCompressionDecoder()],
+ ['format', getFormatDecoder()],
+ ['dataSource', getDataSourceDecoder()],
+ ['dataLength', padRightDecoder(getU32Decoder(), 5)],
+ ['data', getBytesDecoder()],
+ ]);
+}
+
+export function getMetadataCodec(): Codec {
+ return combineCodec(getMetadataEncoder(), getMetadataDecoder());
+}
+
+export function decodeMetadata(
+ encodedAccount: EncodedAccount
+): Account;
+export function decodeMetadata(
+ encodedAccount: MaybeEncodedAccount
+): MaybeAccount;
+export function decodeMetadata(
+ encodedAccount: EncodedAccount | MaybeEncodedAccount
+): Account | MaybeAccount {
+ return decodeAccount(
+ encodedAccount as MaybeEncodedAccount,
+ getMetadataDecoder()
+ );
+}
+
+export async function fetchMetadata(
+ rpc: Parameters[0],
+ address: Address,
+ config?: FetchAccountConfig
+): Promise> {
+ const maybeAccount = await fetchMaybeMetadata(rpc, address, config);
+ assertAccountExists(maybeAccount);
+ return maybeAccount;
+}
+
+export async function fetchMaybeMetadata(
+ rpc: Parameters[0],
+ address: Address,
+ config?: FetchAccountConfig
+): Promise> {
+ const maybeAccount = await fetchEncodedAccount(rpc, address, config);
+ return decodeMetadata(maybeAccount);
+}
+
+export async function fetchAllMetadata(
+ rpc: Parameters[0],
+ addresses: Array,
+ config?: FetchAccountsConfig
+): Promise[]> {
+ const maybeAccounts = await fetchAllMaybeMetadata(rpc, addresses, config);
+ assertAccountsExist(maybeAccounts);
+ return maybeAccounts;
+}
+
+export async function fetchAllMaybeMetadata(
+ rpc: Parameters[0],
+ addresses: Array,
+ config?: FetchAccountsConfig
+): Promise[]> {
+ const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config);
+ return maybeAccounts.map((maybeAccount) => decodeMetadata(maybeAccount));
+}
diff --git a/clients/js/src/generated/index.ts b/clients/js/src/generated/index.ts
new file mode 100644
index 0000000..5fd6de6
--- /dev/null
+++ b/clients/js/src/generated/index.ts
@@ -0,0 +1,12 @@
+/**
+ * This code was AUTOGENERATED using the codama library.
+ * Please DO NOT EDIT THIS FILE, instead use visitors
+ * to add features, then rerun codama to update it.
+ *
+ * @see https://github.com/codama-idl/codama
+ */
+
+export * from './accounts';
+export * from './instructions';
+export * from './programs';
+export * from './types';
diff --git a/clients/js/src/generated/instructions/index.ts b/clients/js/src/generated/instructions/index.ts
new file mode 100644
index 0000000..d2f91b1
--- /dev/null
+++ b/clients/js/src/generated/instructions/index.ts
@@ -0,0 +1,9 @@
+/**
+ * This code was AUTOGENERATED using the codama library.
+ * Please DO NOT EDIT THIS FILE, instead use visitors
+ * to add features, then rerun codama to update it.
+ *
+ * @see https://github.com/codama-idl/codama
+ */
+
+export * from './initialize';
diff --git a/clients/js/src/generated/instructions/initialize.ts b/clients/js/src/generated/instructions/initialize.ts
new file mode 100644
index 0000000..07a2750
--- /dev/null
+++ b/clients/js/src/generated/instructions/initialize.ts
@@ -0,0 +1,294 @@
+/**
+ * This code was AUTOGENERATED using the codama library.
+ * Please DO NOT EDIT THIS FILE, instead use visitors
+ * to add features, then rerun codama to update it.
+ *
+ * @see https://github.com/codama-idl/codama
+ */
+
+import {
+ combineCodec,
+ getBytesDecoder,
+ getBytesEncoder,
+ getOptionDecoder,
+ getOptionEncoder,
+ getStructDecoder,
+ getStructEncoder,
+ getU8Decoder,
+ getU8Encoder,
+ transformEncoder,
+ type Address,
+ type Codec,
+ type Decoder,
+ type Encoder,
+ type IAccountMeta,
+ type IInstruction,
+ type IInstructionWithAccounts,
+ type IInstructionWithData,
+ type Option,
+ type OptionOrNullable,
+ type ReadonlyAccount,
+ type ReadonlyUint8Array,
+} from '@solana/web3.js';
+import { PROGRAM_METADATA_PROGRAM_ADDRESS } from '../programs';
+import { getAccountMetaFactory, type ResolvedAccount } from '../shared';
+import {
+ getCompressionDecoder,
+ getCompressionEncoder,
+ getDataSourceDecoder,
+ getDataSourceEncoder,
+ getEncodingDecoder,
+ getEncodingEncoder,
+ getFormatDecoder,
+ getFormatEncoder,
+ getSeedDecoder,
+ getSeedEncoder,
+ type Compression,
+ type CompressionArgs,
+ type DataSource,
+ type DataSourceArgs,
+ type Encoding,
+ type EncodingArgs,
+ type Format,
+ type FormatArgs,
+ type Seed,
+ type SeedArgs,
+} from '../types';
+
+export const INITIALIZE_DISCRIMINATOR = 1;
+
+export function getInitializeDiscriminatorBytes() {
+ return getU8Encoder().encode(INITIALIZE_DISCRIMINATOR);
+}
+
+export type InitializeInstruction<
+ TProgram extends string = typeof PROGRAM_METADATA_PROGRAM_ADDRESS,
+ TAccountMetadata extends string | IAccountMeta = string,
+ TAccountAuthority extends string | IAccountMeta = string,
+ TAccountProgram extends string | IAccountMeta = string,
+ TAccountProgramData extends string | IAccountMeta = string,
+ TAccountSystem extends string | IAccountMeta = string,
+ TRemainingAccounts extends readonly IAccountMeta[] = [],
+> = IInstruction &
+ IInstructionWithData &
+ IInstructionWithAccounts<
+ [
+ TAccountMetadata extends string
+ ? ReadonlyAccount
+ : TAccountMetadata,
+ TAccountAuthority extends string
+ ? ReadonlyAccount
+ : TAccountAuthority,
+ TAccountProgram extends string
+ ? ReadonlyAccount
+ : TAccountProgram,
+ TAccountProgramData extends string
+ ? ReadonlyAccount
+ : TAccountProgramData,
+ TAccountSystem extends string
+ ? ReadonlyAccount
+ : TAccountSystem,
+ ...TRemainingAccounts,
+ ]
+ >;
+
+export type InitializeInstructionData = {
+ discriminator: number;
+ seed: Seed;
+ encoding: Encoding;
+ compression: Compression;
+ format: Format;
+ dataSource: DataSource;
+ data: Option;
+};
+
+export type InitializeInstructionDataArgs = {
+ seed: SeedArgs;
+ encoding: EncodingArgs;
+ compression: CompressionArgs;
+ format: FormatArgs;
+ dataSource: DataSourceArgs;
+ data: OptionOrNullable;
+};
+
+export function getInitializeInstructionDataEncoder(): Encoder {
+ return transformEncoder(
+ getStructEncoder([
+ ['discriminator', getU8Encoder()],
+ ['seed', getSeedEncoder()],
+ ['encoding', getEncodingEncoder()],
+ ['compression', getCompressionEncoder()],
+ ['format', getFormatEncoder()],
+ ['dataSource', getDataSourceEncoder()],
+ ['data', getOptionEncoder(getBytesEncoder(), { prefix: null })],
+ ]),
+ (value) => ({ ...value, discriminator: INITIALIZE_DISCRIMINATOR })
+ );
+}
+
+export function getInitializeInstructionDataDecoder(): Decoder {
+ return getStructDecoder([
+ ['discriminator', getU8Decoder()],
+ ['seed', getSeedDecoder()],
+ ['encoding', getEncodingDecoder()],
+ ['compression', getCompressionDecoder()],
+ ['format', getFormatDecoder()],
+ ['dataSource', getDataSourceDecoder()],
+ ['data', getOptionDecoder(getBytesDecoder(), { prefix: null })],
+ ]);
+}
+
+export function getInitializeInstructionDataCodec(): Codec<
+ InitializeInstructionDataArgs,
+ InitializeInstructionData
+> {
+ return combineCodec(
+ getInitializeInstructionDataEncoder(),
+ getInitializeInstructionDataDecoder()
+ );
+}
+
+export type InitializeInput<
+ TAccountMetadata extends string = string,
+ TAccountAuthority extends string = string,
+ TAccountProgram extends string = string,
+ TAccountProgramData extends string = string,
+ TAccountSystem extends string = string,
+> = {
+ /** Metadata account the initialize. */
+ metadata: Address;
+ /** Authority (for canonical, must match program upgrade authority). */
+ authority: Address;
+ /** Program account. */
+ program: Address;
+ /** Program account. */
+ programData: Address;
+ /** System program. */
+ system: Address;
+ seed: InitializeInstructionDataArgs['seed'];
+ encoding: InitializeInstructionDataArgs['encoding'];
+ compression: InitializeInstructionDataArgs['compression'];
+ format: InitializeInstructionDataArgs['format'];
+ dataSource: InitializeInstructionDataArgs['dataSource'];
+ data: InitializeInstructionDataArgs['data'];
+};
+
+export function getInitializeInstruction<
+ TAccountMetadata extends string,
+ TAccountAuthority extends string,
+ TAccountProgram extends string,
+ TAccountProgramData extends string,
+ TAccountSystem extends string,
+ TProgramAddress extends Address = typeof PROGRAM_METADATA_PROGRAM_ADDRESS,
+>(
+ input: InitializeInput<
+ TAccountMetadata,
+ TAccountAuthority,
+ TAccountProgram,
+ TAccountProgramData,
+ TAccountSystem
+ >,
+ config?: { programAddress?: TProgramAddress }
+): InitializeInstruction<
+ TProgramAddress,
+ TAccountMetadata,
+ TAccountAuthority,
+ TAccountProgram,
+ TAccountProgramData,
+ TAccountSystem
+> {
+ // Program address.
+ const programAddress =
+ config?.programAddress ?? PROGRAM_METADATA_PROGRAM_ADDRESS;
+
+ // Original accounts.
+ const originalAccounts = {
+ metadata: { value: input.metadata ?? null, isWritable: false },
+ authority: { value: input.authority ?? null, isWritable: false },
+ program: { value: input.program ?? null, isWritable: false },
+ programData: { value: input.programData ?? null, isWritable: false },
+ system: { value: input.system ?? null, isWritable: false },
+ };
+ const accounts = originalAccounts as Record<
+ keyof typeof originalAccounts,
+ ResolvedAccount
+ >;
+
+ // Original args.
+ const args = { ...input };
+
+ const getAccountMeta = getAccountMetaFactory(programAddress, 'programId');
+ const instruction = {
+ accounts: [
+ getAccountMeta(accounts.metadata),
+ getAccountMeta(accounts.authority),
+ getAccountMeta(accounts.program),
+ getAccountMeta(accounts.programData),
+ getAccountMeta(accounts.system),
+ ],
+ programAddress,
+ data: getInitializeInstructionDataEncoder().encode(
+ args as InitializeInstructionDataArgs
+ ),
+ } as InitializeInstruction<
+ TProgramAddress,
+ TAccountMetadata,
+ TAccountAuthority,
+ TAccountProgram,
+ TAccountProgramData,
+ TAccountSystem
+ >;
+
+ return instruction;
+}
+
+export type ParsedInitializeInstruction<
+ TProgram extends string = typeof PROGRAM_METADATA_PROGRAM_ADDRESS,
+ TAccountMetas extends readonly IAccountMeta[] = readonly IAccountMeta[],
+> = {
+ programAddress: Address;
+ accounts: {
+ /** Metadata account the initialize. */
+ metadata: TAccountMetas[0];
+ /** Authority (for canonical, must match program upgrade authority). */
+ authority: TAccountMetas[1];
+ /** Program account. */
+ program: TAccountMetas[2];
+ /** Program account. */
+ programData: TAccountMetas[3];
+ /** System program. */
+ system: TAccountMetas[4];
+ };
+ data: InitializeInstructionData;
+};
+
+export function parseInitializeInstruction<
+ TProgram extends string,
+ TAccountMetas extends readonly IAccountMeta[],
+>(
+ instruction: IInstruction &
+ IInstructionWithAccounts &
+ IInstructionWithData
+): ParsedInitializeInstruction {
+ if (instruction.accounts.length < 5) {
+ // TODO: Coded error.
+ throw new Error('Not enough accounts');
+ }
+ let accountIndex = 0;
+ const getNextAccount = () => {
+ const accountMeta = instruction.accounts![accountIndex]!;
+ accountIndex += 1;
+ return accountMeta;
+ };
+ return {
+ programAddress: instruction.programAddress,
+ accounts: {
+ metadata: getNextAccount(),
+ authority: getNextAccount(),
+ program: getNextAccount(),
+ programData: getNextAccount(),
+ system: getNextAccount(),
+ },
+ data: getInitializeInstructionDataDecoder().decode(instruction.data),
+ };
+}
diff --git a/clients/js/src/generated/programs/index.ts b/clients/js/src/generated/programs/index.ts
new file mode 100644
index 0000000..ec512d0
--- /dev/null
+++ b/clients/js/src/generated/programs/index.ts
@@ -0,0 +1,9 @@
+/**
+ * This code was AUTOGENERATED using the codama library.
+ * Please DO NOT EDIT THIS FILE, instead use visitors
+ * to add features, then rerun codama to update it.
+ *
+ * @see https://github.com/codama-idl/codama
+ */
+
+export * from './programMetadata';
diff --git a/clients/js/src/generated/programs/programMetadata.ts b/clients/js/src/generated/programs/programMetadata.ts
new file mode 100644
index 0000000..fbfd76c
--- /dev/null
+++ b/clients/js/src/generated/programs/programMetadata.ts
@@ -0,0 +1,45 @@
+/**
+ * This code was AUTOGENERATED using the codama library.
+ * Please DO NOT EDIT THIS FILE, instead use visitors
+ * to add features, then rerun codama to update it.
+ *
+ * @see https://github.com/codama-idl/codama
+ */
+
+import {
+ containsBytes,
+ getU8Encoder,
+ type Address,
+ type ReadonlyUint8Array,
+} from '@solana/web3.js';
+import { type ParsedInitializeInstruction } from '../instructions';
+
+export const PROGRAM_METADATA_PROGRAM_ADDRESS =
+ '4FX3oHhpAkJcb2tFFrq9JBY8gc4RhCRM5g75VG9QHnj1' as Address<'4FX3oHhpAkJcb2tFFrq9JBY8gc4RhCRM5g75VG9QHnj1'>;
+
+export enum ProgramMetadataAccount {
+ Buffer,
+ Metadata,
+}
+
+export enum ProgramMetadataInstruction {
+ Initialize,
+}
+
+export function identifyProgramMetadataInstruction(
+ instruction: { data: ReadonlyUint8Array } | ReadonlyUint8Array
+): ProgramMetadataInstruction {
+ const data = 'data' in instruction ? instruction.data : instruction;
+ if (containsBytes(data, getU8Encoder().encode(1), 0)) {
+ return ProgramMetadataInstruction.Initialize;
+ }
+ throw new Error(
+ 'The provided instruction could not be identified as a programMetadata instruction.'
+ );
+}
+
+export type ParsedProgramMetadataInstruction<
+ TProgram extends string = '4FX3oHhpAkJcb2tFFrq9JBY8gc4RhCRM5g75VG9QHnj1',
+> = {
+ instructionType: ProgramMetadataInstruction.Initialize;
+} & ParsedInitializeInstruction;
diff --git a/clients/js/src/generated/shared/index.ts b/clients/js/src/generated/shared/index.ts
new file mode 100644
index 0000000..01a7d93
--- /dev/null
+++ b/clients/js/src/generated/shared/index.ts
@@ -0,0 +1,164 @@
+/**
+ * This code was AUTOGENERATED using the codama library.
+ * Please DO NOT EDIT THIS FILE, instead use visitors
+ * to add features, then rerun codama to update it.
+ *
+ * @see https://github.com/codama-idl/codama
+ */
+
+import {
+ AccountRole,
+ isProgramDerivedAddress,
+ isTransactionSigner as web3JsIsTransactionSigner,
+ type Address,
+ type IAccountMeta,
+ type IAccountSignerMeta,
+ type ProgramDerivedAddress,
+ type TransactionSigner,
+ upgradeRoleToSigner,
+} from '@solana/web3.js';
+
+/**
+ * Asserts that the given value is not null or undefined.
+ * @internal
+ */
+export function expectSome(value: T | null | undefined): T {
+ if (value == null) {
+ throw new Error('Expected a value but received null or undefined.');
+ }
+ return value;
+}
+
+/**
+ * Asserts that the given value is a PublicKey.
+ * @internal
+ */
+export function expectAddress(
+ value:
+ | Address
+ | ProgramDerivedAddress
+ | TransactionSigner
+ | null
+ | undefined
+): Address {
+ if (!value) {
+ throw new Error('Expected a Address.');
+ }
+ if (typeof value === 'object' && 'address' in value) {
+ return value.address;
+ }
+ if (Array.isArray(value)) {
+ return value[0];
+ }
+ return value as Address;
+}
+
+/**
+ * Asserts that the given value is a PDA.
+ * @internal
+ */
+export function expectProgramDerivedAddress(
+ value:
+ | Address
+ | ProgramDerivedAddress
+ | TransactionSigner
+ | null
+ | undefined
+): ProgramDerivedAddress {
+ if (!value || !Array.isArray(value) || !isProgramDerivedAddress(value)) {
+ throw new Error('Expected a ProgramDerivedAddress.');
+ }
+ return value;
+}
+
+/**
+ * Asserts that the given value is a TransactionSigner.
+ * @internal
+ */
+export function expectTransactionSigner(
+ value:
+ | Address
+ | ProgramDerivedAddress
+ | TransactionSigner
+ | null
+ | undefined
+): TransactionSigner {
+ if (!value || !isTransactionSigner(value)) {
+ throw new Error('Expected a TransactionSigner.');
+ }
+ return value;
+}
+
+/**
+ * Defines an instruction account to resolve.
+ * @internal
+ */
+export type ResolvedAccount<
+ T extends string = string,
+ U extends
+ | Address
+ | ProgramDerivedAddress
+ | TransactionSigner
+ | null =
+ | Address
+ | ProgramDerivedAddress
+ | TransactionSigner
+ | null,
+> = {
+ isWritable: boolean;
+ value: U;
+};
+
+/**
+ * Defines an instruction that stores additional bytes on-chain.
+ * @internal
+ */
+export type IInstructionWithByteDelta = {
+ byteDelta: number;
+};
+
+/**
+ * Get account metas and signers from resolved accounts.
+ * @internal
+ */
+export function getAccountMetaFactory(
+ programAddress: Address,
+ optionalAccountStrategy: 'omitted' | 'programId'
+) {
+ return (
+ account: ResolvedAccount
+ ): IAccountMeta | IAccountSignerMeta | undefined => {
+ if (!account.value) {
+ if (optionalAccountStrategy === 'omitted') return;
+ return Object.freeze({
+ address: programAddress,
+ role: AccountRole.READONLY,
+ });
+ }
+
+ const writableRole = account.isWritable
+ ? AccountRole.WRITABLE
+ : AccountRole.READONLY;
+ return Object.freeze({
+ address: expectAddress(account.value),
+ role: isTransactionSigner(account.value)
+ ? upgradeRoleToSigner(writableRole)
+ : writableRole,
+ ...(isTransactionSigner(account.value) ? { signer: account.value } : {}),
+ });
+ };
+}
+
+export function isTransactionSigner(
+ value:
+ | Address
+ | ProgramDerivedAddress
+ | TransactionSigner
+): value is TransactionSigner {
+ return (
+ !!value &&
+ typeof value === 'object' &&
+ 'address' in value &&
+ web3JsIsTransactionSigner(value)
+ );
+}
diff --git a/clients/js/src/generated/types/compression.ts b/clients/js/src/generated/types/compression.ts
new file mode 100644
index 0000000..44ee3e5
--- /dev/null
+++ b/clients/js/src/generated/types/compression.ts
@@ -0,0 +1,36 @@
+/**
+ * This code was AUTOGENERATED using the codama library.
+ * Please DO NOT EDIT THIS FILE, instead use visitors
+ * to add features, then rerun codama to update it.
+ *
+ * @see https://github.com/codama-idl/codama
+ */
+
+import {
+ combineCodec,
+ getEnumDecoder,
+ getEnumEncoder,
+ type Codec,
+ type Decoder,
+ type Encoder,
+} from '@solana/web3.js';
+
+export enum Compression {
+ None,
+ Gzip,
+ Zstd,
+}
+
+export type CompressionArgs = Compression;
+
+export function getCompressionEncoder(): Encoder {
+ return getEnumEncoder(Compression);
+}
+
+export function getCompressionDecoder(): Decoder {
+ return getEnumDecoder(Compression);
+}
+
+export function getCompressionCodec(): Codec {
+ return combineCodec(getCompressionEncoder(), getCompressionDecoder());
+}
diff --git a/clients/js/src/generated/types/dataSource.ts b/clients/js/src/generated/types/dataSource.ts
new file mode 100644
index 0000000..8a475c8
--- /dev/null
+++ b/clients/js/src/generated/types/dataSource.ts
@@ -0,0 +1,36 @@
+/**
+ * This code was AUTOGENERATED using the codama library.
+ * Please DO NOT EDIT THIS FILE, instead use visitors
+ * to add features, then rerun codama to update it.
+ *
+ * @see https://github.com/codama-idl/codama
+ */
+
+import {
+ combineCodec,
+ getEnumDecoder,
+ getEnumEncoder,
+ type Codec,
+ type Decoder,
+ type Encoder,
+} from '@solana/web3.js';
+
+export enum DataSource {
+ Direct,
+ Url,
+ External,
+}
+
+export type DataSourceArgs = DataSource;
+
+export function getDataSourceEncoder(): Encoder {
+ return getEnumEncoder(DataSource);
+}
+
+export function getDataSourceDecoder(): Decoder {
+ return getEnumDecoder(DataSource);
+}
+
+export function getDataSourceCodec(): Codec {
+ return combineCodec(getDataSourceEncoder(), getDataSourceDecoder());
+}
diff --git a/clients/js/src/generated/types/encoding.ts b/clients/js/src/generated/types/encoding.ts
new file mode 100644
index 0000000..29aaeb9
--- /dev/null
+++ b/clients/js/src/generated/types/encoding.ts
@@ -0,0 +1,37 @@
+/**
+ * This code was AUTOGENERATED using the codama library.
+ * Please DO NOT EDIT THIS FILE, instead use visitors
+ * to add features, then rerun codama to update it.
+ *
+ * @see https://github.com/codama-idl/codama
+ */
+
+import {
+ combineCodec,
+ getEnumDecoder,
+ getEnumEncoder,
+ type Codec,
+ type Decoder,
+ type Encoder,
+} from '@solana/web3.js';
+
+export enum Encoding {
+ None,
+ Utf8,
+ Base58,
+ Base64,
+}
+
+export type EncodingArgs = Encoding;
+
+export function getEncodingEncoder(): Encoder {
+ return getEnumEncoder(Encoding);
+}
+
+export function getEncodingDecoder(): Decoder {
+ return getEnumDecoder(Encoding);
+}
+
+export function getEncodingCodec(): Codec {
+ return combineCodec(getEncodingEncoder(), getEncodingDecoder());
+}
diff --git a/clients/js/src/generated/types/format.ts b/clients/js/src/generated/types/format.ts
new file mode 100644
index 0000000..ac78334
--- /dev/null
+++ b/clients/js/src/generated/types/format.ts
@@ -0,0 +1,37 @@
+/**
+ * This code was AUTOGENERATED using the codama library.
+ * Please DO NOT EDIT THIS FILE, instead use visitors
+ * to add features, then rerun codama to update it.
+ *
+ * @see https://github.com/codama-idl/codama
+ */
+
+import {
+ combineCodec,
+ getEnumDecoder,
+ getEnumEncoder,
+ type Codec,
+ type Decoder,
+ type Encoder,
+} from '@solana/web3.js';
+
+export enum Format {
+ None,
+ Json,
+ Yaml,
+ Toml,
+}
+
+export type FormatArgs = Format;
+
+export function getFormatEncoder(): Encoder {
+ return getEnumEncoder(Format);
+}
+
+export function getFormatDecoder(): Decoder {
+ return getEnumDecoder(Format);
+}
+
+export function getFormatCodec(): Codec {
+ return combineCodec(getFormatEncoder(), getFormatDecoder());
+}
diff --git a/clients/js/src/generated/types/index.ts b/clients/js/src/generated/types/index.ts
new file mode 100644
index 0000000..881940e
--- /dev/null
+++ b/clients/js/src/generated/types/index.ts
@@ -0,0 +1,13 @@
+/**
+ * This code was AUTOGENERATED using the codama library.
+ * Please DO NOT EDIT THIS FILE, instead use visitors
+ * to add features, then rerun codama to update it.
+ *
+ * @see https://github.com/codama-idl/codama
+ */
+
+export * from './compression';
+export * from './dataSource';
+export * from './encoding';
+export * from './format';
+export * from './seed';
diff --git a/clients/js/src/generated/types/seed.ts b/clients/js/src/generated/types/seed.ts
new file mode 100644
index 0000000..37115e1
--- /dev/null
+++ b/clients/js/src/generated/types/seed.ts
@@ -0,0 +1,34 @@
+/**
+ * This code was AUTOGENERATED using the codama library.
+ * Please DO NOT EDIT THIS FILE, instead use visitors
+ * to add features, then rerun codama to update it.
+ *
+ * @see https://github.com/codama-idl/codama
+ */
+
+import {
+ combineCodec,
+ fixDecoderSize,
+ fixEncoderSize,
+ getUtf8Decoder,
+ getUtf8Encoder,
+ type Codec,
+ type Decoder,
+ type Encoder,
+} from '@solana/web3.js';
+
+export type Seed = string;
+
+export type SeedArgs = Seed;
+
+export function getSeedEncoder(): Encoder {
+ return fixEncoderSize(getUtf8Encoder(), 16);
+}
+
+export function getSeedDecoder(): Decoder {
+ return fixDecoderSize(getUtf8Decoder(), 16);
+}
+
+export function getSeedCodec(): Codec {
+ return combineCodec(getSeedEncoder(), getSeedDecoder());
+}
diff --git a/package.json b/package.json
index 104d930..4029ec3 100644
--- a/package.json
+++ b/package.json
@@ -6,10 +6,9 @@
"programs:clean": "zx ./scripts/program/clean.mjs",
"programs:format": "zx ./scripts/program/format.mjs",
"programs:lint": "zx ./scripts/program/lint.mjs",
- "generate:idls": "zx ./scripts/generate-idls.mjs",
"solana:check": "zx ./scripts/check-solana-version.mjs",
"solana:link": "zx ./scripts/link-solana-version.mjs",
- "generate": "pnpm generate:idls && pnpm generate:clients",
+ "generate": "pnpm generate:clients",
"generate:clients": "zx ./scripts/generate-clients.mjs",
"validator:start": "zx ./scripts/start-validator.mjs",
"validator:restart": "pnpm validator:start --restart",
@@ -24,12 +23,10 @@
"clients:rust:test": "zx ./scripts/client/test-rust.mjs"
},
"devDependencies": {
- "@codama/nodes-from-anchor": "^1.0.0",
- "@codama/renderers-js": "^1.0.0",
+ "@codama/renderers-js": "^1.1.0",
"@codama/renderers-rust": "^1.0.0",
"@iarna/toml": "^2.2.5",
- "@metaplex-foundation/shank-js": "^0.1.7",
- "codama": "^1.0.0",
+ "codama": "^1.2.0",
"typescript": "^5.5.2",
"zx": "^7.2.3"
},
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 78173f1..310aee8 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -8,11 +8,8 @@ importers:
.:
devDependencies:
- '@codama/nodes-from-anchor':
- specifier: ^1.0.0
- version: 1.1.0
'@codama/renderers-js':
- specifier: ^1.0.0
+ specifier: ^1.1.0
version: 1.1.1(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.7.3)
'@codama/renderers-rust':
specifier: ^1.0.0
@@ -20,11 +17,8 @@ importers:
'@iarna/toml':
specifier: ^2.2.5
version: 2.2.5
- '@metaplex-foundation/shank-js':
- specifier: ^0.1.7
- version: 0.1.7
codama:
- specifier: ^1.0.0
+ specifier: ^1.2.0
version: 1.2.0
typescript:
specifier: ^5.5.2
@@ -69,12 +63,6 @@ packages:
'@iarna/toml@2.2.5':
resolution: {integrity: sha512-trnsAYxU3xnS1gPHPyU961coFyLkh4gAD/0zQ5mymY4yOZ+CYvsPqUbOFSw0aDM4y0tV7tiFxL/1XfXPNC6IPg==}
- '@metaplex-foundation/rustbin@0.3.5':
- resolution: {integrity: sha512-m0wkRBEQB/8krwMwKBvFugufZtYwMXiGHud2cTDAv+aGXK4M90y0Hx67/wpu+AqqoQfdV8VM9YezUOHKD+Z5kA==}
-
- '@metaplex-foundation/shank-js@0.1.7':
- resolution: {integrity: sha512-tSAipn8Ho1UxlMC3jwJ5Opl+Y3lRm60VTkgRDfvzydb57lXW5G+K5MrZhEmhrFUuRYziV+e34CTo+ybpMp1Eqg==}
-
'@noble/hashes@1.7.0':
resolution: {integrity: sha512-HXydb0DgzTpDPwbVeDGCG1gIu7X6+AuU6Zl6av/E/KG8LMsvPntvq+w17CHRpKBmN6Ybdrt1eP3k4cj8DJa78w==}
engines: {node: ^14.21.3 || >=16}
@@ -138,10 +126,6 @@ packages:
a-sync-waterfall@1.0.1:
resolution: {integrity: sha512-RYTOHHdWipFUliRFMCS4X2Yn2X8M87V/OpSqWzKKOGhzqyUxzyVmhHDH9sAvG+ZuQf/TAOFsLCpMw09I1ufUnA==}
- ansi-colors@4.1.3:
- resolution: {integrity: sha512-/6w/C21Pm1A7aZitlI5Ni/2J6FFQN8i1Cvz3kHABAAbw93v/NlvKdVOqz7CCWz/3iv/JplRSEEZ83XION15ovw==}
- engines: {node: '>=6'}
-
asap@2.0.6:
resolution: {integrity: sha512-BSHWgDSAiKs50o2Re8ppvp3seVHXSRM44cdSsT9FfNEUUZLOGWVCsiWaRPWM1Znn+mqZ1OfVZ3z3DWEzSp7hRA==}
@@ -180,15 +164,6 @@ packages:
resolution: {integrity: sha512-0R9ikRb668HB7QDxT1vkpuUBtqc53YyAwMwGeUFKRojY/NWKvdZ+9UYtRfGmhqNbRkTSVpMbmyhXipFFv2cb/A==}
engines: {node: '>= 12'}
- debug@4.4.0:
- resolution: {integrity: sha512-6WTZ/IxCY/T6BALoZHaE4ctp9xm+Z5kY/pzYaCHRFeyVhojxlrm+46y68HA6hr0TcwEssoxNiDEUJQjfPZ/RYA==}
- engines: {node: '>=6.0'}
- peerDependencies:
- supports-color: '*'
- peerDependenciesMeta:
- supports-color:
- optional: true
-
define-data-property@1.1.4:
resolution: {integrity: sha512-rBMvIzlpA8v6E+SJZoo++HAYqsLrkg7MSfIinMPFhmkorw7X+dOXVJQs+QT69zGkzMyfDnIMN2Wid1+NbL3T+A==}
engines: {node: '>= 0.4'}
@@ -339,9 +314,6 @@ packages:
minimist@1.2.8:
resolution: {integrity: sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==}
- ms@2.1.3:
- resolution: {integrity: sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==}
-
node-domexception@1.0.0:
resolution: {integrity: sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ==}
engines: {node: '>=10.5.0'}
@@ -395,11 +367,6 @@ packages:
run-parallel@1.2.0:
resolution: {integrity: sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==}
- semver@7.6.3:
- resolution: {integrity: sha512-oVekP1cKtI+CTDvHWYFUcMtsK/00wmAEfyqKfNdARm8u1wNVhSgaX7A8d4UuIlUI5e84iEwOhs7ZPYRmzU9U6A==}
- engines: {node: '>=10'}
- hasBin: true
-
set-function-length@1.2.2:
resolution: {integrity: sha512-pgRc4hJ4/sNjWCSS9AmnS40x3bNMDTknHgL5UaMBTMyJnU90EgWh1Rz+MC9eFu4BuN/UwZjKQuY/1v3rM7HMfg==}
engines: {node: '>= 0.4'}
@@ -414,9 +381,6 @@ packages:
stream-combiner@0.0.4:
resolution: {integrity: sha512-rT00SPnTVyRsaSz5zgSPma/aHSOic5U1prhYdRy5HS2kTZviFpmDgzilbtsJsxiroqACmayynDN/9VzIbX5DOw==}
- text-table@0.2.0:
- resolution: {integrity: sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw==}
-
through@2.3.8:
resolution: {integrity: sha512-w89qg7PI8wAdvX60bMDP+bFoD5Dvhm9oLheFp5O4a2QF0cSBGsBX4qZmadPMvVqlLJBBci+WqGGOAPvcDeNSVg==}
@@ -424,9 +388,6 @@ packages:
resolution: {integrity: sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==}
engines: {node: '>=8.0'}
- toml@3.0.0:
- resolution: {integrity: sha512-y/mWCZinnvxjTKYhJ+pYxwD0mRLVvOtdS2Awbgxln6iEnt4rk0yBxeSBHkGJcPucRiG0e55mwWp+g/05rsrd6w==}
-
typescript@5.7.3:
resolution: {integrity: sha512-84MVSjMEHP+FQRPy3pX9sTVV/INIex71s9TL2Gm5FG/WG1SqXeKyZ0k7/blY/4FdOzI12CBy1vGc4og/eus0fw==}
engines: {node: '>=14.17'}
@@ -538,23 +499,6 @@ snapshots:
'@iarna/toml@2.2.5': {}
- '@metaplex-foundation/rustbin@0.3.5':
- dependencies:
- debug: 4.4.0
- semver: 7.6.3
- text-table: 0.2.0
- toml: 3.0.0
- transitivePeerDependencies:
- - supports-color
-
- '@metaplex-foundation/shank-js@0.1.7':
- dependencies:
- '@metaplex-foundation/rustbin': 0.3.5
- ansi-colors: 4.1.3
- debug: 4.4.0
- transitivePeerDependencies:
- - supports-color
-
'@noble/hashes@1.7.0': {}
'@nodelib/fs.scandir@2.1.5':
@@ -615,8 +559,6 @@ snapshots:
a-sync-waterfall@1.0.1: {}
- ansi-colors@4.1.3: {}
-
asap@2.0.6: {}
braces@3.0.3:
@@ -655,10 +597,6 @@ snapshots:
data-uri-to-buffer@4.0.1: {}
- debug@4.4.0:
- dependencies:
- ms: 2.1.3
-
define-data-property@1.1.4:
dependencies:
es-define-property: 1.0.1
@@ -821,8 +759,6 @@ snapshots:
minimist@1.2.8: {}
- ms@2.1.3: {}
-
node-domexception@1.0.0: {}
node-fetch@3.3.1:
@@ -861,8 +797,6 @@ snapshots:
dependencies:
queue-microtask: 1.2.3
- semver@7.6.3: {}
-
set-function-length@1.2.2:
dependencies:
define-data-property: 1.1.4
@@ -882,16 +816,12 @@ snapshots:
dependencies:
duplexer: 0.1.2
- text-table@0.2.0: {}
-
through@2.3.8: {}
to-regex-range@5.0.1:
dependencies:
is-number: 7.0.0
- toml@3.0.0: {}
-
typescript@5.7.3: {}
undici-types@5.26.5: {}
diff --git a/program/idl.json b/program/idl.json
new file mode 100644
index 0000000..b4cab27
--- /dev/null
+++ b/program/idl.json
@@ -0,0 +1,442 @@
+{
+ "kind": "rootNode",
+ "standard": "codama",
+ "version": "1.0.0",
+ "program": {
+ "kind": "programNode",
+ "name": "programMetadata",
+ "publicKey": "4FX3oHhpAkJcb2tFFrq9JBY8gc4RhCRM5g75VG9QHnj1",
+ "version": "0.0.0",
+ "pdas": [],
+ "accounts": [
+ {
+ "kind": "accountNode",
+ "name": "buffer",
+ "docs": [],
+ "data": {
+ "kind": "structTypeNode",
+ "fields": [
+ {
+ "kind": "structFieldTypeNode",
+ "name": "discriminator",
+ "docs": [],
+ "type": {
+ "kind": "numberTypeNode",
+ "format": "u8",
+ "endian": "le"
+ },
+ "defaultValue": {
+ "kind": "numberValueNode",
+ "number": 1
+ },
+ "defaultValueStrategy": "omitted"
+ },
+ {
+ "kind": "structFieldTypeNode",
+ "name": "program",
+ "docs": [],
+ "type": {
+ "kind": "zeroableOptionTypeNode",
+ "item": { "kind": "publicKeyTypeNode" }
+ }
+ },
+ {
+ "kind": "structFieldTypeNode",
+ "name": "authority",
+ "docs": [],
+ "type": {
+ "kind": "zeroableOptionTypeNode",
+ "item": { "kind": "publicKeyTypeNode" }
+ }
+ },
+ {
+ "kind": "structFieldTypeNode",
+ "name": "canonical",
+ "docs": [],
+ "type": {
+ "kind": "booleanTypeNode",
+ "size": {
+ "kind": "numberTypeNode",
+ "format": "u8",
+ "endian": "le"
+ }
+ }
+ },
+ {
+ "kind": "structFieldTypeNode",
+ "name": "seed",
+ "docs": [],
+ "type": {
+ "kind": "postOffsetTypeNode",
+ "offset": 14,
+ "strategy": "padded",
+ "type": { "kind": "definedTypeLinkNode", "name": "seed" }
+ }
+ },
+ {
+ "kind": "structFieldTypeNode",
+ "name": "data",
+ "docs": [],
+ "type": { "kind": "bytesTypeNode" }
+ }
+ ]
+ }
+ },
+ {
+ "kind": "accountNode",
+ "name": "metadata",
+ "docs": [],
+ "data": {
+ "kind": "structTypeNode",
+ "fields": [
+ {
+ "kind": "structFieldTypeNode",
+ "name": "discriminator",
+ "docs": [],
+ "type": {
+ "kind": "numberTypeNode",
+ "format": "u8",
+ "endian": "le"
+ },
+ "defaultValue": {
+ "kind": "numberValueNode",
+ "number": 2
+ },
+ "defaultValueStrategy": "omitted"
+ },
+ {
+ "kind": "structFieldTypeNode",
+ "name": "program",
+ "docs": [],
+ "type": { "kind": "publicKeyTypeNode" }
+ },
+ {
+ "kind": "structFieldTypeNode",
+ "name": "authority",
+ "docs": [],
+ "type": {
+ "kind": "zeroableOptionTypeNode",
+ "item": { "kind": "publicKeyTypeNode" }
+ }
+ },
+ {
+ "kind": "structFieldTypeNode",
+ "name": "mutable",
+ "docs": [],
+ "type": {
+ "kind": "booleanTypeNode",
+ "size": {
+ "kind": "numberTypeNode",
+ "format": "u8",
+ "endian": "le"
+ }
+ }
+ },
+ {
+ "kind": "structFieldTypeNode",
+ "name": "canonical",
+ "docs": [],
+ "type": {
+ "kind": "booleanTypeNode",
+ "size": {
+ "kind": "numberTypeNode",
+ "format": "u8",
+ "endian": "le"
+ }
+ }
+ },
+ {
+ "kind": "structFieldTypeNode",
+ "name": "seed",
+ "docs": [],
+ "type": { "kind": "definedTypeLinkNode", "name": "seed" }
+ },
+ {
+ "kind": "structFieldTypeNode",
+ "name": "encoding",
+ "docs": [],
+ "type": { "kind": "definedTypeLinkNode", "name": "encoding" }
+ },
+ {
+ "kind": "structFieldTypeNode",
+ "name": "compression",
+ "docs": [],
+ "type": { "kind": "definedTypeLinkNode", "name": "compression" }
+ },
+ {
+ "kind": "structFieldTypeNode",
+ "name": "format",
+ "docs": [],
+ "type": { "kind": "definedTypeLinkNode", "name": "format" }
+ },
+ {
+ "kind": "structFieldTypeNode",
+ "name": "dataSource",
+ "docs": [],
+ "type": { "kind": "definedTypeLinkNode", "name": "dataSource" }
+ },
+ {
+ "kind": "structFieldTypeNode",
+ "name": "dataLength",
+ "docs": [],
+ "type": {
+ "kind": "postOffsetTypeNode",
+ "offset": 5,
+ "strategy": "padded",
+ "type": {
+ "kind": "numberTypeNode",
+ "format": "u32",
+ "endian": "le"
+ }
+ }
+ },
+ {
+ "kind": "structFieldTypeNode",
+ "name": "data",
+ "docs": [],
+ "type": { "kind": "bytesTypeNode" }
+ }
+ ]
+ }
+ }
+ ],
+ "instructions": [
+ {
+ "kind": "instructionNode",
+ "name": "initialize",
+ "docs": [],
+ "accounts": [
+ {
+ "kind": "instructionAccountNode",
+ "name": "metadata",
+ "docs": ["Metadata account the initialize."],
+ "is_signer": false,
+ "is_writable": true
+ },
+ {
+ "kind": "instructionAccountNode",
+ "name": "authority",
+ "docs": [
+ "Authority (for canonical, must match program upgrade authority)."
+ ],
+ "is_signer": true,
+ "is_writable": false
+ },
+ {
+ "kind": "instructionAccountNode",
+ "name": "program",
+ "docs": ["Program account."],
+ "is_signer": false,
+ "is_writable": false
+ },
+ {
+ "kind": "instructionAccountNode",
+ "name": "programData",
+ "docs": ["Program account."],
+ "is_signer": false,
+ "is_writable": false,
+ "is_optional": true
+ },
+ {
+ "kind": "instructionAccountNode",
+ "name": "system",
+ "docs": ["System program."],
+ "is_signer": false,
+ "is_writable": false,
+ "is_optional": true
+ }
+ ],
+ "arguments": [
+ {
+ "kind": "instructionArgumentNode",
+ "name": "discriminator",
+ "docs": [],
+ "type": {
+ "kind": "numberTypeNode",
+ "format": "u8",
+ "endian": "le"
+ },
+ "defaultValueStrategy": "omitted",
+ "defaultValue": { "kind": "numberValueNode", "number": 1 }
+ },
+ {
+ "kind": "instructionArgumentNode",
+ "name": "seed",
+ "docs": [],
+ "type": { "kind": "definedTypeLinkNode", "name": "seed" }
+ },
+ {
+ "kind": "instructionArgumentNode",
+ "name": "encoding",
+ "docs": [],
+ "type": { "kind": "definedTypeLinkNode", "name": "encoding" }
+ },
+ {
+ "kind": "instructionArgumentNode",
+ "name": "compression",
+ "docs": [],
+ "type": { "kind": "definedTypeLinkNode", "name": "compression" }
+ },
+ {
+ "kind": "instructionArgumentNode",
+ "name": "format",
+ "docs": [],
+ "type": { "kind": "definedTypeLinkNode", "name": "format" }
+ },
+ {
+ "kind": "instructionArgumentNode",
+ "name": "dataSource",
+ "docs": [],
+ "type": { "kind": "definedTypeLinkNode", "name": "dataSource" }
+ },
+ {
+ "kind": "instructionArgumentNode",
+ "name": "data",
+ "docs": [],
+ "type": {
+ "kind": "remainderOptionTypeNode",
+ "item": { "kind": "bytesTypeNode" }
+ }
+ }
+ ],
+ "discriminators": [
+ {
+ "kind": "fieldDiscriminatorNode",
+ "name": "discriminator",
+ "offset": 0
+ }
+ ]
+ }
+ ],
+ "definedTypes": [
+ {
+ "kind": "definedTypeNode",
+ "name": "seed",
+ "docs": [],
+ "type": {
+ "kind": "fixedSizeTypeNode",
+ "size": 16,
+ "type": { "kind": "stringTypeNode", "encoding": "utf8" }
+ }
+ },
+ {
+ "kind": "definedTypeNode",
+ "name": "encoding",
+ "docs": [],
+ "type": {
+ "kind": "enumTypeNode",
+ "variants": [
+ {
+ "kind": "enumEmptyVariantTypeNode",
+ "name": "none"
+ },
+ {
+ "kind": "enumEmptyVariantTypeNode",
+ "name": "utf8"
+ },
+ {
+ "kind": "enumEmptyVariantTypeNode",
+ "name": "base58"
+ },
+ {
+ "kind": "enumEmptyVariantTypeNode",
+ "name": "base64"
+ }
+ ],
+ "size": {
+ "kind": "numberTypeNode",
+ "format": "u8",
+ "endian": "le"
+ }
+ }
+ },
+ {
+ "kind": "definedTypeNode",
+ "name": "compression",
+ "docs": [],
+ "type": {
+ "kind": "enumTypeNode",
+ "variants": [
+ {
+ "kind": "enumEmptyVariantTypeNode",
+ "name": "none"
+ },
+ {
+ "kind": "enumEmptyVariantTypeNode",
+ "name": "gzip"
+ },
+ {
+ "kind": "enumEmptyVariantTypeNode",
+ "name": "zstd"
+ }
+ ],
+ "size": {
+ "kind": "numberTypeNode",
+ "format": "u8",
+ "endian": "le"
+ }
+ }
+ },
+ {
+ "kind": "definedTypeNode",
+ "name": "format",
+ "docs": [],
+ "type": {
+ "kind": "enumTypeNode",
+ "variants": [
+ {
+ "kind": "enumEmptyVariantTypeNode",
+ "name": "none"
+ },
+ {
+ "kind": "enumEmptyVariantTypeNode",
+ "name": "json"
+ },
+ {
+ "kind": "enumEmptyVariantTypeNode",
+ "name": "yaml"
+ },
+ {
+ "kind": "enumEmptyVariantTypeNode",
+ "name": "toml"
+ }
+ ],
+ "size": {
+ "kind": "numberTypeNode",
+ "format": "u8",
+ "endian": "le"
+ }
+ }
+ },
+ {
+ "kind": "definedTypeNode",
+ "name": "dataSource",
+ "docs": [],
+ "type": {
+ "kind": "enumTypeNode",
+ "variants": [
+ {
+ "kind": "enumEmptyVariantTypeNode",
+ "name": "direct"
+ },
+ {
+ "kind": "enumEmptyVariantTypeNode",
+ "name": "url"
+ },
+ {
+ "kind": "enumEmptyVariantTypeNode",
+ "name": "external"
+ }
+ ],
+ "size": {
+ "kind": "numberTypeNode",
+ "format": "u8",
+ "endian": "le"
+ }
+ }
+ }
+ ],
+ "errors": []
+ },
+ "additionalPrograms": []
+}
diff --git a/scripts/generate-clients.mjs b/scripts/generate-clients.mjs
index c10d842..688e2b8 100644
--- a/scripts/generate-clients.mjs
+++ b/scripts/generate-clients.mjs
@@ -1,68 +1,13 @@
#!/usr/bin/env zx
import 'zx/globals';
import * as c from 'codama';
-import { rootNodeFromAnchor } from '@codama/nodes-from-anchor';
import { renderVisitor as renderJavaScriptVisitor } from '@codama/renderers-js';
import { renderVisitor as renderRustVisitor } from '@codama/renderers-rust';
import { getAllProgramIdls } from './utils.mjs';
// Instanciate Codama.
-const [idl, ...additionalIdls] = getAllProgramIdls().map((idl) =>
- rootNodeFromAnchor(require(idl))
-);
-const codama = c.createFromRoot(idl, additionalIdls);
-
-// Update programs.
-codama.update(
- c.updateProgramsVisitor({
- splProgramMetadata: { name: 'programMetadata' },
- })
-);
-
-// Update accounts.
-codama.update(
- c.updateAccountsVisitor({
- counter: {
- seeds: [
- c.constantPdaSeedNodeFromString('utf8', 'counter'),
- c.variablePdaSeedNode(
- 'authority',
- c.publicKeyTypeNode(),
- 'The authority of the counter account'
- ),
- ],
- },
- })
-);
-
-// Update instructions.
-codama.update(
- c.updateInstructionsVisitor({
- create: {
- byteDeltas: [c.instructionByteDeltaNode(c.accountLinkNode('counter'))],
- accounts: {
- counter: { defaultValue: c.pdaValueNode('counter') },
- payer: { defaultValue: c.accountValueNode('authority') },
- },
- },
- increment: {
- accounts: {
- counter: { defaultValue: c.pdaValueNode('counter') },
- },
- arguments: {
- amount: { defaultValue: c.noneValueNode() },
- },
- },
- })
-);
-
-// Set account discriminators.
-const key = (name) => ({ field: 'key', value: c.enumValueNode('Key', name) });
-codama.update(
- c.setAccountDiscriminatorFromFieldVisitor({
- counter: key('counter'),
- })
-);
+const [idl] = getAllProgramIdls();
+const codama = c.createFromRoot(require(idl));
// Render JavaScript.
const jsClient = path.join(__dirname, '..', 'clients', 'js');
@@ -71,12 +16,3 @@ codama.accept(
prettierOptions: require(path.join(jsClient, '.prettierrc.json')),
})
);
-
-// Render Rust.
-const rustClient = path.join(__dirname, '..', 'clients', 'rust');
-codama.accept(
- renderRustVisitor(path.join(rustClient, 'src', 'generated'), {
- formatCode: true,
- crateFolder: rustClient,
- })
-);
diff --git a/scripts/generate-idls.mjs b/scripts/generate-idls.mjs
deleted file mode 100644
index faf2db8..0000000
--- a/scripts/generate-idls.mjs
+++ /dev/null
@@ -1,22 +0,0 @@
-#!/usr/bin/env zx
-import 'zx/globals';
-import { generateIdl } from '@metaplex-foundation/shank-js';
-import { getCargo, getProgramFolders } from './utils.mjs';
-
-const binaryInstallDir = path.join(__dirname, '..', '.cargo');
-
-getProgramFolders().forEach((folder) => {
- const cargo = getCargo(folder);
- const isShank = Object.keys(cargo.dependencies).includes('shank');
- const programDir = path.join(__dirname, '..', folder);
-
- generateIdl({
- generator: isShank ? 'shank' : 'anchor',
- programName: cargo.package.name.replace(/-/g, '_'),
- programId: cargo.package.metadata.solana['program-id'],
- idlDir: programDir,
- idlName: 'idl',
- programDir,
- binaryInstallDir,
- });
-});