Skip to content

Commit

Permalink
Merge pull request #16 from adm-metaex/feat/update-client
Browse files Browse the repository at this point in the history
[MTG-545] feat: update client
  • Loading branch information
RequescoS authored Aug 29, 2024
2 parents ec3dd4a + 702e5cd commit 2213f22
Show file tree
Hide file tree
Showing 11 changed files with 165 additions and 54 deletions.
13 changes: 13 additions & 0 deletions clients/js/src/generated/errors/mplBubblegum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -739,6 +739,19 @@ nameToErrorMap.set(
StakingVoterAuthorityMismatchError
);

/** MiningOwnerMismatch: Invalid mining owner */
export class MiningOwnerMismatchError extends ProgramError {
readonly name: string = 'MiningOwnerMismatch';

readonly code: number = 0x17a3; // 6051

constructor(program: Program, cause?: Error) {
super('Invalid mining owner', program, cause);
}
}
codeToErrorMap.set(0x17a3, MiningOwnerMismatchError);
nameToErrorMap.set('MiningOwnerMismatch', MiningOwnerMismatchError);

/**
* 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/addCanopy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import {
export type AddCanopyInstructionAccounts = {
treeConfig?: PublicKey | Pda;
merkleTree: PublicKey | Pda;
incomingTreeDelegate: Signer;
treeCreatorOrDelegate?: Signer;
logWrapper?: PublicKey | Pda;
compressionProgram?: PublicKey | Pda;
systemProgram?: PublicKey | Pda;
Expand Down Expand Up @@ -82,7 +82,7 @@ export type AddCanopyInstructionArgs = AddCanopyInstructionDataArgs;

// Instruction.
export function addCanopy(
context: Pick<Context, 'eddsa' | 'programs'>,
context: Pick<Context, 'eddsa' | 'identity' | 'programs'>,
input: AddCanopyInstructionAccounts & AddCanopyInstructionArgs
): TransactionBuilder {
// Program ID.
Expand All @@ -99,10 +99,10 @@ export function addCanopy(
value: input.treeConfig ?? null,
},
merkleTree: { index: 1, isWritable: true, value: input.merkleTree ?? null },
incomingTreeDelegate: {
treeCreatorOrDelegate: {
index: 2,
isWritable: false,
value: input.incomingTreeDelegate ?? null,
value: input.treeCreatorOrDelegate ?? null,
},
logWrapper: {
index: 3,
Expand Down Expand Up @@ -130,6 +130,9 @@ export function addCanopy(
merkleTree: expectPublicKey(resolvedAccounts.merkleTree.value),
});
}
if (!resolvedAccounts.treeCreatorOrDelegate.value) {
resolvedAccounts.treeCreatorOrDelegate.value = context.identity;
}
if (!resolvedAccounts.logWrapper.value) {
resolvedAccounts.logWrapper.value = context.programs.getPublicKey(
'splNoop',
Expand Down
10 changes: 6 additions & 4 deletions clients/js/src/generated/instructions/finalizeTreeWithRoot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export type FinalizeTreeWithRootInstructionAccounts = {
staker: Signer;
registrar: PublicKey | Pda;
voter: PublicKey | Pda;
mining: PublicKey | Pda;
feeReceiver: PublicKey | Pda;
logWrapper?: PublicKey | Pda;
compressionProgram?: PublicKey | Pda;
Expand Down Expand Up @@ -124,23 +125,24 @@ export function finalizeTreeWithRoot(
staker: { index: 4, isWritable: false, value: input.staker ?? null },
registrar: { index: 5, isWritable: false, value: input.registrar ?? null },
voter: { index: 6, isWritable: false, value: input.voter ?? null },
mining: { index: 7, isWritable: false, value: input.mining ?? null },
feeReceiver: {
index: 7,
index: 8,
isWritable: true,
value: input.feeReceiver ?? null,
},
logWrapper: {
index: 8,
index: 9,
isWritable: false,
value: input.logWrapper ?? null,
},
compressionProgram: {
index: 9,
index: 10,
isWritable: false,
value: input.compressionProgram ?? null,
},
systemProgram: {
index: 10,
index: 11,
isWritable: false,
value: input.systemProgram ?? null,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export type FinalizeTreeWithRootAndCollectionInstructionAccounts = {
collectionAuthority?: Signer;
registrar: PublicKey | Pda;
voter: PublicKey | Pda;
mining: PublicKey | Pda;
feeReceiver: PublicKey | Pda;
/**
* If there is no collecton authority record PDA then
Expand Down Expand Up @@ -143,43 +144,44 @@ export function finalizeTreeWithRootAndCollection(
},
registrar: { index: 6, isWritable: false, value: input.registrar ?? null },
voter: { index: 7, isWritable: false, value: input.voter ?? null },
mining: { index: 8, isWritable: false, value: input.mining ?? null },
feeReceiver: {
index: 8,
index: 9,
isWritable: true,
value: input.feeReceiver ?? null,
},
collectionAuthorityRecordPda: {
index: 9,
index: 10,
isWritable: false,
value: input.collectionAuthorityRecordPda ?? null,
},
collectionMint: {
index: 10,
index: 11,
isWritable: false,
value: input.collectionMint ?? null,
},
collectionMetadata: {
index: 11,
index: 12,
isWritable: true,
value: input.collectionMetadata ?? null,
},
collectionEdition: {
index: 12,
index: 13,
isWritable: false,
value: input.collectionEdition ?? null,
},
logWrapper: {
index: 13,
index: 14,
isWritable: false,
value: input.logWrapper ?? null,
},
compressionProgram: {
index: 14,
index: 15,
isWritable: false,
value: input.compressionProgram ?? null,
},
systemProgram: {
index: 15,
index: 16,
isWritable: false,
value: input.systemProgram ?? null,
},
Expand Down
17 changes: 10 additions & 7 deletions clients/rust/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion clients/rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ num-traits = "^0.2"
serde = { version = "^1.0", features = ["derive"], optional = true }
serde_with = { version = "^3.0", optional = true }
solana-program = "~1.18.11"
thiserror = "^1.0"
thiserror = "1.0.63"

[dev-dependencies]
assert_matches = "1.5.0"
Expand Down
3 changes: 3 additions & 0 deletions clients/rust/src/generated/errors/mpl_bubblegum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,9 @@ pub enum MplBubblegumError {
/// 6050 (0x17A2) - Staking voter authority mismatch
#[error("Staking voter authority mismatch")]
StakingVoterAuthorityMismatch,
/// 6051 (0x17A3) - Invalid mining owner
#[error("Invalid mining owner")]
MiningOwnerMismatch,
}

impl solana_program::program_error::PrintProgramError for MplBubblegumError {
Expand Down
44 changes: 22 additions & 22 deletions clients/rust/src/generated/instructions/add_canopy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pub struct AddCanopy {

pub merkle_tree: solana_program::pubkey::Pubkey,

pub incoming_tree_delegate: solana_program::pubkey::Pubkey,
pub tree_creator_or_delegate: solana_program::pubkey::Pubkey,

pub log_wrapper: solana_program::pubkey::Pubkey,

Expand Down Expand Up @@ -46,7 +46,7 @@ impl AddCanopy {
false,
));
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
self.incoming_tree_delegate,
self.tree_creator_or_delegate,
true,
));
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
Expand Down Expand Up @@ -99,7 +99,7 @@ pub struct AddCanopyInstructionArgs {
pub struct AddCanopyBuilder {
tree_config: Option<solana_program::pubkey::Pubkey>,
merkle_tree: Option<solana_program::pubkey::Pubkey>,
incoming_tree_delegate: Option<solana_program::pubkey::Pubkey>,
tree_creator_or_delegate: Option<solana_program::pubkey::Pubkey>,
log_wrapper: Option<solana_program::pubkey::Pubkey>,
compression_program: Option<solana_program::pubkey::Pubkey>,
system_program: Option<solana_program::pubkey::Pubkey>,
Expand All @@ -123,11 +123,11 @@ impl AddCanopyBuilder {
self
}
#[inline(always)]
pub fn incoming_tree_delegate(
pub fn tree_creator_or_delegate(
&mut self,
incoming_tree_delegate: solana_program::pubkey::Pubkey,
tree_creator_or_delegate: solana_program::pubkey::Pubkey,
) -> &mut Self {
self.incoming_tree_delegate = Some(incoming_tree_delegate);
self.tree_creator_or_delegate = Some(tree_creator_or_delegate);
self
}
/// `[optional account, default to 'noopb9bkMVfRPU8AsbpTUg8AQkHtKwMYZiFUjNRtMmV']`
Expand Down Expand Up @@ -184,9 +184,9 @@ impl AddCanopyBuilder {
let accounts = AddCanopy {
tree_config: self.tree_config.expect("tree_config is not set"),
merkle_tree: self.merkle_tree.expect("merkle_tree is not set"),
incoming_tree_delegate: self
.incoming_tree_delegate
.expect("incoming_tree_delegate is not set"),
tree_creator_or_delegate: self
.tree_creator_or_delegate
.expect("tree_creator_or_delegate is not set"),
log_wrapper: self.log_wrapper.unwrap_or(solana_program::pubkey!(
"noopb9bkMVfRPU8AsbpTUg8AQkHtKwMYZiFUjNRtMmV"
)),
Expand All @@ -212,7 +212,7 @@ pub struct AddCanopyCpiAccounts<'a, 'b> {

pub merkle_tree: &'b solana_program::account_info::AccountInfo<'a>,

pub incoming_tree_delegate: &'b solana_program::account_info::AccountInfo<'a>,
pub tree_creator_or_delegate: &'b solana_program::account_info::AccountInfo<'a>,

pub log_wrapper: &'b solana_program::account_info::AccountInfo<'a>,

Expand All @@ -230,7 +230,7 @@ pub struct AddCanopyCpi<'a, 'b> {

pub merkle_tree: &'b solana_program::account_info::AccountInfo<'a>,

pub incoming_tree_delegate: &'b solana_program::account_info::AccountInfo<'a>,
pub tree_creator_or_delegate: &'b solana_program::account_info::AccountInfo<'a>,

pub log_wrapper: &'b solana_program::account_info::AccountInfo<'a>,

Expand All @@ -251,7 +251,7 @@ impl<'a, 'b> AddCanopyCpi<'a, 'b> {
__program: program,
tree_config: accounts.tree_config,
merkle_tree: accounts.merkle_tree,
incoming_tree_delegate: accounts.incoming_tree_delegate,
tree_creator_or_delegate: accounts.tree_creator_or_delegate,
log_wrapper: accounts.log_wrapper,
compression_program: accounts.compression_program,
system_program: accounts.system_program,
Expand Down Expand Up @@ -301,7 +301,7 @@ impl<'a, 'b> AddCanopyCpi<'a, 'b> {
false,
));
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
*self.incoming_tree_delegate.key,
*self.tree_creator_or_delegate.key,
true,
));
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
Expand Down Expand Up @@ -336,7 +336,7 @@ impl<'a, 'b> AddCanopyCpi<'a, 'b> {
account_infos.push(self.__program.clone());
account_infos.push(self.tree_config.clone());
account_infos.push(self.merkle_tree.clone());
account_infos.push(self.incoming_tree_delegate.clone());
account_infos.push(self.tree_creator_or_delegate.clone());
account_infos.push(self.log_wrapper.clone());
account_infos.push(self.compression_program.clone());
account_infos.push(self.system_program.clone());
Expand All @@ -363,7 +363,7 @@ impl<'a, 'b> AddCanopyCpiBuilder<'a, 'b> {
__program: program,
tree_config: None,
merkle_tree: None,
incoming_tree_delegate: None,
tree_creator_or_delegate: None,
log_wrapper: None,
compression_program: None,
system_program: None,
Expand All @@ -390,11 +390,11 @@ impl<'a, 'b> AddCanopyCpiBuilder<'a, 'b> {
self
}
#[inline(always)]
pub fn incoming_tree_delegate(
pub fn tree_creator_or_delegate(
&mut self,
incoming_tree_delegate: &'b solana_program::account_info::AccountInfo<'a>,
tree_creator_or_delegate: &'b solana_program::account_info::AccountInfo<'a>,
) -> &mut Self {
self.instruction.incoming_tree_delegate = Some(incoming_tree_delegate);
self.instruction.tree_creator_or_delegate = Some(tree_creator_or_delegate);
self
}
#[inline(always)]
Expand Down Expand Up @@ -497,10 +497,10 @@ impl<'a, 'b> AddCanopyCpiBuilder<'a, 'b> {
.merkle_tree
.expect("merkle_tree is not set"),

incoming_tree_delegate: self
tree_creator_or_delegate: self
.instruction
.incoming_tree_delegate
.expect("incoming_tree_delegate is not set"),
.tree_creator_or_delegate
.expect("tree_creator_or_delegate is not set"),

log_wrapper: self
.instruction
Expand Down Expand Up @@ -529,7 +529,7 @@ struct AddCanopyCpiBuilderInstruction<'a, 'b> {
__program: &'b solana_program::account_info::AccountInfo<'a>,
tree_config: Option<&'b solana_program::account_info::AccountInfo<'a>>,
merkle_tree: Option<&'b solana_program::account_info::AccountInfo<'a>>,
incoming_tree_delegate: Option<&'b solana_program::account_info::AccountInfo<'a>>,
tree_creator_or_delegate: Option<&'b solana_program::account_info::AccountInfo<'a>>,
log_wrapper: Option<&'b solana_program::account_info::AccountInfo<'a>>,
compression_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
system_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
Expand Down
Loading

0 comments on commit 2213f22

Please sign in to comment.