diff --git a/clients/js/src/generated/accounts/escrowV2.ts b/clients/js/src/generated/accounts/escrowV2.ts new file mode 100644 index 0000000..8d3c74b --- /dev/null +++ b/clients/js/src/generated/accounts/escrowV2.ts @@ -0,0 +1,142 @@ +/** + * This code was AUTOGENERATED using the kinobi library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun kinobi to update it. + * + * @see https://github.com/metaplex-foundation/kinobi + */ + +import { + Account, + Context, + Pda, + PublicKey, + RpcAccount, + RpcGetAccountOptions, + RpcGetAccountsOptions, + assertAccountExists, + deserializeAccount, + gpaBuilder, + publicKey as toPublicKey, +} from '@metaplex-foundation/umi'; +import { + Serializer, + array, + mapSerializer, + publicKey as publicKeySerializer, + struct, + u8, +} from '@metaplex-foundation/umi/serializers'; + +export type EscrowV2 = Account; + +export type EscrowV2AccountData = { + discriminator: Array; + authority: PublicKey; + bump: number; +}; + +export type EscrowV2AccountDataArgs = { authority: PublicKey; bump: number }; + +export function getEscrowV2AccountDataSerializer(): Serializer< + EscrowV2AccountDataArgs, + EscrowV2AccountData +> { + return mapSerializer( + struct( + [ + ['discriminator', array(u8(), { size: 8 })], + ['authority', publicKeySerializer()], + ['bump', u8()], + ], + { description: 'EscrowV2AccountData' } + ), + (value) => ({ + ...value, + discriminator: [229, 26, 241, 181, 158, 158, 70, 190], + }) + ) as Serializer; +} + +export function deserializeEscrowV2(rawAccount: RpcAccount): EscrowV2 { + return deserializeAccount(rawAccount, getEscrowV2AccountDataSerializer()); +} + +export async function fetchEscrowV2( + context: Pick, + publicKey: PublicKey | Pda, + options?: RpcGetAccountOptions +): Promise { + const maybeAccount = await context.rpc.getAccount( + toPublicKey(publicKey, false), + options + ); + assertAccountExists(maybeAccount, 'EscrowV2'); + return deserializeEscrowV2(maybeAccount); +} + +export async function safeFetchEscrowV2( + context: Pick, + publicKey: PublicKey | Pda, + options?: RpcGetAccountOptions +): Promise { + const maybeAccount = await context.rpc.getAccount( + toPublicKey(publicKey, false), + options + ); + return maybeAccount.exists ? deserializeEscrowV2(maybeAccount) : null; +} + +export async function fetchAllEscrowV2( + context: Pick, + publicKeys: Array, + options?: RpcGetAccountsOptions +): Promise { + const maybeAccounts = await context.rpc.getAccounts( + publicKeys.map((key) => toPublicKey(key, false)), + options + ); + return maybeAccounts.map((maybeAccount) => { + assertAccountExists(maybeAccount, 'EscrowV2'); + return deserializeEscrowV2(maybeAccount); + }); +} + +export async function safeFetchAllEscrowV2( + context: Pick, + publicKeys: Array, + options?: RpcGetAccountsOptions +): Promise { + const maybeAccounts = await context.rpc.getAccounts( + publicKeys.map((key) => toPublicKey(key, false)), + options + ); + return maybeAccounts + .filter((maybeAccount) => maybeAccount.exists) + .map((maybeAccount) => deserializeEscrowV2(maybeAccount as RpcAccount)); +} + +export function getEscrowV2GpaBuilder( + context: Pick +) { + const programId = context.programs.getPublicKey( + 'mplHybrid', + 'MPL4o4wMzndgh8T1NVDxELQCj5UQfYTYEkabX3wNKtb' + ); + return gpaBuilder(context, programId) + .registerFields<{ + discriminator: Array; + authority: PublicKey; + bump: number; + }>({ + discriminator: [0, array(u8(), { size: 8 })], + authority: [8, publicKeySerializer()], + bump: [40, u8()], + }) + .deserializeUsing((account) => deserializeEscrowV2(account)) + .whereField('discriminator', [229, 26, 241, 181, 158, 158, 70, 190]); +} + +export function getEscrowV2Size(): number { + return 41; +} diff --git a/clients/js/src/generated/accounts/index.ts b/clients/js/src/generated/accounts/index.ts index 517bef2..e1b208f 100644 --- a/clients/js/src/generated/accounts/index.ts +++ b/clients/js/src/generated/accounts/index.ts @@ -7,4 +7,6 @@ */ export * from './escrowV1'; +export * from './escrowV2'; export * from './nftDataV1'; +export * from './recipeV1'; diff --git a/clients/js/src/generated/accounts/recipeV1.ts b/clients/js/src/generated/accounts/recipeV1.ts new file mode 100644 index 0000000..30fdce9 --- /dev/null +++ b/clients/js/src/generated/accounts/recipeV1.ts @@ -0,0 +1,214 @@ +/** + * This code was AUTOGENERATED using the kinobi library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun kinobi to update it. + * + * @see https://github.com/metaplex-foundation/kinobi + */ + +import { + Account, + Context, + Pda, + PublicKey, + RpcAccount, + RpcGetAccountOptions, + RpcGetAccountsOptions, + assertAccountExists, + deserializeAccount, + gpaBuilder, + publicKey as toPublicKey, +} from '@metaplex-foundation/umi'; +import { + Serializer, + array, + mapSerializer, + publicKey as publicKeySerializer, + string, + struct, + u16, + u64, + u8, +} from '@metaplex-foundation/umi/serializers'; + +export type RecipeV1 = Account; + +export type RecipeV1AccountData = { + discriminator: Array; + collection: PublicKey; + authority: PublicKey; + token: PublicKey; + feeLocation: PublicKey; + name: string; + uri: string; + max: bigint; + min: bigint; + amount: bigint; + feeAmountCapture: bigint; + solFeeAmountCapture: bigint; + feeAmountRelease: bigint; + solFeeAmountRelease: bigint; + count: bigint; + path: number; + bump: number; +}; + +export type RecipeV1AccountDataArgs = { + collection: PublicKey; + authority: PublicKey; + token: PublicKey; + feeLocation: PublicKey; + name: string; + uri: string; + max: number | bigint; + min: number | bigint; + amount: number | bigint; + feeAmountCapture: number | bigint; + solFeeAmountCapture: number | bigint; + feeAmountRelease: number | bigint; + solFeeAmountRelease: number | bigint; + count: number | bigint; + path: number; + bump: number; +}; + +export function getRecipeV1AccountDataSerializer(): Serializer< + RecipeV1AccountDataArgs, + RecipeV1AccountData +> { + return mapSerializer( + struct( + [ + ['discriminator', array(u8(), { size: 8 })], + ['collection', publicKeySerializer()], + ['authority', publicKeySerializer()], + ['token', publicKeySerializer()], + ['feeLocation', publicKeySerializer()], + ['name', string()], + ['uri', string()], + ['max', u64()], + ['min', u64()], + ['amount', u64()], + ['feeAmountCapture', u64()], + ['solFeeAmountCapture', u64()], + ['feeAmountRelease', u64()], + ['solFeeAmountRelease', u64()], + ['count', u64()], + ['path', u16()], + ['bump', u8()], + ], + { description: 'RecipeV1AccountData' } + ), + (value) => ({ + ...value, + discriminator: [137, 249, 37, 80, 19, 50, 78, 169], + }) + ) as Serializer; +} + +export function deserializeRecipeV1(rawAccount: RpcAccount): RecipeV1 { + return deserializeAccount(rawAccount, getRecipeV1AccountDataSerializer()); +} + +export async function fetchRecipeV1( + context: Pick, + publicKey: PublicKey | Pda, + options?: RpcGetAccountOptions +): Promise { + const maybeAccount = await context.rpc.getAccount( + toPublicKey(publicKey, false), + options + ); + assertAccountExists(maybeAccount, 'RecipeV1'); + return deserializeRecipeV1(maybeAccount); +} + +export async function safeFetchRecipeV1( + context: Pick, + publicKey: PublicKey | Pda, + options?: RpcGetAccountOptions +): Promise { + const maybeAccount = await context.rpc.getAccount( + toPublicKey(publicKey, false), + options + ); + return maybeAccount.exists ? deserializeRecipeV1(maybeAccount) : null; +} + +export async function fetchAllRecipeV1( + context: Pick, + publicKeys: Array, + options?: RpcGetAccountsOptions +): Promise { + const maybeAccounts = await context.rpc.getAccounts( + publicKeys.map((key) => toPublicKey(key, false)), + options + ); + return maybeAccounts.map((maybeAccount) => { + assertAccountExists(maybeAccount, 'RecipeV1'); + return deserializeRecipeV1(maybeAccount); + }); +} + +export async function safeFetchAllRecipeV1( + context: Pick, + publicKeys: Array, + options?: RpcGetAccountsOptions +): Promise { + const maybeAccounts = await context.rpc.getAccounts( + publicKeys.map((key) => toPublicKey(key, false)), + options + ); + return maybeAccounts + .filter((maybeAccount) => maybeAccount.exists) + .map((maybeAccount) => deserializeRecipeV1(maybeAccount as RpcAccount)); +} + +export function getRecipeV1GpaBuilder( + context: Pick +) { + const programId = context.programs.getPublicKey( + 'mplHybrid', + 'MPL4o4wMzndgh8T1NVDxELQCj5UQfYTYEkabX3wNKtb' + ); + return gpaBuilder(context, programId) + .registerFields<{ + discriminator: Array; + collection: PublicKey; + authority: PublicKey; + token: PublicKey; + feeLocation: PublicKey; + name: string; + uri: string; + max: number | bigint; + min: number | bigint; + amount: number | bigint; + feeAmountCapture: number | bigint; + solFeeAmountCapture: number | bigint; + feeAmountRelease: number | bigint; + solFeeAmountRelease: number | bigint; + count: number | bigint; + path: number; + bump: number; + }>({ + discriminator: [0, array(u8(), { size: 8 })], + collection: [8, publicKeySerializer()], + authority: [40, publicKeySerializer()], + token: [72, publicKeySerializer()], + feeLocation: [104, publicKeySerializer()], + name: [136, string()], + uri: [null, string()], + max: [null, u64()], + min: [null, u64()], + amount: [null, u64()], + feeAmountCapture: [null, u64()], + solFeeAmountCapture: [null, u64()], + feeAmountRelease: [null, u64()], + solFeeAmountRelease: [null, u64()], + count: [null, u64()], + path: [null, u16()], + bump: [null, u8()], + }) + .deserializeUsing((account) => deserializeRecipeV1(account)) + .whereField('discriminator', [137, 249, 37, 80, 19, 50, 78, 169]); +} diff --git a/clients/js/src/generated/errors/mplHybrid.ts b/clients/js/src/generated/errors/mplHybrid.ts index 3cb91d8..20b2e3c 100644 --- a/clients/js/src/generated/errors/mplHybrid.ts +++ b/clients/js/src/generated/errors/mplHybrid.ts @@ -226,6 +226,19 @@ export class InvalidTokenAccountMintError extends ProgramError { codeToErrorMap.set(0x177f, InvalidTokenAccountMintError); nameToErrorMap.set('InvalidTokenAccountMint', InvalidTokenAccountMintError); +/** InvalidAuthority: Invalid Authorities */ +export class InvalidAuthorityError extends ProgramError { + override readonly name: string = 'InvalidAuthority'; + + readonly code: number = 0x1780; // 6016 + + constructor(program: Program, cause?: Error) { + super('Invalid Authorities', program, cause); + } +} +codeToErrorMap.set(0x1780, InvalidAuthorityError); +nameToErrorMap.set('InvalidAuthority', InvalidAuthorityError); + /** * Attempts to resolve a custom program error from the provided error code. * @category Errors diff --git a/clients/js/src/generated/instructions/captureV2.ts b/clients/js/src/generated/instructions/captureV2.ts new file mode 100644 index 0000000..465bc3c --- /dev/null +++ b/clients/js/src/generated/instructions/captureV2.ts @@ -0,0 +1,216 @@ +/** + * This code was AUTOGENERATED using the kinobi library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun kinobi to update it. + * + * @see https://github.com/metaplex-foundation/kinobi + */ + +import { + Context, + Pda, + PublicKey, + Signer, + TransactionBuilder, + transactionBuilder, +} from '@metaplex-foundation/umi'; +import { + Serializer, + array, + mapSerializer, + struct, + u8, +} from '@metaplex-foundation/umi/serializers'; +import { + ResolvedAccount, + ResolvedAccountsWithIndices, + getAccountMetasAndSigners, +} from '../shared'; + +// Accounts. +export type CaptureV2InstructionAccounts = { + owner: Signer; + authority?: Signer; + recipe: PublicKey | Pda; + escrow: PublicKey | Pda; + asset: PublicKey | Pda; + collection: PublicKey | Pda; + userTokenAccount: PublicKey | Pda; + escrowTokenAccount: PublicKey | Pda; + token: PublicKey | Pda; + feeTokenAccount: PublicKey | Pda; + feeSolAccount: PublicKey | Pda; + feeProjectAccount: PublicKey | Pda; + recentBlockhashes: PublicKey | Pda; + mplCore: PublicKey | Pda; + systemProgram?: PublicKey | Pda; + tokenProgram?: PublicKey | Pda; + associatedTokenProgram: PublicKey | Pda; +}; + +// Data. +export type CaptureV2InstructionData = { discriminator: Array }; + +export type CaptureV2InstructionDataArgs = {}; + +export function getCaptureV2InstructionDataSerializer(): Serializer< + CaptureV2InstructionDataArgs, + CaptureV2InstructionData +> { + return mapSerializer< + CaptureV2InstructionDataArgs, + any, + CaptureV2InstructionData + >( + struct( + [['discriminator', array(u8(), { size: 8 })]], + { description: 'CaptureV2InstructionData' } + ), + (value) => ({ + ...value, + discriminator: [51, 185, 212, 68, 232, 11, 101, 30], + }) + ) as Serializer; +} + +// Instruction. +export function captureV2( + context: Pick, + input: CaptureV2InstructionAccounts +): TransactionBuilder { + // Program ID. + const programId = context.programs.getPublicKey( + 'mplHybrid', + 'MPL4o4wMzndgh8T1NVDxELQCj5UQfYTYEkabX3wNKtb' + ); + + // Accounts. + const resolvedAccounts = { + owner: { + index: 0, + isWritable: true as boolean, + value: input.owner ?? null, + }, + authority: { + index: 1, + isWritable: true as boolean, + value: input.authority ?? null, + }, + recipe: { + index: 2, + isWritable: true as boolean, + value: input.recipe ?? null, + }, + escrow: { + index: 3, + isWritable: true as boolean, + value: input.escrow ?? null, + }, + asset: { + index: 4, + isWritable: true as boolean, + value: input.asset ?? null, + }, + collection: { + index: 5, + isWritable: true as boolean, + value: input.collection ?? null, + }, + userTokenAccount: { + index: 6, + isWritable: true as boolean, + value: input.userTokenAccount ?? null, + }, + escrowTokenAccount: { + index: 7, + isWritable: true as boolean, + value: input.escrowTokenAccount ?? null, + }, + token: { + index: 8, + isWritable: false as boolean, + value: input.token ?? null, + }, + feeTokenAccount: { + index: 9, + isWritable: true as boolean, + value: input.feeTokenAccount ?? null, + }, + feeSolAccount: { + index: 10, + isWritable: true as boolean, + value: input.feeSolAccount ?? null, + }, + feeProjectAccount: { + index: 11, + isWritable: true as boolean, + value: input.feeProjectAccount ?? null, + }, + recentBlockhashes: { + index: 12, + isWritable: false as boolean, + value: input.recentBlockhashes ?? null, + }, + mplCore: { + index: 13, + isWritable: false as boolean, + value: input.mplCore ?? null, + }, + systemProgram: { + index: 14, + isWritable: false as boolean, + value: input.systemProgram ?? null, + }, + tokenProgram: { + index: 15, + isWritable: false as boolean, + value: input.tokenProgram ?? null, + }, + associatedTokenProgram: { + index: 16, + isWritable: false as boolean, + value: input.associatedTokenProgram ?? null, + }, + } satisfies ResolvedAccountsWithIndices; + + // Default values. + if (!resolvedAccounts.authority.value) { + resolvedAccounts.authority.value = context.identity; + } + if (!resolvedAccounts.systemProgram.value) { + resolvedAccounts.systemProgram.value = context.programs.getPublicKey( + 'splSystem', + '11111111111111111111111111111111' + ); + resolvedAccounts.systemProgram.isWritable = false; + } + if (!resolvedAccounts.tokenProgram.value) { + resolvedAccounts.tokenProgram.value = context.programs.getPublicKey( + 'splToken', + 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA' + ); + resolvedAccounts.tokenProgram.isWritable = false; + } + + // Accounts in order. + const orderedAccounts: ResolvedAccount[] = Object.values( + resolvedAccounts + ).sort((a, b) => a.index - b.index); + + // Keys and Signers. + const [keys, signers] = getAccountMetasAndSigners( + orderedAccounts, + 'programId', + programId + ); + + // Data. + const data = getCaptureV2InstructionDataSerializer().serialize({}); + + // Bytes Created On Chain. + const bytesCreatedOnChain = 0; + + return transactionBuilder([ + { instruction: { keys, programId, data }, signers, bytesCreatedOnChain }, + ]); +} diff --git a/clients/js/src/generated/instructions/index.ts b/clients/js/src/generated/instructions/index.ts index b3f2fd7..13441b9 100644 --- a/clients/js/src/generated/instructions/index.ts +++ b/clients/js/src/generated/instructions/index.ts @@ -7,8 +7,15 @@ */ export * from './captureV1'; +export * from './captureV2'; export * from './initEscrowV1'; +export * from './initEscrowV2'; export * from './initNftDataV1'; +export * from './initRecipe'; +export * from './migrateNftV1'; +export * from './migrateTokensV1'; export * from './releaseV1'; +export * from './releaseV2'; export * from './updateEscrowV1'; export * from './updateNewDataV1'; +export * from './updateRecipeV1'; diff --git a/clients/js/src/generated/instructions/initEscrowV2.ts b/clients/js/src/generated/instructions/initEscrowV2.ts new file mode 100644 index 0000000..88e4a56 --- /dev/null +++ b/clients/js/src/generated/instructions/initEscrowV2.ts @@ -0,0 +1,125 @@ +/** + * This code was AUTOGENERATED using the kinobi library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun kinobi to update it. + * + * @see https://github.com/metaplex-foundation/kinobi + */ + +import { + Context, + Pda, + PublicKey, + Signer, + TransactionBuilder, + transactionBuilder, +} from '@metaplex-foundation/umi'; +import { + Serializer, + array, + mapSerializer, + struct, + u8, +} from '@metaplex-foundation/umi/serializers'; +import { + ResolvedAccount, + ResolvedAccountsWithIndices, + getAccountMetasAndSigners, +} from '../shared'; + +// Accounts. +export type InitEscrowV2InstructionAccounts = { + escrow: PublicKey | Pda; + authority?: Signer; + systemProgram?: PublicKey | Pda; +}; + +// Data. +export type InitEscrowV2InstructionData = { discriminator: Array }; + +export type InitEscrowV2InstructionDataArgs = {}; + +export function getInitEscrowV2InstructionDataSerializer(): Serializer< + InitEscrowV2InstructionDataArgs, + InitEscrowV2InstructionData +> { + return mapSerializer< + InitEscrowV2InstructionDataArgs, + any, + InitEscrowV2InstructionData + >( + struct( + [['discriminator', array(u8(), { size: 8 })]], + { description: 'InitEscrowV2InstructionData' } + ), + (value) => ({ + ...value, + discriminator: [131, 108, 25, 241, 183, 34, 121, 27], + }) + ) as Serializer; +} + +// Instruction. +export function initEscrowV2( + context: Pick, + input: InitEscrowV2InstructionAccounts +): TransactionBuilder { + // Program ID. + const programId = context.programs.getPublicKey( + 'mplHybrid', + 'MPL4o4wMzndgh8T1NVDxELQCj5UQfYTYEkabX3wNKtb' + ); + + // Accounts. + const resolvedAccounts = { + escrow: { + index: 0, + isWritable: true as boolean, + value: input.escrow ?? null, + }, + authority: { + index: 1, + isWritable: true as boolean, + value: input.authority ?? null, + }, + systemProgram: { + index: 2, + isWritable: false as boolean, + value: input.systemProgram ?? null, + }, + } satisfies ResolvedAccountsWithIndices; + + // Default values. + if (!resolvedAccounts.authority.value) { + resolvedAccounts.authority.value = context.identity; + } + if (!resolvedAccounts.systemProgram.value) { + resolvedAccounts.systemProgram.value = context.programs.getPublicKey( + 'splSystem', + '11111111111111111111111111111111' + ); + resolvedAccounts.systemProgram.isWritable = false; + } + + // Accounts in order. + const orderedAccounts: ResolvedAccount[] = Object.values( + resolvedAccounts + ).sort((a, b) => a.index - b.index); + + // Keys and Signers. + const [keys, signers] = getAccountMetasAndSigners( + orderedAccounts, + 'programId', + programId + ); + + // Data. + const data = getInitEscrowV2InstructionDataSerializer().serialize({}); + + // Bytes Created On Chain. + const bytesCreatedOnChain = 0; + + return transactionBuilder([ + { instruction: { keys, programId, data }, signers, bytesCreatedOnChain }, + ]); +} diff --git a/clients/js/src/generated/instructions/initRecipe.ts b/clients/js/src/generated/instructions/initRecipe.ts new file mode 100644 index 0000000..66289cb --- /dev/null +++ b/clients/js/src/generated/instructions/initRecipe.ts @@ -0,0 +1,215 @@ +/** + * This code was AUTOGENERATED using the kinobi library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun kinobi to update it. + * + * @see https://github.com/metaplex-foundation/kinobi + */ + +import { + Context, + Pda, + PublicKey, + Signer, + TransactionBuilder, + transactionBuilder, +} from '@metaplex-foundation/umi'; +import { + Serializer, + array, + mapSerializer, + string, + struct, + u16, + u64, + u8, +} from '@metaplex-foundation/umi/serializers'; +import { + ResolvedAccount, + ResolvedAccountsWithIndices, + getAccountMetasAndSigners, +} from '../shared'; + +// Accounts. +export type InitRecipeInstructionAccounts = { + recipe: PublicKey | Pda; + authority?: Signer; + collection: PublicKey | Pda; + token: PublicKey | Pda; + feeLocation: PublicKey | Pda; + /** The ATA for token fees to be stored */ + feeAta: PublicKey | Pda; + systemProgram?: PublicKey | Pda; + tokenProgram?: PublicKey | Pda; + associatedTokenProgram: PublicKey | Pda; +}; + +// Data. +export type InitRecipeInstructionData = { + discriminator: Array; + name: string; + uri: string; + max: bigint; + min: bigint; + amount: bigint; + feeAmountCapture: bigint; + feeAmountRelease: bigint; + solFeeAmountCapture: bigint; + solFeeAmountRelease: bigint; + path: number; +}; + +export type InitRecipeInstructionDataArgs = { + name: string; + uri: string; + max: number | bigint; + min: number | bigint; + amount: number | bigint; + feeAmountCapture: number | bigint; + feeAmountRelease: number | bigint; + solFeeAmountCapture: number | bigint; + solFeeAmountRelease: number | bigint; + path: number; +}; + +export function getInitRecipeInstructionDataSerializer(): Serializer< + InitRecipeInstructionDataArgs, + InitRecipeInstructionData +> { + return mapSerializer< + InitRecipeInstructionDataArgs, + any, + InitRecipeInstructionData + >( + struct( + [ + ['discriminator', array(u8(), { size: 8 })], + ['name', string()], + ['uri', string()], + ['max', u64()], + ['min', u64()], + ['amount', u64()], + ['feeAmountCapture', u64()], + ['feeAmountRelease', u64()], + ['solFeeAmountCapture', u64()], + ['solFeeAmountRelease', u64()], + ['path', u16()], + ], + { description: 'InitRecipeInstructionData' } + ), + (value) => ({ + ...value, + discriminator: [196, 35, 249, 242, 64, 106, 51, 53], + }) + ) as Serializer; +} + +// Args. +export type InitRecipeInstructionArgs = InitRecipeInstructionDataArgs; + +// Instruction. +export function initRecipe( + context: Pick, + input: InitRecipeInstructionAccounts & InitRecipeInstructionArgs +): TransactionBuilder { + // Program ID. + const programId = context.programs.getPublicKey( + 'mplHybrid', + 'MPL4o4wMzndgh8T1NVDxELQCj5UQfYTYEkabX3wNKtb' + ); + + // Accounts. + const resolvedAccounts = { + recipe: { + index: 0, + isWritable: true as boolean, + value: input.recipe ?? null, + }, + authority: { + index: 1, + isWritable: true as boolean, + value: input.authority ?? null, + }, + collection: { + index: 2, + isWritable: false as boolean, + value: input.collection ?? null, + }, + token: { + index: 3, + isWritable: false as boolean, + value: input.token ?? null, + }, + feeLocation: { + index: 4, + isWritable: false as boolean, + value: input.feeLocation ?? null, + }, + feeAta: { + index: 5, + isWritable: true as boolean, + value: input.feeAta ?? null, + }, + systemProgram: { + index: 6, + isWritable: false as boolean, + value: input.systemProgram ?? null, + }, + tokenProgram: { + index: 7, + isWritable: false as boolean, + value: input.tokenProgram ?? null, + }, + associatedTokenProgram: { + index: 8, + isWritable: false as boolean, + value: input.associatedTokenProgram ?? null, + }, + } satisfies ResolvedAccountsWithIndices; + + // Arguments. + const resolvedArgs: InitRecipeInstructionArgs = { ...input }; + + // Default values. + if (!resolvedAccounts.authority.value) { + resolvedAccounts.authority.value = context.identity; + } + if (!resolvedAccounts.systemProgram.value) { + resolvedAccounts.systemProgram.value = context.programs.getPublicKey( + 'splSystem', + '11111111111111111111111111111111' + ); + resolvedAccounts.systemProgram.isWritable = false; + } + if (!resolvedAccounts.tokenProgram.value) { + resolvedAccounts.tokenProgram.value = context.programs.getPublicKey( + 'splToken', + 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA' + ); + resolvedAccounts.tokenProgram.isWritable = false; + } + + // Accounts in order. + const orderedAccounts: ResolvedAccount[] = Object.values( + resolvedAccounts + ).sort((a, b) => a.index - b.index); + + // Keys and Signers. + const [keys, signers] = getAccountMetasAndSigners( + orderedAccounts, + 'programId', + programId + ); + + // Data. + const data = getInitRecipeInstructionDataSerializer().serialize( + resolvedArgs as InitRecipeInstructionDataArgs + ); + + // Bytes Created On Chain. + const bytesCreatedOnChain = 0; + + return transactionBuilder([ + { instruction: { keys, programId, data }, signers, bytesCreatedOnChain }, + ]); +} diff --git a/clients/js/src/generated/instructions/migrateNftV1.ts b/clients/js/src/generated/instructions/migrateNftV1.ts new file mode 100644 index 0000000..da93f98 --- /dev/null +++ b/clients/js/src/generated/instructions/migrateNftV1.ts @@ -0,0 +1,149 @@ +/** + * This code was AUTOGENERATED using the kinobi library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun kinobi to update it. + * + * @see https://github.com/metaplex-foundation/kinobi + */ + +import { + Context, + Pda, + PublicKey, + Signer, + TransactionBuilder, + transactionBuilder, +} from '@metaplex-foundation/umi'; +import { + Serializer, + array, + mapSerializer, + struct, + u8, +} from '@metaplex-foundation/umi/serializers'; +import { + ResolvedAccount, + ResolvedAccountsWithIndices, + getAccountMetasAndSigners, +} from '../shared'; + +// Accounts. +export type MigrateNftV1InstructionAccounts = { + authority?: Signer; + escrowNew: PublicKey | Pda; + escrowOld: PublicKey | Pda; + asset: PublicKey | Pda; + collection: PublicKey | Pda; + mplCore: PublicKey | Pda; + systemProgram?: PublicKey | Pda; +}; + +// Data. +export type MigrateNftV1InstructionData = { discriminator: Array }; + +export type MigrateNftV1InstructionDataArgs = {}; + +export function getMigrateNftV1InstructionDataSerializer(): Serializer< + MigrateNftV1InstructionDataArgs, + MigrateNftV1InstructionData +> { + return mapSerializer< + MigrateNftV1InstructionDataArgs, + any, + MigrateNftV1InstructionData + >( + struct( + [['discriminator', array(u8(), { size: 8 })]], + { description: 'MigrateNftV1InstructionData' } + ), + (value) => ({ + ...value, + discriminator: [134, 95, 245, 237, 50, 234, 182, 6], + }) + ) as Serializer; +} + +// Instruction. +export function migrateNftV1( + context: Pick, + input: MigrateNftV1InstructionAccounts +): TransactionBuilder { + // Program ID. + const programId = context.programs.getPublicKey( + 'mplHybrid', + 'MPL4o4wMzndgh8T1NVDxELQCj5UQfYTYEkabX3wNKtb' + ); + + // Accounts. + const resolvedAccounts = { + authority: { + index: 0, + isWritable: true as boolean, + value: input.authority ?? null, + }, + escrowNew: { + index: 1, + isWritable: true as boolean, + value: input.escrowNew ?? null, + }, + escrowOld: { + index: 2, + isWritable: true as boolean, + value: input.escrowOld ?? null, + }, + asset: { + index: 3, + isWritable: true as boolean, + value: input.asset ?? null, + }, + collection: { + index: 4, + isWritable: true as boolean, + value: input.collection ?? null, + }, + mplCore: { + index: 5, + isWritable: false as boolean, + value: input.mplCore ?? null, + }, + systemProgram: { + index: 6, + isWritable: false as boolean, + value: input.systemProgram ?? null, + }, + } satisfies ResolvedAccountsWithIndices; + + // Default values. + if (!resolvedAccounts.authority.value) { + resolvedAccounts.authority.value = context.identity; + } + if (!resolvedAccounts.systemProgram.value) { + resolvedAccounts.systemProgram.value = context.programs.getPublicKey( + 'splSystem', + '11111111111111111111111111111111' + ); + resolvedAccounts.systemProgram.isWritable = false; + } + + // Accounts in order. + const orderedAccounts: ResolvedAccount[] = Object.values( + resolvedAccounts + ).sort((a, b) => a.index - b.index); + + // Keys and Signers. + const [keys, signers] = getAccountMetasAndSigners( + orderedAccounts, + 'programId', + programId + ); + + // Data. + const data = getMigrateNftV1InstructionDataSerializer().serialize({}); + + // Bytes Created On Chain. + const bytesCreatedOnChain = 0; + + return transactionBuilder([ + { instruction: { keys, programId, data }, signers, bytesCreatedOnChain }, + ]); +} diff --git a/clients/js/src/generated/instructions/migrateTokensV1.ts b/clients/js/src/generated/instructions/migrateTokensV1.ts new file mode 100644 index 0000000..9295db9 --- /dev/null +++ b/clients/js/src/generated/instructions/migrateTokensV1.ts @@ -0,0 +1,192 @@ +/** + * This code was AUTOGENERATED using the kinobi library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun kinobi to update it. + * + * @see https://github.com/metaplex-foundation/kinobi + */ + +import { + Context, + Pda, + PublicKey, + Signer, + TransactionBuilder, + transactionBuilder, +} from '@metaplex-foundation/umi'; +import { + Serializer, + array, + mapSerializer, + struct, + u64, + u8, +} from '@metaplex-foundation/umi/serializers'; +import { + ResolvedAccount, + ResolvedAccountsWithIndices, + getAccountMetasAndSigners, +} from '../shared'; + +// Accounts. +export type MigrateTokensV1InstructionAccounts = { + authority?: Signer; + escrowNew: PublicKey | Pda; + escrowOld: PublicKey | Pda; + collection: PublicKey | Pda; + escrowNewTokenAccount: PublicKey | Pda; + escrowOldTokenAccount: PublicKey | Pda; + token: PublicKey | Pda; + systemProgram?: PublicKey | Pda; + tokenProgram?: PublicKey | Pda; + associatedTokenProgram: PublicKey | Pda; +}; + +// Data. +export type MigrateTokensV1InstructionData = { + discriminator: Array; + amount: bigint; +}; + +export type MigrateTokensV1InstructionDataArgs = { amount: number | bigint }; + +export function getMigrateTokensV1InstructionDataSerializer(): Serializer< + MigrateTokensV1InstructionDataArgs, + MigrateTokensV1InstructionData +> { + return mapSerializer< + MigrateTokensV1InstructionDataArgs, + any, + MigrateTokensV1InstructionData + >( + struct( + [ + ['discriminator', array(u8(), { size: 8 })], + ['amount', u64()], + ], + { description: 'MigrateTokensV1InstructionData' } + ), + (value) => ({ + ...value, + discriminator: [214, 119, 117, 84, 29, 252, 202, 13], + }) + ) as Serializer< + MigrateTokensV1InstructionDataArgs, + MigrateTokensV1InstructionData + >; +} + +// Args. +export type MigrateTokensV1InstructionArgs = MigrateTokensV1InstructionDataArgs; + +// Instruction. +export function migrateTokensV1( + context: Pick, + input: MigrateTokensV1InstructionAccounts & MigrateTokensV1InstructionArgs +): TransactionBuilder { + // Program ID. + const programId = context.programs.getPublicKey( + 'mplHybrid', + 'MPL4o4wMzndgh8T1NVDxELQCj5UQfYTYEkabX3wNKtb' + ); + + // Accounts. + const resolvedAccounts = { + authority: { + index: 0, + isWritable: true as boolean, + value: input.authority ?? null, + }, + escrowNew: { + index: 1, + isWritable: true as boolean, + value: input.escrowNew ?? null, + }, + escrowOld: { + index: 2, + isWritable: true as boolean, + value: input.escrowOld ?? null, + }, + collection: { + index: 3, + isWritable: true as boolean, + value: input.collection ?? null, + }, + escrowNewTokenAccount: { + index: 4, + isWritable: true as boolean, + value: input.escrowNewTokenAccount ?? null, + }, + escrowOldTokenAccount: { + index: 5, + isWritable: true as boolean, + value: input.escrowOldTokenAccount ?? null, + }, + token: { + index: 6, + isWritable: false as boolean, + value: input.token ?? null, + }, + systemProgram: { + index: 7, + isWritable: false as boolean, + value: input.systemProgram ?? null, + }, + tokenProgram: { + index: 8, + isWritable: false as boolean, + value: input.tokenProgram ?? null, + }, + associatedTokenProgram: { + index: 9, + isWritable: false as boolean, + value: input.associatedTokenProgram ?? null, + }, + } satisfies ResolvedAccountsWithIndices; + + // Arguments. + const resolvedArgs: MigrateTokensV1InstructionArgs = { ...input }; + + // Default values. + if (!resolvedAccounts.authority.value) { + resolvedAccounts.authority.value = context.identity; + } + if (!resolvedAccounts.systemProgram.value) { + resolvedAccounts.systemProgram.value = context.programs.getPublicKey( + 'splSystem', + '11111111111111111111111111111111' + ); + resolvedAccounts.systemProgram.isWritable = false; + } + if (!resolvedAccounts.tokenProgram.value) { + resolvedAccounts.tokenProgram.value = context.programs.getPublicKey( + 'splToken', + 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA' + ); + resolvedAccounts.tokenProgram.isWritable = false; + } + + // Accounts in order. + const orderedAccounts: ResolvedAccount[] = Object.values( + resolvedAccounts + ).sort((a, b) => a.index - b.index); + + // Keys and Signers. + const [keys, signers] = getAccountMetasAndSigners( + orderedAccounts, + 'programId', + programId + ); + + // Data. + const data = getMigrateTokensV1InstructionDataSerializer().serialize( + resolvedArgs as MigrateTokensV1InstructionDataArgs + ); + + // Bytes Created On Chain. + const bytesCreatedOnChain = 0; + + return transactionBuilder([ + { instruction: { keys, programId, data }, signers, bytesCreatedOnChain }, + ]); +} diff --git a/clients/js/src/generated/instructions/releaseV2.ts b/clients/js/src/generated/instructions/releaseV2.ts new file mode 100644 index 0000000..91be222 --- /dev/null +++ b/clients/js/src/generated/instructions/releaseV2.ts @@ -0,0 +1,216 @@ +/** + * This code was AUTOGENERATED using the kinobi library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun kinobi to update it. + * + * @see https://github.com/metaplex-foundation/kinobi + */ + +import { + Context, + Pda, + PublicKey, + Signer, + TransactionBuilder, + transactionBuilder, +} from '@metaplex-foundation/umi'; +import { + Serializer, + array, + mapSerializer, + struct, + u8, +} from '@metaplex-foundation/umi/serializers'; +import { + ResolvedAccount, + ResolvedAccountsWithIndices, + getAccountMetasAndSigners, +} from '../shared'; + +// Accounts. +export type ReleaseV2InstructionAccounts = { + owner: Signer; + authority?: Signer; + recipe: PublicKey | Pda; + escrow: PublicKey | Pda; + asset: PublicKey | Pda; + collection: PublicKey | Pda; + userTokenAccount: PublicKey | Pda; + escrowTokenAccount: PublicKey | Pda; + token: PublicKey | Pda; + feeTokenAccount: PublicKey | Pda; + feeSolAccount: PublicKey | Pda; + feeProjectAccount: PublicKey | Pda; + recentBlockhashes: PublicKey | Pda; + mplCore: PublicKey | Pda; + systemProgram?: PublicKey | Pda; + tokenProgram?: PublicKey | Pda; + associatedTokenProgram: PublicKey | Pda; +}; + +// Data. +export type ReleaseV2InstructionData = { discriminator: Array }; + +export type ReleaseV2InstructionDataArgs = {}; + +export function getReleaseV2InstructionDataSerializer(): Serializer< + ReleaseV2InstructionDataArgs, + ReleaseV2InstructionData +> { + return mapSerializer< + ReleaseV2InstructionDataArgs, + any, + ReleaseV2InstructionData + >( + struct( + [['discriminator', array(u8(), { size: 8 })]], + { description: 'ReleaseV2InstructionData' } + ), + (value) => ({ + ...value, + discriminator: [11, 29, 101, 146, 69, 134, 78, 61], + }) + ) as Serializer; +} + +// Instruction. +export function releaseV2( + context: Pick, + input: ReleaseV2InstructionAccounts +): TransactionBuilder { + // Program ID. + const programId = context.programs.getPublicKey( + 'mplHybrid', + 'MPL4o4wMzndgh8T1NVDxELQCj5UQfYTYEkabX3wNKtb' + ); + + // Accounts. + const resolvedAccounts = { + owner: { + index: 0, + isWritable: true as boolean, + value: input.owner ?? null, + }, + authority: { + index: 1, + isWritable: true as boolean, + value: input.authority ?? null, + }, + recipe: { + index: 2, + isWritable: true as boolean, + value: input.recipe ?? null, + }, + escrow: { + index: 3, + isWritable: true as boolean, + value: input.escrow ?? null, + }, + asset: { + index: 4, + isWritable: true as boolean, + value: input.asset ?? null, + }, + collection: { + index: 5, + isWritable: true as boolean, + value: input.collection ?? null, + }, + userTokenAccount: { + index: 6, + isWritable: true as boolean, + value: input.userTokenAccount ?? null, + }, + escrowTokenAccount: { + index: 7, + isWritable: true as boolean, + value: input.escrowTokenAccount ?? null, + }, + token: { + index: 8, + isWritable: false as boolean, + value: input.token ?? null, + }, + feeTokenAccount: { + index: 9, + isWritable: true as boolean, + value: input.feeTokenAccount ?? null, + }, + feeSolAccount: { + index: 10, + isWritable: true as boolean, + value: input.feeSolAccount ?? null, + }, + feeProjectAccount: { + index: 11, + isWritable: true as boolean, + value: input.feeProjectAccount ?? null, + }, + recentBlockhashes: { + index: 12, + isWritable: false as boolean, + value: input.recentBlockhashes ?? null, + }, + mplCore: { + index: 13, + isWritable: false as boolean, + value: input.mplCore ?? null, + }, + systemProgram: { + index: 14, + isWritable: false as boolean, + value: input.systemProgram ?? null, + }, + tokenProgram: { + index: 15, + isWritable: false as boolean, + value: input.tokenProgram ?? null, + }, + associatedTokenProgram: { + index: 16, + isWritable: false as boolean, + value: input.associatedTokenProgram ?? null, + }, + } satisfies ResolvedAccountsWithIndices; + + // Default values. + if (!resolvedAccounts.authority.value) { + resolvedAccounts.authority.value = context.identity; + } + if (!resolvedAccounts.systemProgram.value) { + resolvedAccounts.systemProgram.value = context.programs.getPublicKey( + 'splSystem', + '11111111111111111111111111111111' + ); + resolvedAccounts.systemProgram.isWritable = false; + } + if (!resolvedAccounts.tokenProgram.value) { + resolvedAccounts.tokenProgram.value = context.programs.getPublicKey( + 'splToken', + 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA' + ); + resolvedAccounts.tokenProgram.isWritable = false; + } + + // Accounts in order. + const orderedAccounts: ResolvedAccount[] = Object.values( + resolvedAccounts + ).sort((a, b) => a.index - b.index); + + // Keys and Signers. + const [keys, signers] = getAccountMetasAndSigners( + orderedAccounts, + 'programId', + programId + ); + + // Data. + const data = getReleaseV2InstructionDataSerializer().serialize({}); + + // Bytes Created On Chain. + const bytesCreatedOnChain = 0; + + return transactionBuilder([ + { instruction: { keys, programId, data }, signers, bytesCreatedOnChain }, + ]); +} diff --git a/clients/js/src/generated/instructions/updateRecipeV1.ts b/clients/js/src/generated/instructions/updateRecipeV1.ts new file mode 100644 index 0000000..a01896e --- /dev/null +++ b/clients/js/src/generated/instructions/updateRecipeV1.ts @@ -0,0 +1,195 @@ +/** + * This code was AUTOGENERATED using the kinobi library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun kinobi to update it. + * + * @see https://github.com/metaplex-foundation/kinobi + */ + +import { + Context, + Option, + OptionOrNullable, + Pda, + PublicKey, + Signer, + TransactionBuilder, + transactionBuilder, +} from '@metaplex-foundation/umi'; +import { + Serializer, + array, + mapSerializer, + option, + string, + struct, + u16, + u64, + u8, +} from '@metaplex-foundation/umi/serializers'; +import { + ResolvedAccount, + ResolvedAccountsWithIndices, + getAccountMetasAndSigners, +} from '../shared'; + +// Accounts. +export type UpdateRecipeV1InstructionAccounts = { + recipe: PublicKey | Pda; + authority?: Signer; + collection: PublicKey | Pda; + token: PublicKey | Pda; + feeLocation: PublicKey | Pda; + systemProgram?: PublicKey | Pda; +}; + +// Data. +export type UpdateRecipeV1InstructionData = { + discriminator: Array; + name: Option; + uri: Option; + max: Option; + min: Option; + amount: Option; + feeAmountCapture: Option; + feeAmountRelease: Option; + solFeeAmountCapture: Option; + solFeeAmountRelease: Option; + path: Option; +}; + +export type UpdateRecipeV1InstructionDataArgs = { + name: OptionOrNullable; + uri: OptionOrNullable; + max: OptionOrNullable; + min: OptionOrNullable; + amount: OptionOrNullable; + feeAmountCapture: OptionOrNullable; + feeAmountRelease: OptionOrNullable; + solFeeAmountCapture: OptionOrNullable; + solFeeAmountRelease: OptionOrNullable; + path: OptionOrNullable; +}; + +export function getUpdateRecipeV1InstructionDataSerializer(): Serializer< + UpdateRecipeV1InstructionDataArgs, + UpdateRecipeV1InstructionData +> { + return mapSerializer< + UpdateRecipeV1InstructionDataArgs, + any, + UpdateRecipeV1InstructionData + >( + struct( + [ + ['discriminator', array(u8(), { size: 8 })], + ['name', option(string())], + ['uri', option(string())], + ['max', option(u64())], + ['min', option(u64())], + ['amount', option(u64())], + ['feeAmountCapture', option(u64())], + ['feeAmountRelease', option(u64())], + ['solFeeAmountCapture', option(u64())], + ['solFeeAmountRelease', option(u64())], + ['path', option(u16())], + ], + { description: 'UpdateRecipeV1InstructionData' } + ), + (value) => ({ + ...value, + discriminator: [252, 71, 211, 219, 86, 136, 251, 238], + }) + ) as Serializer< + UpdateRecipeV1InstructionDataArgs, + UpdateRecipeV1InstructionData + >; +} + +// Args. +export type UpdateRecipeV1InstructionArgs = UpdateRecipeV1InstructionDataArgs; + +// Instruction. +export function updateRecipeV1( + context: Pick, + input: UpdateRecipeV1InstructionAccounts & UpdateRecipeV1InstructionArgs +): TransactionBuilder { + // Program ID. + const programId = context.programs.getPublicKey( + 'mplHybrid', + 'MPL4o4wMzndgh8T1NVDxELQCj5UQfYTYEkabX3wNKtb' + ); + + // Accounts. + const resolvedAccounts = { + recipe: { + index: 0, + isWritable: true as boolean, + value: input.recipe ?? null, + }, + authority: { + index: 1, + isWritable: true as boolean, + value: input.authority ?? null, + }, + collection: { + index: 2, + isWritable: true as boolean, + value: input.collection ?? null, + }, + token: { + index: 3, + isWritable: false as boolean, + value: input.token ?? null, + }, + feeLocation: { + index: 4, + isWritable: false as boolean, + value: input.feeLocation ?? null, + }, + systemProgram: { + index: 5, + isWritable: false as boolean, + value: input.systemProgram ?? null, + }, + } satisfies ResolvedAccountsWithIndices; + + // Arguments. + const resolvedArgs: UpdateRecipeV1InstructionArgs = { ...input }; + + // Default values. + if (!resolvedAccounts.authority.value) { + resolvedAccounts.authority.value = context.identity; + } + if (!resolvedAccounts.systemProgram.value) { + resolvedAccounts.systemProgram.value = context.programs.getPublicKey( + 'splSystem', + '11111111111111111111111111111111' + ); + resolvedAccounts.systemProgram.isWritable = false; + } + + // Accounts in order. + const orderedAccounts: ResolvedAccount[] = Object.values( + resolvedAccounts + ).sort((a, b) => a.index - b.index); + + // Keys and Signers. + const [keys, signers] = getAccountMetasAndSigners( + orderedAccounts, + 'programId', + programId + ); + + // Data. + const data = getUpdateRecipeV1InstructionDataSerializer().serialize( + resolvedArgs as UpdateRecipeV1InstructionDataArgs + ); + + // Bytes Created On Chain. + const bytesCreatedOnChain = 0; + + return transactionBuilder([ + { instruction: { keys, programId, data }, signers, bytesCreatedOnChain }, + ]); +} diff --git a/clients/rust/src/generated/accounts/escrow_v2.rs b/clients/rust/src/generated/accounts/escrow_v2.rs new file mode 100644 index 0000000..5d2a3fb --- /dev/null +++ b/clients/rust/src/generated/accounts/escrow_v2.rs @@ -0,0 +1,47 @@ +//! This code was AUTOGENERATED using the kinobi library. +//! Please DO NOT EDIT THIS FILE, instead use visitors +//! to add features, then rerun kinobi to update it. +//! +//! [https://github.com/metaplex-foundation/kinobi] +//! + +#[cfg(feature = "anchor")] +use anchor_lang::prelude::{AnchorDeserialize, AnchorSerialize}; +#[cfg(not(feature = "anchor"))] +use borsh::{BorshDeserialize, BorshSerialize}; +use solana_program::pubkey::Pubkey; + +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(not(feature = "anchor"), derive(BorshSerialize, BorshDeserialize))] +#[cfg_attr(feature = "anchor", derive(AnchorSerialize, AnchorDeserialize))] +#[derive(Clone, Debug, Eq, PartialEq)] +pub struct EscrowV2 { + pub discriminator: [u8; 8], + #[cfg_attr( + feature = "serde", + serde(with = "serde_with::As::") + )] + pub authority: Pubkey, + pub bump: u8, +} + +impl EscrowV2 { + pub const LEN: usize = 41; + + #[inline(always)] + pub fn from_bytes(data: &[u8]) -> Result { + let mut data = data; + Self::deserialize(&mut data) + } +} + +impl<'a> TryFrom<&solana_program::account_info::AccountInfo<'a>> for EscrowV2 { + type Error = std::io::Error; + + fn try_from( + account_info: &solana_program::account_info::AccountInfo<'a>, + ) -> Result { + let mut data: &[u8] = &(*account_info.data).borrow(); + Self::deserialize(&mut data) + } +} diff --git a/clients/rust/src/generated/accounts/mod.rs b/clients/rust/src/generated/accounts/mod.rs index e0ff2c6..b927fba 100644 --- a/clients/rust/src/generated/accounts/mod.rs +++ b/clients/rust/src/generated/accounts/mod.rs @@ -6,7 +6,11 @@ //! pub(crate) mod r#escrow_v1; +pub(crate) mod r#escrow_v2; pub(crate) mod r#nft_data_v1; +pub(crate) mod r#recipe_v1; pub use self::r#escrow_v1::*; +pub use self::r#escrow_v2::*; pub use self::r#nft_data_v1::*; +pub use self::r#recipe_v1::*; diff --git a/clients/rust/src/generated/accounts/recipe_v1.rs b/clients/rust/src/generated/accounts/recipe_v1.rs new file mode 100644 index 0000000..114abf4 --- /dev/null +++ b/clients/rust/src/generated/accounts/recipe_v1.rs @@ -0,0 +1,71 @@ +//! This code was AUTOGENERATED using the kinobi library. +//! Please DO NOT EDIT THIS FILE, instead use visitors +//! to add features, then rerun kinobi to update it. +//! +//! [https://github.com/metaplex-foundation/kinobi] +//! + +#[cfg(feature = "anchor")] +use anchor_lang::prelude::{AnchorDeserialize, AnchorSerialize}; +#[cfg(not(feature = "anchor"))] +use borsh::{BorshDeserialize, BorshSerialize}; +use solana_program::pubkey::Pubkey; + +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(not(feature = "anchor"), derive(BorshSerialize, BorshDeserialize))] +#[cfg_attr(feature = "anchor", derive(AnchorSerialize, AnchorDeserialize))] +#[derive(Clone, Debug, Eq, PartialEq)] +pub struct RecipeV1 { + pub discriminator: [u8; 8], + #[cfg_attr( + feature = "serde", + serde(with = "serde_with::As::") + )] + pub collection: Pubkey, + #[cfg_attr( + feature = "serde", + serde(with = "serde_with::As::") + )] + pub authority: Pubkey, + #[cfg_attr( + feature = "serde", + serde(with = "serde_with::As::") + )] + pub token: Pubkey, + #[cfg_attr( + feature = "serde", + serde(with = "serde_with::As::") + )] + pub fee_location: Pubkey, + pub name: String, + pub uri: String, + pub max: u64, + pub min: u64, + pub amount: u64, + pub fee_amount_capture: u64, + pub sol_fee_amount_capture: u64, + pub fee_amount_release: u64, + pub sol_fee_amount_release: u64, + pub count: u64, + pub path: u16, + pub bump: u8, +} + +impl RecipeV1 { + #[inline(always)] + pub fn from_bytes(data: &[u8]) -> Result { + let mut data = data; + Self::deserialize(&mut data) + } +} + +impl<'a> TryFrom<&solana_program::account_info::AccountInfo<'a>> for RecipeV1 { + type Error = std::io::Error; + + fn try_from( + account_info: &solana_program::account_info::AccountInfo<'a>, + ) -> Result { + let mut data: &[u8] = &(*account_info.data).borrow(); + Self::deserialize(&mut data) + } +} diff --git a/clients/rust/src/generated/errors/mpl_hybrid.rs b/clients/rust/src/generated/errors/mpl_hybrid.rs index 9834ad8..8e85fae 100644 --- a/clients/rust/src/generated/errors/mpl_hybrid.rs +++ b/clients/rust/src/generated/errors/mpl_hybrid.rs @@ -58,6 +58,9 @@ pub enum MplHybridError { /// 6015 (0x177F) - Invalid Token Account Mint #[error("Invalid Token Account Mint")] InvalidTokenAccountMint, + /// 6016 (0x1780) - Invalid Authorities + #[error("Invalid Authorities")] + InvalidAuthority, } impl solana_program::program_error::PrintProgramError for MplHybridError { diff --git a/clients/rust/src/generated/instructions/capture_v2.rs b/clients/rust/src/generated/instructions/capture_v2.rs new file mode 100644 index 0000000..b3ad7ea --- /dev/null +++ b/clients/rust/src/generated/instructions/capture_v2.rs @@ -0,0 +1,929 @@ +//! This code was AUTOGENERATED using the kinobi library. +//! Please DO NOT EDIT THIS FILE, instead use visitors +//! to add features, then rerun kinobi to update it. +//! +//! [https://github.com/metaplex-foundation/kinobi] +//! + +#[cfg(feature = "anchor")] +use anchor_lang::prelude::{AnchorDeserialize, AnchorSerialize}; +#[cfg(not(feature = "anchor"))] +use borsh::{BorshDeserialize, BorshSerialize}; + +/// Accounts. +pub struct CaptureV2 { + pub owner: solana_program::pubkey::Pubkey, + + pub authority: solana_program::pubkey::Pubkey, + + pub recipe: solana_program::pubkey::Pubkey, + + pub escrow: solana_program::pubkey::Pubkey, + + pub asset: solana_program::pubkey::Pubkey, + + pub collection: solana_program::pubkey::Pubkey, + + pub user_token_account: solana_program::pubkey::Pubkey, + + pub escrow_token_account: solana_program::pubkey::Pubkey, + + pub token: solana_program::pubkey::Pubkey, + + pub fee_token_account: solana_program::pubkey::Pubkey, + + pub fee_sol_account: solana_program::pubkey::Pubkey, + + pub fee_project_account: solana_program::pubkey::Pubkey, + + pub recent_blockhashes: solana_program::pubkey::Pubkey, + + pub mpl_core: solana_program::pubkey::Pubkey, + + pub system_program: solana_program::pubkey::Pubkey, + + pub token_program: solana_program::pubkey::Pubkey, + + pub associated_token_program: solana_program::pubkey::Pubkey, +} + +impl CaptureV2 { + pub fn instruction(&self) -> solana_program::instruction::Instruction { + self.instruction_with_remaining_accounts(&[]) + } + #[allow(clippy::vec_init_then_push)] + pub fn instruction_with_remaining_accounts( + &self, + remaining_accounts: &[solana_program::instruction::AccountMeta], + ) -> solana_program::instruction::Instruction { + let mut accounts = Vec::with_capacity(17 + remaining_accounts.len()); + accounts.push(solana_program::instruction::AccountMeta::new( + self.owner, true, + )); + accounts.push(solana_program::instruction::AccountMeta::new( + self.authority, + true, + )); + accounts.push(solana_program::instruction::AccountMeta::new( + self.recipe, + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new( + self.escrow, + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new( + self.asset, false, + )); + accounts.push(solana_program::instruction::AccountMeta::new( + self.collection, + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new( + self.user_token_account, + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new( + self.escrow_token_account, + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( + self.token, false, + )); + accounts.push(solana_program::instruction::AccountMeta::new( + self.fee_token_account, + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new( + self.fee_sol_account, + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new( + self.fee_project_account, + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( + self.recent_blockhashes, + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( + self.mpl_core, + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( + self.system_program, + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( + self.token_program, + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( + self.associated_token_program, + false, + )); + accounts.extend_from_slice(remaining_accounts); + let data = CaptureV2InstructionData::new().try_to_vec().unwrap(); + + solana_program::instruction::Instruction { + program_id: crate::MPL_HYBRID_ID, + accounts, + data, + } + } +} + +#[cfg_attr(not(feature = "anchor"), derive(BorshSerialize, BorshDeserialize))] +#[cfg_attr(feature = "anchor", derive(AnchorSerialize, AnchorDeserialize))] +pub struct CaptureV2InstructionData { + discriminator: [u8; 8], +} + +impl CaptureV2InstructionData { + pub fn new() -> Self { + Self { + discriminator: [51, 185, 212, 68, 232, 11, 101, 30], + } + } +} + +/// Instruction builder for `CaptureV2`. +/// +/// ### Accounts: +/// +/// 0. `[writable, signer]` owner +/// 1. `[writable, signer]` authority +/// 2. `[writable]` recipe +/// 3. `[writable]` escrow +/// 4. `[writable]` asset +/// 5. `[writable]` collection +/// 6. `[writable]` user_token_account +/// 7. `[writable]` escrow_token_account +/// 8. `[]` token +/// 9. `[writable]` fee_token_account +/// 10. `[writable]` fee_sol_account +/// 11. `[writable]` fee_project_account +/// 12. `[]` recent_blockhashes +/// 13. `[]` mpl_core +/// 14. `[optional]` system_program (default to `11111111111111111111111111111111`) +/// 15. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) +/// 16. `[]` associated_token_program +#[derive(Default)] +pub struct CaptureV2Builder { + owner: Option, + authority: Option, + recipe: Option, + escrow: Option, + asset: Option, + collection: Option, + user_token_account: Option, + escrow_token_account: Option, + token: Option, + fee_token_account: Option, + fee_sol_account: Option, + fee_project_account: Option, + recent_blockhashes: Option, + mpl_core: Option, + system_program: Option, + token_program: Option, + associated_token_program: Option, + __remaining_accounts: Vec, +} + +impl CaptureV2Builder { + pub fn new() -> Self { + Self::default() + } + #[inline(always)] + pub fn owner(&mut self, owner: solana_program::pubkey::Pubkey) -> &mut Self { + self.owner = Some(owner); + self + } + #[inline(always)] + pub fn authority(&mut self, authority: solana_program::pubkey::Pubkey) -> &mut Self { + self.authority = Some(authority); + self + } + #[inline(always)] + pub fn recipe(&mut self, recipe: solana_program::pubkey::Pubkey) -> &mut Self { + self.recipe = Some(recipe); + self + } + #[inline(always)] + pub fn escrow(&mut self, escrow: solana_program::pubkey::Pubkey) -> &mut Self { + self.escrow = Some(escrow); + self + } + #[inline(always)] + pub fn asset(&mut self, asset: solana_program::pubkey::Pubkey) -> &mut Self { + self.asset = Some(asset); + self + } + #[inline(always)] + pub fn collection(&mut self, collection: solana_program::pubkey::Pubkey) -> &mut Self { + self.collection = Some(collection); + self + } + #[inline(always)] + pub fn user_token_account( + &mut self, + user_token_account: solana_program::pubkey::Pubkey, + ) -> &mut Self { + self.user_token_account = Some(user_token_account); + self + } + #[inline(always)] + pub fn escrow_token_account( + &mut self, + escrow_token_account: solana_program::pubkey::Pubkey, + ) -> &mut Self { + self.escrow_token_account = Some(escrow_token_account); + self + } + #[inline(always)] + pub fn token(&mut self, token: solana_program::pubkey::Pubkey) -> &mut Self { + self.token = Some(token); + self + } + #[inline(always)] + pub fn fee_token_account( + &mut self, + fee_token_account: solana_program::pubkey::Pubkey, + ) -> &mut Self { + self.fee_token_account = Some(fee_token_account); + self + } + #[inline(always)] + pub fn fee_sol_account( + &mut self, + fee_sol_account: solana_program::pubkey::Pubkey, + ) -> &mut Self { + self.fee_sol_account = Some(fee_sol_account); + self + } + #[inline(always)] + pub fn fee_project_account( + &mut self, + fee_project_account: solana_program::pubkey::Pubkey, + ) -> &mut Self { + self.fee_project_account = Some(fee_project_account); + self + } + #[inline(always)] + pub fn recent_blockhashes( + &mut self, + recent_blockhashes: solana_program::pubkey::Pubkey, + ) -> &mut Self { + self.recent_blockhashes = Some(recent_blockhashes); + self + } + #[inline(always)] + pub fn mpl_core(&mut self, mpl_core: solana_program::pubkey::Pubkey) -> &mut Self { + self.mpl_core = Some(mpl_core); + self + } + /// `[optional account, default to '11111111111111111111111111111111']` + #[inline(always)] + pub fn system_program(&mut self, system_program: solana_program::pubkey::Pubkey) -> &mut Self { + self.system_program = Some(system_program); + self + } + /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` + #[inline(always)] + pub fn token_program(&mut self, token_program: solana_program::pubkey::Pubkey) -> &mut Self { + self.token_program = Some(token_program); + self + } + #[inline(always)] + pub fn associated_token_program( + &mut self, + associated_token_program: solana_program::pubkey::Pubkey, + ) -> &mut Self { + self.associated_token_program = Some(associated_token_program); + self + } + /// Add an aditional account to the instruction. + #[inline(always)] + pub fn add_remaining_account( + &mut self, + account: solana_program::instruction::AccountMeta, + ) -> &mut Self { + self.__remaining_accounts.push(account); + self + } + /// Add additional accounts to the instruction. + #[inline(always)] + pub fn add_remaining_accounts( + &mut self, + accounts: &[solana_program::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 { + let accounts = CaptureV2 { + owner: self.owner.expect("owner is not set"), + authority: self.authority.expect("authority is not set"), + recipe: self.recipe.expect("recipe is not set"), + escrow: self.escrow.expect("escrow is not set"), + asset: self.asset.expect("asset is not set"), + collection: self.collection.expect("collection is not set"), + user_token_account: self + .user_token_account + .expect("user_token_account is not set"), + escrow_token_account: self + .escrow_token_account + .expect("escrow_token_account is not set"), + token: self.token.expect("token is not set"), + fee_token_account: self + .fee_token_account + .expect("fee_token_account is not set"), + fee_sol_account: self.fee_sol_account.expect("fee_sol_account is not set"), + fee_project_account: self + .fee_project_account + .expect("fee_project_account is not set"), + recent_blockhashes: self + .recent_blockhashes + .expect("recent_blockhashes is not set"), + mpl_core: self.mpl_core.expect("mpl_core is not set"), + system_program: self + .system_program + .unwrap_or(solana_program::pubkey!("11111111111111111111111111111111")), + token_program: self.token_program.unwrap_or(solana_program::pubkey!( + "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + )), + associated_token_program: self + .associated_token_program + .expect("associated_token_program is not set"), + }; + + accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) + } +} + +/// `capture_v2` CPI accounts. +pub struct CaptureV2CpiAccounts<'a, 'b> { + pub owner: &'b solana_program::account_info::AccountInfo<'a>, + + pub authority: &'b solana_program::account_info::AccountInfo<'a>, + + pub recipe: &'b solana_program::account_info::AccountInfo<'a>, + + pub escrow: &'b solana_program::account_info::AccountInfo<'a>, + + pub asset: &'b solana_program::account_info::AccountInfo<'a>, + + pub collection: &'b solana_program::account_info::AccountInfo<'a>, + + pub user_token_account: &'b solana_program::account_info::AccountInfo<'a>, + + pub escrow_token_account: &'b solana_program::account_info::AccountInfo<'a>, + + pub token: &'b solana_program::account_info::AccountInfo<'a>, + + pub fee_token_account: &'b solana_program::account_info::AccountInfo<'a>, + + pub fee_sol_account: &'b solana_program::account_info::AccountInfo<'a>, + + pub fee_project_account: &'b solana_program::account_info::AccountInfo<'a>, + + pub recent_blockhashes: &'b solana_program::account_info::AccountInfo<'a>, + + pub mpl_core: &'b solana_program::account_info::AccountInfo<'a>, + + pub system_program: &'b solana_program::account_info::AccountInfo<'a>, + + pub token_program: &'b solana_program::account_info::AccountInfo<'a>, + + pub associated_token_program: &'b solana_program::account_info::AccountInfo<'a>, +} + +/// `capture_v2` CPI instruction. +pub struct CaptureV2Cpi<'a, 'b> { + /// The program to invoke. + pub __program: &'b solana_program::account_info::AccountInfo<'a>, + + pub owner: &'b solana_program::account_info::AccountInfo<'a>, + + pub authority: &'b solana_program::account_info::AccountInfo<'a>, + + pub recipe: &'b solana_program::account_info::AccountInfo<'a>, + + pub escrow: &'b solana_program::account_info::AccountInfo<'a>, + + pub asset: &'b solana_program::account_info::AccountInfo<'a>, + + pub collection: &'b solana_program::account_info::AccountInfo<'a>, + + pub user_token_account: &'b solana_program::account_info::AccountInfo<'a>, + + pub escrow_token_account: &'b solana_program::account_info::AccountInfo<'a>, + + pub token: &'b solana_program::account_info::AccountInfo<'a>, + + pub fee_token_account: &'b solana_program::account_info::AccountInfo<'a>, + + pub fee_sol_account: &'b solana_program::account_info::AccountInfo<'a>, + + pub fee_project_account: &'b solana_program::account_info::AccountInfo<'a>, + + pub recent_blockhashes: &'b solana_program::account_info::AccountInfo<'a>, + + pub mpl_core: &'b solana_program::account_info::AccountInfo<'a>, + + pub system_program: &'b solana_program::account_info::AccountInfo<'a>, + + pub token_program: &'b solana_program::account_info::AccountInfo<'a>, + + pub associated_token_program: &'b solana_program::account_info::AccountInfo<'a>, +} + +impl<'a, 'b> CaptureV2Cpi<'a, 'b> { + pub fn new( + program: &'b solana_program::account_info::AccountInfo<'a>, + accounts: CaptureV2CpiAccounts<'a, 'b>, + ) -> Self { + Self { + __program: program, + owner: accounts.owner, + authority: accounts.authority, + recipe: accounts.recipe, + escrow: accounts.escrow, + asset: accounts.asset, + collection: accounts.collection, + user_token_account: accounts.user_token_account, + escrow_token_account: accounts.escrow_token_account, + token: accounts.token, + fee_token_account: accounts.fee_token_account, + fee_sol_account: accounts.fee_sol_account, + fee_project_account: accounts.fee_project_account, + recent_blockhashes: accounts.recent_blockhashes, + mpl_core: accounts.mpl_core, + system_program: accounts.system_program, + token_program: accounts.token_program, + associated_token_program: accounts.associated_token_program, + } + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::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 { + self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) + } + #[inline(always)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) + } + #[allow(clippy::clone_on_copy)] + #[allow(clippy::vec_init_then_push)] + 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 { + let mut accounts = Vec::with_capacity(17 + remaining_accounts.len()); + accounts.push(solana_program::instruction::AccountMeta::new( + *self.owner.key, + true, + )); + accounts.push(solana_program::instruction::AccountMeta::new( + *self.authority.key, + true, + )); + accounts.push(solana_program::instruction::AccountMeta::new( + *self.recipe.key, + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new( + *self.escrow.key, + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new( + *self.asset.key, + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new( + *self.collection.key, + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new( + *self.user_token_account.key, + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new( + *self.escrow_token_account.key, + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( + *self.token.key, + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new( + *self.fee_token_account.key, + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new( + *self.fee_sol_account.key, + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new( + *self.fee_project_account.key, + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( + *self.recent_blockhashes.key, + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( + *self.mpl_core.key, + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( + *self.system_program.key, + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( + *self.token_program.key, + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( + *self.associated_token_program.key, + false, + )); + remaining_accounts.iter().for_each(|remaining_account| { + accounts.push(solana_program::instruction::AccountMeta { + pubkey: *remaining_account.0.key, + is_signer: remaining_account.1, + is_writable: remaining_account.2, + }) + }); + let data = CaptureV2InstructionData::new().try_to_vec().unwrap(); + + let instruction = solana_program::instruction::Instruction { + program_id: crate::MPL_HYBRID_ID, + accounts, + data, + }; + let mut account_infos = Vec::with_capacity(17 + 1 + remaining_accounts.len()); + account_infos.push(self.__program.clone()); + account_infos.push(self.owner.clone()); + account_infos.push(self.authority.clone()); + account_infos.push(self.recipe.clone()); + account_infos.push(self.escrow.clone()); + account_infos.push(self.asset.clone()); + account_infos.push(self.collection.clone()); + account_infos.push(self.user_token_account.clone()); + account_infos.push(self.escrow_token_account.clone()); + account_infos.push(self.token.clone()); + account_infos.push(self.fee_token_account.clone()); + account_infos.push(self.fee_sol_account.clone()); + account_infos.push(self.fee_project_account.clone()); + account_infos.push(self.recent_blockhashes.clone()); + account_infos.push(self.mpl_core.clone()); + account_infos.push(self.system_program.clone()); + account_infos.push(self.token_program.clone()); + account_infos.push(self.associated_token_program.clone()); + remaining_accounts + .iter() + .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); + + if signers_seeds.is_empty() { + solana_program::program::invoke(&instruction, &account_infos) + } else { + solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds) + } + } +} + +/// Instruction builder for `CaptureV2` via CPI. +/// +/// ### Accounts: +/// +/// 0. `[writable, signer]` owner +/// 1. `[writable, signer]` authority +/// 2. `[writable]` recipe +/// 3. `[writable]` escrow +/// 4. `[writable]` asset +/// 5. `[writable]` collection +/// 6. `[writable]` user_token_account +/// 7. `[writable]` escrow_token_account +/// 8. `[]` token +/// 9. `[writable]` fee_token_account +/// 10. `[writable]` fee_sol_account +/// 11. `[writable]` fee_project_account +/// 12. `[]` recent_blockhashes +/// 13. `[]` mpl_core +/// 14. `[]` system_program +/// 15. `[]` token_program +/// 16. `[]` associated_token_program +pub struct CaptureV2CpiBuilder<'a, 'b> { + instruction: Box>, +} + +impl<'a, 'b> CaptureV2CpiBuilder<'a, 'b> { + pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { + let instruction = Box::new(CaptureV2CpiBuilderInstruction { + __program: program, + owner: None, + authority: None, + recipe: None, + escrow: None, + asset: None, + collection: None, + user_token_account: None, + escrow_token_account: None, + token: None, + fee_token_account: None, + fee_sol_account: None, + fee_project_account: None, + recent_blockhashes: None, + mpl_core: None, + system_program: None, + token_program: None, + associated_token_program: None, + __remaining_accounts: Vec::new(), + }); + Self { instruction } + } + #[inline(always)] + pub fn owner(&mut self, owner: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { + self.instruction.owner = Some(owner); + self + } + #[inline(always)] + pub fn authority( + &mut self, + authority: &'b solana_program::account_info::AccountInfo<'a>, + ) -> &mut Self { + self.instruction.authority = Some(authority); + self + } + #[inline(always)] + pub fn recipe( + &mut self, + recipe: &'b solana_program::account_info::AccountInfo<'a>, + ) -> &mut Self { + self.instruction.recipe = Some(recipe); + self + } + #[inline(always)] + pub fn escrow( + &mut self, + escrow: &'b solana_program::account_info::AccountInfo<'a>, + ) -> &mut Self { + self.instruction.escrow = Some(escrow); + self + } + #[inline(always)] + pub fn asset(&mut self, asset: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { + self.instruction.asset = Some(asset); + self + } + #[inline(always)] + pub fn collection( + &mut self, + collection: &'b solana_program::account_info::AccountInfo<'a>, + ) -> &mut Self { + self.instruction.collection = Some(collection); + self + } + #[inline(always)] + pub fn user_token_account( + &mut self, + user_token_account: &'b solana_program::account_info::AccountInfo<'a>, + ) -> &mut Self { + self.instruction.user_token_account = Some(user_token_account); + self + } + #[inline(always)] + pub fn escrow_token_account( + &mut self, + escrow_token_account: &'b solana_program::account_info::AccountInfo<'a>, + ) -> &mut Self { + self.instruction.escrow_token_account = Some(escrow_token_account); + self + } + #[inline(always)] + pub fn token(&mut self, token: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { + self.instruction.token = Some(token); + self + } + #[inline(always)] + pub fn fee_token_account( + &mut self, + fee_token_account: &'b solana_program::account_info::AccountInfo<'a>, + ) -> &mut Self { + self.instruction.fee_token_account = Some(fee_token_account); + self + } + #[inline(always)] + pub fn fee_sol_account( + &mut self, + fee_sol_account: &'b solana_program::account_info::AccountInfo<'a>, + ) -> &mut Self { + self.instruction.fee_sol_account = Some(fee_sol_account); + self + } + #[inline(always)] + pub fn fee_project_account( + &mut self, + fee_project_account: &'b solana_program::account_info::AccountInfo<'a>, + ) -> &mut Self { + self.instruction.fee_project_account = Some(fee_project_account); + self + } + #[inline(always)] + pub fn recent_blockhashes( + &mut self, + recent_blockhashes: &'b solana_program::account_info::AccountInfo<'a>, + ) -> &mut Self { + self.instruction.recent_blockhashes = Some(recent_blockhashes); + self + } + #[inline(always)] + pub fn mpl_core( + &mut self, + mpl_core: &'b solana_program::account_info::AccountInfo<'a>, + ) -> &mut Self { + self.instruction.mpl_core = Some(mpl_core); + self + } + #[inline(always)] + pub fn system_program( + &mut self, + system_program: &'b solana_program::account_info::AccountInfo<'a>, + ) -> &mut Self { + self.instruction.system_program = Some(system_program); + self + } + #[inline(always)] + pub fn token_program( + &mut self, + token_program: &'b solana_program::account_info::AccountInfo<'a>, + ) -> &mut Self { + self.instruction.token_program = Some(token_program); + self + } + #[inline(always)] + pub fn associated_token_program( + &mut self, + associated_token_program: &'b solana_program::account_info::AccountInfo<'a>, + ) -> &mut Self { + self.instruction.associated_token_program = Some(associated_token_program); + self + } + /// Add an additional account to the instruction. + #[inline(always)] + pub fn add_remaining_account( + &mut self, + account: &'b solana_program::account_info::AccountInfo<'a>, + is_writable: bool, + is_signer: bool, + ) -> &mut Self { + self.instruction + .__remaining_accounts + .push((account, is_writable, is_signer)); + self + } + /// Add additional accounts to the instruction. + /// + /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, + /// and a `bool` indicating whether the account is a signer or not. + #[inline(always)] + pub fn add_remaining_accounts( + &mut self, + accounts: &[( + &'b solana_program::account_info::AccountInfo<'a>, + bool, + bool, + )], + ) -> &mut Self { + self.instruction + .__remaining_accounts + .extend_from_slice(accounts); + self + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::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 { + let instruction = CaptureV2Cpi { + __program: self.instruction.__program, + + owner: self.instruction.owner.expect("owner is not set"), + + authority: self.instruction.authority.expect("authority is not set"), + + recipe: self.instruction.recipe.expect("recipe is not set"), + + escrow: self.instruction.escrow.expect("escrow is not set"), + + asset: self.instruction.asset.expect("asset is not set"), + + collection: self.instruction.collection.expect("collection is not set"), + + user_token_account: self + .instruction + .user_token_account + .expect("user_token_account is not set"), + + escrow_token_account: self + .instruction + .escrow_token_account + .expect("escrow_token_account is not set"), + + token: self.instruction.token.expect("token is not set"), + + fee_token_account: self + .instruction + .fee_token_account + .expect("fee_token_account is not set"), + + fee_sol_account: self + .instruction + .fee_sol_account + .expect("fee_sol_account is not set"), + + fee_project_account: self + .instruction + .fee_project_account + .expect("fee_project_account is not set"), + + recent_blockhashes: self + .instruction + .recent_blockhashes + .expect("recent_blockhashes is not set"), + + mpl_core: self.instruction.mpl_core.expect("mpl_core is not set"), + + system_program: self + .instruction + .system_program + .expect("system_program is not set"), + + token_program: self + .instruction + .token_program + .expect("token_program is not set"), + + associated_token_program: self + .instruction + .associated_token_program + .expect("associated_token_program is not set"), + }; + instruction.invoke_signed_with_remaining_accounts( + signers_seeds, + &self.instruction.__remaining_accounts, + ) + } +} + +struct CaptureV2CpiBuilderInstruction<'a, 'b> { + __program: &'b solana_program::account_info::AccountInfo<'a>, + owner: Option<&'b solana_program::account_info::AccountInfo<'a>>, + authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, + recipe: Option<&'b solana_program::account_info::AccountInfo<'a>>, + escrow: Option<&'b solana_program::account_info::AccountInfo<'a>>, + asset: Option<&'b solana_program::account_info::AccountInfo<'a>>, + collection: Option<&'b solana_program::account_info::AccountInfo<'a>>, + user_token_account: Option<&'b solana_program::account_info::AccountInfo<'a>>, + escrow_token_account: Option<&'b solana_program::account_info::AccountInfo<'a>>, + token: Option<&'b solana_program::account_info::AccountInfo<'a>>, + fee_token_account: Option<&'b solana_program::account_info::AccountInfo<'a>>, + fee_sol_account: Option<&'b solana_program::account_info::AccountInfo<'a>>, + fee_project_account: Option<&'b solana_program::account_info::AccountInfo<'a>>, + recent_blockhashes: Option<&'b solana_program::account_info::AccountInfo<'a>>, + mpl_core: Option<&'b solana_program::account_info::AccountInfo<'a>>, + system_program: Option<&'b solana_program::account_info::AccountInfo<'a>>, + token_program: Option<&'b solana_program::account_info::AccountInfo<'a>>, + associated_token_program: Option<&'b solana_program::account_info::AccountInfo<'a>>, + /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. + __remaining_accounts: Vec<( + &'b solana_program::account_info::AccountInfo<'a>, + bool, + bool, + )>, +} diff --git a/clients/rust/src/generated/instructions/init_escrow_v2.rs b/clients/rust/src/generated/instructions/init_escrow_v2.rs new file mode 100644 index 0000000..e4c58e5 --- /dev/null +++ b/clients/rust/src/generated/instructions/init_escrow_v2.rs @@ -0,0 +1,363 @@ +//! This code was AUTOGENERATED using the kinobi library. +//! Please DO NOT EDIT THIS FILE, instead use visitors +//! to add features, then rerun kinobi to update it. +//! +//! [https://github.com/metaplex-foundation/kinobi] +//! + +#[cfg(feature = "anchor")] +use anchor_lang::prelude::{AnchorDeserialize, AnchorSerialize}; +#[cfg(not(feature = "anchor"))] +use borsh::{BorshDeserialize, BorshSerialize}; + +/// Accounts. +pub struct InitEscrowV2 { + pub escrow: solana_program::pubkey::Pubkey, + + pub authority: solana_program::pubkey::Pubkey, + + pub system_program: solana_program::pubkey::Pubkey, +} + +impl InitEscrowV2 { + pub fn instruction(&self) -> solana_program::instruction::Instruction { + self.instruction_with_remaining_accounts(&[]) + } + #[allow(clippy::vec_init_then_push)] + pub fn instruction_with_remaining_accounts( + &self, + remaining_accounts: &[solana_program::instruction::AccountMeta], + ) -> solana_program::instruction::Instruction { + let mut accounts = Vec::with_capacity(3 + remaining_accounts.len()); + accounts.push(solana_program::instruction::AccountMeta::new( + self.escrow, + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new( + self.authority, + true, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( + self.system_program, + false, + )); + accounts.extend_from_slice(remaining_accounts); + let data = InitEscrowV2InstructionData::new().try_to_vec().unwrap(); + + solana_program::instruction::Instruction { + program_id: crate::MPL_HYBRID_ID, + accounts, + data, + } + } +} + +#[cfg_attr(not(feature = "anchor"), derive(BorshSerialize, BorshDeserialize))] +#[cfg_attr(feature = "anchor", derive(AnchorSerialize, AnchorDeserialize))] +pub struct InitEscrowV2InstructionData { + discriminator: [u8; 8], +} + +impl InitEscrowV2InstructionData { + pub fn new() -> Self { + Self { + discriminator: [131, 108, 25, 241, 183, 34, 121, 27], + } + } +} + +/// Instruction builder for `InitEscrowV2`. +/// +/// ### Accounts: +/// +/// 0. `[writable]` escrow +/// 1. `[writable, signer]` authority +/// 2. `[optional]` system_program (default to `11111111111111111111111111111111`) +#[derive(Default)] +pub struct InitEscrowV2Builder { + escrow: Option, + authority: Option, + system_program: Option, + __remaining_accounts: Vec, +} + +impl InitEscrowV2Builder { + pub fn new() -> Self { + Self::default() + } + #[inline(always)] + pub fn escrow(&mut self, escrow: solana_program::pubkey::Pubkey) -> &mut Self { + self.escrow = Some(escrow); + self + } + #[inline(always)] + pub fn authority(&mut self, authority: solana_program::pubkey::Pubkey) -> &mut Self { + self.authority = Some(authority); + self + } + /// `[optional account, default to '11111111111111111111111111111111']` + #[inline(always)] + pub fn system_program(&mut self, system_program: solana_program::pubkey::Pubkey) -> &mut Self { + self.system_program = Some(system_program); + self + } + /// Add an aditional account to the instruction. + #[inline(always)] + pub fn add_remaining_account( + &mut self, + account: solana_program::instruction::AccountMeta, + ) -> &mut Self { + self.__remaining_accounts.push(account); + self + } + /// Add additional accounts to the instruction. + #[inline(always)] + pub fn add_remaining_accounts( + &mut self, + accounts: &[solana_program::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 { + let accounts = InitEscrowV2 { + escrow: self.escrow.expect("escrow is not set"), + authority: self.authority.expect("authority is not set"), + system_program: self + .system_program + .unwrap_or(solana_program::pubkey!("11111111111111111111111111111111")), + }; + + accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) + } +} + +/// `init_escrow_v2` CPI accounts. +pub struct InitEscrowV2CpiAccounts<'a, 'b> { + pub escrow: &'b solana_program::account_info::AccountInfo<'a>, + + pub authority: &'b solana_program::account_info::AccountInfo<'a>, + + pub system_program: &'b solana_program::account_info::AccountInfo<'a>, +} + +/// `init_escrow_v2` CPI instruction. +pub struct InitEscrowV2Cpi<'a, 'b> { + /// The program to invoke. + pub __program: &'b solana_program::account_info::AccountInfo<'a>, + + pub escrow: &'b solana_program::account_info::AccountInfo<'a>, + + pub authority: &'b solana_program::account_info::AccountInfo<'a>, + + pub system_program: &'b solana_program::account_info::AccountInfo<'a>, +} + +impl<'a, 'b> InitEscrowV2Cpi<'a, 'b> { + pub fn new( + program: &'b solana_program::account_info::AccountInfo<'a>, + accounts: InitEscrowV2CpiAccounts<'a, 'b>, + ) -> Self { + Self { + __program: program, + escrow: accounts.escrow, + authority: accounts.authority, + system_program: accounts.system_program, + } + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::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 { + self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) + } + #[inline(always)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) + } + #[allow(clippy::clone_on_copy)] + #[allow(clippy::vec_init_then_push)] + 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 { + let mut accounts = Vec::with_capacity(3 + remaining_accounts.len()); + accounts.push(solana_program::instruction::AccountMeta::new( + *self.escrow.key, + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new( + *self.authority.key, + true, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( + *self.system_program.key, + false, + )); + remaining_accounts.iter().for_each(|remaining_account| { + accounts.push(solana_program::instruction::AccountMeta { + pubkey: *remaining_account.0.key, + is_signer: remaining_account.1, + is_writable: remaining_account.2, + }) + }); + let data = InitEscrowV2InstructionData::new().try_to_vec().unwrap(); + + let instruction = solana_program::instruction::Instruction { + program_id: crate::MPL_HYBRID_ID, + accounts, + data, + }; + let mut account_infos = Vec::with_capacity(3 + 1 + remaining_accounts.len()); + account_infos.push(self.__program.clone()); + account_infos.push(self.escrow.clone()); + account_infos.push(self.authority.clone()); + account_infos.push(self.system_program.clone()); + remaining_accounts + .iter() + .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); + + if signers_seeds.is_empty() { + solana_program::program::invoke(&instruction, &account_infos) + } else { + solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds) + } + } +} + +/// Instruction builder for `InitEscrowV2` via CPI. +/// +/// ### Accounts: +/// +/// 0. `[writable]` escrow +/// 1. `[writable, signer]` authority +/// 2. `[]` system_program +pub struct InitEscrowV2CpiBuilder<'a, 'b> { + instruction: Box>, +} + +impl<'a, 'b> InitEscrowV2CpiBuilder<'a, 'b> { + pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { + let instruction = Box::new(InitEscrowV2CpiBuilderInstruction { + __program: program, + escrow: None, + authority: None, + system_program: None, + __remaining_accounts: Vec::new(), + }); + Self { instruction } + } + #[inline(always)] + pub fn escrow( + &mut self, + escrow: &'b solana_program::account_info::AccountInfo<'a>, + ) -> &mut Self { + self.instruction.escrow = Some(escrow); + self + } + #[inline(always)] + pub fn authority( + &mut self, + authority: &'b solana_program::account_info::AccountInfo<'a>, + ) -> &mut Self { + self.instruction.authority = Some(authority); + self + } + #[inline(always)] + pub fn system_program( + &mut self, + system_program: &'b solana_program::account_info::AccountInfo<'a>, + ) -> &mut Self { + self.instruction.system_program = Some(system_program); + self + } + /// Add an additional account to the instruction. + #[inline(always)] + pub fn add_remaining_account( + &mut self, + account: &'b solana_program::account_info::AccountInfo<'a>, + is_writable: bool, + is_signer: bool, + ) -> &mut Self { + self.instruction + .__remaining_accounts + .push((account, is_writable, is_signer)); + self + } + /// Add additional accounts to the instruction. + /// + /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, + /// and a `bool` indicating whether the account is a signer or not. + #[inline(always)] + pub fn add_remaining_accounts( + &mut self, + accounts: &[( + &'b solana_program::account_info::AccountInfo<'a>, + bool, + bool, + )], + ) -> &mut Self { + self.instruction + .__remaining_accounts + .extend_from_slice(accounts); + self + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::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 { + let instruction = InitEscrowV2Cpi { + __program: self.instruction.__program, + + escrow: self.instruction.escrow.expect("escrow is not set"), + + authority: self.instruction.authority.expect("authority is not set"), + + system_program: self + .instruction + .system_program + .expect("system_program is not set"), + }; + instruction.invoke_signed_with_remaining_accounts( + signers_seeds, + &self.instruction.__remaining_accounts, + ) + } +} + +struct InitEscrowV2CpiBuilderInstruction<'a, 'b> { + __program: &'b solana_program::account_info::AccountInfo<'a>, + escrow: Option<&'b solana_program::account_info::AccountInfo<'a>>, + authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, + system_program: Option<&'b solana_program::account_info::AccountInfo<'a>>, + /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. + __remaining_accounts: Vec<( + &'b solana_program::account_info::AccountInfo<'a>, + bool, + bool, + )>, +} diff --git a/clients/rust/src/generated/instructions/init_recipe.rs b/clients/rust/src/generated/instructions/init_recipe.rs new file mode 100644 index 0000000..90b25b4 --- /dev/null +++ b/clients/rust/src/generated/instructions/init_recipe.rs @@ -0,0 +1,812 @@ +//! This code was AUTOGENERATED using the kinobi library. +//! Please DO NOT EDIT THIS FILE, instead use visitors +//! to add features, then rerun kinobi to update it. +//! +//! [https://github.com/metaplex-foundation/kinobi] +//! + +#[cfg(feature = "anchor")] +use anchor_lang::prelude::{AnchorDeserialize, AnchorSerialize}; +#[cfg(not(feature = "anchor"))] +use borsh::{BorshDeserialize, BorshSerialize}; + +/// Accounts. +pub struct InitRecipe { + pub recipe: solana_program::pubkey::Pubkey, + + pub authority: solana_program::pubkey::Pubkey, + + pub collection: solana_program::pubkey::Pubkey, + + pub token: solana_program::pubkey::Pubkey, + + pub fee_location: solana_program::pubkey::Pubkey, + /// The ATA for token fees to be stored + pub fee_ata: solana_program::pubkey::Pubkey, + + pub system_program: solana_program::pubkey::Pubkey, + + pub token_program: solana_program::pubkey::Pubkey, + + pub associated_token_program: solana_program::pubkey::Pubkey, +} + +impl InitRecipe { + pub fn instruction( + &self, + args: InitRecipeInstructionArgs, + ) -> solana_program::instruction::Instruction { + self.instruction_with_remaining_accounts(args, &[]) + } + #[allow(clippy::vec_init_then_push)] + pub fn instruction_with_remaining_accounts( + &self, + args: InitRecipeInstructionArgs, + remaining_accounts: &[solana_program::instruction::AccountMeta], + ) -> solana_program::instruction::Instruction { + let mut accounts = Vec::with_capacity(9 + remaining_accounts.len()); + accounts.push(solana_program::instruction::AccountMeta::new( + self.recipe, + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new( + self.authority, + true, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( + self.collection, + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( + self.token, false, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( + self.fee_location, + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new( + self.fee_ata, + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( + self.system_program, + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( + self.token_program, + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( + self.associated_token_program, + false, + )); + accounts.extend_from_slice(remaining_accounts); + let mut data = InitRecipeInstructionData::new().try_to_vec().unwrap(); + let mut args = args.try_to_vec().unwrap(); + data.append(&mut args); + + solana_program::instruction::Instruction { + program_id: crate::MPL_HYBRID_ID, + accounts, + data, + } + } +} + +#[cfg_attr(not(feature = "anchor"), derive(BorshSerialize, BorshDeserialize))] +#[cfg_attr(feature = "anchor", derive(AnchorSerialize, AnchorDeserialize))] +pub struct InitRecipeInstructionData { + discriminator: [u8; 8], +} + +impl InitRecipeInstructionData { + pub fn new() -> Self { + Self { + discriminator: [196, 35, 249, 242, 64, 106, 51, 53], + } + } +} + +#[cfg_attr(not(feature = "anchor"), derive(BorshSerialize, BorshDeserialize))] +#[cfg_attr(feature = "anchor", derive(AnchorSerialize, AnchorDeserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[derive(Clone, Debug, Eq, PartialEq)] +pub struct InitRecipeInstructionArgs { + pub name: String, + pub uri: String, + pub max: u64, + pub min: u64, + pub amount: u64, + pub fee_amount_capture: u64, + pub fee_amount_release: u64, + pub sol_fee_amount_capture: u64, + pub sol_fee_amount_release: u64, + pub path: u16, +} + +/// Instruction builder for `InitRecipe`. +/// +/// ### Accounts: +/// +/// 0. `[writable]` recipe +/// 1. `[writable, signer]` authority +/// 2. `[]` collection +/// 3. `[]` token +/// 4. `[]` fee_location +/// 5. `[writable]` fee_ata +/// 6. `[optional]` system_program (default to `11111111111111111111111111111111`) +/// 7. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) +/// 8. `[]` associated_token_program +#[derive(Default)] +pub struct InitRecipeBuilder { + recipe: Option, + authority: Option, + collection: Option, + token: Option, + fee_location: Option, + fee_ata: Option, + system_program: Option, + token_program: Option, + associated_token_program: Option, + name: Option, + uri: Option, + max: Option, + min: Option, + amount: Option, + fee_amount_capture: Option, + fee_amount_release: Option, + sol_fee_amount_capture: Option, + sol_fee_amount_release: Option, + path: Option, + __remaining_accounts: Vec, +} + +impl InitRecipeBuilder { + pub fn new() -> Self { + Self::default() + } + #[inline(always)] + pub fn recipe(&mut self, recipe: solana_program::pubkey::Pubkey) -> &mut Self { + self.recipe = Some(recipe); + self + } + #[inline(always)] + pub fn authority(&mut self, authority: solana_program::pubkey::Pubkey) -> &mut Self { + self.authority = Some(authority); + self + } + #[inline(always)] + pub fn collection(&mut self, collection: solana_program::pubkey::Pubkey) -> &mut Self { + self.collection = Some(collection); + self + } + #[inline(always)] + pub fn token(&mut self, token: solana_program::pubkey::Pubkey) -> &mut Self { + self.token = Some(token); + self + } + #[inline(always)] + pub fn fee_location(&mut self, fee_location: solana_program::pubkey::Pubkey) -> &mut Self { + self.fee_location = Some(fee_location); + self + } + /// The ATA for token fees to be stored + #[inline(always)] + pub fn fee_ata(&mut self, fee_ata: solana_program::pubkey::Pubkey) -> &mut Self { + self.fee_ata = Some(fee_ata); + self + } + /// `[optional account, default to '11111111111111111111111111111111']` + #[inline(always)] + pub fn system_program(&mut self, system_program: solana_program::pubkey::Pubkey) -> &mut Self { + self.system_program = Some(system_program); + self + } + /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` + #[inline(always)] + pub fn token_program(&mut self, token_program: solana_program::pubkey::Pubkey) -> &mut Self { + self.token_program = Some(token_program); + self + } + #[inline(always)] + pub fn associated_token_program( + &mut self, + associated_token_program: solana_program::pubkey::Pubkey, + ) -> &mut Self { + self.associated_token_program = Some(associated_token_program); + self + } + #[inline(always)] + pub fn name(&mut self, name: String) -> &mut Self { + self.name = Some(name); + self + } + #[inline(always)] + pub fn uri(&mut self, uri: String) -> &mut Self { + self.uri = Some(uri); + self + } + #[inline(always)] + pub fn max(&mut self, max: u64) -> &mut Self { + self.max = Some(max); + self + } + #[inline(always)] + pub fn min(&mut self, min: u64) -> &mut Self { + self.min = Some(min); + self + } + #[inline(always)] + pub fn amount(&mut self, amount: u64) -> &mut Self { + self.amount = Some(amount); + self + } + #[inline(always)] + pub fn fee_amount_capture(&mut self, fee_amount_capture: u64) -> &mut Self { + self.fee_amount_capture = Some(fee_amount_capture); + self + } + #[inline(always)] + pub fn fee_amount_release(&mut self, fee_amount_release: u64) -> &mut Self { + self.fee_amount_release = Some(fee_amount_release); + self + } + #[inline(always)] + pub fn sol_fee_amount_capture(&mut self, sol_fee_amount_capture: u64) -> &mut Self { + self.sol_fee_amount_capture = Some(sol_fee_amount_capture); + self + } + #[inline(always)] + pub fn sol_fee_amount_release(&mut self, sol_fee_amount_release: u64) -> &mut Self { + self.sol_fee_amount_release = Some(sol_fee_amount_release); + self + } + #[inline(always)] + pub fn path(&mut self, path: u16) -> &mut Self { + self.path = Some(path); + self + } + /// Add an aditional account to the instruction. + #[inline(always)] + pub fn add_remaining_account( + &mut self, + account: solana_program::instruction::AccountMeta, + ) -> &mut Self { + self.__remaining_accounts.push(account); + self + } + /// Add additional accounts to the instruction. + #[inline(always)] + pub fn add_remaining_accounts( + &mut self, + accounts: &[solana_program::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 { + let accounts = InitRecipe { + recipe: self.recipe.expect("recipe is not set"), + authority: self.authority.expect("authority is not set"), + collection: self.collection.expect("collection is not set"), + token: self.token.expect("token is not set"), + fee_location: self.fee_location.expect("fee_location is not set"), + fee_ata: self.fee_ata.expect("fee_ata is not set"), + system_program: self + .system_program + .unwrap_or(solana_program::pubkey!("11111111111111111111111111111111")), + token_program: self.token_program.unwrap_or(solana_program::pubkey!( + "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + )), + associated_token_program: self + .associated_token_program + .expect("associated_token_program is not set"), + }; + let args = InitRecipeInstructionArgs { + name: self.name.clone().expect("name is not set"), + uri: self.uri.clone().expect("uri is not set"), + max: self.max.clone().expect("max is not set"), + min: self.min.clone().expect("min is not set"), + amount: self.amount.clone().expect("amount is not set"), + fee_amount_capture: self + .fee_amount_capture + .clone() + .expect("fee_amount_capture is not set"), + fee_amount_release: self + .fee_amount_release + .clone() + .expect("fee_amount_release is not set"), + sol_fee_amount_capture: self + .sol_fee_amount_capture + .clone() + .expect("sol_fee_amount_capture is not set"), + sol_fee_amount_release: self + .sol_fee_amount_release + .clone() + .expect("sol_fee_amount_release is not set"), + path: self.path.clone().expect("path is not set"), + }; + + accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) + } +} + +/// `init_recipe` CPI accounts. +pub struct InitRecipeCpiAccounts<'a, 'b> { + pub recipe: &'b solana_program::account_info::AccountInfo<'a>, + + pub authority: &'b solana_program::account_info::AccountInfo<'a>, + + pub collection: &'b solana_program::account_info::AccountInfo<'a>, + + pub token: &'b solana_program::account_info::AccountInfo<'a>, + + pub fee_location: &'b solana_program::account_info::AccountInfo<'a>, + /// The ATA for token fees to be stored + pub fee_ata: &'b solana_program::account_info::AccountInfo<'a>, + + pub system_program: &'b solana_program::account_info::AccountInfo<'a>, + + pub token_program: &'b solana_program::account_info::AccountInfo<'a>, + + pub associated_token_program: &'b solana_program::account_info::AccountInfo<'a>, +} + +/// `init_recipe` CPI instruction. +pub struct InitRecipeCpi<'a, 'b> { + /// The program to invoke. + pub __program: &'b solana_program::account_info::AccountInfo<'a>, + + pub recipe: &'b solana_program::account_info::AccountInfo<'a>, + + pub authority: &'b solana_program::account_info::AccountInfo<'a>, + + pub collection: &'b solana_program::account_info::AccountInfo<'a>, + + pub token: &'b solana_program::account_info::AccountInfo<'a>, + + pub fee_location: &'b solana_program::account_info::AccountInfo<'a>, + /// The ATA for token fees to be stored + pub fee_ata: &'b solana_program::account_info::AccountInfo<'a>, + + pub system_program: &'b solana_program::account_info::AccountInfo<'a>, + + pub token_program: &'b solana_program::account_info::AccountInfo<'a>, + + pub associated_token_program: &'b solana_program::account_info::AccountInfo<'a>, + /// The arguments for the instruction. + pub __args: InitRecipeInstructionArgs, +} + +impl<'a, 'b> InitRecipeCpi<'a, 'b> { + pub fn new( + program: &'b solana_program::account_info::AccountInfo<'a>, + accounts: InitRecipeCpiAccounts<'a, 'b>, + args: InitRecipeInstructionArgs, + ) -> Self { + Self { + __program: program, + recipe: accounts.recipe, + authority: accounts.authority, + collection: accounts.collection, + token: accounts.token, + fee_location: accounts.fee_location, + fee_ata: accounts.fee_ata, + system_program: accounts.system_program, + token_program: accounts.token_program, + associated_token_program: accounts.associated_token_program, + __args: args, + } + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::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 { + self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) + } + #[inline(always)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) + } + #[allow(clippy::clone_on_copy)] + #[allow(clippy::vec_init_then_push)] + 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 { + let mut accounts = Vec::with_capacity(9 + remaining_accounts.len()); + accounts.push(solana_program::instruction::AccountMeta::new( + *self.recipe.key, + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new( + *self.authority.key, + true, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( + *self.collection.key, + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( + *self.token.key, + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( + *self.fee_location.key, + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new( + *self.fee_ata.key, + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( + *self.system_program.key, + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( + *self.token_program.key, + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( + *self.associated_token_program.key, + false, + )); + remaining_accounts.iter().for_each(|remaining_account| { + accounts.push(solana_program::instruction::AccountMeta { + pubkey: *remaining_account.0.key, + is_signer: remaining_account.1, + is_writable: remaining_account.2, + }) + }); + let mut data = InitRecipeInstructionData::new().try_to_vec().unwrap(); + let mut args = self.__args.try_to_vec().unwrap(); + data.append(&mut args); + + let instruction = solana_program::instruction::Instruction { + program_id: crate::MPL_HYBRID_ID, + accounts, + data, + }; + let mut account_infos = Vec::with_capacity(9 + 1 + remaining_accounts.len()); + account_infos.push(self.__program.clone()); + account_infos.push(self.recipe.clone()); + account_infos.push(self.authority.clone()); + account_infos.push(self.collection.clone()); + account_infos.push(self.token.clone()); + account_infos.push(self.fee_location.clone()); + account_infos.push(self.fee_ata.clone()); + account_infos.push(self.system_program.clone()); + account_infos.push(self.token_program.clone()); + account_infos.push(self.associated_token_program.clone()); + remaining_accounts + .iter() + .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); + + if signers_seeds.is_empty() { + solana_program::program::invoke(&instruction, &account_infos) + } else { + solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds) + } + } +} + +/// Instruction builder for `InitRecipe` via CPI. +/// +/// ### Accounts: +/// +/// 0. `[writable]` recipe +/// 1. `[writable, signer]` authority +/// 2. `[]` collection +/// 3. `[]` token +/// 4. `[]` fee_location +/// 5. `[writable]` fee_ata +/// 6. `[]` system_program +/// 7. `[]` token_program +/// 8. `[]` associated_token_program +pub struct InitRecipeCpiBuilder<'a, 'b> { + instruction: Box>, +} + +impl<'a, 'b> InitRecipeCpiBuilder<'a, 'b> { + pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { + let instruction = Box::new(InitRecipeCpiBuilderInstruction { + __program: program, + recipe: None, + authority: None, + collection: None, + token: None, + fee_location: None, + fee_ata: None, + system_program: None, + token_program: None, + associated_token_program: None, + name: None, + uri: None, + max: None, + min: None, + amount: None, + fee_amount_capture: None, + fee_amount_release: None, + sol_fee_amount_capture: None, + sol_fee_amount_release: None, + path: None, + __remaining_accounts: Vec::new(), + }); + Self { instruction } + } + #[inline(always)] + pub fn recipe( + &mut self, + recipe: &'b solana_program::account_info::AccountInfo<'a>, + ) -> &mut Self { + self.instruction.recipe = Some(recipe); + self + } + #[inline(always)] + pub fn authority( + &mut self, + authority: &'b solana_program::account_info::AccountInfo<'a>, + ) -> &mut Self { + self.instruction.authority = Some(authority); + self + } + #[inline(always)] + pub fn collection( + &mut self, + collection: &'b solana_program::account_info::AccountInfo<'a>, + ) -> &mut Self { + self.instruction.collection = Some(collection); + self + } + #[inline(always)] + pub fn token(&mut self, token: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { + self.instruction.token = Some(token); + self + } + #[inline(always)] + pub fn fee_location( + &mut self, + fee_location: &'b solana_program::account_info::AccountInfo<'a>, + ) -> &mut Self { + self.instruction.fee_location = Some(fee_location); + self + } + /// The ATA for token fees to be stored + #[inline(always)] + pub fn fee_ata( + &mut self, + fee_ata: &'b solana_program::account_info::AccountInfo<'a>, + ) -> &mut Self { + self.instruction.fee_ata = Some(fee_ata); + self + } + #[inline(always)] + pub fn system_program( + &mut self, + system_program: &'b solana_program::account_info::AccountInfo<'a>, + ) -> &mut Self { + self.instruction.system_program = Some(system_program); + self + } + #[inline(always)] + pub fn token_program( + &mut self, + token_program: &'b solana_program::account_info::AccountInfo<'a>, + ) -> &mut Self { + self.instruction.token_program = Some(token_program); + self + } + #[inline(always)] + pub fn associated_token_program( + &mut self, + associated_token_program: &'b solana_program::account_info::AccountInfo<'a>, + ) -> &mut Self { + self.instruction.associated_token_program = Some(associated_token_program); + self + } + #[inline(always)] + pub fn name(&mut self, name: String) -> &mut Self { + self.instruction.name = Some(name); + self + } + #[inline(always)] + pub fn uri(&mut self, uri: String) -> &mut Self { + self.instruction.uri = Some(uri); + self + } + #[inline(always)] + pub fn max(&mut self, max: u64) -> &mut Self { + self.instruction.max = Some(max); + self + } + #[inline(always)] + pub fn min(&mut self, min: u64) -> &mut Self { + self.instruction.min = Some(min); + self + } + #[inline(always)] + pub fn amount(&mut self, amount: u64) -> &mut Self { + self.instruction.amount = Some(amount); + self + } + #[inline(always)] + pub fn fee_amount_capture(&mut self, fee_amount_capture: u64) -> &mut Self { + self.instruction.fee_amount_capture = Some(fee_amount_capture); + self + } + #[inline(always)] + pub fn fee_amount_release(&mut self, fee_amount_release: u64) -> &mut Self { + self.instruction.fee_amount_release = Some(fee_amount_release); + self + } + #[inline(always)] + pub fn sol_fee_amount_capture(&mut self, sol_fee_amount_capture: u64) -> &mut Self { + self.instruction.sol_fee_amount_capture = Some(sol_fee_amount_capture); + self + } + #[inline(always)] + pub fn sol_fee_amount_release(&mut self, sol_fee_amount_release: u64) -> &mut Self { + self.instruction.sol_fee_amount_release = Some(sol_fee_amount_release); + self + } + #[inline(always)] + pub fn path(&mut self, path: u16) -> &mut Self { + self.instruction.path = Some(path); + self + } + /// Add an additional account to the instruction. + #[inline(always)] + pub fn add_remaining_account( + &mut self, + account: &'b solana_program::account_info::AccountInfo<'a>, + is_writable: bool, + is_signer: bool, + ) -> &mut Self { + self.instruction + .__remaining_accounts + .push((account, is_writable, is_signer)); + self + } + /// Add additional accounts to the instruction. + /// + /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, + /// and a `bool` indicating whether the account is a signer or not. + #[inline(always)] + pub fn add_remaining_accounts( + &mut self, + accounts: &[( + &'b solana_program::account_info::AccountInfo<'a>, + bool, + bool, + )], + ) -> &mut Self { + self.instruction + .__remaining_accounts + .extend_from_slice(accounts); + self + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::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 { + let args = InitRecipeInstructionArgs { + name: self.instruction.name.clone().expect("name is not set"), + uri: self.instruction.uri.clone().expect("uri is not set"), + max: self.instruction.max.clone().expect("max is not set"), + min: self.instruction.min.clone().expect("min is not set"), + amount: self.instruction.amount.clone().expect("amount is not set"), + fee_amount_capture: self + .instruction + .fee_amount_capture + .clone() + .expect("fee_amount_capture is not set"), + fee_amount_release: self + .instruction + .fee_amount_release + .clone() + .expect("fee_amount_release is not set"), + sol_fee_amount_capture: self + .instruction + .sol_fee_amount_capture + .clone() + .expect("sol_fee_amount_capture is not set"), + sol_fee_amount_release: self + .instruction + .sol_fee_amount_release + .clone() + .expect("sol_fee_amount_release is not set"), + path: self.instruction.path.clone().expect("path is not set"), + }; + let instruction = InitRecipeCpi { + __program: self.instruction.__program, + + recipe: self.instruction.recipe.expect("recipe is not set"), + + authority: self.instruction.authority.expect("authority is not set"), + + collection: self.instruction.collection.expect("collection is not set"), + + token: self.instruction.token.expect("token is not set"), + + fee_location: self + .instruction + .fee_location + .expect("fee_location is not set"), + + fee_ata: self.instruction.fee_ata.expect("fee_ata is not set"), + + system_program: self + .instruction + .system_program + .expect("system_program is not set"), + + token_program: self + .instruction + .token_program + .expect("token_program is not set"), + + associated_token_program: self + .instruction + .associated_token_program + .expect("associated_token_program is not set"), + __args: args, + }; + instruction.invoke_signed_with_remaining_accounts( + signers_seeds, + &self.instruction.__remaining_accounts, + ) + } +} + +struct InitRecipeCpiBuilderInstruction<'a, 'b> { + __program: &'b solana_program::account_info::AccountInfo<'a>, + recipe: Option<&'b solana_program::account_info::AccountInfo<'a>>, + authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, + collection: Option<&'b solana_program::account_info::AccountInfo<'a>>, + token: Option<&'b solana_program::account_info::AccountInfo<'a>>, + fee_location: Option<&'b solana_program::account_info::AccountInfo<'a>>, + fee_ata: Option<&'b solana_program::account_info::AccountInfo<'a>>, + system_program: Option<&'b solana_program::account_info::AccountInfo<'a>>, + token_program: Option<&'b solana_program::account_info::AccountInfo<'a>>, + associated_token_program: Option<&'b solana_program::account_info::AccountInfo<'a>>, + name: Option, + uri: Option, + max: Option, + min: Option, + amount: Option, + fee_amount_capture: Option, + fee_amount_release: Option, + sol_fee_amount_capture: Option, + sol_fee_amount_release: Option, + path: Option, + /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. + __remaining_accounts: Vec<( + &'b solana_program::account_info::AccountInfo<'a>, + bool, + bool, + )>, +} diff --git a/clients/rust/src/generated/instructions/migrate_nft_v1.rs b/clients/rust/src/generated/instructions/migrate_nft_v1.rs new file mode 100644 index 0000000..c81e53b --- /dev/null +++ b/clients/rust/src/generated/instructions/migrate_nft_v1.rs @@ -0,0 +1,507 @@ +//! This code was AUTOGENERATED using the kinobi library. +//! Please DO NOT EDIT THIS FILE, instead use visitors +//! to add features, then rerun kinobi to update it. +//! +//! [https://github.com/metaplex-foundation/kinobi] +//! + +#[cfg(feature = "anchor")] +use anchor_lang::prelude::{AnchorDeserialize, AnchorSerialize}; +#[cfg(not(feature = "anchor"))] +use borsh::{BorshDeserialize, BorshSerialize}; + +/// Accounts. +pub struct MigrateNftV1 { + pub authority: solana_program::pubkey::Pubkey, + + pub escrow_new: solana_program::pubkey::Pubkey, + + pub escrow_old: solana_program::pubkey::Pubkey, + + pub asset: solana_program::pubkey::Pubkey, + + pub collection: solana_program::pubkey::Pubkey, + + pub mpl_core: solana_program::pubkey::Pubkey, + + pub system_program: solana_program::pubkey::Pubkey, +} + +impl MigrateNftV1 { + pub fn instruction(&self) -> solana_program::instruction::Instruction { + self.instruction_with_remaining_accounts(&[]) + } + #[allow(clippy::vec_init_then_push)] + pub fn instruction_with_remaining_accounts( + &self, + remaining_accounts: &[solana_program::instruction::AccountMeta], + ) -> solana_program::instruction::Instruction { + let mut accounts = Vec::with_capacity(7 + remaining_accounts.len()); + accounts.push(solana_program::instruction::AccountMeta::new( + self.authority, + true, + )); + accounts.push(solana_program::instruction::AccountMeta::new( + self.escrow_new, + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new( + self.escrow_old, + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new( + self.asset, false, + )); + accounts.push(solana_program::instruction::AccountMeta::new( + self.collection, + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( + self.mpl_core, + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( + self.system_program, + false, + )); + accounts.extend_from_slice(remaining_accounts); + let data = MigrateNftV1InstructionData::new().try_to_vec().unwrap(); + + solana_program::instruction::Instruction { + program_id: crate::MPL_HYBRID_ID, + accounts, + data, + } + } +} + +#[cfg_attr(not(feature = "anchor"), derive(BorshSerialize, BorshDeserialize))] +#[cfg_attr(feature = "anchor", derive(AnchorSerialize, AnchorDeserialize))] +pub struct MigrateNftV1InstructionData { + discriminator: [u8; 8], +} + +impl MigrateNftV1InstructionData { + pub fn new() -> Self { + Self { + discriminator: [134, 95, 245, 237, 50, 234, 182, 6], + } + } +} + +/// Instruction builder for `MigrateNftV1`. +/// +/// ### Accounts: +/// +/// 0. `[writable, signer]` authority +/// 1. `[writable]` escrow_new +/// 2. `[writable]` escrow_old +/// 3. `[writable]` asset +/// 4. `[writable]` collection +/// 5. `[]` mpl_core +/// 6. `[optional]` system_program (default to `11111111111111111111111111111111`) +#[derive(Default)] +pub struct MigrateNftV1Builder { + authority: Option, + escrow_new: Option, + escrow_old: Option, + asset: Option, + collection: Option, + mpl_core: Option, + system_program: Option, + __remaining_accounts: Vec, +} + +impl MigrateNftV1Builder { + pub fn new() -> Self { + Self::default() + } + #[inline(always)] + pub fn authority(&mut self, authority: solana_program::pubkey::Pubkey) -> &mut Self { + self.authority = Some(authority); + self + } + #[inline(always)] + pub fn escrow_new(&mut self, escrow_new: solana_program::pubkey::Pubkey) -> &mut Self { + self.escrow_new = Some(escrow_new); + self + } + #[inline(always)] + pub fn escrow_old(&mut self, escrow_old: solana_program::pubkey::Pubkey) -> &mut Self { + self.escrow_old = Some(escrow_old); + self + } + #[inline(always)] + pub fn asset(&mut self, asset: solana_program::pubkey::Pubkey) -> &mut Self { + self.asset = Some(asset); + self + } + #[inline(always)] + pub fn collection(&mut self, collection: solana_program::pubkey::Pubkey) -> &mut Self { + self.collection = Some(collection); + self + } + #[inline(always)] + pub fn mpl_core(&mut self, mpl_core: solana_program::pubkey::Pubkey) -> &mut Self { + self.mpl_core = Some(mpl_core); + self + } + /// `[optional account, default to '11111111111111111111111111111111']` + #[inline(always)] + pub fn system_program(&mut self, system_program: solana_program::pubkey::Pubkey) -> &mut Self { + self.system_program = Some(system_program); + self + } + /// Add an aditional account to the instruction. + #[inline(always)] + pub fn add_remaining_account( + &mut self, + account: solana_program::instruction::AccountMeta, + ) -> &mut Self { + self.__remaining_accounts.push(account); + self + } + /// Add additional accounts to the instruction. + #[inline(always)] + pub fn add_remaining_accounts( + &mut self, + accounts: &[solana_program::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 { + let accounts = MigrateNftV1 { + authority: self.authority.expect("authority is not set"), + escrow_new: self.escrow_new.expect("escrow_new is not set"), + escrow_old: self.escrow_old.expect("escrow_old is not set"), + asset: self.asset.expect("asset is not set"), + collection: self.collection.expect("collection is not set"), + mpl_core: self.mpl_core.expect("mpl_core is not set"), + system_program: self + .system_program + .unwrap_or(solana_program::pubkey!("11111111111111111111111111111111")), + }; + + accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) + } +} + +/// `migrate_nft_v1` CPI accounts. +pub struct MigrateNftV1CpiAccounts<'a, 'b> { + pub authority: &'b solana_program::account_info::AccountInfo<'a>, + + pub escrow_new: &'b solana_program::account_info::AccountInfo<'a>, + + pub escrow_old: &'b solana_program::account_info::AccountInfo<'a>, + + pub asset: &'b solana_program::account_info::AccountInfo<'a>, + + pub collection: &'b solana_program::account_info::AccountInfo<'a>, + + pub mpl_core: &'b solana_program::account_info::AccountInfo<'a>, + + pub system_program: &'b solana_program::account_info::AccountInfo<'a>, +} + +/// `migrate_nft_v1` CPI instruction. +pub struct MigrateNftV1Cpi<'a, 'b> { + /// The program to invoke. + pub __program: &'b solana_program::account_info::AccountInfo<'a>, + + pub authority: &'b solana_program::account_info::AccountInfo<'a>, + + pub escrow_new: &'b solana_program::account_info::AccountInfo<'a>, + + pub escrow_old: &'b solana_program::account_info::AccountInfo<'a>, + + pub asset: &'b solana_program::account_info::AccountInfo<'a>, + + pub collection: &'b solana_program::account_info::AccountInfo<'a>, + + pub mpl_core: &'b solana_program::account_info::AccountInfo<'a>, + + pub system_program: &'b solana_program::account_info::AccountInfo<'a>, +} + +impl<'a, 'b> MigrateNftV1Cpi<'a, 'b> { + pub fn new( + program: &'b solana_program::account_info::AccountInfo<'a>, + accounts: MigrateNftV1CpiAccounts<'a, 'b>, + ) -> Self { + Self { + __program: program, + authority: accounts.authority, + escrow_new: accounts.escrow_new, + escrow_old: accounts.escrow_old, + asset: accounts.asset, + collection: accounts.collection, + mpl_core: accounts.mpl_core, + system_program: accounts.system_program, + } + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::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 { + self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) + } + #[inline(always)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) + } + #[allow(clippy::clone_on_copy)] + #[allow(clippy::vec_init_then_push)] + 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 { + let mut accounts = Vec::with_capacity(7 + remaining_accounts.len()); + accounts.push(solana_program::instruction::AccountMeta::new( + *self.authority.key, + true, + )); + accounts.push(solana_program::instruction::AccountMeta::new( + *self.escrow_new.key, + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new( + *self.escrow_old.key, + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new( + *self.asset.key, + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new( + *self.collection.key, + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( + *self.mpl_core.key, + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( + *self.system_program.key, + false, + )); + remaining_accounts.iter().for_each(|remaining_account| { + accounts.push(solana_program::instruction::AccountMeta { + pubkey: *remaining_account.0.key, + is_signer: remaining_account.1, + is_writable: remaining_account.2, + }) + }); + let data = MigrateNftV1InstructionData::new().try_to_vec().unwrap(); + + let instruction = solana_program::instruction::Instruction { + program_id: crate::MPL_HYBRID_ID, + accounts, + data, + }; + let mut account_infos = Vec::with_capacity(7 + 1 + remaining_accounts.len()); + account_infos.push(self.__program.clone()); + account_infos.push(self.authority.clone()); + account_infos.push(self.escrow_new.clone()); + account_infos.push(self.escrow_old.clone()); + account_infos.push(self.asset.clone()); + account_infos.push(self.collection.clone()); + account_infos.push(self.mpl_core.clone()); + account_infos.push(self.system_program.clone()); + remaining_accounts + .iter() + .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); + + if signers_seeds.is_empty() { + solana_program::program::invoke(&instruction, &account_infos) + } else { + solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds) + } + } +} + +/// Instruction builder for `MigrateNftV1` via CPI. +/// +/// ### Accounts: +/// +/// 0. `[writable, signer]` authority +/// 1. `[writable]` escrow_new +/// 2. `[writable]` escrow_old +/// 3. `[writable]` asset +/// 4. `[writable]` collection +/// 5. `[]` mpl_core +/// 6. `[]` system_program +pub struct MigrateNftV1CpiBuilder<'a, 'b> { + instruction: Box>, +} + +impl<'a, 'b> MigrateNftV1CpiBuilder<'a, 'b> { + pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { + let instruction = Box::new(MigrateNftV1CpiBuilderInstruction { + __program: program, + authority: None, + escrow_new: None, + escrow_old: None, + asset: None, + collection: None, + mpl_core: None, + system_program: None, + __remaining_accounts: Vec::new(), + }); + Self { instruction } + } + #[inline(always)] + pub fn authority( + &mut self, + authority: &'b solana_program::account_info::AccountInfo<'a>, + ) -> &mut Self { + self.instruction.authority = Some(authority); + self + } + #[inline(always)] + pub fn escrow_new( + &mut self, + escrow_new: &'b solana_program::account_info::AccountInfo<'a>, + ) -> &mut Self { + self.instruction.escrow_new = Some(escrow_new); + self + } + #[inline(always)] + pub fn escrow_old( + &mut self, + escrow_old: &'b solana_program::account_info::AccountInfo<'a>, + ) -> &mut Self { + self.instruction.escrow_old = Some(escrow_old); + self + } + #[inline(always)] + pub fn asset(&mut self, asset: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { + self.instruction.asset = Some(asset); + self + } + #[inline(always)] + pub fn collection( + &mut self, + collection: &'b solana_program::account_info::AccountInfo<'a>, + ) -> &mut Self { + self.instruction.collection = Some(collection); + self + } + #[inline(always)] + pub fn mpl_core( + &mut self, + mpl_core: &'b solana_program::account_info::AccountInfo<'a>, + ) -> &mut Self { + self.instruction.mpl_core = Some(mpl_core); + self + } + #[inline(always)] + pub fn system_program( + &mut self, + system_program: &'b solana_program::account_info::AccountInfo<'a>, + ) -> &mut Self { + self.instruction.system_program = Some(system_program); + self + } + /// Add an additional account to the instruction. + #[inline(always)] + pub fn add_remaining_account( + &mut self, + account: &'b solana_program::account_info::AccountInfo<'a>, + is_writable: bool, + is_signer: bool, + ) -> &mut Self { + self.instruction + .__remaining_accounts + .push((account, is_writable, is_signer)); + self + } + /// Add additional accounts to the instruction. + /// + /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, + /// and a `bool` indicating whether the account is a signer or not. + #[inline(always)] + pub fn add_remaining_accounts( + &mut self, + accounts: &[( + &'b solana_program::account_info::AccountInfo<'a>, + bool, + bool, + )], + ) -> &mut Self { + self.instruction + .__remaining_accounts + .extend_from_slice(accounts); + self + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::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 { + let instruction = MigrateNftV1Cpi { + __program: self.instruction.__program, + + authority: self.instruction.authority.expect("authority is not set"), + + escrow_new: self.instruction.escrow_new.expect("escrow_new is not set"), + + escrow_old: self.instruction.escrow_old.expect("escrow_old is not set"), + + asset: self.instruction.asset.expect("asset is not set"), + + collection: self.instruction.collection.expect("collection is not set"), + + mpl_core: self.instruction.mpl_core.expect("mpl_core is not set"), + + system_program: self + .instruction + .system_program + .expect("system_program is not set"), + }; + instruction.invoke_signed_with_remaining_accounts( + signers_seeds, + &self.instruction.__remaining_accounts, + ) + } +} + +struct MigrateNftV1CpiBuilderInstruction<'a, 'b> { + __program: &'b solana_program::account_info::AccountInfo<'a>, + authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, + escrow_new: Option<&'b solana_program::account_info::AccountInfo<'a>>, + escrow_old: Option<&'b solana_program::account_info::AccountInfo<'a>>, + asset: Option<&'b solana_program::account_info::AccountInfo<'a>>, + collection: Option<&'b solana_program::account_info::AccountInfo<'a>>, + mpl_core: Option<&'b solana_program::account_info::AccountInfo<'a>>, + system_program: Option<&'b solana_program::account_info::AccountInfo<'a>>, + /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. + __remaining_accounts: Vec<( + &'b solana_program::account_info::AccountInfo<'a>, + bool, + bool, + )>, +} diff --git a/clients/rust/src/generated/instructions/migrate_tokens_v1.rs b/clients/rust/src/generated/instructions/migrate_tokens_v1.rs new file mode 100644 index 0000000..a6c0a47 --- /dev/null +++ b/clients/rust/src/generated/instructions/migrate_tokens_v1.rs @@ -0,0 +1,688 @@ +//! This code was AUTOGENERATED using the kinobi library. +//! Please DO NOT EDIT THIS FILE, instead use visitors +//! to add features, then rerun kinobi to update it. +//! +//! [https://github.com/metaplex-foundation/kinobi] +//! + +#[cfg(feature = "anchor")] +use anchor_lang::prelude::{AnchorDeserialize, AnchorSerialize}; +#[cfg(not(feature = "anchor"))] +use borsh::{BorshDeserialize, BorshSerialize}; + +/// Accounts. +pub struct MigrateTokensV1 { + pub authority: solana_program::pubkey::Pubkey, + + pub escrow_new: solana_program::pubkey::Pubkey, + + pub escrow_old: solana_program::pubkey::Pubkey, + + pub collection: solana_program::pubkey::Pubkey, + + pub escrow_new_token_account: solana_program::pubkey::Pubkey, + + pub escrow_old_token_account: solana_program::pubkey::Pubkey, + + pub token: solana_program::pubkey::Pubkey, + + pub system_program: solana_program::pubkey::Pubkey, + + pub token_program: solana_program::pubkey::Pubkey, + + pub associated_token_program: solana_program::pubkey::Pubkey, +} + +impl MigrateTokensV1 { + pub fn instruction( + &self, + args: MigrateTokensV1InstructionArgs, + ) -> solana_program::instruction::Instruction { + self.instruction_with_remaining_accounts(args, &[]) + } + #[allow(clippy::vec_init_then_push)] + pub fn instruction_with_remaining_accounts( + &self, + args: MigrateTokensV1InstructionArgs, + remaining_accounts: &[solana_program::instruction::AccountMeta], + ) -> solana_program::instruction::Instruction { + let mut accounts = Vec::with_capacity(10 + remaining_accounts.len()); + accounts.push(solana_program::instruction::AccountMeta::new( + self.authority, + true, + )); + accounts.push(solana_program::instruction::AccountMeta::new( + self.escrow_new, + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new( + self.escrow_old, + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new( + self.collection, + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new( + self.escrow_new_token_account, + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new( + self.escrow_old_token_account, + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( + self.token, false, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( + self.system_program, + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( + self.token_program, + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( + self.associated_token_program, + false, + )); + accounts.extend_from_slice(remaining_accounts); + let mut data = MigrateTokensV1InstructionData::new().try_to_vec().unwrap(); + let mut args = args.try_to_vec().unwrap(); + data.append(&mut args); + + solana_program::instruction::Instruction { + program_id: crate::MPL_HYBRID_ID, + accounts, + data, + } + } +} + +#[cfg_attr(not(feature = "anchor"), derive(BorshSerialize, BorshDeserialize))] +#[cfg_attr(feature = "anchor", derive(AnchorSerialize, AnchorDeserialize))] +pub struct MigrateTokensV1InstructionData { + discriminator: [u8; 8], +} + +impl MigrateTokensV1InstructionData { + pub fn new() -> Self { + Self { + discriminator: [214, 119, 117, 84, 29, 252, 202, 13], + } + } +} + +#[cfg_attr(not(feature = "anchor"), derive(BorshSerialize, BorshDeserialize))] +#[cfg_attr(feature = "anchor", derive(AnchorSerialize, AnchorDeserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[derive(Clone, Debug, Eq, PartialEq)] +pub struct MigrateTokensV1InstructionArgs { + pub amount: u64, +} + +/// Instruction builder for `MigrateTokensV1`. +/// +/// ### Accounts: +/// +/// 0. `[writable, signer]` authority +/// 1. `[writable]` escrow_new +/// 2. `[writable]` escrow_old +/// 3. `[writable]` collection +/// 4. `[writable]` escrow_new_token_account +/// 5. `[writable]` escrow_old_token_account +/// 6. `[]` token +/// 7. `[optional]` system_program (default to `11111111111111111111111111111111`) +/// 8. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) +/// 9. `[]` associated_token_program +#[derive(Default)] +pub struct MigrateTokensV1Builder { + authority: Option, + escrow_new: Option, + escrow_old: Option, + collection: Option, + escrow_new_token_account: Option, + escrow_old_token_account: Option, + token: Option, + system_program: Option, + token_program: Option, + associated_token_program: Option, + amount: Option, + __remaining_accounts: Vec, +} + +impl MigrateTokensV1Builder { + pub fn new() -> Self { + Self::default() + } + #[inline(always)] + pub fn authority(&mut self, authority: solana_program::pubkey::Pubkey) -> &mut Self { + self.authority = Some(authority); + self + } + #[inline(always)] + pub fn escrow_new(&mut self, escrow_new: solana_program::pubkey::Pubkey) -> &mut Self { + self.escrow_new = Some(escrow_new); + self + } + #[inline(always)] + pub fn escrow_old(&mut self, escrow_old: solana_program::pubkey::Pubkey) -> &mut Self { + self.escrow_old = Some(escrow_old); + self + } + #[inline(always)] + pub fn collection(&mut self, collection: solana_program::pubkey::Pubkey) -> &mut Self { + self.collection = Some(collection); + self + } + #[inline(always)] + pub fn escrow_new_token_account( + &mut self, + escrow_new_token_account: solana_program::pubkey::Pubkey, + ) -> &mut Self { + self.escrow_new_token_account = Some(escrow_new_token_account); + self + } + #[inline(always)] + pub fn escrow_old_token_account( + &mut self, + escrow_old_token_account: solana_program::pubkey::Pubkey, + ) -> &mut Self { + self.escrow_old_token_account = Some(escrow_old_token_account); + self + } + #[inline(always)] + pub fn token(&mut self, token: solana_program::pubkey::Pubkey) -> &mut Self { + self.token = Some(token); + self + } + /// `[optional account, default to '11111111111111111111111111111111']` + #[inline(always)] + pub fn system_program(&mut self, system_program: solana_program::pubkey::Pubkey) -> &mut Self { + self.system_program = Some(system_program); + self + } + /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` + #[inline(always)] + pub fn token_program(&mut self, token_program: solana_program::pubkey::Pubkey) -> &mut Self { + self.token_program = Some(token_program); + self + } + #[inline(always)] + pub fn associated_token_program( + &mut self, + associated_token_program: solana_program::pubkey::Pubkey, + ) -> &mut Self { + self.associated_token_program = Some(associated_token_program); + self + } + #[inline(always)] + pub fn amount(&mut self, amount: u64) -> &mut Self { + self.amount = Some(amount); + self + } + /// Add an aditional account to the instruction. + #[inline(always)] + pub fn add_remaining_account( + &mut self, + account: solana_program::instruction::AccountMeta, + ) -> &mut Self { + self.__remaining_accounts.push(account); + self + } + /// Add additional accounts to the instruction. + #[inline(always)] + pub fn add_remaining_accounts( + &mut self, + accounts: &[solana_program::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 { + let accounts = MigrateTokensV1 { + authority: self.authority.expect("authority is not set"), + escrow_new: self.escrow_new.expect("escrow_new is not set"), + escrow_old: self.escrow_old.expect("escrow_old is not set"), + collection: self.collection.expect("collection is not set"), + escrow_new_token_account: self + .escrow_new_token_account + .expect("escrow_new_token_account is not set"), + escrow_old_token_account: self + .escrow_old_token_account + .expect("escrow_old_token_account is not set"), + token: self.token.expect("token is not set"), + system_program: self + .system_program + .unwrap_or(solana_program::pubkey!("11111111111111111111111111111111")), + token_program: self.token_program.unwrap_or(solana_program::pubkey!( + "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + )), + associated_token_program: self + .associated_token_program + .expect("associated_token_program is not set"), + }; + let args = MigrateTokensV1InstructionArgs { + amount: self.amount.clone().expect("amount is not set"), + }; + + accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) + } +} + +/// `migrate_tokens_v1` CPI accounts. +pub struct MigrateTokensV1CpiAccounts<'a, 'b> { + pub authority: &'b solana_program::account_info::AccountInfo<'a>, + + pub escrow_new: &'b solana_program::account_info::AccountInfo<'a>, + + pub escrow_old: &'b solana_program::account_info::AccountInfo<'a>, + + pub collection: &'b solana_program::account_info::AccountInfo<'a>, + + pub escrow_new_token_account: &'b solana_program::account_info::AccountInfo<'a>, + + pub escrow_old_token_account: &'b solana_program::account_info::AccountInfo<'a>, + + pub token: &'b solana_program::account_info::AccountInfo<'a>, + + pub system_program: &'b solana_program::account_info::AccountInfo<'a>, + + pub token_program: &'b solana_program::account_info::AccountInfo<'a>, + + pub associated_token_program: &'b solana_program::account_info::AccountInfo<'a>, +} + +/// `migrate_tokens_v1` CPI instruction. +pub struct MigrateTokensV1Cpi<'a, 'b> { + /// The program to invoke. + pub __program: &'b solana_program::account_info::AccountInfo<'a>, + + pub authority: &'b solana_program::account_info::AccountInfo<'a>, + + pub escrow_new: &'b solana_program::account_info::AccountInfo<'a>, + + pub escrow_old: &'b solana_program::account_info::AccountInfo<'a>, + + pub collection: &'b solana_program::account_info::AccountInfo<'a>, + + pub escrow_new_token_account: &'b solana_program::account_info::AccountInfo<'a>, + + pub escrow_old_token_account: &'b solana_program::account_info::AccountInfo<'a>, + + pub token: &'b solana_program::account_info::AccountInfo<'a>, + + pub system_program: &'b solana_program::account_info::AccountInfo<'a>, + + pub token_program: &'b solana_program::account_info::AccountInfo<'a>, + + pub associated_token_program: &'b solana_program::account_info::AccountInfo<'a>, + /// The arguments for the instruction. + pub __args: MigrateTokensV1InstructionArgs, +} + +impl<'a, 'b> MigrateTokensV1Cpi<'a, 'b> { + pub fn new( + program: &'b solana_program::account_info::AccountInfo<'a>, + accounts: MigrateTokensV1CpiAccounts<'a, 'b>, + args: MigrateTokensV1InstructionArgs, + ) -> Self { + Self { + __program: program, + authority: accounts.authority, + escrow_new: accounts.escrow_new, + escrow_old: accounts.escrow_old, + collection: accounts.collection, + escrow_new_token_account: accounts.escrow_new_token_account, + escrow_old_token_account: accounts.escrow_old_token_account, + token: accounts.token, + system_program: accounts.system_program, + token_program: accounts.token_program, + associated_token_program: accounts.associated_token_program, + __args: args, + } + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::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 { + self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) + } + #[inline(always)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) + } + #[allow(clippy::clone_on_copy)] + #[allow(clippy::vec_init_then_push)] + 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 { + let mut accounts = Vec::with_capacity(10 + remaining_accounts.len()); + accounts.push(solana_program::instruction::AccountMeta::new( + *self.authority.key, + true, + )); + accounts.push(solana_program::instruction::AccountMeta::new( + *self.escrow_new.key, + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new( + *self.escrow_old.key, + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new( + *self.collection.key, + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new( + *self.escrow_new_token_account.key, + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new( + *self.escrow_old_token_account.key, + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( + *self.token.key, + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( + *self.system_program.key, + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( + *self.token_program.key, + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( + *self.associated_token_program.key, + false, + )); + remaining_accounts.iter().for_each(|remaining_account| { + accounts.push(solana_program::instruction::AccountMeta { + pubkey: *remaining_account.0.key, + is_signer: remaining_account.1, + is_writable: remaining_account.2, + }) + }); + let mut data = MigrateTokensV1InstructionData::new().try_to_vec().unwrap(); + let mut args = self.__args.try_to_vec().unwrap(); + data.append(&mut args); + + let instruction = solana_program::instruction::Instruction { + program_id: crate::MPL_HYBRID_ID, + accounts, + data, + }; + let mut account_infos = Vec::with_capacity(10 + 1 + remaining_accounts.len()); + account_infos.push(self.__program.clone()); + account_infos.push(self.authority.clone()); + account_infos.push(self.escrow_new.clone()); + account_infos.push(self.escrow_old.clone()); + account_infos.push(self.collection.clone()); + account_infos.push(self.escrow_new_token_account.clone()); + account_infos.push(self.escrow_old_token_account.clone()); + account_infos.push(self.token.clone()); + account_infos.push(self.system_program.clone()); + account_infos.push(self.token_program.clone()); + account_infos.push(self.associated_token_program.clone()); + remaining_accounts + .iter() + .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); + + if signers_seeds.is_empty() { + solana_program::program::invoke(&instruction, &account_infos) + } else { + solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds) + } + } +} + +/// Instruction builder for `MigrateTokensV1` via CPI. +/// +/// ### Accounts: +/// +/// 0. `[writable, signer]` authority +/// 1. `[writable]` escrow_new +/// 2. `[writable]` escrow_old +/// 3. `[writable]` collection +/// 4. `[writable]` escrow_new_token_account +/// 5. `[writable]` escrow_old_token_account +/// 6. `[]` token +/// 7. `[]` system_program +/// 8. `[]` token_program +/// 9. `[]` associated_token_program +pub struct MigrateTokensV1CpiBuilder<'a, 'b> { + instruction: Box>, +} + +impl<'a, 'b> MigrateTokensV1CpiBuilder<'a, 'b> { + pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { + let instruction = Box::new(MigrateTokensV1CpiBuilderInstruction { + __program: program, + authority: None, + escrow_new: None, + escrow_old: None, + collection: None, + escrow_new_token_account: None, + escrow_old_token_account: None, + token: None, + system_program: None, + token_program: None, + associated_token_program: None, + amount: None, + __remaining_accounts: Vec::new(), + }); + Self { instruction } + } + #[inline(always)] + pub fn authority( + &mut self, + authority: &'b solana_program::account_info::AccountInfo<'a>, + ) -> &mut Self { + self.instruction.authority = Some(authority); + self + } + #[inline(always)] + pub fn escrow_new( + &mut self, + escrow_new: &'b solana_program::account_info::AccountInfo<'a>, + ) -> &mut Self { + self.instruction.escrow_new = Some(escrow_new); + self + } + #[inline(always)] + pub fn escrow_old( + &mut self, + escrow_old: &'b solana_program::account_info::AccountInfo<'a>, + ) -> &mut Self { + self.instruction.escrow_old = Some(escrow_old); + self + } + #[inline(always)] + pub fn collection( + &mut self, + collection: &'b solana_program::account_info::AccountInfo<'a>, + ) -> &mut Self { + self.instruction.collection = Some(collection); + self + } + #[inline(always)] + pub fn escrow_new_token_account( + &mut self, + escrow_new_token_account: &'b solana_program::account_info::AccountInfo<'a>, + ) -> &mut Self { + self.instruction.escrow_new_token_account = Some(escrow_new_token_account); + self + } + #[inline(always)] + pub fn escrow_old_token_account( + &mut self, + escrow_old_token_account: &'b solana_program::account_info::AccountInfo<'a>, + ) -> &mut Self { + self.instruction.escrow_old_token_account = Some(escrow_old_token_account); + self + } + #[inline(always)] + pub fn token(&mut self, token: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { + self.instruction.token = Some(token); + self + } + #[inline(always)] + pub fn system_program( + &mut self, + system_program: &'b solana_program::account_info::AccountInfo<'a>, + ) -> &mut Self { + self.instruction.system_program = Some(system_program); + self + } + #[inline(always)] + pub fn token_program( + &mut self, + token_program: &'b solana_program::account_info::AccountInfo<'a>, + ) -> &mut Self { + self.instruction.token_program = Some(token_program); + self + } + #[inline(always)] + pub fn associated_token_program( + &mut self, + associated_token_program: &'b solana_program::account_info::AccountInfo<'a>, + ) -> &mut Self { + self.instruction.associated_token_program = Some(associated_token_program); + self + } + #[inline(always)] + pub fn amount(&mut self, amount: u64) -> &mut Self { + self.instruction.amount = Some(amount); + self + } + /// Add an additional account to the instruction. + #[inline(always)] + pub fn add_remaining_account( + &mut self, + account: &'b solana_program::account_info::AccountInfo<'a>, + is_writable: bool, + is_signer: bool, + ) -> &mut Self { + self.instruction + .__remaining_accounts + .push((account, is_writable, is_signer)); + self + } + /// Add additional accounts to the instruction. + /// + /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, + /// and a `bool` indicating whether the account is a signer or not. + #[inline(always)] + pub fn add_remaining_accounts( + &mut self, + accounts: &[( + &'b solana_program::account_info::AccountInfo<'a>, + bool, + bool, + )], + ) -> &mut Self { + self.instruction + .__remaining_accounts + .extend_from_slice(accounts); + self + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::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 { + let args = MigrateTokensV1InstructionArgs { + amount: self.instruction.amount.clone().expect("amount is not set"), + }; + let instruction = MigrateTokensV1Cpi { + __program: self.instruction.__program, + + authority: self.instruction.authority.expect("authority is not set"), + + escrow_new: self.instruction.escrow_new.expect("escrow_new is not set"), + + escrow_old: self.instruction.escrow_old.expect("escrow_old is not set"), + + collection: self.instruction.collection.expect("collection is not set"), + + escrow_new_token_account: self + .instruction + .escrow_new_token_account + .expect("escrow_new_token_account is not set"), + + escrow_old_token_account: self + .instruction + .escrow_old_token_account + .expect("escrow_old_token_account is not set"), + + token: self.instruction.token.expect("token is not set"), + + system_program: self + .instruction + .system_program + .expect("system_program is not set"), + + token_program: self + .instruction + .token_program + .expect("token_program is not set"), + + associated_token_program: self + .instruction + .associated_token_program + .expect("associated_token_program is not set"), + __args: args, + }; + instruction.invoke_signed_with_remaining_accounts( + signers_seeds, + &self.instruction.__remaining_accounts, + ) + } +} + +struct MigrateTokensV1CpiBuilderInstruction<'a, 'b> { + __program: &'b solana_program::account_info::AccountInfo<'a>, + authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, + escrow_new: Option<&'b solana_program::account_info::AccountInfo<'a>>, + escrow_old: Option<&'b solana_program::account_info::AccountInfo<'a>>, + collection: Option<&'b solana_program::account_info::AccountInfo<'a>>, + escrow_new_token_account: Option<&'b solana_program::account_info::AccountInfo<'a>>, + escrow_old_token_account: Option<&'b solana_program::account_info::AccountInfo<'a>>, + token: Option<&'b solana_program::account_info::AccountInfo<'a>>, + system_program: Option<&'b solana_program::account_info::AccountInfo<'a>>, + token_program: Option<&'b solana_program::account_info::AccountInfo<'a>>, + associated_token_program: Option<&'b solana_program::account_info::AccountInfo<'a>>, + amount: Option, + /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. + __remaining_accounts: Vec<( + &'b solana_program::account_info::AccountInfo<'a>, + bool, + bool, + )>, +} diff --git a/clients/rust/src/generated/instructions/mod.rs b/clients/rust/src/generated/instructions/mod.rs index c54e1ea..900bf20 100644 --- a/clients/rust/src/generated/instructions/mod.rs +++ b/clients/rust/src/generated/instructions/mod.rs @@ -6,15 +6,29 @@ //! pub(crate) mod r#capture_v1; +pub(crate) mod r#capture_v2; pub(crate) mod r#init_escrow_v1; +pub(crate) mod r#init_escrow_v2; pub(crate) mod r#init_nft_data_v1; +pub(crate) mod r#init_recipe; +pub(crate) mod r#migrate_nft_v1; +pub(crate) mod r#migrate_tokens_v1; pub(crate) mod r#release_v1; +pub(crate) mod r#release_v2; pub(crate) mod r#update_escrow_v1; pub(crate) mod r#update_new_data_v1; +pub(crate) mod r#update_recipe_v1; pub use self::r#capture_v1::*; +pub use self::r#capture_v2::*; pub use self::r#init_escrow_v1::*; +pub use self::r#init_escrow_v2::*; pub use self::r#init_nft_data_v1::*; +pub use self::r#init_recipe::*; +pub use self::r#migrate_nft_v1::*; +pub use self::r#migrate_tokens_v1::*; pub use self::r#release_v1::*; +pub use self::r#release_v2::*; pub use self::r#update_escrow_v1::*; pub use self::r#update_new_data_v1::*; +pub use self::r#update_recipe_v1::*; diff --git a/clients/rust/src/generated/instructions/release_v2.rs b/clients/rust/src/generated/instructions/release_v2.rs new file mode 100644 index 0000000..cd9c0a2 --- /dev/null +++ b/clients/rust/src/generated/instructions/release_v2.rs @@ -0,0 +1,929 @@ +//! This code was AUTOGENERATED using the kinobi library. +//! Please DO NOT EDIT THIS FILE, instead use visitors +//! to add features, then rerun kinobi to update it. +//! +//! [https://github.com/metaplex-foundation/kinobi] +//! + +#[cfg(feature = "anchor")] +use anchor_lang::prelude::{AnchorDeserialize, AnchorSerialize}; +#[cfg(not(feature = "anchor"))] +use borsh::{BorshDeserialize, BorshSerialize}; + +/// Accounts. +pub struct ReleaseV2 { + pub owner: solana_program::pubkey::Pubkey, + + pub authority: solana_program::pubkey::Pubkey, + + pub recipe: solana_program::pubkey::Pubkey, + + pub escrow: solana_program::pubkey::Pubkey, + + pub asset: solana_program::pubkey::Pubkey, + + pub collection: solana_program::pubkey::Pubkey, + + pub user_token_account: solana_program::pubkey::Pubkey, + + pub escrow_token_account: solana_program::pubkey::Pubkey, + + pub token: solana_program::pubkey::Pubkey, + + pub fee_token_account: solana_program::pubkey::Pubkey, + + pub fee_sol_account: solana_program::pubkey::Pubkey, + + pub fee_project_account: solana_program::pubkey::Pubkey, + + pub recent_blockhashes: solana_program::pubkey::Pubkey, + + pub mpl_core: solana_program::pubkey::Pubkey, + + pub system_program: solana_program::pubkey::Pubkey, + + pub token_program: solana_program::pubkey::Pubkey, + + pub associated_token_program: solana_program::pubkey::Pubkey, +} + +impl ReleaseV2 { + pub fn instruction(&self) -> solana_program::instruction::Instruction { + self.instruction_with_remaining_accounts(&[]) + } + #[allow(clippy::vec_init_then_push)] + pub fn instruction_with_remaining_accounts( + &self, + remaining_accounts: &[solana_program::instruction::AccountMeta], + ) -> solana_program::instruction::Instruction { + let mut accounts = Vec::with_capacity(17 + remaining_accounts.len()); + accounts.push(solana_program::instruction::AccountMeta::new( + self.owner, true, + )); + accounts.push(solana_program::instruction::AccountMeta::new( + self.authority, + true, + )); + accounts.push(solana_program::instruction::AccountMeta::new( + self.recipe, + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new( + self.escrow, + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new( + self.asset, false, + )); + accounts.push(solana_program::instruction::AccountMeta::new( + self.collection, + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new( + self.user_token_account, + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new( + self.escrow_token_account, + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( + self.token, false, + )); + accounts.push(solana_program::instruction::AccountMeta::new( + self.fee_token_account, + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new( + self.fee_sol_account, + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new( + self.fee_project_account, + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( + self.recent_blockhashes, + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( + self.mpl_core, + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( + self.system_program, + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( + self.token_program, + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( + self.associated_token_program, + false, + )); + accounts.extend_from_slice(remaining_accounts); + let data = ReleaseV2InstructionData::new().try_to_vec().unwrap(); + + solana_program::instruction::Instruction { + program_id: crate::MPL_HYBRID_ID, + accounts, + data, + } + } +} + +#[cfg_attr(not(feature = "anchor"), derive(BorshSerialize, BorshDeserialize))] +#[cfg_attr(feature = "anchor", derive(AnchorSerialize, AnchorDeserialize))] +pub struct ReleaseV2InstructionData { + discriminator: [u8; 8], +} + +impl ReleaseV2InstructionData { + pub fn new() -> Self { + Self { + discriminator: [11, 29, 101, 146, 69, 134, 78, 61], + } + } +} + +/// Instruction builder for `ReleaseV2`. +/// +/// ### Accounts: +/// +/// 0. `[writable, signer]` owner +/// 1. `[writable, signer]` authority +/// 2. `[writable]` recipe +/// 3. `[writable]` escrow +/// 4. `[writable]` asset +/// 5. `[writable]` collection +/// 6. `[writable]` user_token_account +/// 7. `[writable]` escrow_token_account +/// 8. `[]` token +/// 9. `[writable]` fee_token_account +/// 10. `[writable]` fee_sol_account +/// 11. `[writable]` fee_project_account +/// 12. `[]` recent_blockhashes +/// 13. `[]` mpl_core +/// 14. `[optional]` system_program (default to `11111111111111111111111111111111`) +/// 15. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) +/// 16. `[]` associated_token_program +#[derive(Default)] +pub struct ReleaseV2Builder { + owner: Option, + authority: Option, + recipe: Option, + escrow: Option, + asset: Option, + collection: Option, + user_token_account: Option, + escrow_token_account: Option, + token: Option, + fee_token_account: Option, + fee_sol_account: Option, + fee_project_account: Option, + recent_blockhashes: Option, + mpl_core: Option, + system_program: Option, + token_program: Option, + associated_token_program: Option, + __remaining_accounts: Vec, +} + +impl ReleaseV2Builder { + pub fn new() -> Self { + Self::default() + } + #[inline(always)] + pub fn owner(&mut self, owner: solana_program::pubkey::Pubkey) -> &mut Self { + self.owner = Some(owner); + self + } + #[inline(always)] + pub fn authority(&mut self, authority: solana_program::pubkey::Pubkey) -> &mut Self { + self.authority = Some(authority); + self + } + #[inline(always)] + pub fn recipe(&mut self, recipe: solana_program::pubkey::Pubkey) -> &mut Self { + self.recipe = Some(recipe); + self + } + #[inline(always)] + pub fn escrow(&mut self, escrow: solana_program::pubkey::Pubkey) -> &mut Self { + self.escrow = Some(escrow); + self + } + #[inline(always)] + pub fn asset(&mut self, asset: solana_program::pubkey::Pubkey) -> &mut Self { + self.asset = Some(asset); + self + } + #[inline(always)] + pub fn collection(&mut self, collection: solana_program::pubkey::Pubkey) -> &mut Self { + self.collection = Some(collection); + self + } + #[inline(always)] + pub fn user_token_account( + &mut self, + user_token_account: solana_program::pubkey::Pubkey, + ) -> &mut Self { + self.user_token_account = Some(user_token_account); + self + } + #[inline(always)] + pub fn escrow_token_account( + &mut self, + escrow_token_account: solana_program::pubkey::Pubkey, + ) -> &mut Self { + self.escrow_token_account = Some(escrow_token_account); + self + } + #[inline(always)] + pub fn token(&mut self, token: solana_program::pubkey::Pubkey) -> &mut Self { + self.token = Some(token); + self + } + #[inline(always)] + pub fn fee_token_account( + &mut self, + fee_token_account: solana_program::pubkey::Pubkey, + ) -> &mut Self { + self.fee_token_account = Some(fee_token_account); + self + } + #[inline(always)] + pub fn fee_sol_account( + &mut self, + fee_sol_account: solana_program::pubkey::Pubkey, + ) -> &mut Self { + self.fee_sol_account = Some(fee_sol_account); + self + } + #[inline(always)] + pub fn fee_project_account( + &mut self, + fee_project_account: solana_program::pubkey::Pubkey, + ) -> &mut Self { + self.fee_project_account = Some(fee_project_account); + self + } + #[inline(always)] + pub fn recent_blockhashes( + &mut self, + recent_blockhashes: solana_program::pubkey::Pubkey, + ) -> &mut Self { + self.recent_blockhashes = Some(recent_blockhashes); + self + } + #[inline(always)] + pub fn mpl_core(&mut self, mpl_core: solana_program::pubkey::Pubkey) -> &mut Self { + self.mpl_core = Some(mpl_core); + self + } + /// `[optional account, default to '11111111111111111111111111111111']` + #[inline(always)] + pub fn system_program(&mut self, system_program: solana_program::pubkey::Pubkey) -> &mut Self { + self.system_program = Some(system_program); + self + } + /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` + #[inline(always)] + pub fn token_program(&mut self, token_program: solana_program::pubkey::Pubkey) -> &mut Self { + self.token_program = Some(token_program); + self + } + #[inline(always)] + pub fn associated_token_program( + &mut self, + associated_token_program: solana_program::pubkey::Pubkey, + ) -> &mut Self { + self.associated_token_program = Some(associated_token_program); + self + } + /// Add an aditional account to the instruction. + #[inline(always)] + pub fn add_remaining_account( + &mut self, + account: solana_program::instruction::AccountMeta, + ) -> &mut Self { + self.__remaining_accounts.push(account); + self + } + /// Add additional accounts to the instruction. + #[inline(always)] + pub fn add_remaining_accounts( + &mut self, + accounts: &[solana_program::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 { + let accounts = ReleaseV2 { + owner: self.owner.expect("owner is not set"), + authority: self.authority.expect("authority is not set"), + recipe: self.recipe.expect("recipe is not set"), + escrow: self.escrow.expect("escrow is not set"), + asset: self.asset.expect("asset is not set"), + collection: self.collection.expect("collection is not set"), + user_token_account: self + .user_token_account + .expect("user_token_account is not set"), + escrow_token_account: self + .escrow_token_account + .expect("escrow_token_account is not set"), + token: self.token.expect("token is not set"), + fee_token_account: self + .fee_token_account + .expect("fee_token_account is not set"), + fee_sol_account: self.fee_sol_account.expect("fee_sol_account is not set"), + fee_project_account: self + .fee_project_account + .expect("fee_project_account is not set"), + recent_blockhashes: self + .recent_blockhashes + .expect("recent_blockhashes is not set"), + mpl_core: self.mpl_core.expect("mpl_core is not set"), + system_program: self + .system_program + .unwrap_or(solana_program::pubkey!("11111111111111111111111111111111")), + token_program: self.token_program.unwrap_or(solana_program::pubkey!( + "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + )), + associated_token_program: self + .associated_token_program + .expect("associated_token_program is not set"), + }; + + accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) + } +} + +/// `release_v2` CPI accounts. +pub struct ReleaseV2CpiAccounts<'a, 'b> { + pub owner: &'b solana_program::account_info::AccountInfo<'a>, + + pub authority: &'b solana_program::account_info::AccountInfo<'a>, + + pub recipe: &'b solana_program::account_info::AccountInfo<'a>, + + pub escrow: &'b solana_program::account_info::AccountInfo<'a>, + + pub asset: &'b solana_program::account_info::AccountInfo<'a>, + + pub collection: &'b solana_program::account_info::AccountInfo<'a>, + + pub user_token_account: &'b solana_program::account_info::AccountInfo<'a>, + + pub escrow_token_account: &'b solana_program::account_info::AccountInfo<'a>, + + pub token: &'b solana_program::account_info::AccountInfo<'a>, + + pub fee_token_account: &'b solana_program::account_info::AccountInfo<'a>, + + pub fee_sol_account: &'b solana_program::account_info::AccountInfo<'a>, + + pub fee_project_account: &'b solana_program::account_info::AccountInfo<'a>, + + pub recent_blockhashes: &'b solana_program::account_info::AccountInfo<'a>, + + pub mpl_core: &'b solana_program::account_info::AccountInfo<'a>, + + pub system_program: &'b solana_program::account_info::AccountInfo<'a>, + + pub token_program: &'b solana_program::account_info::AccountInfo<'a>, + + pub associated_token_program: &'b solana_program::account_info::AccountInfo<'a>, +} + +/// `release_v2` CPI instruction. +pub struct ReleaseV2Cpi<'a, 'b> { + /// The program to invoke. + pub __program: &'b solana_program::account_info::AccountInfo<'a>, + + pub owner: &'b solana_program::account_info::AccountInfo<'a>, + + pub authority: &'b solana_program::account_info::AccountInfo<'a>, + + pub recipe: &'b solana_program::account_info::AccountInfo<'a>, + + pub escrow: &'b solana_program::account_info::AccountInfo<'a>, + + pub asset: &'b solana_program::account_info::AccountInfo<'a>, + + pub collection: &'b solana_program::account_info::AccountInfo<'a>, + + pub user_token_account: &'b solana_program::account_info::AccountInfo<'a>, + + pub escrow_token_account: &'b solana_program::account_info::AccountInfo<'a>, + + pub token: &'b solana_program::account_info::AccountInfo<'a>, + + pub fee_token_account: &'b solana_program::account_info::AccountInfo<'a>, + + pub fee_sol_account: &'b solana_program::account_info::AccountInfo<'a>, + + pub fee_project_account: &'b solana_program::account_info::AccountInfo<'a>, + + pub recent_blockhashes: &'b solana_program::account_info::AccountInfo<'a>, + + pub mpl_core: &'b solana_program::account_info::AccountInfo<'a>, + + pub system_program: &'b solana_program::account_info::AccountInfo<'a>, + + pub token_program: &'b solana_program::account_info::AccountInfo<'a>, + + pub associated_token_program: &'b solana_program::account_info::AccountInfo<'a>, +} + +impl<'a, 'b> ReleaseV2Cpi<'a, 'b> { + pub fn new( + program: &'b solana_program::account_info::AccountInfo<'a>, + accounts: ReleaseV2CpiAccounts<'a, 'b>, + ) -> Self { + Self { + __program: program, + owner: accounts.owner, + authority: accounts.authority, + recipe: accounts.recipe, + escrow: accounts.escrow, + asset: accounts.asset, + collection: accounts.collection, + user_token_account: accounts.user_token_account, + escrow_token_account: accounts.escrow_token_account, + token: accounts.token, + fee_token_account: accounts.fee_token_account, + fee_sol_account: accounts.fee_sol_account, + fee_project_account: accounts.fee_project_account, + recent_blockhashes: accounts.recent_blockhashes, + mpl_core: accounts.mpl_core, + system_program: accounts.system_program, + token_program: accounts.token_program, + associated_token_program: accounts.associated_token_program, + } + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::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 { + self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) + } + #[inline(always)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) + } + #[allow(clippy::clone_on_copy)] + #[allow(clippy::vec_init_then_push)] + 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 { + let mut accounts = Vec::with_capacity(17 + remaining_accounts.len()); + accounts.push(solana_program::instruction::AccountMeta::new( + *self.owner.key, + true, + )); + accounts.push(solana_program::instruction::AccountMeta::new( + *self.authority.key, + true, + )); + accounts.push(solana_program::instruction::AccountMeta::new( + *self.recipe.key, + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new( + *self.escrow.key, + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new( + *self.asset.key, + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new( + *self.collection.key, + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new( + *self.user_token_account.key, + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new( + *self.escrow_token_account.key, + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( + *self.token.key, + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new( + *self.fee_token_account.key, + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new( + *self.fee_sol_account.key, + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new( + *self.fee_project_account.key, + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( + *self.recent_blockhashes.key, + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( + *self.mpl_core.key, + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( + *self.system_program.key, + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( + *self.token_program.key, + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( + *self.associated_token_program.key, + false, + )); + remaining_accounts.iter().for_each(|remaining_account| { + accounts.push(solana_program::instruction::AccountMeta { + pubkey: *remaining_account.0.key, + is_signer: remaining_account.1, + is_writable: remaining_account.2, + }) + }); + let data = ReleaseV2InstructionData::new().try_to_vec().unwrap(); + + let instruction = solana_program::instruction::Instruction { + program_id: crate::MPL_HYBRID_ID, + accounts, + data, + }; + let mut account_infos = Vec::with_capacity(17 + 1 + remaining_accounts.len()); + account_infos.push(self.__program.clone()); + account_infos.push(self.owner.clone()); + account_infos.push(self.authority.clone()); + account_infos.push(self.recipe.clone()); + account_infos.push(self.escrow.clone()); + account_infos.push(self.asset.clone()); + account_infos.push(self.collection.clone()); + account_infos.push(self.user_token_account.clone()); + account_infos.push(self.escrow_token_account.clone()); + account_infos.push(self.token.clone()); + account_infos.push(self.fee_token_account.clone()); + account_infos.push(self.fee_sol_account.clone()); + account_infos.push(self.fee_project_account.clone()); + account_infos.push(self.recent_blockhashes.clone()); + account_infos.push(self.mpl_core.clone()); + account_infos.push(self.system_program.clone()); + account_infos.push(self.token_program.clone()); + account_infos.push(self.associated_token_program.clone()); + remaining_accounts + .iter() + .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); + + if signers_seeds.is_empty() { + solana_program::program::invoke(&instruction, &account_infos) + } else { + solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds) + } + } +} + +/// Instruction builder for `ReleaseV2` via CPI. +/// +/// ### Accounts: +/// +/// 0. `[writable, signer]` owner +/// 1. `[writable, signer]` authority +/// 2. `[writable]` recipe +/// 3. `[writable]` escrow +/// 4. `[writable]` asset +/// 5. `[writable]` collection +/// 6. `[writable]` user_token_account +/// 7. `[writable]` escrow_token_account +/// 8. `[]` token +/// 9. `[writable]` fee_token_account +/// 10. `[writable]` fee_sol_account +/// 11. `[writable]` fee_project_account +/// 12. `[]` recent_blockhashes +/// 13. `[]` mpl_core +/// 14. `[]` system_program +/// 15. `[]` token_program +/// 16. `[]` associated_token_program +pub struct ReleaseV2CpiBuilder<'a, 'b> { + instruction: Box>, +} + +impl<'a, 'b> ReleaseV2CpiBuilder<'a, 'b> { + pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { + let instruction = Box::new(ReleaseV2CpiBuilderInstruction { + __program: program, + owner: None, + authority: None, + recipe: None, + escrow: None, + asset: None, + collection: None, + user_token_account: None, + escrow_token_account: None, + token: None, + fee_token_account: None, + fee_sol_account: None, + fee_project_account: None, + recent_blockhashes: None, + mpl_core: None, + system_program: None, + token_program: None, + associated_token_program: None, + __remaining_accounts: Vec::new(), + }); + Self { instruction } + } + #[inline(always)] + pub fn owner(&mut self, owner: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { + self.instruction.owner = Some(owner); + self + } + #[inline(always)] + pub fn authority( + &mut self, + authority: &'b solana_program::account_info::AccountInfo<'a>, + ) -> &mut Self { + self.instruction.authority = Some(authority); + self + } + #[inline(always)] + pub fn recipe( + &mut self, + recipe: &'b solana_program::account_info::AccountInfo<'a>, + ) -> &mut Self { + self.instruction.recipe = Some(recipe); + self + } + #[inline(always)] + pub fn escrow( + &mut self, + escrow: &'b solana_program::account_info::AccountInfo<'a>, + ) -> &mut Self { + self.instruction.escrow = Some(escrow); + self + } + #[inline(always)] + pub fn asset(&mut self, asset: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { + self.instruction.asset = Some(asset); + self + } + #[inline(always)] + pub fn collection( + &mut self, + collection: &'b solana_program::account_info::AccountInfo<'a>, + ) -> &mut Self { + self.instruction.collection = Some(collection); + self + } + #[inline(always)] + pub fn user_token_account( + &mut self, + user_token_account: &'b solana_program::account_info::AccountInfo<'a>, + ) -> &mut Self { + self.instruction.user_token_account = Some(user_token_account); + self + } + #[inline(always)] + pub fn escrow_token_account( + &mut self, + escrow_token_account: &'b solana_program::account_info::AccountInfo<'a>, + ) -> &mut Self { + self.instruction.escrow_token_account = Some(escrow_token_account); + self + } + #[inline(always)] + pub fn token(&mut self, token: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { + self.instruction.token = Some(token); + self + } + #[inline(always)] + pub fn fee_token_account( + &mut self, + fee_token_account: &'b solana_program::account_info::AccountInfo<'a>, + ) -> &mut Self { + self.instruction.fee_token_account = Some(fee_token_account); + self + } + #[inline(always)] + pub fn fee_sol_account( + &mut self, + fee_sol_account: &'b solana_program::account_info::AccountInfo<'a>, + ) -> &mut Self { + self.instruction.fee_sol_account = Some(fee_sol_account); + self + } + #[inline(always)] + pub fn fee_project_account( + &mut self, + fee_project_account: &'b solana_program::account_info::AccountInfo<'a>, + ) -> &mut Self { + self.instruction.fee_project_account = Some(fee_project_account); + self + } + #[inline(always)] + pub fn recent_blockhashes( + &mut self, + recent_blockhashes: &'b solana_program::account_info::AccountInfo<'a>, + ) -> &mut Self { + self.instruction.recent_blockhashes = Some(recent_blockhashes); + self + } + #[inline(always)] + pub fn mpl_core( + &mut self, + mpl_core: &'b solana_program::account_info::AccountInfo<'a>, + ) -> &mut Self { + self.instruction.mpl_core = Some(mpl_core); + self + } + #[inline(always)] + pub fn system_program( + &mut self, + system_program: &'b solana_program::account_info::AccountInfo<'a>, + ) -> &mut Self { + self.instruction.system_program = Some(system_program); + self + } + #[inline(always)] + pub fn token_program( + &mut self, + token_program: &'b solana_program::account_info::AccountInfo<'a>, + ) -> &mut Self { + self.instruction.token_program = Some(token_program); + self + } + #[inline(always)] + pub fn associated_token_program( + &mut self, + associated_token_program: &'b solana_program::account_info::AccountInfo<'a>, + ) -> &mut Self { + self.instruction.associated_token_program = Some(associated_token_program); + self + } + /// Add an additional account to the instruction. + #[inline(always)] + pub fn add_remaining_account( + &mut self, + account: &'b solana_program::account_info::AccountInfo<'a>, + is_writable: bool, + is_signer: bool, + ) -> &mut Self { + self.instruction + .__remaining_accounts + .push((account, is_writable, is_signer)); + self + } + /// Add additional accounts to the instruction. + /// + /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, + /// and a `bool` indicating whether the account is a signer or not. + #[inline(always)] + pub fn add_remaining_accounts( + &mut self, + accounts: &[( + &'b solana_program::account_info::AccountInfo<'a>, + bool, + bool, + )], + ) -> &mut Self { + self.instruction + .__remaining_accounts + .extend_from_slice(accounts); + self + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::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 { + let instruction = ReleaseV2Cpi { + __program: self.instruction.__program, + + owner: self.instruction.owner.expect("owner is not set"), + + authority: self.instruction.authority.expect("authority is not set"), + + recipe: self.instruction.recipe.expect("recipe is not set"), + + escrow: self.instruction.escrow.expect("escrow is not set"), + + asset: self.instruction.asset.expect("asset is not set"), + + collection: self.instruction.collection.expect("collection is not set"), + + user_token_account: self + .instruction + .user_token_account + .expect("user_token_account is not set"), + + escrow_token_account: self + .instruction + .escrow_token_account + .expect("escrow_token_account is not set"), + + token: self.instruction.token.expect("token is not set"), + + fee_token_account: self + .instruction + .fee_token_account + .expect("fee_token_account is not set"), + + fee_sol_account: self + .instruction + .fee_sol_account + .expect("fee_sol_account is not set"), + + fee_project_account: self + .instruction + .fee_project_account + .expect("fee_project_account is not set"), + + recent_blockhashes: self + .instruction + .recent_blockhashes + .expect("recent_blockhashes is not set"), + + mpl_core: self.instruction.mpl_core.expect("mpl_core is not set"), + + system_program: self + .instruction + .system_program + .expect("system_program is not set"), + + token_program: self + .instruction + .token_program + .expect("token_program is not set"), + + associated_token_program: self + .instruction + .associated_token_program + .expect("associated_token_program is not set"), + }; + instruction.invoke_signed_with_remaining_accounts( + signers_seeds, + &self.instruction.__remaining_accounts, + ) + } +} + +struct ReleaseV2CpiBuilderInstruction<'a, 'b> { + __program: &'b solana_program::account_info::AccountInfo<'a>, + owner: Option<&'b solana_program::account_info::AccountInfo<'a>>, + authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, + recipe: Option<&'b solana_program::account_info::AccountInfo<'a>>, + escrow: Option<&'b solana_program::account_info::AccountInfo<'a>>, + asset: Option<&'b solana_program::account_info::AccountInfo<'a>>, + collection: Option<&'b solana_program::account_info::AccountInfo<'a>>, + user_token_account: Option<&'b solana_program::account_info::AccountInfo<'a>>, + escrow_token_account: Option<&'b solana_program::account_info::AccountInfo<'a>>, + token: Option<&'b solana_program::account_info::AccountInfo<'a>>, + fee_token_account: Option<&'b solana_program::account_info::AccountInfo<'a>>, + fee_sol_account: Option<&'b solana_program::account_info::AccountInfo<'a>>, + fee_project_account: Option<&'b solana_program::account_info::AccountInfo<'a>>, + recent_blockhashes: Option<&'b solana_program::account_info::AccountInfo<'a>>, + mpl_core: Option<&'b solana_program::account_info::AccountInfo<'a>>, + system_program: Option<&'b solana_program::account_info::AccountInfo<'a>>, + token_program: Option<&'b solana_program::account_info::AccountInfo<'a>>, + associated_token_program: Option<&'b solana_program::account_info::AccountInfo<'a>>, + /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. + __remaining_accounts: Vec<( + &'b solana_program::account_info::AccountInfo<'a>, + bool, + bool, + )>, +} diff --git a/clients/rust/src/generated/instructions/update_recipe_v1.rs b/clients/rust/src/generated/instructions/update_recipe_v1.rs new file mode 100644 index 0000000..cf31785 --- /dev/null +++ b/clients/rust/src/generated/instructions/update_recipe_v1.rs @@ -0,0 +1,677 @@ +//! This code was AUTOGENERATED using the kinobi library. +//! Please DO NOT EDIT THIS FILE, instead use visitors +//! to add features, then rerun kinobi to update it. +//! +//! [https://github.com/metaplex-foundation/kinobi] +//! + +#[cfg(feature = "anchor")] +use anchor_lang::prelude::{AnchorDeserialize, AnchorSerialize}; +#[cfg(not(feature = "anchor"))] +use borsh::{BorshDeserialize, BorshSerialize}; + +/// Accounts. +pub struct UpdateRecipeV1 { + pub recipe: solana_program::pubkey::Pubkey, + + pub authority: solana_program::pubkey::Pubkey, + + pub collection: solana_program::pubkey::Pubkey, + + pub token: solana_program::pubkey::Pubkey, + + pub fee_location: solana_program::pubkey::Pubkey, + + pub system_program: solana_program::pubkey::Pubkey, +} + +impl UpdateRecipeV1 { + pub fn instruction( + &self, + args: UpdateRecipeV1InstructionArgs, + ) -> solana_program::instruction::Instruction { + self.instruction_with_remaining_accounts(args, &[]) + } + #[allow(clippy::vec_init_then_push)] + pub fn instruction_with_remaining_accounts( + &self, + args: UpdateRecipeV1InstructionArgs, + remaining_accounts: &[solana_program::instruction::AccountMeta], + ) -> solana_program::instruction::Instruction { + let mut accounts = Vec::with_capacity(6 + remaining_accounts.len()); + accounts.push(solana_program::instruction::AccountMeta::new( + self.recipe, + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new( + self.authority, + true, + )); + accounts.push(solana_program::instruction::AccountMeta::new( + self.collection, + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( + self.token, false, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( + self.fee_location, + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( + self.system_program, + false, + )); + accounts.extend_from_slice(remaining_accounts); + let mut data = UpdateRecipeV1InstructionData::new().try_to_vec().unwrap(); + let mut args = args.try_to_vec().unwrap(); + data.append(&mut args); + + solana_program::instruction::Instruction { + program_id: crate::MPL_HYBRID_ID, + accounts, + data, + } + } +} + +#[cfg_attr(not(feature = "anchor"), derive(BorshSerialize, BorshDeserialize))] +#[cfg_attr(feature = "anchor", derive(AnchorSerialize, AnchorDeserialize))] +pub struct UpdateRecipeV1InstructionData { + discriminator: [u8; 8], +} + +impl UpdateRecipeV1InstructionData { + pub fn new() -> Self { + Self { + discriminator: [252, 71, 211, 219, 86, 136, 251, 238], + } + } +} + +#[cfg_attr(not(feature = "anchor"), derive(BorshSerialize, BorshDeserialize))] +#[cfg_attr(feature = "anchor", derive(AnchorSerialize, AnchorDeserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[derive(Clone, Debug, Eq, PartialEq)] +pub struct UpdateRecipeV1InstructionArgs { + pub name: Option, + pub uri: Option, + pub max: Option, + pub min: Option, + pub amount: Option, + pub fee_amount_capture: Option, + pub fee_amount_release: Option, + pub sol_fee_amount_capture: Option, + pub sol_fee_amount_release: Option, + pub path: Option, +} + +/// Instruction builder for `UpdateRecipeV1`. +/// +/// ### Accounts: +/// +/// 0. `[writable]` recipe +/// 1. `[writable, signer]` authority +/// 2. `[writable]` collection +/// 3. `[]` token +/// 4. `[]` fee_location +/// 5. `[optional]` system_program (default to `11111111111111111111111111111111`) +#[derive(Default)] +pub struct UpdateRecipeV1Builder { + recipe: Option, + authority: Option, + collection: Option, + token: Option, + fee_location: Option, + system_program: Option, + name: Option, + uri: Option, + max: Option, + min: Option, + amount: Option, + fee_amount_capture: Option, + fee_amount_release: Option, + sol_fee_amount_capture: Option, + sol_fee_amount_release: Option, + path: Option, + __remaining_accounts: Vec, +} + +impl UpdateRecipeV1Builder { + pub fn new() -> Self { + Self::default() + } + #[inline(always)] + pub fn recipe(&mut self, recipe: solana_program::pubkey::Pubkey) -> &mut Self { + self.recipe = Some(recipe); + self + } + #[inline(always)] + pub fn authority(&mut self, authority: solana_program::pubkey::Pubkey) -> &mut Self { + self.authority = Some(authority); + self + } + #[inline(always)] + pub fn collection(&mut self, collection: solana_program::pubkey::Pubkey) -> &mut Self { + self.collection = Some(collection); + self + } + #[inline(always)] + pub fn token(&mut self, token: solana_program::pubkey::Pubkey) -> &mut Self { + self.token = Some(token); + self + } + #[inline(always)] + pub fn fee_location(&mut self, fee_location: solana_program::pubkey::Pubkey) -> &mut Self { + self.fee_location = Some(fee_location); + self + } + /// `[optional account, default to '11111111111111111111111111111111']` + #[inline(always)] + pub fn system_program(&mut self, system_program: solana_program::pubkey::Pubkey) -> &mut Self { + self.system_program = Some(system_program); + self + } + /// `[optional argument]` + #[inline(always)] + pub fn name(&mut self, name: String) -> &mut Self { + self.name = Some(name); + self + } + /// `[optional argument]` + #[inline(always)] + pub fn uri(&mut self, uri: String) -> &mut Self { + self.uri = Some(uri); + self + } + /// `[optional argument]` + #[inline(always)] + pub fn max(&mut self, max: u64) -> &mut Self { + self.max = Some(max); + self + } + /// `[optional argument]` + #[inline(always)] + pub fn min(&mut self, min: u64) -> &mut Self { + self.min = Some(min); + self + } + /// `[optional argument]` + #[inline(always)] + pub fn amount(&mut self, amount: u64) -> &mut Self { + self.amount = Some(amount); + self + } + /// `[optional argument]` + #[inline(always)] + pub fn fee_amount_capture(&mut self, fee_amount_capture: u64) -> &mut Self { + self.fee_amount_capture = Some(fee_amount_capture); + self + } + /// `[optional argument]` + #[inline(always)] + pub fn fee_amount_release(&mut self, fee_amount_release: u64) -> &mut Self { + self.fee_amount_release = Some(fee_amount_release); + self + } + /// `[optional argument]` + #[inline(always)] + pub fn sol_fee_amount_capture(&mut self, sol_fee_amount_capture: u64) -> &mut Self { + self.sol_fee_amount_capture = Some(sol_fee_amount_capture); + self + } + /// `[optional argument]` + #[inline(always)] + pub fn sol_fee_amount_release(&mut self, sol_fee_amount_release: u64) -> &mut Self { + self.sol_fee_amount_release = Some(sol_fee_amount_release); + self + } + /// `[optional argument]` + #[inline(always)] + pub fn path(&mut self, path: u16) -> &mut Self { + self.path = Some(path); + self + } + /// Add an aditional account to the instruction. + #[inline(always)] + pub fn add_remaining_account( + &mut self, + account: solana_program::instruction::AccountMeta, + ) -> &mut Self { + self.__remaining_accounts.push(account); + self + } + /// Add additional accounts to the instruction. + #[inline(always)] + pub fn add_remaining_accounts( + &mut self, + accounts: &[solana_program::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 { + let accounts = UpdateRecipeV1 { + recipe: self.recipe.expect("recipe is not set"), + authority: self.authority.expect("authority is not set"), + collection: self.collection.expect("collection is not set"), + token: self.token.expect("token is not set"), + fee_location: self.fee_location.expect("fee_location is not set"), + system_program: self + .system_program + .unwrap_or(solana_program::pubkey!("11111111111111111111111111111111")), + }; + let args = UpdateRecipeV1InstructionArgs { + name: self.name.clone(), + uri: self.uri.clone(), + max: self.max.clone(), + min: self.min.clone(), + amount: self.amount.clone(), + fee_amount_capture: self.fee_amount_capture.clone(), + fee_amount_release: self.fee_amount_release.clone(), + sol_fee_amount_capture: self.sol_fee_amount_capture.clone(), + sol_fee_amount_release: self.sol_fee_amount_release.clone(), + path: self.path.clone(), + }; + + accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) + } +} + +/// `update_recipe_v1` CPI accounts. +pub struct UpdateRecipeV1CpiAccounts<'a, 'b> { + pub recipe: &'b solana_program::account_info::AccountInfo<'a>, + + pub authority: &'b solana_program::account_info::AccountInfo<'a>, + + pub collection: &'b solana_program::account_info::AccountInfo<'a>, + + pub token: &'b solana_program::account_info::AccountInfo<'a>, + + pub fee_location: &'b solana_program::account_info::AccountInfo<'a>, + + pub system_program: &'b solana_program::account_info::AccountInfo<'a>, +} + +/// `update_recipe_v1` CPI instruction. +pub struct UpdateRecipeV1Cpi<'a, 'b> { + /// The program to invoke. + pub __program: &'b solana_program::account_info::AccountInfo<'a>, + + pub recipe: &'b solana_program::account_info::AccountInfo<'a>, + + pub authority: &'b solana_program::account_info::AccountInfo<'a>, + + pub collection: &'b solana_program::account_info::AccountInfo<'a>, + + pub token: &'b solana_program::account_info::AccountInfo<'a>, + + pub fee_location: &'b solana_program::account_info::AccountInfo<'a>, + + pub system_program: &'b solana_program::account_info::AccountInfo<'a>, + /// The arguments for the instruction. + pub __args: UpdateRecipeV1InstructionArgs, +} + +impl<'a, 'b> UpdateRecipeV1Cpi<'a, 'b> { + pub fn new( + program: &'b solana_program::account_info::AccountInfo<'a>, + accounts: UpdateRecipeV1CpiAccounts<'a, 'b>, + args: UpdateRecipeV1InstructionArgs, + ) -> Self { + Self { + __program: program, + recipe: accounts.recipe, + authority: accounts.authority, + collection: accounts.collection, + token: accounts.token, + fee_location: accounts.fee_location, + system_program: accounts.system_program, + __args: args, + } + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::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 { + self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) + } + #[inline(always)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) + } + #[allow(clippy::clone_on_copy)] + #[allow(clippy::vec_init_then_push)] + 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 { + let mut accounts = Vec::with_capacity(6 + remaining_accounts.len()); + accounts.push(solana_program::instruction::AccountMeta::new( + *self.recipe.key, + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new( + *self.authority.key, + true, + )); + accounts.push(solana_program::instruction::AccountMeta::new( + *self.collection.key, + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( + *self.token.key, + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( + *self.fee_location.key, + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( + *self.system_program.key, + false, + )); + remaining_accounts.iter().for_each(|remaining_account| { + accounts.push(solana_program::instruction::AccountMeta { + pubkey: *remaining_account.0.key, + is_signer: remaining_account.1, + is_writable: remaining_account.2, + }) + }); + let mut data = UpdateRecipeV1InstructionData::new().try_to_vec().unwrap(); + let mut args = self.__args.try_to_vec().unwrap(); + data.append(&mut args); + + let instruction = solana_program::instruction::Instruction { + program_id: crate::MPL_HYBRID_ID, + accounts, + data, + }; + let mut account_infos = Vec::with_capacity(6 + 1 + remaining_accounts.len()); + account_infos.push(self.__program.clone()); + account_infos.push(self.recipe.clone()); + account_infos.push(self.authority.clone()); + account_infos.push(self.collection.clone()); + account_infos.push(self.token.clone()); + account_infos.push(self.fee_location.clone()); + account_infos.push(self.system_program.clone()); + remaining_accounts + .iter() + .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); + + if signers_seeds.is_empty() { + solana_program::program::invoke(&instruction, &account_infos) + } else { + solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds) + } + } +} + +/// Instruction builder for `UpdateRecipeV1` via CPI. +/// +/// ### Accounts: +/// +/// 0. `[writable]` recipe +/// 1. `[writable, signer]` authority +/// 2. `[writable]` collection +/// 3. `[]` token +/// 4. `[]` fee_location +/// 5. `[]` system_program +pub struct UpdateRecipeV1CpiBuilder<'a, 'b> { + instruction: Box>, +} + +impl<'a, 'b> UpdateRecipeV1CpiBuilder<'a, 'b> { + pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { + let instruction = Box::new(UpdateRecipeV1CpiBuilderInstruction { + __program: program, + recipe: None, + authority: None, + collection: None, + token: None, + fee_location: None, + system_program: None, + name: None, + uri: None, + max: None, + min: None, + amount: None, + fee_amount_capture: None, + fee_amount_release: None, + sol_fee_amount_capture: None, + sol_fee_amount_release: None, + path: None, + __remaining_accounts: Vec::new(), + }); + Self { instruction } + } + #[inline(always)] + pub fn recipe( + &mut self, + recipe: &'b solana_program::account_info::AccountInfo<'a>, + ) -> &mut Self { + self.instruction.recipe = Some(recipe); + self + } + #[inline(always)] + pub fn authority( + &mut self, + authority: &'b solana_program::account_info::AccountInfo<'a>, + ) -> &mut Self { + self.instruction.authority = Some(authority); + self + } + #[inline(always)] + pub fn collection( + &mut self, + collection: &'b solana_program::account_info::AccountInfo<'a>, + ) -> &mut Self { + self.instruction.collection = Some(collection); + self + } + #[inline(always)] + pub fn token(&mut self, token: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { + self.instruction.token = Some(token); + self + } + #[inline(always)] + pub fn fee_location( + &mut self, + fee_location: &'b solana_program::account_info::AccountInfo<'a>, + ) -> &mut Self { + self.instruction.fee_location = Some(fee_location); + self + } + #[inline(always)] + pub fn system_program( + &mut self, + system_program: &'b solana_program::account_info::AccountInfo<'a>, + ) -> &mut Self { + self.instruction.system_program = Some(system_program); + self + } + /// `[optional argument]` + #[inline(always)] + pub fn name(&mut self, name: String) -> &mut Self { + self.instruction.name = Some(name); + self + } + /// `[optional argument]` + #[inline(always)] + pub fn uri(&mut self, uri: String) -> &mut Self { + self.instruction.uri = Some(uri); + self + } + /// `[optional argument]` + #[inline(always)] + pub fn max(&mut self, max: u64) -> &mut Self { + self.instruction.max = Some(max); + self + } + /// `[optional argument]` + #[inline(always)] + pub fn min(&mut self, min: u64) -> &mut Self { + self.instruction.min = Some(min); + self + } + /// `[optional argument]` + #[inline(always)] + pub fn amount(&mut self, amount: u64) -> &mut Self { + self.instruction.amount = Some(amount); + self + } + /// `[optional argument]` + #[inline(always)] + pub fn fee_amount_capture(&mut self, fee_amount_capture: u64) -> &mut Self { + self.instruction.fee_amount_capture = Some(fee_amount_capture); + self + } + /// `[optional argument]` + #[inline(always)] + pub fn fee_amount_release(&mut self, fee_amount_release: u64) -> &mut Self { + self.instruction.fee_amount_release = Some(fee_amount_release); + self + } + /// `[optional argument]` + #[inline(always)] + pub fn sol_fee_amount_capture(&mut self, sol_fee_amount_capture: u64) -> &mut Self { + self.instruction.sol_fee_amount_capture = Some(sol_fee_amount_capture); + self + } + /// `[optional argument]` + #[inline(always)] + pub fn sol_fee_amount_release(&mut self, sol_fee_amount_release: u64) -> &mut Self { + self.instruction.sol_fee_amount_release = Some(sol_fee_amount_release); + self + } + /// `[optional argument]` + #[inline(always)] + pub fn path(&mut self, path: u16) -> &mut Self { + self.instruction.path = Some(path); + self + } + /// Add an additional account to the instruction. + #[inline(always)] + pub fn add_remaining_account( + &mut self, + account: &'b solana_program::account_info::AccountInfo<'a>, + is_writable: bool, + is_signer: bool, + ) -> &mut Self { + self.instruction + .__remaining_accounts + .push((account, is_writable, is_signer)); + self + } + /// Add additional accounts to the instruction. + /// + /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, + /// and a `bool` indicating whether the account is a signer or not. + #[inline(always)] + pub fn add_remaining_accounts( + &mut self, + accounts: &[( + &'b solana_program::account_info::AccountInfo<'a>, + bool, + bool, + )], + ) -> &mut Self { + self.instruction + .__remaining_accounts + .extend_from_slice(accounts); + self + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::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 { + let args = UpdateRecipeV1InstructionArgs { + name: self.instruction.name.clone(), + uri: self.instruction.uri.clone(), + max: self.instruction.max.clone(), + min: self.instruction.min.clone(), + amount: self.instruction.amount.clone(), + fee_amount_capture: self.instruction.fee_amount_capture.clone(), + fee_amount_release: self.instruction.fee_amount_release.clone(), + sol_fee_amount_capture: self.instruction.sol_fee_amount_capture.clone(), + sol_fee_amount_release: self.instruction.sol_fee_amount_release.clone(), + path: self.instruction.path.clone(), + }; + let instruction = UpdateRecipeV1Cpi { + __program: self.instruction.__program, + + recipe: self.instruction.recipe.expect("recipe is not set"), + + authority: self.instruction.authority.expect("authority is not set"), + + collection: self.instruction.collection.expect("collection is not set"), + + token: self.instruction.token.expect("token is not set"), + + fee_location: self + .instruction + .fee_location + .expect("fee_location is not set"), + + system_program: self + .instruction + .system_program + .expect("system_program is not set"), + __args: args, + }; + instruction.invoke_signed_with_remaining_accounts( + signers_seeds, + &self.instruction.__remaining_accounts, + ) + } +} + +struct UpdateRecipeV1CpiBuilderInstruction<'a, 'b> { + __program: &'b solana_program::account_info::AccountInfo<'a>, + recipe: Option<&'b solana_program::account_info::AccountInfo<'a>>, + authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, + collection: Option<&'b solana_program::account_info::AccountInfo<'a>>, + token: Option<&'b solana_program::account_info::AccountInfo<'a>>, + fee_location: Option<&'b solana_program::account_info::AccountInfo<'a>>, + system_program: Option<&'b solana_program::account_info::AccountInfo<'a>>, + name: Option, + uri: Option, + max: Option, + min: Option, + amount: Option, + fee_amount_capture: Option, + fee_amount_release: Option, + sol_fee_amount_capture: Option, + sol_fee_amount_release: Option, + path: Option, + /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. + __remaining_accounts: Vec<( + &'b solana_program::account_info::AccountInfo<'a>, + bool, + bool, + )>, +} diff --git a/configs/shank.cjs b/configs/shank.cjs index cc24d2b..05ad88d 100644 --- a/configs/shank.cjs +++ b/configs/shank.cjs @@ -5,12 +5,28 @@ const idlDir = path.join(__dirname, "..", "idls"); const binaryInstallDir = path.join(__dirname, "..", ".crates"); const programDir = path.join(__dirname, "..", "programs"); +// This IDL hook sets the authority account as a signer because Anchor does not support the concept of optional signers. +// This is overridden in the Kinobi config file by setting signer to optional so it remains optional in the generated clients. +let idlHook = (idl) => { + for (const instruction of idl.instructions) { + if (instruction.name === "captureV1" || instruction.name === "releaseV1" || instruction.name === "captureV2" || instruction.name === "releaseV2") { + for (const account of instruction.accounts) { + if (account.name === "authority") { + account.isSigner = true; + } + } + } + } + return idl; +}; + generateIdl({ generator: "anchor", programName: "mpl_hybrid", programId: "MPL4o4wMzndgh8T1NVDxELQCj5UQfYTYEkabX3wNKtb", idlDir, idlName: "mpl_hybrid", + idlHook, binaryInstallDir, programDir: path.join(programDir, "mpl-hybrid"), rustbin: { diff --git a/idls/mpl_hybrid.json b/idls/mpl_hybrid.json index 01c60b2..5c6a45e 100644 --- a/idls/mpl_hybrid.json +++ b/idls/mpl_hybrid.json @@ -2,6 +2,67 @@ "version": "0.0.1", "name": "mpl_hybrid", "instructions": [ + { + "name": "initRecipe", + "accounts": [ + { + "name": "recipe", + "isMut": true, + "isSigner": false + }, + { + "name": "authority", + "isMut": true, + "isSigner": true + }, + { + "name": "collection", + "isMut": false, + "isSigner": false + }, + { + "name": "token", + "isMut": false, + "isSigner": false + }, + { + "name": "feeLocation", + "isMut": false, + "isSigner": false + }, + { + "name": "feeAta", + "isMut": true, + "isSigner": false, + "docs": [ + "The ATA for token fees to be stored" + ] + }, + { + "name": "systemProgram", + "isMut": false, + "isSigner": false + }, + { + "name": "tokenProgram", + "isMut": false, + "isSigner": false + }, + { + "name": "associatedTokenProgram", + "isMut": false, + "isSigner": false + } + ], + "args": [ + { + "name": "ix", + "type": { + "defined": "InitRecipeV1Ix" + } + } + ] + }, { "name": "initEscrowV1", "accounts": [ @@ -63,6 +124,27 @@ } ] }, + { + "name": "initEscrowV2", + "accounts": [ + { + "name": "escrow", + "isMut": true, + "isSigner": false + }, + { + "name": "authority", + "isMut": true, + "isSigner": true + }, + { + "name": "systemProgram", + "isMut": false, + "isSigner": false + } + ], + "args": [] + }, { "name": "initNftDataV1", "accounts": [ @@ -122,6 +204,97 @@ { "name": "authority", "isMut": true, + "isSigner": true + }, + { + "name": "escrow", + "isMut": true, + "isSigner": false + }, + { + "name": "asset", + "isMut": true, + "isSigner": false + }, + { + "name": "collection", + "isMut": true, + "isSigner": false + }, + { + "name": "userTokenAccount", + "isMut": true, + "isSigner": false + }, + { + "name": "escrowTokenAccount", + "isMut": true, + "isSigner": false + }, + { + "name": "token", + "isMut": false, + "isSigner": false + }, + { + "name": "feeTokenAccount", + "isMut": true, + "isSigner": false + }, + { + "name": "feeSolAccount", + "isMut": true, + "isSigner": false + }, + { + "name": "feeProjectAccount", + "isMut": true, + "isSigner": false + }, + { + "name": "recentBlockhashes", + "isMut": false, + "isSigner": false + }, + { + "name": "mplCore", + "isMut": false, + "isSigner": false + }, + { + "name": "systemProgram", + "isMut": false, + "isSigner": false + }, + { + "name": "tokenProgram", + "isMut": false, + "isSigner": false + }, + { + "name": "associatedTokenProgram", + "isMut": false, + "isSigner": false + } + ], + "args": [] + }, + { + "name": "captureV2", + "accounts": [ + { + "name": "owner", + "isMut": true, + "isSigner": true + }, + { + "name": "authority", + "isMut": true, + "isSigner": true + }, + { + "name": "recipe", + "isMut": true, "isSigner": false }, { @@ -208,6 +381,97 @@ { "name": "authority", "isMut": true, + "isSigner": true + }, + { + "name": "escrow", + "isMut": true, + "isSigner": false + }, + { + "name": "asset", + "isMut": true, + "isSigner": false + }, + { + "name": "collection", + "isMut": true, + "isSigner": false + }, + { + "name": "userTokenAccount", + "isMut": true, + "isSigner": false + }, + { + "name": "escrowTokenAccount", + "isMut": true, + "isSigner": false + }, + { + "name": "token", + "isMut": false, + "isSigner": false + }, + { + "name": "feeTokenAccount", + "isMut": true, + "isSigner": false + }, + { + "name": "feeSolAccount", + "isMut": true, + "isSigner": false + }, + { + "name": "feeProjectAccount", + "isMut": true, + "isSigner": false + }, + { + "name": "recentBlockhashes", + "isMut": false, + "isSigner": false + }, + { + "name": "mplCore", + "isMut": false, + "isSigner": false + }, + { + "name": "systemProgram", + "isMut": false, + "isSigner": false + }, + { + "name": "tokenProgram", + "isMut": false, + "isSigner": false + }, + { + "name": "associatedTokenProgram", + "isMut": false, + "isSigner": false + } + ], + "args": [] + }, + { + "name": "releaseV2", + "accounts": [ + { + "name": "owner", + "isMut": true, + "isSigner": true + }, + { + "name": "authority", + "isMut": true, + "isSigner": true + }, + { + "name": "recipe", + "isMut": true, "isSigner": false }, { @@ -283,31 +547,170 @@ ], "args": [] }, + { + "name": "updateRecipeV1", + "accounts": [ + { + "name": "recipe", + "isMut": true, + "isSigner": false + }, + { + "name": "authority", + "isMut": true, + "isSigner": true + }, + { + "name": "collection", + "isMut": true, + "isSigner": false + }, + { + "name": "token", + "isMut": false, + "isSigner": false + }, + { + "name": "feeLocation", + "isMut": false, + "isSigner": false + }, + { + "name": "systemProgram", + "isMut": false, + "isSigner": false + } + ], + "args": [ + { + "name": "ix", + "type": { + "defined": "UpdateRecipeV1Ix" + } + } + ] + }, { "name": "updateEscrowV1", "accounts": [ { - "name": "escrow", + "name": "escrow", + "isMut": true, + "isSigner": false + }, + { + "name": "authority", + "isMut": true, + "isSigner": true + }, + { + "name": "collection", + "isMut": true, + "isSigner": false + }, + { + "name": "token", + "isMut": false, + "isSigner": false + }, + { + "name": "feeLocation", + "isMut": false, + "isSigner": false + }, + { + "name": "systemProgram", + "isMut": false, + "isSigner": false + } + ], + "args": [ + { + "name": "ix", + "type": { + "defined": "UpdateEscrowV1Ix" + } + } + ] + }, + { + "name": "updateNewDataV1", + "accounts": [ + { + "name": "nftData", + "isMut": true, + "isSigner": false + }, + { + "name": "authority", + "isMut": true, + "isSigner": true + }, + { + "name": "collection", + "isMut": false, + "isSigner": false + }, + { + "name": "asset", + "isMut": false, + "isSigner": false + }, + { + "name": "token", + "isMut": false, + "isSigner": false + }, + { + "name": "feeLocation", + "isMut": false, + "isSigner": false + }, + { + "name": "systemProgram", + "isMut": false, + "isSigner": false + } + ], + "args": [ + { + "name": "ix", + "type": { + "defined": "UpdateNftDataV1Ix" + } + } + ] + }, + { + "name": "migrateNftV1", + "accounts": [ + { + "name": "authority", + "isMut": true, + "isSigner": true + }, + { + "name": "escrowNew", "isMut": true, "isSigner": false }, { - "name": "authority", + "name": "escrowOld", "isMut": true, - "isSigner": true + "isSigner": false }, { - "name": "collection", + "name": "asset", "isMut": true, "isSigner": false }, { - "name": "token", - "isMut": false, + "name": "collection", + "isMut": true, "isSigner": false }, { - "name": "feeLocation", + "name": "mplCore", "isMut": false, "isSigner": false }, @@ -317,36 +720,39 @@ "isSigner": false } ], - "args": [ - { - "name": "ix", - "type": { - "defined": "UpdateEscrowV1Ix" - } - } - ] + "args": [] }, { - "name": "updateNewDataV1", + "name": "migrateTokensV1", "accounts": [ { - "name": "nftData", + "name": "authority", + "isMut": true, + "isSigner": true + }, + { + "name": "escrowNew", "isMut": true, "isSigner": false }, { - "name": "authority", + "name": "escrowOld", "isMut": true, - "isSigner": true + "isSigner": false }, { "name": "collection", - "isMut": false, + "isMut": true, "isSigner": false }, { - "name": "asset", - "isMut": false, + "name": "escrowNewTokenAccount", + "isMut": true, + "isSigner": false + }, + { + "name": "escrowOldTokenAccount", + "isMut": true, "isSigner": false }, { @@ -355,12 +761,17 @@ "isSigner": false }, { - "name": "feeLocation", + "name": "systemProgram", "isMut": false, "isSigner": false }, { - "name": "systemProgram", + "name": "tokenProgram", + "isMut": false, + "isSigner": false + }, + { + "name": "associatedTokenProgram", "isMut": false, "isSigner": false } @@ -369,13 +780,29 @@ { "name": "ix", "type": { - "defined": "UpdateNftDataV1Ix" + "defined": "MigrateTokensV1Ix" } } ] } ], "accounts": [ + { + "name": "EscrowV2", + "type": { + "kind": "struct", + "fields": [ + { + "name": "authority", + "type": "publicKey" + }, + { + "name": "bump", + "type": "u8" + } + ] + } + }, { "name": "EscrowV1", "type": { @@ -499,6 +926,78 @@ } ] } + }, + { + "name": "RecipeV1", + "type": { + "kind": "struct", + "fields": [ + { + "name": "collection", + "type": "publicKey" + }, + { + "name": "authority", + "type": "publicKey" + }, + { + "name": "token", + "type": "publicKey" + }, + { + "name": "feeLocation", + "type": "publicKey" + }, + { + "name": "name", + "type": "string" + }, + { + "name": "uri", + "type": "string" + }, + { + "name": "max", + "type": "u64" + }, + { + "name": "min", + "type": "u64" + }, + { + "name": "amount", + "type": "u64" + }, + { + "name": "feeAmountCapture", + "type": "u64" + }, + { + "name": "solFeeAmountCapture", + "type": "u64" + }, + { + "name": "feeAmountRelease", + "type": "u64" + }, + { + "name": "solFeeAmountRelease", + "type": "u64" + }, + { + "name": "count", + "type": "u64" + }, + { + "name": "path", + "type": "u16" + }, + { + "name": "bump", + "type": "u8" + } + ] + } } ], "types": [ @@ -582,6 +1081,66 @@ ] } }, + { + "name": "InitRecipeV1Ix", + "type": { + "kind": "struct", + "fields": [ + { + "name": "name", + "type": "string" + }, + { + "name": "uri", + "type": "string" + }, + { + "name": "max", + "type": "u64" + }, + { + "name": "min", + "type": "u64" + }, + { + "name": "amount", + "type": "u64" + }, + { + "name": "feeAmountCapture", + "type": "u64" + }, + { + "name": "feeAmountRelease", + "type": "u64" + }, + { + "name": "solFeeAmountCapture", + "type": "u64" + }, + { + "name": "solFeeAmountRelease", + "type": "u64" + }, + { + "name": "path", + "type": "u16" + } + ] + } + }, + { + "name": "MigrateTokensV1Ix", + "type": { + "kind": "struct", + "fields": [ + { + "name": "amount", + "type": "u64" + } + ] + } + }, { "name": "UpdateEscrowV1Ix", "type": { @@ -694,6 +1253,74 @@ ] } }, + { + "name": "UpdateRecipeV1Ix", + "type": { + "kind": "struct", + "fields": [ + { + "name": "name", + "type": { + "option": "string" + } + }, + { + "name": "uri", + "type": { + "option": "string" + } + }, + { + "name": "max", + "type": { + "option": "u64" + } + }, + { + "name": "min", + "type": { + "option": "u64" + } + }, + { + "name": "amount", + "type": { + "option": "u64" + } + }, + { + "name": "feeAmountCapture", + "type": { + "option": "u64" + } + }, + { + "name": "feeAmountRelease", + "type": { + "option": "u64" + } + }, + { + "name": "solFeeAmountCapture", + "type": { + "option": "u64" + } + }, + { + "name": "solFeeAmountRelease", + "type": { + "option": "u64" + } + }, + { + "name": "path", + "type": { + "option": "u16" + } + } + ] + } + }, { "name": "Path", "type": { @@ -786,6 +1413,11 @@ "code": 6015, "name": "InvalidTokenAccountMint", "msg": "Invalid Token Account Mint" + }, + { + "code": 6016, + "name": "InvalidAuthority", + "msg": "Invalid Authorities" } ], "metadata": { diff --git a/programs/mpl-hybrid/src/instructions/capture.rs b/programs/mpl-hybrid/src/instructions/capture.rs index feb7d7b..31f23ec 100644 --- a/programs/mpl-hybrid/src/instructions/capture.rs +++ b/programs/mpl-hybrid/src/instructions/capture.rs @@ -174,7 +174,7 @@ pub fn handler_capture_v1(ctx: Context) -> Result<()> { let seed = u64::from_le_bytes(*most_recent) .saturating_sub(clock.unix_timestamp as u64) - .wrapping_mul(escrow.count as u64); + .wrapping_mul(escrow.count); // remainder is the random number between the min and max let remainder = seed diff --git a/programs/mpl-hybrid/src/instructions/capture_v2.rs b/programs/mpl-hybrid/src/instructions/capture_v2.rs index ba1c10d..a8d90bd 100644 --- a/programs/mpl-hybrid/src/instructions/capture_v2.rs +++ b/programs/mpl-hybrid/src/instructions/capture_v2.rs @@ -127,7 +127,6 @@ pub fn handler_capture_v2(ctx: Context) -> Result<()> { let escrow_info = &escrow.to_account_info(); let system_info = &system_program.to_account_info(); - if recipe.authority != escrow.authority { return Err(MplHybridError::InvalidAuthority.into()); } @@ -190,7 +189,7 @@ pub fn handler_capture_v2(ctx: Context) -> Result<()> { let seed = u64::from_le_bytes(*most_recent) .saturating_sub(clock.unix_timestamp as u64) - .wrapping_mul(recipe.count as u64); + .wrapping_mul(recipe.count); // remainder is the random number between the min and max let remainder = seed diff --git a/programs/mpl-hybrid/src/instructions/release_v2.rs b/programs/mpl-hybrid/src/instructions/release_v2.rs index e0c1b4d..9e28f11 100644 --- a/programs/mpl-hybrid/src/instructions/release_v2.rs +++ b/programs/mpl-hybrid/src/instructions/release_v2.rs @@ -131,7 +131,7 @@ pub fn handler_release_v2(ctx: Context) -> Result<()> { if recipe.authority != escrow.authority { return Err(MplHybridError::InvalidAuthority.into()); } - + // Create idempotent if user_token_account.owner == &system_program::ID { solana_program::msg!("Creating user token account"); @@ -268,16 +268,15 @@ pub fn handler_release_v2(ctx: Context) -> Result<()> { &[owner.to_account_info(), fee_sol_account.to_account_info()], )?; - //create transfer fee token instruction let cpi_accounts_fee_transfer = Transfer { from: user_token_account.to_account_info(), to: fee_token_account.to_account_info(), authority: owner.to_account_info(), }; - + let transfer_fees_cpi_ctx = CpiContext::new(cpi_program.clone(), cpi_accounts_fee_transfer); - + token::transfer(transfer_fees_cpi_ctx, recipe.fee_amount_release)?; //create project transfer fee sol instruction for project