Skip to content

Commit

Permalink
Batch 8: DeviceFactorSource + `PrivateHierarchicalDeterministicFact…
Browse files Browse the repository at this point in the history
…orSource` and some `BIP39*` types. (#97)
  • Loading branch information
CyonAlexRDX authored Apr 23, 2024
1 parent 5ccf175 commit d6e3c90
Show file tree
Hide file tree
Showing 100 changed files with 1,765 additions and 308 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "sargon"
version = "0.6.41"
version = "0.6.42"
edition = "2021"
build = "build.rs"

Expand Down Expand Up @@ -141,6 +141,7 @@ k256 = { git = "https://github.com/RustCrypto/elliptic-curves", rev = "e158ce5cf
bip39 = { git = "https://github.com/rust-bitcoin/rust-bip39", rev = "a30760beac21d595b2bda376df4f4e6bf029bcc5", features = [
"serde",
"zeroize",
"french",
] }

# assert-json-diff = "2.0.2"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//
// File.swift
//
//
// Created by Alexander Cyon on 2024-04-22.
//

import Foundation
import SargonUniFFI

extension BIP39Language {
public func wordlist() -> [BIP39Word] {
bip39LanguageWordlist(language: self)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//
// File.swift
//
//
// Created by Alexander Cyon on 2024-04-22.
//

import Foundation
import SargonUniFFI

extension BIP39WordCount {
public static var allCases: [Self] {
bip39WordCountAll()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,16 @@ import Foundation
import SargonUniFFI

extension DerivationPath {
public var path: HdPath {
public var path: HDPath {
derivationPathToHdPath(path: self)
}

public func toString() -> String {
derivationPathToString(path: self)
}

public init(string: String) throws {
self = try newDerivationPathFromString(string: string)
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,15 @@ extension DataProtocol {
}

extension Hash {
public func hash() -> Self {
data.hash()
}
}

extension Hash {
public var data: Data {
bytes.data
}

public var bytes: Exactly32Bytes {
hashGetBytes(hash: self)
}

public init(string: String) throws {
self = try newHashFromString(string: string)
}

public init(bytes32: Exactly32Bytes) {
self = newHashFromBytes(bytes: bytes32)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
//
// File.swift
//
//
// Created by Alexander Cyon on 2024-04-22.
//

import Foundation
import SargonUniFFI

extension PrivateHierarchicalDeterministicFactorSource {

public static func olympia(
mnemonicWithPassphrase: MnemonicWithPassphrase
) -> Self {
newPrivateHdFactorSourceOlympiaFromMnemonicWithPassphrase(
mnemonicWithPassphrase: mnemonicWithPassphrase,
walletClientModel: .iphone
)
}

public static func babylon(
isMainBDFS: Bool,
mnemonicWithPassphrase: MnemonicWithPassphrase
) -> Self {
newPrivateHdFactorSourceBabylonFromMnemonicWithPassphrase(
isMain: isMainBDFS,
mnemonicWithPassphrase: mnemonicWithPassphrase,
walletClientModel: .iphone
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//
// File.swift
//
//
// Created by Alexander Cyon on 2024-04-22.
//

import Foundation
import SargonUniFFI

extension AppPreferences {
public static let `default`: Self = newAppPreferencesDefault()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
//
// File.swift
//
//
// Created by Alexander Cyon on 2024-04-22.
//

import Foundation
import SargonUniFFI

extension DeviceFactorSource {

public static func olympia(
mnemonicWithPassphrase: MnemonicWithPassphrase
) -> Self {
newDeviceFactorSourceOlympia(
mnemonicWithPassphrase: mnemonicWithPassphrase,
walletClientModel: .iphone
)
}

public static func babylon(
mnemonicWithPassphrase: MnemonicWithPassphrase,
isMain: Bool
) -> Self {
newDeviceFactorSourceBabylon(
isMain: isMain,
mnemonicWithPassphrase: mnemonicWithPassphrase,
walletClientModel: .iphone
)
}


public var isMainBDFS: Bool {
deviceFactorSourceIsMainBdfs(deviceFactorSource: self)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,11 @@ extension FactorSource {
public func toString() -> String {
factorSourceToString(factorSource: self)
}

public var supportsOlympia: Bool {
factorSourceSupportsOlympia(factorSource: self)
}
public var supportsBabylon: Bool {
factorSourceSupportsBabylon(factorSource: self)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//
// File.swift
//
//
// Created by Alexander Cyon on 2024-04-22.
//

import Foundation
import SargonUniFFI

extension FactorSourceKind {

public init(string: String) throws {
self = try newFactorSourceKindFromString(string: string)
}

public func toString() -> String {
factorSourceKindToString(kind: self)
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//
// File.swift
//
//
// Created by Alexander Cyon on 2024-04-22.
//

import Foundation
import SargonUniFFI

extension LedgerHardwareWalletModel {
public init(string: String) throws {
self = try newLedgerHwWalletModelFromString(string: string)
}

public func toString() -> String {
ledgerHwWalletModelToString(model: self)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import SargonUniFFI

#if DEBUG
extension BIP39Language {
public static let sample: Self = newBip39LanguageSample()
public static let sampleOther: Self = newBip39LanguageSampleOther()
}
#endif // DEBUG
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import SargonUniFFI

#if DEBUG
extension Mnemonic {
public static let sample: Self = newMnemonicSample()
public static let sampleOther: Self = newMnemonicSampleOther()

public static let sample24ZooVote: Self = try! Self(phrase: "zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo vote")
}
#endif // DEBUG

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//
// File.swift
//
//
// Created by Alexander Cyon on 2024-04-19.
//

import Foundation
import SargonUniFFI

#if DEBUG
extension AppPreferences {
public static let sample: Self = newAppPreferencesSample()
public static let sampleOther: Self = newAppPreferencesSampleOther()
}
#endif // DEBUG
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//
// File.swift
//
//
// Created by Alexander Cyon on 2024-04-22.
//

import Foundation
import SargonUniFFI

#if DEBUG
extension FactorSourceKind {
public static let sample: Self = newFactorSourceKindSample()
public static let sampleOther: Self = newFactorSourceKindSampleOther()
}
#endif // DEBUG
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import SargonUniFFI

#if DEBUG
extension PrivateHierarchicalDeterministicFactorSource {
public static let sample: Self = newPrivateHdFactorSourceSample()
public static let sampleOther: Self = newPrivateHdFactorSourceSampleOther()
}
#endif // DEBUG
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//
// File.swift
//
//
// Created by Alexander Cyon on 2024-04-22.
//

import Foundation
import SargonUniFFI

#if DEBUG
extension LedgerHardwareWalletModel {
public static let sample: Self = newLedgerHwWalletModelSample()
public static let sampleOther: Self = newLedgerHwWalletModelSampleOther()
}
#endif // DEBUG
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
//
// File.swift
//
//
// Created by Alexander Cyon on 2024-04-22.
//

import Foundation
import SargonUniFFI

public typealias BIP39Language = Bip39Language
extension BIP39Language: SargonModel {}
Loading

0 comments on commit d6e3c90

Please sign in to comment.