From c57ac5b05d302dde3c7600cedb8e3054152205b0 Mon Sep 17 00:00:00 2001 From: chizor iwuh Date: Sat, 2 Nov 2024 22:37:58 +0100 Subject: [PATCH] favorites/steel - use workspaces, avoid conflicts --- Cargo.lock | 191 +++++----------------- Cargo.toml | 1 - basics/favorites/steel/Cargo.toml | 3 + basics/favorites/steel/program/Cargo.toml | 2 +- basics/favorites/steel/program/src/lib.rs | 14 +- basics/favorites/steel/tests/test.ts | 2 +- 6 files changed, 57 insertions(+), 156 deletions(-) create mode 100644 basics/favorites/steel/Cargo.toml diff --git a/Cargo.lock b/Cargo.lock index 5bcfd863..f54b45b7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -15,7 +15,7 @@ version = "0.1.0" dependencies = [ "borsh 0.9.3", "borsh-derive 0.9.3", - "solana-program 1.18.17", + "solana-program", ] [[package]] @@ -219,7 +219,7 @@ dependencies = [ "borsh 0.10.3", "bytemuck", "getrandom 0.2.15", - "solana-program 1.18.17", + "solana-program", "thiserror", ] @@ -451,12 +451,6 @@ version = "0.21.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" -[[package]] -name = "base64" -version = "0.22.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" - [[package]] name = "bincode" version = "1.3.3" @@ -744,7 +738,7 @@ dependencies = [ name = "checking-accounts-program" version = "0.1.0" dependencies = [ - "solana-program 1.18.17", + "solana-program", ] [[package]] @@ -771,7 +765,7 @@ version = "0.1.0" dependencies = [ "borsh 0.9.3", "borsh-derive 0.9.3", - "solana-program 1.18.17", + "solana-program", ] [[package]] @@ -813,7 +807,7 @@ version = "0.1.0" dependencies = [ "borsh 0.9.3", "shank", - "solana-program 1.18.17", + "solana-program", ] [[package]] @@ -821,7 +815,7 @@ name = "counter-solana-native" version = "0.1.0" dependencies = [ "borsh 0.9.3", - "solana-program 1.18.17", + "solana-program", ] [[package]] @@ -844,7 +838,7 @@ dependencies = [ name = "create-account-program" version = "0.1.0" dependencies = [ - "solana-program 1.18.17", + "solana-program", ] [[package]] @@ -1060,16 +1054,6 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" -[[package]] -name = "favorites-steel-program" -version = "0.1.0" -dependencies = [ - "bytemuck", - "num_enum 0.7.3", - "solana-program 1.18.17", - "steel 2.1.1", -] - [[package]] name = "feature-probe" version = "0.1.1" @@ -1170,7 +1154,7 @@ dependencies = [ name = "hello-solana-program" version = "0.1.0" dependencies = [ - "solana-program 1.18.17", + "solana-program", ] [[package]] @@ -1587,7 +1571,7 @@ version = "0.1.0" dependencies = [ "borsh 0.9.3", "borsh-derive 0.9.3", - "solana-program 1.18.17", + "solana-program", ] [[package]] @@ -1690,7 +1674,7 @@ version = "0.1.0" dependencies = [ "borsh 0.9.3", "borsh-derive 0.9.3", - "solana-program 1.18.17", + "solana-program", ] [[package]] @@ -1699,7 +1683,7 @@ version = "0.1.0" dependencies = [ "borsh 0.9.3", "borsh-derive 0.9.3", - "solana-program 1.18.17", + "solana-program", ] [[package]] @@ -1708,7 +1692,7 @@ version = "0.1.0" dependencies = [ "borsh 0.9.3", "borsh-derive 0.9.3", - "solana-program 1.18.17", + "solana-program", ] [[package]] @@ -1846,7 +1830,7 @@ version = "0.1.0" dependencies = [ "borsh 0.9.3", "borsh-derive 0.9.3", - "solana-program 1.18.17", + "solana-program", ] [[package]] @@ -1900,7 +1884,7 @@ version = "0.1.0" dependencies = [ "borsh 0.9.3", "borsh-derive 0.9.3", - "solana-program 1.18.17", + "solana-program", ] [[package]] @@ -2218,59 +2202,13 @@ dependencies = [ "sha3 0.10.8", "solana-frozen-abi", "solana-frozen-abi-macro", - "solana-sdk-macro 1.18.17", + "solana-sdk-macro", "thiserror", "tiny-bip39", "wasm-bindgen", "zeroize", ] -[[package]] -name = "solana-program" -version = "2.0.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2625a23c3813b620141ee447819b08d1b9a5f1c69a309754834e3f35798a21fb" -dependencies = [ - "ark-bn254", - "ark-ec", - "ark-ff", - "ark-serialize", - "base64 0.22.1", - "bincode", - "bitflags", - "blake3", - "borsh 0.10.3", - "borsh 1.5.1", - "bs58 0.5.1", - "bv", - "bytemuck", - "bytemuck_derive", - "console_error_panic_hook", - "console_log", - "curve25519-dalek", - "getrandom 0.2.15", - "js-sys", - "lazy_static", - "libsecp256k1", - "log", - "memoffset", - "num-bigint", - "num-derive 0.4.2", - "num-traits", - "parking_lot", - "rand 0.8.5", - "rustc_version", - "rustversion", - "serde", - "serde_bytes", - "serde_derive", - "sha2 0.10.8", - "sha3 0.10.8", - "solana-sdk-macro 2.0.14", - "thiserror", - "wasm-bindgen", -] - [[package]] name = "solana-sdk" version = "1.18.17" @@ -2319,8 +2257,8 @@ dependencies = [ "solana-frozen-abi", "solana-frozen-abi-macro", "solana-logger", - "solana-program 1.18.17", - "solana-sdk-macro 1.18.17", + "solana-program", + "solana-sdk-macro", "thiserror", "uriparse", "wasm-bindgen", @@ -2339,19 +2277,6 @@ dependencies = [ "syn 2.0.72", ] -[[package]] -name = "solana-sdk-macro" -version = "2.0.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93a5a1eabc890415d326707afe62cd7a2009236e8d899c1519566fc8f7e3977b" -dependencies = [ - "bs58 0.5.1", - "proc-macro2", - "quote", - "rustversion", - "syn 2.0.72", -] - [[package]] name = "solana-security-txt" version = "1.1.1" @@ -2380,7 +2305,7 @@ dependencies = [ "serde", "serde_json", "sha3 0.9.1", - "solana-program 1.18.17", + "solana-program", "solana-sdk", "subtle", "thiserror", @@ -2397,7 +2322,7 @@ dependencies = [ "borsh 0.10.3", "num-derive 0.4.2", "num-traits", - "solana-program 1.18.17", + "solana-program", "spl-token", "spl-token-2022 1.0.0", "thiserror", @@ -2410,7 +2335,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cce5d563b58ef1bb2cdbbfe0dfb9ffdc24903b10ae6a4df2d8f425ece375033f" dependencies = [ "bytemuck", - "solana-program 1.18.17", + "solana-program", "spl-discriminator-derive", ] @@ -2444,7 +2369,7 @@ version = "3.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bd0dc6f70db6bacea7ff25870b016a65ba1d1b6013536f08e4fd79a8f9005325" dependencies = [ - "solana-program 1.18.17", + "solana-program", ] [[package]] @@ -2453,7 +2378,7 @@ version = "4.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a49f49f95f2d02111ded31696ab38a081fab623d4c76bd4cb074286db4560836" dependencies = [ - "solana-program 1.18.17", + "solana-program", ] [[package]] @@ -2464,7 +2389,7 @@ checksum = "2881dddfca792737c0706fa0175345ab282b1b0879c7d877bad129645737c079" dependencies = [ "borsh 0.10.3", "bytemuck", - "solana-program 1.18.17", + "solana-program", "solana-zk-token-sdk", "spl-program-error 0.3.0", ] @@ -2477,7 +2402,7 @@ checksum = "af92f74cd3b0fdfda59fef4b571a92123e4df0f67cc43f73163975d31118ef82" dependencies = [ "num-derive 0.3.3", "num-traits", - "solana-program 1.18.17", + "solana-program", "spl-program-error-derive 0.2.0", "thiserror", ] @@ -2490,7 +2415,7 @@ checksum = "249e0318493b6bcf27ae9902600566c689b7dfba9f1bdff5893e92253374e78c" dependencies = [ "num-derive 0.4.2", "num-traits", - "solana-program 1.18.17", + "solana-program", "spl-program-error-derive 0.3.2", "thiserror", ] @@ -2525,7 +2450,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "82149a5a06b5f158d03904066375eaf0c8a2422557cc3d5a25d277260d9a3b16" dependencies = [ "bytemuck", - "solana-program 1.18.17", + "solana-program", "spl-discriminator", "spl-program-error 0.2.0", "spl-type-length-value 0.2.0", @@ -2538,7 +2463,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "615d381f48ddd2bb3c57c7f7fb207591a2a05054639b18a62e785117dd7a8683" dependencies = [ "bytemuck", - "solana-program 1.18.17", + "solana-program", "spl-discriminator", "spl-pod", "spl-program-error 0.3.0", @@ -2556,7 +2481,7 @@ dependencies = [ "num-derive 0.4.2", "num-traits", "num_enum 0.7.3", - "solana-program 1.18.17", + "solana-program", "thiserror", ] @@ -2571,7 +2496,7 @@ dependencies = [ "num-derive 0.3.3", "num-traits", "num_enum 0.6.1", - "solana-program 1.18.17", + "solana-program", "solana-zk-token-sdk", "spl-memo 3.0.1", "spl-token", @@ -2590,7 +2515,7 @@ dependencies = [ "num-derive 0.4.2", "num-traits", "num_enum 0.7.3", - "solana-program 1.18.17", + "solana-program", "solana-security-txt", "solana-zk-token-sdk", "spl-memo 4.0.4", @@ -2610,7 +2535,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b889509d49fa74a4a033ca5dae6c2307e9e918122d97e58562f5c4ffa795c75d" dependencies = [ "bytemuck", - "solana-program 1.18.17", + "solana-program", "spl-discriminator", "spl-pod", "spl-program-error 0.3.0", @@ -2623,7 +2548,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4c16ce3ba6979645fb7627aa1e435576172dd63088dc7848cb09aa331fa1fe4f" dependencies = [ "borsh 0.10.3", - "solana-program 1.18.17", + "solana-program", "spl-discriminator", "spl-pod", "spl-program-error 0.3.0", @@ -2641,7 +2566,7 @@ dependencies = [ "num-derive 0.3.3", "num-traits", "num_enum 0.6.1", - "solana-program 1.18.17", + "solana-program", "spl-discriminator", "spl-tlv-account-resolution 0.2.0", "spl-type-length-value 0.2.0", @@ -2656,7 +2581,7 @@ checksum = "7aabdb7c471566f6ddcee724beb8618449ea24b399e58d464d6b5bc7db550259" dependencies = [ "arrayref", "bytemuck", - "solana-program 1.18.17", + "solana-program", "spl-discriminator", "spl-pod", "spl-program-error 0.3.0", @@ -2671,7 +2596,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f1d085f426b33b8365fb98383d1b8b3925e21bdfe579c851ceaa7f511dbec191" dependencies = [ "bytemuck", - "solana-program 1.18.17", + "solana-program", "spl-discriminator", "spl-program-error 0.2.0", ] @@ -2683,44 +2608,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a468e6f6371f9c69aae760186ea9f1a01c2908351b06a5e0026d21cfc4d7ecac" dependencies = [ "bytemuck", - "solana-program 1.18.17", + "solana-program", "spl-discriminator", "spl-pod", "spl-program-error 0.3.0", ] -[[package]] -name = "steel" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d88c610ca9fd5e4e51bdb6e9964114133a42f006713fe38aff37266fac91e1be" -dependencies = [ - "bytemuck", - "num_enum 0.7.3", - "solana-program 1.18.17", - "thiserror", -] - -[[package]] -name = "steel" -version = "2.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a2ca3cc310b7b71ce7944af64fb4fdaa5d0c2848ac79616d75e401913b6f781" -dependencies = [ - "bytemuck", - "num_enum 0.7.3", - "solana-program 1.18.17", - "thiserror", -] - -[[package]] -name = "steel-hello-solana" -version = "0.1.0" -dependencies = [ - "solana-program 2.0.14", - "steel 1.3.0", -] - [[package]] name = "strsim" version = "0.11.1" @@ -2836,7 +2729,7 @@ version = "0.1.0" dependencies = [ "borsh 0.9.3", "borsh-derive 0.9.3", - "solana-program 1.18.17", + "solana-program", "spl-associated-token-account", "spl-token-2022 0.7.0", ] @@ -2847,7 +2740,7 @@ version = "0.1.0" dependencies = [ "borsh 0.9.3", "borsh-derive 0.9.3", - "solana-program 1.18.17", + "solana-program", "spl-associated-token-account", "spl-token-2022 0.7.0", ] @@ -2858,7 +2751,7 @@ version = "0.1.0" dependencies = [ "borsh 0.9.3", "borsh-derive 0.9.3", - "solana-program 1.18.17", + "solana-program", "spl-associated-token-account", "spl-token-2022 0.7.0", ] @@ -2869,7 +2762,7 @@ version = "0.1.0" dependencies = [ "borsh 0.9.3", "borsh-derive 0.9.3", - "solana-program 1.18.17", + "solana-program", "spl-associated-token-account", "spl-token-2022 0.7.0", ] @@ -2880,7 +2773,7 @@ version = "0.1.0" dependencies = [ "borsh 0.10.3", "borsh-derive 0.9.3", - "solana-program 1.18.17", + "solana-program", "spl-associated-token-account", "spl-token-2022 0.7.0", ] @@ -2963,7 +2856,7 @@ version = "0.1.0" dependencies = [ "borsh 0.9.3", "borsh-derive 0.9.3", - "solana-program 1.18.17", + "solana-program", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 4493f42f..c13e8b8c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,7 +13,6 @@ members = [ "basics/create-account/native/program", "basics/create-account/anchor/programs/create-system-account", "basics/cross-program-invocation/anchor/programs/*", - "basics/favorites/steel/program", "basics/hello-solana/native/program", "basics/hello-solana/anchor/programs/*", "basics/hello-solana/steel/program", diff --git a/basics/favorites/steel/Cargo.toml b/basics/favorites/steel/Cargo.toml new file mode 100644 index 00000000..39fc8ab6 --- /dev/null +++ b/basics/favorites/steel/Cargo.toml @@ -0,0 +1,3 @@ +[workspace] +members = ["program"] +resolver = "2" diff --git a/basics/favorites/steel/program/Cargo.toml b/basics/favorites/steel/program/Cargo.toml index 7b2edb30..e03c8b81 100644 --- a/basics/favorites/steel/program/Cargo.toml +++ b/basics/favorites/steel/program/Cargo.toml @@ -7,7 +7,7 @@ edition = "2021" crate-type = ["cdylib", "lib"] [dependencies] -solana-program = "=1.18.17" +solana-program = "1.18.17" steel = "2.0" bytemuck = "1.14" num_enum = "0.7" diff --git a/basics/favorites/steel/program/src/lib.rs b/basics/favorites/steel/program/src/lib.rs index ee3f61e0..221c0a7e 100644 --- a/basics/favorites/steel/program/src/lib.rs +++ b/basics/favorites/steel/program/src/lib.rs @@ -12,6 +12,10 @@ pub fn process_instruction( accounts: &[AccountInfo], data: &[u8], ) -> ProgramResult { + if program_id.ne(&crate::ID) { + return Err(ProgramError::IncorrectProgramId); + } + let favorites_data = bytemuck::try_from_bytes::(data) .or(Err(ProgramError::InvalidInstructionData))?; @@ -20,7 +24,7 @@ pub fn process_instruction( }; favorites_info.is_writable()?; - favorites_info.has_seeds(&[b"favorites", user.key.as_ref()], program_id)?; + favorites_info.has_seeds(&[FAVORITES_SEED, user.key.as_ref()], &crate::ID)?; // if we have not created our favourites account, let us create it if favorites_info.lamports() == 0 { @@ -28,12 +32,12 @@ pub fn process_instruction( favorites_info, system_program, user, - program_id, - &[b"favorites", user.key.as_ref()], + &crate::ID, + &[FAVORITES_SEED, user.key.as_ref()], )?; } - let favorites = favorites_info.as_account_mut::(program_id)?; + let favorites = favorites_info.as_account_mut::(&crate::ID)?; *favorites = *favorites_data; @@ -68,3 +72,5 @@ pub struct Favorites { pub color: [u8; 48], pub hobbies: [[u8; 48]; 5], } + +pub const FAVORITES_SEED: &[u8] = b"favorites"; diff --git a/basics/favorites/steel/tests/test.ts b/basics/favorites/steel/tests/test.ts index 9abd73ac..efd49719 100644 --- a/basics/favorites/steel/tests/test.ts +++ b/basics/favorites/steel/tests/test.ts @@ -74,7 +74,7 @@ const FavoritesSchema = new Map([ describe('Favorites!', async () => { const favoritesAccount = Keypair.generate(); - const PROGRAM_ID = PublicKey.unique(); + const PROGRAM_ID = new PublicKey('z7msBPQHDJjTvdQRoEcKyENgXDhSRYeHieN1ZMTqo35'); const context = await start([{ name: 'favorites_steel_program', programId: PROGRAM_ID }], []); const client = context.banksClient;