From 81a84cd5e9b2b84d0e8dbbdbcb4767f0ca362d71 Mon Sep 17 00:00:00 2001 From: Kevin Heavey Date: Tue, 3 Dec 2024 17:21:04 +0400 Subject: [PATCH] move program::wasm::instructions to instruction crate (#3874) * move program::wasm::instructions to instruction crate * fmt * unify cfg usage --- sdk/instruction/src/lib.rs | 2 ++ .../wasm/instructions.rs => instruction/src/wasm.rs} | 10 +++++----- sdk/program/src/wasm/mod.rs | 4 ++-- 3 files changed, 9 insertions(+), 7 deletions(-) rename sdk/{program/src/wasm/instructions.rs => instruction/src/wasm.rs} (63%) diff --git a/sdk/instruction/src/lib.rs b/sdk/instruction/src/lib.rs index 12431ba513f91d..673d379c712109 100644 --- a/sdk/instruction/src/lib.rs +++ b/sdk/instruction/src/lib.rs @@ -26,6 +26,8 @@ pub use account_meta::AccountMeta; pub mod error; #[cfg(target_os = "solana")] pub mod syscalls; +#[cfg(all(feature = "std", target_arch = "wasm32"))] +pub mod wasm; /// A directive for a single invocation of a Solana program. /// diff --git a/sdk/program/src/wasm/instructions.rs b/sdk/instruction/src/wasm.rs similarity index 63% rename from sdk/program/src/wasm/instructions.rs rename to sdk/instruction/src/wasm.rs index 36abe05c6f4d8d..03c88bb757a49f 100644 --- a/sdk/program/src/wasm/instructions.rs +++ b/sdk/instruction/src/wasm.rs @@ -1,12 +1,12 @@ -//! The `Instructions` struct is a workaround for the lack of Vec support in wasm-bindgen +//! The `Instructions` struct is a legacy workaround +//! from when wasm-bindgen lacked Vec support //! (ref: https://github.com/rustwasm/wasm-bindgen/issues/111) -#![cfg(target_arch = "wasm32")] -use {crate::instruction::Instruction, wasm_bindgen::prelude::*}; +use {crate::Instruction, wasm_bindgen::prelude::*}; #[wasm_bindgen] #[derive(Default)] pub struct Instructions { - instructions: Vec, + instructions: std::vec::Vec, } #[wasm_bindgen] @@ -21,7 +21,7 @@ impl Instructions { } } -impl From for Vec { +impl From for std::vec::Vec { fn from(instructions: Instructions) -> Self { instructions.instructions } diff --git a/sdk/program/src/wasm/mod.rs b/sdk/program/src/wasm/mod.rs index cdf5bdca138482..337dfb1dbd4887 100644 --- a/sdk/program/src/wasm/mod.rs +++ b/sdk/program/src/wasm/mod.rs @@ -1,8 +1,8 @@ //! solana-program Javascript interface #![cfg(target_arch = "wasm32")] +#[deprecated(since = "2.2.0", note = "Use solana_instruction::wasm instead.")] +pub use solana_instruction::wasm as instructions; use wasm_bindgen::prelude::*; - -pub mod instructions; // This module is intentionally left empty. The wasm system instruction impl can be // found in the `solana-system-interface` crate. pub mod system_instruction {}