forked from solana-labs/solana
-
Notifications
You must be signed in to change notification settings - Fork 254
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extract solana-transaction from solana-sdk (#3634)
* extract transaction crate * make serde and bincode optional * fix frozen-abi support * missing dep for frozen-abi * update digest * fix circular dep * fmt * missing feature activation * add doc_auto_cfg * add "wasm32-unknown-unknown" to doc targets * make solana-feature-set optional * inline some consts * fix wasm support * update expected error * update expected error * missing #![cfg(feature = "full")] * update digest * update digest * remove solana-program (except for dev deps) * add wasm32-unknown-unknown to doc targets * update docs links * tighten deps * remove extraneous commit * use explicit link
- Loading branch information
1 parent
f294b99
commit e4e232c
Showing
17 changed files
with
514 additions
and
268 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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")] | ||
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, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
Oops, something went wrong.