Skip to content

Commit

Permalink
up to 1.41
Browse files Browse the repository at this point in the history
  • Loading branch information
nerzh committed Feb 20, 2023
1 parent 082a906 commit 1ae76df
Show file tree
Hide file tree
Showing 8 changed files with 79 additions and 17 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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.40.0-orange)](https://github.com/tonlabs/ever-sdk)
[![SPM](https://img.shields.io/badge/SDK%20VERSION-1.41.0-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 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.

Expand Down
23 changes: 16 additions & 7 deletions Sources/EverscaleClientSwift/Abi/AbiTypes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -281,14 +281,17 @@ public struct TSDKParamsOfEncodeMessageBody: Codable {
/// Destination address of the message
/// Since ABI version 2.3 destination address of external inbound message is used in messagebody signature calculation. Should be provided when signed external inbound message body iscreated. Otherwise can be omitted.
public var address: String?
/// Signature ID to be used in data to sign preparing when CapSignatureWithId capability is enabled
public var signature_id: Int32?

public init(abi: TSDKAbi, call_set: TSDKCallSet, is_internal: Bool, signer: TSDKSigner, processing_try_index: UInt8? = nil, address: String? = nil) {
public init(abi: TSDKAbi, call_set: TSDKCallSet, is_internal: Bool, signer: TSDKSigner, processing_try_index: UInt8? = nil, address: String? = nil, signature_id: Int32? = nil) {
self.abi = abi
self.call_set = call_set
self.is_internal = is_internal
self.signer = signer
self.processing_try_index = processing_try_index
self.address = address
self.signature_id = signature_id
}
}

Expand Down Expand Up @@ -357,14 +360,17 @@ public struct TSDKParamsOfEncodeMessage: Codable {
/// Retry grow factor is set in Client config:
/// <.....add config parameter with default value here>Default value is 0.
public var processing_try_index: UInt8?
/// Signature ID to be used in data to sign preparing when CapSignatureWithId capability is enabled
public var signature_id: Int32?

public init(abi: TSDKAbi, address: String? = nil, deploy_set: TSDKDeploySet? = nil, call_set: TSDKCallSet? = nil, signer: TSDKSigner, processing_try_index: UInt8? = nil) {
public init(abi: TSDKAbi, address: String? = nil, deploy_set: TSDKDeploySet? = nil, call_set: TSDKCallSet? = nil, signer: TSDKSigner, processing_try_index: UInt8? = nil, signature_id: Int32? = nil) {
self.abi = abi
self.address = address
self.deploy_set = deploy_set
self.call_set = call_set
self.signer = signer
self.processing_try_index = processing_try_index
self.signature_id = signature_id
}
}

Expand Down Expand Up @@ -753,22 +759,25 @@ public struct TSDKParamsOfGetSignatureData: Codable {
public var abi: TSDKAbi
/// Message BOC encoded in `base64`.
public var message: String
/// Signature ID to be used in unsigned data preparing when CapSignatureWithId capability is enabled
public var signature_id: Int32?

public init(abi: TSDKAbi, message: String) {
public init(abi: TSDKAbi, message: String, signature_id: Int32? = nil) {
self.abi = abi
self.message = message
self.signature_id = signature_id
}
}

public struct TSDKResultOfGetSignatureData: Codable {
/// Signature from the message in `hex`.
public var signature: String
/// Hash to verify the signature in `base64`.
public var hash: String
/// Data to verify the signature in `base64`.
public var unsigned: String

public init(signature: String, hash: String) {
public init(signature: String, unsigned: String) {
self.signature = signature
self.hash = hash
self.unsigned = unsigned
}
}

26 changes: 21 additions & 5 deletions Sources/EverscaleClientSwift/Client/ClientTypes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ public struct TSDKClientError: Codable, LocalizedError {
}

public struct TSDKClientConfig: Codable {
public var binding: TSDKBindingConfig?
public var network: TSDKNetworkConfig?
public var crypto: TSDKCryptoConfig?
public var abi: TSDKAbiConfig?
Expand All @@ -90,7 +91,8 @@ public struct TSDKClientConfig: Codable {
/// For file based storage is a folder name where SDK will store its data. For browser based is a browser async storage key prefix. Default (recommended) value is "~/.tonclient" for native environments and ".tonclient" for web-browser.
public var local_storage_path: String?

public init(network: TSDKNetworkConfig? = nil, crypto: TSDKCryptoConfig? = nil, abi: TSDKAbiConfig? = nil, boc: TSDKBocConfig? = nil, proofs: TSDKProofsConfig? = nil, local_storage_path: String? = nil) {
public init(binding: TSDKBindingConfig? = nil, network: TSDKNetworkConfig? = nil, crypto: TSDKCryptoConfig? = nil, abi: TSDKAbiConfig? = nil, boc: TSDKBocConfig? = nil, proofs: TSDKProofsConfig? = nil, local_storage_path: String? = nil) {
self.binding = binding
self.network = network
self.crypto = crypto
self.abi = abi
Expand Down Expand Up @@ -155,10 +157,13 @@ public struct TSDKNetworkConfig: Codable {
/// Subsequent REMP status awaiting timeout. If no status received 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?
/// Network signature ID which is used by VM in signature verifying instructions if capability `CapSignatureWithId` is enabled in blockchain configuration parameters.
/// This parameter should be set to `global_id` field from any blockchain block if network cannot be reachable at the moment of message encoding and the message is aimed to be sent intonetwork with `CapSignatureWithId` enabled. Otherwise signature ID is detected automaticallyinside message encoding functions
public var signature_id: Int32?
/// Access key to GraphQL API (Project secret)
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, first_remp_status_timeout: UInt32? = nil, next_remp_status_timeout: UInt32? = 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, signature_id: Int32? = nil, access_key: String? = nil) {
self.server_address = server_address
self.endpoints = endpoints
self.network_retries_count = network_retries_count
Expand All @@ -175,19 +180,30 @@ public struct TSDKNetworkConfig: Codable {
self.queries_protocol = queries_protocol
self.first_remp_status_timeout = first_remp_status_timeout
self.next_remp_status_timeout = next_remp_status_timeout
self.signature_id = signature_id
self.access_key = access_key
}
}

public struct TSDKBindingConfig: Codable {
public var library: String?
public var version: String?

public init(library: String? = nil, version: String? = nil) {
self.library = library
self.version = version
}
}

public struct TSDKCryptoConfig: Codable {
/// Mnemonic dictionary that will be used by default in crypto functions. If not specified, 1 dictionary will be used.
public var mnemonic_dictionary: UInt8?
/// Mnemonic dictionary that will be used by default in crypto functions. If not specified, `English` dictionary will be used.
public var mnemonic_dictionary: TSDKMnemonicDictionary?
/// Mnemonic word count that will be used by default in crypto functions. If not specified the default value will be 12.
public var mnemonic_word_count: UInt8?
/// Derivation path that will be used by default in crypto functions. If not specified `m/44'/396'/0'/0/0` will be used.
public var hdkey_derivation_path: String?

public init(mnemonic_dictionary: UInt8? = nil, mnemonic_word_count: UInt8? = nil, hdkey_derivation_path: String? = nil) {
public init(mnemonic_dictionary: TSDKMnemonicDictionary? = nil, mnemonic_word_count: UInt8? = nil, hdkey_derivation_path: String? = nil) {
self.mnemonic_dictionary = mnemonic_dictionary
self.mnemonic_word_count = mnemonic_word_count
self.hdkey_derivation_path = hdkey_derivation_path
Expand Down
12 changes: 12 additions & 0 deletions Sources/EverscaleClientSwift/Crypto/CryptoTypes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,18 @@ public enum TSDKBoxEncryptionAlgorithmEnumTypes: String, Codable {
case NaclSecretBox = "NaclSecretBox"
}

public enum TSDKMnemonicDictionary: Int, Codable {
case Ton = 0
case English = 1
case ChineseSimplified = 2
case ChineseTraditional = 3
case French = 4
case Italian = 5
case Japanese = 6
case Korean = 7
case Spanish = 8
}

public enum TSDKParamsOfAppPasswordProviderEnumTypes: String, Codable {
case GetPassword = "GetPassword"
}
Expand Down
11 changes: 11 additions & 0 deletions Sources/EverscaleClientSwift/Net/Net.swift
Original file line number Diff line number Diff line change
Expand Up @@ -346,4 +346,15 @@ public final class TSDKNetModule {
}
}

/// Returns signature ID for configured network if it should be used in messages signature
public func get_signature_id(_ handler: @escaping (TSDKBindingResponse<TSDKResultOfGetSignatureId, TSDKClientError>) throws -> Void
) throws {
let method: String = "get_signature_id"
try binding.requestLibraryAsync(methodName(module, method), "") { (requestId, params, responseType, finished) in
var response: TSDKBindingResponse<TSDKResultOfGetSignatureId, TSDKClientError> = .init()
response.update(requestId, params, responseType, finished)
try handler(response)
}
}

}
9 changes: 9 additions & 0 deletions Sources/EverscaleClientSwift/Net/NetTypes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -533,3 +533,12 @@ public struct TSDKResultOfIteratorNext: Codable {
}
}

public struct TSDKResultOfGetSignatureId: Codable {
/// Signature ID for configured network if it should be used in messages signature
public var signature_id: Int32?

public init(signature_id: Int32? = nil) {
self.signature_id = signature_id
}
}

8 changes: 5 additions & 3 deletions Sources/EverscaleClientSwift/Processing/ProcessingTypes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,20 @@ public enum TSDKProcessingEventEnumTypes: String, Codable {

public struct TSDKProcessingEvent: Codable {
public var type: TSDKProcessingEventEnumTypes
public var message_id: String?
public var message_dst: String?
public var error: TSDKClientError?
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, timestamp: Int? = nil, json: AnyValue? = nil) {
public init(type: TSDKProcessingEventEnumTypes, message_id: String? = nil, message_dst: String? = nil, error: TSDKClientError? = nil, shard_block_id: String? = nil, message: String? = nil, timestamp: Int? = nil, json: AnyValue? = nil) {
self.type = type
self.message_id = message_id
self.message_dst = message_dst
self.error = error
self.shard_block_id = shard_block_id
self.message_id = message_id
self.message = message
self.timestamp = timestamp
self.json = json
Expand Down
5 changes: 4 additions & 1 deletion Sources/EverscaleClientSwift/Tvm/TvmTypes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,16 @@ public struct TSDKExecutionOptions: Codable {
public var transaction_lt: Int?
/// Overrides standard TVM behaviour. If set to `true` then CHKSIG always will return `true`.
public var chksig_always_succeed: Bool?
/// Signature ID to be used in signature verifying instructions when CapSignatureWithId capability is enabled
public var signature_id: Int32?

public init(blockchain_config: String? = nil, block_time: UInt32? = nil, block_lt: Int? = nil, transaction_lt: Int? = nil, chksig_always_succeed: Bool? = nil) {
public init(blockchain_config: String? = nil, block_time: UInt32? = nil, block_lt: Int? = nil, transaction_lt: Int? = nil, chksig_always_succeed: Bool? = nil, signature_id: Int32? = nil) {
self.blockchain_config = blockchain_config
self.block_time = block_time
self.block_lt = block_lt
self.transaction_lt = transaction_lt
self.chksig_always_succeed = chksig_always_succeed
self.signature_id = signature_id
}
}

Expand Down

0 comments on commit 1ae76df

Please sign in to comment.