From cc129b6bfaabafb3e57d84e89149811b8bab71ca Mon Sep 17 00:00:00 2001 From: chizor iwuh Date: Sat, 2 Nov 2024 23:01:32 +0100 Subject: [PATCH] escrow/steel - use workspaces, avoid conflicts --- Cargo.lock | 223 ++++-------------- Cargo.toml | 1 - tokens/escrow/steel/Cargo.toml | 3 + tokens/escrow/steel/program/Cargo.toml | 4 +- .../program/src/instructions/make_offer.rs | 12 +- .../program/src/instructions/take_offer.rs | 12 +- tokens/escrow/steel/program/src/lib.rs | 10 +- 7 files changed, 60 insertions(+), 205 deletions(-) create mode 100644 tokens/escrow/steel/Cargo.toml diff --git a/Cargo.lock b/Cargo.lock index ad7b5a4af..f54b45b7b 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", ] @@ -439,12 +439,6 @@ version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" -[[package]] -name = "az" -version = "1.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b7e4c2464d97fe331d41de9d5db0def0a96f4d823b8b32a2efd503578988973" - [[package]] name = "base64" version = "0.12.3" @@ -457,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" @@ -750,7 +738,7 @@ dependencies = [ name = "checking-accounts-program" version = "0.1.0" dependencies = [ - "solana-program 1.18.17", + "solana-program", ] [[package]] @@ -777,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]] @@ -819,7 +807,7 @@ version = "0.1.0" dependencies = [ "borsh 0.9.3", "shank", - "solana-program 1.18.17", + "solana-program", ] [[package]] @@ -827,7 +815,7 @@ name = "counter-solana-native" version = "0.1.0" dependencies = [ "borsh 0.9.3", - "solana-program 1.18.17", + "solana-program", ] [[package]] @@ -850,7 +838,7 @@ dependencies = [ name = "create-account-program" version = "0.1.0" dependencies = [ - "solana-program 1.18.17", + "solana-program", ] [[package]] @@ -1066,36 +1054,12 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" -[[package]] -name = "escrow-steel-program" -version = "0.1.0" -dependencies = [ - "bytemuck", - "fixed", - "num_enum 0.7.3", - "solana-program 1.18.17", - "spl-token", - "steel 2.1.1", -] - [[package]] name = "feature-probe" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "835a3dc7d1ec9e75e2b5fb4ba75396837112d2060b03f7d43bc1897c7f7211da" -[[package]] -name = "fixed" -version = "1.27.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2fc715d38bea7b5bf487fcd79bcf8c209f0b58014f3018a7a19c2b855f472048" -dependencies = [ - "az", - "bytemuck", - "half", - "typenum", -] - [[package]] name = "fnv" version = "1.0.7" @@ -1139,16 +1103,6 @@ dependencies = [ "wasm-bindgen", ] -[[package]] -name = "half" -version = "2.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6dd08c532ae367adf81c312a4580bc67f1d0fe8bc9c460520283f4c0ff277888" -dependencies = [ - "cfg-if", - "crunchy", -] - [[package]] name = "hand" version = "0.1.0" @@ -1200,7 +1154,7 @@ dependencies = [ name = "hello-solana-program" version = "0.1.0" dependencies = [ - "solana-program 1.18.17", + "solana-program", ] [[package]] @@ -1617,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]] @@ -1720,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]] @@ -1729,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]] @@ -1738,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]] @@ -1876,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]] @@ -1930,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]] @@ -2248,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" @@ -2349,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", @@ -2369,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" @@ -2410,7 +2305,7 @@ dependencies = [ "serde", "serde_json", "sha3 0.9.1", - "solana-program 1.18.17", + "solana-program", "solana-sdk", "subtle", "thiserror", @@ -2427,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", @@ -2440,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", ] @@ -2474,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]] @@ -2483,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]] @@ -2494,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", ] @@ -2507,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", ] @@ -2520,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", ] @@ -2555,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", @@ -2568,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", @@ -2586,7 +2481,7 @@ dependencies = [ "num-derive 0.4.2", "num-traits", "num_enum 0.7.3", - "solana-program 1.18.17", + "solana-program", "thiserror", ] @@ -2601,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", @@ -2620,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", @@ -2640,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", @@ -2653,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", @@ -2671,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", @@ -2686,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", @@ -2701,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", ] @@ -2713,46 +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", - "spl-associated-token-account", - "spl-token", - "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" @@ -2868,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", ] @@ -2879,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", ] @@ -2890,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", ] @@ -2901,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", ] @@ -2912,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", ] @@ -2995,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 6c6266c4b..c13e8b8c0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -30,7 +30,6 @@ members = [ "basics/repository-layout/anchor/programs/*", "basics/transfer-sol/native/program", "basics/transfer-sol/anchor/programs/*", - "tokens/escrow/steel/program", "tokens/token-2022/mint-close-authority/native/program", "tokens/token-2022/non-transferable/native/program", "tokens/token-2022/default-account-state/native/program", diff --git a/tokens/escrow/steel/Cargo.toml b/tokens/escrow/steel/Cargo.toml new file mode 100644 index 000000000..39fc8ab65 --- /dev/null +++ b/tokens/escrow/steel/Cargo.toml @@ -0,0 +1,3 @@ +[workspace] +members = ["program"] +resolver = "2" diff --git a/tokens/escrow/steel/program/Cargo.toml b/tokens/escrow/steel/program/Cargo.toml index 41f6a19d2..c40b5996d 100644 --- a/tokens/escrow/steel/program/Cargo.toml +++ b/tokens/escrow/steel/program/Cargo.toml @@ -7,8 +7,8 @@ edition = "2021" crate-type = ["cdylib", "lib"] [dependencies] -solana-program = "=1.18.17" -steel = {version ="2.0", features=["spl"]} +solana-program = "1.18.17" +steel = {version ="2.1", features=["spl"]} bytemuck = "1.14" num_enum = "0.7" fixed = "=1.27.0" diff --git a/tokens/escrow/steel/program/src/instructions/make_offer.rs b/tokens/escrow/steel/program/src/instructions/make_offer.rs index 0ccd701e7..68ef870bc 100644 --- a/tokens/escrow/steel/program/src/instructions/make_offer.rs +++ b/tokens/escrow/steel/program/src/instructions/make_offer.rs @@ -14,11 +14,7 @@ pub struct MakeOffer { } impl MakeOffer { - pub fn process( - program_id: &Pubkey, - accounts: &[AccountInfo<'_>], - data: &[u8], - ) -> ProgramResult { + pub fn process(accounts: &[AccountInfo<'_>], data: &[u8]) -> ProgramResult { let args = MakeOffer::try_from_bytes(data)?; let [ // accounts order @@ -45,7 +41,7 @@ impl MakeOffer { maker_token_account_a.as_associated_token_account(maker.key, token_mint_a.key)?; let offer_seeds = &[Offer::SEEDS, maker.key.as_ref(), &args.id.to_le_bytes()]; - let (offer_address, offer_bump) = Pubkey::find_program_address(offer_seeds, program_id); + let (offer_address, offer_bump) = Pubkey::find_program_address(offer_seeds, &crate::ID); // check we have the right address, derived from the provided seeds // @@ -53,7 +49,7 @@ impl MakeOffer { // create the offer account // - create_account::(offer_info, system_program, payer, program_id, offer_seeds)?; + create_account::(offer_info, system_program, payer, &crate::ID, offer_seeds)?; // create the vault token account, where the maker will send funds to // @@ -81,7 +77,7 @@ impl MakeOffer { args.token_a_offered_amount, )?; - let offer = offer_info.as_account_mut::(program_id)?; + let offer = offer_info.as_account_mut::(&crate::ID)?; // we record our offer data // diff --git a/tokens/escrow/steel/program/src/instructions/take_offer.rs b/tokens/escrow/steel/program/src/instructions/take_offer.rs index 053d3e2bc..a4c28a281 100644 --- a/tokens/escrow/steel/program/src/instructions/take_offer.rs +++ b/tokens/escrow/steel/program/src/instructions/take_offer.rs @@ -10,7 +10,7 @@ instruction!(EscrowInstruction, TakeOffer); pub struct TakeOffer {} impl TakeOffer { - pub fn process(program_id: &Pubkey, accounts: &[AccountInfo<'_>]) -> ProgramResult { + pub fn process(accounts: &[AccountInfo<'_>]) -> ProgramResult { let [ // accounts order offer_info, @@ -37,7 +37,7 @@ impl TakeOffer { // Validate the offer // let offer = offer_info - .as_account::(program_id)? + .as_account::(&crate::ID)? .assert(|offer| { offer.maker == *maker.key && offer.token_mint_a == *token_mint_a.key @@ -48,7 +48,7 @@ impl TakeOffer { // validate offer account // - offer_info.has_seeds(offer_seeds, program_id)?; + offer_info.has_seeds(offer_seeds, &crate::ID)?; // Create taker token a account, if needed // @@ -155,9 +155,9 @@ impl TakeOffer { invoke_signed_with_bump( &spl_token::instruction::close_account( token_program.key, // token program - vault.key, // token account to close - taker.key, // account to transfer lamports - offer_info.key, // token account ownder + vault.key, // token account to close + taker.key, // account to transfer lamports + offer_info.key, // token account ownder &[offer_info.key], // signer pubkeys )?, &[vault.clone(), taker.clone(), offer_info.clone()], diff --git a/tokens/escrow/steel/program/src/lib.rs b/tokens/escrow/steel/program/src/lib.rs index 8258b9bff..d790a7421 100644 --- a/tokens/escrow/steel/program/src/lib.rs +++ b/tokens/escrow/steel/program/src/lib.rs @@ -13,15 +13,11 @@ pub fn process_instruction( accounts: &[AccountInfo], data: &[u8], ) -> ProgramResult { - // use `crate::ID` as program_id in your program - // - // e.g parse_instruction(&crate::ID, program_id, data) - // - let (ix, data) = parse_instruction(program_id, program_id, data)?; + let (ix, data) = parse_instruction(&crate::ID, program_id, data)?; match ix { - EscrowInstruction::MakeOffer => MakeOffer::process(program_id, accounts, data)?, - EscrowInstruction::TakeOffer => TakeOffer::process(program_id, accounts)?, + EscrowInstruction::MakeOffer => MakeOffer::process(accounts, data)?, + EscrowInstruction::TakeOffer => TakeOffer::process(accounts)?, } Ok(())