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/helpers/lifecycle.ts b/clients/js/src/helpers/lifecycle.ts index 16f26650..e46cd808 100644 --- a/clients/js/src/helpers/lifecycle.ts +++ b/clients/js/src/helpers/lifecycle.ts @@ -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 diff --git a/clients/js/src/plugins/externalPlugins.ts b/clients/js/src/plugins/externalPlugins.ts index 3e83eff1..aa5d2bd8 100644 --- a/clients/js/src/plugins/externalPlugins.ts +++ b/clients/js/src/plugins/externalPlugins.ts @@ -187,9 +187,9 @@ export const findExtraAccounts = ( externalPlugins.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, }) diff --git a/clients/js/src/plugins/oracle.ts b/clients/js/src/plugins/oracle.ts index 67c8d1a4..f7dd0ea8 100644 --- a/clients/js/src/plugins/oracle.ts +++ b/clients/js/src/plugins/oracle.ts @@ -24,8 +24,8 @@ import { validationResultsOffsetToBase, } from './validationResultsOffset'; -export type Oracle = Omit & { - pda?: ExtraAccount; +export type Oracle = Omit & { + baseAddressConfig?: ExtraAccount; resultsOffset: ValidationResultsOffset; }; @@ -36,22 +36,25 @@ export type OraclePlugin = BaseExternalPlugin & 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; 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; diff --git a/clients/js/test/externalPlugins/oracle.test.ts b/clients/js/test/externalPlugins/oracle.test.ts index 8c1e5ea1..4450eabd 100644 --- a/clients/js/test/externalPlugins/oracle.test.ts +++ b/clients/js/test/externalPlugins/oracle.test.ts @@ -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: [ { @@ -1955,7 +1955,7 @@ test('it can use custom pda (with custom program ID) oracle to deny transfer', a bytes: Buffer.from('additional-bytes-seed-bytes', 'utf8'), }, ], - customProgramId: MPL_CORE_ORACLE_EXAMPLE_PROGRAM_ID + customProgramId: MPL_CORE_ORACLE_EXAMPLE_PROGRAM_ID, }, }; @@ -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: [ { @@ -2057,7 +2057,7 @@ test('it can use custom pda (with custom program ID) oracle to deny transfer', a ), }, ], - customProgramId: MPL_CORE_ORACLE_EXAMPLE_PROGRAM_ID + customProgramId: MPL_CORE_ORACLE_EXAMPLE_PROGRAM_ID, }, }, ], @@ -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,7 +2417,7 @@ test('it can update asset to different size name with oracle', async (t) => { update: [CheckResult.CAN_REJECT], }, baseAddress: oracleSigner.publicKey, - pda: undefined, + baseAddressConfig: undefined, }, ], }); @@ -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..e42cefaf 100644 --- a/clients/js/test/helps/lifecycle.test.ts +++ b/clients/js/test/helps/lifecycle.test.ts @@ -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/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/tests/add_external_plugins.rs b/clients/rust/tests/add_external_plugins.rs index 251549ef..a23f36c9 100644 --- a/clients/rust/tests/add_external_plugins.rs +++ b/clients/rust/tests/add_external_plugins.rs @@ -407,7 +407,7 @@ async fn test_add_oracle() { HookableLifecycleEvent::Transfer, ExternalCheckResult { flags: 4 }, )], - pda: None, + base_address_config: None, results_offset: None, })) .instruction(); @@ -432,7 +432,7 @@ async fn test_add_oracle() { plugins: vec![], external_plugins: vec![ExternalPlugin::Oracle(Oracle { base_address: Pubkey::default(), - pda: None, + base_address_config: None, results_offset: ValidationResultsOffset::NoOffset, })], }, @@ -496,7 +496,7 @@ async fn test_cannot_add_oracle_with_duplicate_lifecycle_checks() { ExternalCheckResult { flags: 4 }, ), ], - pda: None, + base_address_config: None, results_offset: None, })) .instruction(); @@ -802,7 +802,7 @@ async fn test_cannot_add_duplicate_external_plugin() { HookableLifecycleEvent::Transfer, ExternalCheckResult { flags: 4 }, )], - pda: None, + base_address_config: None, results_offset: None, })) .instruction(); @@ -817,7 +817,7 @@ async fn test_cannot_add_duplicate_external_plugin() { HookableLifecycleEvent::Transfer, ExternalCheckResult { flags: 4 }, )], - pda: None, + base_address_config: None, results_offset: None, })) .instruction(); diff --git a/clients/rust/tests/create_with_external_plugins.rs b/clients/rust/tests/create_with_external_plugins.rs index 7734728f..af431111 100644 --- a/clients/rust/tests/create_with_external_plugins.rs +++ b/clients/rust/tests/create_with_external_plugins.rs @@ -218,7 +218,7 @@ async fn test_create_oracle() { HookableLifecycleEvent::Transfer, ExternalCheckResult { flags: 4 }, )], - pda: None, + base_address_config: None, results_offset: None, })], }, @@ -239,7 +239,7 @@ async fn test_create_oracle() { plugins: vec![], external_plugins: vec![ExternalPlugin::Oracle(Oracle { base_address: Pubkey::default(), - pda: None, + base_address_config: None, results_offset: ValidationResultsOffset::NoOffset, })], }, @@ -278,7 +278,7 @@ async fn test_cannot_create_oracle_with_duplicate_lifecycle_checks() { ExternalCheckResult { flags: 4 }, ), ], - pda: None, + base_address_config: None, results_offset: None, })], }, diff --git a/clients/rust/tests/remove_external_plugins.rs b/clients/rust/tests/remove_external_plugins.rs index 322ffe9c..ade718cf 100644 --- a/clients/rust/tests/remove_external_plugins.rs +++ b/clients/rust/tests/remove_external_plugins.rs @@ -130,7 +130,7 @@ async fn test_remove_oracle() { HookableLifecycleEvent::Transfer, ExternalCheckResult { flags: 4 }, )], - pda: None, + base_address_config: None, results_offset: None, })], }, @@ -151,7 +151,7 @@ async fn test_remove_oracle() { plugins: vec![], external_plugins: vec![ExternalPlugin::Oracle(Oracle { base_address: Pubkey::default(), - pda: None, + base_address_config: None, results_offset: ValidationResultsOffset::NoOffset, })], }, diff --git a/clients/rust/tests/update_external_plugins.rs b/clients/rust/tests/update_external_plugins.rs index 4a65984d..201dd7ed 100644 --- a/clients/rust/tests/update_external_plugins.rs +++ b/clients/rust/tests/update_external_plugins.rs @@ -244,7 +244,7 @@ async fn test_update_oracle() { HookableLifecycleEvent::Transfer, ExternalCheckResult { flags: 4 }, )], - pda: None, + base_address_config: None, results_offset: None, })], }, @@ -265,7 +265,7 @@ async fn test_update_oracle() { plugins: vec![], external_plugins: vec![ExternalPlugin::Oracle(Oracle { base_address: Pubkey::default(), - pda: None, + base_address_config: None, results_offset: ValidationResultsOffset::NoOffset, })], }, @@ -278,7 +278,7 @@ async fn test_update_oracle() { .key(ExternalPluginKey::Oracle(Pubkey::default())) .update_info(ExternalPluginUpdateInfo::Oracle(OracleUpdateInfo { lifecycle_checks: None, - pda: None, + base_address_config: None, results_offset: Some(ValidationResultsOffset::Custom(10)), })) .instruction(); @@ -303,7 +303,7 @@ async fn test_update_oracle() { plugins: vec![], external_plugins: vec![ExternalPlugin::Oracle(Oracle { base_address: Pubkey::default(), - pda: None, + base_address_config: None, results_offset: ValidationResultsOffset::Custom(10), })], }, @@ -336,7 +336,7 @@ async fn test_cannot_update_oracle_to_have_duplicate_lifecycle_checks() { HookableLifecycleEvent::Transfer, ExternalCheckResult { flags: 4 }, )], - pda: None, + base_address_config: None, results_offset: None, })], }, @@ -357,7 +357,7 @@ async fn test_cannot_update_oracle_to_have_duplicate_lifecycle_checks() { plugins: vec![], external_plugins: vec![ExternalPlugin::Oracle(Oracle { base_address: Pubkey::default(), - pda: None, + base_address_config: None, results_offset: ValidationResultsOffset::NoOffset, })], }, @@ -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(); diff --git a/idls/mpl_core.json b/idls/mpl_core.json index d171b50c..17847690 100644 --- a/idls/mpl_core.json +++ b/idls/mpl_core.json @@ -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" diff --git a/programs/mpl-core/src/plugins/oracle.rs b/programs/mpl-core/src/plugins/oracle.rs index 3d0842c9..0a306472 100644 --- a/programs/mpl-core/src/plugins/oracle.rs +++ b/programs/mpl-core/src/plugins/oracle.rs @@ -16,8 +16,10 @@ 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 plugin. + 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; @@ -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)?, }; @@ -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), @@ -141,8 +143,10 @@ pub struct OracleInitInfo { pub init_plugin_authority: Option, /// The lifecyle events for which the the external plugin 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 plugin. + pub base_address_config: Option, /// Optional offset for validation results struct used in Oracle account. Default /// is `ValidationResultsOffset::NoOffset`. pub results_offset: Option, @@ -153,8 +157,10 @@ pub struct OracleInitInfo { pub struct OracleUpdateInfo { /// The lifecyle events for which the the external plugin 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 plugin. + pub base_address_config: Option, /// Optional offset for validation results struct used in Oracle account. Default /// is `ValidationResultsOffset::NoOffset`. pub results_offset: Option,