Skip to content

Commit

Permalink
[ABW-4051] API to perform Spot Check (#372)
Browse files Browse the repository at this point in the history
* new ctor for MnemonicWithPasswphrase without latter

* WIP

* WIP

* send FactorSource to interactor

* updates to make it work with Android

* update with new behavior

* rename and add docs

* changes after feedback

* Release 1.1.134

[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]

Generated by cargo-workspaces
  • Loading branch information
matiasbzurovski authored Feb 10, 2025
1 parent a18623a commit 72766db
Show file tree
Hide file tree
Showing 102 changed files with 840 additions and 166 deletions.
168 changes: 84 additions & 84 deletions Cargo.lock

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ import Foundation
import SargonUniFFI

extension MnemonicWithPassphrase {
public init(mnemonic: Mnemonic) {
self.init(mnemonic: mnemonic, passphrase: "")
}

public init(jsonData: some DataProtocol) throws {
self = try newMnemonicWithPassphraseFromJsonBytes(
jsonBytes: Data(jsonData)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,8 @@ extension FactorSource {
public var name: String {
factorSourceName(factorSource: self)
}

public func spotCheck(input: SpotCheckInput) -> Bool {
factorSourcePerformSpotCheck(factorSource: self, input: input)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,15 @@ extension FactorSourceID {
public func toString() -> String {
factorSourceIdToString(factorSourceId: self)
}

public var kind: FactorSourceKind {
switch self {
case let .hash(value):
value.kind
}
}

public func spotCheck(input: SpotCheckInput) -> Bool {
factorSourceIdPerformSpotCheck(factorSourceId: self, input: input)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,8 @@ extension FactorSourceIDFromHash {
public func toString() -> String {
factorSourceIdFromHashToString(factorSourceId: self)
}

public func spotCheck(input: SpotCheckInput) -> Bool {
factorSourceIdFromHashPerformSpotCheck(factorSourceIdFromHash: self, input: input)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,8 @@ public class ThrowingHostInteractor: HostInteractor {
public func requestAuthorization(purpose: SargonUniFFI.AuthorizationPurpose) async -> SargonUniFFI.AuthorizationResponse {
.rejected
}

public func spotCheck(factorSource: FactorSource, allowSkip: Bool) async throws -> SpotCheckResponse {
throw CommonError.HostInteractionAborted
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,9 @@ final class MnemonicWithPassphraseTests: Test<MnemonicWithPassphrase> {
func testJSONRoundtripAllSamples() throws {
try eachSampleCodableRoundtripTest()
}

func testInitWithoutPaspshrase() {
let sut = SUT(mnemonic: .sample)
XCTAssertEqual(sut.passphrase, "")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,9 @@ final class FactorSourceIDFromHashTests: SpecificFactorSourceIDTest<FactorSource
// XCTAssertThrowsError(try sut.asGeneral.extract(as: FactorSourceIDFromAddress.self))
// }
// }

func test_spot_check() {
let input = SpotCheckInput.software(mnemonicWithPassphrase: .sample)
XCTAssertTrue(SUT.sample.spotCheck(input: input))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,9 @@ final class FactorSourceIDTests: FactorSourceIDTest<FactorSourceID> {
XCTAssertEqual(sut.asGeneral, sut)
}
}

func test_spot_check() {
let input = SpotCheckInput.software(mnemonicWithPassphrase: .sample)
XCTAssertTrue(SUT.sample.spotCheck(input: input))
}
}
5 changes: 5 additions & 0 deletions apple/Tests/TestCases/Profile/Factor/FactorSourceTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,9 @@ final class FactorSourceTests: FactorSourceTest<FactorSource> {
func test_name() {
XCTAssertEqual(SUT.sample.name, "My Phone")
}

func test_spot_check() {
let input = SpotCheckInput.software(mnemonicWithPassphrase: .sample)
XCTAssertTrue(SUT.sample.spotCheck(input: input))
}
}
2 changes: 1 addition & 1 deletion crates/app/home-cards/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "home-cards"
version = "1.1.133"
version = "1.1.134"
edition = "2021"

[dependencies]
Expand Down
2 changes: 1 addition & 1 deletion crates/app/key-derivation-traits/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "key-derivation-traits"
version = "1.1.133"
version = "1.1.134"
edition = "2021"

[dependencies]
Expand Down
2 changes: 1 addition & 1 deletion crates/app/radix-connect-models/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "radix-connect-models"
version = "1.1.133"
version = "1.1.134"
edition = "2021"

[dependencies]
Expand Down
2 changes: 1 addition & 1 deletion crates/app/radix-connect/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "radix-connect"
version = "1.1.133"
version = "1.1.134"
edition = "2021"


Expand Down
2 changes: 1 addition & 1 deletion crates/app/security-center/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "security-center"
version = "1.1.133"
version = "1.1.134"
edition = "2021"

[dependencies]
Expand Down
2 changes: 1 addition & 1 deletion crates/app/signing-traits/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "signing-traits"
version = "1.1.133"
version = "1.1.134"
edition = "2021"

[dependencies]
Expand Down
2 changes: 1 addition & 1 deletion crates/common/build-info/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "build-info"
version = "1.1.133"
version = "1.1.134"
edition = "2021"
build = "build.rs"

Expand Down
2 changes: 1 addition & 1 deletion crates/common/bytes/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "bytes"
version = "1.1.133"
version = "1.1.134"
edition = "2021"

[dependencies]
Expand Down
2 changes: 1 addition & 1 deletion crates/common/entity-foundation/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "entity-foundation"
version = "1.1.133"
version = "1.1.134"
edition = "2021"

[dependencies]
Expand Down
2 changes: 1 addition & 1 deletion crates/common/host-info/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "host-info"
version = "1.1.133"
version = "1.1.134"
edition = "2021"

[dependencies]
Expand Down
2 changes: 1 addition & 1 deletion crates/common/identified-vec-of/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "identified-vec-of"
version = "1.1.133"
version = "1.1.134"
edition = "2021"

[dependencies]
Expand Down
2 changes: 1 addition & 1 deletion crates/common/metadata/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "metadata"
version = "1.1.133"
version = "1.1.134"
edition = "2021"

[dependencies]
Expand Down
2 changes: 1 addition & 1 deletion crates/common/network/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "network"
version = "1.1.133"
version = "1.1.134"
edition = "2021"

[dependencies]
Expand Down
2 changes: 1 addition & 1 deletion crates/common/numeric/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "numeric"
version = "1.1.133"
version = "1.1.134"
edition = "2021"

[dependencies]
Expand Down
2 changes: 1 addition & 1 deletion crates/common/short-string/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "short-string"
version = "1.1.133"
version = "1.1.134"
edition = "2021"

[dependencies]
Expand Down
2 changes: 1 addition & 1 deletion crates/core/assert-json/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "assert-json"
version = "1.1.133"
version = "1.1.134"
edition = "2021"

[dependencies]
Expand Down
2 changes: 1 addition & 1 deletion crates/core/collections/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "core-collections"
version = "1.1.133"
version = "1.1.134"
edition = "2021"

[dependencies]
Expand Down
2 changes: 1 addition & 1 deletion crates/core/error/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "error"
version = "1.1.133"
version = "1.1.134"
edition = "2021"

[dependencies]
Expand Down
2 changes: 1 addition & 1 deletion crates/core/has-sample-values/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "has-sample-values"
version = "1.1.133"
version = "1.1.134"
edition = "2021"

[dependencies]
Expand Down
2 changes: 1 addition & 1 deletion crates/core/misc/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "core-misc"
version = "1.1.133"
version = "1.1.134"
edition = "2021"

[dependencies]
Expand Down
2 changes: 1 addition & 1 deletion crates/core/prelude/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "prelude"
version = "1.1.133"
version = "1.1.134"
edition = "2021"

[dependencies]
Expand Down
2 changes: 1 addition & 1 deletion crates/core/time-utils/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "time-utils"
version = "1.1.133"
version = "1.1.134"
edition = "2021"

[dependencies]
Expand Down
2 changes: 1 addition & 1 deletion crates/core/utils/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "core-utils"
version = "1.1.133"
version = "1.1.134"
edition = "2021"

[dependencies]
Expand Down
2 changes: 1 addition & 1 deletion crates/crypto/addresses/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "addresses"
version = "1.1.133"
version = "1.1.134"
edition = "2021"

[dependencies]
Expand Down
2 changes: 1 addition & 1 deletion crates/crypto/cap26-models/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "cap26-models"
version = "1.1.133"
version = "1.1.134"
edition = "2021"

[dependencies]
Expand Down
2 changes: 1 addition & 1 deletion crates/crypto/ecc/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ecc"
version = "1.1.133"
version = "1.1.134"
edition = "2021"

[dependencies]
Expand Down
2 changes: 1 addition & 1 deletion crates/crypto/encryption/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "encryption"
version = "1.1.133"
version = "1.1.134"
edition = "2021"

[dependencies]
Expand Down
2 changes: 1 addition & 1 deletion crates/crypto/hash/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "hash"
version = "1.1.133"
version = "1.1.134"
edition = "2021"

[dependencies]
Expand Down
2 changes: 1 addition & 1 deletion crates/crypto/hd/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "hierarchical-deterministic"
version = "1.1.133"
version = "1.1.134"
edition = "2021"

[dependencies]
Expand Down
2 changes: 1 addition & 1 deletion crates/factors/factors/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "factors"
version = "1.1.133"
version = "1.1.134"
edition = "2021"

[dependencies]
Expand Down
Loading

0 comments on commit 72766db

Please sign in to comment.