Skip to content

Commit 3537119

Browse files
authored
Multi nostr consumer (#452)
* Multi consumer * Multi consumer, some lib updates * Send multi id, allow send local ids * ignore data * Ignore data * Formatting * Non allocating string
1 parent b958101 commit 3537119

File tree

27 files changed

+880
-554
lines changed

27 files changed

+880
-554
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/target
22
/contacts/*
3-
/data/*
3+
data/
44
/frontend_build/*
55
/identity/*
66
/bills/*

Cargo.toml

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
[workspace]
22
resolver = "3"
3-
members = [ "crates/bcr-ebill-web", "crates/bcr-ebill-core", "crates/bcr-ebill-api", "crates/bcr-ebill-persistence" , "crates/bcr-ebill-transport", "crates/bcr-ebill-wasm"]
3+
members = [
4+
"crates/bcr-ebill-web",
5+
"crates/bcr-ebill-core",
6+
"crates/bcr-ebill-api",
7+
"crates/bcr-ebill-persistence",
8+
"crates/bcr-ebill-transport",
9+
"crates/bcr-ebill-wasm",
10+
]
411

512

613
[workspace.dependencies]
@@ -9,8 +16,12 @@ borsh = "1.5"
916
borsh-derive = "1.5"
1017
env_logger = { version = "0.11", default-features = false }
1118
log = { version = "0.4", features = ["serde"] }
12-
chrono = { version = "0.4", default-features = false, features = ["serde", "clock"] }
19+
chrono = { version = "0.4", default-features = false, features = [
20+
"serde",
21+
"clock",
22+
] }
1323
tokio = { version = "1.43", default-features = false, features = ["rt"] }
24+
tokio_with_wasm = { version = "0.8.2", features = ["rt"] }
1425
async-trait = "0.1"
1526
serde_json = "1"
1627
serde = { version = "1", default-features = false, features = ["derive"] }
@@ -20,10 +31,10 @@ anyhow = { version = "1", default-features = false }
2031
thiserror = { version = "2", default-features = false }
2132
lazy_static = "1.5"
2233
uuid = { version = "1", default-features = false, features = ["v4", "js"] }
23-
bitcoin = { version = "0.32", default-features = false }
34+
bitcoin = { version = "0.32", default-features = false }
2435
bip39 = { version = "2.1", features = ["rand"] }
2536
ecies = { version = "0.2", default-features = false, features = ["pure"] }
26-
nostr-sdk = { version = "0.39", features = ["nip59"] }
37+
nostr-sdk = { version = "0.40", features = ["nip59"] }
2738
getrandom = { version = "0.3.1", features = ["wasm_js"] }
2839
reqwest = { version = "0.12", default-features = false, features = ["json"] }
2940
async-broadcast = "0.7.2"

crates/bcr-ebill-api/Cargo.toml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,20 @@ uuid.workspace = true
2121
bitcoin.workspace = true
2222
nostr-sdk.workspace = true
2323
futures.workspace = true
24-
reqwest.workspace = true
24+
reqwest.workspace = true
2525
rust_decimal = { version = "1.36.0", default-features = false }
2626
infer = { version = "0.19.0", default-features = false }
2727
bcr-ebill-core = { path = "../bcr-ebill-core" }
2828
bcr-ebill-persistence = { path = "../bcr-ebill-persistence" }
2929
bcr-ebill-transport = { path = "../bcr-ebill-transport" }
30-
31-
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
3230
tokio.workspace = true
3331

32+
[target.'cfg(all(target_arch = "wasm32", target_vendor = "unknown", target_os = "unknown"))'.dependencies]
33+
tokio_with_wasm.workspace = true
34+
3435
[dev-dependencies]
3536
mockall = "0.13.1"
36-
nostr-relay-builder = "0.39.0"
37+
nostr-relay-builder = "0.40"
3738
tokio.workspace = true
3839
async-broadcast.workspace = true
3940

crates/bcr-ebill-api/src/service/bill_service/issue.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,13 @@ impl BillService {
192192
// send notification and blocks to all required recipients
193193
if let Err(e) = self
194194
.notification_service
195-
.send_bill_is_signed_event(&BillChainEvent::new(&bill, &chain, &bill_keys, true)?)
195+
.send_bill_is_signed_event(&BillChainEvent::new(
196+
&bill,
197+
&chain,
198+
&bill_keys,
199+
true,
200+
&identity.identity.node_id,
201+
)?)
196202
.await
197203
{
198204
error!("Error propagating bill via Nostr {e}");

crates/bcr-ebill-api/src/service/bill_service/mod.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2280,7 +2280,7 @@ pub mod tests {
22802280
// Asset request to mint event is sent
22812281
ctx.notification_service
22822282
.expect_send_request_to_mint_event()
2283-
.returning(|_| Ok(()));
2283+
.returning(|_, _| Ok(()));
22842284

22852285
let service = get_service(ctx);
22862286

@@ -2314,7 +2314,7 @@ pub mod tests {
23142314
// Asset request to mint event is sent
23152315
ctx.notification_service
23162316
.expect_send_request_to_mint_event()
2317-
.returning(|_| Ok(()));
2317+
.returning(|_, _| Ok(()));
23182318

23192319
let service = get_service(ctx);
23202320

@@ -2987,23 +2987,25 @@ pub mod tests {
29872987
ctx.notification_service
29882988
.expect_send_request_to_action_timed_out_event()
29892989
.with(
2990+
always(),
29902991
eq("1234"),
29912992
always(),
29922993
eq(ActionType::AcceptBill),
29932994
recipient_check.clone(),
29942995
)
2995-
.returning(|_, _, _, _| Ok(()));
2996+
.returning(|_, _, _, _, _| Ok(()));
29962997

29972998
// send pay timeout notification
29982999
ctx.notification_service
29993000
.expect_send_request_to_action_timed_out_event()
30003001
.with(
3002+
always(),
30013003
eq("4321"),
30023004
always(),
30033005
eq(ActionType::PayBill),
30043006
recipient_check,
30053007
)
3006-
.returning(|_, _, _, _| Ok(()));
3008+
.returning(|_, _, _, _, _| Ok(()));
30073009

30083010
// marks accept bill timeout as sent
30093011
ctx.notification_service

crates/bcr-ebill-api/src/service/bill_service/propagation.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,13 @@ impl BillService {
2323
.get_last_version_bill(blockchain, bill_keys, identity, contacts)
2424
.await?;
2525

26-
let chain_event = BillChainEvent::new(&last_version_bill, blockchain, bill_keys, true)?;
26+
let chain_event = BillChainEvent::new(
27+
&last_version_bill,
28+
blockchain,
29+
bill_keys,
30+
true,
31+
&identity.node_id,
32+
)?;
2733

2834
match bill_action {
2935
BillAction::Accept => {
@@ -57,7 +63,7 @@ impl BillService {
5763
}
5864
BillAction::Mint(_, _, _) => {
5965
self.notification_service
60-
.send_request_to_mint_event(&last_version_bill)
66+
.send_request_to_mint_event(&identity.node_id, &last_version_bill)
6167
.await?;
6268
}
6369
BillAction::OfferToSell(buyer, _, _) => {

crates/bcr-ebill-api/src/service/bill_service/service.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ impl BillService {
198198

199199
self.notification_service
200200
.send_request_to_action_timed_out_event(
201+
&identity.node_id,
201202
bill_id,
202203
Some(bill.sum),
203204
action.to_owned(),

0 commit comments

Comments
 (0)