Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion applications/tari_walletd/src/handlers/auth/jwt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use jsonwebtoken::{errors, DecodingKey, EncodingKey, Header, Validation};
use serde::{Deserialize, Serialize};
use tari_crypto::tari_utilities::SafePassword;
use tari_ootle_wallet_sdk::storage::{
CommitableStore,
CommittableStore,
WalletStorageError,
WalletStore,
WalletStoreReader,
Expand Down
2 changes: 1 addition & 1 deletion applications/tari_walletd/src/services/webauthn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
use std::time::{Duration, Instant};

use tari_ootle_wallet_sdk::storage::{
CommitableStore,
CommittableStore,
WalletStorageError,
WalletStore,
WalletStoreReader,
Expand Down
5 changes: 2 additions & 3 deletions crates/wallet/sdk/src/apis/accounts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ use crate::{
WalletOotleAddressWithKeyIds,
},
network::WalletNetworkInterface,
storage::{CommitableStore, WalletStorageError, WalletStore, WalletStoreReader, WalletStoreWriter},
storage::{CommittableStore, WalletStorageError, WalletStore, WalletStoreReader, WalletStoreWriter},
};

pub struct AccountsApi<'a, TStore, TNetworkInterface> {
Expand Down Expand Up @@ -165,8 +165,7 @@ impl<'a, TStore: WalletStore, TNetworkInterface> AccountsApi<'a, TStore, TNetwor
}

pub fn count(&self) -> Result<u64, AccountsApiError> {
let mut tx = self.store.create_read_tx()?;
let count = tx.accounts_count()?;
let count = self.store.with_read_tx(|tx| tx.accounts_count())?;
Ok(count)
}

Expand Down
2 changes: 1 addition & 1 deletion crates/wallet/sdk/src/apis/confidential_outputs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use crate::{
key_manager::{KeyManagerApi, KeyManagerApiError},
},
models::{Account, ConfidentialOutputModel, OutputStatus, WalletLockId, WalletSecretKey},
storage::{CommitableStore, WalletStorageError, WalletStore, WalletStoreReader, WalletStoreWriter},
storage::{CommittableStore, WalletStorageError, WalletStore, WalletStoreReader, WalletStoreWriter},
};

const LOG_TARGET: &str = "tari::ootle::wallet_sdk::apis::confidential_outputs";
Expand Down
2 changes: 1 addition & 1 deletion crates/wallet/sdk/src/apis/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use std::{str::FromStr, sync::OnceLock};
use serde::{de::DeserializeOwned, Serialize};
use tari_ootle_common_types::{optional::IsNotFoundError, Network};

use crate::storage::{CommitableStore, WalletStorageError, WalletStore, WalletStoreReader, WalletStoreWriter};
use crate::storage::{CommittableStore, WalletStorageError, WalletStore, WalletStoreReader, WalletStoreWriter};

#[derive(Debug, Clone)]
pub struct ConfigApi<'a, TStore> {
Expand Down
2 changes: 1 addition & 1 deletion crates/wallet/sdk/src/apis/key_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ use crate::{
WalletPublicKey,
WalletSecretKey,
},
storage::{CommitableStore, WalletStorageError, WalletStore, WalletStoreReader, WalletStoreWriter},
storage::{CommittableStore, WalletStorageError, WalletStore, WalletStoreReader, WalletStoreWriter},
};

pub type WalletKeyManager = TariKeyManager<Blake2b<U64>>;
Expand Down
8 changes: 6 additions & 2 deletions crates/wallet/sdk/src/apis/locks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,21 @@ use tari_transaction::TransactionId;

use crate::{
models::{WalletLockDropGuard, WalletLockId},
storage::{WalletStorageError, WalletStore, WalletStoreReader, WalletStoreWriter},
storage::{ReadableWalletStore, WalletStorageError, WalletStoreReader, WalletStoreWriter, WriteableWalletStore},
};

#[derive(Clone)]
pub struct LocksApi<'a, TStore> {
store: &'a TStore,
}

