From 4114ca19f2baaaf086d45a6e1233a39cda7fd978 Mon Sep 17 00:00:00 2001 From: nerzh Date: Tue, 3 May 2022 23:36:38 +0200 Subject: [PATCH] up 1.33.0 --- README.md | 2 +- .../EverscaleClientSwift/Abi/AbiTypes.swift | 20 +++++++++++++++---- .../Client/ClientTypes.swift | 19 ++++++++++++++---- .../Crypto/CryptoTypes.swift | 1 + Sources/EverscaleClientSwift/Net/Net.swift | 2 +- .../Processing/ProcessingTypes.swift | 14 ++++++++++++- .../EverscaleClientSwift/Proofs/Proofs.swift | 2 +- 7 files changed, 48 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 3dc5cb5..fb0bd9e 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # Swift Client for Everscale SDK [![SPM](https://img.shields.io/badge/swift-package%20manager-green)](https://swift.org/package-manager/) -[![SPM](https://img.shields.io/badge/SDK%20VERSION-1.32.0-orange)](https://github.com/tonlabs/TON-SDK) +[![SPM](https://img.shields.io/badge/SDK%20VERSION-1.33.0-orange)](https://github.com/tonlabs/TON-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 Everscale 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. diff --git a/Sources/EverscaleClientSwift/Abi/AbiTypes.swift b/Sources/EverscaleClientSwift/Abi/AbiTypes.swift index dbe54f5..acb6bd0 100644 --- a/Sources/EverscaleClientSwift/Abi/AbiTypes.swift +++ b/Sources/EverscaleClientSwift/Abi/AbiTypes.swift @@ -460,10 +460,13 @@ public struct TSDKParamsOfDecodeMessage: Codable { public var abi: TSDKAbi /// Message BOC public var message: String + /// Flag allowing partial BOC decoding when ABI doesn't describe the full body BOC. Controls decoder behaviour when after decoding all described in ABI params there are some data left in BOC: `true` - return decoded values `false` - return error of incomplete BOC deserialization (default) + public var allow_partial: Bool? - public init(abi: TSDKAbi, message: String) { + public init(abi: TSDKAbi, message: String, allow_partial: Bool? = nil) { self.abi = abi self.message = message + self.allow_partial = allow_partial } } @@ -492,11 +495,14 @@ public struct TSDKParamsOfDecodeMessageBody: Codable { public var body: String /// True if the body belongs to the internal message. public var is_internal: Bool + /// Flag allowing partial BOC decoding when ABI doesn't describe the full body BOC. Controls decoder behaviour when after decoding all described in ABI params there are some data left in BOC: `true` - return decoded values `false` - return error of incomplete BOC deserialization (default) + public var allow_partial: Bool? - public init(abi: TSDKAbi, body: String, is_internal: Bool) { + public init(abi: TSDKAbi, body: String, is_internal: Bool, allow_partial: Bool? = nil) { self.abi = abi self.body = body self.is_internal = is_internal + self.allow_partial = allow_partial } } @@ -539,10 +545,13 @@ public struct TSDKParamsOfDecodeAccountData: Codable { public var abi: TSDKAbi /// Data BOC or BOC handle public var data: String + /// Flag allowing partial BOC decoding when ABI doesn't describe the full body BOC. Controls decoder behaviour when after decoding all described in ABI params there are some data left in BOC: `true` - return decoded values `false` - return error of incomplete BOC deserialization (default) + public var allow_partial: Bool? - public init(abi: TSDKAbi, data: String) { + public init(abi: TSDKAbi, data: String, allow_partial: Bool? = nil) { self.abi = abi self.data = data + self.allow_partial = allow_partial } } @@ -620,10 +629,13 @@ public struct TSDKParamsOfDecodeInitialData: Codable { public var abi: TSDKAbi? /// Data BOC or BOC handle public var data: String + /// Flag allowing partial BOC decoding when ABI doesn't describe the full body BOC. Controls decoder behaviour when after decoding all described in ABI params there are some data left in BOC: `true` - return decoded values `false` - return error of incomplete BOC deserialization (default) + public var allow_partial: Bool? - public init(abi: TSDKAbi? = nil, data: String) { + public init(abi: TSDKAbi? = nil, data: String, allow_partial: Bool? = nil) { self.abi = abi self.data = data + self.allow_partial = allow_partial } } diff --git a/Sources/EverscaleClientSwift/Client/ClientTypes.swift b/Sources/EverscaleClientSwift/Client/ClientTypes.swift index 0404011..c6b1495 100644 --- a/Sources/EverscaleClientSwift/Client/ClientTypes.swift +++ b/Sources/EverscaleClientSwift/Client/ClientTypes.swift @@ -80,10 +80,11 @@ public struct TSDKClientConfig: Codable { } public struct TSDKNetworkConfig: Codable { - /// DApp Server public address. For instance, for `net.ton.dev/graphql` GraphQL endpoint the server address will be net.ton.dev + /// **This field is deprecated, but left for backward-compatibility.** DApp Server public address. public var server_address: String? /// List of DApp Server addresses. - /// Any correct URL format can be specified, including IP addresses This parameter is prevailing over `server_address`. + /// Any correct URL format can be specified, including IP addresses. This parameter is prevailing over `server_address`. + /// Check the full list of [supported network endpoints](../ton-os-api/networks.md). public var endpoints: [String]? /// Deprecated. /// You must use `network.max_reconnect_timeout` that allows to specify maximum network resolving timeout. @@ -107,7 +108,7 @@ public struct TSDKNetworkConfig: Codable { /// Must be specified in milliseconds. Default is 15000 (15 sec). public var out_of_sync_threshold: UInt32? /// Maximum number of randomly chosen endpoints the library uses to broadcast a message. - /// Default is 2. + /// Default is 1. public var sending_endpoint_count: UInt8? /// Frequency of sync latency detection. /// Library periodically checks the current endpoint for blockchain data syncronization latency. @@ -125,11 +126,19 @@ public struct TSDKNetworkConfig: Codable { /// `HTTP` or `WS`. /// /// Default is `HTTP`. public var queries_protocol: TSDKNetworkQueriesProtocol? + /// UNSTABLE. + /// First REMP status awaiting timeout. If no status recieved during the timeout than fallback transaction scenario is activated. + /// Must be specified in milliseconds. Default is 1000 (1 sec). + public var first_remp_status_timeout: UInt32? + /// UNSTABLE. + /// Subsequent REMP status awaiting timeout. If no status recieved during the timeout than fallback transaction scenario is activated. + /// Must be specified in milliseconds. Default is 5000 (5 sec). + public var next_remp_status_timeout: UInt32? /// Access key to GraphQL API. /// At the moment is not used in production. public var access_key: String? - public init(server_address: String? = nil, endpoints: [String]? = nil, network_retries_count: Int8? = nil, max_reconnect_timeout: UInt32? = nil, reconnect_timeout: UInt32? = nil, message_retries_count: Int8? = nil, message_processing_timeout: UInt32? = nil, wait_for_timeout: UInt32? = nil, out_of_sync_threshold: UInt32? = nil, sending_endpoint_count: UInt8? = nil, latency_detection_interval: UInt32? = nil, max_latency: UInt32? = nil, query_timeout: UInt32? = nil, queries_protocol: TSDKNetworkQueriesProtocol? = nil, access_key: String? = nil) { + public init(server_address: String? = nil, endpoints: [String]? = nil, network_retries_count: Int8? = nil, max_reconnect_timeout: UInt32? = nil, reconnect_timeout: UInt32? = nil, message_retries_count: Int8? = nil, message_processing_timeout: UInt32? = nil, wait_for_timeout: UInt32? = nil, out_of_sync_threshold: UInt32? = nil, sending_endpoint_count: UInt8? = nil, latency_detection_interval: UInt32? = nil, max_latency: UInt32? = nil, query_timeout: UInt32? = nil, queries_protocol: TSDKNetworkQueriesProtocol? = nil, first_remp_status_timeout: UInt32? = nil, next_remp_status_timeout: UInt32? = nil, access_key: String? = nil) { self.server_address = server_address self.endpoints = endpoints self.network_retries_count = network_retries_count @@ -144,6 +153,8 @@ public struct TSDKNetworkConfig: Codable { self.max_latency = max_latency self.query_timeout = query_timeout self.queries_protocol = queries_protocol + self.first_remp_status_timeout = first_remp_status_timeout + self.next_remp_status_timeout = next_remp_status_timeout self.access_key = access_key } } diff --git a/Sources/EverscaleClientSwift/Crypto/CryptoTypes.swift b/Sources/EverscaleClientSwift/Crypto/CryptoTypes.swift index b9635e9..d59a4d8 100644 --- a/Sources/EverscaleClientSwift/Crypto/CryptoTypes.swift +++ b/Sources/EverscaleClientSwift/Crypto/CryptoTypes.swift @@ -36,6 +36,7 @@ public enum TSDKCryptoErrorCode: Int, Codable { case InvalidCryptoBoxType = 131 case CryptoBoxSecretSerializationError = 132 case CryptoBoxSecretDeserializationError = 133 + case InvalidNonceSize = 134 } public enum TSDKEncryptionAlgorithmEnumTypes: String, Codable { diff --git a/Sources/EverscaleClientSwift/Net/Net.swift b/Sources/EverscaleClientSwift/Net/Net.swift index 3b463cf..6d1c3ef 100644 --- a/Sources/EverscaleClientSwift/Net/Net.swift +++ b/Sources/EverscaleClientSwift/Net/Net.swift @@ -200,7 +200,7 @@ public final class TSDKNetModule { } /// Allows to query and paginate through the list of accounts that the specified account has interacted with, sorted by the time of the last internal message between accounts - /// *Attention* this query retrieves data from 'Counterparties' service which is not supported inthe opensource version of DApp Server (and will not be supported) as well as in TON OS SE (will be supported in SE in future),but is always accessible via [TON OS Devnet/Mainnet Clouds](https://docs.ton.dev/86757ecb2/p/85c869-networks) + /// *Attention* this query retrieves data from 'Counterparties' service which is not supported inthe opensource version of DApp Server (and will not be supported) as well as in Evernode SE (will be supported in SE in future),but is always accessible via [EVER OS Clouds](../ton-os-api/networks.md) public func query_counterparties(_ payload: TSDKParamsOfQueryCounterparties, _ handler: @escaping (TSDKBindingResponse) throws -> Void ) { let method: String = "query_counterparties" diff --git a/Sources/EverscaleClientSwift/Processing/ProcessingTypes.swift b/Sources/EverscaleClientSwift/Processing/ProcessingTypes.swift index 5df2718..fdd1c0e 100644 --- a/Sources/EverscaleClientSwift/Processing/ProcessingTypes.swift +++ b/Sources/EverscaleClientSwift/Processing/ProcessingTypes.swift @@ -12,6 +12,9 @@ public enum TSDKProcessingErrorCode: Int, Codable { case BlockNotFound = 511 case InvalidData = 512 case ExternalSignerMustNotBeUsed = 513 + case MessageRejected = 514 + case InvalidRempStatus = 515 + case NextRempStatusTimeout = 516 } public enum TSDKProcessingEventEnumTypes: String, Codable { @@ -23,6 +26,11 @@ public enum TSDKProcessingEventEnumTypes: String, Codable { case WillFetchNextBlock = "WillFetchNextBlock" case FetchNextBlockFailed = "FetchNextBlockFailed" case MessageExpired = "MessageExpired" + case RempSentToValidators = "RempSentToValidators" + case RempIncludedIntoBlock = "RempIncludedIntoBlock" + case RempIncludedIntoAcceptedBlock = "RempIncludedIntoAcceptedBlock" + case RempOther = "RempOther" + case RempError = "RempError" } public struct TSDKProcessingEvent: Codable { @@ -31,13 +39,17 @@ public struct TSDKProcessingEvent: Codable { public var shard_block_id: String? public var message_id: String? public var message: String? + public var timestamp: Int? + public var json: AnyValue? - public init(type: TSDKProcessingEventEnumTypes, error: TSDKClientError? = nil, shard_block_id: String? = nil, message_id: String? = nil, message: String? = nil) { + public init(type: TSDKProcessingEventEnumTypes, error: TSDKClientError? = nil, shard_block_id: String? = nil, message_id: String? = nil, message: String? = nil, timestamp: Int? = nil, json: AnyValue? = nil) { self.type = type self.error = error self.shard_block_id = shard_block_id self.message_id = message_id self.message = message + self.timestamp = timestamp + self.json = json } } diff --git a/Sources/EverscaleClientSwift/Proofs/Proofs.swift b/Sources/EverscaleClientSwift/Proofs/Proofs.swift index 7988f75..702f92d 100644 --- a/Sources/EverscaleClientSwift/Proofs/Proofs.swift +++ b/Sources/EverscaleClientSwift/Proofs/Proofs.swift @@ -18,7 +18,7 @@ public final class TSDKProofsModule { /// **What Proofs are**Simply, proof is a list of signatures of validators', which have signed this particular master-block. /// The very first validator set's public keys are included in the zero-state. Whe know a root hashof the zero-state, because it is stored in the network configuration file, it is our authorityroot. For proving zero-state it is enough to calculate and compare its root hash. /// In each new validator cycle the validator set is changed. The new one is stored in a key-block,which is signed by the validator set, which we already trust, the next validator set will bestored to the new key-block and signed by the current validator set, and so on. - /// In order to prove any block in the master-chain we need to check, that it has been signed bya trusted validator set. So we need to check all key-blocks' proofs, started from the zero-stateand until the block, which we want to prove. But it can take a lot of time and traffic todownload and prove all key-blocks on a client. For solving this, special trusted blocks are usedin TON-SDK. + /// In order to prove any block in the master-chain we need to check, that it has been signed bya trusted validator set. So we need to check all key-blocks' proofs, started from the zero-stateand until the block, which we want to prove. But it can take a lot of time and traffic todownload and prove all key-blocks on a client. For solving this, special trusted blocks are usedin Ever-SDK. /// The trusted block is the authority root, as well, as the zero-state. Each trusted block is the`id` (e.g. `root_hash`) of the already proven key-block. There can be plenty of trustedblocks, so there can be a lot of authority roots. The hashes of trusted blocks for MainNetand DevNet are hardcoded in SDK in a separated binary file (trusted_key_blocks.bin) and isbeing updated for each release by using `update_trusted_blocks` utility. /// See [update_trusted_blocks](../../../tools/update_trusted_blocks) directory for more info. /// In future SDK releases, one will also be able to provide their hashes of trusted blocks forother networks, besides for MainNet and DevNet.