Skip to content

Commit

Permalink
Rules for Roles (#286)
Browse files Browse the repository at this point in the history
Implement SecurityShieldBuilder which is UniFFI exported, and all logic needed to power it (rules for roles).
  • Loading branch information
CyonAlexRDX authored Dec 6, 2024
1 parent 8d10a02 commit 5fdde66
Show file tree
Hide file tree
Showing 127 changed files with 12,140 additions and 2,676 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ default_install_hook_types: [pre-push]
default_stages: [pre-push]
repos:
- repo: https://github.com/crate-ci/typos
rev: v1.22.7
rev: v1.28.1
hooks:
- id: typos
- repo: local
Expand Down
34 changes: 22 additions & 12 deletions Cargo.lock

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

Original file line number Diff line number Diff line change
@@ -1,19 +1,2 @@
import Foundation
import SargonUniFFI

extension SecurityStructureOfFactorSources {
public init(
metadata: SecurityStructureMetadata,
numberOfDaysUntilAutoConfirmation: UInt16,
matrixOfFactors: MatrixOfFactorSources
) {
assert(matrixOfFactors.primaryRole.thresholdFactors.count >= matrixOfFactors.primaryRole.threshold)
assert(matrixOfFactors.recoveryRole.thresholdFactors.count >= matrixOfFactors.recoveryRole.threshold)
assert(matrixOfFactors.confirmationRole.thresholdFactors.count >= matrixOfFactors.confirmationRole.threshold)
self = newSecurityStructureOfFactorSourcesAutoInDays(
metadata: metadata,
numberOfDaysUntilAutoConfirmation: numberOfDaysUntilAutoConfirmation,
matrixOfFactors: matrixOfFactors
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ extension TransactionManifest {
}

public var summary: ManifestSummary {
get throws {
try transactionManifestSummary(manifest: self)
}
transactionManifestSummary(manifest: self)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import SargonUniFFI

extension SecurityShieldBuilder {
public typealias Factor = FactorSourceID

/// Confirmation Role
public var numberOfDaysUntilAutoConfirm: UInt16 {
get { getNumberOfDaysUntilAutoConfirm() }
set {
precondition(newValue > 0, "Number of days until auto confirm must be greater than zero.")
setNumberOfDaysUntilAutoConfirm(numberOfDays: UInt16(newValue))
}
}

public var threshold: UInt8 {
get { getPrimaryThreshold() }
set { setThreshold(threshold: newValue) }
}

public var primaryRoleThresholdFactors: [Factor] {
getPrimaryThresholdFactors()
}

public var primaryRoleOverrideFactors: [Factor] {
getPrimaryOverrideFactors()
}

public var recoveryRoleFactors: [Factor] {
getRecoveryFactors()
}

public var confirmationRoleFactors: [Factor] {
getConfirmationFactors()
}

/// Name of the shield
public var name: String {
get {
getName()
}
set {
setName(name: newValue)
}
}
}
6 changes: 3 additions & 3 deletions apple/Tests/TestCases/Prelude/Decimal192Tests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ final class Decimal192Tests: Test<Decimal192> {
// Every number multiplied by zero, is zero...
XCTAssertEqual(item * SUT.zero, SUT.zero)
}
// ... incliding `max` and `min`
// ... including `max` and `min`
XCTAssertEqual(SUT.max * 0, 0)
XCTAssertEqual(SUT.min * 0, 0)

Expand All @@ -239,7 +239,7 @@ final class Decimal192Tests: Test<Decimal192> {
// All numbers divided by themselves equals `one`...
XCTAssertEqual(item / item, SUT.one)
}
// ... incliding `max` and `min`
// ... including `max` and `min`
XCTAssertEqual(SUT.max / SUT.max, SUT.one)
XCTAssertEqual(SUT.min / SUT.min, SUT.one)
}
Expand Down Expand Up @@ -481,7 +481,7 @@ final class Decimal192Tests: Test<Decimal192> {
try largeDecimalsStrings.forEach(testLarge)

XCTAssertLessThan(SUT.min.asDouble, SUT.max.asDouble)
XCTAssertNoThrow(try SUT("12345678987654321.000000000000000001").asDouble)
XCTAssertNoThrow(SUT("12345678987654321.000000000000000001").asDouble)
}

private var smallDecimalStrings: [String] {
Expand Down
Loading

0 comments on commit 5fdde66

Please sign in to comment.