Skip to content

Commit

Permalink
Bump CI MSRV and fix new warnings (#530)
Browse files Browse the repository at this point in the history
Because time crate now requires v1.67

Also:
- Fix new clippy warning uninlined-format-args
- Replace deprecated chrono function with same implementation

---------

Co-authored-by: Simon Bihel <[email protected]>
  • Loading branch information
tristanmiller-spruceid and sbihel authored Sep 18, 2023
1 parent db906df commit f22351b
Show file tree
Hide file tree
Showing 24 changed files with 122 additions and 152 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: "1.66.0"
toolchain: "1.67.1"
profile: minimal
override: true
components: rustfmt, clippy
Expand Down
6 changes: 3 additions & 3 deletions did-ethr/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ fn resolve_pk(
Ok(pk_bytes) => pk_bytes,
Err(e) => {
return (
ResolutionMetadata::from_error(&format!("Unable to parse key: {}", e)),
ResolutionMetadata::from_error(&format!("Unable to parse key: {e}")),
None,
None,
);
Expand All @@ -107,7 +107,7 @@ fn resolve_pk(
Ok(hash) => hash,
Err(e) => {
return (
ResolutionMetadata::from_error(&format!("Unable to hash account address: {}", e)),
ResolutionMetadata::from_error(&format!("Unable to hash account address: {e}")),
None,
None,
)
Expand Down Expand Up @@ -309,7 +309,7 @@ impl DIDMethod for DIDEthr {
Ok(hash) => hash,
_ => return None,
};
let did = format!("did:ethr:{}", hash);
let did = format!("did:ethr:{hash}");
Some(did)
}

Expand Down
8 changes: 4 additions & 4 deletions did-ion/src/sidetree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1329,7 +1329,7 @@ impl<S: Sidetree> fmt::Display for SidetreeDID<S> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "did:{}:", S::METHOD)?;
if let Some(network) = S::NETWORK {
write!(f, "{}:", network)?;
write!(f, "{network}:")?;
}
match self {
Self::Short { did_suffix } => f.write_str(&did_suffix.0),
Expand Down Expand Up @@ -1395,7 +1395,7 @@ pub struct HTTPSidetreeDIDResolver<S: Sidetree> {

impl<S: Sidetree> HTTPSidetreeDIDResolver<S> {
pub fn new(sidetree_api_url: &str) -> Self {
let identifiers_url = format!("{}identifiers/", sidetree_api_url);
let identifiers_url = format!("{sidetree_api_url}identifiers/");
Self {
http_did_resolver: HTTPDIDResolver::new(&identifiers_url),
_marker: PhantomData,
Expand Down Expand Up @@ -1571,7 +1571,7 @@ impl fmt::Display for SidetreeAPIError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "Sidetree error {}", self.code)?;
if let Some(ref message) = self.message {
write!(f, ": {}", message)?;
write!(f, ": {message}")?;
}
Ok(())
}
Expand Down Expand Up @@ -1621,7 +1621,7 @@ impl<S: Sidetree + Send + Sync> DIDMethod for SidetreeClient<S> {
.endpoint
.as_ref()
.ok_or_else(|| anyhow!("Missing Sidetree REST API endpoint"))?;
let url = format!("{}operations/", endpoint);
let url = format!("{endpoint}operations/");
let client = Client::builder().build().context("Build HTTP client")?;
let resp = client
.post(url)
Expand Down
2 changes: 1 addition & 1 deletion did-key/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ impl DIDResolver for DIDKey {
]),
id: did.to_string(),
verification_method: Some(vec![VerificationMethod::Map(VerificationMethodMap {
id: format!("{}#{}", did, method_specific_id),
id: format!("{did}#{method_specific_id}"),
type_: vm_type,
controller: did.to_string(),
public_key_jwk: Some(jwk),
Expand Down
13 changes: 5 additions & 8 deletions did-onion/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ pub struct DIDOnion {
impl DIDOnion {
fn with_port(port: usize) -> Self {
Self {
proxy_url: format!("socks5h://127.0.0.1:{}", port),
proxy_url: format!("socks5h://127.0.0.1:{port}"),
}
}
}
Expand Down Expand Up @@ -51,7 +51,7 @@ fn did_onion_url(did: &str) -> Result<String, ResolutionMetadata> {
Some(_) => parts.collect::<Vec<&str>>().join("/"),
None => ".well-known".to_string(),
};
let url = format!("http://{}.onion/{}/did.json", onion_address, path);
let url = format!("http://{onion_address}.onion/{path}/did.json");
Ok(url)
}

Expand Down Expand Up @@ -113,7 +113,7 @@ impl DIDResolver for DIDOnion {
Ok(proxy) => client_builder.proxy(proxy),
Err(err) => {
return (
ResolutionMetadata::from_error(&format!("Error constructing proxy: {}", err)),
ResolutionMetadata::from_error(&format!("Error constructing proxy: {err}")),
Vec::new(),
None,
)
Expand All @@ -123,7 +123,7 @@ impl DIDResolver for DIDOnion {
Ok(c) => c,
Err(err) => {
return (
ResolutionMetadata::from_error(&format!("Error building HTTP client: {}", err)),
ResolutionMetadata::from_error(&format!("Error building HTTP client: {err}")),
Vec::new(),
None,
)
Expand All @@ -137,10 +137,7 @@ impl DIDResolver for DIDOnion {
Ok(req) => req,
Err(err) => {
return (
ResolutionMetadata::from_error(&format!(
"Error sending HTTP request : {}",
err
)),
ResolutionMetadata::from_error(&format!("Error sending HTTP request: {err}")),
Vec::new(),
None,
)
Expand Down
4 changes: 2 additions & 2 deletions did-pkh/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,7 @@ fn generate_caip10_did(key: &JWK, name: &str) -> Result<String, String> {
"aleo" => generate_caip10_aleo(key, reference_opt)?,
_ => return Err("Namespace not supported".to_string()),
};
Ok(format!("did:pkh:{}", account_id))
Ok(format!("did:pkh:{account_id}"))
}

impl DIDMethod for DIDPKH {
Expand Down Expand Up @@ -665,7 +665,7 @@ impl DIDMethod for DIDPKH {
Some(addr) => addr,
None => return None,
};
let did = format!("did:pkh:{}:{}", pkh_name, addr);
let did = format!("did:pkh:{pkh_name}:{addr}");
Some(did)
}

Expand Down
2 changes: 1 addition & 1 deletion did-sol/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ impl DIDMethod for DIDSol {
let did = match jwk.params {
Params::OKP(ref params) if params.curve == "Ed25519" => {
let addr = bs58::encode(&params.public_key.0).into_string();
format!("did:sol:{}", addr)
format!("did:sol:{addr}")
}
_ => {
dbg!(&jwk.params);
Expand Down
10 changes: 5 additions & 5 deletions did-test/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ impl ResolverOutcome {
return Self::RepresentationNotSupportedErrorOutcome
}
ERROR_NOT_FOUND => return Self::NotFoundErrorOutcome,
_ => panic!("Unknown outcome for error: {}", error),
_ => panic!("Unknown outcome for error: {error}"),
}
}
if deactivated == Some(true) {
Expand Down Expand Up @@ -828,7 +828,7 @@ async fn report_method(mut args: Args) {
"onion" => report_method_onion().await,
"pkh" => report_method_pkh().await,
"webkey" => report_method_webkey().await,
method => panic!("unknown method {}", method),
method => panic!("unknown method {method}"),
}
}

Expand All @@ -842,7 +842,7 @@ async fn report_resolver(mut args: Args) {
"onion" => report_resolver_onion().await,
"pkh" => report_resolver_pkh().await,
"webkey" => report_resolver_webkey().await,
method => panic!("unknown method {}", method),
method => panic!("unknown method {method}"),
}
}

Expand All @@ -856,7 +856,7 @@ async fn report_dereferencer(mut args: Args) {
"onion" => report_dereferencer_onion().await,
"pkh" => report_dereferencer_pkh().await,
"webkey" => report_dereferencer_webkey().await,
method => panic!("unknown method {}", method),
method => panic!("unknown method {method}"),
}
}

Expand All @@ -869,6 +869,6 @@ async fn main() {
"method" => report_method(args).await,
"resolver" => report_resolver(args).await,
"dereferencer" => report_dereferencer(args).await,
section => panic!("unknown section {}", section),
section => panic!("unknown section {section}"),
}
}
4 changes: 2 additions & 2 deletions did-tezos/src/explorer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ pub async fn execute_service_view(tzkt_url: &str, did: &str, contract: &str) ->
.build()?;
let url = Url::parse(tzkt_url)?;
let service_result: ServiceResult = client
.get(url.join(&format!("/v1/contracts/{}/storage", contract))?)
.get(url.join(&format!("/v1/contracts/{contract}/storage"))?)
.send()
.await?
.json()
Expand All @@ -78,7 +78,7 @@ pub async fn execute_auth_view(tzkt_url: &str, contract: &str) -> Result<Verific
let client = reqwest::Client::builder().build()?;
let url = Url::parse(tzkt_url)?;
let auth_result: AuthResult = client
.get(url.join(&format!("/v1/contracts/{}/storage", contract))?)
.get(url.join(&format!("/v1/contracts/{contract}/storage"))?)
.send()
.await?
.json()
Expand Down
4 changes: 2 additions & 2 deletions did-tezos/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ impl DIDResolver for DIDTz {

let default_url = match &self.tzkt_url {
Some(u) => u.clone(),
None => format!("https://api.{}.tzkt.io", network),
None => format!("https://api.{network}.tzkt.io"),
};
let mut tzkt_url = &default_url;
if let Some(s) = &input_metadata.property_set {
Expand Down Expand Up @@ -413,7 +413,7 @@ impl DIDTz {
id: String::from(vm_didurl.clone()),
type_: proof_type.to_string(),
controller: did.to_string(),
blockchain_account_id: Some(format!("tezos:{}:{}", genesis_block_hash, address)),
blockchain_account_id: Some(format!("tezos:{genesis_block_hash}:{address}")),
..Default::default()
})]),
authentication: match public_key {
Expand Down
5 changes: 2 additions & 3 deletions did-web/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ impl DIDResolver for DIDWeb {
Ok(c) => c,
Err(err) => {
return (
ResolutionMetadata::from_error(&format!("Error building HTTP client: {}", err)),
ResolutionMetadata::from_error(&format!("Error building HTTP client: {err}")),
Vec::new(),
None,
)
Expand All @@ -133,8 +133,7 @@ impl DIDResolver for DIDWeb {
Err(err) => {
return (
ResolutionMetadata::from_error(&format!(
"Error sending HTTP request ({}): {}",
url, err
"Error sending HTTP request ({url}): {err}"
)),
Vec::new(),
None,
Expand Down
13 changes: 5 additions & 8 deletions did-webkey/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ fn gpg_pk_to_vm(did: &str, pk: SignedPublicKey) -> Result<(VerificationMethodMap
let fingerprint = pk
.fingerprint()
.iter()
.fold(String::new(), |acc, &x| format!("{}{:02X}", acc, x));
.fold(String::new(), |acc, &x| format!("{acc}{x:02X}"));
let vm_url = DIDURL {
did: did.to_string(),
fragment: Some(fingerprint.clone()),
Expand Down Expand Up @@ -228,7 +228,7 @@ fn parse_did_webkey_url(did: &str) -> Result<(DIDWebKeyType, String), Resolution
}
};
#[allow(unused_mut)]
let mut url = format!("https://{}/{}", domain_name, path);
let mut url = format!("https://{domain_name}/{path}");
#[cfg(test)]
PROXY.with(|proxy| {
if let Some(ref proxy) = *proxy.borrow() {
Expand Down Expand Up @@ -259,7 +259,7 @@ impl DIDResolver for DIDWebKey {
Ok(c) => c,
Err(err) => {
return (
ResolutionMetadata::from_error(&format!("Error building HTTP client: {}", err)),
ResolutionMetadata::from_error(&format!("Error building HTTP client: {err}")),
None,
None,
)
Expand All @@ -273,10 +273,7 @@ impl DIDResolver for DIDWebKey {
Ok(req) => req,
Err(err) => {
return (
ResolutionMetadata::from_error(&format!(
"Error sending HTTP request : {}",
err
)),
ResolutionMetadata::from_error(&format!("Error sending HTTP request : {err}")),
None,
None,
)
Expand Down Expand Up @@ -312,7 +309,7 @@ impl DIDResolver for DIDWebKey {
),
Err(err) => {
return (
ResolutionMetadata::from_error(&format!("Error parsing keys: {}", err)),
ResolutionMetadata::from_error(&format!("Error parsing keys: {err}")),
None,
None,
)
Expand Down
2 changes: 1 addition & 1 deletion ssi-core/src/uri.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ impl FromStr for URI {
impl std::fmt::Display for URI {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
match self {
Self::String(ref string) => write!(f, "{}", string),
Self::String(ref string) => write!(f, "{string}"),
}
}
}
2 changes: 1 addition & 1 deletion ssi-crypto/src/hashes/keccak.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pub fn bytes_to_lowerhex(bytes: &[u8]) -> String {
"0x".to_string()
+ &bytes
.iter()
.map(|byte| format!("{:02x}", byte))
.map(|byte| format!("{byte:02x}"))
.collect::<String>()
}

Expand Down
Loading

0 comments on commit f22351b

Please sign in to comment.