Skip to content

Commit

Permalink
generated sdk up
Browse files Browse the repository at this point in the history
  • Loading branch information
coachchucksol committed Oct 16, 2024
1 parent ad6a63c commit 84e8208
Show file tree
Hide file tree
Showing 24 changed files with 1,416 additions and 1,124 deletions.
17 changes: 17 additions & 0 deletions Cargo.lock

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

16 changes: 8 additions & 8 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"

Expand Down Expand Up @@ -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" }
Expand Down
27 changes: 27 additions & 0 deletions clients/rust/weight_table_client/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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 }
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
//! to add features, then rerun kinobi to update it.
//!
//! <https://github.com/kinobi-so/kinobi>
//!
pub(crate) mod r#weight_table;
pub use self::r#weight_table::*;
pub(crate) mod r#weight_table;

pub use self::r#weight_table::*;
Original file line number Diff line number Diff line change
Expand Up @@ -3,54 +3,53 @@
//! to add features, then rerun kinobi to update it.
//!
//! <https://github.com/kinobi-so/kinobi>
//!
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::<serde_with::DisplayFromStr>"))]
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::<serde_with::Bytes>"))]
pub reserved: [u8; 128],
pub table: [WeightEntry; 32],
pub discriminator: u64,
#[cfg_attr(
feature = "serde",
serde(with = "serde_with::As::<serde_with::DisplayFromStr>")
)]
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::<serde_with::Bytes>"))]
pub reserved: [u8; 128],
pub table: [WeightEntry; 32],
}


impl WeightTable {



#[inline(always)]
pub fn from_bytes(data: &[u8]) -> Result<Self, std::io::Error> {
let mut data = data;
Self::deserialize(&mut data)
}
#[inline(always)]
pub fn from_bytes(data: &[u8]) -> Result<Self, std::io::Error> {
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<Self, Self::Error> {
let mut data: &[u8] = &(*account_info.data).borrow();
Self::deserialize(&mut data)
}
fn try_from(
account_info: &solana_program::account_info::AccountInfo<'a>,
) -> Result<Self, Self::Error> {
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<Self> {
Ok(Self::deserialize(buf)?)
Ok(Self::deserialize(buf)?)
}
}

Expand All @@ -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];
}

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
//! to add features, then rerun kinobi to update it.
//!
//! <https://github.com/kinobi-so/kinobi>
//!
use num_derive::FromPrimitive;
use thiserror::Error;
Expand Down Expand Up @@ -35,4 +34,3 @@ impl solana_program::program_error::PrintProgramError for JitoWeightTableError {
solana_program::msg!(&self.to_string());
}
}

8 changes: 3 additions & 5 deletions clients/rust/weight_table_client/src/generated/errors/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
//! to add features, then rerun kinobi to update it.
//!
//! <https://github.com/kinobi-so/kinobi>
//!
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;
Loading

0 comments on commit 84e8208

Please sign in to comment.