Skip to content

Commit

Permalink
Do not panic in the kms::sign() function (#975)
Browse files Browse the repository at this point in the history
Removes unnecessary `unwrap()` call inside the `kms::sign()` function,
which leads to unexpected behavior from the client side.

Also, includes workarounds in order to build the project with outdated
dependencies.
  • Loading branch information
squadgazzz authored Jan 6, 2025
1 parent c4aea8e commit 7979139
Show file tree
Hide file tree
Showing 10 changed files with 20 additions and 17 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/pull-request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
strategy:
matrix:
include:
- rust: 1.70.0
- rust: 1.74.0
examples: false
continue-on-error: false
- rust: stable
Expand Down Expand Up @@ -36,6 +36,9 @@ jobs:
default: true
- uses: Swatinem/rust-cache@v1
- uses: foundry-rs/foundry-toolchain@v1
- uses: actions/setup-node@v3
with:
node-version: '18'
- run: cargo fmt -- --check
- run: cd examples/truffle && yarn --frozen-lockfile && yarn build
# Can't use --all-features here because web3 has mutually exclusive features.
Expand Down
2 changes: 1 addition & 1 deletion ethcontract-common/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ethcontract-common"
version = "0.25.7"
version = "0.25.8"
authors = ["Gnosis developers <[email protected]>"]
edition = "2021"
license = "MIT OR Apache-2.0"
Expand Down
2 changes: 1 addition & 1 deletion ethcontract-common/src/artifact.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ pub struct InsertResult<'a> {
/// but doesn't allow changing its name.
pub struct ContractMut<'a>(&'a mut Contract);

impl<'a> ContractMut<'a> {
impl ContractMut<'_> {
/// Returns mutable reference to contract's abi.
pub fn abi_mut(&mut self) -> &mut Abi {
&mut Arc::make_mut(&mut self.0.interface).abi
Expand Down
2 changes: 1 addition & 1 deletion ethcontract-common/src/bytecode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ impl<'de> Deserialize<'de> for Bytecode {
/// A serde visitor for deserializing bytecode.
struct BytecodeVisitor;

impl<'de> Visitor<'de> for BytecodeVisitor {
impl Visitor<'_> for BytecodeVisitor {
type Value = Bytecode;

fn expecting(&self, f: &mut Formatter) -> FmtResult {
Expand Down
6 changes: 3 additions & 3 deletions ethcontract-derive/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ethcontract-derive"
version = "0.25.7"
version = "0.25.8"
authors = ["Gnosis developers <[email protected]>"]
edition = "2021"
license = "MIT OR Apache-2.0"
Expand All @@ -20,8 +20,8 @@ proc-macro = true

[dependencies]
anyhow = "1.0"
ethcontract-common = { version = "0.25.7", path = "../ethcontract-common" }
ethcontract-generate = { version = "0.25.7", path = "../ethcontract-generate", default-features = false }
ethcontract-common = { version = "0.25.8", path = "../ethcontract-common" }
ethcontract-generate = { version = "0.25.8", path = "../ethcontract-generate", default-features = false }
proc-macro2 = "1.0"
quote = "1.0"
syn = "2.0"
4 changes: 2 additions & 2 deletions ethcontract-generate/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ethcontract-generate"
version = "0.25.7"
version = "0.25.8"
authors = ["Gnosis developers <[email protected]>"]
edition = "2021"
license = "MIT OR Apache-2.0"
Expand All @@ -18,7 +18,7 @@ http = ["curl"]
[dependencies]
anyhow = "1.0"
curl = { version = "0.4", optional = true }
ethcontract-common = { version = "0.25.7", path = "../ethcontract-common" }
ethcontract-common = { version = "0.25.8", path = "../ethcontract-common" }
Inflector = "0.11"
proc-macro2 = "1.0"
quote = "1.0"
Expand Down
6 changes: 3 additions & 3 deletions ethcontract-mock/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ethcontract-mock"
version = "0.25.7"
version = "0.25.8"
authors = ["Gnosis developers <[email protected]>"]
edition = "2021"
license = "MIT OR Apache-2.0"
Expand All @@ -12,12 +12,12 @@ Tools for mocking ethereum contracts.
"""

[dependencies]
ethcontract = { version = "0.25.7", path = "../ethcontract", default-features = false, features = ["derive"] }
ethcontract = { version = "0.25.8", path = "../ethcontract", default-features = false, features = ["derive"] }
hex = "0.4"
mockall = "0.11"
rlp = "0.5"
predicates = "3.0"

[dev-dependencies]
tokio = { version = "1.6", features = ["macros", "rt"] }
ethcontract-derive = { version = "0.25.7", path = "../ethcontract-derive", default-features = false }
ethcontract-derive = { version = "0.25.8", path = "../ethcontract-derive", default-features = false }
6 changes: 3 additions & 3 deletions ethcontract/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ethcontract"
version = "0.25.7"
version = "0.25.8"
authors = ["Gnosis developers <[email protected]>"]
edition = "2021"
license = "MIT OR Apache-2.0"
Expand Down Expand Up @@ -35,8 +35,8 @@ ws-tokio = ["web3/ws-tokio"]
aws-config = { version = "0.55", optional = true }
aws-sdk-kms = { version = "0.28", optional = true }
arrayvec = "0.7"
ethcontract-common = { version = "0.25.7", path = "../ethcontract-common" }
ethcontract-derive = { version = "0.25.7", path = "../ethcontract-derive", optional = true, default-features = false }
ethcontract-common = { version = "0.25.8", path = "../ethcontract-common" }
ethcontract-derive = { version = "0.25.8", path = "../ethcontract-derive", optional = true, default-features = false }
futures = "0.3"
futures-timer = "3.0"
hex = "0.4"
Expand Down
1 change: 1 addition & 0 deletions ethcontract/src/log.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ use web3::Transport;
/// The default poll interval to use for polling logs from the block chain.
#[cfg(not(test))]
pub const DEFAULT_POLL_INTERVAL: Duration = Duration::from_secs(5);
/// The default poll interval to be used in tests.
#[cfg(test)]
pub const DEFAULT_POLL_INTERVAL: Duration = Duration::from_secs(0);

Expand Down
3 changes: 1 addition & 2 deletions ethcontract/src/transaction/kms.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,7 @@ impl Account {
.signing_algorithm(SigningAlgorithmSpec::EcdsaSha256)
.send()
.await
.map_err(aws_sdk_kms::Error::from)
.unwrap();
.map_err(aws_sdk_kms::Error::from)?;
let signature = secp256k1::ecdsa::Signature::from_der(
output.signature().ok_or(Error::InvalidSignature)?.as_ref(),
)
Expand Down

0 comments on commit 7979139

Please sign in to comment.