From fe1ff22525db9a685b5052fb2deb33d4a8c0c0fa Mon Sep 17 00:00:00 2001 From: Nhan Phan Date: Thu, 11 Apr 2024 14:08:19 -0700 Subject: [PATCH] remove unneeded versions --- clients/js/src/constants.ts | 1 - clients/js/src/create.ts | 8 +- ...andyMachineV2.ts => createCandyMachine.ts} | 14 +- .../js/src/generated/accounts/candyMachine.ts | 19 +-- .../js/src/generated/instructions/index.ts | 4 +- ...MachineV2.ts => initializeCandyMachine.ts} | 42 +++--- .../instructions/{mintV2.ts => mintV1.ts} | 34 ++--- .../{setCollectionV2.ts => setCollection.ts} | 35 ++--- .../js/src/generated/types/accountVersion.ts | 26 ---- .../types/candyMachineAccountData.ts | 8 -- clients/js/src/generated/types/index.ts | 1 - clients/js/src/index.ts | 4 +- clients/js/src/{mintV2.ts => mintV1.ts} | 24 ++-- clients/js/test/_setup.ts | 2 +- clients/js/test/createCandyMachineV2.test.ts | 16 +-- .../js/test/createLutForCandyMachine.test.ts | 4 +- .../js/test/defaultGuards/addressGate.test.ts | 8 +- .../js/test/defaultGuards/allocation.test.ts | 16 +-- .../js/test/defaultGuards/allowList.test.ts | 12 +- clients/js/test/defaultGuards/botTax.test.ts | 6 +- clients/js/test/defaultGuards/endDate.test.ts | 8 +- .../defaultGuards/freezeSolPayment.test.ts | 20 +-- .../defaultGuards/freezeTokenPayment.test.ts | 20 +-- .../js/test/defaultGuards/gatekeeper.test.ts | 18 +-- .../js/test/defaultGuards/mintLimit.test.ts | 18 +-- clients/js/test/defaultGuards/nftBurn.test.ts | 12 +- clients/js/test/defaultGuards/nftGate.test.ts | 16 +-- .../test/defaultGuards/nftMintLimit.test.ts | 26 ++-- .../js/test/defaultGuards/nftPayment.test.ts | 16 +-- .../js/test/defaultGuards/programGate.test.ts | 10 +- .../test/defaultGuards/redeemedAmount.test.ts | 12 +- .../js/test/defaultGuards/solFixedFee.test.ts | 8 +- .../js/test/defaultGuards/solPayment.test.ts | 8 +- .../js/test/defaultGuards/startDate.test.ts | 8 +- .../defaultGuards/thirdPartySigner.test.ts | 8 +- .../defaultGuards/token2022Payment.test.ts | 4 +- .../js/test/defaultGuards/tokenBurn.test.ts | 12 +- .../js/test/defaultGuards/tokenGate.test.ts | 14 +- .../test/defaultGuards/tokenPayment.test.ts | 10 +- clients/js/test/edition.test.ts | 14 +- .../js/test/initializeCandyMachineV2.test.ts | 10 +- .../test/{mintV2.test.ts => mintV1.test.ts} | 30 ++--- ...ectionV2.test.ts => setCollection.test.ts} | 8 +- configs/kinobi.cjs | 12 +- idls/candy_guard.json | 2 +- idls/candy_machine_core.json | 30 +---- .../program/src/guards/nft_burn.rs | 59 ++++----- .../program/src/guards/nft_payment.rs | 121 ++++++------------ .../instructions/{mint_v2.rs => mint_v1.rs} | 6 +- .../program/src/instructions/mod.rs | 4 +- programs/candy-guard/program/src/lib.rs | 6 +- .../program/src/constants.rs | 1 - .../{initialize_v2.rs => initialize.rs} | 7 +- .../program/src/instructions/mod.rs | 8 +- ...set_collection_v2.rs => set_collection.rs} | 4 +- .../candy-machine-core/program/src/lib.rs | 8 +- .../program/src/state/candy_machine.rs | 10 -- 57 files changed, 362 insertions(+), 510 deletions(-) rename clients/js/src/{createCandyMachineV2.ts => createCandyMachine.ts} (71%) rename clients/js/src/generated/instructions/{initializeCandyMachineV2.ts => initializeCandyMachine.ts} (84%) rename clients/js/src/generated/instructions/{mintV2.ts => mintV1.ts} (88%) rename clients/js/src/generated/instructions/{setCollectionV2.ts => setCollection.ts} (85%) delete mode 100644 clients/js/src/generated/types/accountVersion.ts rename clients/js/src/{mintV2.ts => mintV1.ts} (75%) rename clients/js/test/{mintV2.test.ts => mintV1.test.ts} (97%) rename clients/js/test/{setCollectionV2.test.ts => setCollection.test.ts} (97%) rename programs/candy-guard/program/src/instructions/{mint_v2.rs => mint_v1.rs} (98%) rename programs/candy-machine-core/program/src/instructions/{initialize_v2.rs => initialize.rs} (94%) rename programs/candy-machine-core/program/src/instructions/{set_collection_v2.rs => set_collection.rs} (97%) diff --git a/clients/js/src/constants.ts b/clients/js/src/constants.ts index 25d86b7..52857b8 100644 --- a/clients/js/src/constants.ts +++ b/clients/js/src/constants.ts @@ -7,7 +7,6 @@ export const CONFIG_LINE_SIZE = 4 + MAX_NAME_LENGTH + 4 + MAX_URI_LENGTH; export const CANDY_MACHINE_HIDDEN_SECTION = 8 + // discriminator - 1 + // version 32 + // authority 32 + // mint authority 32 + // collection mint diff --git a/clients/js/src/create.ts b/clients/js/src/create.ts index 46572ee..056cacf 100644 --- a/clients/js/src/create.ts +++ b/clients/js/src/create.ts @@ -6,18 +6,18 @@ import { createCandyGuard, CreateCandyGuardInstructionDataArgs, } from './createCandyGuard'; -import { createCandyMachineV2 } from './createCandyMachineV2'; +import { createCandyMachine } from './createCandyMachine'; import { DefaultGuardSetArgs } from './defaultGuards'; import { wrap } from './generated'; import { GuardRepository, GuardSetArgs } from './guards'; import { findCandyGuardPda } from './hooked'; export type CreateInput = - Parameters[1] & + Parameters[1] & CreateCandyGuardInstructionDataArgs; export const create = async ( - context: Parameters[0] & { + context: Parameters[0] & { coreGuards: GuardRepository; }, input: CreateInput @@ -27,7 +27,7 @@ export const create = async ( base: input.candyMachine.publicKey, }); return transactionBuilder() - .add(await createCandyMachineV2(context, rest)) + .add(await createCandyMachine(context, rest)) .add( createCandyGuard(context, { base: input.candyMachine, diff --git a/clients/js/src/createCandyMachineV2.ts b/clients/js/src/createCandyMachine.ts similarity index 71% rename from clients/js/src/createCandyMachineV2.ts rename to clients/js/src/createCandyMachine.ts index 0ed1ce1..a25aca2 100644 --- a/clients/js/src/createCandyMachineV2.ts +++ b/clients/js/src/createCandyMachine.ts @@ -6,20 +6,20 @@ import { transactionBuilder, TransactionBuilder, } from '@metaplex-foundation/umi'; -import { initializeCandyMachineV2 } from './generated'; +import { initializeCandyMachine } from './generated'; import { getCandyMachineSize } from './hooked'; -export type CreateCandyMachineV2Input = Omit< - Parameters[1], +export type CreateCandyMachineInput = Omit< + Parameters[1], 'candyMachine' > & { candyMachine: Signer; }; -export const createCandyMachineV2 = async ( - context: Parameters[0] & +export const createCandyMachine = async ( + context: Parameters[0] & Pick, - input: CreateCandyMachineV2Input + input: CreateCandyMachineInput ): Promise => { const space = getCandyMachineSize( input.itemsAvailable, @@ -37,7 +37,7 @@ export const createCandyMachineV2 = async ( }) ) .add( - initializeCandyMachineV2(context, { + initializeCandyMachine(context, { ...input, candyMachine: input.candyMachine.publicKey, }) diff --git a/clients/js/src/generated/accounts/candyMachine.ts b/clients/js/src/generated/accounts/candyMachine.ts index b123e20..f04b0e0 100644 --- a/clients/js/src/generated/accounts/candyMachine.ts +++ b/clients/js/src/generated/accounts/candyMachine.ts @@ -29,12 +29,7 @@ import { CandyMachineAccountData, getCandyMachineAccountDataSerializer, } from '../../hooked'; -import { - AccountVersionArgs, - CandyMachineDataArgs, - getAccountVersionSerializer, - getCandyMachineDataSerializer, -} from '../types'; +import { CandyMachineDataArgs, getCandyMachineDataSerializer } from '../types'; /** Candy machine state and config data. */ export type CandyMachine = Account; @@ -107,7 +102,6 @@ export function getCandyMachineGpaBuilder( return gpaBuilder(context, programId) .registerFields<{ discriminator: Array; - version: AccountVersionArgs; authority: PublicKey; mintAuthority: PublicKey; collectionMint: PublicKey; @@ -115,12 +109,11 @@ export function getCandyMachineGpaBuilder( data: CandyMachineDataArgs; }>({ discriminator: [0, array(u8(), { size: 8 })], - version: [8, getAccountVersionSerializer()], - authority: [9, publicKeySerializer()], - mintAuthority: [41, publicKeySerializer()], - collectionMint: [73, publicKeySerializer()], - itemsRedeemed: [105, u64()], - data: [113, getCandyMachineDataSerializer()], + authority: [8, publicKeySerializer()], + mintAuthority: [40, publicKeySerializer()], + collectionMint: [72, publicKeySerializer()], + itemsRedeemed: [104, u64()], + data: [112, getCandyMachineDataSerializer()], }) .deserializeUsing((account) => deserializeCandyMachine(account) diff --git a/clients/js/src/generated/instructions/index.ts b/clients/js/src/generated/instructions/index.ts index 0a02e56..4c3f0a6 100644 --- a/clients/js/src/generated/instructions/index.ts +++ b/clients/js/src/generated/instructions/index.ts @@ -9,11 +9,11 @@ export * from './addConfigLines'; export * from './deleteCandyGuard'; export * from './deleteCandyMachine'; -export * from './initializeCandyMachineV2'; +export * from './initializeCandyMachine'; export * from './mintAssetFromCandyMachine'; export * from './setCandyGuardAuthority'; export * from './setCandyMachineAuthority'; -export * from './setCollectionV2'; +export * from './setCollection'; export * from './setMintAuthority'; export * from './unwrap'; export * from './updateCandyMachine'; diff --git a/clients/js/src/generated/instructions/initializeCandyMachineV2.ts b/clients/js/src/generated/instructions/initializeCandyMachine.ts similarity index 84% rename from clients/js/src/generated/instructions/initializeCandyMachineV2.ts rename to clients/js/src/generated/instructions/initializeCandyMachine.ts index 5f7b03f..025d9e8 100644 --- a/clients/js/src/generated/instructions/initializeCandyMachineV2.ts +++ b/clients/js/src/generated/instructions/initializeCandyMachine.ts @@ -45,7 +45,7 @@ import { } from '../types'; // Accounts. -export type InitializeCandyMachineV2InstructionAccounts = { +export type InitializeCandyMachineInstructionAccounts = { /** * Candy Machine account. The account space must be allocated to allow accounts larger * than 10kb. @@ -96,7 +96,7 @@ export type InitializeCandyMachineV2InstructionAccounts = { }; // Data. -export type InitializeCandyMachineV2InstructionData = { +export type InitializeCandyMachineInstructionData = { discriminator: Array; /** Number of assets available */ itemsAvailable: bigint; @@ -110,7 +110,7 @@ export type InitializeCandyMachineV2InstructionData = { hiddenSettings: Option; }; -export type InitializeCandyMachineV2InstructionDataArgs = { +export type InitializeCandyMachineInstructionDataArgs = { /** Number of assets available */ itemsAvailable: number | bigint; /** Max supply of each individual asset (default 0) */ @@ -123,16 +123,16 @@ export type InitializeCandyMachineV2InstructionDataArgs = { hiddenSettings?: OptionOrNullable; }; -export function getInitializeCandyMachineV2InstructionDataSerializer(): Serializer< - InitializeCandyMachineV2InstructionDataArgs, - InitializeCandyMachineV2InstructionData +export function getInitializeCandyMachineInstructionDataSerializer(): Serializer< + InitializeCandyMachineInstructionDataArgs, + InitializeCandyMachineInstructionData > { return mapSerializer< - InitializeCandyMachineV2InstructionDataArgs, + InitializeCandyMachineInstructionDataArgs, any, - InitializeCandyMachineV2InstructionData + InitializeCandyMachineInstructionData >( - struct( + struct( [ ['discriminator', array(u8(), { size: 8 })], ['itemsAvailable', u64()], @@ -141,31 +141,31 @@ export function getInitializeCandyMachineV2InstructionDataSerializer(): Serializ ['configLineSettings', option(getConfigLineSettingsSerializer())], ['hiddenSettings', option(getHiddenSettingsSerializer())], ], - { description: 'InitializeCandyMachineV2InstructionData' } + { description: 'InitializeCandyMachineInstructionData' } ), (value) => ({ ...value, - discriminator: [67, 153, 175, 39, 218, 16, 38, 32], + discriminator: [175, 175, 109, 31, 13, 152, 155, 237], maxEditionSupply: value.maxEditionSupply ?? 0, isMutable: value.isMutable ?? true, configLineSettings: value.configLineSettings ?? none(), hiddenSettings: value.hiddenSettings ?? none(), }) ) as Serializer< - InitializeCandyMachineV2InstructionDataArgs, - InitializeCandyMachineV2InstructionData + InitializeCandyMachineInstructionDataArgs, + InitializeCandyMachineInstructionData >; } // Args. -export type InitializeCandyMachineV2InstructionArgs = - InitializeCandyMachineV2InstructionDataArgs; +export type InitializeCandyMachineInstructionArgs = + InitializeCandyMachineInstructionDataArgs; // Instruction. -export function initializeCandyMachineV2( +export function initializeCandyMachine( context: Pick, - input: InitializeCandyMachineV2InstructionAccounts & - InitializeCandyMachineV2InstructionArgs + input: InitializeCandyMachineInstructionAccounts & + InitializeCandyMachineInstructionArgs ): TransactionBuilder { // Program ID. const programId = context.programs.getPublicKey( @@ -211,7 +211,7 @@ export function initializeCandyMachineV2( }; // Arguments. - const resolvedArgs: InitializeCandyMachineV2InstructionArgs = { ...input }; + const resolvedArgs: InitializeCandyMachineInstructionArgs = { ...input }; // Default values. if (!resolvedAccounts.authorityPda.value) { @@ -259,8 +259,8 @@ export function initializeCandyMachineV2( ); // Data. - const data = getInitializeCandyMachineV2InstructionDataSerializer().serialize( - resolvedArgs as InitializeCandyMachineV2InstructionDataArgs + const data = getInitializeCandyMachineInstructionDataSerializer().serialize( + resolvedArgs as InitializeCandyMachineInstructionDataArgs ); // Bytes Created On Chain. diff --git a/clients/js/src/generated/instructions/mintV2.ts b/clients/js/src/generated/instructions/mintV1.ts similarity index 88% rename from clients/js/src/generated/instructions/mintV2.ts rename to clients/js/src/generated/instructions/mintV1.ts index 7ab6c8f..f3736b3 100644 --- a/clients/js/src/generated/instructions/mintV2.ts +++ b/clients/js/src/generated/instructions/mintV1.ts @@ -37,7 +37,7 @@ import { } from '../shared'; // Accounts. -export type MintV2InstructionAccounts = { +export type MintV1InstructionAccounts = { /** Candy Guard account. */ candyGuard?: PublicKey | Pda; /** @@ -104,44 +104,44 @@ export type MintV2InstructionAccounts = { }; // Data. -export type MintV2InstructionData = { +export type MintV1InstructionData = { discriminator: Array; mintArgs: Uint8Array; group: Option; }; -export type MintV2InstructionDataArgs = { +export type MintV1InstructionDataArgs = { mintArgs: Uint8Array; group: OptionOrNullable; }; -export function getMintV2InstructionDataSerializer(): Serializer< - MintV2InstructionDataArgs, - MintV2InstructionData +export function getMintV1InstructionDataSerializer(): Serializer< + MintV1InstructionDataArgs, + MintV1InstructionData > { - return mapSerializer( - struct( + return mapSerializer( + struct( [ ['discriminator', array(u8(), { size: 8 })], ['mintArgs', bytes({ size: u32() })], ['group', option(string())], ], - { description: 'MintV2InstructionData' } + { description: 'MintV1InstructionData' } ), (value) => ({ ...value, - discriminator: [120, 121, 23, 146, 173, 110, 199, 205], + discriminator: [145, 98, 192, 118, 184, 147, 118, 104], }) - ) as Serializer; + ) as Serializer; } // Args. -export type MintV2InstructionArgs = MintV2InstructionDataArgs; +export type MintV1InstructionArgs = MintV1InstructionDataArgs; // Instruction. -export function mintV2( +export function mintV1( context: Pick, - input: MintV2InstructionAccounts & MintV2InstructionArgs + input: MintV1InstructionAccounts & MintV1InstructionArgs ): TransactionBuilder { // Program ID. const programId = context.programs.getPublicKey( @@ -199,7 +199,7 @@ export function mintV2( }; // Arguments. - const resolvedArgs: MintV2InstructionArgs = { ...input }; + const resolvedArgs: MintV1InstructionArgs = { ...input }; // Default values. if (!resolvedAccounts.candyGuard.value) { @@ -264,8 +264,8 @@ export function mintV2( ); // Data. - const data = getMintV2InstructionDataSerializer().serialize( - resolvedArgs as MintV2InstructionDataArgs + const data = getMintV1InstructionDataSerializer().serialize( + resolvedArgs as MintV1InstructionDataArgs ); // Bytes Created On Chain. diff --git a/clients/js/src/generated/instructions/setCollectionV2.ts b/clients/js/src/generated/instructions/setCollection.ts similarity index 85% rename from clients/js/src/generated/instructions/setCollectionV2.ts rename to clients/js/src/generated/instructions/setCollection.ts index 935e3de..bf37555 100644 --- a/clients/js/src/generated/instructions/setCollectionV2.ts +++ b/clients/js/src/generated/instructions/setCollection.ts @@ -31,7 +31,7 @@ import { } from '../shared'; // Accounts. -export type SetCollectionV2InstructionAccounts = { +export type SetCollectionInstructionAccounts = { /** Candy Machine account. */ candyMachine: PublicKey | Pda; /** Candy Machine authority. */ @@ -81,34 +81,37 @@ export type SetCollectionV2InstructionAccounts = { }; // Data. -export type SetCollectionV2InstructionData = { discriminator: Array }; +export type SetCollectionInstructionData = { discriminator: Array }; -export type SetCollectionV2InstructionDataArgs = {}; +export type SetCollectionInstructionDataArgs = {}; -export function getSetCollectionV2InstructionDataSerializer(): Serializer< - SetCollectionV2InstructionDataArgs, - SetCollectionV2InstructionData +export function getSetCollectionInstructionDataSerializer(): Serializer< + SetCollectionInstructionDataArgs, + SetCollectionInstructionData > { return mapSerializer< - SetCollectionV2InstructionDataArgs, + SetCollectionInstructionDataArgs, any, - SetCollectionV2InstructionData + SetCollectionInstructionData >( - struct( + struct( [['discriminator', array(u8(), { size: 8 })]], - { description: 'SetCollectionV2InstructionData' } + { description: 'SetCollectionInstructionData' } ), - (value) => ({ ...value, discriminator: [229, 35, 61, 91, 15, 14, 99, 160] }) + (value) => ({ + ...value, + discriminator: [192, 254, 206, 76, 168, 182, 59, 223], + }) ) as Serializer< - SetCollectionV2InstructionDataArgs, - SetCollectionV2InstructionData + SetCollectionInstructionDataArgs, + SetCollectionInstructionData >; } // Instruction. -export function setCollectionV2( +export function setCollection( context: Pick, - input: SetCollectionV2InstructionAccounts + input: SetCollectionInstructionAccounts ): TransactionBuilder { // Program ID. const programId = context.programs.getPublicKey( @@ -209,7 +212,7 @@ export function setCollectionV2( ); // Data. - const data = getSetCollectionV2InstructionDataSerializer().serialize({}); + const data = getSetCollectionInstructionDataSerializer().serialize({}); // Bytes Created On Chain. const bytesCreatedOnChain = 0; diff --git a/clients/js/src/generated/types/accountVersion.ts b/clients/js/src/generated/types/accountVersion.ts deleted file mode 100644 index 5046ca4..0000000 --- a/clients/js/src/generated/types/accountVersion.ts +++ /dev/null @@ -1,26 +0,0 @@ -/** - * 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 { Serializer, scalarEnum } from '@metaplex-foundation/umi/serializers'; - -/** Account versioning. */ -export enum AccountVersion { - V1, - V2, -} - -export type AccountVersionArgs = AccountVersion; - -export function getAccountVersionSerializer(): Serializer< - AccountVersionArgs, - AccountVersion -> { - return scalarEnum(AccountVersion, { - description: 'AccountVersion', - }) as Serializer; -} diff --git a/clients/js/src/generated/types/candyMachineAccountData.ts b/clients/js/src/generated/types/candyMachineAccountData.ts index 24bf53c..c2090ab 100644 --- a/clients/js/src/generated/types/candyMachineAccountData.ts +++ b/clients/js/src/generated/types/candyMachineAccountData.ts @@ -17,19 +17,14 @@ import { u8, } from '@metaplex-foundation/umi/serializers'; import { - AccountVersion, - AccountVersionArgs, CandyMachineData, CandyMachineDataArgs, - getAccountVersionSerializer, getCandyMachineDataSerializer, } from '.'; /** Candy machine state and config data. */ export type CandyMachineAccountData = { discriminator: Array; - /** Version of the account. */ - version: AccountVersion; /** Authority address. */ authority: PublicKey; /** Authority address allowed to mint from the candy machine. */ @@ -43,8 +38,6 @@ export type CandyMachineAccountData = { }; export type CandyMachineAccountDataArgs = { - /** Version of the account. */ - version: AccountVersionArgs; /** Authority address. */ authority: PublicKey; /** Authority address allowed to mint from the candy machine. */ @@ -69,7 +62,6 @@ export function getCandyMachineAccountDataSerializer(): Serializer< struct( [ ['discriminator', array(u8(), { size: 8 })], - ['version', getAccountVersionSerializer()], ['authority', publicKeySerializer()], ['mintAuthority', publicKeySerializer()], ['collectionMint', publicKeySerializer()], diff --git a/clients/js/src/generated/types/index.ts b/clients/js/src/generated/types/index.ts index 953ee71..a68ed2e 100644 --- a/clients/js/src/generated/types/index.ts +++ b/clients/js/src/generated/types/index.ts @@ -6,7 +6,6 @@ * @see https://github.com/metaplex-foundation/kinobi */ -export * from './accountVersion'; export * from './addressGate'; export * from './allocation'; export * from './allowList'; diff --git a/clients/js/src/index.ts b/clients/js/src/index.ts index ff29410..41f4fe4 100644 --- a/clients/js/src/index.ts +++ b/clients/js/src/index.ts @@ -7,11 +7,11 @@ export * from './programs'; export * from './constants'; export * from './create'; export * from './createCandyGuard'; -export * from './createCandyMachineV2'; +export * from './createCandyMachine'; export * from './createLutForCandyMachine'; export * from './errors'; export * from './merkle'; -export * from './mintV2'; +export * from './mintV1'; export * from './plugin'; export * from './route'; export * from './updateCandyGuard'; diff --git a/clients/js/src/mintV2.ts b/clients/js/src/mintV1.ts similarity index 75% rename from clients/js/src/mintV2.ts rename to clients/js/src/mintV1.ts index 5d54cc4..d43cb5d 100644 --- a/clients/js/src/mintV2.ts +++ b/clients/js/src/mintV1.ts @@ -8,9 +8,9 @@ import { } from '@metaplex-foundation/umi'; import { DefaultGuardSetMintArgs } from './defaultGuards'; import { - MintV2InstructionAccounts, - mintV2 as baseMintV2, -} from './generated/instructions/mintV2'; + MintV1InstructionAccounts, + mintV1 as baseMintV1, +} from './generated/instructions/mintV1'; import { CandyGuardProgram, GuardRepository, @@ -21,7 +21,7 @@ import { } from './guards'; import { findCandyGuardPda } from './hooked'; -export { MintV2InstructionAccounts }; +export { MintV1InstructionAccounts }; export type MintV2InstructionData = { discriminator: Array; @@ -34,11 +34,11 @@ export type MintV2InstructionDataArgs = { group?: OptionOrNullable; }; -export function mintV2( - context: Parameters[0] & { +export function mintV1( + context: Parameters[0] & { coreGuards: GuardRepository; }, - input: MintV2InstructionAccounts & + input: MintV1InstructionAccounts & MintV2InstructionDataArgs< MA extends undefined ? DefaultGuardSetMintArgs : MA > @@ -62,7 +62,7 @@ export function mintV2( MA extends undefined ? DefaultGuardSetMintArgs : MA >(context, program, mintContext, mintArgs); - const ix = baseMintV2(context, { + const ix = baseMintV1(context, { ...rest, mintArgs: data, group, @@ -71,14 +71,6 @@ export function mintV2( const [keys, signers] = parseGuardRemainingAccounts(remainingAccounts); ix.instruction.keys.push(...keys); ix.signers.push(...signers); - // TODO fix size calculation - // ix.bytesCreatedOnChain = - // METADATA_SIZE + MASTER_EDITION_SIZE + 2 * ACCOUNT_HEADER_SIZE; - - // if (isSigner(input.asset)) { - // ix.bytesCreatedOnChain += - // getMintSize() + getTokenSize() + 2 * ACCOUNT_HEADER_SIZE; - // } return transactionBuilder([ix]); } diff --git a/clients/js/test/_setup.ts b/clients/js/test/_setup.ts index 0926d46..a130102 100644 --- a/clients/js/test/_setup.ts +++ b/clients/js/test/_setup.ts @@ -44,7 +44,7 @@ import { GuardSetArgs, addConfigLines, createCandyGuard as baseCreateCandyGuard, - createCandyMachineV2 as baseCreateCandyMachineV2, + createCandyMachine as baseCreateCandyMachineV2, findCandyGuardPda, mplCandyMachine, wrap, diff --git a/clients/js/test/createCandyMachineV2.test.ts b/clients/js/test/createCandyMachineV2.test.ts index ba14ae0..99e960d 100644 --- a/clients/js/test/createCandyMachineV2.test.ts +++ b/clients/js/test/createCandyMachineV2.test.ts @@ -7,9 +7,8 @@ import { } from '@metaplex-foundation/umi'; import test from 'ava'; import { - AccountVersion, CandyMachine, - createCandyMachineV2, + createCandyMachine, fetchCandyMachine, } from '../src'; import { createCollection, createUmi, defaultCandyMachineData } from './_setup'; @@ -23,7 +22,7 @@ test('it can create a candy machine using config line settings', async (t) => { const candyMachine = generateSigner(umi); await transactionBuilder() .add( - await createCandyMachineV2(umi, { + await createCandyMachine(umi, { candyMachine, collection: collection.publicKey, collectionUpdateAuthority: umi.identity, @@ -49,7 +48,6 @@ test('it can create a candy machine using config line settings', async (t) => { authority: publicKey(umi.identity), mintAuthority: publicKey(umi.identity), collectionMint: publicKey(collection), - version: AccountVersion.V2, itemsRedeemed: 0n, data: { itemsAvailable: 100n, @@ -76,7 +74,7 @@ test('it can create a candy machine using hidden settings', async (t) => { const candyMachine = generateSigner(umi); await transactionBuilder() .add( - await createCandyMachineV2(umi, { + await createCandyMachine(umi, { candyMachine, collection: collection.publicKey, collectionUpdateAuthority: umi.identity, @@ -100,7 +98,6 @@ test('it can create a candy machine using hidden settings', async (t) => { authority: publicKey(umi.identity), mintAuthority: publicKey(umi.identity), collectionMint: publicKey(collection), - version: AccountVersion.V2, itemsRedeemed: 0n, data: { itemsAvailable: 100n, @@ -125,7 +122,7 @@ test('it cannot create a candy machine without hidden or config line settings', const candyMachine = generateSigner(umi); const promise = transactionBuilder() .add( - await createCandyMachineV2(umi, { + await createCandyMachine(umi, { ...defaultCandyMachineData(umi), collection, candyMachine, @@ -148,7 +145,7 @@ test('it can create a candy machine of Programmable NFTs', async (t) => { const candyMachine = generateSigner(umi); await transactionBuilder() .add( - await createCandyMachineV2(umi, { + await createCandyMachine(umi, { ...defaultCandyMachineData(umi), candyMachine, collection, @@ -163,7 +160,6 @@ test('it can create a candy machine of Programmable NFTs', async (t) => { ); t.like(candyMachineAccount, { publicKey: publicKey(candyMachine), - version: AccountVersion.V2, }); }); @@ -176,7 +172,7 @@ test("it can create a candy machine that's bigger than 10Kb", async (t) => { const candyMachine = generateSigner(umi); await transactionBuilder() .add( - await createCandyMachineV2(umi, { + await createCandyMachine(umi, { ...defaultCandyMachineData(umi), candyMachine, itemsAvailable: 20000, diff --git a/clients/js/test/createLutForCandyMachine.test.ts b/clients/js/test/createLutForCandyMachine.test.ts index 17f0fdb..5684b03 100644 --- a/clients/js/test/createLutForCandyMachine.test.ts +++ b/clients/js/test/createLutForCandyMachine.test.ts @@ -14,7 +14,7 @@ import { findCandyGuardPda, findCandyMachineAuthorityPda, getMplCoreCandyMachineCoreProgramId, - mintV2, + mintV1, setMintAuthority, } from '../src'; import { @@ -39,7 +39,7 @@ test('it can create a LUT for a candy machine v2', async (t) => { const builderWithoutLut = transactionBuilder() .add(setComputeUnitLimit(umi, { units: 600_000 })) .add( - mintV2(umi, { + mintV1(umi, { candyMachine, asset: mint, collection, diff --git a/clients/js/test/defaultGuards/addressGate.test.ts b/clients/js/test/defaultGuards/addressGate.test.ts index 92a266d..197e8b7 100644 --- a/clients/js/test/defaultGuards/addressGate.test.ts +++ b/clients/js/test/defaultGuards/addressGate.test.ts @@ -6,7 +6,7 @@ import { transactionBuilder, } from '@metaplex-foundation/umi'; import test from 'ava'; -import { mintV2 } from '../../src'; +import { mintV1 } from '../../src'; import { assertBotTax, assertSuccessfulMint, @@ -33,7 +33,7 @@ test('it allows minting from a specific address only', async (t) => { await transactionBuilder() .add(setComputeUnitLimit(umi, { units: 600_000 })) .add( - mintV2(umi, { + mintV1(umi, { candyMachine, asset: mint, minter: allowedAddress, @@ -64,7 +64,7 @@ test('it forbids minting from anyone else', async (t) => { const promise = transactionBuilder() .add(setComputeUnitLimit(umi, { units: 600_000 })) .add( - mintV2(umi, { + mintV1(umi, { candyMachine, asset: mint, minter: unauthorizedMinter, @@ -96,7 +96,7 @@ test('it charges a bot tax when trying to mint using the wrong address', async ( const { signature } = await transactionBuilder() .add(setComputeUnitLimit(umi, { units: 600_000 })) .add( - mintV2(umi, { + mintV1(umi, { candyMachine, asset: mint, minter: unauthorizedMinter, diff --git a/clients/js/test/defaultGuards/allocation.test.ts b/clients/js/test/defaultGuards/allocation.test.ts index 6572183..e452d04 100644 --- a/clients/js/test/defaultGuards/allocation.test.ts +++ b/clients/js/test/defaultGuards/allocation.test.ts @@ -10,7 +10,7 @@ import { fetchAllocationTracker, findCandyGuardPda, findAllocationTrackerPda, - mintV2, + mintV1, route, } from '../../src'; import { @@ -55,7 +55,7 @@ test('it allows minting when the allocation limit is not reached', async (t) => await transactionBuilder() .add(setComputeUnitLimit(umi, { units: 600_000 })) .add( - mintV2(umi, { + mintV1(umi, { candyMachine, asset: mint, collection, @@ -111,7 +111,7 @@ test('it forbids minting when the allocation limit is reached', async (t) => { await transactionBuilder() .add(setComputeUnitLimit(umi, { units: 600_000 })) .add( - mintV2(umi, { + mintV1(umi, { candyMachine, asset: mint, collection, @@ -124,7 +124,7 @@ test('it forbids minting when the allocation limit is reached', async (t) => { const promise = transactionBuilder() .add(setComputeUnitLimit(umi, { units: 600_000 })) .add( - mintV2(umi, { + mintV1(umi, { candyMachine, asset: mint, collection, @@ -196,7 +196,7 @@ test('the allocation limit is local to each id', async (t) => { await transactionBuilder() .add(setComputeUnitLimit(umi, { units: 600_000 })) .add( - mintV2(umi, { + mintV1(umi, { candyMachine, asset: mintA, minter: minterA, @@ -214,7 +214,7 @@ test('the allocation limit is local to each id', async (t) => { await transactionBuilder() .add(setComputeUnitLimit(umi, { units: 600_000 })) .add( - mintV2(umi, { + mintV1(umi, { candyMachine, asset: mintB, minter: minterB, @@ -264,7 +264,7 @@ test('it charges a bot tax when trying to mint after the limit', async (t) => { await transactionBuilder() .add(setComputeUnitLimit(umi, { units: 600_000 })) .add( - mintV2(umi, { + mintV1(umi, { candyMachine, asset: mintA, collection, @@ -278,7 +278,7 @@ test('it charges a bot tax when trying to mint after the limit', async (t) => { const { signature } = await transactionBuilder() .add(setComputeUnitLimit(umi, { units: 600_000 })) .add( - mintV2(umi, { + mintV1(umi, { candyMachine, asset: mintB, collection, diff --git a/clients/js/test/defaultGuards/allowList.test.ts b/clients/js/test/defaultGuards/allowList.test.ts index f10fbdf..5c3e6f1 100644 --- a/clients/js/test/defaultGuards/allowList.test.ts +++ b/clients/js/test/defaultGuards/allowList.test.ts @@ -13,7 +13,7 @@ import { findCandyGuardPda, getMerkleProof, getMerkleRoot, - mintV2, + mintV1, route, } from '../../src'; import { @@ -66,7 +66,7 @@ test('it allows minting from wallets of a predefined list', async (t) => { await transactionBuilder() .add(setComputeUnitLimit(umi, { units: 600_000 })) .add( - mintV2(umi, { + mintV1(umi, { candyMachine, asset: mint, collection, @@ -118,7 +118,7 @@ test('it is possible to verify the proof and mint in the same transaction if the }) ) .add( - mintV2(umi, { + mintV1(umi, { candyMachine, asset: mint, collection, @@ -171,7 +171,7 @@ test('it allows minting even when the payer is different from the minter', async }) ) .add( - mintV2(umi, { + mintV1(umi, { candyMachine, asset: mint, minter, @@ -299,7 +299,7 @@ test('it forbids minting if the wallet has not been verified via the route instr const promise = transactionBuilder() .add(setComputeUnitLimit(umi, { units: 600_000 })) .add( - mintV2(umi, { + mintV1(umi, { candyMachine, asset: mint, collection, @@ -341,7 +341,7 @@ test('it charges a bot tax when trying to mint whilst not verified', async (t) = const { signature } = await transactionBuilder() .add(setComputeUnitLimit(umi, { units: 600_000 })) .add( - mintV2(umi, { + mintV1(umi, { candyMachine, asset: mint, collection, diff --git a/clients/js/test/defaultGuards/botTax.test.ts b/clients/js/test/defaultGuards/botTax.test.ts index ceed95a..e1abecc 100644 --- a/clients/js/test/defaultGuards/botTax.test.ts +++ b/clients/js/test/defaultGuards/botTax.test.ts @@ -6,7 +6,7 @@ import { transactionBuilder, } from '@metaplex-foundation/umi'; import test from 'ava'; -import { mintV2 } from '../../src'; +import { mintV1 } from '../../src'; import { assertBotTax, assertSuccessfulMint, @@ -32,7 +32,7 @@ test('it does nothing if all conditions are valid', async (t) => { await transactionBuilder() .add(setComputeUnitLimit(umi, { units: 600_000 })) .add( - mintV2(umi, { + mintV1(umi, { candyMachine, asset: mint, collection, @@ -61,7 +61,7 @@ test('it optionally charges a bot tax if the mint instruction is not the last on const { signature } = await transactionBuilder() .add(setComputeUnitLimit(umi, { units: 600_000 })) .add( - mintV2(umi, { + mintV1(umi, { candyMachine, asset: mint, collection, diff --git a/clients/js/test/defaultGuards/endDate.test.ts b/clients/js/test/defaultGuards/endDate.test.ts index 1fef8a9..991ca21 100644 --- a/clients/js/test/defaultGuards/endDate.test.ts +++ b/clients/js/test/defaultGuards/endDate.test.ts @@ -6,7 +6,7 @@ import { transactionBuilder, } from '@metaplex-foundation/umi'; import test from 'ava'; -import { mintV2 } from '../../src'; +import { mintV1 } from '../../src'; import { assertBotTax, assertSuccessfulMint, @@ -34,7 +34,7 @@ test('it allows minting before the end date', async (t) => { await transactionBuilder() .add(setComputeUnitLimit(umi, { units: 600_000 })) .add( - mintV2(umi, { + mintV1(umi, { candyMachine, asset: mint, collection, @@ -63,7 +63,7 @@ test('it forbids minting after the end date', async (t) => { const promise = transactionBuilder() .add(setComputeUnitLimit(umi, { units: 600_000 })) .add( - mintV2(umi, { + mintV1(umi, { candyMachine, asset: mint, collection, @@ -93,7 +93,7 @@ test('it charges a bot tax when trying to mint after the end date', async (t) => const { signature } = await transactionBuilder() .add(setComputeUnitLimit(umi, { units: 600_000 })) .add( - mintV2(umi, { + mintV1(umi, { candyMachine, asset: mint, collection, diff --git a/clients/js/test/defaultGuards/freezeSolPayment.test.ts b/clients/js/test/defaultGuards/freezeSolPayment.test.ts index fccf24c..df93acc 100644 --- a/clients/js/test/defaultGuards/freezeSolPayment.test.ts +++ b/clients/js/test/defaultGuards/freezeSolPayment.test.ts @@ -25,7 +25,7 @@ import { findCandyGuardPda, findFreezeEscrowPda, FreezeEscrow, - mintV2, + mintV1, route, } from '../../src'; import { @@ -76,7 +76,7 @@ test('it transfers SOL to an escrow account and freezes the NFT', async (t) => { await transactionBuilder() .add(setComputeUnitLimit(umi, { units: 600_000 })) .add( - mintV2(umi, { + mintV1(umi, { candyMachine, asset: mint, collection, @@ -158,7 +158,7 @@ test('it allows minting even when the payer is different from the minter', async await transactionBuilder() .add(setComputeUnitLimit(umi, { units: 600_000 })) .add( - mintV2(umi, { + mintV1(umi, { candyMachine, asset: mint, minter, @@ -370,7 +370,7 @@ test('it can have multiple freeze escrow and reuse the same ones', async (t) => await transactionBuilder() .add(setComputeUnitLimit(umi, { units: 600_000 })) .add( - mintV2(umi, { + mintV1(umi, { candyMachine, asset: mintD, collection, @@ -501,7 +501,7 @@ test('it fails to mint if the freeze escrow was not initialized', async (t) => { const promise = transactionBuilder() .add(setComputeUnitLimit(umi, { units: 600_000 })) .add( - mintV2(umi, { + mintV1(umi, { candyMachine, asset: mint, collection, @@ -535,7 +535,7 @@ test('it fails to mint if the payer does not have enough funds', async (t) => { const promise = transactionBuilder() .add(setComputeUnitLimit(umi, { units: 600_000 })) .add( - mintV2(umi, { + mintV1(umi, { candyMachine, asset: mint, payer, @@ -573,7 +573,7 @@ test('it charges a bot tax if something goes wrong', async (t) => { const { signature } = await transactionBuilder() .add(setComputeUnitLimit(umi, { units: 600_000 })) .add( - mintV2(umi, { + mintV1(umi, { candyMachine, asset: mint, collection, @@ -611,7 +611,7 @@ test('it transfers SOL to an escrow account and locks the Programmable NFT', asy await transactionBuilder() .add(setComputeUnitLimit(umi, { units: 800_000 })) .add( - mintV2(umi, { + mintV1(umi, { candyMachine, asset: mint, collection, @@ -693,7 +693,7 @@ test('it can thaw a Programmable NFT once all NFTs are minted', async (t) => { await transactionBuilder() .add(setComputeUnitLimit(umi, { units: 800_000 })) .add( - mintV2(umi, { + mintV1(umi, { candyMachine, asset: mint, collection, @@ -807,7 +807,7 @@ const mintNft = async ( await transactionBuilder() .add(setComputeUnitLimit(umi, { units: 600_000 })) .add( - mintV2(umi, { + mintV1(umi, { candyMachine, asset: mint, collection, diff --git a/clients/js/test/defaultGuards/freezeTokenPayment.test.ts b/clients/js/test/defaultGuards/freezeTokenPayment.test.ts index e051551..abed975 100644 --- a/clients/js/test/defaultGuards/freezeTokenPayment.test.ts +++ b/clients/js/test/defaultGuards/freezeTokenPayment.test.ts @@ -25,7 +25,7 @@ import { findCandyGuardPda, findFreezeEscrowPda, FreezeEscrow, - mintV2, + mintV1, route, } from '../../src'; import { @@ -89,7 +89,7 @@ test('it transfers tokens to an escrow account and freezes the NFT', async (t) = await transactionBuilder() .add(setComputeUnitLimit(umi, { units: 600_000 })) .add( - mintV2(umi, { + mintV1(umi, { candyMachine, asset: mint, collection, @@ -180,7 +180,7 @@ test('it allows minting even when the payer is different from the minter', async await transactionBuilder() .add(setComputeUnitLimit(umi, { units: 600_000 })) .add( - mintV2(umi, { + mintV1(umi, { candyMachine, asset: mint, minter, @@ -496,7 +496,7 @@ test('it can have multiple freeze escrow and reuse the same ones', async (t) => await transactionBuilder() .add(setComputeUnitLimit(umi, { units: 600_000 })) .add( - mintV2(umi, { + mintV1(umi, { candyMachine, asset: nftD, collection, @@ -669,7 +669,7 @@ test('it fails to mint if the freeze escrow was not initialized', async (t) => { }) ) .add( - mintV2(umi, { + mintV1(umi, { candyMachine, asset: mint, collection, @@ -725,7 +725,7 @@ test('it fails to mint if the payer does not have enough tokens', async (t) => { }) ) .add( - mintV2(umi, { + mintV1(umi, { candyMachine, asset: mint, collection, @@ -780,7 +780,7 @@ test('it charges a bot tax if something goes wrong', async (t) => { }) ) .add( - mintV2(umi, { + mintV1(umi, { candyMachine, asset: mint, collection, @@ -834,7 +834,7 @@ test('it transfers tokens to an escrow account and locks the Programmable NFT', await transactionBuilder() .add(setComputeUnitLimit(umi, { units: 800_000 })) .add( - mintV2(umi, { + mintV1(umi, { candyMachine, asset: mint, collection, @@ -919,7 +919,7 @@ test('it can thaw a Programmable NFT once all NFTs are minted', async (t) => { await transactionBuilder() .add(setComputeUnitLimit(umi, { units: 800_000 })) .add( - mintV2(umi, { + mintV1(umi, { candyMachine, asset: mint, collection, @@ -1054,7 +1054,7 @@ const mintNft = async ( await transactionBuilder() .add(setComputeUnitLimit(umi, { units: 600_000 })) .add( - mintV2(umi, { + mintV1(umi, { candyMachine, asset: mint, collection, diff --git a/clients/js/test/defaultGuards/gatekeeper.test.ts b/clients/js/test/defaultGuards/gatekeeper.test.ts index 1c9dc36..f029367 100644 --- a/clients/js/test/defaultGuards/gatekeeper.test.ts +++ b/clients/js/test/defaultGuards/gatekeeper.test.ts @@ -26,7 +26,7 @@ import { } from '@metaplex-foundation/umi-web3js-adapters'; import test from 'ava'; import { Buffer } from 'buffer'; -import { mintV2 } from '../../src'; +import { mintV1 } from '../../src'; import { assertBotTax, assertSuccessfulMint, @@ -69,7 +69,7 @@ test('it allows minting via a gatekeeper service', async (t) => { await transactionBuilder() .add(setComputeUnitLimit(umi, { units: 600_000 })) .add( - mintV2(umi, { + mintV1(umi, { candyMachine, asset: mint, collection, @@ -120,7 +120,7 @@ test('it defaults to calculating the gateway token PDA for us', async (t) => { await transactionBuilder() .add(setComputeUnitLimit(umi, { units: 600_000 })) .add( - mintV2(umi, { + mintV1(umi, { candyMachine, asset: mint, collection, @@ -172,7 +172,7 @@ test('it allows minting even when the payer is different from the minter', async await transactionBuilder() .add(setComputeUnitLimit(umi, { units: 600_000 })) .add( - mintV2(umi, { + mintV1(umi, { candyMachine, asset: mint, minter, @@ -215,7 +215,7 @@ test('it forbids minting when providing the wrong token', async (t) => { const promise = transactionBuilder() .add(setComputeUnitLimit(umi, { units: 600_000 })) .add( - mintV2(umi, { + mintV1(umi, { candyMachine, asset: mint, collection, @@ -268,7 +268,7 @@ test('it allows minting using gateway tokens that expire when they are still val await transactionBuilder() .add(setComputeUnitLimit(umi, { units: 600_000 })) .add( - mintV2(umi, { + mintV1(umi, { candyMachine, asset: mint, collection, @@ -321,7 +321,7 @@ test('it forbids minting using gateway tokens that have expired', async (t) => { const promise = transactionBuilder() .add(setComputeUnitLimit(umi, { units: 600_000 })) .add( - mintV2(umi, { + mintV1(umi, { candyMachine, asset: mint, collection, @@ -380,7 +380,7 @@ test('it may immediately mark gateway tokens as expired after using them', async await transactionBuilder() .add(setComputeUnitLimit(umi, { units: 600_000 })) .add( - mintV2(umi, { + mintV1(umi, { candyMachine, asset: mint, collection, @@ -436,7 +436,7 @@ test('it charges a bot tax when trying to mint using the wrong token', async (t) const { signature } = await transactionBuilder() .add(setComputeUnitLimit(umi, { units: 600_000 })) .add( - mintV2(umi, { + mintV1(umi, { candyMachine, asset: mint, collection, diff --git a/clients/js/test/defaultGuards/mintLimit.test.ts b/clients/js/test/defaultGuards/mintLimit.test.ts index 14962d6..8715bc5 100644 --- a/clients/js/test/defaultGuards/mintLimit.test.ts +++ b/clients/js/test/defaultGuards/mintLimit.test.ts @@ -10,7 +10,7 @@ import { fetchMintCounter, findCandyGuardPda, findMintCounterPda, - mintV2, + mintV1, } from '../../src'; import { assertBotTax, @@ -40,7 +40,7 @@ test('it allows minting when the mint limit is not reached', async (t) => { await transactionBuilder() .add(setComputeUnitLimit(umi, { units: 600_000 })) .add( - mintV2(umi, { + mintV1(umi, { candyMachine, asset: mint, collection, @@ -84,7 +84,7 @@ test('it allows minting even when the payer is different from the minter', async await transactionBuilder() .add(setComputeUnitLimit(umi, { units: 600_000 })) .add( - mintV2(umi, { + mintV1(umi, { candyMachine, asset: mint, minter, @@ -128,7 +128,7 @@ test('it forbids minting when the mint limit is reached', async (t) => { await transactionBuilder() .add(setComputeUnitLimit(umi, { units: 600_000 })) .add( - mintV2(umi, { + mintV1(umi, { candyMachine, asset: mint, collection, @@ -141,7 +141,7 @@ test('it forbids minting when the mint limit is reached', async (t) => { const promise = transactionBuilder() .add(setComputeUnitLimit(umi, { units: 600_000 })) .add( - mintV2(umi, { + mintV1(umi, { candyMachine, asset: generateSigner(umi), collection, @@ -175,7 +175,7 @@ test('the mint limit is local to each wallet', async (t) => { await transactionBuilder() .add(setComputeUnitLimit(umi, { units: 600_000 })) .add( - mintV2(umi, { + mintV1(umi, { candyMachine, asset: mintA, minter: minterA, @@ -192,7 +192,7 @@ test('the mint limit is local to each wallet', async (t) => { await transactionBuilder() .add(setComputeUnitLimit(umi, { units: 600_000 })) .add( - mintV2(umi, { + mintV1(umi, { candyMachine, asset: mintB, minter: minterB, @@ -227,7 +227,7 @@ test('it charges a bot tax when trying to mint after the limit', async (t) => { await transactionBuilder() .add(setComputeUnitLimit(umi, { units: 600_000 })) .add( - mintV2(umi, { + mintV1(umi, { candyMachine, asset: mintA, collection, @@ -241,7 +241,7 @@ test('it charges a bot tax when trying to mint after the limit', async (t) => { const { signature } = await transactionBuilder() .add(setComputeUnitLimit(umi, { units: 600_000 })) .add( - mintV2(umi, { + mintV1(umi, { candyMachine, asset: mintB, collection, diff --git a/clients/js/test/defaultGuards/nftBurn.test.ts b/clients/js/test/defaultGuards/nftBurn.test.ts index 978b86e..45994a6 100644 --- a/clients/js/test/defaultGuards/nftBurn.test.ts +++ b/clients/js/test/defaultGuards/nftBurn.test.ts @@ -7,7 +7,7 @@ import { } from '@metaplex-foundation/umi'; import test from 'ava'; import { TokenStandard } from '@metaplex-foundation/mpl-token-metadata'; -import { mintV2 } from '../../src'; +import { mintV1 } from '../../src'; import { assertBotTax, assertBurnedNft, @@ -49,7 +49,7 @@ test('it burns a specific NFT to allow minting', async (t) => { await transactionBuilder() .add(setComputeUnitLimit(umi, { units: 600_000 })) .add( - mintV2(umi, { + mintV1(umi, { candyMachine, asset: mint, collection, @@ -100,7 +100,7 @@ test('it allows minting even when the payer is different from the minter', async await transactionBuilder() .add(setComputeUnitLimit(umi, { units: 600_000 })) .add( - mintV2(umi, { + mintV1(umi, { candyMachine, asset: mint, minter, @@ -142,7 +142,7 @@ test('it fails if there is not valid NFT to burn', async (t) => { const promise = transactionBuilder() .add(setComputeUnitLimit(umi, { units: 600_000 })) .add( - mintV2(umi, { + mintV1(umi, { candyMachine, asset: mint, collection, @@ -182,7 +182,7 @@ test('it charges a bot tax when trying to mint using the wrong NFT', async (t) = const { signature } = await transactionBuilder() .add(setComputeUnitLimit(umi, { units: 600_000 })) .add( - mintV2(umi, { + mintV1(umi, { candyMachine, asset: mint, collection, @@ -229,7 +229,7 @@ test('it burns a specific Programmable NFT to allow minting', async (t) => { await transactionBuilder() .add(setComputeUnitLimit(umi, { units: 600_000 })) .add( - mintV2(umi, { + mintV1(umi, { candyMachine, asset: mint, collection, diff --git a/clients/js/test/defaultGuards/nftGate.test.ts b/clients/js/test/defaultGuards/nftGate.test.ts index f7c35e5..2b79416 100644 --- a/clients/js/test/defaultGuards/nftGate.test.ts +++ b/clients/js/test/defaultGuards/nftGate.test.ts @@ -13,7 +13,7 @@ import { transactionBuilder, } from '@metaplex-foundation/umi'; import test from 'ava'; -import { mintV2 } from '../../src'; +import { mintV1 } from '../../src'; import { assertBotTax, assertSuccessfulMint, @@ -53,7 +53,7 @@ test('it allows minting when the payer owns an NFT from a certain collection', a await transactionBuilder() .add(setComputeUnitLimit(umi, { units: 600_000 })) .add( - mintV2(umi, { + mintV1(umi, { candyMachine, asset: mint, collection, @@ -97,7 +97,7 @@ test('it allows minting even when the payer is different from the minter', async await transactionBuilder() .add(setComputeUnitLimit(umi, { units: 600_000 })) .add( - mintV2(umi, { + mintV1(umi, { candyMachine, asset: mint, minter, @@ -155,7 +155,7 @@ test('it allows minting when the NFT is not on an associated token account', asy await transactionBuilder() .add(setComputeUnitLimit(umi, { units: 600_000 })) .add( - mintV2(umi, { + mintV1(umi, { candyMachine, asset: mint, collection, @@ -221,7 +221,7 @@ test('it forbids minting when the payer does not own an NFT from a certain colle const promise = transactionBuilder() .add(setComputeUnitLimit(umi, { units: 600_000 })) .add( - mintV2(umi, { + mintV1(umi, { candyMachine, asset: mint, collection, @@ -268,7 +268,7 @@ test('it forbids minting when the payer tries to provide an NFT from the wrong c const promise = transactionBuilder() .add(setComputeUnitLimit(umi, { units: 600_000 })) .add( - mintV2(umi, { + mintV1(umi, { candyMachine, asset: mint, collection, @@ -309,7 +309,7 @@ test('it forbids minting when the payer tries to provide an NFT from an unverifi const promise = transactionBuilder() .add(setComputeUnitLimit(umi, { units: 600_000 })) .add( - mintV2(umi, { + mintV1(umi, { candyMachine, asset: mint, collection, @@ -344,7 +344,7 @@ test('it charges a bot tax when trying to mint without owning the right NFT', as const { signature } = await transactionBuilder() .add(setComputeUnitLimit(umi, { units: 600_000 })) .add( - mintV2(umi, { + mintV1(umi, { candyMachine, asset: mint, collection, diff --git a/clients/js/test/defaultGuards/nftMintLimit.test.ts b/clients/js/test/defaultGuards/nftMintLimit.test.ts index cd660c9..f8f27bc 100644 --- a/clients/js/test/defaultGuards/nftMintLimit.test.ts +++ b/clients/js/test/defaultGuards/nftMintLimit.test.ts @@ -19,7 +19,7 @@ import { fetchNftMintCounter, findCandyGuardPda, findNftMintCounterPda, - mintV2, + mintV1, } from '../../src'; import { assertBotTax, @@ -61,7 +61,7 @@ test('it allows minting when the nft mint limit is not reached', async (t) => { await transactionBuilder() .add(setComputeUnitLimit(umi, { units: 600_000 })) .add( - mintV2(umi, { + mintV1(umi, { candyMachine, asset: mint, collection, @@ -118,7 +118,7 @@ test('it allows minting even when the payer is different from the minter', async await transactionBuilder() .add(setComputeUnitLimit(umi, { units: 600_000 })) .add( - mintV2(umi, { + mintV1(umi, { candyMachine, asset: mint, minter, @@ -174,7 +174,7 @@ test('it forbids minting when the nft mint limit is reached', async (t) => { await transactionBuilder() .add(setComputeUnitLimit(umi, { units: 600_000 })) .add( - mintV2(umi, { + mintV1(umi, { candyMachine, asset: mint, collection, @@ -189,7 +189,7 @@ test('it forbids minting when the nft mint limit is reached', async (t) => { const promise = transactionBuilder() .add(setComputeUnitLimit(umi, { units: 600_000 })) .add( - mintV2(umi, { + mintV1(umi, { candyMachine, asset: generateSigner(umi), collection, @@ -234,7 +234,7 @@ test('it forbids minting when minter does not own nft', async (t) => { const promise = transactionBuilder() .add(setComputeUnitLimit(umi, { units: 600_000 })) .add( - mintV2(umi, { + mintV1(umi, { candyMachine, minter: minterA, asset: generateSigner(umi), @@ -289,7 +289,7 @@ test('it forbids minting when nft does not belong to the required collection', a const promise = transactionBuilder() .add(setComputeUnitLimit(umi, { units: 600_000 })) .add( - mintV2(umi, { + mintV1(umi, { candyMachine, asset: generateSigner(umi), collection, @@ -342,7 +342,7 @@ test('the mint limit is local to each nft', async (t) => { await transactionBuilder() .add(setComputeUnitLimit(umi, { units: 600_000 })) .add( - mintV2(umi, { + mintV1(umi, { candyMachine, asset: mintA, minter: minterA, @@ -360,7 +360,7 @@ test('the mint limit is local to each nft', async (t) => { await transactionBuilder() .add(setComputeUnitLimit(umi, { units: 600_000 })) .add( - mintV2(umi, { + mintV1(umi, { candyMachine, asset: mintB, minter: minterA, @@ -407,7 +407,7 @@ test('forbids minting with different owners using the same nft', async (t) => { await transactionBuilder() .add(setComputeUnitLimit(umi, { units: 600_000 })) .add( - mintV2(umi, { + mintV1(umi, { candyMachine, asset: mintA, minter: minterA, @@ -462,7 +462,7 @@ test('forbids minting with different owners using the same nft', async (t) => { const promise = transactionBuilder() .add(setComputeUnitLimit(umi, { units: 600_000 })) .add( - mintV2(umi, { + mintV1(umi, { candyMachine, asset: mintB, minter: minterB, @@ -508,7 +508,7 @@ test('it charges a bot tax when trying to mint after the limit', async (t) => { await transactionBuilder() .add(setComputeUnitLimit(umi, { units: 600_000 })) .add( - mintV2(umi, { + mintV1(umi, { candyMachine, asset: mintA, collection, @@ -524,7 +524,7 @@ test('it charges a bot tax when trying to mint after the limit', async (t) => { const { signature } = await transactionBuilder() .add(setComputeUnitLimit(umi, { units: 600_000 })) .add( - mintV2(umi, { + mintV1(umi, { candyMachine, asset: mintB, collection, diff --git a/clients/js/test/defaultGuards/nftPayment.test.ts b/clients/js/test/defaultGuards/nftPayment.test.ts index ec2ff15..3d7310c 100644 --- a/clients/js/test/defaultGuards/nftPayment.test.ts +++ b/clients/js/test/defaultGuards/nftPayment.test.ts @@ -15,7 +15,7 @@ import { transactionBuilder, } from '@metaplex-foundation/umi'; import test from 'ava'; -import { mintV2 } from '../../src'; +import { mintV1 } from '../../src'; import { assertBotTax, assertSuccessfulMint, @@ -57,7 +57,7 @@ test('it transfers an NFT from the payer to the destination', async (t) => { await transactionBuilder() .add(setComputeUnitLimit(umi, { units: 600_000 })) .add( - mintV2(umi, { + mintV1(umi, { candyMachine, asset: mint, collection, @@ -115,7 +115,7 @@ test('it allows minting even when the payer is different from the minter', async await transactionBuilder() .add(setComputeUnitLimit(umi, { units: 600_000 })) .add( - mintV2(umi, { + mintV1(umi, { candyMachine, asset: mint, minter, @@ -189,7 +189,7 @@ test('it works when the provided NFT is not on an associated token account', asy await transactionBuilder() .add(setComputeUnitLimit(umi, { units: 600_000 })) .add( - mintV2(umi, { + mintV1(umi, { candyMachine, asset: mint, collection, @@ -245,7 +245,7 @@ test('it fails if the payer does not own the right NFT', async (t) => { const promise = transactionBuilder() .add(setComputeUnitLimit(umi, { units: 600_000 })) .add( - mintV2(umi, { + mintV1(umi, { candyMachine, asset: mint, collection, @@ -293,7 +293,7 @@ test('it fails if the payer tries to provide an NFT from an unverified collectio const promise = transactionBuilder() .add(setComputeUnitLimit(umi, { units: 600_000 })) .add( - mintV2(umi, { + mintV1(umi, { candyMachine, asset: mint, collection, @@ -341,7 +341,7 @@ test('it charges a bot tax when trying to pay with the wrong NFT', async (t) => const { signature } = await transactionBuilder() .add(setComputeUnitLimit(umi, { units: 600_000 })) .add( - mintV2(umi, { + mintV1(umi, { candyMachine, asset: mint, collection, @@ -391,7 +391,7 @@ test('it transfers a Programmable NFT from the payer to the destination', async await transactionBuilder() .add(setComputeUnitLimit(umi, { units: 800_000 })) .add( - mintV2(umi, { + mintV1(umi, { candyMachine, asset: mint, collection, diff --git a/clients/js/test/defaultGuards/programGate.test.ts b/clients/js/test/defaultGuards/programGate.test.ts index 7512b7a..ce51059 100644 --- a/clients/js/test/defaultGuards/programGate.test.ts +++ b/clients/js/test/defaultGuards/programGate.test.ts @@ -10,7 +10,7 @@ import { transactionBuilder, } from '@metaplex-foundation/umi'; import test from 'ava'; -import { mintV2 } from '../../src'; +import { mintV1 } from '../../src'; import { assertBotTax, assertSuccessfulMint, @@ -38,7 +38,7 @@ test('it allows minting with specified program in transaction', async (t) => { .add(setComputeUnitLimit(umi, { units: 600_000 })) .add(addMemo(umi, { memo: 'Instruction from the Memo program' })) .add( - mintV2(umi, { + mintV1(umi, { candyMachine, asset: mint, collection, @@ -71,7 +71,7 @@ test('it allows minting even when the payer is different from the minter', async .add(setComputeUnitLimit(umi, { units: 600_000 })) .add(addMemo(umi, { memo: 'Instruction from the Memo program' })) .add( - mintV2(umi, { + mintV1(umi, { candyMachine, asset: mint, minter, @@ -102,7 +102,7 @@ test('it forbids minting with unspecified program in transaction', async (t) => .add(setComputeUnitLimit(umi, { units: 600_000 })) .add(addMemo(umi, { memo: 'Instruction from the Memo program' })) .add( - mintV2(umi, { + mintV1(umi, { candyMachine, asset: mint, collection, @@ -154,7 +154,7 @@ test('it charges a bot tax when minting with unspecified program in transaction' .add(setComputeUnitLimit(umi, { units: 600_000 })) .add(addMemo(umi, { memo: 'Instruction from the Memo program' })) .add( - mintV2(umi, { + mintV1(umi, { candyMachine, asset: mint, collection, diff --git a/clients/js/test/defaultGuards/redeemedAmount.test.ts b/clients/js/test/defaultGuards/redeemedAmount.test.ts index e9ba73d..f8c5909 100644 --- a/clients/js/test/defaultGuards/redeemedAmount.test.ts +++ b/clients/js/test/defaultGuards/redeemedAmount.test.ts @@ -6,7 +6,7 @@ import { transactionBuilder, } from '@metaplex-foundation/umi'; import test from 'ava'; -import { mintV2 } from '../../src'; +import { mintV1 } from '../../src'; import { assertBotTax, assertSuccessfulMint, @@ -35,7 +35,7 @@ test('it allows minting until a threshold of NFTs have been redeemed', async (t) await transactionBuilder() .add(setComputeUnitLimit(umi, { units: 600_000 })) .add( - mintV2(umi, { + mintV1(umi, { candyMachine, asset: mint, collection, @@ -67,7 +67,7 @@ test('it forbids minting once the redeemed threshold has been reached', async (t await transactionBuilder() .add(setComputeUnitLimit(umi, { units: 600_000 })) .add( - mintV2(umi, { + mintV1(umi, { candyMachine, asset: mintA, collection, @@ -81,7 +81,7 @@ test('it forbids minting once the redeemed threshold has been reached', async (t const promise = transactionBuilder() .add(setComputeUnitLimit(umi, { units: 600_000 })) .add( - mintV2(umi, { + mintV1(umi, { candyMachine, asset: mintB, collection, @@ -115,7 +115,7 @@ test('it charges a bot tax when trying to mint once the threshold has been reach await transactionBuilder() .add(setComputeUnitLimit(umi, { units: 600_000 })) .add( - mintV2(umi, { + mintV1(umi, { candyMachine, asset: mintA, collection, @@ -129,7 +129,7 @@ test('it charges a bot tax when trying to mint once the threshold has been reach const { signature } = await transactionBuilder() .add(setComputeUnitLimit(umi, { units: 600_000 })) .add( - mintV2(umi, { + mintV1(umi, { candyMachine, asset: mintB, collection, diff --git a/clients/js/test/defaultGuards/solFixedFee.test.ts b/clients/js/test/defaultGuards/solFixedFee.test.ts index dfb09f5..4a3d097 100644 --- a/clients/js/test/defaultGuards/solFixedFee.test.ts +++ b/clients/js/test/defaultGuards/solFixedFee.test.ts @@ -7,7 +7,7 @@ import { } from '@metaplex-foundation/umi'; import { generateSignerWithSol } from '@metaplex-foundation/umi-bundle-tests'; import test from 'ava'; -import { mintV2 } from '../../src'; +import { mintV1 } from '../../src'; import { assertBotTax, assertSuccessfulMint, @@ -36,7 +36,7 @@ test('it transfers SOL from the payer to the destination', async (t) => { await transactionBuilder() .add(setComputeUnitLimit(umi, { units: 600_000 })) .add( - mintV2(umi, { + mintV1(umi, { candyMachine, asset: mint, minter, @@ -78,7 +78,7 @@ test('it fails if the payer does not have enough funds', async (t) => { const promise = transactionBuilder() .add(setComputeUnitLimit(umi, { units: 600_000 })) .add( - mintV2(umi, { + mintV1(umi, { candyMachine, asset: mint, payer, @@ -116,7 +116,7 @@ test('it charges a bot tax if the payer does not have enough funds', async (t) = const { signature } = await transactionBuilder() .add(setComputeUnitLimit(umi, { units: 600_000 })) .add( - mintV2(umi, { + mintV1(umi, { candyMachine, asset: mint, payer, diff --git a/clients/js/test/defaultGuards/solPayment.test.ts b/clients/js/test/defaultGuards/solPayment.test.ts index 2c759a1..671bb12 100644 --- a/clients/js/test/defaultGuards/solPayment.test.ts +++ b/clients/js/test/defaultGuards/solPayment.test.ts @@ -15,7 +15,7 @@ import { createUmi, createV2, } from '../_setup'; -import { mintV2 } from '../../src'; +import { mintV1 } from '../../src'; test('it transfers SOL from the payer to the destination', async (t) => { // Given a loaded Candy Machine with a solPayment guard. @@ -37,7 +37,7 @@ test('it transfers SOL from the payer to the destination', async (t) => { await transactionBuilder() .add(setComputeUnitLimit(umi, { units: 600_000 })) .add( - mintV2(umi, { + mintV1(umi, { candyMachine, asset: mint, minter, @@ -79,7 +79,7 @@ test('it fails if the payer does not have enough funds', async (t) => { const promise = transactionBuilder() .add(setComputeUnitLimit(umi, { units: 600_000 })) .add( - mintV2(umi, { + mintV1(umi, { candyMachine, asset: mint, payer, @@ -117,7 +117,7 @@ test('it charges a bot tax if the payer does not have enough funds', async (t) = const { signature } = await transactionBuilder() .add(setComputeUnitLimit(umi, { units: 600_000 })) .add( - mintV2(umi, { + mintV1(umi, { candyMachine, asset: mint, payer, diff --git a/clients/js/test/defaultGuards/startDate.test.ts b/clients/js/test/defaultGuards/startDate.test.ts index b6540c1..2b1da73 100644 --- a/clients/js/test/defaultGuards/startDate.test.ts +++ b/clients/js/test/defaultGuards/startDate.test.ts @@ -6,7 +6,7 @@ import { transactionBuilder, } from '@metaplex-foundation/umi'; import test from 'ava'; -import { mintV2 } from '../../src'; +import { mintV1 } from '../../src'; import { assertBotTax, assertSuccessfulMint, @@ -34,7 +34,7 @@ test('it allows minting after the start date', async (t) => { await transactionBuilder() .add(setComputeUnitLimit(umi, { units: 600_000 })) .add( - mintV2(umi, { + mintV1(umi, { candyMachine, asset: mint, collection, @@ -63,7 +63,7 @@ test('it forbids minting before the start date', async (t) => { const promise = transactionBuilder() .add(setComputeUnitLimit(umi, { units: 600_000 })) .add( - mintV2(umi, { + mintV1(umi, { candyMachine, asset: mint, collection, @@ -93,7 +93,7 @@ test('it charges a bot tax when trying to mint before the start date', async (t) const { signature } = await transactionBuilder() .add(setComputeUnitLimit(umi, { units: 600_000 })) .add( - mintV2(umi, { + mintV1(umi, { candyMachine, asset: mint, collection, diff --git a/clients/js/test/defaultGuards/thirdPartySigner.test.ts b/clients/js/test/defaultGuards/thirdPartySigner.test.ts index 6f97cf7..0f5987e 100644 --- a/clients/js/test/defaultGuards/thirdPartySigner.test.ts +++ b/clients/js/test/defaultGuards/thirdPartySigner.test.ts @@ -6,7 +6,7 @@ import { transactionBuilder, } from '@metaplex-foundation/umi'; import test from 'ava'; -import { mintV2 } from '../../src'; +import { mintV1 } from '../../src'; import { assertBotTax, assertSuccessfulMint, @@ -33,7 +33,7 @@ test('it allows minting when the third party signer is provided', async (t) => { await transactionBuilder() .add(setComputeUnitLimit(umi, { units: 600_000 })) .add( - mintV2(umi, { + mintV1(umi, { candyMachine, asset: mint, collection, @@ -67,7 +67,7 @@ test('it forbids minting when the third party signer is wrong', async (t) => { const promise = transactionBuilder() .add(setComputeUnitLimit(umi, { units: 600_000 })) .add( - mintV2(umi, { + mintV1(umi, { candyMachine, asset: mint, collection, @@ -102,7 +102,7 @@ test('it charges a bot tax when trying to mint using the wrong third party signe const { signature } = await transactionBuilder() .add(setComputeUnitLimit(umi, { units: 600_000 })) .add( - mintV2(umi, { + mintV1(umi, { candyMachine, asset: mint, collection, diff --git a/clients/js/test/defaultGuards/token2022Payment.test.ts b/clients/js/test/defaultGuards/token2022Payment.test.ts index 257ad16..3eb7145 100644 --- a/clients/js/test/defaultGuards/token2022Payment.test.ts +++ b/clients/js/test/defaultGuards/token2022Payment.test.ts @@ -8,7 +8,7 @@ import { transactionBuilder, } from '@metaplex-foundation/umi'; import test from 'ava'; -import { mintV2 } from '../../src'; +import { mintV1 } from '../../src'; import { assertSuccessfulMint, createCollection, @@ -56,7 +56,7 @@ test('it transfers Token2022 tokens from the payer to the destination', async (t await transactionBuilder() .add(setComputeUnitLimit(umi, { units: 600_000 })) .add( - mintV2(umi, { + mintV1(umi, { candyMachine, asset: mint, collection, diff --git a/clients/js/test/defaultGuards/tokenBurn.test.ts b/clients/js/test/defaultGuards/tokenBurn.test.ts index 0e15a3d..301055d 100644 --- a/clients/js/test/defaultGuards/tokenBurn.test.ts +++ b/clients/js/test/defaultGuards/tokenBurn.test.ts @@ -18,7 +18,7 @@ import { createUmi, createV2, } from '../_setup'; -import { mintV2 } from '../../src'; +import { mintV1 } from '../../src'; test('it burns a specific token to allow minting', async (t) => { // Given a payer with one token. @@ -49,7 +49,7 @@ test('it burns a specific token to allow minting', async (t) => { await transactionBuilder() .add(setComputeUnitLimit(umi, { units: 600_000 })) .add( - mintV2(umi, { + mintV1(umi, { candyMachine, asset: mint, collection, @@ -104,7 +104,7 @@ test('it allows minting even when the payer is different from the minter', async await transactionBuilder() .add(setComputeUnitLimit(umi, { units: 600_000 })) .add( - mintV2(umi, { + mintV1(umi, { candyMachine, asset: mint, minter, @@ -159,7 +159,7 @@ test('it may burn multiple tokens from a specific mint', async (t) => { await transactionBuilder() .add(setComputeUnitLimit(umi, { units: 600_000 })) .add( - mintV2(umi, { + mintV1(umi, { candyMachine, asset: mint, collection, @@ -213,7 +213,7 @@ test('it fails to mint if there are not enough tokens to burn', async (t) => { const promise = transactionBuilder() .add(setComputeUnitLimit(umi, { units: 600_000 })) .add( - mintV2(umi, { + mintV1(umi, { candyMachine, asset: mint, collection, @@ -268,7 +268,7 @@ test('it charges a bot tax when trying to mint without the required amount of to const { signature } = await transactionBuilder() .add(setComputeUnitLimit(umi, { units: 600_000 })) .add( - mintV2(umi, { + mintV1(umi, { candyMachine, asset: mint, collection, diff --git a/clients/js/test/defaultGuards/tokenGate.test.ts b/clients/js/test/defaultGuards/tokenGate.test.ts index 67143b9..1fd1e5f 100644 --- a/clients/js/test/defaultGuards/tokenGate.test.ts +++ b/clients/js/test/defaultGuards/tokenGate.test.ts @@ -11,7 +11,7 @@ import { transactionBuilder, } from '@metaplex-foundation/umi'; import test from 'ava'; -import { mintV2 } from '../../src'; +import { mintV1 } from '../../src'; import { assertBotTax, assertSuccessfulMint, @@ -49,7 +49,7 @@ test('it allows minting when the payer owns a specific token', async (t) => { await transactionBuilder() .add(setComputeUnitLimit(umi, { units: 600_000 })) .add( - mintV2(umi, { + mintV1(umi, { candyMachine, asset: mint, collection, @@ -94,7 +94,7 @@ test('it allows minting even when the payer is different from the minter', async await transactionBuilder() .add(setComputeUnitLimit(umi, { units: 600_000 })) .add( - mintV2(umi, { + mintV1(umi, { candyMachine, asset: mint, minter, @@ -139,7 +139,7 @@ test('it allows minting when the payer owns multiple tokens from a specific mint await transactionBuilder() .add(setComputeUnitLimit(umi, { units: 600_000 })) .add( - mintV2(umi, { + mintV1(umi, { candyMachine, asset: mint, collection, @@ -193,7 +193,7 @@ test('it forbids minting when the owner does not own any required tokens', async const promise = transactionBuilder() .add(setComputeUnitLimit(umi, { units: 600_000 })) .add( - mintV2(umi, { + mintV1(umi, { candyMachine, asset: mint, collection, @@ -237,7 +237,7 @@ test('it forbids minting when the owner does not own enough tokens', async (t) = const promise = transactionBuilder() .add(setComputeUnitLimit(umi, { units: 600_000 })) .add( - mintV2(umi, { + mintV1(umi, { candyMachine, asset: mint, collection, @@ -282,7 +282,7 @@ test('it charges a bot tax when trying to mint without the right amount of token const { signature } = await transactionBuilder() .add(setComputeUnitLimit(umi, { units: 600_000 })) .add( - mintV2(umi, { + mintV1(umi, { candyMachine, asset: mint, collection, diff --git a/clients/js/test/defaultGuards/tokenPayment.test.ts b/clients/js/test/defaultGuards/tokenPayment.test.ts index 08c1175..f52d573 100644 --- a/clients/js/test/defaultGuards/tokenPayment.test.ts +++ b/clients/js/test/defaultGuards/tokenPayment.test.ts @@ -9,7 +9,7 @@ import { transactionBuilder, } from '@metaplex-foundation/umi'; import test from 'ava'; -import { mintV2 } from '../../src'; +import { mintV1 } from '../../src'; import { assertBotTax, assertSuccessfulMint, @@ -54,7 +54,7 @@ test('it transfers tokens from the payer to the destination', async (t) => { await transactionBuilder() .add(setComputeUnitLimit(umi, { units: 600_000 })) .add( - mintV2(umi, { + mintV1(umi, { candyMachine, asset: mint, collection, @@ -113,7 +113,7 @@ test('it allows minting even when the payer is different from the minter', async await transactionBuilder() .add(setComputeUnitLimit(umi, { units: 600_000 })) .add( - mintV2(umi, { + mintV1(umi, { candyMachine, asset: mint, minter, @@ -170,7 +170,7 @@ test('it fails if the payer does not have enough tokens', async (t) => { const promise = transactionBuilder() .add(setComputeUnitLimit(umi, { units: 600_000 })) .add( - mintV2(umi, { + mintV1(umi, { candyMachine, asset: mint, collection, @@ -223,7 +223,7 @@ test('it charges a bot tax if the payer does not have enough tokens', async (t) const { signature } = await transactionBuilder() .add(setComputeUnitLimit(umi, { units: 600_000 })) .add( - mintV2(umi, { + mintV1(umi, { candyMachine, asset: mint, collection, diff --git a/clients/js/test/edition.test.ts b/clients/js/test/edition.test.ts index a7f1cb4..fa2473e 100644 --- a/clients/js/test/edition.test.ts +++ b/clients/js/test/edition.test.ts @@ -9,7 +9,7 @@ import { } from '@metaplex-foundation/umi'; import { generateSignerWithSol } from '@metaplex-foundation/umi-bundle-tests'; import test from 'ava'; -import { CandyMachine, fetchCandyMachine, mintV2 } from '../src'; +import { CandyMachine, fetchCandyMachine, mintV1 } from '../src'; import { assertSuccessfulMint, createCollection, @@ -42,7 +42,7 @@ test('it can mint edition from a candy guard with guards', async (t) => { await transactionBuilder() .add(setComputeUnitLimit(umi, { units: 600_000 })) .add( - mintV2(umi, { + mintV1(umi, { candyMachine, asset: mint, payer, @@ -98,7 +98,7 @@ test('it can mint edition from a candy guard with groups', async (t) => { await transactionBuilder() .add(setComputeUnitLimit(umi, { units: 600_000 })) .add( - mintV2(umi, { + mintV1(umi, { candyMachine, asset: mint, minter, @@ -142,7 +142,7 @@ test('it can mint many editions from a candy machine with guard in order', async await transactionBuilder() .add(setComputeUnitLimit(umi, { units: 600_000 })) .add( - mintV2(umi, { + mintV1(umi, { candyMachine, asset: mint, payer, @@ -187,7 +187,7 @@ test('it can mint many editions from a candy machine with guard starting from of await transactionBuilder() .add(setComputeUnitLimit(umi, { units: 600_000 })) .add( - mintV2(umi, { + mintV1(umi, { candyMachine, asset: mint, payer, @@ -228,7 +228,7 @@ test('it can mint edition from a candy machine using hidden settings', async (t) await transactionBuilder() .add(setComputeUnitLimit(umi, { units: 600_000 })) .add( - mintV2(umi, { + mintV1(umi, { candyMachine, minter, asset: mint, @@ -272,7 +272,7 @@ test('it overflows when trying to mint editions out of bounds', async (t) => { const res = transactionBuilder() .add(setComputeUnitLimit(umi, { units: 600_000 })) .add( - mintV2(umi, { + mintV1(umi, { candyMachine, minter, asset: mint, diff --git a/clients/js/test/initializeCandyMachineV2.test.ts b/clients/js/test/initializeCandyMachineV2.test.ts index eab696c..c9af4a0 100644 --- a/clients/js/test/initializeCandyMachineV2.test.ts +++ b/clients/js/test/initializeCandyMachineV2.test.ts @@ -8,16 +8,15 @@ import { } from '@metaplex-foundation/umi'; import test from 'ava'; import { - AccountVersion, CandyMachine, fetchCandyMachine, - initializeCandyMachineV2, + initializeCandyMachine, } from '../src'; import { createCollection, createUmi } from './_setup'; /** - * Note that most of the tests for the "initializeCandyMachineV2" instructions are - * part of the "createCandyMachineV2" tests as they are more convenient to test. + * Note that most of the tests for the "initializeCandyMachine" instructions are + * part of the "createCandyMachine" tests as they are more convenient to test. */ test('it can initialize a new candy machine account', async (t) => { @@ -40,7 +39,7 @@ test('it can initialize a new candy machine account', async (t) => { // When we initialize a candy machine at this address. await transactionBuilder() .add( - initializeCandyMachineV2(umi, { + initializeCandyMachine(umi, { candyMachine: candyMachine.publicKey, collection: collection.publicKey, collectionUpdateAuthority: umi.identity, @@ -66,7 +65,6 @@ test('it can initialize a new candy machine account', async (t) => { authority: publicKey(umi.identity), mintAuthority: publicKey(umi.identity), collectionMint: publicKey(collection), - version: AccountVersion.V2, itemsRedeemed: 0n, data: { itemsAvailable: 100n, diff --git a/clients/js/test/mintV2.test.ts b/clients/js/test/mintV1.test.ts similarity index 97% rename from clients/js/test/mintV2.test.ts rename to clients/js/test/mintV1.test.ts index d31329a..4b89b55 100644 --- a/clients/js/test/mintV2.test.ts +++ b/clients/js/test/mintV1.test.ts @@ -12,7 +12,7 @@ import { import { generateSignerWithSol } from '@metaplex-foundation/umi-bundle-tests'; import test from 'ava'; import { fetchAssetV1 } from '@metaplex-foundation/mpl-core'; -import { CandyMachine, fetchCandyMachine, mintV2 } from '../src'; +import { CandyMachine, fetchCandyMachine, mintV1 } from '../src'; import { assertSuccessfulMint, createCollection, @@ -40,7 +40,7 @@ test('it can mint from a candy guard with no guards', async (t) => { await transactionBuilder() .add(setComputeUnitLimit(umi, { units: 600_000 })) .add( - mintV2(umi, { + mintV1(umi, { candyMachine, minter, asset: mint, @@ -79,7 +79,7 @@ test('it can mint from a candy guard with guards', async (t) => { await transactionBuilder() .add(setComputeUnitLimit(umi, { units: 600_000 })) .add( - mintV2(umi, { + mintV1(umi, { candyMachine, asset: mint, payer, @@ -127,7 +127,7 @@ test('it can mint from a candy guard with guards to different owner', async (t) await transactionBuilder() .add(setComputeUnitLimit(umi, { units: 600_000 })) .add( - mintV2(umi, { + mintV1(umi, { candyMachine, asset: mint, payer, @@ -178,7 +178,7 @@ test('it can mint from a candy guard with groups', async (t) => { await transactionBuilder() .add(setComputeUnitLimit(umi, { units: 600_000 })) .add( - mintV2(umi, { + mintV1(umi, { candyMachine, asset: mint, minter, @@ -215,7 +215,7 @@ test('it cannot mint using the default guards if the candy guard has groups', as const promise = transactionBuilder() .add(setComputeUnitLimit(umi, { units: 600_000 })) .add( - mintV2(umi, { + mintV1(umi, { candyMachine, asset: mint, minter, @@ -248,7 +248,7 @@ test('it cannot mint from a group if the provided group label does not exist', a const promise = transactionBuilder() .add(setComputeUnitLimit(umi, { units: 600_000 })) .add( - mintV2(umi, { + mintV1(umi, { candyMachine, asset: mint, minter, @@ -283,7 +283,7 @@ test('it can mint using an explicit payer', async (t) => { await transactionBuilder() .add(setComputeUnitLimit(umi, { units: 600_000 })) .add( - mintV2(umi, { + mintV1(umi, { candyMachine, minter, payer, @@ -318,7 +318,7 @@ test('it cannot mint from an empty candy machine', async (t) => { const promise = transactionBuilder() .add(setComputeUnitLimit(umi, { units: 600_000 })) .add( - mintV2(umi, { + mintV1(umi, { candyMachine, asset: mint, minter, @@ -348,7 +348,7 @@ test('it cannot mint from a candy machine that is not fully loaded', async (t) = const promise = transactionBuilder() .add(setComputeUnitLimit(umi, { units: 600_000 })) .add( - mintV2(umi, { + mintV1(umi, { candyMachine, asset: mint, minter, @@ -374,7 +374,7 @@ test('it cannot mint from a candy machine that has been fully minted', async (t) await transactionBuilder() .add(setComputeUnitLimit(umi, { units: 600_000 })) .add( - mintV2(umi, { + mintV1(umi, { candyMachine, asset: mint, collection, @@ -387,7 +387,7 @@ test('it cannot mint from a candy machine that has been fully minted', async (t) const promise = transactionBuilder() .add(setComputeUnitLimit(umi, { units: 600_000 })) .add( - mintV2(umi, { + mintV1(umi, { candyMachine, asset: generateSigner(umi), collection, @@ -421,7 +421,7 @@ test('it can mint from a candy machine using hidden settings', async (t) => { await transactionBuilder() .add(setComputeUnitLimit(umi, { units: 600_000 })) .add( - mintV2(umi, { + mintV1(umi, { candyMachine, minter, asset: mint, @@ -517,7 +517,7 @@ test('it can mint a programmable NFT', async (t) => { await transactionBuilder() .add(setComputeUnitLimit(umi, { units: 600_000 })) .add( - mintV2(umi, { + mintV1(umi, { candyMachine, minter, asset: mint, @@ -551,7 +551,7 @@ const drain = async ( await transactionBuilder() .add(setComputeUnitLimit(umi, { units: 600_000 })) .add( - mintV2(umi, { + mintV1(umi, { candyMachine, minter, asset: mint, diff --git a/clients/js/test/setCollectionV2.test.ts b/clients/js/test/setCollection.test.ts similarity index 97% rename from clients/js/test/setCollectionV2.test.ts rename to clients/js/test/setCollection.test.ts index 68f4f82..34e6d77 100644 --- a/clients/js/test/setCollectionV2.test.ts +++ b/clients/js/test/setCollection.test.ts @@ -14,7 +14,7 @@ import { CandyMachine, fetchCandyMachine, mintAssetFromCandyMachine, - setCollectionV2, + setCollection, } from '../src'; import { createCollection, createUmi, createV2 } from './_setup'; @@ -36,7 +36,7 @@ test('it can update the collection of a candy machine v2', async (t) => { updateAuthority: collectionUpdateAuthorityB.publicKey, }); - await setCollectionV2(umi, { + await setCollection(umi, { candyMachine: candyMachine.publicKey, collection: collectionA.publicKey, collectionUpdateAuthority: collectionUpdateAuthorityA.publicKey, @@ -89,7 +89,7 @@ test('it cannot update the collection of a candy machine when mint is in progres const collectionB = await createCollection(umi, { updateAuthority: collectionUpdateAuthorityB.publicKey, }); - const promise = setCollectionV2(umi, { + const promise = setCollection(umi, { candyMachine: candyMachine.publicKey, collection: collectionA.publicKey, collectionUpdateAuthority: collectionUpdateAuthorityA.publicKey, @@ -142,7 +142,7 @@ test.only('it can set the same collection of a candy machine when mint is in pro }).sendAndConfirm(umi); // When we set the same collection. - await setCollectionV2(umi, { + await setCollection(umi, { candyMachine: candyMachine.publicKey, collection: collectionA.publicKey, collectionUpdateAuthority: collectionUpdateAuthorityA.publicKey, diff --git a/configs/kinobi.cjs b/configs/kinobi.cjs index 07cd459..2420e03 100755 --- a/configs/kinobi.cjs +++ b/configs/kinobi.cjs @@ -348,8 +348,8 @@ kinobi.update( }, }, }, - "mplCoreCandyMachineCore.initializeV2": { - name: "initializeCandyMachineV2", + "mplCoreCandyMachineCore.initialize": { + name: "initializeCandyMachine", }, "mplCoreCandyMachineCore.mintAsset": { name: "mintAssetFromCandyMachine", @@ -380,7 +380,7 @@ kinobi.update( candyMachineProgram: { defaultsTo: defaultsToCandyMachineAssetProgram() }, } }, - "mplCoreCandyGuard.mintV2": { + "mplCoreCandyGuard.mintV1": { internal: true, args: { label: { name: "group" }, @@ -404,7 +404,7 @@ kinobi.update( candyMachineProgram: { defaultsTo: defaultsToCandyMachineAssetProgram() }, }, }, - "mplCoreCandyMachineCore.setCollectionV2": { + "mplCoreCandyMachineCore.setCollection": { accounts: { newCollectionDelegateRecord: { defaultsTo: defaultsToMetadataDelegateRecordPda( @@ -429,7 +429,6 @@ kinobi.update( kinobi.update( new k.UnwrapTypeDefinedLinksVisitor([ "initializeCandyMachine.candyMachineData", - "initializeCandyMachineV2.candyMachineData", ]) ); kinobi.update(new k.FlattenInstructionArgsStructVisitor()); @@ -445,7 +444,6 @@ const defaultInitialCandyMachineData = { kinobi.update( new k.SetStructDefaultValuesVisitor({ initializeCandyMachineInstructionData: defaultInitialCandyMachineData, - initializeCandyMachineV2InstructionData: defaultInitialCandyMachineData, }) ); @@ -455,8 +453,6 @@ kinobi.update( new k.SetNumberWrappersVisitor({ "candyMachineData.sellerFeeBasisPoints": percentAmount, "initializeCandyMachineInstructionData.sellerFeeBasisPoints": percentAmount, - "initializeCandyMachineV2InstructionData.sellerFeeBasisPoints": - percentAmount, "startDate.date": { kind: "DateTime" }, "endDate.date": { kind: "DateTime" }, "botTax.lamports": { kind: "SolAmount" }, diff --git a/idls/candy_guard.json b/idls/candy_guard.json index 6e8523b..4ab2352 100644 --- a/idls/candy_guard.json +++ b/idls/candy_guard.json @@ -42,7 +42,7 @@ ] }, { - "name": "mintV2", + "name": "mintV1", "docs": [ "Mint an NFT from a candy machine wrapped in the candy guard." ], diff --git a/idls/candy_machine_core.json b/idls/candy_machine_core.json index 2c9b313..d467832 100644 --- a/idls/candy_machine_core.json +++ b/idls/candy_machine_core.json @@ -46,7 +46,7 @@ ] }, { - "name": "initializeV2", + "name": "initialize", "docs": [ "Initialize the candy machine account with the specified data and token standard.", "", @@ -324,7 +324,7 @@ ] }, { - "name": "setCollectionV2", + "name": "setCollection", "docs": [ "Set the collection mint for the candy machine.", "", @@ -564,15 +564,6 @@ "type": { "kind": "struct", "fields": [ - { - "name": "version", - "docs": [ - "Version of the account." - ], - "type": { - "defined": "AccountVersion" - } - }, { "name": "authority", "docs": [ @@ -792,23 +783,6 @@ } ] } - }, - { - "name": "AccountVersion", - "docs": [ - "Account versioning." - ], - "type": { - "kind": "enum", - "variants": [ - { - "name": "V1" - }, - { - "name": "V2" - } - ] - } } ], "errors": [ diff --git a/programs/candy-guard/program/src/guards/nft_burn.rs b/programs/candy-guard/program/src/guards/nft_burn.rs index 9f4e9aa..29e2119 100644 --- a/programs/candy-guard/program/src/guards/nft_burn.rs +++ b/programs/candy-guard/program/src/guards/nft_burn.rs @@ -1,9 +1,8 @@ use super::*; -use mpl_core_candy_machine_core::AccountVersion; use mpl_token_metadata::{ accounts::{Metadata, TokenRecord}, - instructions::{BurnNftCpiBuilder, BurnV1CpiBuilder}, + instructions::BurnV1CpiBuilder, types::TokenStandard, }; @@ -107,42 +106,30 @@ impl Condition for NftBurn { let spl_token_info = spl_token_program.to_account_info(); let token_metadata_info = token_metadata_program.to_account_info(); - if matches!(ctx.accounts.candy_machine.version, AccountVersion::V2) { - let metadata: Metadata = Metadata::try_from(nft_metadata)?; - let mut burn_cpi = BurnV1CpiBuilder::new(&token_metadata_info); - burn_cpi - .authority(&ctx.accounts.minter) - .metadata(nft_metadata) - .edition(Some(nft_edition)) - .mint(nft_mint_account) - .token(nft_account) - .collection_metadata(Some(nft_mint_collection_metadata)) - .system_program(&ctx.accounts.system_program) - .sysvar_instructions(&ctx.accounts.sysvar_instructions) - .spl_token_program(&spl_token_info) - .amount(1); - - if matches!( - metadata.token_standard, - Some(TokenStandard::ProgrammableNonFungible) - ) { - let token_record_info = try_get_account_info(ctx.accounts.remaining, index + 7)?; - burn_cpi.token_record(Some(token_record_info)); - } - - burn_cpi.invoke()?; - } else { - BurnNftCpiBuilder::new(&token_metadata_program.to_account_info()) - .metadata(nft_metadata) - .owner(&ctx.accounts.payer) - .mint(nft_mint_account) - .token_account(nft_account) - .master_edition_account(nft_edition) - .collection_metadata(Some(nft_mint_collection_metadata)) - .spl_token_program(&spl_token_program.to_account_info()) - .invoke()?; + let metadata: Metadata = Metadata::try_from(nft_metadata)?; + let mut burn_cpi = BurnV1CpiBuilder::new(&token_metadata_info); + burn_cpi + .authority(&ctx.accounts.minter) + .metadata(nft_metadata) + .edition(Some(nft_edition)) + .mint(nft_mint_account) + .token(nft_account) + .collection_metadata(Some(nft_mint_collection_metadata)) + .system_program(&ctx.accounts.system_program) + .sysvar_instructions(&ctx.accounts.sysvar_instructions) + .spl_token_program(&spl_token_info) + .amount(1); + + if matches!( + metadata.token_standard, + Some(TokenStandard::ProgrammableNonFungible) + ) { + let token_record_info = try_get_account_info(ctx.accounts.remaining, index + 7)?; + burn_cpi.token_record(Some(token_record_info)); } + burn_cpi.invoke()?; + Ok(()) } } diff --git a/programs/candy-guard/program/src/guards/nft_payment.rs b/programs/candy-guard/program/src/guards/nft_payment.rs index d31daf0..db7d500 100644 --- a/programs/candy-guard/program/src/guards/nft_payment.rs +++ b/programs/candy-guard/program/src/guards/nft_payment.rs @@ -1,17 +1,12 @@ -use mpl_core_candy_machine_core::{constants::MPL_TOKEN_AUTH_RULES_PROGRAM, AccountVersion}; +use mpl_core_candy_machine_core::constants::MPL_TOKEN_AUTH_RULES_PROGRAM; use mpl_token_metadata::{ accounts::{MasterEdition, Metadata, TokenRecord}, instructions::TransferV1CpiBuilder, types::{ProgrammableConfig, TokenStandard}, }; -use solana_program::program::invoke; -use spl_associated_token_account::instruction::create_associated_token_account; use super::*; -use crate::{ - state::GuardType, - utils::{assert_keys_equal, spl_token_transfer, TokenTransferParams}, -}; +use crate::{state::GuardType, utils::assert_keys_equal}; /// Guard that charges another NFT (token) from a specific collection as payment /// for the mint. @@ -157,85 +152,51 @@ impl Condition for NftPayment { let spl_token_info = spl_token_program.to_account_info(); let token_metadata_info = spl_token_program.to_account_info(); - if matches!(ctx.accounts.candy_machine.version, AccountVersion::V2) { - let mut transfer_cpi = TransferV1CpiBuilder::new(&token_metadata_info); + let mut transfer_cpi = TransferV1CpiBuilder::new(&token_metadata_info); + transfer_cpi + .token(nft_account) + .token_owner(&ctx.accounts.minter) + .destination_token(destination_ata) + .destination_owner(destination) + .mint(nft_mint) + .metadata(nft_metadata) + .authority(&ctx.accounts.minter) + .payer(&ctx.accounts.payer) + .system_program(&ctx.accounts.system_program) + .sysvar_instructions(&ctx.accounts.sysvar_instructions) + .spl_token_program(&spl_token_info) + .spl_ata_program(spl_ata_program) + .amount(1); + + let metadata: Metadata = Metadata::try_from(nft_metadata)?; + + if matches!( + metadata.token_standard, + Some(TokenStandard::ProgrammableNonFungible) + ) { + let nft_master_edition = try_get_account_info(ctx.accounts.remaining, index + 8)?; + let owner_token_record = try_get_account_info(ctx.accounts.remaining, index + 9)?; + let destination_token_record = + try_get_account_info(ctx.accounts.remaining, index + 10)?; + transfer_cpi - .token(nft_account) - .token_owner(&ctx.accounts.minter) - .destination_token(destination_ata) - .destination_owner(destination) - .mint(nft_mint) - .metadata(nft_metadata) - .authority(&ctx.accounts.minter) - .payer(&ctx.accounts.payer) - .system_program(&ctx.accounts.system_program) - .sysvar_instructions(&ctx.accounts.sysvar_instructions) - .spl_token_program(&spl_token_info) - .spl_ata_program(spl_ata_program) - .amount(1); - - let metadata: Metadata = Metadata::try_from(nft_metadata)?; - - if matches!( - metadata.token_standard, - Some(TokenStandard::ProgrammableNonFungible) - ) { - let nft_master_edition = try_get_account_info(ctx.accounts.remaining, index + 8)?; - let owner_token_record = try_get_account_info(ctx.accounts.remaining, index + 9)?; - let destination_token_record = - try_get_account_info(ctx.accounts.remaining, index + 10)?; + .edition(Some(nft_master_edition)) + .token_record(Some(owner_token_record)) + .destination_token_record(Some(destination_token_record)); + + if let Some(ProgrammableConfig::V1 { rule_set: Some(_) }) = metadata.programmable_config + { + let auth_rules_program = try_get_account_info(ctx.accounts.remaining, index + 11)?; + let auth_rules = try_get_account_info(ctx.accounts.remaining, index + 12)?; transfer_cpi - .edition(Some(nft_master_edition)) - .token_record(Some(owner_token_record)) - .destination_token_record(Some(destination_token_record)); - - if let Some(ProgrammableConfig::V1 { rule_set: Some(_) }) = - metadata.programmable_config - { - let auth_rules_program = - try_get_account_info(ctx.accounts.remaining, index + 11)?; - let auth_rules = try_get_account_info(ctx.accounts.remaining, index + 12)?; - - transfer_cpi - .authorization_rules_program(Some(auth_rules_program)) - .authorization_rules(Some(auth_rules)); - } + .authorization_rules_program(Some(auth_rules_program)) + .authorization_rules(Some(auth_rules)); } - - transfer_cpi.invoke()?; - } else { - // creates the ATA to receive the NFT - - invoke( - &create_associated_token_account( - ctx.accounts.payer.key, - &self.destination, - nft_mint.key, - &spl_token::ID, - ), - &[ - ctx.accounts.payer.to_account_info(), - destination_ata.to_account_info(), - destination.to_account_info(), - nft_mint.to_account_info(), - ctx.accounts.system_program.to_account_info(), - ], - )?; - - // transfers the NFT - - spl_token_transfer(TokenTransferParams { - source: nft_account.to_account_info(), - destination: destination_ata.to_account_info(), - authority: ctx.accounts.payer.to_account_info(), - authority_signer_seeds: &[], - token_program: spl_token_program.to_account_info(), - // fixed to always require 1 NFT - amount: 1, - })?; } + transfer_cpi.invoke()?; + Ok(()) } } diff --git a/programs/candy-guard/program/src/instructions/mint_v2.rs b/programs/candy-guard/program/src/instructions/mint_v1.rs similarity index 98% rename from programs/candy-guard/program/src/instructions/mint_v2.rs rename to programs/candy-guard/program/src/instructions/mint_v1.rs index cf9c12c..f2f95b3 100644 --- a/programs/candy-guard/program/src/instructions/mint_v2.rs +++ b/programs/candy-guard/program/src/instructions/mint_v1.rs @@ -12,8 +12,8 @@ use crate::{ use super::MintAccounts; -pub fn mint_v2<'info>( - ctx: Context<'_, '_, '_, 'info, MintV2<'info>>, +pub fn mint_v1<'info>( + ctx: Context<'_, '_, '_, 'info, MintV1<'info>>, mint_args: Vec, label: Option, ) -> Result<()> { @@ -187,7 +187,7 @@ fn cpi_mint(ctx: &EvaluationContext) -> Result<()> { /// Mint an NFT. #[derive(Accounts)] -pub struct MintV2<'info> { +pub struct MintV1<'info> { /// Candy Guard account. #[account(seeds = [SEED, candy_guard.base.key().as_ref()], bump = candy_guard.bump)] candy_guard: Account<'info, CandyGuard>, diff --git a/programs/candy-guard/program/src/instructions/mod.rs b/programs/candy-guard/program/src/instructions/mod.rs index 750c5f0..64f9a93 100644 --- a/programs/candy-guard/program/src/instructions/mod.rs +++ b/programs/candy-guard/program/src/instructions/mod.rs @@ -1,6 +1,6 @@ use anchor_lang::prelude::*; pub use initialize::*; -pub use mint_v2::*; +pub use mint_v1::*; use mpl_core_candy_machine_core::CandyMachine; pub use route::*; pub use set_authority::*; @@ -12,7 +12,7 @@ pub use wrap::*; use crate::state::CandyGuard; pub mod initialize; -pub mod mint_v2; +pub mod mint_v1; pub mod route; pub mod set_authority; pub mod unwrap; diff --git a/programs/candy-guard/program/src/lib.rs b/programs/candy-guard/program/src/lib.rs index 4da534c..d2659fb 100644 --- a/programs/candy-guard/program/src/lib.rs +++ b/programs/candy-guard/program/src/lib.rs @@ -22,12 +22,12 @@ pub mod candy_guard { } /// Mint an NFT from a candy machine wrapped in the candy guard. - pub fn mint_v2<'info>( - ctx: Context<'_, '_, '_, 'info, MintV2<'info>>, + pub fn mint_v1<'info>( + ctx: Context<'_, '_, '_, 'info, MintV1<'info>>, mint_args: Vec, label: Option, ) -> Result<()> { - instructions::mint_v2(ctx, mint_args, label) + instructions::mint_v1(ctx, mint_args, label) } /// Route the transaction to a guard instruction. diff --git a/programs/candy-machine-core/program/src/constants.rs b/programs/candy-machine-core/program/src/constants.rs index 4087506..48dbd61 100644 --- a/programs/candy-machine-core/program/src/constants.rs +++ b/programs/candy-machine-core/program/src/constants.rs @@ -23,7 +23,6 @@ pub const AUTHORITY_SEED: &str = "candy_machine"; // Determine the start of the account hidden section. pub const HIDDEN_SECTION: usize = 8 // discriminator - + 1 // version + 32 // authority + 32 // mint authority + 32 // collection mint diff --git a/programs/candy-machine-core/program/src/instructions/initialize_v2.rs b/programs/candy-machine-core/program/src/instructions/initialize.rs similarity index 94% rename from programs/candy-machine-core/program/src/instructions/initialize_v2.rs rename to programs/candy-machine-core/program/src/instructions/initialize.rs index 067ad49..6f44de9 100644 --- a/programs/candy-machine-core/program/src/instructions/initialize_v2.rs +++ b/programs/candy-machine-core/program/src/instructions/initialize.rs @@ -4,15 +4,14 @@ use crate::{ approve_asset_collection_delegate, constants::{AUTHORITY_SEED, HIDDEN_SECTION}, state::{CandyMachine, CandyMachineData}, - AccountVersion, ApproveAssetDelegateHelperAccounts, + ApproveAssetDelegateHelperAccounts, }; -pub fn initialize_v2(ctx: Context, data: CandyMachineData) -> Result<()> { +pub fn initialize(ctx: Context, data: CandyMachineData) -> Result<()> { let candy_machine_account = &mut ctx.accounts.candy_machine; let candy_machine = CandyMachine { data, - version: AccountVersion::V2, authority: ctx.accounts.authority.key(), mint_authority: ctx.accounts.authority.key(), collection_mint: ctx.accounts.collection.key(), @@ -49,7 +48,7 @@ pub fn initialize_v2(ctx: Context, data: CandyMachineData) -> Resu /// Initializes a new candy machine. #[derive(Accounts)] #[instruction(data: CandyMachineData)] -pub struct InitializeV2<'info> { +pub struct Initialize<'info> { /// Candy Machine account. The account space must be allocated to allow accounts larger /// than 10kb. /// diff --git a/programs/candy-machine-core/program/src/instructions/mod.rs b/programs/candy-machine-core/program/src/instructions/mod.rs index 0d360d1..7774f68 100644 --- a/programs/candy-machine-core/program/src/instructions/mod.rs +++ b/programs/candy-machine-core/program/src/instructions/mod.rs @@ -1,17 +1,17 @@ pub mod add_config_lines; -pub mod initialize_v2; +pub mod initialize; pub mod mint_asset; pub mod set_authority; -pub mod set_collection_v2; +pub mod set_collection; pub mod set_mint_authority; pub mod update; pub mod withdraw; pub use add_config_lines::*; -pub use initialize_v2::*; +pub use initialize::*; pub use mint_asset::*; pub use set_authority::*; -pub use set_collection_v2::*; +pub use set_collection::*; pub use set_mint_authority::*; pub use update::*; pub use withdraw::*; diff --git a/programs/candy-machine-core/program/src/instructions/set_collection_v2.rs b/programs/candy-machine-core/program/src/instructions/set_collection.rs similarity index 97% rename from programs/candy-machine-core/program/src/instructions/set_collection_v2.rs rename to programs/candy-machine-core/program/src/instructions/set_collection.rs index 907e2dc..05aa8fc 100644 --- a/programs/candy-machine-core/program/src/instructions/set_collection_v2.rs +++ b/programs/candy-machine-core/program/src/instructions/set_collection.rs @@ -6,7 +6,7 @@ use crate::{ RevokeAssetDelegateHelperAccounts, }; -pub fn set_collection_v2(ctx: Context) -> Result<()> { +pub fn set_collection(ctx: Context) -> Result<()> { let accounts = ctx.accounts; let candy_machine = &mut accounts.candy_machine; @@ -55,7 +55,7 @@ pub fn set_collection_v2(ctx: Context) -> Result<()> { /// Sets the collection PDA for the candy machine. #[derive(Accounts)] -pub struct SetCollectionV2<'info> { +pub struct SetCollection<'info> { /// Candy Machine account. #[account(mut, has_one = authority)] candy_machine: Box>, diff --git a/programs/candy-machine-core/program/src/lib.rs b/programs/candy-machine-core/program/src/lib.rs index 3c80582..6661c69 100644 --- a/programs/candy-machine-core/program/src/lib.rs +++ b/programs/candy-machine-core/program/src/lib.rs @@ -51,8 +51,8 @@ pub mod candy_machine_core { /// 11. `[]` Instructions sysvar account /// 12. `[optional]` Token Authorization Rules program /// 13. `[optional]` Token authorization rules account - pub fn initialize_v2(ctx: Context, data: CandyMachineData) -> Result<()> { - instructions::initialize_v2(ctx, data) + pub fn initialize(ctx: Context, data: CandyMachineData) -> Result<()> { + instructions::initialize(ctx, data) } /// Mint an NFT. @@ -114,8 +114,8 @@ pub mod candy_machine_core { /// 16. `[]` Instructions sysvar account /// 17. `[optional]` Token Authorization Rules program /// 18. `[optional]` Token authorization rules account - pub fn set_collection_v2(ctx: Context) -> Result<()> { - instructions::set_collection_v2(ctx) + pub fn set_collection(ctx: Context) -> Result<()> { + instructions::set_collection(ctx) } /// Set a new mint authority of the candy machine. diff --git a/programs/candy-machine-core/program/src/state/candy_machine.rs b/programs/candy-machine-core/program/src/state/candy_machine.rs index e554eba..a4f08bd 100644 --- a/programs/candy-machine-core/program/src/state/candy_machine.rs +++ b/programs/candy-machine-core/program/src/state/candy_machine.rs @@ -7,8 +7,6 @@ use super::candy_machine_data::CandyMachineData; #[account] #[derive(Default, Debug)] pub struct CandyMachine { - /// Version of the account. - pub version: AccountVersion, /// Authority address. pub authority: Pubkey, /// Authority address allowed to mint from the candy machine. @@ -38,14 +36,6 @@ pub struct ConfigLine { pub uri: String, } -/// Account versioning. -#[derive(AnchorSerialize, AnchorDeserialize, Clone, Default, Debug)] -pub enum AccountVersion { - #[default] - V1, - V2, -} - #[derive(AnchorSerialize, AnchorDeserialize, Eq, PartialEq, Clone, Debug)] pub struct MintAssetArgs { pub plugins: Vec,