Skip to content

Commit

Permalink
update 1.42.1
Browse files Browse the repository at this point in the history
  • Loading branch information
nerzh committed May 22, 2023
1 parent 87cf6e9 commit d06d1d1
Show file tree
Hide file tree
Showing 7 changed files with 409 additions and 6 deletions.
6 changes: 3 additions & 3 deletions ApiParser/Sources/ApiParser/CodeGenerator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -317,13 +317,13 @@ extension CodeGenerator {
\n public init(_ error: Error) {
self.code = 0
self.message = error.localizedDescription
self.data = ([:] as! [String: Any]).toAnyValue()
self.data = [String: Any]().toAnyValue()
}
public init(_ message: String) {
self.code = 0
self.message = message
self.data = ([:] as! [String: Any]).toAnyValue()
self.data = [String: Any]().toAnyValue()
}\n
"""
result.append(customInit)
Expand All @@ -334,7 +334,7 @@ extension CodeGenerator {
result.append("\(property.name): \(property.type) = nil")
} else {
if property.name == "data" {
result.append("\(property.name): \(property.type) = ([:] as! [String: Any]).toAnyValue()")
result.append("\(property.name): \(property.type) = [String: Any]().toAnyValue()")
} else {
result.append("\(property.name): \(property.type)")
}
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</p>

[![SPM](https://img.shields.io/badge/swift-package%20manager-green)](https://swift.org/package-manager/)
[![SPM](https://img.shields.io/badge/SDK%20VERSION-1.41.1-orange)](https://github.com/tonlabs/ever-sdk)
[![SPM](https://img.shields.io/badge/SDK%20VERSION-1.42.1-orange)](https://github.com/tonlabs/ever-sdk)

Swift is a strongly typed language that has long been used not only for iOS development. Apple is actively promoting it to new platforms and today it can be used for almost any task. Thanks to this, this implementation provides the work of TVM (toncoin, everscale, venom, gosh) SDK on many platforms at once, including the native one for mobile phones. Let me remind you that swift can also be built for android.

Expand Down
4 changes: 4 additions & 0 deletions Sources/EverscaleClientSwift/Client/Client.swift
Original file line number Diff line number Diff line change
Expand Up @@ -201,4 +201,8 @@ public final class TSDKClientModule {
}
}
}

deinit {
print("Client DEINIT !")
}
}
4 changes: 2 additions & 2 deletions Sources/EverscaleClientSwift/Client/ClientTypes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [String: Any]().toAnyValue()
public var data: AnyValue = ([:] as! [String: Any]).toAnyValue()

public init(_ error: Error) {
self.code = 0
Expand Down Expand Up @@ -151,7 +151,7 @@ public struct TSDKNetworkConfig: Codable {
public var queries_protocol: TSDKNetworkQueriesProtocol?
/// UNSTABLE.
/// First REMP status awaiting timeout. If no status received during the timeout than fallback transaction scenario is activated.
/// Must be specified in milliseconds. Default is 1000 (1 sec).
/// Must be specified in milliseconds. Default is 1 (1 ms) in order to start fallback scenariotogether with REMP statuses processing while REMP is not properly tuned yet.
public var first_remp_status_timeout: UInt32?
/// UNSTABLE.
/// Subsequent REMP status awaiting timeout. If no status received during the timeout than fallback transaction scenario is activated.
Expand Down
1 change: 1 addition & 0 deletions Sources/EverscaleClientSwift/Net/NetTypes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public enum TSDKNetErrorCode: Int, Codable {
case Unauthorized = 615
case QueryTransactionTreeTimeout = 616
case GraphqlConnectionError = 617
case WrongWebscoketProtocolSequence = 618
}

public enum TSDKSortDirection: String, Codable {
Expand Down
205 changes: 205 additions & 0 deletions Sources/EverscaleClientSwift/Processing/Processing.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,211 @@ public final class TSDKProcessingModule {
self.binding = binding
}

/// Starts monitoring for the processing results of the specified messages.
/// Message monitor performs background monitoring for a message processing resultsfor the specified set of messages.
/// Message monitor can serve several isolated monitoring queues.
/// Each monitor queue has a unique application defined identifier (or name) usedto separate several queue's.
/// There are two important lists inside of the monitoring queue:
/// - unresolved messages: contains messages requested by the application for monitoring and not yet resolved;
/// - resolved results: contains resolved processing results for monitored messages.
/// Each monitoring queue tracks own unresolved and resolved lists.
/// Application can add more messages to the monitoring queue at any time.
/// Message monitor accumulates resolved results.
/// Application should fetch this results with `fetchNextMonitorResults` function.
/// When both unresolved and resolved lists becomes empty, monitor stops any background activityand frees all allocated internal memory.
/// If monitoring queue with specified name already exists then messages will be addedto the unresolved list.
/// If monitoring queue with specified name does not exist then monitoring queue will be createdwith specified unresolved messages.
public func monitor_messages(_ payload: TSDKParamsOfMonitorMessages, _ handler: @escaping (TSDKBindingResponse<TSDKNoneResult, TSDKClientError>) throws -> Void
) throws {
let method: String = "monitor_messages"
try binding.requestLibraryAsync(methodName(module, method), payload) { (requestId, params, responseType, finished) in
var response: TSDKBindingResponse<TSDKNoneResult, TSDKClientError> = .init()
response.update(requestId, params, responseType, finished)
try handler(response)
}
}

/// Starts monitoring for the processing results of the specified messages.
/// Message monitor performs background monitoring for a message processing resultsfor the specified set of messages.
/// Message monitor can serve several isolated monitoring queues.
/// Each monitor queue has a unique application defined identifier (or name) usedto separate several queue's.
/// There are two important lists inside of the monitoring queue:
/// - unresolved messages: contains messages requested by the application for monitoring and not yet resolved;
/// - resolved results: contains resolved processing results for monitored messages.
/// Each monitoring queue tracks own unresolved and resolved lists.
/// Application can add more messages to the monitoring queue at any time.
/// Message monitor accumulates resolved results.
/// Application should fetch this results with `fetchNextMonitorResults` function.
/// When both unresolved and resolved lists becomes empty, monitor stops any background activityand frees all allocated internal memory.
/// If monitoring queue with specified name already exists then messages will be addedto the unresolved list.
/// If monitoring queue with specified name does not exist then monitoring queue will be createdwith specified unresolved messages.
@available(iOS 13, *)
@available(macOS 12, *)
public func monitor_messages(_ payload: TSDKParamsOfMonitorMessages) async throws -> TSDKNoneResult {
try await withCheckedThrowingContinuation { continuation in
do {
let method: String = "monitor_messages"
try binding.requestLibraryAsyncAwait(methodName(module, method), payload) { (requestId, params, responseType, finished) in
var response: TSDKBindingResponse<TSDKNoneResult, TSDKClientError> = .init()
response.update(requestId, params, responseType, finished)
if let error = response.error {
continuation.resume(throwing: error)
} else if let result = response.result {
continuation.resume(returning: result)
} else {
continuation.resume(throwing: TSDKClientError("Nothing for return"))
}
}
} catch {
continuation.resume(throwing: error)
}
}
}

/// Returns summary information about current state of the specified monitoring queue.
public func get_monitor_info(_ payload: TSDKParamsOfGetMonitorInfo, _ handler: @escaping (TSDKBindingResponse<TSDKMonitoringQueueInfo, TSDKClientError>) throws -> Void
) throws {
let method: String = "get_monitor_info"
try binding.requestLibraryAsync(methodName(module, method), payload) { (requestId, params, responseType, finished) in
var response: TSDKBindingResponse<TSDKMonitoringQueueInfo, TSDKClientError> = .init()
response.update(requestId, params, responseType, finished)
try handler(response)
}
}

/// Returns summary information about current state of the specified monitoring queue.
@available(iOS 13, *)
@available(macOS 12, *)
public func get_monitor_info(_ payload: TSDKParamsOfGetMonitorInfo) async throws -> TSDKMonitoringQueueInfo {
try await withCheckedThrowingContinuation { continuation in
do {
let method: String = "get_monitor_info"
try binding.requestLibraryAsyncAwait(methodName(module, method), payload) { (requestId, params, responseType, finished) in
var response: TSDKBindingResponse<TSDKMonitoringQueueInfo, TSDKClientError> = .init()
response.update(requestId, params, responseType, finished)
if let error = response.error {
continuation.resume(throwing: error)
} else if let result = response.result {
continuation.resume(returning: result)
} else {
continuation.resume(throwing: TSDKClientError("Nothing for return"))
}
}
} catch {
continuation.resume(throwing: error)
}
}
}

/// Fetches next resolved results from the specified monitoring queue.
/// Results and waiting options are depends on the `wait` parameter.
/// All returned results will be removed from the queue's resolved list.
public func fetch_next_monitor_results(_ payload: TSDKParamsOfFetchNextMonitorResults, _ handler: @escaping (TSDKBindingResponse<TSDKResultOfFetchNextMonitorResults, TSDKClientError>) throws -> Void
) throws {
let method: String = "fetch_next_monitor_results"
try binding.requestLibraryAsync(methodName(module, method), payload) { (requestId, params, responseType, finished) in
var response: TSDKBindingResponse<TSDKResultOfFetchNextMonitorResults, TSDKClientError> = .init()
response.update(requestId, params, responseType, finished)
try handler(response)
}
}

/// Fetches next resolved results from the specified monitoring queue.
/// Results and waiting options are depends on the `wait` parameter.
/// All returned results will be removed from the queue's resolved list.
@available(iOS 13, *)
@available(macOS 12, *)
public func fetch_next_monitor_results(_ payload: TSDKParamsOfFetchNextMonitorResults) async throws -> TSDKResultOfFetchNextMonitorResults {
try await withCheckedThrowingContinuation { continuation in
do {
let method: String = "fetch_next_monitor_results"
try binding.requestLibraryAsyncAwait(methodName(module, method), payload) { (requestId, params, responseType, finished) in
var response: TSDKBindingResponse<TSDKResultOfFetchNextMonitorResults, TSDKClientError> = .init()
response.update(requestId, params, responseType, finished)
if let error = response.error {
continuation.resume(throwing: error)
} else if let result = response.result {
continuation.resume(returning: result)
} else {
continuation.resume(throwing: TSDKClientError("Nothing for return"))
}
}
} catch {
continuation.resume(throwing: error)
}
}
}

/// Cancels all background activity and releases all allocated system resources for the specified monitoring queue.
public func cancel_monitor(_ payload: TSDKParamsOfCancelMonitor, _ handler: @escaping (TSDKBindingResponse<TSDKNoneResult, TSDKClientError>) throws -> Void
) throws {
let method: String = "cancel_monitor"
try binding.requestLibraryAsync(methodName(module, method), payload) { (requestId, params, responseType, finished) in
var response: TSDKBindingResponse<TSDKNoneResult, TSDKClientError> = .init()
response.update(requestId, params, responseType, finished)
try handler(response)
}
}

/// Cancels all background activity and releases all allocated system resources for the specified monitoring queue.
@available(iOS 13, *)
@available(macOS 12, *)
public func cancel_monitor(_ payload: TSDKParamsOfCancelMonitor) async throws -> TSDKNoneResult {
try await withCheckedThrowingContinuation { continuation in
do {
let method: String = "cancel_monitor"
try binding.requestLibraryAsyncAwait(methodName(module, method), payload) { (requestId, params, responseType, finished) in
var response: TSDKBindingResponse<TSDKNoneResult, TSDKClientError> = .init()
response.update(requestId, params, responseType, finished)
if let error = response.error {
continuation.resume(throwing: error)
} else if let result = response.result {
continuation.resume(returning: result)
} else {
continuation.resume(throwing: TSDKClientError("Nothing for return"))
}
}
} catch {
continuation.resume(throwing: error)
}
}
}

/// Sends specified messages to the blockchain.
public func send_messages(_ payload: TSDKParamsOfSendMessages, _ handler: @escaping (TSDKBindingResponse<TSDKResultOfSendMessages, TSDKClientError>) throws -> Void
) throws {
let method: String = "send_messages"
try binding.requestLibraryAsync(methodName(module, method), payload) { (requestId, params, responseType, finished) in
var response: TSDKBindingResponse<TSDKResultOfSendMessages, TSDKClientError> = .init()
response.update(requestId, params, responseType, finished)
try handler(response)
}
}

/// Sends specified messages to the blockchain.
@available(iOS 13, *)
@available(macOS 12, *)
public func send_messages(_ payload: TSDKParamsOfSendMessages) async throws -> TSDKResultOfSendMessages {
try await withCheckedThrowingContinuation { continuation in
do {
let method: String = "send_messages"
try binding.requestLibraryAsyncAwait(methodName(module, method), payload) { (requestId, params, responseType, finished) in
var response: TSDKBindingResponse<TSDKResultOfSendMessages, TSDKClientError> = .init()
response.update(requestId, params, responseType, finished)
if let error = response.error {
continuation.resume(throwing: error)
} else if let result = response.result {
continuation.resume(returning: result)
} else {
continuation.resume(throwing: TSDKClientError("Nothing for return"))
}
}
} catch {
continuation.resume(throwing: error)
}
}
}

/// Sends message to the network
/// Sends message to the network and returns the last generated shard block of the destination accountbefore the message was sent. It will be required later for message processing.
public func send_message(_ payload: TSDKParamsOfSendMessage, _ handler: @escaping (TSDKBindingResponse<TSDKResultOfSendMessage, TSDKClientError>) throws -> Void
Expand Down
Loading

0 comments on commit d06d1d1

Please sign in to comment.