Skip to content

Commit

Permalink
Use new fiat topup registration mutations
Browse files Browse the repository at this point in the history
  • Loading branch information
danielgranhao authored Dec 4, 2024
1 parent 086406e commit 8f82085
Show file tree
Hide file tree
Showing 20 changed files with 278 additions and 936 deletions.
592 changes: 122 additions & 470 deletions Cargo.lock

Large diffs are not rendered by default.

22 changes: 9 additions & 13 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
members = [
"mock/breez-sdk",
"parser",
"pocketclient"
]

[package]
Expand All @@ -16,22 +15,20 @@ name = "uniffi_lipalightninglib"

[dependencies]
parser = { path = "parser" }
pocketclient = { path = "pocketclient", optional = true }
pocketclient-mock = { path = "mock/pocketclient", optional = true }

chameleon = { git = "https://github.com/getlipa/wild", tag = "v1.28.0", optional = true }
chameleon = { git = "https://github.com/getlipa/wild", tag = "v1.29.0", optional = true }
chameleon-mock = { path = "mock/wild/chameleon", optional = true }
crow = { git = "https://github.com/getlipa/wild", tag = "v1.28.0", optional = true }
crow = { git = "https://github.com/getlipa/wild", tag = "v1.29.0", optional = true }
crow-mock = { path = "mock/wild/crow", optional = true }
graphql = { git = "https://github.com/getlipa/wild", tag = "v1.28.0" }
honeybadger = { git = "https://github.com/getlipa/wild", tag = "v1.28.0", optional = true }
graphql = { git = "https://github.com/getlipa/wild", tag = "v1.29.0" }
honeybadger = { git = "https://github.com/getlipa/wild", tag = "v1.29.0", optional = true }
honeybadger-mock = { path = "mock/wild/honeybadger", optional = true }
parrot = { git = "https://github.com/getlipa/wild", tag = "v1.28.0", optional = true }
parrot = { git = "https://github.com/getlipa/wild", tag = "v1.29.0", optional = true }
parrot-mock = { path = "mock/wild/parrot", optional = true }
perro = { git = "https://github.com/getlipa/perro", tag = "v1.2.0" }
pigeon = { git = "https://github.com/getlipa/wild", tag = "v1.28.0", optional = true }
pigeon = { git = "https://github.com/getlipa/wild", tag = "v1.29.0", optional = true }
pigeon-mock = { path = "mock/wild/pigeon", optional = true }
squirrel = { git = "https://github.com/getlipa/wild", tag = "v1.28.0", optional = true }
squirrel = { git = "https://github.com/getlipa/wild", tag = "v1.29.0", optional = true }
squirrel-mock = { path = "mock/wild/squirrel", optional = true }

breez-sdk-core = { git = "https://github.com/breez/breez-sdk", tag = "0.6.5", optional = true }
Expand All @@ -51,7 +48,6 @@ num_enum = "0.7.3"
phonenumber = "0.3.6"
rand = "0.8.5"
regex = { version = "1.11.1" }
reqwest = { version = "0.12", default-features = false, features = ["json", "blocking", "rustls-tls"] }
rusqlite_migration = "1"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
Expand All @@ -63,8 +59,8 @@ uniffi = "0.28.3"
uuid = { version = "1.11.0", features = ["v5"] }

[features]
default = ["dep:breez-sdk-core", "dep:chameleon", "dep:crow", "dep:honeybadger", "dep:parrot", "dep:pigeon", "dep:squirrel", "dep:pocketclient"]
mock-deps = ["dep:breez-sdk-mock", "dep:chameleon-mock", "dep:crow-mock", "dep:honeybadger-mock", "dep:parrot-mock", "dep:pigeon-mock", "dep:squirrel-mock", "dep:pocketclient-mock"]
default = ["dep:breez-sdk-core", "dep:chameleon", "dep:crow", "dep:honeybadger", "dep:parrot", "dep:pigeon", "dep:squirrel"]
mock-deps = ["dep:breez-sdk-mock", "dep:chameleon-mock", "dep:crow-mock", "dep:honeybadger-mock", "dep:parrot-mock", "dep:pigeon-mock", "dep:squirrel-mock"]

# Bundle sqlite for all targets except iOS.
[target.'cfg(not(target_os = "ios"))'.dependencies]
Expand Down
16 changes: 11 additions & 5 deletions examples/node/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ fn setup_editor(history_path: &Path) -> Editor<CommandHinter, DefaultHistory> {
));