impl<'a, TStore: WalletStore> LocksApi<'a, TStore> {
impl<'a, TStore> LocksApi<'a, TStore> {
pub(crate) fn new(store: &'a TStore) -> Self {
Self { store }
}
}

impl<'a, TStore: WriteableWalletStore> LocksApi<'a, TStore> {
pub fn create_lock(&self) -> Result<WalletLockDropGuard<'a, TStore>, LocksApiError> {
let lock_id = self.store.with_write_tx(|tx| tx.locks_create(None))?;
Ok(WalletLockDropGuard::new(lock_id, self.store))
Expand Down Expand Up @@ -63,7 +65,9 @@ impl<'a, TStore: WalletStore> LocksApi<'a, TStore> {
let num = self.store.with_write_tx(|tx| tx.locks_release_stale())?;
Ok(num)
}
}

impl<TStore: ReadableWalletStore> LocksApi<'_, TStore> {
pub fn get_lock_by_transaction_id(&self, transaction_id: TransactionId) -> Result<WalletLockId, LocksApiError> {
let lock_id = self
.store
Expand Down
2 changes: 1 addition & 1 deletion crates/wallet/sdk/src/apis/non_fungible_tokens.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use thiserror::Error;

use crate::{
models::NonFungibleToken,
storage::{CommitableStore, WalletStorageError, WalletStore, WalletStoreReader, WalletStoreWriter},
storage::{CommittableStore, WalletStorageError, WalletStore, WalletStoreReader, WalletStoreWriter},
};

pub struct NonFungibleTokensApi<'a, TStore> {
Expand Down
2 changes: 1 addition & 1 deletion crates/wallet/sdk/src/apis/stealth_outputs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ use crate::{
StealthOutputModel,
WalletLockId,
},
storage::{CommitableStore, WalletStorageError, WalletStore, WalletStoreReader, WalletStoreWriter},
storage::{CommittableStore, WalletStorageError, WalletStore, WalletStoreReader, WalletStoreWriter},
};

const LOG_TARGET: &str = "tari::ootle::wallet::apis::stealth_outputs";
Expand Down
2 changes: 1 addition & 1 deletion crates/wallet/sdk/src/models/lock_guard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

use crate::{
models::WalletLockId,
storage::{CommitableStore, WalletStoreWriter, WriteableWalletStore},
storage::{CommittableStore, WalletStoreWriter, WriteableWalletStore},
};

const LOG_TARGET: &str = "tari::ootle::wallet::models::lock_guard";
Expand Down
39 changes: 0 additions & 39 deletions crates/wallet/sdk/src/sdk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,45 +96,6 @@ where
})
}

// pub fn create_read_context(&self) -> Result<SdkReadContext<TStore>, WalletSdkError> {
// let read_tx = self.store.create_read_tx()?;
// Ok(SdkReadContext::new(read_tx))
// }
//
// pub fn with_read_context<R, F, E>(&self, f: F) -> Result<R, E>
// where
// F: FnOnce(&mut SdkReadContext<TStore>) -> Result<R, WalletSdkError>,
// E: From<WalletStorageError>,
// {
// let mut ctx = self.create_read_context()?;
// let ret = f(&mut ctx)?;
// Ok(ret)
// }
//
// pub fn create_write_context(&self) -> Result<SdkWriteContext<TStore>, WalletSdkError> {
// let write_tx = self.store.create_write_tx()?;
// Ok(SdkWriteContext::new(write_tx))
// }
//
// pub fn with_write_context<R, F, E>(&self, f: F) -> Result<R, E>
// where
// F: FnOnce(&mut SdkWriteContext<TStore>) -> Result<R, WalletSdkError>,
// E: From<WalletSdkError>,
// {
// let mut ctx = self.create_write_context()?;
// match f(&mut ctx) {
// Ok(r) => {
// ctx.commit()?;
// Ok(r)
// },
// Err(e) => {
// warn!(target: LOG_TARGET, "Transaction failed! rollback");
// ctx.rollback()?;
// Err(e.into())
// },
// }
// }

pub fn get_store_network(store: &TStore) -> Result<Option<Network>, WalletSdkError> {
let config_api = ConfigApi::new(store);
let network = config_api.get(ConfigKey::Network).optional()?;
Expand Down
Loading
Loading