Skip to content

Commit 6a0ab2c

Browse files
tomproCopilot
andauthored
Public bill chain (#525)
* Internal module refactor * Helpers and interfaces * Event store * Refactor event envelope * Fix tests and publish invites * Lookup and store events, tests * Update crates/bcr-ebill-api/src/service/notification_service/default_service.rs Co-authored-by: Copilot <[email protected]> * Update crates/bcr-ebill-api/src/service/notification_service/nostr.rs Co-authored-by: Copilot <[email protected]> * User surreal wrapper * Use async-trait add wasm check to justfile * Review fixes --------- Co-authored-by: Copilot <[email protected]>
1 parent 508bf4f commit 6a0ab2c

File tree

28 files changed

+1306
-305
lines changed

28 files changed

+1306
-305
lines changed

Cargo.toml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ lto = true # Enable Link-Time Optimization
1919
codegen-units = 1 # Reduces binary size at the cost of compile time
2020

2121
[profile.dev]
22-
opt-level = 1 # Avoid surrealdb index out of bounds issue in dev build
22+
opt-level = 1 # Avoid surrealdb index out of bounds issue in dev build
2323

2424
[workspace.dependencies]
2525
sha2 = { version = "0.10", default-features = false }
@@ -30,7 +30,10 @@ chrono = { version = "0.4", default-features = false, features = [
3030
"serde",
3131
"clock",
3232
] }
33-
tokio = { version = "1.43", default-features = false, features = ["rt", "sync"] }
33+
tokio = { version = "1.43", default-features = false, features = [
34+
"rt",
35+
"sync",
36+
] }
3437
tokio_with_wasm = { version = "0.8", features = ["rt", "sync"] }
3538
async-trait = "0.1"
3639
serde_json = "1"
@@ -43,10 +46,11 @@ uuid = { version = "1", default-features = false, features = ["v4", "js"] }
4346
bitcoin = { version = "0.32", default-features = false }
4447
bip39 = { version = "2.1", features = ["rand"] }
4548
ecies = { version = "0.2", default-features = false, features = ["pure"] }
46-
nostr = { version = "0.41" }
47-
nostr-sdk = { version = "0.41", features = ["nip04", "nip59"] }
49+
nostr = { version = "0.42" }
50+
nostr-sdk = { version = "0.42", features = ["nip04", "nip59"] }
51+
getrandom = { version = "0.3.1", features = ["wasm_js"] }
4852
async-broadcast = "0.7.2"
4953
rstest = "0.25.0"
5054
secp256k1 = { version = "0.29" }
5155
reqwest = { version = "0.12", default-features = false }
52-
miniscript = {version = "12.3"}
56+
miniscript = { version = "12.3" }

crates/bcr-ebill-api/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ reqwest = { workspace = true, features = ["default", "json"] }
4343

4444
[dev-dependencies]
4545
mockall = "0.13.1"
46-
nostr-relay-builder = "0.41"
46+
nostr-relay-builder = "0.42"
4747
tokio.workspace = true
4848
async-broadcast.workspace = true
4949

crates/bcr-ebill-api/src/persistence/mod.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@ use crate::Config;
22
#[cfg(not(target_arch = "wasm32"))]
33
use bcr_ebill_persistence::get_surreal_db;
44
use bcr_ebill_persistence::{
5-
BackupStoreApi, ContactStoreApi, NostrEventOffsetStoreApi, NotificationStoreApi,
6-
SurrealBackupStore, SurrealBillChainStore, SurrealBillStore, SurrealCompanyChainStore,
7-
SurrealCompanyStore, SurrealContactStore, SurrealIdentityChainStore, SurrealIdentityStore,
8-
SurrealNostrEventOffsetStore, SurrealNotificationStore,
5+
BackupStoreApi, ContactStoreApi, NostrChainEventStoreApi, NostrEventOffsetStoreApi,
6+
NotificationStoreApi, SurrealBackupStore, SurrealBillChainStore, SurrealBillStore,
7+
SurrealCompanyChainStore, SurrealCompanyStore, SurrealContactStore, SurrealIdentityChainStore,
8+
SurrealIdentityStore, SurrealNostrChainEventStore, SurrealNostrEventOffsetStore,
9+
SurrealNotificationStore,
910
bill::{BillChainStoreApi, BillStoreApi},
1011
company::{CompanyChainStoreApi, CompanyStoreApi},
1112
db::{
@@ -49,6 +50,7 @@ pub struct DbContext {
4950
pub queued_message_store: Arc<dyn NostrQueuedMessageStoreApi>,
5051
pub nostr_contact_store: Arc<dyn NostrContactStoreApi>,
5152
pub mint_store: Arc<dyn MintStoreApi>,
53+
pub nostr_chain_event_store: Arc<dyn NostrChainEventStoreApi>,
5254
}
5355

5456
/// Creates a new instance of the DbContext with the given SurrealDB configuration.
@@ -109,6 +111,8 @@ pub async fn get_db_context(
109111
let queued_message_store = Arc::new(SurrealNostrEventQueueStore::new(surreal_wrapper.clone()));
110112
let nostr_contact_store = Arc::new(SurrealNostrContactStore::new(surreal_wrapper.clone()));
111113
let mint_store = Arc::new(SurrealMintStore::new(surreal_wrapper.clone()));
114+
let nostr_chain_event_store =
115+
Arc::new(SurrealNostrChainEventStore::new(surreal_wrapper.clone()));
112116

113117
Ok(DbContext {
114118
contact_store,
@@ -125,5 +129,6 @@ pub async fn get_db_context(
125129
queued_message_store,
126130
nostr_contact_store,
127131
mint_store,
132+
nostr_chain_event_store,
128133
})
129134
}

0 commit comments

Comments
 (0)