diff --git a/Cargo.lock b/Cargo.lock index b11ae95..5d347c8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1286,7 +1286,7 @@ checksum = "c08d65885ee38876c4f86fa503fb49d7b507c2b62552df7c70b2fce627e06381" [[package]] name = "ore-api" -version = "2.1.3" +version = "2.1.4" dependencies = [ "array-const-fn-init", "bytemuck", @@ -1304,7 +1304,7 @@ dependencies = [ [[package]] name = "ore-program" -version = "2.1.3" +version = "2.1.4" dependencies = [ "drillx", "mpl-token-metadata", @@ -1318,7 +1318,7 @@ dependencies = [ [[package]] name = "ore-utils" -version = "2.1.3" +version = "2.1.4" dependencies = [ "bytemuck", "solana-program", diff --git a/Cargo.toml b/Cargo.toml index fadfd6b..67aa03c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,7 +3,7 @@ resolver = "2" members = ["api", "program", "utils"] [workspace.package] -version = "2.1.3" +version = "2.1.4" edition = "2021" license = "Apache-2.0" homepage = "https://ore.supply" @@ -19,8 +19,8 @@ const-crypto = "0.1.0" drillx = { version = "2.0.0", features = ["solana"] } mpl-token-metadata = "4.1.2" num_enum = "0.7.2" -ore-api = { path = "api", version = "2.1.3" } -ore-utils = { path = "utils", features = ["spl"], version = "2.1.3" } +ore-api = { path = "api", version = "2.1.4" } +ore-utils = { path = "utils", features = ["spl"], version = "2.1.4" } solana-program = "^1.18" spl-token = { version = "^4", features = ["no-entrypoint"] } spl-associated-token-account = { version = "^2.3", features = [ "no-entrypoint" ] } diff --git a/api/src/instruction.rs b/api/src/instruction.rs index e2290e6..0cdfa8d 100644 --- a/api/src/instruction.rs +++ b/api/src/instruction.rs @@ -1,7 +1,7 @@ use bytemuck::{Pod, Zeroable}; use drillx::Solution; use num_enum::TryFromPrimitive; -use ore_utils::{impl_instruction_from_bytes, impl_to_bytes}; +use ore_utils::instruction; use solana_program::{ instruction::{AccountMeta, Instruction}, pubkey::Pubkey, @@ -82,19 +82,12 @@ pub struct UpgradeArgs { pub amount: [u8; 8], } -impl_to_bytes!(InitializeArgs); -impl_to_bytes!(OpenArgs); -impl_to_bytes!(MineArgs); -impl_to_bytes!(ClaimArgs); -impl_to_bytes!(StakeArgs); -impl_to_bytes!(UpgradeArgs); - -impl_instruction_from_bytes!(InitializeArgs); -impl_instruction_from_bytes!(OpenArgs); -impl_instruction_from_bytes!(MineArgs); -impl_instruction_from_bytes!(ClaimArgs); -impl_instruction_from_bytes!(StakeArgs); -impl_instruction_from_bytes!(UpgradeArgs); +instruction!(InitializeArgs); +instruction!(OpenArgs); +instruction!(MineArgs); +instruction!(ClaimArgs); +instruction!(StakeArgs); +instruction!(UpgradeArgs); /// Builds an auth instruction. pub fn auth(proof: Pubkey) -> Instruction { diff --git a/api/src/state/bus.rs b/api/src/state/bus.rs index b5d3cb5..a48c276 100644 --- a/api/src/state/bus.rs +++ b/api/src/state/bus.rs @@ -1,5 +1,5 @@ use bytemuck::{Pod, Zeroable}; -use ore_utils::{impl_account_from_bytes, impl_to_bytes, Discriminator}; +use ore_utils::{account, Discriminator}; use super::AccountDiscriminator; @@ -28,5 +28,4 @@ impl Discriminator for Bus { } } -impl_to_bytes!(Bus); -impl_account_from_bytes!(Bus); +account!(Bus); diff --git a/api/src/state/config.rs b/api/src/state/config.rs index 073f31d..f31b3c6 100644 --- a/api/src/state/config.rs +++ b/api/src/state/config.rs @@ -1,5 +1,5 @@ use bytemuck::{Pod, Zeroable}; -use ore_utils::{impl_account_from_bytes, impl_to_bytes, Discriminator}; +use ore_utils::{account, Discriminator}; use super::AccountDiscriminator; @@ -26,5 +26,4 @@ impl Discriminator for Config { } } -impl_to_bytes!(Config); -impl_account_from_bytes!(Config); +account!(Config); diff --git a/api/src/state/proof.rs b/api/src/state/proof.rs index 592c857..0364514 100644 --- a/api/src/state/proof.rs +++ b/api/src/state/proof.rs @@ -1,5 +1,5 @@ use bytemuck::{Pod, Zeroable}; -use ore_utils::{impl_account_from_bytes, impl_to_bytes, Discriminator}; +use ore_utils::{account, Discriminator}; use solana_program::pubkey::Pubkey; use super::AccountDiscriminator; @@ -43,5 +43,4 @@ impl Discriminator for Proof { } } -impl_to_bytes!(Proof); -impl_account_from_bytes!(Proof); +account!(Proof); diff --git a/api/src/state/treasury.rs b/api/src/state/treasury.rs index 388bdc2..e65e7f6 100644 --- a/api/src/state/treasury.rs +++ b/api/src/state/treasury.rs @@ -1,5 +1,5 @@ use bytemuck::{Pod, Zeroable}; -use ore_utils::{impl_account_from_bytes, impl_to_bytes, Discriminator}; +use ore_utils::{account, Discriminator}; use super::AccountDiscriminator; @@ -15,5 +15,4 @@ impl Discriminator for Treasury { } } -impl_to_bytes!(Treasury); -impl_account_from_bytes!(Treasury); +account!(Treasury); diff --git a/utils/src/lib.rs b/utils/src/lib.rs index 61ef42a..e2dd012 100644 --- a/utils/src/lib.rs +++ b/utils/src/lib.rs @@ -137,3 +137,19 @@ macro_rules! impl_instruction_from_bytes { } }; } + +#[macro_export] +macro_rules! account { + ($struct_name:ident) => { + $crate::impl_to_bytes!($struct_name); + $crate::impl_account_from_bytes!($struct_name); + }; +} + +#[macro_export] +macro_rules! instruction { + ($struct_name:ident) => { + $crate::impl_to_bytes!($struct_name); + $crate::impl_instruction_from_bytes!($struct_name); + }; +}