diff --git a/cmd/crates/stellar-ledger/Cargo.toml b/cmd/crates/stellar-ledger/Cargo.toml index 69764c7b08..b277dce013 100644 --- a/cmd/crates/stellar-ledger/Cargo.toml +++ b/cmd/crates/stellar-ledger/Cargo.toml @@ -32,7 +32,6 @@ home = "0.5.9" tokio = { version = "1", features = ["full"] } reqwest = { version = "0.11", features = ["json"]} soroban-rpc.workspace = true -async-trait.workspace = true testcontainers = { git = "https://github.com/testcontainers/testcontainers-rs.git", rev = "4b3e4f08a2c0bdf521636b03f959f004e6d216aa" } phf = { version = "0.11.2", features = ["macros"] } futures = "0.3.30" diff --git a/cmd/crates/stellar-ledger/src/lib.rs b/cmd/crates/stellar-ledger/src/lib.rs index e09545b805..0af551646a 100644 --- a/cmd/crates/stellar-ledger/src/lib.rs +++ b/cmd/crates/stellar-ledger/src/lib.rs @@ -1,5 +1,4 @@ mod transport_zemu_http; -use async_trait::async_trait; use futures::executor::block_on; use ledger_transport::{APDUCommand, Exchange}; use ledger_transport_hid::{ @@ -272,7 +271,6 @@ where } } -#[async_trait] impl Stellar for LedgerSigner { type Init = LedgerOptions; diff --git a/cmd/crates/stellar-ledger/src/signer.rs b/cmd/crates/stellar-ledger/src/signer.rs index 0da8a42f17..e403c19ec1 100644 --- a/cmd/crates/stellar-ledger/src/signer.rs +++ b/cmd/crates/stellar-ledger/src/signer.rs @@ -1,8 +1,6 @@ -use ed25519_dalek::Signer; -use ledger_transport::async_trait; use sha2::{Digest, Sha256}; use soroban_env_host::xdr::{ - self, DecoratedSignature, Limits, Signature, SignatureHint, Transaction, TransactionEnvelope, + self, DecoratedSignature, Limits, Transaction, TransactionEnvelope, TransactionSignaturePayload, TransactionSignaturePayloadTaggedTransaction, TransactionV1Envelope, WriteXdr, }; @@ -16,7 +14,6 @@ pub enum Error { } /// A trait for signing Stellar transactions and Soroban authorization entries -#[async_trait] pub trait Stellar { /// The type of the options that can be passed when creating a new signer type Init; @@ -56,61 +53,3 @@ pub trait Stellar { })) } } -struct DefaultSigner { - network_passphrase: String, - keypairs: Vec, -} - -impl DefaultSigner { - pub fn get_key( - &self, - key: &stellar_strkey::Strkey, - ) -> Result<&ed25519_dalek::SigningKey, Error> { - match key { - stellar_strkey::Strkey::PublicKeyEd25519(stellar_strkey::ed25519::PublicKey(bytes)) => { - self.keypairs - .iter() - .find(|k| k.verifying_key().to_bytes() == *bytes) - } - _ => None, - } - .ok_or_else(|| { - Error::RpcError(RpcError::MissingSignerForAddress { - address: key.to_string(), - }) - }) - } -} - -#[async_trait] -impl Stellar for DefaultSigner { - type Init = Vec; - fn new(network_passphrase: &str, options: Option>) -> Self { - DefaultSigner { - network_passphrase: network_passphrase.to_string(), - keypairs: options.unwrap_or_default(), - } - } - - fn sign_txn_hash( - &self, - txn: [u8; 32], - source_account: &stellar_strkey::Strkey, - ) -> Result { - let source_account = self.get_key(source_account)?; - let tx_signature = source_account.sign(&txn); - Ok(DecoratedSignature { - // TODO: remove this unwrap. It's safe because we know the length of the array - hint: SignatureHint( - source_account.verifying_key().to_bytes()[28..] - .try_into() - .unwrap(), - ), - signature: Signature(tx_signature.to_bytes().try_into().unwrap()), //FIXME: remove unwrap - }) - } - - fn network_hash(&self) -> xdr::Hash { - xdr::Hash(Sha256::digest(self.network_passphrase.as_bytes()).into()) - } -}