Skip to content

Commit

Permalink
migrate to AnyValue
Browse files Browse the repository at this point in the history
  • Loading branch information
nerzh committed Jul 14, 2021
1 parent a5566fe commit 25db8fb
Show file tree
Hide file tree
Showing 15 changed files with 154 additions and 236 deletions.
4 changes: 2 additions & 2 deletions Sources/ApiParser/TypeConverter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ private let types: [String: String] = [
"Int32": "Int32",
"Int64": "Int64",
"String": "String",
"Value": "AnyJSONType",
"Value": "AnyValue",
"BigInt": "Int",
"Boolean": "Bool"
]
Expand Down Expand Up @@ -140,7 +140,7 @@ class SDKApi {
for field in (from.struct_fields ?? []) {
if isValidPropertyName(field.name) {
var type: String = generateType(field)
if ((from.name ?? "")[#"Params"#] || (field.name ?? "")[#"input"#]) && type[#"AnyJSONType"#] {
if ((from.name ?? "")[#"Params"#] || (field.name ?? "")[#"input"#]) && type[#"AnyValue"#] {
let optional: String = type[#"\?"#] ? "?" : ""
type = "AnyValue\(optional)"
} else if type[#"AbiContract"#] {
Expand Down
12 changes: 6 additions & 6 deletions Sources/TonClientSwift/Abi/AbiTypes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -98,15 +98,15 @@ public struct TSDKDeploySet: Codable {
/// Default is `0`.
public var workchain_id: Int32?
/// List of initial values for contract's public variables.
public var initial_data: AnyJSONType?
public var initial_data: AnyValue?
/// Optional public key that can be provided in deploy set in order to substitute one in TVM file or provided by Signer.
/// Public key resolving priority:
/// 1. Public key from deploy set.
/// 2. Public key, specified in TVM file.
/// 3. Public key, provided by Signer.
public var initial_pubkey: String?

public init(tvc: String, workchain_id: Int32? = nil, initial_data: AnyJSONType? = nil, initial_pubkey: String? = nil) {
public init(tvc: String, workchain_id: Int32? = nil, initial_data: AnyValue? = nil, initial_pubkey: String? = nil) {
self.tvc = tvc
self.workchain_id = workchain_id
self.initial_data = initial_data
Expand Down Expand Up @@ -470,11 +470,11 @@ public struct TSDKDecodedMessageBody: Codable {
/// Function or event name.
public var name: String
/// Parameters or result value.
public var value: AnyJSONType?
public var value: AnyValue?
/// Function header.
public var header: TSDKFunctionHeader?

public init(body_type: TSDKMessageBodyType, name: String, value: AnyJSONType? = nil, header: TSDKFunctionHeader? = nil) {
public init(body_type: TSDKMessageBodyType, name: String, value: AnyValue? = nil, header: TSDKFunctionHeader? = nil) {
self.body_type = body_type
self.name = name
self.value = value
Expand Down Expand Up @@ -546,9 +546,9 @@ public struct TSDKParamsOfDecodeAccountData: Codable {

public struct TSDKResultOfDecodeData: Codable {
/// Decoded data as a JSON structure.
public var data: AnyJSONType
public var data: AnyValue

public init(data: AnyJSONType) {
public init(data: AnyValue) {
self.data = data
}
}
Expand Down
12 changes: 6 additions & 6 deletions Sources/TonClientSwift/Binding/BindingTypes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import Foundation

public struct TSDKContextResponse: Codable {
public var result: UInt32?
public var error: AnyJSONType?
public var error: AnyValue?
}

public struct TSDKBindingRequest<TSDKResult: Codable, TSDKError: Codable, TSDKCustom: Codable> {
Expand All @@ -26,12 +26,12 @@ public enum TSDKBindingResponseType: UInt32 {
public struct TSDKNoneResult: Codable {}

public struct TSDKDefault: Codable {
public var result: AnyJSONType?
public var error: AnyJSONType?
public var data: AnyJSONType?
public var message: AnyJSONType?
public var result: AnyValue?
public var error: AnyValue?
public var data: AnyValue?
public var message: AnyValue?

public init(result: AnyJSONType? = nil, error: AnyJSONType? = nil, data: AnyJSONType? = nil, message: AnyJSONType? = nil) {
public init(result: AnyValue? = nil, error: AnyValue? = nil, data: AnyValue? = nil, message: AnyValue? = nil) {
self.result = result
self.error = error
self.data = data
Expand Down
8 changes: 4 additions & 4 deletions Sources/TonClientSwift/Boc/BocTypes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ public struct TSDKParamsOfParse: Codable {

public struct TSDKResultOfParse: Codable {
/// JSON containing parsed BOC
public var parsed: AnyJSONType
public var parsed: AnyValue

public init(parsed: AnyJSONType) {
public init(parsed: AnyValue) {
self.parsed = parsed
}
}
Expand Down Expand Up @@ -177,13 +177,13 @@ public struct TSDKBuilderOp: Codable {
/// e.g. `123`, `-123`. - Decimal string. e.g. `"123"`, `"-123"`.
/// - `0x` prefixed hexadecimal string.
/// e.g `0x123`, `0X123`, `-0x123`.
public var value: AnyJSONType?
public var value: AnyValue?
/// Nested cell builder
public var builder: [TSDKBuilderOp]?
/// Nested cell BOC encoded with `base64` or BOC cache key.
public var boc: String?

public init(type: TSDKBuilderOpEnumTypes, size: UInt32? = nil, value: AnyJSONType? = nil, builder: [TSDKBuilderOp]? = nil, boc: String? = nil) {
public init(type: TSDKBuilderOpEnumTypes, size: UInt32? = nil, value: AnyValue? = nil, builder: [TSDKBuilderOp]? = nil, boc: String? = nil) {
self.type = type
self.size = size
self.value = value
Expand Down
12 changes: 6 additions & 6 deletions Sources/TonClientSwift/Client/ClientTypes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ public enum TSDKAppRequestResultEnumTypes: String, Codable {
public struct TSDKClientError: Codable, Error {
public var code: UInt32
public var message: String
public var data: AnyJSONType
public var data: AnyValue

public init(code: UInt32, message: String, data: AnyJSONType) {
public init(code: UInt32, message: String, data: AnyValue) {
self.code = code
self.message = message
self.data = data
Expand Down Expand Up @@ -196,19 +196,19 @@ public struct TSDKAppRequestResult: Codable {
/// Error description
public var text: String?
/// Request processing result
public var result: AnyJSONType?
public var result: AnyValue?

public init(type: TSDKAppRequestResultEnumTypes, text: String? = nil, result: AnyJSONType? = nil) {
public init(type: TSDKAppRequestResultEnumTypes, text: String? = nil, result: AnyValue? = nil) {
self.type = type
self.text = text
self.result = result
}
}

public struct TSDKResultOfGetApiReference: Codable {
public var api: AnyJSONType
public var api: AnyValue

public init(api: AnyJSONType) {
public init(api: AnyValue) {
self.api = api
}
}
Expand Down
6 changes: 3 additions & 3 deletions Sources/TonClientSwift/Crypto/CryptoTypes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@ public struct TSDKEncryptionBoxInfo: Codable {
/// Cryptographic algorithm, used by this encryption box
public var algorithm: String?
/// Options, depends on algorithm and specific encryption box implementation
public var options: AnyJSONType?
public var options: AnyValue?
/// Public information, depends on algorithm
public var `public`: AnyJSONType?
public var `public`: AnyValue?

public init(hdpath: String? = nil, algorithm: String? = nil, options: AnyJSONType? = nil, `public`: AnyJSONType? = nil) {
public init(hdpath: String? = nil, algorithm: String? = nil, options: AnyValue? = nil, `public`: AnyValue? = nil) {
self.hdpath = hdpath
self.algorithm = algorithm
self.options = options
Expand Down
Loading

0 comments on commit 25db8fb

Please sign in to comment.