Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extract solana-transaction from solana-sdk #3634

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
38 changes: 38 additions & 0 deletions Cargo.lock

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

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ members = [
"sdk/sysvar",
"sdk/sysvar-id",
"sdk/time-utils",
"sdk/transaction",
"sdk/transaction-context",
"sdk/transaction-error",
"send-transaction-service",
Expand Down Expand Up @@ -563,6 +564,7 @@ solana-sysvar = { path = "sdk/sysvar", version = "=2.2.0" }
solana-sysvar-id = { path = "sdk/sysvar-id", version = "=2.2.0" }
solana-test-validator = { path = "test-validator", version = "=2.2.0" }
solana-thin-client = { path = "thin-client", version = "=2.2.0" }
solana-transaction = { path = "sdk/transaction", version = "=2.2.0" }
solana-transaction-error = { path = "sdk/transaction-error", version = "=2.2.0" }
solana-tpu-client = { path = "tpu-client", version = "=2.2.0", default-features = false }
solana-tpu-client-next = { path = "tpu-client-next", version = "=2.2.0" }
Expand Down
2 changes: 1 addition & 1 deletion gossip/src/protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ pub(crate) const PULL_RESPONSE_MIN_SERIALIZED_SIZE: usize = 161;
#[cfg_attr(
feature = "frozen-abi",
derive(AbiExample, AbiEnumVisitor),
frozen_abi(digest = "D8HvpYCkdo6JweUW61WQ9ZQH2AFvzh3G1qthicnvz4E8")
frozen_abi(digest = "CFvnYRePV1TT51ArsF5Js69ntt1CJpWxJGq4kMJVnNjk")
)]
#[derive(Serialize, Deserialize, Debug)]
#[allow(clippy::large_enum_variant)]
Expand Down
26 changes: 26 additions & 0 deletions programs/sbf/Cargo.lock

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

