forked from solana-labs/solana
-
Notifications
You must be signed in to change notification settings - Fork 259
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* minimize solana_program usage in message module * move CompiledInstruction to message module * move AddressLookupTableAccount to message module * update AddressLookupTableAccount import * start extracting message crate * copy ALL_IDS from sysvar module to avoid dependency * update comment * use system-interface crate * re-export message crate in solana-program * fix tests * fix doc links * add doc_auto_cfg * make serde and bincode optional * inline const from solana_nonce * update lock file * remove thiserror * frozen-abi support * missing feature activation * unused import * fix frozen-abi support * missing dep * sort deps * update digest * update system-interface feature activation * update rev * fmt * use published system-interface crate * add test for inlined ALL_IDS * missing wasm-bindgen dep * reduce example_mocks usage * make blake3 optional * post-rebase fix
- Loading branch information
1 parent
52c0382
commit 773e32c
Showing
22 changed files
with
470 additions
and
214 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
[package] | ||
name = "solana-message" | ||
description = "Solana transaction message types." | ||
documentation = "https://docs.rs/solana-message" | ||
version = { workspace = true } | ||
authors = { workspace = true } | ||
repository = { workspace = true } | ||
homepage = { workspace = true } | ||
license = { workspace = true } | ||
edition = { workspace = true } | ||
|
||
[dependencies] | ||
bincode = { workspace = true, optional = true } | ||
blake3 = { workspace = true, features = ["traits-preview"], optional = true } | ||
lazy_static = { workspace = true } | ||
serde = { workspace = true, optional = true } | ||
serde_derive = { workspace = true, optional = true } | ||
solana-bincode = { 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, features = ["std"] } | ||
solana-logger = { workspace = true, optional = true } | ||
solana-pubkey = { workspace = true } | ||
solana-sanitize = { workspace = true } | ||
solana-sdk-ids = { workspace = true } | ||
solana-short-vec = { workspace = true, optional = true } | ||
solana-system-interface = { workspace = true, optional = true, features = [ | ||
"bincode", | ||
] } | ||
solana-transaction-error = { workspace = true } | ||
|
||
[target.'cfg(target_arch = "wasm32")'.dependencies] | ||
wasm-bindgen = { workspace = true } | ||
|
||
[dev-dependencies] | ||
anyhow = { workspace = true } | ||
bitflags = { workspace = true } | ||
borsh = { workspace = true } | ||
itertools = { workspace = true } | ||
serde_json = { workspace = true } | ||
solana-message = { path = ".", features = ["dev-context-only-utils"] } | ||
solana-nonce = { workspace = true } | ||
solana-program = { path = "../program" } | ||
solana-sha256-hasher = { workspace = true } | ||
solana-sysvar = { workspace = true } | ||
static_assertions = { workspace = true } | ||
|
||
[features] | ||
bincode = [ | ||
"dep:bincode", | ||
"dep:solana-bincode", | ||
"dep:solana-system-interface", | ||
"serde", | ||
] | ||
blake3 = ["dep:blake3"] | ||
dev-context-only-utils = ["bincode", "blake3"] | ||
frozen-abi = [ | ||
"dep:solana-frozen-abi", | ||
"dep:solana-frozen-abi-macro", | ||
"dep:solana-logger", | ||
"solana-hash/frozen-abi", | ||
"solana-pubkey/frozen-abi", | ||
] | ||
serde = [ | ||
"dep:serde", | ||
"dep:serde_derive", | ||
"dep:solana-short-vec", | ||
"solana-hash/serde", | ||
"solana-pubkey/serde", | ||
] | ||
|
||
[package.metadata.docs.rs] | ||
targets = ["x86_64-unknown-linux-gnu"] | ||
all-features = true | ||
rustdoc-args = ["--cfg=docsrs"] | ||
|
||
[lints] | ||
workspace = true |
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
2 changes: 1 addition & 1 deletion
2
sdk/program/src/message/address_loader.rs → sdk/message/src/address_loader.rs
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,56 @@ | ||
#[cfg(feature = "serde")] | ||
use serde_derive::{Deserialize, Serialize}; | ||
#[cfg(feature = "frozen-abi")] | ||
use solana_frozen_abi_macro::AbiExample; | ||
use {solana_pubkey::Pubkey, solana_sanitize::Sanitize}; | ||
|
||
/// A compact encoding of an instruction. | ||
/// | ||
/// A `CompiledInstruction` is a component of a multi-instruction [`Message`], | ||
/// which is the core of a Solana transaction. It is created during the | ||
/// construction of `Message`. Most users will not interact with it directly. | ||
/// | ||
/// [`Message`]: crate::Message | ||
#[cfg_attr(feature = "frozen-abi", derive(AbiExample))] | ||
#[cfg_attr( | ||
feature = "serde", | ||
derive(Deserialize, Serialize), | ||
serde(rename_all = "camelCase") | ||
)] | ||
#[derive(Debug, PartialEq, Eq, Clone)] | ||
pub struct CompiledInstruction { | ||
/// Index into the transaction keys array indicating the program account that executes this instruction. | ||
pub program_id_index: u8, | ||
/// Ordered indices into the transaction keys array indicating which accounts to pass to the program. | ||
#[cfg_attr(feature = "serde", serde(with = "solana_short_vec"))] | ||
pub accounts: Vec<u8>, | ||
/// The program input data. | ||
#[cfg_attr(feature = "serde", serde(with = "solana_short_vec"))] | ||
pub data: Vec<u8>, | ||
} | ||
|
||
impl Sanitize for CompiledInstruction {} | ||
|
||
impl CompiledInstruction { | ||
#[cfg(feature = "bincode")] | ||
pub fn new<T: serde::Serialize>(program_ids_index: u8, data: &T, accounts: Vec<u8>) -> Self { | ||
let data = bincode::serialize(data).unwrap(); | ||
Self { | ||
program_id_index: program_ids_index, | ||
accounts, | ||
data, | ||
} | ||
} | ||
|
||
pub fn new_from_raw_parts(program_id_index: u8, data: Vec<u8>, accounts: Vec<u8>) -> Self { | ||
Self { | ||
program_id_index, | ||
accounts, | ||
data, | ||
} | ||
} | ||
|
||
pub fn program_id<'a>(&self, program_ids: &'a [Pubkey]) -> &'a Pubkey { | ||
&program_ids[self.program_id_index as usize] | ||
} | ||
} |
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
Oops, something went wrong.