Skip to content

Commit

Permalink
[ABW-2589] Transaction History Part Deux (#1052)
Browse files Browse the repository at this point in the history
  • Loading branch information
kugel3 committed Mar 22, 2024
1 parent 455e206 commit 9634ecf
Show file tree
Hide file tree
Showing 33 changed files with 1,552 additions and 1,427 deletions.
52 changes: 27 additions & 25 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,11 @@ GEM
declarative (0.0.20)
digest-crc (0.6.5)
rake (>= 12.0.0, < 14.0.0)
domain_name (0.6.20240107)
domain_name (0.5.20190701)
unf (>= 0.0.5, < 1.0.0)
dotenv (2.8.1)
emoji_regex (3.2.3)
excon (0.110.0)
excon (0.109.0)
faraday (1.10.3)
faraday-em_http (~> 1.0)
faraday-em_synchrony (~> 1.0)
Expand Down Expand Up @@ -111,40 +112,38 @@ GEM
fastlane-plugin-json (1.1.0)
fastlane-plugin-xcconfig (2.0.0)
gh_inspector (1.1.3)
google-apis-androidpublisher_v3 (0.58.0)
google-apis-core (>= 0.14.0, < 2.a)
google-apis-core (0.14.1)
google-apis-androidpublisher_v3 (0.54.0)
google-apis-core (>= 0.11.0, < 2.a)
google-apis-core (0.11.3)
addressable (~> 2.5, >= 2.5.1)
googleauth (~> 1.9)
googleauth (>= 0.16.2, < 2.a)
httpclient (>= 2.8.1, < 3.a)
mini_mime (~> 1.0)
representable (~> 3.0)
retriable (>= 2.0, < 4.a)
rexml
google-apis-iamcredentials_v1 (0.20.0)
google-apis-core (>= 0.14.0, < 2.a)
google-apis-playcustomapp_v1 (0.15.0)
google-apis-core (>= 0.14.0, < 2.a)
google-apis-storage_v1 (0.36.0)
google-apis-core (>= 0.14.0, < 2.a)
google-cloud-core (1.7.0)
google-apis-iamcredentials_v1 (0.17.0)
google-apis-core (>= 0.11.0, < 2.a)
google-apis-playcustomapp_v1 (0.13.0)
google-apis-core (>= 0.11.0, < 2.a)
google-apis-storage_v1 (0.29.0)
google-apis-core (>= 0.11.0, < 2.a)
google-cloud-core (1.6.1)
google-cloud-env (>= 1.0, < 3.a)
google-cloud-errors (~> 1.0)
google-cloud-env (2.1.1)
faraday (>= 1.0, < 3.a)
google-cloud-errors (1.4.0)
google-cloud-storage (1.49.0)
google-cloud-env (1.6.0)
faraday (>= 0.17.3, < 3.0)
google-cloud-errors (1.3.1)
google-cloud-storage (1.45.0)
addressable (~> 2.8)
digest-crc (~> 0.4)
google-apis-core (~> 0.13)
google-apis-iamcredentials_v1 (~> 0.18)
google-apis-storage_v1 (~> 0.33)
google-apis-iamcredentials_v1 (~> 0.1)
google-apis-storage_v1 (~> 0.29.0)
google-cloud-core (~> 1.6)
googleauth (~> 1.9)
googleauth (>= 0.16.2, < 2.a)
mini_mime (~> 1.0)
googleauth (1.11.0)
faraday (>= 1.0, < 3.a)
google-cloud-env (~> 2.1)
googleauth (1.8.1)
faraday (>= 0.17.3, < 3.a)
jwt (>= 1.4, < 3.0)
multi_json (~> 1.11)
os (>= 0.9, < 2.0)
Expand Down Expand Up @@ -179,7 +178,7 @@ GEM
ruby2_keywords (0.0.5)
rubyzip (2.3.2)
security (0.1.3)
signet (0.19.0)
signet (0.18.0)
addressable (~> 2.8)
faraday (>= 0.17.5, < 3.a)
jwt (>= 1.5, < 3.0)
Expand All @@ -196,6 +195,9 @@ GEM
tty-spinner (0.9.3)
tty-cursor (~> 0.7)
uber (0.1.0)
unf (0.1.4)
unf_ext
unf_ext (0.0.9.1)
unicode-display_width (2.5.0)
word_wrap (1.0.0)
xcode-install (2.8.1)
Expand Down
22 changes: 15 additions & 7 deletions RadixWallet.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1202,6 +1202,9 @@
A48FD15F2B55E671009295E9 /* TrackedPoolInteraction.swift in Sources */ = {isa = PBXBuildFile; fileRef = A48FD15E2B55E671009295E9 /* TrackedPoolInteraction.swift */; };
A48FD1612B55F8F0009295E9 /* TransactionReview+Sections.swift in Sources */ = {isa = PBXBuildFile; fileRef = A48FD1602B55F8F0009295E9 /* TransactionReview+Sections.swift */; };
A4B017F72B4C099D00B42B8E /* TransactionReview+DepositSettingView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A4B017F42B4BF59000B42B8E /* TransactionReview+DepositSettingView.swift */; };
A4CFB55D2BA8CA3200778BDD /* TransactionHistory+TableView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A4CFB55C2BA8CA3200778BDD /* TransactionHistory+TableView.swift */; };
A4CFB55F2BAA821E00778BDD /* HScrollBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = A4CFB55E2BAA821E00778BDD /* HScrollBar.swift */; };
A4CFB5612BAA826E00778BDD /* Measure+Position.swift in Sources */ = {isa = PBXBuildFile; fileRef = A4CFB5602BAA826E00778BDD /* Measure+Position.swift */; };
A4EB37C82B6272F3003FE31D /* TrackedValidatorInteraction.swift in Sources */ = {isa = PBXBuildFile; fileRef = A4EB37C72B6272F3003FE31D /* TrackedValidatorInteraction.swift */; };
E62449D52AFBA61100272C67 /* Home+AccountRow+Reducer.swift in Sources */ = {isa = PBXBuildFile; fileRef = E62449D32AFBA61100272C67 /* Home+AccountRow+Reducer.swift */; };
E62449D62AFBA61100272C67 /* Home+AccountRow+View.swift in Sources */ = {isa = PBXBuildFile; fileRef = E62449D42AFBA61100272C67 /* Home+AccountRow+View.swift */; };
Expand Down Expand Up @@ -1311,7 +1314,6 @@
E6DBA3862ADEBFB300A38425 /* DappModelsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = E6DBA3132ADEBFB300A38425 /* DappModelsTests.swift */; };
E6DBA3872ADEBFB300A38425 /* LedgerModelTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = E6DBA3152ADEBFB300A38425 /* LedgerModelTests.swift */; };
E6DBA3882ADEBFB300A38425 /* Validation+ExtraTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = E6DBA3172ADEBFB300A38425 /* Validation+ExtraTests.swift */; };
E6DBA3892ADEBFB300A38425 /* String+ExtraTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = E6DBA3182ADEBFB300A38425 /* String+ExtraTests.swift */; };
E6DBA38B2ADEC0CB00A38425 /* SLIP10TestVectorsHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = E6DBA38A2ADEC0CB00A38425 /* SLIP10TestVectorsHelper.swift */; };
E6FA984A2B04B9AC00748F20 /* ConfirmSkippingBDFS+View.swift in Sources */ = {isa = PBXBuildFile; fileRef = E6FA98482B04B9AC00748F20 /* ConfirmSkippingBDFS+View.swift */; };
E6FA984B2B04B9AC00748F20 /* ConfirmSkippingBDFS.swift in Sources */ = {isa = PBXBuildFile; fileRef = E6FA98492B04B9AC00748F20 /* ConfirmSkippingBDFS.swift */; };
Expand Down Expand Up @@ -2494,6 +2496,9 @@
A48FD15E2B55E671009295E9 /* TrackedPoolInteraction.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TrackedPoolInteraction.swift; sourceTree = "<group>"; };
A48FD1602B55F8F0009295E9 /* TransactionReview+Sections.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "TransactionReview+Sections.swift"; sourceTree = "<group>"; };
A4B017F42B4BF59000B42B8E /* TransactionReview+DepositSettingView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "TransactionReview+DepositSettingView.swift"; sourceTree = "<group>"; };
A4CFB55C2BA8CA3200778BDD /* TransactionHistory+TableView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "TransactionHistory+TableView.swift"; sourceTree = "<group>"; };
A4CFB55E2BAA821E00778BDD /* HScrollBar.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HScrollBar.swift; sourceTree = "<group>"; };
A4CFB5602BAA826E00778BDD /* Measure+Position.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Measure+Position.swift"; sourceTree = "<group>"; };
A4EB37C72B6272F3003FE31D /* TrackedValidatorInteraction.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TrackedValidatorInteraction.swift; sourceTree = "<group>"; };
E62449D32AFBA61100272C67 /* Home+AccountRow+Reducer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Home+AccountRow+Reducer.swift"; sourceTree = "<group>"; };
E62449D42AFBA61100272C67 /* Home+AccountRow+View.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Home+AccountRow+View.swift"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -2602,7 +2607,6 @@
E6DBA3132ADEBFB300A38425 /* DappModelsTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DappModelsTests.swift; sourceTree = "<group>"; };
E6DBA3152ADEBFB300A38425 /* LedgerModelTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LedgerModelTests.swift; sourceTree = "<group>"; };
E6DBA3172ADEBFB300A38425 /* Validation+ExtraTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Validation+ExtraTests.swift"; sourceTree = "<group>"; };
E6DBA3182ADEBFB300A38425 /* String+ExtraTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "String+ExtraTests.swift"; sourceTree = "<group>"; };
E6DBA38A2ADEC0CB00A38425 /* SLIP10TestVectorsHelper.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SLIP10TestVectorsHelper.swift; sourceTree = "<group>"; };
E6FA98482B04B9AC00748F20 /* ConfirmSkippingBDFS+View.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "ConfirmSkippingBDFS+View.swift"; sourceTree = "<group>"; };
E6FA98492B04B9AC00748F20 /* ConfirmSkippingBDFS.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConfirmSkippingBDFS.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -2781,7 +2785,7 @@
48CFBC602ADC10D800E77A5C /* Features */ = {
isa = PBXGroup;
children = (
A41557512B7645D40040AD4E /* AccountHistory */,
A41557512B7645D40040AD4E /* TransactionHistory */,
48AE39D82B0CBE3900813CF3 /* AccountRecoveryScan */,
830EA9D42AE94014004C8051 /* AccountAndPersonaHidingFeature */,
48CFBC612ADC10D800E77A5C /* SecurityStructureConfigurationList */,
Expand Down Expand Up @@ -5796,6 +5800,8 @@
839B6C532B21D28400402651 /* ExpandableTextView.swift */,
83D663AF2B271D0100D1AB9E /* TruncationMask.swift */,
83EA887D2B7E68EE00FF8424 /* TotalCurrencyWorthView.swift */,
A4CFB55E2BAA821E00778BDD /* HScrollBar.swift */,
A4CFB5602BAA826E00778BDD /* Measure+Position.swift */,
);
path = DesignSystem;
sourceTree = "<group>";
Expand Down Expand Up @@ -6891,15 +6897,16 @@
path = ManualAccountRecoveryScan;
sourceTree = "<group>";
};
A41557512B7645D40040AD4E /* AccountHistory */ = {
A41557512B7645D40040AD4E /* TransactionHistory */ = {
isa = PBXGroup;
children = (
A41557522B7645E70040AD4E /* TransactionHistory+Reducer.swift */,
A41557542B7645F70040AD4E /* TransactionHistory+View.swift */,
A4CFB55C2BA8CA3200778BDD /* TransactionHistory+TableView.swift */,
A462B5C02B95210000C26D20 /* TransactionHistoryFilters+Reducer.swift */,
A462B5C22B95212600C26D20 /* TransactionHistoryFilters+View.swift */,
);
path = AccountHistory;
path = TransactionHistory;
sourceTree = "<group>";
};
A462B5752B820D1200C26D20 /* TransactionHistoryClient */ = {
Expand Down Expand Up @@ -7602,7 +7609,6 @@
isa = PBXGroup;
children = (
E6DBA3172ADEBFB300A38425 /* Validation+ExtraTests.swift */,
E6DBA3182ADEBFB300A38425 /* String+ExtraTests.swift */,
);
path = FeaturePreludeTests;
sourceTree = "<group>";
Expand Down Expand Up @@ -7844,7 +7850,6 @@
E6DBA3822ADEBFB300A38425 /* FactorSourcesClientLiveTests.swift in Sources */,
E6DBA3852ADEBFB300A38425 /* FaucetClientTests.swift in Sources */,
E6DBA3252ADEBFB300A38425 /* DecimalTests.swift in Sources */,
E6DBA3892ADEBFB300A38425 /* String+ExtraTests.swift in Sources */,
E6DBA3222ADEBFB300A38425 /* RadixConnectJSONValues.swift in Sources */,
E6DBA31E2ADEBFB300A38425 /* DataChannelMocks.swift in Sources */,
E6DBA36C2ADEBFB300A38425 /* SnapshotHeaderTests.swift in Sources */,
Expand Down Expand Up @@ -8384,6 +8389,7 @@
48CFC5052ADC10DA00E77A5C /* TransactionPreviewResponseLogsInner.swift in Sources */,
48CFC2FF2ADC10D900E77A5C /* AccountSecurity+View.swift in Sources */,
48CFC56B2ADC10DA00E77A5C /* MetadataU8ArrayValue.swift in Sources */,
A4CFB55F2BAA821E00778BDD /* HScrollBar.swift in Sources */,
48CFC2F92ADC10D900E77A5C /* InfoOfNewPersona+Reducer.swift in Sources */,
48CFC44D2ADC10DA00E77A5C /* MnemonicClient+Live.swift in Sources */,
48CFC57E2ADC10DA00E77A5C /* ValidatorState.swift in Sources */,
Expand Down Expand Up @@ -8427,6 +8433,7 @@
48CFC42C2ADC10DA00E77A5C /* Unit.swift in Sources */,
48CFC6622ADC10DB00E77A5C /* FactorSource.swift in Sources */,
48CFC2602ADC10D900E77A5C /* EditPersonaEntry+View.swift in Sources */,
A4CFB5612BAA826E00778BDD /* Measure+Position.swift in Sources */,
48AE39E22B0CBE8200813CF3 /* AccountRecoveryScanInProgress.swift in Sources */,
48CFC2E92ADC10D900E77A5C /* SimpleCreateSecurityStructureFlow+View.swift in Sources */,
48CFC5162ADC10DA00E77A5C /* EntityNotFoundError.swift in Sources */,
Expand Down Expand Up @@ -8855,6 +8862,7 @@
48CFC3D42ADC10D900E77A5C /* BIP39+WordCount.swift in Sources */,
48CFC47B2ADC10DA00E77A5C /* LocalAuthenticationClient+Test.swift in Sources */,
48CFC2CB2ADC10D900E77A5C /* ResourceAsset+View.swift in Sources */,
A4CFB55D2BA8CA3200778BDD /* TransactionHistory+TableView.swift in Sources */,
48CFC5FB2ADC10DA00E77A5C /* ImageAsset+Extension.swift in Sources */,
48CFC4C22ADC10DA00E77A5C /* StateEntityDetailsResponseNonFungibleVaultDetails.swift in Sources */,
48CFC3852ADC10D900E77A5C /* EmptyAssetListView.swift in Sources */,
Expand Down
9 changes: 8 additions & 1 deletion RadixWallet/Clients/CacheClient/CacheClient+Interface.swift
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ extension CacheClient {
case rolaDappVerificationMetadata(_ definitionAddress: String)
case rolaWellKnownFileVerification(_ url: String)
case tokenPrices(_ currency: FiatCurrency)
case dateOfFirstTransaction(_ accountAddress: AccountAddress)

var filesystemFilePath: String {
switch self {
Expand Down Expand Up @@ -118,6 +119,8 @@ extension CacheClient {
return "\(filesystemFolderPath)/RolaWellKnownFileVerification-\(url)"
case let .tokenPrices(currency):
return "\(filesystemFolderPath)/prices-\(currency.rawValue)"
case let .dateOfFirstTransaction(address):
return "\(filesystemFolderPath)/account-\(address.address)"
}
}

Expand Down Expand Up @@ -151,6 +154,8 @@ extension CacheClient {
return "RolaWellKnownFileVerification"
case .tokenPrices:
return "TokenPrices"
case .dateOfFirstTransaction:
return "DateOfFirstTransaction"
}
}

Expand All @@ -161,11 +166,13 @@ extension CacheClient {
var lifetime: TimeInterval {
switch self {
case .networkName, .onLedgerEntity:
60 * 60 * 24 // On day cache
60 * 60 * 24 // One day cache
case .dAppRequestMetadata, .rolaDappVerificationMetadata, .rolaWellKnownFileVerification:
60
case .tokenPrices:
60 * 5 // 5 minutes
case .dateOfFirstTransaction:
99 * 365 * 60 * 60 * 24
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,51 +2,40 @@ import Foundation

// MARK: - TransactionHistoryClient
public struct TransactionHistoryClient: Sendable, DependencyKey {
public var getFirstTransactionDate: GetFirstTransactionDate
public var getTransactionHistory: GetTransactionHistory
}

// MARK: TransactionHistoryClient.GetTransactionHistory
extension TransactionHistoryClient {
public typealias GetFirstTransactionDate = @Sendable (AccountAddress) async throws -> Date?
public typealias GetTransactionHistory = @Sendable (TransactionHistoryRequest) async throws -> TransactionHistoryResponse
}

// MARK: - TransactionHistoryRequest
public struct TransactionHistoryRequest: Sendable, Hashable {
public let account: AccountAddress
public let parameters: TransactionHistoryParameters
public let parameters: Parameters
public let cursor: String?

public let allResourcesAddresses: Set<ResourceAddress>
public let resources: IdentifiedArrayOf<OnLedgerEntity.Resource>

// MARK: - Parameters
public struct Parameters: Sendable, Hashable {
public let period: Range<Date>
public let filters: [TransactionFilter]
public let direction: TransactionHistory.Direction
}
}

// MARK: - TransactionHistoryResponse
public struct TransactionHistoryResponse: Sendable, Hashable {
public let parameters: TransactionHistoryParameters
public let nextCursor: String?
public let totalCount: Int64?
public let resources: IdentifiedArrayOf<OnLedgerEntity.Resource>
public let items: [TransactionHistoryItem]
}

// MARK: - TransactionHistoryParameters
public struct TransactionHistoryParameters: Sendable, Hashable {
public let period: Range<Date>
public let downwards: Bool
public let filters: [TransactionFilter]

public init(period: Range<Date>, downwards: Bool = true, filters: [TransactionFilter] = []) {
self.period = period
self.downwards = downwards
self.filters = filters
}

/// The other parameter set already encompasses these transactions
public func covers(_ parameters: Self) -> Bool {
filters == parameters.filters && period.contains(parameters.period)
}
}

// MARK: - TransactionHistoryItem
public struct TransactionHistoryItem: Sendable, Hashable, Identifiable {
public let id: TXID
Expand Down Expand Up @@ -86,8 +75,8 @@ public enum TransactionFilter: Hashable, Sendable {
case transactionType(TransactionType)

public enum TransferType: CaseIterable, Sendable {
case withdrawal
case deposit
case withdrawal
}

public typealias TransactionType = GatewayAPI.ManifestClass
Expand Down
Loading

0 comments on commit 9634ecf

Please sign in to comment.