Skip to content

Unit tests #9

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
.DS_Store
.swiftpm
.build
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,4 @@ class ExampleInstrumentedTest {
.map { it.toInt(16).toByte() }
.toByteArray()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,4 @@ class KeyManagerTest {
assertTrue(KeyManager.deleteEntry("test_prefix"))
assertFalse(KeyManager.deleteEntry("nonexistent"))
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ class ExampleUnitTest {
fun addition_isCorrect() {
assertEquals(4, 2 + 2)
}
}
}
105 changes: 56 additions & 49 deletions Package.resolved
Original file line number Diff line number Diff line change
@@ -1,52 +1,59 @@
{
"object": {
"pins": [
{
"package": "BigInt",
"repositoryURL": "https://github.com/attaswift/BigInt.git",
"state": {
"branch": null,
"revision": "0ed110f7555c34ff468e72e1686e59721f2b0da6",
"version": "5.3.0"
}
},
{
"package": "Flow",
"repositoryURL": "https://github.com/outblock/flow-swift.git",
"state": {
"branch": null,
"revision": "50b60826c4ce18adaa151946d11d468ac1fc98dd",
"version": "0.3.9"
}
},
{
"package": "KeychainAccess",
"repositoryURL": "https://github.com/kishikawakatsumi/KeychainAccess",
"state": {
"branch": null,
"revision": "84e546727d66f1adc5439debad16270d0fdd04e7",
"version": "4.2.2"
}
},
{
"package": "SwiftFormat",
"repositoryURL": "https://github.com/nicklockwood/SwiftFormat",
"state": {
"branch": null,
"revision": "fef156a6135e584985ed26713dd2e9ee41f952cb",
"version": "0.53.0"
}
},
{
"package": "WalletCore",
"repositoryURL": "https://github.com/Outblock/wallet-core",
"state": {
"branch": "master",
"revision": "24497b1e6f34f171ad421dae8699758bda09e78d",
"version": null
}
"pins" : [
{
"identity" : "bigint",
"kind" : "remoteSourceControl",
"location" : "https://github.com/attaswift/BigInt.git",
"state" : {
"revision" : "0ed110f7555c34ff468e72e1686e59721f2b0da6",
"version" : "5.3.0"
}
]
},
"version": 1
},
{
"identity" : "factory",
"kind" : "remoteSourceControl",
"location" : "https://github.com/hmlongco/Factory.git",
"state" : {
"revision" : "fb04a8918848e413d3921d346a23bae7f81088d9",
"version" : "2.4.3"
}
},
{
"identity" : "flow-swift",
"kind" : "remoteSourceControl",
"location" : "https://github.com/outblock/flow-swift.git",
"state" : {
"revision" : "50b60826c4ce18adaa151946d11d468ac1fc98dd",
"version" : "0.3.9"
}
},
{
"identity" : "keychainaccess",
"kind" : "remoteSourceControl",
"location" : "https://github.com/kishikawakatsumi/KeychainAccess",
"state" : {
"revision" : "84e546727d66f1adc5439debad16270d0fdd04e7",
"version" : "4.2.2"
}
},
{
"identity" : "swiftformat",
"kind" : "remoteSourceControl",
"location" : "https://github.com/nicklockwood/SwiftFormat",
"state" : {
"revision" : "fef156a6135e584985ed26713dd2e9ee41f952cb",
"version" : "0.53.0"
}
},
{
"identity" : "wallet-core",
"kind" : "remoteSourceControl",
"location" : "https://github.com/Outblock/wallet-core",
"state" : {
"branch" : "master",
"revision" : "24497b1e6f34f171ad421dae8699758bda09e78d"
}
}
],
"version" : 2
}
10 changes: 7 additions & 3 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version: 5.5
// swift-tools-version: 5.7
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd recomend bumping this to 6.0 since it's a new project, and there was only one error I saw when changing it (Flow.Address needs to be Sendable)

// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription
Expand All @@ -17,8 +17,9 @@ let package = Package(
dependencies: [
.package(url: "https://github.com/kishikawakatsumi/KeychainAccess", from: "4.2.2"),
.package(url: "https://github.com/outblock/flow-swift.git", from: "0.3.9"),
.package(url: "https://github.com/Outblock/wallet-core", .branchItem("master")),
.package(url: "https://github.com/Outblock/wallet-core", branch: "master"),
.package(url: "https://github.com/nicklockwood/SwiftFormat", from: "0.50.4"),
.package(url: "https://github.com/hmlongco/Factory.git", from: "2.4.3")
],
targets: [
.target(
Expand All @@ -28,12 +29,15 @@ let package = Package(
.product(name: "Flow", package: "flow-swift"),
.product(name: "WalletCore", package: "wallet-core"),
.product(name: "WalletCoreSwiftProtobuf", package: "wallet-core"),
.product(name: "Factory", package: "Factory")
],
path: "iOS/FlowWalletKit/Sources"
),
.testTarget(
name: "FlowWalletKitTests",
dependencies: ["FlowWalletKit"],
dependencies: [
"FlowWalletKit"
],
path: "iOS/FlowWalletKit/Tests"
),
]
Expand Down
2 changes: 1 addition & 1 deletion iOS/FlowWalletKit/Sources/Crypto/BIP39.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import Foundation
import WalletCore

public enum BIP39 {
public enum SeedPhraseLength: Int,Codable {
public enum SeedPhraseLength: Int, Codable, Sendable {
case twelve = 12
case fifteen = 15
case twentyFour = 24
Expand Down
15 changes: 15 additions & 0 deletions iOS/FlowWalletKit/Sources/DI/Container.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//
// Container.swift
// FlowWalletKit
//
// Created by Marty Ulrich on 3/24/25.
//

import Factory
import Foundation

extension Container {
var keychainStorage: Factory<StorageProtocol> {
self { KeychainStorage(service: Bundle.main.bundleIdentifier!, label: "keychain", synchronizable: false) }
}
}
30 changes: 0 additions & 30 deletions iOS/FlowWalletKit/Sources/FWKManager.swift

This file was deleted.

18 changes: 7 additions & 11 deletions iOS/FlowWalletKit/Sources/Keys/KeyProtocol.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ public protocol KeyProtocol: Identifiable {

var keyType: KeyType { get }

var storage: StorageProtocol { set get }
var storage: StorageProtocol { get }

static func create(_ advance: Advance, storage: StorageProtocol) throws -> Key
static func create(storage: StorageProtocol) throws -> Key
static func createAndStore(id: String, password: String, storage: StorageProtocol) throws -> Key
static func get(id: String, password: String, storage: StorageProtocol) throws -> Key
static func restore(secret: Secret, storage: StorageProtocol) throws -> Key
static func create(_ advance: Advance) throws -> Key
static func create() throws -> Key
static func createAndStore(id: String, password: String) throws -> Key
static func get(id: String, password: String) throws -> Key
static func restore(secret: Secret) throws -> Key

func store(id: String, password: String) throws
func isValidSignature(signature: Data, message: Data, signAlgo: Flow.SignatureAlgorithm) -> Bool
Expand All @@ -42,10 +42,6 @@ public protocol KeyProtocol: Identifiable {
}

public extension KeyProtocol {
var storage: StorageProtocol {
FWKManager.shared.storage
}

var id: String {
if let data = publicKey(signAlgo: .ECDSA_P256) {
return data.hexString
Expand All @@ -66,7 +62,7 @@ public extension KeyProtocol {
storage.allKeys
}

static func create(_: Advance, storage _: any StorageProtocol) throws -> Key {
static func create(_: Advance) throws -> Key {
throw WalletError.noImplement
}
}
Loading