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

Avoid inlining UpdateArgs #50

Merged
merged 3 commits into from
Oct 4, 2023
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
33 changes: 6 additions & 27 deletions clients/js/src/generated/instructions/updateMetadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,10 @@ import {
import {
Serializer,
array,
bool,
bytes,
mapSerializer,
option,
string,
struct,
u16,
u32,
u64,
u8,
Expand All @@ -39,12 +36,12 @@ import {
getAccountMetasAndSigners,
} from '../shared';
import {
Creator,
CreatorArgs,
MetadataArgs,
MetadataArgsArgs,
getCreatorSerializer,
UpdateArgs,
UpdateArgsArgs,
getMetadataArgsSerializer,
getUpdateArgsSerializer,
} from '../types';

// Accounts.
Expand All @@ -69,27 +66,15 @@ export type UpdateMetadataInstructionData = {
nonce: bigint;
index: number;
currentMetadata: Option<MetadataArgs>;
name: Option<string>;
symbol: Option<string>;
uri: Option<string>;
creators: Option<Array<Creator>>;
sellerFeeBasisPoints: Option<number>;
primarySaleHappened: Option<boolean>;
isMutable: Option<boolean>;
updateArgs: UpdateArgs;
};

export type UpdateMetadataInstructionDataArgs = {
root: Uint8Array;
nonce: number | bigint;
index: number;
currentMetadata: OptionOrNullable<MetadataArgsArgs>;
name: OptionOrNullable<string>;
symbol: OptionOrNullable<string>;
uri: OptionOrNullable<string>;
creators: OptionOrNullable<Array<CreatorArgs>>;
sellerFeeBasisPoints: OptionOrNullable<number>;
primarySaleHappened: OptionOrNullable<boolean>;
isMutable: OptionOrNullable<boolean>;
updateArgs: UpdateArgsArgs;
};

export function getUpdateMetadataInstructionDataSerializer(): Serializer<
Expand All @@ -108,13 +93,7 @@ export function getUpdateMetadataInstructionDataSerializer(): Serializer<
['nonce', u64()],
['index', u32()],
['currentMetadata', option(getMetadataArgsSerializer())],
['name', option(string())],
['symbol', option(string())],
['uri', option(string())],
['creators', option(array(getCreatorSerializer()))],
['sellerFeeBasisPoints', option(u16())],
['primarySaleHappened', option(bool())],
['isMutable', option(bool())],
['updateArgs', getUpdateArgsSerializer()],
],
{ description: 'UpdateMetadataInstructionData' }
),
Expand Down
1 change: 1 addition & 0 deletions clients/js/src/generated/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export * from './leafSchema';
export * from './metadataArgs';
export * from './tokenProgramVersion';
export * from './tokenStandard';
export * from './updateArgs';
export * from './useMethod';
export * from './uses';
export * from './version';
70 changes: 70 additions & 0 deletions clients/js/src/generated/types/updateArgs.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/**
* 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 { Option, OptionOrNullable, none } from '@metaplex-foundation/umi';
import {
Serializer,
array,
bool,
mapSerializer,
option,
string,
struct,
u16,
} from '@metaplex-foundation/umi/serializers';
import { Creator, CreatorArgs, getCreatorSerializer } from '.';

export type UpdateArgs = {
name: Option<string>;
symbol: Option<string>;
uri: Option<string>;
creators: Option<Array<Creator>>;
sellerFeeBasisPoints: Option<number>;
primarySaleHappened: Option<boolean>;
isMutable: Option<boolean>;
};

export type UpdateArgsArgs = {
name?: OptionOrNullable<string>;
symbol?: OptionOrNullable<string>;
uri?: OptionOrNullable<string>;
creators?: OptionOrNullable<Array<CreatorArgs>>;
sellerFeeBasisPoints?: OptionOrNullable<number>;
primarySaleHappened?: OptionOrNullable<boolean>;
isMutable?: OptionOrNullable<boolean>;
};

export function getUpdateArgsSerializer(): Serializer<
UpdateArgsArgs,
UpdateArgs
> {
return mapSerializer<UpdateArgsArgs, any, UpdateArgs>(
struct<UpdateArgs>(
[
['name', option(string())],
['symbol', option(string())],
['uri', option(string())],
['creators', option(array(getCreatorSerializer()))],
['sellerFeeBasisPoints', option(u16())],
['primarySaleHappened', option(bool())],
['isMutable', option(bool())],
],
{ description: 'UpdateArgs' }
),
(value) => ({
...value,
name: value.name ?? none(),
symbol: value.symbol ?? none(),
uri: value.uri ?? none(),
creators: value.creators ?? none(),
sellerFeeBasisPoints: value.sellerFeeBasisPoints ?? none(),
primarySaleHappened: value.primarySaleHappened ?? none(),
isMutable: value.isMutable ?? none(),
})
) as Serializer<UpdateArgsArgs, UpdateArgs>;
}
136 changes: 15 additions & 121 deletions clients/rust/src/generated/instructions/update_metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
//! [https://github.com/metaplex-foundation/kinobi]
//!

use crate::generated::types::Creator;
use crate::generated::types::MetadataArgs;
use crate::generated::types::UpdateArgs;
use borsh::BorshDeserialize;
use borsh::BorshSerialize;

Expand Down Expand Up @@ -132,13 +132,7 @@ pub struct UpdateMetadataInstructionArgs {
pub nonce: u64,
pub index: u32,
pub current_metadata: Option<MetadataArgs>,
pub name: Option<String>,
pub symbol: Option<String>,
pub uri: Option<String>,
pub creators: Option<Vec<Creator>>,
pub seller_fee_basis_points: Option<u16>,
pub primary_sale_happened: Option<bool>,
pub is_mutable: Option<bool>,
pub update_args: UpdateArgs,
}

/// Instruction builder.
Expand All @@ -159,13 +153,7 @@ pub struct UpdateMetadataBuilder {
nonce: Option<u64>,
index: Option<u32>,
current_metadata: Option<MetadataArgs>,
name: Option<String>,
symbol: Option<String>,
uri: Option<String>,
creators: Option<Vec<Creator>>,
seller_fee_basis_points: Option<u16>,
primary_sale_happened: Option<bool>,
is_mutable: Option<bool>,
update_args: Option<UpdateArgs>,
__remaining_accounts: Vec<solana_program::instruction::AccountMeta>,
}

Expand Down Expand Up @@ -266,46 +254,9 @@ impl UpdateMetadataBuilder {
self.current_metadata = Some(current_metadata);
self
}
/// `[optional argument]`
#[inline(always)]
pub fn name(&mut self, name: String) -> &mut Self {
self.name = Some(name);
self
}
/// `[optional argument]`
#[inline(always)]
pub fn symbol(&mut self, symbol: String) -> &mut Self {
self.symbol = Some(symbol);
self
}
/// `[optional argument]`
#[inline(always)]
pub fn uri(&mut self, uri: String) -> &mut Self {
self.uri = Some(uri);
self
}
/// `[optional argument]`
#[inline(always)]
pub fn creators(&mut self, creators: Vec<Creator>) -> &mut Self {
self.creators = Some(creators);
self
}
/// `[optional argument]`
#[inline(always)]
pub fn seller_fee_basis_points(&mut self, seller_fee_basis_points: u16) -> &mut Self {
self.seller_fee_basis_points = Some(seller_fee_basis_points);
self
}
/// `[optional argument]`
#[inline(always)]
pub fn primary_sale_happened(&mut self, primary_sale_happened: bool) -> &mut Self {
self.primary_sale_happened = Some(primary_sale_happened);
self
}
/// `[optional argument]`
#[inline(always)]
pub fn is_mutable(&mut self, is_mutable: bool) -> &mut Self {
self.is_mutable = Some(is_mutable);
pub fn update_args(&mut self, update_args: UpdateArgs) -> &mut Self {
self.update_args = Some(update_args);
self
}
/// Add an aditional account to the instruction.
Expand Down Expand Up @@ -357,13 +308,7 @@ impl UpdateMetadataBuilder {
nonce: self.nonce.clone().expect("nonce is not set"),
index: self.index.clone().expect("index is not set"),
current_metadata: self.current_metadata.clone(),
name: self.name.clone(),
symbol: self.symbol.clone(),
uri: self.uri.clone(),
creators: self.creators.clone(),
seller_fee_basis_points: self.seller_fee_basis_points.clone(),
primary_sale_happened: self.primary_sale_happened.clone(),
is_mutable: self.is_mutable.clone(),
update_args: self.update_args.clone().expect("update_args is not set"),
};

accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts)
Expand Down Expand Up @@ -599,13 +544,7 @@ impl<'a, 'b> UpdateMetadataCpiBuilder<'a, 'b> {
nonce: None,
index: None,
current_metadata: None,
name: None,
symbol: None,
uri: None,
creators: None,
seller_fee_basis_points: None,
primary_sale_happened: None,
is_mutable: None,
update_args: None,
__remaining_accounts: Vec::new(),
});
Self { instruction }
Expand Down Expand Up @@ -717,46 +656,9 @@ impl<'a, 'b> UpdateMetadataCpiBuilder<'a, 'b> {
self.instruction.current_metadata = Some(current_metadata);
self
}
/// `[optional argument]`
#[inline(always)]
pub fn name(&mut self, name: String) -> &mut Self {
self.instruction.name = Some(name);
self
}
/// `[optional argument]`
#[inline(always)]
pub fn symbol(&mut self, symbol: String) -> &mut Self {
self.instruction.symbol = Some(symbol);
self
}
/// `[optional argument]`
#[inline(always)]
pub fn uri(&mut self, uri: String) -> &mut Self {
self.instruction.uri = Some(uri);
self
}
/// `[optional argument]`
#[inline(always)]
pub fn creators(&mut self, creators: Vec<Creator>) -> &mut Self {
self.instruction.creators = Some(creators);
self
}
/// `[optional argument]`
#[inline(always)]
pub fn seller_fee_basis_points(&mut self, seller_fee_basis_points: u16) -> &mut Self {
self.instruction.seller_fee_basis_points = Some(seller_fee_basis_points);
self
}
/// `[optional argument]`
#[inline(always)]
pub fn primary_sale_happened(&mut self, primary_sale_happened: bool) -> &mut Self {
self.instruction.primary_sale_happened = Some(primary_sale_happened);
self
}
/// `[optional argument]`
#[inline(always)]
pub fn is_mutable(&mut self, is_mutable: bool) -> &mut Self {
self.instruction.is_mutable = Some(is_mutable);
pub fn update_args(&mut self, update_args: UpdateArgs) -> &mut Self {
self.instruction.update_args = Some(update_args);
self
}
/// Add an additional account to the instruction.
Expand Down Expand Up @@ -805,13 +707,11 @@ impl<'a, 'b> UpdateMetadataCpiBuilder<'a, 'b> {
nonce: self.instruction.nonce.clone().expect("nonce is not set"),
index: self.instruction.index.clone().expect("index is not set"),
current_metadata: self.instruction.current_metadata.clone(),
name: self.instruction.name.clone(),
symbol: self.instruction.symbol.clone(),
uri: self.instruction.uri.clone(),
creators: self.instruction.creators.clone(),
seller_fee_basis_points: self.instruction.seller_fee_basis_points.clone(),
primary_sale_happened: self.instruction.primary_sale_happened.clone(),
is_mutable: self.instruction.is_mutable.clone(),
update_args: self
.instruction
.update_args
.clone()
.expect("update_args is not set"),
};
let instruction = UpdateMetadataCpi {
__program: self.instruction.__program,
Expand Down Expand Up @@ -887,13 +787,7 @@ struct UpdateMetadataCpiBuilderInstruction<'a, 'b> {
nonce: Option<u64>,
index: Option<u32>,
current_metadata: Option<MetadataArgs>,
name: Option<String>,
symbol: Option<String>,
uri: Option<String>,
creators: Option<Vec<Creator>>,
seller_fee_basis_points: Option<u16>,
primary_sale_happened: Option<bool>,
is_mutable: Option<bool>,
update_args: Option<UpdateArgs>,
/// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`.
__remaining_accounts: Vec<(
&'b solana_program::account_info::AccountInfo<'a>,
Expand Down
2 changes: 2 additions & 0 deletions clients/rust/src/generated/types/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ pub(crate) mod leaf_schema;
pub(crate) mod metadata_args;
pub(crate) mod token_program_version;
pub(crate) mod token_standard;
pub(crate) mod update_args;
pub(crate) mod use_method;
pub(crate) mod uses;
pub(crate) mod version;
Expand All @@ -31,6 +32,7 @@ pub use self::leaf_schema::*;
pub use self::metadata_args::*;
pub use self::token_program_version::*;
pub use self::token_standard::*;
pub use self::update_args::*;
pub use self::use_method::*;
pub use self::uses::*;
pub use self::version::*;
22 changes: 22 additions & 0 deletions clients/rust/src/generated/types/update_args.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
//! 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.
//!
//! [https://github.com/metaplex-foundation/kinobi]
//!

use crate::generated::types::Creator;
use borsh::BorshDeserialize;
use borsh::BorshSerialize;

#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct UpdateArgs {
pub name: Option<String>,
pub symbol: Option<String>,
pub uri: Option<String>,
pub creators: Option<Vec<Creator>>,
pub seller_fee_basis_points: Option<u16>,
pub primary_sale_happened: Option<bool>,
pub is_mutable: Option<bool>,
}
Loading
Loading