Skip to content

Commit

Permalink
Danenbm/no init data (#66)
Browse files Browse the repository at this point in the history
* Do not allow data init on 3P plugins

* Also no lifecycle checks for data store.

* Regenerate IDL and clients
  • Loading branch information
danenbm authored Apr 12, 2024
1 parent e5fb23b commit b06195f
Show file tree
Hide file tree
Showing 9 changed files with 3 additions and 125 deletions.
28 changes: 0 additions & 28 deletions clients/js/src/generated/types/dataStoreInitInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,44 +9,28 @@
import { Option, OptionOrNullable } from '@metaplex-foundation/umi';
import {
Serializer,
array,
bytes,
option,
struct,
tuple,
u32,
} from '@metaplex-foundation/umi/serializers';
import {
ExternalCheckResult,
ExternalCheckResultArgs,
ExternalPluginSchema,
ExternalPluginSchemaArgs,
HookableLifecycleEvent,
HookableLifecycleEventArgs,
PluginAuthority,
PluginAuthorityArgs,
getExternalCheckResultSerializer,
getExternalPluginSchemaSerializer,
getHookableLifecycleEventSerializer,
getPluginAuthoritySerializer,
} from '.';

export type DataStoreInitInfo = {
dataAuthority: PluginAuthority;
initPluginAuthority: Option<PluginAuthority>;
lifecycleChecks: Option<Array<[HookableLifecycleEvent, ExternalCheckResult]>>;
schema: Option<ExternalPluginSchema>;
data: Option<Uint8Array>;
};

export type DataStoreInitInfoArgs = {
dataAuthority: PluginAuthorityArgs;
initPluginAuthority: OptionOrNullable<PluginAuthorityArgs>;
lifecycleChecks: OptionOrNullable<
Array<[HookableLifecycleEventArgs, ExternalCheckResultArgs]>
>;
schema: OptionOrNullable<ExternalPluginSchemaArgs>;
data: OptionOrNullable<Uint8Array>;
};

export function getDataStoreInitInfoSerializer(): Serializer<
Expand All @@ -57,19 +41,7 @@ export function getDataStoreInitInfoSerializer(): Serializer<
[
['dataAuthority', getPluginAuthoritySerializer()],
['initPluginAuthority', option(getPluginAuthoritySerializer())],
[
'lifecycleChecks',
option(
array(
tuple([
getHookableLifecycleEventSerializer(),
getExternalCheckResultSerializer(),
])
)
),
],
['schema', option(getExternalPluginSchemaSerializer())],
['data', option(bytes({ size: u32() }))],
],
{ description: 'DataStoreInitInfo' }
) as Serializer<DataStoreInitInfoArgs, DataStoreInitInfo>;
Expand Down
31 changes: 2 additions & 29 deletions clients/js/src/generated/types/dataStoreUpdateInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,32 +9,18 @@
import { Option, OptionOrNullable } from '@metaplex-foundation/umi';
import {
Serializer,
array,
option,
struct,
tuple,
} from '@metaplex-foundation/umi/serializers';
import {
ExternalCheckResult,
ExternalCheckResultArgs,
ExternalPluginSchema,
ExternalPluginSchemaArgs,
HookableLifecycleEvent,
HookableLifecycleEventArgs,
getExternalCheckResultSerializer,
getExternalPluginSchemaSerializer,
getHookableLifecycleEventSerializer,
} from '.';

export type DataStoreUpdateInfo = {
lifecycleChecks: Option<Array<[HookableLifecycleEvent, ExternalCheckResult]>>;
schema: Option<ExternalPluginSchema>;
};
export type DataStoreUpdateInfo = { schema: Option<ExternalPluginSchema> };

export type DataStoreUpdateInfoArgs = {
lifecycleChecks: OptionOrNullable<
Array<[HookableLifecycleEventArgs, ExternalCheckResultArgs]>
>;
schema: OptionOrNullable<ExternalPluginSchemaArgs>;
};

Expand All @@ -43,20 +29,7 @@ export function getDataStoreUpdateInfoSerializer(): Serializer<
DataStoreUpdateInfo
> {
return struct<DataStoreUpdateInfo>(
[
[
'lifecycleChecks',
option(
array(
tuple([
getHookableLifecycleEventSerializer(),
getExternalCheckResultSerializer(),
])
)
),
],
['schema', option(getExternalPluginSchemaSerializer())],
],
[['schema', option(getExternalPluginSchemaSerializer())]],
{ description: 'DataStoreUpdateInfo' }
) as Serializer<DataStoreUpdateInfoArgs, DataStoreUpdateInfo>;
}
5 changes: 0 additions & 5 deletions clients/js/src/generated/types/lifecycleHookInitInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,10 @@ import { Option, OptionOrNullable, PublicKey } from '@metaplex-foundation/umi';
import {
Serializer,
array,
bytes,
option,
publicKey as publicKeySerializer,
struct,
tuple,
u32,
} from '@metaplex-foundation/umi/serializers';
import {
ExternalCheckResult,
Expand All @@ -41,7 +39,6 @@ export type LifecycleHookInitInfo = {
lifecycleChecks: Option<Array<[HookableLifecycleEvent, ExternalCheckResult]>>;
extraAccounts: Option<Array<ExtraAccount>>;
schema: Option<ExternalPluginSchema>;
data: Option<Uint8Array>;
};

export type LifecycleHookInitInfoArgs = {
Expand All @@ -52,7 +49,6 @@ export type LifecycleHookInitInfoArgs = {
>;
extraAccounts: OptionOrNullable<Array<ExtraAccountArgs>>;
schema: OptionOrNullable<ExternalPluginSchemaArgs>;
data: OptionOrNullable<Uint8Array>;
};

export function getLifecycleHookInitInfoSerializer(): Serializer<
Expand All @@ -76,7 +72,6 @@ export function getLifecycleHookInitInfoSerializer(): Serializer<
],
['extraAccounts', option(array(getExtraAccountSerializer()))],
['schema', option(getExternalPluginSchemaSerializer())],
['data', option(bytes({ size: u32() }))],
],
{ description: 'LifecycleHookInitInfo' }
) as Serializer<LifecycleHookInitInfoArgs, LifecycleHookInitInfo>;
Expand Down
4 changes: 0 additions & 4 deletions clients/rust/src/generated/types/data_store_init_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@
//! [https://github.com/metaplex-foundation/kinobi]
//!
use crate::generated::types::ExternalCheckResult;
use crate::generated::types::ExternalPluginSchema;
use crate::generated::types::HookableLifecycleEvent;
use crate::generated::types::PluginAuthority;
use borsh::BorshDeserialize;
use borsh::BorshSerialize;
Expand All @@ -17,7 +15,5 @@ use borsh::BorshSerialize;
pub struct DataStoreInitInfo {
pub data_authority: PluginAuthority,
pub init_plugin_authority: Option<PluginAuthority>,
pub lifecycle_checks: Option<Vec<(HookableLifecycleEvent, ExternalCheckResult)>>,
pub schema: Option<ExternalPluginSchema>,
pub data: Option<Vec<u8>>,
}
3 changes: 0 additions & 3 deletions clients/rust/src/generated/types/data_store_update_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,12 @@
//! [https://github.com/metaplex-foundation/kinobi]
//!
use crate::generated::types::ExternalCheckResult;
use crate::generated::types::ExternalPluginSchema;
use crate::generated::types::HookableLifecycleEvent;
use borsh::BorshDeserialize;
use borsh::BorshSerialize;

#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct DataStoreUpdateInfo {
pub lifecycle_checks: Option<Vec<(HookableLifecycleEvent, ExternalCheckResult)>>,
pub schema: Option<ExternalPluginSchema>,
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,4 @@ pub struct LifecycleHookInitInfo {
pub lifecycle_checks: Option<Vec<(HookableLifecycleEvent, ExternalCheckResult)>>,
pub extra_accounts: Option<Vec<ExtraAccount>>,
pub schema: Option<ExternalPluginSchema>,
pub data: Option<Vec<u8>>,
}
46 changes: 0 additions & 46 deletions idls/mpl_core.json
Original file line number Diff line number Diff line change
Expand Up @@ -2034,36 +2034,13 @@
}
}
},
{
"name": "lifecycleChecks",
"type": {
"option": {
"vec": {
"tuple": [
{
"defined": "HookableLifecycleEvent"
},
{
"defined": "ExternalCheckResult"
}
]
}
}
}
},
{
"name": "schema",
"type": {
"option": {
"defined": "ExternalPluginSchema"
}
}
},
{
"name": "data",
"type": {
"option": "bytes"
}
}
]
}
Expand All @@ -2073,23 +2050,6 @@
"type": {
"kind": "struct",
"fields": [
{
"name": "lifecycleChecks",
"type": {
"option": {
"vec": {
"tuple": [
{
"defined": "HookableLifecycleEvent"
},
{
"defined": "ExternalCheckResult"
}
]
}
}
}
},
{
"name": "schema",
"type": {
Expand Down Expand Up @@ -2208,12 +2168,6 @@
"defined": "ExternalPluginSchema"
}
}
},
{
"name": "data",
"type": {
"option": "bytes"
}
}
]
}
Expand Down
8 changes: 1 addition & 7 deletions programs/mpl-core/src/plugins/data_store.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use borsh::{BorshDeserialize, BorshSerialize};

use super::{Authority, ExternalCheckResult, ExternalPluginSchema, HookableLifecycleEvent};
use super::{Authority, ExternalPluginSchema};

/// The data store third party plugin contains arbitrary data that can be written to by the
/// authority specified in the `ExternalPluginKey`. Note this is different then the plugin
Expand All @@ -23,19 +23,13 @@ pub struct DataStoreInitInfo {
pub data_authority: Authority,
/// Initial plugin authority who can update plugin properties.
pub init_plugin_authority: Option<Authority>,
/// The lifecyle events for which the the external plugin is active.
pub lifecycle_checks: Option<Vec<(HookableLifecycleEvent, ExternalCheckResult)>>,
/// Schema for the data used by the plugin.
pub schema: Option<ExternalPluginSchema>,
/// External plugin initial data.
pub data: Option<Vec<u8>>,
}

/// Data store update info.
#[derive(Clone, Debug, BorshSerialize, BorshDeserialize, Eq, PartialEq)]
pub struct DataStoreUpdateInfo {
/// The lifecyle events for which the the external plugin is active.
pub lifecycle_checks: Option<Vec<(HookableLifecycleEvent, ExternalCheckResult)>>,
/// Schema for the data used by the plugin.
pub schema: Option<ExternalPluginSchema>,
}
2 changes: 0 additions & 2 deletions programs/mpl-core/src/plugins/lifecycle_hook.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ pub struct LifecycleHookInitInfo {
pub extra_accounts: Option<Vec<ExtraAccount>>,
/// Schema for the data used by the plugin.
pub schema: Option<ExternalPluginSchema>,
/// External plugin initial data.
pub data: Option<Vec<u8>>,
}

/// Lifecycle hook update info.
Expand Down

0 comments on commit b06195f

Please sign in to comment.