Skip to content

Commit 9ce9a22

Browse files
committed
swift format
1 parent e924a30 commit 9ce9a22

File tree

3 files changed

+25
-25
lines changed

3 files changed

+25
-25
lines changed

BDKSwiftExampleWallet/Extensions/BDK+Extensions/Persister+Extensions.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ extension Persister {
99
let persister = try Persister.newSqlite(path: URL.persistenceBackendPath)
1010
return persister
1111
}
12-
12+
1313
static func loadConnection() throws -> Persister {
1414
let persistenceBackendPath = URL.persistenceBackendPath
1515
let persister = try Persister.newSqlite(path: persistenceBackendPath)
1616
return persister
1717
}
18-
18+
1919
static func deleteConnection() throws {
2020
let walletDataDirectoryURL = URL.walletDataDirectoryURL
2121
if FileManager.default.fileExists(atPath: walletDataDirectoryURL.path) {

BDKSwiftExampleWallet/Extensions/Int+Extensions.swift

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -40,49 +40,49 @@ extension UInt64 {
4040
numberFormatter.usesGroupingSeparator = true
4141
numberFormatter.groupingSeparator = ","
4242
numberFormatter.generatesDecimalNumbers = false
43-
43+
4444
return numberFormatter
4545
}
46-
46+
4747
func formattedSatoshis() -> String {
4848
if self == 0 {
4949
return "0.00 000 000"
5050
} else {
5151
// Convert satoshis to BTC (1 BTC = 100,000,000 sats)
5252
let btcValue = Double(self) / 100_000_000.0
53-
53+
5454
// Format BTC value to exactly 8 decimal places
5555
let btcString = String(format: "%.8f", btcValue)
56-
56+
5757
// Split the string at the decimal point
5858
let parts = btcString.split(separator: ".")
5959
guard parts.count == 2 else { return btcString }
60-
60+
6161
let wholePart = String(parts[0])
6262
let decimalPart = String(parts[1])
63-
63+
6464
// Ensure decimal part is exactly 8 digits
6565
let paddedDecimal = decimalPart.padding(toLength: 8, withPad: "0", startingAt: 0)
66-
66+
6767
// Format as XX.XX XXX XXX
6868
let first = paddedDecimal.prefix(2)
6969
let second = paddedDecimal.dropFirst(2).prefix(3)
7070
let third = paddedDecimal.dropFirst(5).prefix(3)
71-
71+
7272
let formattedBalance = "\(wholePart).\(first) \(second) \(third)"
7373

7474
return formattedBalance
7575
}
7676
}
77-
77+
7878
func formattedBip177() -> String {
7979
if self != .zero && self >= 1_000_000 && self % 1_000_000 == .zero {
8080
return "\(self / 1_000_000)M"
81-
81+
8282
} else if self != .zero && self % 1_000 == 0 {
8383
return "\(self / 1_000)K"
8484
}
85-
85+
8686
return numberFormatter.string(from: NSNumber(value: self)) ?? "0"
8787
}
8888
}

BDKSwiftExampleWalletTests/Extensions/BDKSwiftExampleWalletInt+Extensions.swift

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,34 +34,34 @@ final class BDKSwiftExampleWalletInt_Extensions: XCTestCase {
3434
func testBip177() {
3535
let oneHundred = UInt64(100).formattedBip177()
3636
XCTAssertEqual(oneHundred, "100")
37-
37+
3838
let oneThousand = UInt64(1000).formattedBip177()
3939
XCTAssertEqual(oneThousand, "1K")
40-
40+
4141
let oneThousandOne = UInt64(1001).formattedBip177()
4242
XCTAssertEqual(oneThousandOne, "1,001")
43-
43+
4444
let tenThousand = UInt64(10000).formattedBip177()
4545
XCTAssertEqual(tenThousand, "10K")
46-
46+
4747
let tenThousandOne = UInt64(10001).formattedBip177()
4848
XCTAssertEqual(tenThousandOne, "10,001")
49-
49+
5050
let oneHundredThousand = UInt64(100000).formattedBip177()
5151
XCTAssertEqual(oneHundredThousand, "100K")
52-
52+
5353
let oneHundredThousandOne = UInt64(100001).formattedBip177()
5454
XCTAssertEqual(oneHundredThousandOne, "100,001")
55-
56-
let oneMillion = UInt64(1000000).formattedBip177()
55+
56+
let oneMillion = UInt64(1_000_000).formattedBip177()
5757
XCTAssertEqual(oneMillion, "1M")
58-
59-
let oneMillionOne = UInt64(1000001).formattedBip177()
58+
59+
let oneMillionOne = UInt64(1_000_001).formattedBip177()
6060
XCTAssertEqual(oneMillionOne, "1,000,001")
61-
61+
6262
let treeMillions = UInt64(325_000_000).formattedBip177()
6363
XCTAssertEqual(treeMillions, "325M")
64-
64+
6565
let treeMillionsOne = UInt64(325_000_001).formattedBip177()
6666
XCTAssertEqual(treeMillionsOne, "325,000,001")
6767
}

0 commit comments

Comments
 (0)