diff --git a/Cargo.lock b/Cargo.lock index ea81f17..1db387c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2563,6 +2563,7 @@ dependencies = [ "jito-vault-core", "jito-vault-program", "jito-vault-sdk", + "jito-weight-table-client", "log", "shank", "solana-program", @@ -2644,6 +2645,22 @@ dependencies = [ "thiserror", ] +[[package]] +name = "jito-weight-table-client" +version = "0.0.1" +dependencies = [ + "anchor-lang", + "borsh 0.10.4", + "bytemuck", + "num-derive 0.4.2", + "num-traits", + "serde", + "serde_with 3.11.0", + "solana-program", + "solana-sdk", + "thiserror", +] + [[package]] name = "jito-weight-table-core" version = "0.0.1" diff --git a/Cargo.toml b/Cargo.toml index 9562616..07ae9af 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,15 +1,15 @@ [workspace] members = [ "cli", + "integration_tests", + "clients/rust/weight_table_client", "reward_core", "reward_program", "reward_sdk", + "shank_cli", "weight_table_core", "weight_table_program", - "weight_table_sdk", - "shank_cli", - "integration_tests" -] + "weight_table_sdk"] resolver = "2" @@ -67,10 +67,10 @@ spl-token = { version = "4.0.0", features = ["no-entrypoint"] } syn = "2.0.72" thiserror = "1.0.57" tokio = { version = "1.36.0", features = ["full"] } -jito-weight-table-core = { path = "./weight_table_core", version="0.0.1"} -jito-weight-table-program = { path = "./weight_table_program", version="0.0.1"} -jito-weight-table-sdk = { path = "./weight_table_sdk", version="0.0.1"} -jito-weight-table-client = { path = "./clients/rust/weight_table_client", version="0.0.1"} +jito-weight-table-core = { path = "./weight_table_core", version = "0.0.1" } +jito-weight-table-program = { path = "./weight_table_program", version = "0.0.1" } +jito-weight-table-sdk = { path = "./weight_table_sdk", version = "0.0.1" } +jito-weight-table-client = { path = "./clients/rust/weight_table_client", version = "0.0.1" } jito-reward-core = { path = "./reward_core", version = "=0.0.1" } jito-reward-program = { path = "./reward_program", version = "=0.0.1" } jito-reward-sdk = { path = "./reward_sdk", version = "=0.0.1" } diff --git a/clients/rust/weight_table_client/Cargo.toml b/clients/rust/weight_table_client/Cargo.toml index e69de29..24060a5 100644 --- a/clients/rust/weight_table_client/Cargo.toml +++ b/clients/rust/weight_table_client/Cargo.toml @@ -0,0 +1,27 @@ +[package] +name = "jito-weight-table-client" +description = "Jito Weight Table Client" +version = { workspace = true } +authors = { workspace = true } +repository = { workspace = true } +homepage = { workspace = true } +license = { workspace = true } +edition = { workspace = true } +readme = { workspace = true } + +[features] +serde = [] +anchor = [] +anchor-idl-build = [] + +[dependencies] +anchor-lang = { workspace = true } +borsh = { workspace = true } +bytemuck = { workspace = true } +num-derive = { workspace = true } +num-traits = { workspace = true } +serde = { workspace = true } +serde_with = { workspace = true } +solana-program = { workspace = true } +solana-sdk = { workspace = true } +thiserror = { workspace = true } diff --git a/clients/rust/weight_table_client/src/generated/accounts/mod.rs b/clients/rust/weight_table_client/src/generated/accounts/mod.rs index a4ff2d4..cbf30af 100644 --- a/clients/rust/weight_table_client/src/generated/accounts/mod.rs +++ b/clients/rust/weight_table_client/src/generated/accounts/mod.rs @@ -3,9 +3,7 @@ //! to add features, then rerun kinobi to update it. //! //! -//! - - pub(crate) mod r#weight_table; - pub use self::r#weight_table::*; +pub(crate) mod r#weight_table; +pub use self::r#weight_table::*; diff --git a/clients/rust/weight_table_client/src/generated/accounts/weight_table.rs b/clients/rust/weight_table_client/src/generated/accounts/weight_table.rs index 18a5eb3..dbe6c9d 100644 --- a/clients/rust/weight_table_client/src/generated/accounts/weight_table.rs +++ b/clients/rust/weight_table_client/src/generated/accounts/weight_table.rs @@ -3,54 +3,53 @@ //! to add features, then rerun kinobi to update it. //! //! -//! +use borsh::{BorshDeserialize, BorshSerialize}; use solana_program::pubkey::Pubkey; -use crate::generated::types::WeightEntry; -use borsh::BorshSerialize; -use borsh::BorshDeserialize; +use crate::generated::types::WeightEntry; #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct WeightTable { -pub discriminator: u64, -#[cfg_attr(feature = "serde", serde(with = "serde_with::As::"))] -pub ncn: Pubkey, -pub ncn_epoch: u64, -pub slot_created: u64, -pub slot_finalized: u64, -pub bump: u8, -#[cfg_attr(feature = "serde", serde(with = "serde_with::As::"))] -pub reserved: [u8; 128], -pub table: [WeightEntry; 32], + pub discriminator: u64, + #[cfg_attr( + feature = "serde", + serde(with = "serde_with::As::") + )] + pub ncn: Pubkey, + pub ncn_epoch: u64, + pub slot_created: u64, + pub slot_finalized: u64, + pub bump: u8, + #[cfg_attr(feature = "serde", serde(with = "serde_with::As::"))] + pub reserved: [u8; 128], + pub table: [WeightEntry; 32], } - impl WeightTable { - - - - #[inline(always)] - pub fn from_bytes(data: &[u8]) -> Result { - let mut data = data; - Self::deserialize(&mut data) - } + #[inline(always)] + pub fn from_bytes(data: &[u8]) -> Result { + let mut data = data; + Self::deserialize(&mut data) + } } impl<'a> TryFrom<&solana_program::account_info::AccountInfo<'a>> for WeightTable { - type Error = std::io::Error; + type Error = std::io::Error; - fn try_from(account_info: &solana_program::account_info::AccountInfo<'a>) -> Result { - let mut data: &[u8] = &(*account_info.data).borrow(); - Self::deserialize(&mut data) - } + fn try_from( + account_info: &solana_program::account_info::AccountInfo<'a>, + ) -> Result { + let mut data: &[u8] = &(*account_info.data).borrow(); + Self::deserialize(&mut data) + } } #[cfg(feature = "anchor")] impl anchor_lang::AccountDeserialize for WeightTable { fn try_deserialize_unchecked(buf: &mut &[u8]) -> anchor_lang::Result { - Ok(Self::deserialize(buf)?) + Ok(Self::deserialize(buf)?) } } @@ -60,16 +59,14 @@ impl anchor_lang::AccountSerialize for WeightTable {} #[cfg(feature = "anchor")] impl anchor_lang::Owner for WeightTable { fn owner() -> Pubkey { - crate::JITO_WEIGHT_TABLE_ID + crate::JITO_WEIGHT_TABLE_ID } } #[cfg(feature = "anchor-idl-build")] impl anchor_lang::IdlBuild for WeightTable {} - #[cfg(feature = "anchor-idl-build")] impl anchor_lang::Discriminator for WeightTable { - const DISCRIMINATOR: [u8; 8] = [0; 8]; + const DISCRIMINATOR: [u8; 8] = [0; 8]; } - diff --git a/clients/rust/weight_table_client/src/generated/errors/jito_weight_table.rs b/clients/rust/weight_table_client/src/generated/errors/jito_weight_table.rs index bf6530c..f3368d3 100644 --- a/clients/rust/weight_table_client/src/generated/errors/jito_weight_table.rs +++ b/clients/rust/weight_table_client/src/generated/errors/jito_weight_table.rs @@ -3,7 +3,6 @@ //! to add features, then rerun kinobi to update it. //! //! -//! use num_derive::FromPrimitive; use thiserror::Error; @@ -35,4 +34,3 @@ impl solana_program::program_error::PrintProgramError for JitoWeightTableError { solana_program::msg!(&self.to_string()); } } - diff --git a/clients/rust/weight_table_client/src/generated/errors/mod.rs b/clients/rust/weight_table_client/src/generated/errors/mod.rs index f0c0db3..b362769 100644 --- a/clients/rust/weight_table_client/src/generated/errors/mod.rs +++ b/clients/rust/weight_table_client/src/generated/errors/mod.rs @@ -3,9 +3,7 @@ //! to add features, then rerun kinobi to update it. //! //! -//! - pub(crate) mod jito_weight_table; - - pub use self::jito_weight_table::JitoWeightTableError; - +pub(crate) mod jito_weight_table; + +pub use self::jito_weight_table::JitoWeightTableError; diff --git a/clients/rust/weight_table_client/src/generated/instructions/finalize_weight_table.rs b/clients/rust/weight_table_client/src/generated/instructions/finalize_weight_table.rs index 06b1577..adc9e71 100644 --- a/clients/rust/weight_table_client/src/generated/instructions/finalize_weight_table.rs +++ b/clients/rust/weight_table_client/src/generated/instructions/finalize_weight_table.rs @@ -3,384 +3,454 @@ //! to add features, then rerun kinobi to update it. //! //! -//! -use borsh::BorshDeserialize; -use borsh::BorshSerialize; +use borsh::{BorshDeserialize, BorshSerialize}; /// Accounts. pub struct FinalizeWeightTable { - - - pub ncn: solana_program::pubkey::Pubkey, - - - pub weight_table: solana_program::pubkey::Pubkey, - - - pub weight_table_admin: solana_program::pubkey::Pubkey, - - - pub restaking_program_id: solana_program::pubkey::Pubkey, - } + pub ncn: solana_program::pubkey::Pubkey, + + pub weight_table: solana_program::pubkey::Pubkey, + + pub weight_table_admin: solana_program::pubkey::Pubkey, + + pub restaking_program_id: solana_program::pubkey::Pubkey, +} impl FinalizeWeightTable { - pub fn instruction(&self, args: FinalizeWeightTableInstructionArgs) -> solana_program::instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts(&self, args: FinalizeWeightTableInstructionArgs, remaining_accounts: &[solana_program::instruction::AccountMeta]) -> solana_program::instruction::Instruction { - let mut accounts = Vec::with_capacity(4 + remaining_accounts.len()); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( - self.ncn, - false - )); - accounts.push(solana_program::instruction::AccountMeta::new( + pub fn instruction( + &self, + args: FinalizeWeightTableInstructionArgs, + ) -> solana_program::instruction::Instruction { + self.instruction_with_remaining_accounts(args, &[]) + } + #[allow(clippy::vec_init_then_push)] + pub fn instruction_with_remaining_accounts( + &self, + args: FinalizeWeightTableInstructionArgs, + remaining_accounts: &[solana_program::instruction::AccountMeta], + ) -> solana_program::instruction::Instruction { + let mut accounts = Vec::with_capacity(4 + remaining_accounts.len()); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( + self.ncn, false, + )); + accounts.push(solana_program::instruction::AccountMeta::new( self.weight_table, - false - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( self.weight_table_admin, - true - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + true, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( self.restaking_program_id, - false - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = FinalizeWeightTableInstructionData::new().try_to_vec().unwrap(); - let mut args = args.try_to_vec().unwrap(); - data.append(&mut args); - - solana_program::instruction::Instruction { - program_id: crate::JITO_WEIGHT_TABLE_ID, - accounts, - data, + false, + )); + accounts.extend_from_slice(remaining_accounts); + let mut data = FinalizeWeightTableInstructionData::new() + .try_to_vec() + .unwrap(); + let mut args = args.try_to_vec().unwrap(); + data.append(&mut args); + + solana_program::instruction::Instruction { + program_id: crate::JITO_WEIGHT_TABLE_ID, + accounts, + data, + } } - } } #[derive(BorshDeserialize, BorshSerialize)] pub struct FinalizeWeightTableInstructionData { - discriminator: u8, - } + discriminator: u8, +} impl FinalizeWeightTableInstructionData { - pub fn new() -> Self { - Self { - discriminator: 2, - } - } + pub fn new() -> Self { + Self { discriminator: 2 } + } } impl Default for FinalizeWeightTableInstructionData { - fn default() -> Self { - Self::new() - } + fn default() -> Self { + Self::new() + } } #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct FinalizeWeightTableInstructionArgs { - pub ncn_epoch: u64, - } - + pub ncn_epoch: u64, +} /// Instruction builder for `FinalizeWeightTable`. /// /// ### Accounts: /// - /// 0. `[]` ncn - /// 1. `[writable]` weight_table - /// 2. `[signer]` weight_table_admin - /// 3. `[]` restaking_program_id +/// 0. `[]` ncn +/// 1. `[writable]` weight_table +/// 2. `[signer]` weight_table_admin +/// 3. `[]` restaking_program_id #[derive(Clone, Debug, Default)] pub struct FinalizeWeightTableBuilder { - ncn: Option, - weight_table: Option, - weight_table_admin: Option, - restaking_program_id: Option, - ncn_epoch: Option, - __remaining_accounts: Vec, + ncn: Option, + weight_table: Option, + weight_table_admin: Option, + restaking_program_id: Option, + ncn_epoch: Option, + __remaining_accounts: Vec, } impl FinalizeWeightTableBuilder { - pub fn new() -> Self { - Self::default() - } - #[inline(always)] + pub fn new() -> Self { + Self::default() + } + #[inline(always)] pub fn ncn(&mut self, ncn: solana_program::pubkey::Pubkey) -> &mut Self { - self.ncn = Some(ncn); - self + self.ncn = Some(ncn); + self } - #[inline(always)] + #[inline(always)] pub fn weight_table(&mut self, weight_table: solana_program::pubkey::Pubkey) -> &mut Self { - self.weight_table = Some(weight_table); - self + self.weight_table = Some(weight_table); + self } - #[inline(always)] - pub fn weight_table_admin(&mut self, weight_table_admin: solana_program::pubkey::Pubkey) -> &mut Self { - self.weight_table_admin = Some(weight_table_admin); - self + #[inline(always)] + pub fn weight_table_admin( + &mut self, + weight_table_admin: solana_program::pubkey::Pubkey, + ) -> &mut Self { + self.weight_table_admin = Some(weight_table_admin); + self } - #[inline(always)] - pub fn restaking_program_id(&mut self, restaking_program_id: solana_program::pubkey::Pubkey) -> &mut Self { - self.restaking_program_id = Some(restaking_program_id); - self + #[inline(always)] + pub fn restaking_program_id( + &mut self, + restaking_program_id: solana_program::pubkey::Pubkey, + ) -> &mut Self { + self.restaking_program_id = Some(restaking_program_id); + self } - #[inline(always)] - pub fn ncn_epoch(&mut self, ncn_epoch: u64) -> &mut Self { + #[inline(always)] + pub fn ncn_epoch(&mut self, ncn_epoch: u64) -> &mut Self { self.ncn_epoch = Some(ncn_epoch); self - } - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_program::instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts(&mut self, accounts: &[solana_program::instruction::AccountMeta]) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_program::instruction::Instruction { - let accounts = FinalizeWeightTable { - ncn: self.ncn.expect("ncn is not set"), - weight_table: self.weight_table.expect("weight_table is not set"), - weight_table_admin: self.weight_table_admin.expect("weight_table_admin is not set"), - restaking_program_id: self.restaking_program_id.expect("restaking_program_id is not set"), - }; - let args = FinalizeWeightTableInstructionArgs { - ncn_epoch: self.ncn_epoch.clone().expect("ncn_epoch is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } + } + /// Add an additional account to the instruction. + #[inline(always)] + pub fn add_remaining_account( + &mut self, + account: solana_program::instruction::AccountMeta, + ) -> &mut Self { + self.__remaining_accounts.push(account); + self + } + /// Add additional accounts to the instruction. + #[inline(always)] + pub fn add_remaining_accounts( + &mut self, + accounts: &[solana_program::instruction::AccountMeta], + ) -> &mut Self { + self.__remaining_accounts.extend_from_slice(accounts); + self + } + #[allow(clippy::clone_on_copy)] + pub fn instruction(&self) -> solana_program::instruction::Instruction { + let accounts = FinalizeWeightTable { + ncn: self.ncn.expect("ncn is not set"), + weight_table: self.weight_table.expect("weight_table is not set"), + weight_table_admin: self + .weight_table_admin + .expect("weight_table_admin is not set"), + restaking_program_id: self + .restaking_program_id + .expect("restaking_program_id is not set"), + }; + let args = FinalizeWeightTableInstructionArgs { + ncn_epoch: self.ncn_epoch.clone().expect("ncn_epoch is not set"), + }; + + accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) + } } - /// `finalize_weight_table` CPI accounts. - pub struct FinalizeWeightTableCpiAccounts<'a, 'b> { - - - pub ncn: &'b solana_program::account_info::AccountInfo<'a>, - - - pub weight_table: &'b solana_program::account_info::AccountInfo<'a>, - - - pub weight_table_admin: &'b solana_program::account_info::AccountInfo<'a>, - - - pub restaking_program_id: &'b solana_program::account_info::AccountInfo<'a>, - } +/// `finalize_weight_table` CPI accounts. +pub struct FinalizeWeightTableCpiAccounts<'a, 'b> { + pub ncn: &'b solana_program::account_info::AccountInfo<'a>, + + pub weight_table: &'b solana_program::account_info::AccountInfo<'a>, + + pub weight_table_admin: &'b solana_program::account_info::AccountInfo<'a>, + + pub restaking_program_id: &'b solana_program::account_info::AccountInfo<'a>, +} /// `finalize_weight_table` CPI instruction. pub struct FinalizeWeightTableCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_program::account_info::AccountInfo<'a>, - - - pub ncn: &'b solana_program::account_info::AccountInfo<'a>, - - - pub weight_table: &'b solana_program::account_info::AccountInfo<'a>, - - - pub weight_table_admin: &'b solana_program::account_info::AccountInfo<'a>, - - - pub restaking_program_id: &'b solana_program::account_info::AccountInfo<'a>, - /// The arguments for the instruction. + /// The program to invoke. + pub __program: &'b solana_program::account_info::AccountInfo<'a>, + + pub ncn: &'b solana_program::account_info::AccountInfo<'a>, + + pub weight_table: &'b solana_program::account_info::AccountInfo<'a>, + + pub weight_table_admin: &'b solana_program::account_info::AccountInfo<'a>, + + pub restaking_program_id: &'b solana_program::account_info::AccountInfo<'a>, + /// The arguments for the instruction. pub __args: FinalizeWeightTableInstructionArgs, - } +} impl<'a, 'b> FinalizeWeightTableCpi<'a, 'b> { - pub fn new( - program: &'b solana_program::account_info::AccountInfo<'a>, - accounts: FinalizeWeightTableCpiAccounts<'a, 'b>, - args: FinalizeWeightTableInstructionArgs, - ) -> Self { - Self { - __program: program, - ncn: accounts.ncn, - weight_table: accounts.weight_table, - weight_table_admin: accounts.weight_table_admin, - restaking_program_id: accounts.restaking_program_id, - __args: args, - } - } - #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - #[inline(always)] - pub fn invoke_with_remaining_accounts(&self, remaining_accounts: &[(&'b solana_program::account_info::AccountInfo<'a>, bool, bool)]) -> solana_program::entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - #[inline(always)] - pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program::entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_program::account_info::AccountInfo<'a>, bool, bool)] - ) -> solana_program::entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(4 + remaining_accounts.len()); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + pub fn new( + program: &'b solana_program::account_info::AccountInfo<'a>, + accounts: FinalizeWeightTableCpiAccounts<'a, 'b>, + args: FinalizeWeightTableInstructionArgs, + ) -> Self { + Self { + __program: program, + ncn: accounts.ncn, + weight_table: accounts.weight_table, + weight_table_admin: accounts.weight_table_admin, + restaking_program_id: accounts.restaking_program_id, + __args: args, + } + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(&[], &[]) + } + #[inline(always)] + pub fn invoke_with_remaining_accounts( + &self, + remaining_accounts: &[( + &'b solana_program::account_info::AccountInfo<'a>, + bool, + bool, + )], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) + } + #[inline(always)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) + } + #[allow(clippy::clone_on_copy)] + #[allow(clippy::vec_init_then_push)] + pub fn invoke_signed_with_remaining_accounts( + &self, + signers_seeds: &[&[&[u8]]], + remaining_accounts: &[( + &'b solana_program::account_info::AccountInfo<'a>, + bool, + bool, + )], + ) -> solana_program::entrypoint::ProgramResult { + let mut accounts = Vec::with_capacity(4 + remaining_accounts.len()); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( *self.ncn.key, - false - )); - accounts.push(solana_program::instruction::AccountMeta::new( + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new( *self.weight_table.key, - false - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( *self.weight_table_admin.key, - true - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + true, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( *self.restaking_program_id.key, - false - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_program::instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = FinalizeWeightTableInstructionData::new().try_to_vec().unwrap(); - let mut args = self.__args.try_to_vec().unwrap(); - data.append(&mut args); - - let instruction = solana_program::instruction::Instruction { - program_id: crate::JITO_WEIGHT_TABLE_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(4 + 1 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.ncn.clone()); - account_infos.push(self.weight_table.clone()); - account_infos.push(self.weight_table_admin.clone()); - account_infos.push(self.restaking_program_id.clone()); - remaining_accounts.iter().for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_program::program::invoke(&instruction, &account_infos) - } else { - solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds) + false, + )); + remaining_accounts.iter().for_each(|remaining_account| { + accounts.push(solana_program::instruction::AccountMeta { + pubkey: *remaining_account.0.key, + is_signer: remaining_account.1, + is_writable: remaining_account.2, + }) + }); + let mut data = FinalizeWeightTableInstructionData::new() + .try_to_vec() + .unwrap(); + let mut args = self.__args.try_to_vec().unwrap(); + data.append(&mut args); + + let instruction = solana_program::instruction::Instruction { + program_id: crate::JITO_WEIGHT_TABLE_ID, + accounts, + data, + }; + let mut account_infos = Vec::with_capacity(4 + 1 + remaining_accounts.len()); + account_infos.push(self.__program.clone()); + account_infos.push(self.ncn.clone()); + account_infos.push(self.weight_table.clone()); + account_infos.push(self.weight_table_admin.clone()); + account_infos.push(self.restaking_program_id.clone()); + remaining_accounts + .iter() + .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); + + if signers_seeds.is_empty() { + solana_program::program::invoke(&instruction, &account_infos) + } else { + solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds) + } } - } } /// Instruction builder for `FinalizeWeightTable` via CPI. /// /// ### Accounts: /// - /// 0. `[]` ncn - /// 1. `[writable]` weight_table - /// 2. `[signer]` weight_table_admin - /// 3. `[]` restaking_program_id +/// 0. `[]` ncn +/// 1. `[writable]` weight_table +/// 2. `[signer]` weight_table_admin +/// 3. `[]` restaking_program_id #[derive(Clone, Debug)] pub struct FinalizeWeightTableCpiBuilder<'a, 'b> { - instruction: Box>, + instruction: Box>, } impl<'a, 'b> FinalizeWeightTableCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(FinalizeWeightTableCpiBuilderInstruction { - __program: program, - ncn: None, - weight_table: None, - weight_table_admin: None, - restaking_program_id: None, - ncn_epoch: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - #[inline(always)] + pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { + let instruction = Box::new(FinalizeWeightTableCpiBuilderInstruction { + __program: program, + ncn: None, + weight_table: None, + weight_table_admin: None, + restaking_program_id: None, + ncn_epoch: None, + __remaining_accounts: Vec::new(), + }); + Self { instruction } + } + #[inline(always)] pub fn ncn(&mut self, ncn: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.ncn = Some(ncn); - self + self.instruction.ncn = Some(ncn); + self } - #[inline(always)] - pub fn weight_table(&mut self, weight_table: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.weight_table = Some(weight_table); - self + #[inline(always)] + pub fn weight_table( + &mut self, + weight_table: &'b solana_program::account_info::AccountInfo<'a>, + ) -> &mut Self { + self.instruction.weight_table = Some(weight_table); + self } - #[inline(always)] - pub fn weight_table_admin(&mut self, weight_table_admin: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.weight_table_admin = Some(weight_table_admin); - self + #[inline(always)] + pub fn weight_table_admin( + &mut self, + weight_table_admin: &'b solana_program::account_info::AccountInfo<'a>, + ) -> &mut Self { + self.instruction.weight_table_admin = Some(weight_table_admin); + self } - #[inline(always)] - pub fn restaking_program_id(&mut self, restaking_program_id: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.restaking_program_id = Some(restaking_program_id); - self + #[inline(always)] + pub fn restaking_program_id( + &mut self, + restaking_program_id: &'b solana_program::account_info::AccountInfo<'a>, + ) -> &mut Self { + self.instruction.restaking_program_id = Some(restaking_program_id); + self } - #[inline(always)] - pub fn ncn_epoch(&mut self, ncn_epoch: u64) -> &mut Self { + #[inline(always)] + pub fn ncn_epoch(&mut self, ncn_epoch: u64) -> &mut Self { self.instruction.ncn_epoch = Some(ncn_epoch); self - } - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: &'b solana_program::account_info::AccountInfo<'a>, is_writable: bool, is_signer: bool) -> &mut Self { - self.instruction.__remaining_accounts.push((account, is_writable, is_signer)); - self - } - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts(&mut self, accounts: &[(&'b solana_program::account_info::AccountInfo<'a>, bool, bool)]) -> &mut Self { - self.instruction.__remaining_accounts.extend_from_slice(accounts); - self - } - #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { - self.invoke_signed(&[]) - } - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program::entrypoint::ProgramResult { - let args = FinalizeWeightTableInstructionArgs { - ncn_epoch: self.instruction.ncn_epoch.clone().expect("ncn_epoch is not set"), - }; + } + /// Add an additional account to the instruction. + #[inline(always)] + pub fn add_remaining_account( + &mut self, + account: &'b solana_program::account_info::AccountInfo<'a>, + is_writable: bool, + is_signer: bool, + ) -> &mut Self { + self.instruction + .__remaining_accounts + .push((account, is_writable, is_signer)); + self + } + /// Add additional accounts to the instruction. + /// + /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, + /// and a `bool` indicating whether the account is a signer or not. + #[inline(always)] + pub fn add_remaining_accounts( + &mut self, + accounts: &[( + &'b solana_program::account_info::AccountInfo<'a>, + bool, + bool, + )], + ) -> &mut Self { + self.instruction + .__remaining_accounts + .extend_from_slice(accounts); + self + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed(&[]) + } + #[allow(clippy::clone_on_copy)] + #[allow(clippy::vec_init_then_push)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + let args = FinalizeWeightTableInstructionArgs { + ncn_epoch: self + .instruction + .ncn_epoch + .clone() + .expect("ncn_epoch is not set"), + }; let instruction = FinalizeWeightTableCpi { - __program: self.instruction.__program, - - ncn: self.instruction.ncn.expect("ncn is not set"), - - weight_table: self.instruction.weight_table.expect("weight_table is not set"), - - weight_table_admin: self.instruction.weight_table_admin.expect("weight_table_admin is not set"), - - restaking_program_id: self.instruction.restaking_program_id.expect("restaking_program_id is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts(signers_seeds, &self.instruction.__remaining_accounts) - } + __program: self.instruction.__program, + + ncn: self.instruction.ncn.expect("ncn is not set"), + + weight_table: self + .instruction + .weight_table + .expect("weight_table is not set"), + + weight_table_admin: self + .instruction + .weight_table_admin + .expect("weight_table_admin is not set"), + + restaking_program_id: self + .instruction + .restaking_program_id + .expect("restaking_program_id is not set"), + __args: args, + }; + instruction.invoke_signed_with_remaining_accounts( + signers_seeds, + &self.instruction.__remaining_accounts, + ) + } } #[derive(Clone, Debug)] struct FinalizeWeightTableCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_program::account_info::AccountInfo<'a>, - ncn: Option<&'b solana_program::account_info::AccountInfo<'a>>, - weight_table: Option<&'b solana_program::account_info::AccountInfo<'a>>, - weight_table_admin: Option<&'b solana_program::account_info::AccountInfo<'a>>, - restaking_program_id: Option<&'b solana_program::account_info::AccountInfo<'a>>, - ncn_epoch: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_program::account_info::AccountInfo<'a>, bool, bool)>, + __program: &'b solana_program::account_info::AccountInfo<'a>, + ncn: Option<&'b solana_program::account_info::AccountInfo<'a>>, + weight_table: Option<&'b solana_program::account_info::AccountInfo<'a>>, + weight_table_admin: Option<&'b solana_program::account_info::AccountInfo<'a>>, + restaking_program_id: Option<&'b solana_program::account_info::AccountInfo<'a>>, + ncn_epoch: Option, + /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. + __remaining_accounts: Vec<( + &'b solana_program::account_info::AccountInfo<'a>, + bool, + bool, + )>, } - diff --git a/clients/rust/weight_table_client/src/generated/instructions/initialize_weight_table.rs b/clients/rust/weight_table_client/src/generated/instructions/initialize_weight_table.rs index 923b0e1..6d61c11 100644 --- a/clients/rust/weight_table_client/src/generated/instructions/initialize_weight_table.rs +++ b/clients/rust/weight_table_client/src/generated/instructions/initialize_weight_table.rs @@ -3,461 +3,538 @@ //! to add features, then rerun kinobi to update it. //! //! -//! -use borsh::BorshDeserialize; -use borsh::BorshSerialize; +use borsh::{BorshDeserialize, BorshSerialize}; /// Accounts. pub struct InitializeWeightTable { - - - pub restaking_config: solana_program::pubkey::Pubkey, - - - pub ncn: solana_program::pubkey::Pubkey, - - - pub weight_table: solana_program::pubkey::Pubkey, - - - pub weight_table_admin: solana_program::pubkey::Pubkey, - - - pub restaking_program_id: solana_program::pubkey::Pubkey, - - - pub system_program: solana_program::pubkey::Pubkey, - } + pub restaking_config: solana_program::pubkey::Pubkey, + + pub ncn: solana_program::pubkey::Pubkey, + + pub weight_table: solana_program::pubkey::Pubkey, + + pub weight_table_admin: solana_program::pubkey::Pubkey, + + pub restaking_program_id: solana_program::pubkey::Pubkey, + + pub system_program: solana_program::pubkey::Pubkey, +} impl InitializeWeightTable { - pub fn instruction(&self, args: InitializeWeightTableInstructionArgs) -> solana_program::instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts(&self, args: InitializeWeightTableInstructionArgs, remaining_accounts: &[solana_program::instruction::AccountMeta]) -> solana_program::instruction::Instruction { - let mut accounts = Vec::with_capacity(6 + remaining_accounts.len()); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + pub fn instruction( + &self, + args: InitializeWeightTableInstructionArgs, + ) -> solana_program::instruction::Instruction { + self.instruction_with_remaining_accounts(args, &[]) + } + #[allow(clippy::vec_init_then_push)] + pub fn instruction_with_remaining_accounts( + &self, + args: InitializeWeightTableInstructionArgs, + remaining_accounts: &[solana_program::instruction::AccountMeta], + ) -> solana_program::instruction::Instruction { + let mut accounts = Vec::with_capacity(6 + remaining_accounts.len()); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( self.restaking_config, - false - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( - self.ncn, - false - )); - accounts.push(solana_program::instruction::AccountMeta::new( + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( + self.ncn, false, + )); + accounts.push(solana_program::instruction::AccountMeta::new( self.weight_table, - true - )); - accounts.push(solana_program::instruction::AccountMeta::new( + true, + )); + accounts.push(solana_program::instruction::AccountMeta::new( self.weight_table_admin, - true - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + true, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( self.restaking_program_id, - false - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( self.system_program, - false - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = InitializeWeightTableInstructionData::new().try_to_vec().unwrap(); - let mut args = args.try_to_vec().unwrap(); - data.append(&mut args); - - solana_program::instruction::Instruction { - program_id: crate::JITO_WEIGHT_TABLE_ID, - accounts, - data, - } - } + false, + )); + accounts.extend_from_slice(remaining_accounts); + let mut data = InitializeWeightTableInstructionData::new() + .try_to_vec() + .unwrap(); + let mut args = args.try_to_vec().unwrap(); + data.append(&mut args); + + solana_program::instruction::Instruction { + program_id: crate::JITO_WEIGHT_TABLE_ID, + accounts, + data, + } + } } #[derive(BorshDeserialize, BorshSerialize)] pub struct InitializeWeightTableInstructionData { - discriminator: u8, - } + discriminator: u8, +} impl InitializeWeightTableInstructionData { - pub fn new() -> Self { - Self { - discriminator: 0, - } - } + pub fn new() -> Self { + Self { discriminator: 0 } + } } impl Default for InitializeWeightTableInstructionData { - fn default() -> Self { - Self::new() - } + fn default() -> Self { + Self::new() + } } #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct InitializeWeightTableInstructionArgs { - pub first_slot_of_ncn_epoch: Option, - } - + pub first_slot_of_ncn_epoch: Option, +} /// Instruction builder for `InitializeWeightTable`. /// /// ### Accounts: /// - /// 0. `[]` restaking_config - /// 1. `[]` ncn - /// 2. `[writable, signer]` weight_table - /// 3. `[writable, signer]` weight_table_admin - /// 4. `[]` restaking_program_id - /// 5. `[optional]` system_program (default to `11111111111111111111111111111111`) +/// 0. `[]` restaking_config +/// 1. `[]` ncn +/// 2. `[writable, signer]` weight_table +/// 3. `[writable, signer]` weight_table_admin +/// 4. `[]` restaking_program_id +/// 5. `[optional]` system_program (default to `11111111111111111111111111111111`) #[derive(Clone, Debug, Default)] pub struct InitializeWeightTableBuilder { - restaking_config: Option, - ncn: Option, - weight_table: Option, - weight_table_admin: Option, - restaking_program_id: Option, - system_program: Option, - first_slot_of_ncn_epoch: Option, - __remaining_accounts: Vec, + restaking_config: Option, + ncn: Option, + weight_table: Option, + weight_table_admin: Option, + restaking_program_id: Option, + system_program: Option, + first_slot_of_ncn_epoch: Option, + __remaining_accounts: Vec, } impl InitializeWeightTableBuilder { - pub fn new() -> Self { - Self::default() - } - #[inline(always)] - pub fn restaking_config(&mut self, restaking_config: solana_program::pubkey::Pubkey) -> &mut Self { - self.restaking_config = Some(restaking_config); - self - } - #[inline(always)] + pub fn new() -> Self { + Self::default() + } + #[inline(always)] + pub fn restaking_config( + &mut self, + restaking_config: solana_program::pubkey::Pubkey, + ) -> &mut Self { + self.restaking_config = Some(restaking_config); + self + } + #[inline(always)] pub fn ncn(&mut self, ncn: solana_program::pubkey::Pubkey) -> &mut Self { - self.ncn = Some(ncn); - self + self.ncn = Some(ncn); + self } - #[inline(always)] + #[inline(always)] pub fn weight_table(&mut self, weight_table: solana_program::pubkey::Pubkey) -> &mut Self { - self.weight_table = Some(weight_table); - self + self.weight_table = Some(weight_table); + self } - #[inline(always)] - pub fn weight_table_admin(&mut self, weight_table_admin: solana_program::pubkey::Pubkey) -> &mut Self { - self.weight_table_admin = Some(weight_table_admin); - self + #[inline(always)] + pub fn weight_table_admin( + &mut self, + weight_table_admin: solana_program::pubkey::Pubkey, + ) -> &mut Self { + self.weight_table_admin = Some(weight_table_admin); + self } - #[inline(always)] - pub fn restaking_program_id(&mut self, restaking_program_id: solana_program::pubkey::Pubkey) -> &mut Self { - self.restaking_program_id = Some(restaking_program_id); - self + #[inline(always)] + pub fn restaking_program_id( + &mut self, + restaking_program_id: solana_program::pubkey::Pubkey, + ) -> &mut Self { + self.restaking_program_id = Some(restaking_program_id); + self } - /// `[optional account, default to '11111111111111111111111111111111']` -#[inline(always)] + /// `[optional account, default to '11111111111111111111111111111111']` + #[inline(always)] pub fn system_program(&mut self, system_program: solana_program::pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self + self.system_program = Some(system_program); + self } - /// `[optional argument]` -#[inline(always)] - pub fn first_slot_of_ncn_epoch(&mut self, first_slot_of_ncn_epoch: u64) -> &mut Self { + /// `[optional argument]` + #[inline(always)] + pub fn first_slot_of_ncn_epoch(&mut self, first_slot_of_ncn_epoch: u64) -> &mut Self { self.first_slot_of_ncn_epoch = Some(first_slot_of_ncn_epoch); self - } - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_program::instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts(&mut self, accounts: &[solana_program::instruction::AccountMeta]) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_program::instruction::Instruction { - let accounts = InitializeWeightTable { - restaking_config: self.restaking_config.expect("restaking_config is not set"), - ncn: self.ncn.expect("ncn is not set"), - weight_table: self.weight_table.expect("weight_table is not set"), - weight_table_admin: self.weight_table_admin.expect("weight_table_admin is not set"), - restaking_program_id: self.restaking_program_id.expect("restaking_program_id is not set"), - system_program: self.system_program.unwrap_or(solana_program::pubkey!("11111111111111111111111111111111")), - }; - let args = InitializeWeightTableInstructionArgs { - first_slot_of_ncn_epoch: self.first_slot_of_ncn_epoch.clone(), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } + } + /// Add an additional account to the instruction. + #[inline(always)] + pub fn add_remaining_account( + &mut self, + account: solana_program::instruction::AccountMeta, + ) -> &mut Self { + self.__remaining_accounts.push(account); + self + } + /// Add additional accounts to the instruction. + #[inline(always)] + pub fn add_remaining_accounts( + &mut self, + accounts: &[solana_program::instruction::AccountMeta], + ) -> &mut Self { + self.__remaining_accounts.extend_from_slice(accounts); + self + } + #[allow(clippy::clone_on_copy)] + pub fn instruction(&self) -> solana_program::instruction::Instruction { + let accounts = InitializeWeightTable { + restaking_config: self.restaking_config.expect("restaking_config is not set"), + ncn: self.ncn.expect("ncn is not set"), + weight_table: self.weight_table.expect("weight_table is not set"), + weight_table_admin: self + .weight_table_admin + .expect("weight_table_admin is not set"), + restaking_program_id: self + .restaking_program_id + .expect("restaking_program_id is not set"), + system_program: self + .system_program + .unwrap_or(solana_program::pubkey!("11111111111111111111111111111111")), + }; + let args = InitializeWeightTableInstructionArgs { + first_slot_of_ncn_epoch: self.first_slot_of_ncn_epoch.clone(), + }; + + accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) + } } - /// `initialize_weight_table` CPI accounts. - pub struct InitializeWeightTableCpiAccounts<'a, 'b> { - - - pub restaking_config: &'b solana_program::account_info::AccountInfo<'a>, - - - pub ncn: &'b solana_program::account_info::AccountInfo<'a>, - - - pub weight_table: &'b solana_program::account_info::AccountInfo<'a>, - - - pub weight_table_admin: &'b solana_program::account_info::AccountInfo<'a>, - - - pub restaking_program_id: &'b solana_program::account_info::AccountInfo<'a>, - - - pub system_program: &'b solana_program::account_info::AccountInfo<'a>, - } +/// `initialize_weight_table` CPI accounts. +pub struct InitializeWeightTableCpiAccounts<'a, 'b> { + pub restaking_config: &'b solana_program::account_info::AccountInfo<'a>, + + pub ncn: &'b solana_program::account_info::AccountInfo<'a>, + + pub weight_table: &'b solana_program::account_info::AccountInfo<'a>, + + pub weight_table_admin: &'b solana_program::account_info::AccountInfo<'a>, + + pub restaking_program_id: &'b solana_program::account_info::AccountInfo<'a>, + + pub system_program: &'b solana_program::account_info::AccountInfo<'a>, +} /// `initialize_weight_table` CPI instruction. pub struct InitializeWeightTableCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_program::account_info::AccountInfo<'a>, - - - pub restaking_config: &'b solana_program::account_info::AccountInfo<'a>, - - - pub ncn: &'b solana_program::account_info::AccountInfo<'a>, - - - pub weight_table: &'b solana_program::account_info::AccountInfo<'a>, - - - pub weight_table_admin: &'b solana_program::account_info::AccountInfo<'a>, - - - pub restaking_program_id: &'b solana_program::account_info::AccountInfo<'a>, - - - pub system_program: &'b solana_program::account_info::AccountInfo<'a>, - /// The arguments for the instruction. + /// The program to invoke. + pub __program: &'b solana_program::account_info::AccountInfo<'a>, + + pub restaking_config: &'b solana_program::account_info::AccountInfo<'a>, + + pub ncn: &'b solana_program::account_info::AccountInfo<'a>, + + pub weight_table: &'b solana_program::account_info::AccountInfo<'a>, + + pub weight_table_admin: &'b solana_program::account_info::AccountInfo<'a>, + + pub restaking_program_id: &'b solana_program::account_info::AccountInfo<'a>, + + pub system_program: &'b solana_program::account_info::AccountInfo<'a>, + /// The arguments for the instruction. pub __args: InitializeWeightTableInstructionArgs, - } +} impl<'a, 'b> InitializeWeightTableCpi<'a, 'b> { - pub fn new( - program: &'b solana_program::account_info::AccountInfo<'a>, - accounts: InitializeWeightTableCpiAccounts<'a, 'b>, - args: InitializeWeightTableInstructionArgs, - ) -> Self { - Self { - __program: program, - restaking_config: accounts.restaking_config, - ncn: accounts.ncn, - weight_table: accounts.weight_table, - weight_table_admin: accounts.weight_table_admin, - restaking_program_id: accounts.restaking_program_id, - system_program: accounts.system_program, - __args: args, - } - } - #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - #[inline(always)] - pub fn invoke_with_remaining_accounts(&self, remaining_accounts: &[(&'b solana_program::account_info::AccountInfo<'a>, bool, bool)]) -> solana_program::entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - #[inline(always)] - pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program::entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_program::account_info::AccountInfo<'a>, bool, bool)] - ) -> solana_program::entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(6 + remaining_accounts.len()); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + pub fn new( + program: &'b solana_program::account_info::AccountInfo<'a>, + accounts: InitializeWeightTableCpiAccounts<'a, 'b>, + args: InitializeWeightTableInstructionArgs, + ) -> Self { + Self { + __program: program, + restaking_config: accounts.restaking_config, + ncn: accounts.ncn, + weight_table: accounts.weight_table, + weight_table_admin: accounts.weight_table_admin, + restaking_program_id: accounts.restaking_program_id, + system_program: accounts.system_program, + __args: args, + } + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(&[], &[]) + } + #[inline(always)] + pub fn invoke_with_remaining_accounts( + &self, + remaining_accounts: &[( + &'b solana_program::account_info::AccountInfo<'a>, + bool, + bool, + )], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) + } + #[inline(always)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) + } + #[allow(clippy::clone_on_copy)] + #[allow(clippy::vec_init_then_push)] + pub fn invoke_signed_with_remaining_accounts( + &self, + signers_seeds: &[&[&[u8]]], + remaining_accounts: &[( + &'b solana_program::account_info::AccountInfo<'a>, + bool, + bool, + )], + ) -> solana_program::entrypoint::ProgramResult { + let mut accounts = Vec::with_capacity(6 + remaining_accounts.len()); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( *self.restaking_config.key, - false - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( *self.ncn.key, - false - )); - accounts.push(solana_program::instruction::AccountMeta::new( + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new( *self.weight_table.key, - true - )); - accounts.push(solana_program::instruction::AccountMeta::new( + true, + )); + accounts.push(solana_program::instruction::AccountMeta::new( *self.weight_table_admin.key, - true - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + true, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( *self.restaking_program_id.key, - false - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( *self.system_program.key, - false - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_program::instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = InitializeWeightTableInstructionData::new().try_to_vec().unwrap(); - let mut args = self.__args.try_to_vec().unwrap(); - data.append(&mut args); - - let instruction = solana_program::instruction::Instruction { - program_id: crate::JITO_WEIGHT_TABLE_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(6 + 1 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.restaking_config.clone()); - account_infos.push(self.ncn.clone()); - account_infos.push(self.weight_table.clone()); - account_infos.push(self.weight_table_admin.clone()); - account_infos.push(self.restaking_program_id.clone()); - account_infos.push(self.system_program.clone()); - remaining_accounts.iter().for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_program::program::invoke(&instruction, &account_infos) - } else { - solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } + false, + )); + remaining_accounts.iter().for_each(|remaining_account| { + accounts.push(solana_program::instruction::AccountMeta { + pubkey: *remaining_account.0.key, + is_signer: remaining_account.1, + is_writable: remaining_account.2, + }) + }); + let mut data = InitializeWeightTableInstructionData::new() + .try_to_vec() + .unwrap(); + let mut args = self.__args.try_to_vec().unwrap(); + data.append(&mut args); + + let instruction = solana_program::instruction::Instruction { + program_id: crate::JITO_WEIGHT_TABLE_ID, + accounts, + data, + }; + let mut account_infos = Vec::with_capacity(6 + 1 + remaining_accounts.len()); + account_infos.push(self.__program.clone()); + account_infos.push(self.restaking_config.clone()); + account_infos.push(self.ncn.clone()); + account_infos.push(self.weight_table.clone()); + account_infos.push(self.weight_table_admin.clone()); + account_infos.push(self.restaking_program_id.clone()); + account_infos.push(self.system_program.clone()); + remaining_accounts + .iter() + .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); + + if signers_seeds.is_empty() { + solana_program::program::invoke(&instruction, &account_infos) + } else { + solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds) + } + } } /// Instruction builder for `InitializeWeightTable` via CPI. /// /// ### Accounts: /// - /// 0. `[]` restaking_config - /// 1. `[]` ncn - /// 2. `[writable, signer]` weight_table - /// 3. `[writable, signer]` weight_table_admin - /// 4. `[]` restaking_program_id - /// 5. `[]` system_program +/// 0. `[]` restaking_config +/// 1. `[]` ncn +/// 2. `[writable, signer]` weight_table +/// 3. `[writable, signer]` weight_table_admin +/// 4. `[]` restaking_program_id +/// 5. `[]` system_program #[derive(Clone, Debug)] pub struct InitializeWeightTableCpiBuilder<'a, 'b> { - instruction: Box>, + instruction: Box>, } impl<'a, 'b> InitializeWeightTableCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(InitializeWeightTableCpiBuilderInstruction { - __program: program, - restaking_config: None, - ncn: None, - weight_table: None, - weight_table_admin: None, - restaking_program_id: None, - system_program: None, - first_slot_of_ncn_epoch: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - #[inline(always)] - pub fn restaking_config(&mut self, restaking_config: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.restaking_config = Some(restaking_config); - self - } - #[inline(always)] + pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { + let instruction = Box::new(InitializeWeightTableCpiBuilderInstruction { + __program: program, + restaking_config: None, + ncn: None, + weight_table: None, + weight_table_admin: None, + restaking_program_id: None, + system_program: None, + first_slot_of_ncn_epoch: None, + __remaining_accounts: Vec::new(), + }); + Self { instruction } + } + #[inline(always)] + pub fn restaking_config( + &mut self, + restaking_config: &'b solana_program::account_info::AccountInfo<'a>, + ) -> &mut Self { + self.instruction.restaking_config = Some(restaking_config); + self + } + #[inline(always)] pub fn ncn(&mut self, ncn: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.ncn = Some(ncn); - self - } - #[inline(always)] - pub fn weight_table(&mut self, weight_table: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.weight_table = Some(weight_table); - self - } - #[inline(always)] - pub fn weight_table_admin(&mut self, weight_table_admin: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.weight_table_admin = Some(weight_table_admin); - self - } - #[inline(always)] - pub fn restaking_program_id(&mut self, restaking_program_id: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.restaking_program_id = Some(restaking_program_id); - self - } - #[inline(always)] - pub fn system_program(&mut self, system_program: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - /// `[optional argument]` -#[inline(always)] - pub fn first_slot_of_ncn_epoch(&mut self, first_slot_of_ncn_epoch: u64) -> &mut Self { + self.instruction.ncn = Some(ncn); + self + } + #[inline(always)] + pub fn weight_table( + &mut self, + weight_table: &'b solana_program::account_info::AccountInfo<'a>, + ) -> &mut Self { + self.instruction.weight_table = Some(weight_table); + self + } + #[inline(always)] + pub fn weight_table_admin( + &mut self, + weight_table_admin: &'b solana_program::account_info::AccountInfo<'a>, + ) -> &mut Self { + self.instruction.weight_table_admin = Some(weight_table_admin); + self + } + #[inline(always)] + pub fn restaking_program_id( + &mut self, + restaking_program_id: &'b solana_program::account_info::AccountInfo<'a>, + ) -> &mut Self { + self.instruction.restaking_program_id = Some(restaking_program_id); + self + } + #[inline(always)] + pub fn system_program( + &mut self, + system_program: &'b solana_program::account_info::AccountInfo<'a>, + ) -> &mut Self { + self.instruction.system_program = Some(system_program); + self + } + /// `[optional argument]` + #[inline(always)] + pub fn first_slot_of_ncn_epoch(&mut self, first_slot_of_ncn_epoch: u64) -> &mut Self { self.instruction.first_slot_of_ncn_epoch = Some(first_slot_of_ncn_epoch); self - } - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: &'b solana_program::account_info::AccountInfo<'a>, is_writable: bool, is_signer: bool) -> &mut Self { - self.instruction.__remaining_accounts.push((account, is_writable, is_signer)); - self - } - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts(&mut self, accounts: &[(&'b solana_program::account_info::AccountInfo<'a>, bool, bool)]) -> &mut Self { - self.instruction.__remaining_accounts.extend_from_slice(accounts); - self - } - #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { - self.invoke_signed(&[]) - } - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program::entrypoint::ProgramResult { - let args = InitializeWeightTableInstructionArgs { - first_slot_of_ncn_epoch: self.instruction.first_slot_of_ncn_epoch.clone(), - }; + } + /// Add an additional account to the instruction. + #[inline(always)] + pub fn add_remaining_account( + &mut self, + account: &'b solana_program::account_info::AccountInfo<'a>, + is_writable: bool, + is_signer: bool, + ) -> &mut Self { + self.instruction + .__remaining_accounts + .push((account, is_writable, is_signer)); + self + } + /// Add additional accounts to the instruction. + /// + /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, + /// and a `bool` indicating whether the account is a signer or not. + #[inline(always)] + pub fn add_remaining_accounts( + &mut self, + accounts: &[( + &'b solana_program::account_info::AccountInfo<'a>, + bool, + bool, + )], + ) -> &mut Self { + self.instruction + .__remaining_accounts + .extend_from_slice(accounts); + self + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed(&[]) + } + #[allow(clippy::clone_on_copy)] + #[allow(clippy::vec_init_then_push)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + let args = InitializeWeightTableInstructionArgs { + first_slot_of_ncn_epoch: self.instruction.first_slot_of_ncn_epoch.clone(), + }; let instruction = InitializeWeightTableCpi { - __program: self.instruction.__program, - - restaking_config: self.instruction.restaking_config.expect("restaking_config is not set"), - - ncn: self.instruction.ncn.expect("ncn is not set"), - - weight_table: self.instruction.weight_table.expect("weight_table is not set"), - - weight_table_admin: self.instruction.weight_table_admin.expect("weight_table_admin is not set"), - - restaking_program_id: self.instruction.restaking_program_id.expect("restaking_program_id is not set"), - - system_program: self.instruction.system_program.expect("system_program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts(signers_seeds, &self.instruction.__remaining_accounts) - } + __program: self.instruction.__program, + + restaking_config: self + .instruction + .restaking_config + .expect("restaking_config is not set"), + + ncn: self.instruction.ncn.expect("ncn is not set"), + + weight_table: self + .instruction + .weight_table + .expect("weight_table is not set"), + + weight_table_admin: self + .instruction + .weight_table_admin + .expect("weight_table_admin is not set"), + + restaking_program_id: self + .instruction + .restaking_program_id + .expect("restaking_program_id is not set"), + + system_program: self + .instruction + .system_program + .expect("system_program is not set"), + __args: args, + }; + instruction.invoke_signed_with_remaining_accounts( + signers_seeds, + &self.instruction.__remaining_accounts, + ) + } } #[derive(Clone, Debug)] struct InitializeWeightTableCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_program::account_info::AccountInfo<'a>, - restaking_config: Option<&'b solana_program::account_info::AccountInfo<'a>>, - ncn: Option<&'b solana_program::account_info::AccountInfo<'a>>, - weight_table: Option<&'b solana_program::account_info::AccountInfo<'a>>, - weight_table_admin: Option<&'b solana_program::account_info::AccountInfo<'a>>, - restaking_program_id: Option<&'b solana_program::account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_program::account_info::AccountInfo<'a>>, - first_slot_of_ncn_epoch: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_program::account_info::AccountInfo<'a>, bool, bool)>, + __program: &'b solana_program::account_info::AccountInfo<'a>, + restaking_config: Option<&'b solana_program::account_info::AccountInfo<'a>>, + ncn: Option<&'b solana_program::account_info::AccountInfo<'a>>, + weight_table: Option<&'b solana_program::account_info::AccountInfo<'a>>, + weight_table_admin: Option<&'b solana_program::account_info::AccountInfo<'a>>, + restaking_program_id: Option<&'b solana_program::account_info::AccountInfo<'a>>, + system_program: Option<&'b solana_program::account_info::AccountInfo<'a>>, + first_slot_of_ncn_epoch: Option, + /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. + __remaining_accounts: Vec<( + &'b solana_program::account_info::AccountInfo<'a>, + bool, + bool, + )>, } - diff --git a/clients/rust/weight_table_client/src/generated/instructions/mod.rs b/clients/rust/weight_table_client/src/generated/instructions/mod.rs index 28b5f22..db9b2e2 100644 --- a/clients/rust/weight_table_client/src/generated/instructions/mod.rs +++ b/clients/rust/weight_table_client/src/generated/instructions/mod.rs @@ -3,13 +3,11 @@ //! to add features, then rerun kinobi to update it. //! //! -//! - - pub(crate) mod r#finalize_weight_table; - pub(crate) mod r#initialize_weight_table; - pub(crate) mod r#update_weight_table; - pub use self::r#finalize_weight_table::*; - pub use self::r#initialize_weight_table::*; - pub use self::r#update_weight_table::*; +pub(crate) mod r#finalize_weight_table; +pub(crate) mod r#initialize_weight_table; +pub(crate) mod r#update_weight_table; +pub use self::{ + r#finalize_weight_table::*, r#initialize_weight_table::*, r#update_weight_table::*, +}; diff --git a/clients/rust/weight_table_client/src/generated/instructions/update_weight_table.rs b/clients/rust/weight_table_client/src/generated/instructions/update_weight_table.rs index e12aa44..d8e8030 100644 --- a/clients/rust/weight_table_client/src/generated/instructions/update_weight_table.rs +++ b/clients/rust/weight_table_client/src/generated/instructions/update_weight_table.rs @@ -3,416 +3,500 @@ //! to add features, then rerun kinobi to update it. //! //! -//! -use borsh::BorshDeserialize; -use borsh::BorshSerialize; +use borsh::{BorshDeserialize, BorshSerialize}; /// Accounts. pub struct UpdateWeightTable { - - - pub ncn: solana_program::pubkey::Pubkey, - - - pub weight_table: solana_program::pubkey::Pubkey, - - - pub weight_table_admin: solana_program::pubkey::Pubkey, - - - pub restaking_program_id: solana_program::pubkey::Pubkey, - } + pub ncn: solana_program::pubkey::Pubkey, + + pub weight_table: solana_program::pubkey::Pubkey, + + pub weight_table_admin: solana_program::pubkey::Pubkey, + + pub restaking_program_id: solana_program::pubkey::Pubkey, +} impl UpdateWeightTable { - pub fn instruction(&self, args: UpdateWeightTableInstructionArgs) -> solana_program::instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts(&self, args: UpdateWeightTableInstructionArgs, remaining_accounts: &[solana_program::instruction::AccountMeta]) -> solana_program::instruction::Instruction { - let mut accounts = Vec::with_capacity(4 + remaining_accounts.len()); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( - self.ncn, - false - )); - accounts.push(solana_program::instruction::AccountMeta::new( + pub fn instruction( + &self, + args: UpdateWeightTableInstructionArgs, + ) -> solana_program::instruction::Instruction { + self.instruction_with_remaining_accounts(args, &[]) + } + #[allow(clippy::vec_init_then_push)] + pub fn instruction_with_remaining_accounts( + &self, + args: UpdateWeightTableInstructionArgs, + remaining_accounts: &[solana_program::instruction::AccountMeta], + ) -> solana_program::instruction::Instruction { + let mut accounts = Vec::with_capacity(4 + remaining_accounts.len()); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( + self.ncn, false, + )); + accounts.push(solana_program::instruction::AccountMeta::new( self.weight_table, - false - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( self.weight_table_admin, - true - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + true, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( self.restaking_program_id, - false - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = UpdateWeightTableInstructionData::new().try_to_vec().unwrap(); - let mut args = args.try_to_vec().unwrap(); - data.append(&mut args); - - solana_program::instruction::Instruction { - program_id: crate::JITO_WEIGHT_TABLE_ID, - accounts, - data, - } - } + false, + )); + accounts.extend_from_slice(remaining_accounts); + let mut data = UpdateWeightTableInstructionData::new() + .try_to_vec() + .unwrap(); + let mut args = args.try_to_vec().unwrap(); + data.append(&mut args); + + solana_program::instruction::Instruction { + program_id: crate::JITO_WEIGHT_TABLE_ID, + accounts, + data, + } + } } #[derive(BorshDeserialize, BorshSerialize)] pub struct UpdateWeightTableInstructionData { - discriminator: u8, - } + discriminator: u8, +} impl UpdateWeightTableInstructionData { - pub fn new() -> Self { - Self { - discriminator: 1, - } - } + pub fn new() -> Self { + Self { discriminator: 1 } + } } impl Default for UpdateWeightTableInstructionData { - fn default() -> Self { - Self::new() - } + fn default() -> Self { + Self::new() + } } #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct UpdateWeightTableInstructionArgs { - pub ncn_epoch: u64, - pub weight_numerator: u64, - pub weight_denominator: u64, - } - + pub ncn_epoch: u64, + pub weight_numerator: u64, + pub weight_denominator: u64, +} /// Instruction builder for `UpdateWeightTable`. /// /// ### Accounts: /// - /// 0. `[]` ncn - /// 1. `[writable]` weight_table - /// 2. `[signer]` weight_table_admin - /// 3. `[]` restaking_program_id +/// 0. `[]` ncn +/// 1. `[writable]` weight_table +/// 2. `[signer]` weight_table_admin +/// 3. `[]` restaking_program_id #[derive(Clone, Debug, Default)] pub struct UpdateWeightTableBuilder { - ncn: Option, - weight_table: Option, - weight_table_admin: Option, - restaking_program_id: Option, - ncn_epoch: Option, - weight_numerator: Option, - weight_denominator: Option, - __remaining_accounts: Vec, + ncn: Option, + weight_table: Option, + weight_table_admin: Option, + restaking_program_id: Option, + ncn_epoch: Option, + weight_numerator: Option, + weight_denominator: Option, + __remaining_accounts: Vec, } impl UpdateWeightTableBuilder { - pub fn new() -> Self { - Self::default() - } - #[inline(always)] + pub fn new() -> Self { + Self::default() + } + #[inline(always)] pub fn ncn(&mut self, ncn: solana_program::pubkey::Pubkey) -> &mut Self { - self.ncn = Some(ncn); - self + self.ncn = Some(ncn); + self } - #[inline(always)] + #[inline(always)] pub fn weight_table(&mut self, weight_table: solana_program::pubkey::Pubkey) -> &mut Self { - self.weight_table = Some(weight_table); - self + self.weight_table = Some(weight_table); + self } - #[inline(always)] - pub fn weight_table_admin(&mut self, weight_table_admin: solana_program::pubkey::Pubkey) -> &mut Self { - self.weight_table_admin = Some(weight_table_admin); - self + #[inline(always)] + pub fn weight_table_admin( + &mut self, + weight_table_admin: solana_program::pubkey::Pubkey, + ) -> &mut Self { + self.weight_table_admin = Some(weight_table_admin); + self } - #[inline(always)] - pub fn restaking_program_id(&mut self, restaking_program_id: solana_program::pubkey::Pubkey) -> &mut Self { - self.restaking_program_id = Some(restaking_program_id); - self + #[inline(always)] + pub fn restaking_program_id( + &mut self, + restaking_program_id: solana_program::pubkey::Pubkey, + ) -> &mut Self { + self.restaking_program_id = Some(restaking_program_id); + self } - #[inline(always)] - pub fn ncn_epoch(&mut self, ncn_epoch: u64) -> &mut Self { + #[inline(always)] + pub fn ncn_epoch(&mut self, ncn_epoch: u64) -> &mut Self { self.ncn_epoch = Some(ncn_epoch); self - } - #[inline(always)] - pub fn weight_numerator(&mut self, weight_numerator: u64) -> &mut Self { + } + #[inline(always)] + pub fn weight_numerator(&mut self, weight_numerator: u64) -> &mut Self { self.weight_numerator = Some(weight_numerator); self - } - #[inline(always)] - pub fn weight_denominator(&mut self, weight_denominator: u64) -> &mut Self { + } + #[inline(always)] + pub fn weight_denominator(&mut self, weight_denominator: u64) -> &mut Self { self.weight_denominator = Some(weight_denominator); self - } - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_program::instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts(&mut self, accounts: &[solana_program::instruction::AccountMeta]) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_program::instruction::Instruction { - let accounts = UpdateWeightTable { - ncn: self.ncn.expect("ncn is not set"), - weight_table: self.weight_table.expect("weight_table is not set"), - weight_table_admin: self.weight_table_admin.expect("weight_table_admin is not set"), - restaking_program_id: self.restaking_program_id.expect("restaking_program_id is not set"), - }; - let args = UpdateWeightTableInstructionArgs { - ncn_epoch: self.ncn_epoch.clone().expect("ncn_epoch is not set"), - weight_numerator: self.weight_numerator.clone().expect("weight_numerator is not set"), - weight_denominator: self.weight_denominator.clone().expect("weight_denominator is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } + } + /// Add an additional account to the instruction. + #[inline(always)] + pub fn add_remaining_account( + &mut self, + account: solana_program::instruction::AccountMeta, + ) -> &mut Self { + self.__remaining_accounts.push(account); + self + } + /// Add additional accounts to the instruction. + #[inline(always)] + pub fn add_remaining_accounts( + &mut self, + accounts: &[solana_program::instruction::AccountMeta], + ) -> &mut Self { + self.__remaining_accounts.extend_from_slice(accounts); + self + } + #[allow(clippy::clone_on_copy)] + pub fn instruction(&self) -> solana_program::instruction::Instruction { + let accounts = UpdateWeightTable { + ncn: self.ncn.expect("ncn is not set"), + weight_table: self.weight_table.expect("weight_table is not set"), + weight_table_admin: self + .weight_table_admin + .expect("weight_table_admin is not set"), + restaking_program_id: self + .restaking_program_id + .expect("restaking_program_id is not set"), + }; + let args = UpdateWeightTableInstructionArgs { + ncn_epoch: self.ncn_epoch.clone().expect("ncn_epoch is not set"), + weight_numerator: self + .weight_numerator + .clone() + .expect("weight_numerator is not set"), + weight_denominator: self + .weight_denominator + .clone() + .expect("weight_denominator is not set"), + }; + + accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) + } } - /// `update_weight_table` CPI accounts. - pub struct UpdateWeightTableCpiAccounts<'a, 'b> { - - - pub ncn: &'b solana_program::account_info::AccountInfo<'a>, - - - pub weight_table: &'b solana_program::account_info::AccountInfo<'a>, - - - pub weight_table_admin: &'b solana_program::account_info::AccountInfo<'a>, - - - pub restaking_program_id: &'b solana_program::account_info::AccountInfo<'a>, - } +/// `update_weight_table` CPI accounts. +pub struct UpdateWeightTableCpiAccounts<'a, 'b> { + pub ncn: &'b solana_program::account_info::AccountInfo<'a>, + + pub weight_table: &'b solana_program::account_info::AccountInfo<'a>, + + pub weight_table_admin: &'b solana_program::account_info::AccountInfo<'a>, + + pub restaking_program_id: &'b solana_program::account_info::AccountInfo<'a>, +} /// `update_weight_table` CPI instruction. pub struct UpdateWeightTableCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_program::account_info::AccountInfo<'a>, - - - pub ncn: &'b solana_program::account_info::AccountInfo<'a>, - - - pub weight_table: &'b solana_program::account_info::AccountInfo<'a>, - - - pub weight_table_admin: &'b solana_program::account_info::AccountInfo<'a>, - - - pub restaking_program_id: &'b solana_program::account_info::AccountInfo<'a>, - /// The arguments for the instruction. + /// The program to invoke. + pub __program: &'b solana_program::account_info::AccountInfo<'a>, + + pub ncn: &'b solana_program::account_info::AccountInfo<'a>, + + pub weight_table: &'b solana_program::account_info::AccountInfo<'a>, + + pub weight_table_admin: &'b solana_program::account_info::AccountInfo<'a>, + + pub restaking_program_id: &'b solana_program::account_info::AccountInfo<'a>, + /// The arguments for the instruction. pub __args: UpdateWeightTableInstructionArgs, - } +} impl<'a, 'b> UpdateWeightTableCpi<'a, 'b> { - pub fn new( - program: &'b solana_program::account_info::AccountInfo<'a>, - accounts: UpdateWeightTableCpiAccounts<'a, 'b>, - args: UpdateWeightTableInstructionArgs, - ) -> Self { - Self { - __program: program, - ncn: accounts.ncn, - weight_table: accounts.weight_table, - weight_table_admin: accounts.weight_table_admin, - restaking_program_id: accounts.restaking_program_id, - __args: args, - } - } - #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - #[inline(always)] - pub fn invoke_with_remaining_accounts(&self, remaining_accounts: &[(&'b solana_program::account_info::AccountInfo<'a>, bool, bool)]) -> solana_program::entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - #[inline(always)] - pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program::entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_program::account_info::AccountInfo<'a>, bool, bool)] - ) -> solana_program::entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(4 + remaining_accounts.len()); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + pub fn new( + program: &'b solana_program::account_info::AccountInfo<'a>, + accounts: UpdateWeightTableCpiAccounts<'a, 'b>, + args: UpdateWeightTableInstructionArgs, + ) -> Self { + Self { + __program: program, + ncn: accounts.ncn, + weight_table: accounts.weight_table, + weight_table_admin: accounts.weight_table_admin, + restaking_program_id: accounts.restaking_program_id, + __args: args, + } + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(&[], &[]) + } + #[inline(always)] + pub fn invoke_with_remaining_accounts( + &self, + remaining_accounts: &[( + &'b solana_program::account_info::AccountInfo<'a>, + bool, + bool, + )], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) + } + #[inline(always)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) + } + #[allow(clippy::clone_on_copy)] + #[allow(clippy::vec_init_then_push)] + pub fn invoke_signed_with_remaining_accounts( + &self, + signers_seeds: &[&[&[u8]]], + remaining_accounts: &[( + &'b solana_program::account_info::AccountInfo<'a>, + bool, + bool, + )], + ) -> solana_program::entrypoint::ProgramResult { + let mut accounts = Vec::with_capacity(4 + remaining_accounts.len()); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( *self.ncn.key, - false - )); - accounts.push(solana_program::instruction::AccountMeta::new( + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new( *self.weight_table.key, - false - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( *self.weight_table_admin.key, - true - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + true, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( *self.restaking_program_id.key, - false - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_program::instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = UpdateWeightTableInstructionData::new().try_to_vec().unwrap(); - let mut args = self.__args.try_to_vec().unwrap(); - data.append(&mut args); - - let instruction = solana_program::instruction::Instruction { - program_id: crate::JITO_WEIGHT_TABLE_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(4 + 1 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.ncn.clone()); - account_infos.push(self.weight_table.clone()); - account_infos.push(self.weight_table_admin.clone()); - account_infos.push(self.restaking_program_id.clone()); - remaining_accounts.iter().for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_program::program::invoke(&instruction, &account_infos) - } else { - solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } + false, + )); + remaining_accounts.iter().for_each(|remaining_account| { + accounts.push(solana_program::instruction::AccountMeta { + pubkey: *remaining_account.0.key, + is_signer: remaining_account.1, + is_writable: remaining_account.2, + }) + }); + let mut data = UpdateWeightTableInstructionData::new() + .try_to_vec() + .unwrap(); + let mut args = self.__args.try_to_vec().unwrap(); + data.append(&mut args); + + let instruction = solana_program::instruction::Instruction { + program_id: crate::JITO_WEIGHT_TABLE_ID, + accounts, + data, + }; + let mut account_infos = Vec::with_capacity(4 + 1 + remaining_accounts.len()); + account_infos.push(self.__program.clone()); + account_infos.push(self.ncn.clone()); + account_infos.push(self.weight_table.clone()); + account_infos.push(self.weight_table_admin.clone()); + account_infos.push(self.restaking_program_id.clone()); + remaining_accounts + .iter() + .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); + + if signers_seeds.is_empty() { + solana_program::program::invoke(&instruction, &account_infos) + } else { + solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds) + } + } } /// Instruction builder for `UpdateWeightTable` via CPI. /// /// ### Accounts: /// - /// 0. `[]` ncn - /// 1. `[writable]` weight_table - /// 2. `[signer]` weight_table_admin - /// 3. `[]` restaking_program_id +/// 0. `[]` ncn +/// 1. `[writable]` weight_table +/// 2. `[signer]` weight_table_admin +/// 3. `[]` restaking_program_id #[derive(Clone, Debug)] pub struct UpdateWeightTableCpiBuilder<'a, 'b> { - instruction: Box>, + instruction: Box>, } impl<'a, 'b> UpdateWeightTableCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(UpdateWeightTableCpiBuilderInstruction { - __program: program, - ncn: None, - weight_table: None, - weight_table_admin: None, - restaking_program_id: None, - ncn_epoch: None, - weight_numerator: None, - weight_denominator: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - #[inline(always)] + pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { + let instruction = Box::new(UpdateWeightTableCpiBuilderInstruction { + __program: program, + ncn: None, + weight_table: None, + weight_table_admin: None, + restaking_program_id: None, + ncn_epoch: None, + weight_numerator: None, + weight_denominator: None, + __remaining_accounts: Vec::new(), + }); + Self { instruction } + } + #[inline(always)] pub fn ncn(&mut self, ncn: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.ncn = Some(ncn); - self - } - #[inline(always)] - pub fn weight_table(&mut self, weight_table: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.weight_table = Some(weight_table); - self - } - #[inline(always)] - pub fn weight_table_admin(&mut self, weight_table_admin: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.weight_table_admin = Some(weight_table_admin); - self - } - #[inline(always)] - pub fn restaking_program_id(&mut self, restaking_program_id: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.restaking_program_id = Some(restaking_program_id); - self - } - #[inline(always)] - pub fn ncn_epoch(&mut self, ncn_epoch: u64) -> &mut Self { + self.instruction.ncn = Some(ncn); + self + } + #[inline(always)] + pub fn weight_table( + &mut self, + weight_table: &'b solana_program::account_info::AccountInfo<'a>, + ) -> &mut Self { + self.instruction.weight_table = Some(weight_table); + self + } + #[inline(always)] + pub fn weight_table_admin( + &mut self, + weight_table_admin: &'b solana_program::account_info::AccountInfo<'a>, + ) -> &mut Self { + self.instruction.weight_table_admin = Some(weight_table_admin); + self + } + #[inline(always)] + pub fn restaking_program_id( + &mut self, + restaking_program_id: &'b solana_program::account_info::AccountInfo<'a>, + ) -> &mut Self { + self.instruction.restaking_program_id = Some(restaking_program_id); + self + } + #[inline(always)] + pub fn ncn_epoch(&mut self, ncn_epoch: u64) -> &mut Self { self.instruction.ncn_epoch = Some(ncn_epoch); self - } - #[inline(always)] - pub fn weight_numerator(&mut self, weight_numerator: u64) -> &mut Self { + } + #[inline(always)] + pub fn weight_numerator(&mut self, weight_numerator: u64) -> &mut Self { self.instruction.weight_numerator = Some(weight_numerator); self - } - #[inline(always)] - pub fn weight_denominator(&mut self, weight_denominator: u64) -> &mut Self { + } + #[inline(always)] + pub fn weight_denominator(&mut self, weight_denominator: u64) -> &mut Self { self.instruction.weight_denominator = Some(weight_denominator); self - } - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: &'b solana_program::account_info::AccountInfo<'a>, is_writable: bool, is_signer: bool) -> &mut Self { - self.instruction.__remaining_accounts.push((account, is_writable, is_signer)); - self - } - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts(&mut self, accounts: &[(&'b solana_program::account_info::AccountInfo<'a>, bool, bool)]) -> &mut Self { - self.instruction.__remaining_accounts.extend_from_slice(accounts); - self - } - #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { - self.invoke_signed(&[]) - } - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program::entrypoint::ProgramResult { - let args = UpdateWeightTableInstructionArgs { - ncn_epoch: self.instruction.ncn_epoch.clone().expect("ncn_epoch is not set"), - weight_numerator: self.instruction.weight_numerator.clone().expect("weight_numerator is not set"), - weight_denominator: self.instruction.weight_denominator.clone().expect("weight_denominator is not set"), - }; + } + /// Add an additional account to the instruction. + #[inline(always)] + pub fn add_remaining_account( + &mut self, + account: &'b solana_program::account_info::AccountInfo<'a>, + is_writable: bool, + is_signer: bool, + ) -> &mut Self { + self.instruction + .__remaining_accounts + .push((account, is_writable, is_signer)); + self + } + /// Add additional accounts to the instruction. + /// + /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, + /// and a `bool` indicating whether the account is a signer or not. + #[inline(always)] + pub fn add_remaining_accounts( + &mut self, + accounts: &[( + &'b solana_program::account_info::AccountInfo<'a>, + bool, + bool, + )], + ) -> &mut Self { + self.instruction + .__remaining_accounts + .extend_from_slice(accounts); + self + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed(&[]) + } + #[allow(clippy::clone_on_copy)] + #[allow(clippy::vec_init_then_push)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + let args = UpdateWeightTableInstructionArgs { + ncn_epoch: self + .instruction + .ncn_epoch + .clone() + .expect("ncn_epoch is not set"), + weight_numerator: self + .instruction + .weight_numerator + .clone() + .expect("weight_numerator is not set"), + weight_denominator: self + .instruction + .weight_denominator + .clone() + .expect("weight_denominator is not set"), + }; let instruction = UpdateWeightTableCpi { - __program: self.instruction.__program, - - ncn: self.instruction.ncn.expect("ncn is not set"), - - weight_table: self.instruction.weight_table.expect("weight_table is not set"), - - weight_table_admin: self.instruction.weight_table_admin.expect("weight_table_admin is not set"), - - restaking_program_id: self.instruction.restaking_program_id.expect("restaking_program_id is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts(signers_seeds, &self.instruction.__remaining_accounts) - } + __program: self.instruction.__program, + + ncn: self.instruction.ncn.expect("ncn is not set"), + + weight_table: self + .instruction + .weight_table + .expect("weight_table is not set"), + + weight_table_admin: self + .instruction + .weight_table_admin + .expect("weight_table_admin is not set"), + + restaking_program_id: self + .instruction + .restaking_program_id + .expect("restaking_program_id is not set"), + __args: args, + }; + instruction.invoke_signed_with_remaining_accounts( + signers_seeds, + &self.instruction.__remaining_accounts, + ) + } } #[derive(Clone, Debug)] struct UpdateWeightTableCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_program::account_info::AccountInfo<'a>, - ncn: Option<&'b solana_program::account_info::AccountInfo<'a>>, - weight_table: Option<&'b solana_program::account_info::AccountInfo<'a>>, - weight_table_admin: Option<&'b solana_program::account_info::AccountInfo<'a>>, - restaking_program_id: Option<&'b solana_program::account_info::AccountInfo<'a>>, - ncn_epoch: Option, - weight_numerator: Option, - weight_denominator: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_program::account_info::AccountInfo<'a>, bool, bool)>, + __program: &'b solana_program::account_info::AccountInfo<'a>, + ncn: Option<&'b solana_program::account_info::AccountInfo<'a>>, + weight_table: Option<&'b solana_program::account_info::AccountInfo<'a>>, + weight_table_admin: Option<&'b solana_program::account_info::AccountInfo<'a>>, + restaking_program_id: Option<&'b solana_program::account_info::AccountInfo<'a>>, + ncn_epoch: Option, + weight_numerator: Option, + weight_denominator: Option, + /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. + __remaining_accounts: Vec<( + &'b solana_program::account_info::AccountInfo<'a>, + bool, + bool, + )>, } - diff --git a/clients/rust/weight_table_client/src/generated/mod.rs b/clients/rust/weight_table_client/src/generated/mod.rs index fb73336..4a699f9 100644 --- a/clients/rust/weight_table_client/src/generated/mod.rs +++ b/clients/rust/weight_table_client/src/generated/mod.rs @@ -3,12 +3,11 @@ //! to add features, then rerun kinobi to update it. //! //! -//! - pub mod accounts; - pub mod errors; - pub mod instructions; - pub mod programs; - pub mod types; - - pub(crate) use programs::*; +pub mod accounts; +pub mod errors; +pub mod instructions; +pub mod programs; +pub mod types; + +pub(crate) use programs::*; diff --git a/clients/rust/weight_table_client/src/generated/programs.rs b/clients/rust/weight_table_client/src/generated/programs.rs index 95fa17b..d43271d 100644 --- a/clients/rust/weight_table_client/src/generated/programs.rs +++ b/clients/rust/weight_table_client/src/generated/programs.rs @@ -3,11 +3,8 @@ //! to add features, then rerun kinobi to update it. //! //! -//! use solana_program::{pubkey, pubkey::Pubkey}; - - /// `jito_weight_table` program ID. - pub const JITO_WEIGHT_TABLE_ID: Pubkey = pubkey!("ENHcxLEWQxRyS8VbC7Pb6GKc739vVaBZ2toJvQSL68vM"); - +/// `jito_weight_table` program ID. +pub const JITO_WEIGHT_TABLE_ID: Pubkey = pubkey!("ENHcxLEWQxRyS8VbC7Pb6GKc739vVaBZ2toJvQSL68vM"); diff --git a/clients/rust/weight_table_client/src/generated/types/mod.rs b/clients/rust/weight_table_client/src/generated/types/mod.rs index 0f82690..8a77ad9 100644 --- a/clients/rust/weight_table_client/src/generated/types/mod.rs +++ b/clients/rust/weight_table_client/src/generated/types/mod.rs @@ -3,11 +3,8 @@ //! to add features, then rerun kinobi to update it. //! //! -//! - - pub(crate) mod r#weight; - pub(crate) mod r#weight_entry; - pub use self::r#weight::*; - pub use self::r#weight_entry::*; +pub(crate) mod r#weight; +pub(crate) mod r#weight_entry; +pub use self::{r#weight::*, r#weight_entry::*}; diff --git a/clients/rust/weight_table_client/src/generated/types/weight.rs b/clients/rust/weight_table_client/src/generated/types/weight.rs index a098f9e..17c173e 100644 --- a/clients/rust/weight_table_client/src/generated/types/weight.rs +++ b/clients/rust/weight_table_client/src/generated/types/weight.rs @@ -3,16 +3,12 @@ //! to add features, then rerun kinobi to update it. //! //! -//! -use borsh::BorshSerialize; -use borsh::BorshDeserialize; +use borsh::{BorshDeserialize, BorshSerialize}; #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct Weight { -pub numerator: u64, -pub denominator: u64, + pub numerator: u64, + pub denominator: u64, } - - diff --git a/clients/rust/weight_table_client/src/generated/types/weight_entry.rs b/clients/rust/weight_table_client/src/generated/types/weight_entry.rs index 5f7d424..0975a35 100644 --- a/clients/rust/weight_table_client/src/generated/types/weight_entry.rs +++ b/clients/rust/weight_table_client/src/generated/types/weight_entry.rs @@ -3,19 +3,19 @@ //! to add features, then rerun kinobi to update it. //! //! -//! +use borsh::{BorshDeserialize, BorshSerialize}; use solana_program::pubkey::Pubkey; + use crate::generated::types::Weight; -use borsh::BorshSerialize; -use borsh::BorshDeserialize; #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct WeightEntry { -#[cfg_attr(feature = "serde", serde(with = "serde_with::As::"))] -pub mint: Pubkey, -pub weight: Weight, + #[cfg_attr( + feature = "serde", + serde(with = "serde_with::As::") + )] + pub mint: Pubkey, + pub weight: Weight, } - - diff --git a/clients/rust/weight_table_client/src/lib.rs b/clients/rust/weight_table_client/src/lib.rs index e69de29..e89d973 100644 --- a/clients/rust/weight_table_client/src/lib.rs +++ b/clients/rust/weight_table_client/src/lib.rs @@ -0,0 +1,29 @@ +#![allow(clippy::all)] +#![allow(clippy::nursery)] +#![allow(clippy::integer_division)] +#![allow(clippy::arithmetic_side_effects)] +#![allow(clippy::style)] +#![allow(clippy::perf)] +mod generated; + +use generated::*; + +pub mod accounts { + pub use super::generated::accounts::*; +} + +pub mod instructions { + pub use super::generated::instructions::*; +} + +pub mod errors { + pub use super::generated::errors::*; +} + +pub mod types { + pub use super::generated::types::*; +} + +pub mod programs { + pub use super::generated::programs::*; +} diff --git a/integration_tests/Cargo.toml b/integration_tests/Cargo.toml index 5b6c2df..c888a95 100644 --- a/integration_tests/Cargo.toml +++ b/integration_tests/Cargo.toml @@ -31,3 +31,5 @@ tokio = { workspace = true } [dependencies] log = "0.4.21" +jito-weight-table-client = { workspace = true } + diff --git a/integration_tests/src/main.rs b/integration_tests/src/main.rs index deea281..fa998e8 100644 --- a/integration_tests/src/main.rs +++ b/integration_tests/src/main.rs @@ -1,3 +1,11 @@ +// use jito_restaking_client::instructions::{ +// InitializeConfigBuilder, InitializeNcnBuilder, InitializeOperatorBuilder, +// }; + +// use jito_weight_table_client::types::Weight; +use jito_weight_table_client::programs::JITO_WEIGHT_TABLE_ID; + pub fn main() { - println!("Hello, world!"); + // let weight = Weight::new(1, 2).unwrap(); + println!("Hello, world! {:?}", JITO_WEIGHT_TABLE_ID); } diff --git a/reward_core/Cargo.toml b/reward_core/Cargo.toml index 47c9a46..09dacaf 100644 --- a/reward_core/Cargo.toml +++ b/reward_core/Cargo.toml @@ -14,10 +14,10 @@ borsh = { workspace = true } bytemuck = { workspace = true } jito-bytemuck = { workspace = true } jito-jsm-core = { workspace = true } -jito-vault-sdk = { workspace = true } -jito-vault-core = { workspace = true } +jito-restaking-core = { workspace = true } jito-restaking-sdk = { workspace = true } -jito-restaking-core= { workspace = true } +jito-vault-core = { workspace = true } +jito-vault-sdk = { workspace = true } shank = { workspace = true } solana-program = { workspace = true } spl-associated-token-account = { workspace = true } diff --git a/reward_program/Cargo.toml b/reward_program/Cargo.toml index ebaf086..36526a3 100644 --- a/reward_program/Cargo.toml +++ b/reward_program/Cargo.toml @@ -35,8 +35,8 @@ jito-restaking-program = { workspace = true } jito-reward-core = { workspace = true } jito-reward-sdk = { workspace = true } jito-vault-core = { workspace = true } -jito-vault-sdk = { workspace = true } jito-vault-program = { workspace = true } +jito-vault-sdk = { workspace = true } shank = { workspace = true } solana-program = { workspace = true } solana-security-txt = { workspace = true } diff --git a/weight_table_core/Cargo.toml b/weight_table_core/Cargo.toml index f67bdd6..1018ca9 100644 --- a/weight_table_core/Cargo.toml +++ b/weight_table_core/Cargo.toml @@ -14,10 +14,10 @@ borsh = { workspace = true } bytemuck = { workspace = true } jito-bytemuck = { workspace = true } jito-jsm-core = { workspace = true } -jito-vault-sdk = { workspace = true } -jito-vault-core = { workspace = true } +jito-restaking-core = { workspace = true } jito-restaking-sdk = { workspace = true } -jito-restaking-core= { workspace = true } +jito-vault-core = { workspace = true } +jito-vault-sdk = { workspace = true } shank = { workspace = true } solana-program = { workspace = true } spl-associated-token-account = { workspace = true } diff --git a/weight_table_program/Cargo.toml b/weight_table_program/Cargo.toml index d3f99d9..463decf 100644 --- a/weight_table_program/Cargo.toml +++ b/weight_table_program/Cargo.toml @@ -25,22 +25,22 @@ borsh = { workspace = true } bytemuck = { workspace = true } cfg-if = { workspace = true } const_str_to_pubkey = { workspace = true } -jito-reward-core = { workspace = true } jito-bytemuck = { workspace = true } jito-jsm-core = { workspace = true } -jito-vault-sdk = { workspace = true } -jito-vault-core = { workspace = true } -jito-restaking-sdk = { workspace = true } -jito-restaking-core= { workspace = true } +jito-restaking-core = { workspace = true } jito-restaking-program = { workspace = true } +jito-restaking-sdk = { workspace = true } +jito-reward-core = { workspace = true } +jito-vault-core = { workspace = true } +jito-vault-sdk = { workspace = true } jito-weight-table-core = { workspace = true } jito-weight-table-sdk = { workspace = true } shank = { workspace = true } solana-program = { workspace = true } +solana-security-txt = { workspace = true } spl-associated-token-account = { workspace = true } spl-token = { workspace = true } thiserror = { workspace = true } -solana-security-txt = { workspace = true } [dev-dependencies] assert_matches = { workspace = true } diff --git a/weight_table_sdk/Cargo.toml b/weight_table_sdk/Cargo.toml index c25cc59..1fbe5f3 100644 --- a/weight_table_sdk/Cargo.toml +++ b/weight_table_sdk/Cargo.toml @@ -14,10 +14,10 @@ borsh = { workspace = true } bytemuck = { workspace = true } jito-bytemuck = { workspace = true } jito-jsm-core = { workspace = true } -jito-vault-sdk = { workspace = true } -jito-vault-core = { workspace = true } +jito-restaking-core = { workspace = true } jito-restaking-sdk = { workspace = true } -jito-restaking-core= { workspace = true } +jito-vault-core = { workspace = true } +jito-vault-sdk = { workspace = true } shank = { workspace = true } solana-program = { workspace = true } spl-associated-token-account = { workspace = true }