From c7d78b9b93a219e6be6fc594f01f1d9563a1600c Mon Sep 17 00:00:00 2001 From: Nhan Phan Date: Fri, 10 May 2024 13:07:28 -0700 Subject: [PATCH] Nhan/rename external plugin (#119) * bump version v1-alpha * bump version v1-alpha * initial rename * Rename Oracle pda - stacked onto rename external plugin (#121) * Format fix * Rename oracle pda to base_address_config in program * Regenerate IDL and clients * Update oracle SDK functions * Format JS and fix all tests * rename to external plugin adapater * formatting * rename back to external validation result * use internal validationresult type * rename a few more things * minor nits, comments --------- Co-authored-by: Michael Danenberg <56533526+danenbm@users.noreply.github.com> --- clients/js/src/generated/errors/mplCore.ts | 60 +++--- ...> addCollectionExternalPluginAdapterV1.ts} | 52 ++--- ...ginV1.ts => addExternalPluginAdapterV1.ts} | 55 +++--- .../instructions/createCollectionV2.ts | 18 +- .../js/src/generated/instructions/createV2.ts | 18 +- .../js/src/generated/instructions/index.ts | 16 +- ...emoveCollectionExternalPluginAdapterV1.ts} | 52 ++--- ...V1.ts => removeExternalPluginAdapterV1.ts} | 57 +++--- ...pdateCollectionExternalPluginAdapterV1.ts} | 64 +++--- ...V1.ts => updateExternalPluginAdapterV1.ts} | 69 +++---- ...eCollectionExternalPluginAdapterDataV1.ts} | 60 +++--- ...ts => writeExternalPluginAdapterDataV1.ts} | 56 +++--- .../js/src/generated/types/baseDataStore.ts | 12 +- .../generated/types/baseDataStoreInitInfo.ts | 12 +- .../types/baseDataStoreUpdateInfo.ts | 14 +- .../baseExternalPluginAdapterInitInfo.ts | 113 +++++++++++ .../types/baseExternalPluginAdapterKey.ts | 106 ++++++++++ ...=> baseExternalPluginAdapterUpdateInfo.ts} | 66 ++++--- .../types/baseExternalPluginInitInfo.ts | 104 ---------- .../generated/types/baseExternalPluginKey.ts | 94 --------- .../src/generated/types/baseLifecycleHook.ts | 12 +- .../types/baseLifecycleHookInitInfo.ts | 12 +- .../types/baseLifecycleHookUpdateInfo.ts | 12 +- clients/js/src/generated/types/baseOracle.ts | 6 +- .../src/generated/types/baseOracleInitInfo.ts | 6 +- .../generated/types/baseOracleUpdateInfo.ts | 6 +- ...rnalPlugin.ts => externalPluginAdapter.ts} | 58 +++--- .../types/externalPluginAdapterSchema.ts | 29 +++ .../types/externalPluginAdapterType.ts | 26 +++ .../generated/types/externalPluginSchema.ts | 26 --- .../src/generated/types/externalPluginType.ts | 26 --- .../generated/types/externalRegistryRecord.ts | 12 +- clients/js/src/generated/types/index.ts | 12 +- clients/js/src/helpers/lifecycle.ts | 15 +- clients/js/src/helpers/state.ts | 35 ++-- clients/js/src/hooked/assetAccountData.ts | 21 +- .../js/src/hooked/collectionAccountData.ts | 19 +- clients/js/src/hooked/pluginRegistryV1Data.ts | 14 +- clients/js/src/instructions/addPlugin.ts | 18 +- clients/js/src/instructions/burn.ts | 9 +- .../collection/addCollectionPlugin.ts | 20 +- .../approveCollectionPluginAuthority.ts | 28 +-- .../collection/createCollection.ts | 22 ++- .../collection/removeCollectionPlugin.ts | 17 +- .../revokeCollectionPluginAuthority.ts | 23 +-- .../collection/updateCollectionPlugin.ts | 22 +-- clients/js/src/instructions/create.ts | 48 +++-- clients/js/src/instructions/removePlugin.ts | 18 +- clients/js/src/instructions/transfer.ts | 9 +- clients/js/src/instructions/update.ts | 9 +- clients/js/src/instructions/updatePlugin.ts | 22 +-- clients/js/src/plugins/dataStore.ts | 22 +-- ...uginKey.ts => externalPluginAdapterKey.ts} | 10 +- ...st.ts => externalPluginAdapterManifest.ts} | 6 +- ...alPlugins.ts => externalPluginAdapters.ts} | 57 +++--- clients/js/src/plugins/index.ts | 6 +- clients/js/src/plugins/lib.ts | 12 +- clients/js/src/plugins/lifecycleChecks.ts | 10 +- clients/js/src/plugins/lifecycleHook.ts | 22 +-- clients/js/src/plugins/oracle.ts | 47 +++-- clients/js/test/_setupRaw.ts | 6 +- clients/js/test/_setupSdk.ts | 6 +- .../js/test/externalPlugins/oracle.test.ts | 80 ++++---- clients/js/test/helps/lifecycle.test.ts | 6 +- clients/rust/src/generated/errors/mpl_core.rs | 30 +-- ..._collection_external_plugin_adapter_v1.rs} | 72 +++---- ...1.rs => add_external_plugin_adapter_v1.rs} | 72 +++---- .../instructions/create_collection_v2.rs | 28 +-- .../src/generated/instructions/create_v2.rs | 28 +-- .../rust/src/generated/instructions/mod.rs | 32 +-- ..._collection_external_plugin_adapter_v1.rs} | 92 ++++----- ...s => remove_external_plugin_adapter_v1.rs} | 72 +++---- ..._collection_external_plugin_adapter_v1.rs} | 106 +++++----- ...s => update_external_plugin_adapter_v1.rs} | 84 ++++---- ...ection_external_plugin_adapter_data_v1.rs} | 104 +++++----- ... write_external_plugin_adapter_data_v1.rs} | 82 ++++---- .../rust/src/generated/types/data_store.rs | 4 +- .../generated/types/data_store_init_info.rs | 4 +- .../generated/types/data_store_update_info.rs | 4 +- ...l_plugin.rs => external_plugin_adapter.rs} | 2 +- ...s => external_plugin_adapter_init_info.rs} | 2 +- ..._key.rs => external_plugin_adapter_key.rs} | 2 +- ...a.rs => external_plugin_adapter_schema.rs} | 2 +- ...ype.rs => external_plugin_adapter_type.rs} | 2 +- ...=> external_plugin_adapter_update_info.rs} | 2 +- .../types/external_registry_record.rs | 4 +- .../src/generated/types/lifecycle_hook.rs | 4 +- .../types/lifecycle_hook_init_info.rs | 4 +- .../types/lifecycle_hook_update_info.rs | 4 +- clients/rust/src/generated/types/mod.rs | 24 +-- clients/rust/src/generated/types/oracle.rs | 2 +- .../src/generated/types/oracle_init_info.rs | 2 +- .../src/generated/types/oracle_update_info.rs | 2 +- clients/rust/src/hooked/advanced_types.rs | 28 +-- clients/rust/src/hooked/asset.rs | 16 +- clients/rust/src/hooked/plugin.rs | 50 ++--- clients/rust/tests/add_external_plugins.rs | 176 +++++++++-------- clients/rust/tests/create.rs | 20 +- clients/rust/tests/create_collection.rs | 10 +- .../tests/create_with_external_plugins.rs | 71 ++++--- clients/rust/tests/plugins.rs | 12 +- clients/rust/tests/remove_external_plugins.rs | 58 +++--- clients/rust/tests/setup/mod.rs | 44 +++-- clients/rust/tests/transfer.rs | 8 +- clients/rust/tests/update_external_plugins.rs | 112 ++++++----- configs/kinobi.cjs | 16 +- idls/mpl_core.json | 146 +++++++------- programs/mpl-core/src/error.rs | 30 +-- programs/mpl-core/src/instruction.rs | 59 +++--- programs/mpl-core/src/plugins/data_store.rs | 13 +- ...plugins.rs => external_plugin_adapters.rs} | 185 ++++++++++-------- programs/mpl-core/src/plugins/lifecycle.rs | 149 +++++++------- .../mpl-core/src/plugins/lifecycle_hook.rs | 18 +- programs/mpl-core/src/plugins/mod.rs | 4 +- programs/mpl-core/src/plugins/oracle.rs | 36 ++-- .../mpl-core/src/plugins/plugin_registry.rs | 28 +-- programs/mpl-core/src/plugins/utils.rs | 76 +++---- ...ugin.rs => add_external_plugin_adapter.rs} | 79 ++++---- programs/mpl-core/src/processor/burn.rs | 6 +- programs/mpl-core/src/processor/create.rs | 23 +-- .../src/processor/create_collection.rs | 26 +-- programs/mpl-core/src/processor/mod.rs | 64 +++--- ...n.rs => remove_external_plugin_adapter.rs} | 69 +++---- programs/mpl-core/src/processor/transfer.rs | 4 +- programs/mpl-core/src/processor/update.rs | 6 +- ...n.rs => update_external_plugin_adapter.rs} | 70 +++---- ... => write_external_plugin_adapter_data.rs} | 22 +-- programs/mpl-core/src/state/asset.rs | 52 ++--- programs/mpl-core/src/state/collection.rs | 52 ++--- programs/mpl-core/src/utils.rs | 79 ++++---- 130 files changed, 2495 insertions(+), 2294 deletions(-) rename clients/js/src/generated/instructions/{addCollectionExternalPluginV1.ts => addCollectionExternalPluginAdapterV1.ts} (64%) rename clients/js/src/generated/instructions/{addExternalPluginV1.ts => addExternalPluginAdapterV1.ts} (67%) rename clients/js/src/generated/instructions/{removeCollectionExternalPluginV1.ts => removeCollectionExternalPluginAdapterV1.ts} (64%) rename clients/js/src/generated/instructions/{removeExternalPluginV1.ts => removeExternalPluginAdapterV1.ts} (67%) rename clients/js/src/generated/instructions/{updateCollectionExternalPluginV1.ts => updateCollectionExternalPluginAdapterV1.ts} (59%) rename clients/js/src/generated/instructions/{updateExternalPluginV1.ts => updateExternalPluginAdapterV1.ts} (63%) rename clients/js/src/generated/instructions/{writeCollectionExternalPluginDataV1.ts => writeCollectionExternalPluginAdapterDataV1.ts} (62%) rename clients/js/src/generated/instructions/{writeExternalPluginDataV1.ts => writeExternalPluginAdapterDataV1.ts} (66%) create mode 100644 clients/js/src/generated/types/baseExternalPluginAdapterInitInfo.ts create mode 100644 clients/js/src/generated/types/baseExternalPluginAdapterKey.ts rename clients/js/src/generated/types/{baseExternalPluginUpdateInfo.ts => baseExternalPluginAdapterUpdateInfo.ts} (51%) delete mode 100644 clients/js/src/generated/types/baseExternalPluginInitInfo.ts delete mode 100644 clients/js/src/generated/types/baseExternalPluginKey.ts rename clients/js/src/generated/types/{externalPlugin.ts => externalPluginAdapter.ts} (51%) create mode 100644 clients/js/src/generated/types/externalPluginAdapterSchema.ts create mode 100644 clients/js/src/generated/types/externalPluginAdapterType.ts delete mode 100644 clients/js/src/generated/types/externalPluginSchema.ts delete mode 100644 clients/js/src/generated/types/externalPluginType.ts rename clients/js/src/plugins/{externalPluginKey.ts => externalPluginAdapterKey.ts} (75%) rename clients/js/src/plugins/{externalPluginManifest.ts => externalPluginAdapterManifest.ts} (71%) rename clients/js/src/plugins/{externalPlugins.ts => externalPluginAdapters.ts} (72%) rename clients/rust/src/generated/instructions/{add_collection_external_plugin_v1.rs => add_collection_external_plugin_adapter_v1.rs} (87%) rename clients/rust/src/generated/instructions/{add_external_plugin_v1.rs => add_external_plugin_adapter_v1.rs} (89%) rename clients/rust/src/generated/instructions/{remove_collection_external_plugin_v1.rs => remove_collection_external_plugin_adapter_v1.rs} (85%) rename clients/rust/src/generated/instructions/{remove_external_plugin_v1.rs => remove_external_plugin_adapter_v1.rs} (89%) rename clients/rust/src/generated/instructions/{update_collection_external_plugin_v1.rs => update_collection_external_plugin_adapter_v1.rs} (84%) rename clients/rust/src/generated/instructions/{update_external_plugin_v1.rs => update_external_plugin_adapter_v1.rs} (88%) rename clients/rust/src/generated/instructions/{write_collection_external_plugin_data_v1.rs => write_collection_external_plugin_adapter_data_v1.rs} (83%) rename clients/rust/src/generated/instructions/{write_external_plugin_data_v1.rs => write_external_plugin_adapter_data_v1.rs} (88%) rename clients/rust/src/generated/types/{external_plugin.rs => external_plugin_adapter.rs} (96%) rename clients/rust/src/generated/types/{external_plugin_init_info.rs => external_plugin_adapter_init_info.rs} (95%) rename clients/rust/src/generated/types/{external_plugin_key.rs => external_plugin_adapter_key.rs} (96%) rename clients/rust/src/generated/types/{external_plugin_schema.rs => external_plugin_adapter_schema.rs} (95%) rename clients/rust/src/generated/types/{external_plugin_type.rs => external_plugin_adapter_type.rs} (95%) rename clients/rust/src/generated/types/{external_plugin_update_info.rs => external_plugin_adapter_update_info.rs} (95%) rename programs/mpl-core/src/plugins/{external_plugins.rs => external_plugin_adapters.rs} (69%) rename programs/mpl-core/src/processor/{add_external_plugin.rs => add_external_plugin_adapter.rs} (63%) rename programs/mpl-core/src/processor/{remove_external_plugin.rs => remove_external_plugin_adapter.rs} (64%) rename programs/mpl-core/src/processor/{update_external_plugin.rs => update_external_plugin_adapter.rs} (76%) rename programs/mpl-core/src/processor/{write_external_plugin_data.rs => write_external_plugin_adapter_data.rs} (51%) diff --git a/clients/js/src/generated/errors/mplCore.ts b/clients/js/src/generated/errors/mplCore.ts index e4055ee8..a634ff54 100644 --- a/clients/js/src/generated/errors/mplCore.ts +++ b/clients/js/src/generated/errors/mplCore.ts @@ -433,33 +433,40 @@ export class InvalidLogWrapperProgramError extends ProgramError { codeToErrorMap.set(0x1e, InvalidLogWrapperProgramError); nameToErrorMap.set('InvalidLogWrapperProgram', InvalidLogWrapperProgramError); -/** ExternalPluginNotFound: External Plugin not found */ -export class ExternalPluginNotFoundError extends ProgramError { - override readonly name: string = 'ExternalPluginNotFound'; +/** ExternalPluginAdapterNotFound: External PluginExternalPluginAdapter not found */ +export class ExternalPluginAdapterNotFoundError extends ProgramError { + override readonly name: string = 'ExternalPluginAdapterNotFound'; readonly code: number = 0x1f; // 31 constructor(program: Program, cause?: Error) { - super('External Plugin not found', program, cause); + super('External PluginExternalPluginAdapter not found', program, cause); } } -codeToErrorMap.set(0x1f, ExternalPluginNotFoundError); -nameToErrorMap.set('ExternalPluginNotFound', ExternalPluginNotFoundError); +codeToErrorMap.set(0x1f, ExternalPluginAdapterNotFoundError); +nameToErrorMap.set( + 'ExternalPluginAdapterNotFound', + ExternalPluginAdapterNotFoundError +); -/** ExternalPluginAlreadyExists: External Plugin already exists */ -export class ExternalPluginAlreadyExistsError extends ProgramError { - override readonly name: string = 'ExternalPluginAlreadyExists'; +/** ExternalPluginAdapterAlreadyExists: External PluginExternalPluginAdapter already exists */ +export class ExternalPluginAdapterAlreadyExistsError extends ProgramError { + override readonly name: string = 'ExternalPluginAdapterAlreadyExists'; readonly code: number = 0x20; // 32 constructor(program: Program, cause?: Error) { - super('External Plugin already exists', program, cause); + super( + 'External PluginExternalPluginAdapter already exists', + program, + cause + ); } } -codeToErrorMap.set(0x20, ExternalPluginAlreadyExistsError); +codeToErrorMap.set(0x20, ExternalPluginAdapterAlreadyExistsError); nameToErrorMap.set( - 'ExternalPluginAlreadyExists', - ExternalPluginAlreadyExistsError + 'ExternalPluginAdapterAlreadyExists', + ExternalPluginAdapterAlreadyExistsError ); /** MissingAsset: Missing asset needed for extra account PDA derivation */ @@ -479,20 +486,23 @@ export class MissingAssetError extends ProgramError { codeToErrorMap.set(0x21, MissingAssetError); nameToErrorMap.set('MissingAsset', MissingAssetError); -/** MissingExternalAccount: Missing account needed for external plugin */ -export class MissingExternalAccountError extends ProgramError { - override readonly name: string = 'MissingExternalAccount'; +/** MissingExternalPluginAdapterAccount: Missing account needed for external plugin adapter */ +export class MissingExternalPluginAdapterAccountError extends ProgramError { + override readonly name: string = 'MissingExternalPluginAdapterAccount'; readonly code: number = 0x22; // 34 constructor(program: Program, cause?: Error) { - super('Missing account needed for external plugin', program, cause); + super('Missing account needed for external plugin adapter', program, cause); } } -codeToErrorMap.set(0x22, MissingExternalAccountError); -nameToErrorMap.set('MissingExternalAccount', MissingExternalAccountError); +codeToErrorMap.set(0x22, MissingExternalPluginAdapterAccountError); +nameToErrorMap.set( + 'MissingExternalPluginAdapterAccount', + MissingExternalPluginAdapterAccountError +); -/** OracleCanRejectOnly: Oracle external plugin can only be configured to reject */ +/** OracleCanRejectOnly: Oracle external plugin adapter can only be configured to reject */ export class OracleCanRejectOnlyError extends ProgramError { override readonly name: string = 'OracleCanRejectOnly'; @@ -500,7 +510,7 @@ export class OracleCanRejectOnlyError extends ProgramError { constructor(program: Program, cause?: Error) { super( - 'Oracle external plugin can only be configured to reject', + 'Oracle external plugin adapter can only be configured to reject', program, cause ); @@ -509,7 +519,7 @@ export class OracleCanRejectOnlyError extends ProgramError { codeToErrorMap.set(0x23, OracleCanRejectOnlyError); nameToErrorMap.set('OracleCanRejectOnly', OracleCanRejectOnlyError); -/** RequiresLifecycleCheck: External plugin must have at least one lifecycle check */ +/** RequiresLifecycleCheck: External plugin adapter must have at least one lifecycle check */ export class RequiresLifecycleCheckError extends ProgramError { override readonly name: string = 'RequiresLifecycleCheck'; @@ -517,7 +527,7 @@ export class RequiresLifecycleCheckError extends ProgramError { constructor(program: Program, cause?: Error) { super( - 'External plugin must have at least one lifecycle check', + 'External plugin adapter must have at least one lifecycle check', program, cause ); @@ -526,7 +536,7 @@ export class RequiresLifecycleCheckError extends ProgramError { codeToErrorMap.set(0x24, RequiresLifecycleCheckError); nameToErrorMap.set('RequiresLifecycleCheck', RequiresLifecycleCheckError); -/** DuplicateLifecycleChecks: Duplicate lifecycle checks were provided for external plugin */ +/** DuplicateLifecycleChecks: Duplicate lifecycle checks were provided for external plugin adapter */ export class DuplicateLifecycleChecksError extends ProgramError { override readonly name: string = 'DuplicateLifecycleChecks'; @@ -534,7 +544,7 @@ export class DuplicateLifecycleChecksError extends ProgramError { constructor(program: Program, cause?: Error) { super( - 'Duplicate lifecycle checks were provided for external plugin', + 'Duplicate lifecycle checks were provided for external plugin adapter ', program, cause ); diff --git a/clients/js/src/generated/instructions/addCollectionExternalPluginV1.ts b/clients/js/src/generated/instructions/addCollectionExternalPluginAdapterV1.ts similarity index 64% rename from clients/js/src/generated/instructions/addCollectionExternalPluginV1.ts rename to clients/js/src/generated/instructions/addCollectionExternalPluginAdapterV1.ts index b81511a1..672e235b 100644 --- a/clients/js/src/generated/instructions/addCollectionExternalPluginV1.ts +++ b/clients/js/src/generated/instructions/addCollectionExternalPluginAdapterV1.ts @@ -26,13 +26,13 @@ import { getAccountMetasAndSigners, } from '../shared'; import { - BaseExternalPluginInitInfo, - BaseExternalPluginInitInfoArgs, - getBaseExternalPluginInitInfoSerializer, + BaseExternalPluginAdapterInitInfo, + BaseExternalPluginAdapterInitInfoArgs, + getBaseExternalPluginAdapterInitInfoSerializer, } from '../types'; // Accounts. -export type AddCollectionExternalPluginV1InstructionAccounts = { +export type AddCollectionExternalPluginAdapterV1InstructionAccounts = { /** The address of the asset */ collection: PublicKey | Pda; /** The account paying for the storage fees */ @@ -46,47 +46,47 @@ export type AddCollectionExternalPluginV1InstructionAccounts = { }; // Data. -export type AddCollectionExternalPluginV1InstructionData = { +export type AddCollectionExternalPluginAdapterV1InstructionData = { discriminator: number; - initInfo: BaseExternalPluginInitInfo; + initInfo: BaseExternalPluginAdapterInitInfo; }; -export type AddCollectionExternalPluginV1InstructionDataArgs = { - initInfo: BaseExternalPluginInitInfoArgs; +export type AddCollectionExternalPluginAdapterV1InstructionDataArgs = { + initInfo: BaseExternalPluginAdapterInitInfoArgs; }; -export function getAddCollectionExternalPluginV1InstructionDataSerializer(): Serializer< - AddCollectionExternalPluginV1InstructionDataArgs, - AddCollectionExternalPluginV1InstructionData +export function getAddCollectionExternalPluginAdapterV1InstructionDataSerializer(): Serializer< + AddCollectionExternalPluginAdapterV1InstructionDataArgs, + AddCollectionExternalPluginAdapterV1InstructionData > { return mapSerializer< - AddCollectionExternalPluginV1InstructionDataArgs, + AddCollectionExternalPluginAdapterV1InstructionDataArgs, any, - AddCollectionExternalPluginV1InstructionData + AddCollectionExternalPluginAdapterV1InstructionData >( - struct( + struct( [ ['discriminator', u8()], - ['initInfo', getBaseExternalPluginInitInfoSerializer()], + ['initInfo', getBaseExternalPluginAdapterInitInfoSerializer()], ], - { description: 'AddCollectionExternalPluginV1InstructionData' } + { description: 'AddCollectionExternalPluginAdapterV1InstructionData' } ), (value) => ({ ...value, discriminator: 23 }) ) as Serializer< - AddCollectionExternalPluginV1InstructionDataArgs, - AddCollectionExternalPluginV1InstructionData + AddCollectionExternalPluginAdapterV1InstructionDataArgs, + AddCollectionExternalPluginAdapterV1InstructionData >; } // Args. -export type AddCollectionExternalPluginV1InstructionArgs = - AddCollectionExternalPluginV1InstructionDataArgs; +export type AddCollectionExternalPluginAdapterV1InstructionArgs = + AddCollectionExternalPluginAdapterV1InstructionDataArgs; // Instruction. -export function addCollectionExternalPluginV1( +export function addCollectionExternalPluginAdapterV1( context: Pick, - input: AddCollectionExternalPluginV1InstructionAccounts & - AddCollectionExternalPluginV1InstructionArgs + input: AddCollectionExternalPluginAdapterV1InstructionAccounts & + AddCollectionExternalPluginAdapterV1InstructionArgs ): TransactionBuilder { // Program ID. const programId = context.programs.getPublicKey( @@ -124,7 +124,7 @@ export function addCollectionExternalPluginV1( } satisfies ResolvedAccountsWithIndices; // Arguments. - const resolvedArgs: AddCollectionExternalPluginV1InstructionArgs = { + const resolvedArgs: AddCollectionExternalPluginAdapterV1InstructionArgs = { ...input, }; @@ -154,8 +154,8 @@ export function addCollectionExternalPluginV1( // Data. const data = - getAddCollectionExternalPluginV1InstructionDataSerializer().serialize( - resolvedArgs as AddCollectionExternalPluginV1InstructionDataArgs + getAddCollectionExternalPluginAdapterV1InstructionDataSerializer().serialize( + resolvedArgs as AddCollectionExternalPluginAdapterV1InstructionDataArgs ); // Bytes Created On Chain. diff --git a/clients/js/src/generated/instructions/addExternalPluginV1.ts b/clients/js/src/generated/instructions/addExternalPluginAdapterV1.ts similarity index 67% rename from clients/js/src/generated/instructions/addExternalPluginV1.ts rename to clients/js/src/generated/instructions/addExternalPluginAdapterV1.ts index 0028614f..b8059a3d 100644 --- a/clients/js/src/generated/instructions/addExternalPluginV1.ts +++ b/clients/js/src/generated/instructions/addExternalPluginAdapterV1.ts @@ -26,13 +26,13 @@ import { getAccountMetasAndSigners, } from '../shared'; import { - BaseExternalPluginInitInfo, - BaseExternalPluginInitInfoArgs, - getBaseExternalPluginInitInfoSerializer, + BaseExternalPluginAdapterInitInfo, + BaseExternalPluginAdapterInitInfoArgs, + getBaseExternalPluginAdapterInitInfoSerializer, } from '../types'; // Accounts. -export type AddExternalPluginV1InstructionAccounts = { +export type AddExternalPluginAdapterV1InstructionAccounts = { /** The address of the asset */ asset: PublicKey | Pda; /** The collection to which the asset belongs */ @@ -48,47 +48,47 @@ export type AddExternalPluginV1InstructionAccounts = { }; // Data. -export type AddExternalPluginV1InstructionData = { +export type AddExternalPluginAdapterV1InstructionData = { discriminator: number; - initInfo: BaseExternalPluginInitInfo; + initInfo: BaseExternalPluginAdapterInitInfo; }; -export type AddExternalPluginV1InstructionDataArgs = { - initInfo: BaseExternalPluginInitInfoArgs; +export type AddExternalPluginAdapterV1InstructionDataArgs = { + initInfo: BaseExternalPluginAdapterInitInfoArgs; }; -export function getAddExternalPluginV1InstructionDataSerializer(): Serializer< - AddExternalPluginV1InstructionDataArgs, - AddExternalPluginV1InstructionData +export function getAddExternalPluginAdapterV1InstructionDataSerializer(): Serializer< + AddExternalPluginAdapterV1InstructionDataArgs, + AddExternalPluginAdapterV1InstructionData > { return mapSerializer< - AddExternalPluginV1InstructionDataArgs, + AddExternalPluginAdapterV1InstructionDataArgs, any, - AddExternalPluginV1InstructionData + AddExternalPluginAdapterV1InstructionData >( - struct( + struct( [ ['discriminator', u8()], - ['initInfo', getBaseExternalPluginInitInfoSerializer()], + ['initInfo', getBaseExternalPluginAdapterInitInfoSerializer()], ], - { description: 'AddExternalPluginV1InstructionData' } + { description: 'AddExternalPluginAdapterV1InstructionData' } ), (value) => ({ ...value, discriminator: 22 }) ) as Serializer< - AddExternalPluginV1InstructionDataArgs, - AddExternalPluginV1InstructionData + AddExternalPluginAdapterV1InstructionDataArgs, + AddExternalPluginAdapterV1InstructionData >; } // Args. -export type AddExternalPluginV1InstructionArgs = - AddExternalPluginV1InstructionDataArgs; +export type AddExternalPluginAdapterV1InstructionArgs = + AddExternalPluginAdapterV1InstructionDataArgs; // Instruction. -export function addExternalPluginV1( +export function addExternalPluginAdapterV1( context: Pick, - input: AddExternalPluginV1InstructionAccounts & - AddExternalPluginV1InstructionArgs + input: AddExternalPluginAdapterV1InstructionAccounts & + AddExternalPluginAdapterV1InstructionArgs ): TransactionBuilder { // Program ID. const programId = context.programs.getPublicKey( @@ -131,7 +131,7 @@ export function addExternalPluginV1( } satisfies ResolvedAccountsWithIndices; // Arguments. - const resolvedArgs: AddExternalPluginV1InstructionArgs = { ...input }; + const resolvedArgs: AddExternalPluginAdapterV1InstructionArgs = { ...input }; // Default values. if (!resolvedAccounts.payer.value) { @@ -158,9 +158,10 @@ export function addExternalPluginV1( ); // Data. - const data = getAddExternalPluginV1InstructionDataSerializer().serialize( - resolvedArgs as AddExternalPluginV1InstructionDataArgs - ); + const data = + getAddExternalPluginAdapterV1InstructionDataSerializer().serialize( + resolvedArgs as AddExternalPluginAdapterV1InstructionDataArgs + ); // Bytes Created On Chain. const bytesCreatedOnChain = 0; diff --git a/clients/js/src/generated/instructions/createCollectionV2.ts b/clients/js/src/generated/instructions/createCollectionV2.ts index b37cdc22..79555332 100644 --- a/clients/js/src/generated/instructions/createCollectionV2.ts +++ b/clients/js/src/generated/instructions/createCollectionV2.ts @@ -32,11 +32,11 @@ import { getAccountMetasAndSigners, } from '../shared'; import { - BaseExternalPluginInitInfo, - BaseExternalPluginInitInfoArgs, + BaseExternalPluginAdapterInitInfo, + BaseExternalPluginAdapterInitInfoArgs, PluginAuthorityPair, PluginAuthorityPairArgs, - getBaseExternalPluginInitInfoSerializer, + getBaseExternalPluginAdapterInitInfoSerializer, getPluginAuthorityPairSerializer, } from '../types'; @@ -58,14 +58,16 @@ export type CreateCollectionV2InstructionData = { name: string; uri: string; plugins: Option>; - externalPlugins: Option>; + externalPluginAdapters: Option>; }; export type CreateCollectionV2InstructionDataArgs = { name: string; uri: string; plugins?: OptionOrNullable>; - externalPlugins?: OptionOrNullable>; + externalPluginAdapters?: OptionOrNullable< + Array + >; }; export function getCreateCollectionV2InstructionDataSerializer(): Serializer< @@ -84,8 +86,8 @@ export function getCreateCollectionV2InstructionDataSerializer(): Serializer< ['uri', string()], ['plugins', option(array(getPluginAuthorityPairSerializer()))], [ - 'externalPlugins', - option(array(getBaseExternalPluginInitInfoSerializer())), + 'externalPluginAdapters', + option(array(getBaseExternalPluginAdapterInitInfoSerializer())), ], ], { description: 'CreateCollectionV2InstructionData' } @@ -94,7 +96,7 @@ export function getCreateCollectionV2InstructionDataSerializer(): Serializer< ...value, discriminator: 21, plugins: value.plugins ?? none(), - externalPlugins: value.externalPlugins ?? [], + externalPluginAdapters: value.externalPluginAdapters ?? [], }) ) as Serializer< CreateCollectionV2InstructionDataArgs, diff --git a/clients/js/src/generated/instructions/createV2.ts b/clients/js/src/generated/instructions/createV2.ts index 98c44296..a5ca8707 100644 --- a/clients/js/src/generated/instructions/createV2.ts +++ b/clients/js/src/generated/instructions/createV2.ts @@ -31,13 +31,13 @@ import { getAccountMetasAndSigners, } from '../shared'; import { - BaseExternalPluginInitInfo, - BaseExternalPluginInitInfoArgs, + BaseExternalPluginAdapterInitInfo, + BaseExternalPluginAdapterInitInfoArgs, DataState, DataStateArgs, PluginAuthorityPair, PluginAuthorityPairArgs, - getBaseExternalPluginInitInfoSerializer, + getBaseExternalPluginAdapterInitInfoSerializer, getDataStateSerializer, getPluginAuthorityPairSerializer, } from '../types'; @@ -69,7 +69,7 @@ export type CreateV2InstructionData = { name: string; uri: string; plugins: Option>; - externalPlugins: Option>; + externalPluginAdapters: Option>; }; export type CreateV2InstructionDataArgs = { @@ -77,7 +77,9 @@ export type CreateV2InstructionDataArgs = { name: string; uri: string; plugins?: OptionOrNullable>; - externalPlugins?: OptionOrNullable>; + externalPluginAdapters?: OptionOrNullable< + Array + >; }; export function getCreateV2InstructionDataSerializer(): Serializer< @@ -97,8 +99,8 @@ export function getCreateV2InstructionDataSerializer(): Serializer< ['uri', string()], ['plugins', option(array(getPluginAuthorityPairSerializer()))], [ - 'externalPlugins', - option(array(getBaseExternalPluginInitInfoSerializer())), + 'externalPluginAdapters', + option(array(getBaseExternalPluginAdapterInitInfoSerializer())), ], ], { description: 'CreateV2InstructionData' } @@ -108,7 +110,7 @@ export function getCreateV2InstructionDataSerializer(): Serializer< discriminator: 20, dataState: value.dataState ?? DataState.AccountState, plugins: value.plugins ?? [], - externalPlugins: value.externalPlugins ?? [], + externalPluginAdapters: value.externalPluginAdapters ?? [], }) ) as Serializer; } diff --git a/clients/js/src/generated/instructions/index.ts b/clients/js/src/generated/instructions/index.ts index 7ffc9bb3..6b62997e 100644 --- a/clients/js/src/generated/instructions/index.ts +++ b/clients/js/src/generated/instructions/index.ts @@ -6,9 +6,9 @@ * @see https://github.com/metaplex-foundation/kinobi */ -export * from './addCollectionExternalPluginV1'; +export * from './addCollectionExternalPluginAdapterV1'; export * from './addCollectionPluginV1'; -export * from './addExternalPluginV1'; +export * from './addExternalPluginAdapterV1'; export * from './addPluginV1'; export * from './approveCollectionPluginAuthorityV1'; export * from './approvePluginAuthorityV1'; @@ -21,18 +21,18 @@ export * from './createCollectionV2'; export * from './createV1'; export * from './createV2'; export * from './decompressV1'; -export * from './removeCollectionExternalPluginV1'; +export * from './removeCollectionExternalPluginAdapterV1'; export * from './removeCollectionPluginV1'; -export * from './removeExternalPluginV1'; +export * from './removeExternalPluginAdapterV1'; export * from './removePluginV1'; export * from './revokeCollectionPluginAuthorityV1'; export * from './revokePluginAuthorityV1'; export * from './transferV1'; -export * from './updateCollectionExternalPluginV1'; +export * from './updateCollectionExternalPluginAdapterV1'; export * from './updateCollectionPluginV1'; export * from './updateCollectionV1'; -export * from './updateExternalPluginV1'; +export * from './updateExternalPluginAdapterV1'; export * from './updatePluginV1'; export * from './updateV1'; -export * from './writeCollectionExternalPluginDataV1'; -export * from './writeExternalPluginDataV1'; +export * from './writeCollectionExternalPluginAdapterDataV1'; +export * from './writeExternalPluginAdapterDataV1'; diff --git a/clients/js/src/generated/instructions/removeCollectionExternalPluginV1.ts b/clients/js/src/generated/instructions/removeCollectionExternalPluginAdapterV1.ts similarity index 64% rename from clients/js/src/generated/instructions/removeCollectionExternalPluginV1.ts rename to clients/js/src/generated/instructions/removeCollectionExternalPluginAdapterV1.ts index 22a74562..e414ba71 100644 --- a/clients/js/src/generated/instructions/removeCollectionExternalPluginV1.ts +++ b/clients/js/src/generated/instructions/removeCollectionExternalPluginAdapterV1.ts @@ -26,13 +26,13 @@ import { getAccountMetasAndSigners, } from '../shared'; import { - BaseExternalPluginKey, - BaseExternalPluginKeyArgs, - getBaseExternalPluginKeySerializer, + BaseExternalPluginAdapterKey, + BaseExternalPluginAdapterKeyArgs, + getBaseExternalPluginAdapterKeySerializer, } from '../types'; // Accounts. -export type RemoveCollectionExternalPluginV1InstructionAccounts = { +export type RemoveCollectionExternalPluginAdapterV1InstructionAccounts = { /** The address of the asset */ collection: PublicKey | Pda; /** The account paying for the storage fees */ @@ -46,47 +46,47 @@ export type RemoveCollectionExternalPluginV1InstructionAccounts = { }; // Data. -export type RemoveCollectionExternalPluginV1InstructionData = { +export type RemoveCollectionExternalPluginAdapterV1InstructionData = { discriminator: number; - key: BaseExternalPluginKey; + key: BaseExternalPluginAdapterKey; }; -export type RemoveCollectionExternalPluginV1InstructionDataArgs = { - key: BaseExternalPluginKeyArgs; +export type RemoveCollectionExternalPluginAdapterV1InstructionDataArgs = { + key: BaseExternalPluginAdapterKeyArgs; }; -export function getRemoveCollectionExternalPluginV1InstructionDataSerializer(): Serializer< - RemoveCollectionExternalPluginV1InstructionDataArgs, - RemoveCollectionExternalPluginV1InstructionData +export function getRemoveCollectionExternalPluginAdapterV1InstructionDataSerializer(): Serializer< + RemoveCollectionExternalPluginAdapterV1InstructionDataArgs, + RemoveCollectionExternalPluginAdapterV1InstructionData > { return mapSerializer< - RemoveCollectionExternalPluginV1InstructionDataArgs, + RemoveCollectionExternalPluginAdapterV1InstructionDataArgs, any, - RemoveCollectionExternalPluginV1InstructionData + RemoveCollectionExternalPluginAdapterV1InstructionData >( - struct( + struct( [ ['discriminator', u8()], - ['key', getBaseExternalPluginKeySerializer()], + ['key', getBaseExternalPluginAdapterKeySerializer()], ], - { description: 'RemoveCollectionExternalPluginV1InstructionData' } + { description: 'RemoveCollectionExternalPluginAdapterV1InstructionData' } ), (value) => ({ ...value, discriminator: 25 }) ) as Serializer< - RemoveCollectionExternalPluginV1InstructionDataArgs, - RemoveCollectionExternalPluginV1InstructionData + RemoveCollectionExternalPluginAdapterV1InstructionDataArgs, + RemoveCollectionExternalPluginAdapterV1InstructionData >; } // Args. -export type RemoveCollectionExternalPluginV1InstructionArgs = - RemoveCollectionExternalPluginV1InstructionDataArgs; +export type RemoveCollectionExternalPluginAdapterV1InstructionArgs = + RemoveCollectionExternalPluginAdapterV1InstructionDataArgs; // Instruction. -export function removeCollectionExternalPluginV1( +export function removeCollectionExternalPluginAdapterV1( context: Pick, - input: RemoveCollectionExternalPluginV1InstructionAccounts & - RemoveCollectionExternalPluginV1InstructionArgs + input: RemoveCollectionExternalPluginAdapterV1InstructionAccounts & + RemoveCollectionExternalPluginAdapterV1InstructionArgs ): TransactionBuilder { // Program ID. const programId = context.programs.getPublicKey( @@ -124,7 +124,7 @@ export function removeCollectionExternalPluginV1( } satisfies ResolvedAccountsWithIndices; // Arguments. - const resolvedArgs: RemoveCollectionExternalPluginV1InstructionArgs = { + const resolvedArgs: RemoveCollectionExternalPluginAdapterV1InstructionArgs = { ...input, }; @@ -154,8 +154,8 @@ export function removeCollectionExternalPluginV1( // Data. const data = - getRemoveCollectionExternalPluginV1InstructionDataSerializer().serialize( - resolvedArgs as RemoveCollectionExternalPluginV1InstructionDataArgs + getRemoveCollectionExternalPluginAdapterV1InstructionDataSerializer().serialize( + resolvedArgs as RemoveCollectionExternalPluginAdapterV1InstructionDataArgs ); // Bytes Created On Chain. diff --git a/clients/js/src/generated/instructions/removeExternalPluginV1.ts b/clients/js/src/generated/instructions/removeExternalPluginAdapterV1.ts similarity index 67% rename from clients/js/src/generated/instructions/removeExternalPluginV1.ts rename to clients/js/src/generated/instructions/removeExternalPluginAdapterV1.ts index 58e2901c..92349dfe 100644 --- a/clients/js/src/generated/instructions/removeExternalPluginV1.ts +++ b/clients/js/src/generated/instructions/removeExternalPluginAdapterV1.ts @@ -26,13 +26,13 @@ import { getAccountMetasAndSigners, } from '../shared'; import { - BaseExternalPluginKey, - BaseExternalPluginKeyArgs, - getBaseExternalPluginKeySerializer, + BaseExternalPluginAdapterKey, + BaseExternalPluginAdapterKeyArgs, + getBaseExternalPluginAdapterKeySerializer, } from '../types'; // Accounts. -export type RemoveExternalPluginV1InstructionAccounts = { +export type RemoveExternalPluginAdapterV1InstructionAccounts = { /** The address of the asset */ asset: PublicKey | Pda; /** The collection to which the asset belongs */ @@ -48,47 +48,47 @@ export type RemoveExternalPluginV1InstructionAccounts = { }; // Data. -export type RemoveExternalPluginV1InstructionData = { +export type RemoveExternalPluginAdapterV1InstructionData = { discriminator: number; - key: BaseExternalPluginKey; + key: BaseExternalPluginAdapterKey; }; -export type RemoveExternalPluginV1InstructionDataArgs = { - key: BaseExternalPluginKeyArgs; +export type RemoveExternalPluginAdapterV1InstructionDataArgs = { + key: BaseExternalPluginAdapterKeyArgs; }; -export function getRemoveExternalPluginV1InstructionDataSerializer(): Serializer< - RemoveExternalPluginV1InstructionDataArgs, - RemoveExternalPluginV1InstructionData +export function getRemoveExternalPluginAdapterV1InstructionDataSerializer(): Serializer< + RemoveExternalPluginAdapterV1InstructionDataArgs, + RemoveExternalPluginAdapterV1InstructionData > { return mapSerializer< - RemoveExternalPluginV1InstructionDataArgs, + RemoveExternalPluginAdapterV1InstructionDataArgs, any, - RemoveExternalPluginV1InstructionData + RemoveExternalPluginAdapterV1InstructionData >( - struct( + struct( [ ['discriminator', u8()], - ['key', getBaseExternalPluginKeySerializer()], + ['key', getBaseExternalPluginAdapterKeySerializer()], ], - { description: 'RemoveExternalPluginV1InstructionData' } + { description: 'RemoveExternalPluginAdapterV1InstructionData' } ), (value) => ({ ...value, discriminator: 24 }) ) as Serializer< - RemoveExternalPluginV1InstructionDataArgs, - RemoveExternalPluginV1InstructionData + RemoveExternalPluginAdapterV1InstructionDataArgs, + RemoveExternalPluginAdapterV1InstructionData >; } // Args. -export type RemoveExternalPluginV1InstructionArgs = - RemoveExternalPluginV1InstructionDataArgs; +export type RemoveExternalPluginAdapterV1InstructionArgs = + RemoveExternalPluginAdapterV1InstructionDataArgs; // Instruction. -export function removeExternalPluginV1( +export function removeExternalPluginAdapterV1( context: Pick, - input: RemoveExternalPluginV1InstructionAccounts & - RemoveExternalPluginV1InstructionArgs + input: RemoveExternalPluginAdapterV1InstructionAccounts & + RemoveExternalPluginAdapterV1InstructionArgs ): TransactionBuilder { // Program ID. const programId = context.programs.getPublicKey( @@ -131,7 +131,9 @@ export function removeExternalPluginV1( } satisfies ResolvedAccountsWithIndices; // Arguments. - const resolvedArgs: RemoveExternalPluginV1InstructionArgs = { ...input }; + const resolvedArgs: RemoveExternalPluginAdapterV1InstructionArgs = { + ...input, + }; // Default values. if (!resolvedAccounts.payer.value) { @@ -158,9 +160,10 @@ export function removeExternalPluginV1( ); // Data. - const data = getRemoveExternalPluginV1InstructionDataSerializer().serialize( - resolvedArgs as RemoveExternalPluginV1InstructionDataArgs - ); + const data = + getRemoveExternalPluginAdapterV1InstructionDataSerializer().serialize( + resolvedArgs as RemoveExternalPluginAdapterV1InstructionDataArgs + ); // Bytes Created On Chain. const bytesCreatedOnChain = 0; diff --git a/clients/js/src/generated/instructions/updateCollectionExternalPluginV1.ts b/clients/js/src/generated/instructions/updateCollectionExternalPluginAdapterV1.ts similarity index 59% rename from clients/js/src/generated/instructions/updateCollectionExternalPluginV1.ts rename to clients/js/src/generated/instructions/updateCollectionExternalPluginAdapterV1.ts index 7302636c..c04c8e08 100644 --- a/clients/js/src/generated/instructions/updateCollectionExternalPluginV1.ts +++ b/clients/js/src/generated/instructions/updateCollectionExternalPluginAdapterV1.ts @@ -26,16 +26,16 @@ import { getAccountMetasAndSigners, } from '../shared'; import { - BaseExternalPluginKey, - BaseExternalPluginKeyArgs, - BaseExternalPluginUpdateInfo, - BaseExternalPluginUpdateInfoArgs, - getBaseExternalPluginKeySerializer, - getBaseExternalPluginUpdateInfoSerializer, + BaseExternalPluginAdapterKey, + BaseExternalPluginAdapterKeyArgs, + BaseExternalPluginAdapterUpdateInfo, + BaseExternalPluginAdapterUpdateInfoArgs, + getBaseExternalPluginAdapterKeySerializer, + getBaseExternalPluginAdapterUpdateInfoSerializer, } from '../types'; // Accounts. -export type UpdateCollectionExternalPluginV1InstructionAccounts = { +export type UpdateCollectionExternalPluginAdapterV1InstructionAccounts = { /** The address of the asset */ collection: PublicKey | Pda; /** The account paying for the storage fees */ @@ -49,50 +49,50 @@ export type UpdateCollectionExternalPluginV1InstructionAccounts = { }; // Data. -export type UpdateCollectionExternalPluginV1InstructionData = { +export type UpdateCollectionExternalPluginAdapterV1InstructionData = { discriminator: number; - key: BaseExternalPluginKey; - updateInfo: BaseExternalPluginUpdateInfo; + key: BaseExternalPluginAdapterKey; + updateInfo: BaseExternalPluginAdapterUpdateInfo; }; -export type UpdateCollectionExternalPluginV1InstructionDataArgs = { - key: BaseExternalPluginKeyArgs; - updateInfo: BaseExternalPluginUpdateInfoArgs; +export type UpdateCollectionExternalPluginAdapterV1InstructionDataArgs = { + key: BaseExternalPluginAdapterKeyArgs; + updateInfo: BaseExternalPluginAdapterUpdateInfoArgs; }; -export function getUpdateCollectionExternalPluginV1InstructionDataSerializer(): Serializer< - UpdateCollectionExternalPluginV1InstructionDataArgs, - UpdateCollectionExternalPluginV1InstructionData +export function getUpdateCollectionExternalPluginAdapterV1InstructionDataSerializer(): Serializer< + UpdateCollectionExternalPluginAdapterV1InstructionDataArgs, + UpdateCollectionExternalPluginAdapterV1InstructionData > { return mapSerializer< - UpdateCollectionExternalPluginV1InstructionDataArgs, + UpdateCollectionExternalPluginAdapterV1InstructionDataArgs, any, - UpdateCollectionExternalPluginV1InstructionData + UpdateCollectionExternalPluginAdapterV1InstructionData >( - struct( + struct( [ ['discriminator', u8()], - ['key', getBaseExternalPluginKeySerializer()], - ['updateInfo', getBaseExternalPluginUpdateInfoSerializer()], + ['key', getBaseExternalPluginAdapterKeySerializer()], + ['updateInfo', getBaseExternalPluginAdapterUpdateInfoSerializer()], ], - { description: 'UpdateCollectionExternalPluginV1InstructionData' } + { description: 'UpdateCollectionExternalPluginAdapterV1InstructionData' } ), (value) => ({ ...value, discriminator: 27 }) ) as Serializer< - UpdateCollectionExternalPluginV1InstructionDataArgs, - UpdateCollectionExternalPluginV1InstructionData + UpdateCollectionExternalPluginAdapterV1InstructionDataArgs, + UpdateCollectionExternalPluginAdapterV1InstructionData >; } // Args. -export type UpdateCollectionExternalPluginV1InstructionArgs = - UpdateCollectionExternalPluginV1InstructionDataArgs; +export type UpdateCollectionExternalPluginAdapterV1InstructionArgs = + UpdateCollectionExternalPluginAdapterV1InstructionDataArgs; // Instruction. -export function updateCollectionExternalPluginV1( +export function updateCollectionExternalPluginAdapterV1( context: Pick, - input: UpdateCollectionExternalPluginV1InstructionAccounts & - UpdateCollectionExternalPluginV1InstructionArgs + input: UpdateCollectionExternalPluginAdapterV1InstructionAccounts & + UpdateCollectionExternalPluginAdapterV1InstructionArgs ): TransactionBuilder { // Program ID. const programId = context.programs.getPublicKey( @@ -130,7 +130,7 @@ export function updateCollectionExternalPluginV1( } satisfies ResolvedAccountsWithIndices; // Arguments. - const resolvedArgs: UpdateCollectionExternalPluginV1InstructionArgs = { + const resolvedArgs: UpdateCollectionExternalPluginAdapterV1InstructionArgs = { ...input, }; @@ -160,8 +160,8 @@ export function updateCollectionExternalPluginV1( // Data. const data = - getUpdateCollectionExternalPluginV1InstructionDataSerializer().serialize( - resolvedArgs as UpdateCollectionExternalPluginV1InstructionDataArgs + getUpdateCollectionExternalPluginAdapterV1InstructionDataSerializer().serialize( + resolvedArgs as UpdateCollectionExternalPluginAdapterV1InstructionDataArgs ); // Bytes Created On Chain. diff --git a/clients/js/src/generated/instructions/updateExternalPluginV1.ts b/clients/js/src/generated/instructions/updateExternalPluginAdapterV1.ts similarity index 63% rename from clients/js/src/generated/instructions/updateExternalPluginV1.ts rename to clients/js/src/generated/instructions/updateExternalPluginAdapterV1.ts index e6958bfc..53c61537 100644 --- a/clients/js/src/generated/instructions/updateExternalPluginV1.ts +++ b/clients/js/src/generated/instructions/updateExternalPluginAdapterV1.ts @@ -26,16 +26,16 @@ import { getAccountMetasAndSigners, } from '../shared'; import { - BaseExternalPluginKey, - BaseExternalPluginKeyArgs, - BaseExternalPluginUpdateInfo, - BaseExternalPluginUpdateInfoArgs, - getBaseExternalPluginKeySerializer, - getBaseExternalPluginUpdateInfoSerializer, + BaseExternalPluginAdapterKey, + BaseExternalPluginAdapterKeyArgs, + BaseExternalPluginAdapterUpdateInfo, + BaseExternalPluginAdapterUpdateInfoArgs, + getBaseExternalPluginAdapterKeySerializer, + getBaseExternalPluginAdapterUpdateInfoSerializer, } from '../types'; // Accounts. -export type UpdateExternalPluginV1InstructionAccounts = { +export type UpdateExternalPluginAdapterV1InstructionAccounts = { /** The address of the asset */ asset: PublicKey | Pda; /** The collection to which the asset belongs */ @@ -51,50 +51,50 @@ export type UpdateExternalPluginV1InstructionAccounts = { }; // Data. -export type UpdateExternalPluginV1InstructionData = { +export type UpdateExternalPluginAdapterV1InstructionData = { discriminator: number; - key: BaseExternalPluginKey; - updateInfo: BaseExternalPluginUpdateInfo; + key: BaseExternalPluginAdapterKey; + updateInfo: BaseExternalPluginAdapterUpdateInfo; }; -export type UpdateExternalPluginV1InstructionDataArgs = { - key: BaseExternalPluginKeyArgs; - updateInfo: BaseExternalPluginUpdateInfoArgs; +export type UpdateExternalPluginAdapterV1InstructionDataArgs = { + key: BaseExternalPluginAdapterKeyArgs; + updateInfo: BaseExternalPluginAdapterUpdateInfoArgs; }; -export function getUpdateExternalPluginV1InstructionDataSerializer(): Serializer< - UpdateExternalPluginV1InstructionDataArgs, - UpdateExternalPluginV1InstructionData +export function getUpdateExternalPluginAdapterV1InstructionDataSerializer(): Serializer< + UpdateExternalPluginAdapterV1InstructionDataArgs, + UpdateExternalPluginAdapterV1InstructionData > { return mapSerializer< - UpdateExternalPluginV1InstructionDataArgs, + UpdateExternalPluginAdapterV1InstructionDataArgs, any, - UpdateExternalPluginV1InstructionData + UpdateExternalPluginAdapterV1InstructionData >( - struct( + struct( [ ['discriminator', u8()], - ['key', getBaseExternalPluginKeySerializer()], - ['updateInfo', getBaseExternalPluginUpdateInfoSerializer()], + ['key', getBaseExternalPluginAdapterKeySerializer()], + ['updateInfo', getBaseExternalPluginAdapterUpdateInfoSerializer()], ], - { description: 'UpdateExternalPluginV1InstructionData' } + { description: 'UpdateExternalPluginAdapterV1InstructionData' } ), (value) => ({ ...value, discriminator: 26 }) ) as Serializer< - UpdateExternalPluginV1InstructionDataArgs, - UpdateExternalPluginV1InstructionData + UpdateExternalPluginAdapterV1InstructionDataArgs, + UpdateExternalPluginAdapterV1InstructionData >; } // Args. -export type UpdateExternalPluginV1InstructionArgs = - UpdateExternalPluginV1InstructionDataArgs; +export type UpdateExternalPluginAdapterV1InstructionArgs = + UpdateExternalPluginAdapterV1InstructionDataArgs; // Instruction. -export function updateExternalPluginV1( +export function updateExternalPluginAdapterV1( context: Pick, - input: UpdateExternalPluginV1InstructionAccounts & - UpdateExternalPluginV1InstructionArgs + input: UpdateExternalPluginAdapterV1InstructionAccounts & + UpdateExternalPluginAdapterV1InstructionArgs ): TransactionBuilder { // Program ID. const programId = context.programs.getPublicKey( @@ -137,7 +137,9 @@ export function updateExternalPluginV1( } satisfies ResolvedAccountsWithIndices; // Arguments. - const resolvedArgs: UpdateExternalPluginV1InstructionArgs = { ...input }; + const resolvedArgs: UpdateExternalPluginAdapterV1InstructionArgs = { + ...input, + }; // Default values. if (!resolvedAccounts.payer.value) { @@ -164,9 +166,10 @@ export function updateExternalPluginV1( ); // Data. - const data = getUpdateExternalPluginV1InstructionDataSerializer().serialize( - resolvedArgs as UpdateExternalPluginV1InstructionDataArgs - ); + const data = + getUpdateExternalPluginAdapterV1InstructionDataSerializer().serialize( + resolvedArgs as UpdateExternalPluginAdapterV1InstructionDataArgs + ); // Bytes Created On Chain. const bytesCreatedOnChain = 0; diff --git a/clients/js/src/generated/instructions/writeCollectionExternalPluginDataV1.ts b/clients/js/src/generated/instructions/writeCollectionExternalPluginAdapterDataV1.ts similarity index 62% rename from clients/js/src/generated/instructions/writeCollectionExternalPluginDataV1.ts rename to clients/js/src/generated/instructions/writeCollectionExternalPluginAdapterDataV1.ts index 21c4b141..1397b69a 100644 --- a/clients/js/src/generated/instructions/writeCollectionExternalPluginDataV1.ts +++ b/clients/js/src/generated/instructions/writeCollectionExternalPluginAdapterDataV1.ts @@ -28,18 +28,18 @@ import { getAccountMetasAndSigners, } from '../shared'; import { - BaseExternalPluginKey, - BaseExternalPluginKeyArgs, - getBaseExternalPluginKeySerializer, + BaseExternalPluginAdapterKey, + BaseExternalPluginAdapterKeyArgs, + getBaseExternalPluginAdapterKeySerializer, } from '../types'; // Accounts. -export type WriteCollectionExternalPluginDataV1InstructionAccounts = { +export type WriteCollectionExternalPluginAdapterDataV1InstructionAccounts = { /** The address of the asset */ collection: PublicKey | Pda; /** The account paying for the storage fees */ payer?: Signer; - /** The Data Authority of the External Plugin */ + /** The Data Authority of the External PluginExternalPluginAdapter */ authority?: Signer; /** The system program */ systemProgram?: PublicKey | Pda; @@ -48,50 +48,53 @@ export type WriteCollectionExternalPluginDataV1InstructionAccounts = { }; // Data. -export type WriteCollectionExternalPluginDataV1InstructionData = { +export type WriteCollectionExternalPluginAdapterDataV1InstructionData = { discriminator: number; - key: BaseExternalPluginKey; + key: BaseExternalPluginAdapterKey; data: Uint8Array; }; -export type WriteCollectionExternalPluginDataV1InstructionDataArgs = { - key: BaseExternalPluginKeyArgs; +export type WriteCollectionExternalPluginAdapterDataV1InstructionDataArgs = { + key: BaseExternalPluginAdapterKeyArgs; data: Uint8Array; }; -export function getWriteCollectionExternalPluginDataV1InstructionDataSerializer(): Serializer< - WriteCollectionExternalPluginDataV1InstructionDataArgs, - WriteCollectionExternalPluginDataV1InstructionData +export function getWriteCollectionExternalPluginAdapterDataV1InstructionDataSerializer(): Serializer< + WriteCollectionExternalPluginAdapterDataV1InstructionDataArgs, + WriteCollectionExternalPluginAdapterDataV1InstructionData > { return mapSerializer< - WriteCollectionExternalPluginDataV1InstructionDataArgs, + WriteCollectionExternalPluginAdapterDataV1InstructionDataArgs, any, - WriteCollectionExternalPluginDataV1InstructionData + WriteCollectionExternalPluginAdapterDataV1InstructionData >( - struct( + struct( [ ['discriminator', u8()], - ['key', getBaseExternalPluginKeySerializer()], + ['key', getBaseExternalPluginAdapterKeySerializer()], ['data', bytes({ size: u32() })], ], - { description: 'WriteCollectionExternalPluginDataV1InstructionData' } + { + description: + 'WriteCollectionExternalPluginAdapterDataV1InstructionData', + } ), (value) => ({ ...value, discriminator: 29 }) ) as Serializer< - WriteCollectionExternalPluginDataV1InstructionDataArgs, - WriteCollectionExternalPluginDataV1InstructionData + WriteCollectionExternalPluginAdapterDataV1InstructionDataArgs, + WriteCollectionExternalPluginAdapterDataV1InstructionData >; } // Args. -export type WriteCollectionExternalPluginDataV1InstructionArgs = - WriteCollectionExternalPluginDataV1InstructionDataArgs; +export type WriteCollectionExternalPluginAdapterDataV1InstructionArgs = + WriteCollectionExternalPluginAdapterDataV1InstructionDataArgs; // Instruction. -export function writeCollectionExternalPluginDataV1( +export function writeCollectionExternalPluginAdapterDataV1( context: Pick, - input: WriteCollectionExternalPluginDataV1InstructionAccounts & - WriteCollectionExternalPluginDataV1InstructionArgs + input: WriteCollectionExternalPluginAdapterDataV1InstructionAccounts & + WriteCollectionExternalPluginAdapterDataV1InstructionArgs ): TransactionBuilder { // Program ID. const programId = context.programs.getPublicKey( @@ -129,9 +132,8 @@ export function writeCollectionExternalPluginDataV1( } satisfies ResolvedAccountsWithIndices; // Arguments. - const resolvedArgs: WriteCollectionExternalPluginDataV1InstructionArgs = { - ...input, - }; + const resolvedArgs: WriteCollectionExternalPluginAdapterDataV1InstructionArgs = + { ...input }; // Default values. if (!resolvedAccounts.payer.value) { @@ -159,8 +161,8 @@ export function writeCollectionExternalPluginDataV1( // Data. const data = - getWriteCollectionExternalPluginDataV1InstructionDataSerializer().serialize( - resolvedArgs as WriteCollectionExternalPluginDataV1InstructionDataArgs + getWriteCollectionExternalPluginAdapterDataV1InstructionDataSerializer().serialize( + resolvedArgs as WriteCollectionExternalPluginAdapterDataV1InstructionDataArgs ); // Bytes Created On Chain. diff --git a/clients/js/src/generated/instructions/writeExternalPluginDataV1.ts b/clients/js/src/generated/instructions/writeExternalPluginAdapterDataV1.ts similarity index 66% rename from clients/js/src/generated/instructions/writeExternalPluginDataV1.ts rename to clients/js/src/generated/instructions/writeExternalPluginAdapterDataV1.ts index 76d0568e..78e639ba 100644 --- a/clients/js/src/generated/instructions/writeExternalPluginDataV1.ts +++ b/clients/js/src/generated/instructions/writeExternalPluginAdapterDataV1.ts @@ -28,20 +28,20 @@ import { getAccountMetasAndSigners, } from '../shared'; import { - BaseExternalPluginKey, - BaseExternalPluginKeyArgs, - getBaseExternalPluginKeySerializer, + BaseExternalPluginAdapterKey, + BaseExternalPluginAdapterKeyArgs, + getBaseExternalPluginAdapterKeySerializer, } from '../types'; // Accounts. -export type WriteExternalPluginDataV1InstructionAccounts = { +export type WriteExternalPluginAdapterDataV1InstructionAccounts = { /** The address of the asset */ asset: PublicKey | Pda; /** The collection to which the asset belongs */ collection?: PublicKey | Pda; /** The account paying for the storage fees */ payer?: Signer; - /** The Data Authority of the External Plugin */ + /** The Data Authority of the External PluginExternalPluginAdapter */ authority?: Signer; /** The system program */ systemProgram?: PublicKey | Pda; @@ -50,50 +50,50 @@ export type WriteExternalPluginDataV1InstructionAccounts = { }; // Data. -export type WriteExternalPluginDataV1InstructionData = { +export type WriteExternalPluginAdapterDataV1InstructionData = { discriminator: number; - key: BaseExternalPluginKey; + key: BaseExternalPluginAdapterKey; data: Uint8Array; }; -export type WriteExternalPluginDataV1InstructionDataArgs = { - key: BaseExternalPluginKeyArgs; +export type WriteExternalPluginAdapterDataV1InstructionDataArgs = { + key: BaseExternalPluginAdapterKeyArgs; data: Uint8Array; }; -export function getWriteExternalPluginDataV1InstructionDataSerializer(): Serializer< - WriteExternalPluginDataV1InstructionDataArgs, - WriteExternalPluginDataV1InstructionData +export function getWriteExternalPluginAdapterDataV1InstructionDataSerializer(): Serializer< + WriteExternalPluginAdapterDataV1InstructionDataArgs, + WriteExternalPluginAdapterDataV1InstructionData > { return mapSerializer< - WriteExternalPluginDataV1InstructionDataArgs, + WriteExternalPluginAdapterDataV1InstructionDataArgs, any, - WriteExternalPluginDataV1InstructionData + WriteExternalPluginAdapterDataV1InstructionData >( - struct( + struct( [ ['discriminator', u8()], - ['key', getBaseExternalPluginKeySerializer()], + ['key', getBaseExternalPluginAdapterKeySerializer()], ['data', bytes({ size: u32() })], ], - { description: 'WriteExternalPluginDataV1InstructionData' } + { description: 'WriteExternalPluginAdapterDataV1InstructionData' } ), (value) => ({ ...value, discriminator: 28 }) ) as Serializer< - WriteExternalPluginDataV1InstructionDataArgs, - WriteExternalPluginDataV1InstructionData + WriteExternalPluginAdapterDataV1InstructionDataArgs, + WriteExternalPluginAdapterDataV1InstructionData >; } // Args. -export type WriteExternalPluginDataV1InstructionArgs = - WriteExternalPluginDataV1InstructionDataArgs; +export type WriteExternalPluginAdapterDataV1InstructionArgs = + WriteExternalPluginAdapterDataV1InstructionDataArgs; // Instruction. -export function writeExternalPluginDataV1( +export function writeExternalPluginAdapterDataV1( context: Pick, - input: WriteExternalPluginDataV1InstructionAccounts & - WriteExternalPluginDataV1InstructionArgs + input: WriteExternalPluginAdapterDataV1InstructionAccounts & + WriteExternalPluginAdapterDataV1InstructionArgs ): TransactionBuilder { // Program ID. const programId = context.programs.getPublicKey( @@ -136,7 +136,9 @@ export function writeExternalPluginDataV1( } satisfies ResolvedAccountsWithIndices; // Arguments. - const resolvedArgs: WriteExternalPluginDataV1InstructionArgs = { ...input }; + const resolvedArgs: WriteExternalPluginAdapterDataV1InstructionArgs = { + ...input, + }; // Default values. if (!resolvedAccounts.payer.value) { @@ -164,8 +166,8 @@ export function writeExternalPluginDataV1( // Data. const data = - getWriteExternalPluginDataV1InstructionDataSerializer().serialize( - resolvedArgs as WriteExternalPluginDataV1InstructionDataArgs + getWriteExternalPluginAdapterDataV1InstructionDataSerializer().serialize( + resolvedArgs as WriteExternalPluginAdapterDataV1InstructionDataArgs ); // Bytes Created On Chain. diff --git a/clients/js/src/generated/types/baseDataStore.ts b/clients/js/src/generated/types/baseDataStore.ts index 35d75863..e83eff4d 100644 --- a/clients/js/src/generated/types/baseDataStore.ts +++ b/clients/js/src/generated/types/baseDataStore.ts @@ -10,20 +10,20 @@ import { Serializer, struct } from '@metaplex-foundation/umi/serializers'; import { BasePluginAuthority, BasePluginAuthorityArgs, - ExternalPluginSchema, - ExternalPluginSchemaArgs, + ExternalPluginAdapterSchema, + ExternalPluginAdapterSchemaArgs, getBasePluginAuthoritySerializer, - getExternalPluginSchemaSerializer, + getExternalPluginAdapterSchemaSerializer, } from '.'; export type BaseDataStore = { dataAuthority: BasePluginAuthority; - schema: ExternalPluginSchema; + schema: ExternalPluginAdapterSchema; }; export type BaseDataStoreArgs = { dataAuthority: BasePluginAuthorityArgs; - schema: ExternalPluginSchemaArgs; + schema: ExternalPluginAdapterSchemaArgs; }; export function getBaseDataStoreSerializer(): Serializer< @@ -33,7 +33,7 @@ export function getBaseDataStoreSerializer(): Serializer< return struct( [ ['dataAuthority', getBasePluginAuthoritySerializer()], - ['schema', getExternalPluginSchemaSerializer()], + ['schema', getExternalPluginAdapterSchemaSerializer()], ], { description: 'BaseDataStore' } ) as Serializer; diff --git a/clients/js/src/generated/types/baseDataStoreInitInfo.ts b/clients/js/src/generated/types/baseDataStoreInitInfo.ts index 30263140..b23c72f6 100644 --- a/clients/js/src/generated/types/baseDataStoreInitInfo.ts +++ b/clients/js/src/generated/types/baseDataStoreInitInfo.ts @@ -15,22 +15,22 @@ import { import { BasePluginAuthority, BasePluginAuthorityArgs, - ExternalPluginSchema, - ExternalPluginSchemaArgs, + ExternalPluginAdapterSchema, + ExternalPluginAdapterSchemaArgs, getBasePluginAuthoritySerializer, - getExternalPluginSchemaSerializer, + getExternalPluginAdapterSchemaSerializer, } from '.'; export type BaseDataStoreInitInfo = { dataAuthority: BasePluginAuthority; initPluginAuthority: Option; - schema: Option; + schema: Option; }; export type BaseDataStoreInitInfoArgs = { dataAuthority: BasePluginAuthorityArgs; initPluginAuthority: OptionOrNullable; - schema: OptionOrNullable; + schema: OptionOrNullable; }; export function getBaseDataStoreInitInfoSerializer(): Serializer< @@ -41,7 +41,7 @@ export function getBaseDataStoreInitInfoSerializer(): Serializer< [ ['dataAuthority', getBasePluginAuthoritySerializer()], ['initPluginAuthority', option(getBasePluginAuthoritySerializer())], - ['schema', option(getExternalPluginSchemaSerializer())], + ['schema', option(getExternalPluginAdapterSchemaSerializer())], ], { description: 'BaseDataStoreInitInfo' } ) as Serializer; diff --git a/clients/js/src/generated/types/baseDataStoreUpdateInfo.ts b/clients/js/src/generated/types/baseDataStoreUpdateInfo.ts index e2202de7..53b65c4c 100644 --- a/clients/js/src/generated/types/baseDataStoreUpdateInfo.ts +++ b/clients/js/src/generated/types/baseDataStoreUpdateInfo.ts @@ -13,15 +13,17 @@ import { struct, } from '@metaplex-foundation/umi/serializers'; import { - ExternalPluginSchema, - ExternalPluginSchemaArgs, - getExternalPluginSchemaSerializer, + ExternalPluginAdapterSchema, + ExternalPluginAdapterSchemaArgs, + getExternalPluginAdapterSchemaSerializer, } from '.'; -export type BaseDataStoreUpdateInfo = { schema: Option }; +export type BaseDataStoreUpdateInfo = { + schema: Option; +}; export type BaseDataStoreUpdateInfoArgs = { - schema: OptionOrNullable; + schema: OptionOrNullable; }; export function getBaseDataStoreUpdateInfoSerializer(): Serializer< @@ -29,7 +31,7 @@ export function getBaseDataStoreUpdateInfoSerializer(): Serializer< BaseDataStoreUpdateInfo > { return struct( - [['schema', option(getExternalPluginSchemaSerializer())]], + [['schema', option(getExternalPluginAdapterSchemaSerializer())]], { description: 'BaseDataStoreUpdateInfo' } ) as Serializer; } diff --git a/clients/js/src/generated/types/baseExternalPluginAdapterInitInfo.ts b/clients/js/src/generated/types/baseExternalPluginAdapterInitInfo.ts new file mode 100644 index 00000000..2649b73a --- /dev/null +++ b/clients/js/src/generated/types/baseExternalPluginAdapterInitInfo.ts @@ -0,0 +1,113 @@ +/** + * 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 { + GetDataEnumKind, + GetDataEnumKindContent, + Serializer, + dataEnum, + struct, + tuple, +} from '@metaplex-foundation/umi/serializers'; +import { + BaseDataStoreInitInfo, + BaseDataStoreInitInfoArgs, + BaseLifecycleHookInitInfo, + BaseLifecycleHookInitInfoArgs, + BaseOracleInitInfo, + BaseOracleInitInfoArgs, + getBaseDataStoreInitInfoSerializer, + getBaseLifecycleHookInitInfoSerializer, + getBaseOracleInitInfoSerializer, +} from '.'; + +export type BaseExternalPluginAdapterInitInfo = + | { __kind: 'LifecycleHook'; fields: [BaseLifecycleHookInitInfo] } + | { __kind: 'Oracle'; fields: [BaseOracleInitInfo] } + | { __kind: 'DataStore'; fields: [BaseDataStoreInitInfo] }; + +export type BaseExternalPluginAdapterInitInfoArgs = + | { __kind: 'LifecycleHook'; fields: [BaseLifecycleHookInitInfoArgs] } + | { __kind: 'Oracle'; fields: [BaseOracleInitInfoArgs] } + | { __kind: 'DataStore'; fields: [BaseDataStoreInitInfoArgs] }; + +export function getBaseExternalPluginAdapterInitInfoSerializer(): Serializer< + BaseExternalPluginAdapterInitInfoArgs, + BaseExternalPluginAdapterInitInfo +> { + return dataEnum( + [ + [ + 'LifecycleHook', + struct< + GetDataEnumKindContent< + BaseExternalPluginAdapterInitInfo, + 'LifecycleHook' + > + >([['fields', tuple([getBaseLifecycleHookInitInfoSerializer()])]]), + ], + [ + 'Oracle', + struct< + GetDataEnumKindContent + >([['fields', tuple([getBaseOracleInitInfoSerializer()])]]), + ], + [ + 'DataStore', + struct< + GetDataEnumKindContent + >([['fields', tuple([getBaseDataStoreInitInfoSerializer()])]]), + ], + ], + { description: 'BaseExternalPluginAdapterInitInfo' } + ) as Serializer< + BaseExternalPluginAdapterInitInfoArgs, + BaseExternalPluginAdapterInitInfo + >; +} + +// Data Enum Helpers. +export function baseExternalPluginAdapterInitInfo( + kind: 'LifecycleHook', + data: GetDataEnumKindContent< + BaseExternalPluginAdapterInitInfoArgs, + 'LifecycleHook' + >['fields'] +): GetDataEnumKind; +export function baseExternalPluginAdapterInitInfo( + kind: 'Oracle', + data: GetDataEnumKindContent< + BaseExternalPluginAdapterInitInfoArgs, + 'Oracle' + >['fields'] +): GetDataEnumKind; +export function baseExternalPluginAdapterInitInfo( + kind: 'DataStore', + data: GetDataEnumKindContent< + BaseExternalPluginAdapterInitInfoArgs, + 'DataStore' + >['fields'] +): GetDataEnumKind; +export function baseExternalPluginAdapterInitInfo< + K extends BaseExternalPluginAdapterInitInfoArgs['__kind'], +>( + kind: K, + data?: any +): Extract { + return Array.isArray(data) + ? { __kind: kind, fields: data } + : { __kind: kind, ...(data ?? {}) }; +} +export function isBaseExternalPluginAdapterInitInfo< + K extends BaseExternalPluginAdapterInitInfo['__kind'], +>( + kind: K, + value: BaseExternalPluginAdapterInitInfo +): value is BaseExternalPluginAdapterInitInfo & { __kind: K } { + return value.__kind === kind; +} diff --git a/clients/js/src/generated/types/baseExternalPluginAdapterKey.ts b/clients/js/src/generated/types/baseExternalPluginAdapterKey.ts new file mode 100644 index 00000000..1a57e653 --- /dev/null +++ b/clients/js/src/generated/types/baseExternalPluginAdapterKey.ts @@ -0,0 +1,106 @@ +/** + * 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 { PublicKey } from '@metaplex-foundation/umi'; +import { + GetDataEnumKind, + GetDataEnumKindContent, + Serializer, + dataEnum, + publicKey as publicKeySerializer, + struct, + tuple, +} from '@metaplex-foundation/umi/serializers'; +import { + BasePluginAuthority, + BasePluginAuthorityArgs, + getBasePluginAuthoritySerializer, +} from '.'; + +export type BaseExternalPluginAdapterKey = + | { __kind: 'LifecycleHook'; fields: [PublicKey] } + | { __kind: 'Oracle'; fields: [PublicKey] } + | { __kind: 'DataStore'; fields: [BasePluginAuthority] }; + +export type BaseExternalPluginAdapterKeyArgs = + | { __kind: 'LifecycleHook'; fields: [PublicKey] } + | { __kind: 'Oracle'; fields: [PublicKey] } + | { __kind: 'DataStore'; fields: [BasePluginAuthorityArgs] }; + +export function getBaseExternalPluginAdapterKeySerializer(): Serializer< + BaseExternalPluginAdapterKeyArgs, + BaseExternalPluginAdapterKey +> { + return dataEnum( + [ + [ + 'LifecycleHook', + struct< + GetDataEnumKindContent + >([['fields', tuple([publicKeySerializer()])]]), + ], + [ + 'Oracle', + struct>([ + ['fields', tuple([publicKeySerializer()])], + ]), + ], + [ + 'DataStore', + struct< + GetDataEnumKindContent + >([['fields', tuple([getBasePluginAuthoritySerializer()])]]), + ], + ], + { description: 'BaseExternalPluginAdapterKey' } + ) as Serializer< + BaseExternalPluginAdapterKeyArgs, + BaseExternalPluginAdapterKey + >; +} + +// Data Enum Helpers. +export function baseExternalPluginAdapterKey( + kind: 'LifecycleHook', + data: GetDataEnumKindContent< + BaseExternalPluginAdapterKeyArgs, + 'LifecycleHook' + >['fields'] +): GetDataEnumKind; +export function baseExternalPluginAdapterKey( + kind: 'Oracle', + data: GetDataEnumKindContent< + BaseExternalPluginAdapterKeyArgs, + 'Oracle' + >['fields'] +): GetDataEnumKind; +export function baseExternalPluginAdapterKey( + kind: 'DataStore', + data: GetDataEnumKindContent< + BaseExternalPluginAdapterKeyArgs, + 'DataStore' + >['fields'] +): GetDataEnumKind; +export function baseExternalPluginAdapterKey< + K extends BaseExternalPluginAdapterKeyArgs['__kind'], +>( + kind: K, + data?: any +): Extract { + return Array.isArray(data) + ? { __kind: kind, fields: data } + : { __kind: kind, ...(data ?? {}) }; +} +export function isBaseExternalPluginAdapterKey< + K extends BaseExternalPluginAdapterKey['__kind'], +>( + kind: K, + value: BaseExternalPluginAdapterKey +): value is BaseExternalPluginAdapterKey & { __kind: K } { + return value.__kind === kind; +} diff --git a/clients/js/src/generated/types/baseExternalPluginUpdateInfo.ts b/clients/js/src/generated/types/baseExternalPluginAdapterUpdateInfo.ts similarity index 51% rename from clients/js/src/generated/types/baseExternalPluginUpdateInfo.ts rename to clients/js/src/generated/types/baseExternalPluginAdapterUpdateInfo.ts index 6cd1e7d7..4fc19360 100644 --- a/clients/js/src/generated/types/baseExternalPluginUpdateInfo.ts +++ b/clients/js/src/generated/types/baseExternalPluginAdapterUpdateInfo.ts @@ -26,85 +26,91 @@ import { getBaseOracleUpdateInfoSerializer, } from '.'; -export type BaseExternalPluginUpdateInfo = +export type BaseExternalPluginAdapterUpdateInfo = | { __kind: 'LifecycleHook'; fields: [BaseLifecycleHookUpdateInfo] } | { __kind: 'Oracle'; fields: [BaseOracleUpdateInfo] } | { __kind: 'DataStore'; fields: [BaseDataStoreUpdateInfo] }; -export type BaseExternalPluginUpdateInfoArgs = +export type BaseExternalPluginAdapterUpdateInfoArgs = | { __kind: 'LifecycleHook'; fields: [BaseLifecycleHookUpdateInfoArgs] } | { __kind: 'Oracle'; fields: [BaseOracleUpdateInfoArgs] } | { __kind: 'DataStore'; fields: [BaseDataStoreUpdateInfoArgs] }; -export function getBaseExternalPluginUpdateInfoSerializer(): Serializer< - BaseExternalPluginUpdateInfoArgs, - BaseExternalPluginUpdateInfo +export function getBaseExternalPluginAdapterUpdateInfoSerializer(): Serializer< + BaseExternalPluginAdapterUpdateInfoArgs, + BaseExternalPluginAdapterUpdateInfo > { - return dataEnum( + return dataEnum( [ [ 'LifecycleHook', struct< - GetDataEnumKindContent + GetDataEnumKindContent< + BaseExternalPluginAdapterUpdateInfo, + 'LifecycleHook' + > >([['fields', tuple([getBaseLifecycleHookUpdateInfoSerializer()])]]), ], [ 'Oracle', - struct>([ - ['fields', tuple([getBaseOracleUpdateInfoSerializer()])], - ]), + struct< + GetDataEnumKindContent + >([['fields', tuple([getBaseOracleUpdateInfoSerializer()])]]), ], [ 'DataStore', struct< - GetDataEnumKindContent + GetDataEnumKindContent< + BaseExternalPluginAdapterUpdateInfo, + 'DataStore' + > >([['fields', tuple([getBaseDataStoreUpdateInfoSerializer()])]]), ], ], - { description: 'BaseExternalPluginUpdateInfo' } + { description: 'BaseExternalPluginAdapterUpdateInfo' } ) as Serializer< - BaseExternalPluginUpdateInfoArgs, - BaseExternalPluginUpdateInfo + BaseExternalPluginAdapterUpdateInfoArgs, + BaseExternalPluginAdapterUpdateInfo >; } // Data Enum Helpers. -export function baseExternalPluginUpdateInfo( +export function baseExternalPluginAdapterUpdateInfo( kind: 'LifecycleHook', data: GetDataEnumKindContent< - BaseExternalPluginUpdateInfoArgs, + BaseExternalPluginAdapterUpdateInfoArgs, 'LifecycleHook' >['fields'] -): GetDataEnumKind; -export function baseExternalPluginUpdateInfo( +): GetDataEnumKind; +export function baseExternalPluginAdapterUpdateInfo( kind: 'Oracle', data: GetDataEnumKindContent< - BaseExternalPluginUpdateInfoArgs, + BaseExternalPluginAdapterUpdateInfoArgs, 'Oracle' >['fields'] -): GetDataEnumKind; -export function baseExternalPluginUpdateInfo( +): GetDataEnumKind; +export function baseExternalPluginAdapterUpdateInfo( kind: 'DataStore', data: GetDataEnumKindContent< - BaseExternalPluginUpdateInfoArgs, + BaseExternalPluginAdapterUpdateInfoArgs, 'DataStore' >['fields'] -): GetDataEnumKind; -export function baseExternalPluginUpdateInfo< - K extends BaseExternalPluginUpdateInfoArgs['__kind'], +): GetDataEnumKind; +export function baseExternalPluginAdapterUpdateInfo< + K extends BaseExternalPluginAdapterUpdateInfoArgs['__kind'], >( kind: K, data?: any -): Extract { +): Extract { return Array.isArray(data) ? { __kind: kind, fields: data } : { __kind: kind, ...(data ?? {}) }; } -export function isBaseExternalPluginUpdateInfo< - K extends BaseExternalPluginUpdateInfo['__kind'], +export function isBaseExternalPluginAdapterUpdateInfo< + K extends BaseExternalPluginAdapterUpdateInfo['__kind'], >( kind: K, - value: BaseExternalPluginUpdateInfo -): value is BaseExternalPluginUpdateInfo & { __kind: K } { + value: BaseExternalPluginAdapterUpdateInfo +): value is BaseExternalPluginAdapterUpdateInfo & { __kind: K } { return value.__kind === kind; } diff --git a/clients/js/src/generated/types/baseExternalPluginInitInfo.ts b/clients/js/src/generated/types/baseExternalPluginInitInfo.ts deleted file mode 100644 index c739845e..00000000 --- a/clients/js/src/generated/types/baseExternalPluginInitInfo.ts +++ /dev/null @@ -1,104 +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 { - GetDataEnumKind, - GetDataEnumKindContent, - Serializer, - dataEnum, - struct, - tuple, -} from '@metaplex-foundation/umi/serializers'; -import { - BaseDataStoreInitInfo, - BaseDataStoreInitInfoArgs, - BaseLifecycleHookInitInfo, - BaseLifecycleHookInitInfoArgs, - BaseOracleInitInfo, - BaseOracleInitInfoArgs, - getBaseDataStoreInitInfoSerializer, - getBaseLifecycleHookInitInfoSerializer, - getBaseOracleInitInfoSerializer, -} from '.'; - -export type BaseExternalPluginInitInfo = - | { __kind: 'LifecycleHook'; fields: [BaseLifecycleHookInitInfo] } - | { __kind: 'Oracle'; fields: [BaseOracleInitInfo] } - | { __kind: 'DataStore'; fields: [BaseDataStoreInitInfo] }; - -export type BaseExternalPluginInitInfoArgs = - | { __kind: 'LifecycleHook'; fields: [BaseLifecycleHookInitInfoArgs] } - | { __kind: 'Oracle'; fields: [BaseOracleInitInfoArgs] } - | { __kind: 'DataStore'; fields: [BaseDataStoreInitInfoArgs] }; - -export function getBaseExternalPluginInitInfoSerializer(): Serializer< - BaseExternalPluginInitInfoArgs, - BaseExternalPluginInitInfo -> { - return dataEnum( - [ - [ - 'LifecycleHook', - struct< - GetDataEnumKindContent - >([['fields', tuple([getBaseLifecycleHookInitInfoSerializer()])]]), - ], - [ - 'Oracle', - struct>([ - ['fields', tuple([getBaseOracleInitInfoSerializer()])], - ]), - ], - [ - 'DataStore', - struct>( - [['fields', tuple([getBaseDataStoreInitInfoSerializer()])]] - ), - ], - ], - { description: 'BaseExternalPluginInitInfo' } - ) as Serializer; -} - -// Data Enum Helpers. -export function baseExternalPluginInitInfo( - kind: 'LifecycleHook', - data: GetDataEnumKindContent< - BaseExternalPluginInitInfoArgs, - 'LifecycleHook' - >['fields'] -): GetDataEnumKind; -export function baseExternalPluginInitInfo( - kind: 'Oracle', - data: GetDataEnumKindContent< - BaseExternalPluginInitInfoArgs, - 'Oracle' - >['fields'] -): GetDataEnumKind; -export function baseExternalPluginInitInfo( - kind: 'DataStore', - data: GetDataEnumKindContent< - BaseExternalPluginInitInfoArgs, - 'DataStore' - >['fields'] -): GetDataEnumKind; -export function baseExternalPluginInitInfo< - K extends BaseExternalPluginInitInfoArgs['__kind'], ->(kind: K, data?: any): Extract { - return Array.isArray(data) - ? { __kind: kind, fields: data } - : { __kind: kind, ...(data ?? {}) }; -} -export function isBaseExternalPluginInitInfo< - K extends BaseExternalPluginInitInfo['__kind'], ->( - kind: K, - value: BaseExternalPluginInitInfo -): value is BaseExternalPluginInitInfo & { __kind: K } { - return value.__kind === kind; -} diff --git a/clients/js/src/generated/types/baseExternalPluginKey.ts b/clients/js/src/generated/types/baseExternalPluginKey.ts deleted file mode 100644 index 294d0052..00000000 --- a/clients/js/src/generated/types/baseExternalPluginKey.ts +++ /dev/null @@ -1,94 +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 { PublicKey } from '@metaplex-foundation/umi'; -import { - GetDataEnumKind, - GetDataEnumKindContent, - Serializer, - dataEnum, - publicKey as publicKeySerializer, - struct, - tuple, -} from '@metaplex-foundation/umi/serializers'; -import { - BasePluginAuthority, - BasePluginAuthorityArgs, - getBasePluginAuthoritySerializer, -} from '.'; - -export type BaseExternalPluginKey = - | { __kind: 'LifecycleHook'; fields: [PublicKey] } - | { __kind: 'Oracle'; fields: [PublicKey] } - | { __kind: 'DataStore'; fields: [BasePluginAuthority] }; - -export type BaseExternalPluginKeyArgs = - | { __kind: 'LifecycleHook'; fields: [PublicKey] } - | { __kind: 'Oracle'; fields: [PublicKey] } - | { __kind: 'DataStore'; fields: [BasePluginAuthorityArgs] }; - -export function getBaseExternalPluginKeySerializer(): Serializer< - BaseExternalPluginKeyArgs, - BaseExternalPluginKey -> { - return dataEnum( - [ - [ - 'LifecycleHook', - struct>([ - ['fields', tuple([publicKeySerializer()])], - ]), - ], - [ - 'Oracle', - struct>([ - ['fields', tuple([publicKeySerializer()])], - ]), - ], - [ - 'DataStore', - struct>([ - ['fields', tuple([getBasePluginAuthoritySerializer()])], - ]), - ], - ], - { description: 'BaseExternalPluginKey' } - ) as Serializer; -} - -// Data Enum Helpers. -export function baseExternalPluginKey( - kind: 'LifecycleHook', - data: GetDataEnumKindContent< - BaseExternalPluginKeyArgs, - 'LifecycleHook' - >['fields'] -): GetDataEnumKind; -export function baseExternalPluginKey( - kind: 'Oracle', - data: GetDataEnumKindContent['fields'] -): GetDataEnumKind; -export function baseExternalPluginKey( - kind: 'DataStore', - data: GetDataEnumKindContent['fields'] -): GetDataEnumKind; -export function baseExternalPluginKey< - K extends BaseExternalPluginKeyArgs['__kind'], ->(kind: K, data?: any): Extract { - return Array.isArray(data) - ? { __kind: kind, fields: data } - : { __kind: kind, ...(data ?? {}) }; -} -export function isBaseExternalPluginKey< - K extends BaseExternalPluginKey['__kind'], ->( - kind: K, - value: BaseExternalPluginKey -): value is BaseExternalPluginKey & { __kind: K } { - return value.__kind === kind; -} diff --git a/clients/js/src/generated/types/baseLifecycleHook.ts b/clients/js/src/generated/types/baseLifecycleHook.ts index 1d2dd840..51e1d737 100644 --- a/clients/js/src/generated/types/baseLifecycleHook.ts +++ b/clients/js/src/generated/types/baseLifecycleHook.ts @@ -19,25 +19,25 @@ import { BaseExtraAccountArgs, BasePluginAuthority, BasePluginAuthorityArgs, - ExternalPluginSchema, - ExternalPluginSchemaArgs, + ExternalPluginAdapterSchema, + ExternalPluginAdapterSchemaArgs, getBaseExtraAccountSerializer, getBasePluginAuthoritySerializer, - getExternalPluginSchemaSerializer, + getExternalPluginAdapterSchemaSerializer, } from '.'; export type BaseLifecycleHook = { hookedProgram: PublicKey; extraAccounts: Option>; dataAuthority: Option; - schema: ExternalPluginSchema; + schema: ExternalPluginAdapterSchema; }; export type BaseLifecycleHookArgs = { hookedProgram: PublicKey; extraAccounts: OptionOrNullable>; dataAuthority: OptionOrNullable; - schema: ExternalPluginSchemaArgs; + schema: ExternalPluginAdapterSchemaArgs; }; export function getBaseLifecycleHookSerializer(): Serializer< @@ -49,7 +49,7 @@ export function getBaseLifecycleHookSerializer(): Serializer< ['hookedProgram', publicKeySerializer()], ['extraAccounts', option(array(getBaseExtraAccountSerializer()))], ['dataAuthority', option(getBasePluginAuthoritySerializer())], - ['schema', getExternalPluginSchemaSerializer()], + ['schema', getExternalPluginAdapterSchemaSerializer()], ], { description: 'BaseLifecycleHook' } ) as Serializer; diff --git a/clients/js/src/generated/types/baseLifecycleHookInitInfo.ts b/clients/js/src/generated/types/baseLifecycleHookInitInfo.ts index 3f4e483f..d9cd9bca 100644 --- a/clients/js/src/generated/types/baseLifecycleHookInitInfo.ts +++ b/clients/js/src/generated/types/baseLifecycleHookInitInfo.ts @@ -22,14 +22,14 @@ import { BasePluginAuthorityArgs, ExternalCheckResult, ExternalCheckResultArgs, - ExternalPluginSchema, - ExternalPluginSchemaArgs, + ExternalPluginAdapterSchema, + ExternalPluginAdapterSchemaArgs, HookableLifecycleEvent, HookableLifecycleEventArgs, getBaseExtraAccountSerializer, getBasePluginAuthoritySerializer, getExternalCheckResultSerializer, - getExternalPluginSchemaSerializer, + getExternalPluginAdapterSchemaSerializer, getHookableLifecycleEventSerializer, } from '.'; @@ -39,7 +39,7 @@ export type BaseLifecycleHookInitInfo = { lifecycleChecks: Array<[HookableLifecycleEvent, ExternalCheckResult]>; extraAccounts: Option>; dataAuthority: Option; - schema: Option; + schema: Option; }; export type BaseLifecycleHookInitInfoArgs = { @@ -48,7 +48,7 @@ export type BaseLifecycleHookInitInfoArgs = { lifecycleChecks: Array<[HookableLifecycleEventArgs, ExternalCheckResultArgs]>; extraAccounts: OptionOrNullable>; dataAuthority: OptionOrNullable; - schema: OptionOrNullable; + schema: OptionOrNullable; }; export function getBaseLifecycleHookInitInfoSerializer(): Serializer< @@ -70,7 +70,7 @@ export function getBaseLifecycleHookInitInfoSerializer(): Serializer< ], ['extraAccounts', option(array(getBaseExtraAccountSerializer()))], ['dataAuthority', option(getBasePluginAuthoritySerializer())], - ['schema', option(getExternalPluginSchemaSerializer())], + ['schema', option(getExternalPluginAdapterSchemaSerializer())], ], { description: 'BaseLifecycleHookInitInfo' } ) as Serializer; diff --git a/clients/js/src/generated/types/baseLifecycleHookUpdateInfo.ts b/clients/js/src/generated/types/baseLifecycleHookUpdateInfo.ts index 68ba9e48..26450898 100644 --- a/clients/js/src/generated/types/baseLifecycleHookUpdateInfo.ts +++ b/clients/js/src/generated/types/baseLifecycleHookUpdateInfo.ts @@ -19,20 +19,20 @@ import { BaseExtraAccountArgs, ExternalCheckResult, ExternalCheckResultArgs, - ExternalPluginSchema, - ExternalPluginSchemaArgs, + ExternalPluginAdapterSchema, + ExternalPluginAdapterSchemaArgs, HookableLifecycleEvent, HookableLifecycleEventArgs, getBaseExtraAccountSerializer, getExternalCheckResultSerializer, - getExternalPluginSchemaSerializer, + getExternalPluginAdapterSchemaSerializer, getHookableLifecycleEventSerializer, } from '.'; export type BaseLifecycleHookUpdateInfo = { lifecycleChecks: Option>; extraAccounts: Option>; - schema: Option; + schema: Option; }; export type BaseLifecycleHookUpdateInfoArgs = { @@ -40,7 +40,7 @@ export type BaseLifecycleHookUpdateInfoArgs = { Array<[HookableLifecycleEventArgs, ExternalCheckResultArgs]> >; extraAccounts: OptionOrNullable>; - schema: OptionOrNullable; + schema: OptionOrNullable; }; export function getBaseLifecycleHookUpdateInfoSerializer(): Serializer< @@ -61,7 +61,7 @@ export function getBaseLifecycleHookUpdateInfoSerializer(): Serializer< ), ], ['extraAccounts', option(array(getBaseExtraAccountSerializer()))], - ['schema', option(getExternalPluginSchemaSerializer())], + ['schema', option(getExternalPluginAdapterSchemaSerializer())], ], { description: 'BaseLifecycleHookUpdateInfo' } ) as Serializer; diff --git a/clients/js/src/generated/types/baseOracle.ts b/clients/js/src/generated/types/baseOracle.ts index 933c4df4..7b73d53f 100644 --- a/clients/js/src/generated/types/baseOracle.ts +++ b/clients/js/src/generated/types/baseOracle.ts @@ -24,13 +24,13 @@ import { export type BaseOracle = { baseAddress: PublicKey; - pda: Option; + baseAddressConfig: Option; resultsOffset: BaseValidationResultsOffset; }; export type BaseOracleArgs = { baseAddress: PublicKey; - pda: OptionOrNullable; + baseAddressConfig: OptionOrNullable; resultsOffset: BaseValidationResultsOffsetArgs; }; @@ -41,7 +41,7 @@ export function getBaseOracleSerializer(): Serializer< return struct( [ ['baseAddress', publicKeySerializer()], - ['pda', option(getBaseExtraAccountSerializer())], + ['baseAddressConfig', option(getBaseExtraAccountSerializer())], ['resultsOffset', getBaseValidationResultsOffsetSerializer()], ], { description: 'BaseOracle' } diff --git a/clients/js/src/generated/types/baseOracleInitInfo.ts b/clients/js/src/generated/types/baseOracleInitInfo.ts index 12ff3dfd..4f046613 100644 --- a/clients/js/src/generated/types/baseOracleInitInfo.ts +++ b/clients/js/src/generated/types/baseOracleInitInfo.ts @@ -37,7 +37,7 @@ export type BaseOracleInitInfo = { baseAddress: PublicKey; initPluginAuthority: Option; lifecycleChecks: Array<[HookableLifecycleEvent, ExternalCheckResult]>; - pda: Option; + baseAddressConfig: Option; resultsOffset: Option; }; @@ -45,7 +45,7 @@ export type BaseOracleInitInfoArgs = { baseAddress: PublicKey; initPluginAuthority: OptionOrNullable; lifecycleChecks: Array<[HookableLifecycleEventArgs, ExternalCheckResultArgs]>; - pda: OptionOrNullable; + baseAddressConfig: OptionOrNullable; resultsOffset: OptionOrNullable; }; @@ -66,7 +66,7 @@ export function getBaseOracleInitInfoSerializer(): Serializer< ]) ), ], - ['pda', option(getBaseExtraAccountSerializer())], + ['baseAddressConfig', option(getBaseExtraAccountSerializer())], ['resultsOffset', option(getBaseValidationResultsOffsetSerializer())], ], { description: 'BaseOracleInitInfo' } diff --git a/clients/js/src/generated/types/baseOracleUpdateInfo.ts b/clients/js/src/generated/types/baseOracleUpdateInfo.ts index ae97c039..7483a374 100644 --- a/clients/js/src/generated/types/baseOracleUpdateInfo.ts +++ b/clients/js/src/generated/types/baseOracleUpdateInfo.ts @@ -31,7 +31,7 @@ import { export type BaseOracleUpdateInfo = { lifecycleChecks: Option>; - pda: Option; + baseAddressConfig: Option; resultsOffset: Option; }; @@ -39,7 +39,7 @@ export type BaseOracleUpdateInfoArgs = { lifecycleChecks: OptionOrNullable< Array<[HookableLifecycleEventArgs, ExternalCheckResultArgs]> >; - pda: OptionOrNullable; + baseAddressConfig: OptionOrNullable; resultsOffset: OptionOrNullable; }; @@ -60,7 +60,7 @@ export function getBaseOracleUpdateInfoSerializer(): Serializer< ) ), ], - ['pda', option(getBaseExtraAccountSerializer())], + ['baseAddressConfig', option(getBaseExtraAccountSerializer())], ['resultsOffset', option(getBaseValidationResultsOffsetSerializer())], ], { description: 'BaseOracleUpdateInfo' } diff --git a/clients/js/src/generated/types/externalPlugin.ts b/clients/js/src/generated/types/externalPluginAdapter.ts similarity index 51% rename from clients/js/src/generated/types/externalPlugin.ts rename to clients/js/src/generated/types/externalPluginAdapter.ts index 3170b201..b50617df 100644 --- a/clients/js/src/generated/types/externalPlugin.ts +++ b/clients/js/src/generated/types/externalPluginAdapter.ts @@ -26,69 +26,73 @@ import { getBaseOracleSerializer, } from '.'; -export type ExternalPlugin = +export type ExternalPluginAdapter = | { __kind: 'LifecycleHook'; fields: [BaseLifecycleHook] } | { __kind: 'Oracle'; fields: [BaseOracle] } | { __kind: 'DataStore'; fields: [BaseDataStore] }; -export type ExternalPluginArgs = +export type ExternalPluginAdapterArgs = | { __kind: 'LifecycleHook'; fields: [BaseLifecycleHookArgs] } | { __kind: 'Oracle'; fields: [BaseOracleArgs] } | { __kind: 'DataStore'; fields: [BaseDataStoreArgs] }; -export function getExternalPluginSerializer(): Serializer< - ExternalPluginArgs, - ExternalPlugin +export function getExternalPluginAdapterSerializer(): Serializer< + ExternalPluginAdapterArgs, + ExternalPluginAdapter > { - return dataEnum( + return dataEnum( [ [ 'LifecycleHook', - struct>([ + struct>([ ['fields', tuple([getBaseLifecycleHookSerializer()])], ]), ], [ 'Oracle', - struct>([ + struct>([ ['fields', tuple([getBaseOracleSerializer()])], ]), ], [ 'DataStore', - struct>([ + struct>([ ['fields', tuple([getBaseDataStoreSerializer()])], ]), ], ], - { description: 'ExternalPlugin' } - ) as Serializer; + { description: 'ExternalPluginAdapter' } + ) as Serializer; } // Data Enum Helpers. -export function externalPlugin( +export function externalPluginAdapter( kind: 'LifecycleHook', - data: GetDataEnumKindContent['fields'] -): GetDataEnumKind; -export function externalPlugin( + data: GetDataEnumKindContent< + ExternalPluginAdapterArgs, + 'LifecycleHook' + >['fields'] +): GetDataEnumKind; +export function externalPluginAdapter( kind: 'Oracle', - data: GetDataEnumKindContent['fields'] -): GetDataEnumKind; -export function externalPlugin( + data: GetDataEnumKindContent['fields'] +): GetDataEnumKind; +export function externalPluginAdapter( kind: 'DataStore', - data: GetDataEnumKindContent['fields'] -): GetDataEnumKind; -export function externalPlugin( - kind: K, - data?: any -): Extract { + data: GetDataEnumKindContent['fields'] +): GetDataEnumKind; +export function externalPluginAdapter< + K extends ExternalPluginAdapterArgs['__kind'], +>(kind: K, data?: any): Extract { return Array.isArray(data) ? { __kind: kind, fields: data } : { __kind: kind, ...(data ?? {}) }; } -export function isExternalPlugin( +export function isExternalPluginAdapter< + K extends ExternalPluginAdapter['__kind'], +>( kind: K, - value: ExternalPlugin -): value is ExternalPlugin & { __kind: K } { + value: ExternalPluginAdapter +): value is ExternalPluginAdapter & { __kind: K } { return value.__kind === kind; } diff --git a/clients/js/src/generated/types/externalPluginAdapterSchema.ts b/clients/js/src/generated/types/externalPluginAdapterSchema.ts new file mode 100644 index 00000000..cbaff13a --- /dev/null +++ b/clients/js/src/generated/types/externalPluginAdapterSchema.ts @@ -0,0 +1,29 @@ +/** + * 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'; + +export enum ExternalPluginAdapterSchema { + Binary, + Json, + MsgPack, +} + +export type ExternalPluginAdapterSchemaArgs = ExternalPluginAdapterSchema; + +export function getExternalPluginAdapterSchemaSerializer(): Serializer< + ExternalPluginAdapterSchemaArgs, + ExternalPluginAdapterSchema +> { + return scalarEnum(ExternalPluginAdapterSchema, { + description: 'ExternalPluginAdapterSchema', + }) as Serializer< + ExternalPluginAdapterSchemaArgs, + ExternalPluginAdapterSchema + >; +} diff --git a/clients/js/src/generated/types/externalPluginAdapterType.ts b/clients/js/src/generated/types/externalPluginAdapterType.ts new file mode 100644 index 00000000..a0141f37 --- /dev/null +++ b/clients/js/src/generated/types/externalPluginAdapterType.ts @@ -0,0 +1,26 @@ +/** + * 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'; + +export enum ExternalPluginAdapterType { + LifecycleHook, + Oracle, + DataStore, +} + +export type ExternalPluginAdapterTypeArgs = ExternalPluginAdapterType; + +export function getExternalPluginAdapterTypeSerializer(): Serializer< + ExternalPluginAdapterTypeArgs, + ExternalPluginAdapterType +> { + return scalarEnum(ExternalPluginAdapterType, { + description: 'ExternalPluginAdapterType', + }) as Serializer; +} diff --git a/clients/js/src/generated/types/externalPluginSchema.ts b/clients/js/src/generated/types/externalPluginSchema.ts deleted file mode 100644 index 97b0e9f1..00000000 --- a/clients/js/src/generated/types/externalPluginSchema.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'; - -export enum ExternalPluginSchema { - Binary, - Json, - MsgPack, -} - -export type ExternalPluginSchemaArgs = ExternalPluginSchema; - -export function getExternalPluginSchemaSerializer(): Serializer< - ExternalPluginSchemaArgs, - ExternalPluginSchema -> { - return scalarEnum(ExternalPluginSchema, { - description: 'ExternalPluginSchema', - }) as Serializer; -} diff --git a/clients/js/src/generated/types/externalPluginType.ts b/clients/js/src/generated/types/externalPluginType.ts deleted file mode 100644 index 46dea348..00000000 --- a/clients/js/src/generated/types/externalPluginType.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'; - -export enum ExternalPluginType { - LifecycleHook, - Oracle, - DataStore, -} - -export type ExternalPluginTypeArgs = ExternalPluginType; - -export function getExternalPluginTypeSerializer(): Serializer< - ExternalPluginTypeArgs, - ExternalPluginType -> { - return scalarEnum(ExternalPluginType, { - description: 'ExternalPluginType', - }) as Serializer; -} diff --git a/clients/js/src/generated/types/externalRegistryRecord.ts b/clients/js/src/generated/types/externalRegistryRecord.ts index 344a6888..6d9f8134 100644 --- a/clients/js/src/generated/types/externalRegistryRecord.ts +++ b/clients/js/src/generated/types/externalRegistryRecord.ts @@ -20,18 +20,18 @@ import { BasePluginAuthorityArgs, ExternalCheckResult, ExternalCheckResultArgs, - ExternalPluginType, - ExternalPluginTypeArgs, + ExternalPluginAdapterType, + ExternalPluginAdapterTypeArgs, HookableLifecycleEvent, HookableLifecycleEventArgs, getBasePluginAuthoritySerializer, getExternalCheckResultSerializer, - getExternalPluginTypeSerializer, + getExternalPluginAdapterTypeSerializer, getHookableLifecycleEventSerializer, } from '.'; export type ExternalRegistryRecord = { - pluginType: ExternalPluginType; + pluginType: ExternalPluginAdapterType; authority: BasePluginAuthority; lifecycleChecks: Option>; offset: bigint; @@ -40,7 +40,7 @@ export type ExternalRegistryRecord = { }; export type ExternalRegistryRecordArgs = { - pluginType: ExternalPluginTypeArgs; + pluginType: ExternalPluginAdapterTypeArgs; authority: BasePluginAuthorityArgs; lifecycleChecks: OptionOrNullable< Array<[HookableLifecycleEventArgs, ExternalCheckResultArgs]> @@ -56,7 +56,7 @@ export function getExternalRegistryRecordSerializer(): Serializer< > { return struct( [ - ['pluginType', getExternalPluginTypeSerializer()], + ['pluginType', getExternalPluginAdapterTypeSerializer()], ['authority', getBasePluginAuthoritySerializer()], [ 'lifecycleChecks', diff --git a/clients/js/src/generated/types/index.ts b/clients/js/src/generated/types/index.ts index 8a62ffa6..ca171c8e 100644 --- a/clients/js/src/generated/types/index.ts +++ b/clients/js/src/generated/types/index.ts @@ -12,9 +12,9 @@ export * from './attributes'; export * from './baseDataStore'; export * from './baseDataStoreInitInfo'; export * from './baseDataStoreUpdateInfo'; -export * from './baseExternalPluginInitInfo'; -export * from './baseExternalPluginKey'; -export * from './baseExternalPluginUpdateInfo'; +export * from './baseExternalPluginAdapterInitInfo'; +export * from './baseExternalPluginAdapterKey'; +export * from './baseExternalPluginAdapterUpdateInfo'; export * from './baseExtraAccount'; export * from './baseLifecycleHook'; export * from './baseLifecycleHookInitInfo'; @@ -35,9 +35,9 @@ export * from './creator'; export * from './dataState'; export * from './edition'; export * from './externalCheckResult'; -export * from './externalPlugin'; -export * from './externalPluginSchema'; -export * from './externalPluginType'; +export * from './externalPluginAdapter'; +export * from './externalPluginAdapterSchema'; +export * from './externalPluginAdapterType'; export * from './externalRegistryRecord'; export * from './externalValidationResult'; export * from './freezeDelegate'; diff --git a/clients/js/src/helpers/lifecycle.ts b/clients/js/src/helpers/lifecycle.ts index 16f26650..c77eca8f 100644 --- a/clients/js/src/helpers/lifecycle.ts +++ b/clients/js/src/helpers/lifecycle.ts @@ -23,7 +23,7 @@ export enum LifecycleValidationError { /** * Check if the given authority is eligible to transfer the asset. - * This does NOT check the asset's royalty rule sets or external plugins. Use `validateTransfer` for more comprehensive checks. + * This does NOT check the asset's royalty rule sets or external plugin adapters. Use `validateTransfer` for more comprehensive checks. * @deprecated since v1.0.0. Use `validateTransfer` instead. * @param {PublicKey | string} authority Pubkey * @param {AssetV1} asset Asset @@ -106,7 +106,7 @@ export async function validateTransfer( ) .filter((o) => { // there's no PDA to derive, we can check the oracle account - if (!o.pda) { + if (!o.baseAddressConfig) { return true; } // If there's a recipient in the inputs, we can try to check the oracle account @@ -114,7 +114,11 @@ export async function validateTransfer( return true; } - if (!getExtraAccountRequiredInputs(o.pda).includes('recipient')) { + if ( + !getExtraAccountRequiredInputs(o.baseAddressConfig).includes( + 'recipient' + ) + ) { return true; } // we skip the check if there's a recipient required but no recipient provided @@ -178,7 +182,7 @@ export async function validateTransfer( /** * Check if the given pubkey is eligible to burn the asset. - * This does NOT check external plugins, use `validateBurn` for more comprehensive checks. + * This does NOT check external plugin adapters, use `validateBurn` for more comprehensive checks. * @deprecated since v1.0.0. Use `validateBurn` instead. * @param {PublicKey | string} authority Pubkey * @param {AssetV1} asset Asset @@ -317,7 +321,7 @@ export async function validateBurn( /** * Check if the given pubkey is eligible to update the asset. - * This does NOT check external plugins. Use `validateUpdate` for more comprehensive checks. + * This does NOT check external plugin adapters. Use `validateUpdate` for more comprehensive checks. * @deprecated since v1.0.0. Use `validateTransfer` instead. * @param {PublicKey | string} authority Pubkey * @param {AssetV1} asset Asset @@ -385,6 +389,7 @@ export async function validateUpdate( } return v?.update === ExternalValidationResult.Pass; }); + if (!oraclePass) { return LifecycleValidationError.OracleValidationFailed; } diff --git a/clients/js/src/helpers/state.ts b/clients/js/src/helpers/state.ts index 926f3c4c..44655ef7 100644 --- a/clients/js/src/helpers/state.ts +++ b/clients/js/src/helpers/state.ts @@ -1,6 +1,6 @@ import { PublicKey, publicKey } from '@metaplex-foundation/umi'; import { AssetV1, CollectionV1 } from '../generated'; -import { ExternalPluginsList } from '../plugins'; +import { ExternalPluginAdaptersList } from '../plugins'; import { OracleInitInfoArgs, OraclePlugin } from '../plugins/oracle'; import { DataStoreInitInfoArgs, DataStorePlugin } from '../plugins/dataStore'; import { @@ -21,12 +21,12 @@ export function collectionAddress(asset: AssetV1): PublicKey | undefined { return undefined; } -const externalPluginKeys: (keyof ExternalPluginsList)[] = [ +const externalPluginAdapterKeys: (keyof ExternalPluginAdaptersList)[] = [ 'oracles', 'dataStores', 'lifecycleHooks', ]; -export const getExternalPluginKeyAsString = ( +export const getExternalPluginAdapterKeyAsString = ( plugin: | OraclePlugin | DataStorePlugin @@ -48,36 +48,36 @@ export const getExternalPluginKeyAsString = ( } }; -export const deriveExternalPlugins = ( - asset: ExternalPluginsList, - collection?: ExternalPluginsList +export const deriveExternalPluginAdapters = ( + asset: ExternalPluginAdaptersList, + collection?: ExternalPluginAdaptersList ) => { if (!collection) { return asset; } - const externalPlugins: ExternalPluginsList = {}; - externalPluginKeys.forEach((key) => { + const externalPluginAdapters: ExternalPluginAdaptersList = {}; + externalPluginAdapterKeys.forEach((key) => { const set = new Set(); if (asset[key] || collection[key]) { - externalPlugins[key] = []; + externalPluginAdapters[key] = []; } asset[key]?.forEach( (plugin: OraclePlugin | DataStorePlugin | LifecycleHookPlugin) => { - set.add(getExternalPluginKeyAsString(plugin)); - externalPlugins[key]?.push(plugin as any); + set.add(getExternalPluginAdapterKeyAsString(plugin)); + externalPluginAdapters[key]?.push(plugin as any); } ); collection[key]?.forEach( (plugin: OraclePlugin | DataStorePlugin | LifecycleHookPlugin) => { - if (!set.has(getExternalPluginKeyAsString(plugin))) { - externalPlugins[key]?.push(plugin as any); + if (!set.has(getExternalPluginAdapterKeyAsString(plugin))) { + externalPluginAdapters[key]?.push(plugin as any); } } ); }); - return externalPlugins; + return externalPluginAdapters; }; /** * Derive the asset plugins from the asset and collection. Plugins on the asset take precedence over plugins on the collection. @@ -92,12 +92,15 @@ export function deriveAssetPlugins( if (!collection) { return asset; } - const externalPlugins = deriveExternalPlugins(asset, collection); + const externalPluginAdapters = deriveExternalPluginAdapters( + asset, + collection + ); return { ...collection, ...asset, - ...externalPlugins, + ...externalPluginAdapters, }; } diff --git a/clients/js/src/hooked/assetAccountData.ts b/clients/js/src/hooked/assetAccountData.ts index d3c9e267..51851a50 100644 --- a/clients/js/src/hooked/assetAccountData.ts +++ b/clients/js/src/hooked/assetAccountData.ts @@ -22,16 +22,16 @@ import { getPluginRegistryV1AccountDataSerializer, } from './pluginRegistryV1Data'; import { - ExternalPluginsList, - externalRegistryRecordsToExternalPluginList, -} from '../plugins/externalPlugins'; + ExternalPluginAdaptersList, + externalRegistryRecordsToExternalPluginAdapterList, +} from '../plugins/externalPluginAdapters'; export type AssetV1AccountData = Omit< GenAssetV1AccountData, 'updateAuthority' > & PluginsList & - ExternalPluginsList & { + ExternalPluginAdaptersList & { pluginHeader?: Omit; updateAuthority: UpdateAuthority; }; @@ -69,7 +69,7 @@ export const getAssetV1AccountDataSerializer = (): Serializer< let pluginHeader: PluginHeaderV1AccountData | undefined; let pluginRegistry: PluginRegistryV1AccountData | undefined; let pluginsList: PluginsList | undefined; - let externalPluginsList: ExternalPluginsList | undefined; + let externalPluginAdaptersList: ExternalPluginAdaptersList | undefined; let finalOffset = assetOffset; if (buffer.length !== assetOffset) { @@ -89,10 +89,11 @@ export const getAssetV1AccountDataSerializer = (): Serializer< buffer ); - externalPluginsList = externalRegistryRecordsToExternalPluginList( - pluginRegistry.externalRegistry, - buffer - ); + externalPluginAdaptersList = + externalRegistryRecordsToExternalPluginAdapterList( + pluginRegistry.externalRegistry, + buffer + ); } const updateAuth = { type: asset.updateAuthority.__kind, @@ -106,7 +107,7 @@ export const getAssetV1AccountDataSerializer = (): Serializer< { pluginHeader, ...pluginsList, - ...externalPluginsList, + ...externalPluginAdaptersList, ...asset, updateAuthority: updateAuth, }, diff --git a/clients/js/src/hooked/collectionAccountData.ts b/clients/js/src/hooked/collectionAccountData.ts index d36e81cc..5f389469 100644 --- a/clients/js/src/hooked/collectionAccountData.ts +++ b/clients/js/src/hooked/collectionAccountData.ts @@ -12,8 +12,8 @@ import { getCollectionV1AccountDataSerializer as genGetCollectionV1AccountDataSerializer, } from '../generated/types/collectionV1AccountData'; import { - ExternalPluginsList, - externalRegistryRecordsToExternalPluginList, + ExternalPluginAdaptersList, + externalRegistryRecordsToExternalPluginAdapterList, PluginsList, registryRecordsToPluginsList, } from '../plugins'; @@ -24,7 +24,7 @@ import { export type CollectionV1AccountData = GenCollectionV1AccountData & PluginsList & - ExternalPluginsList & { + ExternalPluginAdaptersList & { pluginHeader?: Omit; }; @@ -62,7 +62,7 @@ export const getCollectionV1AccountDataSerializer = (): Serializer< let pluginHeader: PluginHeaderV1AccountData | undefined; let pluginRegistry: PluginRegistryV1AccountData | undefined; let pluginsList: PluginsList | undefined; - let externalPluginsList: ExternalPluginsList | undefined; + let externalPluginAdaptersList: ExternalPluginAdaptersList | undefined; let finalOffset = collectionOffset; if (buffer.length !== collectionOffset) { @@ -82,17 +82,18 @@ export const getCollectionV1AccountDataSerializer = (): Serializer< buffer ); - externalPluginsList = externalRegistryRecordsToExternalPluginList( - pluginRegistry.externalRegistry, - buffer - ); + externalPluginAdaptersList = + externalRegistryRecordsToExternalPluginAdapterList( + pluginRegistry.externalRegistry, + buffer + ); } return [ { pluginHeader, ...pluginsList, - ...externalPluginsList, + ...externalPluginAdaptersList, ...collection, }, finalOffset, diff --git a/clients/js/src/hooked/pluginRegistryV1Data.ts b/clients/js/src/hooked/pluginRegistryV1Data.ts index 62a76836..00ee11e1 100644 --- a/clients/js/src/hooked/pluginRegistryV1Data.ts +++ b/clients/js/src/hooked/pluginRegistryV1Data.ts @@ -15,8 +15,8 @@ import { getPluginTypeSerializer, ExternalRegistryRecordArgs, ExternalRegistryRecord, - getExternalPluginTypeSerializer, - ExternalPluginType, + getExternalPluginAdapterTypeSerializer, + ExternalPluginAdapterType, getHookableLifecycleEventSerializer, getExternalCheckResultSerializer, } from '../generated'; @@ -87,12 +87,12 @@ export function getRegistryRecordSerializer(): Serializer< }; } -export function getExternalRegistryRecordSerializer(): Serializer< +export function getAdapterRegistryRecordSerializer(): Serializer< ExternalRegistryRecordArgs, ExternalRegistryRecordWithUnknown > { return { - description: 'ExternalRegistryRecordWithUnknown', + description: 'AdapterRegistryRecordWithUnknown', fixedSize: null, maxSize: null, serialize: () => { @@ -103,13 +103,13 @@ export function getExternalRegistryRecordSerializer(): Serializer< offset = 0 ): [ExternalRegistryRecordWithUnknown, number] => { let [pluginType, pluginTypeOffset, isUnknown] = [ - ExternalPluginType.DataStore, + ExternalPluginAdapterType.DataStore, offset + 1, true, ]; try { [pluginType, pluginTypeOffset] = - getExternalPluginTypeSerializer().deserialize(buffer, offset); + getExternalPluginAdapterTypeSerializer().deserialize(buffer, offset); isUnknown = false; } catch (e) { // do nothing @@ -183,7 +183,7 @@ export function getPluginRegistryV1AccountDataSerializer(): Serializer< ).deserialize(buffer, keyOffset); const [externalRegistry, externalRegistryOffset] = array( - getExternalRegistryRecordSerializer() + getAdapterRegistryRecordSerializer() ).deserialize(buffer, registryOffset); return [ diff --git a/clients/js/src/instructions/addPlugin.ts b/clients/js/src/instructions/addPlugin.ts index c9b10228..399a2a15 100644 --- a/clients/js/src/instructions/addPlugin.ts +++ b/clients/js/src/instructions/addPlugin.ts @@ -1,16 +1,16 @@ import { Context } from '@metaplex-foundation/umi'; -import { addPluginV1, addExternalPluginV1 } from '../generated'; +import { addPluginV1, addExternalPluginAdapterV1 } from '../generated'; import { AddablePluginAuthorityPairArgsV2, - ExternalPluginInitInfoArgs, - createExternalPluginInitInfo, - isExternalPluginType, + ExternalPluginAdapterInitInfoArgs, + createExternalPluginAdapterInitInfo, + isExternalPluginAdapterType, pluginAuthorityPairV2, } from '../plugins'; export type AddPluginArgsPlugin = | AddablePluginAuthorityPairArgsV2 - | ExternalPluginInitInfoArgs; + | ExternalPluginAdapterInitInfoArgs; export type AddPluginArgs = Omit< Parameters[1], @@ -23,11 +23,11 @@ export const addPlugin = ( context: Pick, { plugin, ...args }: AddPluginArgs ) => { - if (isExternalPluginType(plugin)) { - return addExternalPluginV1(context, { + if (isExternalPluginAdapterType(plugin)) { + return addExternalPluginAdapterV1(context, { ...args, - initInfo: createExternalPluginInitInfo( - plugin as ExternalPluginInitInfoArgs + initInfo: createExternalPluginAdapterInitInfo( + plugin as ExternalPluginAdapterInitInfoArgs ), }); } diff --git a/clients/js/src/instructions/burn.ts b/clients/js/src/instructions/burn.ts index 1aa2b7d8..396aa5a0 100644 --- a/clients/js/src/instructions/burn.ts +++ b/clients/js/src/instructions/burn.ts @@ -1,7 +1,7 @@ import { Context } from '@metaplex-foundation/umi'; import { CollectionV1, burnV1, AssetV1 } from '../generated'; import { findExtraAccounts } from '../plugins'; -import { deriveExternalPlugins } from '../helpers'; +import { deriveExternalPluginAdapters } from '../helpers'; export type BurnArgs = Omit< Parameters[1], @@ -15,12 +15,15 @@ export const burn = ( context: Pick, { asset, collection, ...args }: BurnArgs ) => { - const derivedExternalPlugins = deriveExternalPlugins(asset, collection); + const derivedExternalPluginAdapters = deriveExternalPluginAdapters( + asset, + collection + ); const extraAccounts = findExtraAccounts( context, 'burn', - derivedExternalPlugins, + derivedExternalPluginAdapters, { asset: asset.publicKey, collection: collection?.publicKey, diff --git a/clients/js/src/instructions/collection/addCollectionPlugin.ts b/clients/js/src/instructions/collection/addCollectionPlugin.ts index 07877aa2..84b900c1 100644 --- a/clients/js/src/instructions/collection/addCollectionPlugin.ts +++ b/clients/js/src/instructions/collection/addCollectionPlugin.ts @@ -1,15 +1,15 @@ import { Context } from '@metaplex-foundation/umi'; import { - addCollectionExternalPluginV1, + addCollectionExternalPluginAdapterV1, addCollectionPluginV1, } from '../../generated'; import { AddablePluginArgsV2, pluginAuthorityPairV2 } from '../../plugins'; import { - createExternalPluginInitInfo, - ExternalPluginInitInfoArgs, - isExternalPluginType, -} from '../../plugins/externalPlugins'; + createExternalPluginAdapterInitInfo, + ExternalPluginAdapterInitInfoArgs, + isExternalPluginAdapterType, +} from '../../plugins/externalPluginAdapters'; export type AddCollectionPluginArgs = Omit< Parameters[1], @@ -17,18 +17,18 @@ export type AddCollectionPluginArgs = Omit< > & { plugin: | Exclude - | ExternalPluginInitInfoArgs; + | ExternalPluginAdapterInitInfoArgs; }; export const addCollectionPlugin = ( context: Pick, { plugin, ...args }: AddCollectionPluginArgs ) => { - if (isExternalPluginType(plugin)) { - return addCollectionExternalPluginV1(context, { + if (isExternalPluginAdapterType(plugin)) { + return addCollectionExternalPluginAdapterV1(context, { ...args, - initInfo: createExternalPluginInitInfo( - plugin as ExternalPluginInitInfoArgs + initInfo: createExternalPluginAdapterInitInfo( + plugin as ExternalPluginAdapterInitInfoArgs ), }); } diff --git a/clients/js/src/instructions/collection/approveCollectionPluginAuthority.ts b/clients/js/src/instructions/collection/approveCollectionPluginAuthority.ts index 01d47bf8..848cb374 100644 --- a/clients/js/src/instructions/collection/approveCollectionPluginAuthority.ts +++ b/clients/js/src/instructions/collection/approveCollectionPluginAuthority.ts @@ -3,40 +3,24 @@ import { approveCollectionPluginAuthorityV1, PluginType, } from '../../generated'; -import { - isExternalPluginType, - PluginAuthority, - pluginAuthorityToBase, -} from '../../plugins'; -import { ExternalPluginKey } from '../../plugins/externalPluginKey'; +import { PluginAuthority, pluginAuthorityToBase } from '../../plugins'; export type ApproveCollectionPluginAuthorityArgs = Omit< Parameters[1], 'pluginType' | 'newAuthority' > & { - plugin: - | { - type: keyof typeof PluginType; - } - | ExternalPluginKey; + plugin: { + type: keyof typeof PluginType; + }; newAuthority: PluginAuthority; }; export const approveCollectionPluginAuthority = ( context: Pick, { plugin, newAuthority, ...args }: ApproveCollectionPluginAuthorityArgs -) => { - if (isExternalPluginType(plugin)) { - // TODO implement this - // return approveCollectionExternalPluginAuthorityV1(context, { - // ...args, - // key: externalPluginKeyToBase(plugin as ExternalPluginKey), - // }); - } - - return approveCollectionPluginAuthorityV1(context, { +) => + approveCollectionPluginAuthorityV1(context, { ...args, pluginType: PluginType[plugin.type as keyof typeof PluginType], newAuthority: pluginAuthorityToBase(newAuthority), }); -}; diff --git a/clients/js/src/instructions/collection/createCollection.ts b/clients/js/src/instructions/collection/createCollection.ts index 6528f190..62045bc7 100644 --- a/clients/js/src/instructions/collection/createCollection.ts +++ b/clients/js/src/instructions/collection/createCollection.ts @@ -2,20 +2,20 @@ import { Context } from '@metaplex-foundation/umi'; import { createCollectionV2 } from '../../generated'; import { PluginAuthorityPairArgsV2, - createExternalPluginInitInfo, + createExternalPluginAdapterInitInfo, pluginAuthorityPairV2, } from '../../plugins'; import { - ExternalPluginInitInfoArgs, - isExternalPluginType, -} from '../../plugins/externalPlugins'; + ExternalPluginAdapterInitInfoArgs, + isExternalPluginAdapterType, +} from '../../plugins/externalPluginAdapters'; export type CreateCollectionArgs = Omit< Parameters[1], - 'plugins' | 'externalPlugins' + 'plugins' | 'externalPluginAdapters' > & { - plugins?: (PluginAuthorityPairArgsV2 | ExternalPluginInitInfoArgs)[]; + plugins?: (PluginAuthorityPairArgsV2 | ExternalPluginAdapterInitInfoArgs)[]; }; export const createCollection = ( @@ -23,11 +23,11 @@ export const createCollection = ( { plugins, ...args }: CreateCollectionArgs ) => { const firstPartyPlugins: PluginAuthorityPairArgsV2[] = []; - const externalPlugins: ExternalPluginInitInfoArgs[] = []; + const externalPluginAdapters: ExternalPluginAdapterInitInfoArgs[] = []; plugins?.forEach((plugin) => { - if (isExternalPluginType(plugin)) { - externalPlugins.push(plugin as ExternalPluginInitInfoArgs); + if (isExternalPluginAdapterType(plugin)) { + externalPluginAdapters.push(plugin as ExternalPluginAdapterInitInfoArgs); } else { firstPartyPlugins.push(plugin as PluginAuthorityPairArgsV2); } @@ -36,6 +36,8 @@ export const createCollection = ( return createCollectionV2(context, { ...args, plugins: firstPartyPlugins.map(pluginAuthorityPairV2), - externalPlugins: externalPlugins.map(createExternalPluginInitInfo), + externalPluginAdapters: externalPluginAdapters.map( + createExternalPluginAdapterInitInfo + ), }); }; diff --git a/clients/js/src/instructions/collection/removeCollectionPlugin.ts b/clients/js/src/instructions/collection/removeCollectionPlugin.ts index e7ba28d1..c8325ce7 100644 --- a/clients/js/src/instructions/collection/removeCollectionPlugin.ts +++ b/clients/js/src/instructions/collection/removeCollectionPlugin.ts @@ -1,12 +1,15 @@ import { Context } from '@metaplex-foundation/umi'; import { PluginType, - removeCollectionExternalPluginV1, + removeCollectionExternalPluginAdapterV1, removeCollectionPluginV1, } from '../../generated'; -import { ExternalPluginKey, externalPluginKeyToBase } from '../../plugins'; +import { + ExternalPluginAdapterKey, + externalPluginAdapterKeyToBase, +} from '../../plugins'; -import { isExternalPluginType } from '../../plugins/externalPlugins'; +import { isExternalPluginAdapterType } from '../../plugins/externalPluginAdapters'; export type RemoveCollectionPluginArgs = Omit< Parameters[1], @@ -16,17 +19,17 @@ export type RemoveCollectionPluginArgs = Omit< | { type: Exclude; } - | ExternalPluginKey; + | ExternalPluginAdapterKey; }; export const removeCollectionPlugin = ( context: Pick, { plugin, ...args }: RemoveCollectionPluginArgs ) => { - if (isExternalPluginType(plugin)) { - return removeCollectionExternalPluginV1(context, { + if (isExternalPluginAdapterType(plugin)) { + return removeCollectionExternalPluginAdapterV1(context, { ...args, - key: externalPluginKeyToBase(plugin as ExternalPluginKey), + key: externalPluginAdapterKeyToBase(plugin as ExternalPluginAdapterKey), }); } diff --git a/clients/js/src/instructions/collection/revokeCollectionPluginAuthority.ts b/clients/js/src/instructions/collection/revokeCollectionPluginAuthority.ts index f732eb71..fd3183d5 100644 --- a/clients/js/src/instructions/collection/revokeCollectionPluginAuthority.ts +++ b/clients/js/src/instructions/collection/revokeCollectionPluginAuthority.ts @@ -1,33 +1,20 @@ import { Context } from '@metaplex-foundation/umi'; import { revokeCollectionPluginAuthorityV1, PluginType } from '../../generated'; -import { isExternalPluginType } from '../../plugins'; -import { ExternalPluginKey } from '../../plugins/externalPluginKey'; export type RevokeCollectionPluginAuthorityArgs = Omit< Parameters[1], 'pluginType' > & { - plugin: - | { - type: keyof typeof PluginType; - } - | ExternalPluginKey; + plugin: { + type: keyof typeof PluginType; + }; }; export const revokeCollectionPluginAuthority = ( context: Pick, { plugin, ...args }: RevokeCollectionPluginAuthorityArgs -) => { - if (isExternalPluginType(plugin)) { - // TODO implement this - // return revokeCollectionExternalPluginAuthorityV1(context, { - // ...args, - // key: externalPluginKeyToBase(plugin as ExternalPluginKey), - // }); - } - - return revokeCollectionPluginAuthorityV1(context, { +) => + revokeCollectionPluginAuthorityV1(context, { ...args, pluginType: PluginType[plugin.type as keyof typeof PluginType], }); -}; diff --git a/clients/js/src/instructions/collection/updateCollectionPlugin.ts b/clients/js/src/instructions/collection/updateCollectionPlugin.ts index 848838f5..cf1fced5 100644 --- a/clients/js/src/instructions/collection/updateCollectionPlugin.ts +++ b/clients/js/src/instructions/collection/updateCollectionPlugin.ts @@ -1,34 +1,34 @@ import { Context } from '@metaplex-foundation/umi'; import { updateCollectionPluginV1, - updateCollectionExternalPluginV1, + updateCollectionExternalPluginAdapterV1, } from '../../generated'; import { - createExternalPluginUpdateInfo, + createExternalPluginAdapterUpdateInfo, PluginArgsV2, createPluginV2, - externalPluginKeyToBase, - isExternalPluginType, + externalPluginAdapterKeyToBase, + isExternalPluginAdapterType, } from '../../plugins'; -import { ExternalPluginUpdateInfoArgs } from '../../plugins/externalPlugins'; +import { ExternalPluginAdapterUpdateInfoArgs } from '../../plugins/externalPluginAdapters'; export type UpdateCollectionPluginArgs = Omit< Parameters[1], 'plugin' > & { - plugin: PluginArgsV2 | ExternalPluginUpdateInfoArgs; + plugin: PluginArgsV2 | ExternalPluginAdapterUpdateInfoArgs; }; export const updateCollectionPlugin = ( context: Pick, { plugin, ...args }: UpdateCollectionPluginArgs ) => { - if (isExternalPluginType(plugin)) { - const plug = plugin as ExternalPluginUpdateInfoArgs; - return updateCollectionExternalPluginV1(context, { + if (isExternalPluginAdapterType(plugin)) { + const plug = plugin as ExternalPluginAdapterUpdateInfoArgs; + return updateCollectionExternalPluginAdapterV1(context, { ...args, - updateInfo: createExternalPluginUpdateInfo(plug), - key: externalPluginKeyToBase(plug.key), + updateInfo: createExternalPluginAdapterUpdateInfo(plug), + key: externalPluginAdapterKeyToBase(plug.key), }); } diff --git a/clients/js/src/instructions/create.ts b/clients/js/src/instructions/create.ts index 6390d268..b811e128 100644 --- a/clients/js/src/instructions/create.ts +++ b/clients/js/src/instructions/create.ts @@ -1,25 +1,29 @@ import { Context, publicKey } from '@metaplex-foundation/umi'; -import { CollectionV1, createV2, ExternalPluginSchema } from '../generated'; import { - createExternalPluginInitInfo, + CollectionV1, + createV2, + ExternalPluginAdapterSchema, +} from '../generated'; +import { + createExternalPluginAdapterInitInfo, findExtraAccounts, PluginAuthorityPairArgsV2, pluginAuthorityPairV2, } from '../plugins'; -import { deriveExternalPlugins } from '../helpers'; +import { deriveExternalPluginAdapters } from '../helpers'; import { - ExternalPluginInitInfoArgs, - ExternalPluginsList, - isExternalPluginType, -} from '../plugins/externalPlugins'; + ExternalPluginAdapterInitInfoArgs, + ExternalPluginAdaptersList, + isExternalPluginAdapterType, +} from '../plugins/externalPluginAdapters'; export type CreateArgsPlugin = | PluginAuthorityPairArgsV2 - | ExternalPluginInitInfoArgs; + | ExternalPluginAdapterInitInfoArgs; export type CreateArgs = Omit< Parameters[1], - 'plugins' | 'externalPlugins' | 'collection' + 'plugins' | 'externalPluginAdapters' | 'collection' > & { collection?: Pick; plugins?: CreateArgsPlugin[]; @@ -31,21 +35,21 @@ export const create = ( ) => { const owner = args.owner || args.updateAuthority || args.payer; - const assetExternalPlugins: ExternalPluginsList = { + const assetExternalPluginAdapters: ExternalPluginAdaptersList = { oracles: [], lifecycleHooks: [], }; - const externalPlugins: ExternalPluginInitInfoArgs[] = []; + const externalPluginAdapters: ExternalPluginAdapterInitInfoArgs[] = []; const firstPartyPlugins: PluginAuthorityPairArgsV2[] = []; - // Create dummy external plugins to resuse findExtraAccounts method + // Create dummy external plugin adapters to resuse findExtraAccounts method plugins?.forEach((plugin) => { - if (isExternalPluginType(plugin)) { - externalPlugins.push(plugin as ExternalPluginInitInfoArgs); + if (isExternalPluginAdapterType(plugin)) { + externalPluginAdapters.push(plugin as ExternalPluginAdapterInitInfoArgs); switch (plugin.type) { case 'Oracle': - assetExternalPlugins.oracles?.push({ + assetExternalPluginAdapters.oracles?.push({ ...plugin, resultsOffset: plugin.resultsOffset || { type: 'NoOffset' }, baseAddress: plugin.baseAddress, @@ -59,14 +63,14 @@ export const create = ( // Do nothing, datastore has no extra accounts break; case 'LifecycleHook': - assetExternalPlugins.lifecycleHooks?.push({ + assetExternalPluginAdapters.lifecycleHooks?.push({ ...plugin, hookedProgram: plugin.hookedProgram, authority: plugin.initPluginAuthority || { type: 'UpdateAuthority', }, type: 'LifecycleHook', - schema: plugin.schema || ExternalPluginSchema.Binary, + schema: plugin.schema || ExternalPluginAdapterSchema.Binary, }); break; default: @@ -77,14 +81,14 @@ export const create = ( } }); - const derivedExternalPlugins = deriveExternalPlugins( - assetExternalPlugins, + const derivedExternalPluginAdapters = deriveExternalPluginAdapters( + assetExternalPluginAdapters, collection ); const extraAccounts = findExtraAccounts( context, 'create', - derivedExternalPlugins, + derivedExternalPluginAdapters, { asset: asset.publicKey, collection: collection ? collection.publicKey : undefined, @@ -96,7 +100,9 @@ export const create = ( return createV2(context, { ...args, plugins: firstPartyPlugins.map(pluginAuthorityPairV2), - externalPlugins: externalPlugins.map(createExternalPluginInitInfo), + externalPluginAdapters: externalPluginAdapters.map( + createExternalPluginAdapterInitInfo + ), asset, collection: collection ? collection.publicKey : undefined, }).addRemainingAccounts(extraAccounts); diff --git a/clients/js/src/instructions/removePlugin.ts b/clients/js/src/instructions/removePlugin.ts index f29391b6..0c2dad0c 100644 --- a/clients/js/src/instructions/removePlugin.ts +++ b/clients/js/src/instructions/removePlugin.ts @@ -1,20 +1,20 @@ import { Context } from '@metaplex-foundation/umi'; import { removePluginV1, - removeExternalPluginV1, + removeExternalPluginAdapterV1, PluginType, } from '../generated'; -import { isExternalPluginType } from '../plugins'; +import { isExternalPluginAdapterType } from '../plugins'; import { - ExternalPluginKey, - externalPluginKeyToBase, -} from '../plugins/externalPluginKey'; + ExternalPluginAdapterKey, + externalPluginAdapterKeyToBase, +} from '../plugins/externalPluginAdapterKey'; export type RemovePluginArgsPlugin = | { type: Exclude; } - | ExternalPluginKey; + | ExternalPluginAdapterKey; export type RemovePluginArgs = Omit< Parameters[1], @@ -27,10 +27,10 @@ export const removePlugin = ( context: Pick, { plugin, ...args }: RemovePluginArgs ) => { - if (isExternalPluginType(plugin)) { - return removeExternalPluginV1(context, { + if (isExternalPluginAdapterType(plugin)) { + return removeExternalPluginAdapterV1(context, { ...args, - key: externalPluginKeyToBase(plugin as ExternalPluginKey), + key: externalPluginAdapterKeyToBase(plugin as ExternalPluginAdapterKey), }); } diff --git a/clients/js/src/instructions/transfer.ts b/clients/js/src/instructions/transfer.ts index 0b86c072..49200b7a 100644 --- a/clients/js/src/instructions/transfer.ts +++ b/clients/js/src/instructions/transfer.ts @@ -1,7 +1,7 @@ import { Context, publicKey } from '@metaplex-foundation/umi'; import { CollectionV1, transferV1, AssetV1 } from '../generated'; import { findExtraAccounts } from '../plugins'; -import { deriveExternalPlugins } from '../helpers'; +import { deriveExternalPluginAdapters } from '../helpers'; export type TransferArgs = Omit< Parameters[1], @@ -15,12 +15,15 @@ export const transfer = ( context: Pick, { asset, collection, ...args }: TransferArgs ) => { - const derivedExternalPlugins = deriveExternalPlugins(asset, collection); + const derivedExternalPluginAdapters = deriveExternalPluginAdapters( + asset, + collection + ); const extraAccounts = findExtraAccounts( context, 'transfer', - derivedExternalPlugins, + derivedExternalPluginAdapters, { asset: asset.publicKey, collection: collection?.publicKey, diff --git a/clients/js/src/instructions/update.ts b/clients/js/src/instructions/update.ts index b635a1b9..f67d7c8b 100644 --- a/clients/js/src/instructions/update.ts +++ b/clients/js/src/instructions/update.ts @@ -6,7 +6,7 @@ import { UpdateV1InstructionDataArgs, } from '../generated'; import { findExtraAccounts } from '../plugins'; -import { deriveExternalPlugins } from '../helpers'; +import { deriveExternalPluginAdapters } from '../helpers'; export type UpdateArgs = Omit< Parameters[1], @@ -22,12 +22,15 @@ export const update = ( context: Pick, { asset, collection, name, uri, ...args }: UpdateArgs ) => { - const derivedExternalPlugins = deriveExternalPlugins(asset, collection); + const derivedExternalPluginAdapters = deriveExternalPluginAdapters( + asset, + collection + ); const extraAccounts = findExtraAccounts( context, 'update', - derivedExternalPlugins, + derivedExternalPluginAdapters, { asset: asset.publicKey, collection: collection?.publicKey, diff --git a/clients/js/src/instructions/updatePlugin.ts b/clients/js/src/instructions/updatePlugin.ts index 34529f49..2e8f916b 100644 --- a/clients/js/src/instructions/updatePlugin.ts +++ b/clients/js/src/instructions/updatePlugin.ts @@ -1,17 +1,17 @@ import { Context } from '@metaplex-foundation/umi'; -import { updatePluginV1, updateExternalPluginV1 } from '../generated'; +import { updatePluginV1, updateExternalPluginAdapterV1 } from '../generated'; import { - createExternalPluginUpdateInfo, + createExternalPluginAdapterUpdateInfo, createPluginV2, - externalPluginKeyToBase, - isExternalPluginType, + externalPluginAdapterKeyToBase, + isExternalPluginAdapterType, PluginArgsV2, } from '../plugins'; -import { ExternalPluginUpdateInfoArgs } from '../plugins/externalPlugins'; +import { ExternalPluginAdapterUpdateInfoArgs } from '../plugins/externalPluginAdapters'; export type UpdatePluginArgsPlugin = | PluginArgsV2 - | ExternalPluginUpdateInfoArgs; + | ExternalPluginAdapterUpdateInfoArgs; export type UpdatePluginArgs = Omit< Parameters[1], @@ -24,12 +24,12 @@ export const updatePlugin = ( context: Pick, { plugin, ...args }: UpdatePluginArgs ) => { - if (isExternalPluginType(plugin)) { - const plug = plugin as ExternalPluginUpdateInfoArgs; - return updateExternalPluginV1(context, { + if (isExternalPluginAdapterType(plugin)) { + const plug = plugin as ExternalPluginAdapterUpdateInfoArgs; + return updateExternalPluginAdapterV1(context, { ...args, - updateInfo: createExternalPluginUpdateInfo(plug), - key: externalPluginKeyToBase(plug.key), + updateInfo: createExternalPluginAdapterUpdateInfo(plug), + key: externalPluginAdapterKeyToBase(plug.key), }); } diff --git a/clients/js/src/plugins/dataStore.ts b/clients/js/src/plugins/dataStore.ts index 31faff45..04aa1ca0 100644 --- a/clients/js/src/plugins/dataStore.ts +++ b/clients/js/src/plugins/dataStore.ts @@ -2,13 +2,13 @@ import { BaseDataStore, BaseDataStoreInitInfoArgs, BaseDataStoreUpdateInfoArgs, - ExternalPluginSchema, + ExternalPluginAdapterSchema, ExternalRegistryRecord, } from '../generated'; -import { ExternalPluginKey } from './externalPluginKey'; -import { ExternalPluginManifest } from './externalPluginManifest'; -import { BaseExternalPlugin } from './externalPlugins'; -import { parseExternalPluginData } from './lib'; +import { ExternalPluginAdapterKey } from './externalPluginAdapterKey'; +import { ExternalPluginAdapterManifest } from './externalPluginAdapterManifest'; +import { BaseExternalPluginAdapter } from './externalPluginAdapters'; +import { parseExternalPluginAdapterData } from './lib'; import { LifecycleChecks } from './lifecycleChecks'; import { PluginAuthority, @@ -21,7 +21,7 @@ export type DataStore = Omit & { data?: any; }; -export type DataStorePlugin = BaseExternalPlugin & +export type DataStorePlugin = BaseExternalPluginAdapter & DataStore & { type: 'DataStore'; dataAuthority: PluginAuthority; @@ -34,7 +34,7 @@ export type DataStoreInitInfoArgs = Omit< type: 'DataStore'; initPluginAuthority?: PluginAuthority; lifecycleChecks?: LifecycleChecks; - schema?: ExternalPluginSchema; + schema?: ExternalPluginAdapterSchema; dataAuthority: PluginAuthority; }; @@ -42,8 +42,8 @@ export type DataStoreUpdateInfoArgs = Omit< BaseDataStoreUpdateInfoArgs, 'schema' > & { - key: ExternalPluginKey; - schema?: ExternalPluginSchema; + key: ExternalPluginAdapterKey; + schema?: ExternalPluginAdapterSchema; }; export function dataStoreInitInfoArgsToBase( @@ -74,11 +74,11 @@ export function dataStoreFromBase( return { ...s, dataAuthority: pluginAuthorityFromBase(s.dataAuthority), - data: parseExternalPluginData(s, r, account), + data: parseExternalPluginAdapterData(s, r, account), }; } -export const dataStoreManifest: ExternalPluginManifest< +export const dataStoreManifest: ExternalPluginAdapterManifest< DataStore, BaseDataStore, DataStoreInitInfoArgs, diff --git a/clients/js/src/plugins/externalPluginKey.ts b/clients/js/src/plugins/externalPluginAdapterKey.ts similarity index 75% rename from clients/js/src/plugins/externalPluginKey.ts rename to clients/js/src/plugins/externalPluginAdapterKey.ts index dba3448a..e86610b0 100644 --- a/clients/js/src/plugins/externalPluginKey.ts +++ b/clients/js/src/plugins/externalPluginAdapterKey.ts @@ -1,8 +1,8 @@ import { PublicKey } from '@metaplex-foundation/umi'; -import { BaseExternalPluginKey } from '../generated'; +import { BaseExternalPluginAdapterKey } from '../generated'; import { PluginAuthority, pluginAuthorityToBase } from './pluginAuthority'; -export type ExternalPluginKey = +export type ExternalPluginAdapterKey = | { type: 'Oracle'; baseAddress: PublicKey; @@ -16,9 +16,9 @@ export type ExternalPluginKey = hookedProgram: PublicKey; }; -export function externalPluginKeyToBase( - e: ExternalPluginKey -): BaseExternalPluginKey { +export function externalPluginAdapterKeyToBase( + e: ExternalPluginAdapterKey +): BaseExternalPluginAdapterKey { if (e.type === 'Oracle') { return { __kind: 'Oracle', diff --git a/clients/js/src/plugins/externalPluginManifest.ts b/clients/js/src/plugins/externalPluginAdapterManifest.ts similarity index 71% rename from clients/js/src/plugins/externalPluginManifest.ts rename to clients/js/src/plugins/externalPluginAdapterManifest.ts index e323116b..b7704965 100644 --- a/clients/js/src/plugins/externalPluginManifest.ts +++ b/clients/js/src/plugins/externalPluginAdapterManifest.ts @@ -1,7 +1,7 @@ import { ExternalRegistryRecord } from 'src/generated'; -import { ExternalPluginTypeString } from './externalPlugins'; +import { ExternalPluginAdapterTypeString } from './externalPluginAdapters'; -export type ExternalPluginManifest< +export type ExternalPluginAdapterManifest< T extends Object, Base extends Object, Init extends Object, @@ -9,7 +9,7 @@ export type ExternalPluginManifest< Update extends Object, UpdateBase extends Object, > = { - type: ExternalPluginTypeString; + type: ExternalPluginAdapterTypeString; fromBase: ( input: Base, record: ExternalRegistryRecord, diff --git a/clients/js/src/plugins/externalPlugins.ts b/clients/js/src/plugins/externalPluginAdapters.ts similarity index 72% rename from clients/js/src/plugins/externalPlugins.ts rename to clients/js/src/plugins/externalPluginAdapters.ts index 3e83eff1..d5dcaef0 100644 --- a/clients/js/src/plugins/externalPlugins.ts +++ b/clients/js/src/plugins/externalPluginAdapters.ts @@ -8,11 +8,11 @@ import { pluginAuthorityFromBase, } from '.'; import { - BaseExternalPluginInitInfoArgs, - BaseExternalPluginKey, - BaseExternalPluginUpdateInfoArgs, + BaseExternalPluginAdapterInitInfoArgs, + BaseExternalPluginAdapterKey, + BaseExternalPluginAdapterUpdateInfoArgs, ExternalRegistryRecord, - getExternalPluginSerializer, + getExternalPluginAdapterSerializer, } from '../generated'; import { @@ -37,17 +37,18 @@ import { import { BasePlugin } from './types'; import { extraAccountToAccountMeta } from './extraAccount'; -export type ExternalPluginTypeString = BaseExternalPluginKey['__kind']; +export type ExternalPluginAdapterTypeString = + BaseExternalPluginAdapterKey['__kind']; -export type BaseExternalPlugin = BasePlugin & LifecycleChecksContainer; +export type BaseExternalPluginAdapter = BasePlugin & LifecycleChecksContainer; -export type ExternalPluginsList = { +export type ExternalPluginAdaptersList = { oracles?: OraclePlugin[]; dataStores?: DataStorePlugin[]; lifecycleHooks?: LifecycleHookPlugin[]; }; -export type ExternalPluginInitInfoArgs = +export type ExternalPluginAdapterInitInfoArgs = | ({ type: 'Oracle'; } & OracleInitInfoArgs) @@ -58,7 +59,7 @@ export type ExternalPluginInitInfoArgs = type: 'DataStore'; } & DataStoreInitInfoArgs); -export type ExternalPluginUpdateInfoArgs = +export type ExternalPluginAdapterUpdateInfoArgs = | ({ type: 'Oracle'; } & OracleUpdateInfoArgs) @@ -69,30 +70,30 @@ export type ExternalPluginUpdateInfoArgs = type: 'DataStore'; } & DataStoreUpdateInfoArgs); -export const externalPluginManifests = { +export const externalPluginAdapterManifests = { Oracle: oracleManifest, DataStore: dataStoreManifest, LifecycleHook: lifecycleHookManifest, }; -export type ExternalPluginData = { +export type ExternalPluginAdapterData = { dataLen: bigint; dataOffset: bigint; }; -export function externalRegistryRecordsToExternalPluginList( +export function externalRegistryRecordsToExternalPluginAdapterList( records: ExternalRegistryRecord[], accountData: Uint8Array -): ExternalPluginsList { - const result: ExternalPluginsList = {}; +): ExternalPluginAdaptersList { + const result: ExternalPluginAdaptersList = {}; records.forEach((record) => { - const deserializedPlugin = getExternalPluginSerializer().deserialize( + const deserializedPlugin = getExternalPluginAdapterSerializer().deserialize( accountData, Number(record.offset) )[0]; - const mappedPlugin: BaseExternalPlugin = { + const mappedPlugin: BaseExternalPluginAdapter = { lifecycleChecks: record.lifecycleChecks.__option === 'Some' ? lifecycleChecksFromBase(record.lifecycleChecks.value) @@ -139,7 +140,7 @@ export function externalRegistryRecordsToExternalPluginList( return result; } -export const isExternalPluginType = (plugin: { type: string }) => { +export const isExternalPluginAdapterType = (plugin: { type: string }) => { if ( plugin.type === 'Oracle' || plugin.type === 'LifecycleHook' || @@ -150,22 +151,22 @@ export const isExternalPluginType = (plugin: { type: string }) => { return false; }; -export function createExternalPluginInitInfo({ +export function createExternalPluginAdapterInitInfo({ type, ...args -}: ExternalPluginInitInfoArgs): BaseExternalPluginInitInfoArgs { - const manifest = externalPluginManifests[type]; +}: ExternalPluginAdapterInitInfoArgs): BaseExternalPluginAdapterInitInfoArgs { + const manifest = externalPluginAdapterManifests[type]; return { __kind: type, fields: [manifest.initToBase(args as any)] as any, }; } -export function createExternalPluginUpdateInfo({ +export function createExternalPluginAdapterUpdateInfo({ type, ...args -}: ExternalPluginUpdateInfoArgs): BaseExternalPluginUpdateInfoArgs { - const manifest = externalPluginManifests[type]; +}: ExternalPluginAdapterUpdateInfoArgs): BaseExternalPluginAdapterUpdateInfoArgs { + const manifest = externalPluginAdapterManifests[type]; return { __kind: type, fields: [manifest.updateToBase(args as any)] as any, @@ -175,7 +176,7 @@ export function createExternalPluginUpdateInfo({ export const findExtraAccounts = ( context: Pick, lifecycle: LifecycleEvent, - externalPlugins: ExternalPluginsList, + externalPluginAdapters: ExternalPluginAdaptersList, inputs: { asset: PublicKey; collection?: PublicKey; @@ -185,11 +186,11 @@ export const findExtraAccounts = ( ): AccountMeta[] => { const accounts: AccountMeta[] = []; - externalPlugins.oracles?.forEach((oracle) => { + externalPluginAdapters.oracles?.forEach((oracle) => { if (oracle.lifecycleChecks?.[lifecycle]) { - if (oracle.pda) { + if (oracle.baseAddressConfig) { accounts.push( - extraAccountToAccountMeta(context, oracle.pda, { + extraAccountToAccountMeta(context, oracle.baseAddressConfig, { ...inputs, program: oracle.baseAddress, }) @@ -204,7 +205,7 @@ export const findExtraAccounts = ( } }); - externalPlugins.lifecycleHooks?.forEach((hook) => { + externalPluginAdapters.lifecycleHooks?.forEach((hook) => { if (hook.lifecycleChecks?.[lifecycle]) { accounts.push({ pubkey: hook.hookedProgram, diff --git a/clients/js/src/plugins/index.ts b/clients/js/src/plugins/index.ts index ba8a63ad..61fab882 100644 --- a/clients/js/src/plugins/index.ts +++ b/clients/js/src/plugins/index.ts @@ -4,11 +4,11 @@ export * from './dataStore'; export * from './lifecycleChecks'; export * from './lifecycleHook'; export * from './oracle'; -export * from './externalPluginKey'; -export * from './externalPluginManifest'; +export * from './externalPluginAdapterKey'; +export * from './externalPluginAdapterManifest'; export * from './pluginAuthority'; export * from './types'; -export * from './externalPlugins'; +export * from './externalPluginAdapters'; export * from './updateAuthority'; export * from './seed'; export * from './extraAccount'; diff --git a/clients/js/src/plugins/lib.ts b/clients/js/src/plugins/lib.ts index 67dc4a45..5e9ab484 100644 --- a/clients/js/src/plugins/lib.ts +++ b/clients/js/src/plugins/lib.ts @@ -8,7 +8,7 @@ import { RegistryRecord, PluginAuthorityPair, PluginType, - ExternalPluginSchema, + ExternalPluginAdapterSchema, } from '../generated'; import { toWords } from '../utils'; @@ -188,9 +188,9 @@ export function pluginKeyToPluginType(pluginKey: keyof PluginsList) { pluginKey.slice(1)) as keyof typeof PluginType; } -export function parseExternalPluginData( +export function parseExternalPluginAdapterData( plugin: { - schema: ExternalPluginSchema; + schema: ExternalPluginAdapterSchema; }, record: { dataLen: Option; @@ -204,11 +204,11 @@ export function parseExternalPluginData( Number(record.dataOffset) + Number(record.dataLen) ); - if (plugin.schema === ExternalPluginSchema.Binary) { + if (plugin.schema === ExternalPluginAdapterSchema.Binary) { data = dataSlice; - } else if (plugin.schema === ExternalPluginSchema.Json) { + } else if (plugin.schema === ExternalPluginAdapterSchema.Json) { data = JSON.parse(new TextDecoder().decode(dataSlice)); - } else if (plugin.schema === ExternalPluginSchema.MsgPack) { + } else if (plugin.schema === ExternalPluginAdapterSchema.MsgPack) { // eslint-disable-next-line no-console console.warn( 'MsgPack schema currently not supported, falling back to binary' diff --git a/clients/js/src/plugins/lifecycleChecks.ts b/clients/js/src/plugins/lifecycleChecks.ts index 6aedfaf8..7539a6c7 100644 --- a/clients/js/src/plugins/lifecycleChecks.ts +++ b/clients/js/src/plugins/lifecycleChecks.ts @@ -4,14 +4,14 @@ import { capitalizeFirstLetter } from '../utils'; export type LifecycleEvent = 'create' | 'update' | 'transfer' | 'burn'; -// ExternalCheckResult is a bit array +// ExternalCheckResult is a bit array export enum CheckResult { CAN_LISTEN, CAN_APPROVE, CAN_REJECT, } -export const externalCheckResultToCheckResults = ( +export const adapterCheckResultToCheckResults = ( check: ExternalCheckResult ): CheckResult[] => { const results: CheckResult[] = []; @@ -27,7 +27,7 @@ export const externalCheckResultToCheckResults = ( return results; }; -export const checkResultsToExternalCheckResult = ( +export const checkResultsToAdapterCheckResult = ( results: CheckResult[] ): ExternalCheckResult => { let flags = 0; @@ -78,7 +78,7 @@ export function lifecycleChecksToBase( if (value) { return [ lifecycleCheckKeyToEnum(k), - checkResultsToExternalCheckResult(value), + checkResultsToAdapterCheckResult(value), ]; } return null; @@ -95,7 +95,7 @@ export function lifecycleChecksFromBase( const checks: LifecycleChecks = {}; l.forEach(([event, check]) => { checks[hookableLifecycleEventToLifecycleCheckKey(event)] = - externalCheckResultToCheckResults(check); + adapterCheckResultToCheckResults(check); }); return checks; } diff --git a/clients/js/src/plugins/lifecycleHook.ts b/clients/js/src/plugins/lifecycleHook.ts index 7cd8ad99..f3de62c1 100644 --- a/clients/js/src/plugins/lifecycleHook.ts +++ b/clients/js/src/plugins/lifecycleHook.ts @@ -8,7 +8,7 @@ import { BaseLifecycleHook, BaseLifecycleHookInitInfoArgs, BaseLifecycleHookUpdateInfoArgs, - ExternalPluginSchema, + ExternalPluginAdapterSchema, ExternalRegistryRecord, } from '../generated'; import { LifecycleChecks, lifecycleChecksToBase } from './lifecycleChecks'; @@ -17,10 +17,10 @@ import { pluginAuthorityFromBase, pluginAuthorityToBase, } from './pluginAuthority'; -import { BaseExternalPlugin } from './externalPlugins'; -import { ExternalPluginManifest } from './externalPluginManifest'; -import { ExternalPluginKey } from './externalPluginKey'; -import { parseExternalPluginData } from './lib'; +import { BaseExternalPluginAdapter } from './externalPluginAdapters'; +import { ExternalPluginAdapterManifest } from './externalPluginAdapterManifest'; +import { ExternalPluginAdapterKey } from './externalPluginAdapterKey'; +import { parseExternalPluginAdapterData } from './lib'; export type LifecycleHook = Omit< BaseLifecycleHook, @@ -31,7 +31,7 @@ export type LifecycleHook = Omit< data?: any; }; -export type LifecycleHookPlugin = BaseExternalPlugin & +export type LifecycleHookPlugin = BaseExternalPluginAdapter & LifecycleHook & { type: 'LifecycleHook'; hookedProgram: PublicKey; @@ -48,7 +48,7 @@ export type LifecycleHookInitInfoArgs = Omit< type: 'LifecycleHook'; initPluginAuthority?: PluginAuthority; lifecycleChecks: LifecycleChecks; - schema?: ExternalPluginSchema; + schema?: ExternalPluginAdapterSchema; extraAccounts?: Array; dataAuthority?: PluginAuthority; }; @@ -57,10 +57,10 @@ export type LifecycleHookUpdateInfoArgs = Omit< BaseLifecycleHookUpdateInfoArgs, 'lifecycleChecks' | 'extraAccounts' | 'schema' > & { - key: ExternalPluginKey; + key: ExternalPluginAdapterKey; lifecycleChecks?: LifecycleChecks; extraAccounts?: Array; - schema?: ExternalPluginSchema; + schema?: ExternalPluginAdapterSchema; }; export function lifecycleHookInitInfoArgsToBase( @@ -108,7 +108,7 @@ export function lifecycleHookFromBase( s.extraAccounts.__option === 'Some' ? s.extraAccounts.value.map(extraAccountFromBase) : undefined, - data: parseExternalPluginData(s, r, account), + data: parseExternalPluginAdapterData(s, r, account), dataAuthority: s.dataAuthority.__option === 'Some' ? pluginAuthorityFromBase(s.dataAuthority.value) @@ -116,7 +116,7 @@ export function lifecycleHookFromBase( }; } -export const lifecycleHookManifest: ExternalPluginManifest< +export const lifecycleHookManifest: ExternalPluginAdapterManifest< LifecycleHook, BaseLifecycleHook, LifecycleHookInitInfoArgs, diff --git a/clients/js/src/plugins/oracle.ts b/clients/js/src/plugins/oracle.ts index 67c8d1a4..712d5635 100644 --- a/clients/js/src/plugins/oracle.ts +++ b/clients/js/src/plugins/oracle.ts @@ -15,43 +15,46 @@ import { } from '../generated'; import { LifecycleChecks, lifecycleChecksToBase } from './lifecycleChecks'; import { PluginAuthority, pluginAuthorityToBase } from './pluginAuthority'; -import { ExternalPluginManifest } from './externalPluginManifest'; -import { BaseExternalPlugin } from './externalPlugins'; -import { ExternalPluginKey } from './externalPluginKey'; +import { ExternalPluginAdapterManifest } from './externalPluginAdapterManifest'; +import { BaseExternalPluginAdapter } from './externalPluginAdapters'; +import { ExternalPluginAdapterKey } from './externalPluginAdapterKey'; import { ValidationResultsOffset, validationResultsOffsetFromBase, validationResultsOffsetToBase, } from './validationResultsOffset'; -export type Oracle = Omit & { - pda?: ExtraAccount; +export type Oracle = Omit & { + baseAddressConfig?: ExtraAccount; resultsOffset: ValidationResultsOffset; }; -export type OraclePlugin = BaseExternalPlugin & +export type OraclePlugin = BaseExternalPluginAdapter & Oracle & { type: 'Oracle'; }; export type OracleInitInfoArgs = Omit< BaseOracleInitInfoArgs, - 'initPluginAuthority' | 'lifecycleChecks' | 'pda' | 'resultsOffset' + | 'initPluginAuthority' + | 'lifecycleChecks' + | 'baseAddressConfig' + | 'resultsOffset' > & { type: 'Oracle'; initPluginAuthority?: PluginAuthority; lifecycleChecks: LifecycleChecks; - pda?: ExtraAccount; + baseAddressConfig?: ExtraAccount; resultsOffset?: ValidationResultsOffset; }; export type OracleUpdateInfoArgs = Omit< BaseOracleUpdateInfoArgs, - 'lifecycleChecks' | 'pda' | 'resultsOffset' + 'lifecycleChecks' | 'baseAddressConfig' | 'resultsOffset' > & { - key: ExternalPluginKey; + key: ExternalPluginAdapterKey; lifecycleChecks?: LifecycleChecks; - pda?: ExtraAccount; + baseAddressConfig?: ExtraAccount; resultsOffset?: ValidationResultsOffset; }; @@ -60,7 +63,9 @@ export function oracleInitInfoArgsToBase( ): BaseOracleInitInfoArgs { return { baseAddress: o.baseAddress, - pda: o.pda ? extraAccountToBase(o.pda) : null, + baseAddressConfig: o.baseAddressConfig + ? extraAccountToBase(o.baseAddressConfig) + : null, lifecycleChecks: lifecycleChecksToBase(o.lifecycleChecks), initPluginAuthority: o.initPluginAuthority ? pluginAuthorityToBase(o.initPluginAuthority) @@ -75,7 +80,9 @@ export function oracleUpdateInfoArgsToBase( o: OracleUpdateInfoArgs ): BaseOracleUpdateInfoArgs { return { - pda: o.pda ? extraAccountToBase(o.pda) : null, + baseAddressConfig: o.baseAddressConfig + ? extraAccountToBase(o.baseAddressConfig) + : null, lifecycleChecks: o.lifecycleChecks ? lifecycleChecksToBase(o.lifecycleChecks) : null, @@ -92,15 +99,17 @@ export function oracleFromBase( ): Oracle { return { ...s, - pda: - s.pda.__option === 'Some' ? extraAccountFromBase(s.pda.value) : undefined, + baseAddressConfig: + s.baseAddressConfig.__option === 'Some' + ? extraAccountFromBase(s.baseAddressConfig.value) + : undefined, resultsOffset: validationResultsOffsetFromBase(s.resultsOffset), }; } export function findOracleAccount( context: Pick, - oracle: Pick, + oracle: Pick, inputs: { asset?: PublicKey; collection?: PublicKey; @@ -108,11 +117,11 @@ export function findOracleAccount( owner?: PublicKey; } ): PublicKey { - if (!oracle.pda) { + if (!oracle.baseAddressConfig) { return oracle.baseAddress; } - return extraAccountToAccountMeta(context, oracle.pda, { + return extraAccountToAccountMeta(context, oracle.baseAddressConfig, { ...inputs, program: oracle.baseAddress, }).pubkey; @@ -132,7 +141,7 @@ export function deserializeOracleValidation( return getOracleValidationSerializer().deserialize(data, offs)[0]; } -export const oracleManifest: ExternalPluginManifest< +export const oracleManifest: ExternalPluginAdapterManifest< Oracle, BaseOracle, OracleInitInfoArgs, diff --git a/clients/js/test/_setupRaw.ts b/clients/js/test/_setupRaw.ts index 77b97003..94687ae8 100644 --- a/clients/js/test/_setupRaw.ts +++ b/clients/js/test/_setupRaw.ts @@ -22,7 +22,7 @@ import { PluginsList, PluginAuthorityPairArgs, UpdateAuthority, - ExternalPluginsList, + ExternalPluginAdaptersList, } from '../src'; export const createUmi = async () => (await basecreateUmi()).use(mplCore()); @@ -146,7 +146,7 @@ export const assertAsset = async ( name?: string | RegExp; uri?: string | RegExp; } & PluginsList & - ExternalPluginsList + ExternalPluginAdaptersList ) => { const { asset, owner, name, uri, ...rest } = input; const assetAddress = publicKey(input.asset); @@ -181,7 +181,7 @@ export const assertCollection = async ( numMinted?: number; currentSize?: number; } & PluginsList & - ExternalPluginsList + ExternalPluginAdaptersList ) => { const { collection, name, uri, updateAuthority, ...rest } = input; diff --git a/clients/js/test/_setupSdk.ts b/clients/js/test/_setupSdk.ts index b2ecd281..eac10de4 100644 --- a/clients/js/test/_setupSdk.ts +++ b/clients/js/test/_setupSdk.ts @@ -13,7 +13,7 @@ import { CollectionV1, AssetV1, PluginAuthorityPairArgsV2, - ExternalPluginInitInfoArgs, + ExternalPluginAdapterInitInfoArgs, create, createCollection as baseCreateCollection, } from '../src'; @@ -29,7 +29,7 @@ export type CreateAssetHelperArgs = { authority?: Signer; updateAuthority?: PublicKey | Signer; collection?: PublicKey | CollectionV1; - plugins?: (ExternalPluginInitInfoArgs | PluginAuthorityPairArgsV2)[]; + plugins?: (ExternalPluginAdapterInitInfoArgs | PluginAuthorityPairArgsV2)[]; }; export const createAsset = async ( umi: Umi, @@ -69,7 +69,7 @@ export type CreateCollectionHelperArgs = { name?: string; uri?: string; updateAuthority?: PublicKey | Signer; - plugins?: (ExternalPluginInitInfoArgs | PluginAuthorityPairArgsV2)[]; + plugins?: (ExternalPluginAdapterInitInfoArgs | PluginAuthorityPairArgsV2)[]; }; export const createCollection = async ( diff --git a/clients/js/test/externalPlugins/oracle.test.ts b/clients/js/test/externalPlugins/oracle.test.ts index dc754127..0c7f189d 100644 --- a/clients/js/test/externalPlugins/oracle.test.ts +++ b/clients/js/test/externalPlugins/oracle.test.ts @@ -22,8 +22,8 @@ import { close, } from '@metaplex-foundation/mpl-core-oracle-example'; import { generateSigner, sol } from '@metaplex-foundation/umi'; -import { ExternalValidationResult } from '@metaplex-foundation/mpl-core-oracle-example/dist/src/hooked'; import { generateSignerWithSol } from '@metaplex-foundation/umi-bundle-tests'; +import { createAccount } from '@metaplex-foundation/mpl-toolbox'; import { assertAsset, assertBurned, @@ -44,8 +44,8 @@ import { addPlugin, updatePlugin, fetchAssetV1, + ExternalValidationResult, } from '../../src'; -import { createAccount } from '@metaplex-foundation/mpl-toolbox'; const createUmi = async () => (await baseCreateUmi()).use(mplCoreOracleExample()); @@ -130,7 +130,7 @@ test('it can use fixed address oracle to deny update', async (t) => { lifecycleChecks: { update: [CheckResult.CAN_REJECT], }, - pda: undefined, + baseAddressConfig: undefined, }, ], }); @@ -227,7 +227,7 @@ test('it can use fixed address oracle to deny update via collection', async (t) lifecycleChecks: { update: [CheckResult.CAN_REJECT], }, - pda: undefined, + baseAddressConfig: undefined, }, ], }); @@ -314,7 +314,7 @@ test('it can use fixed address oracle to deny transfer', async (t) => { lifecycleChecks: { transfer: [CheckResult.CAN_REJECT], }, - pda: undefined, + baseAddressConfig: undefined, }, ], }); @@ -419,7 +419,7 @@ test('it cannot update oracle to have no lifecycle checks', async (t) => { lifecycleChecks: { transfer: [CheckResult.CAN_REJECT], }, - pda: undefined, + baseAddressConfig: undefined, }, ], }); @@ -460,7 +460,7 @@ test('it cannot update oracle to have no lifecycle checks', async (t) => { lifecycleChecks: { transfer: [CheckResult.CAN_REJECT], }, - pda: undefined, + baseAddressConfig: undefined, }, ], }); @@ -636,7 +636,7 @@ test('it cannot update oracle to approve', async (t) => { lifecycleChecks: { transfer: [CheckResult.CAN_REJECT], }, - pda: undefined, + baseAddressConfig: undefined, }, ], }); @@ -678,7 +678,7 @@ test('it cannot update oracle to approve', async (t) => { lifecycleChecks: { transfer: [CheckResult.CAN_REJECT], }, - pda: undefined, + baseAddressConfig: undefined, }, ], }); @@ -722,7 +722,7 @@ test('it cannot update oracle to approve in addition to reject', async (t) => { lifecycleChecks: { transfer: [CheckResult.CAN_REJECT], }, - pda: undefined, + baseAddressConfig: undefined, }, ], }); @@ -764,7 +764,7 @@ test('it cannot update oracle to approve in addition to reject', async (t) => { lifecycleChecks: { transfer: [CheckResult.CAN_REJECT], }, - pda: undefined, + baseAddressConfig: undefined, }, ], }); @@ -874,7 +874,7 @@ test('it cannot update oracle to listen', async (t) => { lifecycleChecks: { transfer: [CheckResult.CAN_REJECT], }, - pda: undefined, + baseAddressConfig: undefined, }, ], }); @@ -916,7 +916,7 @@ test('it cannot update oracle to listen', async (t) => { lifecycleChecks: { transfer: [CheckResult.CAN_REJECT], }, - pda: undefined, + baseAddressConfig: undefined, }, ], }); @@ -985,7 +985,7 @@ test('it cannot use fixed address oracle to deny transfer if not registered for lifecycleChecks: { create: [CheckResult.CAN_REJECT], }, - pda: undefined, + baseAddressConfig: undefined, }, ], }); @@ -1079,7 +1079,7 @@ test('it can use fixed address oracle to deny create', async (t) => { lifecycleChecks: { create: [CheckResult.CAN_REJECT], }, - pda: undefined, + baseAddressConfig: undefined, }, ], }); @@ -1160,7 +1160,7 @@ test('it can use preconfigured program pda oracle to deny update', async (t) => update: [CheckResult.CAN_REJECT], }, baseAddress: MPL_CORE_ORACLE_EXAMPLE_PROGRAM_ID, - pda: { + baseAddressConfig: { type: 'PreconfiguredProgram', }, }; @@ -1247,7 +1247,7 @@ test('it can use preconfigured program pda oracle to deny update', async (t) => lifecycleChecks: { update: [CheckResult.CAN_REJECT], }, - pda: { + baseAddressConfig: { type: 'PreconfiguredProgram', }, }, @@ -1267,7 +1267,7 @@ test('it can use preconfigured collection pda oracle to deny update', async (t) update: [CheckResult.CAN_REJECT], }, baseAddress: MPL_CORE_ORACLE_EXAMPLE_PROGRAM_ID, - pda: { + baseAddressConfig: { type: 'PreconfiguredCollection', }, }; @@ -1350,7 +1350,7 @@ test('it can use preconfigured collection pda oracle to deny update', async (t) lifecycleChecks: { update: [CheckResult.CAN_REJECT], }, - pda: { + baseAddressConfig: { type: 'PreconfiguredCollection', }, }, @@ -1370,7 +1370,7 @@ test('it can use preconfigured owner pda oracle to deny burn', async (t) => { burn: [CheckResult.CAN_REJECT], }, baseAddress: MPL_CORE_ORACLE_EXAMPLE_PROGRAM_ID, - pda: { + baseAddressConfig: { type: 'PreconfiguredOwner', }, }; @@ -1426,7 +1426,7 @@ test('it can use preconfigured owner pda oracle to deny burn', async (t) => { lifecycleChecks: { burn: [CheckResult.CAN_REJECT], }, - pda: { + baseAddressConfig: { type: 'PreconfiguredOwner', }, }, @@ -1469,7 +1469,7 @@ test('it can use preconfigured recipient pda oracle to deny transfer', async (t) transfer: [CheckResult.CAN_REJECT], }, baseAddress: MPL_CORE_ORACLE_EXAMPLE_PROGRAM_ID, - pda: { + baseAddressConfig: { type: 'PreconfiguredRecipient', }, }; @@ -1544,7 +1544,7 @@ test('it can use preconfigured recipient pda oracle to deny transfer', async (t) lifecycleChecks: { transfer: [CheckResult.CAN_REJECT], }, - pda: { + baseAddressConfig: { type: 'PreconfiguredRecipient', }, }, @@ -1564,7 +1564,7 @@ test('it can use preconfigured asset pda oracle to deny update', async (t) => { update: [CheckResult.CAN_REJECT], }, baseAddress: MPL_CORE_ORACLE_EXAMPLE_PROGRAM_ID, - pda: { + baseAddressConfig: { type: 'PreconfiguredAsset', }, }; @@ -1640,7 +1640,7 @@ test('it can use preconfigured asset pda oracle to deny update', async (t) => { lifecycleChecks: { update: [CheckResult.CAN_REJECT], }, - pda: { + baseAddressConfig: { type: 'PreconfiguredAsset', }, }, @@ -1663,7 +1663,7 @@ test('it can use custom pda (all seeds) oracle to deny transfer', async (t) => { transfer: [CheckResult.CAN_REJECT], }, baseAddress: MPL_CORE_ORACLE_EXAMPLE_PROGRAM_ID, - pda: { + baseAddressConfig: { type: 'CustomPda', seeds: [ { type: 'Collection' }, @@ -1771,7 +1771,7 @@ test('it can use custom pda (all seeds) oracle to deny transfer', async (t) => { lifecycleChecks: { transfer: [CheckResult.CAN_REJECT], }, - pda: { + baseAddressConfig: { type: 'CustomPda', seeds: [ { type: 'Collection' }, @@ -1804,7 +1804,7 @@ test('it can use custom pda (typical) oracle to deny transfer', async (t) => { transfer: [CheckResult.CAN_REJECT], }, baseAddress: MPL_CORE_ORACLE_EXAMPLE_PROGRAM_ID, - pda: { + baseAddressConfig: { type: 'CustomPda', seeds: [ { @@ -1903,7 +1903,7 @@ test('it can use custom pda (typical) oracle to deny transfer', async (t) => { lifecycleChecks: { transfer: [CheckResult.CAN_REJECT], }, - pda: { + baseAddressConfig: { type: 'CustomPda', seeds: [ { @@ -1942,7 +1942,7 @@ test('it can use custom pda (with custom program ID) oracle to deny transfer', a transfer: [CheckResult.CAN_REJECT], }, baseAddress: randomProgramId, - pda: { + baseAddressConfig: { type: 'CustomPda', seeds: [ { @@ -2042,7 +2042,7 @@ test('it can use custom pda (with custom program ID) oracle to deny transfer', a lifecycleChecks: { transfer: [CheckResult.CAN_REJECT], }, - pda: { + baseAddressConfig: { type: 'CustomPda', seeds: [ { @@ -2089,7 +2089,7 @@ test('it can use preconfigured asset pda custom offset oracle to deny update', a update: [CheckResult.CAN_REJECT], }, baseAddress: MPL_CORE_ORACLE_EXAMPLE_PROGRAM_ID, - pda: { + baseAddressConfig: { type: 'PreconfiguredAsset', }, }; @@ -2208,7 +2208,7 @@ test('it can use preconfigured asset pda custom offset oracle to deny update', a lifecycleChecks: { update: [CheckResult.CAN_REJECT], }, - pda: { + baseAddressConfig: { type: 'PreconfiguredAsset', }, }, @@ -2417,13 +2417,13 @@ test('it can update asset to different size name with oracle', async (t) => { update: [CheckResult.CAN_REJECT], }, baseAddress: oracleSigner.publicKey, - pda: undefined, + baseAddressConfig: undefined, }, ], }); }); -test('it can update oracle to different size external plugin', async (t) => { +test('it can update oracle to different size external plugin adapter', async (t) => { const umi = await createUmi(); const oracleSigner = generateSigner(umi); await fixedAccountInit(umi, { @@ -2483,7 +2483,7 @@ test('it can update oracle to different size external plugin', async (t) => { burn: [CheckResult.CAN_REJECT], }, baseAddress: oracleSigner.publicKey, - pda: undefined, + baseAddressConfig: undefined, }, ], }); @@ -2524,7 +2524,7 @@ test('it can update oracle to different size external plugin', async (t) => { transfer: [CheckResult.CAN_REJECT], }, baseAddress: oracleSigner.publicKey, - pda: undefined, + baseAddressConfig: undefined, }, ], }); @@ -2595,7 +2595,7 @@ test('it transfer fails but does not panic when oracle account does not exist', lifecycleChecks: { transfer: [CheckResult.CAN_REJECT], }, - pda: undefined, + baseAddressConfig: undefined, }, ], }); @@ -2653,7 +2653,7 @@ test('it transfer fails but does not panic when oracle account is too small', as lifecycleChecks: { transfer: [CheckResult.CAN_REJECT], }, - pda: undefined, + baseAddressConfig: undefined, }, ], }); @@ -2711,7 +2711,7 @@ test('it empty account does not default to valid oracle', async (t) => { lifecycleChecks: { transfer: [CheckResult.CAN_REJECT], }, - pda: undefined, + baseAddressConfig: undefined, }, ], }); diff --git a/clients/js/test/helps/lifecycle.test.ts b/clients/js/test/helps/lifecycle.test.ts index c98f58a4..b947cba6 100644 --- a/clients/js/test/helps/lifecycle.test.ts +++ b/clients/js/test/helps/lifecycle.test.ts @@ -9,13 +9,13 @@ import { canBurn, canTransfer, CheckResult, - ExternalValidationResult, findOracleAccount, LifecycleValidationError, OracleInitInfoArgs, validateBurn, validateTransfer, validateUpdate, + ExternalValidationResult, } from '../../src'; import { createUmi } from '../_setupRaw'; import { createAsset, createAssetWithCollection } from '../_setupSdk'; @@ -460,7 +460,7 @@ test('it can validate non-transferrable asset with oracle with recipient seed', transfer: [CheckResult.CAN_REJECT], }, baseAddress: MPL_CORE_ORACLE_EXAMPLE_PROGRAM_ID, - pda: { + baseAddressConfig: { type: 'CustomPda', seeds: [ { type: 'Collection' }, @@ -543,7 +543,7 @@ test('it can validate and skip transferrable asset with oracle with recipient se transfer: [CheckResult.CAN_REJECT], }, baseAddress: MPL_CORE_ORACLE_EXAMPLE_PROGRAM_ID, - pda: { + baseAddressConfig: { type: 'CustomPda', seeds: [ { diff --git a/clients/rust/src/generated/errors/mpl_core.rs b/clients/rust/src/generated/errors/mpl_core.rs index 2c148460..e079f3f4 100644 --- a/clients/rust/src/generated/errors/mpl_core.rs +++ b/clients/rust/src/generated/errors/mpl_core.rs @@ -103,26 +103,26 @@ pub enum MplCoreError { /// 30 (0x1E) - Invalid Log Wrapper Program #[error("Invalid Log Wrapper Program")] InvalidLogWrapperProgram, - /// 31 (0x1F) - External Plugin not found - #[error("External Plugin not found")] - ExternalPluginNotFound, - /// 32 (0x20) - External Plugin already exists - #[error("External Plugin already exists")] - ExternalPluginAlreadyExists, + /// 31 (0x1F) - External PluginExternalPluginAdapter not found + #[error("External PluginExternalPluginAdapter not found")] + ExternalPluginAdapterNotFound, + /// 32 (0x20) - External PluginExternalPluginAdapter already exists + #[error("External PluginExternalPluginAdapter already exists")] + ExternalPluginAdapterAlreadyExists, /// 33 (0x21) - Missing asset needed for extra account PDA derivation #[error("Missing asset needed for extra account PDA derivation")] MissingAsset, - /// 34 (0x22) - Missing account needed for external plugin - #[error("Missing account needed for external plugin")] - MissingExternalAccount, - /// 35 (0x23) - Oracle external plugin can only be configured to reject - #[error("Oracle external plugin can only be configured to reject")] + /// 34 (0x22) - Missing account needed for external plugin adapter + #[error("Missing account needed for external plugin adapter")] + MissingExternalPluginAdapterAccount, + /// 35 (0x23) - Oracle external plugin adapter can only be configured to reject + #[error("Oracle external plugin adapter can only be configured to reject")] OracleCanRejectOnly, - /// 36 (0x24) - External plugin must have at least one lifecycle check - #[error("External plugin must have at least one lifecycle check")] + /// 36 (0x24) - External plugin adapter must have at least one lifecycle check + #[error("External plugin adapter must have at least one lifecycle check")] RequiresLifecycleCheck, - /// 37 (0x25) - Duplicate lifecycle checks were provided for external plugin - #[error("Duplicate lifecycle checks were provided for external plugin")] + /// 37 (0x25) - Duplicate lifecycle checks were provided for external plugin adapter + #[error("Duplicate lifecycle checks were provided for external plugin adapter ")] DuplicateLifecycleChecks, /// 38 (0x26) - Could not read from oracle account #[error("Could not read from oracle account")] diff --git a/clients/rust/src/generated/instructions/add_collection_external_plugin_v1.rs b/clients/rust/src/generated/instructions/add_collection_external_plugin_adapter_v1.rs similarity index 87% rename from clients/rust/src/generated/instructions/add_collection_external_plugin_v1.rs rename to clients/rust/src/generated/instructions/add_collection_external_plugin_adapter_v1.rs index 6b4b5994..117d693c 100644 --- a/clients/rust/src/generated/instructions/add_collection_external_plugin_v1.rs +++ b/clients/rust/src/generated/instructions/add_collection_external_plugin_adapter_v1.rs @@ -5,14 +5,14 @@ //! [https://github.com/metaplex-foundation/kinobi] //! -use crate::generated::types::ExternalPluginInitInfo; +use crate::generated::types::ExternalPluginAdapterInitInfo; #[cfg(feature = "anchor")] use anchor_lang::prelude::{AnchorDeserialize, AnchorSerialize}; #[cfg(not(feature = "anchor"))] use borsh::{BorshDeserialize, BorshSerialize}; /// Accounts. -pub struct AddCollectionExternalPluginV1 { +pub struct AddCollectionExternalPluginAdapterV1 { /// The address of the asset pub collection: solana_program::pubkey::Pubkey, /// The account paying for the storage fees @@ -25,17 +25,17 @@ pub struct AddCollectionExternalPluginV1 { pub log_wrapper: Option, } -impl AddCollectionExternalPluginV1 { +impl AddCollectionExternalPluginAdapterV1 { pub fn instruction( &self, - args: AddCollectionExternalPluginV1InstructionArgs, + args: AddCollectionExternalPluginAdapterV1InstructionArgs, ) -> solana_program::instruction::Instruction { self.instruction_with_remaining_accounts(args, &[]) } #[allow(clippy::vec_init_then_push)] pub fn instruction_with_remaining_accounts( &self, - args: AddCollectionExternalPluginV1InstructionArgs, + args: AddCollectionExternalPluginAdapterV1InstructionArgs, remaining_accounts: &[solana_program::instruction::AccountMeta], ) -> solana_program::instruction::Instruction { let mut accounts = Vec::with_capacity(5 + remaining_accounts.len()); @@ -72,7 +72,7 @@ impl AddCollectionExternalPluginV1 { )); } accounts.extend_from_slice(remaining_accounts); - let mut data = AddCollectionExternalPluginV1InstructionData::new() + let mut data = AddCollectionExternalPluginAdapterV1InstructionData::new() .try_to_vec() .unwrap(); let mut args = args.try_to_vec().unwrap(); @@ -88,11 +88,11 @@ impl AddCollectionExternalPluginV1 { #[cfg_attr(not(feature = "anchor"), derive(BorshSerialize, BorshDeserialize))] #[cfg_attr(feature = "anchor", derive(AnchorSerialize, AnchorDeserialize))] -pub struct AddCollectionExternalPluginV1InstructionData { +pub struct AddCollectionExternalPluginAdapterV1InstructionData { discriminator: u8, } -impl AddCollectionExternalPluginV1InstructionData { +impl AddCollectionExternalPluginAdapterV1InstructionData { pub fn new() -> Self { Self { discriminator: 23 } } @@ -102,11 +102,11 @@ impl AddCollectionExternalPluginV1InstructionData { #[cfg_attr(feature = "anchor", derive(AnchorSerialize, AnchorDeserialize))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Debug, Eq, PartialEq)] -pub struct AddCollectionExternalPluginV1InstructionArgs { - pub init_info: ExternalPluginInitInfo, +pub struct AddCollectionExternalPluginAdapterV1InstructionArgs { + pub init_info: ExternalPluginAdapterInitInfo, } -/// Instruction builder for `AddCollectionExternalPluginV1`. +/// Instruction builder for `AddCollectionExternalPluginAdapterV1`. /// /// ### Accounts: /// @@ -116,17 +116,17 @@ pub struct AddCollectionExternalPluginV1InstructionArgs { /// 3. `[optional]` system_program (default to `11111111111111111111111111111111`) /// 4. `[optional]` log_wrapper #[derive(Default)] -pub struct AddCollectionExternalPluginV1Builder { +pub struct AddCollectionExternalPluginAdapterV1Builder { collection: Option, payer: Option, authority: Option, system_program: Option, log_wrapper: Option, - init_info: Option, + init_info: Option, __remaining_accounts: Vec, } -impl AddCollectionExternalPluginV1Builder { +impl AddCollectionExternalPluginAdapterV1Builder { pub fn new() -> Self { Self::default() } @@ -167,7 +167,7 @@ impl AddCollectionExternalPluginV1Builder { self } #[inline(always)] - pub fn init_info(&mut self, init_info: ExternalPluginInitInfo) -> &mut Self { + pub fn init_info(&mut self, init_info: ExternalPluginAdapterInitInfo) -> &mut Self { self.init_info = Some(init_info); self } @@ -191,7 +191,7 @@ impl AddCollectionExternalPluginV1Builder { } #[allow(clippy::clone_on_copy)] pub fn instruction(&self) -> solana_program::instruction::Instruction { - let accounts = AddCollectionExternalPluginV1 { + let accounts = AddCollectionExternalPluginAdapterV1 { collection: self.collection.expect("collection is not set"), payer: self.payer.expect("payer is not set"), authority: self.authority, @@ -200,7 +200,7 @@ impl AddCollectionExternalPluginV1Builder { .unwrap_or(solana_program::pubkey!("11111111111111111111111111111111")), log_wrapper: self.log_wrapper, }; - let args = AddCollectionExternalPluginV1InstructionArgs { + let args = AddCollectionExternalPluginAdapterV1InstructionArgs { init_info: self.init_info.clone().expect("init_info is not set"), }; @@ -208,8 +208,8 @@ impl AddCollectionExternalPluginV1Builder { } } -/// `add_collection_external_plugin_v1` CPI accounts. -pub struct AddCollectionExternalPluginV1CpiAccounts<'a, 'b> { +/// `add_collection_external_plugin_adapter_v1` CPI accounts. +pub struct AddCollectionExternalPluginAdapterV1CpiAccounts<'a, 'b> { /// The address of the asset pub collection: &'b solana_program::account_info::AccountInfo<'a>, /// The account paying for the storage fees @@ -222,8 +222,8 @@ pub struct AddCollectionExternalPluginV1CpiAccounts<'a, 'b> { pub log_wrapper: Option<&'b solana_program::account_info::AccountInfo<'a>>, } -/// `add_collection_external_plugin_v1` CPI instruction. -pub struct AddCollectionExternalPluginV1Cpi<'a, 'b> { +/// `add_collection_external_plugin_adapter_v1` CPI instruction. +pub struct AddCollectionExternalPluginAdapterV1Cpi<'a, 'b> { /// The program to invoke. pub __program: &'b solana_program::account_info::AccountInfo<'a>, /// The address of the asset @@ -237,14 +237,14 @@ pub struct AddCollectionExternalPluginV1Cpi<'a, 'b> { /// The SPL Noop Program pub log_wrapper: Option<&'b solana_program::account_info::AccountInfo<'a>>, /// The arguments for the instruction. - pub __args: AddCollectionExternalPluginV1InstructionArgs, + pub __args: AddCollectionExternalPluginAdapterV1InstructionArgs, } -impl<'a, 'b> AddCollectionExternalPluginV1Cpi<'a, 'b> { +impl<'a, 'b> AddCollectionExternalPluginAdapterV1Cpi<'a, 'b> { pub fn new( program: &'b solana_program::account_info::AccountInfo<'a>, - accounts: AddCollectionExternalPluginV1CpiAccounts<'a, 'b>, - args: AddCollectionExternalPluginV1InstructionArgs, + accounts: AddCollectionExternalPluginAdapterV1CpiAccounts<'a, 'b>, + args: AddCollectionExternalPluginAdapterV1InstructionArgs, ) -> Self { Self { __program: program, @@ -331,7 +331,7 @@ impl<'a, 'b> AddCollectionExternalPluginV1Cpi<'a, 'b> { is_writable: remaining_account.2, }) }); - let mut data = AddCollectionExternalPluginV1InstructionData::new() + let mut data = AddCollectionExternalPluginAdapterV1InstructionData::new() .try_to_vec() .unwrap(); let mut args = self.__args.try_to_vec().unwrap(); @@ -365,7 +365,7 @@ impl<'a, 'b> AddCollectionExternalPluginV1Cpi<'a, 'b> { } } -/// Instruction builder for `AddCollectionExternalPluginV1` via CPI. +/// Instruction builder for `AddCollectionExternalPluginAdapterV1` via CPI. /// /// ### Accounts: /// @@ -374,13 +374,13 @@ impl<'a, 'b> AddCollectionExternalPluginV1Cpi<'a, 'b> { /// 2. `[signer, optional]` authority /// 3. `[]` system_program /// 4. `[optional]` log_wrapper -pub struct AddCollectionExternalPluginV1CpiBuilder<'a, 'b> { - instruction: Box>, +pub struct AddCollectionExternalPluginAdapterV1CpiBuilder<'a, 'b> { + instruction: Box>, } -impl<'a, 'b> AddCollectionExternalPluginV1CpiBuilder<'a, 'b> { +impl<'a, 'b> AddCollectionExternalPluginAdapterV1CpiBuilder<'a, 'b> { pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(AddCollectionExternalPluginV1CpiBuilderInstruction { + let instruction = Box::new(AddCollectionExternalPluginAdapterV1CpiBuilderInstruction { __program: program, collection: None, payer: None, @@ -437,7 +437,7 @@ impl<'a, 'b> AddCollectionExternalPluginV1CpiBuilder<'a, 'b> { self } #[inline(always)] - pub fn init_info(&mut self, init_info: ExternalPluginInitInfo) -> &mut Self { + pub fn init_info(&mut self, init_info: ExternalPluginAdapterInitInfo) -> &mut Self { self.instruction.init_info = Some(init_info); self } @@ -482,14 +482,14 @@ impl<'a, 'b> AddCollectionExternalPluginV1CpiBuilder<'a, 'b> { &self, signers_seeds: &[&[&[u8]]], ) -> solana_program::entrypoint::ProgramResult { - let args = AddCollectionExternalPluginV1InstructionArgs { + let args = AddCollectionExternalPluginAdapterV1InstructionArgs { init_info: self .instruction .init_info .clone() .expect("init_info is not set"), }; - let instruction = AddCollectionExternalPluginV1Cpi { + let instruction = AddCollectionExternalPluginAdapterV1Cpi { __program: self.instruction.__program, collection: self.instruction.collection.expect("collection is not set"), @@ -513,14 +513,14 @@ impl<'a, 'b> AddCollectionExternalPluginV1CpiBuilder<'a, 'b> { } } -struct AddCollectionExternalPluginV1CpiBuilderInstruction<'a, 'b> { +struct AddCollectionExternalPluginAdapterV1CpiBuilderInstruction<'a, 'b> { __program: &'b solana_program::account_info::AccountInfo<'a>, collection: Option<&'b solana_program::account_info::AccountInfo<'a>>, payer: Option<&'b solana_program::account_info::AccountInfo<'a>>, authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, system_program: Option<&'b solana_program::account_info::AccountInfo<'a>>, log_wrapper: Option<&'b solana_program::account_info::AccountInfo<'a>>, - init_info: Option, + init_info: Option, /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. __remaining_accounts: Vec<( &'b solana_program::account_info::AccountInfo<'a>, diff --git a/clients/rust/src/generated/instructions/add_external_plugin_v1.rs b/clients/rust/src/generated/instructions/add_external_plugin_adapter_v1.rs similarity index 89% rename from clients/rust/src/generated/instructions/add_external_plugin_v1.rs rename to clients/rust/src/generated/instructions/add_external_plugin_adapter_v1.rs index 2548bf87..58f773a9 100644 --- a/clients/rust/src/generated/instructions/add_external_plugin_v1.rs +++ b/clients/rust/src/generated/instructions/add_external_plugin_adapter_v1.rs @@ -5,14 +5,14 @@ //! [https://github.com/metaplex-foundation/kinobi] //! -use crate::generated::types::ExternalPluginInitInfo; +use crate::generated::types::ExternalPluginAdapterInitInfo; #[cfg(feature = "anchor")] use anchor_lang::prelude::{AnchorDeserialize, AnchorSerialize}; #[cfg(not(feature = "anchor"))] use borsh::{BorshDeserialize, BorshSerialize}; /// Accounts. -pub struct AddExternalPluginV1 { +pub struct AddExternalPluginAdapterV1 { /// The address of the asset pub asset: solana_program::pubkey::Pubkey, /// The collection to which the asset belongs @@ -27,17 +27,17 @@ pub struct AddExternalPluginV1 { pub log_wrapper: Option, } -impl AddExternalPluginV1 { +impl AddExternalPluginAdapterV1 { pub fn instruction( &self, - args: AddExternalPluginV1InstructionArgs, + args: AddExternalPluginAdapterV1InstructionArgs, ) -> solana_program::instruction::Instruction { self.instruction_with_remaining_accounts(args, &[]) } #[allow(clippy::vec_init_then_push)] pub fn instruction_with_remaining_accounts( &self, - args: AddExternalPluginV1InstructionArgs, + args: AddExternalPluginAdapterV1InstructionArgs, remaining_accounts: &[solana_program::instruction::AccountMeta], ) -> solana_program::instruction::Instruction { let mut accounts = Vec::with_capacity(6 + remaining_accounts.len()); @@ -83,7 +83,7 @@ impl AddExternalPluginV1 { )); } accounts.extend_from_slice(remaining_accounts); - let mut data = AddExternalPluginV1InstructionData::new() + let mut data = AddExternalPluginAdapterV1InstructionData::new() .try_to_vec() .unwrap(); let mut args = args.try_to_vec().unwrap(); @@ -99,11 +99,11 @@ impl AddExternalPluginV1 { #[cfg_attr(not(feature = "anchor"), derive(BorshSerialize, BorshDeserialize))] #[cfg_attr(feature = "anchor", derive(AnchorSerialize, AnchorDeserialize))] -pub struct AddExternalPluginV1InstructionData { +pub struct AddExternalPluginAdapterV1InstructionData { discriminator: u8, } -impl AddExternalPluginV1InstructionData { +impl AddExternalPluginAdapterV1InstructionData { pub fn new() -> Self { Self { discriminator: 22 } } @@ -113,11 +113,11 @@ impl AddExternalPluginV1InstructionData { #[cfg_attr(feature = "anchor", derive(AnchorSerialize, AnchorDeserialize))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Debug, Eq, PartialEq)] -pub struct AddExternalPluginV1InstructionArgs { - pub init_info: ExternalPluginInitInfo, +pub struct AddExternalPluginAdapterV1InstructionArgs { + pub init_info: ExternalPluginAdapterInitInfo, } -/// Instruction builder for `AddExternalPluginV1`. +/// Instruction builder for `AddExternalPluginAdapterV1`. /// /// ### Accounts: /// @@ -128,18 +128,18 @@ pub struct AddExternalPluginV1InstructionArgs { /// 4. `[optional]` system_program (default to `11111111111111111111111111111111`) /// 5. `[optional]` log_wrapper #[derive(Default)] -pub struct AddExternalPluginV1Builder { +pub struct AddExternalPluginAdapterV1Builder { asset: Option, collection: Option, payer: Option, authority: Option, system_program: Option, log_wrapper: Option, - init_info: Option, + init_info: Option, __remaining_accounts: Vec, } -impl AddExternalPluginV1Builder { +impl AddExternalPluginAdapterV1Builder { pub fn new() -> Self { Self::default() } @@ -187,7 +187,7 @@ impl AddExternalPluginV1Builder { self } #[inline(always)] - pub fn init_info(&mut self, init_info: ExternalPluginInitInfo) -> &mut Self { + pub fn init_info(&mut self, init_info: ExternalPluginAdapterInitInfo) -> &mut Self { self.init_info = Some(init_info); self } @@ -211,7 +211,7 @@ impl AddExternalPluginV1Builder { } #[allow(clippy::clone_on_copy)] pub fn instruction(&self) -> solana_program::instruction::Instruction { - let accounts = AddExternalPluginV1 { + let accounts = AddExternalPluginAdapterV1 { asset: self.asset.expect("asset is not set"), collection: self.collection, payer: self.payer.expect("payer is not set"), @@ -221,7 +221,7 @@ impl AddExternalPluginV1Builder { .unwrap_or(solana_program::pubkey!("11111111111111111111111111111111")), log_wrapper: self.log_wrapper, }; - let args = AddExternalPluginV1InstructionArgs { + let args = AddExternalPluginAdapterV1InstructionArgs { init_info: self.init_info.clone().expect("init_info is not set"), }; @@ -229,8 +229,8 @@ impl AddExternalPluginV1Builder { } } -/// `add_external_plugin_v1` CPI accounts. -pub struct AddExternalPluginV1CpiAccounts<'a, 'b> { +/// `add_external_plugin_adapter_v1` CPI accounts. +pub struct AddExternalPluginAdapterV1CpiAccounts<'a, 'b> { /// The address of the asset pub asset: &'b solana_program::account_info::AccountInfo<'a>, /// The collection to which the asset belongs @@ -245,8 +245,8 @@ pub struct AddExternalPluginV1CpiAccounts<'a, 'b> { pub log_wrapper: Option<&'b solana_program::account_info::AccountInfo<'a>>, } -/// `add_external_plugin_v1` CPI instruction. -pub struct AddExternalPluginV1Cpi<'a, 'b> { +/// `add_external_plugin_adapter_v1` CPI instruction. +pub struct AddExternalPluginAdapterV1Cpi<'a, 'b> { /// The program to invoke. pub __program: &'b solana_program::account_info::AccountInfo<'a>, /// The address of the asset @@ -262,14 +262,14 @@ pub struct AddExternalPluginV1Cpi<'a, 'b> { /// The SPL Noop Program pub log_wrapper: Option<&'b solana_program::account_info::AccountInfo<'a>>, /// The arguments for the instruction. - pub __args: AddExternalPluginV1InstructionArgs, + pub __args: AddExternalPluginAdapterV1InstructionArgs, } -impl<'a, 'b> AddExternalPluginV1Cpi<'a, 'b> { +impl<'a, 'b> AddExternalPluginAdapterV1Cpi<'a, 'b> { pub fn new( program: &'b solana_program::account_info::AccountInfo<'a>, - accounts: AddExternalPluginV1CpiAccounts<'a, 'b>, - args: AddExternalPluginV1InstructionArgs, + accounts: AddExternalPluginAdapterV1CpiAccounts<'a, 'b>, + args: AddExternalPluginAdapterV1InstructionArgs, ) -> Self { Self { __program: program, @@ -368,7 +368,7 @@ impl<'a, 'b> AddExternalPluginV1Cpi<'a, 'b> { is_writable: remaining_account.2, }) }); - let mut data = AddExternalPluginV1InstructionData::new() + let mut data = AddExternalPluginAdapterV1InstructionData::new() .try_to_vec() .unwrap(); let mut args = self.__args.try_to_vec().unwrap(); @@ -405,7 +405,7 @@ impl<'a, 'b> AddExternalPluginV1Cpi<'a, 'b> { } } -/// Instruction builder for `AddExternalPluginV1` via CPI. +/// Instruction builder for `AddExternalPluginAdapterV1` via CPI. /// /// ### Accounts: /// @@ -415,13 +415,13 @@ impl<'a, 'b> AddExternalPluginV1Cpi<'a, 'b> { /// 3. `[signer, optional]` authority /// 4. `[]` system_program /// 5. `[optional]` log_wrapper -pub struct AddExternalPluginV1CpiBuilder<'a, 'b> { - instruction: Box>, +pub struct AddExternalPluginAdapterV1CpiBuilder<'a, 'b> { + instruction: Box>, } -impl<'a, 'b> AddExternalPluginV1CpiBuilder<'a, 'b> { +impl<'a, 'b> AddExternalPluginAdapterV1CpiBuilder<'a, 'b> { pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(AddExternalPluginV1CpiBuilderInstruction { + let instruction = Box::new(AddExternalPluginAdapterV1CpiBuilderInstruction { __program: program, asset: None, collection: None, @@ -486,7 +486,7 @@ impl<'a, 'b> AddExternalPluginV1CpiBuilder<'a, 'b> { self } #[inline(always)] - pub fn init_info(&mut self, init_info: ExternalPluginInitInfo) -> &mut Self { + pub fn init_info(&mut self, init_info: ExternalPluginAdapterInitInfo) -> &mut Self { self.instruction.init_info = Some(init_info); self } @@ -531,14 +531,14 @@ impl<'a, 'b> AddExternalPluginV1CpiBuilder<'a, 'b> { &self, signers_seeds: &[&[&[u8]]], ) -> solana_program::entrypoint::ProgramResult { - let args = AddExternalPluginV1InstructionArgs { + let args = AddExternalPluginAdapterV1InstructionArgs { init_info: self .instruction .init_info .clone() .expect("init_info is not set"), }; - let instruction = AddExternalPluginV1Cpi { + let instruction = AddExternalPluginAdapterV1Cpi { __program: self.instruction.__program, asset: self.instruction.asset.expect("asset is not set"), @@ -564,7 +564,7 @@ impl<'a, 'b> AddExternalPluginV1CpiBuilder<'a, 'b> { } } -struct AddExternalPluginV1CpiBuilderInstruction<'a, 'b> { +struct AddExternalPluginAdapterV1CpiBuilderInstruction<'a, 'b> { __program: &'b solana_program::account_info::AccountInfo<'a>, asset: Option<&'b solana_program::account_info::AccountInfo<'a>>, collection: Option<&'b solana_program::account_info::AccountInfo<'a>>, @@ -572,7 +572,7 @@ struct AddExternalPluginV1CpiBuilderInstruction<'a, 'b> { authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, system_program: Option<&'b solana_program::account_info::AccountInfo<'a>>, log_wrapper: Option<&'b solana_program::account_info::AccountInfo<'a>>, - init_info: Option, + init_info: Option, /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. __remaining_accounts: Vec<( &'b solana_program::account_info::AccountInfo<'a>, diff --git a/clients/rust/src/generated/instructions/create_collection_v2.rs b/clients/rust/src/generated/instructions/create_collection_v2.rs index 26ba05ed..49778729 100644 --- a/clients/rust/src/generated/instructions/create_collection_v2.rs +++ b/clients/rust/src/generated/instructions/create_collection_v2.rs @@ -5,7 +5,7 @@ //! [https://github.com/metaplex-foundation/kinobi] //! -use crate::generated::types::ExternalPluginInitInfo; +use crate::generated::types::ExternalPluginAdapterInitInfo; use crate::generated::types::PluginAuthorityPair; #[cfg(feature = "anchor")] use anchor_lang::prelude::{AnchorDeserialize, AnchorSerialize}; @@ -95,7 +95,7 @@ pub struct CreateCollectionV2InstructionArgs { pub name: String, pub uri: String, pub plugins: Option>, - pub external_plugins: Option>, + pub external_plugin_adapters: Option>, } /// Instruction builder for `CreateCollectionV2`. @@ -115,7 +115,7 @@ pub struct CreateCollectionV2Builder { name: Option, uri: Option, plugins: Option>, - external_plugins: Option>, + external_plugin_adapters: Option>, __remaining_accounts: Vec, } @@ -170,8 +170,11 @@ impl CreateCollectionV2Builder { } /// `[optional argument]` #[inline(always)] - pub fn external_plugins(&mut self, external_plugins: Vec) -> &mut Self { - self.external_plugins = Some(external_plugins); + pub fn external_plugin_adapters( + &mut self, + external_plugin_adapters: Vec, + ) -> &mut Self { + self.external_plugin_adapters = Some(external_plugin_adapters); self } /// Add an aditional account to the instruction. @@ -206,7 +209,7 @@ impl CreateCollectionV2Builder { name: self.name.clone().expect("name is not set"), uri: self.uri.clone().expect("uri is not set"), plugins: self.plugins.clone(), - external_plugins: self.external_plugins.clone(), + external_plugin_adapters: self.external_plugin_adapters.clone(), }; accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) @@ -374,7 +377,7 @@ impl<'a, 'b> CreateCollectionV2CpiBuilder<'a, 'b> { name: None, uri: None, plugins: None, - external_plugins: None, + external_plugin_adapters: None, __remaining_accounts: Vec::new(), }); Self { instruction } @@ -431,8 +434,11 @@ impl<'a, 'b> CreateCollectionV2CpiBuilder<'a, 'b> { } /// `[optional argument]` #[inline(always)] - pub fn external_plugins(&mut self, external_plugins: Vec) -> &mut Self { - self.instruction.external_plugins = Some(external_plugins); + pub fn external_plugin_adapters( + &mut self, + external_plugin_adapters: Vec, + ) -> &mut Self { + self.instruction.external_plugin_adapters = Some(external_plugin_adapters); self } /// Add an additional account to the instruction. @@ -480,7 +486,7 @@ impl<'a, 'b> CreateCollectionV2CpiBuilder<'a, 'b> { name: self.instruction.name.clone().expect("name is not set"), uri: self.instruction.uri.clone().expect("uri is not set"), plugins: self.instruction.plugins.clone(), - external_plugins: self.instruction.external_plugins.clone(), + external_plugin_adapters: self.instruction.external_plugin_adapters.clone(), }; let instruction = CreateCollectionV2Cpi { __program: self.instruction.__program, @@ -513,7 +519,7 @@ struct CreateCollectionV2CpiBuilderInstruction<'a, 'b> { name: Option, uri: Option, plugins: Option>, - external_plugins: Option>, + external_plugin_adapters: Option>, /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. __remaining_accounts: Vec<( &'b solana_program::account_info::AccountInfo<'a>, diff --git a/clients/rust/src/generated/instructions/create_v2.rs b/clients/rust/src/generated/instructions/create_v2.rs index 7b048c89..d5b91499 100644 --- a/clients/rust/src/generated/instructions/create_v2.rs +++ b/clients/rust/src/generated/instructions/create_v2.rs @@ -6,7 +6,7 @@ //! use crate::generated::types::DataState; -use crate::generated::types::ExternalPluginInitInfo; +use crate::generated::types::ExternalPluginAdapterInitInfo; use crate::generated::types::PluginAuthorityPair; #[cfg(feature = "anchor")] use anchor_lang::prelude::{AnchorDeserialize, AnchorSerialize}; @@ -143,7 +143,7 @@ pub struct CreateV2InstructionArgs { pub name: String, pub uri: String, pub plugins: Option>, - pub external_plugins: Option>, + pub external_plugin_adapters: Option>, } /// Instruction builder for `CreateV2`. @@ -172,7 +172,7 @@ pub struct CreateV2Builder { name: Option, uri: Option, plugins: Option>, - external_plugins: Option>, + external_plugin_adapters: Option>, __remaining_accounts: Vec, } @@ -264,8 +264,11 @@ impl CreateV2Builder { } /// `[optional argument]` #[inline(always)] - pub fn external_plugins(&mut self, external_plugins: Vec) -> &mut Self { - self.external_plugins = Some(external_plugins); + pub fn external_plugin_adapters( + &mut self, + external_plugin_adapters: Vec, + ) -> &mut Self { + self.external_plugin_adapters = Some(external_plugin_adapters); self } /// Add an aditional account to the instruction. @@ -305,7 +308,7 @@ impl CreateV2Builder { name: self.name.clone().expect("name is not set"), uri: self.uri.clone().expect("uri is not set"), plugins: self.plugins.clone(), - external_plugins: self.external_plugins.clone(), + external_plugin_adapters: self.external_plugin_adapters.clone(), }; accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) @@ -555,7 +558,7 @@ impl<'a, 'b> CreateV2CpiBuilder<'a, 'b> { name: None, uri: None, plugins: None, - external_plugins: None, + external_plugin_adapters: None, __remaining_accounts: Vec::new(), }); Self { instruction } @@ -655,8 +658,11 @@ impl<'a, 'b> CreateV2CpiBuilder<'a, 'b> { } /// `[optional argument]` #[inline(always)] - pub fn external_plugins(&mut self, external_plugins: Vec) -> &mut Self { - self.instruction.external_plugins = Some(external_plugins); + pub fn external_plugin_adapters( + &mut self, + external_plugin_adapters: Vec, + ) -> &mut Self { + self.instruction.external_plugin_adapters = Some(external_plugin_adapters); self } /// Add an additional account to the instruction. @@ -709,7 +715,7 @@ impl<'a, 'b> CreateV2CpiBuilder<'a, 'b> { name: self.instruction.name.clone().expect("name is not set"), uri: self.instruction.uri.clone().expect("uri is not set"), plugins: self.instruction.plugins.clone(), - external_plugins: self.instruction.external_plugins.clone(), + external_plugin_adapters: self.instruction.external_plugin_adapters.clone(), }; let instruction = CreateV2Cpi { __program: self.instruction.__program, @@ -755,7 +761,7 @@ struct CreateV2CpiBuilderInstruction<'a, 'b> { name: Option, uri: Option, plugins: Option>, - external_plugins: Option>, + external_plugin_adapters: Option>, /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. __remaining_accounts: Vec<( &'b solana_program::account_info::AccountInfo<'a>, diff --git a/clients/rust/src/generated/instructions/mod.rs b/clients/rust/src/generated/instructions/mod.rs index 8f936d43..116673db 100644 --- a/clients/rust/src/generated/instructions/mod.rs +++ b/clients/rust/src/generated/instructions/mod.rs @@ -5,9 +5,9 @@ //! [https://github.com/metaplex-foundation/kinobi] //! -pub(crate) mod r#add_collection_external_plugin_v1; +pub(crate) mod r#add_collection_external_plugin_adapter_v1; pub(crate) mod r#add_collection_plugin_v1; -pub(crate) mod r#add_external_plugin_v1; +pub(crate) mod r#add_external_plugin_adapter_v1; pub(crate) mod r#add_plugin_v1; pub(crate) mod r#approve_collection_plugin_authority_v1; pub(crate) mod r#approve_plugin_authority_v1; @@ -20,25 +20,25 @@ pub(crate) mod r#create_collection_v2; pub(crate) mod r#create_v1; pub(crate) mod r#create_v2; pub(crate) mod r#decompress_v1; -pub(crate) mod r#remove_collection_external_plugin_v1; +pub(crate) mod r#remove_collection_external_plugin_adapter_v1; pub(crate) mod r#remove_collection_plugin_v1; -pub(crate) mod r#remove_external_plugin_v1; +pub(crate) mod r#remove_external_plugin_adapter_v1; pub(crate) mod r#remove_plugin_v1; pub(crate) mod r#revoke_collection_plugin_authority_v1; pub(crate) mod r#revoke_plugin_authority_v1; pub(crate) mod r#transfer_v1; -pub(crate) mod r#update_collection_external_plugin_v1; +pub(crate) mod r#update_collection_external_plugin_adapter_v1; pub(crate) mod r#update_collection_plugin_v1; pub(crate) mod r#update_collection_v1; -pub(crate) mod r#update_external_plugin_v1; +pub(crate) mod r#update_external_plugin_adapter_v1; pub(crate) mod r#update_plugin_v1; pub(crate) mod r#update_v1; -pub(crate) mod r#write_collection_external_plugin_data_v1; -pub(crate) mod r#write_external_plugin_data_v1; +pub(crate) mod r#write_collection_external_plugin_adapter_data_v1; +pub(crate) mod r#write_external_plugin_adapter_data_v1; -pub use self::r#add_collection_external_plugin_v1::*; +pub use self::r#add_collection_external_plugin_adapter_v1::*; pub use self::r#add_collection_plugin_v1::*; -pub use self::r#add_external_plugin_v1::*; +pub use self::r#add_external_plugin_adapter_v1::*; pub use self::r#add_plugin_v1::*; pub use self::r#approve_collection_plugin_authority_v1::*; pub use self::r#approve_plugin_authority_v1::*; @@ -51,18 +51,18 @@ pub use self::r#create_collection_v2::*; pub use self::r#create_v1::*; pub use self::r#create_v2::*; pub use self::r#decompress_v1::*; -pub use self::r#remove_collection_external_plugin_v1::*; +pub use self::r#remove_collection_external_plugin_adapter_v1::*; pub use self::r#remove_collection_plugin_v1::*; -pub use self::r#remove_external_plugin_v1::*; +pub use self::r#remove_external_plugin_adapter_v1::*; pub use self::r#remove_plugin_v1::*; pub use self::r#revoke_collection_plugin_authority_v1::*; pub use self::r#revoke_plugin_authority_v1::*; pub use self::r#transfer_v1::*; -pub use self::r#update_collection_external_plugin_v1::*; +pub use self::r#update_collection_external_plugin_adapter_v1::*; pub use self::r#update_collection_plugin_v1::*; pub use self::r#update_collection_v1::*; -pub use self::r#update_external_plugin_v1::*; +pub use self::r#update_external_plugin_adapter_v1::*; pub use self::r#update_plugin_v1::*; pub use self::r#update_v1::*; -pub use self::r#write_collection_external_plugin_data_v1::*; -pub use self::r#write_external_plugin_data_v1::*; +pub use self::r#write_collection_external_plugin_adapter_data_v1::*; +pub use self::r#write_external_plugin_adapter_data_v1::*; diff --git a/clients/rust/src/generated/instructions/remove_collection_external_plugin_v1.rs b/clients/rust/src/generated/instructions/remove_collection_external_plugin_adapter_v1.rs similarity index 85% rename from clients/rust/src/generated/instructions/remove_collection_external_plugin_v1.rs rename to clients/rust/src/generated/instructions/remove_collection_external_plugin_adapter_v1.rs index 9dde3d8a..5d2fb72d 100644 --- a/clients/rust/src/generated/instructions/remove_collection_external_plugin_v1.rs +++ b/clients/rust/src/generated/instructions/remove_collection_external_plugin_adapter_v1.rs @@ -5,14 +5,14 @@ //! [https://github.com/metaplex-foundation/kinobi] //! -use crate::generated::types::ExternalPluginKey; +use crate::generated::types::ExternalPluginAdapterKey; #[cfg(feature = "anchor")] use anchor_lang::prelude::{AnchorDeserialize, AnchorSerialize}; #[cfg(not(feature = "anchor"))] use borsh::{BorshDeserialize, BorshSerialize}; /// Accounts. -pub struct RemoveCollectionExternalPluginV1 { +pub struct RemoveCollectionExternalPluginAdapterV1 { /// The address of the asset pub collection: solana_program::pubkey::Pubkey, /// The account paying for the storage fees @@ -25,17 +25,17 @@ pub struct RemoveCollectionExternalPluginV1 { pub log_wrapper: Option, } -impl RemoveCollectionExternalPluginV1 { +impl RemoveCollectionExternalPluginAdapterV1 { pub fn instruction( &self, - args: RemoveCollectionExternalPluginV1InstructionArgs, + args: RemoveCollectionExternalPluginAdapterV1InstructionArgs, ) -> solana_program::instruction::Instruction { self.instruction_with_remaining_accounts(args, &[]) } #[allow(clippy::vec_init_then_push)] pub fn instruction_with_remaining_accounts( &self, - args: RemoveCollectionExternalPluginV1InstructionArgs, + args: RemoveCollectionExternalPluginAdapterV1InstructionArgs, remaining_accounts: &[solana_program::instruction::AccountMeta], ) -> solana_program::instruction::Instruction { let mut accounts = Vec::with_capacity(5 + remaining_accounts.len()); @@ -72,7 +72,7 @@ impl RemoveCollectionExternalPluginV1 { )); } accounts.extend_from_slice(remaining_accounts); - let mut data = RemoveCollectionExternalPluginV1InstructionData::new() + let mut data = RemoveCollectionExternalPluginAdapterV1InstructionData::new() .try_to_vec() .unwrap(); let mut args = args.try_to_vec().unwrap(); @@ -88,11 +88,11 @@ impl RemoveCollectionExternalPluginV1 { #[cfg_attr(not(feature = "anchor"), derive(BorshSerialize, BorshDeserialize))] #[cfg_attr(feature = "anchor", derive(AnchorSerialize, AnchorDeserialize))] -pub struct RemoveCollectionExternalPluginV1InstructionData { +pub struct RemoveCollectionExternalPluginAdapterV1InstructionData { discriminator: u8, } -impl RemoveCollectionExternalPluginV1InstructionData { +impl RemoveCollectionExternalPluginAdapterV1InstructionData { pub fn new() -> Self { Self { discriminator: 25 } } @@ -102,11 +102,11 @@ impl RemoveCollectionExternalPluginV1InstructionData { #[cfg_attr(feature = "anchor", derive(AnchorSerialize, AnchorDeserialize))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Debug, Eq, PartialEq)] -pub struct RemoveCollectionExternalPluginV1InstructionArgs { - pub key: ExternalPluginKey, +pub struct RemoveCollectionExternalPluginAdapterV1InstructionArgs { + pub key: ExternalPluginAdapterKey, } -/// Instruction builder for `RemoveCollectionExternalPluginV1`. +/// Instruction builder for `RemoveCollectionExternalPluginAdapterV1`. /// /// ### Accounts: /// @@ -116,17 +116,17 @@ pub struct RemoveCollectionExternalPluginV1InstructionArgs { /// 3. `[optional]` system_program (default to `11111111111111111111111111111111`) /// 4. `[optional]` log_wrapper #[derive(Default)] -pub struct RemoveCollectionExternalPluginV1Builder { +pub struct RemoveCollectionExternalPluginAdapterV1Builder { collection: Option, payer: Option, authority: Option, system_program: Option, log_wrapper: Option, - key: Option, + key: Option, __remaining_accounts: Vec, } -impl RemoveCollectionExternalPluginV1Builder { +impl RemoveCollectionExternalPluginAdapterV1Builder { pub fn new() -> Self { Self::default() } @@ -167,7 +167,7 @@ impl RemoveCollectionExternalPluginV1Builder { self } #[inline(always)] - pub fn key(&mut self, key: ExternalPluginKey) -> &mut Self { + pub fn key(&mut self, key: ExternalPluginAdapterKey) -> &mut Self { self.key = Some(key); self } @@ -191,7 +191,7 @@ impl RemoveCollectionExternalPluginV1Builder { } #[allow(clippy::clone_on_copy)] pub fn instruction(&self) -> solana_program::instruction::Instruction { - let accounts = RemoveCollectionExternalPluginV1 { + let accounts = RemoveCollectionExternalPluginAdapterV1 { collection: self.collection.expect("collection is not set"), payer: self.payer.expect("payer is not set"), authority: self.authority, @@ -200,7 +200,7 @@ impl RemoveCollectionExternalPluginV1Builder { .unwrap_or(solana_program::pubkey!("11111111111111111111111111111111")), log_wrapper: self.log_wrapper, }; - let args = RemoveCollectionExternalPluginV1InstructionArgs { + let args = RemoveCollectionExternalPluginAdapterV1InstructionArgs { key: self.key.clone().expect("key is not set"), }; @@ -208,8 +208,8 @@ impl RemoveCollectionExternalPluginV1Builder { } } -/// `remove_collection_external_plugin_v1` CPI accounts. -pub struct RemoveCollectionExternalPluginV1CpiAccounts<'a, 'b> { +/// `remove_collection_external_plugin_adapter_v1` CPI accounts. +pub struct RemoveCollectionExternalPluginAdapterV1CpiAccounts<'a, 'b> { /// The address of the asset pub collection: &'b solana_program::account_info::AccountInfo<'a>, /// The account paying for the storage fees @@ -222,8 +222,8 @@ pub struct RemoveCollectionExternalPluginV1CpiAccounts<'a, 'b> { pub log_wrapper: Option<&'b solana_program::account_info::AccountInfo<'a>>, } -/// `remove_collection_external_plugin_v1` CPI instruction. -pub struct RemoveCollectionExternalPluginV1Cpi<'a, 'b> { +/// `remove_collection_external_plugin_adapter_v1` CPI instruction. +pub struct RemoveCollectionExternalPluginAdapterV1Cpi<'a, 'b> { /// The program to invoke. pub __program: &'b solana_program::account_info::AccountInfo<'a>, /// The address of the asset @@ -237,14 +237,14 @@ pub struct RemoveCollectionExternalPluginV1Cpi<'a, 'b> { /// The SPL Noop Program pub log_wrapper: Option<&'b solana_program::account_info::AccountInfo<'a>>, /// The arguments for the instruction. - pub __args: RemoveCollectionExternalPluginV1InstructionArgs, + pub __args: RemoveCollectionExternalPluginAdapterV1InstructionArgs, } -impl<'a, 'b> RemoveCollectionExternalPluginV1Cpi<'a, 'b> { +impl<'a, 'b> RemoveCollectionExternalPluginAdapterV1Cpi<'a, 'b> { pub fn new( program: &'b solana_program::account_info::AccountInfo<'a>, - accounts: RemoveCollectionExternalPluginV1CpiAccounts<'a, 'b>, - args: RemoveCollectionExternalPluginV1InstructionArgs, + accounts: RemoveCollectionExternalPluginAdapterV1CpiAccounts<'a, 'b>, + args: RemoveCollectionExternalPluginAdapterV1InstructionArgs, ) -> Self { Self { __program: program, @@ -331,7 +331,7 @@ impl<'a, 'b> RemoveCollectionExternalPluginV1Cpi<'a, 'b> { is_writable: remaining_account.2, }) }); - let mut data = RemoveCollectionExternalPluginV1InstructionData::new() + let mut data = RemoveCollectionExternalPluginAdapterV1InstructionData::new() .try_to_vec() .unwrap(); let mut args = self.__args.try_to_vec().unwrap(); @@ -365,7 +365,7 @@ impl<'a, 'b> RemoveCollectionExternalPluginV1Cpi<'a, 'b> { } } -/// Instruction builder for `RemoveCollectionExternalPluginV1` via CPI. +/// Instruction builder for `RemoveCollectionExternalPluginAdapterV1` via CPI. /// /// ### Accounts: /// @@ -374,22 +374,24 @@ impl<'a, 'b> RemoveCollectionExternalPluginV1Cpi<'a, 'b> { /// 2. `[signer, optional]` authority /// 3. `[]` system_program /// 4. `[optional]` log_wrapper -pub struct RemoveCollectionExternalPluginV1CpiBuilder<'a, 'b> { - instruction: Box>, +pub struct RemoveCollectionExternalPluginAdapterV1CpiBuilder<'a, 'b> { + instruction: Box>, } -impl<'a, 'b> RemoveCollectionExternalPluginV1CpiBuilder<'a, 'b> { +impl<'a, 'b> RemoveCollectionExternalPluginAdapterV1CpiBuilder<'a, 'b> { pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(RemoveCollectionExternalPluginV1CpiBuilderInstruction { - __program: program, - collection: None, - payer: None, - authority: None, - system_program: None, - log_wrapper: None, - key: None, - __remaining_accounts: Vec::new(), - }); + let instruction = Box::new( + RemoveCollectionExternalPluginAdapterV1CpiBuilderInstruction { + __program: program, + collection: None, + payer: None, + authority: None, + system_program: None, + log_wrapper: None, + key: None, + __remaining_accounts: Vec::new(), + }, + ); Self { instruction } } /// The address of the asset @@ -437,7 +439,7 @@ impl<'a, 'b> RemoveCollectionExternalPluginV1CpiBuilder<'a, 'b> { self } #[inline(always)] - pub fn key(&mut self, key: ExternalPluginKey) -> &mut Self { + pub fn key(&mut self, key: ExternalPluginAdapterKey) -> &mut Self { self.instruction.key = Some(key); self } @@ -482,10 +484,10 @@ impl<'a, 'b> RemoveCollectionExternalPluginV1CpiBuilder<'a, 'b> { &self, signers_seeds: &[&[&[u8]]], ) -> solana_program::entrypoint::ProgramResult { - let args = RemoveCollectionExternalPluginV1InstructionArgs { + let args = RemoveCollectionExternalPluginAdapterV1InstructionArgs { key: self.instruction.key.clone().expect("key is not set"), }; - let instruction = RemoveCollectionExternalPluginV1Cpi { + let instruction = RemoveCollectionExternalPluginAdapterV1Cpi { __program: self.instruction.__program, collection: self.instruction.collection.expect("collection is not set"), @@ -509,14 +511,14 @@ impl<'a, 'b> RemoveCollectionExternalPluginV1CpiBuilder<'a, 'b> { } } -struct RemoveCollectionExternalPluginV1CpiBuilderInstruction<'a, 'b> { +struct RemoveCollectionExternalPluginAdapterV1CpiBuilderInstruction<'a, 'b> { __program: &'b solana_program::account_info::AccountInfo<'a>, collection: Option<&'b solana_program::account_info::AccountInfo<'a>>, payer: Option<&'b solana_program::account_info::AccountInfo<'a>>, authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, system_program: Option<&'b solana_program::account_info::AccountInfo<'a>>, log_wrapper: Option<&'b solana_program::account_info::AccountInfo<'a>>, - key: Option, + key: Option, /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. __remaining_accounts: Vec<( &'b solana_program::account_info::AccountInfo<'a>, diff --git a/clients/rust/src/generated/instructions/remove_external_plugin_v1.rs b/clients/rust/src/generated/instructions/remove_external_plugin_adapter_v1.rs similarity index 89% rename from clients/rust/src/generated/instructions/remove_external_plugin_v1.rs rename to clients/rust/src/generated/instructions/remove_external_plugin_adapter_v1.rs index 106f9cf6..4e027b85 100644 --- a/clients/rust/src/generated/instructions/remove_external_plugin_v1.rs +++ b/clients/rust/src/generated/instructions/remove_external_plugin_adapter_v1.rs @@ -5,14 +5,14 @@ //! [https://github.com/metaplex-foundation/kinobi] //! -use crate::generated::types::ExternalPluginKey; +use crate::generated::types::ExternalPluginAdapterKey; #[cfg(feature = "anchor")] use anchor_lang::prelude::{AnchorDeserialize, AnchorSerialize}; #[cfg(not(feature = "anchor"))] use borsh::{BorshDeserialize, BorshSerialize}; /// Accounts. -pub struct RemoveExternalPluginV1 { +pub struct RemoveExternalPluginAdapterV1 { /// The address of the asset pub asset: solana_program::pubkey::Pubkey, /// The collection to which the asset belongs @@ -27,17 +27,17 @@ pub struct RemoveExternalPluginV1 { pub log_wrapper: Option, } -impl RemoveExternalPluginV1 { +impl RemoveExternalPluginAdapterV1 { pub fn instruction( &self, - args: RemoveExternalPluginV1InstructionArgs, + args: RemoveExternalPluginAdapterV1InstructionArgs, ) -> solana_program::instruction::Instruction { self.instruction_with_remaining_accounts(args, &[]) } #[allow(clippy::vec_init_then_push)] pub fn instruction_with_remaining_accounts( &self, - args: RemoveExternalPluginV1InstructionArgs, + args: RemoveExternalPluginAdapterV1InstructionArgs, remaining_accounts: &[solana_program::instruction::AccountMeta], ) -> solana_program::instruction::Instruction { let mut accounts = Vec::with_capacity(6 + remaining_accounts.len()); @@ -83,7 +83,7 @@ impl RemoveExternalPluginV1 { )); } accounts.extend_from_slice(remaining_accounts); - let mut data = RemoveExternalPluginV1InstructionData::new() + let mut data = RemoveExternalPluginAdapterV1InstructionData::new() .try_to_vec() .unwrap(); let mut args = args.try_to_vec().unwrap(); @@ -99,11 +99,11 @@ impl RemoveExternalPluginV1 { #[cfg_attr(not(feature = "anchor"), derive(BorshSerialize, BorshDeserialize))] #[cfg_attr(feature = "anchor", derive(AnchorSerialize, AnchorDeserialize))] -pub struct RemoveExternalPluginV1InstructionData { +pub struct RemoveExternalPluginAdapterV1InstructionData { discriminator: u8, } -impl RemoveExternalPluginV1InstructionData { +impl RemoveExternalPluginAdapterV1InstructionData { pub fn new() -> Self { Self { discriminator: 24 } } @@ -113,11 +113,11 @@ impl RemoveExternalPluginV1InstructionData { #[cfg_attr(feature = "anchor", derive(AnchorSerialize, AnchorDeserialize))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Debug, Eq, PartialEq)] -pub struct RemoveExternalPluginV1InstructionArgs { - pub key: ExternalPluginKey, +pub struct RemoveExternalPluginAdapterV1InstructionArgs { + pub key: ExternalPluginAdapterKey, } -/// Instruction builder for `RemoveExternalPluginV1`. +/// Instruction builder for `RemoveExternalPluginAdapterV1`. /// /// ### Accounts: /// @@ -128,18 +128,18 @@ pub struct RemoveExternalPluginV1InstructionArgs { /// 4. `[optional]` system_program (default to `11111111111111111111111111111111`) /// 5. `[optional]` log_wrapper #[derive(Default)] -pub struct RemoveExternalPluginV1Builder { +pub struct RemoveExternalPluginAdapterV1Builder { asset: Option, collection: Option, payer: Option, authority: Option, system_program: Option, log_wrapper: Option, - key: Option, + key: Option, __remaining_accounts: Vec, } -impl RemoveExternalPluginV1Builder { +impl RemoveExternalPluginAdapterV1Builder { pub fn new() -> Self { Self::default() } @@ -187,7 +187,7 @@ impl RemoveExternalPluginV1Builder { self } #[inline(always)] - pub fn key(&mut self, key: ExternalPluginKey) -> &mut Self { + pub fn key(&mut self, key: ExternalPluginAdapterKey) -> &mut Self { self.key = Some(key); self } @@ -211,7 +211,7 @@ impl RemoveExternalPluginV1Builder { } #[allow(clippy::clone_on_copy)] pub fn instruction(&self) -> solana_program::instruction::Instruction { - let accounts = RemoveExternalPluginV1 { + let accounts = RemoveExternalPluginAdapterV1 { asset: self.asset.expect("asset is not set"), collection: self.collection, payer: self.payer.expect("payer is not set"), @@ -221,7 +221,7 @@ impl RemoveExternalPluginV1Builder { .unwrap_or(solana_program::pubkey!("11111111111111111111111111111111")), log_wrapper: self.log_wrapper, }; - let args = RemoveExternalPluginV1InstructionArgs { + let args = RemoveExternalPluginAdapterV1InstructionArgs { key: self.key.clone().expect("key is not set"), }; @@ -229,8 +229,8 @@ impl RemoveExternalPluginV1Builder { } } -/// `remove_external_plugin_v1` CPI accounts. -pub struct RemoveExternalPluginV1CpiAccounts<'a, 'b> { +/// `remove_external_plugin_adapter_v1` CPI accounts. +pub struct RemoveExternalPluginAdapterV1CpiAccounts<'a, 'b> { /// The address of the asset pub asset: &'b solana_program::account_info::AccountInfo<'a>, /// The collection to which the asset belongs @@ -245,8 +245,8 @@ pub struct RemoveExternalPluginV1CpiAccounts<'a, 'b> { pub log_wrapper: Option<&'b solana_program::account_info::AccountInfo<'a>>, } -/// `remove_external_plugin_v1` CPI instruction. -pub struct RemoveExternalPluginV1Cpi<'a, 'b> { +/// `remove_external_plugin_adapter_v1` CPI instruction. +pub struct RemoveExternalPluginAdapterV1Cpi<'a, 'b> { /// The program to invoke. pub __program: &'b solana_program::account_info::AccountInfo<'a>, /// The address of the asset @@ -262,14 +262,14 @@ pub struct RemoveExternalPluginV1Cpi<'a, 'b> { /// The SPL Noop Program pub log_wrapper: Option<&'b solana_program::account_info::AccountInfo<'a>>, /// The arguments for the instruction. - pub __args: RemoveExternalPluginV1InstructionArgs, + pub __args: RemoveExternalPluginAdapterV1InstructionArgs, } -impl<'a, 'b> RemoveExternalPluginV1Cpi<'a, 'b> { +impl<'a, 'b> RemoveExternalPluginAdapterV1Cpi<'a, 'b> { pub fn new( program: &'b solana_program::account_info::AccountInfo<'a>, - accounts: RemoveExternalPluginV1CpiAccounts<'a, 'b>, - args: RemoveExternalPluginV1InstructionArgs, + accounts: RemoveExternalPluginAdapterV1CpiAccounts<'a, 'b>, + args: RemoveExternalPluginAdapterV1InstructionArgs, ) -> Self { Self { __program: program, @@ -368,7 +368,7 @@ impl<'a, 'b> RemoveExternalPluginV1Cpi<'a, 'b> { is_writable: remaining_account.2, }) }); - let mut data = RemoveExternalPluginV1InstructionData::new() + let mut data = RemoveExternalPluginAdapterV1InstructionData::new() .try_to_vec() .unwrap(); let mut args = self.__args.try_to_vec().unwrap(); @@ -405,7 +405,7 @@ impl<'a, 'b> RemoveExternalPluginV1Cpi<'a, 'b> { } } -/// Instruction builder for `RemoveExternalPluginV1` via CPI. +/// Instruction builder for `RemoveExternalPluginAdapterV1` via CPI. /// /// ### Accounts: /// @@ -415,13 +415,13 @@ impl<'a, 'b> RemoveExternalPluginV1Cpi<'a, 'b> { /// 3. `[signer, optional]` authority /// 4. `[]` system_program /// 5. `[optional]` log_wrapper -pub struct RemoveExternalPluginV1CpiBuilder<'a, 'b> { - instruction: Box>, +pub struct RemoveExternalPluginAdapterV1CpiBuilder<'a, 'b> { + instruction: Box>, } -impl<'a, 'b> RemoveExternalPluginV1CpiBuilder<'a, 'b> { +impl<'a, 'b> RemoveExternalPluginAdapterV1CpiBuilder<'a, 'b> { pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(RemoveExternalPluginV1CpiBuilderInstruction { + let instruction = Box::new(RemoveExternalPluginAdapterV1CpiBuilderInstruction { __program: program, asset: None, collection: None, @@ -486,7 +486,7 @@ impl<'a, 'b> RemoveExternalPluginV1CpiBuilder<'a, 'b> { self } #[inline(always)] - pub fn key(&mut self, key: ExternalPluginKey) -> &mut Self { + pub fn key(&mut self, key: ExternalPluginAdapterKey) -> &mut Self { self.instruction.key = Some(key); self } @@ -531,10 +531,10 @@ impl<'a, 'b> RemoveExternalPluginV1CpiBuilder<'a, 'b> { &self, signers_seeds: &[&[&[u8]]], ) -> solana_program::entrypoint::ProgramResult { - let args = RemoveExternalPluginV1InstructionArgs { + let args = RemoveExternalPluginAdapterV1InstructionArgs { key: self.instruction.key.clone().expect("key is not set"), }; - let instruction = RemoveExternalPluginV1Cpi { + let instruction = RemoveExternalPluginAdapterV1Cpi { __program: self.instruction.__program, asset: self.instruction.asset.expect("asset is not set"), @@ -560,7 +560,7 @@ impl<'a, 'b> RemoveExternalPluginV1CpiBuilder<'a, 'b> { } } -struct RemoveExternalPluginV1CpiBuilderInstruction<'a, 'b> { +struct RemoveExternalPluginAdapterV1CpiBuilderInstruction<'a, 'b> { __program: &'b solana_program::account_info::AccountInfo<'a>, asset: Option<&'b solana_program::account_info::AccountInfo<'a>>, collection: Option<&'b solana_program::account_info::AccountInfo<'a>>, @@ -568,7 +568,7 @@ struct RemoveExternalPluginV1CpiBuilderInstruction<'a, 'b> { authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, system_program: Option<&'b solana_program::account_info::AccountInfo<'a>>, log_wrapper: Option<&'b solana_program::account_info::AccountInfo<'a>>, - key: Option, + key: Option, /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. __remaining_accounts: Vec<( &'b solana_program::account_info::AccountInfo<'a>, diff --git a/clients/rust/src/generated/instructions/update_collection_external_plugin_v1.rs b/clients/rust/src/generated/instructions/update_collection_external_plugin_adapter_v1.rs similarity index 84% rename from clients/rust/src/generated/instructions/update_collection_external_plugin_v1.rs rename to clients/rust/src/generated/instructions/update_collection_external_plugin_adapter_v1.rs index 8e1a3f2b..bc396088 100644 --- a/clients/rust/src/generated/instructions/update_collection_external_plugin_v1.rs +++ b/clients/rust/src/generated/instructions/update_collection_external_plugin_adapter_v1.rs @@ -5,15 +5,15 @@ //! [https://github.com/metaplex-foundation/kinobi] //! -use crate::generated::types::ExternalPluginKey; -use crate::generated::types::ExternalPluginUpdateInfo; +use crate::generated::types::ExternalPluginAdapterKey; +use crate::generated::types::ExternalPluginAdapterUpdateInfo; #[cfg(feature = "anchor")] use anchor_lang::prelude::{AnchorDeserialize, AnchorSerialize}; #[cfg(not(feature = "anchor"))] use borsh::{BorshDeserialize, BorshSerialize}; /// Accounts. -pub struct UpdateCollectionExternalPluginV1 { +pub struct UpdateCollectionExternalPluginAdapterV1 { /// The address of the asset pub collection: solana_program::pubkey::Pubkey, /// The account paying for the storage fees @@ -26,17 +26,17 @@ pub struct UpdateCollectionExternalPluginV1 { pub log_wrapper: Option, } -impl UpdateCollectionExternalPluginV1 { +impl UpdateCollectionExternalPluginAdapterV1 { pub fn instruction( &self, - args: UpdateCollectionExternalPluginV1InstructionArgs, + args: UpdateCollectionExternalPluginAdapterV1InstructionArgs, ) -> solana_program::instruction::Instruction { self.instruction_with_remaining_accounts(args, &[]) } #[allow(clippy::vec_init_then_push)] pub fn instruction_with_remaining_accounts( &self, - args: UpdateCollectionExternalPluginV1InstructionArgs, + args: UpdateCollectionExternalPluginAdapterV1InstructionArgs, remaining_accounts: &[solana_program::instruction::AccountMeta], ) -> solana_program::instruction::Instruction { let mut accounts = Vec::with_capacity(5 + remaining_accounts.len()); @@ -73,7 +73,7 @@ impl UpdateCollectionExternalPluginV1 { )); } accounts.extend_from_slice(remaining_accounts); - let mut data = UpdateCollectionExternalPluginV1InstructionData::new() + let mut data = UpdateCollectionExternalPluginAdapterV1InstructionData::new() .try_to_vec() .unwrap(); let mut args = args.try_to_vec().unwrap(); @@ -89,11 +89,11 @@ impl UpdateCollectionExternalPluginV1 { #[cfg_attr(not(feature = "anchor"), derive(BorshSerialize, BorshDeserialize))] #[cfg_attr(feature = "anchor", derive(AnchorSerialize, AnchorDeserialize))] -pub struct UpdateCollectionExternalPluginV1InstructionData { +pub struct UpdateCollectionExternalPluginAdapterV1InstructionData { discriminator: u8, } -impl UpdateCollectionExternalPluginV1InstructionData { +impl UpdateCollectionExternalPluginAdapterV1InstructionData { pub fn new() -> Self { Self { discriminator: 27 } } @@ -103,12 +103,12 @@ impl UpdateCollectionExternalPluginV1InstructionData { #[cfg_attr(feature = "anchor", derive(AnchorSerialize, AnchorDeserialize))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Debug, Eq, PartialEq)] -pub struct UpdateCollectionExternalPluginV1InstructionArgs { - pub key: ExternalPluginKey, - pub update_info: ExternalPluginUpdateInfo, +pub struct UpdateCollectionExternalPluginAdapterV1InstructionArgs { + pub key: ExternalPluginAdapterKey, + pub update_info: ExternalPluginAdapterUpdateInfo, } -/// Instruction builder for `UpdateCollectionExternalPluginV1`. +/// Instruction builder for `UpdateCollectionExternalPluginAdapterV1`. /// /// ### Accounts: /// @@ -118,18 +118,18 @@ pub struct UpdateCollectionExternalPluginV1InstructionArgs { /// 3. `[optional]` system_program (default to `11111111111111111111111111111111`) /// 4. `[optional]` log_wrapper #[derive(Default)] -pub struct UpdateCollectionExternalPluginV1Builder { +pub struct UpdateCollectionExternalPluginAdapterV1Builder { collection: Option, payer: Option, authority: Option, system_program: Option, log_wrapper: Option, - key: Option, - update_info: Option, + key: Option, + update_info: Option, __remaining_accounts: Vec, } -impl UpdateCollectionExternalPluginV1Builder { +impl UpdateCollectionExternalPluginAdapterV1Builder { pub fn new() -> Self { Self::default() } @@ -170,12 +170,12 @@ impl UpdateCollectionExternalPluginV1Builder { self } #[inline(always)] - pub fn key(&mut self, key: ExternalPluginKey) -> &mut Self { + pub fn key(&mut self, key: ExternalPluginAdapterKey) -> &mut Self { self.key = Some(key); self } #[inline(always)] - pub fn update_info(&mut self, update_info: ExternalPluginUpdateInfo) -> &mut Self { + pub fn update_info(&mut self, update_info: ExternalPluginAdapterUpdateInfo) -> &mut Self { self.update_info = Some(update_info); self } @@ -199,7 +199,7 @@ impl UpdateCollectionExternalPluginV1Builder { } #[allow(clippy::clone_on_copy)] pub fn instruction(&self) -> solana_program::instruction::Instruction { - let accounts = UpdateCollectionExternalPluginV1 { + let accounts = UpdateCollectionExternalPluginAdapterV1 { collection: self.collection.expect("collection is not set"), payer: self.payer.expect("payer is not set"), authority: self.authority, @@ -208,7 +208,7 @@ impl UpdateCollectionExternalPluginV1Builder { .unwrap_or(solana_program::pubkey!("11111111111111111111111111111111")), log_wrapper: self.log_wrapper, }; - let args = UpdateCollectionExternalPluginV1InstructionArgs { + let args = UpdateCollectionExternalPluginAdapterV1InstructionArgs { key: self.key.clone().expect("key is not set"), update_info: self.update_info.clone().expect("update_info is not set"), }; @@ -217,8 +217,8 @@ impl UpdateCollectionExternalPluginV1Builder { } } -/// `update_collection_external_plugin_v1` CPI accounts. -pub struct UpdateCollectionExternalPluginV1CpiAccounts<'a, 'b> { +/// `update_collection_external_plugin_adapter_v1` CPI accounts. +pub struct UpdateCollectionExternalPluginAdapterV1CpiAccounts<'a, 'b> { /// The address of the asset pub collection: &'b solana_program::account_info::AccountInfo<'a>, /// The account paying for the storage fees @@ -231,8 +231,8 @@ pub struct UpdateCollectionExternalPluginV1CpiAccounts<'a, 'b> { pub log_wrapper: Option<&'b solana_program::account_info::AccountInfo<'a>>, } -/// `update_collection_external_plugin_v1` CPI instruction. -pub struct UpdateCollectionExternalPluginV1Cpi<'a, 'b> { +/// `update_collection_external_plugin_adapter_v1` CPI instruction. +pub struct UpdateCollectionExternalPluginAdapterV1Cpi<'a, 'b> { /// The program to invoke. pub __program: &'b solana_program::account_info::AccountInfo<'a>, /// The address of the asset @@ -246,14 +246,14 @@ pub struct UpdateCollectionExternalPluginV1Cpi<'a, 'b> { /// The SPL Noop Program pub log_wrapper: Option<&'b solana_program::account_info::AccountInfo<'a>>, /// The arguments for the instruction. - pub __args: UpdateCollectionExternalPluginV1InstructionArgs, + pub __args: UpdateCollectionExternalPluginAdapterV1InstructionArgs, } -impl<'a, 'b> UpdateCollectionExternalPluginV1Cpi<'a, 'b> { +impl<'a, 'b> UpdateCollectionExternalPluginAdapterV1Cpi<'a, 'b> { pub fn new( program: &'b solana_program::account_info::AccountInfo<'a>, - accounts: UpdateCollectionExternalPluginV1CpiAccounts<'a, 'b>, - args: UpdateCollectionExternalPluginV1InstructionArgs, + accounts: UpdateCollectionExternalPluginAdapterV1CpiAccounts<'a, 'b>, + args: UpdateCollectionExternalPluginAdapterV1InstructionArgs, ) -> Self { Self { __program: program, @@ -340,7 +340,7 @@ impl<'a, 'b> UpdateCollectionExternalPluginV1Cpi<'a, 'b> { is_writable: remaining_account.2, }) }); - let mut data = UpdateCollectionExternalPluginV1InstructionData::new() + let mut data = UpdateCollectionExternalPluginAdapterV1InstructionData::new() .try_to_vec() .unwrap(); let mut args = self.__args.try_to_vec().unwrap(); @@ -374,7 +374,7 @@ impl<'a, 'b> UpdateCollectionExternalPluginV1Cpi<'a, 'b> { } } -/// Instruction builder for `UpdateCollectionExternalPluginV1` via CPI. +/// Instruction builder for `UpdateCollectionExternalPluginAdapterV1` via CPI. /// /// ### Accounts: /// @@ -383,23 +383,25 @@ impl<'a, 'b> UpdateCollectionExternalPluginV1Cpi<'a, 'b> { /// 2. `[signer, optional]` authority /// 3. `[]` system_program /// 4. `[optional]` log_wrapper -pub struct UpdateCollectionExternalPluginV1CpiBuilder<'a, 'b> { - instruction: Box>, +pub struct UpdateCollectionExternalPluginAdapterV1CpiBuilder<'a, 'b> { + instruction: Box>, } -impl<'a, 'b> UpdateCollectionExternalPluginV1CpiBuilder<'a, 'b> { +impl<'a, 'b> UpdateCollectionExternalPluginAdapterV1CpiBuilder<'a, 'b> { pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(UpdateCollectionExternalPluginV1CpiBuilderInstruction { - __program: program, - collection: None, - payer: None, - authority: None, - system_program: None, - log_wrapper: None, - key: None, - update_info: None, - __remaining_accounts: Vec::new(), - }); + let instruction = Box::new( + UpdateCollectionExternalPluginAdapterV1CpiBuilderInstruction { + __program: program, + collection: None, + payer: None, + authority: None, + system_program: None, + log_wrapper: None, + key: None, + update_info: None, + __remaining_accounts: Vec::new(), + }, + ); Self { instruction } } /// The address of the asset @@ -447,12 +449,12 @@ impl<'a, 'b> UpdateCollectionExternalPluginV1CpiBuilder<'a, 'b> { self } #[inline(always)] - pub fn key(&mut self, key: ExternalPluginKey) -> &mut Self { + pub fn key(&mut self, key: ExternalPluginAdapterKey) -> &mut Self { self.instruction.key = Some(key); self } #[inline(always)] - pub fn update_info(&mut self, update_info: ExternalPluginUpdateInfo) -> &mut Self { + pub fn update_info(&mut self, update_info: ExternalPluginAdapterUpdateInfo) -> &mut Self { self.instruction.update_info = Some(update_info); self } @@ -497,7 +499,7 @@ impl<'a, 'b> UpdateCollectionExternalPluginV1CpiBuilder<'a, 'b> { &self, signers_seeds: &[&[&[u8]]], ) -> solana_program::entrypoint::ProgramResult { - let args = UpdateCollectionExternalPluginV1InstructionArgs { + let args = UpdateCollectionExternalPluginAdapterV1InstructionArgs { key: self.instruction.key.clone().expect("key is not set"), update_info: self .instruction @@ -505,7 +507,7 @@ impl<'a, 'b> UpdateCollectionExternalPluginV1CpiBuilder<'a, 'b> { .clone() .expect("update_info is not set"), }; - let instruction = UpdateCollectionExternalPluginV1Cpi { + let instruction = UpdateCollectionExternalPluginAdapterV1Cpi { __program: self.instruction.__program, collection: self.instruction.collection.expect("collection is not set"), @@ -529,15 +531,15 @@ impl<'a, 'b> UpdateCollectionExternalPluginV1CpiBuilder<'a, 'b> { } } -struct UpdateCollectionExternalPluginV1CpiBuilderInstruction<'a, 'b> { +struct UpdateCollectionExternalPluginAdapterV1CpiBuilderInstruction<'a, 'b> { __program: &'b solana_program::account_info::AccountInfo<'a>, collection: Option<&'b solana_program::account_info::AccountInfo<'a>>, payer: Option<&'b solana_program::account_info::AccountInfo<'a>>, authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, system_program: Option<&'b solana_program::account_info::AccountInfo<'a>>, log_wrapper: Option<&'b solana_program::account_info::AccountInfo<'a>>, - key: Option, - update_info: Option, + key: Option, + update_info: Option, /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. __remaining_accounts: Vec<( &'b solana_program::account_info::AccountInfo<'a>, diff --git a/clients/rust/src/generated/instructions/update_external_plugin_v1.rs b/clients/rust/src/generated/instructions/update_external_plugin_adapter_v1.rs similarity index 88% rename from clients/rust/src/generated/instructions/update_external_plugin_v1.rs rename to clients/rust/src/generated/instructions/update_external_plugin_adapter_v1.rs index 09faadb6..d55b2934 100644 --- a/clients/rust/src/generated/instructions/update_external_plugin_v1.rs +++ b/clients/rust/src/generated/instructions/update_external_plugin_adapter_v1.rs @@ -5,15 +5,15 @@ //! [https://github.com/metaplex-foundation/kinobi] //! -use crate::generated::types::ExternalPluginKey; -use crate::generated::types::ExternalPluginUpdateInfo; +use crate::generated::types::ExternalPluginAdapterKey; +use crate::generated::types::ExternalPluginAdapterUpdateInfo; #[cfg(feature = "anchor")] use anchor_lang::prelude::{AnchorDeserialize, AnchorSerialize}; #[cfg(not(feature = "anchor"))] use borsh::{BorshDeserialize, BorshSerialize}; /// Accounts. -pub struct UpdateExternalPluginV1 { +pub struct UpdateExternalPluginAdapterV1 { /// The address of the asset pub asset: solana_program::pubkey::Pubkey, /// The collection to which the asset belongs @@ -28,17 +28,17 @@ pub struct UpdateExternalPluginV1 { pub log_wrapper: Option, } -impl UpdateExternalPluginV1 { +impl UpdateExternalPluginAdapterV1 { pub fn instruction( &self, - args: UpdateExternalPluginV1InstructionArgs, + args: UpdateExternalPluginAdapterV1InstructionArgs, ) -> solana_program::instruction::Instruction { self.instruction_with_remaining_accounts(args, &[]) } #[allow(clippy::vec_init_then_push)] pub fn instruction_with_remaining_accounts( &self, - args: UpdateExternalPluginV1InstructionArgs, + args: UpdateExternalPluginAdapterV1InstructionArgs, remaining_accounts: &[solana_program::instruction::AccountMeta], ) -> solana_program::instruction::Instruction { let mut accounts = Vec::with_capacity(6 + remaining_accounts.len()); @@ -84,7 +84,7 @@ impl UpdateExternalPluginV1 { )); } accounts.extend_from_slice(remaining_accounts); - let mut data = UpdateExternalPluginV1InstructionData::new() + let mut data = UpdateExternalPluginAdapterV1InstructionData::new() .try_to_vec() .unwrap(); let mut args = args.try_to_vec().unwrap(); @@ -100,11 +100,11 @@ impl UpdateExternalPluginV1 { #[cfg_attr(not(feature = "anchor"), derive(BorshSerialize, BorshDeserialize))] #[cfg_attr(feature = "anchor", derive(AnchorSerialize, AnchorDeserialize))] -pub struct UpdateExternalPluginV1InstructionData { +pub struct UpdateExternalPluginAdapterV1InstructionData { discriminator: u8, } -impl UpdateExternalPluginV1InstructionData { +impl UpdateExternalPluginAdapterV1InstructionData { pub fn new() -> Self { Self { discriminator: 26 } } @@ -114,12 +114,12 @@ impl UpdateExternalPluginV1InstructionData { #[cfg_attr(feature = "anchor", derive(AnchorSerialize, AnchorDeserialize))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Debug, Eq, PartialEq)] -pub struct UpdateExternalPluginV1InstructionArgs { - pub key: ExternalPluginKey, - pub update_info: ExternalPluginUpdateInfo, +pub struct UpdateExternalPluginAdapterV1InstructionArgs { + pub key: ExternalPluginAdapterKey, + pub update_info: ExternalPluginAdapterUpdateInfo, } -/// Instruction builder for `UpdateExternalPluginV1`. +/// Instruction builder for `UpdateExternalPluginAdapterV1`. /// /// ### Accounts: /// @@ -130,19 +130,19 @@ pub struct UpdateExternalPluginV1InstructionArgs { /// 4. `[optional]` system_program (default to `11111111111111111111111111111111`) /// 5. `[optional]` log_wrapper #[derive(Default)] -pub struct UpdateExternalPluginV1Builder { +pub struct UpdateExternalPluginAdapterV1Builder { asset: Option, collection: Option, payer: Option, authority: Option, system_program: Option, log_wrapper: Option, - key: Option, - update_info: Option, + key: Option, + update_info: Option, __remaining_accounts: Vec, } -impl UpdateExternalPluginV1Builder { +impl UpdateExternalPluginAdapterV1Builder { pub fn new() -> Self { Self::default() } @@ -190,12 +190,12 @@ impl UpdateExternalPluginV1Builder { self } #[inline(always)] - pub fn key(&mut self, key: ExternalPluginKey) -> &mut Self { + pub fn key(&mut self, key: ExternalPluginAdapterKey) -> &mut Self { self.key = Some(key); self } #[inline(always)] - pub fn update_info(&mut self, update_info: ExternalPluginUpdateInfo) -> &mut Self { + pub fn update_info(&mut self, update_info: ExternalPluginAdapterUpdateInfo) -> &mut Self { self.update_info = Some(update_info); self } @@ -219,7 +219,7 @@ impl UpdateExternalPluginV1Builder { } #[allow(clippy::clone_on_copy)] pub fn instruction(&self) -> solana_program::instruction::Instruction { - let accounts = UpdateExternalPluginV1 { + let accounts = UpdateExternalPluginAdapterV1 { asset: self.asset.expect("asset is not set"), collection: self.collection, payer: self.payer.expect("payer is not set"), @@ -229,7 +229,7 @@ impl UpdateExternalPluginV1Builder { .unwrap_or(solana_program::pubkey!("11111111111111111111111111111111")), log_wrapper: self.log_wrapper, }; - let args = UpdateExternalPluginV1InstructionArgs { + let args = UpdateExternalPluginAdapterV1InstructionArgs { key: self.key.clone().expect("key is not set"), update_info: self.update_info.clone().expect("update_info is not set"), }; @@ -238,8 +238,8 @@ impl UpdateExternalPluginV1Builder { } } -/// `update_external_plugin_v1` CPI accounts. -pub struct UpdateExternalPluginV1CpiAccounts<'a, 'b> { +/// `update_external_plugin_adapter_v1` CPI accounts. +pub struct UpdateExternalPluginAdapterV1CpiAccounts<'a, 'b> { /// The address of the asset pub asset: &'b solana_program::account_info::AccountInfo<'a>, /// The collection to which the asset belongs @@ -254,8 +254,8 @@ pub struct UpdateExternalPluginV1CpiAccounts<'a, 'b> { pub log_wrapper: Option<&'b solana_program::account_info::AccountInfo<'a>>, } -/// `update_external_plugin_v1` CPI instruction. -pub struct UpdateExternalPluginV1Cpi<'a, 'b> { +/// `update_external_plugin_adapter_v1` CPI instruction. +pub struct UpdateExternalPluginAdapterV1Cpi<'a, 'b> { /// The program to invoke. pub __program: &'b solana_program::account_info::AccountInfo<'a>, /// The address of the asset @@ -271,14 +271,14 @@ pub struct UpdateExternalPluginV1Cpi<'a, 'b> { /// The SPL Noop Program pub log_wrapper: Option<&'b solana_program::account_info::AccountInfo<'a>>, /// The arguments for the instruction. - pub __args: UpdateExternalPluginV1InstructionArgs, + pub __args: UpdateExternalPluginAdapterV1InstructionArgs, } -impl<'a, 'b> UpdateExternalPluginV1Cpi<'a, 'b> { +impl<'a, 'b> UpdateExternalPluginAdapterV1Cpi<'a, 'b> { pub fn new( program: &'b solana_program::account_info::AccountInfo<'a>, - accounts: UpdateExternalPluginV1CpiAccounts<'a, 'b>, - args: UpdateExternalPluginV1InstructionArgs, + accounts: UpdateExternalPluginAdapterV1CpiAccounts<'a, 'b>, + args: UpdateExternalPluginAdapterV1InstructionArgs, ) -> Self { Self { __program: program, @@ -377,7 +377,7 @@ impl<'a, 'b> UpdateExternalPluginV1Cpi<'a, 'b> { is_writable: remaining_account.2, }) }); - let mut data = UpdateExternalPluginV1InstructionData::new() + let mut data = UpdateExternalPluginAdapterV1InstructionData::new() .try_to_vec() .unwrap(); let mut args = self.__args.try_to_vec().unwrap(); @@ -414,7 +414,7 @@ impl<'a, 'b> UpdateExternalPluginV1Cpi<'a, 'b> { } } -/// Instruction builder for `UpdateExternalPluginV1` via CPI. +/// Instruction builder for `UpdateExternalPluginAdapterV1` via CPI. /// /// ### Accounts: /// @@ -424,13 +424,13 @@ impl<'a, 'b> UpdateExternalPluginV1Cpi<'a, 'b> { /// 3. `[signer, optional]` authority /// 4. `[]` system_program /// 5. `[optional]` log_wrapper -pub struct UpdateExternalPluginV1CpiBuilder<'a, 'b> { - instruction: Box>, +pub struct UpdateExternalPluginAdapterV1CpiBuilder<'a, 'b> { + instruction: Box>, } -impl<'a, 'b> UpdateExternalPluginV1CpiBuilder<'a, 'b> { +impl<'a, 'b> UpdateExternalPluginAdapterV1CpiBuilder<'a, 'b> { pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(UpdateExternalPluginV1CpiBuilderInstruction { + let instruction = Box::new(UpdateExternalPluginAdapterV1CpiBuilderInstruction { __program: program, asset: None, collection: None, @@ -496,12 +496,12 @@ impl<'a, 'b> UpdateExternalPluginV1CpiBuilder<'a, 'b> { self } #[inline(always)] - pub fn key(&mut self, key: ExternalPluginKey) -> &mut Self { + pub fn key(&mut self, key: ExternalPluginAdapterKey) -> &mut Self { self.instruction.key = Some(key); self } #[inline(always)] - pub fn update_info(&mut self, update_info: ExternalPluginUpdateInfo) -> &mut Self { + pub fn update_info(&mut self, update_info: ExternalPluginAdapterUpdateInfo) -> &mut Self { self.instruction.update_info = Some(update_info); self } @@ -546,7 +546,7 @@ impl<'a, 'b> UpdateExternalPluginV1CpiBuilder<'a, 'b> { &self, signers_seeds: &[&[&[u8]]], ) -> solana_program::entrypoint::ProgramResult { - let args = UpdateExternalPluginV1InstructionArgs { + let args = UpdateExternalPluginAdapterV1InstructionArgs { key: self.instruction.key.clone().expect("key is not set"), update_info: self .instruction @@ -554,7 +554,7 @@ impl<'a, 'b> UpdateExternalPluginV1CpiBuilder<'a, 'b> { .clone() .expect("update_info is not set"), }; - let instruction = UpdateExternalPluginV1Cpi { + let instruction = UpdateExternalPluginAdapterV1Cpi { __program: self.instruction.__program, asset: self.instruction.asset.expect("asset is not set"), @@ -580,7 +580,7 @@ impl<'a, 'b> UpdateExternalPluginV1CpiBuilder<'a, 'b> { } } -struct UpdateExternalPluginV1CpiBuilderInstruction<'a, 'b> { +struct UpdateExternalPluginAdapterV1CpiBuilderInstruction<'a, 'b> { __program: &'b solana_program::account_info::AccountInfo<'a>, asset: Option<&'b solana_program::account_info::AccountInfo<'a>>, collection: Option<&'b solana_program::account_info::AccountInfo<'a>>, @@ -588,8 +588,8 @@ struct UpdateExternalPluginV1CpiBuilderInstruction<'a, 'b> { authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, system_program: Option<&'b solana_program::account_info::AccountInfo<'a>>, log_wrapper: Option<&'b solana_program::account_info::AccountInfo<'a>>, - key: Option, - update_info: Option, + key: Option, + update_info: Option, /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. __remaining_accounts: Vec<( &'b solana_program::account_info::AccountInfo<'a>, diff --git a/clients/rust/src/generated/instructions/write_collection_external_plugin_data_v1.rs b/clients/rust/src/generated/instructions/write_collection_external_plugin_adapter_data_v1.rs similarity index 83% rename from clients/rust/src/generated/instructions/write_collection_external_plugin_data_v1.rs rename to clients/rust/src/generated/instructions/write_collection_external_plugin_adapter_data_v1.rs index acf3f3cf..16bf3b74 100644 --- a/clients/rust/src/generated/instructions/write_collection_external_plugin_data_v1.rs +++ b/clients/rust/src/generated/instructions/write_collection_external_plugin_adapter_data_v1.rs @@ -5,19 +5,19 @@ //! [https://github.com/metaplex-foundation/kinobi] //! -use crate::generated::types::ExternalPluginKey; +use crate::generated::types::ExternalPluginAdapterKey; #[cfg(feature = "anchor")] use anchor_lang::prelude::{AnchorDeserialize, AnchorSerialize}; #[cfg(not(feature = "anchor"))] use borsh::{BorshDeserialize, BorshSerialize}; /// Accounts. -pub struct WriteCollectionExternalPluginDataV1 { +pub struct WriteCollectionExternalPluginAdapterDataV1 { /// The address of the asset pub collection: solana_program::pubkey::Pubkey, /// The account paying for the storage fees pub payer: solana_program::pubkey::Pubkey, - /// The Data Authority of the External Plugin + /// The Data Authority of the External PluginExternalPluginAdapter pub authority: Option, /// The system program pub system_program: solana_program::pubkey::Pubkey, @@ -25,17 +25,17 @@ pub struct WriteCollectionExternalPluginDataV1 { pub log_wrapper: Option, } -impl WriteCollectionExternalPluginDataV1 { +impl WriteCollectionExternalPluginAdapterDataV1 { pub fn instruction( &self, - args: WriteCollectionExternalPluginDataV1InstructionArgs, + args: WriteCollectionExternalPluginAdapterDataV1InstructionArgs, ) -> solana_program::instruction::Instruction { self.instruction_with_remaining_accounts(args, &[]) } #[allow(clippy::vec_init_then_push)] pub fn instruction_with_remaining_accounts( &self, - args: WriteCollectionExternalPluginDataV1InstructionArgs, + args: WriteCollectionExternalPluginAdapterDataV1InstructionArgs, remaining_accounts: &[solana_program::instruction::AccountMeta], ) -> solana_program::instruction::Instruction { let mut accounts = Vec::with_capacity(5 + remaining_accounts.len()); @@ -72,7 +72,7 @@ impl WriteCollectionExternalPluginDataV1 { )); } accounts.extend_from_slice(remaining_accounts); - let mut data = WriteCollectionExternalPluginDataV1InstructionData::new() + let mut data = WriteCollectionExternalPluginAdapterDataV1InstructionData::new() .try_to_vec() .unwrap(); let mut args = args.try_to_vec().unwrap(); @@ -88,11 +88,11 @@ impl WriteCollectionExternalPluginDataV1 { #[cfg_attr(not(feature = "anchor"), derive(BorshSerialize, BorshDeserialize))] #[cfg_attr(feature = "anchor", derive(AnchorSerialize, AnchorDeserialize))] -pub struct WriteCollectionExternalPluginDataV1InstructionData { +pub struct WriteCollectionExternalPluginAdapterDataV1InstructionData { discriminator: u8, } -impl WriteCollectionExternalPluginDataV1InstructionData { +impl WriteCollectionExternalPluginAdapterDataV1InstructionData { pub fn new() -> Self { Self { discriminator: 29 } } @@ -102,12 +102,12 @@ impl WriteCollectionExternalPluginDataV1InstructionData { #[cfg_attr(feature = "anchor", derive(AnchorSerialize, AnchorDeserialize))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Debug, Eq, PartialEq)] -pub struct WriteCollectionExternalPluginDataV1InstructionArgs { - pub key: ExternalPluginKey, +pub struct WriteCollectionExternalPluginAdapterDataV1InstructionArgs { + pub key: ExternalPluginAdapterKey, pub data: Vec, } -/// Instruction builder for `WriteCollectionExternalPluginDataV1`. +/// Instruction builder for `WriteCollectionExternalPluginAdapterDataV1`. /// /// ### Accounts: /// @@ -117,18 +117,18 @@ pub struct WriteCollectionExternalPluginDataV1InstructionArgs { /// 3. `[optional]` system_program (default to `11111111111111111111111111111111`) /// 4. `[optional]` log_wrapper #[derive(Default)] -pub struct WriteCollectionExternalPluginDataV1Builder { +pub struct WriteCollectionExternalPluginAdapterDataV1Builder { collection: Option, payer: Option, authority: Option, system_program: Option, log_wrapper: Option, - key: Option, + key: Option, data: Option>, __remaining_accounts: Vec, } -impl WriteCollectionExternalPluginDataV1Builder { +impl WriteCollectionExternalPluginAdapterDataV1Builder { pub fn new() -> Self { Self::default() } @@ -145,7 +145,7 @@ impl WriteCollectionExternalPluginDataV1Builder { self } /// `[optional account]` - /// The Data Authority of the External Plugin + /// The Data Authority of the External PluginExternalPluginAdapter #[inline(always)] pub fn authority(&mut self, authority: Option) -> &mut Self { self.authority = authority; @@ -169,7 +169,7 @@ impl WriteCollectionExternalPluginDataV1Builder { self } #[inline(always)] - pub fn key(&mut self, key: ExternalPluginKey) -> &mut Self { + pub fn key(&mut self, key: ExternalPluginAdapterKey) -> &mut Self { self.key = Some(key); self } @@ -198,7 +198,7 @@ impl WriteCollectionExternalPluginDataV1Builder { } #[allow(clippy::clone_on_copy)] pub fn instruction(&self) -> solana_program::instruction::Instruction { - let accounts = WriteCollectionExternalPluginDataV1 { + let accounts = WriteCollectionExternalPluginAdapterDataV1 { collection: self.collection.expect("collection is not set"), payer: self.payer.expect("payer is not set"), authority: self.authority, @@ -207,7 +207,7 @@ impl WriteCollectionExternalPluginDataV1Builder { .unwrap_or(solana_program::pubkey!("11111111111111111111111111111111")), log_wrapper: self.log_wrapper, }; - let args = WriteCollectionExternalPluginDataV1InstructionArgs { + let args = WriteCollectionExternalPluginAdapterDataV1InstructionArgs { key: self.key.clone().expect("key is not set"), data: self.data.clone().expect("data is not set"), }; @@ -216,13 +216,13 @@ impl WriteCollectionExternalPluginDataV1Builder { } } -/// `write_collection_external_plugin_data_v1` CPI accounts. -pub struct WriteCollectionExternalPluginDataV1CpiAccounts<'a, 'b> { +/// `write_collection_external_plugin_adapter_data_v1` CPI accounts. +pub struct WriteCollectionExternalPluginAdapterDataV1CpiAccounts<'a, 'b> { /// The address of the asset pub collection: &'b solana_program::account_info::AccountInfo<'a>, /// The account paying for the storage fees pub payer: &'b solana_program::account_info::AccountInfo<'a>, - /// The Data Authority of the External Plugin + /// The Data Authority of the External PluginExternalPluginAdapter pub authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, /// The system program pub system_program: &'b solana_program::account_info::AccountInfo<'a>, @@ -230,29 +230,29 @@ pub struct WriteCollectionExternalPluginDataV1CpiAccounts<'a, 'b> { pub log_wrapper: Option<&'b solana_program::account_info::AccountInfo<'a>>, } -/// `write_collection_external_plugin_data_v1` CPI instruction. -pub struct WriteCollectionExternalPluginDataV1Cpi<'a, 'b> { +/// `write_collection_external_plugin_adapter_data_v1` CPI instruction. +pub struct WriteCollectionExternalPluginAdapterDataV1Cpi<'a, 'b> { /// The program to invoke. pub __program: &'b solana_program::account_info::AccountInfo<'a>, /// The address of the asset pub collection: &'b solana_program::account_info::AccountInfo<'a>, /// The account paying for the storage fees pub payer: &'b solana_program::account_info::AccountInfo<'a>, - /// The Data Authority of the External Plugin + /// The Data Authority of the External PluginExternalPluginAdapter pub authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, /// The system program pub system_program: &'b solana_program::account_info::AccountInfo<'a>, /// The SPL Noop Program pub log_wrapper: Option<&'b solana_program::account_info::AccountInfo<'a>>, /// The arguments for the instruction. - pub __args: WriteCollectionExternalPluginDataV1InstructionArgs, + pub __args: WriteCollectionExternalPluginAdapterDataV1InstructionArgs, } -impl<'a, 'b> WriteCollectionExternalPluginDataV1Cpi<'a, 'b> { +impl<'a, 'b> WriteCollectionExternalPluginAdapterDataV1Cpi<'a, 'b> { pub fn new( program: &'b solana_program::account_info::AccountInfo<'a>, - accounts: WriteCollectionExternalPluginDataV1CpiAccounts<'a, 'b>, - args: WriteCollectionExternalPluginDataV1InstructionArgs, + accounts: WriteCollectionExternalPluginAdapterDataV1CpiAccounts<'a, 'b>, + args: WriteCollectionExternalPluginAdapterDataV1InstructionArgs, ) -> Self { Self { __program: program, @@ -339,7 +339,7 @@ impl<'a, 'b> WriteCollectionExternalPluginDataV1Cpi<'a, 'b> { is_writable: remaining_account.2, }) }); - let mut data = WriteCollectionExternalPluginDataV1InstructionData::new() + let mut data = WriteCollectionExternalPluginAdapterDataV1InstructionData::new() .try_to_vec() .unwrap(); let mut args = self.__args.try_to_vec().unwrap(); @@ -373,7 +373,7 @@ impl<'a, 'b> WriteCollectionExternalPluginDataV1Cpi<'a, 'b> { } } -/// Instruction builder for `WriteCollectionExternalPluginDataV1` via CPI. +/// Instruction builder for `WriteCollectionExternalPluginAdapterDataV1` via CPI. /// /// ### Accounts: /// @@ -382,23 +382,25 @@ impl<'a, 'b> WriteCollectionExternalPluginDataV1Cpi<'a, 'b> { /// 2. `[signer, optional]` authority /// 3. `[]` system_program /// 4. `[optional]` log_wrapper -pub struct WriteCollectionExternalPluginDataV1CpiBuilder<'a, 'b> { - instruction: Box>, +pub struct WriteCollectionExternalPluginAdapterDataV1CpiBuilder<'a, 'b> { + instruction: Box>, } -impl<'a, 'b> WriteCollectionExternalPluginDataV1CpiBuilder<'a, 'b> { +impl<'a, 'b> WriteCollectionExternalPluginAdapterDataV1CpiBuilder<'a, 'b> { pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(WriteCollectionExternalPluginDataV1CpiBuilderInstruction { - __program: program, - collection: None, - payer: None, - authority: None, - system_program: None, - log_wrapper: None, - key: None, - data: None, - __remaining_accounts: Vec::new(), - }); + let instruction = Box::new( + WriteCollectionExternalPluginAdapterDataV1CpiBuilderInstruction { + __program: program, + collection: None, + payer: None, + authority: None, + system_program: None, + log_wrapper: None, + key: None, + data: None, + __remaining_accounts: Vec::new(), + }, + ); Self { instruction } } /// The address of the asset @@ -417,7 +419,7 @@ impl<'a, 'b> WriteCollectionExternalPluginDataV1CpiBuilder<'a, 'b> { self } /// `[optional account]` - /// The Data Authority of the External Plugin + /// The Data Authority of the External PluginExternalPluginAdapter #[inline(always)] pub fn authority( &mut self, @@ -446,7 +448,7 @@ impl<'a, 'b> WriteCollectionExternalPluginDataV1CpiBuilder<'a, 'b> { self } #[inline(always)] - pub fn key(&mut self, key: ExternalPluginKey) -> &mut Self { + pub fn key(&mut self, key: ExternalPluginAdapterKey) -> &mut Self { self.instruction.key = Some(key); self } @@ -496,11 +498,11 @@ impl<'a, 'b> WriteCollectionExternalPluginDataV1CpiBuilder<'a, 'b> { &self, signers_seeds: &[&[&[u8]]], ) -> solana_program::entrypoint::ProgramResult { - let args = WriteCollectionExternalPluginDataV1InstructionArgs { + let args = WriteCollectionExternalPluginAdapterDataV1InstructionArgs { key: self.instruction.key.clone().expect("key is not set"), data: self.instruction.data.clone().expect("data is not set"), }; - let instruction = WriteCollectionExternalPluginDataV1Cpi { + let instruction = WriteCollectionExternalPluginAdapterDataV1Cpi { __program: self.instruction.__program, collection: self.instruction.collection.expect("collection is not set"), @@ -524,14 +526,14 @@ impl<'a, 'b> WriteCollectionExternalPluginDataV1CpiBuilder<'a, 'b> { } } -struct WriteCollectionExternalPluginDataV1CpiBuilderInstruction<'a, 'b> { +struct WriteCollectionExternalPluginAdapterDataV1CpiBuilderInstruction<'a, 'b> { __program: &'b solana_program::account_info::AccountInfo<'a>, collection: Option<&'b solana_program::account_info::AccountInfo<'a>>, payer: Option<&'b solana_program::account_info::AccountInfo<'a>>, authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, system_program: Option<&'b solana_program::account_info::AccountInfo<'a>>, log_wrapper: Option<&'b solana_program::account_info::AccountInfo<'a>>, - key: Option, + key: Option, data: Option>, /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. __remaining_accounts: Vec<( diff --git a/clients/rust/src/generated/instructions/write_external_plugin_data_v1.rs b/clients/rust/src/generated/instructions/write_external_plugin_adapter_data_v1.rs similarity index 88% rename from clients/rust/src/generated/instructions/write_external_plugin_data_v1.rs rename to clients/rust/src/generated/instructions/write_external_plugin_adapter_data_v1.rs index e9166487..0e0123e0 100644 --- a/clients/rust/src/generated/instructions/write_external_plugin_data_v1.rs +++ b/clients/rust/src/generated/instructions/write_external_plugin_adapter_data_v1.rs @@ -5,21 +5,21 @@ //! [https://github.com/metaplex-foundation/kinobi] //! -use crate::generated::types::ExternalPluginKey; +use crate::generated::types::ExternalPluginAdapterKey; #[cfg(feature = "anchor")] use anchor_lang::prelude::{AnchorDeserialize, AnchorSerialize}; #[cfg(not(feature = "anchor"))] use borsh::{BorshDeserialize, BorshSerialize}; /// Accounts. -pub struct WriteExternalPluginDataV1 { +pub struct WriteExternalPluginAdapterDataV1 { /// The address of the asset pub asset: solana_program::pubkey::Pubkey, /// The collection to which the asset belongs pub collection: Option, /// The account paying for the storage fees pub payer: solana_program::pubkey::Pubkey, - /// The Data Authority of the External Plugin + /// The Data Authority of the External PluginExternalPluginAdapter pub authority: Option, /// The system program pub system_program: solana_program::pubkey::Pubkey, @@ -27,17 +27,17 @@ pub struct WriteExternalPluginDataV1 { pub log_wrapper: Option, } -impl WriteExternalPluginDataV1 { +impl WriteExternalPluginAdapterDataV1 { pub fn instruction( &self, - args: WriteExternalPluginDataV1InstructionArgs, + args: WriteExternalPluginAdapterDataV1InstructionArgs, ) -> solana_program::instruction::Instruction { self.instruction_with_remaining_accounts(args, &[]) } #[allow(clippy::vec_init_then_push)] pub fn instruction_with_remaining_accounts( &self, - args: WriteExternalPluginDataV1InstructionArgs, + args: WriteExternalPluginAdapterDataV1InstructionArgs, remaining_accounts: &[solana_program::instruction::AccountMeta], ) -> solana_program::instruction::Instruction { let mut accounts = Vec::with_capacity(6 + remaining_accounts.len()); @@ -83,7 +83,7 @@ impl WriteExternalPluginDataV1 { )); } accounts.extend_from_slice(remaining_accounts); - let mut data = WriteExternalPluginDataV1InstructionData::new() + let mut data = WriteExternalPluginAdapterDataV1InstructionData::new() .try_to_vec() .unwrap(); let mut args = args.try_to_vec().unwrap(); @@ -99,11 +99,11 @@ impl WriteExternalPluginDataV1 { #[cfg_attr(not(feature = "anchor"), derive(BorshSerialize, BorshDeserialize))] #[cfg_attr(feature = "anchor", derive(AnchorSerialize, AnchorDeserialize))] -pub struct WriteExternalPluginDataV1InstructionData { +pub struct WriteExternalPluginAdapterDataV1InstructionData { discriminator: u8, } -impl WriteExternalPluginDataV1InstructionData { +impl WriteExternalPluginAdapterDataV1InstructionData { pub fn new() -> Self { Self { discriminator: 28 } } @@ -113,12 +113,12 @@ impl WriteExternalPluginDataV1InstructionData { #[cfg_attr(feature = "anchor", derive(AnchorSerialize, AnchorDeserialize))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Debug, Eq, PartialEq)] -pub struct WriteExternalPluginDataV1InstructionArgs { - pub key: ExternalPluginKey, +pub struct WriteExternalPluginAdapterDataV1InstructionArgs { + pub key: ExternalPluginAdapterKey, pub data: Vec, } -/// Instruction builder for `WriteExternalPluginDataV1`. +/// Instruction builder for `WriteExternalPluginAdapterDataV1`. /// /// ### Accounts: /// @@ -129,19 +129,19 @@ pub struct WriteExternalPluginDataV1InstructionArgs { /// 4. `[optional]` system_program (default to `11111111111111111111111111111111`) /// 5. `[optional]` log_wrapper #[derive(Default)] -pub struct WriteExternalPluginDataV1Builder { +pub struct WriteExternalPluginAdapterDataV1Builder { asset: Option, collection: Option, payer: Option, authority: Option, system_program: Option, log_wrapper: Option, - key: Option, + key: Option, data: Option>, __remaining_accounts: Vec, } -impl WriteExternalPluginDataV1Builder { +impl WriteExternalPluginAdapterDataV1Builder { pub fn new() -> Self { Self::default() } @@ -165,7 +165,7 @@ impl WriteExternalPluginDataV1Builder { self } /// `[optional account]` - /// The Data Authority of the External Plugin + /// The Data Authority of the External PluginExternalPluginAdapter #[inline(always)] pub fn authority(&mut self, authority: Option) -> &mut Self { self.authority = authority; @@ -189,7 +189,7 @@ impl WriteExternalPluginDataV1Builder { self } #[inline(always)] - pub fn key(&mut self, key: ExternalPluginKey) -> &mut Self { + pub fn key(&mut self, key: ExternalPluginAdapterKey) -> &mut Self { self.key = Some(key); self } @@ -218,7 +218,7 @@ impl WriteExternalPluginDataV1Builder { } #[allow(clippy::clone_on_copy)] pub fn instruction(&self) -> solana_program::instruction::Instruction { - let accounts = WriteExternalPluginDataV1 { + let accounts = WriteExternalPluginAdapterDataV1 { asset: self.asset.expect("asset is not set"), collection: self.collection, payer: self.payer.expect("payer is not set"), @@ -228,7 +228,7 @@ impl WriteExternalPluginDataV1Builder { .unwrap_or(solana_program::pubkey!("11111111111111111111111111111111")), log_wrapper: self.log_wrapper, }; - let args = WriteExternalPluginDataV1InstructionArgs { + let args = WriteExternalPluginAdapterDataV1InstructionArgs { key: self.key.clone().expect("key is not set"), data: self.data.clone().expect("data is not set"), }; @@ -237,15 +237,15 @@ impl WriteExternalPluginDataV1Builder { } } -/// `write_external_plugin_data_v1` CPI accounts. -pub struct WriteExternalPluginDataV1CpiAccounts<'a, 'b> { +/// `write_external_plugin_adapter_data_v1` CPI accounts. +pub struct WriteExternalPluginAdapterDataV1CpiAccounts<'a, 'b> { /// The address of the asset pub asset: &'b solana_program::account_info::AccountInfo<'a>, /// The collection to which the asset belongs pub collection: Option<&'b solana_program::account_info::AccountInfo<'a>>, /// The account paying for the storage fees pub payer: &'b solana_program::account_info::AccountInfo<'a>, - /// The Data Authority of the External Plugin + /// The Data Authority of the External PluginExternalPluginAdapter pub authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, /// The system program pub system_program: &'b solana_program::account_info::AccountInfo<'a>, @@ -253,8 +253,8 @@ pub struct WriteExternalPluginDataV1CpiAccounts<'a, 'b> { pub log_wrapper: Option<&'b solana_program::account_info::AccountInfo<'a>>, } -/// `write_external_plugin_data_v1` CPI instruction. -pub struct WriteExternalPluginDataV1Cpi<'a, 'b> { +/// `write_external_plugin_adapter_data_v1` CPI instruction. +pub struct WriteExternalPluginAdapterDataV1Cpi<'a, 'b> { /// The program to invoke. pub __program: &'b solana_program::account_info::AccountInfo<'a>, /// The address of the asset @@ -263,21 +263,21 @@ pub struct WriteExternalPluginDataV1Cpi<'a, 'b> { pub collection: Option<&'b solana_program::account_info::AccountInfo<'a>>, /// The account paying for the storage fees pub payer: &'b solana_program::account_info::AccountInfo<'a>, - /// The Data Authority of the External Plugin + /// The Data Authority of the External PluginExternalPluginAdapter pub authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, /// The system program pub system_program: &'b solana_program::account_info::AccountInfo<'a>, /// The SPL Noop Program pub log_wrapper: Option<&'b solana_program::account_info::AccountInfo<'a>>, /// The arguments for the instruction. - pub __args: WriteExternalPluginDataV1InstructionArgs, + pub __args: WriteExternalPluginAdapterDataV1InstructionArgs, } -impl<'a, 'b> WriteExternalPluginDataV1Cpi<'a, 'b> { +impl<'a, 'b> WriteExternalPluginAdapterDataV1Cpi<'a, 'b> { pub fn new( program: &'b solana_program::account_info::AccountInfo<'a>, - accounts: WriteExternalPluginDataV1CpiAccounts<'a, 'b>, - args: WriteExternalPluginDataV1InstructionArgs, + accounts: WriteExternalPluginAdapterDataV1CpiAccounts<'a, 'b>, + args: WriteExternalPluginAdapterDataV1InstructionArgs, ) -> Self { Self { __program: program, @@ -376,7 +376,7 @@ impl<'a, 'b> WriteExternalPluginDataV1Cpi<'a, 'b> { is_writable: remaining_account.2, }) }); - let mut data = WriteExternalPluginDataV1InstructionData::new() + let mut data = WriteExternalPluginAdapterDataV1InstructionData::new() .try_to_vec() .unwrap(); let mut args = self.__args.try_to_vec().unwrap(); @@ -413,7 +413,7 @@ impl<'a, 'b> WriteExternalPluginDataV1Cpi<'a, 'b> { } } -/// Instruction builder for `WriteExternalPluginDataV1` via CPI. +/// Instruction builder for `WriteExternalPluginAdapterDataV1` via CPI. /// /// ### Accounts: /// @@ -423,13 +423,13 @@ impl<'a, 'b> WriteExternalPluginDataV1Cpi<'a, 'b> { /// 3. `[signer, optional]` authority /// 4. `[]` system_program /// 5. `[optional]` log_wrapper -pub struct WriteExternalPluginDataV1CpiBuilder<'a, 'b> { - instruction: Box>, +pub struct WriteExternalPluginAdapterDataV1CpiBuilder<'a, 'b> { + instruction: Box>, } -impl<'a, 'b> WriteExternalPluginDataV1CpiBuilder<'a, 'b> { +impl<'a, 'b> WriteExternalPluginAdapterDataV1CpiBuilder<'a, 'b> { pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(WriteExternalPluginDataV1CpiBuilderInstruction { + let instruction = Box::new(WriteExternalPluginAdapterDataV1CpiBuilderInstruction { __program: program, asset: None, collection: None, @@ -466,7 +466,7 @@ impl<'a, 'b> WriteExternalPluginDataV1CpiBuilder<'a, 'b> { self } /// `[optional account]` - /// The Data Authority of the External Plugin + /// The Data Authority of the External PluginExternalPluginAdapter #[inline(always)] pub fn authority( &mut self, @@ -495,7 +495,7 @@ impl<'a, 'b> WriteExternalPluginDataV1CpiBuilder<'a, 'b> { self } #[inline(always)] - pub fn key(&mut self, key: ExternalPluginKey) -> &mut Self { + pub fn key(&mut self, key: ExternalPluginAdapterKey) -> &mut Self { self.instruction.key = Some(key); self } @@ -545,11 +545,11 @@ impl<'a, 'b> WriteExternalPluginDataV1CpiBuilder<'a, 'b> { &self, signers_seeds: &[&[&[u8]]], ) -> solana_program::entrypoint::ProgramResult { - let args = WriteExternalPluginDataV1InstructionArgs { + let args = WriteExternalPluginAdapterDataV1InstructionArgs { key: self.instruction.key.clone().expect("key is not set"), data: self.instruction.data.clone().expect("data is not set"), }; - let instruction = WriteExternalPluginDataV1Cpi { + let instruction = WriteExternalPluginAdapterDataV1Cpi { __program: self.instruction.__program, asset: self.instruction.asset.expect("asset is not set"), @@ -575,7 +575,7 @@ impl<'a, 'b> WriteExternalPluginDataV1CpiBuilder<'a, 'b> { } } -struct WriteExternalPluginDataV1CpiBuilderInstruction<'a, 'b> { +struct WriteExternalPluginAdapterDataV1CpiBuilderInstruction<'a, 'b> { __program: &'b solana_program::account_info::AccountInfo<'a>, asset: Option<&'b solana_program::account_info::AccountInfo<'a>>, collection: Option<&'b solana_program::account_info::AccountInfo<'a>>, @@ -583,7 +583,7 @@ struct WriteExternalPluginDataV1CpiBuilderInstruction<'a, 'b> { authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, system_program: Option<&'b solana_program::account_info::AccountInfo<'a>>, log_wrapper: Option<&'b solana_program::account_info::AccountInfo<'a>>, - key: Option, + key: Option, data: Option>, /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. __remaining_accounts: Vec<( diff --git a/clients/rust/src/generated/types/data_store.rs b/clients/rust/src/generated/types/data_store.rs index b7ad38e2..7d7f5577 100644 --- a/clients/rust/src/generated/types/data_store.rs +++ b/clients/rust/src/generated/types/data_store.rs @@ -5,7 +5,7 @@ //! [https://github.com/metaplex-foundation/kinobi] //! -use crate::generated::types::ExternalPluginSchema; +use crate::generated::types::ExternalPluginAdapterSchema; use crate::generated::types::PluginAuthority; #[cfg(feature = "anchor")] use anchor_lang::prelude::{AnchorDeserialize, AnchorSerialize}; @@ -18,5 +18,5 @@ use borsh::{BorshDeserialize, BorshSerialize}; #[derive(Clone, Debug, Eq, PartialEq)] pub struct DataStore { pub data_authority: PluginAuthority, - pub schema: ExternalPluginSchema, + pub schema: ExternalPluginAdapterSchema, } diff --git a/clients/rust/src/generated/types/data_store_init_info.rs b/clients/rust/src/generated/types/data_store_init_info.rs index d03a5fd2..bdcf7213 100644 --- a/clients/rust/src/generated/types/data_store_init_info.rs +++ b/clients/rust/src/generated/types/data_store_init_info.rs @@ -5,7 +5,7 @@ //! [https://github.com/metaplex-foundation/kinobi] //! -use crate::generated::types::ExternalPluginSchema; +use crate::generated::types::ExternalPluginAdapterSchema; use crate::generated::types::PluginAuthority; #[cfg(feature = "anchor")] use anchor_lang::prelude::{AnchorDeserialize, AnchorSerialize}; @@ -19,5 +19,5 @@ use borsh::{BorshDeserialize, BorshSerialize}; pub struct DataStoreInitInfo { pub data_authority: PluginAuthority, pub init_plugin_authority: Option, - pub schema: Option, + pub schema: Option, } diff --git a/clients/rust/src/generated/types/data_store_update_info.rs b/clients/rust/src/generated/types/data_store_update_info.rs index c6a31437..c9fe1584 100644 --- a/clients/rust/src/generated/types/data_store_update_info.rs +++ b/clients/rust/src/generated/types/data_store_update_info.rs @@ -5,7 +5,7 @@ //! [https://github.com/metaplex-foundation/kinobi] //! -use crate::generated::types::ExternalPluginSchema; +use crate::generated::types::ExternalPluginAdapterSchema; #[cfg(feature = "anchor")] use anchor_lang::prelude::{AnchorDeserialize, AnchorSerialize}; #[cfg(not(feature = "anchor"))] @@ -16,5 +16,5 @@ use borsh::{BorshDeserialize, BorshSerialize}; #[cfg_attr(feature = "anchor", derive(AnchorSerialize, AnchorDeserialize))] #[derive(Clone, Debug, Eq, PartialEq)] pub struct DataStoreUpdateInfo { - pub schema: Option, + pub schema: Option, } diff --git a/clients/rust/src/generated/types/external_plugin.rs b/clients/rust/src/generated/types/external_plugin_adapter.rs similarity index 96% rename from clients/rust/src/generated/types/external_plugin.rs rename to clients/rust/src/generated/types/external_plugin_adapter.rs index 2dc1b48a..00e02d0a 100644 --- a/clients/rust/src/generated/types/external_plugin.rs +++ b/clients/rust/src/generated/types/external_plugin_adapter.rs @@ -17,7 +17,7 @@ use borsh::{BorshDeserialize, BorshSerialize}; #[cfg_attr(not(feature = "anchor"), derive(BorshSerialize, BorshDeserialize))] #[cfg_attr(feature = "anchor", derive(AnchorSerialize, AnchorDeserialize))] #[derive(Clone, Debug, Eq, PartialEq)] -pub enum ExternalPlugin { +pub enum ExternalPluginAdapter { LifecycleHook(LifecycleHook), Oracle(Oracle), DataStore(DataStore), diff --git a/clients/rust/src/generated/types/external_plugin_init_info.rs b/clients/rust/src/generated/types/external_plugin_adapter_init_info.rs similarity index 95% rename from clients/rust/src/generated/types/external_plugin_init_info.rs rename to clients/rust/src/generated/types/external_plugin_adapter_init_info.rs index 20a838d5..2168a069 100644 --- a/clients/rust/src/generated/types/external_plugin_init_info.rs +++ b/clients/rust/src/generated/types/external_plugin_adapter_init_info.rs @@ -17,7 +17,7 @@ use borsh::{BorshDeserialize, BorshSerialize}; #[cfg_attr(not(feature = "anchor"), derive(BorshSerialize, BorshDeserialize))] #[cfg_attr(feature = "anchor", derive(AnchorSerialize, AnchorDeserialize))] #[derive(Clone, Debug, Eq, PartialEq)] -pub enum ExternalPluginInitInfo { +pub enum ExternalPluginAdapterInitInfo { LifecycleHook(LifecycleHookInitInfo), Oracle(OracleInitInfo), DataStore(DataStoreInitInfo), diff --git a/clients/rust/src/generated/types/external_plugin_key.rs b/clients/rust/src/generated/types/external_plugin_adapter_key.rs similarity index 96% rename from clients/rust/src/generated/types/external_plugin_key.rs rename to clients/rust/src/generated/types/external_plugin_adapter_key.rs index 7550c7ef..b8d3b68d 100644 --- a/clients/rust/src/generated/types/external_plugin_key.rs +++ b/clients/rust/src/generated/types/external_plugin_adapter_key.rs @@ -16,7 +16,7 @@ use solana_program::pubkey::Pubkey; #[cfg_attr(not(feature = "anchor"), derive(BorshSerialize, BorshDeserialize))] #[cfg_attr(feature = "anchor", derive(AnchorSerialize, AnchorDeserialize))] #[derive(Clone, Debug, Eq, PartialEq)] -pub enum ExternalPluginKey { +pub enum ExternalPluginAdapterKey { #[cfg_attr( feature = "serde", serde(with = "serde_with::As::") diff --git a/clients/rust/src/generated/types/external_plugin_schema.rs b/clients/rust/src/generated/types/external_plugin_adapter_schema.rs similarity index 95% rename from clients/rust/src/generated/types/external_plugin_schema.rs rename to clients/rust/src/generated/types/external_plugin_adapter_schema.rs index 164be69d..6502eb7c 100644 --- a/clients/rust/src/generated/types/external_plugin_schema.rs +++ b/clients/rust/src/generated/types/external_plugin_adapter_schema.rs @@ -15,7 +15,7 @@ use num_derive::FromPrimitive; #[cfg_attr(not(feature = "anchor"), derive(BorshSerialize, BorshDeserialize))] #[cfg_attr(feature = "anchor", derive(AnchorSerialize, AnchorDeserialize))] #[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Hash, FromPrimitive)] -pub enum ExternalPluginSchema { +pub enum ExternalPluginAdapterSchema { Binary, Json, MsgPack, diff --git a/clients/rust/src/generated/types/external_plugin_type.rs b/clients/rust/src/generated/types/external_plugin_adapter_type.rs similarity index 95% rename from clients/rust/src/generated/types/external_plugin_type.rs rename to clients/rust/src/generated/types/external_plugin_adapter_type.rs index 4235e42e..0a7c025e 100644 --- a/clients/rust/src/generated/types/external_plugin_type.rs +++ b/clients/rust/src/generated/types/external_plugin_adapter_type.rs @@ -15,7 +15,7 @@ use num_derive::FromPrimitive; #[cfg_attr(not(feature = "anchor"), derive(BorshSerialize, BorshDeserialize))] #[cfg_attr(feature = "anchor", derive(AnchorSerialize, AnchorDeserialize))] #[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Hash, FromPrimitive)] -pub enum ExternalPluginType { +pub enum ExternalPluginAdapterType { LifecycleHook, Oracle, DataStore, diff --git a/clients/rust/src/generated/types/external_plugin_update_info.rs b/clients/rust/src/generated/types/external_plugin_adapter_update_info.rs similarity index 95% rename from clients/rust/src/generated/types/external_plugin_update_info.rs rename to clients/rust/src/generated/types/external_plugin_adapter_update_info.rs index 0641197c..cd709990 100644 --- a/clients/rust/src/generated/types/external_plugin_update_info.rs +++ b/clients/rust/src/generated/types/external_plugin_adapter_update_info.rs @@ -17,7 +17,7 @@ use borsh::{BorshDeserialize, BorshSerialize}; #[cfg_attr(not(feature = "anchor"), derive(BorshSerialize, BorshDeserialize))] #[cfg_attr(feature = "anchor", derive(AnchorSerialize, AnchorDeserialize))] #[derive(Clone, Debug, Eq, PartialEq)] -pub enum ExternalPluginUpdateInfo { +pub enum ExternalPluginAdapterUpdateInfo { LifecycleHook(LifecycleHookUpdateInfo), Oracle(OracleUpdateInfo), DataStore(DataStoreUpdateInfo), diff --git a/clients/rust/src/generated/types/external_registry_record.rs b/clients/rust/src/generated/types/external_registry_record.rs index 63146d39..6dbef310 100644 --- a/clients/rust/src/generated/types/external_registry_record.rs +++ b/clients/rust/src/generated/types/external_registry_record.rs @@ -6,7 +6,7 @@ //! use crate::generated::types::ExternalCheckResult; -use crate::generated::types::ExternalPluginType; +use crate::generated::types::ExternalPluginAdapterType; use crate::generated::types::HookableLifecycleEvent; use crate::generated::types::PluginAuthority; #[cfg(feature = "anchor")] @@ -19,7 +19,7 @@ use borsh::{BorshDeserialize, BorshSerialize}; #[cfg_attr(feature = "anchor", derive(AnchorSerialize, AnchorDeserialize))] #[derive(Clone, Debug, Eq, PartialEq)] pub struct ExternalRegistryRecord { - pub plugin_type: ExternalPluginType, + pub plugin_type: ExternalPluginAdapterType, pub authority: PluginAuthority, pub lifecycle_checks: Option>, pub offset: u64, diff --git a/clients/rust/src/generated/types/lifecycle_hook.rs b/clients/rust/src/generated/types/lifecycle_hook.rs index f625972e..d7ea8373 100644 --- a/clients/rust/src/generated/types/lifecycle_hook.rs +++ b/clients/rust/src/generated/types/lifecycle_hook.rs @@ -5,7 +5,7 @@ //! [https://github.com/metaplex-foundation/kinobi] //! -use crate::generated::types::ExternalPluginSchema; +use crate::generated::types::ExternalPluginAdapterSchema; use crate::generated::types::ExtraAccount; use crate::generated::types::PluginAuthority; #[cfg(feature = "anchor")] @@ -26,5 +26,5 @@ pub struct LifecycleHook { pub hooked_program: Pubkey, pub extra_accounts: Option>, pub data_authority: Option, - pub schema: ExternalPluginSchema, + pub schema: ExternalPluginAdapterSchema, } diff --git a/clients/rust/src/generated/types/lifecycle_hook_init_info.rs b/clients/rust/src/generated/types/lifecycle_hook_init_info.rs index b6516a35..16b54c70 100644 --- a/clients/rust/src/generated/types/lifecycle_hook_init_info.rs +++ b/clients/rust/src/generated/types/lifecycle_hook_init_info.rs @@ -6,7 +6,7 @@ //! use crate::generated::types::ExternalCheckResult; -use crate::generated::types::ExternalPluginSchema; +use crate::generated::types::ExternalPluginAdapterSchema; use crate::generated::types::ExtraAccount; use crate::generated::types::HookableLifecycleEvent; use crate::generated::types::PluginAuthority; @@ -30,5 +30,5 @@ pub struct LifecycleHookInitInfo { pub lifecycle_checks: Vec<(HookableLifecycleEvent, ExternalCheckResult)>, pub extra_accounts: Option>, pub data_authority: Option, - pub schema: Option, + pub schema: Option, } diff --git a/clients/rust/src/generated/types/lifecycle_hook_update_info.rs b/clients/rust/src/generated/types/lifecycle_hook_update_info.rs index 382a342c..ebefb9b7 100644 --- a/clients/rust/src/generated/types/lifecycle_hook_update_info.rs +++ b/clients/rust/src/generated/types/lifecycle_hook_update_info.rs @@ -6,7 +6,7 @@ //! use crate::generated::types::ExternalCheckResult; -use crate::generated::types::ExternalPluginSchema; +use crate::generated::types::ExternalPluginAdapterSchema; use crate::generated::types::ExtraAccount; use crate::generated::types::HookableLifecycleEvent; #[cfg(feature = "anchor")] @@ -21,5 +21,5 @@ use borsh::{BorshDeserialize, BorshSerialize}; pub struct LifecycleHookUpdateInfo { pub lifecycle_checks: Option>, pub extra_accounts: Option>, - pub schema: Option, + pub schema: Option, } diff --git a/clients/rust/src/generated/types/mod.rs b/clients/rust/src/generated/types/mod.rs index 291d366e..0b2d39bd 100644 --- a/clients/rust/src/generated/types/mod.rs +++ b/clients/rust/src/generated/types/mod.rs @@ -17,12 +17,12 @@ pub(crate) mod r#data_store_init_info; pub(crate) mod r#data_store_update_info; pub(crate) mod r#edition; pub(crate) mod r#external_check_result; -pub(crate) mod r#external_plugin; -pub(crate) mod r#external_plugin_init_info; -pub(crate) mod r#external_plugin_key; -pub(crate) mod r#external_plugin_schema; -pub(crate) mod r#external_plugin_type; -pub(crate) mod r#external_plugin_update_info; +pub(crate) mod r#external_plugin_adapter; +pub(crate) mod r#external_plugin_adapter_init_info; +pub(crate) mod r#external_plugin_adapter_key; +pub(crate) mod r#external_plugin_adapter_schema; +pub(crate) mod r#external_plugin_adapter_type; +pub(crate) mod r#external_plugin_adapter_update_info; pub(crate) mod r#external_registry_record; pub(crate) mod r#external_validation_result; pub(crate) mod r#extra_account; @@ -69,12 +69,12 @@ pub use self::r#data_store_init_info::*; pub use self::r#data_store_update_info::*; pub use self::r#edition::*; pub use self::r#external_check_result::*; -pub use self::r#external_plugin::*; -pub use self::r#external_plugin_init_info::*; -pub use self::r#external_plugin_key::*; -pub use self::r#external_plugin_schema::*; -pub use self::r#external_plugin_type::*; -pub use self::r#external_plugin_update_info::*; +pub use self::r#external_plugin_adapter::*; +pub use self::r#external_plugin_adapter_init_info::*; +pub use self::r#external_plugin_adapter_key::*; +pub use self::r#external_plugin_adapter_schema::*; +pub use self::r#external_plugin_adapter_type::*; +pub use self::r#external_plugin_adapter_update_info::*; pub use self::r#external_registry_record::*; pub use self::r#external_validation_result::*; pub use self::r#extra_account::*; diff --git a/clients/rust/src/generated/types/oracle.rs b/clients/rust/src/generated/types/oracle.rs index cd004210..f4b7e829 100644 --- a/clients/rust/src/generated/types/oracle.rs +++ b/clients/rust/src/generated/types/oracle.rs @@ -23,6 +23,6 @@ pub struct Oracle { serde(with = "serde_with::As::") )] pub base_address: Pubkey, - pub pda: Option, + pub base_address_config: Option, pub results_offset: ValidationResultsOffset, } diff --git a/clients/rust/src/generated/types/oracle_init_info.rs b/clients/rust/src/generated/types/oracle_init_info.rs index 71fb3233..ed8ea193 100644 --- a/clients/rust/src/generated/types/oracle_init_info.rs +++ b/clients/rust/src/generated/types/oracle_init_info.rs @@ -28,6 +28,6 @@ pub struct OracleInitInfo { pub base_address: Pubkey, pub init_plugin_authority: Option, pub lifecycle_checks: Vec<(HookableLifecycleEvent, ExternalCheckResult)>, - pub pda: Option, + pub base_address_config: Option, pub results_offset: Option, } diff --git a/clients/rust/src/generated/types/oracle_update_info.rs b/clients/rust/src/generated/types/oracle_update_info.rs index a7868ffe..b2d23097 100644 --- a/clients/rust/src/generated/types/oracle_update_info.rs +++ b/clients/rust/src/generated/types/oracle_update_info.rs @@ -20,6 +20,6 @@ use borsh::{BorshDeserialize, BorshSerialize}; #[derive(Clone, Debug, Eq, PartialEq)] pub struct OracleUpdateInfo { pub lifecycle_checks: Option>, - pub pda: Option, + pub base_address_config: Option, pub results_offset: Option, } diff --git a/clients/rust/src/hooked/advanced_types.rs b/clients/rust/src/hooked/advanced_types.rs index 273e660d..e7e6d520 100644 --- a/clients/rust/src/hooked/advanced_types.rs +++ b/clients/rust/src/hooked/advanced_types.rs @@ -9,8 +9,8 @@ use crate::{ accounts::{BaseAssetV1, BaseCollectionV1, PluginHeaderV1}, types::{ AddBlocker, Attributes, BurnDelegate, DataStore, Edition, ExternalCheckResult, - ExternalPlugin, ExternalPluginKey, FreezeDelegate, ImmutableMetadata, Key, LifecycleHook, - MasterEdition, Oracle, PermanentBurnDelegate, PermanentFreezeDelegate, + ExternalPluginAdapter, ExternalPluginAdapterKey, FreezeDelegate, ImmutableMetadata, Key, + LifecycleHook, MasterEdition, Oracle, PermanentBurnDelegate, PermanentFreezeDelegate, PermanentTransferDelegate, PluginAuthority, Royalties, TransferDelegate, UpdateDelegate, }, }; @@ -165,7 +165,7 @@ pub struct PluginsList { } #[derive(Debug, Default)] -pub struct ExternalPluginsList { +pub struct ExternalPluginAdaptersList { pub lifecycle_hooks: Vec, pub oracles: Vec, pub data_stores: Vec, @@ -175,7 +175,7 @@ pub struct ExternalPluginsList { pub struct Asset { pub base: BaseAssetV1, pub plugin_list: PluginsList, - pub external_plugin_list: ExternalPluginsList, + pub external_plugin_adapter_list: ExternalPluginAdaptersList, pub plugin_header: Option, } @@ -201,7 +201,7 @@ impl RegistryRecordSafe { } } -/// External Registry record that can be used when the plugin type is not known (i.e. a `ExternalPluginType` that +///ExternalPluginAdapter Registry record that can be used when the plugin type is not known (i.e. a `ExternalPluginAdapterType` that /// is too new for this client to know about). pub struct ExternalRegistryRecordSafe { pub plugin_type: u8, @@ -220,7 +220,7 @@ impl ExternalRegistryRecordSafe { } /// Plugin registry that an account can safely be deserialized into even if some plugins are -/// not known. Note this skips over external plugins for now, and will be updated when those +/// not known. Note this skips over external plugin adapters for now, and will be updated when those /// are defined. pub struct PluginRegistryV1Safe { pub _key: Key, @@ -282,15 +282,17 @@ impl PluginRegistryV1Safe { } } -impl From<&ExternalPlugin> for ExternalPluginKey { - fn from(plugin: &ExternalPlugin) -> Self { +impl From<&ExternalPluginAdapter> for ExternalPluginAdapterKey { + fn from(plugin: &ExternalPluginAdapter) -> Self { match plugin { - ExternalPlugin::DataStore(data_store) => { - ExternalPluginKey::DataStore(data_store.data_authority.clone()) + ExternalPluginAdapter::DataStore(data_store) => { + ExternalPluginAdapterKey::DataStore(data_store.data_authority.clone()) } - ExternalPlugin::Oracle(oracle) => ExternalPluginKey::Oracle(oracle.base_address), - ExternalPlugin::LifecycleHook(lifecycle_hook) => { - ExternalPluginKey::LifecycleHook(lifecycle_hook.hooked_program) + ExternalPluginAdapter::Oracle(oracle) => { + ExternalPluginAdapterKey::Oracle(oracle.base_address) + } + ExternalPluginAdapter::LifecycleHook(lifecycle_hook) => { + ExternalPluginAdapterKey::LifecycleHook(lifecycle_hook.hooked_program) } } } diff --git a/clients/rust/src/hooked/asset.rs b/clients/rust/src/hooked/asset.rs index 7ce08d7c..8131e986 100644 --- a/clients/rust/src/hooked/asset.rs +++ b/clients/rust/src/hooked/asset.rs @@ -5,7 +5,7 @@ use borsh::BorshSerialize; use crate::{ accounts::{BaseAssetV1, PluginHeaderV1}, - registry_records_to_external_plugin_list, registry_records_to_plugin_list, Asset, + registry_records_to_external_plugin_adapter_list, registry_records_to_plugin_list, Asset, PluginRegistryV1Safe, }; @@ -13,20 +13,24 @@ impl Asset { pub fn deserialize(data: &[u8]) -> Result { let base = BaseAssetV1::from_bytes(data)?; let base_data = base.try_to_vec()?; - let (plugin_header, plugin_list, external_plugin_list) = if base_data.len() != data.len() { + let (plugin_header, plugin_list, external_plugin_adapter_list) = if base_data.len() + != data.len() + { let plugin_header = PluginHeaderV1::from_bytes(&data[base_data.len()..])?; let plugin_registry = PluginRegistryV1Safe::from_bytes( &data[plugin_header.plugin_registry_offset as usize..], )?; let plugin_list = registry_records_to_plugin_list(&plugin_registry.registry, data)?; - let external_plugin_list = - registry_records_to_external_plugin_list(&plugin_registry.external_registry, data)?; + let external_plugin_adapter_list = registry_records_to_external_plugin_adapter_list( + &plugin_registry.external_registry, + data, + )?; ( Some(plugin_header), Some(plugin_list), - Some(external_plugin_list), + Some(external_plugin_adapter_list), ) } else { (None, None, None) @@ -35,7 +39,7 @@ impl Asset { Ok(Self { base, plugin_list: plugin_list.unwrap_or_default(), - external_plugin_list: external_plugin_list.unwrap_or_default(), + external_plugin_adapter_list: external_plugin_adapter_list.unwrap_or_default(), plugin_header, }) } diff --git a/clients/rust/src/hooked/plugin.rs b/clients/rust/src/hooked/plugin.rs index 2bbbbab3..283edb4c 100644 --- a/clients/rust/src/hooked/plugin.rs +++ b/clients/rust/src/hooked/plugin.rs @@ -9,10 +9,11 @@ use crate::{ accounts::{BaseAssetV1, PluginHeaderV1}, errors::MplCoreError, types::{ - ExternalPlugin, ExternalPluginType, Plugin, PluginAuthority, PluginType, RegistryRecord, + ExternalPluginAdapter, ExternalPluginAdapterType, Plugin, PluginAuthority, PluginType, + RegistryRecord, }, AddBlockerPlugin, AttributesPlugin, BaseAuthority, BasePlugin, BurnDelegatePlugin, DataBlob, - EditionPlugin, ExternalPluginsList, ExternalRegistryRecordSafe, FreezeDelegatePlugin, + EditionPlugin, ExternalPluginAdaptersList, ExternalRegistryRecordSafe, FreezeDelegatePlugin, ImmutableMetadataPlugin, MasterEditionPlugin, PermanentBurnDelegatePlugin, PermanentFreezeDelegatePlugin, PermanentTransferDelegatePlugin, PluginRegistryV1Safe, PluginsList, RegistryRecordSafe, RoyaltiesPlugin, SolanaAccount, TransferDelegatePlugin, @@ -108,7 +109,7 @@ pub fn fetch_plugins(account_data: &[u8]) -> Result, std::io } /// List all plugins in an account, dropping any unknown plugins (i.e. `PluginType`s that are too -/// new for this client to know about). Note this also does not support external plugins for now, +/// new for this client to know about). Note this also does not support external plugin adapters for now, /// and will be updated when those are defined. pub fn list_plugins(account_data: &[u8]) -> Result, std::io::Error> { let asset = BaseAssetV1::from_bytes(account_data)?; @@ -214,30 +215,33 @@ pub(crate) fn registry_records_to_plugin_list( result } -// Convert a slice of `ExternalRegistryRecordSafe` into the `ExternalPluginsList` type, dropping any unknown -// plugins (i.e. `ExternalPluginType`s that are too new for this client to know about). -pub(crate) fn registry_records_to_external_plugin_list( +// Convert a slice of `AdapterRegistryRecordSafe` into the `ExternalPluginAdaptersList` type, dropping any unknown +// plugins (i.e. `ExternalPluginAdapterType`s that are too new for this client to know about). +pub(crate) fn registry_records_to_external_plugin_adapter_list( registry_records: &[ExternalRegistryRecordSafe], account_data: &[u8], -) -> Result { - let result = - registry_records - .iter() - .try_fold(ExternalPluginsList::default(), |mut acc, record| { - if ExternalPluginType::from_u8(record.plugin_type).is_some() { - let plugin = - ExternalPlugin::deserialize(&mut &account_data[record.offset as usize..])?; - - match plugin { - ExternalPlugin::LifecycleHook(lifecycle_hook) => { - acc.lifecycle_hooks.push(lifecycle_hook) - } - ExternalPlugin::Oracle(oracle) => acc.oracles.push(oracle), - ExternalPlugin::DataStore(data_store) => acc.data_stores.push(data_store), +) -> Result { + let result = registry_records.iter().try_fold( + ExternalPluginAdaptersList::default(), + |mut acc, record| { + if ExternalPluginAdapterType::from_u8(record.plugin_type).is_some() { + let plugin = ExternalPluginAdapter::deserialize( + &mut &account_data[record.offset as usize..], + )?; + + match plugin { + ExternalPluginAdapter::LifecycleHook(lifecycle_hook) => { + acc.lifecycle_hooks.push(lifecycle_hook) + } + ExternalPluginAdapter::Oracle(oracle) => acc.oracles.push(oracle), + ExternalPluginAdapter::DataStore(data_store) => { + acc.data_stores.push(data_store) } } - Ok(acc) - }); + } + Ok(acc) + }, + ); result } diff --git a/clients/rust/tests/add_external_plugins.rs b/clients/rust/tests/add_external_plugins.rs index 251549ef..f08935dc 100644 --- a/clients/rust/tests/add_external_plugins.rs +++ b/clients/rust/tests/add_external_plugins.rs @@ -2,11 +2,14 @@ pub mod setup; use mpl_core::{ errors::MplCoreError, - instructions::{AddCollectionExternalPluginV1Builder, AddExternalPluginV1Builder}, + instructions::{ + AddCollectionExternalPluginAdapterV1Builder, AddExternalPluginAdapterV1Builder, + }, types::{ - DataStore, DataStoreInitInfo, ExternalCheckResult, ExternalPlugin, ExternalPluginInitInfo, - ExternalPluginSchema, HookableLifecycleEvent, LifecycleHook, LifecycleHookInitInfo, Oracle, - OracleInitInfo, PluginAuthority, UpdateAuthority, ValidationResultsOffset, + DataStore, DataStoreInitInfo, ExternalCheckResult, ExternalPluginAdapter, + ExternalPluginAdapterInitInfo, ExternalPluginAdapterSchema, HookableLifecycleEvent, + LifecycleHook, LifecycleHookInitInfo, Oracle, OracleInitInfo, PluginAuthority, + UpdateAuthority, ValidationResultsOffset, }, }; pub use setup::*; @@ -34,7 +37,7 @@ async fn test_add_lifecycle_hook() { update_authority: None, collection: None, plugins: vec![], - external_plugins: vec![], + external_plugin_adapters: vec![], }, ) .await @@ -51,15 +54,15 @@ async fn test_add_lifecycle_hook() { name: None, uri: None, plugins: vec![], - external_plugins: vec![], + external_plugin_adapters: vec![], }, ) .await; - let add_external_plugin_ix = AddExternalPluginV1Builder::new() + let add_external_plugin_adapter_ix = AddExternalPluginAdapterV1Builder::new() .asset(asset.pubkey()) .payer(context.payer.pubkey()) - .init_info(ExternalPluginInitInfo::LifecycleHook( + .init_info(ExternalPluginAdapterInitInfo::LifecycleHook( LifecycleHookInitInfo { hooked_program: pubkey!("MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr"), init_plugin_authority: Some(PluginAuthority::UpdateAuthority), @@ -75,7 +78,7 @@ async fn test_add_lifecycle_hook() { .instruction(); let tx = Transaction::new_signed_with_payer( - &[add_external_plugin_ix], + &[add_external_plugin_adapter_ix], Some(&context.payer.pubkey()), &[&context.payer], context.last_blockhash, @@ -92,11 +95,11 @@ async fn test_add_lifecycle_hook() { name: None, uri: None, plugins: vec![], - external_plugins: vec![ExternalPlugin::LifecycleHook(LifecycleHook { + external_plugin_adapters: vec![ExternalPluginAdapter::LifecycleHook(LifecycleHook { hooked_program: pubkey!("MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr"), extra_accounts: None, data_authority: Some(PluginAuthority::UpdateAuthority), - schema: ExternalPluginSchema::Binary, + schema: ExternalPluginAdapterSchema::Binary, })], }, ) @@ -122,7 +125,7 @@ async fn test_cannot_add_lifecycle_hook_with_duplicate_lifecycle_checks() { update_authority: None, collection: None, plugins: vec![], - external_plugins: vec![], + external_plugin_adapters: vec![], }, ) .await @@ -139,15 +142,15 @@ async fn test_cannot_add_lifecycle_hook_with_duplicate_lifecycle_checks() { name: None, uri: None, plugins: vec![], - external_plugins: vec![], + external_plugin_adapters: vec![], }, ) .await; - let add_external_plugin_ix = AddExternalPluginV1Builder::new() + let add_external_plugin_adapter_ix = AddExternalPluginAdapterV1Builder::new() .asset(asset.pubkey()) .payer(context.payer.pubkey()) - .init_info(ExternalPluginInitInfo::LifecycleHook( + .init_info(ExternalPluginAdapterInitInfo::LifecycleHook( LifecycleHookInitInfo { hooked_program: pubkey!("MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr"), init_plugin_authority: Some(PluginAuthority::UpdateAuthority), @@ -169,7 +172,7 @@ async fn test_cannot_add_lifecycle_hook_with_duplicate_lifecycle_checks() { .instruction(); let tx = Transaction::new_signed_with_payer( - &[add_external_plugin_ix], + &[add_external_plugin_adapter_ix], Some(&context.payer.pubkey()), &[&context.payer], context.last_blockhash, @@ -192,7 +195,7 @@ async fn test_cannot_add_lifecycle_hook_with_duplicate_lifecycle_checks() { name: None, uri: None, plugins: vec![], - external_plugins: vec![], + external_plugin_adapters: vec![], }, ) .await; @@ -216,7 +219,7 @@ async fn test_temporarily_cannot_add_lifecycle_hook() { update_authority: None, collection: None, plugins: vec![], - external_plugins: vec![], + external_plugin_adapters: vec![], }, ) .await @@ -233,15 +236,15 @@ async fn test_temporarily_cannot_add_lifecycle_hook() { name: None, uri: None, plugins: vec![], - external_plugins: vec![], + external_plugin_adapters: vec![], }, ) .await; - let add_external_plugin_ix = AddExternalPluginV1Builder::new() + let add_external_plugin_adapter_ix = AddExternalPluginAdapterV1Builder::new() .asset(asset.pubkey()) .payer(context.payer.pubkey()) - .init_info(ExternalPluginInitInfo::LifecycleHook( + .init_info(ExternalPluginAdapterInitInfo::LifecycleHook( LifecycleHookInitInfo { hooked_program: pubkey!("MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr"), init_plugin_authority: Some(PluginAuthority::UpdateAuthority), @@ -257,7 +260,7 @@ async fn test_temporarily_cannot_add_lifecycle_hook() { .instruction(); let tx = Transaction::new_signed_with_payer( - &[add_external_plugin_ix], + &[add_external_plugin_adapter_ix], Some(&context.payer.pubkey()), &[&context.payer], context.last_blockhash, @@ -280,7 +283,7 @@ async fn test_temporarily_cannot_add_lifecycle_hook() { name: None, uri: None, plugins: vec![], - external_plugins: vec![], + external_plugin_adapters: vec![], }, ) .await; @@ -300,7 +303,7 @@ async fn test_temporarily_cannot_add_lifecycle_hook_on_collection() { name: None, uri: None, plugins: vec![], - external_plugins: vec![], + external_plugin_adapters: vec![], }, ) .await @@ -321,10 +324,10 @@ async fn test_temporarily_cannot_add_lifecycle_hook_on_collection() { ) .await; - let add_external_plugin_ix = AddCollectionExternalPluginV1Builder::new() + let add_external_plugin_adapter_ix = AddCollectionExternalPluginAdapterV1Builder::new() .collection(collection.pubkey()) .payer(context.payer.pubkey()) - .init_info(ExternalPluginInitInfo::LifecycleHook( + .init_info(ExternalPluginAdapterInitInfo::LifecycleHook( LifecycleHookInitInfo { hooked_program: pubkey!("MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr"), init_plugin_authority: Some(PluginAuthority::UpdateAuthority), @@ -340,7 +343,7 @@ async fn test_temporarily_cannot_add_lifecycle_hook_on_collection() { .instruction(); let tx = Transaction::new_signed_with_payer( - &[add_external_plugin_ix], + &[add_external_plugin_adapter_ix], Some(&context.payer.pubkey()), &[&context.payer], context.last_blockhash, @@ -375,7 +378,7 @@ async fn test_add_oracle() { update_authority: None, collection: None, plugins: vec![], - external_plugins: vec![], + external_plugin_adapters: vec![], }, ) .await @@ -392,28 +395,28 @@ async fn test_add_oracle() { name: None, uri: None, plugins: vec![], - external_plugins: vec![], + external_plugin_adapters: vec![], }, ) .await; - let add_external_plugin_ix = AddExternalPluginV1Builder::new() + let add_external_plugin_adapter_ix = AddExternalPluginAdapterV1Builder::new() .asset(asset.pubkey()) .payer(context.payer.pubkey()) - .init_info(ExternalPluginInitInfo::Oracle(OracleInitInfo { + .init_info(ExternalPluginAdapterInitInfo::Oracle(OracleInitInfo { base_address: Pubkey::default(), init_plugin_authority: Some(PluginAuthority::UpdateAuthority), lifecycle_checks: vec![( HookableLifecycleEvent::Transfer, ExternalCheckResult { flags: 4 }, )], - pda: None, + base_address_config: None, results_offset: None, })) .instruction(); let tx = Transaction::new_signed_with_payer( - &[add_external_plugin_ix], + &[add_external_plugin_adapter_ix], Some(&context.payer.pubkey()), &[&context.payer], context.last_blockhash, @@ -430,9 +433,9 @@ async fn test_add_oracle() { name: None, uri: None, plugins: vec![], - external_plugins: vec![ExternalPlugin::Oracle(Oracle { + external_plugin_adapters: vec![ExternalPluginAdapter::Oracle(Oracle { base_address: Pubkey::default(), - pda: None, + base_address_config: None, results_offset: ValidationResultsOffset::NoOffset, })], }, @@ -458,7 +461,7 @@ async fn test_cannot_add_oracle_with_duplicate_lifecycle_checks() { update_authority: None, collection: None, plugins: vec![], - external_plugins: vec![], + external_plugin_adapters: vec![], }, ) .await @@ -475,15 +478,15 @@ async fn test_cannot_add_oracle_with_duplicate_lifecycle_checks() { name: None, uri: None, plugins: vec![], - external_plugins: vec![], + external_plugin_adapters: vec![], }, ) .await; - let add_external_plugin_ix = AddExternalPluginV1Builder::new() + let add_external_plugin_adapter_ix = AddExternalPluginAdapterV1Builder::new() .asset(asset.pubkey()) .payer(context.payer.pubkey()) - .init_info(ExternalPluginInitInfo::Oracle(OracleInitInfo { + .init_info(ExternalPluginAdapterInitInfo::Oracle(OracleInitInfo { base_address: Pubkey::default(), init_plugin_authority: Some(PluginAuthority::UpdateAuthority), lifecycle_checks: vec![ @@ -496,13 +499,13 @@ async fn test_cannot_add_oracle_with_duplicate_lifecycle_checks() { ExternalCheckResult { flags: 4 }, ), ], - pda: None, + base_address_config: None, results_offset: None, })) .instruction(); let tx = Transaction::new_signed_with_payer( - &[add_external_plugin_ix], + &[add_external_plugin_adapter_ix], Some(&context.payer.pubkey()), &[&context.payer], context.last_blockhash, @@ -525,7 +528,7 @@ async fn test_cannot_add_oracle_with_duplicate_lifecycle_checks() { name: None, uri: None, plugins: vec![], - external_plugins: vec![], + external_plugin_adapters: vec![], }, ) .await; @@ -550,7 +553,7 @@ async fn test_add_data_store() { update_authority: None, collection: None, plugins: vec![], - external_plugins: vec![], + external_plugin_adapters: vec![], }, ) .await @@ -567,23 +570,25 @@ async fn test_add_data_store() { name: None, uri: None, plugins: vec![], - external_plugins: vec![], + external_plugin_adapters: vec![], }, ) .await; - let add_external_plugin_ix = AddExternalPluginV1Builder::new() + let add_external_plugin_adapter_ix = AddExternalPluginAdapterV1Builder::new() .asset(asset.pubkey()) .payer(context.payer.pubkey()) - .init_info(ExternalPluginInitInfo::DataStore(DataStoreInitInfo { - init_plugin_authority: Some(PluginAuthority::UpdateAuthority), - data_authority: PluginAuthority::UpdateAuthority, - schema: None, - })) + .init_info(ExternalPluginAdapterInitInfo::DataStore( + DataStoreInitInfo { + init_plugin_authority: Some(PluginAuthority::UpdateAuthority), + data_authority: PluginAuthority::UpdateAuthority, + schema: None, + }, + )) .instruction(); let tx = Transaction::new_signed_with_payer( - &[add_external_plugin_ix], + &[add_external_plugin_adapter_ix], Some(&context.payer.pubkey()), &[&context.payer], context.last_blockhash, @@ -600,9 +605,9 @@ async fn test_add_data_store() { name: None, uri: None, plugins: vec![], - external_plugins: vec![ExternalPlugin::DataStore(DataStore { + external_plugin_adapters: vec![ExternalPluginAdapter::DataStore(DataStore { data_authority: PluginAuthority::UpdateAuthority, - schema: ExternalPluginSchema::Binary, + schema: ExternalPluginAdapterSchema::Binary, })], }, ) @@ -627,7 +632,7 @@ async fn test_temporarily_cannot_add_data_store() { update_authority: None, collection: None, plugins: vec![], - external_plugins: vec![], + external_plugin_adapters: vec![], }, ) .await @@ -644,23 +649,25 @@ async fn test_temporarily_cannot_add_data_store() { name: None, uri: None, plugins: vec![], - external_plugins: vec![], + external_plugin_adapters: vec![], }, ) .await; - let add_external_plugin_ix = AddExternalPluginV1Builder::new() + let add_external_plugin_adapter_ix = AddExternalPluginAdapterV1Builder::new() .asset(asset.pubkey()) .payer(context.payer.pubkey()) - .init_info(ExternalPluginInitInfo::DataStore(DataStoreInitInfo { - init_plugin_authority: Some(PluginAuthority::UpdateAuthority), - data_authority: PluginAuthority::UpdateAuthority, - schema: None, - })) + .init_info(ExternalPluginAdapterInitInfo::DataStore( + DataStoreInitInfo { + init_plugin_authority: Some(PluginAuthority::UpdateAuthority), + data_authority: PluginAuthority::UpdateAuthority, + schema: None, + }, + )) .instruction(); let tx = Transaction::new_signed_with_payer( - &[add_external_plugin_ix], + &[add_external_plugin_adapter_ix], Some(&context.payer.pubkey()), &[&context.payer], context.last_blockhash, @@ -683,7 +690,7 @@ async fn test_temporarily_cannot_add_data_store() { name: None, uri: None, plugins: vec![], - external_plugins: vec![], + external_plugin_adapters: vec![], }, ) .await; @@ -703,7 +710,7 @@ async fn test_temporarily_cannot_add_data_store_on_collection() { name: None, uri: None, plugins: vec![], - external_plugins: vec![], + external_plugin_adapters: vec![], }, ) .await @@ -724,18 +731,20 @@ async fn test_temporarily_cannot_add_data_store_on_collection() { ) .await; - let add_external_plugin_ix = AddCollectionExternalPluginV1Builder::new() + let add_external_plugin_adapter_ix = AddCollectionExternalPluginAdapterV1Builder::new() .collection(collection.pubkey()) .payer(context.payer.pubkey()) - .init_info(ExternalPluginInitInfo::DataStore(DataStoreInitInfo { - init_plugin_authority: Some(PluginAuthority::UpdateAuthority), - data_authority: PluginAuthority::UpdateAuthority, - schema: None, - })) + .init_info(ExternalPluginAdapterInitInfo::DataStore( + DataStoreInitInfo { + init_plugin_authority: Some(PluginAuthority::UpdateAuthority), + data_authority: PluginAuthority::UpdateAuthority, + schema: None, + }, + )) .instruction(); let tx = Transaction::new_signed_with_payer( - &[add_external_plugin_ix], + &[add_external_plugin_adapter_ix], Some(&context.payer.pubkey()), &[&context.payer], context.last_blockhash, @@ -753,7 +762,7 @@ async fn test_temporarily_cannot_add_data_store_on_collection() { } #[tokio::test] -async fn test_cannot_add_duplicate_external_plugin() { +async fn test_cannot_add_duplicate_external_plugin_adapter() { let mut context = program_test().start_with_context().await; let asset = Keypair::new(); @@ -770,7 +779,7 @@ async fn test_cannot_add_duplicate_external_plugin() { update_authority: None, collection: None, plugins: vec![], - external_plugins: vec![], + external_plugin_adapters: vec![], }, ) .await @@ -787,43 +796,46 @@ async fn test_cannot_add_duplicate_external_plugin() { name: None, uri: None, plugins: vec![], - external_plugins: vec![], + external_plugin_adapters: vec![], }, ) .await; - let add_external_plugin_ix0 = AddExternalPluginV1Builder::new() + let add_external_plugin_adapter_ix0 = AddExternalPluginAdapterV1Builder::new() .asset(asset.pubkey()) .payer(context.payer.pubkey()) - .init_info(ExternalPluginInitInfo::Oracle(OracleInitInfo { + .init_info(ExternalPluginAdapterInitInfo::Oracle(OracleInitInfo { base_address: Pubkey::default(), init_plugin_authority: Some(PluginAuthority::UpdateAuthority), lifecycle_checks: vec![( HookableLifecycleEvent::Transfer, ExternalCheckResult { flags: 4 }, )], - pda: None, + base_address_config: None, results_offset: None, })) .instruction(); - let add_external_plugin_ix1 = AddExternalPluginV1Builder::new() + let add_external_plugin_adapter_ix1 = AddExternalPluginAdapterV1Builder::new() .asset(asset.pubkey()) .payer(context.payer.pubkey()) - .init_info(ExternalPluginInitInfo::Oracle(OracleInitInfo { + .init_info(ExternalPluginAdapterInitInfo::Oracle(OracleInitInfo { base_address: Pubkey::default(), init_plugin_authority: Some(PluginAuthority::UpdateAuthority), lifecycle_checks: vec![( HookableLifecycleEvent::Transfer, ExternalCheckResult { flags: 4 }, )], - pda: None, + base_address_config: None, results_offset: None, })) .instruction(); let tx = Transaction::new_signed_with_payer( - &[add_external_plugin_ix0, add_external_plugin_ix1], + &[ + add_external_plugin_adapter_ix0, + add_external_plugin_adapter_ix1, + ], Some(&context.payer.pubkey()), &[&context.payer], context.last_blockhash, @@ -835,5 +847,5 @@ async fn test_cannot_add_duplicate_external_plugin() { .await .unwrap_err(); - assert_custom_instruction_error!(1, error, MplCoreError::ExternalPluginAlreadyExists); + assert_custom_instruction_error!(1, error, MplCoreError::ExternalPluginAdapterAlreadyExists); } diff --git a/clients/rust/tests/create.rs b/clients/rust/tests/create.rs index 83a7ca5b..a48f947f 100644 --- a/clients/rust/tests/create.rs +++ b/clients/rust/tests/create.rs @@ -26,7 +26,7 @@ async fn create_asset_in_account_state() { update_authority: None, collection: None, plugins: vec![], - external_plugins: vec![], + external_plugin_adapters: vec![], }, ) .await @@ -43,7 +43,7 @@ async fn create_asset_in_account_state() { name: None, uri: None, plugins: vec![], - external_plugins: vec![], + external_plugin_adapters: vec![], }, ) .await; @@ -71,7 +71,7 @@ async fn create_asset_with_different_payer() { update_authority: None, collection: None, plugins: vec![], - external_plugins: vec![], + external_plugin_adapters: vec![], }, ) .await @@ -86,7 +86,7 @@ async fn create_asset_with_different_payer() { name: None, uri: None, plugins: vec![], - external_plugins: vec![], + external_plugin_adapters: vec![], }, ) .await; @@ -113,7 +113,7 @@ async fn create_asset_with_plugins() { plugin: Plugin::FreezeDelegate(FreezeDelegate { frozen: false }), authority: None, }], - external_plugins: vec![], + external_plugin_adapters: vec![], }, ) .await @@ -133,7 +133,7 @@ async fn create_asset_with_plugins() { plugin: Plugin::FreezeDelegate(FreezeDelegate { frozen: false }), authority: Some(PluginAuthority::Owner), }], - external_plugins: vec![], + external_plugin_adapters: vec![], }, ) .await; @@ -161,7 +161,7 @@ async fn create_asset_with_different_update_authority() { update_authority: Some(update_authority.pubkey()), collection: None, plugins: vec![], - external_plugins: vec![], + external_plugin_adapters: vec![], }, ) .await @@ -177,7 +177,7 @@ async fn create_asset_with_different_update_authority() { name: None, uri: None, plugins: vec![], - external_plugins: vec![], + external_plugin_adapters: vec![], }, ) .await; @@ -208,7 +208,7 @@ async fn create_asset_with_plugins_with_different_update_authority() { plugin: Plugin::FreezeDelegate(FreezeDelegate { frozen: false }), authority: None, }], - external_plugins: vec![], + external_plugin_adapters: vec![], }, ) .await @@ -227,7 +227,7 @@ async fn create_asset_with_plugins_with_different_update_authority() { plugin: Plugin::FreezeDelegate(FreezeDelegate { frozen: false }), authority: Some(PluginAuthority::Owner), }], - external_plugins: vec![], + external_plugin_adapters: vec![], }, ) .await; diff --git a/clients/rust/tests/create_collection.rs b/clients/rust/tests/create_collection.rs index ddb8a898..84ff4ddf 100644 --- a/clients/rust/tests/create_collection.rs +++ b/clients/rust/tests/create_collection.rs @@ -20,7 +20,7 @@ async fn test_create_collection() { name: None, uri: None, plugins: vec![], - external_plugins: vec![], + external_plugin_adapters: vec![], }, ) .await @@ -60,7 +60,7 @@ async fn create_collection_with_different_payer() { name: None, uri: None, plugins: vec![], - external_plugins: vec![], + external_plugin_adapters: vec![], }, ) .await @@ -106,7 +106,7 @@ async fn create_collection_with_plugins() { rule_set: RuleSet::ProgramDenyList(vec![]), }), }], - external_plugins: vec![], + external_plugin_adapters: vec![], }, ) .await @@ -156,7 +156,7 @@ async fn create_collection_with_different_update_authority() { name: None, uri: None, plugins: vec![], - external_plugins: vec![], + external_plugin_adapters: vec![], }, ) .await @@ -205,7 +205,7 @@ async fn create_collection_with_plugins_with_different_plugin_authority() { rule_set: RuleSet::ProgramDenyList(vec![]), }), }], - external_plugins: vec![], + external_plugin_adapters: vec![], }, ) .await diff --git a/clients/rust/tests/create_with_external_plugins.rs b/clients/rust/tests/create_with_external_plugins.rs index 7734728f..411e48ee 100644 --- a/clients/rust/tests/create_with_external_plugins.rs +++ b/clients/rust/tests/create_with_external_plugins.rs @@ -3,9 +3,10 @@ pub mod setup; use mpl_core::{ errors::MplCoreError, types::{ - DataStore, DataStoreInitInfo, ExternalCheckResult, ExternalPlugin, ExternalPluginInitInfo, - ExternalPluginSchema, HookableLifecycleEvent, LifecycleHook, LifecycleHookInitInfo, Oracle, - OracleInitInfo, PluginAuthority, UpdateAuthority, ValidationResultsOffset, + DataStore, DataStoreInitInfo, ExternalCheckResult, ExternalPluginAdapter, + ExternalPluginAdapterInitInfo, ExternalPluginAdapterSchema, HookableLifecycleEvent, + LifecycleHook, LifecycleHookInitInfo, Oracle, OracleInitInfo, PluginAuthority, + UpdateAuthority, ValidationResultsOffset, }, }; pub use setup::*; @@ -33,7 +34,7 @@ async fn test_create_lifecycle_hook() { update_authority: None, collection: None, plugins: vec![], - external_plugins: vec![ExternalPluginInitInfo::LifecycleHook( + external_plugin_adapters: vec![ExternalPluginAdapterInitInfo::LifecycleHook( LifecycleHookInitInfo { hooked_program: pubkey!("MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr"), init_plugin_authority: Some(PluginAuthority::UpdateAuthority), @@ -62,11 +63,11 @@ async fn test_create_lifecycle_hook() { name: None, uri: None, plugins: vec![], - external_plugins: vec![ExternalPlugin::LifecycleHook(LifecycleHook { + external_plugin_adapters: vec![ExternalPluginAdapter::LifecycleHook(LifecycleHook { hooked_program: pubkey!("MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr"), extra_accounts: None, data_authority: Some(PluginAuthority::UpdateAuthority), - schema: ExternalPluginSchema::Binary, + schema: ExternalPluginAdapterSchema::Binary, })], }, ) @@ -92,7 +93,7 @@ async fn test_cannot_create_lifecycle_hook_with_duplicate_lifecycle_checks() { update_authority: None, collection: None, plugins: vec![], - external_plugins: vec![ExternalPluginInitInfo::LifecycleHook( + external_plugin_adapters: vec![ExternalPluginAdapterInitInfo::LifecycleHook( LifecycleHookInitInfo { hooked_program: pubkey!("MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr"), init_plugin_authority: Some(PluginAuthority::UpdateAuthority), @@ -137,7 +138,7 @@ async fn test_temporarily_cannot_create_lifecycle_hook() { update_authority: None, collection: None, plugins: vec![], - external_plugins: vec![ExternalPluginInitInfo::LifecycleHook( + external_plugin_adapters: vec![ExternalPluginAdapterInitInfo::LifecycleHook( LifecycleHookInitInfo { hooked_program: pubkey!("MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr"), init_plugin_authority: Some(PluginAuthority::UpdateAuthority), @@ -172,7 +173,7 @@ async fn test_temporarily_cannot_create_lifecycle_hook_on_collection() { name: None, uri: None, plugins: vec![], - external_plugins: vec![ExternalPluginInitInfo::LifecycleHook( + external_plugin_adapters: vec![ExternalPluginAdapterInitInfo::LifecycleHook( LifecycleHookInitInfo { hooked_program: pubkey!("MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr"), init_plugin_authority: Some(PluginAuthority::UpdateAuthority), @@ -211,14 +212,14 @@ async fn test_create_oracle() { update_authority: None, collection: None, plugins: vec![], - external_plugins: vec![ExternalPluginInitInfo::Oracle(OracleInitInfo { + external_plugin_adapters: vec![ExternalPluginAdapterInitInfo::Oracle(OracleInitInfo { base_address: Pubkey::default(), init_plugin_authority: Some(PluginAuthority::UpdateAuthority), lifecycle_checks: vec![( HookableLifecycleEvent::Transfer, ExternalCheckResult { flags: 4 }, )], - pda: None, + base_address_config: None, results_offset: None, })], }, @@ -237,9 +238,9 @@ async fn test_create_oracle() { name: None, uri: None, plugins: vec![], - external_plugins: vec![ExternalPlugin::Oracle(Oracle { + external_plugin_adapters: vec![ExternalPluginAdapter::Oracle(Oracle { base_address: Pubkey::default(), - pda: None, + base_address_config: None, results_offset: ValidationResultsOffset::NoOffset, })], }, @@ -265,7 +266,7 @@ async fn test_cannot_create_oracle_with_duplicate_lifecycle_checks() { update_authority: None, collection: None, plugins: vec![], - external_plugins: vec![ExternalPluginInitInfo::Oracle(OracleInitInfo { + external_plugin_adapters: vec![ExternalPluginAdapterInitInfo::Oracle(OracleInitInfo { base_address: Pubkey::default(), init_plugin_authority: Some(PluginAuthority::UpdateAuthority), lifecycle_checks: vec![ @@ -278,7 +279,7 @@ async fn test_cannot_create_oracle_with_duplicate_lifecycle_checks() { ExternalCheckResult { flags: 4 }, ), ], - pda: None, + base_address_config: None, results_offset: None, })], }, @@ -308,11 +309,13 @@ async fn test_create_data_store() { update_authority: None, collection: None, plugins: vec![], - external_plugins: vec![ExternalPluginInitInfo::DataStore(DataStoreInitInfo { - init_plugin_authority: Some(PluginAuthority::UpdateAuthority), - data_authority: PluginAuthority::UpdateAuthority, - schema: None, - })], + external_plugin_adapters: vec![ExternalPluginAdapterInitInfo::DataStore( + DataStoreInitInfo { + init_plugin_authority: Some(PluginAuthority::UpdateAuthority), + data_authority: PluginAuthority::UpdateAuthority, + schema: None, + }, + )], }, ) .await @@ -329,9 +332,9 @@ async fn test_create_data_store() { name: None, uri: None, plugins: vec![], - external_plugins: vec![ExternalPlugin::DataStore(DataStore { + external_plugin_adapters: vec![ExternalPluginAdapter::DataStore(DataStore { data_authority: PluginAuthority::UpdateAuthority, - schema: ExternalPluginSchema::Binary, + schema: ExternalPluginAdapterSchema::Binary, })], }, ) @@ -356,11 +359,13 @@ async fn test_temporarily_cannot_create_data_store() { update_authority: None, collection: None, plugins: vec![], - external_plugins: vec![ExternalPluginInitInfo::DataStore(DataStoreInitInfo { - init_plugin_authority: Some(PluginAuthority::UpdateAuthority), - data_authority: PluginAuthority::UpdateAuthority, - schema: None, - })], + external_plugin_adapters: vec![ExternalPluginAdapterInitInfo::DataStore( + DataStoreInitInfo { + init_plugin_authority: Some(PluginAuthority::UpdateAuthority), + data_authority: PluginAuthority::UpdateAuthority, + schema: None, + }, + )], }, ) .await @@ -383,11 +388,13 @@ async fn test_temporarily_cannot_create_data_store_on_collection() { name: None, uri: None, plugins: vec![], - external_plugins: vec![ExternalPluginInitInfo::DataStore(DataStoreInitInfo { - init_plugin_authority: Some(PluginAuthority::UpdateAuthority), - data_authority: PluginAuthority::UpdateAuthority, - schema: None, - })], + external_plugin_adapters: vec![ExternalPluginAdapterInitInfo::DataStore( + DataStoreInitInfo { + init_plugin_authority: Some(PluginAuthority::UpdateAuthority), + data_authority: PluginAuthority::UpdateAuthority, + schema: None, + }, + )], }, ) .await diff --git a/clients/rust/tests/plugins.rs b/clients/rust/tests/plugins.rs index 5c789ce2..431ddb28 100644 --- a/clients/rust/tests/plugins.rs +++ b/clients/rust/tests/plugins.rs @@ -51,7 +51,7 @@ async fn test_fetch_plugin() { }), }, ], - external_plugins: vec![], + external_plugin_adapters: vec![], }, ) .await @@ -84,7 +84,7 @@ async fn test_fetch_plugin() { }), }, ], - external_plugins: vec![], + external_plugin_adapters: vec![], }, ) .await; @@ -161,7 +161,7 @@ async fn test_fetch_plugins() { }), }, ], - external_plugins: vec![], + external_plugin_adapters: vec![], }, ) .await @@ -194,7 +194,7 @@ async fn test_fetch_plugins() { }), }, ], - external_plugins: vec![], + external_plugin_adapters: vec![], }, ) .await; @@ -272,7 +272,7 @@ async fn test_list_plugins() { }), }, ], - external_plugins: vec![], + external_plugin_adapters: vec![], }, ) .await @@ -305,7 +305,7 @@ async fn test_list_plugins() { }), }, ], - external_plugins: vec![], + external_plugin_adapters: vec![], }, ) .await; diff --git a/clients/rust/tests/remove_external_plugins.rs b/clients/rust/tests/remove_external_plugins.rs index 322ffe9c..6e1a99ca 100644 --- a/clients/rust/tests/remove_external_plugins.rs +++ b/clients/rust/tests/remove_external_plugins.rs @@ -1,12 +1,12 @@ #![cfg(feature = "test-sbf")] pub mod setup; use mpl_core::{ - instructions::RemoveExternalPluginV1Builder, + instructions::RemoveExternalPluginAdapterV1Builder, types::{ - DataStore, DataStoreInitInfo, ExternalCheckResult, ExternalPlugin, ExternalPluginInitInfo, - ExternalPluginKey, ExternalPluginSchema, HookableLifecycleEvent, LifecycleHook, - LifecycleHookInitInfo, Oracle, OracleInitInfo, PluginAuthority, UpdateAuthority, - ValidationResultsOffset, + DataStore, DataStoreInitInfo, ExternalCheckResult, ExternalPluginAdapter, + ExternalPluginAdapterInitInfo, ExternalPluginAdapterKey, ExternalPluginAdapterSchema, + HookableLifecycleEvent, LifecycleHook, LifecycleHookInitInfo, Oracle, OracleInitInfo, + PluginAuthority, UpdateAuthority, ValidationResultsOffset, }, }; pub use setup::*; @@ -34,7 +34,7 @@ async fn test_remove_lifecycle_hook() { update_authority: None, collection: None, plugins: vec![], - external_plugins: vec![ExternalPluginInitInfo::LifecycleHook( + external_plugin_adapters: vec![ExternalPluginAdapterInitInfo::LifecycleHook( LifecycleHookInitInfo { hooked_program: pubkey!("MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr"), init_plugin_authority: Some(PluginAuthority::UpdateAuthority), @@ -63,20 +63,20 @@ async fn test_remove_lifecycle_hook() { name: None, uri: None, plugins: vec![], - external_plugins: vec![ExternalPlugin::LifecycleHook(LifecycleHook { + external_plugin_adapters: vec![ExternalPluginAdapter::LifecycleHook(LifecycleHook { hooked_program: pubkey!("MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr"), extra_accounts: None, data_authority: Some(PluginAuthority::UpdateAuthority), - schema: ExternalPluginSchema::Binary, + schema: ExternalPluginAdapterSchema::Binary, })], }, ) .await; - let ix = RemoveExternalPluginV1Builder::new() + let ix = RemoveExternalPluginAdapterV1Builder::new() .asset(asset.pubkey()) .payer(context.payer.pubkey()) - .key(ExternalPluginKey::LifecycleHook(pubkey!( + .key(ExternalPluginAdapterKey::LifecycleHook(pubkey!( "MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr" ))) .instruction(); @@ -99,7 +99,7 @@ async fn test_remove_lifecycle_hook() { name: None, uri: None, plugins: vec![], - external_plugins: vec![], + external_plugin_adapters: vec![], }, ) .await; @@ -123,14 +123,14 @@ async fn test_remove_oracle() { update_authority: None, collection: None, plugins: vec![], - external_plugins: vec![ExternalPluginInitInfo::Oracle(OracleInitInfo { + external_plugin_adapters: vec![ExternalPluginAdapterInitInfo::Oracle(OracleInitInfo { base_address: Pubkey::default(), init_plugin_authority: Some(PluginAuthority::UpdateAuthority), lifecycle_checks: vec![( HookableLifecycleEvent::Transfer, ExternalCheckResult { flags: 4 }, )], - pda: None, + base_address_config: None, results_offset: None, })], }, @@ -149,19 +149,19 @@ async fn test_remove_oracle() { name: None, uri: None, plugins: vec![], - external_plugins: vec![ExternalPlugin::Oracle(Oracle { + external_plugin_adapters: vec![ExternalPluginAdapter::Oracle(Oracle { base_address: Pubkey::default(), - pda: None, + base_address_config: None, results_offset: ValidationResultsOffset::NoOffset, })], }, ) .await; - let ix = RemoveExternalPluginV1Builder::new() + let ix = RemoveExternalPluginAdapterV1Builder::new() .asset(asset.pubkey()) .payer(context.payer.pubkey()) - .key(ExternalPluginKey::Oracle(Pubkey::default())) + .key(ExternalPluginAdapterKey::Oracle(Pubkey::default())) .instruction(); let tx = Transaction::new_signed_with_payer( @@ -182,7 +182,7 @@ async fn test_remove_oracle() { name: None, uri: None, plugins: vec![], - external_plugins: vec![], + external_plugin_adapters: vec![], }, ) .await; @@ -207,11 +207,13 @@ async fn test_remove_data_store() { update_authority: None, collection: None, plugins: vec![], - external_plugins: vec![ExternalPluginInitInfo::DataStore(DataStoreInitInfo { - init_plugin_authority: Some(PluginAuthority::UpdateAuthority), - data_authority: PluginAuthority::UpdateAuthority, - schema: None, - })], + external_plugin_adapters: vec![ExternalPluginAdapterInitInfo::DataStore( + DataStoreInitInfo { + init_plugin_authority: Some(PluginAuthority::UpdateAuthority), + data_authority: PluginAuthority::UpdateAuthority, + schema: None, + }, + )], }, ) .await @@ -228,18 +230,18 @@ async fn test_remove_data_store() { name: None, uri: None, plugins: vec![], - external_plugins: vec![ExternalPlugin::DataStore(DataStore { + external_plugin_adapters: vec![ExternalPluginAdapter::DataStore(DataStore { data_authority: PluginAuthority::UpdateAuthority, - schema: ExternalPluginSchema::Binary, + schema: ExternalPluginAdapterSchema::Binary, })], }, ) .await; - let ix = RemoveExternalPluginV1Builder::new() + let ix = RemoveExternalPluginAdapterV1Builder::new() .asset(asset.pubkey()) .payer(context.payer.pubkey()) - .key(ExternalPluginKey::DataStore( + .key(ExternalPluginAdapterKey::DataStore( PluginAuthority::UpdateAuthority, )) .instruction(); @@ -262,7 +264,7 @@ async fn test_remove_data_store() { name: None, uri: None, plugins: vec![], - external_plugins: vec![], + external_plugin_adapters: vec![], }, ) .await; diff --git a/clients/rust/tests/setup/mod.rs b/clients/rust/tests/setup/mod.rs index dd318aa9..6a7c402e 100644 --- a/clients/rust/tests/setup/mod.rs +++ b/clients/rust/tests/setup/mod.rs @@ -1,8 +1,8 @@ use mpl_core::{ instructions::{CreateCollectionV2Builder, CreateV2Builder}, types::{ - DataState, ExternalPlugin, ExternalPluginInitInfo, Key, Plugin, PluginAuthorityPair, - UpdateAuthority, + DataState, ExternalPluginAdapter, ExternalPluginAdapterInitInfo, Key, Plugin, + PluginAuthorityPair, UpdateAuthority, }, Asset, Collection, }; @@ -34,7 +34,7 @@ pub struct CreateAssetHelperArgs<'a> { pub collection: Option, // TODO use PluginList type here pub plugins: Vec, - pub external_plugins: Vec, + pub external_plugin_adapters: Vec, } pub async fn create_asset<'a>( @@ -54,7 +54,7 @@ pub async fn create_asset<'a>( .name(input.name.unwrap_or(DEFAULT_ASSET_NAME.to_owned())) .uri(input.uri.unwrap_or(DEFAULT_ASSET_URI.to_owned())) .plugins(input.plugins) - .external_plugins(input.external_plugins) + .external_plugin_adapters(input.external_plugin_adapters) .instruction(); let mut signers = vec![input.asset, &context.payer]; @@ -80,7 +80,7 @@ pub struct AssertAssetHelperArgs { pub uri: Option, // TODO use PluginList type here pub plugins: Vec, - pub external_plugins: Vec, + pub external_plugin_adapters: Vec, } pub async fn assert_asset(context: &mut ProgramTestContext, input: AssertAssetHelperArgs) { @@ -133,21 +133,27 @@ pub async fn assert_asset(context: &mut ProgramTestContext, input: AssertAssetHe } assert_eq!( - input.external_plugins.len(), - asset.external_plugin_list.lifecycle_hooks.len() - + asset.external_plugin_list.oracles.len() - + asset.external_plugin_list.data_stores.len() + input.external_plugin_adapters.len(), + asset.external_plugin_adapter_list.lifecycle_hooks.len() + + asset.external_plugin_adapter_list.oracles.len() + + asset.external_plugin_adapter_list.data_stores.len() ); - for plugin in input.external_plugins { + for plugin in input.external_plugin_adapters { match plugin { - ExternalPlugin::LifecycleHook(hook) => { - assert!(asset.external_plugin_list.lifecycle_hooks.contains(&hook)) + ExternalPluginAdapter::LifecycleHook(hook) => { + assert!(asset + .external_plugin_adapter_list + .lifecycle_hooks + .contains(&hook)) } - ExternalPlugin::Oracle(oracle) => { - assert!(asset.external_plugin_list.oracles.contains(&oracle)) + ExternalPluginAdapter::Oracle(oracle) => { + assert!(asset.external_plugin_adapter_list.oracles.contains(&oracle)) } - ExternalPlugin::DataStore(data_store) => { - assert!(asset.external_plugin_list.data_stores.contains(&data_store)) + ExternalPluginAdapter::DataStore(data_store) => { + assert!(asset + .external_plugin_adapter_list + .data_stores + .contains(&data_store)) } } } @@ -162,7 +168,7 @@ pub struct CreateCollectionHelperArgs<'a> { pub uri: Option, // TODO use PluginList type here pub plugins: Vec, - pub external_plugins: Vec, + pub external_plugin_adapters: Vec, } pub async fn create_collection<'a>( @@ -178,7 +184,7 @@ pub async fn create_collection<'a>( .name(input.name.unwrap_or(DEFAULT_COLLECTION_NAME.to_owned())) .uri(input.uri.unwrap_or(DEFAULT_COLLECTION_URI.to_owned())) .plugins(input.plugins) - .external_plugins(input.external_plugins) + .external_plugin_adapters(input.external_plugin_adapters) .instruction(); let mut signers = vec![input.collection, &context.payer]; @@ -258,7 +264,7 @@ pub async fn assert_collection( } } - // TODO validate external plugins here. + // TODO validate external plugin adapters here. } pub async fn airdrop( diff --git a/clients/rust/tests/transfer.rs b/clients/rust/tests/transfer.rs index ab51390a..bc4beafd 100644 --- a/clients/rust/tests/transfer.rs +++ b/clients/rust/tests/transfer.rs @@ -27,7 +27,7 @@ async fn transfer_asset_as_owner() { update_authority: None, collection: None, plugins: vec![], - external_plugins: vec![], + external_plugin_adapters: vec![], }, ) .await @@ -59,7 +59,7 @@ async fn transfer_asset_as_owner() { name: None, uri: None, plugins: vec![], - external_plugins: vec![], + external_plugin_adapters: vec![], }, ) .await; @@ -94,7 +94,7 @@ async fn transfer_asset_with_royalties() { rule_set: RuleSet::ProgramDenyList(vec![]), }), }], - external_plugins: vec![], + external_plugin_adapters: vec![], }, ) .await @@ -135,7 +135,7 @@ async fn transfer_asset_with_royalties() { rule_set: RuleSet::ProgramDenyList(vec![]), }), }], - external_plugins: vec![], + external_plugin_adapters: vec![], }, ) .await; diff --git a/clients/rust/tests/update_external_plugins.rs b/clients/rust/tests/update_external_plugins.rs index 4a65984d..22972f9e 100644 --- a/clients/rust/tests/update_external_plugins.rs +++ b/clients/rust/tests/update_external_plugins.rs @@ -2,13 +2,13 @@ pub mod setup; use mpl_core::{ errors::MplCoreError, - instructions::UpdateExternalPluginV1Builder, + instructions::UpdateExternalPluginAdapterV1Builder, types::{ - DataStore, DataStoreInitInfo, DataStoreUpdateInfo, ExternalCheckResult, ExternalPlugin, - ExternalPluginInitInfo, ExternalPluginKey, ExternalPluginSchema, ExternalPluginUpdateInfo, - HookableLifecycleEvent, LifecycleHook, LifecycleHookInitInfo, LifecycleHookUpdateInfo, - Oracle, OracleInitInfo, OracleUpdateInfo, PluginAuthority, UpdateAuthority, - ValidationResultsOffset, + DataStore, DataStoreInitInfo, DataStoreUpdateInfo, ExternalCheckResult, + ExternalPluginAdapter, ExternalPluginAdapterInitInfo, ExternalPluginAdapterKey, + ExternalPluginAdapterSchema, ExternalPluginAdapterUpdateInfo, HookableLifecycleEvent, + LifecycleHook, LifecycleHookInitInfo, LifecycleHookUpdateInfo, Oracle, OracleInitInfo, + OracleUpdateInfo, PluginAuthority, UpdateAuthority, ValidationResultsOffset, }, }; pub use setup::*; @@ -36,7 +36,7 @@ async fn test_update_lifecycle_hook() { update_authority: None, collection: None, plugins: vec![], - external_plugins: vec![ExternalPluginInitInfo::LifecycleHook( + external_plugin_adapters: vec![ExternalPluginAdapterInitInfo::LifecycleHook( LifecycleHookInitInfo { hooked_program: pubkey!("MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr"), init_plugin_authority: Some(PluginAuthority::UpdateAuthority), @@ -65,27 +65,27 @@ async fn test_update_lifecycle_hook() { name: None, uri: None, plugins: vec![], - external_plugins: vec![ExternalPlugin::LifecycleHook(LifecycleHook { + external_plugin_adapters: vec![ExternalPluginAdapter::LifecycleHook(LifecycleHook { hooked_program: pubkey!("MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr"), extra_accounts: None, data_authority: Some(PluginAuthority::UpdateAuthority), - schema: ExternalPluginSchema::Binary, + schema: ExternalPluginAdapterSchema::Binary, })], }, ) .await; - let ix = UpdateExternalPluginV1Builder::new() + let ix = UpdateExternalPluginAdapterV1Builder::new() .asset(asset.pubkey()) .payer(context.payer.pubkey()) - .key(ExternalPluginKey::LifecycleHook(pubkey!( + .key(ExternalPluginAdapterKey::LifecycleHook(pubkey!( "MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr" ))) - .update_info(ExternalPluginUpdateInfo::LifecycleHook( + .update_info(ExternalPluginAdapterUpdateInfo::LifecycleHook( LifecycleHookUpdateInfo { lifecycle_checks: None, extra_accounts: None, - schema: Some(ExternalPluginSchema::Json), + schema: Some(ExternalPluginAdapterSchema::Json), }, )) .instruction(); @@ -108,11 +108,11 @@ async fn test_update_lifecycle_hook() { name: None, uri: None, plugins: vec![], - external_plugins: vec![ExternalPlugin::LifecycleHook(LifecycleHook { + external_plugin_adapters: vec![ExternalPluginAdapter::LifecycleHook(LifecycleHook { hooked_program: pubkey!("MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr"), extra_accounts: None, data_authority: Some(PluginAuthority::UpdateAuthority), - schema: ExternalPluginSchema::Json, + schema: ExternalPluginAdapterSchema::Json, })], }, ) @@ -138,7 +138,7 @@ async fn test_cannot_update_lifecycle_hook_to_have_duplicate_lifecycle_checks() update_authority: None, collection: None, plugins: vec![], - external_plugins: vec![ExternalPluginInitInfo::LifecycleHook( + external_plugin_adapters: vec![ExternalPluginAdapterInitInfo::LifecycleHook( LifecycleHookInitInfo { hooked_program: pubkey!("MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr"), init_plugin_authority: Some(PluginAuthority::UpdateAuthority), @@ -167,23 +167,23 @@ async fn test_cannot_update_lifecycle_hook_to_have_duplicate_lifecycle_checks() name: None, uri: None, plugins: vec![], - external_plugins: vec![ExternalPlugin::LifecycleHook(LifecycleHook { + external_plugin_adapters: vec![ExternalPluginAdapter::LifecycleHook(LifecycleHook { hooked_program: pubkey!("MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr"), extra_accounts: None, data_authority: Some(PluginAuthority::UpdateAuthority), - schema: ExternalPluginSchema::Binary, + schema: ExternalPluginAdapterSchema::Binary, })], }, ) .await; - let ix = UpdateExternalPluginV1Builder::new() + let ix = UpdateExternalPluginAdapterV1Builder::new() .asset(asset.pubkey()) .payer(context.payer.pubkey()) - .key(ExternalPluginKey::LifecycleHook(pubkey!( + .key(ExternalPluginAdapterKey::LifecycleHook(pubkey!( "MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr" ))) - .update_info(ExternalPluginUpdateInfo::LifecycleHook( + .update_info(ExternalPluginAdapterUpdateInfo::LifecycleHook( LifecycleHookUpdateInfo { lifecycle_checks: Some(vec![ ( @@ -196,7 +196,7 @@ async fn test_cannot_update_lifecycle_hook_to_have_duplicate_lifecycle_checks() ), ]), extra_accounts: None, - schema: Some(ExternalPluginSchema::Json), + schema: Some(ExternalPluginAdapterSchema::Json), }, )) .instruction(); @@ -237,14 +237,14 @@ async fn test_update_oracle() { update_authority: None, collection: None, plugins: vec![], - external_plugins: vec![ExternalPluginInitInfo::Oracle(OracleInitInfo { + external_plugin_adapters: vec![ExternalPluginAdapterInitInfo::Oracle(OracleInitInfo { base_address: Pubkey::default(), init_plugin_authority: Some(PluginAuthority::UpdateAuthority), lifecycle_checks: vec![( HookableLifecycleEvent::Transfer, ExternalCheckResult { flags: 4 }, )], - pda: None, + base_address_config: None, results_offset: None, })], }, @@ -263,22 +263,22 @@ async fn test_update_oracle() { name: None, uri: None, plugins: vec![], - external_plugins: vec![ExternalPlugin::Oracle(Oracle { + external_plugin_adapters: vec![ExternalPluginAdapter::Oracle(Oracle { base_address: Pubkey::default(), - pda: None, + base_address_config: None, results_offset: ValidationResultsOffset::NoOffset, })], }, ) .await; - let ix = UpdateExternalPluginV1Builder::new() + let ix = UpdateExternalPluginAdapterV1Builder::new() .asset(asset.pubkey()) .payer(context.payer.pubkey()) - .key(ExternalPluginKey::Oracle(Pubkey::default())) - .update_info(ExternalPluginUpdateInfo::Oracle(OracleUpdateInfo { + .key(ExternalPluginAdapterKey::Oracle(Pubkey::default())) + .update_info(ExternalPluginAdapterUpdateInfo::Oracle(OracleUpdateInfo { lifecycle_checks: None, - pda: None, + base_address_config: None, results_offset: Some(ValidationResultsOffset::Custom(10)), })) .instruction(); @@ -301,9 +301,9 @@ async fn test_update_oracle() { name: None, uri: None, plugins: vec![], - external_plugins: vec![ExternalPlugin::Oracle(Oracle { + external_plugin_adapters: vec![ExternalPluginAdapter::Oracle(Oracle { base_address: Pubkey::default(), - pda: None, + base_address_config: None, results_offset: ValidationResultsOffset::Custom(10), })], }, @@ -329,14 +329,14 @@ async fn test_cannot_update_oracle_to_have_duplicate_lifecycle_checks() { update_authority: None, collection: None, plugins: vec![], - external_plugins: vec![ExternalPluginInitInfo::Oracle(OracleInitInfo { + external_plugin_adapters: vec![ExternalPluginAdapterInitInfo::Oracle(OracleInitInfo { base_address: Pubkey::default(), init_plugin_authority: Some(PluginAuthority::UpdateAuthority), lifecycle_checks: vec![( HookableLifecycleEvent::Transfer, ExternalCheckResult { flags: 4 }, )], - pda: None, + base_address_config: None, results_offset: None, })], }, @@ -355,20 +355,20 @@ async fn test_cannot_update_oracle_to_have_duplicate_lifecycle_checks() { name: None, uri: None, plugins: vec![], - external_plugins: vec![ExternalPlugin::Oracle(Oracle { + external_plugin_adapters: vec![ExternalPluginAdapter::Oracle(Oracle { base_address: Pubkey::default(), - pda: None, + base_address_config: None, results_offset: ValidationResultsOffset::NoOffset, })], }, ) .await; - let ix = UpdateExternalPluginV1Builder::new() + let ix = UpdateExternalPluginAdapterV1Builder::new() .asset(asset.pubkey()) .payer(context.payer.pubkey()) - .key(ExternalPluginKey::Oracle(Pubkey::default())) - .update_info(ExternalPluginUpdateInfo::Oracle(OracleUpdateInfo { + .key(ExternalPluginAdapterKey::Oracle(Pubkey::default())) + .update_info(ExternalPluginAdapterUpdateInfo::Oracle(OracleUpdateInfo { lifecycle_checks: Some(vec![ ( HookableLifecycleEvent::Transfer, @@ -379,7 +379,7 @@ async fn test_cannot_update_oracle_to_have_duplicate_lifecycle_checks() { ExternalCheckResult { flags: 4 }, ), ]), - pda: None, + base_address_config: None, results_offset: Some(ValidationResultsOffset::Custom(10)), })) .instruction(); @@ -421,11 +421,13 @@ async fn test_update_data_store() { update_authority: None, collection: None, plugins: vec![], - external_plugins: vec![ExternalPluginInitInfo::DataStore(DataStoreInitInfo { - init_plugin_authority: Some(PluginAuthority::UpdateAuthority), - data_authority: PluginAuthority::UpdateAuthority, - schema: None, - })], + external_plugin_adapters: vec![ExternalPluginAdapterInitInfo::DataStore( + DataStoreInitInfo { + init_plugin_authority: Some(PluginAuthority::UpdateAuthority), + data_authority: PluginAuthority::UpdateAuthority, + schema: None, + }, + )], }, ) .await @@ -442,23 +444,25 @@ async fn test_update_data_store() { name: None, uri: None, plugins: vec![], - external_plugins: vec![ExternalPlugin::DataStore(DataStore { + external_plugin_adapters: vec![ExternalPluginAdapter::DataStore(DataStore { data_authority: PluginAuthority::UpdateAuthority, - schema: ExternalPluginSchema::Binary, + schema: ExternalPluginAdapterSchema::Binary, })], }, ) .await; - let ix = UpdateExternalPluginV1Builder::new() + let ix = UpdateExternalPluginAdapterV1Builder::new() .asset(asset.pubkey()) .payer(context.payer.pubkey()) - .key(ExternalPluginKey::DataStore( + .key(ExternalPluginAdapterKey::DataStore( PluginAuthority::UpdateAuthority, )) - .update_info(ExternalPluginUpdateInfo::DataStore(DataStoreUpdateInfo { - schema: Some(ExternalPluginSchema::Json), - })) + .update_info(ExternalPluginAdapterUpdateInfo::DataStore( + DataStoreUpdateInfo { + schema: Some(ExternalPluginAdapterSchema::Json), + }, + )) .instruction(); let tx = Transaction::new_signed_with_payer( @@ -479,9 +483,9 @@ async fn test_update_data_store() { name: None, uri: None, plugins: vec![], - external_plugins: vec![ExternalPlugin::DataStore(DataStore { + external_plugin_adapters: vec![ExternalPluginAdapter::DataStore(DataStore { data_authority: PluginAuthority::UpdateAuthority, - schema: ExternalPluginSchema::Json, + schema: ExternalPluginAdapterSchema::Json, })], }, ) diff --git a/configs/kinobi.cjs b/configs/kinobi.cjs index 2623b1d0..c6aaf750 100755 --- a/configs/kinobi.cjs +++ b/configs/kinobi.cjs @@ -82,7 +82,7 @@ kinobi.update( plugins: { defaultValue: k.arrayValueNode([]) }, - externalPlugins: { + externalPluginAdapters: { defaultValue: k.arrayValueNode([]) }, dataState: { @@ -102,7 +102,7 @@ kinobi.update( plugins: { defaultValue: k.noneValueNode() }, - externalPlugins: { + externalPluginAdapters: { defaultValue: k.arrayValueNode([]) }, } @@ -195,14 +195,14 @@ kinobi.update( extraAccount: { name: "baseExtraAccount" }, - externalPluginKey: { - name: "baseExternalPluginKey" + externalPluginAdapterKey: { + name: "baseExternalPluginAdapterKey" }, - externalPluginInitInfo: { - name: "baseExternalPluginInitInfo" + externalPluginAdapterInitInfo: { + name: "baseExternalPluginAdapterInitInfo" }, - externalPluginUpdateInfo: { - name: "baseExternalPluginUpdateInfo" + externalPluginAdapterUpdateInfo: { + name: "baseExternalPluginAdapterUpdateInfo" }, oracle: { name: "baseOracle" diff --git a/idls/mpl_core.json b/idls/mpl_core.json index d171b50c..743d25dc 100644 --- a/idls/mpl_core.json +++ b/idls/mpl_core.json @@ -1405,7 +1405,7 @@ } }, { - "name": "AddExternalPluginV1", + "name": "AddExternalPluginAdapterV1", "accounts": [ { "name": "asset", @@ -1461,9 +1461,9 @@ ], "args": [ { - "name": "addExternalPluginV1Args", + "name": "addExternalPluginAdapterV1Args", "type": { - "defined": "AddExternalPluginV1Args" + "defined": "AddExternalPluginAdapterV1Args" } } ], @@ -1473,7 +1473,7 @@ } }, { - "name": "AddCollectionExternalPluginV1", + "name": "AddCollectionExternalPluginAdapterV1", "accounts": [ { "name": "collection", @@ -1520,9 +1520,9 @@ ], "args": [ { - "name": "addCollectionExternalPluginV1Args", + "name": "addCollectionExternalPluginAdapterV1Args", "type": { - "defined": "AddCollectionExternalPluginV1Args" + "defined": "AddCollectionExternalPluginAdapterV1Args" } } ], @@ -1532,7 +1532,7 @@ } }, { - "name": "RemoveExternalPluginV1", + "name": "RemoveExternalPluginAdapterV1", "accounts": [ { "name": "asset", @@ -1588,9 +1588,9 @@ ], "args": [ { - "name": "removeExternalPluginV1Args", + "name": "removeExternalPluginAdapterV1Args", "type": { - "defined": "RemoveExternalPluginV1Args" + "defined": "RemoveExternalPluginAdapterV1Args" } } ], @@ -1600,7 +1600,7 @@ } }, { - "name": "RemoveCollectionExternalPluginV1", + "name": "RemoveCollectionExternalPluginAdapterV1", "accounts": [ { "name": "collection", @@ -1647,9 +1647,9 @@ ], "args": [ { - "name": "removeCollectionExternalPluginV1Args", + "name": "removeCollectionExternalPluginAdapterV1Args", "type": { - "defined": "RemoveCollectionExternalPluginV1Args" + "defined": "RemoveCollectionExternalPluginAdapterV1Args" } } ], @@ -1659,7 +1659,7 @@ } }, { - "name": "UpdateExternalPluginV1", + "name": "UpdateExternalPluginAdapterV1", "accounts": [ { "name": "asset", @@ -1715,9 +1715,9 @@ ], "args": [ { - "name": "updateExternalPluginV1Args", + "name": "updateExternalPluginAdapterV1Args", "type": { - "defined": "UpdateExternalPluginV1Args" + "defined": "UpdateExternalPluginAdapterV1Args" } } ], @@ -1727,7 +1727,7 @@ } }, { - "name": "UpdateCollectionExternalPluginV1", + "name": "UpdateCollectionExternalPluginAdapterV1", "accounts": [ { "name": "collection", @@ -1774,9 +1774,9 @@ ], "args": [ { - "name": "updateCollectionExternalPluginV1Args", + "name": "updateCollectionExternalPluginAdapterV1Args", "type": { - "defined": "UpdateCollectionExternalPluginV1Args" + "defined": "UpdateCollectionExternalPluginAdapterV1Args" } } ], @@ -1786,7 +1786,7 @@ } }, { - "name": "WriteExternalPluginDataV1", + "name": "WriteExternalPluginAdapterDataV1", "accounts": [ { "name": "asset", @@ -1819,7 +1819,7 @@ "isSigner": true, "isOptional": true, "docs": [ - "The Data Authority of the External Plugin" + "The Data Authority of the External PluginExternalPluginAdapter" ] }, { @@ -1842,9 +1842,9 @@ ], "args": [ { - "name": "writeExternalPluginDataV1Args", + "name": "writeExternalPluginAdapterDataV1Args", "type": { - "defined": "WriteExternalPluginDataV1Args" + "defined": "WriteExternalPluginAdapterDataV1Args" } } ], @@ -1854,7 +1854,7 @@ } }, { - "name": "WriteCollectionExternalPluginDataV1", + "name": "WriteCollectionExternalPluginAdapterDataV1", "accounts": [ { "name": "collection", @@ -1878,7 +1878,7 @@ "isSigner": true, "isOptional": true, "docs": [ - "The Data Authority of the External Plugin" + "The Data Authority of the External PluginExternalPluginAdapter" ] }, { @@ -1901,9 +1901,9 @@ ], "args": [ { - "name": "writeCollectionExternalPluginDataV1Args", + "name": "writeCollectionExternalPluginAdapterDataV1Args", "type": { - "defined": "WriteCollectionExternalPluginDataV1Args" + "defined": "WriteCollectionExternalPluginAdapterDataV1Args" } } ], @@ -2141,7 +2141,7 @@ { "name": "schema", "type": { - "defined": "ExternalPluginSchema" + "defined": "ExternalPluginAdapterSchema" } } ] @@ -2170,7 +2170,7 @@ "name": "schema", "type": { "option": { - "defined": "ExternalPluginSchema" + "defined": "ExternalPluginAdapterSchema" } } } @@ -2186,7 +2186,7 @@ "name": "schema", "type": { "option": { - "defined": "ExternalPluginSchema" + "defined": "ExternalPluginAdapterSchema" } } } @@ -2266,7 +2266,7 @@ { "name": "schema", "type": { - "defined": "ExternalPluginSchema" + "defined": "ExternalPluginAdapterSchema" } } ] @@ -2326,7 +2326,7 @@ "name": "schema", "type": { "option": { - "defined": "ExternalPluginSchema" + "defined": "ExternalPluginAdapterSchema" } } } @@ -2369,7 +2369,7 @@ "name": "schema", "type": { "option": { - "defined": "ExternalPluginSchema" + "defined": "ExternalPluginAdapterSchema" } } } @@ -2412,7 +2412,7 @@ "type": "publicKey" }, { - "name": "pda", + "name": "baseAddressConfig", "type": { "option": { "defined": "ExtraAccount" @@ -2461,7 +2461,7 @@ } }, { - "name": "pda", + "name": "baseAddressConfig", "type": { "option": { "defined": "ExtraAccount" @@ -2502,7 +2502,7 @@ } }, { - "name": "pda", + "name": "baseAddressConfig", "type": { "option": { "defined": "ExtraAccount" @@ -2578,7 +2578,7 @@ { "name": "pluginType", "type": { - "defined": "ExternalPluginType" + "defined": "ExternalPluginAdapterType" } }, { @@ -2687,28 +2687,28 @@ } }, { - "name": "AddExternalPluginV1Args", + "name": "AddExternalPluginAdapterV1Args", "type": { "kind": "struct", "fields": [ { "name": "initInfo", "type": { - "defined": "ExternalPluginInitInfo" + "defined": "ExternalPluginAdapterInitInfo" } } ] } }, { - "name": "AddCollectionExternalPluginV1Args", + "name": "AddCollectionExternalPluginAdapterV1Args", "type": { "kind": "struct", "fields": [ { "name": "initInfo", "type": { - "defined": "ExternalPluginInitInfo" + "defined": "ExternalPluginAdapterInitInfo" } } ] @@ -2899,11 +2899,11 @@ } }, { - "name": "externalPlugins", + "name": "externalPluginAdapters", "type": { "option": { "vec": { - "defined": "ExternalPluginInitInfo" + "defined": "ExternalPluginAdapterInitInfo" } } } @@ -2961,11 +2961,11 @@ } }, { - "name": "externalPlugins", + "name": "externalPluginAdapters", "type": { "option": { "vec": { - "defined": "ExternalPluginInitInfo" + "defined": "ExternalPluginAdapterInitInfo" } } } @@ -2988,28 +2988,28 @@ } }, { - "name": "RemoveExternalPluginV1Args", + "name": "RemoveExternalPluginAdapterV1Args", "type": { "kind": "struct", "fields": [ { "name": "key", "type": { - "defined": "ExternalPluginKey" + "defined": "ExternalPluginAdapterKey" } } ] } }, { - "name": "RemoveCollectionExternalPluginV1Args", + "name": "RemoveCollectionExternalPluginAdapterV1Args", "type": { "kind": "struct", "fields": [ { "name": "key", "type": { - "defined": "ExternalPluginKey" + "defined": "ExternalPluginAdapterKey" } } ] @@ -3136,40 +3136,40 @@ } }, { - "name": "UpdateExternalPluginV1Args", + "name": "UpdateExternalPluginAdapterV1Args", "type": { "kind": "struct", "fields": [ { "name": "key", "type": { - "defined": "ExternalPluginKey" + "defined": "ExternalPluginAdapterKey" } }, { "name": "updateInfo", "type": { - "defined": "ExternalPluginUpdateInfo" + "defined": "ExternalPluginAdapterUpdateInfo" } } ] } }, { - "name": "UpdateCollectionExternalPluginV1Args", + "name": "UpdateCollectionExternalPluginAdapterV1Args", "type": { "kind": "struct", "fields": [ { "name": "key", "type": { - "defined": "ExternalPluginKey" + "defined": "ExternalPluginAdapterKey" } }, { "name": "updateInfo", "type": { - "defined": "ExternalPluginUpdateInfo" + "defined": "ExternalPluginAdapterUpdateInfo" } } ] @@ -3204,14 +3204,14 @@ } }, { - "name": "WriteExternalPluginDataV1Args", + "name": "WriteExternalPluginAdapterDataV1Args", "type": { "kind": "struct", "fields": [ { "name": "key", "type": { - "defined": "ExternalPluginKey" + "defined": "ExternalPluginAdapterKey" } }, { @@ -3222,14 +3222,14 @@ } }, { - "name": "WriteCollectionExternalPluginDataV1Args", + "name": "WriteCollectionExternalPluginAdapterDataV1Args", "type": { "kind": "struct", "fields": [ { "name": "key", "type": { - "defined": "ExternalPluginKey" + "defined": "ExternalPluginAdapterKey" } }, { @@ -3489,7 +3489,7 @@ } }, { - "name": "ExternalPluginType", + "name": "ExternalPluginAdapterType", "type": { "kind": "enum", "variants": [ @@ -3506,7 +3506,7 @@ } }, { - "name": "ExternalPlugin", + "name": "ExternalPluginAdapter", "type": { "kind": "enum", "variants": [ @@ -3707,7 +3707,7 @@ } }, { - "name": "ExternalPluginSchema", + "name": "ExternalPluginAdapterSchema", "type": { "kind": "enum", "variants": [ @@ -3724,7 +3724,7 @@ } }, { - "name": "ExternalPluginInitInfo", + "name": "ExternalPluginAdapterInitInfo", "type": { "kind": "enum", "variants": [ @@ -3756,7 +3756,7 @@ } }, { - "name": "ExternalPluginUpdateInfo", + "name": "ExternalPluginAdapterUpdateInfo", "type": { "kind": "enum", "variants": [ @@ -3788,7 +3788,7 @@ } }, { - "name": "ExternalPluginKey", + "name": "ExternalPluginAdapterKey", "type": { "kind": "enum", "variants": [ @@ -4187,13 +4187,13 @@ }, { "code": 31, - "name": "ExternalPluginNotFound", - "msg": "External Plugin not found" + "name": "ExternalPluginAdapterNotFound", + "msg": "External PluginExternalPluginAdapter not found" }, { "code": 32, - "name": "ExternalPluginAlreadyExists", - "msg": "External Plugin already exists" + "name": "ExternalPluginAdapterAlreadyExists", + "msg": "External PluginExternalPluginAdapter already exists" }, { "code": 33, @@ -4202,23 +4202,23 @@ }, { "code": 34, - "name": "MissingExternalAccount", - "msg": "Missing account needed for external plugin" + "name": "MissingExternalPluginAdapterAccount", + "msg": "Missing account needed for external plugin adapter" }, { "code": 35, "name": "OracleCanRejectOnly", - "msg": "Oracle external plugin can only be configured to reject" + "msg": "Oracle external plugin adapter can only be configured to reject" }, { "code": 36, "name": "RequiresLifecycleCheck", - "msg": "External plugin must have at least one lifecycle check" + "msg": "External plugin adapter must have at least one lifecycle check" }, { "code": 37, "name": "DuplicateLifecycleChecks", - "msg": "Duplicate lifecycle checks were provided for external plugin" + "msg": "Duplicate lifecycle checks were provided for external plugin adapter " }, { "code": 38, diff --git a/programs/mpl-core/src/error.rs b/programs/mpl-core/src/error.rs index 214f7173..9c02b853 100644 --- a/programs/mpl-core/src/error.rs +++ b/programs/mpl-core/src/error.rs @@ -133,32 +133,32 @@ pub enum MplCoreError { #[error("Invalid Log Wrapper Program")] InvalidLogWrapperProgram, - /// 31 - External Plugin not found - #[error("External Plugin not found")] - ExternalPluginNotFound, + /// 31 - External PluginExternalPluginAdapter not found + #[error("External PluginExternalPluginAdapter not found")] + ExternalPluginAdapterNotFound, - /// 32 - External Plugin already exists - #[error("External Plugin already exists")] - ExternalPluginAlreadyExists, + /// 32 - External PluginExternalPluginAdapter already exists + #[error("External PluginExternalPluginAdapter already exists")] + ExternalPluginAdapterAlreadyExists, /// 33 - Missing asset needed for extra account PDA derivation #[error("Missing asset needed for extra account PDA derivation")] MissingAsset, - /// 34 - Missing account needed for external plugin - #[error("Missing account needed for external plugin")] - MissingExternalAccount, + /// 34 - Missing account needed for external plugin adapter + #[error("Missing account needed for external plugin adapter")] + MissingExternalPluginAdapterAccount, - /// 35 - Oracle external plugin can only be configured to reject - #[error("Oracle external plugin can only be configured to reject")] + /// 35 - Oracle external plugin adapter can only be configured to reject + #[error("Oracle external plugin adapter can only be configured to reject")] OracleCanRejectOnly, - /// 36 - External plugin must have at least one lifecycle check - #[error("External plugin must have at least one lifecycle check")] + /// 36 - External plugin adapter must have at least one lifecycle check + #[error("External plugin adapter must have at least one lifecycle check")] RequiresLifecycleCheck, - /// 37 - Duplicate lifecycle checks were provided for external plugin - #[error("Duplicate lifecycle checks were provided for external plugin")] + /// 37 - Duplicate lifecycle checks were provided for external plugin adapter + #[error("Duplicate lifecycle checks were provided for external plugin adapter ")] DuplicateLifecycleChecks, /// 38 - Could not read from oracle account diff --git a/programs/mpl-core/src/instruction.rs b/programs/mpl-core/src/instruction.rs index ca1352cf..5cb980f5 100644 --- a/programs/mpl-core/src/instruction.rs +++ b/programs/mpl-core/src/instruction.rs @@ -3,15 +3,16 @@ use borsh::{BorshDeserialize, BorshSerialize}; use shank::{ShankContext, ShankInstruction}; use crate::processor::{ - AddCollectionExternalPluginV1Args, AddCollectionPluginV1Args, AddExternalPluginV1Args, - AddPluginV1Args, ApproveCollectionPluginAuthorityV1Args, ApprovePluginAuthorityV1Args, - BurnCollectionV1Args, BurnV1Args, CompressV1Args, CreateCollectionV1Args, - CreateCollectionV2Args, CreateV1Args, CreateV2Args, DecompressV1Args, - RemoveCollectionExternalPluginV1Args, RemoveCollectionPluginV1Args, RemoveExternalPluginV1Args, - RemovePluginV1Args, RevokeCollectionPluginAuthorityV1Args, RevokePluginAuthorityV1Args, - TransferV1Args, UpdateCollectionExternalPluginV1Args, UpdateCollectionPluginV1Args, - UpdateCollectionV1Args, UpdateExternalPluginV1Args, UpdatePluginV1Args, UpdateV1Args, - WriteCollectionExternalPluginDataV1Args, WriteExternalPluginDataV1Args, + AddCollectionExternalPluginAdapterV1Args, AddCollectionPluginV1Args, + AddExternalPluginAdapterV1Args, AddPluginV1Args, ApproveCollectionPluginAuthorityV1Args, + ApprovePluginAuthorityV1Args, BurnCollectionV1Args, BurnV1Args, CompressV1Args, + CreateCollectionV1Args, CreateCollectionV2Args, CreateV1Args, CreateV2Args, DecompressV1Args, + RemoveCollectionExternalPluginAdapterV1Args, RemoveCollectionPluginV1Args, + RemoveExternalPluginAdapterV1Args, RemovePluginV1Args, RevokeCollectionPluginAuthorityV1Args, + RevokePluginAuthorityV1Args, TransferV1Args, UpdateCollectionExternalPluginAdapterV1Args, + UpdateCollectionPluginV1Args, UpdateCollectionV1Args, UpdateExternalPluginAdapterV1Args, + UpdatePluginV1Args, UpdateV1Args, WriteCollectionExternalPluginAdapterDataV1Args, + WriteExternalPluginAdapterDataV1Args, }; /// Instructions supported by the mpl-core program. @@ -193,7 +194,7 @@ pub(crate) enum MplAssetInstruction { Collect, /// Create a new mpl-core Asset V2. - /// This function creates the initial Asset, with or without internal/external plugins. + /// This function creates the initial Asset, with or without internal/external plugin adapters. #[account(0, writable, signer, name="asset", desc = "The address of the new asset")] #[account(1, optional, writable, name="collection", desc = "The collection to which the asset belongs")] #[account(2, optional, signer, name="authority", desc = "The authority signing for creation")] @@ -205,78 +206,78 @@ pub(crate) enum MplAssetInstruction { CreateV2(CreateV2Args), /// Create a new mpl-core Collection V2. - /// This function creates the initial Collection, with or without internal/external plugins. + /// This function creates the initial Collection, with or without internal/external plugin adapters. #[account(0, writable, signer, name="collection", desc = "The address of the new asset")] #[account(1, optional, name="update_authority", desc = "The authority of the new asset")] #[account(2, writable, signer, name="payer", desc = "The account paying for the storage fees")] #[account(3, name="system_program", desc = "The system program")] CreateCollectionV2(CreateCollectionV2Args), - /// Add an external plugin to an mpl-core. + /// Add an external plugin adapter to an mpl-core. #[account(0, writable, name="asset", desc = "The address of the asset")] #[account(1, optional, writable, name="collection", desc = "The collection to which the asset belongs")] #[account(2, writable, signer, name="payer", desc = "The account paying for the storage fees")] #[account(3, optional, signer, name="authority", desc = "The owner or delegate of the asset")] #[account(4, name="system_program", desc = "The system program")] #[account(5, optional, name="log_wrapper", desc = "The SPL Noop Program")] - AddExternalPluginV1(AddExternalPluginV1Args), + AddExternalPluginAdapterV1(AddExternalPluginAdapterV1Args), - /// Add an external plugin to an mpl-core Collection. + /// Add an external plugin adapter to an mpl-core Collection. #[account(0, writable, name="collection", desc = "The address of the asset")] #[account(1, writable, signer, name="payer", desc = "The account paying for the storage fees")] #[account(2, optional, signer, name="authority", desc = "The owner or delegate of the asset")] #[account(3, name="system_program", desc = "The system program")] #[account(4, optional, name="log_wrapper", desc = "The SPL Noop Program")] - AddCollectionExternalPluginV1(AddCollectionExternalPluginV1Args), + AddCollectionExternalPluginAdapterV1(AddCollectionExternalPluginAdapterV1Args), - /// Remove an external plugin from an mpl-core. + /// Remove an external plugin adapter from an mpl-core. #[account(0, writable, name="asset", desc = "The address of the asset")] #[account(1, optional, writable, name="collection", desc = "The collection to which the asset belongs")] #[account(2, writable, signer, name="payer", desc = "The account paying for the storage fees")] #[account(3, optional, signer, name="authority", desc = "The owner or delegate of the asset")] #[account(4, name="system_program", desc = "The system program")] #[account(5, optional, name="log_wrapper", desc = "The SPL Noop Program")] - RemoveExternalPluginV1(RemoveExternalPluginV1Args), + RemoveExternalPluginAdapterV1(RemoveExternalPluginAdapterV1Args), - /// Remove an external plugin from an mpl-core Collection. + /// Remove an external plugin adapter from an mpl-core Collection. #[account(0, writable, name="collection", desc = "The address of the asset")] #[account(1, writable, signer, name="payer", desc = "The account paying for the storage fees")] #[account(2, optional, signer, name="authority", desc = "The owner or delegate of the asset")] #[account(3, name="system_program", desc = "The system program")] #[account(4, optional, name="log_wrapper", desc = "The SPL Noop Program")] - RemoveCollectionExternalPluginV1(RemoveCollectionExternalPluginV1Args), + RemoveCollectionExternalPluginAdapterV1(RemoveCollectionExternalPluginAdapterV1Args), - /// Update the data for an external plugin of an mpl-core. + /// Update the data for an external plugin adapter of an mpl-core. #[account(0, writable, name="asset", desc = "The address of the asset")] #[account(1, optional, writable, name="collection", desc = "The collection to which the asset belongs")] #[account(2, writable, signer, name="payer", desc = "The account paying for the storage fees")] #[account(3, optional, signer, name="authority", desc = "The owner or delegate of the asset")] #[account(4, name="system_program", desc = "The system program")] #[account(5, optional, name="log_wrapper", desc = "The SPL Noop Program")] - UpdateExternalPluginV1(UpdateExternalPluginV1Args), + UpdateExternalPluginAdapterV1(UpdateExternalPluginAdapterV1Args), - /// Update the data for an external plugin of an mpl-core Collection. + /// Update the data for an external plugin adapter of an mpl-core Collection. #[account(0, writable, name="collection", desc = "The address of the asset")] #[account(1, writable, signer, name="payer", desc = "The account paying for the storage fees")] #[account(2, optional, signer, name="authority", desc = "The owner or delegate of the asset")] #[account(3, name="system_program", desc = "The system program")] #[account(4, optional, name="log_wrapper", desc = "The SPL Noop Program")] - UpdateCollectionExternalPluginV1(UpdateCollectionExternalPluginV1Args), + UpdateCollectionExternalPluginAdapterV1(UpdateCollectionExternalPluginAdapterV1Args), - /// Add an external plugin to an mpl-core. + /// Add an external plugin adapter to an mpl-core. #[account(0, writable, name="asset", desc = "The address of the asset")] #[account(1, optional, writable, name="collection", desc = "The collection to which the asset belongs")] #[account(2, writable, signer, name="payer", desc = "The account paying for the storage fees")] - #[account(3, optional, signer, name="authority", desc = "The Data Authority of the External Plugin")] + #[account(3, optional, signer, name="authority", desc = "The Data Authority of the External PluginExternalPluginAdapter")] #[account(4, name="system_program", desc = "The system program")] #[account(5, optional, name="log_wrapper", desc = "The SPL Noop Program")] - WriteExternalPluginDataV1(WriteExternalPluginDataV1Args), + WriteExternalPluginAdapterDataV1(WriteExternalPluginAdapterDataV1Args), - /// Add an external plugin to an mpl-core. + /// Add an external plugin adapter to an mpl-core. #[account(0, writable, name="collection", desc = "The address of the asset")] #[account(1, writable, signer, name="payer", desc = "The account paying for the storage fees")] - #[account(2, optional, signer, name="authority", desc = "The Data Authority of the External Plugin")] + #[account(2, optional, signer, name="authority", desc = "The Data Authority of the External PluginExternalPluginAdapter")] #[account(3, name="system_program", desc = "The system program")] #[account(4, optional, name="log_wrapper", desc = "The SPL Noop Program")] - WriteCollectionExternalPluginDataV1(WriteCollectionExternalPluginDataV1Args), + WriteCollectionExternalPluginAdapterDataV1(WriteCollectionExternalPluginAdapterDataV1Args), } diff --git a/programs/mpl-core/src/plugins/data_store.rs b/programs/mpl-core/src/plugins/data_store.rs index 490e254e..76e959d7 100644 --- a/programs/mpl-core/src/plugins/data_store.rs +++ b/programs/mpl-core/src/plugins/data_store.rs @@ -2,12 +2,13 @@ use borsh::{BorshDeserialize, BorshSerialize}; use solana_program::program_error::ProgramError; use super::{ - Authority, ExternalPluginSchema, PluginValidation, PluginValidationContext, ValidationResult, + Authority, ExternalPluginAdapterSchema, PluginValidation, PluginValidationContext, + ValidationResult, }; /// The data store third party plugin contains arbitrary data that can be written to by the /// `data_authority`. Note this is different then the overall plugin authority stored in the -/// `ExternalPluginRecord` as it cannot update/revoke authority or change other metadata for the +/// `ExternalRegistryRecord` as it cannot update/revoke authority or change other metadata for the /// plugin. The data is stored at the plugin's data offset (which in the account is immediately /// after this header). #[derive(Clone, Debug, BorshSerialize, BorshDeserialize, Eq, PartialEq)] @@ -16,7 +17,7 @@ pub struct DataStore { /// added. pub data_authority: Authority, /// Schema for the data used by the plugin. - pub schema: ExternalPluginSchema, + pub schema: ExternalPluginAdapterSchema, } impl DataStore { @@ -29,7 +30,7 @@ impl DataStore { } impl PluginValidation for DataStore { - fn validate_add_external_plugin( + fn validate_add_external_plugin_adapter( &self, _ctx: &PluginValidationContext, ) -> Result { @@ -62,12 +63,12 @@ pub struct DataStoreInitInfo { /// Initial plugin authority who can update plugin properties. pub init_plugin_authority: Option, /// Schema for the data used by the plugin. - pub schema: Option, + pub schema: Option, } /// Data store update info. #[derive(Clone, Debug, BorshSerialize, BorshDeserialize, Eq, PartialEq)] pub struct DataStoreUpdateInfo { /// Schema for the data used by the plugin. - pub schema: Option, + pub schema: Option, } diff --git a/programs/mpl-core/src/plugins/external_plugins.rs b/programs/mpl-core/src/plugins/external_plugin_adapters.rs similarity index 69% rename from programs/mpl-core/src/plugins/external_plugins.rs rename to programs/mpl-core/src/plugins/external_plugin_adapters.rs index d9412acd..ceb25fb4 100644 --- a/programs/mpl-core/src/plugins/external_plugins.rs +++ b/programs/mpl-core/src/plugins/external_plugin_adapters.rs @@ -21,7 +21,7 @@ use super::{ #[derive( Clone, Copy, Debug, BorshSerialize, BorshDeserialize, Eq, PartialEq, EnumCount, PartialOrd, Ord, )] -pub enum ExternalPluginType { +pub enum ExternalPluginAdapterType { /// Lifecycle Hook. LifecycleHook, /// Oracle. @@ -30,31 +30,33 @@ pub enum ExternalPluginType { DataStore, } -impl From<&ExternalPluginKey> for ExternalPluginType { - fn from(key: &ExternalPluginKey) -> Self { +impl From<&ExternalPluginAdapterKey> for ExternalPluginAdapterType { + fn from(key: &ExternalPluginAdapterKey) -> Self { match key { - ExternalPluginKey::LifecycleHook(_) => ExternalPluginType::LifecycleHook, - ExternalPluginKey::Oracle(_) => ExternalPluginType::Oracle, - ExternalPluginKey::DataStore(_) => ExternalPluginType::DataStore, + ExternalPluginAdapterKey::LifecycleHook(_) => ExternalPluginAdapterType::LifecycleHook, + ExternalPluginAdapterKey::Oracle(_) => ExternalPluginAdapterType::Oracle, + ExternalPluginAdapterKey::DataStore(_) => ExternalPluginAdapterType::DataStore, } } } -impl From<&ExternalPluginInitInfo> for ExternalPluginType { - fn from(init_info: &ExternalPluginInitInfo) -> Self { +impl From<&ExternalPluginAdapterInitInfo> for ExternalPluginAdapterType { + fn from(init_info: &ExternalPluginAdapterInitInfo) -> Self { match init_info { - ExternalPluginInitInfo::LifecycleHook(_) => ExternalPluginType::LifecycleHook, - ExternalPluginInitInfo::Oracle(_) => ExternalPluginType::Oracle, - ExternalPluginInitInfo::DataStore(_) => ExternalPluginType::DataStore, + ExternalPluginAdapterInitInfo::LifecycleHook(_) => { + ExternalPluginAdapterType::LifecycleHook + } + ExternalPluginAdapterInitInfo::Oracle(_) => ExternalPluginAdapterType::Oracle, + ExternalPluginAdapterInitInfo::DataStore(_) => ExternalPluginAdapterType::DataStore, } } } -/// Definition of the external plugin variants, each containing a link to the external plugin +/// Definition of the external plugin adapter variants, each containing a link to the external plugin adapter /// struct. #[repr(C)] #[derive(Clone, Debug, BorshSerialize, BorshDeserialize, Eq, PartialEq)] -pub enum ExternalPlugin { +pub enum ExternalPluginAdapter { /// Lifecycle Hook. The hooked program and extra accounts are specified in the attached /// struct. The hooked program is called at specified lifecycle events and will return a /// validation result and new data to store. @@ -67,22 +69,25 @@ pub enum ExternalPlugin { DataStore(DataStore), } -impl ExternalPlugin { +impl ExternalPluginAdapter { /// Update the plugin from the update info. - pub fn update(&mut self, update_info: &ExternalPluginUpdateInfo) { + pub fn update(&mut self, update_info: &ExternalPluginAdapterUpdateInfo) { match (self, update_info) { ( - ExternalPlugin::LifecycleHook(lifecycle_hook), - ExternalPluginUpdateInfo::LifecycleHook(update_info), + ExternalPluginAdapter::LifecycleHook(lifecycle_hook), + ExternalPluginAdapterUpdateInfo::LifecycleHook(update_info), ) => { lifecycle_hook.update(update_info); } - (ExternalPlugin::Oracle(oracle), ExternalPluginUpdateInfo::Oracle(update_info)) => { + ( + ExternalPluginAdapter::Oracle(oracle), + ExternalPluginAdapterUpdateInfo::Oracle(update_info), + ) => { oracle.update(update_info); } ( - ExternalPlugin::DataStore(data_store), - ExternalPluginUpdateInfo::DataStore(update_info), + ExternalPluginAdapter::DataStore(data_store), + ExternalPluginAdapterUpdateInfo::DataStore(update_info), ) => { data_store.update(update_info); } @@ -91,9 +96,9 @@ impl ExternalPlugin { } /// Check if a plugin is permitted to approve or deny a create action. - pub fn check_create(plugin: &ExternalPluginInitInfo) -> ExternalCheckResult { + pub fn check_create(plugin: &ExternalPluginAdapterInitInfo) -> ExternalCheckResult { match plugin { - ExternalPluginInitInfo::LifecycleHook(init_info) => { + ExternalPluginAdapterInitInfo::LifecycleHook(init_info) => { if let Some(checks) = init_info .lifecycle_checks .iter() @@ -104,7 +109,7 @@ impl ExternalPlugin { ExternalCheckResult::none() } } - ExternalPluginInitInfo::Oracle(init_info) => { + ExternalPluginAdapterInitInfo::Oracle(init_info) => { if let Some(checks) = init_info .lifecycle_checks .iter() @@ -115,69 +120,81 @@ impl ExternalPlugin { ExternalCheckResult::none() } } - ExternalPluginInitInfo::DataStore(_) => ExternalCheckResult::none(), + ExternalPluginAdapterInitInfo::DataStore(_) => ExternalCheckResult::none(), } } - /// Validate the add external plugin lifecycle event. + /// Validate the add external plugin adapter lifecycle event. pub(crate) fn validate_create( - external_plugin: &ExternalPlugin, + external_plugin_adapter: &ExternalPluginAdapter, ctx: &PluginValidationContext, ) -> Result { - match external_plugin { - ExternalPlugin::LifecycleHook(lifecycle_hook) => lifecycle_hook.validate_create(ctx), - ExternalPlugin::Oracle(oracle) => oracle.validate_create(ctx), - ExternalPlugin::DataStore(data_store) => data_store.validate_create(ctx), + match external_plugin_adapter { + ExternalPluginAdapter::LifecycleHook(lifecycle_hook) => { + lifecycle_hook.validate_create(ctx) + } + ExternalPluginAdapter::Oracle(oracle) => oracle.validate_create(ctx), + ExternalPluginAdapter::DataStore(data_store) => data_store.validate_create(ctx), } } /// Route the validation of the update action to the appropriate plugin. pub(crate) fn validate_update( - external_plugin: &ExternalPlugin, + external_plugin_adapter: &ExternalPluginAdapter, ctx: &PluginValidationContext, ) -> Result { - match external_plugin { - ExternalPlugin::LifecycleHook(lifecycle_hook) => lifecycle_hook.validate_update(ctx), - ExternalPlugin::Oracle(oracle) => oracle.validate_update(ctx), - ExternalPlugin::DataStore(data_store) => data_store.validate_update(ctx), + match external_plugin_adapter { + ExternalPluginAdapter::LifecycleHook(lifecycle_hook) => { + lifecycle_hook.validate_update(ctx) + } + ExternalPluginAdapter::Oracle(oracle) => oracle.validate_update(ctx), + ExternalPluginAdapter::DataStore(data_store) => data_store.validate_update(ctx), } } /// Route the validation of the burn action to the appropriate plugin. pub(crate) fn validate_burn( - external_plugin: &ExternalPlugin, + external_plugin_adapter: &ExternalPluginAdapter, ctx: &PluginValidationContext, ) -> Result { - match external_plugin { - ExternalPlugin::LifecycleHook(lifecycle_hook) => lifecycle_hook.validate_burn(ctx), - ExternalPlugin::Oracle(oracle) => oracle.validate_burn(ctx), - ExternalPlugin::DataStore(data_store) => data_store.validate_burn(ctx), + match external_plugin_adapter { + ExternalPluginAdapter::LifecycleHook(lifecycle_hook) => { + lifecycle_hook.validate_burn(ctx) + } + ExternalPluginAdapter::Oracle(oracle) => oracle.validate_burn(ctx), + ExternalPluginAdapter::DataStore(data_store) => data_store.validate_burn(ctx), } } - /// Route the validation of the transfer action to the appropriate external plugin. + /// Route the validation of the transfer action to the appropriate external plugin adapter. pub(crate) fn validate_transfer( - external_plugin: &ExternalPlugin, + external_plugin_adapter: &ExternalPluginAdapter, ctx: &PluginValidationContext, ) -> Result { - match external_plugin { - ExternalPlugin::LifecycleHook(lifecycle_hook) => lifecycle_hook.validate_transfer(ctx), - ExternalPlugin::Oracle(oracle) => oracle.validate_transfer(ctx), - ExternalPlugin::DataStore(data_store) => data_store.validate_transfer(ctx), + match external_plugin_adapter { + ExternalPluginAdapter::LifecycleHook(lifecycle_hook) => { + lifecycle_hook.validate_transfer(ctx) + } + ExternalPluginAdapter::Oracle(oracle) => oracle.validate_transfer(ctx), + ExternalPluginAdapter::DataStore(data_store) => data_store.validate_transfer(ctx), } } - /// Validate the add external plugin lifecycle event. - pub(crate) fn validate_add_external_plugin( - external_plugin: &ExternalPlugin, + /// Validate the add external plugin adapter lifecycle event. + pub(crate) fn validate_add_external_plugin_adapter( + external_plugin_adapter: &ExternalPluginAdapter, ctx: &PluginValidationContext, ) -> Result { - match external_plugin { - ExternalPlugin::LifecycleHook(lifecycle_hook) => { - lifecycle_hook.validate_add_external_plugin(ctx) + match external_plugin_adapter { + ExternalPluginAdapter::LifecycleHook(lifecycle_hook) => { + lifecycle_hook.validate_add_external_plugin_adapter(ctx) + } + ExternalPluginAdapter::Oracle(oracle) => { + oracle.validate_add_external_plugin_adapter(ctx) + } + ExternalPluginAdapter::DataStore(data_store) => { + data_store.validate_add_external_plugin_adapter(ctx) } - ExternalPlugin::Oracle(oracle) => oracle.validate_add_external_plugin(ctx), - ExternalPlugin::DataStore(data_store) => data_store.validate_add_external_plugin(ctx), } } @@ -199,17 +216,17 @@ impl ExternalPlugin { } } -impl From<&ExternalPluginInitInfo> for ExternalPlugin { - fn from(init_info: &ExternalPluginInitInfo) -> Self { +impl From<&ExternalPluginAdapterInitInfo> for ExternalPluginAdapter { + fn from(init_info: &ExternalPluginAdapterInitInfo) -> Self { match init_info { - ExternalPluginInitInfo::LifecycleHook(init_info) => { - ExternalPlugin::LifecycleHook(LifecycleHook::from(init_info)) + ExternalPluginAdapterInitInfo::LifecycleHook(init_info) => { + ExternalPluginAdapter::LifecycleHook(LifecycleHook::from(init_info)) } - ExternalPluginInitInfo::Oracle(init_info) => { - ExternalPlugin::Oracle(Oracle::from(init_info)) + ExternalPluginAdapterInitInfo::Oracle(init_info) => { + ExternalPluginAdapter::Oracle(Oracle::from(init_info)) } - ExternalPluginInitInfo::DataStore(init_info) => { - ExternalPlugin::DataStore(DataStore::from(init_info)) + ExternalPluginAdapterInitInfo::DataStore(init_info) => { + ExternalPluginAdapter::DataStore(DataStore::from(init_info)) } } } @@ -217,9 +234,9 @@ impl From<&ExternalPluginInitInfo> for ExternalPlugin { #[repr(C)] #[derive(Eq, PartialEq, Clone, BorshSerialize, BorshDeserialize, Debug, PartialOrd, Ord, Hash)] -/// An enum listing all the lifecyle events available for external plugin hooks. Note that some +/// An enum listing all the lifecyle events available for external plugin adapter hooks. Note that some /// lifecycle events such as adding and removing plugins will be checked by default as they are -/// inherently part of the external plugin system. +/// inherently part of the external plugin adapter system. pub enum HookableLifecycleEvent { /// Add a plugin. Create, @@ -234,7 +251,7 @@ pub enum HookableLifecycleEvent { /// Prefix used with some of the `ExtraAccounts` that are PDAs. pub const MPL_CORE_PREFIX: &str = "mpl-core"; -/// Type used to specify extra accounts for external plugins. +/// Type used to specify extra accounts for external plugin adapters. #[repr(C)] #[derive(Clone, Debug, BorshSerialize, BorshDeserialize, Eq, PartialEq)] pub enum ExtraAccount { @@ -432,7 +449,7 @@ pub enum Seed { /// Schema used for third party plugin data. #[repr(C)] #[derive(Clone, Copy, Debug, BorshSerialize, BorshDeserialize, Eq, PartialEq, Default)] -pub enum ExternalPluginSchema { +pub enum ExternalPluginAdapterSchema { /// Raw binary data. #[default] Binary, @@ -442,10 +459,10 @@ pub enum ExternalPluginSchema { MsgPack, } -/// Information needed to initialize an external plugin. +/// Information needed to initialize an external plugin adapter. #[repr(C)] #[derive(Clone, Debug, BorshSerialize, BorshDeserialize, Eq, PartialEq)] -pub enum ExternalPluginInitInfo { +pub enum ExternalPluginAdapterInitInfo { /// Lifecycle Hook. LifecycleHook(LifecycleHookInitInfo), /// Oracle. @@ -454,10 +471,10 @@ pub enum ExternalPluginInitInfo { DataStore(DataStoreInitInfo), } -/// Information needed to update an external plugin. +/// Information needed to update an external plugin adapter. #[repr(C)] #[derive(Clone, Debug, BorshSerialize, BorshDeserialize, Eq, PartialEq)] -pub enum ExternalPluginUpdateInfo { +pub enum ExternalPluginAdapterUpdateInfo { /// Lifecycle Hook. LifecycleHook(LifecycleHookUpdateInfo), /// Oracle. @@ -466,12 +483,12 @@ pub enum ExternalPluginUpdateInfo { DataStore(DataStoreUpdateInfo), } -/// Key used to uniquely specify an external plugin after it is created. +/// Key used to uniquely specify an external plugin adapter after it is created. #[repr(C)] #[derive( Clone, Copy, Debug, BorshSerialize, BorshDeserialize, Eq, PartialEq, EnumCount, PartialOrd, Ord, )] -pub enum ExternalPluginKey { +pub enum ExternalPluginAdapterKey { /// Lifecycle Hook. LifecycleHook(Pubkey), /// Oracle. @@ -480,7 +497,7 @@ pub enum ExternalPluginKey { DataStore(Authority), } -impl ExternalPluginKey { +impl ExternalPluginAdapterKey { pub(crate) fn from_record( account: &AccountInfo, external_registry_record: &ExternalRegistryRecord, @@ -491,17 +508,17 @@ impl ExternalPluginKey { .ok_or(MplCoreError::NumericalOverflow)?; match external_registry_record.plugin_type { - ExternalPluginType::LifecycleHook => { + ExternalPluginAdapterType::LifecycleHook => { let pubkey = Pubkey::deserialize(&mut &account.data.borrow()[pubkey_or_authority_offset..])?; Ok(Self::LifecycleHook(pubkey)) } - ExternalPluginType::Oracle => { + ExternalPluginAdapterType::Oracle => { let pubkey = Pubkey::deserialize(&mut &account.data.borrow()[pubkey_or_authority_offset..])?; Ok(Self::Oracle(pubkey)) } - ExternalPluginType::DataStore => { + ExternalPluginAdapterType::DataStore => { let authority = Authority::deserialize( &mut &account.data.borrow()[pubkey_or_authority_offset..], )?; @@ -511,17 +528,17 @@ impl ExternalPluginKey { } } -impl From<&ExternalPluginInitInfo> for ExternalPluginKey { - fn from(init_info: &ExternalPluginInitInfo) -> Self { +impl From<&ExternalPluginAdapterInitInfo> for ExternalPluginAdapterKey { + fn from(init_info: &ExternalPluginAdapterInitInfo) -> Self { match init_info { - ExternalPluginInitInfo::LifecycleHook(init_info) => { - ExternalPluginKey::LifecycleHook(init_info.hooked_program) + ExternalPluginAdapterInitInfo::LifecycleHook(init_info) => { + ExternalPluginAdapterKey::LifecycleHook(init_info.hooked_program) } - ExternalPluginInitInfo::Oracle(init_info) => { - ExternalPluginKey::Oracle(init_info.base_address) + ExternalPluginAdapterInitInfo::Oracle(init_info) => { + ExternalPluginAdapterKey::Oracle(init_info.base_address) } - ExternalPluginInitInfo::DataStore(init_info) => { - ExternalPluginKey::DataStore(init_info.data_authority) + ExternalPluginAdapterInitInfo::DataStore(init_info) => { + ExternalPluginAdapterKey::DataStore(init_info.data_authority) } } } diff --git a/programs/mpl-core/src/plugins/lifecycle.rs b/programs/mpl-core/src/plugins/lifecycle.rs index 0ae06008..8871f1e1 100644 --- a/programs/mpl-core/src/plugins/lifecycle.rs +++ b/programs/mpl-core/src/plugins/lifecycle.rs @@ -9,7 +9,8 @@ use crate::{ }; use super::{ - ExternalPlugin, ExternalPluginKey, ExternalRegistryRecord, Plugin, PluginType, RegistryRecord, + ExternalPluginAdapter, ExternalPluginAdapterKey, ExternalRegistryRecord, Plugin, PluginType, + RegistryRecord, }; /// Lifecycle permissions @@ -27,12 +28,12 @@ pub enum CheckResult { CanForceApprove, } -/// Lifecycle permissions for external, third party plugins. +/// Lifecycle permissions for adapter, third party plugins. /// Third party plugins use this field to indicate their permission to listen, approve, and/or /// deny a lifecycle event. #[derive(BorshDeserialize, BorshSerialize, Eq, PartialEq, Copy, Clone, Debug)] pub struct ExternalCheckResult { - /// Bitfield for external check results. + /// Bitfield for external plugin adapter check results. pub flags: u32, } @@ -46,7 +47,7 @@ impl ExternalCheckResult { } } -/// Bitfield representation of lifecycle permissions for external, third party plugins. +/// Bitfield representation of lifecycle permissions for external plugin adapter, third party plugins. #[bitfield(bits = 32)] #[derive(Eq, PartialEq, Copy, Clone, Debug)] pub struct ExternalCheckResultBits { @@ -183,24 +184,24 @@ impl PluginType { } } - /// Check permissions for the add external plugin lifecycle event. - pub fn check_add_external_plugin(plugin_type: &PluginType) -> CheckResult { + /// Check permissions for the add external plugin adapter lifecycle event. + pub fn check_add_external_plugin_adapter(plugin_type: &PluginType) -> CheckResult { #[allow(clippy::match_single_binding)] match plugin_type { _ => CheckResult::None, } } - /// Check permissions for the remove external plugin lifecycle event. - pub fn check_remove_external_plugin(plugin_type: &PluginType) -> CheckResult { + /// Check permissions for the remove external plugin adapter lifecycle event. + pub fn check_remove_external_plugin_adapter(plugin_type: &PluginType) -> CheckResult { #[allow(clippy::match_single_binding)] match plugin_type { _ => CheckResult::None, } } - /// Check permissions for the update external plugin lifecycle event. - pub fn check_update_external_plugin(plugin_type: &PluginType) -> CheckResult { + /// Check permissions for the update external plugin adapter lifecycle event. + pub fn check_update_external_plugin_adapter(plugin_type: &PluginType) -> CheckResult { #[allow(clippy::match_single_binding)] match plugin_type { _ => CheckResult::None, @@ -592,77 +593,87 @@ impl Plugin { } } - /// Validate the add external plugin lifecycle event. - pub(crate) fn validate_add_external_plugin( + /// Validate the add external plugin adapter lifecycle event. + pub(crate) fn validate_add_external_plugin_adapter( plugin: &Plugin, ctx: &PluginValidationContext, ) -> Result { match plugin { - Plugin::Royalties(royalties) => royalties.validate_add_external_plugin(ctx), - Plugin::FreezeDelegate(freeze) => freeze.validate_add_external_plugin(ctx), - Plugin::BurnDelegate(burn) => burn.validate_add_external_plugin(ctx), - Plugin::TransferDelegate(transfer) => transfer.validate_add_external_plugin(ctx), + Plugin::Royalties(royalties) => royalties.validate_add_external_plugin_adapter(ctx), + Plugin::FreezeDelegate(freeze) => freeze.validate_add_external_plugin_adapter(ctx), + Plugin::BurnDelegate(burn) => burn.validate_add_external_plugin_adapter(ctx), + Plugin::TransferDelegate(transfer) => { + transfer.validate_add_external_plugin_adapter(ctx) + } Plugin::UpdateDelegate(update_delegate) => { - update_delegate.validate_add_external_plugin(ctx) + update_delegate.validate_add_external_plugin_adapter(ctx) } Plugin::PermanentFreezeDelegate(permanent_freeze) => { - permanent_freeze.validate_add_external_plugin(ctx) + permanent_freeze.validate_add_external_plugin_adapter(ctx) } - Plugin::Attributes(attributes) => attributes.validate_add_external_plugin(ctx), + Plugin::Attributes(attributes) => attributes.validate_add_external_plugin_adapter(ctx), Plugin::PermanentTransferDelegate(permanent_transfer) => { - permanent_transfer.validate_add_external_plugin(ctx) + permanent_transfer.validate_add_external_plugin_adapter(ctx) } Plugin::PermanentBurnDelegate(permanent_burn) => { - permanent_burn.validate_add_external_plugin(ctx) + permanent_burn.validate_add_external_plugin_adapter(ctx) } - Plugin::Edition(edition) => edition.validate_add_external_plugin(ctx), + Plugin::Edition(edition) => edition.validate_add_external_plugin_adapter(ctx), Plugin::MasterEdition(master_edition) => { - master_edition.validate_add_external_plugin(ctx) + master_edition.validate_add_external_plugin_adapter(ctx) + } + Plugin::AddBlocker(add_blocker) => { + add_blocker.validate_add_external_plugin_adapter(ctx) } - Plugin::AddBlocker(add_blocker) => add_blocker.validate_add_external_plugin(ctx), Plugin::ImmutableMetadata(immutable_metadata) => { - immutable_metadata.validate_add_external_plugin(ctx) + immutable_metadata.validate_add_external_plugin_adapter(ctx) } } } /// Validate the remove plugin lifecycle event. - pub(crate) fn validate_remove_external_plugin( + pub(crate) fn validate_remove_external_plugin_adapter( plugin: &Plugin, ctx: &PluginValidationContext, ) -> Result { match plugin { - Plugin::Royalties(royalties) => royalties.validate_remove_external_plugin(ctx), - Plugin::FreezeDelegate(freeze) => freeze.validate_remove_external_plugin(ctx), - Plugin::BurnDelegate(burn) => burn.validate_remove_external_plugin(ctx), - Plugin::TransferDelegate(transfer) => transfer.validate_remove_external_plugin(ctx), + Plugin::Royalties(royalties) => royalties.validate_remove_external_plugin_adapter(ctx), + Plugin::FreezeDelegate(freeze) => freeze.validate_remove_external_plugin_adapter(ctx), + Plugin::BurnDelegate(burn) => burn.validate_remove_external_plugin_adapter(ctx), + Plugin::TransferDelegate(transfer) => { + transfer.validate_remove_external_plugin_adapter(ctx) + } Plugin::UpdateDelegate(update_delegate) => { - update_delegate.validate_remove_external_plugin(ctx) + update_delegate.validate_remove_external_plugin_adapter(ctx) } Plugin::PermanentFreezeDelegate(permanent_freeze) => { - permanent_freeze.validate_remove_external_plugin(ctx) + permanent_freeze.validate_remove_external_plugin_adapter(ctx) + } + Plugin::Attributes(attributes) => { + attributes.validate_remove_external_plugin_adapter(ctx) } - Plugin::Attributes(attributes) => attributes.validate_remove_external_plugin(ctx), Plugin::PermanentTransferDelegate(permanent_transfer) => { - permanent_transfer.validate_remove_external_plugin(ctx) + permanent_transfer.validate_remove_external_plugin_adapter(ctx) } Plugin::PermanentBurnDelegate(permanent_burn) => { - permanent_burn.validate_remove_external_plugin(ctx) + permanent_burn.validate_remove_external_plugin_adapter(ctx) } - Plugin::Edition(edition) => edition.validate_remove_external_plugin(ctx), + Plugin::Edition(edition) => edition.validate_remove_external_plugin_adapter(ctx), Plugin::MasterEdition(master_edition) => { - master_edition.validate_remove_external_plugin(ctx) + master_edition.validate_remove_external_plugin_adapter(ctx) + } + Plugin::AddBlocker(add_blocker) => { + add_blocker.validate_remove_external_plugin_adapter(ctx) } - Plugin::AddBlocker(add_blocker) => add_blocker.validate_remove_external_plugin(ctx), Plugin::ImmutableMetadata(immutable_metadata) => { - immutable_metadata.validate_remove_external_plugin(ctx) + immutable_metadata.validate_remove_external_plugin_adapter(ctx) } } } /// Route the validation of the update_plugin action to the appropriate plugin. /// There is no check for updating a plugin because the plugin itself MUST validate the change. - pub(crate) fn validate_update_external_plugin( + pub(crate) fn validate_update_external_plugin_adapter( plugin: &Plugin, ctx: &PluginValidationContext, ) -> Result { @@ -677,30 +688,36 @@ impl Plugin { }; let result = match plugin { - Plugin::Royalties(royalties) => royalties.validate_update_external_plugin(ctx), - Plugin::FreezeDelegate(freeze) => freeze.validate_update_external_plugin(ctx), - Plugin::BurnDelegate(burn) => burn.validate_update_external_plugin(ctx), - Plugin::TransferDelegate(transfer) => transfer.validate_update_external_plugin(ctx), + Plugin::Royalties(royalties) => royalties.validate_update_external_plugin_adapter(ctx), + Plugin::FreezeDelegate(freeze) => freeze.validate_update_external_plugin_adapter(ctx), + Plugin::BurnDelegate(burn) => burn.validate_update_external_plugin_adapter(ctx), + Plugin::TransferDelegate(transfer) => { + transfer.validate_update_external_plugin_adapter(ctx) + } Plugin::UpdateDelegate(update_delegate) => { - update_delegate.validate_update_external_plugin(ctx) + update_delegate.validate_update_external_plugin_adapter(ctx) } Plugin::PermanentFreezeDelegate(permanent_freeze) => { - permanent_freeze.validate_update_external_plugin(ctx) + permanent_freeze.validate_update_external_plugin_adapter(ctx) + } + Plugin::Attributes(attributes) => { + attributes.validate_update_external_plugin_adapter(ctx) } - Plugin::Attributes(attributes) => attributes.validate_update_external_plugin(ctx), Plugin::PermanentTransferDelegate(permanent_transfer) => { - permanent_transfer.validate_update_external_plugin(ctx) + permanent_transfer.validate_update_external_plugin_adapter(ctx) } Plugin::PermanentBurnDelegate(permanent_burn) => { - permanent_burn.validate_update_external_plugin(ctx) + permanent_burn.validate_update_external_plugin_adapter(ctx) } - Plugin::Edition(edition) => edition.validate_update_external_plugin(ctx), + Plugin::Edition(edition) => edition.validate_update_external_plugin_adapter(ctx), Plugin::MasterEdition(master_edition) => { - master_edition.validate_update_external_plugin(ctx) + master_edition.validate_update_external_plugin_adapter(ctx) + } + Plugin::AddBlocker(add_blocker) => { + add_blocker.validate_update_external_plugin_adapter(ctx) } - Plugin::AddBlocker(add_blocker) => add_blocker.validate_update_external_plugin(ctx), Plugin::ImmutableMetadata(immutable_metadata) => { - immutable_metadata.validate_update_external_plugin(ctx) + immutable_metadata.validate_update_external_plugin_adapter(ctx) } }?; @@ -739,8 +756,8 @@ pub enum ValidationResult { ForceApproved, } -/// External plugins lifecycle validations -/// External plugins utilize this to indicate whether they approve or reject a lifecycle action. +/// External plugin adapters lifecycle validations +/// External plugin adapters utilize this to indicate whether they approve or reject a lifecycle action. #[derive(Eq, PartialEq, Debug, Clone, BorshDeserialize, BorshSerialize)] pub enum ExternalValidationResult { /// The plugin approves the lifecycle action. @@ -801,7 +818,7 @@ pub(crate) trait PluginValidation { } /// Validate the add plugin lifecycle action. - fn validate_add_external_plugin( + fn validate_add_external_plugin_adapter( &self, _ctx: &PluginValidationContext, ) -> Result { @@ -809,7 +826,7 @@ pub(crate) trait PluginValidation { } /// Validate the remove plugin lifecycle action. - fn validate_remove_external_plugin( + fn validate_remove_external_plugin_adapter( &self, _ctx: &PluginValidationContext, ) -> Result { @@ -905,7 +922,7 @@ pub(crate) trait PluginValidation { } /// Validate the update_plugin lifecycle action. - fn validate_update_external_plugin( + fn validate_update_external_plugin_adapter( &self, _ctx: &PluginValidationContext, ) -> Result { @@ -980,15 +997,15 @@ pub(crate) fn validate_plugin_checks<'a>( } } -/// This function iterates through all external plugin checks passed in and performs the validation +/// This function iterates through all external plugin adapter checks passed in and performs the validation /// by deserializing and calling validate on the plugin. /// The STRONGEST result is returned. #[allow(clippy::too_many_arguments, clippy::type_complexity)] -pub(crate) fn validate_external_plugin_checks<'a>( +pub(crate) fn validate_external_plugin_adapter_checks<'a>( key: Key, accounts: &'a [AccountInfo<'a>], external_checks: &BTreeMap< - ExternalPluginKey, + ExternalPluginAdapterKey, (Key, ExternalCheckResultBits, ExternalRegistryRecord), >, authority: &'a AccountInfo<'a>, @@ -997,8 +1014,8 @@ pub(crate) fn validate_external_plugin_checks<'a>( asset: Option<&'a AccountInfo<'a>>, collection: Option<&'a AccountInfo<'a>>, resolved_authorities: &[Authority], - external_plugin_validate_fp: fn( - &ExternalPlugin, + external_plugin_adapter_validate_fp: fn( + &ExternalPluginAdapter, &PluginValidationContext, ) -> Result, ) -> Result { @@ -1026,8 +1043,8 @@ pub(crate) fn validate_external_plugin_checks<'a>( target_plugin: new_plugin, }; - let result = external_plugin_validate_fp( - &ExternalPlugin::load(account, external_registry_record.offset)?, + let result = external_plugin_adapter_validate_fp( + &ExternalPluginAdapter::load(account, external_registry_record.offset)?, &validation_ctx, )?; match result { @@ -1042,7 +1059,7 @@ pub(crate) fn validate_external_plugin_checks<'a>( } } ValidationResult::Pass => continue, - // Force approved will not be possible from external plugins. + // Force approved will not be possible from external plugin adapters. ValidationResult::ForceApproved => unreachable!(), } } diff --git a/programs/mpl-core/src/plugins/lifecycle_hook.rs b/programs/mpl-core/src/plugins/lifecycle_hook.rs index d5f1b834..81938d5c 100644 --- a/programs/mpl-core/src/plugins/lifecycle_hook.rs +++ b/programs/mpl-core/src/plugins/lifecycle_hook.rs @@ -2,12 +2,12 @@ use borsh::{BorshDeserialize, BorshSerialize}; use solana_program::{program_error::ProgramError, pubkey::Pubkey}; use super::{ - Authority, ExternalCheckResult, ExternalPluginSchema, ExtraAccount, HookableLifecycleEvent, - PluginValidation, PluginValidationContext, ValidationResult, + Authority, ExternalCheckResult, ExternalPluginAdapterSchema, ExtraAccount, + HookableLifecycleEvent, PluginValidation, PluginValidationContext, ValidationResult, }; /// Lifecycle hook that CPIs into the `hooked_program`. This hook is used for any lifecycle events -/// that were selected in the `ExternalPluginRecord` for the plugin. If any extra accounts are +/// that were selected in the `ExternalRegistryRecord` for the plugin. If any extra accounts are /// present in the `extra_accounts` optional `Vec`, then these accounts are added to the CPI call /// in the order in which they are in the Vec. Any PDAs in the `Vec` are derived using the hooked /// program. The hooked program will return a validation result and new data to store at the @@ -23,7 +23,7 @@ pub struct LifecycleHook { /// the plugin is added. pub data_authority: Option, /// Schema for the data used by the plugin. - pub schema: ExternalPluginSchema, // 1 + pub schema: ExternalPluginAdapterSchema, // 1 } impl LifecycleHook { @@ -39,7 +39,7 @@ impl LifecycleHook { } impl PluginValidation for LifecycleHook { - fn validate_add_external_plugin( + fn validate_add_external_plugin_adapter( &self, _ctx: &PluginValidationContext, ) -> Result { @@ -72,7 +72,7 @@ pub struct LifecycleHookInitInfo { pub hooked_program: Pubkey, /// Initial plugin authority. pub init_plugin_authority: Option, - /// The lifecyle events for which the the external plugin is active. + /// The lifecyle events for which the the external plugin adapter is active. pub lifecycle_checks: Vec<(HookableLifecycleEvent, ExternalCheckResult)>, /// The extra accounts to use for the lifecycle hook. pub extra_accounts: Option>, @@ -81,16 +81,16 @@ pub struct LifecycleHookInitInfo { /// the plugin is added. pub data_authority: Option, /// Schema for the data used by the plugin. - pub schema: Option, + pub schema: Option, } /// Lifecycle hook update info. #[derive(Clone, Debug, BorshSerialize, BorshDeserialize, Eq, PartialEq)] pub struct LifecycleHookUpdateInfo { - /// The lifecyle events for which the the external plugin is active. + /// The lifecyle events for which the the external plugin adapter is active. pub lifecycle_checks: Option>, /// The extra accounts to use for the lifecycle hook. pub extra_accounts: Option>, /// Schema for the data used by the plugin. - pub schema: Option, + pub schema: Option, } diff --git a/programs/mpl-core/src/plugins/mod.rs b/programs/mpl-core/src/plugins/mod.rs index fedd2caa..93ef8da7 100644 --- a/programs/mpl-core/src/plugins/mod.rs +++ b/programs/mpl-core/src/plugins/mod.rs @@ -3,7 +3,7 @@ mod attributes; mod burn_delegate; mod data_store; mod edition; -mod external_plugins; +mod external_plugin_adapters; mod freeze_delegate; mod immutable_metadata; mod lifecycle; @@ -28,7 +28,7 @@ pub use attributes::*; pub use burn_delegate::*; pub use data_store::*; pub use edition::*; -pub use external_plugins::*; +pub use external_plugin_adapters::*; pub use freeze_delegate::*; pub use immutable_metadata::*; pub use lifecycle::*; diff --git a/programs/mpl-core/src/plugins/oracle.rs b/programs/mpl-core/src/plugins/oracle.rs index 3d0842c9..a0a0c1c7 100644 --- a/programs/mpl-core/src/plugins/oracle.rs +++ b/programs/mpl-core/src/plugins/oracle.rs @@ -10,14 +10,16 @@ use super::{ /// Oracle plugin that allows getting a `ValidationResult` for a lifecycle event from an arbitrary /// account either specified by or derived from the `base_address`. This hook is used for any -/// lifecycle events that were selected in the `ExternalPluginRecord` for the plugin. +/// lifecycle events that were selected in the `ExternalRegistryRecord` for the plugin. #[derive(Clone, Debug, BorshSerialize, BorshDeserialize, Eq, PartialEq)] pub struct Oracle { /// The address of the oracle, or if using the `pda` option, a program ID from which /// to derive a PDA. pub base_address: Pubkey, - /// Optional PDA (derived from Pubkey attached to `ExternalPluginKey`). - pub pda: Option, + /// Optional account specification (PDA derived from `base_address` or other available account + /// specifications). Note that even when this configuration is used there is still only one + /// Oracle account specified by the adapter. + pub base_address_config: Option, /// Validation results offset in the Oracle account. Default is `ValidationResultsOffset::NoOffset`. pub results_offset: ValidationResultsOffset, } @@ -25,8 +27,8 @@ pub struct Oracle { impl Oracle { /// Updates the oracle with the new info. pub fn update(&mut self, info: &OracleUpdateInfo) { - if let Some(pda) = &info.pda { - self.pda = Some(pda.clone()); + if let Some(base_address_config) = &info.base_address_config { + self.base_address_config = Some(base_address_config.clone()); } if let Some(results_offset) = &info.results_offset { self.results_offset = *results_offset; @@ -35,7 +37,7 @@ impl Oracle { } impl PluginValidation for Oracle { - fn validate_add_external_plugin( + fn validate_add_external_plugin_adapter( &self, _ctx: &PluginValidationContext, ) -> Result { @@ -77,7 +79,7 @@ impl Oracle { ctx: &PluginValidationContext, event: HookableLifecycleEvent, ) -> Result { - let oracle_account = match &self.pda { + let oracle_account = match &self.base_address_config { None => self.base_address, Some(extra_account) => extra_account.derive(&self.base_address, ctx)?, }; @@ -86,7 +88,7 @@ impl Oracle { .accounts .iter() .find(|account| *account.key == oracle_account) - .ok_or(MplCoreError::MissingExternalAccount)?; + .ok_or(MplCoreError::MissingExternalPluginAdapterAccount)?; let offset = self.results_offset.to_offset_usize(); @@ -123,7 +125,7 @@ impl From<&OracleInitInfo> for Oracle { fn from(init_info: &OracleInitInfo) -> Self { Self { base_address: init_info.base_address, - pda: init_info.pda.clone(), + base_address_config: init_info.base_address_config.clone(), results_offset: init_info .results_offset .unwrap_or(ValidationResultsOffset::NoOffset), @@ -139,10 +141,12 @@ pub struct OracleInitInfo { pub base_address: Pubkey, /// Initial plugin authority. pub init_plugin_authority: Option, - /// The lifecyle events for which the the external plugin is active. + /// The lifecyle events for which the the external plugin adapter is active. pub lifecycle_checks: Vec<(HookableLifecycleEvent, ExternalCheckResult)>, - /// Optional PDA (derived from Pubkey attached to `ExternalPluginKey`). - pub pda: Option, + /// Optional account specification (PDA derived from `base_address` or other available account + /// specifications). Note that even when this configuration is used there is still only one + /// Oracle account specified by the adapter. + pub base_address_config: Option, /// Optional offset for validation results struct used in Oracle account. Default /// is `ValidationResultsOffset::NoOffset`. pub results_offset: Option, @@ -151,10 +155,12 @@ pub struct OracleInitInfo { /// Oracle update info. #[derive(Clone, Debug, BorshSerialize, BorshDeserialize, Eq, PartialEq)] pub struct OracleUpdateInfo { - /// The lifecyle events for which the the external plugin is active. + /// The lifecyle events for which the the external plugin adapter is active. pub lifecycle_checks: Option>, - /// Optional PDA (derived from Pubkey attached to `ExternalPluginKey`). - pub pda: Option, + /// Optional account specification (PDA derived from `base_address` or other available account + /// specifications). Note that even when this configuration is used there is still only one + /// Oracle account specified by the adapter. + pub base_address_config: Option, /// Optional offset for validation results struct used in Oracle account. Default /// is `ValidationResultsOffset::NoOffset`. pub results_offset: Option, diff --git a/programs/mpl-core/src/plugins/plugin_registry.rs b/programs/mpl-core/src/plugins/plugin_registry.rs index a843bae6..e2c9f6cd 100644 --- a/programs/mpl-core/src/plugins/plugin_registry.rs +++ b/programs/mpl-core/src/plugins/plugin_registry.rs @@ -9,8 +9,8 @@ use crate::{ }; use super::{ - CheckResult, ExternalCheckResult, ExternalCheckResultBits, ExternalPluginKey, - ExternalPluginType, ExternalPluginUpdateInfo, HookableLifecycleEvent, PluginType, + CheckResult, ExternalCheckResult, ExternalCheckResultBits, ExternalPluginAdapterKey, + ExternalPluginAdapterType, ExternalPluginAdapterUpdateInfo, HookableLifecycleEvent, PluginType, }; /// The Plugin Registry stores a record of all plugins, their location, and their authorities. @@ -21,7 +21,7 @@ pub struct PluginRegistryV1 { pub key: Key, // 1 /// The registry of all plugins. pub registry: Vec, // 4 - /// The registry of all external, third party, plugins. + /// The registry of all adapter, third party, plugins. pub external_registry: Vec, // 4 } @@ -41,13 +41,13 @@ impl PluginRegistryV1 { } } - pub(crate) fn check_external_registry( + pub(crate) fn check_adapter_registry( &self, account: &AccountInfo, key: Key, lifecycle_event: &HookableLifecycleEvent, result: &mut BTreeMap< - ExternalPluginKey, + ExternalPluginAdapterKey, (Key, ExternalCheckResultBits, ExternalRegistryRecord), >, ) -> ProgramResult { @@ -55,7 +55,7 @@ impl PluginRegistryV1 { if let Some(lifecycle_checks) = &record.lifecycle_checks { for (event, check_result) in lifecycle_checks { if event == lifecycle_event { - let plugin_key = ExternalPluginKey::from_record(account, record)?; + let plugin_key = ExternalPluginAdapterKey::from_record(account, record)?; result.insert( plugin_key, @@ -113,11 +113,11 @@ impl RegistryRecord { #[repr(C)] #[derive(Clone, BorshSerialize, BorshDeserialize, Debug)] pub struct ExternalRegistryRecord { - /// The external, third party plugin type. - pub plugin_type: ExternalPluginType, - /// The authority of the external plugin. + /// The adapter, third party plugin type. + pub plugin_type: ExternalPluginAdapterType, + /// The authority of the external plugin adapter. pub authority: Authority, - /// The lifecyle events for which the the external plugin is active. + /// The lifecyle events for which the the external plugin adapter is active. pub lifecycle_checks: Option>, /// The offset to the plugin in the account. pub offset: usize, // 8 @@ -128,16 +128,16 @@ pub struct ExternalRegistryRecord { } impl ExternalRegistryRecord { - /// Update the external registry record with the new info, if relevant. - pub fn update(&mut self, update_info: &ExternalPluginUpdateInfo) -> ProgramResult { + /// Update the adapter registry record with the new info, if relevant. + pub fn update(&mut self, update_info: &ExternalPluginAdapterUpdateInfo) -> ProgramResult { match update_info { - ExternalPluginUpdateInfo::LifecycleHook(update_info) => { + ExternalPluginAdapterUpdateInfo::LifecycleHook(update_info) => { if let Some(checks) = &update_info.lifecycle_checks { validate_lifecycle_checks(checks, false)?; self.lifecycle_checks = update_info.lifecycle_checks.clone() } } - ExternalPluginUpdateInfo::Oracle(update_info) => { + ExternalPluginAdapterUpdateInfo::Oracle(update_info) => { if let Some(checks) = &update_info.lifecycle_checks { validate_lifecycle_checks(checks, true)?; self.lifecycle_checks = update_info.lifecycle_checks.clone() diff --git a/programs/mpl-core/src/plugins/utils.rs b/programs/mpl-core/src/plugins/utils.rs index c1a974a3..d124862f 100644 --- a/programs/mpl-core/src/plugins/utils.rs +++ b/programs/mpl-core/src/plugins/utils.rs @@ -13,8 +13,9 @@ use crate::{ }; use super::{ - ExternalPlugin, ExternalPluginInitInfo, ExternalPluginKey, ExternalPluginType, - ExternalRegistryRecord, Plugin, PluginHeaderV1, PluginRegistryV1, PluginType, RegistryRecord, + ExternalPluginAdapter, ExternalPluginAdapterInitInfo, ExternalPluginAdapterKey, + ExternalPluginAdapterType, ExternalRegistryRecord, Plugin, PluginHeaderV1, PluginRegistryV1, + PluginType, RegistryRecord, }; /// Create plugin header and registry if it doesn't exist @@ -179,19 +180,19 @@ pub fn fetch_wrapped_plugin( Ok((registry_record.authority, plugin)) } -/// Fetch the external plugin from the registry. -pub fn fetch_wrapped_external_plugin( +/// Fetch the external plugin adapter from the registry. +pub fn fetch_wrapped_external_plugin_adapter( account: &AccountInfo, core: Option<&T>, - plugin_key: &ExternalPluginKey, -) -> Result<(Authority, ExternalPlugin), ProgramError> { + plugin_key: &ExternalPluginAdapterKey, +) -> Result<(Authority, ExternalPluginAdapter), ProgramError> { let size = match core { Some(core) => core.get_size(), None => { let asset = T::load(account, 0)?; if asset.get_size() == account.data_len() { - return Err(MplCoreError::ExternalPluginNotFound.into()); + return Err(MplCoreError::ExternalPluginAdapterNotFound.into()); } asset.get_size() @@ -202,16 +203,17 @@ pub fn fetch_wrapped_external_plugin( let plugin_registry = PluginRegistryV1::load(account, header.plugin_registry_offset)?; // Find the plugin in the registry. - let result = find_external_plugin(&plugin_registry, plugin_key, account)?; + let result = find_external_plugin_adapter(&plugin_registry, plugin_key, account)?; if let (_, Some(record)) = result { // Deserialize the plugin. - let plugin = ExternalPlugin::deserialize(&mut &(*account.data).borrow()[record.offset..])?; + let plugin = + ExternalPluginAdapter::deserialize(&mut &(*account.data).borrow()[record.offset..])?; // Return the plugin and its authority. Ok((record.authority, plugin)) } else { - Err(MplCoreError::ExternalPluginNotFound.into()) + Err(MplCoreError::ExternalPluginAdapterNotFound.into()) } } @@ -307,9 +309,9 @@ pub fn initialize_plugin<'a, T: DataBlob + SolanaAccount>( Ok(()) } -/// Add an external plugin to the registry and initialize it. -pub fn initialize_external_plugin<'a, T: DataBlob + SolanaAccount>( - init_info: &ExternalPluginInitInfo, +/// Add an external plugin adapter to the registry and initialize it. +pub fn initialize_external_plugin_adapter<'a, T: DataBlob + SolanaAccount>( + init_info: &ExternalPluginAdapterInitInfo, plugin_header: &mut PluginHeaderV1, plugin_registry: &mut PluginRegistryV1, account: &AccountInfo<'a>, @@ -320,38 +322,43 @@ pub fn initialize_external_plugin<'a, T: DataBlob + SolanaAccount>( let header_offset = core.get_size(); let plugin_type = init_info.into(); - // Note currently we are blocking adding LifecycleHook and DataStore external plugins as they + // Note currently we are blocking adding LifecycleHook and DataStore external plugin adapters as they // are still in development. match init_info { - ExternalPluginInitInfo::LifecycleHook(_) | ExternalPluginInitInfo::DataStore(_) => { + ExternalPluginAdapterInitInfo::LifecycleHook(_) + | ExternalPluginAdapterInitInfo::DataStore(_) => { return Err(MplCoreError::NotAvailable.into()); } - ExternalPluginInitInfo::Oracle(_) => (), + ExternalPluginAdapterInitInfo::Oracle(_) => (), } // You cannot add a duplicate plugin. for record in plugin_registry.external_registry.iter() { - if ExternalPluginKey::from_record(account, record)? == ExternalPluginKey::from(init_info) { - return Err(MplCoreError::ExternalPluginAlreadyExists.into()); + if ExternalPluginAdapterKey::from_record(account, record)? + == ExternalPluginAdapterKey::from(init_info) + { + return Err(MplCoreError::ExternalPluginAdapterAlreadyExists.into()); } } let (authority, lifecycle_checks) = match init_info { - ExternalPluginInitInfo::LifecycleHook(init_info) => { + ExternalPluginAdapterInitInfo::LifecycleHook(init_info) => { validate_lifecycle_checks(&init_info.lifecycle_checks, false)?; ( init_info.init_plugin_authority, Some(init_info.lifecycle_checks.clone()), ) } - ExternalPluginInitInfo::Oracle(init_info) => { + ExternalPluginAdapterInitInfo::Oracle(init_info) => { validate_lifecycle_checks(&init_info.lifecycle_checks, true)?; ( init_info.init_plugin_authority, Some(init_info.lifecycle_checks.clone()), ) } - ExternalPluginInitInfo::DataStore(init_info) => (init_info.init_plugin_authority, None), + ExternalPluginAdapterInitInfo::DataStore(init_info) => { + (init_info.init_plugin_authority, None) + } }; let old_registry_offset = plugin_header.plugin_registry_offset; @@ -365,11 +372,11 @@ pub fn initialize_external_plugin<'a, T: DataBlob + SolanaAccount>( data_len: None, }; - let mut plugin = ExternalPlugin::from(init_info); + let mut plugin = ExternalPluginAdapter::from(init_info); // If the plugin is a LifecycleHook or DataStore, then we need to set the data offset and length. match &mut plugin { - ExternalPlugin::LifecycleHook(_) | ExternalPlugin::DataStore(_) => { + ExternalPluginAdapter::LifecycleHook(_) | ExternalPluginAdapter::DataStore(_) => { new_registry_record.data_offset = Some(old_registry_offset); new_registry_record.data_len = Some(0); } @@ -522,22 +529,22 @@ pub fn delete_plugin<'a, T: DataBlob>( } /// Remove a plugin from the registry and delete it. -pub fn delete_external_plugin<'a, T: DataBlob>( - plugin_key: &ExternalPluginKey, +pub fn delete_external_plugin_adapter<'a, T: DataBlob>( + plugin_key: &ExternalPluginAdapterKey, asset: &T, account: &AccountInfo<'a>, payer: &AccountInfo<'a>, system_program: &AccountInfo<'a>, ) -> ProgramResult { if asset.get_size() == account.data_len() { - return Err(MplCoreError::ExternalPluginNotFound.into()); + return Err(MplCoreError::ExternalPluginAdapterNotFound.into()); } //TODO: Bytemuck this. let mut header = PluginHeaderV1::load(account, asset.get_size())?; let mut plugin_registry = PluginRegistryV1::load(account, header.plugin_registry_offset)?; - let result = find_external_plugin(&plugin_registry, plugin_key, account)?; + let result = find_external_plugin_adapter(&plugin_registry, plugin_key, account)?; if let (Some(index), _) = result { let registry_record = plugin_registry.external_registry.remove(index); @@ -545,7 +552,7 @@ pub fn delete_external_plugin<'a, T: DataBlob>( // Fetch the offset of the plugin to be removed. let plugin_offset = registry_record.offset; - let plugin = ExternalPlugin::load(account, plugin_offset)?; + let plugin = ExternalPluginAdapter::load(account, plugin_offset)?; let serialized_plugin = plugin.try_to_vec()?; // Get the offset of the plugin after the one being removed. @@ -599,7 +606,7 @@ pub fn delete_external_plugin<'a, T: DataBlob>( resize_or_reallocate_account(account, payer, system_program, new_size)?; } else { - return Err(MplCoreError::ExternalPluginNotFound.into()); + return Err(MplCoreError::ExternalPluginAdapterNotFound.into()); } Ok(()) @@ -671,16 +678,17 @@ pub fn revoke_authority_on_plugin<'a>( Ok(()) } -pub(crate) fn find_external_plugin<'b>( +pub(crate) fn find_external_plugin_adapter<'b>( plugin_registry: &'b PluginRegistryV1, - plugin_key: &ExternalPluginKey, + plugin_key: &ExternalPluginAdapterKey, account: &AccountInfo<'_>, ) -> Result<(Option, Option<&'b ExternalRegistryRecord>), ProgramError> { let mut result = (None, None); for (i, record) in plugin_registry.external_registry.iter().enumerate() { - if record.plugin_type == ExternalPluginType::from(plugin_key) + if record.plugin_type == ExternalPluginAdapterType::from(plugin_key) && (match plugin_key { - ExternalPluginKey::LifecycleHook(address) | ExternalPluginKey::Oracle(address) => { + ExternalPluginAdapterKey::LifecycleHook(address) + | ExternalPluginAdapterKey::Oracle(address) => { let pubkey_offset = record .offset .checked_add(1) @@ -692,7 +700,7 @@ pub(crate) fn find_external_plugin<'b>( Err(_) => return Err(MplCoreError::DeserializationError.into()), } } - ExternalPluginKey::DataStore(authority) => { + ExternalPluginAdapterKey::DataStore(authority) => { let authority_offset = record .offset .checked_add(1) diff --git a/programs/mpl-core/src/processor/add_external_plugin.rs b/programs/mpl-core/src/processor/add_external_plugin_adapter.rs similarity index 63% rename from programs/mpl-core/src/processor/add_external_plugin.rs rename to programs/mpl-core/src/processor/add_external_plugin_adapter.rs index d6d31a6c..85cd0733 100644 --- a/programs/mpl-core/src/processor/add_external_plugin.rs +++ b/programs/mpl-core/src/processor/add_external_plugin_adapter.rs @@ -4,10 +4,13 @@ use solana_program::{account_info::AccountInfo, entrypoint::ProgramResult, msg}; use crate::{ error::MplCoreError, - instruction::accounts::{AddCollectionExternalPluginV1Accounts, AddExternalPluginV1Accounts}, + instruction::accounts::{ + AddCollectionExternalPluginAdapterV1Accounts, AddExternalPluginAdapterV1Accounts, + }, plugins::{ - create_meta_idempotent, initialize_external_plugin, ExternalPlugin, ExternalPluginInitInfo, - Plugin, PluginType, PluginValidationContext, ValidationResult, + create_meta_idempotent, initialize_external_plugin_adapter, ExternalPluginAdapter, + ExternalPluginAdapterInitInfo, Plugin, PluginType, PluginValidationContext, + ValidationResult, }, state::{AssetV1, Authority, CollectionV1, DataBlob, Key, SolanaAccount}, utils::{ @@ -17,16 +20,16 @@ use crate::{ #[repr(C)] #[derive(BorshSerialize, BorshDeserialize, PartialEq, Eq, Debug, Clone)] -pub(crate) struct AddExternalPluginV1Args { - /// External plugin initialization info. - pub init_info: ExternalPluginInitInfo, +pub(crate) struct AddExternalPluginAdapterV1Args { + /// External plugin adapter initialization info. + pub init_info: ExternalPluginAdapterInitInfo, } -pub(crate) fn add_external_plugin<'a>( +pub(crate) fn add_external_plugin_adapter<'a>( accounts: &'a [AccountInfo<'a>], - args: AddExternalPluginV1Args, + args: AddExternalPluginAdapterV1Args, ) -> ProgramResult { - let ctx = AddExternalPluginV1Accounts::context(accounts)?; + let ctx = AddExternalPluginAdapterV1Accounts::context(accounts)?; // Guards. assert_signer(ctx.accounts.payer)?; @@ -58,15 +61,15 @@ pub(crate) fn add_external_plugin<'a>( target_plugin: None, }; - if ExternalPlugin::validate_add_external_plugin( - &ExternalPlugin::from(&args.init_info), + if ExternalPluginAdapter::validate_add_external_plugin_adapter( + &ExternalPluginAdapter::from(&args.init_info), &validation_ctx, )? == ValidationResult::Rejected { return Err(MplCoreError::InvalidAuthority.into()); } - let external_plugin = ExternalPlugin::from(&args.init_info); + let external_plugin_adapter = ExternalPluginAdapter::from(&args.init_info); // Validate asset permissions. let (mut asset, _, _) = validate_asset_permissions( @@ -76,13 +79,13 @@ pub(crate) fn add_external_plugin<'a>( ctx.accounts.collection, None, None, - Some(&external_plugin), - AssetV1::check_add_external_plugin, - CollectionV1::check_add_external_plugin, - PluginType::check_add_external_plugin, - AssetV1::validate_add_external_plugin, - CollectionV1::validate_add_external_plugin, - Plugin::validate_add_external_plugin, + Some(&external_plugin_adapter), + AssetV1::check_add_external_plugin_adapter, + CollectionV1::check_add_external_plugin_adapter, + PluginType::check_add_external_plugin_adapter, + AssetV1::validate_add_external_plugin_adapter, + CollectionV1::validate_add_external_plugin_adapter, + Plugin::validate_add_external_plugin_adapter, None, None, )?; @@ -90,7 +93,7 @@ pub(crate) fn add_external_plugin<'a>( // Increment sequence number and save only if it is `Some(_)`. asset.increment_seq_and_save(ctx.accounts.asset)?; - process_add_external_plugin::( + process_add_external_plugin_adapter::( ctx.accounts.asset, ctx.accounts.payer, ctx.accounts.system_program, @@ -100,16 +103,16 @@ pub(crate) fn add_external_plugin<'a>( #[repr(C)] #[derive(BorshSerialize, BorshDeserialize, PartialEq, Eq, Debug, Clone)] -pub(crate) struct AddCollectionExternalPluginV1Args { - /// External plugin initialization info. - pub init_info: ExternalPluginInitInfo, +pub(crate) struct AddCollectionExternalPluginAdapterV1Args { + /// External plugin adapter initialization info. + pub init_info: ExternalPluginAdapterInitInfo, } -pub(crate) fn add_collection_external_plugin<'a>( +pub(crate) fn add_collection_external_plugin_adapter<'a>( accounts: &'a [AccountInfo<'a>], - args: AddCollectionExternalPluginV1Args, + args: AddCollectionExternalPluginAdapterV1Args, ) -> ProgramResult { - let ctx = AddCollectionExternalPluginV1Accounts::context(accounts)?; + let ctx = AddCollectionExternalPluginAdapterV1Accounts::context(accounts)?; // Guards. assert_signer(ctx.accounts.payer)?; @@ -136,15 +139,15 @@ pub(crate) fn add_collection_external_plugin<'a>( target_plugin: None, }; - if ExternalPlugin::validate_add_external_plugin( - &ExternalPlugin::from(&args.init_info), + if ExternalPluginAdapter::validate_add_external_plugin_adapter( + &ExternalPluginAdapter::from(&args.init_info), &validation_ctx, )? == ValidationResult::Rejected { return Err(MplCoreError::InvalidAuthority.into()); } - let external_plugin = ExternalPlugin::from(&args.init_info); + let external_plugin_adapter = ExternalPluginAdapter::from(&args.init_info); // Validate collection permissions. let _ = validate_collection_permissions( @@ -152,16 +155,16 @@ pub(crate) fn add_collection_external_plugin<'a>( authority, ctx.accounts.collection, None, - Some(&external_plugin), - CollectionV1::check_add_external_plugin, - PluginType::check_add_external_plugin, - CollectionV1::validate_add_external_plugin, - Plugin::validate_add_external_plugin, + Some(&external_plugin_adapter), + CollectionV1::check_add_external_plugin_adapter, + PluginType::check_add_external_plugin_adapter, + CollectionV1::validate_add_external_plugin_adapter, + Plugin::validate_add_external_plugin_adapter, None, None, )?; - process_add_external_plugin::( + process_add_external_plugin_adapter::( ctx.accounts.collection, ctx.accounts.payer, ctx.accounts.system_program, @@ -169,15 +172,15 @@ pub(crate) fn add_collection_external_plugin<'a>( ) } -fn process_add_external_plugin<'a, T: DataBlob + SolanaAccount>( +fn process_add_external_plugin_adapter<'a, T: DataBlob + SolanaAccount>( account: &AccountInfo<'a>, payer: &AccountInfo<'a>, system_program: &AccountInfo<'a>, - init_info: &ExternalPluginInitInfo, + init_info: &ExternalPluginAdapterInitInfo, ) -> ProgramResult { let (_, mut plugin_header, mut plugin_registry) = create_meta_idempotent::(account, payer, system_program)?; - initialize_external_plugin::( + initialize_external_plugin_adapter::( init_info, &mut plugin_header, &mut plugin_registry, diff --git a/programs/mpl-core/src/processor/burn.rs b/programs/mpl-core/src/processor/burn.rs index 8d01f7d1..2e78c4cb 100644 --- a/programs/mpl-core/src/processor/burn.rs +++ b/programs/mpl-core/src/processor/burn.rs @@ -5,7 +5,7 @@ use solana_program::{account_info::AccountInfo, entrypoint::ProgramResult, msg}; use crate::{ error::MplCoreError, instruction::accounts::{BurnCollectionV1Accounts, BurnV1Accounts}, - plugins::{ExternalPlugin, HookableLifecycleEvent, Plugin, PluginType}, + plugins::{ExternalPluginAdapter, HookableLifecycleEvent, Plugin, PluginType}, state::{AssetV1, CollectionV1, CompressionProof, Key, SolanaAccount, Wrappable}, utils::{ close_program_account, load_key, rebuild_account_state_from_proof_data, resolve_authority, @@ -97,7 +97,7 @@ pub(crate) fn burn<'a>(accounts: &'a [AccountInfo<'a>], args: BurnV1Args) -> Pro AssetV1::validate_burn, CollectionV1::validate_burn, Plugin::validate_burn, - Some(ExternalPlugin::validate_burn), + Some(ExternalPluginAdapter::validate_burn), Some(HookableLifecycleEvent::Burn), )?; @@ -142,7 +142,7 @@ pub(crate) fn burn_collection<'a>( PluginType::check_burn, CollectionV1::validate_burn, Plugin::validate_burn, - Some(ExternalPlugin::validate_burn), + Some(ExternalPluginAdapter::validate_burn), Some(HookableLifecycleEvent::Burn), )?; diff --git a/programs/mpl-core/src/processor/create.rs b/programs/mpl-core/src/processor/create.rs index 08247179..5ecea2f2 100644 --- a/programs/mpl-core/src/processor/create.rs +++ b/programs/mpl-core/src/processor/create.rs @@ -9,9 +9,10 @@ use crate::{ error::MplCoreError, instruction::accounts::CreateV2Accounts, plugins::{ - create_meta_idempotent, create_plugin_meta, initialize_external_plugin, initialize_plugin, - CheckResult, ExternalCheckResultBits, ExternalPlugin, ExternalPluginInitInfo, Plugin, - PluginAuthorityPair, PluginType, PluginValidationContext, ValidationResult, + create_meta_idempotent, create_plugin_meta, initialize_external_plugin_adapter, + initialize_plugin, CheckResult, ExternalCheckResultBits, ExternalPluginAdapter, + ExternalPluginAdapterInitInfo, Plugin, PluginAuthorityPair, PluginType, + PluginValidationContext, ValidationResult, }, state::{ AssetV1, Authority, CollectionV1, DataState, SolanaAccount, UpdateAuthority, COLLECT_AMOUNT, @@ -35,7 +36,7 @@ pub(crate) struct CreateV2Args { pub(crate) name: String, pub(crate) uri: String, pub(crate) plugins: Option>, - pub(crate) external_plugins: Option>, + pub(crate) external_plugin_adapters: Option>, } impl From for CreateV2Args { @@ -45,7 +46,7 @@ impl From for CreateV2Args { name: item.name, uri: item.uri, plugins: item.plugins, - external_plugins: None, + external_plugin_adapters: None, } } } @@ -199,7 +200,7 @@ pub(crate) fn process_create<'a>( } } - if let Some(plugins) = args.external_plugins { + if let Some(plugins) = args.external_plugin_adapters { if !plugins.is_empty() { let (_, mut plugin_header, mut plugin_registry) = create_meta_idempotent::( ctx.accounts.asset, @@ -208,7 +209,7 @@ pub(crate) fn process_create<'a>( )?; for plugin_init_info in &plugins { let external_check_result_bits = ExternalCheckResultBits::from( - ExternalPlugin::check_create(plugin_init_info), + ExternalPluginAdapter::check_create(plugin_init_info), ); if external_check_result_bits.can_reject() { @@ -216,22 +217,22 @@ pub(crate) fn process_create<'a>( accounts, asset_info: Some(ctx.accounts.asset), collection_info: ctx.accounts.collection, - // External plugins are always managed by the update authority. + // External plugin adapters are always managed by the update authority. self_authority: &Authority::UpdateAuthority, authority_info: authority, resolved_authorities: None, new_owner: None, target_plugin: None, }; - if ExternalPlugin::validate_create( - &ExternalPlugin::from(plugin_init_info), + if ExternalPluginAdapter::validate_create( + &ExternalPluginAdapter::from(plugin_init_info), &validation_ctx, )? == ValidationResult::Rejected { approved = false; } } - initialize_external_plugin::( + initialize_external_plugin_adapter::( plugin_init_info, &mut plugin_header, &mut plugin_registry, diff --git a/programs/mpl-core/src/processor/create_collection.rs b/programs/mpl-core/src/processor/create_collection.rs index 9a50084d..dd907718 100644 --- a/programs/mpl-core/src/processor/create_collection.rs +++ b/programs/mpl-core/src/processor/create_collection.rs @@ -9,9 +9,10 @@ use crate::{ error::MplCoreError, instruction::accounts::CreateCollectionV2Accounts, plugins::{ - create_meta_idempotent, create_plugin_meta, initialize_external_plugin, initialize_plugin, - CheckResult, ExternalCheckResultBits, ExternalPlugin, ExternalPluginInitInfo, Plugin, - PluginAuthorityPair, PluginType, PluginValidationContext, ValidationResult, + create_meta_idempotent, create_plugin_meta, initialize_external_plugin_adapter, + initialize_plugin, CheckResult, ExternalCheckResultBits, ExternalPluginAdapter, + ExternalPluginAdapterInitInfo, Plugin, PluginAuthorityPair, PluginType, + PluginValidationContext, ValidationResult, }, state::{Authority, CollectionV1, Key}, }; @@ -30,7 +31,7 @@ pub(crate) struct CreateCollectionV2Args { pub(crate) name: String, pub(crate) uri: String, pub(crate) plugins: Option>, - pub(crate) external_plugins: Option>, + pub(crate) external_plugin_adapters: Option>, } impl From for CreateCollectionV2Args { @@ -39,7 +40,7 @@ impl From for CreateCollectionV2Args { name: item.name, uri: item.uri, plugins: item.plugins, - external_plugins: None, + external_plugin_adapters: None, } } } @@ -161,7 +162,7 @@ pub(crate) fn process_create_collection<'a>( } } - if let Some(plugins) = args.external_plugins { + if let Some(plugins) = args.external_plugin_adapters { if !plugins.is_empty() { let (_, mut plugin_header, mut plugin_registry) = create_meta_idempotent::( ctx.accounts.collection, @@ -169,30 +170,31 @@ pub(crate) fn process_create_collection<'a>( ctx.accounts.system_program, )?; for plugin_init_info in &plugins { - let external_check_result_bits = - ExternalCheckResultBits::from(ExternalPlugin::check_create(plugin_init_info)); + let external_check_result_bits = ExternalCheckResultBits::from( + ExternalPluginAdapter::check_create(plugin_init_info), + ); if external_check_result_bits.can_reject() { let validation_ctx = PluginValidationContext { accounts, asset_info: None, collection_info: Some(ctx.accounts.collection), - // External plugins are always managed by the update authority. + // External plugin adapters are always managed by the update authority. self_authority: &Authority::UpdateAuthority, authority_info: authority, resolved_authorities: None, new_owner: None, target_plugin: None, }; - if ExternalPlugin::validate_create( - &ExternalPlugin::from(plugin_init_info), + if ExternalPluginAdapter::validate_create( + &ExternalPluginAdapter::from(plugin_init_info), &validation_ctx, )? == ValidationResult::Rejected { approved = false; }; } - initialize_external_plugin::( + initialize_external_plugin_adapter::( plugin_init_info, &mut plugin_header, &mut plugin_registry, diff --git a/programs/mpl-core/src/processor/mod.rs b/programs/mpl-core/src/processor/mod.rs index bae3dae3..476d2629 100644 --- a/programs/mpl-core/src/processor/mod.rs +++ b/programs/mpl-core/src/processor/mod.rs @@ -1,4 +1,4 @@ -mod add_external_plugin; +mod add_external_plugin_adapter; mod add_plugin; mod approve_plugin_authority; mod burn; @@ -7,16 +7,16 @@ mod compress; mod create; mod create_collection; mod decompress; -mod remove_external_plugin; +mod remove_external_plugin_adapter; mod remove_plugin; mod revoke_plugin_authority; mod transfer; mod update; -mod update_external_plugin; +mod update_external_plugin_adapter; mod update_plugin; -mod write_external_plugin_data; +mod write_external_plugin_adapter_data; -pub(crate) use add_external_plugin::*; +pub(crate) use add_external_plugin_adapter::*; pub(crate) use add_plugin::*; pub(crate) use approve_plugin_authority::*; pub(crate) use burn::*; @@ -25,14 +25,14 @@ pub(crate) use compress::*; pub(crate) use create::*; pub(crate) use create_collection::*; pub(crate) use decompress::*; -pub(crate) use remove_external_plugin::*; +pub(crate) use remove_external_plugin_adapter::*; pub(crate) use remove_plugin::*; pub(crate) use revoke_plugin_authority::*; pub(crate) use transfer::*; pub(crate) use update::*; -pub(crate) use update_external_plugin::*; +pub(crate) use update_external_plugin_adapter::*; pub(crate) use update_plugin::*; -pub(crate) use write_external_plugin_data::*; +pub(crate) use write_external_plugin_adapter_data::*; use borsh::BorshDeserialize; use solana_program::{account_info::AccountInfo, entrypoint::ProgramResult, msg, pubkey::Pubkey}; @@ -132,37 +132,37 @@ pub fn process_instruction<'a>( msg!("Instruction: CreateCollectionV2"); create_collection_v2(accounts, args) } - MplAssetInstruction::AddExternalPluginV1(args) => { - msg!("Instruction: AddExternalPlugin"); - add_external_plugin(accounts, args) + MplAssetInstruction::AddExternalPluginAdapterV1(args) => { + msg!("Instruction: AddExternalPluginAdapter"); + add_external_plugin_adapter(accounts, args) } - MplAssetInstruction::AddCollectionExternalPluginV1(args) => { - msg!("Instruction: AddCollectionExternalPlugin"); - add_collection_external_plugin(accounts, args) + MplAssetInstruction::AddCollectionExternalPluginAdapterV1(args) => { + msg!("Instruction: AddCollectionExternalPluginAdapter"); + add_collection_external_plugin_adapter(accounts, args) } - MplAssetInstruction::RemoveExternalPluginV1(args) => { - msg!("Instruction: RemoveExternalPlugin"); - remove_external_plugin(accounts, args) + MplAssetInstruction::RemoveExternalPluginAdapterV1(args) => { + msg!("Instruction: RemoveExternalPluginAdapter"); + remove_external_plugin_adapter(accounts, args) } - MplAssetInstruction::RemoveCollectionExternalPluginV1(args) => { - msg!("Instruction: RemoveCollectionExternalPlugin"); - remove_collection_external_plugin(accounts, args) + MplAssetInstruction::RemoveCollectionExternalPluginAdapterV1(args) => { + msg!("Instruction: RemoveCollectionExternalPluginAdapter"); + remove_collection_external_plugin_adapter(accounts, args) } - MplAssetInstruction::UpdateExternalPluginV1(args) => { - msg!("Instruction: UpdateExternalPlugin"); - update_external_plugin(accounts, args) + MplAssetInstruction::UpdateExternalPluginAdapterV1(args) => { + msg!("Instruction: UpdateExternalPluginAdapter"); + update_external_plugin_adapter(accounts, args) } - MplAssetInstruction::UpdateCollectionExternalPluginV1(args) => { - msg!("Instruction: UpdateCollectionExternalPlugin"); - update_collection_external_plugin(accounts, args) + MplAssetInstruction::UpdateCollectionExternalPluginAdapterV1(args) => { + msg!("Instruction: UpdateCollectionExternalPluginAdapter"); + update_collection_external_plugin_adapter(accounts, args) } - MplAssetInstruction::WriteExternalPluginDataV1(args) => { - msg!("Instruction: WriteExternalPluginDataV1"); - write_external_plugin_data(accounts, args) + MplAssetInstruction::WriteExternalPluginAdapterDataV1(args) => { + msg!("Instruction: WriteExternalPluginAdapterDataV1"); + write_external_plugin_adapter_data(accounts, args) } - MplAssetInstruction::WriteCollectionExternalPluginDataV1(args) => { - msg!("Instruction: WriteCollectionExternalPluginDataV1"); - write_collection_external_plugin_data(accounts, args) + MplAssetInstruction::WriteCollectionExternalPluginAdapterDataV1(args) => { + msg!("Instruction: WriteCollectionExternalPluginAdapterDataV1"); + write_collection_external_plugin_adapter_data(accounts, args) } } } diff --git a/programs/mpl-core/src/processor/remove_external_plugin.rs b/programs/mpl-core/src/processor/remove_external_plugin_adapter.rs similarity index 64% rename from programs/mpl-core/src/processor/remove_external_plugin.rs rename to programs/mpl-core/src/processor/remove_external_plugin_adapter.rs index ce5a8a87..a6e6d716 100644 --- a/programs/mpl-core/src/processor/remove_external_plugin.rs +++ b/programs/mpl-core/src/processor/remove_external_plugin_adapter.rs @@ -5,11 +5,11 @@ use solana_program::{account_info::AccountInfo, entrypoint::ProgramResult, msg}; use crate::{ error::MplCoreError, instruction::accounts::{ - RemoveCollectionExternalPluginV1Accounts, RemoveExternalPluginV1Accounts, + RemoveCollectionExternalPluginAdapterV1Accounts, RemoveExternalPluginAdapterV1Accounts, }, plugins::{ - delete_external_plugin, fetch_wrapped_external_plugin, ExternalPluginKey, Plugin, - PluginType, + delete_external_plugin_adapter, fetch_wrapped_external_plugin_adapter, + ExternalPluginAdapterKey, Plugin, PluginType, }, state::{AssetV1, CollectionV1, DataBlob, Key}, utils::{ @@ -20,16 +20,16 @@ use crate::{ #[repr(C)] #[derive(BorshSerialize, BorshDeserialize, PartialEq, Eq, Debug, Clone)] -pub(crate) struct RemoveExternalPluginV1Args { - /// External plugin key. - pub key: ExternalPluginKey, +pub(crate) struct RemoveExternalPluginAdapterV1Args { + /// External plugin adapter key. + pub key: ExternalPluginAdapterKey, } -pub(crate) fn remove_external_plugin<'a>( +pub(crate) fn remove_external_plugin_adapter<'a>( accounts: &'a [AccountInfo<'a>], - args: RemoveExternalPluginV1Args, + args: RemoveExternalPluginAdapterV1Args, ) -> ProgramResult { - let ctx = RemoveExternalPluginV1Accounts::context(accounts)?; + let ctx = RemoveExternalPluginAdapterV1Accounts::context(accounts)?; // Guards. assert_signer(ctx.accounts.payer)?; @@ -57,8 +57,11 @@ pub(crate) fn remove_external_plugin<'a>( return Err(MplCoreError::PluginNotFound.into()); } - let (_, plugin_to_remove) = - fetch_wrapped_external_plugin::(ctx.accounts.asset, Some(&asset), &args.key)?; + let (_, plugin_to_remove) = fetch_wrapped_external_plugin_adapter::( + ctx.accounts.asset, + Some(&asset), + &args.key, + )?; // Validate asset permissions. let _ = validate_asset_permissions( @@ -69,17 +72,17 @@ pub(crate) fn remove_external_plugin<'a>( None, None, Some(&plugin_to_remove), - AssetV1::check_remove_external_plugin, - CollectionV1::check_remove_external_plugin, - PluginType::check_remove_external_plugin, - AssetV1::validate_remove_external_plugin, - CollectionV1::validate_remove_external_plugin, - Plugin::validate_remove_external_plugin, + AssetV1::check_remove_external_plugin_adapter, + CollectionV1::check_remove_external_plugin_adapter, + PluginType::check_remove_external_plugin_adapter, + AssetV1::validate_remove_external_plugin_adapter, + CollectionV1::validate_remove_external_plugin_adapter, + Plugin::validate_remove_external_plugin_adapter, None, None, )?; - process_remove_external_plugin( + process_remove_external_plugin_adapter( &args.key, &asset, ctx.accounts.asset, @@ -90,16 +93,16 @@ pub(crate) fn remove_external_plugin<'a>( #[repr(C)] #[derive(BorshSerialize, BorshDeserialize, PartialEq, Eq, Debug, Clone)] -pub(crate) struct RemoveCollectionExternalPluginV1Args { - /// External plugin key. - pub key: ExternalPluginKey, +pub(crate) struct RemoveCollectionExternalPluginAdapterV1Args { + /// External plugin adapter key. + pub key: ExternalPluginAdapterKey, } -pub(crate) fn remove_collection_external_plugin<'a>( +pub(crate) fn remove_collection_external_plugin_adapter<'a>( accounts: &'a [AccountInfo<'a>], - args: RemoveCollectionExternalPluginV1Args, + args: RemoveCollectionExternalPluginAdapterV1Args, ) -> ProgramResult { - let ctx = RemoveCollectionExternalPluginV1Accounts::context(accounts)?; + let ctx = RemoveCollectionExternalPluginAdapterV1Accounts::context(accounts)?; // Guards. assert_signer(ctx.accounts.payer)?; @@ -123,7 +126,7 @@ pub(crate) fn remove_collection_external_plugin<'a>( return Err(MplCoreError::PluginNotFound.into()); } - let (_, plugin_to_remove) = fetch_wrapped_external_plugin::( + let (_, plugin_to_remove) = fetch_wrapped_external_plugin_adapter::( ctx.accounts.collection, Some(&collection), &args.key, @@ -136,15 +139,15 @@ pub(crate) fn remove_collection_external_plugin<'a>( ctx.accounts.collection, None, Some(&plugin_to_remove), - CollectionV1::check_remove_external_plugin, - PluginType::check_remove_external_plugin, - CollectionV1::validate_remove_external_plugin, - Plugin::validate_remove_external_plugin, + CollectionV1::check_remove_external_plugin_adapter, + PluginType::check_remove_external_plugin_adapter, + CollectionV1::validate_remove_external_plugin_adapter, + Plugin::validate_remove_external_plugin_adapter, None, None, )?; - process_remove_external_plugin( + process_remove_external_plugin_adapter( &args.key, &collection, ctx.accounts.collection, @@ -153,12 +156,12 @@ pub(crate) fn remove_collection_external_plugin<'a>( ) } -fn process_remove_external_plugin<'a, T: DataBlob>( - plugin_key: &ExternalPluginKey, +fn process_remove_external_plugin_adapter<'a, T: DataBlob>( + plugin_key: &ExternalPluginAdapterKey, core: &T, account: &AccountInfo<'a>, payer: &AccountInfo<'a>, system_program: &AccountInfo<'a>, ) -> ProgramResult { - delete_external_plugin(plugin_key, core, account, payer, system_program) + delete_external_plugin_adapter(plugin_key, core, account, payer, system_program) } diff --git a/programs/mpl-core/src/processor/transfer.rs b/programs/mpl-core/src/processor/transfer.rs index c95d8f34..fac7c48b 100644 --- a/programs/mpl-core/src/processor/transfer.rs +++ b/programs/mpl-core/src/processor/transfer.rs @@ -5,7 +5,7 @@ use solana_program::{account_info::AccountInfo, entrypoint::ProgramResult, msg}; use crate::{ error::MplCoreError, instruction::accounts::TransferV1Accounts, - plugins::{ExternalPlugin, HookableLifecycleEvent, Plugin, PluginType}, + plugins::{ExternalPluginAdapter, HookableLifecycleEvent, Plugin, PluginType}, state::{AssetV1, Authority, CollectionV1, CompressionProof, Key, SolanaAccount, Wrappable}, utils::{ compress_into_account_space, load_key, rebuild_account_state_from_proof_data, @@ -90,7 +90,7 @@ pub(crate) fn transfer<'a>(accounts: &'a [AccountInfo<'a>], args: TransferV1Args AssetV1::validate_transfer, CollectionV1::validate_transfer, Plugin::validate_transfer, - Some(ExternalPlugin::validate_transfer), + Some(ExternalPluginAdapter::validate_transfer), Some(HookableLifecycleEvent::Transfer), )?; diff --git a/programs/mpl-core/src/processor/update.rs b/programs/mpl-core/src/processor/update.rs index bda8ca6f..eac48df4 100644 --- a/programs/mpl-core/src/processor/update.rs +++ b/programs/mpl-core/src/processor/update.rs @@ -8,7 +8,7 @@ use crate::{ error::MplCoreError, instruction::accounts::{UpdateCollectionV1Accounts, UpdateV1Accounts}, plugins::{ - ExternalPlugin, HookableLifecycleEvent, Plugin, PluginHeaderV1, PluginRegistryV1, + ExternalPluginAdapter, HookableLifecycleEvent, Plugin, PluginHeaderV1, PluginRegistryV1, PluginType, }, state::{AssetV1, CollectionV1, DataBlob, Key, SolanaAccount, UpdateAuthority}, @@ -63,7 +63,7 @@ pub(crate) fn update<'a>(accounts: &'a [AccountInfo<'a>], args: UpdateV1Args) -> AssetV1::validate_update, CollectionV1::validate_update, Plugin::validate_update, - Some(ExternalPlugin::validate_update), + Some(ExternalPluginAdapter::validate_update), Some(HookableLifecycleEvent::Update), )?; @@ -149,7 +149,7 @@ pub(crate) fn update_collection<'a>( PluginType::check_update, CollectionV1::validate_update, Plugin::validate_update, - Some(ExternalPlugin::validate_update), + Some(ExternalPluginAdapter::validate_update), Some(HookableLifecycleEvent::Update), )?; diff --git a/programs/mpl-core/src/processor/update_external_plugin.rs b/programs/mpl-core/src/processor/update_external_plugin_adapter.rs similarity index 76% rename from programs/mpl-core/src/processor/update_external_plugin.rs rename to programs/mpl-core/src/processor/update_external_plugin_adapter.rs index f5eaf667..67a6ee1e 100644 --- a/programs/mpl-core/src/processor/update_external_plugin.rs +++ b/programs/mpl-core/src/processor/update_external_plugin_adapter.rs @@ -7,11 +7,12 @@ use solana_program::{ use crate::{ error::MplCoreError, instruction::accounts::{ - UpdateCollectionExternalPluginV1Accounts, UpdateExternalPluginV1Accounts, + UpdateCollectionExternalPluginAdapterV1Accounts, UpdateExternalPluginAdapterV1Accounts, }, plugins::{ - fetch_wrapped_external_plugin, find_external_plugin, ExternalPlugin, ExternalPluginKey, - ExternalPluginUpdateInfo, Plugin, PluginHeaderV1, PluginRegistryV1, PluginType, + fetch_wrapped_external_plugin_adapter, find_external_plugin_adapter, ExternalPluginAdapter, + ExternalPluginAdapterKey, ExternalPluginAdapterUpdateInfo, Plugin, PluginHeaderV1, + PluginRegistryV1, PluginType, }, state::{AssetV1, CollectionV1, DataBlob, Key, SolanaAccount}, utils::{ @@ -22,19 +23,19 @@ use crate::{ #[repr(C)] #[derive(BorshSerialize, BorshDeserialize, PartialEq, Eq, Debug, Clone)] -pub(crate) struct UpdateExternalPluginV1Args { - /// External plugin key. - pub key: ExternalPluginKey, +pub(crate) struct UpdateExternalPluginAdapterV1Args { + /// External plugin adapter key. + pub key: ExternalPluginAdapterKey, /// Plugin info to update. - pub update_info: ExternalPluginUpdateInfo, + pub update_info: ExternalPluginAdapterUpdateInfo, } -pub(crate) fn update_external_plugin<'a>( +pub(crate) fn update_external_plugin_adapter<'a>( accounts: &'a [AccountInfo<'a>], - args: UpdateExternalPluginV1Args, + args: UpdateExternalPluginAdapterV1Args, ) -> ProgramResult { // Accounts. - let ctx = UpdateExternalPluginV1Accounts::context(accounts)?; + let ctx = UpdateExternalPluginAdapterV1Accounts::context(accounts)?; // Guards. assert_signer(ctx.accounts.payer)?; @@ -56,7 +57,7 @@ pub(crate) fn update_external_plugin<'a>( } let (_, plugin) = - fetch_wrapped_external_plugin::(ctx.accounts.asset, None, &args.key)?; + fetch_wrapped_external_plugin_adapter::(ctx.accounts.asset, None, &args.key)?; let (mut asset, plugin_header, plugin_registry) = validate_asset_permissions( accounts, @@ -66,12 +67,12 @@ pub(crate) fn update_external_plugin<'a>( None, None, Some(&plugin), - AssetV1::check_update_external_plugin, - CollectionV1::check_update_external_plugin, - PluginType::check_update_external_plugin, - AssetV1::validate_update_external_plugin, - CollectionV1::validate_update_external_plugin, - Plugin::validate_update_external_plugin, + AssetV1::check_update_external_plugin_adapter, + CollectionV1::check_update_external_plugin_adapter, + PluginType::check_update_external_plugin_adapter, + AssetV1::validate_update_external_plugin_adapter, + CollectionV1::validate_update_external_plugin_adapter, + Plugin::validate_update_external_plugin_adapter, None, None, )?; @@ -79,7 +80,7 @@ pub(crate) fn update_external_plugin<'a>( // Increment sequence number and save only if it is `Some(_)`. asset.increment_seq_and_save(ctx.accounts.asset)?; - process_update_external_plugin( + process_update_external_plugin_adapter( asset, plugin, args.key, @@ -94,19 +95,19 @@ pub(crate) fn update_external_plugin<'a>( #[repr(C)] #[derive(BorshSerialize, BorshDeserialize, PartialEq, Eq, Debug, Clone)] -pub(crate) struct UpdateCollectionExternalPluginV1Args { - /// External plugin key. - pub key: ExternalPluginKey, +pub(crate) struct UpdateCollectionExternalPluginAdapterV1Args { + /// External plugin adapter key. + pub key: ExternalPluginAdapterKey, /// Plugin info to update. - pub update_info: ExternalPluginUpdateInfo, + pub update_info: ExternalPluginAdapterUpdateInfo, } -pub(crate) fn update_collection_external_plugin<'a>( +pub(crate) fn update_collection_external_plugin_adapter<'a>( accounts: &'a [AccountInfo<'a>], - args: UpdateCollectionExternalPluginV1Args, + args: UpdateCollectionExternalPluginAdapterV1Args, ) -> ProgramResult { // Accounts. - let ctx = UpdateCollectionExternalPluginV1Accounts::context(accounts)?; + let ctx = UpdateCollectionExternalPluginAdapterV1Accounts::context(accounts)?; // Guards. assert_signer(ctx.accounts.payer)?; @@ -122,8 +123,11 @@ pub(crate) fn update_collection_external_plugin<'a>( } } - let (_, plugin) = - fetch_wrapped_external_plugin::(ctx.accounts.collection, None, &args.key)?; + let (_, plugin) = fetch_wrapped_external_plugin_adapter::( + ctx.accounts.collection, + None, + &args.key, + )?; // Validate collection permissions. let (collection, plugin_header, plugin_registry) = validate_collection_permissions( @@ -140,7 +144,7 @@ pub(crate) fn update_collection_external_plugin<'a>( None, )?; - process_update_external_plugin( + process_update_external_plugin_adapter( collection, plugin, args.key, @@ -154,11 +158,11 @@ pub(crate) fn update_collection_external_plugin<'a>( } #[allow(clippy::too_many_arguments)] -fn process_update_external_plugin<'a, T: DataBlob + SolanaAccount>( +fn process_update_external_plugin_adapter<'a, T: DataBlob + SolanaAccount>( core: T, - plugin: ExternalPlugin, - key: ExternalPluginKey, - update_info: ExternalPluginUpdateInfo, + plugin: ExternalPluginAdapter, + key: ExternalPluginAdapterKey, + update_info: ExternalPluginAdapterUpdateInfo, plugin_header: Option, plugin_registry: Option, account: &AccountInfo<'a>, @@ -169,7 +173,7 @@ fn process_update_external_plugin<'a, T: DataBlob + SolanaAccount>( let mut plugin_header = plugin_header.ok_or(MplCoreError::PluginsNotInitialized)?; let plugin_registry_clone = plugin_registry.clone(); - let (_, record) = find_external_plugin(&plugin_registry_clone, &key, account)?; + let (_, record) = find_external_plugin_adapter(&plugin_registry_clone, &key, account)?; let mut registry_record = record.ok_or(MplCoreError::PluginNotFound)?.clone(); registry_record.update(&update_info)?; diff --git a/programs/mpl-core/src/processor/write_external_plugin_data.rs b/programs/mpl-core/src/processor/write_external_plugin_adapter_data.rs similarity index 51% rename from programs/mpl-core/src/processor/write_external_plugin_data.rs rename to programs/mpl-core/src/processor/write_external_plugin_adapter_data.rs index 081c30ca..5c132fcb 100644 --- a/programs/mpl-core/src/processor/write_external_plugin_data.rs +++ b/programs/mpl-core/src/processor/write_external_plugin_adapter_data.rs @@ -1,36 +1,36 @@ use borsh::{BorshDeserialize, BorshSerialize}; use solana_program::{account_info::AccountInfo, entrypoint::ProgramResult}; -use crate::{error::MplCoreError, plugins::ExternalPluginKey}; +use crate::{error::MplCoreError, plugins::ExternalPluginAdapterKey}; #[repr(C)] #[derive(BorshSerialize, BorshDeserialize, PartialEq, Eq, Debug, Clone)] -pub(crate) struct WriteExternalPluginDataV1Args { - /// External plugin key. - pub key: ExternalPluginKey, +pub(crate) struct WriteExternalPluginAdapterDataV1Args { + /// External plugin adapter key. + pub key: ExternalPluginAdapterKey, /// The data to write. pub data: Vec, } -pub(crate) fn write_external_plugin_data<'a>( +pub(crate) fn write_external_plugin_adapter_data<'a>( _accounts: &'a [AccountInfo<'a>], - _args: WriteExternalPluginDataV1Args, + _args: WriteExternalPluginAdapterDataV1Args, ) -> ProgramResult { Err(MplCoreError::NotAvailable.into()) } #[repr(C)] #[derive(BorshSerialize, BorshDeserialize, PartialEq, Eq, Debug, Clone)] -pub(crate) struct WriteCollectionExternalPluginDataV1Args { - /// External plugin key. - pub key: ExternalPluginKey, +pub(crate) struct WriteCollectionExternalPluginAdapterDataV1Args { + /// External plugin adapter key. + pub key: ExternalPluginAdapterKey, /// The data to write. pub data: Vec, } -pub(crate) fn write_collection_external_plugin_data<'a>( +pub(crate) fn write_collection_external_plugin_adapter_data<'a>( _accounts: &'a [AccountInfo<'a>], - _args: WriteCollectionExternalPluginDataV1Args, + _args: WriteCollectionExternalPluginAdapterDataV1Args, ) -> ProgramResult { Err(MplCoreError::NotAvailable.into()) } diff --git a/programs/mpl-core/src/state/asset.rs b/programs/mpl-core/src/state/asset.rs index 2d93390b..6134b857 100644 --- a/programs/mpl-core/src/state/asset.rs +++ b/programs/mpl-core/src/state/asset.rs @@ -8,7 +8,7 @@ use std::mem::size_of; use crate::{ error::MplCoreError, - plugins::{CheckResult, ExternalPlugin, Plugin, ValidationResult}, + plugins::{CheckResult, ExternalPluginAdapter, Plugin, ValidationResult}, state::{Compressible, CompressionProof, DataBlob, Key, SolanaAccount}, }; @@ -113,18 +113,18 @@ impl AssetV1 { CheckResult::CanApprove } - /// Check permissions for the add external plugin lifecycle event. - pub fn check_add_external_plugin() -> CheckResult { + /// Check permissions for the add external plugin adapter lifecycle event. + pub fn check_add_external_plugin_adapter() -> CheckResult { CheckResult::CanApprove } - /// Check permissions for the remove external plugin lifecycle event. - pub fn check_remove_external_plugin() -> CheckResult { + /// Check permissions for the remove external plugin adapter lifecycle event. + pub fn check_remove_external_plugin_adapter() -> CheckResult { CheckResult::CanApprove } - /// Check permissions for the update external plugin lifecycle event. - pub fn check_update_external_plugin() -> CheckResult { + /// Check permissions for the update external plugin adapter lifecycle event. + pub fn check_update_external_plugin_adapter() -> CheckResult { CheckResult::CanApprove } @@ -133,7 +133,7 @@ impl AssetV1 { &self, authority_info: &AccountInfo, new_plugin: Option<&Plugin>, - _: Option<&ExternalPlugin>, + _: Option<&ExternalPluginAdapter>, ) -> Result { let new_plugin = match new_plugin { Some(plugin) => plugin, @@ -158,7 +158,7 @@ impl AssetV1 { &self, authority_info: &AccountInfo, plugin_to_remove: Option<&Plugin>, - _: Option<&ExternalPlugin>, + _: Option<&ExternalPluginAdapter>, ) -> Result { let plugin = match plugin_to_remove { Some(plugin) => plugin, @@ -181,7 +181,7 @@ impl AssetV1 { &self, _authority_info: &AccountInfo, _plugin: Option<&Plugin>, - _: Option<&ExternalPlugin>, + _: Option<&ExternalPluginAdapter>, ) -> Result { Ok(ValidationResult::Pass) } @@ -191,7 +191,7 @@ impl AssetV1 { &self, authority_info: &AccountInfo, plugin: Option<&Plugin>, - _: Option<&ExternalPlugin>, + _: Option<&ExternalPluginAdapter>, ) -> Result { if let Some(plugin) = plugin { if (plugin.manager() == Authority::UpdateAuthority @@ -213,7 +213,7 @@ impl AssetV1 { &self, authority_info: &AccountInfo, plugin: Option<&Plugin>, - _: Option<&ExternalPlugin>, + _: Option<&ExternalPluginAdapter>, ) -> Result { if let Some(plugin) = plugin { if (plugin.manager() == Authority::UpdateAuthority @@ -235,7 +235,7 @@ impl AssetV1 { &self, authority_info: &AccountInfo, _: Option<&Plugin>, - _: Option<&ExternalPlugin>, + _: Option<&ExternalPluginAdapter>, ) -> Result { if authority_info.key == &self.update_authority.key() { solana_program::msg!("Asset: Approved"); @@ -250,7 +250,7 @@ impl AssetV1 { &self, authority_info: &AccountInfo, _: Option<&Plugin>, - _: Option<&ExternalPlugin>, + _: Option<&ExternalPluginAdapter>, ) -> Result { if authority_info.key == &self.owner { solana_program::msg!("Asset: Approved"); @@ -265,7 +265,7 @@ impl AssetV1 { &self, authority_info: &AccountInfo, _: Option<&Plugin>, - _: Option<&ExternalPlugin>, + _: Option<&ExternalPluginAdapter>, ) -> Result { if authority_info.key == &self.owner { solana_program::msg!("Asset: Approved"); @@ -280,7 +280,7 @@ impl AssetV1 { &self, authority_info: &AccountInfo, _: Option<&Plugin>, - _: Option<&ExternalPlugin>, + _: Option<&ExternalPluginAdapter>, ) -> Result { if authority_info.key == &self.owner { solana_program::msg!("Asset: Approved"); @@ -295,7 +295,7 @@ impl AssetV1 { &self, authority_info: &AccountInfo, _: Option<&Plugin>, - _: Option<&ExternalPlugin>, + _: Option<&ExternalPluginAdapter>, ) -> Result { if authority_info.key == &self.owner { solana_program::msg!("Asset: Approved"); @@ -305,12 +305,12 @@ impl AssetV1 { } } - /// Validate the add external plugin lifecycle event. - pub fn validate_add_external_plugin( + /// Validate the add external plugin adapter lifecycle event. + pub fn validate_add_external_plugin_adapter( &self, authority_info: &AccountInfo, _: Option<&Plugin>, - _new_plugin: Option<&ExternalPlugin>, + _new_plugin: Option<&ExternalPluginAdapter>, ) -> Result { // If it's not in a collection, then it can be added. if UpdateAuthority::Address(*authority_info.key) == self.update_authority { @@ -321,12 +321,12 @@ impl AssetV1 { } } - /// Validate the remove external plugin lifecycle event. - pub fn validate_remove_external_plugin( + /// Validate the remove external plugin adapter lifecycle event. + pub fn validate_remove_external_plugin_adapter( &self, authority_info: &AccountInfo, _: Option<&Plugin>, - _plugin_to_remove: Option<&ExternalPlugin>, + _plugin_to_remove: Option<&ExternalPluginAdapter>, ) -> Result { if self.update_authority == UpdateAuthority::Address(*authority_info.key) { solana_program::msg!("Asset: Approved"); @@ -336,12 +336,12 @@ impl AssetV1 { } } - /// Validate the update external plugin lifecycle event. - pub fn validate_update_external_plugin( + /// Validate the update external plugin adapter lifecycle event. + pub fn validate_update_external_plugin_adapter( &self, authority_info: &AccountInfo, _: Option<&Plugin>, - _plugin: Option<&ExternalPlugin>, + _plugin: Option<&ExternalPluginAdapter>, ) -> Result { if self.update_authority == UpdateAuthority::Address(*authority_info.key) { solana_program::msg!("Asset: Approved"); diff --git a/programs/mpl-core/src/state/collection.rs b/programs/mpl-core/src/state/collection.rs index 2307172c..82da9d7f 100644 --- a/programs/mpl-core/src/state/collection.rs +++ b/programs/mpl-core/src/state/collection.rs @@ -4,7 +4,7 @@ use solana_program::{account_info::AccountInfo, program_error::ProgramError, pub use crate::{ error::MplCoreError, - plugins::{CheckResult, ExternalPlugin, Plugin, ValidationResult}, + plugins::{CheckResult, ExternalPluginAdapter, Plugin, ValidationResult}, }; use super::{Authority, CoreAsset, DataBlob, Key, SolanaAccount, UpdateAuthority}; @@ -98,18 +98,18 @@ impl CollectionV1 { CheckResult::None } - /// Check permissions for the add external plugin lifecycle event. - pub fn check_add_external_plugin() -> CheckResult { + /// Check permissions for the add external plugin adapter lifecycle event. + pub fn check_add_external_plugin_adapter() -> CheckResult { CheckResult::CanApprove } - /// Check permissions for the remove external plugin lifecycle event. - pub fn check_remove_external_plugin() -> CheckResult { + /// Check permissions for the remove external plugin adapter lifecycle event. + pub fn check_remove_external_plugin_adapter() -> CheckResult { CheckResult::CanApprove } - /// Check permissions for the update external plugin lifecycle event. - pub fn check_update_external_plugin() -> CheckResult { + /// Check permissions for the update external plugin adapter lifecycle event. + pub fn check_update_external_plugin_adapter() -> CheckResult { CheckResult::CanApprove } @@ -118,7 +118,7 @@ impl CollectionV1 { &self, authority_info: &AccountInfo, new_plugin: Option<&Plugin>, - _: Option<&ExternalPlugin>, + _: Option<&ExternalPluginAdapter>, ) -> Result { let new_plugin = match new_plugin { Some(plugin) => plugin, @@ -140,7 +140,7 @@ impl CollectionV1 { &self, authority_info: &AccountInfo, plugin_to_remove: Option<&Plugin>, - _: Option<&ExternalPlugin>, + _: Option<&ExternalPluginAdapter>, ) -> Result { let plugin_to_remove = match plugin_to_remove { Some(plugin) => plugin, @@ -162,7 +162,7 @@ impl CollectionV1 { &self, _authority_info: &AccountInfo, _plugin: Option<&Plugin>, - _: Option<&ExternalPlugin>, + _: Option<&ExternalPluginAdapter>, ) -> Result { Ok(ValidationResult::Pass) } @@ -172,7 +172,7 @@ impl CollectionV1 { &self, authority_info: &AccountInfo, plugin: Option<&Plugin>, - _: Option<&ExternalPlugin>, + _: Option<&ExternalPluginAdapter>, ) -> Result { let plugin = match plugin { Some(plugin) => plugin, @@ -194,7 +194,7 @@ impl CollectionV1 { &self, authority_info: &AccountInfo, plugin: Option<&Plugin>, - _: Option<&ExternalPlugin>, + _: Option<&ExternalPluginAdapter>, ) -> Result { let plugin = match plugin { Some(plugin) => plugin, @@ -216,7 +216,7 @@ impl CollectionV1 { &self, _authority_info: &AccountInfo, _: Option<&Plugin>, - _: Option<&ExternalPlugin>, + _: Option<&ExternalPluginAdapter>, ) -> Result { Ok(ValidationResult::Pass) } @@ -226,7 +226,7 @@ impl CollectionV1 { &self, _authority_info: &AccountInfo, _: Option<&Plugin>, - _: Option<&ExternalPlugin>, + _: Option<&ExternalPluginAdapter>, ) -> Result { Ok(ValidationResult::Pass) } @@ -236,7 +236,7 @@ impl CollectionV1 { &self, authority_info: &AccountInfo, _: Option<&Plugin>, - _: Option<&ExternalPlugin>, + _: Option<&ExternalPluginAdapter>, ) -> Result { if authority_info.key == &self.update_authority { solana_program::msg!("Collection: Approved"); @@ -251,7 +251,7 @@ impl CollectionV1 { &self, _authority_info: &AccountInfo, _: Option<&Plugin>, - _: Option<&ExternalPlugin>, + _: Option<&ExternalPluginAdapter>, ) -> Result { Ok(ValidationResult::Pass) } @@ -261,17 +261,17 @@ impl CollectionV1 { &self, _authority_info: &AccountInfo, _: Option<&Plugin>, - _: Option<&ExternalPlugin>, + _: Option<&ExternalPluginAdapter>, ) -> Result { Ok(ValidationResult::Pass) } - /// Validate the add external plugin lifecycle event. - pub fn validate_add_external_plugin( + /// Validate the add external plugin adapter lifecycle event. + pub fn validate_add_external_plugin_adapter( &self, authority_info: &AccountInfo, _: Option<&Plugin>, - _new_plugin: Option<&ExternalPlugin>, + _new_plugin: Option<&ExternalPluginAdapter>, ) -> Result { // Approve if the update authority matches the authority. if *authority_info.key == self.update_authority { @@ -282,12 +282,12 @@ impl CollectionV1 { } } - /// Validate the remove external plugin lifecycle event. - pub fn validate_remove_external_plugin( + /// Validate the remove external plugin adapter lifecycle event. + pub fn validate_remove_external_plugin_adapter( &self, authority_info: &AccountInfo, _: Option<&Plugin>, - _plugin_to_remove: Option<&ExternalPlugin>, + _plugin_to_remove: Option<&ExternalPluginAdapter>, ) -> Result { if self.update_authority == *authority_info.key { solana_program::msg!("Asset: Approved"); @@ -297,12 +297,12 @@ impl CollectionV1 { } } - /// Validate the update external plugin lifecycle event. - pub fn validate_update_external_plugin( + /// Validate the update external plugin adapter lifecycle event. + pub fn validate_update_external_plugin_adapter( &self, authority_info: &AccountInfo, _: Option<&Plugin>, - _plugin: Option<&ExternalPlugin>, + _plugin: Option<&ExternalPluginAdapter>, ) -> Result { if self.update_authority == *authority_info.key { solana_program::msg!("Asset: Approved"); diff --git a/programs/mpl-core/src/utils.rs b/programs/mpl-core/src/utils.rs index 81458c40..bf68bc19 100644 --- a/programs/mpl-core/src/utils.rs +++ b/programs/mpl-core/src/utils.rs @@ -12,10 +12,11 @@ use solana_program::{ use crate::{ error::MplCoreError, plugins::{ - create_meta_idempotent, initialize_plugin, validate_external_plugin_checks, - validate_plugin_checks, CheckResult, ExternalCheckResultBits, ExternalPlugin, - ExternalPluginKey, ExternalRegistryRecord, HookableLifecycleEvent, Plugin, PluginHeaderV1, - PluginRegistryV1, PluginType, PluginValidationContext, RegistryRecord, ValidationResult, + create_meta_idempotent, initialize_plugin, validate_external_plugin_adapter_checks, + validate_plugin_checks, CheckResult, ExternalCheckResultBits, ExternalPluginAdapter, + ExternalPluginAdapterKey, ExternalRegistryRecord, HookableLifecycleEvent, Plugin, + PluginHeaderV1, PluginRegistryV1, PluginType, PluginValidationContext, RegistryRecord, + ValidationResult, }, state::{ AssetV1, Authority, CollectionV1, Compressible, CompressionProof, CoreAsset, DataBlob, @@ -207,7 +208,7 @@ pub(crate) fn validate_asset_permissions<'a>( collection: Option<&'a AccountInfo<'a>>, new_owner: Option<&'a AccountInfo<'a>>, new_plugin: Option<&Plugin>, - new_external_plugin: Option<&ExternalPlugin>, + new_external_plugin_adapter: Option<&ExternalPluginAdapter>, asset_check_fp: fn() -> CheckResult, collection_check_fp: fn() -> CheckResult, plugin_check_fp: fn(&PluginType) -> CheckResult, @@ -215,25 +216,28 @@ pub(crate) fn validate_asset_permissions<'a>( &AssetV1, &AccountInfo, Option<&Plugin>, - Option<&ExternalPlugin>, + Option<&ExternalPluginAdapter>, ) -> Result, collection_validate_fp: fn( &CollectionV1, &AccountInfo, Option<&Plugin>, - Option<&ExternalPlugin>, + Option<&ExternalPluginAdapter>, ) -> Result, plugin_validate_fp: fn( &Plugin, &PluginValidationContext, ) -> Result, - external_plugin_validate_fp: Option< - fn(&ExternalPlugin, &PluginValidationContext) -> Result, + external_plugin_adapter_validate_fp: Option< + fn( + &ExternalPluginAdapter, + &PluginValidationContext, + ) -> Result, >, hookable_lifecycle_event: Option, ) -> Result<(AssetV1, Option, Option), ProgramError> { - if external_plugin_validate_fp.is_some() && hookable_lifecycle_event.is_none() - || external_plugin_validate_fp.is_none() && hookable_lifecycle_event.is_some() + if external_plugin_adapter_validate_fp.is_some() && hookable_lifecycle_event.is_none() + || external_plugin_adapter_validate_fp.is_none() && hookable_lifecycle_event.is_some() { panic!("Missing function parameters to validate_asset_permissions"); } @@ -255,7 +259,7 @@ pub(crate) fn validate_asset_permissions<'a>( let mut checks: BTreeMap = BTreeMap::new(); let mut external_checks: BTreeMap< - ExternalPluginKey, + ExternalPluginAdapterKey, (Key, ExternalCheckResultBits, ExternalRegistryRecord), > = BTreeMap::new(); @@ -275,7 +279,7 @@ pub(crate) fn validate_asset_permissions<'a>( r.check_registry(Key::CollectionV1, plugin_check_fp, &mut checks); if let Some(lifecycle_event) = &hookable_lifecycle_event { - r.check_external_registry( + r.check_adapter_registry( collection_info, Key::CollectionV1, lifecycle_event, @@ -290,7 +294,7 @@ pub(crate) fn validate_asset_permissions<'a>( if let Some(registry) = plugin_registry.as_ref() { registry.check_registry(Key::AssetV1, plugin_check_fp, &mut checks); if let Some(lifecycle_event) = &hookable_lifecycle_event { - registry.check_external_registry( + registry.check_adapter_registry( asset, Key::AssetV1, lifecycle_event, @@ -307,7 +311,7 @@ pub(crate) fn validate_asset_permissions<'a>( &deserialized_asset, authority_info, new_plugin, - new_external_plugin, + new_external_plugin_adapter, )? { ValidationResult::Approved => approved = true, ValidationResult::Rejected => rejected = true, @@ -323,7 +327,7 @@ pub(crate) fn validate_asset_permissions<'a>( &CollectionV1::load(collection.ok_or(MplCoreError::MissingCollection)?, 0)?, authority_info, new_plugin, - new_external_plugin, + new_external_plugin_adapter, )? { ValidationResult::Approved => approved = true, ValidationResult::Rejected => rejected = true, @@ -374,8 +378,8 @@ pub(crate) fn validate_asset_permissions<'a>( } }; - if let Some(external_plugin_validate_fp) = external_plugin_validate_fp { - match validate_external_plugin_checks( + if let Some(external_plugin_adapter_validate_fp) = external_plugin_adapter_validate_fp { + match validate_external_plugin_adapter_checks( Key::CollectionV1, accounts, &external_checks, @@ -385,16 +389,16 @@ pub(crate) fn validate_asset_permissions<'a>( Some(asset), collection, &resolved_authorities, - external_plugin_validate_fp, + external_plugin_adapter_validate_fp, )? { ValidationResult::Approved => approved = true, ValidationResult::Rejected => rejected = true, ValidationResult::Pass => (), - // Force approved will not be possible from external plugins. + // Force approved will not be possible from external plugin adapters. ValidationResult::ForceApproved => unreachable!(), }; - match validate_external_plugin_checks( + match validate_external_plugin_adapter_checks( Key::AssetV1, accounts, &external_checks, @@ -404,12 +408,12 @@ pub(crate) fn validate_asset_permissions<'a>( Some(asset), collection, &resolved_authorities, - external_plugin_validate_fp, + external_plugin_adapter_validate_fp, )? { ValidationResult::Approved => approved = true, ValidationResult::Rejected => rejected = true, ValidationResult::Pass => (), - // Force approved will not be possible from external plugins. + // Force approved will not be possible from external plugin adapters. ValidationResult::ForceApproved => unreachable!(), }; } @@ -430,21 +434,24 @@ pub(crate) fn validate_collection_permissions<'a>( authority_info: &'a AccountInfo<'a>, collection: &'a AccountInfo<'a>, new_plugin: Option<&Plugin>, - new_external_plugin: Option<&ExternalPlugin>, + new_external_plugin_adapter: Option<&ExternalPluginAdapter>, collection_check_fp: fn() -> CheckResult, plugin_check_fp: fn(&PluginType) -> CheckResult, collection_validate_fp: fn( &CollectionV1, &AccountInfo, Option<&Plugin>, - Option<&ExternalPlugin>, + Option<&ExternalPluginAdapter>, ) -> Result, plugin_validate_fp: fn( &Plugin, &PluginValidationContext, ) -> Result, - external_plugin_validate_fp: Option< - fn(&ExternalPlugin, &PluginValidationContext) -> Result, + external_plugin_adapter_validate_fp: Option< + fn( + &ExternalPluginAdapter, + &PluginValidationContext, + ) -> Result, >, hookable_lifecycle_event: Option, ) -> Result< @@ -455,8 +462,8 @@ pub(crate) fn validate_collection_permissions<'a>( ), ProgramError, > { - if external_plugin_validate_fp.is_some() && hookable_lifecycle_event.is_none() - || external_plugin_validate_fp.is_none() && hookable_lifecycle_event.is_some() + if external_plugin_adapter_validate_fp.is_some() && hookable_lifecycle_event.is_none() + || external_plugin_adapter_validate_fp.is_none() && hookable_lifecycle_event.is_some() { panic!("Missing function parameters to validate_asset_permissions"); } @@ -467,7 +474,7 @@ pub(crate) fn validate_collection_permissions<'a>( resolve_pubkey_to_authorities_collection(authority_info, collection)?; let mut checks: BTreeMap = BTreeMap::new(); let mut external_checks: BTreeMap< - ExternalPluginKey, + ExternalPluginAdapterKey, (Key, ExternalCheckResultBits, ExternalRegistryRecord), > = BTreeMap::new(); @@ -477,7 +484,7 @@ pub(crate) fn validate_collection_permissions<'a>( if let Some(registry) = plugin_registry.as_ref() { registry.check_registry(Key::CollectionV1, plugin_check_fp, &mut checks); if let Some(lifecycle_event) = hookable_lifecycle_event { - registry.check_external_registry( + registry.check_adapter_registry( collection, Key::CollectionV1, &lifecycle_event, @@ -501,7 +508,7 @@ pub(crate) fn validate_collection_permissions<'a>( &deserialized_collection, authority_info, new_plugin, - new_external_plugin, + new_external_plugin_adapter, )?, _ => return Err(MplCoreError::IncorrectAccount.into()), }; @@ -535,8 +542,8 @@ pub(crate) fn validate_collection_permissions<'a>( } }; - if let Some(external_plugin_validate_fp) = external_plugin_validate_fp { - match validate_external_plugin_checks( + if let Some(external_plugin_adapter_validate_fp) = external_plugin_adapter_validate_fp { + match validate_external_plugin_adapter_checks( Key::CollectionV1, accounts, &external_checks, @@ -546,12 +553,12 @@ pub(crate) fn validate_collection_permissions<'a>( None, Some(collection), &resolved_authorities, - external_plugin_validate_fp, + external_plugin_adapter_validate_fp, )? { ValidationResult::Approved => approved = true, ValidationResult::Rejected => rejected = true, ValidationResult::Pass => (), - // Force approved will not be possible from external plugins. + // Force approved will not be possible from external plugin adapters. ValidationResult::ForceApproved => unreachable!(), }; }