Skip to content

Commit

Permalink
fix imports and dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinheavey committed Nov 6, 2024
1 parent fa1c493 commit 921b7e6
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 9 deletions.
9 changes: 9 additions & 0 deletions Cargo.lock

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

12 changes: 11 additions & 1 deletion sdk/secp256k1-instruction/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,21 @@ sha3 = { workspace = true }
solana-feature-set = { workspace = true }
solana-instruction = { workspace = true, features = ["std"] }
solana-precompile-error = { workspace = true }
solana-pubkey = { workspace = true, optional = true }

[dev-dependencies]
anyhow = { workspace = true }
hex = { workspace = true }
rand0-7 = { workspace = true }
solana-hash = { workspace = true }
solana-logger = { workspace = true }
solana-program = { path = "../program" }
solana-sdk = { path = ".." }
solana-secp256k1-instruction = { path = ".", features = ["dev-context-only-utils"] }

[features]
bincode = ["dep:bincode", "serde"]
bincode = ["dep:bincode", "dep:solana-pubkey", "serde"]
dev-context-only-utils = ["bincode"]
serde = ["dep:serde", "dep:serde_derive"]

[package.metadata.docs.rs]
Expand Down
24 changes: 16 additions & 8 deletions sdk/secp256k1-instruction/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -796,6 +796,11 @@ pub const SIGNATURE_SERIALIZED_SIZE: usize = 64;
pub const SIGNATURE_OFFSETS_SERIALIZED_SIZE: usize = 11;
pub const DATA_START: usize = SIGNATURE_OFFSETS_SERIALIZED_SIZE + 1;

// inline from solana_sdk::secp256k1_program to avoid solana_sdk dependency
#[cfg(feature = "bincode")]
const SECP256K1_PROGRAM_ID: solana_pubkey::Pubkey =
solana_pubkey::pubkey!("KeccakSecp256k11111111111111111111111111111");

/// Offsets of signature data within a secp256k1 instruction.
///
/// See the [module documentation][md] for a complete description.
Expand Down Expand Up @@ -891,7 +896,7 @@ pub fn new_secp256k1_instruction(
bincode::serialize_into(writer, &offsets).unwrap();

Instruction {
program_id: solana_sdk::secp256k1_program::id(),
program_id: SECP256K1_PROGRAM_ID,
accounts: vec![],
data: instruction_data,
}
Expand Down Expand Up @@ -1031,16 +1036,14 @@ fn get_data_slice<'a>(
pub mod test {
use {
super::*,
crate::{
hash::Hash,
rand0_7::{thread_rng, Rng},
solana_feature_set::FeatureSet,
solana_hash::Hash,
solana_sdk::{
keccak,
secp256k1_instruction::{
new_secp256k1_instruction, SecpSignatureOffsets, SIGNATURE_OFFSETS_SERIALIZED_SIZE,
},
signature::{Keypair, Signer},
signer::{keypair::Keypair, Signer},
transaction::Transaction,
},
rand0_7::{thread_rng, Rng},
};

fn test_case(
Expand Down Expand Up @@ -1306,4 +1309,9 @@ pub mod test {
)
.unwrap();
}

#[test]
fn test_inlined_program_id() {
assert_eq!(SECP256K1_PROGRAM_ID, solana_sdk::secp256k1_program::id());
}
}

0 comments on commit 921b7e6

Please sign in to comment.