[#556] Rename Transaction to TransactionNG
This change is really only replace one string with other. No logic was changed.
This commit is contained in:
parent
3d488f6e15
commit
c4df36db36
|
@ -16,7 +16,7 @@ class PaginatedTransactionsViewController: UIViewController {
|
|||
|
||||
// swiftlint:disable:next implicitly_unwrapped_optional
|
||||
var paginatedRepository: PaginatedTransactionRepository!
|
||||
var transactions: [TransactionNG.Overview] = []
|
||||
var transactions: [Transaction.Overview] = []
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
|
|
|
@ -19,7 +19,7 @@ final class TransactionDetailModel {
|
|||
|
||||
init() {}
|
||||
|
||||
init(sendTransaction transaction: TransactionNG.Sent) {
|
||||
init(sendTransaction transaction: Transaction.Sent) {
|
||||
self.id = transaction.rawID.toHexStringTxId()
|
||||
self.minedHeight = transaction.minedHeight?.description
|
||||
self.expiryHeight = transaction.expiryHeight?.description
|
||||
|
@ -31,7 +31,7 @@ final class TransactionDetailModel {
|
|||
// }
|
||||
}
|
||||
|
||||
init(receivedTransaction transaction: TransactionNG.Received) {
|
||||
init(receivedTransaction transaction: Transaction.Received) {
|
||||
self.id = transaction.rawID.toHexStringTxId()
|
||||
self.minedHeight = transaction.minedHeight?.description
|
||||
self.expiryHeight = transaction.expiryHeight?.description
|
||||
|
@ -51,7 +51,7 @@ final class TransactionDetailModel {
|
|||
self.zatoshi = NumberFormatter.zcashNumberFormatter.string(from: NSNumber(value: pendingTransaction.value.amount))
|
||||
}
|
||||
|
||||
init(transaction: TransactionNG.Overview) {
|
||||
init(transaction: Transaction.Overview) {
|
||||
self.id = transaction.rawID.toHexStringTxId()
|
||||
self.minedHeight = transaction.minedHeight?.description
|
||||
self.expiryHeight = transaction.expiryHeight?.description
|
||||
|
|
|
@ -63,7 +63,7 @@ public protocol CompactBlockDownloading {
|
|||
Gets the transaction for the Id given
|
||||
- Parameter txId: Data representing the transaction Id
|
||||
*/
|
||||
func fetchTransaction(txId: Data) async throws -> TransactionNG.Fetched
|
||||
func fetchTransaction(txId: Data) async throws -> Transaction.Fetched
|
||||
|
||||
func fetchUnspentTransactionOutputs(tAddress: String, startHeight: BlockHeight) -> AsyncThrowingStream<UnspentTransactionOutputEntity, Error>
|
||||
|
||||
|
@ -149,7 +149,7 @@ extension CompactBlockDownloader: CompactBlockDownloading {
|
|||
try self.storage.latestHeight()
|
||||
}
|
||||
|
||||
func fetchTransaction(txId: Data) async throws -> TransactionNG.Fetched {
|
||||
func fetchTransaction(txId: Data) async throws -> Transaction.Fetched {
|
||||
try await lightwalletService.fetchTransaction(txId: txId)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ extension CompactBlockProcessor {
|
|||
case txIdNotFound(txId: Data)
|
||||
}
|
||||
|
||||
private func enhance(transaction: TransactionNG.Overview) async throws -> TransactionNG.Overview {
|
||||
private func enhance(transaction: Transaction.Overview) async throws -> Transaction.Overview {
|
||||
LoggerProxy.debug("Zoom.... Enhance... Tx: \(transaction.rawID.toHexStringTxId())")
|
||||
|
||||
let fetchedTransaction = try await downloader.fetchTransaction(txId: transaction.rawID)
|
||||
|
@ -37,7 +37,7 @@ extension CompactBlockProcessor {
|
|||
)
|
||||
}
|
||||
|
||||
let confirmedTx: TransactionNG.Overview
|
||||
let confirmedTx: Transaction.Overview
|
||||
do {
|
||||
confirmedTx = try transactionRepository.find(rawID: fetchedTransaction.rawID)
|
||||
} catch {
|
||||
|
|
|
@ -110,14 +110,14 @@ protocol EnhancementStreamDelegate: AnyObject {
|
|||
public protocol EnhancementProgress {
|
||||
var totalTransactions: Int { get }
|
||||
var enhancedTransactions: Int { get }
|
||||
var lastFoundTransaction: TransactionNG.Overview? { get }
|
||||
var lastFoundTransaction: Transaction.Overview? { get }
|
||||
var range: CompactBlockRange { get }
|
||||
}
|
||||
|
||||
public struct EnhancementStreamProgress: EnhancementProgress {
|
||||
public var totalTransactions: Int
|
||||
public var enhancedTransactions: Int
|
||||
public var lastFoundTransaction: TransactionNG.Overview?
|
||||
public var lastFoundTransaction: Transaction.Overview?
|
||||
public var range: CompactBlockRange
|
||||
|
||||
public var progress: Float {
|
||||
|
@ -690,7 +690,7 @@ public actor CompactBlockProcessor {
|
|||
)
|
||||
}
|
||||
|
||||
func notifyTransactions(_ txs: [TransactionNG.Overview], in range: BlockRange) {
|
||||
func notifyTransactions(_ txs: [Transaction.Overview], in range: BlockRange) {
|
||||
NotificationSender.default.post(
|
||||
name: .blockProcessorFoundTransactions,
|
||||
object: self,
|
||||
|
|
|
@ -32,13 +32,13 @@ class PagedTransactionDAO: PaginatedTransactionRepository {
|
|||
self.kind = kind
|
||||
}
|
||||
|
||||
func page(_ number: Int) throws -> [TransactionNG.Overview]? {
|
||||
func page(_ number: Int) throws -> [Transaction.Overview]? {
|
||||
let offset = number * pageSize
|
||||
guard offset < itemCount else { return nil }
|
||||
return try transactionRepository.find(offset: offset, limit: pageSize, kind: kind)
|
||||
}
|
||||
|
||||
func page(_ number: Int, result: @escaping (Result<[TransactionNG.Overview]?, Error>) -> Void) {
|
||||
func page(_ number: Int, result: @escaping (Result<[Transaction.Overview]?, Error>) -> Void) {
|
||||
DispatchQueue.global(qos: .userInitiated).async { [weak self] in
|
||||
guard let self = self else { return }
|
||||
do {
|
||||
|
|
|
@ -39,104 +39,104 @@ class TransactionSQLDAO: TransactionRepository {
|
|||
}
|
||||
|
||||
func countUnmined() throws -> Int {
|
||||
try dbProvider.connection().scalar(transactions.filter(TransactionNG.Overview.Column.minedHeight == nil).count)
|
||||
try dbProvider.connection().scalar(transactions.filter(Transaction.Overview.Column.minedHeight == nil).count)
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Queries
|
||||
|
||||
extension TransactionSQLDAO {
|
||||
func find(id: Int) throws -> TransactionNG.Overview {
|
||||
func find(id: Int) throws -> Transaction.Overview {
|
||||
let query = transactionsView
|
||||
.filter(TransactionNG.Overview.Column.id == id)
|
||||
.filter(Transaction.Overview.Column.id == id)
|
||||
.limit(1)
|
||||
|
||||
return try execute(query) { try TransactionNG.Overview(row: $0) }
|
||||
return try execute(query) { try Transaction.Overview(row: $0) }
|
||||
}
|
||||
|
||||
func find(rawID: Data) throws -> TransactionNG.Overview {
|
||||
func find(rawID: Data) throws -> Transaction.Overview {
|
||||
let query = transactionsView
|
||||
.filter(TransactionNG.Overview.Column.rawID == Blob(bytes: rawID.bytes))
|
||||
.filter(Transaction.Overview.Column.rawID == Blob(bytes: rawID.bytes))
|
||||
.limit(1)
|
||||
|
||||
return try execute(query) { try TransactionNG.Overview(row: $0) }
|
||||
return try execute(query) { try Transaction.Overview(row: $0) }
|
||||
}
|
||||
|
||||
func find(offset: Int, limit: Int, kind: TransactionKind) throws -> [TransactionNG.Overview] {
|
||||
func find(offset: Int, limit: Int, kind: TransactionKind) throws -> [Transaction.Overview] {
|
||||
let query = transactionsView
|
||||
.order(TransactionNG.Overview.Column.minedHeight.asc, TransactionNG.Overview.Column.id.asc)
|
||||
.order(Transaction.Overview.Column.minedHeight.asc, Transaction.Overview.Column.id.asc)
|
||||
.filterQueryFor(kind: kind)
|
||||
.limit(limit, offset: offset)
|
||||
|
||||
return try execute(query) { try TransactionNG.Overview(row: $0) }
|
||||
return try execute(query) { try Transaction.Overview(row: $0) }
|
||||
}
|
||||
|
||||
func find(in range: BlockRange, limit: Int, kind: TransactionKind) throws -> [TransactionNG.Overview] {
|
||||
func find(in range: BlockRange, limit: Int, kind: TransactionKind) throws -> [Transaction.Overview] {
|
||||
let query = transactionsView
|
||||
.order(TransactionNG.Overview.Column.minedHeight.asc, TransactionNG.Overview.Column.id.asc)
|
||||
.order(Transaction.Overview.Column.minedHeight.asc, Transaction.Overview.Column.id.asc)
|
||||
.filter(
|
||||
TransactionNG.Overview.Column.minedHeight >= BlockHeight(range.start.height) &&
|
||||
TransactionNG.Overview.Column.minedHeight <= BlockHeight(range.end.height)
|
||||
Transaction.Overview.Column.minedHeight >= BlockHeight(range.start.height) &&
|
||||
Transaction.Overview.Column.minedHeight <= BlockHeight(range.end.height)
|
||||
)
|
||||
.filterQueryFor(kind: kind)
|
||||
.limit(limit)
|
||||
|
||||
return try execute(query) { try TransactionNG.Overview(row: $0) }
|
||||
return try execute(query) { try Transaction.Overview(row: $0) }
|
||||
}
|
||||
|
||||
func find(from transaction: TransactionNG.Overview, limit: Int, kind: TransactionKind) throws -> [TransactionNG.Overview] {
|
||||
func find(from transaction: Transaction.Overview, limit: Int, kind: TransactionKind) throws -> [Transaction.Overview] {
|
||||
let query = transactionsView
|
||||
.order(TransactionNG.Overview.Column.minedHeight.asc, TransactionNG.Overview.Column.id.asc)
|
||||
.filter(Int64(transaction.blocktime) > TransactionNG.Overview.Column.blockTime && transaction.index > TransactionNG.Overview.Column.index)
|
||||
.order(Transaction.Overview.Column.minedHeight.asc, Transaction.Overview.Column.id.asc)
|
||||
.filter(Int64(transaction.blocktime) > Transaction.Overview.Column.blockTime && transaction.index > Transaction.Overview.Column.index)
|
||||
.filterQueryFor(kind: kind)
|
||||
.limit(limit)
|
||||
|
||||
return try execute(query) { try TransactionNG.Overview(row: $0) }
|
||||
return try execute(query) { try Transaction.Overview(row: $0) }
|
||||
}
|
||||
|
||||
func findReceived(offset: Int, limit: Int) throws -> [TransactionNG.Received] {
|
||||
func findReceived(offset: Int, limit: Int) throws -> [Transaction.Received] {
|
||||
let query = receivedTransactionsView
|
||||
.order(TransactionNG.Received.Column.minedHeight.asc, TransactionNG.Received.Column.id.asc)
|
||||
.order(Transaction.Received.Column.minedHeight.asc, Transaction.Received.Column.id.asc)
|
||||
.limit(limit, offset: offset)
|
||||
|
||||
return try execute(query) { try TransactionNG.Received(row: $0) }
|
||||
return try execute(query) { try Transaction.Received(row: $0) }
|
||||
}
|
||||
|
||||
func findSent(offset: Int, limit: Int) throws -> [TransactionNG.Sent] {
|
||||
func findSent(offset: Int, limit: Int) throws -> [Transaction.Sent] {
|
||||
let query = sentTransactionsView
|
||||
.order(TransactionNG.Sent.Column.minedHeight.asc, TransactionNG.Sent.Column.id.asc)
|
||||
.order(Transaction.Sent.Column.minedHeight.asc, Transaction.Sent.Column.id.asc)
|
||||
.limit(limit, offset: offset)
|
||||
|
||||
return try execute(query) { try TransactionNG.Sent(row: $0) }
|
||||
return try execute(query) { try Transaction.Sent(row: $0) }
|
||||
}
|
||||
|
||||
func findSent(from transaction: TransactionNG.Sent, limit: Int) throws -> [TransactionNG.Sent] {
|
||||
func findSent(from transaction: Transaction.Sent, limit: Int) throws -> [Transaction.Sent] {
|
||||
let query = sentTransactionsView
|
||||
.order(TransactionNG.Sent.Column.minedHeight.asc, TransactionNG.Sent.Column.id.asc)
|
||||
.filter(Int64(transaction.blocktime) > TransactionNG.Sent.Column.blockTime && transaction.index > TransactionNG.Sent.Column.index)
|
||||
.order(Transaction.Sent.Column.minedHeight.asc, Transaction.Sent.Column.id.asc)
|
||||
.filter(Int64(transaction.blocktime) > Transaction.Sent.Column.blockTime && transaction.index > Transaction.Sent.Column.index)
|
||||
.limit(limit)
|
||||
|
||||
return try execute(query) { try TransactionNG.Sent(row: $0) }
|
||||
return try execute(query) { try Transaction.Sent(row: $0) }
|
||||
}
|
||||
|
||||
func findSent(in range: BlockRange, limit: Int) throws -> [TransactionNG.Sent] {
|
||||
func findSent(in range: BlockRange, limit: Int) throws -> [Transaction.Sent] {
|
||||
let query = sentTransactionsView
|
||||
.order(TransactionNG.Sent.Column.minedHeight.asc, TransactionNG.Sent.Column.id.asc)
|
||||
.order(Transaction.Sent.Column.minedHeight.asc, Transaction.Sent.Column.id.asc)
|
||||
.filter(
|
||||
TransactionNG.Sent.Column.minedHeight >= BlockHeight(range.start.height) &&
|
||||
TransactionNG.Sent.Column.minedHeight <= BlockHeight(range.end.height)
|
||||
Transaction.Sent.Column.minedHeight >= BlockHeight(range.start.height) &&
|
||||
Transaction.Sent.Column.minedHeight <= BlockHeight(range.end.height)
|
||||
)
|
||||
.limit(limit)
|
||||
|
||||
return try execute(query) { try TransactionNG.Sent(row: $0) }
|
||||
return try execute(query) { try Transaction.Sent(row: $0) }
|
||||
}
|
||||
|
||||
func findSent(rawID: Data) throws -> TransactionNG.Sent {
|
||||
func findSent(rawID: Data) throws -> Transaction.Sent {
|
||||
let query = sentTransactionsView
|
||||
.order(TransactionNG.Sent.Column.minedHeight.asc, TransactionNG.Sent.Column.id.asc)
|
||||
.filter(TransactionNG.Sent.Column.rawID == Blob(bytes: rawID.bytes)).limit(1)
|
||||
.order(Transaction.Sent.Column.minedHeight.asc, Transaction.Sent.Column.id.asc)
|
||||
.filter(Transaction.Sent.Column.rawID == Blob(bytes: rawID.bytes)).limit(1)
|
||||
|
||||
return try execute(query) { try TransactionNG.Sent(row: $0) }
|
||||
return try execute(query) { try Transaction.Sent(row: $0) }
|
||||
}
|
||||
|
||||
private func execute<Entity>(_ query: View, createEntity: (Row) throws -> Entity) throws -> Entity {
|
||||
|
@ -161,9 +161,9 @@ private extension View {
|
|||
case .all:
|
||||
return self
|
||||
case .sent:
|
||||
return filter(TransactionNG.Overview.Column.value < 0)
|
||||
return filter(Transaction.Overview.Column.value < 0)
|
||||
case .received:
|
||||
return filter(TransactionNG.Overview.Column.value >= 0)
|
||||
return filter(Transaction.Overview.Column.value >= 0)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -196,8 +196,8 @@ public extension PendingTransactionEntity {
|
|||
}
|
||||
|
||||
public extension PendingTransactionEntity {
|
||||
func makeTransactionEntity(defaultFee: Zatoshi) -> TransactionNG.Overview {
|
||||
return TransactionNG.Overview(
|
||||
func makeTransactionEntity(defaultFee: Zatoshi) -> Transaction.Overview {
|
||||
return Transaction.Overview(
|
||||
blocktime: createTime,
|
||||
expiryHeight: expiryHeight,
|
||||
fee: fee ?? defaultFee,
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
import Foundation
|
||||
import SQLite
|
||||
|
||||
public enum TransactionNG {
|
||||
public enum Transaction {
|
||||
|
||||
public struct Overview {
|
||||
public let blocktime: TimeInterval
|
||||
|
@ -63,7 +63,7 @@ public enum TransactionNG {
|
|||
}
|
||||
}
|
||||
|
||||
extension TransactionNG.Overview {
|
||||
extension Transaction.Overview {
|
||||
enum Column {
|
||||
static let id = Expression<Int>("id_tx")
|
||||
static let minedHeight = Expression<BlockHeight?>("mined_height")
|
||||
|
@ -117,7 +117,7 @@ extension TransactionNG.Overview {
|
|||
}
|
||||
}
|
||||
|
||||
extension TransactionNG.Received {
|
||||
extension Transaction.Received {
|
||||
enum Column {
|
||||
static let id = Expression<Int>("id_tx")
|
||||
static let minedHeight = Expression<BlockHeight?>("mined_height")
|
||||
|
@ -152,7 +152,7 @@ extension TransactionNG.Received {
|
|||
}
|
||||
}
|
||||
|
||||
extension TransactionNG.Sent {
|
||||
extension Transaction.Sent {
|
||||
enum Column {
|
||||
static let id = Expression<Int>("id_tx")
|
||||
static let minedHeight = Expression<BlockHeight?>("mined_height")
|
||||
|
|
|
@ -26,10 +26,10 @@ public protocol PaginatedTransactionRepository {
|
|||
/**
|
||||
Returns the page number if exists. Blocking
|
||||
*/
|
||||
func page(_ number: Int) throws -> [TransactionNG.Overview]?
|
||||
func page(_ number: Int) throws -> [Transaction.Overview]?
|
||||
|
||||
/**
|
||||
Returns the page number if exists. Non-blocking
|
||||
*/
|
||||
func page(_ number: Int, result: @escaping (Result<[TransactionNG.Overview]?, Error>) -> Void)
|
||||
func page(_ number: Int, result: @escaping (Result<[Transaction.Overview]?, Error>) -> Void)
|
||||
}
|
||||
|
|
|
@ -19,15 +19,15 @@ protocol TransactionRepository {
|
|||
func lastScannedHeight() throws -> BlockHeight
|
||||
func isInitialized() throws -> Bool
|
||||
|
||||
// MARK: - TransactionNG methods
|
||||
// MARK: - Transaction methods
|
||||
|
||||
func find(id: Int) throws -> TransactionNG.Overview
|
||||
func find(rawID: Data) throws -> TransactionNG.Overview
|
||||
func find(offset: Int, limit: Int, kind: TransactionKind) throws -> [TransactionNG.Overview]
|
||||
func find(in range: BlockRange, limit: Int, kind: TransactionKind) throws -> [TransactionNG.Overview]
|
||||
func find(from: TransactionNG.Overview, limit: Int, kind: TransactionKind) throws -> [TransactionNG.Overview]
|
||||
func findReceived(offset: Int, limit: Int) throws -> [TransactionNG.Received]
|
||||
func findSent(offset: Int, limit: Int) throws -> [TransactionNG.Sent]
|
||||
func findSent(in range: BlockRange, limit: Int) throws -> [TransactionNG.Sent]
|
||||
func findSent(rawID: Data) throws -> TransactionNG.Sent
|
||||
func find(id: Int) throws -> Transaction.Overview
|
||||
func find(rawID: Data) throws -> Transaction.Overview
|
||||
func find(offset: Int, limit: Int, kind: TransactionKind) throws -> [Transaction.Overview]
|
||||
func find(in range: BlockRange, limit: Int, kind: TransactionKind) throws -> [Transaction.Overview]
|
||||
func find(from: Transaction.Overview, limit: Int, kind: TransactionKind) throws -> [Transaction.Overview]
|
||||
func findReceived(offset: Int, limit: Int) throws -> [Transaction.Received]
|
||||
func findSent(offset: Int, limit: Int) throws -> [Transaction.Sent]
|
||||
func findSent(in range: BlockRange, limit: Int) throws -> [Transaction.Sent]
|
||||
func findSent(rawID: Data) throws -> Transaction.Sent
|
||||
}
|
||||
|
|
|
@ -248,12 +248,12 @@ extension LightWalletGRPCService: LightWalletService {
|
|||
}
|
||||
}
|
||||
|
||||
public func fetchTransaction(txId: Data) async throws -> TransactionNG.Fetched {
|
||||
public func fetchTransaction(txId: Data) async throws -> Transaction.Fetched {
|
||||
var txFilter = TxFilter()
|
||||
txFilter.hash = txId
|
||||
|
||||
let rawTx = try await compactTxStreamerAsync.getTransaction(txFilter)
|
||||
return TransactionNG.Fetched(rawID: txId, minedHeight: BlockHeight(rawTx.height), raw: rawTx.data)
|
||||
return Transaction.Fetched(rawID: txId, minedHeight: BlockHeight(rawTx.height), raw: rawTx.data)
|
||||
}
|
||||
|
||||
public func fetchUTXOs(
|
||||
|
|
|
@ -125,7 +125,7 @@ public protocol LightWalletService {
|
|||
/// - Parameter txId: data representing the transaction ID
|
||||
/// - Throws: LightWalletServiceError
|
||||
/// - Returns: LightWalletServiceResponse
|
||||
func fetchTransaction(txId: Data) async throws -> TransactionNG.Fetched
|
||||
func fetchTransaction(txId: Data) async throws -> Transaction.Fetched
|
||||
|
||||
func fetchUTXOs(for tAddress: String, height: BlockHeight) -> AsyncThrowingStream<UnspentTransactionOutputEntity, Error>
|
||||
|
||||
|
|
|
@ -136,13 +136,13 @@ public protocol Synchronizer {
|
|||
var pendingTransactions: [PendingTransactionEntity] { get }
|
||||
|
||||
/// all the transactions that are on the blockchain
|
||||
var clearedTransactions: [TransactionNG.Overview] { get }
|
||||
var clearedTransactions: [Transaction.Overview] { get }
|
||||
|
||||
/// All transactions that are related to sending funds
|
||||
var sentTransactions: [TransactionNG.Sent] { get }
|
||||
var sentTransactions: [Transaction.Sent] { get }
|
||||
|
||||
/// all transactions related to receiving funds
|
||||
var receivedTransactions: [TransactionNG.Received] { get }
|
||||
var receivedTransactions: [Transaction.Received] { get }
|
||||
|
||||
/// A repository serving transactions in a paginated manner
|
||||
/// - Parameter kind: Transaction Kind expected from this PaginatedTransactionRepository
|
||||
|
@ -153,7 +153,7 @@ public protocol Synchronizer {
|
|||
/// - from: the confirmed transaction from which the query should start from or nil to retrieve from the most recent transaction
|
||||
/// - limit: the maximum amount of items this should return if available
|
||||
/// - Returns: an array with the given Transactions or nil
|
||||
func allConfirmedTransactions(from transaction: TransactionNG.Overview, limit: Int) throws -> [TransactionNG.Overview]
|
||||
func allConfirmedTransactions(from transaction: Transaction.Overview, limit: Int) throws -> [Transaction.Overview]
|
||||
|
||||
/// Returns the latest block height from the provided Lightwallet endpoint
|
||||
func latestHeight(result: @escaping (Result<BlockHeight, Error>) -> Void)
|
||||
|
@ -265,7 +265,7 @@ public enum TransactionKind {
|
|||
public enum RewindPolicy {
|
||||
case birthday
|
||||
case height(blockheight: BlockHeight)
|
||||
case transaction(_ transaction: TransactionNG.Overview)
|
||||
case transaction(_ transaction: Transaction.Overview)
|
||||
case quick
|
||||
}
|
||||
|
||||
|
|
|
@ -350,7 +350,7 @@ public class SDKSynchronizer: Synchronizer {
|
|||
@objc func transactionsFound(_ notification: Notification) {
|
||||
guard
|
||||
let userInfo = notification.userInfo,
|
||||
let foundTransactions = userInfo[CompactBlockProcessorNotificationKey.foundTransactions] as? [TransactionNG.Overview]
|
||||
let foundTransactions = userInfo[CompactBlockProcessorNotificationKey.foundTransactions] as? [Transaction.Overview]
|
||||
else {
|
||||
return
|
||||
}
|
||||
|
@ -564,7 +564,7 @@ public class SDKSynchronizer: Synchronizer {
|
|||
transactionManager.cancel(pendingTransaction: transaction)
|
||||
}
|
||||
|
||||
public func allReceivedTransactions() throws -> [TransactionNG.Received] {
|
||||
public func allReceivedTransactions() throws -> [Transaction.Received] {
|
||||
try transactionRepository.findReceived(offset: 0, limit: Int.max)
|
||||
}
|
||||
|
||||
|
@ -572,15 +572,15 @@ public class SDKSynchronizer: Synchronizer {
|
|||
try transactionManager.allPendingTransactions() ?? [PendingTransactionEntity]()
|
||||
}
|
||||
|
||||
public func allClearedTransactions() throws -> [TransactionNG.Overview] {
|
||||
public func allClearedTransactions() throws -> [Transaction.Overview] {
|
||||
return try transactionRepository.find(offset: 0, limit: Int.max, kind: .all)
|
||||
}
|
||||
|
||||
public func allSentTransactions() throws -> [TransactionNG.Sent] {
|
||||
public func allSentTransactions() throws -> [Transaction.Sent] {
|
||||
return try transactionRepository.findSent(offset: 0, limit: Int.max)
|
||||
}
|
||||
|
||||
public func allConfirmedTransactions(from transaction: TransactionNG.Overview, limit: Int) throws -> [TransactionNG.Overview] {
|
||||
public func allConfirmedTransactions(from transaction: Transaction.Overview, limit: Int) throws -> [Transaction.Overview] {
|
||||
return try transactionRepository.find(from: transaction, limit: limit, kind: .all)
|
||||
}
|
||||
|
||||
|
@ -864,15 +864,15 @@ extension SDKSynchronizer {
|
|||
(try? self.allPendingTransactions()) ?? [PendingTransactionEntity]()
|
||||
}
|
||||
|
||||
public var clearedTransactions: [TransactionNG.Overview] {
|
||||
public var clearedTransactions: [Transaction.Overview] {
|
||||
(try? self.allClearedTransactions()) ?? []
|
||||
}
|
||||
|
||||
public var sentTransactions: [TransactionNG.Sent] {
|
||||
public var sentTransactions: [Transaction.Sent] {
|
||||
(try? self.allSentTransactions()) ?? []
|
||||
}
|
||||
|
||||
public var receivedTransactions: [TransactionNG.Received] {
|
||||
public var receivedTransactions: [Transaction.Received] {
|
||||
(try? self.allReceivedTransactions()) ?? []
|
||||
}
|
||||
}
|
||||
|
@ -913,6 +913,6 @@ extension ConnectionState {
|
|||
private struct NullEnhancementProgress: EnhancementProgress {
|
||||
var totalTransactions: Int { 0 }
|
||||
var enhancedTransactions: Int { 0 }
|
||||
var lastFoundTransaction: TransactionNG.Overview? { nil }
|
||||
var lastFoundTransaction: Transaction.Overview? { nil }
|
||||
var range: CompactBlockRange { 0 ... 0 }
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ enum TransactionManagerError: Error {
|
|||
case submitFailed(PendingTransactionEntity, errorCode: Int)
|
||||
case shieldingEncodingFailed(PendingTransactionEntity, reason: String)
|
||||
case cannotEncodeInternalTx(PendingTransactionEntity)
|
||||
case transactionNotMined(PendingTransactionEntity, TransactionNG.Overview)
|
||||
case transactionNotMined(PendingTransactionEntity, Transaction.Overview)
|
||||
}
|
||||
|
||||
class PersistentTransactionManager: OutboundTransactionManager {
|
||||
|
|
|
@ -36,7 +36,7 @@ protocol TransactionEncoder {
|
|||
to address: String,
|
||||
memoBytes: MemoBytes?,
|
||||
from accountIndex: Int
|
||||
) async throws -> TransactionNG.Overview
|
||||
) async throws -> Transaction.Overview
|
||||
|
||||
/**
|
||||
Creates a transaction that will attempt to shield transparent funds that are present on the cacheDB .throwing an exception whenever things are missing. When the provided wallet implementation doesn't throw an exception, we wrap the issue into a descriptive exception ourselves (rather than using double-bangs for things).
|
||||
|
@ -52,5 +52,5 @@ protocol TransactionEncoder {
|
|||
spendingKey: UnifiedSpendingKey,
|
||||
memoBytes: MemoBytes?,
|
||||
from accountIndex: Int
|
||||
) async throws -> TransactionNG.Overview
|
||||
) async throws -> Transaction.Overview
|
||||
}
|
||||
|
|
|
@ -53,7 +53,7 @@ class WalletTransactionEncoder: TransactionEncoder {
|
|||
to address: String,
|
||||
memoBytes: MemoBytes?,
|
||||
from accountIndex: Int
|
||||
) async throws -> TransactionNG.Overview {
|
||||
) async throws -> Transaction.Overview {
|
||||
let txId = try createSpend(
|
||||
spendingKey: spendingKey,
|
||||
zatoshi: zatoshi,
|
||||
|
@ -103,7 +103,7 @@ class WalletTransactionEncoder: TransactionEncoder {
|
|||
spendingKey: UnifiedSpendingKey,
|
||||
memoBytes: MemoBytes?,
|
||||
from accountIndex: Int
|
||||
) async throws -> TransactionNG.Overview {
|
||||
) async throws -> Transaction.Overview {
|
||||
let txId = try createShieldingSpend(
|
||||
spendingKey: spendingKey,
|
||||
memo: memoBytes,
|
||||
|
|
|
@ -605,7 +605,7 @@ class AdvancedReOrgTests: XCTestCase {
|
|||
|
||||
var initialBalance = Zatoshi(-1)
|
||||
var initialVerifiedBalance = Zatoshi(-1)
|
||||
var incomingTx: TransactionNG.Received!
|
||||
var incomingTx: Transaction.Received!
|
||||
try coordinator.sync(completion: { _ in
|
||||
firstSyncExpectation.fulfill()
|
||||
}, error: self.handleError)
|
||||
|
|
|
@ -952,7 +952,7 @@ class BalanceTests: XCTestCase {
|
|||
try await withCheckedThrowingContinuation { continuation in
|
||||
do {
|
||||
try coordinator.sync(completion: { synchronizer in
|
||||
let confirmedTx: TransactionNG.Overview!
|
||||
let confirmedTx: Transaction.Overview!
|
||||
do {
|
||||
confirmedTx = try synchronizer.allClearedTransactions().first(where: { confirmed -> Bool in
|
||||
confirmed.rawID == pendingTx?.rawTransactionId
|
||||
|
@ -1190,7 +1190,7 @@ class BalanceTests: XCTestCase {
|
|||
}
|
||||
|
||||
class SDKSynchonizerListener {
|
||||
var transactionsFound: (([TransactionNG.Overview]) -> Void)?
|
||||
var transactionsFound: (([Transaction.Overview]) -> Void)?
|
||||
var synchronizerMinedTransaction: ((PendingTransactionEntity) -> Void)?
|
||||
|
||||
func subscribeToSynchronizer(_ synchronizer: SDKSynchronizer) {
|
||||
|
@ -1204,7 +1204,7 @@ class SDKSynchonizerListener {
|
|||
|
||||
@objc func txFound(_ notification: Notification) {
|
||||
DispatchQueue.main.async { [weak self] in
|
||||
guard let txs = notification.userInfo?[SDKSynchronizer.NotificationKeys.foundTransactions] as? [TransactionNG.Overview] else {
|
||||
guard let txs = notification.userInfo?[SDKSynchronizer.NotificationKeys.foundTransactions] as? [Transaction.Overview] else {
|
||||
XCTFail("expected [ConfirmedTransactionEntity] array")
|
||||
return
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ class SychronizerDarksideTests: XCTestCase {
|
|||
var expectedReorgHeight: BlockHeight = 665188
|
||||
var expectedRewindHeight: BlockHeight = 665188
|
||||
var reorgExpectation = XCTestExpectation(description: "reorg")
|
||||
var foundTransactions: [TransactionNG.Overview] = []
|
||||
var foundTransactions: [Transaction.Overview] = []
|
||||
|
||||
override func setUpWithError() throws {
|
||||
try super.setUpWithError()
|
||||
|
@ -184,7 +184,7 @@ class SychronizerDarksideTests: XCTestCase {
|
|||
@objc func handleFoundTransactions(_ notification: Notification) {
|
||||
guard
|
||||
let userInfo = notification.userInfo,
|
||||
let transactions = userInfo[SDKSynchronizer.NotificationKeys.foundTransactions] as? [TransactionNG.Overview]
|
||||
let transactions = userInfo[SDKSynchronizer.NotificationKeys.foundTransactions] as? [Transaction.Overview]
|
||||
else {
|
||||
return
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ class TransactionRepositoryTests: XCTestCase {
|
|||
}
|
||||
|
||||
func testFindById() {
|
||||
var transaction: TransactionNG.Overview!
|
||||
var transaction: Transaction.Overview!
|
||||
XCTAssertNoThrow(try { transaction = try self.transactionRepository.find(id: 10) }())
|
||||
|
||||
XCTAssertEqual(transaction.id, 10)
|
||||
|
@ -48,7 +48,7 @@ class TransactionRepositoryTests: XCTestCase {
|
|||
}
|
||||
|
||||
func testFindByTxId() {
|
||||
var transaction: TransactionNG.Overview!
|
||||
var transaction: Transaction.Overview!
|
||||
|
||||
let id = Data(fromHexEncodedString: "01af48bcc4e9667849a073b8b5c539a0fc19de71aac775377929dc6567a36eff")!
|
||||
|
||||
|
@ -62,21 +62,21 @@ class TransactionRepositoryTests: XCTestCase {
|
|||
}
|
||||
|
||||
func testFindAllSentTransactions() {
|
||||
var transactions: [TransactionNG.Overview] = []
|
||||
var transactions: [Transaction.Overview] = []
|
||||
XCTAssertNoThrow(try { transactions = try self.transactionRepository.find(offset: 0, limit: Int.max, kind: .sent) }())
|
||||
XCTAssertEqual(transactions.count, 13)
|
||||
transactions.forEach { XCTAssertEqual($0.isSentTransaction, true) }
|
||||
}
|
||||
|
||||
func testFindAllReceivedTransactions() {
|
||||
var transactions: [TransactionNG.Overview] = []
|
||||
var transactions: [Transaction.Overview] = []
|
||||
XCTAssertNoThrow(try { transactions = try self.transactionRepository.find(offset: 0, limit: Int.max, kind: .received) }())
|
||||
XCTAssertEqual(transactions.count, 8)
|
||||
transactions.forEach { XCTAssertEqual($0.isSentTransaction, false) }
|
||||
}
|
||||
|
||||
func testFindAllTransactions() {
|
||||
var transactions: [TransactionNG.Overview] = []
|
||||
var transactions: [Transaction.Overview] = []
|
||||
XCTAssertNoThrow(try { transactions = try self.transactionRepository.find(offset: 0, limit: Int.max, kind: .all) }())
|
||||
XCTAssertEqual(transactions.count, 21)
|
||||
}
|
||||
|
@ -94,10 +94,10 @@ class TransactionRepositoryTests: XCTestCase {
|
|||
}
|
||||
|
||||
func testFindAllFrom() throws {
|
||||
var transaction: TransactionNG.Overview!
|
||||
var transaction: Transaction.Overview!
|
||||
XCTAssertNoThrow(try { transaction = try self.transactionRepository.find(id: 16) }())
|
||||
|
||||
var transactionsFrom: [TransactionNG.Overview] = []
|
||||
var transactionsFrom: [Transaction.Overview] = []
|
||||
XCTAssertNoThrow(try { transactionsFrom = try self.transactionRepository.find(from: transaction, limit: Int.max, kind: .all) }())
|
||||
|
||||
XCTAssertEqual(transactionsFrom.count, 8)
|
||||
|
|
|
@ -171,7 +171,7 @@ class DarksideWalletService: LightWalletService {
|
|||
try await service.submit(spendTransaction: spendTransaction)
|
||||
}
|
||||
|
||||
func fetchTransaction(txId: Data) async throws -> TransactionNG.Fetched {
|
||||
func fetchTransaction(txId: Data) async throws -> Transaction.Fetched {
|
||||
try await service.fetchTransaction(txId: txId)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -71,7 +71,7 @@ class MockLightWalletService: LightWalletService {
|
|||
LightWalletServiceMockResponse(errorCode: 0, errorMessage: "", unknownFields: UnknownStorage())
|
||||
}
|
||||
|
||||
func fetchTransaction(txId: Data) async throws -> TransactionNG.Fetched {
|
||||
return TransactionNG.Fetched(rawID: Data(), minedHeight: -1, raw: Data())
|
||||
func fetchTransaction(txId: Data) async throws -> Transaction.Fetched {
|
||||
return Transaction.Fetched(rawID: Data(), minedHeight: -1, raw: Data())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,9 +21,9 @@ class MockTransactionRepository {
|
|||
var reference: [Kind] = []
|
||||
var network: ZcashNetwork
|
||||
|
||||
var transactionsNG: [TransactionNG.Overview] = []
|
||||
var receivedTransactionsNG: [TransactionNG.Received] = []
|
||||
var sentTransactionsNG: [TransactionNG.Sent] = []
|
||||
var transactionsNG: [Transaction.Overview] = []
|
||||
var receivedTransactionsNG: [Transaction.Received] = []
|
||||
var sentTransactionsNG: [Transaction.Sent] = []
|
||||
|
||||
var allCount: Int {
|
||||
receivedCount + sentCount
|
||||
|
@ -81,11 +81,11 @@ extension MockTransactionRepository: TransactionRepository {
|
|||
nil
|
||||
}
|
||||
|
||||
func findBy(id: Int) throws -> TransactionNG.Overview? {
|
||||
func findBy(id: Int) throws -> Transaction.Overview? {
|
||||
transactionsNG.first(where: { $0.id == id })
|
||||
}
|
||||
|
||||
func findBy(rawId: Data) throws -> TransactionNG.Overview? {
|
||||
func findBy(rawId: Data) throws -> Transaction.Overview? {
|
||||
transactionsNG.first(where: { $0.rawID == rawId })
|
||||
}
|
||||
|
||||
|
@ -104,7 +104,7 @@ enum MockTransactionRepositoryError: Error {
|
|||
|
||||
extension MockTransactionRepository {
|
||||
func generateNG() {
|
||||
var txArray: [TransactionNG.Overview] = []
|
||||
var txArray: [Transaction.Overview] = []
|
||||
reference = referenceArray()
|
||||
for index in 0 ..< reference.count {
|
||||
txArray.append(mockTx(index: index, kind: reference[index]))
|
||||
|
@ -112,7 +112,7 @@ extension MockTransactionRepository {
|
|||
transactionsNG = txArray
|
||||
}
|
||||
|
||||
func mockTx(index: Int, kind: Kind) -> TransactionNG.Overview {
|
||||
func mockTx(index: Int, kind: Kind) -> Transaction.Overview {
|
||||
switch kind {
|
||||
case .received:
|
||||
return mockReceived(index)
|
||||
|
@ -121,8 +121,8 @@ extension MockTransactionRepository {
|
|||
}
|
||||
}
|
||||
|
||||
func mockSent(_ index: Int) -> TransactionNG.Overview {
|
||||
return TransactionNG.Overview(
|
||||
func mockSent(_ index: Int) -> Transaction.Overview {
|
||||
return Transaction.Overview(
|
||||
blocktime: randomTimeInterval(),
|
||||
expiryHeight: BlockHeight.max,
|
||||
fee: Zatoshi(2),
|
||||
|
@ -140,8 +140,8 @@ extension MockTransactionRepository {
|
|||
)
|
||||
}
|
||||
|
||||
func mockReceived(_ index: Int) -> TransactionNG.Overview {
|
||||
return TransactionNG.Overview(
|
||||
func mockReceived(_ index: Int) -> Transaction.Overview {
|
||||
return Transaction.Overview(
|
||||
blocktime: randomTimeInterval(),
|
||||
expiryHeight: BlockHeight.max,
|
||||
fee: Zatoshi(2),
|
||||
|
@ -159,13 +159,13 @@ extension MockTransactionRepository {
|
|||
)
|
||||
}
|
||||
|
||||
func slice(txs: [TransactionNG.Overview], offset: Int, limit: Int) -> [TransactionNG.Overview] {
|
||||
func slice(txs: [Transaction.Overview], offset: Int, limit: Int) -> [Transaction.Overview] {
|
||||
guard offset < txs.count else { return [] }
|
||||
|
||||
return Array(txs[offset ..< min(offset + limit, txs.count - offset)])
|
||||
}
|
||||
|
||||
func find(id: Int) throws -> TransactionNG.Overview {
|
||||
func find(id: Int) throws -> Transaction.Overview {
|
||||
guard let transaction = transactionsNG.first(where: { $0.id == id }) else {
|
||||
throw TransactionRepositoryError.notFound
|
||||
}
|
||||
|
@ -173,7 +173,7 @@ extension MockTransactionRepository {
|
|||
return transaction
|
||||
}
|
||||
|
||||
func find(rawID: Data) throws -> TransactionNG.Overview {
|
||||
func find(rawID: Data) throws -> Transaction.Overview {
|
||||
guard let transaction = transactionsNG.first(where: { $0.rawID == rawID }) else {
|
||||
throw TransactionRepositoryError.notFound
|
||||
}
|
||||
|
@ -181,31 +181,31 @@ extension MockTransactionRepository {
|
|||
return transaction
|
||||
}
|
||||
|
||||
func find(offset: Int, limit: Int, kind: TransactionKind) throws -> [ZcashLightClientKit.TransactionNG.Overview] {
|
||||
func find(offset: Int, limit: Int, kind: TransactionKind) throws -> [ZcashLightClientKit.Transaction.Overview] {
|
||||
throw MockTransactionRepositoryError.notImplemented
|
||||
}
|
||||
|
||||
func find(in range: BlockRange, limit: Int, kind: TransactionKind) throws -> [TransactionNG.Overview] {
|
||||
func find(in range: BlockRange, limit: Int, kind: TransactionKind) throws -> [Transaction.Overview] {
|
||||
throw MockTransactionRepositoryError.notImplemented
|
||||
}
|
||||
|
||||
func find(from: TransactionNG.Overview, limit: Int, kind: TransactionKind) throws -> [TransactionNG.Overview] {
|
||||
func find(from: Transaction.Overview, limit: Int, kind: TransactionKind) throws -> [Transaction.Overview] {
|
||||
throw MockTransactionRepositoryError.notImplemented
|
||||
}
|
||||
|
||||
func findReceived(offset: Int, limit: Int) throws -> [TransactionNG.Received] {
|
||||
func findReceived(offset: Int, limit: Int) throws -> [Transaction.Received] {
|
||||
throw MockTransactionRepositoryError.notImplemented
|
||||
}
|
||||
|
||||
func findSent(offset: Int, limit: Int) throws -> [TransactionNG.Sent] {
|
||||
func findSent(offset: Int, limit: Int) throws -> [Transaction.Sent] {
|
||||
throw MockTransactionRepositoryError.notImplemented
|
||||
}
|
||||
|
||||
func findSent(in range: BlockRange, limit: Int) throws -> [TransactionNG.Sent] {
|
||||
func findSent(in range: BlockRange, limit: Int) throws -> [Transaction.Sent] {
|
||||
throw MockTransactionRepositoryError.notImplemented
|
||||
}
|
||||
|
||||
func findSent(rawID: Data) throws -> TransactionNG.Sent {
|
||||
func findSent(rawID: Data) throws -> Transaction.Sent {
|
||||
throw MockTransactionRepositoryError.notImplemented
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue