Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move key information into init structs #65

Merged
merged 2 commits into from
Apr 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,7 @@ import {
import {
ExternalPluginInitInfo,
ExternalPluginInitInfoArgs,
ExternalPluginKey,
ExternalPluginKeyArgs,
getExternalPluginInitInfoSerializer,
getExternalPluginKeySerializer,
} from '../types';

// Accounts.
Expand All @@ -51,12 +48,10 @@ export type AddCollectionExternalPluginV1InstructionAccounts = {
// Data.
export type AddCollectionExternalPluginV1InstructionData = {
discriminator: number;
key: ExternalPluginKey;
initInfo: ExternalPluginInitInfo;
};

export type AddCollectionExternalPluginV1InstructionDataArgs = {
key: ExternalPluginKeyArgs;
initInfo: ExternalPluginInitInfoArgs;
};

Expand All @@ -72,7 +67,6 @@ export function getAddCollectionExternalPluginV1InstructionDataSerializer(): Ser
struct<AddCollectionExternalPluginV1InstructionData>(
[
['discriminator', u8()],
['key', getExternalPluginKeySerializer()],
['initInfo', getExternalPluginInitInfoSerializer()],
],
{ description: 'AddCollectionExternalPluginV1InstructionData' }
Expand Down
6 changes: 0 additions & 6 deletions clients/js/src/generated/instructions/addExternalPluginV1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,7 @@ import {
import {
ExternalPluginInitInfo,
ExternalPluginInitInfoArgs,
ExternalPluginKey,
ExternalPluginKeyArgs,
getExternalPluginInitInfoSerializer,
getExternalPluginKeySerializer,
} from '../types';

// Accounts.
Expand All @@ -53,12 +50,10 @@ export type AddExternalPluginV1InstructionAccounts = {
// Data.
export type AddExternalPluginV1InstructionData = {
discriminator: number;
key: ExternalPluginKey;
initInfo: ExternalPluginInitInfo;
};

export type AddExternalPluginV1InstructionDataArgs = {
key: ExternalPluginKeyArgs;
initInfo: ExternalPluginInitInfoArgs;
};

Expand All @@ -74,7 +69,6 @@ export function getAddExternalPluginV1InstructionDataSerializer(): Serializer<
struct<AddExternalPluginV1InstructionData>(
[
['discriminator', u8()],
['key', getExternalPluginKeySerializer()],
['initInfo', getExternalPluginInitInfoSerializer()],
],
{ description: 'AddExternalPluginV1InstructionData' }
Expand Down
9 changes: 6 additions & 3 deletions clients/js/src/generated/types/dataStoreInitInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,16 @@ import {
} from '.';

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

export type DataStoreInitInfoArgs = {
initAuthority: OptionOrNullable<PluginAuthorityArgs>;
dataAuthority: PluginAuthorityArgs;
initPluginAuthority: OptionOrNullable<PluginAuthorityArgs>;
lifecycleChecks: OptionOrNullable<
Array<[HookableLifecycleEventArgs, ExternalCheckResultArgs]>
>;
Expand All @@ -53,7 +55,8 @@ export function getDataStoreInitInfoSerializer(): Serializer<
> {
return struct<DataStoreInitInfo>(
[
['initAuthority', option(getPluginAuthoritySerializer())],
['dataAuthority', getPluginAuthoritySerializer()],
['initPluginAuthority', option(getPluginAuthoritySerializer())],
[
'lifecycleChecks',
option(
Expand Down
12 changes: 8 additions & 4 deletions clients/js/src/generated/types/lifecycleHookInitInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@
* @see https://github.com/metaplex-foundation/kinobi
*/

import { Option, OptionOrNullable } from '@metaplex-foundation/umi';
import { Option, OptionOrNullable, PublicKey } from '@metaplex-foundation/umi';
import {
Serializer,
array,
bytes,
option,
publicKey as publicKeySerializer,
struct,
tuple,
u32,
Expand All @@ -35,15 +36,17 @@ import {
} from '.';

export type LifecycleHookInitInfo = {
initAuthority: Option<PluginAuthority>;
hookedProgram: PublicKey;
initPluginAuthority: Option<PluginAuthority>;
lifecycleChecks: Option<Array<[HookableLifecycleEvent, ExternalCheckResult]>>;
extraAccounts: Option<Array<ExtraAccount>>;
schema: Option<ExternalPluginSchema>;
data: Option<Uint8Array>;
};

export type LifecycleHookInitInfoArgs = {
initAuthority: OptionOrNullable<PluginAuthorityArgs>;
hookedProgram: PublicKey;
initPluginAuthority: OptionOrNullable<PluginAuthorityArgs>;
lifecycleChecks: OptionOrNullable<
Array<[HookableLifecycleEventArgs, ExternalCheckResultArgs]>
>;
Expand All @@ -58,7 +61,8 @@ export function getLifecycleHookInitInfoSerializer(): Serializer<
> {
return struct<LifecycleHookInitInfo>(
[
['initAuthority', option(getPluginAuthoritySerializer())],
['hookedProgram', publicKeySerializer()],
['initPluginAuthority', option(getPluginAuthoritySerializer())],
[
'lifecycleChecks',
option(
Expand Down
12 changes: 8 additions & 4 deletions clients/js/src/generated/types/oracleInitInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@
* @see https://github.com/metaplex-foundation/kinobi
*/

import { Option, OptionOrNullable } from '@metaplex-foundation/umi';
import { Option, OptionOrNullable, PublicKey } from '@metaplex-foundation/umi';
import {
Serializer,
array,
option,
publicKey as publicKeySerializer,
struct,
tuple,
} from '@metaplex-foundation/umi/serializers';
Expand All @@ -30,13 +31,15 @@ import {
} from '.';

export type OracleInitInfo = {
initAuthority: Option<PluginAuthority>;
baseAddress: PublicKey;
initPluginAuthority: Option<PluginAuthority>;
lifecycleChecks: Option<Array<[HookableLifecycleEvent, ExternalCheckResult]>>;
pda: Option<ExtraAccount>;
};

export type OracleInitInfoArgs = {
initAuthority: OptionOrNullable<PluginAuthorityArgs>;
baseAddress: PublicKey;
initPluginAuthority: OptionOrNullable<PluginAuthorityArgs>;
lifecycleChecks: OptionOrNullable<
Array<[HookableLifecycleEventArgs, ExternalCheckResultArgs]>
>;
Expand All @@ -49,7 +52,8 @@ export function getOracleInitInfoSerializer(): Serializer<
> {
return struct<OracleInitInfo>(
[
['initAuthority', option(getPluginAuthoritySerializer())],
['baseAddress', publicKeySerializer()],
['initPluginAuthority', option(getPluginAuthoritySerializer())],
[
'lifecycleChecks',
option(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
//!

use crate::generated::types::ExternalPluginInitInfo;
use crate::generated::types::ExternalPluginKey;
use borsh::BorshDeserialize;
use borsh::BorshSerialize;

Expand Down Expand Up @@ -99,7 +98,6 @@ impl AddCollectionExternalPluginV1InstructionData {
#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct AddCollectionExternalPluginV1InstructionArgs {
pub key: ExternalPluginKey,
pub init_info: ExternalPluginInitInfo,
}

Expand All @@ -119,7 +117,6 @@ pub struct AddCollectionExternalPluginV1Builder {
authority: Option<solana_program::pubkey::Pubkey>,
system_program: Option<solana_program::pubkey::Pubkey>,
log_wrapper: Option<solana_program::pubkey::Pubkey>,
key: Option<ExternalPluginKey>,
init_info: Option<ExternalPluginInitInfo>,
__remaining_accounts: Vec<solana_program::instruction::AccountMeta>,
}
Expand Down Expand Up @@ -165,11 +162,6 @@ impl AddCollectionExternalPluginV1Builder {
self
}
#[inline(always)]
pub fn key(&mut self, key: ExternalPluginKey) -> &mut Self {
self.key = Some(key);
self
}
#[inline(always)]
pub fn init_info(&mut self, init_info: ExternalPluginInitInfo) -> &mut Self {
self.init_info = Some(init_info);
self
Expand Down Expand Up @@ -204,7 +196,6 @@ impl AddCollectionExternalPluginV1Builder {
log_wrapper: self.log_wrapper,
};
let args = AddCollectionExternalPluginV1InstructionArgs {
key: self.key.clone().expect("key is not set"),
init_info: self.init_info.clone().expect("init_info is not set"),
};

Expand Down Expand Up @@ -391,7 +382,6 @@ impl<'a, 'b> AddCollectionExternalPluginV1CpiBuilder<'a, 'b> {
authority: None,
system_program: None,
log_wrapper: None,
key: None,
init_info: None,
__remaining_accounts: Vec::new(),
});
Expand Down Expand Up @@ -442,11 +432,6 @@ impl<'a, 'b> AddCollectionExternalPluginV1CpiBuilder<'a, 'b> {
self
}
#[inline(always)]
pub fn key(&mut self, key: ExternalPluginKey) -> &mut Self {
self.instruction.key = Some(key);
self
}
#[inline(always)]
pub fn init_info(&mut self, init_info: ExternalPluginInitInfo) -> &mut Self {
self.instruction.init_info = Some(init_info);
self
Expand Down Expand Up @@ -493,7 +478,6 @@ impl<'a, 'b> AddCollectionExternalPluginV1CpiBuilder<'a, 'b> {
signers_seeds: &[&[&[u8]]],
) -> solana_program::entrypoint::ProgramResult {
let args = AddCollectionExternalPluginV1InstructionArgs {
key: self.instruction.key.clone().expect("key is not set"),
init_info: self
.instruction
.init_info
Expand Down Expand Up @@ -531,7 +515,6 @@ struct AddCollectionExternalPluginV1CpiBuilderInstruction<'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<ExternalPluginKey>,
init_info: Option<ExternalPluginInitInfo>,
/// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`.
__remaining_accounts: Vec<(
Expand Down
17 changes: 0 additions & 17 deletions clients/rust/src/generated/instructions/add_external_plugin_v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
//!

use crate::generated::types::ExternalPluginInitInfo;
use crate::generated::types::ExternalPluginKey;
use borsh::BorshDeserialize;
use borsh::BorshSerialize;

Expand Down Expand Up @@ -110,7 +109,6 @@ impl AddExternalPluginV1InstructionData {
#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct AddExternalPluginV1InstructionArgs {
pub key: ExternalPluginKey,
pub init_info: ExternalPluginInitInfo,
}

Expand All @@ -132,7 +130,6 @@ pub struct AddExternalPluginV1Builder {
authority: Option<solana_program::pubkey::Pubkey>,
system_program: Option<solana_program::pubkey::Pubkey>,
log_wrapper: Option<solana_program::pubkey::Pubkey>,
key: Option<ExternalPluginKey>,
init_info: Option<ExternalPluginInitInfo>,
__remaining_accounts: Vec<solana_program::instruction::AccountMeta>,
}
Expand Down Expand Up @@ -185,11 +182,6 @@ impl AddExternalPluginV1Builder {
self
}
#[inline(always)]
pub fn key(&mut self, key: ExternalPluginKey) -> &mut Self {
self.key = Some(key);
self
}
#[inline(always)]
pub fn init_info(&mut self, init_info: ExternalPluginInitInfo) -> &mut Self {
self.init_info = Some(init_info);
self
Expand Down Expand Up @@ -225,7 +217,6 @@ impl AddExternalPluginV1Builder {
log_wrapper: self.log_wrapper,
};
let args = AddExternalPluginV1InstructionArgs {
key: self.key.clone().expect("key is not set"),
init_info: self.init_info.clone().expect("init_info is not set"),
};

Expand Down Expand Up @@ -433,7 +424,6 @@ impl<'a, 'b> AddExternalPluginV1CpiBuilder<'a, 'b> {
authority: None,
system_program: None,
log_wrapper: None,
key: None,
init_info: None,
__remaining_accounts: Vec::new(),
});
Expand Down Expand Up @@ -491,11 +481,6 @@ impl<'a, 'b> AddExternalPluginV1CpiBuilder<'a, 'b> {
self
}
#[inline(always)]
pub fn key(&mut self, key: ExternalPluginKey) -> &mut Self {
self.instruction.key = Some(key);
self
}
#[inline(always)]
pub fn init_info(&mut self, init_info: ExternalPluginInitInfo) -> &mut Self {
self.instruction.init_info = Some(init_info);
self
Expand Down Expand Up @@ -542,7 +527,6 @@ impl<'a, 'b> AddExternalPluginV1CpiBuilder<'a, 'b> {
signers_seeds: &[&[&[u8]]],
) -> solana_program::entrypoint::ProgramResult {
let args = AddExternalPluginV1InstructionArgs {
key: self.instruction.key.clone().expect("key is not set"),
init_info: self
.instruction
.init_info
Expand Down Expand Up @@ -583,7 +567,6 @@ 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>>,
key: Option<ExternalPluginKey>,
init_info: Option<ExternalPluginInitInfo>,
/// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`.
__remaining_accounts: Vec<(
Expand Down
3 changes: 2 additions & 1 deletion clients/rust/src/generated/types/data_store_init_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ use borsh::BorshSerialize;
#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct DataStoreInitInfo {
pub init_authority: Option<PluginAuthority>,
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>>,
Expand Down
8 changes: 7 additions & 1 deletion clients/rust/src/generated/types/lifecycle_hook_init_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,17 @@ use crate::generated::types::HookableLifecycleEvent;
use crate::generated::types::PluginAuthority;
use borsh::BorshDeserialize;
use borsh::BorshSerialize;
use solana_program::pubkey::Pubkey;

#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct LifecycleHookInitInfo {
pub init_authority: Option<PluginAuthority>,
#[cfg_attr(
feature = "serde",
serde(with = "serde_with::As::<serde_with::DisplayFromStr>")
)]
pub hooked_program: Pubkey,
pub init_plugin_authority: Option<PluginAuthority>,
pub lifecycle_checks: Option<Vec<(HookableLifecycleEvent, ExternalCheckResult)>>,
pub extra_accounts: Option<Vec<ExtraAccount>>,
pub schema: Option<ExternalPluginSchema>,
Expand Down
8 changes: 7 additions & 1 deletion clients/rust/src/generated/types/oracle_init_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,17 @@ use crate::generated::types::HookableLifecycleEvent;
use crate::generated::types::PluginAuthority;
use borsh::BorshDeserialize;
use borsh::BorshSerialize;
use solana_program::pubkey::Pubkey;

#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct OracleInitInfo {
pub init_authority: Option<PluginAuthority>,
#[cfg_attr(
feature = "serde",
serde(with = "serde_with::As::<serde_with::DisplayFromStr>")
)]
pub base_address: Pubkey,
pub init_plugin_authority: Option<PluginAuthority>,
pub lifecycle_checks: Option<Vec<(HookableLifecycleEvent, ExternalCheckResult)>>,
pub pda: Option<ExtraAccount>,
}
Loading