Skip to content

Commit

Permalink
Merge branch 'main' into ABW-3213
Browse files Browse the repository at this point in the history
  • Loading branch information
matiasbzurovski committed May 7, 2024
2 parents 32a0001 + 79d007f commit 427f39d
Show file tree
Hide file tree
Showing 603 changed files with 5,150 additions and 86,167 deletions.
2 changes: 2 additions & 0 deletions Aux/Radix-Wallet--iOS--Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
<string>zbra</string>
<string>filza</string>
<string>activator</string>
<string>googlegmail</string>
<string>ms-outlook</string>
</array>
</dict>
</plist>
2,408 changes: 485 additions & 1,923 deletions RadixWallet.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"originHash" : "f8e8a767cab7d9334987bf06a9dbed1c6759bf30eb416e1f63c6552765355846",
"originHash" : "136e3a1717e535f7f4817c4c452e7f0f9a077f467187dd7381b7e2ab133531b1",
"pins" : [
{
"identity" : "anycodable",
Expand Down Expand Up @@ -82,15 +82,6 @@
"version" : "2.2.3"
}
},
{
"identity" : "k1",
"kind" : "remoteSourceControl",
"location" : "https://github.com/Sajjon/K1",
"state" : {
"revision" : "9e6c2716b2e6b306d38ca5ec85ff6c16ea148ad1",
"version" : "0.3.8"
}
},
{
"identity" : "keychainaccess",
"kind" : "remoteSourceControl",
Expand Down Expand Up @@ -123,8 +114,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/radixdlt/sargon",
"state" : {
"revision" : "47032cdd7b6ff22b50ffb56cf20ce70a438c5f53",
"version" : "0.6.47"
"revision" : "a02679cd3f4be02964ccd7a3cc07f1f685cca332",
"version" : "0.7.4"
}
},
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import Sargon

