Skip to content

Commit

Permalink
Regenerate IDL and clients
Browse files Browse the repository at this point in the history
  • Loading branch information
danenbm committed Mar 8, 2024
1 parent bd5f3be commit e1b3a1a
Show file tree
Hide file tree
Showing 9 changed files with 184 additions and 52 deletions.
26 changes: 26 additions & 0 deletions clients/js/src/generated/errors/mplCore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,32 @@ export class MissingNewOwnerError extends ProgramError {
codeToErrorMap.set(0x15, MissingNewOwnerError);
nameToErrorMap.set('MissingNewOwner', MissingNewOwnerError);

/** MissingSystemProgram: Missing system program */
export class MissingSystemProgramError extends ProgramError {
override readonly name: string = 'MissingSystemProgram';

readonly code: number = 0x16; // 22

constructor(program: Program, cause?: Error) {
super('Missing system program', program, cause);
}
}
codeToErrorMap.set(0x16, MissingSystemProgramError);
nameToErrorMap.set('MissingSystemProgram', MissingSystemProgramError);

/** NotImplemented: Not implemented */
export class NotImplementedError extends ProgramError {
override readonly name: string = 'NotImplemented';

readonly code: number = 0x17; // 23

constructor(program: Program, cause?: Error) {
super('Not implemented', program, cause);
}
}
codeToErrorMap.set(0x17, NotImplementedError);
nameToErrorMap.set('NotImplemented', NotImplementedError);

/**
* Attempts to resolve a custom program error from the provided error code.
* @category Errors
Expand Down
11 changes: 7 additions & 4 deletions clients/js/src/generated/instructions/compress.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export type CompressInstructionAccounts = {
/** The collection to which the asset belongs */
collection?: PublicKey | Pda;
/** The owner or delegate of the asset */
owner: Signer;
authority?: Signer;
/** The account receiving the storage fees */
payer?: Signer;
/** The system program */
Expand Down Expand Up @@ -65,7 +65,7 @@ export function getCompressInstructionDataSerializer(): Serializer<

// Instruction.
export function compress(
context: Pick<Context, 'programs'>,
context: Pick<Context, 'identity' | 'programs'>,
input: CompressInstructionAccounts
): TransactionBuilder {
// Program ID.
Expand All @@ -86,10 +86,10 @@ export function compress(
isWritable: false as boolean,
value: input.collection ?? null,
},
owner: {
authority: {
index: 2,
isWritable: false as boolean,
value: input.owner ?? null,
value: input.authority ?? null,
},
payer: {
index: 3,
Expand All @@ -109,6 +109,9 @@ export function compress(
} satisfies ResolvedAccountsWithIndices;

// Default values.
if (!resolvedAccounts.authority.value) {
resolvedAccounts.authority.value = context.identity;
}
if (!resolvedAccounts.systemProgram.value) {
resolvedAccounts.systemProgram.value = context.programs.getPublicKey(
'splSystem',
Expand Down
11 changes: 7 additions & 4 deletions clients/js/src/generated/instructions/decompress.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export type DecompressInstructionAccounts = {
/** The collection to which the asset belongs */
collection?: PublicKey | Pda;
/** The owner or delegate of the asset */
owner: Signer;
authority?: Signer;
/** The account paying for the storage fees */
payer?: Signer;
/** The system program */
Expand Down Expand Up @@ -82,7 +82,7 @@ export type DecompressInstructionArgs = DecompressInstructionDataArgs;

// Instruction.
export function decompress(
context: Pick<Context, 'programs'>,
context: Pick<Context, 'identity' | 'programs'>,
input: DecompressInstructionAccounts & DecompressInstructionArgs
): TransactionBuilder {
// Program ID.
Expand All @@ -103,10 +103,10 @@ export function decompress(
isWritable: false as boolean,
value: input.collection ?? null,
},
owner: {
authority: {
index: 2,
isWritable: false as boolean,
value: input.owner ?? null,
value: input.authority ?? null,
},
payer: {
index: 3,
Expand All @@ -129,6 +129,9 @@ export function decompress(
const resolvedArgs: DecompressInstructionArgs = { ...input };

// Default values.
if (!resolvedAccounts.authority.value) {
resolvedAccounts.authority.value = context.identity;
}
if (!resolvedAccounts.systemProgram.value) {
resolvedAccounts.systemProgram.value = context.programs.getPublicKey(
'splSystem',
Expand Down
9 changes: 8 additions & 1 deletion clients/js/src/generated/instructions/transfer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ export type TransferInstructionAccounts = {
payer?: Signer;
/** The new owner to which to transfer the asset */
newOwner: PublicKey | Pda;
/** The system program */
systemProgram?: PublicKey | Pda;
/** The SPL Noop Program */
logWrapper?: PublicKey | Pda;
};
Expand Down Expand Up @@ -121,9 +123,14 @@ export function transfer(
isWritable: false as boolean,
value: input.newOwner ?? null,
},
logWrapper: {
systemProgram: {
index: 5,
isWritable: false as boolean,
value: input.systemProgram ?? null,
},
logWrapper: {
index: 6,
isWritable: false as boolean,
value: input.logWrapper ?? null,
},
} satisfies ResolvedAccountsWithIndices;
Expand Down
6 changes: 6 additions & 0 deletions clients/rust/src/generated/errors/mpl_core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,12 @@ pub enum MplCoreError {
/// 21 (0x15) - Missing new owner
#[error("Missing new owner")]
MissingNewOwner,
/// 22 (0x16) - Missing system program
#[error("Missing system program")]
MissingSystemProgram,
/// 23 (0x17) - Not implemented
#[error("Not implemented")]
NotImplemented,
}

impl solana_program::program_error::PrintProgramError for MplCoreError {
Expand Down
40 changes: 22 additions & 18 deletions clients/rust/src/generated/instructions/compress.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pub struct Compress {
/// The collection to which the asset belongs
pub collection: Option<solana_program::pubkey::Pubkey>,
/// The owner or delegate of the asset
pub owner: solana_program::pubkey::Pubkey,
pub authority: solana_program::pubkey::Pubkey,
/// The account receiving the storage fees
pub payer: Option<solana_program::pubkey::Pubkey>,
/// The system program
Expand Down Expand Up @@ -48,7 +48,8 @@ impl Compress {
));
}
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
self.owner, true,
self.authority,
true,
));
if let Some(payer) = self.payer {
accounts.push(solana_program::instruction::AccountMeta::new(payer, true));
Expand Down Expand Up @@ -101,15 +102,15 @@ impl CompressInstructionData {
///
/// 0. `[writable]` asset
/// 1. `[optional]` collection
/// 2. `[signer]` owner
/// 2. `[signer]` authority
/// 3. `[writable, signer, optional]` payer
/// 4. `[optional]` system_program (default to `11111111111111111111111111111111`)
/// 5. `[optional]` log_wrapper
#[derive(Default)]
pub struct CompressBuilder {
asset: Option<solana_program::pubkey::Pubkey>,
collection: Option<solana_program::pubkey::Pubkey>,
owner: Option<solana_program::pubkey::Pubkey>,
authority: Option<solana_program::pubkey::Pubkey>,
payer: Option<solana_program::pubkey::Pubkey>,
system_program: Option<solana_program::pubkey::Pubkey>,
log_wrapper: Option<solana_program::pubkey::Pubkey>,
Expand All @@ -135,8 +136,8 @@ impl CompressBuilder {
}
/// The owner or delegate of the asset
#[inline(always)]
pub fn owner(&mut self, owner: solana_program::pubkey::Pubkey) -> &mut Self {
self.owner = Some(owner);
pub fn authority(&mut self, authority: solana_program::pubkey::Pubkey) -> &mut Self {
self.authority = Some(authority);
self
}
/// `[optional account]`
Expand Down Expand Up @@ -186,7 +187,7 @@ impl CompressBuilder {
let accounts = Compress {
asset: self.asset.expect("asset is not set"),
collection: self.collection,
owner: self.owner.expect("owner is not set"),
authority: self.authority.expect("authority is not set"),
payer: self.payer,
system_program: self
.system_program
Expand All @@ -205,7 +206,7 @@ pub struct CompressCpiAccounts<'a, 'b> {
/// The collection to which the asset belongs
pub collection: Option<&'b solana_program::account_info::AccountInfo<'a>>,
/// The owner or delegate of the asset
pub owner: &'b solana_program::account_info::AccountInfo<'a>,
pub authority: &'b solana_program::account_info::AccountInfo<'a>,
/// The account receiving the storage fees
pub payer: Option<&'b solana_program::account_info::AccountInfo<'a>>,
/// The system program
Expand All @@ -223,7 +224,7 @@ pub struct CompressCpi<'a, 'b> {
/// The collection to which the asset belongs
pub collection: Option<&'b solana_program::account_info::AccountInfo<'a>>,
/// The owner or delegate of the asset
pub owner: &'b solana_program::account_info::AccountInfo<'a>,
pub authority: &'b solana_program::account_info::AccountInfo<'a>,
/// The account receiving the storage fees
pub payer: Option<&'b solana_program::account_info::AccountInfo<'a>>,
/// The system program
Expand All @@ -241,7 +242,7 @@ impl<'a, 'b> CompressCpi<'a, 'b> {
__program: program,
asset: accounts.asset,
collection: accounts.collection,
owner: accounts.owner,
authority: accounts.authority,
payer: accounts.payer,
system_program: accounts.system_program,
log_wrapper: accounts.log_wrapper,
Expand Down Expand Up @@ -297,7 +298,7 @@ impl<'a, 'b> CompressCpi<'a, 'b> {
));
}
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
*self.owner.key,
*self.authority.key,
true,
));
if let Some(payer) = self.payer {
Expand Down Expand Up @@ -345,7 +346,7 @@ impl<'a, 'b> CompressCpi<'a, 'b> {
if let Some(collection) = self.collection {
account_infos.push(collection.clone());
}
account_infos.push(self.owner.clone());
account_infos.push(self.authority.clone());
if let Some(payer) = self.payer {
account_infos.push(payer.clone());
}
Expand All @@ -371,7 +372,7 @@ impl<'a, 'b> CompressCpi<'a, 'b> {
///
/// 0. `[writable]` asset
/// 1. `[optional]` collection
/// 2. `[signer]` owner
/// 2. `[signer]` authority
/// 3. `[writable, signer, optional]` payer
/// 4. `[]` system_program
/// 5. `[optional]` log_wrapper
Expand All @@ -385,7 +386,7 @@ impl<'a, 'b> CompressCpiBuilder<'a, 'b> {
__program: program,
asset: None,
collection: None,
owner: None,
authority: None,
payer: None,
system_program: None,
log_wrapper: None,
Expand All @@ -411,8 +412,11 @@ impl<'a, 'b> CompressCpiBuilder<'a, 'b> {
}
/// The owner or delegate of the asset
#[inline(always)]
pub fn owner(&mut self, owner: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self {
self.instruction.owner = Some(owner);
pub fn authority(
&mut self,
authority: &'b solana_program::account_info::AccountInfo<'a>,
) -> &mut Self {
self.instruction.authority = Some(authority);
self
}
/// `[optional account]`
Expand Down Expand Up @@ -492,7 +496,7 @@ impl<'a, 'b> CompressCpiBuilder<'a, 'b> {

collection: self.instruction.collection,

owner: self.instruction.owner.expect("owner is not set"),
authority: self.instruction.authority.expect("authority is not set"),

payer: self.instruction.payer,

Expand All @@ -514,7 +518,7 @@ struct CompressCpiBuilderInstruction<'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>>,
owner: Option<&'b solana_program::account_info::AccountInfo<'a>>,
authority: Option<&'b solana_program::account_info::AccountInfo<'a>>,
payer: 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>>,
Expand Down
Loading

0 comments on commit e1b3a1a

Please sign in to comment.