From 1f99b61dce89ef8ec845aa7e470ab2649871de03 Mon Sep 17 00:00:00 2001 From: "pharms.eth" <100330083+pharms-eth@users.noreply.github.com> Date: Sun, 5 Mar 2023 21:03:48 -0800 Subject: [PATCH 01/10] Update HexDecodable+Extensions.swift --- .../EthereumNetwork/Utility/HexDecodable+Extensions.swift | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/Sources/Web3Core/EthereumNetwork/Utility/HexDecodable+Extensions.swift b/Sources/Web3Core/EthereumNetwork/Utility/HexDecodable+Extensions.swift index d64bb9a09..372efa001 100644 --- a/Sources/Web3Core/EthereumNetwork/Utility/HexDecodable+Extensions.swift +++ b/Sources/Web3Core/EthereumNetwork/Utility/HexDecodable+Extensions.swift @@ -20,12 +20,8 @@ extension Data: LiteralInitiableFromString { public static func fromHex(_ hex: String) -> Data? { let string = hex.lowercased().stripHexPrefix() let array = [UInt8](hex: string) - if array.count == 0 { - if hex == "0x" || hex == "" { - return Data() - } else { - return nil - } + if (array.count == 0) { + return (hex == "0x" || hex.isEmpty) ? Data() : nil } return Data(array) } From f1cb0ae1c290952ee86ba5681b502af8313e1664 Mon Sep 17 00:00:00 2001 From: "pharms.eth" <100330083+pharms-eth@users.noreply.github.com> Date: Sun, 5 Mar 2023 21:04:08 -0800 Subject: [PATCH 02/10] Update Data+Extension.swift --- Sources/Web3Core/Utility/Data+Extension.swift | 38 ++++++++++--------- 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/Sources/Web3Core/Utility/Data+Extension.swift b/Sources/Web3Core/Utility/Data+Extension.swift index 448728f1a..cc5ef89a0 100755 --- a/Sources/Web3Core/Utility/Data+Extension.swift +++ b/Sources/Web3Core/Utility/Data+Extension.swift @@ -5,7 +5,8 @@ import Foundation -extension Data { +public extension Data { + init(fromArray values: [T]) { let values = values let ptrUB = values.withUnsafeBufferPointer { (ptr: UnsafeBufferPointer) in return ptr } @@ -33,32 +34,33 @@ extension Data { return difference == UInt8(0x00) } - public static func zero(_ data: inout Data) { + static func zero(_ data: inout Data) { let count = data.count data.withUnsafeMutableBytes { (body: UnsafeMutableRawBufferPointer) in body.baseAddress?.assumingMemoryBound(to: UInt8.self).initialize(repeating: 0, count: count) } } - public static func randomBytes(length: Int) -> Data? { - for _ in 0...1024 { - var data = Data(repeating: 0, count: length) - let result = data.withUnsafeMutableBytes { (body: UnsafeMutableRawBufferPointer) -> Int32? in - if let bodyAddress = body.baseAddress, body.count > 0 { - let pointer = bodyAddress.assumingMemoryBound(to: UInt8.self) - return SecRandomCopyBytes(kSecRandomDefault, length, pointer) - } else { - return nil - } - } - if let notNilResult = result, notNilResult == errSecSuccess { - return data - } + static func randomBytes(length: Int) -> Data? { + let entropy_bit_size = length//128 + //# valid_entropy_bit_sizes = [128, 160, 192, 224, 256], count: [12, 15, 18, 21, 24] + var entropy_bytes = [UInt8](repeating: 0, count: entropy_bit_size)// / 8) + + let status = SecRandomCopyBytes(kSecRandomDefault, entropy_bytes.count, &entropy_bytes) + + if status != errSecSuccess { // Always test the status. + + } else { + entropy_bytes = [UInt8](repeating: 0, count: entropy_bit_size)// / 8) + arc4random_buf(&entropy_bytes, entropy_bytes.count) } - return nil + + let entropyData = entropy_bytes.shuffled() + + return Data(entropyData) } - public func bitsInRange(_ startingBit: Int, _ length: Int) -> UInt64? { // return max of 8 bytes for simplicity, non-public + func bitsInRange(_ startingBit: Int, _ length: Int) -> UInt64? { // return max of 8 bytes for simplicity, non-public if startingBit + length / 8 > self.count, length > 64, startingBit > 0, length >= 1 { return nil } let bytes = self[(startingBit/8) ..< (startingBit+length+7)/8] let padding = Data(repeating: 0, count: 8 - bytes.count) From ad87a988a41b752cec793ad07149de700ece9b39 Mon Sep 17 00:00:00 2001 From: "pharms.eth" <100330083+pharms-eth@users.noreply.github.com> Date: Sun, 5 Mar 2023 21:04:16 -0800 Subject: [PATCH 03/10] Update String+Extension.swift --- .../Web3Core/Utility/String+Extension.swift | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/Sources/Web3Core/Utility/String+Extension.swift b/Sources/Web3Core/Utility/String+Extension.swift index dbe0a10ca..f60187bb4 100755 --- a/Sources/Web3Core/Utility/String+Extension.swift +++ b/Sources/Web3Core/Utility/String+Extension.swift @@ -92,7 +92,7 @@ extension String { guard let matcher = try? NSRegularExpression(pattern: "^(?0x)(?0+)(?[0-9a-fA-F]*)$", options: .dotMatchesLineSeparators) else { - NSLog("stripLeadingZeroes(): failed to parse regex pattern.") + print("stripLeadingZeroes(): failed to parse regex pattern.") return self } let match = matcher.captureGroups(string: hex, options: .anchored) @@ -135,6 +135,26 @@ extension String { func trim() -> String { trimmingCharacters(in: .whitespacesAndNewlines) } + + /// Splits a string into groups of `every` n characters, grouping from left-to-right by default. If `backwards` is true, right-to-left. + public func split(every: Int, backwards: Bool = false) -> [String] { + var result = [String]() + + for i in stride(from: 0, to: self.count, by: every) { + switch backwards { + case true: + let endIndex = self.index(self.endIndex, offsetBy: -i) + let startIndex = self.index(endIndex, offsetBy: -every, limitedBy: self.startIndex) ?? self.startIndex + result.insert(String(self[startIndex.. Date: Sun, 2 Apr 2023 22:59:13 +0300 Subject: [PATCH 04/10] chore: refactoring + documentation for Data.fromHex function --- .../Utility/HexDecodable+Extensions.swift | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/Sources/Web3Core/EthereumNetwork/Utility/HexDecodable+Extensions.swift b/Sources/Web3Core/EthereumNetwork/Utility/HexDecodable+Extensions.swift index 372efa001..739442fca 100644 --- a/Sources/Web3Core/EthereumNetwork/Utility/HexDecodable+Extensions.swift +++ b/Sources/Web3Core/EthereumNetwork/Utility/HexDecodable+Extensions.swift @@ -17,12 +17,17 @@ extension BigInt: LiteralInitiableFromString { } extension BigUInt: LiteralInitiableFromString { } extension Data: LiteralInitiableFromString { + /// Converts hexadecimal string representation of some bytes into actual bytes. + /// Notes: + /// - empty string will return `nil`; + /// - empty hex string, meaning it's equal to `"0x"`, will return empty `Data` object. + /// - Parameter hex: bytes represented as string. + /// - Returns: optional raw bytes. public static func fromHex(_ hex: String) -> Data? { - let string = hex.lowercased().stripHexPrefix() - let array = [UInt8](hex: string) - if (array.count == 0) { - return (hex == "0x" || hex.isEmpty) ? Data() : nil - } - return Data(array) + let hex = hex.lowercased().trim() + guard !hex.isEmpty else { return nil } + guard hex != "0x" else { return Data() } + let bytes = [UInt8](hex: hex.stripHexPrefix()) + return bytes.isEmpty ? nil : Data(bytes) } } From 468beaafbf3714ec8c550d00e54520326ca51114 Mon Sep 17 00:00:00 2001 From: "pharms.eth" <100330083+pharms-eth@users.noreply.github.com> Date: Wed, 19 Apr 2023 20:21:11 -0700 Subject: [PATCH 05/10] updates as per conversations --- Sources/Web3Core/Utility/Data+Extension.swift | 23 +++++++++++-------- .../Web3Core/Utility/String+Extension.swift | 2 +- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/Sources/Web3Core/Utility/Data+Extension.swift b/Sources/Web3Core/Utility/Data+Extension.swift index cc5ef89a0..420ad8b5e 100755 --- a/Sources/Web3Core/Utility/Data+Extension.swift +++ b/Sources/Web3Core/Utility/Data+Extension.swift @@ -41,21 +41,24 @@ public extension Data { } } - static func randomBytes(length: Int) -> Data? { - let entropy_bit_size = length//128 - //# valid_entropy_bit_sizes = [128, 160, 192, 224, 256], count: [12, 15, 18, 21, 24] - var entropy_bytes = [UInt8](repeating: 0, count: entropy_bit_size)// / 8) + /** + Generates an array of random bytes with the specified length. + + - Parameter length: The number of random bytes to generate. - let status = SecRandomCopyBytes(kSecRandomDefault, entropy_bytes.count, &entropy_bytes) + - Returns: An optional `Data` object containing the generated random bytes, or `nil` if an error occurs during generation. + - Note: This function uses `SecRandomCopyBytes` to generate random bytes and shuffles the resulting array before returning it as a `Data` object. If an error occurs during random bytes generation, the function returns `nil`. + */ + static func randomBytes(length: Int) -> Data? { + var entropyBytes = [UInt8](repeating: 0, count: length) - if status != errSecSuccess { // Always test the status. + let status = SecRandomCopyBytes(kSecRandomDefault, entropyBytes.count, &entropyBytes) - } else { - entropy_bytes = [UInt8](repeating: 0, count: entropy_bit_size)// / 8) - arc4random_buf(&entropy_bytes, entropy_bytes.count) + guard status == errSecSuccess else { + return nil } - let entropyData = entropy_bytes.shuffled() + let entropyData = entropyBytes.shuffled() return Data(entropyData) } diff --git a/Sources/Web3Core/Utility/String+Extension.swift b/Sources/Web3Core/Utility/String+Extension.swift index f60187bb4..529fe2ff0 100755 --- a/Sources/Web3Core/Utility/String+Extension.swift +++ b/Sources/Web3Core/Utility/String+Extension.swift @@ -92,7 +92,7 @@ extension String { guard let matcher = try? NSRegularExpression(pattern: "^(?0x)(?0+)(?[0-9a-fA-F]*)$", options: .dotMatchesLineSeparators) else { - print("stripLeadingZeroes(): failed to parse regex pattern.") + NSLog("stripLeadingZeroes(): failed to parse regex pattern.") return self } let match = matcher.captureGroups(string: hex, options: .anchored) From 17af93772e0f582600b3e37a72f38fe05a9e4821 Mon Sep 17 00:00:00 2001 From: Jenea Vranceanu <36865532+JeneaVranceanu@users.noreply.github.com> Date: Thu, 4 May 2023 15:32:58 +0300 Subject: [PATCH 06/10] chore: updated docs for randomBytes + minor refactoring --- Sources/Web3Core/Utility/Data+Extension.swift | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/Sources/Web3Core/Utility/Data+Extension.swift b/Sources/Web3Core/Utility/Data+Extension.swift index 420ad8b5e..78fb00753 100755 --- a/Sources/Web3Core/Utility/Data+Extension.swift +++ b/Sources/Web3Core/Utility/Data+Extension.swift @@ -42,25 +42,23 @@ public extension Data { } /** - Generates an array of random bytes with the specified length. - + Generates an array of random bytes of the specified length. + This function uses `SecRandomCopyBytes` to generate random bytes returning it as a `Data` object. + If an error occurs during random bytes generation, the function returns `nil`. + Error occurs only if `SecRandomCopyBytes` returns status that is not `errSecSuccess`. + See [all status codes](https://developer.apple.com/documentation/security/1542001-security_framework_result_codes) for possible error reasons. + Note: in v4 of web3swift this function will be deprecated and a new implementation will be provided that will throw occured error. - Parameter length: The number of random bytes to generate. - - Returns: An optional `Data` object containing the generated random bytes, or `nil` if an error occurs during generation. - - Note: This function uses `SecRandomCopyBytes` to generate random bytes and shuffles the resulting array before returning it as a `Data` object. If an error occurs during random bytes generation, the function returns `nil`. + - Returns: optional `Data` object containing the generated random bytes, or `nil` if an error occured during generation. */ static func randomBytes(length: Int) -> Data? { var entropyBytes = [UInt8](repeating: 0, count: length) - let status = SecRandomCopyBytes(kSecRandomDefault, entropyBytes.count, &entropyBytes) - guard status == errSecSuccess else { return nil } - - let entropyData = entropyBytes.shuffled() - - return Data(entropyData) + return Data(entropyBytes) } func bitsInRange(_ startingBit: Int, _ length: Int) -> UInt64? { // return max of 8 bytes for simplicity, non-public From e87d8edc62d7d042ca72a23eb8672bd9d9971e14 Mon Sep 17 00:00:00 2001 From: Jenea Vranceanu <36865532+JeneaVranceanu@users.noreply.github.com> Date: Thu, 4 May 2023 19:32:42 +0300 Subject: [PATCH 07/10] chore: fixed typo in Data+Extension.swift --- Sources/Web3Core/Utility/Data+Extension.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sources/Web3Core/Utility/Data+Extension.swift b/Sources/Web3Core/Utility/Data+Extension.swift index 78fb00753..01a3b1c70 100755 --- a/Sources/Web3Core/Utility/Data+Extension.swift +++ b/Sources/Web3Core/Utility/Data+Extension.swift @@ -47,10 +47,10 @@ public extension Data { If an error occurs during random bytes generation, the function returns `nil`. Error occurs only if `SecRandomCopyBytes` returns status that is not `errSecSuccess`. See [all status codes](https://developer.apple.com/documentation/security/1542001-security_framework_result_codes) for possible error reasons. - Note: in v4 of web3swift this function will be deprecated and a new implementation will be provided that will throw occured error. + Note: in v4 of web3swift this function will be deprecated and a new implementation will be provided that will throw occurred error. - Parameter length: The number of random bytes to generate. - - Returns: optional `Data` object containing the generated random bytes, or `nil` if an error occured during generation. + - Returns: optional `Data` object containing the generated random bytes, or `nil` if an error occurred during generation. */ static func randomBytes(length: Int) -> Data? { var entropyBytes = [UInt8](repeating: 0, count: length) From ab8aaba8b50a3395b8fc2b822be041eec740aaf1 Mon Sep 17 00:00:00 2001 From: Jenea Vranceanu Date: Thu, 4 May 2023 19:59:11 +0300 Subject: [PATCH 08/10] chore: lint issue fixed --- Sources/Web3Core/Utility/Data+Extension.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/Web3Core/Utility/Data+Extension.swift b/Sources/Web3Core/Utility/Data+Extension.swift index 01a3b1c70..3a8185d0e 100755 --- a/Sources/Web3Core/Utility/Data+Extension.swift +++ b/Sources/Web3Core/Utility/Data+Extension.swift @@ -43,7 +43,7 @@ public extension Data { /** Generates an array of random bytes of the specified length. - This function uses `SecRandomCopyBytes` to generate random bytes returning it as a `Data` object. + This function uses `SecRandomCopyBytes` to generate random bytes returning it as a `Data` object. If an error occurs during random bytes generation, the function returns `nil`. Error occurs only if `SecRandomCopyBytes` returns status that is not `errSecSuccess`. See [all status codes](https://developer.apple.com/documentation/security/1542001-security_framework_result_codes) for possible error reasons. From e8a5e2bf4e799d7bb35a0a3e280b00cd2da2ec0d Mon Sep 17 00:00:00 2001 From: "pharms.eth" <100330083+pharms-eth@users.noreply.github.com> Date: Mon, 28 Aug 2023 19:21:59 -0700 Subject: [PATCH 09/10] add string spit test --- Package.swift | 11 +++++++---- .../EthereumNetwork/Request/APIRequest+Methods.swift | 1 + .../Utility/Async+BackwardCapability.swift | 1 - Sources/web3swift/Utils/ENS/ENSRegistry.swift | 10 ++++++++++ .../localTests/UncategorizedTests.swift | 11 +++++++++++ 5 files changed, 29 insertions(+), 5 deletions(-) diff --git a/Package.swift b/Package.swift index 96a315782..9b760afca 100755 --- a/Package.swift +++ b/Package.swift @@ -6,20 +6,22 @@ import PackageDescription let package = Package( name: "Web3swift", platforms: [ - .macOS(.v10_15), .iOS(.v13) + .macOS(.v12), .iOS(.v13) ], products: [ .library(name: "web3swift", targets: ["web3swift"]) ], dependencies: [ .package(url: "https://github.com/attaswift/BigInt.git", from: "5.3.0"), - .package(url: "https://github.com/krzyzanowskim/CryptoSwift.git", from: "1.5.1") + .package(url: "https://github.com/krzyzanowskim/CryptoSwift.git", from: "1.5.1"), +// .package(url: "https://github.com/realm/SwiftLint", branch: "main") ], targets: [ .target(name: "secp256k1"), .target( name: "Web3Core", - dependencies: ["BigInt", "secp256k1", "CryptoSwift"] + dependencies: ["BigInt", "secp256k1", "CryptoSwift"]//, +// plugins: [.plugin(name: "SwiftLintPlugin", package: "SwiftLint")] ), .target( name: "web3swift", @@ -28,7 +30,8 @@ let package = Package( .copy("./Browser/browser.js"), .copy("./Browser/browser.min.js"), .copy("./Browser/wk.bridge.min.js") - ] + ]//, +// plugins: [.plugin(name: "SwiftLintPlugin", package: "SwiftLint")] ), .testTarget( name: "localTests", diff --git a/Sources/Web3Core/EthereumNetwork/Request/APIRequest+Methods.swift b/Sources/Web3Core/EthereumNetwork/Request/APIRequest+Methods.swift index 58e13aa0f..9a4ba150b 100644 --- a/Sources/Web3Core/EthereumNetwork/Request/APIRequest+Methods.swift +++ b/Sources/Web3Core/EthereumNetwork/Request/APIRequest+Methods.swift @@ -39,6 +39,7 @@ extension APIRequest { throw Web3Error.nodeError(desc: "\(error.message)\nError code: \(error.code)") } let description = "\(parsedErrorCode.errorName). Error code: \(error.code). \(error.message)" + print(description) switch parsedErrorCode { case .parseError, .invalidParams: throw Web3Error.inputError(desc: description) diff --git a/Sources/Web3Core/EthereumNetwork/Utility/Async+BackwardCapability.swift b/Sources/Web3Core/EthereumNetwork/Utility/Async+BackwardCapability.swift index e6b67ae83..0496bb615 100644 --- a/Sources/Web3Core/EthereumNetwork/Utility/Async+BackwardCapability.swift +++ b/Sources/Web3Core/EthereumNetwork/Utility/Async+BackwardCapability.swift @@ -8,7 +8,6 @@ import Foundation @available(iOS, obsoleted: 15.0, message: "Use the built-in API instead") -@available(macOS, obsoleted: 12.0, message: "Use the built-in API instead") extension URLSession { func data(for request: URLRequest) async throws -> (Data, HTTPURLResponse) { try await withCheckedThrowingContinuation { continuation in diff --git a/Sources/web3swift/Utils/ENS/ENSRegistry.swift b/Sources/web3swift/Utils/ENS/ENSRegistry.swift index 1e91001b0..21ec0aaf2 100644 --- a/Sources/web3swift/Utils/ENS/ENSRegistry.swift +++ b/Sources/web3swift/Utils/ENS/ENSRegistry.swift @@ -65,6 +65,16 @@ public extension ENS { return Resolver(web3: self.web3, resolverContractAddress: resolverAddress) } + let hexCharacters: [Character] = Array("0123456789abcdef") + + func hexlify(_ value: Data) -> String { + var result = "0x" + for byte in value { + result += "\(hexCharacters[Int(byte / 16)])\(hexCharacters[Int(byte % 16)])" + } + return result + } + public func getTTL(node: String) async throws -> BigUInt { guard let nameHash = NameHash.nameHash(node) else {throw Web3Error.processingError(desc: "Failed to get name hash")} diff --git a/Tests/web3swiftTests/localTests/UncategorizedTests.swift b/Tests/web3swiftTests/localTests/UncategorizedTests.swift index f47ccdeec..82917d4dc 100755 --- a/Tests/web3swiftTests/localTests/UncategorizedTests.swift +++ b/Tests/web3swiftTests/localTests/UncategorizedTests.swift @@ -51,6 +51,17 @@ class UncategorizedTests: XCTestCase { XCTAssert(biguint == BigUInt("126978086000000000")) } + func testStringSplit() { + XCTAssertEqual("abcdefgh".split(every: 3), ["abc", "def", "gh"]) + XCTAssertEqual("abcdefgh".split(every: 3, backwards: true), ["ab", "cde", "fgh"]) + + XCTAssertEqual("abcdefgh".split(every: 10), ["abcdefgh"]) + XCTAssertEqual("".split(every: 3), []) + + XCTAssertEqual("abcdefgh".split(every: 1), ["a", "b", "c", "d", "e", "f", "g", "h"]) + XCTAssertEqual("abcdefgh".split(every: 1, backwards: true), ["a", "b", "c", "d", "e", "f", "g", "h"]) // should be the same as from the front + } + func testBloom() throws { let positive = [ "testtest", From fc5a8dff5f2a6d2a333a567a4ca19213d68adb42 Mon Sep 17 00:00:00 2001 From: "pharms.eth" <100330083+pharms-eth@users.noreply.github.com> Date: Mon, 28 Aug 2023 23:46:55 -0700 Subject: [PATCH 10/10] Revert "add string spit test" github issue This reverts commit e8a5e2bf4e799d7bb35a0a3e280b00cd2da2ec0d. --- Package.swift | 11 ++++------- .../EthereumNetwork/Request/APIRequest+Methods.swift | 1 - .../Utility/Async+BackwardCapability.swift | 1 + Sources/web3swift/Utils/ENS/ENSRegistry.swift | 10 ---------- 4 files changed, 5 insertions(+), 18 deletions(-) diff --git a/Package.swift b/Package.swift index 9b760afca..96a315782 100755 --- a/Package.swift +++ b/Package.swift @@ -6,22 +6,20 @@ import PackageDescription let package = Package( name: "Web3swift", platforms: [ - .macOS(.v12), .iOS(.v13) + .macOS(.v10_15), .iOS(.v13) ], products: [ .library(name: "web3swift", targets: ["web3swift"]) ], dependencies: [ .package(url: "https://github.com/attaswift/BigInt.git", from: "5.3.0"), - .package(url: "https://github.com/krzyzanowskim/CryptoSwift.git", from: "1.5.1"), -// .package(url: "https://github.com/realm/SwiftLint", branch: "main") + .package(url: "https://github.com/krzyzanowskim/CryptoSwift.git", from: "1.5.1") ], targets: [ .target(name: "secp256k1"), .target( name: "Web3Core", - dependencies: ["BigInt", "secp256k1", "CryptoSwift"]//, -// plugins: [.plugin(name: "SwiftLintPlugin", package: "SwiftLint")] + dependencies: ["BigInt", "secp256k1", "CryptoSwift"] ), .target( name: "web3swift", @@ -30,8 +28,7 @@ let package = Package( .copy("./Browser/browser.js"), .copy("./Browser/browser.min.js"), .copy("./Browser/wk.bridge.min.js") - ]//, -// plugins: [.plugin(name: "SwiftLintPlugin", package: "SwiftLint")] + ] ), .testTarget( name: "localTests", diff --git a/Sources/Web3Core/EthereumNetwork/Request/APIRequest+Methods.swift b/Sources/Web3Core/EthereumNetwork/Request/APIRequest+Methods.swift index 9a4ba150b..58e13aa0f 100644 --- a/Sources/Web3Core/EthereumNetwork/Request/APIRequest+Methods.swift +++ b/Sources/Web3Core/EthereumNetwork/Request/APIRequest+Methods.swift @@ -39,7 +39,6 @@ extension APIRequest { throw Web3Error.nodeError(desc: "\(error.message)\nError code: \(error.code)") } let description = "\(parsedErrorCode.errorName). Error code: \(error.code). \(error.message)" - print(description) switch parsedErrorCode { case .parseError, .invalidParams: throw Web3Error.inputError(desc: description) diff --git a/Sources/Web3Core/EthereumNetwork/Utility/Async+BackwardCapability.swift b/Sources/Web3Core/EthereumNetwork/Utility/Async+BackwardCapability.swift index 0496bb615..e6b67ae83 100644 --- a/Sources/Web3Core/EthereumNetwork/Utility/Async+BackwardCapability.swift +++ b/Sources/Web3Core/EthereumNetwork/Utility/Async+BackwardCapability.swift @@ -8,6 +8,7 @@ import Foundation @available(iOS, obsoleted: 15.0, message: "Use the built-in API instead") +@available(macOS, obsoleted: 12.0, message: "Use the built-in API instead") extension URLSession { func data(for request: URLRequest) async throws -> (Data, HTTPURLResponse) { try await withCheckedThrowingContinuation { continuation in diff --git a/Sources/web3swift/Utils/ENS/ENSRegistry.swift b/Sources/web3swift/Utils/ENS/ENSRegistry.swift index 21ec0aaf2..1e91001b0 100644 --- a/Sources/web3swift/Utils/ENS/ENSRegistry.swift +++ b/Sources/web3swift/Utils/ENS/ENSRegistry.swift @@ -65,16 +65,6 @@ public extension ENS { return Resolver(web3: self.web3, resolverContractAddress: resolverAddress) } - let hexCharacters: [Character] = Array("0123456789abcdef") - - func hexlify(_ value: Data) -> String { - var result = "0x" - for byte in value { - result += "\(hexCharacters[Int(byte / 16)])\(hexCharacters[Int(byte % 16)])" - } - return result - } - public func getTTL(node: String) async throws -> BigUInt { guard let nameHash = NameHash.nameHash(node) else {throw Web3Error.processingError(desc: "Failed to get name hash")}