Skip to content

Commit a1e1392

Browse files
committed
Update dependencies and fix hex string initialization
- Update BigInt to 5.7.0 - Pin secp256k1.swift to exact version 0.12.2 - Update Swift package dependencies (NIO, collections, HTTP types, etc.) - Add new Swift package dependencies (swift-asn1, swift-async-algorithms, swift-certificates, swift-crypto, swift-service-lifecycle) - Fix empty hex string handling in HexExtensions to initialize to 0 instead of nil
1 parent a7b1b94 commit a1e1392

File tree

4 files changed

+88
-28
lines changed

4 files changed

+88
-28
lines changed

Package.resolved

Lines changed: 68 additions & 23 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ let package = Package(
1515
dependencies: [
1616
.package(url: "https://github.com/attaswift/BigInt", from: "5.3.0"),
1717
.package(url: "https://github.com/iwill/generic-json-swift", .upToNextMajor(from: "2.0.2")),
18-
.package(url: "https://github.com/GigaBitcoin/secp256k1.swift.git", .upToNextMajor(from: "0.6.0")),
18+
.package(url: "https://github.com/GigaBitcoin/secp256k1.swift.git", exact: "0.12.2"),
1919
.package(url: "https://github.com/vapor/websocket-kit.git", from: "2.16.1"),
2020
.package(url: "https://github.com/apple/swift-log.git", from: "1.6.4")
2121
],

Package@swift-6.1.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ let package = Package(
1515
dependencies: [
1616
.package(url: "https://github.com/attaswift/BigInt", from: "5.3.0"),
1717
.package(url: "https://github.com/iwill/generic-json-swift", .upToNextMajor(from: "2.0.2")),
18-
.package(url: "https://github.com/GigaBitcoin/secp256k1.swift.git", .upToNextMajor(from: "0.6.0")),
18+
.package(url: "https://github.com/GigaBitcoin/secp256k1.swift.git", exact: "0.12.2"),
1919
.package(url: "https://github.com/vapor/websocket-kit.git", from: "2.16.1"),
2020
.package(url: "https://github.com/apple/swift-log.git", from: "1.6.4")
2121
],

web3swift/src/Extensions/HexExtensions.swift

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,12 @@ import Foundation
88

99
public extension BigUInt {
1010
init?(hex: String) {
11-
self.init(hex.web3.noHexPrefix.lowercased(), radix: 16)
11+
let stripped = hex.web3.noHexPrefix.lowercased()
12+
if stripped.isEmpty {
13+
self.init(0)
14+
} else {
15+
self.init(stripped, radix: 16)
16+
}
1217
}
1318
}
1419

@@ -24,13 +29,23 @@ public extension Web3Extensions where Base == BigUInt {
2429

2530
public extension BigInt {
2631
init?(hex: String) {
27-
self.init(hex.web3.noHexPrefix.lowercased(), radix: 16)
32+
let stripped = hex.web3.noHexPrefix.lowercased()
33+
if stripped.isEmpty {
34+
self.init(0)
35+
} else {
36+
self.init(stripped, radix: 16)
37+
}
2838
}
2939
}
3040

3141
public extension Int {
3242
init?(hex: String) {
33-
self.init(hex.web3.noHexPrefix, radix: 16)
43+
let stripped = hex.web3.noHexPrefix
44+
if stripped.isEmpty {
45+
self.init(0)
46+
} else {
47+
self.init(stripped, radix: 16)
48+
}
3449
}
3550
}
3651

0 commit comments

Comments
 (0)