-
Notifications
You must be signed in to change notification settings - Fork 254
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
Changes from 22 commits
db3972b
b25ea7d
4cf2f68
f28750c
29a5956
cc9188a
f2ba2fe
50bee51
16e42e9
5efd4ba
3a299bf
3186832
37058f0
6c29379
20b61ec
1a36b04
97f389f
e22445e
8b0db58
11a6137
183dcf3
3ed1367
f3faa9d
26901da
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#![cfg(feature = "full")] | ||
#[deprecated(since = "2.2.0", note = "Use solana_transaction_error crate instead")] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: all of these re-exports except for |
||
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, | ||
}, | ||
}; |
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's this change for?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't remember why it happened in this PR but it is a good change, otherwise you can't see the wasm-specific code on docs.rs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's possible i meant to add it for the solana-transaction crate. But it matters for solana-instruction too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it's not needed, let's make the change in a separate PR. That way we can add it to all of the affected crates at once. I put in #3901 for it