Skip to content

Commit

Permalink
chore: rename withdrawal to withdraw (so confusing)
Browse files Browse the repository at this point in the history
  • Loading branch information
lsunsi committed Dec 4, 2023
1 parent bbbfd79 commit a8017f9
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 17 deletions.
12 changes: 6 additions & 6 deletions src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ impl Client {
crate::core::Query::ChannelRequest(core) => {
Query::ChannelRequest(ChannelRequest { client, core })
}
crate::core::Query::WithdrawalRequest(core) => {
Query::WithdrawalRequest(WithdrawalRequest { client, core })
crate::core::Query::WithdrawRequest(core) => {
Query::WithdrawRequest(WithdrawRequest { client, core })
}
})
}
Expand All @@ -32,7 +32,7 @@ impl Client {
pub enum Query<'a> {
PayRequest(PayRequest<'a>),
ChannelRequest(ChannelRequest<'a>),
WithdrawalRequest(WithdrawalRequest<'a>),
WithdrawRequest(WithdrawRequest<'a>),
}

#[derive(Clone, Debug)]
Expand All @@ -48,9 +48,9 @@ pub struct ChannelRequest<'a> {
}

#[derive(Clone, Debug)]
pub struct WithdrawalRequest<'a> {
pub struct WithdrawRequest<'a> {
client: &'a reqwest::Client,
pub core: crate::core::withdrawal_request::WithdrawalRequest,
pub core: crate::core::withdraw_request::WithdrawRequest,
}

impl PayRequest<'_> {
Expand Down Expand Up @@ -109,7 +109,7 @@ impl ChannelRequest<'_> {
}
}

impl WithdrawalRequest<'_> {
impl WithdrawRequest<'_> {
/// # Errors
///
/// Returns errors on network or deserialization failures.
Expand Down
8 changes: 4 additions & 4 deletions src/core.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pub mod channel_request;
pub mod pay_request;
pub mod withdrawal_request;
pub mod withdraw_request;

/// # Errors
///
Expand Down Expand Up @@ -72,7 +72,7 @@ fn resolve_address(s: &str) -> Result<url::Url, &'static str> {
pub enum Query {
PayRequest(pay_request::PayRequest),
ChannelRequest(channel_request::ChannelRequest),
WithdrawalRequest(withdrawal_request::WithdrawalRequest),
WithdrawRequest(withdraw_request::WithdrawRequest),
}

impl std::str::FromStr for Query {
Expand All @@ -89,9 +89,9 @@ impl std::str::FromStr for Query {
if tag.tag == channel_request::TAG {
let cr = s.parse().map_err(|_| "deserialize data failed")?;
Ok(Query::ChannelRequest(cr))
} else if tag.tag == withdrawal_request::TAG {
} else if tag.tag == withdraw_request::TAG {
let wr = s.parse().map_err(|_| "deserialize data failed")?;
Ok(Query::WithdrawalRequest(wr))
Ok(Query::WithdrawRequest(wr))
} else if tag.tag == pay_request::TAG {
let pr = s.parse().map_err(|_| "deserialize data failed")?;
Ok(Query::PayRequest(pr))
Expand Down
14 changes: 7 additions & 7 deletions src/core/withdrawal_request.rs → src/core/withdraw_request.rs
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
pub const TAG: &str = "withdrawalRequest";
pub const TAG: &str = "withdrawRequest";

#[derive(Clone, Debug)]
pub struct WithdrawalRequest {
pub struct WithdrawRequest {
k1: String,
callback: url::Url,
pub description: String,
pub min: u64,
pub max: u64,
}

impl std::str::FromStr for WithdrawalRequest {
impl std::str::FromStr for WithdrawRequest {
type Err = &'static str;

fn from_str(s: &str) -> Result<Self, Self::Err> {
let d: serde::QueryResponse =
miniserde::json::from_str(s).map_err(|_| "deserialize failed")?;

Ok(WithdrawalRequest {
Ok(WithdrawRequest {
k1: d.k1,
callback: d.callback.0,
description: d.default_description,
Expand All @@ -26,7 +26,7 @@ impl std::str::FromStr for WithdrawalRequest {
}
}

impl WithdrawalRequest {
impl WithdrawRequest {
/// # Errors
///
/// Returns errors on network or deserialization failures.
Expand Down Expand Up @@ -71,7 +71,7 @@ mod tests {
}
"#;

let parsed = input.parse::<super::WithdrawalRequest>().expect("parse");
let parsed = input.parse::<super::WithdrawRequest>().expect("parse");

assert_eq!(parsed.callback.to_string(), "https://yuri/?o=callback");
assert_eq!(parsed.description, "verde com bolinhas");
Expand All @@ -92,7 +92,7 @@ mod tests {
}
"#;

let parsed = input.parse::<super::WithdrawalRequest>().expect("parse");
let parsed = input.parse::<super::WithdrawRequest>().expect("parse");

assert_eq!(
parsed.callback("pierre").to_string(),
Expand Down

0 comments on commit a8017f9

Please sign in to comment.