diff --git a/Sources/XyoClient/Address/AccountServices.swift b/Sources/XyoClient/Address/AccountServices.swift index d3b1a57..c58cd2a 100644 --- a/Sources/XyoClient/Address/AccountServices.swift +++ b/Sources/XyoClient/Address/AccountServices.swift @@ -1,7 +1,7 @@ import Foundation public class AccountServices { - func getNamedAccount(name: String = "default") -> AccountInstance { + public static func getNamedAccount(name: String = "default") -> AccountInstance { // let _ = removeFromKeychain(key: name) if let existingAccount = getStoredAccount(name: name) { return existingAccount @@ -18,7 +18,7 @@ public class AccountServices { } } - private func getStoredAccount(name: String) -> AccountInstance? { + private static func getStoredAccount(name: String) -> AccountInstance? { // Lookup previously saved private key if it exists if let storedPrivateKeyString = getFromKeychain(key: name) { if let parsedPrivateKeyData = Data.dataFrom(hexString: storedPrivateKeyString) { diff --git a/Tests/XyoClientTests/AccountServices.swift b/Tests/XyoClientTests/AccountServices.swift index c813712..426e529 100644 --- a/Tests/XyoClientTests/AccountServices.swift +++ b/Tests/XyoClientTests/AccountServices.swift @@ -16,11 +16,8 @@ class AccountServicesTests: XCTestCase { ] func testGetNamedAccount_CreatesAndReturnsNewAccount_WhenNoExistingAccount() { - - let accountServices = AccountServices() - // Act - let account = accountServices.getNamedAccount(name: "testAccount") + let account = AccountServices.getNamedAccount(name: "testAccount") // Assert XCTAssertNotNil(account) @@ -28,13 +25,11 @@ class AccountServicesTests: XCTestCase { } func testGetNamedAccount_ReturnsExistingAccount_WhenAccountExists() { - let accountServices = AccountServices() - // Act // Initial attempt create account - let accountA = accountServices.getNamedAccount(name: "testAccount") + let accountA = AccountServices.getNamedAccount(name: "testAccount") // Subsequent ones retrieve account - let accountB = accountServices.getNamedAccount(name: "testAccount") + let accountB = AccountServices.getNamedAccount(name: "testAccount") // Asserts let addressA = accountA.address