Skip to content
This repository has been archived by the owner on Dec 12, 2024. It is now read-only.

Commit

Permalink
Fix linting
Browse files Browse the repository at this point in the history
  • Loading branch information
KendallWeihe committed Sep 30, 2024
1 parent 3b08877 commit 7730c25
Show file tree
Hide file tree
Showing 20 changed files with 84 additions and 76 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ thiserror = "1.0.50"
http-std = { git = "https://github.com/TBD54566975/web5-rs", rev = "005bd3c04574039ad7c3e41eeefae877b9895104" }
web5 = { git = "https://github.com/TBD54566975/web5-rs", rev = "005bd3c04574039ad7c3e41eeefae877b9895104" }
web5_uniffi_wrapper = { git = "https://github.com/TBD54566975/web5-rs", rev = "005bd3c04574039ad7c3e41eeefae877b9895104" }

2 changes: 1 addition & 1 deletion bindings/tbdex_wasm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ web5 = { workspace = true }
web-sys = { version = "0.3.70", features = ["console"] }

[lib]
crate-type = ["cdylib"]
crate-type = ["cdylib"]
2 changes: 1 addition & 1 deletion bindings/tbdex_wasm/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ impl WasmTbdexError {

#[wasm_bindgen(getter)]
pub fn is_web5_error(&self) -> bool {
self.is_tbdex_error.clone()
self.is_tbdex_error
}
}

Expand Down
16 changes: 7 additions & 9 deletions bindings/tbdex_wasm/src/foreign_fetch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ unsafe impl Sync for ConcreteForeignFetch {}

impl Client for ConcreteForeignFetch {
fn fetch(&self, url: &str, options: Option<FetchOptions>) -> http_std::Result<Response> {
let wasm_options = options.and_then(|o| Some(WasmFetchOptions::from(o)));
let wasm_options = options.map(WasmFetchOptions::from);
let wasm_response = self.0.fetch(url, wasm_options);
Ok(wasm_response.into())
}
}

#[wasm_bindgen]
pub fn set_http_client(foreign_fetch: ForeignFetch) -> () {
pub fn set_http_client(foreign_fetch: ForeignFetch) {
http_std::set_client(Arc::new(ConcreteForeignFetch(foreign_fetch)))
}

Expand Down Expand Up @@ -68,12 +68,10 @@ fn method_from_str(method: &str) -> Result<Method> {
"GET" => Ok(Method::Get),
"POST" => Ok(Method::Post),
"PUT" => Ok(Method::Put),
_ => {
return Err(map_err(TbdexError::HttpClient(format!(
"unknown method {}",
method
))))
}
_ => Err(map_err(TbdexError::HttpClient(format!(
"unknown method {}",
method
)))),
}
}

