diff --git a/Package.swift b/Package.swift index b81406c..e4bc41d 100644 --- a/Package.swift +++ b/Package.swift @@ -16,7 +16,7 @@ let package = Package( .package(name: "SwiftRegularExpression", url: "https://github.com/nerzh/swift-regular-expression.git", .upToNextMajor(from: "0.2.4")), .package(name: "FileUtils", url: "https://github.com/nerzh/SwiftFileUtils", .upToNextMinor(from: "1.3.0")), .package(name: "BigInt", url: "https://github.com/bytehubio/BigInt", .exact("5.3.0")), - .package(name: "SwiftExtensionsPack", url: "https://github.com/nerzh/swift-extensions-pack", .upToNextMinor(from: "1.2.0")), + .package(name: "SwiftExtensionsPack", url: "https://github.com/nerzh/swift-extensions-pack", .upToNextMinor(from: "1.3.1")), ], targets: [ .systemLibrary(name: "CTonSDK", pkgConfig: "libton_client"), diff --git a/Sources/EverscaleClientSwift/Client/ClientTypes.swift b/Sources/EverscaleClientSwift/Client/ClientTypes.swift index b3c2cd8..54cb86f 100644 --- a/Sources/EverscaleClientSwift/Client/ClientTypes.swift +++ b/Sources/EverscaleClientSwift/Client/ClientTypes.swift @@ -60,7 +60,7 @@ public struct TSDKClientError: Codable, LocalizedError { public var failureReason: String? { self.message } public var recoverySuggestion: String? { self.message } public var helpAnchor: String? { self.message } - public var data: AnyValue = ([:] as! [String: Any]).toAnyValue() + public var data: AnyValue = [String: Any]().toAnyValue() public init(_ error: Error) { self.code = 0 diff --git a/Sources/EverscaleClientSwift/Extensions/String.swift b/Sources/EverscaleClientSwift/Extensions/String.swift deleted file mode 100644 index f81caa6..0000000 --- a/Sources/EverscaleClientSwift/Extensions/String.swift +++ /dev/null @@ -1,48 +0,0 @@ -// -// Created by Oleh Hudeichuk on 18.10.2020. -// - -import Foundation - -public extension String { - - func bytes(_ using: Encoding = .utf8) -> Int { - self.data(using: using)?.count ?? 0 - } - - // TO DECODABLE STRUCT - func toModel(_ model: T.Type) -> T? where T : Decodable { - guard let data = self.data(using: String.Encoding.utf8) else { return nil } - return try? JSONDecoder().decode(model, from: data) - } - - func getPointer(_ handler: (_ pointer: UnsafePointer, _ len: Int) throws -> Void) rethrows { - var string = self - try string.withUTF8 { (p: UnsafeBufferPointer) in - try p.baseAddress?.withMemoryRebound(to: T.self, capacity: p.count) { (p2: UnsafePointer) in - try handler(p2, p.count) - } - } - } - - func base64Encoded() -> String? { - if let data = self.data(using: .utf8) { - return data.base64EncodedString() - } - return nil - } - - func base64Decoded() -> String? { - if let data = Data(base64Encoded: self, options: .ignoreUnknownCharacters) { - return String(data: data, encoding: .utf8) - } - return nil - } - - func isBase64() -> Bool { - if let encoded = self.base64Decoded()?.base64Encoded() { - return encoded.trimmingCharacters(in: .whitespacesAndNewlines) == self - } - return false - } -} diff --git a/Tests/EverscaleClientSwiftTests/BindingTests.swift b/Tests/EverscaleClientSwiftTests/BindingTests.swift index 7d3f825..47e519f 100644 --- a/Tests/EverscaleClientSwiftTests/BindingTests.swift +++ b/Tests/EverscaleClientSwiftTests/BindingTests.swift @@ -11,7 +11,7 @@ import class Foundation.Bundle final class BindingTests: XCTestCase { func testConvertToTSDKString() throws { - var string: TSDKString = .init() + var string: tc_string_data_t! try TSDKBindingModule.convertToTSDKString("Hello😀") { tsdkString in string = tsdkString }