Skip to content
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

chore(deps): bump trezor-client #206

Merged
merged 1 commit into from
Feb 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions crates/signer-trezor/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ alloy-network.workspace = true
alloy-primitives.workspace = true
alloy-signer.workspace = true

# TODO: bump this and remove protobuf pin
trezor-client = { version = "=0.1.0", default-features = false, features = ["ethereum"] }
protobuf = "=3.2.0"
trezor-client = { version = "=0.1.3", default-features = false, features = ["ethereum"] }

async-trait.workspace = true
semver.workspace = true
Expand Down
3 changes: 0 additions & 3 deletions crates/signer-trezor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@
#[macro_use]
extern crate tracing;

// TODO: Needed to pin version.
use protobuf as _;

mod signer;
pub use signer::TrezorSigner;

Expand Down
25 changes: 11 additions & 14 deletions crates/signer-trezor/src/signer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,13 @@ impl Signer for TrezorSigner {

#[inline]
async fn sign_transaction(&self, tx: &mut SignableTx) -> Result<Signature> {
// TODO: the Trezor Ethereum sign transaction protobufs don't require a chain ID, but the
// trezor-client API does not reflect this.
// https://github.com/trezor/trezor-firmware/pull/3482
let chain_id = if let Some(chain_id) = self.chain_id {
if let Some(chain_id) = self.chain_id {
tx.set_chain_id_checked(chain_id)?;
chain_id
} else {
tx.chain_id().ok_or(TrezorError::MissingChainId).map_err(alloy_signer::Error::other)?
};
let mut sig = self.sign_tx_inner(tx, chain_id).await.map_err(alloy_signer::Error::other)?;
sig = sig.with_chain_id(chain_id);
}
let mut sig = self.sign_tx_inner(tx).await.map_err(alloy_signer::Error::other)?;
if let Some(chain_id) = self.chain_id.or_else(|| tx.chain_id()) {
sig = sig.with_chain_id(chain_id);
}
Ok(sig)
}

Expand Down Expand Up @@ -162,7 +158,6 @@ impl TrezorSigner {
async fn sign_tx_inner(
&self,
tx: &dyn Transaction<Signature = Signature>,
chain_id: ChainId,
) -> Result<Signature, TrezorError> {
let mut client = self.get_client()?;
let path = Self::convert_path(&self.derivation);
Expand All @@ -185,6 +180,7 @@ impl TrezorSigner {
let value = u256_to_trezor(value);

let data = tx.input().to_vec();
let chain_id = tx.chain_id();

// TODO: Uncomment in 1.76
/*
Expand Down Expand Up @@ -272,9 +268,10 @@ fn address_to_trezor(x: &Address) -> String {
}

fn signature_from_trezor(x: trezor_client::client::Signature) -> Result<Signature, TrezorError> {
let s = U256::from_limbs(x.s.0);
let r = U256::from_limbs(x.r.0);
Signature::from_rs_and_parity(r, s, Parity::Eip155(x.v)).map_err(Into::into)
let r = U256::from_be_bytes(x.r);
let s = U256::from_be_bytes(x.s);
let v = Parity::Eip155(x.v);
Signature::from_rs_and_parity(r, s, v).map_err(Into::into)
}

#[cfg(test)]
Expand Down
Loading