Expand Down Expand Up @@ -108,7 +106,7 @@ impl WasmFetchOptions {

#[wasm_bindgen(getter)]
pub fn method(&self) -> Option<String> {
self.inner.method.as_ref().and_then(|m| Some(m.to_string()))
self.inner.method.as_ref().map(|m| m.to_string())
}

#[wasm_bindgen(getter)]
Expand Down
6 changes: 3 additions & 3 deletions bindings/tbdex_wasm/src/messages/cancel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ impl WasmCancel {
}

pub fn to_json_string(&self) -> Result<String> {
Ok(self.inner.to_json_string().map_err(map_err)?)
self.inner.to_json_string().map_err(map_err)
}

#[wasm_bindgen]
Expand All @@ -54,12 +54,12 @@ impl WasmCancel {

#[wasm_bindgen]
pub fn sign(&mut self, bearer_did: WasmBearerDid) -> Result<()> {
Ok(self.inner.sign(&bearer_did.into()).map_err(map_err)?)
self.inner.sign(&bearer_did.into()).map_err(map_err)
}

#[wasm_bindgen]
pub fn verify(&self) -> Result<()> {
Ok(self.inner.verify().map_err(map_err)?)
self.inner.verify().map_err(map_err)
}

#[wasm_bindgen(getter)]
Expand Down
6 changes: 3 additions & 3 deletions bindings/tbdex_wasm/src/messages/close.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ impl WasmClose {
}

pub fn to_json_string(&self) -> Result<String> {
Ok(self.inner.to_json_string().map_err(map_err)?)
self.inner.to_json_string().map_err(map_err)
}

#[wasm_bindgen]
Expand All @@ -54,12 +54,12 @@ impl WasmClose {

#[wasm_bindgen]
pub fn sign(&mut self, bearer_did: WasmBearerDid) -> Result<()> {
Ok(self.inner.sign(&bearer_did.into()).map_err(map_err)?)
self.inner.sign(&bearer_did.into()).map_err(map_err)
}

#[wasm_bindgen]
pub fn verify(&self) -> Result<()> {
Ok(self.inner.verify().map_err(map_err)?)
self.inner.verify().map_err(map_err)
}

#[wasm_bindgen(getter)]
Expand Down
3 changes: 2 additions & 1 deletion bindings/tbdex_wasm/src/messages/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ use wasm_bindgen::prelude::wasm_bindgen;

pub mod cancel;
pub mod close;
pub mod order;
pub mod order_instructions;
pub mod order_status;
pub mod order;
pub mod quote;
pub mod rfq;

Expand All @@ -30,6 +30,7 @@ impl From<WasmMessageMetadata> for MessageMetadata {

#[wasm_bindgen]
impl WasmMessageMetadata {
#[allow(clippy::too_many_arguments)]
#[wasm_bindgen(constructor)]
pub fn new(
from: String,
Expand Down
12 changes: 9 additions & 3 deletions bindings/tbdex_wasm/src/messages/order.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ impl WasmOrder {
}

pub fn to_json_string(&self) -> Result<String> {
Ok(self.inner.to_json_string().map_err(map_err)?)
self.inner.to_json_string().map_err(map_err)
}

#[wasm_bindgen]
Expand All @@ -52,12 +52,12 @@ impl WasmOrder {

#[wasm_bindgen]
pub fn sign(&mut self, bearer_did: WasmBearerDid) -> Result<()> {
Ok(self.inner.sign(&bearer_did.into()).map_err(map_err)?)
self.inner.sign(&bearer_did.into()).map_err(map_err)
}

#[wasm_bindgen]
pub fn verify(&self) -> Result<()> {
Ok(self.inner.verify().map_err(map_err)?)
self.inner.verify().map_err(map_err)
}

#[wasm_bindgen(getter)]
Expand Down Expand Up @@ -102,3 +102,9 @@ impl WasmOrderData {
}
}
}

impl Default for WasmOrderData {
fn default() -> Self {
Self::new()
}
}
6 changes: 3 additions & 3 deletions bindings/tbdex_wasm/src/messages/order_instructions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ impl WasmOrderInstructions {
}

pub fn to_json_string(&self) -> Result<String> {
Ok(self.inner.to_json_string().map_err(map_err)?)
self.inner.to_json_string().map_err(map_err)
}

#[wasm_bindgen]
Expand All @@ -65,12 +65,12 @@ impl WasmOrderInstructions {

#[wasm_bindgen]
pub fn sign(&mut self, bearer_did: WasmBearerDid) -> Result<()> {
Ok(self.inner.sign(&bearer_did.into()).map_err(map_err)?)
self.inner.sign(&bearer_did.into()).map_err(map_err)
}

#[wasm_bindgen]
pub fn verify(&self) -> Result<()> {
Ok(self.inner.verify().map_err(map_err)?)
self.inner.verify().map_err(map_err)
}

#[wasm_bindgen(getter)]
Expand Down
6 changes: 3 additions & 3 deletions bindings/tbdex_wasm/src/messages/order_status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ impl WasmOrderStatus {
}

pub fn to_json_string(&self) -> Result<String> {
Ok(self.inner.to_json_string().map_err(map_err)?)
self.inner.to_json_string().map_err(map_err)
}

#[wasm_bindgen]
Expand All @@ -60,12 +60,12 @@ impl WasmOrderStatus {

#[wasm_bindgen]
pub fn sign(&mut self, bearer_did: WasmBearerDid) -> Result<()> {
Ok(self.inner.sign(&bearer_did.into()).map_err(map_err)?)
self.inner.sign(&bearer_did.into()).map_err(map_err)
}

#[wasm_bindgen]
pub fn verify(&self) -> Result<()> {
Ok(self.inner.verify().map_err(map_err)?)
self.inner.verify().map_err(map_err)
}

#[wasm_bindgen(getter)]
Expand Down
6 changes: 3 additions & 3 deletions bindings/tbdex_wasm/src/messages/quote.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ impl WasmQuote {
}

pub fn to_json_string(&self) -> Result<String> {
Ok(self.inner.to_json_string().map_err(map_err)?)
self.inner.to_json_string().map_err(map_err)
}

#[wasm_bindgen]
Expand All @@ -54,12 +54,12 @@ impl WasmQuote {

#[wasm_bindgen]
pub fn sign(&mut self, bearer_did: WasmBearerDid) -> Result<()> {
Ok(self.inner.sign(&bearer_did.into()).map_err(map_err)?)
self.inner.sign(&bearer_did.into()).map_err(map_err)
}

#[wasm_bindgen]
pub fn verify(&self) -> Result<()> {
Ok(self.inner.verify().map_err(map_err)?)
self.inner.verify().map_err(map_err)
}

#[wasm_bindgen(getter)]
Expand Down
15 changes: 7 additions & 8 deletions bindings/tbdex_wasm/src/messages/rfq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ impl WasmRfq {
}

pub fn to_json_string(&self) -> Result<String> {
Ok(self.inner.to_json_string().map_err(map_err)?)
self.inner.to_json_string().map_err(map_err)
}

#[wasm_bindgen]
Expand All @@ -70,30 +70,29 @@ impl WasmRfq {

#[wasm_bindgen]
pub fn sign(&mut self, bearer_did: WasmBearerDid) -> Result<()> {
Ok(self.inner.sign(&bearer_did.into()).map_err(map_err)?)
self.inner.sign(&bearer_did.into()).map_err(map_err)
}

#[wasm_bindgen]
pub fn verify(&self) -> Result<()> {
Ok(self.inner.verify().map_err(map_err)?)
self.inner.verify().map_err(map_err)
}

#[wasm_bindgen]
pub fn verify_offering_requirements(&self, offering: WasmOffering) -> Result<()> {
Ok(self
.inner
self.inner
.verify_offering_requirements(&offering.into())
.map_err(map_err)?)
.map_err(map_err)
}

#[wasm_bindgen]
pub fn verify_all_private_data(&self) -> Result<()> {
Ok(self.inner.verify_all_private_data().map_err(map_err)?)
self.inner.verify_all_private_data().map_err(map_err)
}

#[wasm_bindgen]
pub fn verify_present_private_data(&self) -> Result<()> {
Ok(self.inner.verify_present_private_data().map_err(map_err)?)
self.inner.verify_present_private_data().map_err(map_err)
}

#[wasm_bindgen(getter)]
Expand Down
6 changes: 3 additions & 3 deletions bindings/tbdex_wasm/src/resources/balance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ impl WasmBalance {
}

pub fn to_json_string(&self) -> Result<String> {
Ok(self.inner.to_json_string().map_err(map_err)?)
self.inner.to_json_string().map_err(map_err)
}

#[wasm_bindgen]
Expand All @@ -50,12 +50,12 @@ impl WasmBalance {

#[wasm_bindgen]
pub fn sign(&mut self, bearer_did: WasmBearerDid) -> Result<()> {
Ok(self.inner.sign(&bearer_did.into()).map_err(map_err)?)
self.inner.sign(&bearer_did.into()).map_err(map_err)
}

#[wasm_bindgen]
pub fn verify(&self) -> Result<()> {
Ok(self.inner.verify().map_err(map_err)?)
self.inner.verify().map_err(map_err)
}

#[wasm_bindgen(getter)]
Expand Down
6 changes: 4 additions & 2 deletions bindings/tbdex_wasm/src/resources/offering.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ impl WasmOffering {
}

pub fn to_json_string(&self) -> Result<String> {
Ok(self.inner.to_json_string().map_err(map_err)?)
self.inner.to_json_string().map_err(map_err)
}

pub fn create(
Expand Down Expand Up @@ -114,7 +114,7 @@ impl WasmOfferingData {
payout_units_per_payin_unit,
payin: payin.into(),
payout: payout.into(),
required_claims: required_claims.and_then(|rc| Some(rc.into())),
required_claims: required_claims.map(|rc| rc.into()),
cancellation: cancellation.into(),
},
}
Expand Down Expand Up @@ -232,6 +232,7 @@ impl From<PayinMethod> for WasmPayinMethod {

#[wasm_bindgen]
impl WasmPayinMethod {
#[allow(clippy::too_many_arguments)]
#[wasm_bindgen(constructor)]
pub fn new(
kind: String,
Expand Down Expand Up @@ -387,6 +388,7 @@ impl From<PayoutMethod> for WasmPayoutMethod {

#[wasm_bindgen]
impl WasmPayoutMethod {
#[allow(clippy::too_many_arguments)]
#[wasm_bindgen(constructor)]
pub fn new(
kind: String,
Expand Down
1 change: 1 addition & 0 deletions bindings/tbdex_wasm/src/web5/did.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ impl From<Did> for WasmDid {

#[wasm_bindgen]
impl WasmDid {
#[allow(clippy::too_many_arguments)]
#[wasm_bindgen(constructor)]
pub fn new(
uri: String,
Expand Down
8 changes: 3 additions & 5 deletions bindings/tbdex_wasm/src/web5/document.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ impl From<Document> for WasmDocument {

#[wasm_bindgen]
impl WasmDocument {
#[allow(clippy::too_many_arguments)]
#[wasm_bindgen(constructor)]
pub fn new(
id: String,
Expand Down Expand Up @@ -56,10 +57,7 @@ impl WasmDocument {
key_agreement,
capability_invocation,
capability_delegation,
service: match service {
None => None,
Some(wss) => Some(wss.into_iter().map(|ws| ws.into()).collect()),
},
service: service.map(|wss| wss.into_iter().map(|ws| ws.into()).collect()),
},
}
}
Expand All @@ -73,7 +71,7 @@ impl WasmDocument {

#[wasm_bindgen]
pub fn to_json_string(&self) -> Result<String> {
Ok(self.inner.to_json_string().map_err(map_web5_err)?)
self.inner.to_json_string().map_err(map_web5_err)
}

#[wasm_bindgen(getter)]
Expand Down
2 changes: 1 addition & 1 deletion bindings/tbdex_wasm/src/web5/portable_did.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ impl WasmPortableDid {

#[wasm_bindgen]
pub fn to_json_string(&self) -> Result<String> {
Ok(self.inner.to_json_string().map_err(map_web5_err)?)
self.inner.to_json_string().map_err(map_web5_err)
}

#[wasm_bindgen(getter)]
Expand Down
Loading

0 comments on commit 7730c25

Please sign in to comment.