mirror of
https://github.com/luminous-devs/lume.git
synced 2024-09-29 00:10:47 +00:00
fix: remove native db
This commit is contained in:
parent
6a08c1de10
commit
d7bbda6e7b
129
src-tauri/Cargo.lock
generated
129
src-tauri/Cargo.lock
generated
@ -621,12 +621,6 @@ version = "3.14.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7f30e7476521f6f8af1a1c4c0b8cc94f0bee37d91763d0ca2665f299b6cd8aec"
|
||||
|
||||
[[package]]
|
||||
name = "bytecount"
|
||||
version = "0.6.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e1e5f035d16fc623ae5f74981db80a439803888314e3a555fd6f04acd51a3205"
|
||||
|
||||
[[package]]
|
||||
name = "bytemuck"
|
||||
version = "1.14.1"
|
||||
@ -726,19 +720,6 @@ dependencies = [
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cargo_metadata"
|
||||
version = "0.14.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4acbb09d9ee8e23699b9634375c72795d095bf268439da88562cf9b501f181fa"
|
||||
dependencies = [
|
||||
"camino",
|
||||
"cargo-platform",
|
||||
"semver",
|
||||
"serde",
|
||||
"serde_json",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cargo_metadata"
|
||||
version = "0.18.1"
|
||||
@ -1478,15 +1459,6 @@ dependencies = [
|
||||
"windows-sys 0.52.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "error-chain"
|
||||
version = "0.12.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2d2f06b9cac1506ece98fe3231e3cc9c4410ec3d5b1f24ae1c8946f0742cdefc"
|
||||
dependencies = [
|
||||
"version_check",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "error-code"
|
||||
version = "2.3.1"
|
||||
@ -2856,10 +2828,7 @@ name = "lume"
|
||||
version = "3.0.0"
|
||||
dependencies = [
|
||||
"keyring",
|
||||
"native_db",
|
||||
"native_model",
|
||||
"nostr-sdk",
|
||||
"once_cell",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"tauri",
|
||||
@ -3054,57 +3023,6 @@ dependencies = [
|
||||
"tempfile",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "native_db"
|
||||
version = "0.5.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "76960432093260203b73b1740426362abac4883c638f0f6c2648eb60b9e07cfe"
|
||||
dependencies = [
|
||||
"native_db_macro",
|
||||
"native_model",
|
||||
"redb",
|
||||
"serde",
|
||||
"skeptic",
|
||||
"thiserror",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "native_db_macro"
|
||||
version = "0.5.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fdacf1ab4dfa5e0d5dfdd84f4ffde4e2f6943570855d1f9f95d93bede1633afd"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.48",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "native_model"
|
||||
version = "0.4.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "83ab302fa10b708fcb04d497a937b472137cff9e5b79420085efd7a007b5f095"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"bincode",
|
||||
"native_model_macro",
|
||||
"serde",
|
||||
"skeptic",
|
||||
"thiserror",
|
||||
"zerocopy",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "native_model_macro"
|
||||
version = "0.4.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6e18cc9c2195ac588c81f3e3acdfe026e79a60c1d304c2f5ef4489e168f81aa2"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.48",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ndk"
|
||||
version = "0.7.0"
|
||||
@ -3932,17 +3850,6 @@ dependencies = [
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pulldown-cmark"
|
||||
version = "0.9.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "57206b407293d2bcd3af849ce869d52068623f19e1b5ff8e8778e3309439682b"
|
||||
dependencies = [
|
||||
"bitflags 2.4.2",
|
||||
"memchr",
|
||||
"unicase",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "quick-xml"
|
||||
version = "0.30.0"
|
||||
@ -4074,15 +3981,6 @@ dependencies = [
|
||||
"pin-project-lite",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "redb"
|
||||
version = "1.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "72623e6275cd430215b741f41ebda34db93a13ebde253f908b70871c46afc5ba"
|
||||
dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "redox_syscall"
|
||||
version = "0.4.1"
|
||||
@ -4714,21 +4612,6 @@ version = "0.3.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "38b58827f4464d87d377d175e90bf58eb00fd8716ff0a62f80356b5e61555d0d"
|
||||
|
||||
[[package]]
|
||||
name = "skeptic"
|
||||
version = "0.13.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "16d23b015676c90a0f01c197bfdc786c20342c73a0afdda9025adb0bc42940a8"
|
||||
dependencies = [
|
||||
"bytecount",
|
||||
"cargo_metadata 0.14.2",
|
||||
"error-chain",
|
||||
"glob",
|
||||
"pulldown-cmark",
|
||||
"tempfile",
|
||||
"walkdir 2.4.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "slab"
|
||||
version = "0.4.9"
|
||||
@ -5484,7 +5367,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e7104f0639a1f3a7ebd7aac793be47d7924f569e7c10c6853083529bf9bb3fe6"
|
||||
dependencies = [
|
||||
"brotli",
|
||||
"cargo_metadata 0.18.1",
|
||||
"cargo_metadata",
|
||||
"ctor",
|
||||
"dunce",
|
||||
"glob",
|
||||
@ -5958,15 +5841,6 @@ dependencies = [
|
||||
"winapi 0.3.9",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "unicase"
|
||||
version = "2.7.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f7d2d4dafb69621809a81864c9c1b864479e1235c0dd4e199924b9742439ed89"
|
||||
dependencies = [
|
||||
"version_check",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "unicode-bidi"
|
||||
version = "0.3.15"
|
||||
@ -6992,7 +6866,6 @@ version = "0.7.32"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "74d4d3961e53fa4c9a25a8637fc2bfaf2595b3d3ae34875568a5cf64787716be"
|
||||
dependencies = [
|
||||
"byteorder",
|
||||
"zerocopy-derive",
|
||||
]
|
||||
|
||||
|
@ -38,9 +38,6 @@ tauri-plugin-window-state = "2.0.0-beta"
|
||||
tauri-plugin-theme = { git = "https://github.com/wyhaya/tauri-plugin-theme" }
|
||||
webpage = { version = "2.0", features = ["serde"] }
|
||||
keyring = "2"
|
||||
native_db = "0.5.3"
|
||||
native_model = "0.4.6"
|
||||
once_cell = "1.19.0"
|
||||
|
||||
[features]
|
||||
# by default Tauri runs in production mode
|
||||
|
@ -1,29 +0,0 @@
|
||||
use once_cell::sync::Lazy;
|
||||
|
||||
pub(crate) mod api {
|
||||
use native_db::{native_db, InnerKeyValue};
|
||||
use native_model::{native_model, Model};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
pub mod v1 {
|
||||
use super::*;
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
#[native_model(id = 1, version = 2)]
|
||||
#[native_db]
|
||||
pub struct Account {
|
||||
#[primary_key]
|
||||
pub pubkey: String,
|
||||
#[secondary_key]
|
||||
status: String,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub static DATABASE_BUILDER: Lazy<native_db::DatabaseBuilder> = Lazy::new(|| {
|
||||
let mut builder = native_db::DatabaseBuilder::new();
|
||||
builder
|
||||
.define::<api::v1::Account>()
|
||||
.expect("failed to define model Account v1");
|
||||
builder
|
||||
});
|
@ -4,12 +4,8 @@
|
||||
)]
|
||||
|
||||
pub mod commands;
|
||||
pub mod db;
|
||||
pub mod nostr;
|
||||
|
||||
use crate::db::api::v1::AccountKey;
|
||||
use crate::db::DATABASE_BUILDER;
|
||||
use db::api::v1::Account;
|
||||
use keyring::Entry;
|
||||
use nostr_sdk::prelude::*;
|
||||
use std::sync::Arc;
|
||||
@ -38,18 +34,6 @@ fn main() {
|
||||
// Create nostr connection
|
||||
let client = ClientBuilder::default().database(nostr_db).build();
|
||||
|
||||
// Create app database connection
|
||||
let db = DATABASE_BUILDER
|
||||
.create(config_dir.join("app.db"))
|
||||
.expect("failed to create app database");
|
||||
|
||||
// Run migration for app database
|
||||
let rw = db
|
||||
.rw_transaction()
|
||||
.expect("failed to create rw migration transaction");
|
||||
rw.migrate::<Account>().expect("failed to migrate Account");
|
||||
rw.commit().expect("failed to commit migration");
|
||||
|
||||
// Add some bootstrap relays
|
||||
// #TODO: Pull bootstrap relays from user's settings
|
||||
client
|
||||
@ -65,37 +49,26 @@ fn main() {
|
||||
client.connect().await;
|
||||
|
||||
// Get stored account
|
||||
let r = db.r_transaction().expect("failed to create ro transaction");
|
||||
let accounts: Vec<Account> = r
|
||||
.scan()
|
||||
.secondary(AccountKey::status)
|
||||
.expect("failed to scan accounts")
|
||||
.start_with("active")
|
||||
.collect();
|
||||
let entry = Entry::new("Lume", "Account").unwrap();
|
||||
let mut contact_list = None;
|
||||
|
||||
// Run somethings if account existed
|
||||
if let Some(account) = accounts.into_iter().nth(0) {
|
||||
// Add signer with stored private key
|
||||
let entry = Entry::new("Lume", &account.pubkey).expect("failed to load secret");
|
||||
if let Ok(key) = entry.get_password() {
|
||||
let secret_key = SecretKey::from_bech32(key).unwrap();
|
||||
let keys = Keys::new(secret_key);
|
||||
let signer = ClientSigner::Keys(keys);
|
||||
|
||||
if let Ok(key) = entry.get_password() {
|
||||
let secret_key = SecretKey::from_bech32(key).unwrap();
|
||||
let keys = Keys::new(secret_key);
|
||||
let signer = ClientSigner::Keys(keys);
|
||||
// Update client's signer
|
||||
client.set_signer(Some(signer)).await;
|
||||
|
||||
// Update client's signer
|
||||
client.set_signer(Some(signer)).await;
|
||||
|
||||
// Get contact list
|
||||
contact_list = Some(
|
||||
client
|
||||
.get_contact_list(Some(Duration::from_secs(10)))
|
||||
.await
|
||||
.unwrap(),
|
||||
);
|
||||
}
|
||||
}
|
||||
// Get contact list
|
||||
contact_list = Some(
|
||||
client
|
||||
.get_contact_list(Some(Duration::from_secs(10)))
|
||||
.await
|
||||
.unwrap(),
|
||||
);
|
||||
};
|
||||
|
||||
// Init global state
|
||||
handle.manage(Nostr {
|
||||
|
Loading…
Reference in New Issue
Block a user