diff --git a/applications/tari_walletd/src/handlers/auth/jwt.rs b/applications/tari_walletd/src/handlers/auth/jwt.rs index aff94c2397..b4292fd5a8 100644 --- a/applications/tari_walletd/src/handlers/auth/jwt.rs +++ b/applications/tari_walletd/src/handlers/auth/jwt.rs @@ -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, diff --git a/applications/tari_walletd/src/services/webauthn.rs b/applications/tari_walletd/src/services/webauthn.rs index d14db6f8d8..e58e406107 100644 --- a/applications/tari_walletd/src/services/webauthn.rs +++ b/applications/tari_walletd/src/services/webauthn.rs @@ -4,7 +4,7 @@ use std::time::{Duration, Instant}; use tari_ootle_wallet_sdk::storage::{ - CommitableStore, + CommittableStore, WalletStorageError, WalletStore, WalletStoreReader, diff --git a/crates/wallet/sdk/src/apis/accounts.rs b/crates/wallet/sdk/src/apis/accounts.rs index 6769e88f92..e479aea1f6 100644 --- a/crates/wallet/sdk/src/apis/accounts.rs +++ b/crates/wallet/sdk/src/apis/accounts.rs @@ -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> { @@ -165,8 +165,7 @@ impl<'a, TStore: WalletStore, TNetworkInterface> AccountsApi<'a, TStore, TNetwor } pub fn count(&self) -> Result { - 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) } diff --git a/crates/wallet/sdk/src/apis/confidential_outputs.rs b/crates/wallet/sdk/src/apis/confidential_outputs.rs index 35f0e24ed3..2be54abe64 100644 --- a/crates/wallet/sdk/src/apis/confidential_outputs.rs +++ b/crates/wallet/sdk/src/apis/confidential_outputs.rs @@ -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"; diff --git a/crates/wallet/sdk/src/apis/config.rs b/crates/wallet/sdk/src/apis/config.rs index 921337de03..da6d74ebfb 100644 --- a/crates/wallet/sdk/src/apis/config.rs +++ b/crates/wallet/sdk/src/apis/config.rs @@ -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> { diff --git a/crates/wallet/sdk/src/apis/key_manager.rs b/crates/wallet/sdk/src/apis/key_manager.rs index 729b52e543..c1864bc84b 100644 --- a/crates/wallet/sdk/src/apis/key_manager.rs +++ b/crates/wallet/sdk/src/apis/key_manager.rs @@ -34,7 +34,7 @@ use crate::{ WalletPublicKey, WalletSecretKey, }, - storage::{CommitableStore, WalletStorageError, WalletStore, WalletStoreReader, WalletStoreWriter}, + storage::{CommittableStore, WalletStorageError, WalletStore, WalletStoreReader, WalletStoreWriter}, }; pub type WalletKeyManager = TariKeyManager>; diff --git a/crates/wallet/sdk/src/apis/locks.rs b/crates/wallet/sdk/src/apis/locks.rs index 743a021357..b607f5ec8a 100644 --- a/crates/wallet/sdk/src/apis/locks.rs +++ b/crates/wallet/sdk/src/apis/locks.rs @@ -10,7 +10,7 @@ use tari_transaction::TransactionId; use crate::{ models::{WalletLockDropGuard, WalletLockId}, - storage::{WalletStorageError, WalletStore, WalletStoreReader, WalletStoreWriter}, + storage::{ReadableWalletStore, WalletStorageError, WalletStoreReader, WalletStoreWriter, WriteableWalletStore}, }; #[derive(Clone)] @@ -18,11 +18,13 @@ 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, LocksApiError> { let lock_id = self.store.with_write_tx(|tx| tx.locks_create(None))?; Ok(WalletLockDropGuard::new(lock_id, self.store)) @@ -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 LocksApi<'_, TStore> { pub fn get_lock_by_transaction_id(&self, transaction_id: TransactionId) -> Result { let lock_id = self .store diff --git a/crates/wallet/sdk/src/apis/non_fungible_tokens.rs b/crates/wallet/sdk/src/apis/non_fungible_tokens.rs index 1eb18a8e15..7aad124c2f 100644 --- a/crates/wallet/sdk/src/apis/non_fungible_tokens.rs +++ b/crates/wallet/sdk/src/apis/non_fungible_tokens.rs @@ -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> { diff --git a/crates/wallet/sdk/src/apis/stealth_outputs.rs b/crates/wallet/sdk/src/apis/stealth_outputs.rs index ffbeb31feb..3f2ffb6cde 100644 --- a/crates/wallet/sdk/src/apis/stealth_outputs.rs +++ b/crates/wallet/sdk/src/apis/stealth_outputs.rs @@ -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"; diff --git a/crates/wallet/sdk/src/models/lock_guard.rs b/crates/wallet/sdk/src/models/lock_guard.rs index 0b56cff79b..f67dfd8b58 100644 --- a/crates/wallet/sdk/src/models/lock_guard.rs +++ b/crates/wallet/sdk/src/models/lock_guard.rs @@ -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"; diff --git a/crates/wallet/sdk/src/sdk.rs b/crates/wallet/sdk/src/sdk.rs index 08eb8a3c92..61356054d2 100644 --- a/crates/wallet/sdk/src/sdk.rs +++ b/crates/wallet/sdk/src/sdk.rs @@ -96,45 +96,6 @@ where }) } - // pub fn create_read_context(&self) -> Result, WalletSdkError> { - // let read_tx = self.store.create_read_tx()?; - // Ok(SdkReadContext::new(read_tx)) - // } - // - // pub fn with_read_context(&self, f: F) -> Result - // where - // F: FnOnce(&mut SdkReadContext) -> Result, - // E: From, - // { - // let mut ctx = self.create_read_context()?; - // let ret = f(&mut ctx)?; - // Ok(ret) - // } - // - // pub fn create_write_context(&self) -> Result, WalletSdkError> { - // let write_tx = self.store.create_write_tx()?; - // Ok(SdkWriteContext::new(write_tx)) - // } - // - // pub fn with_write_context(&self, f: F) -> Result - // where - // F: FnOnce(&mut SdkWriteContext) -> Result, - // E: From, - // { - // 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, WalletSdkError> { let config_api = ConfigApi::new(store); let network = config_api.get(ConfigKey::Network).optional()?; diff --git a/crates/wallet/sdk/src/storage.rs b/crates/wallet/sdk/src/storage.rs deleted file mode 100644 index ae6f1267ba..0000000000 --- a/crates/wallet/sdk/src/storage.rs +++ /dev/null @@ -1,520 +0,0 @@ -// Copyright 2023 The Tari Project -// SPDX-License-Identifier: BSD-3-Clause - -use std::{ - collections::{HashMap, HashSet}, - ops::{Deref, DerefMut}, - time::Duration, -}; - -use tari_engine_types::{ - resource::Resource, - substate::{SubstateDiff, SubstateId}, -}; -use tari_ootle_common_types::{ - optional::IsNotFoundError, - shard::Shard, - substate_type::SubstateType, - StateVersion, - VersionedSubstateIdRef, -}; -use tari_template_lib::{ - models::{UtxoAddress, UtxoId, VaultId}, - prelude::{ - ComponentAddress, - NonFungibleId, - PedersenCommitmentBytes, - ResourceAddress, - ResourceType, - RistrettoPublicKeyBytes, - }, - types::{crypto::UtxoTag, Amount, TemplateAddress}, -}; -use tari_transaction::{Transaction, TransactionId}; -use webauthn_rs::prelude::Passkey; - -use crate::models::{ - Account, - AccountUpdate, - AuthoredTemplateModel, - ConfidentialOutputModel, - Config, - ImportedKeyId, - KeyId, - KeyType, - NewAccountData, - NonFungibleToken, - OutputStatus, - ResourceModel, - StealthBalance, - StealthOutputModel, - SubstateModel, - TransactionStatus, - UtxoUnspent, - VaultModel, - WalletLockId, - WalletTransaction, - WalletTransactionUpdate, -}; - -pub trait ReadableWalletStore { - type ReadTransaction<'a>: WalletStoreReader - where Self: 'a; - - fn create_read_tx(&self) -> Result, WalletStorageError>; - - fn with_read_tx) -> Result, R, E>(&self, f: F) -> Result - where E: From { - let mut tx = self.create_read_tx()?; - let ret = f(&mut tx)?; - Ok(ret) - } -} - -pub trait WriteableWalletStore: ReadableWalletStore { - type WriteTransaction<'a>: WalletStoreWriter + Deref> + DerefMut - where Self: 'a; - - fn create_write_tx(&self) -> Result, WalletStorageError>; - - fn with_write_tx) -> Result, R, E>(&self, f: F) -> Result - where E: From { - let mut tx = self.create_write_tx()?; - match f(&mut tx) { - Ok(r) => { - tx.commit()?; - Ok(r) - }, - Err(e) => { - if let Err(err) = tx.rollback() { - log::error!("Failed to rollback transaction: {}", err); - } - Err(e) - }, - } - } -} - -pub trait WalletStore: ReadableWalletStore + WriteableWalletStore {} - -impl WalletStore for T where T: ReadableWalletStore + WriteableWalletStore {} - -#[derive(Debug, thiserror::Error)] -pub enum WalletStorageError { - #[error("General database failure for operation {operation}: {details}")] - GeneralFailure { operation: &'static str, details: String }, - #[error("Bad query for operation {operation}: {details}")] - BadQuery { operation: &'static str, details: String }, - #[error("Failed to decode for operation {operation} on {item}: {details}")] - DecodingError { - operation: &'static str, - item: &'static str, - details: String, - }, - #[error("Failed to encode for operation {operation} on {item}: {details}")] - EncodingError { - operation: &'static str, - item: &'static str, - details: String, - }, - #[error("[{operation}] {entity} not found with key {key}")] - NotFound { - operation: &'static str, - entity: String, - key: String, - }, - #[error("Operation error {operation}: {details}")] - OperationError { operation: &'static str, details: String }, - #[error("Data inconsistency for operation {operation}: {details}")] - DataInconsistent { operation: &'static str, details: String }, - #[error("Encryption error {operation}: {details}")] - EncryptionError { operation: &'static str, details: String }, - #[error("Decryption error {operation}: {details}")] - DecryptionError { operation: &'static str, details: String }, -} - -impl IsNotFoundError for WalletStorageError { - fn is_not_found_error(&self) -> bool { - matches!(self, Self::NotFound { .. }) - } -} - -impl WalletStorageError { - pub fn general(operation: &'static str, e: E) -> Self { - Self::GeneralFailure { - operation, - details: e.to_string(), - } - } - - pub fn bad_query>(operation: &'static str, details: E) -> Self { - Self::BadQuery { - operation, - details: details.into(), - } - } - - pub fn not_found(operation: &'static str, entity: String, key: String) -> Self { - Self::NotFound { operation, entity, key } - } -} - -pub trait WalletStoreReader { - // Key manager - fn key_manager_get_all(&mut self, branch: &str) -> Result, WalletStorageError>; - fn key_manager_get_active_index(&mut self, branch: &str) -> Result; - fn key_manager_get_last_index(&mut self, branch: &str) -> Result; - fn key_manager_get_raw_imported_key(&mut self, id: u64) -> Result<(KeyType, Box<[u8]>), WalletStorageError>; - // Config - fn config_get(&mut self, key: &str) -> Result, WalletStorageError>; - fn config_get_string(&mut self, key: &str) -> Result, WalletStorageError>; - fn config_exists(&mut self, key: &str) -> Result; - // JWT - fn jwt_get_all(&mut self) -> Result)>, WalletStorageError>; - // Transactions - fn transactions_get(&mut self, transaction_id: TransactionId) -> Result; - fn transactions_fetch_all( - &mut self, - status: Option, - component: Option, - signed_by_public_key: Option, - ) -> Result, WalletStorageError>; - // Substates - fn substates_get(&mut self, address: &SubstateId) -> Result; - fn substates_get_all( - &mut self, - by_type: Option, - by_template_address: Option<&TemplateAddress>, - limit: Option, - offset: Option, - ) -> Result, WalletStorageError>; - fn substates_get_children(&mut self, parent: &SubstateId) -> Result, WalletStorageError>; - // Accounts - fn accounts_get(&mut self, address: &ComponentAddress) -> Result; - fn accounts_get_many(&mut self, offset: usize, limit: usize) -> Result, WalletStorageError>; - fn accounts_get_default(&mut self) -> Result; - fn accounts_count(&mut self) -> Result; - fn accounts_get_by_name(&mut self, name: &str) -> Result; - fn accounts_get_by_vault(&mut self, vault_id: &VaultId) -> Result; - fn accounts_get_associated_stealth_resources( - &mut self, - address: &ComponentAddress, - ) -> Result, WalletStorageError>; - - // Vaults - fn vaults_get(&mut self, vault_id: &VaultId) -> Result; - fn vaults_exists(&mut self, vault_id: &VaultId) -> Result; - fn vaults_get_by_resource( - &mut self, - account_addr: &ComponentAddress, - resource_address: &ResourceAddress, - ) -> Result; - fn vaults_get_by_account(&mut self, account_addr: &ComponentAddress) - -> Result, WalletStorageError>; - - // Resources - fn resources_get(&mut self, resource_address: &ResourceAddress) -> Result; - fn resources_get_by_type(&mut self, resource_type: ResourceType) -> Result, WalletStorageError>; - fn resources_get_many<'a, I: IntoIterator>( - &mut self, - addresses: I, - ) -> Result, WalletStorageError>; - - // Confidential Outputs - fn confidential_outputs_get_unspent_balance(&mut self, vault_id: &VaultId) -> Result; - fn confidential_outputs_get_locked_by_lock_id( - &mut self, - lock_id: WalletLockId, - ) -> Result, WalletStorageError>; - fn confidential_outputs_get_by_commitment( - &mut self, - vault_id: &VaultId, - commitment: &PedersenCommitmentBytes, - ) -> Result; - - fn confidential_outputs_get_by_account_and_status( - &mut self, - account_addr: &ComponentAddress, - status: OutputStatus, - ) -> Result, WalletStorageError>; - - // Stealth outputs - fn stealth_outputs_get_unspent_balance( - &mut self, - resource_address: &ResourceAddress, - ) -> Result; - - fn stealth_outputs_count_by_status( - &mut self, - account_addr: &ComponentAddress, - resource_address: &ResourceAddress, - status: OutputStatus, - ) -> Result; - - fn stealth_outputs_get_unspent_by_account( - &mut self, - account_addr: &ComponentAddress, - exclude_locked: bool, - ) -> Result, WalletStorageError>; - - fn stealth_outputs_get_locked_by_lock_id( - &mut self, - lock_id: WalletLockId, - ) -> Result, WalletStorageError>; - fn stealth_outputs_get_by_commitment( - &mut self, - resource_address: &ResourceAddress, - commitment: &PedersenCommitmentBytes, - ) -> Result; - - fn stealth_outputs_get_many( - &mut self, - resource_address: &ResourceAddress, - by_account: Option<&ComponentAddress>, - by_status: Option, - ) -> Result, WalletStorageError>; - - // Output Locks - fn locks_get_by_transaction_id( - &mut self, - transaction_id: TransactionId, - ) -> Result; - - // Non fungible tokens - fn non_fungible_token_get_by_nft_id( - &mut self, - resource_address: ResourceAddress, - nft_id: NonFungibleId, - ) -> Result; - - fn non_fungible_token_get_ids_by_vault_id( - &mut self, - vault_id: &VaultId, - limit: u64, - offset: u64, - ) -> Result, WalletStorageError>; - - fn non_fungible_token_get_all( - &mut self, - account: ComponentAddress, - limit: u64, - offset: u64, - ) -> Result, WalletStorageError>; - - fn non_fungible_token_get_resource_address( - &mut self, - nft_id: NonFungibleId, - ) -> Result; - - // Webauthn registration - fn webauthn_is_user_registered(&mut self, username: &str) -> Result; - fn webauthn_reg_fetch_passkeys(&mut self, username: String) -> Result, WalletStorageError>; - - // Authored templates - fn authored_templates_exists_by_address(&mut self, address: &TemplateAddress) -> Result; - fn authored_templates_fetch_by_public_key( - &mut self, - author_public_key: &RistrettoPublicKeyBytes, - page: u64, - page_size: u64, - ) -> Result<(Vec, u64), WalletStorageError>; - - fn shard_state_version_get( - &mut self, - account: &ComponentAddress, - resource: &ResourceAddress, - ) -> Result, WalletStorageError>; - - fn utxo_process_queue_fetch_batch( - &mut self, - batch_size: usize, - ) -> Result>, WalletStorageError>; -} - -pub type TagAndPublicNoncePair = (UtxoTag, RistrettoPublicKeyBytes); - -pub trait CommitableStore { - fn commit(&mut self) -> Result<(), WalletStorageError>; - fn rollback(&mut self) -> Result<(), WalletStorageError>; -} - -pub trait WalletStoreWriter: CommitableStore { - // JWT - fn jwt_add_empty_token(&mut self) -> Result; - fn jwt_store_decision(&mut self, id: u64, permissions_token: Option<&str>) -> Result<(), WalletStorageError>; - fn jwt_is_revoked(&mut self, token: &str) -> Result; - fn jwt_revoke(&mut self, token_id: i32) -> Result<(), WalletStorageError>; - - // Key manager - fn key_manager_insert_or_ignore(&mut self, branch: &str, index: u64) -> Result<(), WalletStorageError>; - fn key_manager_set_active_index(&mut self, branch: &str, index: u64) -> Result<(), WalletStorageError>; - fn key_manager_reset_index(&mut self, branch: &str, index: u64) -> Result<(), WalletStorageError>; - fn key_manager_insert_imported_key( - &mut self, - label: &str, - encrypted_key: &[u8], - key_type: KeyType, - ) -> Result; - - // Config - fn config_set( - &mut self, - key: &str, - value: &T, - is_encrypted: bool, - ) -> Result<(), WalletStorageError>; - - // Transactions - fn transactions_insert( - &mut self, - transaction: &Transaction, - new_account_info: Option<&NewAccountData>, - is_dry_run: bool, - ) -> Result<(), WalletStorageError>; - fn transactions_update(&mut self, update: WalletTransactionUpdate<'_>) -> Result<(), WalletStorageError>; - - // Substates - fn substates_upsert_root( - &mut self, - substate_id: VersionedSubstateIdRef<'_>, - referenced_substates: HashSet, - module_name: Option, - template_addr: Option, - ) -> Result<(), WalletStorageError>; - fn substates_upsert_child( - &mut self, - parent: &SubstateId, - address: VersionedSubstateIdRef<'_>, - referenced_substates: HashSet, - ) -> Result<(), WalletStorageError>; - fn substates_remove(&mut self, substate: &SubstateId) -> Result; - - // Accounts - fn accounts_set_default(&mut self, account_addr: &ComponentAddress) -> Result<(), WalletStorageError>; - fn accounts_insert( - &mut self, - account_name: Option<&str>, - account_addr: &ComponentAddress, - view_only_key_id: KeyId, - owner_key_id: Option, - owner_public_key: &RistrettoPublicKeyBytes, - associated_stealth_resources: &HashSet, - is_confirmed_on_chain: bool, - is_default: bool, - ) -> Result<(), WalletStorageError>; - - fn accounts_update( - &mut self, - account_addr: &ComponentAddress, - update: AccountUpdate<'_>, - ) -> Result<(), WalletStorageError>; - - fn accounts_add_stealth_resource( - &mut self, - account_addr: &ComponentAddress, - resource_address: ResourceAddress, - ) -> Result<(), WalletStorageError>; - - // Vaults - fn vaults_insert(&mut self, vault: VaultModel) -> Result<(), WalletStorageError>; - fn vaults_update( - &mut self, - vault_id: VaultId, - revealed_balance: Amount, - confidential_balance: Amount, - ) -> Result<(), WalletStorageError>; - fn vaults_lock_revealed_funds( - &mut self, - lock_id: WalletLockId, - vault_id: &VaultId, - amount_to_lock: Amount, - ) -> Result<(), WalletStorageError>; - fn vaults_finalized_locked_revealed_funds(&mut self, lock_id: WalletLockId) -> Result<(), WalletStorageError>; - fn vaults_release_lock_revealed_funds(&mut self, lock_id: WalletLockId) -> Result<(), WalletStorageError>; - // Resources - fn resources_upsert(&mut self, address: &ResourceAddress, resource: &Resource) -> Result<(), WalletStorageError>; - // Confidential Outputs - fn confidential_outputs_lock_smallest_amount( - &mut self, - vault_id: &VaultId, - lock_id: WalletLockId, - ) -> Result; - fn confidential_outputs_insert(&mut self, output: ConfidentialOutputModel) -> Result<(), WalletStorageError>; - /// Mark outputs as finalized - fn confidential_outputs_finalize_by_lock_id(&mut self, lock_id: WalletLockId) -> Result<(), WalletStorageError>; - /// Release outputs that were locked and remove pending unconfirmed outputs for this proof - fn confidential_outputs_release_by_lock_id(&mut self, lock_id: WalletLockId) -> Result<(), WalletStorageError>; - - // Stealth Outputs - fn stealth_outputs_lock_smallest_amount( - &mut self, - account_addr: &ComponentAddress, - resource_address: &ResourceAddress, - lock_id: WalletLockId, - ) -> Result; - fn stealth_outputs_insert(&mut self, output: &StealthOutputModel) -> Result<(), WalletStorageError>; - fn stealth_outputs_mark_as_spent( - &mut self, - resource_address: &ResourceAddress, - id: &UtxoId, - ) -> Result<(), WalletStorageError>; - fn stealth_outputs_update( - &mut self, - address: &UtxoAddress, - is_burnt: Option, - status: Option, - is_frozen: Option, - ) -> Result<(), WalletStorageError>; - - // Locks - fn locks_create(&mut self, timeout: Option) -> Result; - - fn locks_delete(&mut self, lock_id: WalletLockId) -> Result<(), WalletStorageError>; - fn locks_link_transaction( - &mut self, - lock_id: WalletLockId, - transaction_id: TransactionId, - ) -> Result<(), WalletStorageError>; - - fn locks_release_stale(&mut self) -> Result; - - /// Release the lock including all outputs and vaults that were locked. Release is used when a transaction is - /// aborted. - fn locks_release(&mut self, lock_id: WalletLockId) -> Result<(), WalletStorageError>; - /// Finalize the lock according to the provided diff. Any outputs and vaults locked by this lock and included in the - /// diff are finalised (marked as unspent/funds removed/added as necessary). Any objects not included in the diff - /// are reverted and released from the lock. This is used when a transaction is committed. - fn locks_unlock_finalized(&mut self, lock_id: WalletLockId, diff: &SubstateDiff) -> Result<(), WalletStorageError>; - - // Non fungible tokens - fn non_fungible_token_upsert(&mut self, non_fungible_token: &NonFungibleToken) -> Result<(), WalletStorageError>; - fn non_fungible_token_remove( - &mut self, - vault_id: &VaultId, - non_fungible_id: &NonFungibleId, - ) -> Result<(), WalletStorageError>; - - // Webauthn registrations - fn webauthn_reg_insert(&mut self, username: String, passkey: Passkey) -> Result<(), WalletStorageError>; - - // Authored templates - fn authored_templates_insert(&mut self, model: AuthoredTemplateModel) -> Result<(), WalletStorageError>; - fn shard_state_version_set_many>( - &mut self, - account: &ComponentAddress, - resource_address: &ResourceAddress, - shard_state_versions: I, - ) -> Result<(), WalletStorageError>; - - fn utxo_process_queue_extend>( - &mut self, - resource_address: &ResourceAddress, - items: I, - ) -> Result<(), WalletStorageError>; - fn utxo_process_queue_remove_item( - &mut self, - resource_address: ResourceAddress, - tag: UtxoTag, - public_nonce: RistrettoPublicKeyBytes, - ) -> Result<(), WalletStorageError>; -} diff --git a/crates/wallet/sdk/src/storage/error.rs b/crates/wallet/sdk/src/storage/error.rs new file mode 100644 index 0000000000..b1c449208d --- /dev/null +++ b/crates/wallet/sdk/src/storage/error.rs @@ -0,0 +1,72 @@ +// Copyright 2025 The Tari Project +// SPDX-License-Identifier: BSD-3-Clause + +use tari_ootle_common_types::optional::IsNotFoundError; +use tari_template_lib::prelude::{crypto::UtxoTag, RistrettoPublicKeyBytes}; + +#[derive(Debug, thiserror::Error)] +pub enum WalletStorageError { + #[error("General database failure for operation {operation}: {details}")] + GeneralFailure { operation: &'static str, details: String }, + #[error("Bad query for operation {operation}: {details}")] + BadQuery { operation: &'static str, details: String }, + #[error("Failed to decode for operation {operation} on {item}: {details}")] + DecodingError { + operation: &'static str, + item: &'static str, + details: String, + }, + #[error("Failed to encode for operation {operation} on {item}: {details}")] + EncodingError { + operation: &'static str, + item: &'static str, + details: String, + }, + #[error("[{operation}] {entity} not found with key {key}")] + NotFound { + operation: &'static str, + entity: String, + key: String, + }, + #[error("Operation error {operation}: {details}")] + OperationError { operation: &'static str, details: String }, + #[error("Data inconsistency for operation {operation}: {details}")] + DataInconsistent { operation: &'static str, details: String }, + #[error("Encryption error {operation}: {details}")] + EncryptionError { operation: &'static str, details: String }, + #[error("Decryption error {operation}: {details}")] + DecryptionError { operation: &'static str, details: String }, +} + +impl IsNotFoundError for WalletStorageError { + fn is_not_found_error(&self) -> bool { + matches!(self, Self::NotFound { .. }) + } +} + +impl WalletStorageError { + pub fn general(operation: &'static str, e: E) -> Self { + Self::GeneralFailure { + operation, + details: e.to_string(), + } + } + + pub fn bad_query>(operation: &'static str, details: E) -> Self { + Self::BadQuery { + operation, + details: details.into(), + } + } + + pub fn not_found(operation: &'static str, entity: String, key: String) -> Self { + Self::NotFound { operation, entity, key } + } +} + +pub type TagAndPublicNoncePair = (UtxoTag, RistrettoPublicKeyBytes); + +pub trait CommittableStore { + fn commit(&mut self) -> Result<(), WalletStorageError>; + fn rollback(&mut self) -> Result<(), WalletStorageError>; +} diff --git a/crates/wallet/sdk/src/storage/mod.rs b/crates/wallet/sdk/src/storage/mod.rs new file mode 100644 index 0000000000..800dca14f0 --- /dev/null +++ b/crates/wallet/sdk/src/storage/mod.rs @@ -0,0 +1,74 @@ +// Copyright 2023 The Tari Project +// SPDX-License-Identifier: BSD-3-Clause + +pub use error::*; +pub use reader::*; +pub use writer::*; + +mod error; +mod reader; +mod writer; + +use std::ops::{Deref, DerefMut}; + +pub trait ReadableWalletStore { + type ReadTransaction<'a>: WalletStoreReader + where Self: 'a; + + fn create_read_tx(&self) -> Result, WalletStorageError>; + + fn with_read_tx) -> Result, R, E>(&self, f: F) -> Result + where E: From { + let mut tx = self.create_read_tx()?; + let ret = f(&mut tx)?; + Ok(ret) + } +} + +impl ReadableWalletStore for &T { + type ReadTransaction<'a> + = T::ReadTransaction<'a> + where Self: 'a; + + fn create_read_tx(&self) -> Result, WalletStorageError> { + (**self).create_read_tx() + } +} + +pub trait WriteableWalletStore: ReadableWalletStore { + type WriteTransaction<'a>: WalletStoreWriter + Deref> + DerefMut + where Self: 'a; + + fn create_write_tx(&self) -> Result, WalletStorageError>; + + fn with_write_tx) -> Result, R, E>(&self, f: F) -> Result + where E: From { + let mut tx = self.create_write_tx()?; + match f(&mut tx) { + Ok(r) => { + tx.commit()?; + Ok(r) + }, + Err(e) => { + if let Err(err) = tx.rollback() { + log::error!("Failed to rollback transaction: {}", err); + } + Err(e) + }, + } + } +} + +impl WriteableWalletStore for &T { + type WriteTransaction<'a> + = T::WriteTransaction<'a> + where Self: 'a; + + fn create_write_tx(&self) -> Result, WalletStorageError> { + (**self).create_write_tx() + } +} + +pub trait WalletStore: ReadableWalletStore + WriteableWalletStore {} + +impl WalletStore for T where T: ReadableWalletStore + WriteableWalletStore {} diff --git a/crates/wallet/sdk/src/storage/reader.rs b/crates/wallet/sdk/src/storage/reader.rs new file mode 100644 index 0000000000..a5f7bcf8ce --- /dev/null +++ b/crates/wallet/sdk/src/storage/reader.rs @@ -0,0 +1,206 @@ +// Copyright 2025 The Tari Project +// SPDX-License-Identifier: BSD-3-Clause + +use std::collections::{HashMap, HashSet}; + +use tari_engine_types::substate::SubstateId; +use tari_ootle_common_types::{shard::Shard, substate_type::SubstateType, StateVersion}; +use tari_template_lib::{ + models::{ComponentAddress, NonFungibleId, ResourceAddress, VaultId}, + prelude::{PedersenCommitmentBytes, ResourceType, RistrettoPublicKeyBytes, TemplateAddress}, +}; +use tari_transaction::TransactionId; +use webauthn_rs::prelude::Passkey; + +use crate::{ + models::{ + Account, + AuthoredTemplateModel, + ConfidentialOutputModel, + Config, + KeyType, + NonFungibleToken, + OutputStatus, + ResourceModel, + StealthBalance, + StealthOutputModel, + SubstateModel, + TransactionStatus, + VaultModel, + WalletLockId, + WalletTransaction, + }, + storage::{TagAndPublicNoncePair, WalletStorageError}, +}; + +pub trait WalletStoreReader { + // Key manager + fn key_manager_get_all(&mut self, branch: &str) -> Result, WalletStorageError>; + fn key_manager_get_active_index(&mut self, branch: &str) -> Result; + fn key_manager_get_last_index(&mut self, branch: &str) -> Result; + fn key_manager_get_raw_imported_key(&mut self, id: u64) -> Result<(KeyType, Box<[u8]>), WalletStorageError>; + // Config + fn config_get(&mut self, key: &str) -> Result, WalletStorageError>; + fn config_get_string(&mut self, key: &str) -> Result, WalletStorageError>; + fn config_exists(&mut self, key: &str) -> Result; + // JWT + fn jwt_get_all(&mut self) -> Result)>, WalletStorageError>; + // Transactions + fn transactions_get(&mut self, transaction_id: TransactionId) -> Result; + fn transactions_fetch_all( + &mut self, + status: Option, + component: Option, + signed_by_public_key: Option, + ) -> Result, WalletStorageError>; + // Substates + fn substates_get(&mut self, address: &SubstateId) -> Result; + fn substates_get_all( + &mut self, + by_type: Option, + by_template_address: Option<&TemplateAddress>, + limit: Option, + offset: Option, + ) -> Result, WalletStorageError>; + fn substates_get_children(&mut self, parent: &SubstateId) -> Result, WalletStorageError>; + // Accounts + fn accounts_get(&mut self, address: &ComponentAddress) -> Result; + fn accounts_get_many(&mut self, offset: usize, limit: usize) -> Result, WalletStorageError>; + fn accounts_get_default(&mut self) -> Result; + fn accounts_count(&mut self) -> Result; + fn accounts_get_by_name(&mut self, name: &str) -> Result; + fn accounts_get_by_vault(&mut self, vault_id: &VaultId) -> Result; + fn accounts_get_associated_stealth_resources( + &mut self, + address: &ComponentAddress, + ) -> Result, WalletStorageError>; + + // Vaults + fn vaults_get(&mut self, vault_id: &VaultId) -> Result; + fn vaults_exists(&mut self, vault_id: &VaultId) -> Result; + fn vaults_get_by_resource( + &mut self, + account_addr: &ComponentAddress, + resource_address: &ResourceAddress, + ) -> Result; + fn vaults_get_by_account(&mut self, account_addr: &ComponentAddress) + -> Result, WalletStorageError>; + + // Resources + fn resources_get(&mut self, resource_address: &ResourceAddress) -> Result; + fn resources_get_by_type(&mut self, resource_type: ResourceType) -> Result, WalletStorageError>; + fn resources_get_many<'a, I: IntoIterator>( + &mut self, + addresses: I, + ) -> Result, WalletStorageError>; + + // Confidential Outputs + fn confidential_outputs_get_unspent_balance(&mut self, vault_id: &VaultId) -> Result; + fn confidential_outputs_get_locked_by_lock_id( + &mut self, + lock_id: WalletLockId, + ) -> Result, WalletStorageError>; + fn confidential_outputs_get_by_commitment( + &mut self, + vault_id: &VaultId, + commitment: &PedersenCommitmentBytes, + ) -> Result; + + fn confidential_outputs_get_by_account_and_status( + &mut self, + account_addr: &ComponentAddress, + status: OutputStatus, + ) -> Result, WalletStorageError>; + + // Stealth outputs + fn stealth_outputs_get_unspent_balance( + &mut self, + resource_address: &ResourceAddress, + ) -> Result; + + fn stealth_outputs_count_by_status( + &mut self, + account_addr: &ComponentAddress, + resource_address: &ResourceAddress, + status: OutputStatus, + ) -> Result; + + fn stealth_outputs_get_unspent_by_account( + &mut self, + account_addr: &ComponentAddress, + exclude_locked: bool, + ) -> Result, WalletStorageError>; + + fn stealth_outputs_get_locked_by_lock_id( + &mut self, + lock_id: WalletLockId, + ) -> Result, WalletStorageError>; + fn stealth_outputs_get_by_commitment( + &mut self, + resource_address: &ResourceAddress, + commitment: &PedersenCommitmentBytes, + ) -> Result; + + fn stealth_outputs_get_many( + &mut self, + resource_address: &ResourceAddress, + by_account: Option<&ComponentAddress>, + by_status: Option, + ) -> Result, WalletStorageError>; + + // Output Locks + fn locks_get_by_transaction_id( + &mut self, + transaction_id: TransactionId, + ) -> Result; + + // Non fungible tokens + fn non_fungible_token_get_by_nft_id( + &mut self, + resource_address: ResourceAddress, + nft_id: NonFungibleId, + ) -> Result; + + fn non_fungible_token_get_ids_by_vault_id( + &mut self, + vault_id: &VaultId, + limit: u64, + offset: u64, + ) -> Result, WalletStorageError>; + + fn non_fungible_token_get_all( + &mut self, + account: ComponentAddress, + limit: u64, + offset: u64, + ) -> Result, WalletStorageError>; + + fn non_fungible_token_get_resource_address( + &mut self, + nft_id: NonFungibleId, + ) -> Result; + + // Webauthn registration + fn webauthn_is_user_registered(&mut self, username: &str) -> Result; + fn webauthn_reg_fetch_passkeys(&mut self, username: String) -> Result, WalletStorageError>; + + // Authored templates + fn authored_templates_exists_by_address(&mut self, address: &TemplateAddress) -> Result; + fn authored_templates_fetch_by_public_key( + &mut self, + author_public_key: &RistrettoPublicKeyBytes, + page: u64, + page_size: u64, + ) -> Result<(Vec, u64), WalletStorageError>; + + fn shard_state_version_get( + &mut self, + account: &ComponentAddress, + resource: &ResourceAddress, + ) -> Result, WalletStorageError>; + + fn utxo_process_queue_fetch_batch( + &mut self, + batch_size: usize, + ) -> Result>, WalletStorageError>; +} diff --git a/crates/wallet/sdk/src/storage/writer.rs b/crates/wallet/sdk/src/storage/writer.rs new file mode 100644 index 0000000000..f6745b8153 --- /dev/null +++ b/crates/wallet/sdk/src/storage/writer.rs @@ -0,0 +1,218 @@ +// Copyright 2025 The Tari Project +// SPDX-License-Identifier: BSD-3-Clause + +use std::{collections::HashSet, time::Duration}; + +use tari_engine_types::{ + resource::Resource, + substate::{SubstateDiff, SubstateId}, +}; +use tari_ootle_common_types::{shard::Shard, StateVersion, VersionedSubstateIdRef}; +use tari_template_lib::{ + models::{ComponentAddress, NonFungibleId, ResourceAddress, UtxoAddress, UtxoId, VaultId}, + prelude::{crypto::UtxoTag, Amount, RistrettoPublicKeyBytes, TemplateAddress}, +}; +use tari_transaction::{Transaction, TransactionId}; +use webauthn_rs::prelude::Passkey; + +use crate::{ + models::{ + AccountUpdate, + AuthoredTemplateModel, + ConfidentialOutputModel, + ImportedKeyId, + KeyId, + KeyType, + NewAccountData, + NonFungibleToken, + OutputStatus, + StealthOutputModel, + SubstateModel, + UtxoUnspent, + VaultModel, + WalletLockId, + WalletTransactionUpdate, + }, + storage::{CommittableStore, WalletStorageError}, +}; + +pub trait WalletStoreWriter: CommittableStore { + // JWT + fn jwt_add_empty_token(&mut self) -> Result; + fn jwt_store_decision(&mut self, id: u64, permissions_token: Option<&str>) -> Result<(), WalletStorageError>; + fn jwt_is_revoked(&mut self, token: &str) -> Result; + fn jwt_revoke(&mut self, token_id: i32) -> Result<(), WalletStorageError>; + + // Key manager + fn key_manager_insert_or_ignore(&mut self, branch: &str, index: u64) -> Result<(), WalletStorageError>; + fn key_manager_set_active_index(&mut self, branch: &str, index: u64) -> Result<(), WalletStorageError>; + fn key_manager_reset_index(&mut self, branch: &str, index: u64) -> Result<(), WalletStorageError>; + fn key_manager_insert_imported_key( + &mut self, + label: &str, + encrypted_key: &[u8], + key_type: KeyType, + ) -> Result; + + // Config + fn config_set( + &mut self, + key: &str, + value: &T, + is_encrypted: bool, + ) -> Result<(), WalletStorageError>; + + // Transactions + fn transactions_insert( + &mut self, + transaction: &Transaction, + new_account_info: Option<&NewAccountData>, + is_dry_run: bool, + ) -> Result<(), WalletStorageError>; + fn transactions_update(&mut self, update: WalletTransactionUpdate<'_>) -> Result<(), WalletStorageError>; + + // Substates + fn substates_upsert_root( + &mut self, + substate_id: VersionedSubstateIdRef<'_>, + referenced_substates: HashSet, + module_name: Option, + template_addr: Option, + ) -> Result<(), WalletStorageError>; + fn substates_upsert_child( + &mut self, + parent: &SubstateId, + address: VersionedSubstateIdRef<'_>, + referenced_substates: HashSet, + ) -> Result<(), WalletStorageError>; + fn substates_remove(&mut self, substate: &SubstateId) -> Result; + + // Accounts + fn accounts_set_default(&mut self, account_addr: &ComponentAddress) -> Result<(), WalletStorageError>; + fn accounts_insert( + &mut self, + account_name: Option<&str>, + account_addr: &ComponentAddress, + view_only_key_id: KeyId, + owner_key_id: Option, + owner_public_key: &RistrettoPublicKeyBytes, + associated_stealth_resources: &HashSet, + is_confirmed_on_chain: bool, + is_default: bool, + ) -> Result<(), WalletStorageError>; + + fn accounts_update( + &mut self, + account_addr: &ComponentAddress, + update: AccountUpdate<'_>, + ) -> Result<(), WalletStorageError>; + + fn accounts_add_stealth_resource( + &mut self, + account_addr: &ComponentAddress, + resource_address: ResourceAddress, + ) -> Result<(), WalletStorageError>; + + // Vaults + fn vaults_insert(&mut self, vault: VaultModel) -> Result<(), WalletStorageError>; + fn vaults_update( + &mut self, + vault_id: VaultId, + revealed_balance: Amount, + confidential_balance: Amount, + ) -> Result<(), WalletStorageError>; + fn vaults_lock_revealed_funds( + &mut self, + lock_id: WalletLockId, + vault_id: &VaultId, + amount_to_lock: Amount, + ) -> Result<(), WalletStorageError>; + fn vaults_finalized_locked_revealed_funds(&mut self, lock_id: WalletLockId) -> Result<(), WalletStorageError>; + fn vaults_release_lock_revealed_funds(&mut self, lock_id: WalletLockId) -> Result<(), WalletStorageError>; + // Resources + fn resources_upsert(&mut self, address: &ResourceAddress, resource: &Resource) -> Result<(), WalletStorageError>; + // Confidential Outputs + fn confidential_outputs_lock_smallest_amount( + &mut self, + vault_id: &VaultId, + lock_id: WalletLockId, + ) -> Result; + fn confidential_outputs_insert(&mut self, output: ConfidentialOutputModel) -> Result<(), WalletStorageError>; + /// Mark outputs as finalized + fn confidential_outputs_finalize_by_lock_id(&mut self, lock_id: WalletLockId) -> Result<(), WalletStorageError>; + /// Release outputs that were locked and remove pending unconfirmed outputs for this proof + fn confidential_outputs_release_by_lock_id(&mut self, lock_id: WalletLockId) -> Result<(), WalletStorageError>; + + // Stealth Outputs + fn stealth_outputs_lock_smallest_amount( + &mut self, + account_addr: &ComponentAddress, + resource_address: &ResourceAddress, + lock_id: WalletLockId, + ) -> Result; + fn stealth_outputs_insert(&mut self, output: &StealthOutputModel) -> Result<(), WalletStorageError>; + fn stealth_outputs_mark_as_spent( + &mut self, + resource_address: &ResourceAddress, + id: &UtxoId, + ) -> Result<(), WalletStorageError>; + fn stealth_outputs_update( + &mut self, + address: &UtxoAddress, + is_burnt: Option, + status: Option, + is_frozen: Option, + ) -> Result<(), WalletStorageError>; + + // Locks + fn locks_create(&mut self, timeout: Option) -> Result; + + fn locks_delete(&mut self, lock_id: WalletLockId) -> Result<(), WalletStorageError>; + fn locks_link_transaction( + &mut self, + lock_id: WalletLockId, + transaction_id: TransactionId, + ) -> Result<(), WalletStorageError>; + + fn locks_release_stale(&mut self) -> Result; + + /// Release the lock including all outputs and vaults that were locked. Release is used when a transaction is + /// aborted. + fn locks_release(&mut self, lock_id: WalletLockId) -> Result<(), WalletStorageError>; + /// Finalize the lock according to the provided diff. Any outputs and vaults locked by this lock and included in the + /// diff are finalised (marked as unspent/funds removed/added as necessary). Any objects not included in the diff + /// are reverted and released from the lock. This is used when a transaction is committed. + fn locks_unlock_finalized(&mut self, lock_id: WalletLockId, diff: &SubstateDiff) -> Result<(), WalletStorageError>; + + // Non fungible tokens + fn non_fungible_token_upsert(&mut self, non_fungible_token: &NonFungibleToken) -> Result<(), WalletStorageError>; + fn non_fungible_token_remove( + &mut self, + vault_id: &VaultId, + non_fungible_id: &NonFungibleId, + ) -> Result<(), WalletStorageError>; + + // Webauthn registrations + fn webauthn_reg_insert(&mut self, username: String, passkey: Passkey) -> Result<(), WalletStorageError>; + + // Authored templates + fn authored_templates_insert(&mut self, model: AuthoredTemplateModel) -> Result<(), WalletStorageError>; + fn shard_state_version_set_many>( + &mut self, + account: &ComponentAddress, + resource_address: &ResourceAddress, + shard_state_versions: I, + ) -> Result<(), WalletStorageError>; + + fn utxo_process_queue_extend>( + &mut self, + resource_address: &ResourceAddress, + items: I, + ) -> Result<(), WalletStorageError>; + fn utxo_process_queue_remove_item( + &mut self, + resource_address: ResourceAddress, + tag: UtxoTag, + public_nonce: RistrettoPublicKeyBytes, + ) -> Result<(), WalletStorageError>; +} diff --git a/crates/wallet/storage_sqlite/src/writer.rs b/crates/wallet/storage_sqlite/src/writer.rs index a753e98897..82597405cb 100644 --- a/crates/wallet/storage_sqlite/src/writer.rs +++ b/crates/wallet/storage_sqlite/src/writer.rs @@ -46,7 +46,7 @@ use tari_ootle_wallet_sdk::{ WalletLockId, WalletTransactionUpdate, }, - storage::{CommitableStore, WalletStorageError, WalletStoreReader, WalletStoreWriter}, + storage::{CommittableStore, WalletStorageError, WalletStoreReader, WalletStoreWriter}, }; use tari_template_lib::{ models::{ComponentAddress, NonFungibleId, ResourceAddress, UtxoAddress, UtxoId, VaultId}, @@ -232,7 +232,7 @@ impl<'a> WriteTransaction<'a> { } } -impl CommitableStore for WriteTransaction<'_> { +impl CommittableStore for WriteTransaction<'_> { fn commit(&mut self) -> Result<(), WalletStorageError> { self.transaction.commit_internal()?; Ok(()) diff --git a/crates/wallet/storage_sqlite/tests/accounts.rs b/crates/wallet/storage_sqlite/tests/accounts.rs index 8b5d109ec0..4c99ac5b93 100644 --- a/crates/wallet/storage_sqlite/tests/accounts.rs +++ b/crates/wallet/storage_sqlite/tests/accounts.rs @@ -5,7 +5,7 @@ use std::str::FromStr; use tari_ootle_wallet_sdk::{ models::{AccountUpdate, KeyId}, - storage::{CommitableStore, WalletStoreReader, WalletStoreWriter, WriteableWalletStore}, + storage::{CommittableStore, WalletStoreReader, WalletStoreWriter, WriteableWalletStore}, }; use tari_ootle_wallet_storage_sqlite::SqliteWalletStore; use tari_template_lib::{models::ComponentAddress, prelude::RistrettoPublicKeyBytes}; diff --git a/crates/wallet/storage_sqlite/tests/config.rs b/crates/wallet/storage_sqlite/tests/config.rs index 24a1ad8cb3..60ab1e4e5e 100644 --- a/crates/wallet/storage_sqlite/tests/config.rs +++ b/crates/wallet/storage_sqlite/tests/config.rs @@ -2,7 +2,7 @@ // SPDX-License-Identifier: BSD-3-Clause use tari_ootle_common_types::optional::Optional; -use tari_ootle_wallet_sdk::storage::{CommitableStore, WalletStoreReader, WalletStoreWriter, WriteableWalletStore}; +use tari_ootle_wallet_sdk::storage::{CommittableStore, WalletStoreReader, WalletStoreWriter, WriteableWalletStore}; use tari_ootle_wallet_storage_sqlite::SqliteWalletStore; #[test] diff --git a/crates/wallet/storage_sqlite/tests/key_manager_state.rs b/crates/wallet/storage_sqlite/tests/key_manager_state.rs index 91f64713ec..6375b0a6bc 100644 --- a/crates/wallet/storage_sqlite/tests/key_manager_state.rs +++ b/crates/wallet/storage_sqlite/tests/key_manager_state.rs @@ -2,7 +2,7 @@ // SPDX-License-Identifier: BSD-3-Clause use tari_ootle_common_types::optional::Optional; -use tari_ootle_wallet_sdk::storage::{CommitableStore, WalletStoreReader, WalletStoreWriter, WriteableWalletStore}; +use tari_ootle_wallet_sdk::storage::{CommittableStore, WalletStoreReader, WalletStoreWriter, WriteableWalletStore}; use tari_ootle_wallet_storage_sqlite::SqliteWalletStore; #[test] diff --git a/crates/wallet/storage_sqlite/tests/substates.rs b/crates/wallet/storage_sqlite/tests/substates.rs index b254365695..518713420a 100644 --- a/crates/wallet/storage_sqlite/tests/substates.rs +++ b/crates/wallet/storage_sqlite/tests/substates.rs @@ -5,7 +5,7 @@ use std::{collections::HashSet, str::FromStr}; use tari_engine_types::substate::SubstateId; use tari_ootle_common_types::{optional::Optional, VersionedSubstateIdRef}; -use tari_ootle_wallet_sdk::storage::{CommitableStore, WalletStoreReader, WalletStoreWriter, WriteableWalletStore}; +use tari_ootle_wallet_sdk::storage::{CommittableStore, WalletStoreReader, WalletStoreWriter, WriteableWalletStore}; use tari_ootle_wallet_storage_sqlite::SqliteWalletStore; #[test] diff --git a/crates/wallet/storage_sqlite/tests/transaction.rs b/crates/wallet/storage_sqlite/tests/transaction.rs index ead47aea8d..d1d59e358b 100644 --- a/crates/wallet/storage_sqlite/tests/transaction.rs +++ b/crates/wallet/storage_sqlite/tests/transaction.rs @@ -5,7 +5,7 @@ use tari_crypto::ristretto::RistrettoSecretKey; use tari_ootle_common_types::optional::Optional; use tari_ootle_wallet_sdk::{ models::TransactionStatus, - storage::{CommitableStore, WalletStoreReader, WalletStoreWriter, WriteableWalletStore}, + storage::{CommittableStore, WalletStoreReader, WalletStoreWriter, WriteableWalletStore}, }; use tari_ootle_wallet_storage_sqlite::SqliteWalletStore; use tari_transaction::{args, Transaction, TransactionId};