11 changes: 10 additions & 1 deletion sdk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ full = [
"dep:solana-seed-derivable",
"dep:solana-seed-phrase",
"dep:solana-signer",
"dep:solana-transaction",
"dep:solana-transaction-error",
]
borsh = [
Expand All @@ -60,6 +61,7 @@ dev-context-only-utils = [
"solana-account/dev-context-only-utils",
"solana-compute-budget-interface/dev-context-only-utils",
"solana-rent-debits/dev-context-only-utils",
"solana-transaction/dev-context-only-utils",
"solana-transaction-context/dev-context-only-utils",
]
frozen-abi = [
Expand All @@ -74,7 +76,8 @@ frozen-abi = [
"solana-reward-info/frozen-abi",
"solana-short-vec/frozen-abi",
"solana-signature/frozen-abi",
"solana-transaction-error/frozen-abi",
"solana-transaction/frozen-abi",
"solana-transaction-error/frozen-abi"
]
# Enables the "vendored" feature of openssl inside of secp256r1-program
openssl-vendored = ["solana-precompiles/openssl-vendored"]
Expand Down Expand Up @@ -173,6 +176,12 @@ solana-signature = { workspace = true, features = [
], optional = true }
solana-signer = { workspace = true, optional = true }
solana-time-utils = { workspace = true }
solana-transaction = { workspace = true, features = [
"bincode",
"precompiles",
"serde",
"verify"
], optional = true }
solana-transaction-context = { workspace = true, features = ["bincode"] }
solana-transaction-error = { workspace = true, features = [
"serde",
Expand Down
2 changes: 1 addition & 1 deletion sdk/instruction/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ serde = [
std = []

[package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"]
targets = ["x86_64-unknown-linux-gnu", "wasm32-unknown-unknown"]
all-features = true
rustdoc-args = ["--cfg=docsrs"]

Expand Down
7 changes: 6 additions & 1 deletion sdk/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ pub mod rpc_port;
pub mod shred_version;
pub mod signature;
pub mod signer;
pub mod simple_vote_transaction_checker;
pub mod system_transaction;
pub mod transaction;
pub mod transport;
Expand Down Expand Up @@ -203,6 +202,12 @@ pub use solana_serde_varint as serde_varint;
pub use solana_short_vec as short_vec;
#[deprecated(since = "2.2.0", note = "Use `solana-time-utils` crate instead")]
pub use solana_time_utils as timing;
#[cfg(feature = "full")]
#[deprecated(
since = "2.2.0",
note = "Use `solana_transaction::simple_vote_transaction_checker` instead"
)]
pub use solana_transaction::simple_vote_transaction_checker;
#[deprecated(
since = "2.2.0",
note = "Use `solana-transaction-context` crate instead"
Expand Down
20 changes: 20 additions & 0 deletions sdk/src/transaction.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#[deprecated(since = "2.2.0", note = "Use solana_transaction_error crate instead")]
pub use solana_transaction_error::{
AddressLoaderError, SanitizeMessageError, TransactionError, TransactionResult as Result,
TransportError, TransportResult,
};
#[deprecated(since = "2.2.0", note = "Use solana_transaction crate instead")]
pub use {
solana_program::message::{AddressLoader, SimpleAddressLoader},
solana_transaction::{
sanitized::{
MessageHash, SanitizedTransaction, TransactionAccountLocks, MAX_TX_ACCOUNT_LOCKS,
},
uses_durable_nonce,
versioned::{
sanitized::SanitizedVersionedTransaction, Legacy, TransactionVersion,
VersionedTransaction,
},
Transaction, TransactionVerificationMode,
},
};
57 changes: 3 additions & 54 deletions sdk/src/wasm/transaction.rs
Original file line number Diff line number Diff line change
@@ -1,54 +1,3 @@
//! `Transaction` Javascript interface
#![cfg(target_arch = "wasm32")]
#![allow(non_snake_case)]
use {
crate::{hash::Hash, message::Message, signer::keypair::Keypair, transaction::Transaction},
solana_program::{
pubkey::Pubkey,
wasm::{display_to_jsvalue, instructions::Instructions},
},
wasm_bindgen::prelude::*,
};

#[wasm_bindgen]
impl Transaction {
/// Create a new `Transaction`
#[wasm_bindgen(constructor)]
pub fn constructor(instructions: Instructions, payer: Option<Pubkey>) -> Transaction {
let instructions: Vec<_> = instructions.into();
Transaction::new_with_payer(&instructions, payer.as_ref())
}

/// Return a message containing all data that should be signed.
#[wasm_bindgen(js_name = message)]
pub fn js_message(&self) -> Message {
self.message.clone()
}

/// Return the serialized message data to sign.
pub fn messageData(&self) -> Box<[u8]> {
self.message_data().into()
}

/// Verify the transaction
#[wasm_bindgen(js_name = verify)]
pub fn js_verify(&self) -> Result<(), JsValue> {
self.verify().map_err(display_to_jsvalue)
}

pub fn partialSign(&mut self, keypair: &Keypair, recent_blockhash: &Hash) {
self.partial_sign(&[keypair], *recent_blockhash);
}

pub fn isSigned(&self) -> bool {
self.is_signed()
}

pub fn toBytes(&self) -> Box<[u8]> {
bincode::serialize(self).unwrap().into()
}

pub fn fromBytes(bytes: &[u8]) -> Result<Transaction, JsValue> {
bincode::deserialize(bytes).map_err(display_to_jsvalue)
}
}
//! This module is empty but has not yet been removed because that would
//! technically be a breaking change. There was never anything to import
//! from here.
75 changes: 75 additions & 0 deletions sdk/transaction/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
[package]
name = "solana-transaction"
description = "Solana transaction-types"
documentation = "https://docs.rs/solana-transaction"
version = { workspace = true }
authors = { workspace = true }
repository = { workspace = true }
homepage = { workspace = true }
license = { workspace = true }
edition = { workspace = true }

[dependencies]
bincode = { workspace = true, optional = true }
serde = { workspace = true, optional = true }
serde_derive = { workspace = true, optional = true }
solana-bincode = { workspace = true, optional = true }
solana-feature-set = { workspace = true, optional = true }
solana-frozen-abi = { workspace = true, optional = true }
solana-frozen-abi-macro = { workspace = true, optional = true }
solana-hash = { workspace = true }
solana-instruction = { workspace = true }
solana-logger = { workspace = true, optional = true }
solana-precompiles = { workspace = true, optional = true }
solana-program = { workspace = true }
solana-pubkey = { workspace = true }
solana-reserved-account-keys = { workspace = true }
solana-sanitize = { workspace = true }
solana-sdk-ids = { workspace = true }
solana-short-vec = { workspace = true, optional = true }
solana-signature = { workspace = true }
solana-signer = { workspace = true }
solana-transaction-error = { workspace = true }

[target.'cfg(target_arch = "wasm32")'.dependencies]
solana-keypair = { workspace = true }
wasm-bindgen = { workspace = true }

[dev-dependencies]
anyhow = { workspace = true }
bincode = { workspace = true }
borsh = { workspace = true }
solana-hash = { workspace = true }
solana-instruction = { workspace = true, features = ["borsh"] }
solana-keypair = { workspace = true }
solana-nonce = { workspace = true }
solana-packet = { workspace = true }
solana-presigner = { workspace = true }
solana-program = { workspace = true, default-features = false }
solana-pubkey = { workspace = true, features = ["rand"] }
solana-sdk = { path = ".." }
solana-sha256-hasher = { workspace = true }
solana-transaction = { path = ".", features = ["dev-context-only-utils"] }
static_assertions = { workspace = true }

[features]
bincode = ["dep:bincode", "dep:solana-bincode", "serde"]
dev-context-only-utils = ["bincode", "precompiles", "serde", "verify"]
frozen-abi = [
"dep:solana-frozen-abi",
"dep:solana-frozen-abi-macro",
"dep:solana-logger",
]
precompiles = ["dep:solana-feature-set", "dep:solana-precompiles"]
serde = [
"dep:serde",
"dep:serde_derive",
"dep:solana-short-vec",
"solana-signature/serde",
]
verify = ["solana-signature/verify"]

[package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"]
all-features = true
rustdoc-args = ["--cfg=docsrs"]
Loading
Loading