hints.insert(CommandHint::new(
"registertopup <IBAN> <currency> [email] [referral code]",
"registertopup <IBAN> <currency> <provider> [email] [referral code]",
"registertopup ",
));
hints.insert(CommandHint::new("resettopup", "resettopup"));
Expand Down Expand Up @@ -559,7 +559,7 @@ fn help() {
println!(" getfailedswapresolvingfees <swap address>");
println!(" refundfailedswap <swap address> <to address>");
println!();
println!(" registertopup <IBAN> <currency> [email] [referral code]");
println!(" registertopup <IBAN> <currency> <provider> [email] [referral code]");
println!(" resettopup");
println!(" getregisteredtopup");
println!(" listoffers");
Expand Down Expand Up @@ -1151,12 +1151,18 @@ fn register_topup(node: &LightningNode, words: &mut dyn Iterator<Item = &str>) -

let currency = words.next().ok_or(anyhow!("Currency is required"))?;

let provider = words.next().ok_or(anyhow!("Provider is required"))?;

let email = words.next().map(String::from);
let referral = words.next().map(String::from);

let topup_info =
node.fiat_topup()
.register(email, referral, iban.to_string(), currency.to_string())?;
let topup_info = node.fiat_topup().register(
email,
iban.to_string(),
currency.to_string(),
provider.to_string(),
referral,
)?;
println!("{topup_info:?}");

Ok(())
Expand Down
9 changes: 0 additions & 9 deletions mock/pocketclient/Cargo.toml

This file was deleted.

42 changes: 0 additions & 42 deletions mock/pocketclient/src/lib.rs

This file was deleted.

4 changes: 2 additions & 2 deletions mock/wild/chameleon/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ edition = "2021"
name = "chameleon"

[dependencies]
chameleon = { git = "https://github.com/getlipa/wild", tag = "v1.28.0" }
graphql = { git = "https://github.com/getlipa/wild", tag = "v1.28.0" }
chameleon = { git = "https://github.com/getlipa/wild", tag = "v1.29.0" }
graphql = { git = "https://github.com/getlipa/wild", tag = "v1.29.0" }
honeybadger-mock = { path = "../honeybadger" }
lazy_static = "1.4.0"
rand = "0.8.5"
5 changes: 3 additions & 2 deletions mock/wild/crow/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ edition = "2021"
name = "crow"

[dependencies]
crow = { git = "https://github.com/getlipa/wild", tag = "v1.28.0" }
graphql = { git = "https://github.com/getlipa/wild", tag = "v1.28.0" }
crow = { git = "https://github.com/getlipa/wild", tag = "v1.29.0" }
graphql = { git = "https://github.com/getlipa/wild", tag = "v1.29.0" }
honeybadger-mock = { path = "../honeybadger" }
isocountry = { version = "0.3.2" }
isolanguage-1 = { version = "0.2.2" }
lazy_static = "1.4.0"
uuid = { version = "1.11.0", features = ["v4"] }
54 changes: 47 additions & 7 deletions mock/wild/crow/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,19 @@ use std::time::{Duration, SystemTime};
pub use isocountry::CountryCode;
pub use isolanguage_1::LanguageCode;

pub use crow::FiatTopupSetupChallenge;
pub use crow::FiatTopupSetupInfo;
pub use crow::PermanentFailureCode;
pub use crow::TemporaryFailureCode;
pub use crow::TopupError;
pub use crow::TopupInfo;
pub use crow::TopupStatus;
use lazy_static::lazy_static;
use uuid::Uuid;

lazy_static! {
static ref TOPUPS: Mutex<Vec<TopupInfo>> = Mutex::new(Vec::new());
static ref EMAIL: Mutex<Option<String>> = Mutex::new(None);
}

const REFUND_EMAIL: &str = "refund@top.up";
Expand All @@ -27,15 +31,34 @@ impl OfferManager {
Self {}
}

pub fn register_topup(
pub fn start_topup_setup(
&self,
order_id: String,
_node_pubkey: String,
_provider: String,
_source_iban: String,
_user_currency: String,
email: Option<String>,
_referral: Option<String>,
) -> graphql::Result<()> {
_referral_code: Option<String>,
) -> graphql::Result<FiatTopupSetupChallenge> {
let mut stored_email = EMAIL.lock().unwrap();
*stored_email = email;

Ok(FiatTopupSetupChallenge {
id: "id".to_string(),
challenge: "challenge".to_string(),
})
}

pub fn complete_topup_setup(
&self,
id: String,
_signed_challenge: String,
_source_iban: String,
) -> graphql::Result<FiatTopupSetupInfo> {
let mut status = TopupStatus::READY;

if let Some(email) = email {
let stored_email = EMAIL.lock().unwrap();
if let Some(email) = stored_email.as_ref() {
match email.as_str() {
REFUND_EMAIL => status = TopupStatus::REFUNDED,
FAIL_EMAIL => status = TopupStatus::FAILED,
Expand All @@ -44,7 +67,7 @@ impl OfferManager {
}

TOPUPS.lock().unwrap().push(TopupInfo {
id: order_id,
id,
status,
amount_sat: 30_000,
topup_value_minor_units: 20_00, // 20 EUR
Expand All @@ -60,7 +83,24 @@ impl OfferManager {
error: None,
});

Ok(())
Ok(FiatTopupSetupInfo {
order_id: Uuid::new_v4().to_string(),
debitor_iban: "Mock debitor_iban".to_string(),
creditor_reference: "Mock creditor_reference".to_string(),
creditor_iban: "Mock creditor_iban".to_string(),
creditor_bank_name: "Mock creditor_bank_name".to_string(),
creditor_bank_street: "Mock creditor_bank_street".to_string(),
creditor_bank_postal_code: "Mock creditor_bank_postal_code".to_string(),
creditor_bank_town: "Mock creditor_bank_town".to_string(),
creditor_bank_country: "Mock creditor_bank_country".to_string(),
creditor_bank_bic: "Mock creditor_bank_bic".to_string(),
creditor_name: "Mock creditor_name".to_string(),
creditor_street: "Mock creditor_street".to_string(),
creditor_postal_code: "Mock creditor_postal_code".to_string(),
creditor_town: "Mock creditor_town".to_string(),
creditor_country: "Mock creditor_country".to_string(),
currency: "Mock currency".to_string(),
})
}

pub fn register_notification_token(
Expand Down
4 changes: 2 additions & 2 deletions mock/wild/honeybadger/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ edition = "2021"
name = "honeybadger"

[dependencies]
graphql = { git = "https://github.com/getlipa/wild", tag = "v1.28.0" }
honeybadger = { git = "https://github.com/getlipa/wild", tag = "v1.28.0" }
graphql = { git = "https://github.com/getlipa/wild", tag = "v1.29.0" }
honeybadger = { git = "https://github.com/getlipa/wild", tag = "v1.29.0" }
rand = "0.8.5"
secp256k1 = { version = "0.27.0", features = ["global-context"] }
tokio = "1.37.0"
Expand Down
4 changes: 2 additions & 2 deletions mock/wild/parrot/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ edition = "2021"
name = "parrot"

[dependencies]
graphql = { git = "https://github.com/getlipa/wild", tag = "v1.28.0" }
graphql = { git = "https://github.com/getlipa/wild", tag = "v1.29.0" }
honeybadger-mock = { path = "../honeybadger" }
parrot = { git = "https://github.com/getlipa/wild", tag = "v1.28.0" }
parrot = { git = "https://github.com/getlipa/wild", tag = "v1.29.0" }
2 changes: 1 addition & 1 deletion mock/wild/pigeon/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ edition = "2021"
name = "pigeon"

[dependencies]
graphql = { git = "https://github.com/getlipa/wild", tag = "v1.28.0" }
graphql = { git = "https://github.com/getlipa/wild", tag = "v1.29.0" }
honeybadger-mock = { path = "../honeybadger" }
lazy_static = "1.4.0"
4 changes: 2 additions & 2 deletions mock/wild/squirrel/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ edition = "2021"
name = "squirrel"

[dependencies]
graphql = { git = "https://github.com/getlipa/wild", tag = "v1.28.0" }
graphql = { git = "https://github.com/getlipa/wild", tag = "v1.29.0" }
honeybadger-mock = { path = "../honeybadger" }
squirrel = { git = "https://github.com/getlipa/wild", tag = "v1.28.0" }
squirrel = { git = "https://github.com/getlipa/wild", tag = "v1.29.0" }
11 changes: 0 additions & 11 deletions pocketclient/Cargo.toml

This file was deleted.

Loading

0 comments on commit 8f82085

Please sign in to comment.