// MARK: - AccountPortfoliosClient
public struct AccountPortfoliosClient: Sendable {
/// Fetches the account portfolios for the given addresses.
Expand Down Expand Up @@ -43,7 +45,7 @@ extension AccountPortfoliosClient {
@Dependency(\.onLedgerEntitiesClient) var onLedgerEntitiesClient
@Dependency(\.cacheClient) var cacheClient

let changedAccounts: [Profile.Network.Account.EntityAddress]?
let changedAccounts: [AccountAddress]?
let poolAddressesToRefresh: [PoolAddress]?
do {
let manifest = intent.manifest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ extension AccountPortfoliosClient: DependencyKey {

/// Fetches the pool and stake units details for a given account; Will update the portfolio accordingly
@Sendable
func fetchPoolAndStakeUnitsDetails(_ account: OnLedgerEntity.Account, cachingStrategy: OnLedgerEntitiesClient.CachingStrategy) async {
func fetchPoolAndStakeUnitsDetails(_ account: OnLedgerEntity.OnLedgerAccount, cachingStrategy: OnLedgerEntitiesClient.CachingStrategy) async {
async let poolDetailsFetch = Task {
do {
let poolUnitDetails = try await onLedgerEntitiesClient.getOwnedPoolUnitsDetails(account, cachingStrategy: cachingStrategy)
Expand Down Expand Up @@ -178,7 +178,7 @@ extension AccountPortfoliosClient: DependencyKey {
}()
}

extension OnLedgerEntity.Account {
extension OnLedgerEntity.OnLedgerAccount {
/// The resources which can have prices
fileprivate var resourcesWithPrices: [ResourceAddress] {
allFungibleResourceAddresses + poolUnitResources.poolUnits.flatMap(\.poolResources)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import Foundation
// MARK: - Definition
extension AccountPortfoliosClient {
public struct AccountPortfolio: Sendable, Hashable, CustomDebugStringConvertible {
public var account: OnLedgerEntity.Account
public var account: OnLedgerEntity.OnLedgerAccount
public var poolUnitDetails: Loadable<[OnLedgerEntitiesClient.OwnedResourcePoolDetails]> = .idle
public var stakeUnitDetails: Loadable<IdentifiedArrayOf<OnLedgerEntitiesClient.OwnedStakeDetails>> = .idle

Expand All @@ -25,13 +25,13 @@ extension AccountPortfoliosClient {

// Useful for DEBUG mode, when we want to display proper resources fiat worth on mainnet
// but use random prices on testnets; as one resources from mainnet have prices.
var gateway: Radix.Gateway = .mainnet
var gateway: Gateway = .mainnet
}
}

// MARK: - Portfolio Setters/Getters
extension AccountPortfoliosClient.State {
func setRadixGateway(_ gateway: Radix.Gateway) {
func setRadixGateway(_ gateway: Gateway) {
self.gateway = gateway
}

Expand Down Expand Up @@ -127,7 +127,7 @@ extension AccountPortfoliosClient.State {

// MARK: - Stake and Pool details handling
extension AccountPortfoliosClient.State {
func calculateWorth(_ gateway: Radix.Gateway) -> (ResourceAddress, ResourceAmount) -> FiatWorth? {
func calculateWorth(_ gateway: Gateway) -> (ResourceAddress, ResourceAmount) -> FiatWorth? {
{ resourceAddress, amount in
let price = {
#if DEBUG
Expand Down
28 changes: 11 additions & 17 deletions RadixWallet/Clients/AccountsClient/AccountsClient+Interface.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import IdentifiedCollections
import Sargon

// MARK: - AccountsClient
public struct AccountsClient: Sendable {
public var getCurrentNetworkID: GetCurrentNetworkID
Expand Down Expand Up @@ -95,29 +98,27 @@ public struct AccountsClient: Sendable {
}

extension AccountsClient {
public typealias Accounts = IdentifiedArrayOf<Profile.Network.Account>

public typealias GetCurrentNetworkID = @Sendable () async -> NetworkID

public typealias NextAppearanceID = @Sendable (NetworkID?, _ offset: Int?) async -> Profile.Network.Account.AppearanceID
public typealias NextAppearanceID = @Sendable (NetworkID?, _ offset: Int?) async -> AppearanceID

public typealias GetAccountsOnCurrentNetwork = @Sendable () async throws -> Accounts
public typealias GetHiddenAccountsOnCurrentNetwork = @Sendable () async throws -> Accounts
public typealias GetAccountsOnNetwork = @Sendable (NetworkID) async throws -> Accounts

public typealias AccountsOnCurrentNetwork = @Sendable () async -> AnyAsyncSequence<Accounts>
public typealias AccountUpdates = @Sendable (AccountAddress) async -> AnyAsyncSequence<Profile.Network.Account>
public typealias AccountUpdates = @Sendable (AccountAddress) async -> AnyAsyncSequence<Account>

public typealias NewVirtualAccount = @Sendable (NewAccountRequest) async throws -> Profile.Network.Account
public typealias SaveVirtualAccounts = @Sendable ([Profile.Network.Account]) async throws -> Void
public typealias NewVirtualAccount = @Sendable (NewAccountRequest) async throws -> Account
public typealias SaveVirtualAccounts = @Sendable (Accounts) async throws -> Void

public typealias GetAccountByAddress = @Sendable (AccountAddress) async throws -> Profile.Network.Account
public typealias GetAccountByAddress = @Sendable (AccountAddress) async throws -> Account

public typealias HasAccountOnNetwork = @Sendable (NetworkID) async throws -> Bool

public typealias UpdateAccount = @Sendable (Profile.Network.Account) async throws -> Void
public typealias UpdateAccount = @Sendable (Account) async throws -> Void
#if DEBUG
public typealias DebugOnlyDeleteAccount = @Sendable (Profile.Network.Account) async throws -> Void
public typealias DebugOnlyDeleteAccount = @Sendable (Account) async throws -> Void
#endif
}

Expand All @@ -135,14 +136,7 @@ public struct NewAccountRequest: Sendable, Hashable {

extension AccountsClient {
/// Saves a virtual account into the profile.
public func saveVirtualAccount(_ account: Profile.Network.Account) async throws {
public func saveVirtualAccount(_ account: Account) async throws {
try await saveVirtualAccounts([account])
}
}

// FIXME: Delete this TEMPORARY bridge, once Wallet uses Sargon Profile!
extension AccountsClient {
public func fromSargon(_ sargonAccount: Sargon.Account) async throws -> Profile.Network.Account {
try await getAccountByAddress(sargonAccount.address)
}
}
14 changes: 9 additions & 5 deletions RadixWallet/Clients/AccountsClient/AccountsClient+Live.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ extension AccountsClient: DependencyKey {
}
}

let getCurrentNetworkID: GetCurrentNetworkID = { await profileStore.profile.networkID }
let getCurrentNetworkID: GetCurrentNetworkID = {
await profileStore.profile.networkID
}

let getAccountsOnNetwork: GetAccountsOnNetwork = {
try await profileStore.profile.network(id: $0).getAccounts()
Expand All @@ -29,7 +31,7 @@ extension AccountsClient: DependencyKey {
let currentNetworkID = await getCurrentNetworkID()
let networkID = maybeNetworkID ?? currentNetworkID
let numberOfAccounts = await (try? profileStore.profile.network(id: networkID).numberOfAccountsIncludingHidden) ?? 0
return Profile.Network.Account.AppearanceID.fromNumberOfAccounts(numberOfAccounts + offset)
return AppearanceID.fromNumberOfAccounts(numberOfAccounts + offset)
}

let hasAccountOnNetwork: HasAccountOnNetwork = { networkID in
Expand All @@ -46,7 +48,9 @@ extension AccountsClient: DependencyKey {
try await profileStore.profile.network(id: getCurrentNetworkID()).getHiddenAccounts()
}

let accountsOnCurrentNetwork: AccountsOnCurrentNetwork = { await profileStore.accountValues() }
let accountsOnCurrentNetwork: AccountsOnCurrentNetwork = {
await profileStore.accountValues()
}

let accountUpdates: AccountUpdates = { address in
await profileStore.accountValues().compactMap {
Expand All @@ -58,10 +62,10 @@ extension AccountsClient: DependencyKey {
let newVirtualAccount: NewVirtualAccount = { request in
let networkID = request.networkID
let appearanceID = await nextAppearanceID(networkID, nil)
return try Profile.Network.Account(
return Account(
networkID: networkID,
factorInstance: request.factorInstance,
displayName: request.name,
displayName: DisplayName(nonEmpty: request.name),
extraProperties: .init(appearanceID: appearanceID)
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ extension AccountsClient: TestDependencyKey {
#if DEBUG
public static let noop = Self(
getCurrentNetworkID: { .kisharnet },
nextAppearanceID: { _, _ in ._0 },
nextAppearanceID: { _, _ in .sample },
getAccountsOnCurrentNetwork: { throw NoopError() },
getHiddenAccountsOnCurrentNetwork: { throw NoopError() },
accountsOnCurrentNetwork: { AsyncLazySequence([]).eraseToAnyAsyncSequence() },
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import Sargon

// MARK: - AppPreferencesClient
public struct AppPreferencesClient: Sendable {
public var appPreferenceUpdates: AppPreferenceUpdates
Expand All @@ -12,24 +14,20 @@ public struct AppPreferencesClient: Sendable {
public var extractProfileSnapshot: ExtractProfileSnapshot
public var deleteProfileAndFactorSources: DeleteProfileSnapshot

public var getDetailsOfSecurityStructure: GetDetailsOfSecurityStructure

public init(
appPreferenceUpdates: @escaping AppPreferenceUpdates,
getPreferences: @escaping GetPreferences,
updatePreferences: @escaping UpdatePreferences,
extractProfileSnapshot: @escaping ExtractProfileSnapshot,
deleteProfileAndFactorSources: @escaping DeleteProfileSnapshot,
setIsCloudProfileSyncEnabled: @escaping SetIsCloudProfileSyncEnabled,
getDetailsOfSecurityStructure: @escaping GetDetailsOfSecurityStructure
setIsCloudProfileSyncEnabled: @escaping SetIsCloudProfileSyncEnabled
) {
self.appPreferenceUpdates = appPreferenceUpdates
self.getPreferences = getPreferences
self.updatePreferences = updatePreferences
self.extractProfileSnapshot = extractProfileSnapshot
self.deleteProfileAndFactorSources = deleteProfileAndFactorSources
self.setIsCloudProfileSyncEnabled = setIsCloudProfileSyncEnabled
self.getDetailsOfSecurityStructure = getDetailsOfSecurityStructure
}
}

Expand All @@ -39,9 +37,8 @@ extension AppPreferencesClient {
public typealias SetIsCloudProfileSyncEnabled = @Sendable (Bool) async throws -> Void
public typealias GetPreferences = @Sendable () async -> AppPreferences
public typealias UpdatePreferences = @Sendable (AppPreferences) async throws -> Void
public typealias ExtractProfileSnapshot = @Sendable () async -> ProfileSnapshot
public typealias ExtractProfileSnapshot = @Sendable () async -> Profile
public typealias DeleteProfileSnapshot = @Sendable (_ keepInICloudIfPresent: Bool) async throws -> Void
public typealias GetDetailsOfSecurityStructure = @Sendable (SecurityStructureConfigurationReference) async throws -> SecurityStructureConfigurationDetailed
}

extension AppPreferencesClient {
Expand All @@ -59,7 +56,7 @@ extension AppPreferencesClient {
}

public func updatingDisplay<T>(
_ mutateDisplay: @Sendable (inout AppPreferences.Display) throws -> T
_ mutateDisplay: @Sendable (inout AppDisplay) throws -> T
) async throws -> T {
try await updating { preferences in
try mutateDisplay(&preferences.display)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,16 @@ extension AppPreferencesClient: DependencyKey {
appPreferenceUpdates: {
await profileStore.appPreferencesValues()
},
getPreferences: { await profileStore.profile.appPreferences },
getPreferences: {
await profileStore.profile.appPreferences
},
updatePreferences: { newPreferences in
try await profileStore.updating {
$0.appPreferences = newPreferences
}
},
extractProfileSnapshot: {
await profileStore.profile.snapshot()
await profileStore.profile
},
deleteProfileAndFactorSources: { keepInICloudIfPresent in
try await profileStore.deleteProfile(keepInICloudIfPresent: keepInICloudIfPresent)
Expand All @@ -33,9 +35,6 @@ extension AppPreferencesClient: DependencyKey {
profile.id,
isEnabled ? .enable : .disable
)
},
getDetailsOfSecurityStructure: { configRef in
try await profileStore.profile.detailedSecurityStructureConfiguration(reference: configRef)
}
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ extension AppPreferencesClient: TestDependencyKey {
updatePreferences: unimplemented("\(Self.self).updatePreferences"),
extractProfileSnapshot: unimplemented("\(Self.self).extractProfileSnapshot"),
deleteProfileAndFactorSources: unimplemented("\(Self.self).deleteProfileAndFactorSources"),
setIsCloudProfileSyncEnabled: unimplemented("\(Self.self).setIsCloudProfileSyncEnabled"),
getDetailsOfSecurityStructure: unimplemented("\(Self.self).getDetailsOfSecurityStructure")
setIsCloudProfileSyncEnabled: unimplemented("\(Self.self).setIsCloudProfileSyncEnabled")
)
}

Expand All @@ -20,7 +19,6 @@ extension AppPreferencesClient {
updatePreferences: { _ in },
extractProfileSnapshot: { fatalError() },
deleteProfileAndFactorSources: { _ in },
setIsCloudProfileSyncEnabled: { _ in },
getDetailsOfSecurityStructure: { _ in throw NoopError() }
setIsCloudProfileSyncEnabled: { _ in }
)
}
Loading

0 comments on commit 427f39d

Please sign in to comment.