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

Fixes for new clippy lints / rustc warnings #369

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
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
15 changes: 14 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[workspace]
resolver = "2"

# this is for the new crate structure. The legacy code (current CML) still resides in the `rust` directory.
members = [
Expand Down Expand Up @@ -32,4 +33,16 @@ exclude = [

[profile.release]
lto = true
opt-level = "z"
opt-level = "z"

[workspace.dependencies]
cbor_event = "2.4.0"
hex = "0.4.0"
linked-hash-map = "0.5.3"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0.57"
serde-wasm-bindgen = "0.4.5"
wasm-bindgen = { version = "0.2.97" }
schemars = "0.8.8"
derivative = "2.2.0"
thiserror = "1.0.37"
16 changes: 8 additions & 8 deletions chain/rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,23 @@ used_from_wasm = ["wasm-bindgen"]
[dependencies]
cml-core = { "path" = "../../core/rust", version = "6.0.1" }
cml-crypto = { "path" = "../../crypto/rust", version = "6.0.1" }
cbor_event = "2.2.0"
linked-hash-map = "0.5.3"
derivative = "2.2.0"
serde = { version = "1.0", features = ["derive"] }
cbor_event.workspace = true
linked-hash-map.workspace = true
derivative.workspace = true
serde.workspace = true
serde_json = { version = "1.0.57", features = ["arbitrary_precision"] }
schemars = "0.8.8"
schemars.workspace = true

bech32 = "0.7.2"
hex = "0.4.0"
hex.workspace = true
itertools = "0.10.1"
getrandom = { version = "0.2.3", features = ["js"] }
rand = "0.8.5"
fraction = "0.10.0"
base64 = "0.21.5"
num-bigint = "0.4.0"
num-integer = "0.1.45"
thiserror = "1.0.37"
thiserror.workspace = true
num = "0.4"
unicode-segmentation = "1.10.1"
chrono = "0.4.38"
Expand All @@ -44,7 +44,7 @@ chrono = "0.4.38"
noop_proc_macro = { version = "0.3.0", optional = false }

# wasm
wasm-bindgen = { version = "0.2.87", optional = true }
wasm-bindgen = { version = "0.2.97", optional = true }


[dev-dependencies]
Expand Down
7 changes: 2 additions & 5 deletions chain/rust/src/builders/witness_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,11 +140,8 @@ impl RequiredWitnessSet {
// }

pub fn add_script_hash(&mut self, script_hash: ScriptHash) {
match self.script_refs.get(&script_hash) {
None => {
self.scripts.insert(script_hash);
}
Some(_) => {}
if !self.script_refs.contains(&script_hash) {
self.scripts.insert(script_hash);
}
}

Expand Down
6 changes: 3 additions & 3 deletions chain/rust/src/byron/base58.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ pub fn decode(input: &str) -> Result<Vec<u8>> {
base_decode(ALPHABET, input.as_bytes())
}

/// decode from base58 the given input
//pub fn decode_bytes(input: &[u8]) -> Result<Vec<u8>> {
// /// decode from base58 the given input
// pub fn decode_bytes(input: &[u8]) -> Result<Vec<u8>> {
// base_decode(ALPHABET, input)
//}
// }

fn base_encode(alphabet_s: &str, input: &[u8]) -> Vec<u8> {
let alphabet = alphabet_s.as_bytes();
Expand Down
2 changes: 1 addition & 1 deletion chain/rust/src/byron/crc32.rs
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ impl Crc32 {
/// beware that the order in which you update the Crc32
/// matter.
#[inline]
pub fn update<'a, I>(&'a mut self, bytes: I) -> &mut Self
pub fn update<'a, I>(&'a mut self, bytes: I) -> &'a mut Self
where
I: IntoIterator<Item = &'a u8>,
{
Expand Down
1 change: 0 additions & 1 deletion chain/rust/src/genesis/byron/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ use cml_crypto::{

/// Configuration for the wallet-crypto
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Clone, Copy)]
#[cfg_attr(feature = "generic-serialization", derive(Serialize, Deserialize))]
pub struct Config {
pub protocol_magic: ProtocolMagic,
}
Expand Down
6 changes: 3 additions & 3 deletions chain/rust/src/genesis/shelley/raw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ use crate::assets::Coin;
use serde::{Deserialize, Serialize};
use std::collections::HashMap;

/// Parsing of the JSON representation of the Shelley genesis block
/// Note: for a lot of these fields, I didn't check what the max valid size is in the Haskell code
/// so I just used u64 everywhere
// Parsing of the JSON representation of the Shelley genesis block
// Note: for a lot of these fields, I didn't check what the max valid size is in the Haskell code
// so I just used u64 everywhere

#[allow(non_snake_case)]
#[derive(Serialize, Deserialize, Debug)]
Expand Down
12 changes: 6 additions & 6 deletions chain/wasm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ cml-core-wasm = { path = "../../core/wasm", version = "6.0.1" }
# TODO: remove this dependency if possible to reduce confusion? maybe pub export necessary things in crypto-wasm?
cml-crypto = { path = "../../crypto/rust", version = "6.0.1" }
cml-crypto-wasm = { path = "../../crypto/wasm", version = "6.0.1" }
cbor_event = "2.4.0"
hex = "0.4.0"
wasm-bindgen = { version = "0.2.87" }
linked-hash-map = "0.5.3"
serde_json = "1.0.57"
serde-wasm-bindgen = "0.4.5"
cbor_event.workspace = true
hex.workspace = true
wasm-bindgen.workspace = true
linked-hash-map.workspace = true
serde_json.workspace = true
serde-wasm-bindgen.workspace = true
14 changes: 7 additions & 7 deletions cip25/rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ crate-type = ["cdylib", "rlib"]
cml-chain = { "path" = "../../chain/rust", version = "6.0.1" }
cml-core = { "path" = "../../core/rust", version = "6.0.1" }
cml-crypto = { "path" = "../../crypto/rust", version = "6.0.1" }
cbor_event = "2.2.0"
hex = "0.4.0"
schemars = "0.8.8"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0.57"
thiserror = "1.0.37"
cbor_event.workspace = true
hex.workspace = true
schemars.workspace = true
serde.workspace = true
serde_json.workspace = true
thiserror.workspace = true
# for enums
wasm-bindgen = { version = "0.2.87" }
wasm-bindgen.workspace = true
12 changes: 6 additions & 6 deletions cip25/wasm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ keywords = ["cardano", "cip25"]
crate-type = ["cdylib", "rlib"]

[dependencies]
cbor_event = "2.2.0"
cbor_event.workspace = true
cml-chain = { path = "../../chain/rust", version = "6.0.1", features = ["used_from_wasm"] }
cml-chain-wasm = { path = "../../chain/wasm", version = "6.0.1" }
cml-core = { path = "../../core/rust", version = "6.0.1" }
cml-core-wasm = { path = "../../core/wasm", version = "6.0.1" }
cml-cip25 = { path = "../rust", version = "6.0.1" }
hex = "0.4.0"
linked-hash-map = "0.5.3"
serde_json = "1.0.57"
serde-wasm-bindgen = "0.4.5"
wasm-bindgen = { version = "0.2.87" }
hex.workspace = true
linked-hash-map.workspace = true
serde_json.workspace = true
serde-wasm-bindgen.workspace = true
wasm-bindgen.workspace = true
16 changes: 8 additions & 8 deletions cip36/rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ crate-type = ["cdylib", "rlib"]
cml-core = { "path" = "../../core/rust", version = "6.0.1" }
cml-crypto = { "path" = "../../crypto/rust", version = "6.0.1" }
cml-chain = { "path" = "../../chain/rust", version = "6.0.1" }
cbor_event = "2.2.0"
linked-hash-map = "0.5.3"
derivative = "2.2.0"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0.57"
schemars = "0.8.8"
hex = "0.4.0"
thiserror = "1.0.37"
cbor_event.workspace = true
linked-hash-map.workspace = true
derivative.workspace = true
serde.workspace = true
serde_json.workspace = true
schemars.workspace = true
hex.workspace = true
thiserror.workspace = true
12 changes: 6 additions & 6 deletions cip36/wasm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ cml-chain = { path = "../../chain/rust", version = "6.0.1" }
cml-chain-wasm = { path = "../../chain/wasm", version = "6.0.1" }
cml-core = { path = "../../core/rust", version = "6.0.1" }
cml-core-wasm = { path = "../../core/wasm", version = "6.0.1" }
cbor_event = "2.2.0"
hex = "0.4.0"
wasm-bindgen = { version = "0.2.87" }
linked-hash-map = "0.5.3"
serde_json = "1.0.57"
serde-wasm-bindgen = "0.4.5"
cbor_event.workspace = true
hex.workspace = true
wasm-bindgen.workspace = true
linked-hash-map.workspace = true
serde_json.workspace = true
serde-wasm-bindgen.workspace = true
12 changes: 6 additions & 6 deletions cml/wasm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ cml-cip25-wasm = { path = "../../cip25/wasm", version = "6.0.1" }
cml-cip36-wasm = { path = "../../cip36/wasm", version = "6.0.1" }
cml-crypto-wasm = { path = "../../crypto/wasm", version = "6.0.1" }
cml-core-wasm = { path = "../../core/wasm", version = "6.0.1" }
cbor_event = "2.4.0"
hex = "0.4.0"
linked-hash-map = "0.5.3"
serde_json = "1.0.57"
serde-wasm-bindgen = "0.4.5"
wasm-bindgen = { version = "0.2.87" }
cbor_event.workspace = true
hex.workspace = true
linked-hash-map.workspace = true
serde_json.workspace = true
serde-wasm-bindgen.workspace = true
wasm-bindgen.workspace = true
16 changes: 8 additions & 8 deletions core/rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ keywords = ["cardano"]
crate-type = ["cdylib", "rlib"]

[dependencies]
cbor_event = "2.2.0"
linked-hash-map = "0.5.3"
derivative = "2.2.0"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0.57"
schemars = "0.8.8"
cbor_event.workspace = true
linked-hash-map.workspace = true
derivative.workspace = true
serde.workspace = true
serde_json.workspace = true
schemars.workspace = true

bech32 = "0.7.2"
hex = "0.4.0"
hex.workspace = true
itertools = "0.10.1"
getrandom = { version = "0.2.3", features = ["js"] }
rand = "0.8.5"
Expand All @@ -31,7 +31,7 @@ base64 = "0.13"
num-bigint = "0.4.0"
num-integer = "0.1.45"
#rand_os = "0.1"
thiserror = "1.0.37"
thiserror.workspace = true
cfg-if = "1"


Expand Down
12 changes: 6 additions & 6 deletions core/wasm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ crate-type = ["cdylib", "rlib"]

[dependencies]
cml-core = { path = "../rust", version = "6.0.1" }
cbor_event = "2.2.0"
hex = "0.4.0"
wasm-bindgen = { version = "0.2.87" }
linked-hash-map = "0.5.3"
serde_json = "1.0.57"
serde-wasm-bindgen = "0.4.5"
cbor_event.workspace = true
hex.workspace = true
wasm-bindgen.workspace = true
linked-hash-map.workspace = true
serde_json.workspace = true
serde-wasm-bindgen.workspace = true
6 changes: 3 additions & 3 deletions core/wasm/src/wasm_wrappers.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/// Various code-generation macros to help with WASM wrapper creation.
/// Includes many things that auto-generated by cddl-codegen so we can
/// use these with utility code that had to be hand-written.
//! Various code-generation macros to help with WASM wrapper creation.
//! Includes many things that auto-generated by cddl-codegen so we can
//! use these with utility code that had to be hand-written.

/// Auto-declare From/AsRef conversions between rust and WASM wrappers
#[macro_export]
Expand Down
19 changes: 12 additions & 7 deletions crypto/rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,29 @@ keywords = ["cardano"]
[lib]
crate-type = ["cdylib", "rlib"]

[features]
# these features are only used within chain-libs
generic-serialization = []
property-test-api = []

[dependencies]
cml-core = { "path" = "../../core/rust", version = "6.0.1" }
base64 = "0.21.5"
cbor_event = "2.2.0"
cbor_event.workspace = true
cryptoxide = "0.4.2"
ed25519-bip32 = "0.4.1"
sha2 = "^0.9"
digest = "^0.9"
bech32 = "0.7.2"
hex = "0.4.0"
thiserror = "1.0.37"
hex.workspace = true
thiserror.workspace = true
rand = "0.8.5"
cfg-if = "1"

derivative = "2.2.0"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0.57"
schemars = "0.8.8"
derivative.workspace = true
serde.workspace = true
serde_json.workspace = true
schemars.workspace = true

[dev-dependencies]
quickcheck = "0.9.2"
Expand Down
2 changes: 1 addition & 1 deletion crypto/rust/src/chain_crypto/sign.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ impl<A: VerificationAlgorithm, T> Signature<T, A> {

pub trait SafeSignatureCoerce<T> {}

impl<'a, T> SafeSignatureCoerce<ByteArray<T>> for ByteSlice<'a, T> {}
impl<T> SafeSignatureCoerce<ByteArray<T>> for ByteSlice<'_, T> {}

impl<A: VerificationAlgorithm, T: AsRef<[u8]>> Signature<T, A> {
#[must_use]
Expand Down
2 changes: 1 addition & 1 deletion crypto/rust/src/typed_bytes/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ impl<T> AsRef<[u8]> for ByteArray<T> {
}
}

impl<'a, T> AsRef<[u8]> for ByteSlice<'a, T> {
impl<T> AsRef<[u8]> for ByteSlice<'_, T> {
fn as_ref(&self) -> &[u8] {
self.as_slice()
}
Expand Down
8 changes: 4 additions & 4 deletions crypto/wasm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ crate-type = ["cdylib", "rlib"]
[dependencies]
cml-core-wasm = { path = "../../core/wasm", version = "6.0.1" }
cml-crypto = { path = "../rust", version = "6.0.1" }
cbor_event = "2.2.0"
wasm-bindgen = { version = "0.2.87" }
linked-hash-map = "0.5.3"
serde_json = "1.0.57"
cbor_event.workspace = true
wasm-bindgen.workspace = true
linked-hash-map.workspace = true
serde_json.workspace = true
14 changes: 7 additions & 7 deletions multi-era/rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,16 @@ used_from_wasm = ["wasm-bindgen"]
cml-core = { path = "../../core/rust", version = "6.0.1" }
cml-crypto = { path = "../../crypto/rust", version = "6.0.1" }
cml-chain = { path = "../../chain/rust", version = "6.0.1" }
cbor_event = "2.4.0"
linked-hash-map = "0.5.3"
derivative = "2.2.0"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0.57"
schemars = "0.8.8"
cbor_event.workspace = true
linked-hash-map.workspace = true
derivative.workspace = true
serde.workspace = true
serde_json.workspace = true
schemars.workspace = true

# only for declaring hash types
bech32 = "0.7.2"
hex = "0.4.0"
hex.workspace = true

# non-wasm
noop_proc_macro = { version = "0.3.0" }
Expand Down
Loading
Loading