Skip to content
This repository was archived by the owner on Mar 26, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Features/Onboarding/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ let package = Package(
dependencies: [
"Onboarding",
.product(name: "WalletServiceTestKit", package: "FeatureServices"),
.product(name: "KeystoreTestKit", package: "Keystore"),
.product(name: "NameServiceTestKit", package: "ChainServices"),
.product(name: "StoreTestKit", package: "Store"),
],
path: "Tests"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ extension CreateWalletModel {
source: .create
)
walletService.acceptTerms()
WalletPreferences(walletId: wallet.walletId).completeInitialSynchronization()
return wallet
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import Primitives
import WalletService
import AvatarService
import PrimitivesComponents
import Preferences
import enum Keystore.KeystoreImportType

@Observable
Expand Down Expand Up @@ -51,7 +50,6 @@ extension ImportWalletViewModel {
func importWallet(data: WalletImportData) async throws -> Wallet {
let wallet = try await walletService.loadOrCreateWallet(name: data.name, type: data.keystoreType, source: .import)
walletService.acceptTerms()
WalletPreferences(walletId: wallet.walletId).completeInitialSynchronization()
try await walletService.setCurrent(wallet: wallet)
return wallet
}
Expand Down
30 changes: 30 additions & 0 deletions Features/Onboarding/Tests/CreateWalletModelTests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// Copyright (c). Gem Wallet. All rights reserved.

import Foundation
import Testing
import Preferences
import Keystore
import KeystoreTestKit
import StoreTestKit
import WalletServiceTestKit

@testable import Onboarding

@MainActor
struct CreateWalletModelTests {

@Test
func createWalletSetsAddressStatus() async throws {
let model = CreateWalletModel(
walletService: .mock(keystore: KeystoreMock()),
avatarService: .init(store: .mock()),
onComplete: nil
)

let wallet = try await model.createWallet(words: LocalKeystore.words)
let preferences = WalletPreferences(walletId: wallet.walletId)

#expect(preferences.completeInitialAddressStatus)
#expect(preferences.completeInitialLoadAssets)
}
}
35 changes: 35 additions & 0 deletions Features/Onboarding/Tests/ImportWalletViewModelTests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// Copyright (c). Gem Wallet. All rights reserved.

import Foundation
import Testing
import Preferences
import Keystore
import KeystoreTestKit
import NameServiceTestKit
import StoreTestKit
import WalletServiceTestKit

@testable import Onboarding

@MainActor
struct ImportWalletViewModelTests {

@Test
func importWalletDoesNotSetAddressStatus() async throws {
let model = ImportWalletViewModel(
walletService: .mock(keystore: KeystoreMock()),
avatarService: .init(store: .mock()),
nameService: .mock(),
onComplete: nil
)

let wallet = try await model.importWallet(data: WalletImportData(
name: "Test",
keystoreType: .phrase(words: LocalKeystore.words, chains: [.tron])
))
let preferences = WalletPreferences(walletId: wallet.walletId)

#expect(preferences.completeInitialAddressStatus == false)
#expect(preferences.completeInitialLoadAssets == false)
}
}
4 changes: 0 additions & 4 deletions Packages/Preferences/Sources/WalletPreferences.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,6 @@ public final class WalletPreferences: @unchecked Sendable {
get { defaults.bool(forKey: Keys.completeInitialAddressStatus) }
}

public var isCompleteInitialSynchronization: Bool {
completeInitialAddressStatus && completeInitialLoadAssets
}

public func completeInitialSynchronization() {
completeInitialAddressStatus = true
completeInitialLoadAssets = true
Expand Down
Loading