diff --git a/Cargo.lock b/Cargo.lock index b94da54..d95c1e2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1911,9 +1911,9 @@ dependencies = [ [[package]] name = "kaigan" -version = "0.2.6" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ba15de5aeb137f0f65aa3bf82187647f1285abfe5b20c80c2c37f7007ad519a" +checksum = "4f25ded719a2354f6b1a51d0c0741c25bc7afe038617664eb37f6418439eb084" dependencies = [ "borsh 0.10.4", "serde", @@ -3371,9 +3371,9 @@ dependencies = [ [[package]] name = "solana-account-info" -version = "2.2.1" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0c17d606a298a205fae325489fbed88ee6dc4463c111672172327e741c8905d" +checksum = "c8f5152a288ef1912300fc6efa6c2d1f9bb55d9398eb6c72326360b8063987da" dependencies = [ "bincode", "serde", @@ -3691,9 +3691,9 @@ dependencies = [ [[package]] name = "solana-decode-error" -version = "2.2.1" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10a6a6383af236708048f8bd8d03db8ca4ff7baf4a48e5d580f4cce545925470" +checksum = "8c781686a18db2f942e70913f7ca15dc120ec38dcab42ff7557db2c70c625a35" dependencies = [ "num-traits", ] @@ -5558,8 +5558,14 @@ dependencies = [ "num-traits", "serde", "serde_with", + "solana-account", + "solana-account-info", "solana-client", - "solana-program", + "solana-cpi", + "solana-decode-error", + "solana-instruction", + "solana-program-error", + "solana-pubkey", "solana-sdk", "thiserror 1.0.69", ] diff --git a/clients/js/package.json b/clients/js/package.json index b0e0dc3..0feaeb3 100644 --- a/clients/js/package.json +++ b/clients/js/package.json @@ -85,6 +85,5 @@ "test/": "dist/test/" } } - }, - "packageManager": "pnpm@9.1.0" + } } diff --git a/clients/js/src/generated/accounts/buffer.ts b/clients/js/src/generated/accounts/buffer.ts index d4858d0..18c0118 100644 --- a/clients/js/src/generated/accounts/buffer.ts +++ b/clients/js/src/generated/accounts/buffer.ts @@ -1,7 +1,7 @@ /** - * This code was AUTOGENERATED using the codama library. + * 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. + * to add features, then rerun Codama to update it. * * @see https://github.com/codama-idl/codama */ @@ -40,7 +40,7 @@ import { type OptionOrNullable, type ReadonlyUint8Array, } from '@solana/kit'; -import { MetadataSeeds, findMetadataPda } from '../pdas'; +import { findMetadataPda, MetadataSeeds } from '../pdas'; import { AccountDiscriminator, getAccountDiscriminatorDecoder, diff --git a/clients/js/src/generated/accounts/index.ts b/clients/js/src/generated/accounts/index.ts index 2d0538c..38c3593 100644 --- a/clients/js/src/generated/accounts/index.ts +++ b/clients/js/src/generated/accounts/index.ts @@ -1,7 +1,7 @@ /** - * This code was AUTOGENERATED using the codama library. + * 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. + * to add features, then rerun Codama to update it. * * @see https://github.com/codama-idl/codama */ diff --git a/clients/js/src/generated/accounts/metadata.ts b/clients/js/src/generated/accounts/metadata.ts index f9ad58f..d790dbe 100644 --- a/clients/js/src/generated/accounts/metadata.ts +++ b/clients/js/src/generated/accounts/metadata.ts @@ -1,7 +1,7 @@ /** - * This code was AUTOGENERATED using the codama library. + * 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. + * to add features, then rerun Codama to update it. * * @see https://github.com/codama-idl/codama */ @@ -42,7 +42,7 @@ import { type OptionOrNullable, type ReadonlyUint8Array, } from '@solana/kit'; -import { MetadataSeeds, findMetadataPda } from '../pdas'; +import { findMetadataPda, MetadataSeeds } from '../pdas'; import { AccountDiscriminator, getAccountDiscriminatorDecoder, diff --git a/clients/js/src/generated/index.ts b/clients/js/src/generated/index.ts index 0b3d90a..923de15 100644 --- a/clients/js/src/generated/index.ts +++ b/clients/js/src/generated/index.ts @@ -1,7 +1,7 @@ /** - * This code was AUTOGENERATED using the codama library. + * 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. + * to add features, then rerun Codama to update it. * * @see https://github.com/codama-idl/codama */ diff --git a/clients/js/src/generated/instructions/allocate.ts b/clients/js/src/generated/instructions/allocate.ts index 84d334e..a308e76 100644 --- a/clients/js/src/generated/instructions/allocate.ts +++ b/clients/js/src/generated/instructions/allocate.ts @@ -1,7 +1,7 @@ /** - * This code was AUTOGENERATED using the codama library. + * 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. + * to add features, then rerun Codama to update it. * * @see https://github.com/codama-idl/codama */ @@ -195,7 +195,7 @@ export function getAllocateInstruction< } const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { + return Object.freeze({ accounts: [ getAccountMeta(accounts.buffer), getAccountMeta(accounts.authority), @@ -203,10 +203,10 @@ export function getAllocateInstruction< getAccountMeta(accounts.programData), getAccountMeta(accounts.system), ], - programAddress, data: getAllocateInstructionDataEncoder().encode( args as AllocateInstructionDataArgs ), + programAddress, } as AllocateInstruction< TProgramAddress, TAccountBuffer, @@ -214,9 +214,7 @@ export function getAllocateInstruction< TAccountProgram, TAccountProgramData, TAccountSystem - >; - - return instruction; + >); } export type ParsedAllocateInstruction< diff --git a/clients/js/src/generated/instructions/close.ts b/clients/js/src/generated/instructions/close.ts index e3e755d..7b82345 100644 --- a/clients/js/src/generated/instructions/close.ts +++ b/clients/js/src/generated/instructions/close.ts @@ -1,7 +1,7 @@ /** - * This code was AUTOGENERATED using the codama library. + * 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. + * to add features, then rerun Codama to update it. * * @see https://github.com/codama-idl/codama */ @@ -155,7 +155,7 @@ export function getCloseInstruction< >; const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { + return Object.freeze({ accounts: [ getAccountMeta(accounts.account), getAccountMeta(accounts.authority), @@ -163,8 +163,8 @@ export function getCloseInstruction< getAccountMeta(accounts.programData), getAccountMeta(accounts.destination), ], - programAddress, data: getCloseInstructionDataEncoder().encode({}), + programAddress, } as CloseInstruction< TProgramAddress, TAccountAccount, @@ -172,9 +172,7 @@ export function getCloseInstruction< TAccountProgram, TAccountProgramData, TAccountDestination - >; - - return instruction; + >); } export type ParsedCloseInstruction< diff --git a/clients/js/src/generated/instructions/extend.ts b/clients/js/src/generated/instructions/extend.ts index 89008bc..7ca58a5 100644 --- a/clients/js/src/generated/instructions/extend.ts +++ b/clients/js/src/generated/instructions/extend.ts @@ -1,7 +1,7 @@ /** - * This code was AUTOGENERATED using the codama library. + * 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. + * to add features, then rerun Codama to update it. * * @see https://github.com/codama-idl/codama */ @@ -163,26 +163,24 @@ export function getExtendInstruction< const args = { ...input }; const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { + return Object.freeze({ accounts: [ getAccountMeta(accounts.account), getAccountMeta(accounts.authority), getAccountMeta(accounts.program), getAccountMeta(accounts.programData), ], - programAddress, data: getExtendInstructionDataEncoder().encode( args as ExtendInstructionDataArgs ), + programAddress, } as ExtendInstruction< TProgramAddress, TAccountAccount, TAccountAuthority, TAccountProgram, TAccountProgramData - >; - - return instruction; + >); } export type ParsedExtendInstruction< diff --git a/clients/js/src/generated/instructions/index.ts b/clients/js/src/generated/instructions/index.ts index ef01e18..3c53513 100644 --- a/clients/js/src/generated/instructions/index.ts +++ b/clients/js/src/generated/instructions/index.ts @@ -1,7 +1,7 @@ /** - * This code was AUTOGENERATED using the codama library. + * 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. + * to add features, then rerun Codama to update it. * * @see https://github.com/codama-idl/codama */ diff --git a/clients/js/src/generated/instructions/initialize.ts b/clients/js/src/generated/instructions/initialize.ts index 4ea382d..857f8ae 100644 --- a/clients/js/src/generated/instructions/initialize.ts +++ b/clients/js/src/generated/instructions/initialize.ts @@ -1,7 +1,7 @@ /** - * This code was AUTOGENERATED using the codama library. + * 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. + * to add features, then rerun Codama to update it. * * @see https://github.com/codama-idl/codama */ @@ -258,7 +258,7 @@ export async function getInitializeInstructionAsync< } const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { + return Object.freeze({ accounts: [ getAccountMeta(accounts.metadata), getAccountMeta(accounts.authority), @@ -266,10 +266,10 @@ export async function getInitializeInstructionAsync< getAccountMeta(accounts.programData), getAccountMeta(accounts.system), ], - programAddress, data: getInitializeInstructionDataEncoder().encode( args as InitializeInstructionDataArgs ), + programAddress, } as InitializeInstruction< TProgramAddress, TAccountMetadata, @@ -277,9 +277,7 @@ export async function getInitializeInstructionAsync< TAccountProgram, TAccountProgramData, TAccountSystem - >; - - return instruction; + >); } export type InitializeInput< @@ -358,7 +356,7 @@ export function getInitializeInstruction< } const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { + return Object.freeze({ accounts: [ getAccountMeta(accounts.metadata), getAccountMeta(accounts.authority), @@ -366,10 +364,10 @@ export function getInitializeInstruction< getAccountMeta(accounts.programData), getAccountMeta(accounts.system), ], - programAddress, data: getInitializeInstructionDataEncoder().encode( args as InitializeInstructionDataArgs ), + programAddress, } as InitializeInstruction< TProgramAddress, TAccountMetadata, @@ -377,9 +375,7 @@ export function getInitializeInstruction< TAccountProgram, TAccountProgramData, TAccountSystem - >; - - return instruction; + >); } export type ParsedInitializeInstruction< diff --git a/clients/js/src/generated/instructions/setAuthority.ts b/clients/js/src/generated/instructions/setAuthority.ts index dc4b7ad..1e81eb6 100644 --- a/clients/js/src/generated/instructions/setAuthority.ts +++ b/clients/js/src/generated/instructions/setAuthority.ts @@ -1,7 +1,7 @@ /** - * This code was AUTOGENERATED using the codama library. + * 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. + * to add features, then rerun Codama to update it. * * @see https://github.com/codama-idl/codama */ @@ -165,26 +165,24 @@ export function getSetAuthorityInstruction< const args = { ...input }; const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { + return Object.freeze({ accounts: [ getAccountMeta(accounts.account), getAccountMeta(accounts.authority), getAccountMeta(accounts.program), getAccountMeta(accounts.programData), ], - programAddress, data: getSetAuthorityInstructionDataEncoder().encode( args as SetAuthorityInstructionDataArgs ), + programAddress, } as SetAuthorityInstruction< TProgramAddress, TAccountAccount, TAccountAuthority, TAccountProgram, TAccountProgramData - >; - - return instruction; + >); } export type ParsedSetAuthorityInstruction< diff --git a/clients/js/src/generated/instructions/setData.ts b/clients/js/src/generated/instructions/setData.ts index 2448ad5..8a7ab97 100644 --- a/clients/js/src/generated/instructions/setData.ts +++ b/clients/js/src/generated/instructions/setData.ts @@ -1,7 +1,7 @@ /** - * This code was AUTOGENERATED using the codama library. + * 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. + * to add features, then rerun Codama to update it. * * @see https://github.com/codama-idl/codama */ @@ -219,7 +219,7 @@ export function getSetDataInstruction< const args = { ...input }; const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { + return Object.freeze({ accounts: [ getAccountMeta(accounts.metadata), getAccountMeta(accounts.authority), @@ -227,10 +227,10 @@ export function getSetDataInstruction< getAccountMeta(accounts.program), getAccountMeta(accounts.programData), ], - programAddress, data: getSetDataInstructionDataEncoder().encode( args as SetDataInstructionDataArgs ), + programAddress, } as SetDataInstruction< TProgramAddress, TAccountMetadata, @@ -238,9 +238,7 @@ export function getSetDataInstruction< TAccountBuffer, TAccountProgram, TAccountProgramData - >; - - return instruction; + >); } export type ParsedSetDataInstruction< diff --git a/clients/js/src/generated/instructions/setImmutable.ts b/clients/js/src/generated/instructions/setImmutable.ts index 809943e..0620dd5 100644 --- a/clients/js/src/generated/instructions/setImmutable.ts +++ b/clients/js/src/generated/instructions/setImmutable.ts @@ -1,7 +1,7 @@ /** - * This code was AUTOGENERATED using the codama library. + * 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. + * to add features, then rerun Codama to update it. * * @see https://github.com/codama-idl/codama */ @@ -144,24 +144,22 @@ export function getSetImmutableInstruction< >; const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { + return Object.freeze({ accounts: [ getAccountMeta(accounts.metadata), getAccountMeta(accounts.authority), getAccountMeta(accounts.program), getAccountMeta(accounts.programData), ], - programAddress, data: getSetImmutableInstructionDataEncoder().encode({}), + programAddress, } as SetImmutableInstruction< TProgramAddress, TAccountMetadata, TAccountAuthority, TAccountProgram, TAccountProgramData - >; - - return instruction; + >); } export type ParsedSetImmutableInstruction< diff --git a/clients/js/src/generated/instructions/trim.ts b/clients/js/src/generated/instructions/trim.ts index d39d41b..b2bf8c6 100644 --- a/clients/js/src/generated/instructions/trim.ts +++ b/clients/js/src/generated/instructions/trim.ts @@ -1,7 +1,7 @@ /** - * This code was AUTOGENERATED using the codama library. + * 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. + * to add features, then rerun Codama to update it. * * @see https://github.com/codama-idl/codama */ @@ -174,7 +174,7 @@ export function getTrimInstruction< } const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { + return Object.freeze({ accounts: [ getAccountMeta(accounts.account), getAccountMeta(accounts.authority), @@ -183,8 +183,8 @@ export function getTrimInstruction< getAccountMeta(accounts.destination), getAccountMeta(accounts.rent), ], - programAddress, data: getTrimInstructionDataEncoder().encode({}), + programAddress, } as TrimInstruction< TProgramAddress, TAccountAccount, @@ -193,9 +193,7 @@ export function getTrimInstruction< TAccountProgramData, TAccountDestination, TAccountRent - >; - - return instruction; + >); } export type ParsedTrimInstruction< diff --git a/clients/js/src/generated/instructions/write.ts b/clients/js/src/generated/instructions/write.ts index 20a599a..74f56a5 100644 --- a/clients/js/src/generated/instructions/write.ts +++ b/clients/js/src/generated/instructions/write.ts @@ -1,7 +1,7 @@ /** - * This code was AUTOGENERATED using the codama library. + * 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. + * to add features, then rerun Codama to update it. * * @see https://github.com/codama-idl/codama */ @@ -175,24 +175,22 @@ export function getWriteInstruction< const args = { ...input }; const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { + return Object.freeze({ accounts: [ getAccountMeta(accounts.buffer), getAccountMeta(accounts.authority), getAccountMeta(accounts.sourceBuffer), ], - programAddress, data: getWriteInstructionDataEncoder().encode( args as WriteInstructionDataArgs ), + programAddress, } as WriteInstruction< TProgramAddress, TAccountBuffer, TAccountAuthority, TAccountSourceBuffer - >; - - return instruction; + >); } export type ParsedWriteInstruction< @@ -209,7 +207,6 @@ export type ParsedWriteInstruction< * Buffer to copy the data from. * You may use the `data` argument instead of this account to pass data directly. */ - sourceBuffer?: TAccountMetas[2] | undefined; }; data: WriteInstructionData; diff --git a/clients/js/src/generated/pdas/canonical.ts b/clients/js/src/generated/pdas/canonical.ts index af4ac02..7e30d2f 100644 --- a/clients/js/src/generated/pdas/canonical.ts +++ b/clients/js/src/generated/pdas/canonical.ts @@ -1,7 +1,7 @@ /** - * This code was AUTOGENERATED using the codama library. + * 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. + * to add features, then rerun Codama to update it. * * @see https://github.com/codama-idl/codama */ diff --git a/clients/js/src/generated/pdas/index.ts b/clients/js/src/generated/pdas/index.ts index 47f6e7a..4d75aa9 100644 --- a/clients/js/src/generated/pdas/index.ts +++ b/clients/js/src/generated/pdas/index.ts @@ -1,7 +1,7 @@ /** - * This code was AUTOGENERATED using the codama library. + * 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. + * to add features, then rerun Codama to update it. * * @see https://github.com/codama-idl/codama */ diff --git a/clients/js/src/generated/pdas/metadata.ts b/clients/js/src/generated/pdas/metadata.ts index 5c186fc..fb32200 100644 --- a/clients/js/src/generated/pdas/metadata.ts +++ b/clients/js/src/generated/pdas/metadata.ts @@ -1,7 +1,7 @@ /** - * This code was AUTOGENERATED using the codama library. + * 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. + * to add features, then rerun Codama to update it. * * @see https://github.com/codama-idl/codama */ diff --git a/clients/js/src/generated/pdas/nonCanonical.ts b/clients/js/src/generated/pdas/nonCanonical.ts index cba4486..1bac9f7 100644 --- a/clients/js/src/generated/pdas/nonCanonical.ts +++ b/clients/js/src/generated/pdas/nonCanonical.ts @@ -1,7 +1,7 @@ /** - * This code was AUTOGENERATED using the codama library. + * 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. + * to add features, then rerun Codama to update it. * * @see https://github.com/codama-idl/codama */ diff --git a/clients/js/src/generated/programs/index.ts b/clients/js/src/generated/programs/index.ts index ec512d0..37bb6ba 100644 --- a/clients/js/src/generated/programs/index.ts +++ b/clients/js/src/generated/programs/index.ts @@ -1,7 +1,7 @@ /** - * This code was AUTOGENERATED using the codama library. + * 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. + * to add features, then rerun Codama to update it. * * @see https://github.com/codama-idl/codama */ diff --git a/clients/js/src/generated/programs/programMetadata.ts b/clients/js/src/generated/programs/programMetadata.ts index 80def8b..7b7f9c4 100644 --- a/clients/js/src/generated/programs/programMetadata.ts +++ b/clients/js/src/generated/programs/programMetadata.ts @@ -1,7 +1,7 @@ /** - * This code was AUTOGENERATED using the codama library. + * 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. + * to add features, then rerun Codama to update it. * * @see https://github.com/codama-idl/codama */ diff --git a/clients/js/src/generated/shared/index.ts b/clients/js/src/generated/shared/index.ts index 8841a27..83a3183 100644 --- a/clients/js/src/generated/shared/index.ts +++ b/clients/js/src/generated/shared/index.ts @@ -1,7 +1,7 @@ /** - * This code was AUTOGENERATED using the codama library. + * 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. + * to add features, then rerun Codama to update it. * * @see https://github.com/codama-idl/codama */ diff --git a/clients/js/src/generated/types/accountDiscriminator.ts b/clients/js/src/generated/types/accountDiscriminator.ts index ce942fa..acceab7 100644 --- a/clients/js/src/generated/types/accountDiscriminator.ts +++ b/clients/js/src/generated/types/accountDiscriminator.ts @@ -1,7 +1,7 @@ /** - * This code was AUTOGENERATED using the codama library. + * 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. + * to add features, then rerun Codama to update it. * * @see https://github.com/codama-idl/codama */ diff --git a/clients/js/src/generated/types/compression.ts b/clients/js/src/generated/types/compression.ts index 877a4f6..f4962bc 100644 --- a/clients/js/src/generated/types/compression.ts +++ b/clients/js/src/generated/types/compression.ts @@ -1,7 +1,7 @@ /** - * This code was AUTOGENERATED using the codama library. + * 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. + * to add features, then rerun Codama to update it. * * @see https://github.com/codama-idl/codama */ diff --git a/clients/js/src/generated/types/dataSource.ts b/clients/js/src/generated/types/dataSource.ts index 12c45de..92f1ff9 100644 --- a/clients/js/src/generated/types/dataSource.ts +++ b/clients/js/src/generated/types/dataSource.ts @@ -1,7 +1,7 @@ /** - * This code was AUTOGENERATED using the codama library. + * 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. + * to add features, then rerun Codama to update it. * * @see https://github.com/codama-idl/codama */ diff --git a/clients/js/src/generated/types/encoding.ts b/clients/js/src/generated/types/encoding.ts index 39e7780..b2d8440 100644 --- a/clients/js/src/generated/types/encoding.ts +++ b/clients/js/src/generated/types/encoding.ts @@ -1,7 +1,7 @@ /** - * This code was AUTOGENERATED using the codama library. + * 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. + * to add features, then rerun Codama to update it. * * @see https://github.com/codama-idl/codama */ diff --git a/clients/js/src/generated/types/externalData.ts b/clients/js/src/generated/types/externalData.ts index 069283f..dff10fb 100644 --- a/clients/js/src/generated/types/externalData.ts +++ b/clients/js/src/generated/types/externalData.ts @@ -1,7 +1,7 @@ /** - * This code was AUTOGENERATED using the codama library. + * 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. + * to add features, then rerun Codama to update it. * * @see https://github.com/codama-idl/codama */ diff --git a/clients/js/src/generated/types/format.ts b/clients/js/src/generated/types/format.ts index 7548528..b675803 100644 --- a/clients/js/src/generated/types/format.ts +++ b/clients/js/src/generated/types/format.ts @@ -1,7 +1,7 @@ /** - * This code was AUTOGENERATED using the codama library. + * 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. + * to add features, then rerun Codama to update it. * * @see https://github.com/codama-idl/codama */ diff --git a/clients/js/src/generated/types/index.ts b/clients/js/src/generated/types/index.ts index 397d4f5..dce65b0 100644 --- a/clients/js/src/generated/types/index.ts +++ b/clients/js/src/generated/types/index.ts @@ -1,7 +1,7 @@ /** - * This code was AUTOGENERATED using the codama library. + * 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. + * to add features, then rerun Codama to update it. * * @see https://github.com/codama-idl/codama */ diff --git a/clients/js/src/generated/types/seed.ts b/clients/js/src/generated/types/seed.ts index 6111c29..8e1a883 100644 --- a/clients/js/src/generated/types/seed.ts +++ b/clients/js/src/generated/types/seed.ts @@ -1,7 +1,7 @@ /** - * This code was AUTOGENERATED using the codama library. + * 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. + * to add features, then rerun Codama to update it. * * @see https://github.com/codama-idl/codama */ diff --git a/clients/rust/Cargo.toml b/clients/rust/Cargo.toml index a20880d..a22c4c0 100644 --- a/clients/rust/Cargo.toml +++ b/clients/rust/Cargo.toml @@ -17,8 +17,14 @@ num-derive = "^0.4" num-traits = "^0.2" serde = { version = "^1.0", features = ["derive"], optional = true } serde_with = { version = "^3.0", optional = true } +solana-account = "~2.2" +solana-account-info = "~2.3" solana-client = { version = "^2.3", optional = true } -solana-program = "^2.2" -solana-sdk = { version = "^2.2", optional = true } +solana-cpi = "~2.2" +solana-decode-error = "~2.3" +solana-instruction = "~2.3" +solana-program-error = "~2.2" +solana-pubkey = { version = "~2.4", features = ["curve25519", "borsh"] } +solana-sdk = { version = "^2.3", optional = true } thiserror = "^1.0" -kaigan = { version = "^0.2", features = ["serde"] } +kaigan = { version = "^0.3", features = ["serde"] } diff --git a/clients/rust/src/generated/accounts/buffer.rs b/clients/rust/src/generated/accounts/buffer.rs index e0612a0..7341b09 100644 --- a/clients/rust/src/generated/accounts/buffer.rs +++ b/clients/rust/src/generated/accounts/buffer.rs @@ -31,12 +31,10 @@ impl Buffer { } } -impl<'a> TryFrom<&solana_program::account_info::AccountInfo<'a>> for Buffer { +impl<'a> TryFrom<&solana_account_info::AccountInfo<'a>> for Buffer { type Error = std::io::Error; - fn try_from( - account_info: &solana_program::account_info::AccountInfo<'a>, - ) -> Result { + fn try_from(account_info: &solana_account_info::AccountInfo<'a>) -> Result { let mut data: &[u8] = &(*account_info.data).borrow(); Self::deserialize(&mut data) } @@ -45,7 +43,7 @@ impl<'a> TryFrom<&solana_program::account_info::AccountInfo<'a>> for Buffer { #[cfg(feature = "fetch")] pub fn fetch_buffer( rpc: &solana_client::rpc_client::RpcClient, - address: &solana_program::pubkey::Pubkey, + address: &solana_pubkey::Pubkey, ) -> Result, std::io::Error> { let accounts = fetch_all_buffer(rpc, &[*address])?; Ok(accounts[0].clone()) @@ -54,7 +52,7 @@ pub fn fetch_buffer( #[cfg(feature = "fetch")] pub fn fetch_all_buffer( rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_program::pubkey::Pubkey], + addresses: &[solana_pubkey::Pubkey], ) -> Result>, std::io::Error> { let accounts = rpc .get_multiple_accounts(addresses) @@ -79,7 +77,7 @@ pub fn fetch_all_buffer( #[cfg(feature = "fetch")] pub fn fetch_maybe_buffer( rpc: &solana_client::rpc_client::RpcClient, - address: &solana_program::pubkey::Pubkey, + address: &solana_pubkey::Pubkey, ) -> Result, std::io::Error> { let accounts = fetch_all_maybe_buffer(rpc, &[*address])?; Ok(accounts[0].clone()) @@ -88,7 +86,7 @@ pub fn fetch_maybe_buffer( #[cfg(feature = "fetch")] pub fn fetch_all_maybe_buffer( rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_program::pubkey::Pubkey], + addresses: &[solana_pubkey::Pubkey], ) -> Result>, std::io::Error> { let accounts = rpc .get_multiple_accounts(addresses) diff --git a/clients/rust/src/generated/accounts/metadata.rs b/clients/rust/src/generated/accounts/metadata.rs index 9b1224c..988db95 100644 --- a/clients/rust/src/generated/accounts/metadata.rs +++ b/clients/rust/src/generated/accounts/metadata.rs @@ -15,7 +15,7 @@ use crate::hooked::ZeroableOptionPubkey; use borsh::BorshDeserialize; use borsh::BorshSerialize; use kaigan::types::RemainderVec; -use solana_program::pubkey::Pubkey; +use solana_pubkey::Pubkey; #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] @@ -46,12 +46,10 @@ impl Metadata { } } -impl<'a> TryFrom<&solana_program::account_info::AccountInfo<'a>> for Metadata { +impl<'a> TryFrom<&solana_account_info::AccountInfo<'a>> for Metadata { type Error = std::io::Error; - fn try_from( - account_info: &solana_program::account_info::AccountInfo<'a>, - ) -> Result { + fn try_from(account_info: &solana_account_info::AccountInfo<'a>) -> Result { let mut data: &[u8] = &(*account_info.data).borrow(); Self::deserialize(&mut data) } @@ -60,7 +58,7 @@ impl<'a> TryFrom<&solana_program::account_info::AccountInfo<'a>> for Metadata { #[cfg(feature = "fetch")] pub fn fetch_metadata( rpc: &solana_client::rpc_client::RpcClient, - address: &solana_program::pubkey::Pubkey, + address: &solana_pubkey::Pubkey, ) -> Result, std::io::Error> { let accounts = fetch_all_metadata(rpc, &[*address])?; Ok(accounts[0].clone()) @@ -69,7 +67,7 @@ pub fn fetch_metadata( #[cfg(feature = "fetch")] pub fn fetch_all_metadata( rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_program::pubkey::Pubkey], + addresses: &[solana_pubkey::Pubkey], ) -> Result>, std::io::Error> { let accounts = rpc .get_multiple_accounts(addresses) @@ -94,7 +92,7 @@ pub fn fetch_all_metadata( #[cfg(feature = "fetch")] pub fn fetch_maybe_metadata( rpc: &solana_client::rpc_client::RpcClient, - address: &solana_program::pubkey::Pubkey, + address: &solana_pubkey::Pubkey, ) -> Result, std::io::Error> { let accounts = fetch_all_maybe_metadata(rpc, &[*address])?; Ok(accounts[0].clone()) @@ -103,7 +101,7 @@ pub fn fetch_maybe_metadata( #[cfg(feature = "fetch")] pub fn fetch_all_maybe_metadata( rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_program::pubkey::Pubkey], + addresses: &[solana_pubkey::Pubkey], ) -> Result>, std::io::Error> { let accounts = rpc .get_multiple_accounts(addresses) diff --git a/clients/rust/src/generated/instructions/allocate.rs b/clients/rust/src/generated/instructions/allocate.rs index 5d18f50..a54ab8a 100644 --- a/clients/rust/src/generated/instructions/allocate.rs +++ b/clients/rust/src/generated/instructions/allocate.rs @@ -9,26 +9,25 @@ use crate::hooked::RemainderOptionSeed; use borsh::BorshDeserialize; use borsh::BorshSerialize; +pub const ALLOCATE_DISCRIMINATOR: u8 = 7; + /// Accounts. #[derive(Debug)] pub struct Allocate { /// Buffer account to allocate. - pub buffer: solana_program::pubkey::Pubkey, + pub buffer: solana_pubkey::Pubkey, /// Authority account. - pub authority: solana_program::pubkey::Pubkey, + pub authority: solana_pubkey::Pubkey, /// Program account. - pub program: Option, + pub program: Option, /// Program data account. - pub program_data: Option, + pub program_data: Option, /// System program. - pub system: Option, + pub system: Option, } impl Allocate { - pub fn instruction( - &self, - args: AllocateInstructionArgs, - ) -> solana_program::instruction::Instruction { + pub fn instruction(&self, args: AllocateInstructionArgs) -> solana_instruction::Instruction { self.instruction_with_remaining_accounts(args, &[]) } #[allow(clippy::arithmetic_side_effects)] @@ -36,54 +35,49 @@ impl Allocate { pub fn instruction_with_remaining_accounts( &self, args: AllocateInstructionArgs, - remaining_accounts: &[solana_program::instruction::AccountMeta], - ) -> solana_program::instruction::Instruction { + remaining_accounts: &[solana_instruction::AccountMeta], + ) -> solana_instruction::Instruction { let mut accounts = Vec::with_capacity(5 + remaining_accounts.len()); - accounts.push(solana_program::instruction::AccountMeta::new( - self.buffer, - false, - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new(self.buffer, false)); + accounts.push(solana_instruction::AccountMeta::new_readonly( self.authority, true, )); if let Some(program) = self.program { - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( program, false, )); } else { - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( crate::PROGRAM_METADATA_ID, false, )); } if let Some(program_data) = self.program_data { - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( program_data, false, )); } else { - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( crate::PROGRAM_METADATA_ID, false, )); } if let Some(system) = self.system { - accounts.push(solana_program::instruction::AccountMeta::new_readonly( - system, false, - )); + accounts.push(solana_instruction::AccountMeta::new_readonly(system, false)); } else { - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( crate::PROGRAM_METADATA_ID, false, )); } accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&AllocateInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); + let mut data = AllocateInstructionData::new().try_to_vec().unwrap(); + let mut args = args.try_to_vec().unwrap(); data.append(&mut args); - solana_program::instruction::Instruction { + solana_instruction::Instruction { program_id: crate::PROGRAM_METADATA_ID, accounts, data, @@ -101,6 +95,10 @@ impl AllocateInstructionData { pub fn new() -> Self { Self { discriminator: 7 } } + + pub(crate) fn try_to_vec(&self) -> Result, std::io::Error> { + borsh::to_vec(self) + } } impl Default for AllocateInstructionData { @@ -115,6 +113,12 @@ pub struct AllocateInstructionArgs { pub seed: RemainderOptionSeed, } +impl AllocateInstructionArgs { + pub(crate) fn try_to_vec(&self) -> Result, std::io::Error> { + borsh::to_vec(self) + } +} + /// Instruction builder for `Allocate`. /// /// ### Accounts: @@ -126,13 +130,13 @@ pub struct AllocateInstructionArgs { /// 4. `[optional]` system (default to `11111111111111111111111111111111`) #[derive(Clone, Debug, Default)] pub struct AllocateBuilder { - buffer: Option, - authority: Option, - program: Option, - program_data: Option, - system: Option, + buffer: Option, + authority: Option, + program: Option, + program_data: Option, + system: Option, seed: Option, - __remaining_accounts: Vec, + __remaining_accounts: Vec, } impl AllocateBuilder { @@ -141,37 +145,34 @@ impl AllocateBuilder { } /// Buffer account to allocate. #[inline(always)] - pub fn buffer(&mut self, buffer: solana_program::pubkey::Pubkey) -> &mut Self { + pub fn buffer(&mut self, buffer: solana_pubkey::Pubkey) -> &mut Self { self.buffer = Some(buffer); self } /// Authority account. #[inline(always)] - pub fn authority(&mut self, authority: solana_program::pubkey::Pubkey) -> &mut Self { + pub fn authority(&mut self, authority: solana_pubkey::Pubkey) -> &mut Self { self.authority = Some(authority); self } /// `[optional account]` /// Program account. #[inline(always)] - pub fn program(&mut self, program: Option) -> &mut Self { + pub fn program(&mut self, program: Option) -> &mut Self { self.program = program; self } /// `[optional account]` /// Program data account. #[inline(always)] - pub fn program_data( - &mut self, - program_data: Option, - ) -> &mut Self { + pub fn program_data(&mut self, program_data: Option) -> &mut Self { self.program_data = program_data; self } /// `[optional account]` /// System program. #[inline(always)] - pub fn system(&mut self, system: Option) -> &mut Self { + pub fn system(&mut self, system: Option) -> &mut Self { self.system = system; self } @@ -182,10 +183,7 @@ impl AllocateBuilder { } /// Add an additional account to the instruction. #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: solana_program::instruction::AccountMeta, - ) -> &mut Self { + pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { self.__remaining_accounts.push(account); self } @@ -193,13 +191,13 @@ impl AllocateBuilder { #[inline(always)] pub fn add_remaining_accounts( &mut self, - accounts: &[solana_program::instruction::AccountMeta], + accounts: &[solana_instruction::AccountMeta], ) -> &mut Self { self.__remaining_accounts.extend_from_slice(accounts); self } #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_program::instruction::Instruction { + pub fn instruction(&self) -> solana_instruction::Instruction { let accounts = Allocate { buffer: self.buffer.expect("buffer is not set"), authority: self.authority.expect("authority is not set"), @@ -218,38 +216,38 @@ impl AllocateBuilder { /// `allocate` CPI accounts. pub struct AllocateCpiAccounts<'a, 'b> { /// Buffer account to allocate. - pub buffer: &'b solana_program::account_info::AccountInfo<'a>, + pub buffer: &'b solana_account_info::AccountInfo<'a>, /// Authority account. - pub authority: &'b solana_program::account_info::AccountInfo<'a>, + pub authority: &'b solana_account_info::AccountInfo<'a>, /// Program account. - pub program: Option<&'b solana_program::account_info::AccountInfo<'a>>, + pub program: Option<&'b solana_account_info::AccountInfo<'a>>, /// Program data account. - pub program_data: Option<&'b solana_program::account_info::AccountInfo<'a>>, + pub program_data: Option<&'b solana_account_info::AccountInfo<'a>>, /// System program. - pub system: Option<&'b solana_program::account_info::AccountInfo<'a>>, + pub system: Option<&'b solana_account_info::AccountInfo<'a>>, } /// `allocate` CPI instruction. pub struct AllocateCpi<'a, 'b> { /// The program to invoke. - pub __program: &'b solana_program::account_info::AccountInfo<'a>, + pub __program: &'b solana_account_info::AccountInfo<'a>, /// Buffer account to allocate. - pub buffer: &'b solana_program::account_info::AccountInfo<'a>, + pub buffer: &'b solana_account_info::AccountInfo<'a>, /// Authority account. - pub authority: &'b solana_program::account_info::AccountInfo<'a>, + pub authority: &'b solana_account_info::AccountInfo<'a>, /// Program account. - pub program: Option<&'b solana_program::account_info::AccountInfo<'a>>, + pub program: Option<&'b solana_account_info::AccountInfo<'a>>, /// Program data account. - pub program_data: Option<&'b solana_program::account_info::AccountInfo<'a>>, + pub program_data: Option<&'b solana_account_info::AccountInfo<'a>>, /// System program. - pub system: Option<&'b solana_program::account_info::AccountInfo<'a>>, + pub system: Option<&'b solana_account_info::AccountInfo<'a>>, /// The arguments for the instruction. pub __args: AllocateInstructionArgs, } impl<'a, 'b> AllocateCpi<'a, 'b> { pub fn new( - program: &'b solana_program::account_info::AccountInfo<'a>, + program: &'b solana_account_info::AccountInfo<'a>, accounts: AllocateCpiAccounts<'a, 'b>, args: AllocateInstructionArgs, ) -> Self { @@ -264,25 +262,18 @@ impl<'a, 'b> AllocateCpi<'a, 'b> { } } #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + pub fn invoke(&self) -> solana_program_error::ProgramResult { self.invoke_signed_with_remaining_accounts(&[], &[]) } #[inline(always)] pub fn invoke_with_remaining_accounts( &self, - remaining_accounts: &[( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )], - ) -> solana_program::entrypoint::ProgramResult { + remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], + ) -> solana_program_error::ProgramResult { self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) } #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program::entrypoint::ProgramResult { + pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult { self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) } #[allow(clippy::arithmetic_side_effects)] @@ -291,66 +282,62 @@ impl<'a, 'b> AllocateCpi<'a, 'b> { pub fn invoke_signed_with_remaining_accounts( &self, signers_seeds: &[&[&[u8]]], - remaining_accounts: &[( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )], - ) -> solana_program::entrypoint::ProgramResult { + remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], + ) -> solana_program_error::ProgramResult { let mut accounts = Vec::with_capacity(5 + remaining_accounts.len()); - accounts.push(solana_program::instruction::AccountMeta::new( + accounts.push(solana_instruction::AccountMeta::new( *self.buffer.key, false, )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( *self.authority.key, true, )); if let Some(program) = self.program { - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( *program.key, false, )); } else { - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( crate::PROGRAM_METADATA_ID, false, )); } if let Some(program_data) = self.program_data { - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( *program_data.key, false, )); } else { - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( crate::PROGRAM_METADATA_ID, false, )); } if let Some(system) = self.system { - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( *system.key, false, )); } else { - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( crate::PROGRAM_METADATA_ID, false, )); } remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_program::instruction::AccountMeta { + accounts.push(solana_instruction::AccountMeta { pubkey: *remaining_account.0.key, is_signer: remaining_account.1, is_writable: remaining_account.2, }) }); - let mut data = borsh::to_vec(&AllocateInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); + let mut data = AllocateInstructionData::new().try_to_vec().unwrap(); + let mut args = self.__args.try_to_vec().unwrap(); data.append(&mut args); - let instruction = solana_program::instruction::Instruction { + let instruction = solana_instruction::Instruction { program_id: crate::PROGRAM_METADATA_ID, accounts, data, @@ -373,9 +360,9 @@ impl<'a, 'b> AllocateCpi<'a, 'b> { .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); if signers_seeds.is_empty() { - solana_program::program::invoke(&instruction, &account_infos) + solana_cpi::invoke(&instruction, &account_infos) } else { - solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds) + solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) } } } @@ -395,7 +382,7 @@ pub struct AllocateCpiBuilder<'a, 'b> { } impl<'a, 'b> AllocateCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { + pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { let instruction = Box::new(AllocateCpiBuilderInstruction { __program: program, buffer: None, @@ -410,19 +397,13 @@ impl<'a, 'b> AllocateCpiBuilder<'a, 'b> { } /// Buffer account to allocate. #[inline(always)] - pub fn buffer( - &mut self, - buffer: &'b solana_program::account_info::AccountInfo<'a>, - ) -> &mut Self { + pub fn buffer(&mut self, buffer: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { self.instruction.buffer = Some(buffer); self } /// Authority account. #[inline(always)] - pub fn authority( - &mut self, - authority: &'b solana_program::account_info::AccountInfo<'a>, - ) -> &mut Self { + pub fn authority(&mut self, authority: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { self.instruction.authority = Some(authority); self } @@ -431,7 +412,7 @@ impl<'a, 'b> AllocateCpiBuilder<'a, 'b> { #[inline(always)] pub fn program( &mut self, - program: Option<&'b solana_program::account_info::AccountInfo<'a>>, + program: Option<&'b solana_account_info::AccountInfo<'a>>, ) -> &mut Self { self.instruction.program = program; self @@ -441,7 +422,7 @@ impl<'a, 'b> AllocateCpiBuilder<'a, 'b> { #[inline(always)] pub fn program_data( &mut self, - program_data: Option<&'b solana_program::account_info::AccountInfo<'a>>, + program_data: Option<&'b solana_account_info::AccountInfo<'a>>, ) -> &mut Self { self.instruction.program_data = program_data; self @@ -451,7 +432,7 @@ impl<'a, 'b> AllocateCpiBuilder<'a, 'b> { #[inline(always)] pub fn system( &mut self, - system: Option<&'b solana_program::account_info::AccountInfo<'a>>, + system: Option<&'b solana_account_info::AccountInfo<'a>>, ) -> &mut Self { self.instruction.system = system; self @@ -465,7 +446,7 @@ impl<'a, 'b> AllocateCpiBuilder<'a, 'b> { #[inline(always)] pub fn add_remaining_account( &mut self, - account: &'b solana_program::account_info::AccountInfo<'a>, + account: &'b solana_account_info::AccountInfo<'a>, is_writable: bool, is_signer: bool, ) -> &mut Self { @@ -481,11 +462,7 @@ impl<'a, 'b> AllocateCpiBuilder<'a, 'b> { #[inline(always)] pub fn add_remaining_accounts( &mut self, - accounts: &[( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )], + accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], ) -> &mut Self { self.instruction .__remaining_accounts @@ -493,15 +470,12 @@ impl<'a, 'b> AllocateCpiBuilder<'a, 'b> { self } #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + pub fn invoke(&self) -> solana_program_error::ProgramResult { self.invoke_signed(&[]) } #[allow(clippy::clone_on_copy)] #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program::entrypoint::ProgramResult { + pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult { let args = AllocateInstructionArgs { seed: self.instruction.seed.clone().expect("seed is not set"), }; @@ -528,17 +502,13 @@ impl<'a, 'b> AllocateCpiBuilder<'a, 'b> { #[derive(Clone, Debug)] struct AllocateCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_program::account_info::AccountInfo<'a>, - buffer: Option<&'b solana_program::account_info::AccountInfo<'a>>, - authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, - program: Option<&'b solana_program::account_info::AccountInfo<'a>>, - program_data: Option<&'b solana_program::account_info::AccountInfo<'a>>, - system: Option<&'b solana_program::account_info::AccountInfo<'a>>, + __program: &'b solana_account_info::AccountInfo<'a>, + buffer: Option<&'b solana_account_info::AccountInfo<'a>>, + authority: Option<&'b solana_account_info::AccountInfo<'a>>, + program: Option<&'b solana_account_info::AccountInfo<'a>>, + program_data: Option<&'b solana_account_info::AccountInfo<'a>>, + system: Option<&'b solana_account_info::AccountInfo<'a>>, seed: Option, /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )>, + __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, } diff --git a/clients/rust/src/generated/instructions/close.rs b/clients/rust/src/generated/instructions/close.rs index c70f7a5..a0329c4 100644 --- a/clients/rust/src/generated/instructions/close.rs +++ b/clients/rust/src/generated/instructions/close.rs @@ -8,69 +8,68 @@ use borsh::BorshDeserialize; use borsh::BorshSerialize; +pub const CLOSE_DISCRIMINATOR: u8 = 6; + /// Accounts. #[derive(Debug)] pub struct Close { /// Account to close. - pub account: solana_program::pubkey::Pubkey, + pub account: solana_pubkey::Pubkey, /// Authority account. - pub authority: solana_program::pubkey::Pubkey, + pub authority: solana_pubkey::Pubkey, /// Program account. - pub program: Option, + pub program: Option, /// Program data account. - pub program_data: Option, + pub program_data: Option, /// Destination account. - pub destination: solana_program::pubkey::Pubkey, + pub destination: solana_pubkey::Pubkey, } impl Close { - pub fn instruction(&self) -> solana_program::instruction::Instruction { + pub fn instruction(&self) -> solana_instruction::Instruction { self.instruction_with_remaining_accounts(&[]) } #[allow(clippy::arithmetic_side_effects)] #[allow(clippy::vec_init_then_push)] pub fn instruction_with_remaining_accounts( &self, - remaining_accounts: &[solana_program::instruction::AccountMeta], - ) -> solana_program::instruction::Instruction { + remaining_accounts: &[solana_instruction::AccountMeta], + ) -> solana_instruction::Instruction { let mut accounts = Vec::with_capacity(5 + remaining_accounts.len()); - accounts.push(solana_program::instruction::AccountMeta::new( - self.account, - false, - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new(self.account, false)); + accounts.push(solana_instruction::AccountMeta::new_readonly( self.authority, true, )); if let Some(program) = self.program { - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( program, false, )); } else { - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( crate::PROGRAM_METADATA_ID, false, )); } if let Some(program_data) = self.program_data { - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( program_data, false, )); } else { - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( crate::PROGRAM_METADATA_ID, false, )); } - accounts.push(solana_program::instruction::AccountMeta::new( + accounts.push(solana_instruction::AccountMeta::new( self.destination, false, )); accounts.extend_from_slice(remaining_accounts); - let data = borsh::to_vec(&CloseInstructionData::new()).unwrap(); + let data = CloseInstructionData::new().try_to_vec().unwrap(); - solana_program::instruction::Instruction { + solana_instruction::Instruction { program_id: crate::PROGRAM_METADATA_ID, accounts, data, @@ -88,6 +87,10 @@ impl CloseInstructionData { pub fn new() -> Self { Self { discriminator: 6 } } + + pub(crate) fn try_to_vec(&self) -> Result, std::io::Error> { + borsh::to_vec(self) + } } impl Default for CloseInstructionData { @@ -107,12 +110,12 @@ impl Default for CloseInstructionData { /// 4. `[writable]` destination #[derive(Clone, Debug, Default)] pub struct CloseBuilder { - account: Option, - authority: Option, - program: Option, - program_data: Option, - destination: Option, - __remaining_accounts: Vec, + account: Option, + authority: Option, + program: Option, + program_data: Option, + destination: Option, + __remaining_accounts: Vec, } impl CloseBuilder { @@ -121,45 +124,39 @@ impl CloseBuilder { } /// Account to close. #[inline(always)] - pub fn account(&mut self, account: solana_program::pubkey::Pubkey) -> &mut Self { + pub fn account(&mut self, account: solana_pubkey::Pubkey) -> &mut Self { self.account = Some(account); self } /// Authority account. #[inline(always)] - pub fn authority(&mut self, authority: solana_program::pubkey::Pubkey) -> &mut Self { + pub fn authority(&mut self, authority: solana_pubkey::Pubkey) -> &mut Self { self.authority = Some(authority); self } /// `[optional account]` /// Program account. #[inline(always)] - pub fn program(&mut self, program: Option) -> &mut Self { + pub fn program(&mut self, program: Option) -> &mut Self { self.program = program; self } /// `[optional account]` /// Program data account. #[inline(always)] - pub fn program_data( - &mut self, - program_data: Option, - ) -> &mut Self { + pub fn program_data(&mut self, program_data: Option) -> &mut Self { self.program_data = program_data; self } /// Destination account. #[inline(always)] - pub fn destination(&mut self, destination: solana_program::pubkey::Pubkey) -> &mut Self { + pub fn destination(&mut self, destination: solana_pubkey::Pubkey) -> &mut Self { self.destination = Some(destination); self } /// Add an additional account to the instruction. #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: solana_program::instruction::AccountMeta, - ) -> &mut Self { + pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { self.__remaining_accounts.push(account); self } @@ -167,13 +164,13 @@ impl CloseBuilder { #[inline(always)] pub fn add_remaining_accounts( &mut self, - accounts: &[solana_program::instruction::AccountMeta], + accounts: &[solana_instruction::AccountMeta], ) -> &mut Self { self.__remaining_accounts.extend_from_slice(accounts); self } #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_program::instruction::Instruction { + pub fn instruction(&self) -> solana_instruction::Instruction { let accounts = Close { account: self.account.expect("account is not set"), authority: self.authority.expect("authority is not set"), @@ -189,36 +186,36 @@ impl CloseBuilder { /// `close` CPI accounts. pub struct CloseCpiAccounts<'a, 'b> { /// Account to close. - pub account: &'b solana_program::account_info::AccountInfo<'a>, + pub account: &'b solana_account_info::AccountInfo<'a>, /// Authority account. - pub authority: &'b solana_program::account_info::AccountInfo<'a>, + pub authority: &'b solana_account_info::AccountInfo<'a>, /// Program account. - pub program: Option<&'b solana_program::account_info::AccountInfo<'a>>, + pub program: Option<&'b solana_account_info::AccountInfo<'a>>, /// Program data account. - pub program_data: Option<&'b solana_program::account_info::AccountInfo<'a>>, + pub program_data: Option<&'b solana_account_info::AccountInfo<'a>>, /// Destination account. - pub destination: &'b solana_program::account_info::AccountInfo<'a>, + pub destination: &'b solana_account_info::AccountInfo<'a>, } /// `close` CPI instruction. pub struct CloseCpi<'a, 'b> { /// The program to invoke. - pub __program: &'b solana_program::account_info::AccountInfo<'a>, + pub __program: &'b solana_account_info::AccountInfo<'a>, /// Account to close. - pub account: &'b solana_program::account_info::AccountInfo<'a>, + pub account: &'b solana_account_info::AccountInfo<'a>, /// Authority account. - pub authority: &'b solana_program::account_info::AccountInfo<'a>, + pub authority: &'b solana_account_info::AccountInfo<'a>, /// Program account. - pub program: Option<&'b solana_program::account_info::AccountInfo<'a>>, + pub program: Option<&'b solana_account_info::AccountInfo<'a>>, /// Program data account. - pub program_data: Option<&'b solana_program::account_info::AccountInfo<'a>>, + pub program_data: Option<&'b solana_account_info::AccountInfo<'a>>, /// Destination account. - pub destination: &'b solana_program::account_info::AccountInfo<'a>, + pub destination: &'b solana_account_info::AccountInfo<'a>, } impl<'a, 'b> CloseCpi<'a, 'b> { pub fn new( - program: &'b solana_program::account_info::AccountInfo<'a>, + program: &'b solana_account_info::AccountInfo<'a>, accounts: CloseCpiAccounts<'a, 'b>, ) -> Self { Self { @@ -231,25 +228,18 @@ impl<'a, 'b> CloseCpi<'a, 'b> { } } #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + pub fn invoke(&self) -> solana_program_error::ProgramResult { self.invoke_signed_with_remaining_accounts(&[], &[]) } #[inline(always)] pub fn invoke_with_remaining_accounts( &self, - remaining_accounts: &[( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )], - ) -> solana_program::entrypoint::ProgramResult { + remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], + ) -> solana_program_error::ProgramResult { self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) } #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program::entrypoint::ProgramResult { + pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult { self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) } #[allow(clippy::arithmetic_side_effects)] @@ -258,57 +248,53 @@ impl<'a, 'b> CloseCpi<'a, 'b> { pub fn invoke_signed_with_remaining_accounts( &self, signers_seeds: &[&[&[u8]]], - remaining_accounts: &[( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )], - ) -> solana_program::entrypoint::ProgramResult { + remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], + ) -> solana_program_error::ProgramResult { let mut accounts = Vec::with_capacity(5 + remaining_accounts.len()); - accounts.push(solana_program::instruction::AccountMeta::new( + accounts.push(solana_instruction::AccountMeta::new( *self.account.key, false, )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( *self.authority.key, true, )); if let Some(program) = self.program { - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( *program.key, false, )); } else { - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( crate::PROGRAM_METADATA_ID, false, )); } if let Some(program_data) = self.program_data { - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( *program_data.key, false, )); } else { - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( crate::PROGRAM_METADATA_ID, false, )); } - accounts.push(solana_program::instruction::AccountMeta::new( + accounts.push(solana_instruction::AccountMeta::new( *self.destination.key, false, )); remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_program::instruction::AccountMeta { + accounts.push(solana_instruction::AccountMeta { pubkey: *remaining_account.0.key, is_signer: remaining_account.1, is_writable: remaining_account.2, }) }); - let data = borsh::to_vec(&CloseInstructionData::new()).unwrap(); + let data = CloseInstructionData::new().try_to_vec().unwrap(); - let instruction = solana_program::instruction::Instruction { + let instruction = solana_instruction::Instruction { program_id: crate::PROGRAM_METADATA_ID, accounts, data, @@ -329,9 +315,9 @@ impl<'a, 'b> CloseCpi<'a, 'b> { .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); if signers_seeds.is_empty() { - solana_program::program::invoke(&instruction, &account_infos) + solana_cpi::invoke(&instruction, &account_infos) } else { - solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds) + solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) } } } @@ -351,7 +337,7 @@ pub struct CloseCpiBuilder<'a, 'b> { } impl<'a, 'b> CloseCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { + pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { let instruction = Box::new(CloseCpiBuilderInstruction { __program: program, account: None, @@ -365,19 +351,13 @@ impl<'a, 'b> CloseCpiBuilder<'a, 'b> { } /// Account to close. #[inline(always)] - pub fn account( - &mut self, - account: &'b solana_program::account_info::AccountInfo<'a>, - ) -> &mut Self { + pub fn account(&mut self, account: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { self.instruction.account = Some(account); self } /// Authority account. #[inline(always)] - pub fn authority( - &mut self, - authority: &'b solana_program::account_info::AccountInfo<'a>, - ) -> &mut Self { + pub fn authority(&mut self, authority: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { self.instruction.authority = Some(authority); self } @@ -386,7 +366,7 @@ impl<'a, 'b> CloseCpiBuilder<'a, 'b> { #[inline(always)] pub fn program( &mut self, - program: Option<&'b solana_program::account_info::AccountInfo<'a>>, + program: Option<&'b solana_account_info::AccountInfo<'a>>, ) -> &mut Self { self.instruction.program = program; self @@ -396,7 +376,7 @@ impl<'a, 'b> CloseCpiBuilder<'a, 'b> { #[inline(always)] pub fn program_data( &mut self, - program_data: Option<&'b solana_program::account_info::AccountInfo<'a>>, + program_data: Option<&'b solana_account_info::AccountInfo<'a>>, ) -> &mut Self { self.instruction.program_data = program_data; self @@ -405,7 +385,7 @@ impl<'a, 'b> CloseCpiBuilder<'a, 'b> { #[inline(always)] pub fn destination( &mut self, - destination: &'b solana_program::account_info::AccountInfo<'a>, + destination: &'b solana_account_info::AccountInfo<'a>, ) -> &mut Self { self.instruction.destination = Some(destination); self @@ -414,7 +394,7 @@ impl<'a, 'b> CloseCpiBuilder<'a, 'b> { #[inline(always)] pub fn add_remaining_account( &mut self, - account: &'b solana_program::account_info::AccountInfo<'a>, + account: &'b solana_account_info::AccountInfo<'a>, is_writable: bool, is_signer: bool, ) -> &mut Self { @@ -430,11 +410,7 @@ impl<'a, 'b> CloseCpiBuilder<'a, 'b> { #[inline(always)] pub fn add_remaining_accounts( &mut self, - accounts: &[( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )], + accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], ) -> &mut Self { self.instruction .__remaining_accounts @@ -442,15 +418,12 @@ impl<'a, 'b> CloseCpiBuilder<'a, 'b> { self } #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + pub fn invoke(&self) -> solana_program_error::ProgramResult { self.invoke_signed(&[]) } #[allow(clippy::clone_on_copy)] #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program::entrypoint::ProgramResult { + pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult { let instruction = CloseCpi { __program: self.instruction.__program, @@ -476,16 +449,12 @@ impl<'a, 'b> CloseCpiBuilder<'a, 'b> { #[derive(Clone, Debug)] struct CloseCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_program::account_info::AccountInfo<'a>, - account: Option<&'b solana_program::account_info::AccountInfo<'a>>, - authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, - program: Option<&'b solana_program::account_info::AccountInfo<'a>>, - program_data: Option<&'b solana_program::account_info::AccountInfo<'a>>, - destination: Option<&'b solana_program::account_info::AccountInfo<'a>>, + __program: &'b solana_account_info::AccountInfo<'a>, + account: Option<&'b solana_account_info::AccountInfo<'a>>, + authority: Option<&'b solana_account_info::AccountInfo<'a>>, + program: Option<&'b solana_account_info::AccountInfo<'a>>, + program_data: Option<&'b solana_account_info::AccountInfo<'a>>, + destination: Option<&'b solana_account_info::AccountInfo<'a>>, /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )>, + __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, } diff --git a/clients/rust/src/generated/instructions/extend.rs b/clients/rust/src/generated/instructions/extend.rs index be5e049..bec9dd6 100644 --- a/clients/rust/src/generated/instructions/extend.rs +++ b/clients/rust/src/generated/instructions/extend.rs @@ -8,24 +8,23 @@ use borsh::BorshDeserialize; use borsh::BorshSerialize; +pub const EXTEND_DISCRIMINATOR: u8 = 8; + /// Accounts. #[derive(Debug)] pub struct Extend { /// Buffer or metadata account. - pub account: solana_program::pubkey::Pubkey, + pub account: solana_pubkey::Pubkey, /// Authority account. - pub authority: solana_program::pubkey::Pubkey, + pub authority: solana_pubkey::Pubkey, /// Program account. - pub program: Option, + pub program: Option, /// Program data account. - pub program_data: Option, + pub program_data: Option, } impl Extend { - pub fn instruction( - &self, - args: ExtendInstructionArgs, - ) -> solana_program::instruction::Instruction { + pub fn instruction(&self, args: ExtendInstructionArgs) -> solana_instruction::Instruction { self.instruction_with_remaining_accounts(args, &[]) } #[allow(clippy::arithmetic_side_effects)] @@ -33,44 +32,41 @@ impl Extend { pub fn instruction_with_remaining_accounts( &self, args: ExtendInstructionArgs, - remaining_accounts: &[solana_program::instruction::AccountMeta], - ) -> solana_program::instruction::Instruction { + remaining_accounts: &[solana_instruction::AccountMeta], + ) -> solana_instruction::Instruction { let mut accounts = Vec::with_capacity(4 + remaining_accounts.len()); - accounts.push(solana_program::instruction::AccountMeta::new( - self.account, - false, - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new(self.account, false)); + accounts.push(solana_instruction::AccountMeta::new_readonly( self.authority, true, )); if let Some(program) = self.program { - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( program, false, )); } else { - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( crate::PROGRAM_METADATA_ID, false, )); } if let Some(program_data) = self.program_data { - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( program_data, false, )); } else { - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( crate::PROGRAM_METADATA_ID, false, )); } accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&ExtendInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); + let mut data = ExtendInstructionData::new().try_to_vec().unwrap(); + let mut args = args.try_to_vec().unwrap(); data.append(&mut args); - solana_program::instruction::Instruction { + solana_instruction::Instruction { program_id: crate::PROGRAM_METADATA_ID, accounts, data, @@ -88,6 +84,10 @@ impl ExtendInstructionData { pub fn new() -> Self { Self { discriminator: 8 } } + + pub(crate) fn try_to_vec(&self) -> Result, std::io::Error> { + borsh::to_vec(self) + } } impl Default for ExtendInstructionData { @@ -102,6 +102,12 @@ pub struct ExtendInstructionArgs { pub length: u16, } +impl ExtendInstructionArgs { + pub(crate) fn try_to_vec(&self) -> Result, std::io::Error> { + borsh::to_vec(self) + } +} + /// Instruction builder for `Extend`. /// /// ### Accounts: @@ -112,12 +118,12 @@ pub struct ExtendInstructionArgs { /// 3. `[optional]` program_data #[derive(Clone, Debug, Default)] pub struct ExtendBuilder { - account: Option, - authority: Option, - program: Option, - program_data: Option, + account: Option, + authority: Option, + program: Option, + program_data: Option, length: Option, - __remaining_accounts: Vec, + __remaining_accounts: Vec, } impl ExtendBuilder { @@ -126,30 +132,27 @@ impl ExtendBuilder { } /// Buffer or metadata account. #[inline(always)] - pub fn account(&mut self, account: solana_program::pubkey::Pubkey) -> &mut Self { + pub fn account(&mut self, account: solana_pubkey::Pubkey) -> &mut Self { self.account = Some(account); self } /// Authority account. #[inline(always)] - pub fn authority(&mut self, authority: solana_program::pubkey::Pubkey) -> &mut Self { + pub fn authority(&mut self, authority: solana_pubkey::Pubkey) -> &mut Self { self.authority = Some(authority); self } /// `[optional account]` /// Program account. #[inline(always)] - pub fn program(&mut self, program: Option) -> &mut Self { + pub fn program(&mut self, program: Option) -> &mut Self { self.program = program; self } /// `[optional account]` /// Program data account. #[inline(always)] - pub fn program_data( - &mut self, - program_data: Option, - ) -> &mut Self { + pub fn program_data(&mut self, program_data: Option) -> &mut Self { self.program_data = program_data; self } @@ -160,10 +163,7 @@ impl ExtendBuilder { } /// Add an additional account to the instruction. #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: solana_program::instruction::AccountMeta, - ) -> &mut Self { + pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { self.__remaining_accounts.push(account); self } @@ -171,13 +171,13 @@ impl ExtendBuilder { #[inline(always)] pub fn add_remaining_accounts( &mut self, - accounts: &[solana_program::instruction::AccountMeta], + accounts: &[solana_instruction::AccountMeta], ) -> &mut Self { self.__remaining_accounts.extend_from_slice(accounts); self } #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_program::instruction::Instruction { + pub fn instruction(&self) -> solana_instruction::Instruction { let accounts = Extend { account: self.account.expect("account is not set"), authority: self.authority.expect("authority is not set"), @@ -195,34 +195,34 @@ impl ExtendBuilder { /// `extend` CPI accounts. pub struct ExtendCpiAccounts<'a, 'b> { /// Buffer or metadata account. - pub account: &'b solana_program::account_info::AccountInfo<'a>, + pub account: &'b solana_account_info::AccountInfo<'a>, /// Authority account. - pub authority: &'b solana_program::account_info::AccountInfo<'a>, + pub authority: &'b solana_account_info::AccountInfo<'a>, /// Program account. - pub program: Option<&'b solana_program::account_info::AccountInfo<'a>>, + pub program: Option<&'b solana_account_info::AccountInfo<'a>>, /// Program data account. - pub program_data: Option<&'b solana_program::account_info::AccountInfo<'a>>, + pub program_data: Option<&'b solana_account_info::AccountInfo<'a>>, } /// `extend` CPI instruction. pub struct ExtendCpi<'a, 'b> { /// The program to invoke. - pub __program: &'b solana_program::account_info::AccountInfo<'a>, + pub __program: &'b solana_account_info::AccountInfo<'a>, /// Buffer or metadata account. - pub account: &'b solana_program::account_info::AccountInfo<'a>, + pub account: &'b solana_account_info::AccountInfo<'a>, /// Authority account. - pub authority: &'b solana_program::account_info::AccountInfo<'a>, + pub authority: &'b solana_account_info::AccountInfo<'a>, /// Program account. - pub program: Option<&'b solana_program::account_info::AccountInfo<'a>>, + pub program: Option<&'b solana_account_info::AccountInfo<'a>>, /// Program data account. - pub program_data: Option<&'b solana_program::account_info::AccountInfo<'a>>, + pub program_data: Option<&'b solana_account_info::AccountInfo<'a>>, /// The arguments for the instruction. pub __args: ExtendInstructionArgs, } impl<'a, 'b> ExtendCpi<'a, 'b> { pub fn new( - program: &'b solana_program::account_info::AccountInfo<'a>, + program: &'b solana_account_info::AccountInfo<'a>, accounts: ExtendCpiAccounts<'a, 'b>, args: ExtendInstructionArgs, ) -> Self { @@ -236,25 +236,18 @@ impl<'a, 'b> ExtendCpi<'a, 'b> { } } #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + pub fn invoke(&self) -> solana_program_error::ProgramResult { self.invoke_signed_with_remaining_accounts(&[], &[]) } #[inline(always)] pub fn invoke_with_remaining_accounts( &self, - remaining_accounts: &[( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )], - ) -> solana_program::entrypoint::ProgramResult { + remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], + ) -> solana_program_error::ProgramResult { self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) } #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program::entrypoint::ProgramResult { + pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult { self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) } #[allow(clippy::arithmetic_side_effects)] @@ -263,55 +256,51 @@ impl<'a, 'b> ExtendCpi<'a, 'b> { pub fn invoke_signed_with_remaining_accounts( &self, signers_seeds: &[&[&[u8]]], - remaining_accounts: &[( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )], - ) -> solana_program::entrypoint::ProgramResult { + remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], + ) -> solana_program_error::ProgramResult { let mut accounts = Vec::with_capacity(4 + remaining_accounts.len()); - accounts.push(solana_program::instruction::AccountMeta::new( + accounts.push(solana_instruction::AccountMeta::new( *self.account.key, false, )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( *self.authority.key, true, )); if let Some(program) = self.program { - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( *program.key, false, )); } else { - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( crate::PROGRAM_METADATA_ID, false, )); } if let Some(program_data) = self.program_data { - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( *program_data.key, false, )); } else { - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( crate::PROGRAM_METADATA_ID, false, )); } remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_program::instruction::AccountMeta { + accounts.push(solana_instruction::AccountMeta { pubkey: *remaining_account.0.key, is_signer: remaining_account.1, is_writable: remaining_account.2, }) }); - let mut data = borsh::to_vec(&ExtendInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); + let mut data = ExtendInstructionData::new().try_to_vec().unwrap(); + let mut args = self.__args.try_to_vec().unwrap(); data.append(&mut args); - let instruction = solana_program::instruction::Instruction { + let instruction = solana_instruction::Instruction { program_id: crate::PROGRAM_METADATA_ID, accounts, data, @@ -331,9 +320,9 @@ impl<'a, 'b> ExtendCpi<'a, 'b> { .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); if signers_seeds.is_empty() { - solana_program::program::invoke(&instruction, &account_infos) + solana_cpi::invoke(&instruction, &account_infos) } else { - solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds) + solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) } } } @@ -352,7 +341,7 @@ pub struct ExtendCpiBuilder<'a, 'b> { } impl<'a, 'b> ExtendCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { + pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { let instruction = Box::new(ExtendCpiBuilderInstruction { __program: program, account: None, @@ -366,19 +355,13 @@ impl<'a, 'b> ExtendCpiBuilder<'a, 'b> { } /// Buffer or metadata account. #[inline(always)] - pub fn account( - &mut self, - account: &'b solana_program::account_info::AccountInfo<'a>, - ) -> &mut Self { + pub fn account(&mut self, account: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { self.instruction.account = Some(account); self } /// Authority account. #[inline(always)] - pub fn authority( - &mut self, - authority: &'b solana_program::account_info::AccountInfo<'a>, - ) -> &mut Self { + pub fn authority(&mut self, authority: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { self.instruction.authority = Some(authority); self } @@ -387,7 +370,7 @@ impl<'a, 'b> ExtendCpiBuilder<'a, 'b> { #[inline(always)] pub fn program( &mut self, - program: Option<&'b solana_program::account_info::AccountInfo<'a>>, + program: Option<&'b solana_account_info::AccountInfo<'a>>, ) -> &mut Self { self.instruction.program = program; self @@ -397,7 +380,7 @@ impl<'a, 'b> ExtendCpiBuilder<'a, 'b> { #[inline(always)] pub fn program_data( &mut self, - program_data: Option<&'b solana_program::account_info::AccountInfo<'a>>, + program_data: Option<&'b solana_account_info::AccountInfo<'a>>, ) -> &mut Self { self.instruction.program_data = program_data; self @@ -411,7 +394,7 @@ impl<'a, 'b> ExtendCpiBuilder<'a, 'b> { #[inline(always)] pub fn add_remaining_account( &mut self, - account: &'b solana_program::account_info::AccountInfo<'a>, + account: &'b solana_account_info::AccountInfo<'a>, is_writable: bool, is_signer: bool, ) -> &mut Self { @@ -427,11 +410,7 @@ impl<'a, 'b> ExtendCpiBuilder<'a, 'b> { #[inline(always)] pub fn add_remaining_accounts( &mut self, - accounts: &[( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )], + accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], ) -> &mut Self { self.instruction .__remaining_accounts @@ -439,15 +418,12 @@ impl<'a, 'b> ExtendCpiBuilder<'a, 'b> { self } #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + pub fn invoke(&self) -> solana_program_error::ProgramResult { self.invoke_signed(&[]) } #[allow(clippy::clone_on_copy)] #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program::entrypoint::ProgramResult { + pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult { let args = ExtendInstructionArgs { length: self.instruction.length.clone().expect("length is not set"), }; @@ -472,16 +448,12 @@ impl<'a, 'b> ExtendCpiBuilder<'a, 'b> { #[derive(Clone, Debug)] struct ExtendCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_program::account_info::AccountInfo<'a>, - account: Option<&'b solana_program::account_info::AccountInfo<'a>>, - authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, - program: Option<&'b solana_program::account_info::AccountInfo<'a>>, - program_data: Option<&'b solana_program::account_info::AccountInfo<'a>>, + __program: &'b solana_account_info::AccountInfo<'a>, + account: Option<&'b solana_account_info::AccountInfo<'a>>, + authority: Option<&'b solana_account_info::AccountInfo<'a>>, + program: Option<&'b solana_account_info::AccountInfo<'a>>, + program_data: Option<&'b solana_account_info::AccountInfo<'a>>, length: Option, /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )>, + __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, } diff --git a/clients/rust/src/generated/instructions/initialize.rs b/clients/rust/src/generated/instructions/initialize.rs index 5c172d1..540a0d3 100644 --- a/clients/rust/src/generated/instructions/initialize.rs +++ b/clients/rust/src/generated/instructions/initialize.rs @@ -14,26 +14,25 @@ use crate::hooked::RemainderOptionBytes; use borsh::BorshDeserialize; use borsh::BorshSerialize; +pub const INITIALIZE_DISCRIMINATOR: u8 = 1; + /// Accounts. #[derive(Debug)] pub struct Initialize { /// Metadata account the initialize. - pub metadata: solana_program::pubkey::Pubkey, + pub metadata: solana_pubkey::Pubkey, /// Authority (for canonical, must match program upgrade authority). - pub authority: solana_program::pubkey::Pubkey, + pub authority: solana_pubkey::Pubkey, /// Program account. - pub program: solana_program::pubkey::Pubkey, + pub program: solana_pubkey::Pubkey, /// Program data account. - pub program_data: Option, + pub program_data: Option, /// System program. - pub system: Option, + pub system: Option, } impl Initialize { - pub fn instruction( - &self, - args: InitializeInstructionArgs, - ) -> solana_program::instruction::Instruction { + pub fn instruction(&self, args: InitializeInstructionArgs) -> solana_instruction::Instruction { self.instruction_with_remaining_accounts(args, &[]) } #[allow(clippy::arithmetic_side_effects)] @@ -41,48 +40,43 @@ impl Initialize { pub fn instruction_with_remaining_accounts( &self, args: InitializeInstructionArgs, - remaining_accounts: &[solana_program::instruction::AccountMeta], - ) -> solana_program::instruction::Instruction { + remaining_accounts: &[solana_instruction::AccountMeta], + ) -> solana_instruction::Instruction { let mut accounts = Vec::with_capacity(5 + remaining_accounts.len()); - accounts.push(solana_program::instruction::AccountMeta::new( - self.metadata, - false, - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new(self.metadata, false)); + accounts.push(solana_instruction::AccountMeta::new_readonly( self.authority, true, )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( self.program, false, )); if let Some(program_data) = self.program_data { - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( program_data, false, )); } else { - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( crate::PROGRAM_METADATA_ID, false, )); } if let Some(system) = self.system { - accounts.push(solana_program::instruction::AccountMeta::new_readonly( - system, false, - )); + accounts.push(solana_instruction::AccountMeta::new_readonly(system, false)); } else { - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( crate::PROGRAM_METADATA_ID, false, )); } accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&InitializeInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); + let mut data = InitializeInstructionData::new().try_to_vec().unwrap(); + let mut args = args.try_to_vec().unwrap(); data.append(&mut args); - solana_program::instruction::Instruction { + solana_instruction::Instruction { program_id: crate::PROGRAM_METADATA_ID, accounts, data, @@ -100,6 +94,10 @@ impl InitializeInstructionData { pub fn new() -> Self { Self { discriminator: 1 } } + + pub(crate) fn try_to_vec(&self) -> Result, std::io::Error> { + borsh::to_vec(self) + } } impl Default for InitializeInstructionData { @@ -119,6 +117,12 @@ pub struct InitializeInstructionArgs { pub data: RemainderOptionBytes, } +impl InitializeInstructionArgs { + pub(crate) fn try_to_vec(&self) -> Result, std::io::Error> { + borsh::to_vec(self) + } +} + /// Instruction builder for `Initialize`. /// /// ### Accounts: @@ -130,18 +134,18 @@ pub struct InitializeInstructionArgs { /// 4. `[optional]` system (default to `11111111111111111111111111111111`) #[derive(Clone, Debug, Default)] pub struct InitializeBuilder { - metadata: Option, - authority: Option, - program: Option, - program_data: Option, - system: Option, + metadata: Option, + authority: Option, + program: Option, + program_data: Option, + system: Option, seed: Option, encoding: Option, compression: Option, format: Option, data_source: Option, data: Option, - __remaining_accounts: Vec, + __remaining_accounts: Vec, } impl InitializeBuilder { @@ -150,36 +154,33 @@ impl InitializeBuilder { } /// Metadata account the initialize. #[inline(always)] - pub fn metadata(&mut self, metadata: solana_program::pubkey::Pubkey) -> &mut Self { + pub fn metadata(&mut self, metadata: solana_pubkey::Pubkey) -> &mut Self { self.metadata = Some(metadata); self } /// Authority (for canonical, must match program upgrade authority). #[inline(always)] - pub fn authority(&mut self, authority: solana_program::pubkey::Pubkey) -> &mut Self { + pub fn authority(&mut self, authority: solana_pubkey::Pubkey) -> &mut Self { self.authority = Some(authority); self } /// Program account. #[inline(always)] - pub fn program(&mut self, program: solana_program::pubkey::Pubkey) -> &mut Self { + pub fn program(&mut self, program: solana_pubkey::Pubkey) -> &mut Self { self.program = Some(program); self } /// `[optional account]` /// Program data account. #[inline(always)] - pub fn program_data( - &mut self, - program_data: Option, - ) -> &mut Self { + pub fn program_data(&mut self, program_data: Option) -> &mut Self { self.program_data = program_data; self } /// `[optional account]` /// System program. #[inline(always)] - pub fn system(&mut self, system: Option) -> &mut Self { + pub fn system(&mut self, system: Option) -> &mut Self { self.system = system; self } @@ -215,10 +216,7 @@ impl InitializeBuilder { } /// Add an additional account to the instruction. #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: solana_program::instruction::AccountMeta, - ) -> &mut Self { + pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { self.__remaining_accounts.push(account); self } @@ -226,13 +224,13 @@ impl InitializeBuilder { #[inline(always)] pub fn add_remaining_accounts( &mut self, - accounts: &[solana_program::instruction::AccountMeta], + accounts: &[solana_instruction::AccountMeta], ) -> &mut Self { self.__remaining_accounts.extend_from_slice(accounts); self } #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_program::instruction::Instruction { + pub fn instruction(&self) -> solana_instruction::Instruction { let accounts = Initialize { metadata: self.metadata.expect("metadata is not set"), authority: self.authority.expect("authority is not set"), @@ -256,38 +254,38 @@ impl InitializeBuilder { /// `initialize` CPI accounts. pub struct InitializeCpiAccounts<'a, 'b> { /// Metadata account the initialize. - pub metadata: &'b solana_program::account_info::AccountInfo<'a>, + pub metadata: &'b solana_account_info::AccountInfo<'a>, /// Authority (for canonical, must match program upgrade authority). - pub authority: &'b solana_program::account_info::AccountInfo<'a>, + pub authority: &'b solana_account_info::AccountInfo<'a>, /// Program account. - pub program: &'b solana_program::account_info::AccountInfo<'a>, + pub program: &'b solana_account_info::AccountInfo<'a>, /// Program data account. - pub program_data: Option<&'b solana_program::account_info::AccountInfo<'a>>, + pub program_data: Option<&'b solana_account_info::AccountInfo<'a>>, /// System program. - pub system: Option<&'b solana_program::account_info::AccountInfo<'a>>, + pub system: Option<&'b solana_account_info::AccountInfo<'a>>, } /// `initialize` CPI instruction. pub struct InitializeCpi<'a, 'b> { /// The program to invoke. - pub __program: &'b solana_program::account_info::AccountInfo<'a>, + pub __program: &'b solana_account_info::AccountInfo<'a>, /// Metadata account the initialize. - pub metadata: &'b solana_program::account_info::AccountInfo<'a>, + pub metadata: &'b solana_account_info::AccountInfo<'a>, /// Authority (for canonical, must match program upgrade authority). - pub authority: &'b solana_program::account_info::AccountInfo<'a>, + pub authority: &'b solana_account_info::AccountInfo<'a>, /// Program account. - pub program: &'b solana_program::account_info::AccountInfo<'a>, + pub program: &'b solana_account_info::AccountInfo<'a>, /// Program data account. - pub program_data: Option<&'b solana_program::account_info::AccountInfo<'a>>, + pub program_data: Option<&'b solana_account_info::AccountInfo<'a>>, /// System program. - pub system: Option<&'b solana_program::account_info::AccountInfo<'a>>, + pub system: Option<&'b solana_account_info::AccountInfo<'a>>, /// The arguments for the instruction. pub __args: InitializeInstructionArgs, } impl<'a, 'b> InitializeCpi<'a, 'b> { pub fn new( - program: &'b solana_program::account_info::AccountInfo<'a>, + program: &'b solana_account_info::AccountInfo<'a>, accounts: InitializeCpiAccounts<'a, 'b>, args: InitializeInstructionArgs, ) -> Self { @@ -302,25 +300,18 @@ impl<'a, 'b> InitializeCpi<'a, 'b> { } } #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + pub fn invoke(&self) -> solana_program_error::ProgramResult { self.invoke_signed_with_remaining_accounts(&[], &[]) } #[inline(always)] pub fn invoke_with_remaining_accounts( &self, - remaining_accounts: &[( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )], - ) -> solana_program::entrypoint::ProgramResult { + remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], + ) -> solana_program_error::ProgramResult { self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) } #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program::entrypoint::ProgramResult { + pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult { self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) } #[allow(clippy::arithmetic_side_effects)] @@ -329,59 +320,55 @@ impl<'a, 'b> InitializeCpi<'a, 'b> { pub fn invoke_signed_with_remaining_accounts( &self, signers_seeds: &[&[&[u8]]], - remaining_accounts: &[( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )], - ) -> solana_program::entrypoint::ProgramResult { + remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], + ) -> solana_program_error::ProgramResult { let mut accounts = Vec::with_capacity(5 + remaining_accounts.len()); - accounts.push(solana_program::instruction::AccountMeta::new( + accounts.push(solana_instruction::AccountMeta::new( *self.metadata.key, false, )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( *self.authority.key, true, )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( *self.program.key, false, )); if let Some(program_data) = self.program_data { - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( *program_data.key, false, )); } else { - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( crate::PROGRAM_METADATA_ID, false, )); } if let Some(system) = self.system { - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( *system.key, false, )); } else { - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( crate::PROGRAM_METADATA_ID, false, )); } remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_program::instruction::AccountMeta { + accounts.push(solana_instruction::AccountMeta { pubkey: *remaining_account.0.key, is_signer: remaining_account.1, is_writable: remaining_account.2, }) }); - let mut data = borsh::to_vec(&InitializeInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); + let mut data = InitializeInstructionData::new().try_to_vec().unwrap(); + let mut args = self.__args.try_to_vec().unwrap(); data.append(&mut args); - let instruction = solana_program::instruction::Instruction { + let instruction = solana_instruction::Instruction { program_id: crate::PROGRAM_METADATA_ID, accounts, data, @@ -402,9 +389,9 @@ impl<'a, 'b> InitializeCpi<'a, 'b> { .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); if signers_seeds.is_empty() { - solana_program::program::invoke(&instruction, &account_infos) + solana_cpi::invoke(&instruction, &account_infos) } else { - solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds) + solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) } } } @@ -424,7 +411,7 @@ pub struct InitializeCpiBuilder<'a, 'b> { } impl<'a, 'b> InitializeCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { + pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { let instruction = Box::new(InitializeCpiBuilderInstruction { __program: program, metadata: None, @@ -444,28 +431,19 @@ impl<'a, 'b> InitializeCpiBuilder<'a, 'b> { } /// Metadata account the initialize. #[inline(always)] - pub fn metadata( - &mut self, - metadata: &'b solana_program::account_info::AccountInfo<'a>, - ) -> &mut Self { + pub fn metadata(&mut self, metadata: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { self.instruction.metadata = Some(metadata); self } /// Authority (for canonical, must match program upgrade authority). #[inline(always)] - pub fn authority( - &mut self, - authority: &'b solana_program::account_info::AccountInfo<'a>, - ) -> &mut Self { + pub fn authority(&mut self, authority: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { self.instruction.authority = Some(authority); self } /// Program account. #[inline(always)] - pub fn program( - &mut self, - program: &'b solana_program::account_info::AccountInfo<'a>, - ) -> &mut Self { + pub fn program(&mut self, program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { self.instruction.program = Some(program); self } @@ -474,7 +452,7 @@ impl<'a, 'b> InitializeCpiBuilder<'a, 'b> { #[inline(always)] pub fn program_data( &mut self, - program_data: Option<&'b solana_program::account_info::AccountInfo<'a>>, + program_data: Option<&'b solana_account_info::AccountInfo<'a>>, ) -> &mut Self { self.instruction.program_data = program_data; self @@ -484,7 +462,7 @@ impl<'a, 'b> InitializeCpiBuilder<'a, 'b> { #[inline(always)] pub fn system( &mut self, - system: Option<&'b solana_program::account_info::AccountInfo<'a>>, + system: Option<&'b solana_account_info::AccountInfo<'a>>, ) -> &mut Self { self.instruction.system = system; self @@ -523,7 +501,7 @@ impl<'a, 'b> InitializeCpiBuilder<'a, 'b> { #[inline(always)] pub fn add_remaining_account( &mut self, - account: &'b solana_program::account_info::AccountInfo<'a>, + account: &'b solana_account_info::AccountInfo<'a>, is_writable: bool, is_signer: bool, ) -> &mut Self { @@ -539,11 +517,7 @@ impl<'a, 'b> InitializeCpiBuilder<'a, 'b> { #[inline(always)] pub fn add_remaining_accounts( &mut self, - accounts: &[( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )], + accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], ) -> &mut Self { self.instruction .__remaining_accounts @@ -551,15 +525,12 @@ impl<'a, 'b> InitializeCpiBuilder<'a, 'b> { self } #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + pub fn invoke(&self) -> solana_program_error::ProgramResult { self.invoke_signed(&[]) } #[allow(clippy::clone_on_copy)] #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program::entrypoint::ProgramResult { + pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult { let args = InitializeInstructionArgs { seed: self.instruction.seed.clone().expect("seed is not set"), encoding: self @@ -603,12 +574,12 @@ impl<'a, 'b> InitializeCpiBuilder<'a, 'b> { #[derive(Clone, Debug)] struct InitializeCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_program::account_info::AccountInfo<'a>, - metadata: Option<&'b solana_program::account_info::AccountInfo<'a>>, - authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, - program: Option<&'b solana_program::account_info::AccountInfo<'a>>, - program_data: Option<&'b solana_program::account_info::AccountInfo<'a>>, - system: Option<&'b solana_program::account_info::AccountInfo<'a>>, + __program: &'b solana_account_info::AccountInfo<'a>, + metadata: Option<&'b solana_account_info::AccountInfo<'a>>, + authority: Option<&'b solana_account_info::AccountInfo<'a>>, + program: Option<&'b solana_account_info::AccountInfo<'a>>, + program_data: Option<&'b solana_account_info::AccountInfo<'a>>, + system: Option<&'b solana_account_info::AccountInfo<'a>>, seed: Option, encoding: Option, compression: Option, @@ -616,9 +587,5 @@ struct InitializeCpiBuilderInstruction<'a, 'b> { data_source: Option, data: Option, /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )>, + __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, } diff --git a/clients/rust/src/generated/instructions/set_authority.rs b/clients/rust/src/generated/instructions/set_authority.rs index 269407e..2375c89 100644 --- a/clients/rust/src/generated/instructions/set_authority.rs +++ b/clients/rust/src/generated/instructions/set_authority.rs @@ -7,26 +7,28 @@ use borsh::BorshDeserialize; use borsh::BorshSerialize; -use solana_program::pubkey::Pubkey; +use solana_pubkey::Pubkey; + +pub const SET_AUTHORITY_DISCRIMINATOR: u8 = 2; /// Accounts. #[derive(Debug)] pub struct SetAuthority { /// Metadata or buffer account. - pub account: solana_program::pubkey::Pubkey, + pub account: solana_pubkey::Pubkey, /// Current authority account. - pub authority: solana_program::pubkey::Pubkey, + pub authority: solana_pubkey::Pubkey, /// Program account. - pub program: Option, + pub program: Option, /// Program data account. - pub program_data: Option, + pub program_data: Option, } impl SetAuthority { pub fn instruction( &self, args: SetAuthorityInstructionArgs, - ) -> solana_program::instruction::Instruction { + ) -> solana_instruction::Instruction { self.instruction_with_remaining_accounts(args, &[]) } #[allow(clippy::arithmetic_side_effects)] @@ -34,44 +36,41 @@ impl SetAuthority { pub fn instruction_with_remaining_accounts( &self, args: SetAuthorityInstructionArgs, - remaining_accounts: &[solana_program::instruction::AccountMeta], - ) -> solana_program::instruction::Instruction { + remaining_accounts: &[solana_instruction::AccountMeta], + ) -> solana_instruction::Instruction { let mut accounts = Vec::with_capacity(4 + remaining_accounts.len()); - accounts.push(solana_program::instruction::AccountMeta::new( - self.account, - false, - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new(self.account, false)); + accounts.push(solana_instruction::AccountMeta::new_readonly( self.authority, true, )); if let Some(program) = self.program { - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( program, false, )); } else { - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( crate::PROGRAM_METADATA_ID, false, )); } if let Some(program_data) = self.program_data { - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( program_data, false, )); } else { - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( crate::PROGRAM_METADATA_ID, false, )); } accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&SetAuthorityInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); + let mut data = SetAuthorityInstructionData::new().try_to_vec().unwrap(); + let mut args = args.try_to_vec().unwrap(); data.append(&mut args); - solana_program::instruction::Instruction { + solana_instruction::Instruction { program_id: crate::PROGRAM_METADATA_ID, accounts, data, @@ -89,6 +88,10 @@ impl SetAuthorityInstructionData { pub fn new() -> Self { Self { discriminator: 2 } } + + pub(crate) fn try_to_vec(&self) -> Result, std::io::Error> { + borsh::to_vec(self) + } } impl Default for SetAuthorityInstructionData { @@ -103,6 +106,12 @@ pub struct SetAuthorityInstructionArgs { pub new_authority: Option, } +impl SetAuthorityInstructionArgs { + pub(crate) fn try_to_vec(&self) -> Result, std::io::Error> { + borsh::to_vec(self) + } +} + /// Instruction builder for `SetAuthority`. /// /// ### Accounts: @@ -113,12 +122,12 @@ pub struct SetAuthorityInstructionArgs { /// 3. `[optional]` program_data #[derive(Clone, Debug, Default)] pub struct SetAuthorityBuilder { - account: Option, - authority: Option, - program: Option, - program_data: Option, + account: Option, + authority: Option, + program: Option, + program_data: Option, new_authority: Option, - __remaining_accounts: Vec, + __remaining_accounts: Vec, } impl SetAuthorityBuilder { @@ -127,30 +136,27 @@ impl SetAuthorityBuilder { } /// Metadata or buffer account. #[inline(always)] - pub fn account(&mut self, account: solana_program::pubkey::Pubkey) -> &mut Self { + pub fn account(&mut self, account: solana_pubkey::Pubkey) -> &mut Self { self.account = Some(account); self } /// Current authority account. #[inline(always)] - pub fn authority(&mut self, authority: solana_program::pubkey::Pubkey) -> &mut Self { + pub fn authority(&mut self, authority: solana_pubkey::Pubkey) -> &mut Self { self.authority = Some(authority); self } /// `[optional account]` /// Program account. #[inline(always)] - pub fn program(&mut self, program: Option) -> &mut Self { + pub fn program(&mut self, program: Option) -> &mut Self { self.program = program; self } /// `[optional account]` /// Program data account. #[inline(always)] - pub fn program_data( - &mut self, - program_data: Option, - ) -> &mut Self { + pub fn program_data(&mut self, program_data: Option) -> &mut Self { self.program_data = program_data; self } @@ -162,10 +168,7 @@ impl SetAuthorityBuilder { } /// Add an additional account to the instruction. #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: solana_program::instruction::AccountMeta, - ) -> &mut Self { + pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { self.__remaining_accounts.push(account); self } @@ -173,13 +176,13 @@ impl SetAuthorityBuilder { #[inline(always)] pub fn add_remaining_accounts( &mut self, - accounts: &[solana_program::instruction::AccountMeta], + accounts: &[solana_instruction::AccountMeta], ) -> &mut Self { self.__remaining_accounts.extend_from_slice(accounts); self } #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_program::instruction::Instruction { + pub fn instruction(&self) -> solana_instruction::Instruction { let accounts = SetAuthority { account: self.account.expect("account is not set"), authority: self.authority.expect("authority is not set"), @@ -197,34 +200,34 @@ impl SetAuthorityBuilder { /// `set_authority` CPI accounts. pub struct SetAuthorityCpiAccounts<'a, 'b> { /// Metadata or buffer account. - pub account: &'b solana_program::account_info::AccountInfo<'a>, + pub account: &'b solana_account_info::AccountInfo<'a>, /// Current authority account. - pub authority: &'b solana_program::account_info::AccountInfo<'a>, + pub authority: &'b solana_account_info::AccountInfo<'a>, /// Program account. - pub program: Option<&'b solana_program::account_info::AccountInfo<'a>>, + pub program: Option<&'b solana_account_info::AccountInfo<'a>>, /// Program data account. - pub program_data: Option<&'b solana_program::account_info::AccountInfo<'a>>, + pub program_data: Option<&'b solana_account_info::AccountInfo<'a>>, } /// `set_authority` CPI instruction. pub struct SetAuthorityCpi<'a, 'b> { /// The program to invoke. - pub __program: &'b solana_program::account_info::AccountInfo<'a>, + pub __program: &'b solana_account_info::AccountInfo<'a>, /// Metadata or buffer account. - pub account: &'b solana_program::account_info::AccountInfo<'a>, + pub account: &'b solana_account_info::AccountInfo<'a>, /// Current authority account. - pub authority: &'b solana_program::account_info::AccountInfo<'a>, + pub authority: &'b solana_account_info::AccountInfo<'a>, /// Program account. - pub program: Option<&'b solana_program::account_info::AccountInfo<'a>>, + pub program: Option<&'b solana_account_info::AccountInfo<'a>>, /// Program data account. - pub program_data: Option<&'b solana_program::account_info::AccountInfo<'a>>, + pub program_data: Option<&'b solana_account_info::AccountInfo<'a>>, /// The arguments for the instruction. pub __args: SetAuthorityInstructionArgs, } impl<'a, 'b> SetAuthorityCpi<'a, 'b> { pub fn new( - program: &'b solana_program::account_info::AccountInfo<'a>, + program: &'b solana_account_info::AccountInfo<'a>, accounts: SetAuthorityCpiAccounts<'a, 'b>, args: SetAuthorityInstructionArgs, ) -> Self { @@ -238,25 +241,18 @@ impl<'a, 'b> SetAuthorityCpi<'a, 'b> { } } #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + pub fn invoke(&self) -> solana_program_error::ProgramResult { self.invoke_signed_with_remaining_accounts(&[], &[]) } #[inline(always)] pub fn invoke_with_remaining_accounts( &self, - remaining_accounts: &[( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )], - ) -> solana_program::entrypoint::ProgramResult { + remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], + ) -> solana_program_error::ProgramResult { self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) } #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program::entrypoint::ProgramResult { + pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult { self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) } #[allow(clippy::arithmetic_side_effects)] @@ -265,55 +261,51 @@ impl<'a, 'b> SetAuthorityCpi<'a, 'b> { pub fn invoke_signed_with_remaining_accounts( &self, signers_seeds: &[&[&[u8]]], - remaining_accounts: &[( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )], - ) -> solana_program::entrypoint::ProgramResult { + remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], + ) -> solana_program_error::ProgramResult { let mut accounts = Vec::with_capacity(4 + remaining_accounts.len()); - accounts.push(solana_program::instruction::AccountMeta::new( + accounts.push(solana_instruction::AccountMeta::new( *self.account.key, false, )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( *self.authority.key, true, )); if let Some(program) = self.program { - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( *program.key, false, )); } else { - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( crate::PROGRAM_METADATA_ID, false, )); } if let Some(program_data) = self.program_data { - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( *program_data.key, false, )); } else { - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( crate::PROGRAM_METADATA_ID, false, )); } remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_program::instruction::AccountMeta { + accounts.push(solana_instruction::AccountMeta { pubkey: *remaining_account.0.key, is_signer: remaining_account.1, is_writable: remaining_account.2, }) }); - let mut data = borsh::to_vec(&SetAuthorityInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); + let mut data = SetAuthorityInstructionData::new().try_to_vec().unwrap(); + let mut args = self.__args.try_to_vec().unwrap(); data.append(&mut args); - let instruction = solana_program::instruction::Instruction { + let instruction = solana_instruction::Instruction { program_id: crate::PROGRAM_METADATA_ID, accounts, data, @@ -333,9 +325,9 @@ impl<'a, 'b> SetAuthorityCpi<'a, 'b> { .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); if signers_seeds.is_empty() { - solana_program::program::invoke(&instruction, &account_infos) + solana_cpi::invoke(&instruction, &account_infos) } else { - solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds) + solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) } } } @@ -354,7 +346,7 @@ pub struct SetAuthorityCpiBuilder<'a, 'b> { } impl<'a, 'b> SetAuthorityCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { + pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { let instruction = Box::new(SetAuthorityCpiBuilderInstruction { __program: program, account: None, @@ -368,19 +360,13 @@ impl<'a, 'b> SetAuthorityCpiBuilder<'a, 'b> { } /// Metadata or buffer account. #[inline(always)] - pub fn account( - &mut self, - account: &'b solana_program::account_info::AccountInfo<'a>, - ) -> &mut Self { + pub fn account(&mut self, account: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { self.instruction.account = Some(account); self } /// Current authority account. #[inline(always)] - pub fn authority( - &mut self, - authority: &'b solana_program::account_info::AccountInfo<'a>, - ) -> &mut Self { + pub fn authority(&mut self, authority: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { self.instruction.authority = Some(authority); self } @@ -389,7 +375,7 @@ impl<'a, 'b> SetAuthorityCpiBuilder<'a, 'b> { #[inline(always)] pub fn program( &mut self, - program: Option<&'b solana_program::account_info::AccountInfo<'a>>, + program: Option<&'b solana_account_info::AccountInfo<'a>>, ) -> &mut Self { self.instruction.program = program; self @@ -399,7 +385,7 @@ impl<'a, 'b> SetAuthorityCpiBuilder<'a, 'b> { #[inline(always)] pub fn program_data( &mut self, - program_data: Option<&'b solana_program::account_info::AccountInfo<'a>>, + program_data: Option<&'b solana_account_info::AccountInfo<'a>>, ) -> &mut Self { self.instruction.program_data = program_data; self @@ -414,7 +400,7 @@ impl<'a, 'b> SetAuthorityCpiBuilder<'a, 'b> { #[inline(always)] pub fn add_remaining_account( &mut self, - account: &'b solana_program::account_info::AccountInfo<'a>, + account: &'b solana_account_info::AccountInfo<'a>, is_writable: bool, is_signer: bool, ) -> &mut Self { @@ -430,11 +416,7 @@ impl<'a, 'b> SetAuthorityCpiBuilder<'a, 'b> { #[inline(always)] pub fn add_remaining_accounts( &mut self, - accounts: &[( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )], + accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], ) -> &mut Self { self.instruction .__remaining_accounts @@ -442,15 +424,12 @@ impl<'a, 'b> SetAuthorityCpiBuilder<'a, 'b> { self } #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + pub fn invoke(&self) -> solana_program_error::ProgramResult { self.invoke_signed(&[]) } #[allow(clippy::clone_on_copy)] #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program::entrypoint::ProgramResult { + pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult { let args = SetAuthorityInstructionArgs { new_authority: self.instruction.new_authority.clone(), }; @@ -475,16 +454,12 @@ impl<'a, 'b> SetAuthorityCpiBuilder<'a, 'b> { #[derive(Clone, Debug)] struct SetAuthorityCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_program::account_info::AccountInfo<'a>, - account: Option<&'b solana_program::account_info::AccountInfo<'a>>, - authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, - program: Option<&'b solana_program::account_info::AccountInfo<'a>>, - program_data: Option<&'b solana_program::account_info::AccountInfo<'a>>, + __program: &'b solana_account_info::AccountInfo<'a>, + account: Option<&'b solana_account_info::AccountInfo<'a>>, + authority: Option<&'b solana_account_info::AccountInfo<'a>>, + program: Option<&'b solana_account_info::AccountInfo<'a>>, + program_data: Option<&'b solana_account_info::AccountInfo<'a>>, new_authority: Option, /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )>, + __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, } diff --git a/clients/rust/src/generated/instructions/set_data.rs b/clients/rust/src/generated/instructions/set_data.rs index 9aac119..268a3b7 100644 --- a/clients/rust/src/generated/instructions/set_data.rs +++ b/clients/rust/src/generated/instructions/set_data.rs @@ -13,26 +13,25 @@ use crate::hooked::RemainderOptionBytes; use borsh::BorshDeserialize; use borsh::BorshSerialize; +pub const SET_DATA_DISCRIMINATOR: u8 = 3; + /// Accounts. #[derive(Debug)] pub struct SetData { /// Metadata account. - pub metadata: solana_program::pubkey::Pubkey, + pub metadata: solana_pubkey::Pubkey, /// Authority account. - pub authority: solana_program::pubkey::Pubkey, + pub authority: solana_pubkey::Pubkey, /// Buffer account to copy data from. - pub buffer: Option, + pub buffer: Option, /// Program account. - pub program: Option, + pub program: Option, /// Program data account. - pub program_data: Option, + pub program_data: Option, } impl SetData { - pub fn instruction( - &self, - args: SetDataInstructionArgs, - ) -> solana_program::instruction::Instruction { + pub fn instruction(&self, args: SetDataInstructionArgs) -> solana_instruction::Instruction { self.instruction_with_remaining_accounts(args, &[]) } #[allow(clippy::arithmetic_side_effects)] @@ -40,52 +39,49 @@ impl SetData { pub fn instruction_with_remaining_accounts( &self, args: SetDataInstructionArgs, - remaining_accounts: &[solana_program::instruction::AccountMeta], - ) -> solana_program::instruction::Instruction { + remaining_accounts: &[solana_instruction::AccountMeta], + ) -> solana_instruction::Instruction { let mut accounts = Vec::with_capacity(5 + remaining_accounts.len()); - accounts.push(solana_program::instruction::AccountMeta::new( - self.metadata, - false, - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new(self.metadata, false)); + accounts.push(solana_instruction::AccountMeta::new_readonly( self.authority, true, )); if let Some(buffer) = self.buffer { - accounts.push(solana_program::instruction::AccountMeta::new(buffer, false)); + accounts.push(solana_instruction::AccountMeta::new(buffer, false)); } else { - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( crate::PROGRAM_METADATA_ID, false, )); } if let Some(program) = self.program { - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( program, false, )); } else { - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( crate::PROGRAM_METADATA_ID, false, )); } if let Some(program_data) = self.program_data { - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( program_data, false, )); } else { - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( crate::PROGRAM_METADATA_ID, false, )); } accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&SetDataInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); + let mut data = SetDataInstructionData::new().try_to_vec().unwrap(); + let mut args = args.try_to_vec().unwrap(); data.append(&mut args); - solana_program::instruction::Instruction { + solana_instruction::Instruction { program_id: crate::PROGRAM_METADATA_ID, accounts, data, @@ -103,6 +99,10 @@ impl SetDataInstructionData { pub fn new() -> Self { Self { discriminator: 3 } } + + pub(crate) fn try_to_vec(&self) -> Result, std::io::Error> { + borsh::to_vec(self) + } } impl Default for SetDataInstructionData { @@ -121,6 +121,12 @@ pub struct SetDataInstructionArgs { pub data: RemainderOptionBytes, } +impl SetDataInstructionArgs { + pub(crate) fn try_to_vec(&self) -> Result, std::io::Error> { + borsh::to_vec(self) + } +} + /// Instruction builder for `SetData`. /// /// ### Accounts: @@ -132,17 +138,17 @@ pub struct SetDataInstructionArgs { /// 4. `[optional]` program_data #[derive(Clone, Debug, Default)] pub struct SetDataBuilder { - metadata: Option, - authority: Option, - buffer: Option, - program: Option, - program_data: Option, + metadata: Option, + authority: Option, + buffer: Option, + program: Option, + program_data: Option, encoding: Option, compression: Option, format: Option, data_source: Option, data: Option, - __remaining_accounts: Vec, + __remaining_accounts: Vec, } impl SetDataBuilder { @@ -151,37 +157,34 @@ impl SetDataBuilder { } /// Metadata account. #[inline(always)] - pub fn metadata(&mut self, metadata: solana_program::pubkey::Pubkey) -> &mut Self { + pub fn metadata(&mut self, metadata: solana_pubkey::Pubkey) -> &mut Self { self.metadata = Some(metadata); self } /// Authority account. #[inline(always)] - pub fn authority(&mut self, authority: solana_program::pubkey::Pubkey) -> &mut Self { + pub fn authority(&mut self, authority: solana_pubkey::Pubkey) -> &mut Self { self.authority = Some(authority); self } /// `[optional account]` /// Buffer account to copy data from. #[inline(always)] - pub fn buffer(&mut self, buffer: Option) -> &mut Self { + pub fn buffer(&mut self, buffer: Option) -> &mut Self { self.buffer = buffer; self } /// `[optional account]` /// Program account. #[inline(always)] - pub fn program(&mut self, program: Option) -> &mut Self { + pub fn program(&mut self, program: Option) -> &mut Self { self.program = program; self } /// `[optional account]` /// Program data account. #[inline(always)] - pub fn program_data( - &mut self, - program_data: Option, - ) -> &mut Self { + pub fn program_data(&mut self, program_data: Option) -> &mut Self { self.program_data = program_data; self } @@ -212,10 +215,7 @@ impl SetDataBuilder { } /// Add an additional account to the instruction. #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: solana_program::instruction::AccountMeta, - ) -> &mut Self { + pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { self.__remaining_accounts.push(account); self } @@ -223,13 +223,13 @@ impl SetDataBuilder { #[inline(always)] pub fn add_remaining_accounts( &mut self, - accounts: &[solana_program::instruction::AccountMeta], + accounts: &[solana_instruction::AccountMeta], ) -> &mut Self { self.__remaining_accounts.extend_from_slice(accounts); self } #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_program::instruction::Instruction { + pub fn instruction(&self) -> solana_instruction::Instruction { let accounts = SetData { metadata: self.metadata.expect("metadata is not set"), authority: self.authority.expect("authority is not set"), @@ -252,38 +252,38 @@ impl SetDataBuilder { /// `set_data` CPI accounts. pub struct SetDataCpiAccounts<'a, 'b> { /// Metadata account. - pub metadata: &'b solana_program::account_info::AccountInfo<'a>, + pub metadata: &'b solana_account_info::AccountInfo<'a>, /// Authority account. - pub authority: &'b solana_program::account_info::AccountInfo<'a>, + pub authority: &'b solana_account_info::AccountInfo<'a>, /// Buffer account to copy data from. - pub buffer: Option<&'b solana_program::account_info::AccountInfo<'a>>, + pub buffer: Option<&'b solana_account_info::AccountInfo<'a>>, /// Program account. - pub program: Option<&'b solana_program::account_info::AccountInfo<'a>>, + pub program: Option<&'b solana_account_info::AccountInfo<'a>>, /// Program data account. - pub program_data: Option<&'b solana_program::account_info::AccountInfo<'a>>, + pub program_data: Option<&'b solana_account_info::AccountInfo<'a>>, } /// `set_data` CPI instruction. pub struct SetDataCpi<'a, 'b> { /// The program to invoke. - pub __program: &'b solana_program::account_info::AccountInfo<'a>, + pub __program: &'b solana_account_info::AccountInfo<'a>, /// Metadata account. - pub metadata: &'b solana_program::account_info::AccountInfo<'a>, + pub metadata: &'b solana_account_info::AccountInfo<'a>, /// Authority account. - pub authority: &'b solana_program::account_info::AccountInfo<'a>, + pub authority: &'b solana_account_info::AccountInfo<'a>, /// Buffer account to copy data from. - pub buffer: Option<&'b solana_program::account_info::AccountInfo<'a>>, + pub buffer: Option<&'b solana_account_info::AccountInfo<'a>>, /// Program account. - pub program: Option<&'b solana_program::account_info::AccountInfo<'a>>, + pub program: Option<&'b solana_account_info::AccountInfo<'a>>, /// Program data account. - pub program_data: Option<&'b solana_program::account_info::AccountInfo<'a>>, + pub program_data: Option<&'b solana_account_info::AccountInfo<'a>>, /// The arguments for the instruction. pub __args: SetDataInstructionArgs, } impl<'a, 'b> SetDataCpi<'a, 'b> { pub fn new( - program: &'b solana_program::account_info::AccountInfo<'a>, + program: &'b solana_account_info::AccountInfo<'a>, accounts: SetDataCpiAccounts<'a, 'b>, args: SetDataInstructionArgs, ) -> Self { @@ -298,25 +298,18 @@ impl<'a, 'b> SetDataCpi<'a, 'b> { } } #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + pub fn invoke(&self) -> solana_program_error::ProgramResult { self.invoke_signed_with_remaining_accounts(&[], &[]) } #[inline(always)] pub fn invoke_with_remaining_accounts( &self, - remaining_accounts: &[( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )], - ) -> solana_program::entrypoint::ProgramResult { + remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], + ) -> solana_program_error::ProgramResult { self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) } #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program::entrypoint::ProgramResult { + pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult { self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) } #[allow(clippy::arithmetic_side_effects)] @@ -325,66 +318,59 @@ impl<'a, 'b> SetDataCpi<'a, 'b> { pub fn invoke_signed_with_remaining_accounts( &self, signers_seeds: &[&[&[u8]]], - remaining_accounts: &[( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )], - ) -> solana_program::entrypoint::ProgramResult { + remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], + ) -> solana_program_error::ProgramResult { let mut accounts = Vec::with_capacity(5 + remaining_accounts.len()); - accounts.push(solana_program::instruction::AccountMeta::new( + accounts.push(solana_instruction::AccountMeta::new( *self.metadata.key, false, )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( *self.authority.key, true, )); if let Some(buffer) = self.buffer { - accounts.push(solana_program::instruction::AccountMeta::new( - *buffer.key, - false, - )); + accounts.push(solana_instruction::AccountMeta::new(*buffer.key, false)); } else { - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( crate::PROGRAM_METADATA_ID, false, )); } if let Some(program) = self.program { - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( *program.key, false, )); } else { - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( crate::PROGRAM_METADATA_ID, false, )); } if let Some(program_data) = self.program_data { - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( *program_data.key, false, )); } else { - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( crate::PROGRAM_METADATA_ID, false, )); } remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_program::instruction::AccountMeta { + accounts.push(solana_instruction::AccountMeta { pubkey: *remaining_account.0.key, is_signer: remaining_account.1, is_writable: remaining_account.2, }) }); - let mut data = borsh::to_vec(&SetDataInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); + let mut data = SetDataInstructionData::new().try_to_vec().unwrap(); + let mut args = self.__args.try_to_vec().unwrap(); data.append(&mut args); - let instruction = solana_program::instruction::Instruction { + let instruction = solana_instruction::Instruction { program_id: crate::PROGRAM_METADATA_ID, accounts, data, @@ -407,9 +393,9 @@ impl<'a, 'b> SetDataCpi<'a, 'b> { .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); if signers_seeds.is_empty() { - solana_program::program::invoke(&instruction, &account_infos) + solana_cpi::invoke(&instruction, &account_infos) } else { - solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds) + solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) } } } @@ -429,7 +415,7 @@ pub struct SetDataCpiBuilder<'a, 'b> { } impl<'a, 'b> SetDataCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { + pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { let instruction = Box::new(SetDataCpiBuilderInstruction { __program: program, metadata: None, @@ -448,19 +434,13 @@ impl<'a, 'b> SetDataCpiBuilder<'a, 'b> { } /// Metadata account. #[inline(always)] - pub fn metadata( - &mut self, - metadata: &'b solana_program::account_info::AccountInfo<'a>, - ) -> &mut Self { + pub fn metadata(&mut self, metadata: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { self.instruction.metadata = Some(metadata); self } /// Authority account. #[inline(always)] - pub fn authority( - &mut self, - authority: &'b solana_program::account_info::AccountInfo<'a>, - ) -> &mut Self { + pub fn authority(&mut self, authority: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { self.instruction.authority = Some(authority); self } @@ -469,7 +449,7 @@ impl<'a, 'b> SetDataCpiBuilder<'a, 'b> { #[inline(always)] pub fn buffer( &mut self, - buffer: Option<&'b solana_program::account_info::AccountInfo<'a>>, + buffer: Option<&'b solana_account_info::AccountInfo<'a>>, ) -> &mut Self { self.instruction.buffer = buffer; self @@ -479,7 +459,7 @@ impl<'a, 'b> SetDataCpiBuilder<'a, 'b> { #[inline(always)] pub fn program( &mut self, - program: Option<&'b solana_program::account_info::AccountInfo<'a>>, + program: Option<&'b solana_account_info::AccountInfo<'a>>, ) -> &mut Self { self.instruction.program = program; self @@ -489,7 +469,7 @@ impl<'a, 'b> SetDataCpiBuilder<'a, 'b> { #[inline(always)] pub fn program_data( &mut self, - program_data: Option<&'b solana_program::account_info::AccountInfo<'a>>, + program_data: Option<&'b solana_account_info::AccountInfo<'a>>, ) -> &mut Self { self.instruction.program_data = program_data; self @@ -523,7 +503,7 @@ impl<'a, 'b> SetDataCpiBuilder<'a, 'b> { #[inline(always)] pub fn add_remaining_account( &mut self, - account: &'b solana_program::account_info::AccountInfo<'a>, + account: &'b solana_account_info::AccountInfo<'a>, is_writable: bool, is_signer: bool, ) -> &mut Self { @@ -539,11 +519,7 @@ impl<'a, 'b> SetDataCpiBuilder<'a, 'b> { #[inline(always)] pub fn add_remaining_accounts( &mut self, - accounts: &[( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )], + accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], ) -> &mut Self { self.instruction .__remaining_accounts @@ -551,15 +527,12 @@ impl<'a, 'b> SetDataCpiBuilder<'a, 'b> { self } #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + pub fn invoke(&self) -> solana_program_error::ProgramResult { self.invoke_signed(&[]) } #[allow(clippy::clone_on_copy)] #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program::entrypoint::ProgramResult { + pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult { let args = SetDataInstructionArgs { encoding: self .instruction @@ -602,21 +575,17 @@ impl<'a, 'b> SetDataCpiBuilder<'a, 'b> { #[derive(Clone, Debug)] struct SetDataCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_program::account_info::AccountInfo<'a>, - metadata: Option<&'b solana_program::account_info::AccountInfo<'a>>, - authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, - buffer: Option<&'b solana_program::account_info::AccountInfo<'a>>, - program: Option<&'b solana_program::account_info::AccountInfo<'a>>, - program_data: Option<&'b solana_program::account_info::AccountInfo<'a>>, + __program: &'b solana_account_info::AccountInfo<'a>, + metadata: Option<&'b solana_account_info::AccountInfo<'a>>, + authority: Option<&'b solana_account_info::AccountInfo<'a>>, + buffer: Option<&'b solana_account_info::AccountInfo<'a>>, + program: Option<&'b solana_account_info::AccountInfo<'a>>, + program_data: Option<&'b solana_account_info::AccountInfo<'a>>, encoding: Option, compression: Option, format: Option, data_source: Option, data: Option, /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )>, + __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, } diff --git a/clients/rust/src/generated/instructions/set_immutable.rs b/clients/rust/src/generated/instructions/set_immutable.rs index 5fb1d90..0533642 100644 --- a/clients/rust/src/generated/instructions/set_immutable.rs +++ b/clients/rust/src/generated/instructions/set_immutable.rs @@ -8,63 +8,62 @@ use borsh::BorshDeserialize; use borsh::BorshSerialize; +pub const SET_IMMUTABLE_DISCRIMINATOR: u8 = 4; + /// Accounts. #[derive(Debug)] pub struct SetImmutable { /// Metadata account. - pub metadata: solana_program::pubkey::Pubkey, + pub metadata: solana_pubkey::Pubkey, /// Authority account. - pub authority: solana_program::pubkey::Pubkey, + pub authority: solana_pubkey::Pubkey, /// Program account. - pub program: Option, + pub program: Option, /// Program data account. - pub program_data: Option, + pub program_data: Option, } impl SetImmutable { - pub fn instruction(&self) -> solana_program::instruction::Instruction { + pub fn instruction(&self) -> solana_instruction::Instruction { self.instruction_with_remaining_accounts(&[]) } #[allow(clippy::arithmetic_side_effects)] #[allow(clippy::vec_init_then_push)] pub fn instruction_with_remaining_accounts( &self, - remaining_accounts: &[solana_program::instruction::AccountMeta], - ) -> solana_program::instruction::Instruction { + remaining_accounts: &[solana_instruction::AccountMeta], + ) -> solana_instruction::Instruction { let mut accounts = Vec::with_capacity(4 + remaining_accounts.len()); - accounts.push(solana_program::instruction::AccountMeta::new( - self.metadata, - false, - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new(self.metadata, false)); + accounts.push(solana_instruction::AccountMeta::new_readonly( self.authority, true, )); if let Some(program) = self.program { - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( program, false, )); } else { - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( crate::PROGRAM_METADATA_ID, false, )); } if let Some(program_data) = self.program_data { - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( program_data, false, )); } else { - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( crate::PROGRAM_METADATA_ID, false, )); } accounts.extend_from_slice(remaining_accounts); - let data = borsh::to_vec(&SetImmutableInstructionData::new()).unwrap(); + let data = SetImmutableInstructionData::new().try_to_vec().unwrap(); - solana_program::instruction::Instruction { + solana_instruction::Instruction { program_id: crate::PROGRAM_METADATA_ID, accounts, data, @@ -82,6 +81,10 @@ impl SetImmutableInstructionData { pub fn new() -> Self { Self { discriminator: 4 } } + + pub(crate) fn try_to_vec(&self) -> Result, std::io::Error> { + borsh::to_vec(self) + } } impl Default for SetImmutableInstructionData { @@ -100,11 +103,11 @@ impl Default for SetImmutableInstructionData { /// 3. `[optional]` program_data #[derive(Clone, Debug, Default)] pub struct SetImmutableBuilder { - metadata: Option, - authority: Option, - program: Option, - program_data: Option, - __remaining_accounts: Vec, + metadata: Option, + authority: Option, + program: Option, + program_data: Option, + __remaining_accounts: Vec, } impl SetImmutableBuilder { @@ -113,39 +116,33 @@ impl SetImmutableBuilder { } /// Metadata account. #[inline(always)] - pub fn metadata(&mut self, metadata: solana_program::pubkey::Pubkey) -> &mut Self { + pub fn metadata(&mut self, metadata: solana_pubkey::Pubkey) -> &mut Self { self.metadata = Some(metadata); self } /// Authority account. #[inline(always)] - pub fn authority(&mut self, authority: solana_program::pubkey::Pubkey) -> &mut Self { + pub fn authority(&mut self, authority: solana_pubkey::Pubkey) -> &mut Self { self.authority = Some(authority); self } /// `[optional account]` /// Program account. #[inline(always)] - pub fn program(&mut self, program: Option) -> &mut Self { + pub fn program(&mut self, program: Option) -> &mut Self { self.program = program; self } /// `[optional account]` /// Program data account. #[inline(always)] - pub fn program_data( - &mut self, - program_data: Option, - ) -> &mut Self { + pub fn program_data(&mut self, program_data: Option) -> &mut Self { self.program_data = program_data; self } /// Add an additional account to the instruction. #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: solana_program::instruction::AccountMeta, - ) -> &mut Self { + pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { self.__remaining_accounts.push(account); self } @@ -153,13 +150,13 @@ impl SetImmutableBuilder { #[inline(always)] pub fn add_remaining_accounts( &mut self, - accounts: &[solana_program::instruction::AccountMeta], + accounts: &[solana_instruction::AccountMeta], ) -> &mut Self { self.__remaining_accounts.extend_from_slice(accounts); self } #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_program::instruction::Instruction { + pub fn instruction(&self) -> solana_instruction::Instruction { let accounts = SetImmutable { metadata: self.metadata.expect("metadata is not set"), authority: self.authority.expect("authority is not set"), @@ -174,32 +171,32 @@ impl SetImmutableBuilder { /// `set_immutable` CPI accounts. pub struct SetImmutableCpiAccounts<'a, 'b> { /// Metadata account. - pub metadata: &'b solana_program::account_info::AccountInfo<'a>, + pub metadata: &'b solana_account_info::AccountInfo<'a>, /// Authority account. - pub authority: &'b solana_program::account_info::AccountInfo<'a>, + pub authority: &'b solana_account_info::AccountInfo<'a>, /// Program account. - pub program: Option<&'b solana_program::account_info::AccountInfo<'a>>, + pub program: Option<&'b solana_account_info::AccountInfo<'a>>, /// Program data account. - pub program_data: Option<&'b solana_program::account_info::AccountInfo<'a>>, + pub program_data: Option<&'b solana_account_info::AccountInfo<'a>>, } /// `set_immutable` CPI instruction. pub struct SetImmutableCpi<'a, 'b> { /// The program to invoke. - pub __program: &'b solana_program::account_info::AccountInfo<'a>, + pub __program: &'b solana_account_info::AccountInfo<'a>, /// Metadata account. - pub metadata: &'b solana_program::account_info::AccountInfo<'a>, + pub metadata: &'b solana_account_info::AccountInfo<'a>, /// Authority account. - pub authority: &'b solana_program::account_info::AccountInfo<'a>, + pub authority: &'b solana_account_info::AccountInfo<'a>, /// Program account. - pub program: Option<&'b solana_program::account_info::AccountInfo<'a>>, + pub program: Option<&'b solana_account_info::AccountInfo<'a>>, /// Program data account. - pub program_data: Option<&'b solana_program::account_info::AccountInfo<'a>>, + pub program_data: Option<&'b solana_account_info::AccountInfo<'a>>, } impl<'a, 'b> SetImmutableCpi<'a, 'b> { pub fn new( - program: &'b solana_program::account_info::AccountInfo<'a>, + program: &'b solana_account_info::AccountInfo<'a>, accounts: SetImmutableCpiAccounts<'a, 'b>, ) -> Self { Self { @@ -211,25 +208,18 @@ impl<'a, 'b> SetImmutableCpi<'a, 'b> { } } #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + pub fn invoke(&self) -> solana_program_error::ProgramResult { self.invoke_signed_with_remaining_accounts(&[], &[]) } #[inline(always)] pub fn invoke_with_remaining_accounts( &self, - remaining_accounts: &[( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )], - ) -> solana_program::entrypoint::ProgramResult { + remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], + ) -> solana_program_error::ProgramResult { self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) } #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program::entrypoint::ProgramResult { + pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult { self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) } #[allow(clippy::arithmetic_side_effects)] @@ -238,53 +228,49 @@ impl<'a, 'b> SetImmutableCpi<'a, 'b> { pub fn invoke_signed_with_remaining_accounts( &self, signers_seeds: &[&[&[u8]]], - remaining_accounts: &[( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )], - ) -> solana_program::entrypoint::ProgramResult { + remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], + ) -> solana_program_error::ProgramResult { let mut accounts = Vec::with_capacity(4 + remaining_accounts.len()); - accounts.push(solana_program::instruction::AccountMeta::new( + accounts.push(solana_instruction::AccountMeta::new( *self.metadata.key, false, )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( *self.authority.key, true, )); if let Some(program) = self.program { - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( *program.key, false, )); } else { - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( crate::PROGRAM_METADATA_ID, false, )); } if let Some(program_data) = self.program_data { - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( *program_data.key, false, )); } else { - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( crate::PROGRAM_METADATA_ID, false, )); } remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_program::instruction::AccountMeta { + accounts.push(solana_instruction::AccountMeta { pubkey: *remaining_account.0.key, is_signer: remaining_account.1, is_writable: remaining_account.2, }) }); - let data = borsh::to_vec(&SetImmutableInstructionData::new()).unwrap(); + let data = SetImmutableInstructionData::new().try_to_vec().unwrap(); - let instruction = solana_program::instruction::Instruction { + let instruction = solana_instruction::Instruction { program_id: crate::PROGRAM_METADATA_ID, accounts, data, @@ -304,9 +290,9 @@ impl<'a, 'b> SetImmutableCpi<'a, 'b> { .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); if signers_seeds.is_empty() { - solana_program::program::invoke(&instruction, &account_infos) + solana_cpi::invoke(&instruction, &account_infos) } else { - solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds) + solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) } } } @@ -325,7 +311,7 @@ pub struct SetImmutableCpiBuilder<'a, 'b> { } impl<'a, 'b> SetImmutableCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { + pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { let instruction = Box::new(SetImmutableCpiBuilderInstruction { __program: program, metadata: None, @@ -338,19 +324,13 @@ impl<'a, 'b> SetImmutableCpiBuilder<'a, 'b> { } /// Metadata account. #[inline(always)] - pub fn metadata( - &mut self, - metadata: &'b solana_program::account_info::AccountInfo<'a>, - ) -> &mut Self { + pub fn metadata(&mut self, metadata: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { self.instruction.metadata = Some(metadata); self } /// Authority account. #[inline(always)] - pub fn authority( - &mut self, - authority: &'b solana_program::account_info::AccountInfo<'a>, - ) -> &mut Self { + pub fn authority(&mut self, authority: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { self.instruction.authority = Some(authority); self } @@ -359,7 +339,7 @@ impl<'a, 'b> SetImmutableCpiBuilder<'a, 'b> { #[inline(always)] pub fn program( &mut self, - program: Option<&'b solana_program::account_info::AccountInfo<'a>>, + program: Option<&'b solana_account_info::AccountInfo<'a>>, ) -> &mut Self { self.instruction.program = program; self @@ -369,7 +349,7 @@ impl<'a, 'b> SetImmutableCpiBuilder<'a, 'b> { #[inline(always)] pub fn program_data( &mut self, - program_data: Option<&'b solana_program::account_info::AccountInfo<'a>>, + program_data: Option<&'b solana_account_info::AccountInfo<'a>>, ) -> &mut Self { self.instruction.program_data = program_data; self @@ -378,7 +358,7 @@ impl<'a, 'b> SetImmutableCpiBuilder<'a, 'b> { #[inline(always)] pub fn add_remaining_account( &mut self, - account: &'b solana_program::account_info::AccountInfo<'a>, + account: &'b solana_account_info::AccountInfo<'a>, is_writable: bool, is_signer: bool, ) -> &mut Self { @@ -394,11 +374,7 @@ impl<'a, 'b> SetImmutableCpiBuilder<'a, 'b> { #[inline(always)] pub fn add_remaining_accounts( &mut self, - accounts: &[( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )], + accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], ) -> &mut Self { self.instruction .__remaining_accounts @@ -406,15 +382,12 @@ impl<'a, 'b> SetImmutableCpiBuilder<'a, 'b> { self } #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + pub fn invoke(&self) -> solana_program_error::ProgramResult { self.invoke_signed(&[]) } #[allow(clippy::clone_on_copy)] #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program::entrypoint::ProgramResult { + pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult { let instruction = SetImmutableCpi { __program: self.instruction.__program, @@ -435,15 +408,11 @@ impl<'a, 'b> SetImmutableCpiBuilder<'a, 'b> { #[derive(Clone, Debug)] struct SetImmutableCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_program::account_info::AccountInfo<'a>, - metadata: Option<&'b solana_program::account_info::AccountInfo<'a>>, - authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, - program: Option<&'b solana_program::account_info::AccountInfo<'a>>, - program_data: Option<&'b solana_program::account_info::AccountInfo<'a>>, + __program: &'b solana_account_info::AccountInfo<'a>, + metadata: Option<&'b solana_account_info::AccountInfo<'a>>, + authority: Option<&'b solana_account_info::AccountInfo<'a>>, + program: Option<&'b solana_account_info::AccountInfo<'a>>, + program_data: Option<&'b solana_account_info::AccountInfo<'a>>, /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )>, + __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, } diff --git a/clients/rust/src/generated/instructions/trim.rs b/clients/rust/src/generated/instructions/trim.rs index c7dcf7e..ba936eb 100644 --- a/clients/rust/src/generated/instructions/trim.rs +++ b/clients/rust/src/generated/instructions/trim.rs @@ -8,74 +8,73 @@ use borsh::BorshDeserialize; use borsh::BorshSerialize; +pub const TRIM_DISCRIMINATOR: u8 = 5; + /// Accounts. #[derive(Debug)] pub struct Trim { /// Buffer or metadata account. - pub account: solana_program::pubkey::Pubkey, + pub account: solana_pubkey::Pubkey, /// Authority account. - pub authority: solana_program::pubkey::Pubkey, + pub authority: solana_pubkey::Pubkey, /// Program account. - pub program: Option, + pub program: Option, /// Program data account. - pub program_data: Option, + pub program_data: Option, /// Destination account. - pub destination: solana_program::pubkey::Pubkey, + pub destination: solana_pubkey::Pubkey, /// Rent sysvar account. - pub rent: solana_program::pubkey::Pubkey, + pub rent: solana_pubkey::Pubkey, } impl Trim { - pub fn instruction(&self) -> solana_program::instruction::Instruction { + pub fn instruction(&self) -> solana_instruction::Instruction { self.instruction_with_remaining_accounts(&[]) } #[allow(clippy::arithmetic_side_effects)] #[allow(clippy::vec_init_then_push)] pub fn instruction_with_remaining_accounts( &self, - remaining_accounts: &[solana_program::instruction::AccountMeta], - ) -> solana_program::instruction::Instruction { + remaining_accounts: &[solana_instruction::AccountMeta], + ) -> solana_instruction::Instruction { let mut accounts = Vec::with_capacity(6 + remaining_accounts.len()); - accounts.push(solana_program::instruction::AccountMeta::new( - self.account, - false, - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new(self.account, false)); + accounts.push(solana_instruction::AccountMeta::new_readonly( self.authority, true, )); if let Some(program) = self.program { - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( program, false, )); } else { - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( crate::PROGRAM_METADATA_ID, false, )); } if let Some(program_data) = self.program_data { - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( program_data, false, )); } else { - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( crate::PROGRAM_METADATA_ID, false, )); } - accounts.push(solana_program::instruction::AccountMeta::new( + accounts.push(solana_instruction::AccountMeta::new( self.destination, false, )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( self.rent, false, )); accounts.extend_from_slice(remaining_accounts); - let data = borsh::to_vec(&TrimInstructionData::new()).unwrap(); + let data = TrimInstructionData::new().try_to_vec().unwrap(); - solana_program::instruction::Instruction { + solana_instruction::Instruction { program_id: crate::PROGRAM_METADATA_ID, accounts, data, @@ -93,6 +92,10 @@ impl TrimInstructionData { pub fn new() -> Self { Self { discriminator: 5 } } + + pub(crate) fn try_to_vec(&self) -> Result, std::io::Error> { + borsh::to_vec(self) + } } impl Default for TrimInstructionData { @@ -113,13 +116,13 @@ impl Default for TrimInstructionData { /// 5. `[optional]` rent (default to `SysvarRent111111111111111111111111111111111`) #[derive(Clone, Debug, Default)] pub struct TrimBuilder { - account: Option, - authority: Option, - program: Option, - program_data: Option, - destination: Option, - rent: Option, - __remaining_accounts: Vec, + account: Option, + authority: Option, + program: Option, + program_data: Option, + destination: Option, + rent: Option, + __remaining_accounts: Vec, } impl TrimBuilder { @@ -128,52 +131,46 @@ impl TrimBuilder { } /// Buffer or metadata account. #[inline(always)] - pub fn account(&mut self, account: solana_program::pubkey::Pubkey) -> &mut Self { + pub fn account(&mut self, account: solana_pubkey::Pubkey) -> &mut Self { self.account = Some(account); self } /// Authority account. #[inline(always)] - pub fn authority(&mut self, authority: solana_program::pubkey::Pubkey) -> &mut Self { + pub fn authority(&mut self, authority: solana_pubkey::Pubkey) -> &mut Self { self.authority = Some(authority); self } /// `[optional account]` /// Program account. #[inline(always)] - pub fn program(&mut self, program: Option) -> &mut Self { + pub fn program(&mut self, program: Option) -> &mut Self { self.program = program; self } /// `[optional account]` /// Program data account. #[inline(always)] - pub fn program_data( - &mut self, - program_data: Option, - ) -> &mut Self { + pub fn program_data(&mut self, program_data: Option) -> &mut Self { self.program_data = program_data; self } /// Destination account. #[inline(always)] - pub fn destination(&mut self, destination: solana_program::pubkey::Pubkey) -> &mut Self { + pub fn destination(&mut self, destination: solana_pubkey::Pubkey) -> &mut Self { self.destination = Some(destination); self } /// `[optional account, default to 'SysvarRent111111111111111111111111111111111']` /// Rent sysvar account. #[inline(always)] - pub fn rent(&mut self, rent: solana_program::pubkey::Pubkey) -> &mut Self { + pub fn rent(&mut self, rent: solana_pubkey::Pubkey) -> &mut Self { self.rent = Some(rent); self } /// Add an additional account to the instruction. #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: solana_program::instruction::AccountMeta, - ) -> &mut Self { + pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { self.__remaining_accounts.push(account); self } @@ -181,20 +178,20 @@ impl TrimBuilder { #[inline(always)] pub fn add_remaining_accounts( &mut self, - accounts: &[solana_program::instruction::AccountMeta], + accounts: &[solana_instruction::AccountMeta], ) -> &mut Self { self.__remaining_accounts.extend_from_slice(accounts); self } #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_program::instruction::Instruction { + pub fn instruction(&self) -> solana_instruction::Instruction { let accounts = Trim { account: self.account.expect("account is not set"), authority: self.authority.expect("authority is not set"), program: self.program, program_data: self.program_data, destination: self.destination.expect("destination is not set"), - rent: self.rent.unwrap_or(solana_program::pubkey!( + rent: self.rent.unwrap_or(solana_pubkey::pubkey!( "SysvarRent111111111111111111111111111111111" )), }; @@ -206,40 +203,40 @@ impl TrimBuilder { /// `trim` CPI accounts. pub struct TrimCpiAccounts<'a, 'b> { /// Buffer or metadata account. - pub account: &'b solana_program::account_info::AccountInfo<'a>, + pub account: &'b solana_account_info::AccountInfo<'a>, /// Authority account. - pub authority: &'b solana_program::account_info::AccountInfo<'a>, + pub authority: &'b solana_account_info::AccountInfo<'a>, /// Program account. - pub program: Option<&'b solana_program::account_info::AccountInfo<'a>>, + pub program: Option<&'b solana_account_info::AccountInfo<'a>>, /// Program data account. - pub program_data: Option<&'b solana_program::account_info::AccountInfo<'a>>, + pub program_data: Option<&'b solana_account_info::AccountInfo<'a>>, /// Destination account. - pub destination: &'b solana_program::account_info::AccountInfo<'a>, + pub destination: &'b solana_account_info::AccountInfo<'a>, /// Rent sysvar account. - pub rent: &'b solana_program::account_info::AccountInfo<'a>, + pub rent: &'b solana_account_info::AccountInfo<'a>, } /// `trim` CPI instruction. pub struct TrimCpi<'a, 'b> { /// The program to invoke. - pub __program: &'b solana_program::account_info::AccountInfo<'a>, + pub __program: &'b solana_account_info::AccountInfo<'a>, /// Buffer or metadata account. - pub account: &'b solana_program::account_info::AccountInfo<'a>, + pub account: &'b solana_account_info::AccountInfo<'a>, /// Authority account. - pub authority: &'b solana_program::account_info::AccountInfo<'a>, + pub authority: &'b solana_account_info::AccountInfo<'a>, /// Program account. - pub program: Option<&'b solana_program::account_info::AccountInfo<'a>>, + pub program: Option<&'b solana_account_info::AccountInfo<'a>>, /// Program data account. - pub program_data: Option<&'b solana_program::account_info::AccountInfo<'a>>, + pub program_data: Option<&'b solana_account_info::AccountInfo<'a>>, /// Destination account. - pub destination: &'b solana_program::account_info::AccountInfo<'a>, + pub destination: &'b solana_account_info::AccountInfo<'a>, /// Rent sysvar account. - pub rent: &'b solana_program::account_info::AccountInfo<'a>, + pub rent: &'b solana_account_info::AccountInfo<'a>, } impl<'a, 'b> TrimCpi<'a, 'b> { pub fn new( - program: &'b solana_program::account_info::AccountInfo<'a>, + program: &'b solana_account_info::AccountInfo<'a>, accounts: TrimCpiAccounts<'a, 'b>, ) -> Self { Self { @@ -253,25 +250,18 @@ impl<'a, 'b> TrimCpi<'a, 'b> { } } #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + pub fn invoke(&self) -> solana_program_error::ProgramResult { self.invoke_signed_with_remaining_accounts(&[], &[]) } #[inline(always)] pub fn invoke_with_remaining_accounts( &self, - remaining_accounts: &[( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )], - ) -> solana_program::entrypoint::ProgramResult { + remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], + ) -> solana_program_error::ProgramResult { self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) } #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program::entrypoint::ProgramResult { + pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult { self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) } #[allow(clippy::arithmetic_side_effects)] @@ -280,61 +270,57 @@ impl<'a, 'b> TrimCpi<'a, 'b> { pub fn invoke_signed_with_remaining_accounts( &self, signers_seeds: &[&[&[u8]]], - remaining_accounts: &[( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )], - ) -> solana_program::entrypoint::ProgramResult { + remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], + ) -> solana_program_error::ProgramResult { let mut accounts = Vec::with_capacity(6 + remaining_accounts.len()); - accounts.push(solana_program::instruction::AccountMeta::new( + accounts.push(solana_instruction::AccountMeta::new( *self.account.key, false, )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( *self.authority.key, true, )); if let Some(program) = self.program { - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( *program.key, false, )); } else { - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( crate::PROGRAM_METADATA_ID, false, )); } if let Some(program_data) = self.program_data { - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( *program_data.key, false, )); } else { - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( crate::PROGRAM_METADATA_ID, false, )); } - accounts.push(solana_program::instruction::AccountMeta::new( + accounts.push(solana_instruction::AccountMeta::new( *self.destination.key, false, )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( *self.rent.key, false, )); remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_program::instruction::AccountMeta { + accounts.push(solana_instruction::AccountMeta { pubkey: *remaining_account.0.key, is_signer: remaining_account.1, is_writable: remaining_account.2, }) }); - let data = borsh::to_vec(&TrimInstructionData::new()).unwrap(); + let data = TrimInstructionData::new().try_to_vec().unwrap(); - let instruction = solana_program::instruction::Instruction { + let instruction = solana_instruction::Instruction { program_id: crate::PROGRAM_METADATA_ID, accounts, data, @@ -356,9 +342,9 @@ impl<'a, 'b> TrimCpi<'a, 'b> { .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); if signers_seeds.is_empty() { - solana_program::program::invoke(&instruction, &account_infos) + solana_cpi::invoke(&instruction, &account_infos) } else { - solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds) + solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) } } } @@ -379,7 +365,7 @@ pub struct TrimCpiBuilder<'a, 'b> { } impl<'a, 'b> TrimCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { + pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { let instruction = Box::new(TrimCpiBuilderInstruction { __program: program, account: None, @@ -394,19 +380,13 @@ impl<'a, 'b> TrimCpiBuilder<'a, 'b> { } /// Buffer or metadata account. #[inline(always)] - pub fn account( - &mut self, - account: &'b solana_program::account_info::AccountInfo<'a>, - ) -> &mut Self { + pub fn account(&mut self, account: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { self.instruction.account = Some(account); self } /// Authority account. #[inline(always)] - pub fn authority( - &mut self, - authority: &'b solana_program::account_info::AccountInfo<'a>, - ) -> &mut Self { + pub fn authority(&mut self, authority: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { self.instruction.authority = Some(authority); self } @@ -415,7 +395,7 @@ impl<'a, 'b> TrimCpiBuilder<'a, 'b> { #[inline(always)] pub fn program( &mut self, - program: Option<&'b solana_program::account_info::AccountInfo<'a>>, + program: Option<&'b solana_account_info::AccountInfo<'a>>, ) -> &mut Self { self.instruction.program = program; self @@ -425,7 +405,7 @@ impl<'a, 'b> TrimCpiBuilder<'a, 'b> { #[inline(always)] pub fn program_data( &mut self, - program_data: Option<&'b solana_program::account_info::AccountInfo<'a>>, + program_data: Option<&'b solana_account_info::AccountInfo<'a>>, ) -> &mut Self { self.instruction.program_data = program_data; self @@ -434,14 +414,14 @@ impl<'a, 'b> TrimCpiBuilder<'a, 'b> { #[inline(always)] pub fn destination( &mut self, - destination: &'b solana_program::account_info::AccountInfo<'a>, + destination: &'b solana_account_info::AccountInfo<'a>, ) -> &mut Self { self.instruction.destination = Some(destination); self } /// Rent sysvar account. #[inline(always)] - pub fn rent(&mut self, rent: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { + pub fn rent(&mut self, rent: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { self.instruction.rent = Some(rent); self } @@ -449,7 +429,7 @@ impl<'a, 'b> TrimCpiBuilder<'a, 'b> { #[inline(always)] pub fn add_remaining_account( &mut self, - account: &'b solana_program::account_info::AccountInfo<'a>, + account: &'b solana_account_info::AccountInfo<'a>, is_writable: bool, is_signer: bool, ) -> &mut Self { @@ -465,11 +445,7 @@ impl<'a, 'b> TrimCpiBuilder<'a, 'b> { #[inline(always)] pub fn add_remaining_accounts( &mut self, - accounts: &[( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )], + accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], ) -> &mut Self { self.instruction .__remaining_accounts @@ -477,15 +453,12 @@ impl<'a, 'b> TrimCpiBuilder<'a, 'b> { self } #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + pub fn invoke(&self) -> solana_program_error::ProgramResult { self.invoke_signed(&[]) } #[allow(clippy::clone_on_copy)] #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program::entrypoint::ProgramResult { + pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult { let instruction = TrimCpi { __program: self.instruction.__program, @@ -513,17 +486,13 @@ impl<'a, 'b> TrimCpiBuilder<'a, 'b> { #[derive(Clone, Debug)] struct TrimCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_program::account_info::AccountInfo<'a>, - account: Option<&'b solana_program::account_info::AccountInfo<'a>>, - authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, - program: Option<&'b solana_program::account_info::AccountInfo<'a>>, - program_data: Option<&'b solana_program::account_info::AccountInfo<'a>>, - destination: Option<&'b solana_program::account_info::AccountInfo<'a>>, - rent: Option<&'b solana_program::account_info::AccountInfo<'a>>, + __program: &'b solana_account_info::AccountInfo<'a>, + account: Option<&'b solana_account_info::AccountInfo<'a>>, + authority: Option<&'b solana_account_info::AccountInfo<'a>>, + program: Option<&'b solana_account_info::AccountInfo<'a>>, + program_data: Option<&'b solana_account_info::AccountInfo<'a>>, + destination: Option<&'b solana_account_info::AccountInfo<'a>>, + rent: Option<&'b solana_account_info::AccountInfo<'a>>, /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )>, + __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, } diff --git a/clients/rust/src/generated/instructions/write.rs b/clients/rust/src/generated/instructions/write.rs index f4d4086..505df64 100644 --- a/clients/rust/src/generated/instructions/write.rs +++ b/clients/rust/src/generated/instructions/write.rs @@ -9,23 +9,22 @@ use crate::hooked::RemainderOptionBytes; use borsh::BorshDeserialize; use borsh::BorshSerialize; +pub const WRITE_DISCRIMINATOR: u8 = 0; + /// Accounts. #[derive(Debug)] pub struct Write { /// The buffer to write to. - pub buffer: solana_program::pubkey::Pubkey, + pub buffer: solana_pubkey::Pubkey, /// The authority of the buffer. - pub authority: solana_program::pubkey::Pubkey, + pub authority: solana_pubkey::Pubkey, /// Buffer to copy the data from. /// You may use the `data` argument instead of this account to pass data directly. - pub source_buffer: Option, + pub source_buffer: Option, } impl Write { - pub fn instruction( - &self, - args: WriteInstructionArgs, - ) -> solana_program::instruction::Instruction { + pub fn instruction(&self, args: WriteInstructionArgs) -> solana_instruction::Instruction { self.instruction_with_remaining_accounts(args, &[]) } #[allow(clippy::arithmetic_side_effects)] @@ -33,34 +32,31 @@ impl Write { pub fn instruction_with_remaining_accounts( &self, args: WriteInstructionArgs, - remaining_accounts: &[solana_program::instruction::AccountMeta], - ) -> solana_program::instruction::Instruction { + remaining_accounts: &[solana_instruction::AccountMeta], + ) -> solana_instruction::Instruction { let mut accounts = Vec::with_capacity(3 + remaining_accounts.len()); - accounts.push(solana_program::instruction::AccountMeta::new( - self.buffer, - false, - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new(self.buffer, false)); + accounts.push(solana_instruction::AccountMeta::new_readonly( self.authority, true, )); if let Some(source_buffer) = self.source_buffer { - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( source_buffer, false, )); } else { - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( crate::PROGRAM_METADATA_ID, false, )); } accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&WriteInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); + let mut data = WriteInstructionData::new().try_to_vec().unwrap(); + let mut args = args.try_to_vec().unwrap(); data.append(&mut args); - solana_program::instruction::Instruction { + solana_instruction::Instruction { program_id: crate::PROGRAM_METADATA_ID, accounts, data, @@ -78,6 +74,10 @@ impl WriteInstructionData { pub fn new() -> Self { Self { discriminator: 0 } } + + pub(crate) fn try_to_vec(&self) -> Result, std::io::Error> { + borsh::to_vec(self) + } } impl Default for WriteInstructionData { @@ -93,6 +93,12 @@ pub struct WriteInstructionArgs { pub data: RemainderOptionBytes, } +impl WriteInstructionArgs { + pub(crate) fn try_to_vec(&self) -> Result, std::io::Error> { + borsh::to_vec(self) + } +} + /// Instruction builder for `Write`. /// /// ### Accounts: @@ -102,12 +108,12 @@ pub struct WriteInstructionArgs { /// 2. `[optional]` source_buffer #[derive(Clone, Debug, Default)] pub struct WriteBuilder { - buffer: Option, - authority: Option, - source_buffer: Option, + buffer: Option, + authority: Option, + source_buffer: Option, offset: Option, data: Option, - __remaining_accounts: Vec, + __remaining_accounts: Vec, } impl WriteBuilder { @@ -116,13 +122,13 @@ impl WriteBuilder { } /// The buffer to write to. #[inline(always)] - pub fn buffer(&mut self, buffer: solana_program::pubkey::Pubkey) -> &mut Self { + pub fn buffer(&mut self, buffer: solana_pubkey::Pubkey) -> &mut Self { self.buffer = Some(buffer); self } /// The authority of the buffer. #[inline(always)] - pub fn authority(&mut self, authority: solana_program::pubkey::Pubkey) -> &mut Self { + pub fn authority(&mut self, authority: solana_pubkey::Pubkey) -> &mut Self { self.authority = Some(authority); self } @@ -130,10 +136,7 @@ impl WriteBuilder { /// Buffer to copy the data from. /// You may use the `data` argument instead of this account to pass data directly. #[inline(always)] - pub fn source_buffer( - &mut self, - source_buffer: Option, - ) -> &mut Self { + pub fn source_buffer(&mut self, source_buffer: Option) -> &mut Self { self.source_buffer = source_buffer; self } @@ -149,10 +152,7 @@ impl WriteBuilder { } /// Add an additional account to the instruction. #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: solana_program::instruction::AccountMeta, - ) -> &mut Self { + pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { self.__remaining_accounts.push(account); self } @@ -160,13 +160,13 @@ impl WriteBuilder { #[inline(always)] pub fn add_remaining_accounts( &mut self, - accounts: &[solana_program::instruction::AccountMeta], + accounts: &[solana_instruction::AccountMeta], ) -> &mut Self { self.__remaining_accounts.extend_from_slice(accounts); self } #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_program::instruction::Instruction { + pub fn instruction(&self) -> solana_instruction::Instruction { let accounts = Write { buffer: self.buffer.expect("buffer is not set"), authority: self.authority.expect("authority is not set"), @@ -184,32 +184,32 @@ impl WriteBuilder { /// `write` CPI accounts. pub struct WriteCpiAccounts<'a, 'b> { /// The buffer to write to. - pub buffer: &'b solana_program::account_info::AccountInfo<'a>, + pub buffer: &'b solana_account_info::AccountInfo<'a>, /// The authority of the buffer. - pub authority: &'b solana_program::account_info::AccountInfo<'a>, + pub authority: &'b solana_account_info::AccountInfo<'a>, /// Buffer to copy the data from. /// You may use the `data` argument instead of this account to pass data directly. - pub source_buffer: Option<&'b solana_program::account_info::AccountInfo<'a>>, + pub source_buffer: Option<&'b solana_account_info::AccountInfo<'a>>, } /// `write` CPI instruction. pub struct WriteCpi<'a, 'b> { /// The program to invoke. - pub __program: &'b solana_program::account_info::AccountInfo<'a>, + pub __program: &'b solana_account_info::AccountInfo<'a>, /// The buffer to write to. - pub buffer: &'b solana_program::account_info::AccountInfo<'a>, + pub buffer: &'b solana_account_info::AccountInfo<'a>, /// The authority of the buffer. - pub authority: &'b solana_program::account_info::AccountInfo<'a>, + pub authority: &'b solana_account_info::AccountInfo<'a>, /// Buffer to copy the data from. /// You may use the `data` argument instead of this account to pass data directly. - pub source_buffer: Option<&'b solana_program::account_info::AccountInfo<'a>>, + pub source_buffer: Option<&'b solana_account_info::AccountInfo<'a>>, /// The arguments for the instruction. pub __args: WriteInstructionArgs, } impl<'a, 'b> WriteCpi<'a, 'b> { pub fn new( - program: &'b solana_program::account_info::AccountInfo<'a>, + program: &'b solana_account_info::AccountInfo<'a>, accounts: WriteCpiAccounts<'a, 'b>, args: WriteInstructionArgs, ) -> Self { @@ -222,25 +222,18 @@ impl<'a, 'b> WriteCpi<'a, 'b> { } } #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + pub fn invoke(&self) -> solana_program_error::ProgramResult { self.invoke_signed_with_remaining_accounts(&[], &[]) } #[inline(always)] pub fn invoke_with_remaining_accounts( &self, - remaining_accounts: &[( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )], - ) -> solana_program::entrypoint::ProgramResult { + remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], + ) -> solana_program_error::ProgramResult { self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) } #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program::entrypoint::ProgramResult { + pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult { self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) } #[allow(clippy::arithmetic_side_effects)] @@ -249,44 +242,40 @@ impl<'a, 'b> WriteCpi<'a, 'b> { pub fn invoke_signed_with_remaining_accounts( &self, signers_seeds: &[&[&[u8]]], - remaining_accounts: &[( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )], - ) -> solana_program::entrypoint::ProgramResult { + remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], + ) -> solana_program_error::ProgramResult { let mut accounts = Vec::with_capacity(3 + remaining_accounts.len()); - accounts.push(solana_program::instruction::AccountMeta::new( + accounts.push(solana_instruction::AccountMeta::new( *self.buffer.key, false, )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( *self.authority.key, true, )); if let Some(source_buffer) = self.source_buffer { - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( *source_buffer.key, false, )); } else { - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( crate::PROGRAM_METADATA_ID, false, )); } remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_program::instruction::AccountMeta { + accounts.push(solana_instruction::AccountMeta { pubkey: *remaining_account.0.key, is_signer: remaining_account.1, is_writable: remaining_account.2, }) }); - let mut data = borsh::to_vec(&WriteInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); + let mut data = WriteInstructionData::new().try_to_vec().unwrap(); + let mut args = self.__args.try_to_vec().unwrap(); data.append(&mut args); - let instruction = solana_program::instruction::Instruction { + let instruction = solana_instruction::Instruction { program_id: crate::PROGRAM_METADATA_ID, accounts, data, @@ -303,9 +292,9 @@ impl<'a, 'b> WriteCpi<'a, 'b> { .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); if signers_seeds.is_empty() { - solana_program::program::invoke(&instruction, &account_infos) + solana_cpi::invoke(&instruction, &account_infos) } else { - solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds) + solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) } } } @@ -323,7 +312,7 @@ pub struct WriteCpiBuilder<'a, 'b> { } impl<'a, 'b> WriteCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { + pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { let instruction = Box::new(WriteCpiBuilderInstruction { __program: program, buffer: None, @@ -337,19 +326,13 @@ impl<'a, 'b> WriteCpiBuilder<'a, 'b> { } /// The buffer to write to. #[inline(always)] - pub fn buffer( - &mut self, - buffer: &'b solana_program::account_info::AccountInfo<'a>, - ) -> &mut Self { + pub fn buffer(&mut self, buffer: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { self.instruction.buffer = Some(buffer); self } /// The authority of the buffer. #[inline(always)] - pub fn authority( - &mut self, - authority: &'b solana_program::account_info::AccountInfo<'a>, - ) -> &mut Self { + pub fn authority(&mut self, authority: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { self.instruction.authority = Some(authority); self } @@ -359,7 +342,7 @@ impl<'a, 'b> WriteCpiBuilder<'a, 'b> { #[inline(always)] pub fn source_buffer( &mut self, - source_buffer: Option<&'b solana_program::account_info::AccountInfo<'a>>, + source_buffer: Option<&'b solana_account_info::AccountInfo<'a>>, ) -> &mut Self { self.instruction.source_buffer = source_buffer; self @@ -378,7 +361,7 @@ impl<'a, 'b> WriteCpiBuilder<'a, 'b> { #[inline(always)] pub fn add_remaining_account( &mut self, - account: &'b solana_program::account_info::AccountInfo<'a>, + account: &'b solana_account_info::AccountInfo<'a>, is_writable: bool, is_signer: bool, ) -> &mut Self { @@ -394,11 +377,7 @@ impl<'a, 'b> WriteCpiBuilder<'a, 'b> { #[inline(always)] pub fn add_remaining_accounts( &mut self, - accounts: &[( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )], + accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], ) -> &mut Self { self.instruction .__remaining_accounts @@ -406,15 +385,12 @@ impl<'a, 'b> WriteCpiBuilder<'a, 'b> { self } #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + pub fn invoke(&self) -> solana_program_error::ProgramResult { self.invoke_signed(&[]) } #[allow(clippy::clone_on_copy)] #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program::entrypoint::ProgramResult { + pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult { let args = WriteInstructionArgs { offset: self.instruction.offset.clone().expect("offset is not set"), data: self.instruction.data.clone().expect("data is not set"), @@ -438,16 +414,12 @@ impl<'a, 'b> WriteCpiBuilder<'a, 'b> { #[derive(Clone, Debug)] struct WriteCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_program::account_info::AccountInfo<'a>, - buffer: Option<&'b solana_program::account_info::AccountInfo<'a>>, - authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, - source_buffer: Option<&'b solana_program::account_info::AccountInfo<'a>>, + __program: &'b solana_account_info::AccountInfo<'a>, + buffer: Option<&'b solana_account_info::AccountInfo<'a>>, + authority: Option<&'b solana_account_info::AccountInfo<'a>>, + source_buffer: Option<&'b solana_account_info::AccountInfo<'a>>, offset: Option, data: Option, /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )>, + __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, } diff --git a/clients/rust/src/generated/programs.rs b/clients/rust/src/generated/programs.rs index b0d74a7..489f3a2 100644 --- a/clients/rust/src/generated/programs.rs +++ b/clients/rust/src/generated/programs.rs @@ -5,7 +5,7 @@ //! //! -use solana_program::{pubkey, pubkey::Pubkey}; +use solana_pubkey::{pubkey, Pubkey}; /// `program_metadata` program ID. pub const PROGRAM_METADATA_ID: Pubkey = pubkey!("ProgM6JCCvbYkfKqJYHePx4xxSUSqJp7rh8Lyv7nk7S"); diff --git a/clients/rust/src/generated/shared.rs b/clients/rust/src/generated/shared.rs index 4b9a0d5..71b906d 100644 --- a/clients/rust/src/generated/shared.rs +++ b/clients/rust/src/generated/shared.rs @@ -8,8 +8,8 @@ #[cfg(feature = "fetch")] #[derive(Debug, Clone)] pub struct DecodedAccount { - pub address: solana_program::pubkey::Pubkey, - pub account: solana_sdk::account::Account, + pub address: solana_pubkey::Pubkey, + pub account: solana_account::Account, pub data: T, } @@ -17,5 +17,5 @@ pub struct DecodedAccount { #[derive(Debug, Clone)] pub enum MaybeAccount { Exists(DecodedAccount), - NotFound(solana_program::pubkey::Pubkey), + NotFound(solana_pubkey::Pubkey), } diff --git a/clients/rust/src/generated/types/external_data.rs b/clients/rust/src/generated/types/external_data.rs index 729b83c..ac88cad 100644 --- a/clients/rust/src/generated/types/external_data.rs +++ b/clients/rust/src/generated/types/external_data.rs @@ -8,7 +8,7 @@ use crate::hooked::ZeroableOptionOffset; use borsh::BorshDeserialize; use borsh::BorshSerialize; -use solana_program::pubkey::Pubkey; +use solana_pubkey::Pubkey; #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] diff --git a/clients/rust/src/hooked/zeroable_options.rs b/clients/rust/src/hooked/zeroable_options.rs index 8071178..616d6c1 100644 --- a/clients/rust/src/hooked/zeroable_options.rs +++ b/clients/rust/src/hooked/zeroable_options.rs @@ -1,7 +1,7 @@ use std::fmt::Display; use borsh::{BorshDeserialize, BorshSerialize}; -use solana_program::pubkey::Pubkey; +use solana_pubkey::Pubkey; pub type ZeroableOptionOffset = ZeroableOption; pub type ZeroableOptionPubkey = ZeroableOption; diff --git a/package.json b/package.json index a779c5f..75cac17 100644 --- a/package.json +++ b/package.json @@ -26,8 +26,8 @@ "rust:semver": "cargo semver-checks" }, "devDependencies": { - "@codama/renderers-js": "^1.3.5", - "@codama/renderers-rust": "~1.0", + "@codama/renderers-js": "^1.4.2", + "@codama/renderers-rust": "^1.2.7", "@iarna/toml": "^2.2.5", "codama": "^1.3", "typescript": "^5.5.2", @@ -36,5 +36,5 @@ "engines": { "node": ">=v20.0.0" }, - "packageManager": "pnpm@9.1.0" + "packageManager": "pnpm@10.15.1" } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 09ab5c4..347bd84 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -9,11 +9,11 @@ importers: .: devDependencies: '@codama/renderers-js': - specifier: ^1.3.5 - version: 1.3.5(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.7.3) + specifier: ^1.4.2 + version: 1.4.2(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.7.3) '@codama/renderers-rust': - specifier: ~1.0 - version: 1.0.19(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.7.3) + specifier: ^1.2.7 + version: 1.2.7(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.7.3) '@iarna/toml': specifier: ^2.2.5 version: 2.2.5 @@ -33,59 +33,45 @@ packages: resolution: {integrity: sha512-3m84aErp6W0cFIArYh9Ymzp2QFFHL+zFx/QS8R8piBjkA/WbSTdslZnierBBqgXkoSM6uIqvm008DSvo3gj1LA==} hasBin: true - '@codama/errors@1.2.11': - resolution: {integrity: sha512-npkIj4bqLMENt2HPtxzLitaduwtl/kaQkW1lFJJdJR7Fu1rD0R4jQkiysqvzMggviOFMnR2/ANutXxKy3NaqQA==} - hasBin: true - '@codama/errors@1.3.3': resolution: {integrity: sha512-iyo5qEW/rgNTTtcZnGqahcnUtMHRRTlTzeTZo6SLpuNistbEn2itOssnklNZVClhXR/4Td0riHwGedP3AjwgJA==} hasBin: true - '@codama/errors@1.3.4': - resolution: {integrity: sha512-gEbfWkf5J1klGlLbrg5zIMYTncYO6SCsLRxKbDRrE1TmxRqt3cUovQyPhccGcNh/e/GisauIGjbsZTJaFNgXuw==} + '@codama/errors@1.3.7': + resolution: {integrity: sha512-96BF8agDVc2vAgL4qw1lZZfuJ7XBefdzTBk2VOUnOhdMQiLb0QhJCC4BH88OcL+rZXQdet4pk7Qwarj1I1GFKg==} hasBin: true - '@codama/node-types@1.2.11': - resolution: {integrity: sha512-4yUA2uYwC/VmtyiRZe+89mWJ3BiN9D6mckiYgvpyOHTNtQ0y35CQpPloJzb0hiRcWIuVaOmV+AWqZrZn5wbzkg==} - '@codama/node-types@1.3.3': resolution: {integrity: sha512-41GdFy/OPRemXTAmptDSi/wDXHPimy40mx9v0z2EdIMNYEyKAYZDcvr2jzSei8meeCV9j4PgKF5snwBQK7HaSg==} - '@codama/node-types@1.3.4': - resolution: {integrity: sha512-WOKU9v019gfX58y+I+hadokckvYLEZKvcsXpf578S+B+sV9YBCOhIjlzDDONcfe9iGUw49M6VpyWkp+EenasLg==} - - '@codama/nodes@1.2.11': - resolution: {integrity: sha512-+cJrFHYcNMwjgfChgY3ujbUNu8dmsokcbq5UGzuS5CCSJ8g7t3SIc07tTj/VJwZnKrClCSiKl12chP7Q0Vc2Rw==} + '@codama/node-types@1.3.7': + resolution: {integrity: sha512-L9UTFfoeki5t+BYJAa4OMsqBPpbMbx8YJQar+55mYcjwGlJsKJW7mRfLYvwEFkCUYyLdNva40OVmTf88jccZCA==} '@codama/nodes@1.3.3': resolution: {integrity: sha512-CgxGfH6ndcZpvf+RfVwSyIOyq8cNejbqY9TRr4SqVMIEbE1Wpqx+GPrEGRKtwHgB8KqsWCz7Pve8BCGhsPkr2g==} - '@codama/nodes@1.3.4': - resolution: {integrity: sha512-Q3eS/kMqiozZzlpY/otVfQQ9M3pRdCS0D1dlB3TyuHWBAJiAGPfjRT21KQ4M8xub6eTWJY7PwT7sykPqS/fQPg==} - - '@codama/renderers-core@1.0.13': - resolution: {integrity: sha512-1/IDgYlsKi1CZCJ6imyiIk/BJDYNKzUnwfD0m/HwLOhzyKZwn0OAbMMQuKkBgcclmzD/izxmHxYHJvAJZSBl+w==} + '@codama/nodes@1.3.7': + resolution: {integrity: sha512-3OV6SIBcqsIDARyzZVGdfnffNlnKSYcb0aGp/9Liz5/EID0oBTIyuh/Cmj5Ww6RX4WPb+GNAxABAGW94zbcfQg==} - '@codama/renderers-core@1.1.0': - resolution: {integrity: sha512-OscEiIv4nXiiqb2I9PWDI0Aw8bM6Qdtb9oqbuFb0XXt8hJTeLoNk+AN8ZZFtJMtiy+SizJjUsbX2KFE2HsVhdg==} + '@codama/renderers-core@1.2.2': + resolution: {integrity: sha512-dPyHgn5L45G+tWP17ITvOlpX3+s2FcJHMjAhFZlmUHAJpH/wl+UsUwuWg698iSb56Er2jUwqX7srw5iZf7XHjQ==} - '@codama/renderers-js@1.3.5': - resolution: {integrity: sha512-c23KBVOqmNd02pzxSTGxBUKVnC6LOZOK2KPeYCb3EsmD5E4YSEFAMt2bI66BsbzuisKxLya9dop7UG5wRGfIIg==} + '@codama/renderers-js@1.4.2': + resolution: {integrity: sha512-emYJEPNDQ/DjHYDBNPt/HEr+97ClpEQT7LPPNZ44DRSEG4Qj9ti/aBvtgOrIyESyyTOaKrUzu7Ew6S+TBB/eFg==} + engines: {node: '>=20.18.0'} - '@codama/renderers-rust@1.0.19': - resolution: {integrity: sha512-ur2oQsMZ0P/g0DXY4tcw6Hznsq8ax1n968lfUNnxMHNBYr3zdhfJRBvzsF7RtcYkEvengOafQn1N5AlsNv1GBA==} + '@codama/renderers-rust@1.2.7': + resolution: {integrity: sha512-wD6JRfm4GZmY0vUhgHB1fTHIaCw3zrQ7PXl4Fv1hBNiX6hKor5vE72GkIztG/VCZkl1WWVJTNLRLho5oldN9LQ==} + engines: {node: '>=20.18.0'} '@codama/validators@1.3.3': resolution: {integrity: sha512-dj3vlwMlxU57l6cRLxb76ZwlrEGv+dq7llDtH0aqc1z3OW5SOryREUuzeqL7T/2hY8FiY+pxjH4CQx+A08hULQ==} - '@codama/visitors-core@1.2.11': - resolution: {integrity: sha512-+hf5NT7DzxxVus+z3mVVrE53hW60E83ao64Ya3zyVFa+vLCUnAcYgrpL8I6UU391QymgDa0NfYJXedgjqWkfGw==} - '@codama/visitors-core@1.3.3': resolution: {integrity: sha512-Kuz2we5iDhq0Y9bPwEjEGGSueBPJkLxoDkJ+Z3NuHlqo/k2aHvDNl9NaoOOUPwNzPVbntfpJW9Ga3pP9oc/PQQ==} - '@codama/visitors-core@1.3.4': - resolution: {integrity: sha512-TCP1ncA0ErBvv5q8BKCRvv98qHh9on8MOiPhdToJ/w50aNm0y5Y2mHbUWqk5vle8k3V9fuo7uf1aAOaqA6G4Vg==} + '@codama/visitors-core@1.3.7': + resolution: {integrity: sha512-B1JnzhRDJiLxewha/F3YzeEp8Zrtd7eKiGNJFJHSPufAnIVm2lQUDaKS+OrAOHnSRmRKIAVdzfpFpdz6EM0N6Q==} '@codama/visitors@1.3.3': resolution: {integrity: sha512-ReZoo0kItffkhpvl9qRjy3HV1nZXv/k8p4wZ10NveUTDtRghk72YkY0kpK2lt/p+2SlWrhQ9IkO4Q+EQoqABrA==} @@ -105,53 +91,27 @@ packages: resolution: {integrity: sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg==} engines: {node: '>= 8'} - '@solana/codecs-core@2.0.0-rc.4': - resolution: {integrity: sha512-JIrTSps032mSE3wBxW3bXOqWfoy4CMy1CX/XeVCijyh5kLVxZTSDIdRTYdePdL1yzaOZF1Xysvt1DhOUgBdM+A==} - engines: {node: '>=20.18.0'} - peerDependencies: - typescript: '>=5' - - '@solana/codecs-core@3.0.1': - resolution: {integrity: sha512-7U12QJX6VZeq03r0l0SZnGPk+YHbyU9lDjEZpjiSHdWbixy8inoYTsqV523Soy41SnGwvVsfiJf7SUB5kvgGaQ==} + '@solana/codecs-core@3.0.3': + resolution: {integrity: sha512-emKykJ3h1DmnDOY29Uv9eJXP8E/FHzvlUBJ6te+5EbKdFjj7vdlKYPfDxOI6iGdXTY+YC/ELtbNBh6QwF2uEDQ==} engines: {node: '>=20.18.0'} peerDependencies: typescript: '>=5.3.3' - '@solana/codecs-numbers@2.0.0-rc.4': - resolution: {integrity: sha512-ZJR7TaUO65+3Hzo3YOOUCS0wlzh17IW+j0MZC2LCk1R0woaypRpHKj4iSMYeQOZkMxsd9QT3WNvjFrPC2qA6Sw==} - engines: {node: '>=20.18.0'} - peerDependencies: - typescript: '>=5' - - '@solana/codecs-numbers@3.0.1': - resolution: {integrity: sha512-HdXioWMVc0Ih9N7vuEF11pMwQWHqSF/TQrCDKljr981QQ5q/pBleUZB3hM43zP/ndnTasIxqAuLXIypricAGqg==} + '@solana/codecs-numbers@3.0.3': + resolution: {integrity: sha512-pfXkH9J0glrM8qj6389GAn30+cJOxzXLR2FsPOHCUMXrqLhGjMMZAWhsQkpOQ37SGc/7EiQsT/gmyGC7gxHqJQ==} engines: {node: '>=20.18.0'} peerDependencies: typescript: '>=5.3.3' - '@solana/codecs-strings@2.0.0-rc.4': - resolution: {integrity: sha512-LGfK2RL0BKjYYUfzu2FG/gTgCsYOMz9FKVs2ntji6WneZygPxJTV5W98K3J8Rl0JewpCSCFQH3xjLSHBJUS0fA==} - engines: {node: '>=20.18.0'} - peerDependencies: - fastestsmallesttextencoderdecoder: ^1.0.22 - typescript: '>=5' - - '@solana/codecs-strings@3.0.1': - resolution: {integrity: sha512-UxaD1Xdxe35Y2B0HnSHe48ok8ew+tyrVI1w65eHj0NzGb9FxLx/KuuEg/b/qXQRUB75JQjDo8IBh5rWZ7rl5qQ==} + '@solana/codecs-strings@3.0.3': + resolution: {integrity: sha512-VHBXnnTVtcQ1j+7Vrz+qSYo38no+jiHRdGnhFspRXEHNJbllzwKqgBE7YN3qoIXH+MKxgJUcwO5KHmdzf8Wn2A==} engines: {node: '>=20.18.0'} peerDependencies: fastestsmallesttextencoderdecoder: ^1.0.22 typescript: '>=5.3.3' - '@solana/errors@2.0.0-rc.4': - resolution: {integrity: sha512-0PPaMyB81keEHG/1pnyEuiBVKctbXO641M2w3CIOrYT/wzjunfF0FTxsqq9wYJeYo0AyiefCKGgSPs6wiY2PpQ==} - engines: {node: '>=20.18.0'} - hasBin: true - peerDependencies: - typescript: '>=5' - - '@solana/errors@3.0.1': - resolution: {integrity: sha512-/EhRoJLrO03wj+3/miA6YkBnGjAS12mvilWkQ4LBv/hVqhUF9V8JXpSMnD40hoaMraE23V9IaHNHcfoJmldjwA==} + '@solana/errors@3.0.3': + resolution: {integrity: sha512-1l84xJlHNva6io62PcYfUamwWlc0eM95nHgCrKX0g0cLoC6D6QHYPCEbEVkR+C5UtP9JDgyQM8MFiv+Ei5tO9Q==} engines: {node: '>=20.18.0'} hasBin: true peerDependencies: @@ -197,10 +157,6 @@ packages: resolution: {integrity: sha512-oKlSFMcMwpUg2ednkhQ454wfWiU/ul3CkJe/PEHcTKuiX6RpbehUiFMXu13HalGZxfUwCQzZG747YXBn1im9ww==} engines: {node: '>= 0.4'} - call-bound@1.0.3: - resolution: {integrity: sha512-YTd+6wGlNlPxSuri7Y6X8tY2dmm12UMH66RpKMhiX6rsk5wXXnYgbUcOt8kiS31/AjfoTOvCsE+w8nZQLQnzHA==} - engines: {node: '>= 0.4'} - call-bound@1.0.4: resolution: {integrity: sha512-+ys997U96po4Kx/ABpBCqhA9EuxJaQWDQg7295H4hBphv3IZg0boBKuwYpt4YXp6MZ5AmZQnU/tyMTlRpaSejg==} engines: {node: '>= 0.4'} @@ -213,22 +169,22 @@ packages: resolution: {integrity: sha512-46QrSQFyVSEyYAgQ22hQ+zDa60YHA4fBstHmtSApj1Y5vKtG27fWowW03jCk5KcbXEWPZUIR894aARCA/G1kfQ==} engines: {node: ^12.17.0 || ^14.13 || >=16.0.0} + chalk@5.6.2: + resolution: {integrity: sha512-7NzBL0rN6fMUW+f7A6Io4h40qQlG+xGmtMxfbnH/K7TAtt8JQWVQK+6g0UXKMeVJoyV5EkkNsErQ8pVD3bLHbA==} + engines: {node: ^12.17.0 || ^14.13 || >=16.0.0} + codama@1.3.3: resolution: {integrity: sha512-eCOflah25uWKHGyjvW2FPydRAwhDw4ZAjBuBFF9AVJIE3xknR+pcRMLdlxO5LO3ixlxkHKHdESXJY/aVXmzZtw==} hasBin: true - commander@12.1.0: - resolution: {integrity: sha512-Vw8qHK3bZM9y/P10u3Vib8o/DdkvA2OtPtZvD871QKjy74Wj1WSKFILMPRPSdUSx5RFK1arlJzEtA4PkFgnbuA==} - engines: {node: '>=18'} - - commander@13.1.0: - resolution: {integrity: sha512-/rFeCpNJQbhSZjGVwO9RFV3xPqbnERS8MmIQzCtD/zl6gpJuV/bMLuN92oG3F7d8oDEHHRrujSXNUr8fpjntKw==} - engines: {node: '>=18'} - commander@14.0.0: resolution: {integrity: sha512-2uM9rYjPvyq39NwLRqaiLtWHyDC1FvryJDa2ATTVims5YAS4PupsEQsDvP14FqhFr0P49CYDugi59xaxJlTXRA==} engines: {node: '>=20'} + commander@14.0.1: + resolution: {integrity: sha512-2JkV3gUZUVrbNA+1sjBOYLsMZ5cEEl8GTFP2a4AVz5hvasAMCQ1D2l2le/cX+pV4N6ZU17zjUahLpIXRrnWL8A==} + engines: {node: '>=20'} + commander@5.1.0: resolution: {integrity: sha512-P0CysNDQ7rtVw4QIQtm+MRxV66vKFSvlsQvGYXZWR3qFU0jlMKHZZZgw8e+8DSah4UDKMqnknRDQz+xuQXQ/Zg==} engines: {node: '>= 6'} @@ -367,10 +323,6 @@ packages: isexe@2.0.0: resolution: {integrity: sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==} - json-stable-stringify@1.2.1: - resolution: {integrity: sha512-Lp6HbbBgosLmJbjx0pBLbgvx68FaFU1sdkmBuckmhhJ88kL13OA51CDtR2yJB50eCNMH9wRqtQNNiAqQH4YXnA==} - engines: {node: '>= 0.4'} - json-stable-stringify@1.3.0: resolution: {integrity: sha512-qtYiSSFlwot9XHtF9bD9c7rwKjr+RecWT//ZnPvSmEjpV5mmPOCN4j8UjY5hbjNkOwZ/jQv3J6R1/pL7RwgMsg==} engines: {node: '>= 0.4'} @@ -533,78 +485,57 @@ snapshots: picocolors: 1.1.1 prompts: 2.4.2 - '@codama/errors@1.2.11': - dependencies: - '@codama/node-types': 1.2.11 - chalk: 5.4.1 - commander: 13.1.0 - '@codama/errors@1.3.3': dependencies: '@codama/node-types': 1.3.3 chalk: 5.6.0 commander: 14.0.0 - '@codama/errors@1.3.4': + '@codama/errors@1.3.7': dependencies: - '@codama/node-types': 1.3.4 - chalk: 5.6.0 - commander: 14.0.0 - - '@codama/node-types@1.2.11': {} + '@codama/node-types': 1.3.7 + commander: 14.0.1 + picocolors: 1.1.1 '@codama/node-types@1.3.3': {} - '@codama/node-types@1.3.4': {} - - '@codama/nodes@1.2.11': - dependencies: - '@codama/errors': 1.2.11 - '@codama/node-types': 1.2.11 + '@codama/node-types@1.3.7': {} '@codama/nodes@1.3.3': dependencies: '@codama/errors': 1.3.3 '@codama/node-types': 1.3.3 - '@codama/nodes@1.3.4': - dependencies: - '@codama/errors': 1.3.4 - '@codama/node-types': 1.3.4 - - '@codama/renderers-core@1.0.13': + '@codama/nodes@1.3.7': dependencies: - '@codama/errors': 1.2.11 - '@codama/nodes': 1.2.11 - '@codama/visitors-core': 1.2.11 + '@codama/errors': 1.3.7 + '@codama/node-types': 1.3.7 - '@codama/renderers-core@1.1.0': + '@codama/renderers-core@1.2.2': dependencies: - '@codama/errors': 1.3.4 - '@codama/nodes': 1.3.4 - '@codama/visitors-core': 1.3.4 + '@codama/errors': 1.3.7 + '@codama/nodes': 1.3.7 + '@codama/visitors-core': 1.3.7 - '@codama/renderers-js@1.3.5(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.7.3)': + '@codama/renderers-js@1.4.2(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.7.3)': dependencies: - '@codama/errors': 1.3.4 - '@codama/nodes': 1.3.4 - '@codama/renderers-core': 1.1.0 - '@codama/visitors-core': 1.3.4 - '@solana/codecs-strings': 3.0.1(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.7.3) - nunjucks: 3.2.4 + '@codama/errors': 1.3.7 + '@codama/nodes': 1.3.7 + '@codama/renderers-core': 1.2.2 + '@codama/visitors-core': 1.3.7 + '@solana/codecs-strings': 3.0.3(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.7.3) prettier: 3.6.2 transitivePeerDependencies: - - chokidar - fastestsmallesttextencoderdecoder - typescript - '@codama/renderers-rust@1.0.19(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.7.3)': + '@codama/renderers-rust@1.2.7(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.7.3)': dependencies: - '@codama/errors': 1.2.11 - '@codama/nodes': 1.2.11 - '@codama/renderers-core': 1.0.13 - '@codama/visitors-core': 1.2.11 - '@solana/codecs-strings': 2.0.0-rc.4(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.7.3) + '@codama/errors': 1.3.7 + '@codama/nodes': 1.3.7 + '@codama/renderers-core': 1.2.2 + '@codama/visitors-core': 1.3.7 + '@solana/codecs-strings': 3.0.3(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.7.3) nunjucks: 3.2.4 transitivePeerDependencies: - chokidar @@ -617,22 +548,16 @@ snapshots: '@codama/nodes': 1.3.3 '@codama/visitors-core': 1.3.3 - '@codama/visitors-core@1.2.11': - dependencies: - '@codama/errors': 1.2.11 - '@codama/nodes': 1.2.11 - json-stable-stringify: 1.2.1 - '@codama/visitors-core@1.3.3': dependencies: '@codama/errors': 1.3.3 '@codama/nodes': 1.3.3 json-stable-stringify: 1.3.0 - '@codama/visitors-core@1.3.4': + '@codama/visitors-core@1.3.7': dependencies: - '@codama/errors': 1.3.4 - '@codama/nodes': 1.3.4 + '@codama/errors': 1.3.7 + '@codama/nodes': 1.3.7 json-stable-stringify: 1.3.0 '@codama/visitors@1.3.3': @@ -655,53 +580,28 @@ snapshots: '@nodelib/fs.scandir': 2.1.5 fastq: 1.18.0 - '@solana/codecs-core@2.0.0-rc.4(typescript@5.7.3)': + '@solana/codecs-core@3.0.3(typescript@5.7.3)': dependencies: - '@solana/errors': 2.0.0-rc.4(typescript@5.7.3) + '@solana/errors': 3.0.3(typescript@5.7.3) typescript: 5.7.3 - '@solana/codecs-core@3.0.1(typescript@5.7.3)': + '@solana/codecs-numbers@3.0.3(typescript@5.7.3)': dependencies: - '@solana/errors': 3.0.1(typescript@5.7.3) - typescript: 5.7.3 - - '@solana/codecs-numbers@2.0.0-rc.4(typescript@5.7.3)': - dependencies: - '@solana/codecs-core': 2.0.0-rc.4(typescript@5.7.3) - '@solana/errors': 2.0.0-rc.4(typescript@5.7.3) - typescript: 5.7.3 - - '@solana/codecs-numbers@3.0.1(typescript@5.7.3)': - dependencies: - '@solana/codecs-core': 3.0.1(typescript@5.7.3) - '@solana/errors': 3.0.1(typescript@5.7.3) - typescript: 5.7.3 - - '@solana/codecs-strings@2.0.0-rc.4(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.7.3)': - dependencies: - '@solana/codecs-core': 2.0.0-rc.4(typescript@5.7.3) - '@solana/codecs-numbers': 2.0.0-rc.4(typescript@5.7.3) - '@solana/errors': 2.0.0-rc.4(typescript@5.7.3) - fastestsmallesttextencoderdecoder: 1.0.22 + '@solana/codecs-core': 3.0.3(typescript@5.7.3) + '@solana/errors': 3.0.3(typescript@5.7.3) typescript: 5.7.3 - '@solana/codecs-strings@3.0.1(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.7.3)': + '@solana/codecs-strings@3.0.3(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.7.3)': dependencies: - '@solana/codecs-core': 3.0.1(typescript@5.7.3) - '@solana/codecs-numbers': 3.0.1(typescript@5.7.3) - '@solana/errors': 3.0.1(typescript@5.7.3) + '@solana/codecs-core': 3.0.3(typescript@5.7.3) + '@solana/codecs-numbers': 3.0.3(typescript@5.7.3) + '@solana/errors': 3.0.3(typescript@5.7.3) fastestsmallesttextencoderdecoder: 1.0.22 typescript: 5.7.3 - '@solana/errors@2.0.0-rc.4(typescript@5.7.3)': + '@solana/errors@3.0.3(typescript@5.7.3)': dependencies: - chalk: 5.6.0 - commander: 12.1.0 - typescript: 5.7.3 - - '@solana/errors@3.0.1(typescript@5.7.3)': - dependencies: - chalk: 5.6.0 + chalk: 5.6.2 commander: 14.0.0 typescript: 5.7.3 @@ -749,11 +649,6 @@ snapshots: get-intrinsic: 1.2.7 set-function-length: 1.2.2 - call-bound@1.0.3: - dependencies: - call-bind-apply-helpers: 1.0.1 - get-intrinsic: 1.2.7 - call-bound@1.0.4: dependencies: call-bind-apply-helpers: 1.0.2 @@ -763,6 +658,8 @@ snapshots: chalk@5.6.0: {} + chalk@5.6.2: {} + codama@1.3.3: dependencies: '@codama/cli': 1.3.1 @@ -771,12 +668,10 @@ snapshots: '@codama/validators': 1.3.3 '@codama/visitors': 1.3.3 - commander@12.1.0: {} - - commander@13.1.0: {} - commander@14.0.0: {} + commander@14.0.1: {} + commander@5.1.0: {} data-uri-to-buffer@4.0.1: {} @@ -931,14 +826,6 @@ snapshots: isexe@2.0.0: {} - json-stable-stringify@1.2.1: - dependencies: - call-bind: 1.0.8 - call-bound: 1.0.3 - isarray: 2.0.5 - jsonify: 0.0.1 - object-keys: 1.1.1 - json-stable-stringify@1.3.0: dependencies: call-bind: 1.0.8 diff --git a/scripts/generate-clients.mjs b/scripts/generate-clients.mjs index 96e3702..072a709 100644 --- a/scripts/generate-clients.mjs +++ b/scripts/generate-clients.mjs @@ -92,6 +92,7 @@ codama.accept( renderRustVisitor(path.join(rustClient, 'src', 'generated'), { formatCode: true, crateFolder: rustClient, + toolchain: '+nightly-2025-02-16', anchorTraits: false, linkOverrides: { definedTypes: {