From 5b5999ff33f7cdf2d27586e2fb06bcda416678cd Mon Sep 17 00:00:00 2001 From: Max Voloshinskii Date: Mon, 12 Aug 2024 14:26:45 +0300 Subject: [PATCH 1/3] Add custom_payload --- .../ton-api/Sources/Generated/Client.swift | 56 +++++ .../ton-api/Sources/Generated/Types.swift | 229 +++++++++++++++++- .../ton-api/openapi_generation/openapi.yml | 51 ++++ 3 files changed, 335 insertions(+), 1 deletion(-) diff --git a/Packages/ton-api/Sources/Generated/Client.swift b/Packages/ton-api/Sources/Generated/Client.swift index e00b721..c2cb021 100644 --- a/Packages/ton-api/Sources/Generated/Client.swift +++ b/Packages/ton-api/Sources/Generated/Client.swift @@ -3691,6 +3691,62 @@ public struct Client: APIProtocol { } ) } + /// Get jetton's custom payload and state init required for transfer + /// + /// - Remark: HTTP `GET /v2/jettons/{jetton_id}/transfer/{account_id}/payload`. + /// - Remark: Generated from `#/paths//v2/jettons/{jetton_id}/transfer/{account_id}/payload/get(getJettonTransferPayload)`. + public func getJettonTransferPayload(_ input: Operations.getJettonTransferPayload.Input) async throws + -> Operations.getJettonTransferPayload.Output + { + try await client.send( + input: input, + forOperation: Operations.getJettonTransferPayload.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/v2/jettons/{}/transfer/{}/payload", + parameters: [input.path.account_id, input.path.jetton_id] + ) + var request: HTTPTypes.HTTPRequest = .init(soar_path: path, method: .get) + suppressMutabilityWarning(&request) + converter.setAcceptHeader(in: &request.headerFields, contentTypes: input.headers.accept) + return (request, nil) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.getJettonTransferPayload.Output.Ok.Body + if try contentType == nil + || converter.isMatchingContentType(received: contentType, expectedRaw: "application/json") + { + body = try await converter.getResponseBodyAsJSON( + Components.Schemas.JettonTransferPayload.self, + from: responseBody, + transforming: { value in .json(value) } + ) + } else { + throw converter.makeUnexpectedContentTypeError(contentType: contentType) + } + return .ok(.init(body: body)) + default: + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Components.Responses._Error.Body + if try contentType == nil + || converter.isMatchingContentType(received: contentType, expectedRaw: "application/json") + { + body = try await converter.getResponseBodyAsJSON( + Components.Responses._Error.Body.jsonPayload.self, + from: responseBody, + transforming: { value in .json(value) } + ) + } else { + throw converter.makeUnexpectedContentTypeError(contentType: contentType) + } + return .`default`(statusCode: response.status.code, .init(body: body)) + } + } + ) + } /// Get only jetton transfers in the event /// /// - Remark: HTTP `GET /v2/events/{event_id}/jettons`. diff --git a/Packages/ton-api/Sources/Generated/Types.swift b/Packages/ton-api/Sources/Generated/Types.swift index 9605fde..16f2947 100644 --- a/Packages/ton-api/Sources/Generated/Types.swift +++ b/Packages/ton-api/Sources/Generated/Types.swift @@ -339,6 +339,12 @@ public protocol APIProtocol: Sendable { /// - Remark: HTTP `GET /v2/jettons/{account_id}/holders`. /// - Remark: Generated from `#/paths//v2/jettons/{account_id}/holders/get(getJettonHolders)`. func getJettonHolders(_ input: Operations.getJettonHolders.Input) async throws -> Operations.getJettonHolders.Output + /// Get jetton's custom payload and state init required for transfer + /// + /// - Remark: HTTP `GET /v2/jettons/{jetton_id}/transfer/{account_id}/payload`. + /// - Remark: Generated from `#/paths//v2/jettons/{jetton_id}/transfer/{account_id}/payload/get(getJettonTransferPayload)`. + func getJettonTransferPayload(_ input: Operations.getJettonTransferPayload.Input) async throws + -> Operations.getJettonTransferPayload.Output /// Get only jetton transfers in the event /// /// - Remark: HTTP `GET /v2/events/{event_id}/jettons`. @@ -1128,6 +1134,16 @@ extension APIProtocol { ) async throws -> Operations.getJettonHolders.Output { try await getJettonHolders(Operations.getJettonHolders.Input(path: path, query: query, headers: headers)) } + /// Get jetton's custom payload and state init required for transfer + /// + /// - Remark: HTTP `GET /v2/jettons/{jetton_id}/transfer/{account_id}/payload`. + /// - Remark: Generated from `#/paths//v2/jettons/{jetton_id}/transfer/{account_id}/payload/get(getJettonTransferPayload)`. + public func getJettonTransferPayload( + path: Operations.getJettonTransferPayload.Input.Path, + headers: Operations.getJettonTransferPayload.Input.Headers = .init() + ) async throws -> Operations.getJettonTransferPayload.Output { + try await getJettonTransferPayload(Operations.getJettonTransferPayload.Input(path: path, headers: headers)) + } /// Get only jetton transfers in the event /// /// - Remark: HTTP `GET /v2/events/{event_id}/jettons`. @@ -4654,6 +4670,30 @@ public enum Components { public var wallet_address: Components.Schemas.AccountAddress /// - Remark: Generated from `#/components/schemas/JettonBalance/jetton`. public var jetton: Components.Schemas.JettonPreview + /// - Remark: Generated from `#/components/schemas/JettonBalance/extensions`. + public var extensions: [Swift.String]? + /// - Remark: Generated from `#/components/schemas/JettonBalance/lock`. + public struct lockPayload: Codable, Hashable, Sendable { + /// - Remark: Generated from `#/components/schemas/JettonBalance/lock/amount`. + public var amount: Swift.String + /// - Remark: Generated from `#/components/schemas/JettonBalance/lock/till`. + public var till: Swift.Int64 + /// Creates a new `lockPayload`. + /// + /// - Parameters: + /// - amount: + /// - till: + public init(amount: Swift.String, till: Swift.Int64) { + self.amount = amount + self.till = till + } + public enum CodingKeys: String, CodingKey { + case amount + case till + } + } + /// - Remark: Generated from `#/components/schemas/JettonBalance/lock`. + public var lock: Components.Schemas.JettonBalance.lockPayload? /// Creates a new `JettonBalance`. /// /// - Parameters: @@ -4661,22 +4701,30 @@ public enum Components { /// - price: /// - wallet_address: /// - jetton: + /// - extensions: + /// - lock: public init( balance: Swift.String, price: Components.Schemas.TokenRates? = nil, wallet_address: Components.Schemas.AccountAddress, - jetton: Components.Schemas.JettonPreview + jetton: Components.Schemas.JettonPreview, + extensions: [Swift.String]? = nil, + lock: Components.Schemas.JettonBalance.lockPayload? = nil ) { self.balance = balance self.price = price self.wallet_address = wallet_address self.jetton = jetton + self.extensions = extensions + self.lock = lock } public enum CodingKeys: String, CodingKey { case balance case price case wallet_address case jetton + case extensions + case lock } } /// - Remark: Generated from `#/components/schemas/JettonsBalances`. @@ -5014,6 +5062,8 @@ public enum Components { case DomainRenew = "DomainRenew" case Unknown = "Unknown" } + /// - Remark: Generated from `#/components/schemas/Action/type`. + public var _type: Components.Schemas.Action._typePayload /// - Remark: Generated from `#/components/schemas/Action/status`. @frozen public enum statusPayload: String, Codable, Hashable, Sendable { case ok = "ok" @@ -5062,6 +5112,7 @@ public enum Components { /// Creates a new `Action`. /// /// - Parameters: + /// - _type: /// - status: /// - TonTransfer: /// - ContractDeploy: @@ -5083,6 +5134,7 @@ public enum Components { /// - DomainRenew: /// - simple_preview: public init( + _type: Components.Schemas.Action._typePayload, status: Components.Schemas.Action.statusPayload, TonTransfer: Components.Schemas.TonTransferAction? = nil, ContractDeploy: Components.Schemas.ContractDeployAction? = nil, @@ -5104,6 +5156,7 @@ public enum Components { DomainRenew: Components.Schemas.DomainRenewAction? = nil, simple_preview: Components.Schemas.ActionSimplePreview ) { + self._type = _type self.status = status self.TonTransfer = TonTransfer self.ContractDeploy = ContractDeploy @@ -5126,6 +5179,7 @@ public enum Components { self.simple_preview = simple_preview } public enum CodingKeys: String, CodingKey { + case _type = "type" case status case TonTransfer case ContractDeploy @@ -7051,6 +7105,39 @@ public enum Components { public init(addresses: Components.Schemas.JettonHolders.addressesPayload) { self.addresses = addresses } public enum CodingKeys: String, CodingKey { case addresses } } + /// - Remark: Generated from `#/components/schemas/JettonTransferPayload`. + public struct JettonTransferPayload: Codable, Hashable, Sendable { + /// hex-encoded BoC + /// + /// - Remark: Generated from `#/components/schemas/JettonTransferPayload/custom_payload`. + public var custom_payload: Swift.String? + /// hex-encoded BoC + /// + /// - Remark: Generated from `#/components/schemas/JettonTransferPayload/state_init`. + public var state_init: Swift.String? + /// - Remark: Generated from `#/components/schemas/JettonTransferPayload/payload`. + public var payload: OpenAPIRuntime.OpenAPIValueContainer + /// Creates a new `JettonTransferPayload`. + /// + /// - Parameters: + /// - custom_payload: hex-encoded BoC + /// - state_init: hex-encoded BoC + /// - payload: + public init( + custom_payload: Swift.String? = nil, + state_init: Swift.String? = nil, + payload: OpenAPIRuntime.OpenAPIValueContainer + ) { + self.custom_payload = custom_payload + self.state_init = state_init + self.payload = payload + } + public enum CodingKeys: String, CodingKey { + case custom_payload + case state_init + case payload + } + } /// - Remark: Generated from `#/components/schemas/AccountStaking`. public struct AccountStaking: Codable, Hashable, Sendable { /// - Remark: Generated from `#/components/schemas/AccountStaking/pools`. @@ -16080,6 +16167,146 @@ public enum Operations { public static var allCases: [Self] { [.json] } } } + /// Get jetton's custom payload and state init required for transfer + /// + /// - Remark: HTTP `GET /v2/jettons/{jetton_id}/transfer/{account_id}/payload`. + /// - Remark: Generated from `#/paths//v2/jettons/{jetton_id}/transfer/{account_id}/payload/get(getJettonTransferPayload)`. + public enum getJettonTransferPayload { + public static let id: Swift.String = "getJettonTransferPayload" + public struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/v2/jettons/{jetton_id}/transfer/{account_id}/payload/GET/path`. + public struct Path: Sendable, Hashable { + /// account ID + /// + /// - Remark: Generated from `#/paths/v2/jettons/{jetton_id}/transfer/{account_id}/payload/GET/path/account_id`. + public var account_id: Components.Parameters.accountIDParameter + /// jetton ID + /// + /// - Remark: Generated from `#/paths/v2/jettons/{jetton_id}/transfer/{account_id}/payload/GET/path/jetton_id`. + public var jetton_id: Components.Parameters.jettonIDParameter + /// Creates a new `Path`. + /// + /// - Parameters: + /// - account_id: account ID + /// - jetton_id: jetton ID + public init( + account_id: Components.Parameters.accountIDParameter, + jetton_id: Components.Parameters.jettonIDParameter + ) { + self.account_id = account_id + self.jetton_id = jetton_id + } + } + public var path: Operations.getJettonTransferPayload.Input.Path + /// - Remark: Generated from `#/paths/v2/jettons/{jetton_id}/transfer/{account_id}/payload/GET/header`. + public struct Headers: Sendable, Hashable { + public var accept: + [OpenAPIRuntime.AcceptHeaderContentType] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + public init( + accept: [OpenAPIRuntime.AcceptHeaderContentType< + Operations.getJettonTransferPayload.AcceptableContentType + >] = .defaultValues() + ) { self.accept = accept } + } + public var headers: Operations.getJettonTransferPayload.Input.Headers + /// Creates a new `Input`. + /// + /// - Parameters: + /// - path: + /// - headers: + public init( + path: Operations.getJettonTransferPayload.Input.Path, + headers: Operations.getJettonTransferPayload.Input.Headers = .init() + ) { + self.path = path + self.headers = headers + } + } + @frozen public enum Output: Sendable, Hashable { + public struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/v2/jettons/{jetton_id}/transfer/{account_id}/payload/GET/responses/200/content`. + @frozen public enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/v2/jettons/{jetton_id}/transfer/{account_id}/payload/GET/responses/200/content/application\/json`. + case json(Components.Schemas.JettonTransferPayload) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + public var json: Components.Schemas.JettonTransferPayload { + get throws { + switch self { + case let .json(body): return body + } + } + } + } + /// Received HTTP response body + public var body: Operations.getJettonTransferPayload.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - body: Received HTTP response body + public init(body: Operations.getJettonTransferPayload.Output.Ok.Body) { self.body = body } + } + /// jetton's custom payload + /// + /// - Remark: Generated from `#/paths//v2/jettons/{jetton_id}/transfer/{account_id}/payload/get(getJettonTransferPayload)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.getJettonTransferPayload.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + public var ok: Operations.getJettonTransferPayload.Output.Ok { + get throws { + switch self { + case let .ok(response): return response + default: try throwUnexpectedResponseStatus(expectedStatus: "ok", response: self) + } + } + } + /// Some error during request processing + /// + /// - Remark: Generated from `#/paths//v2/jettons/{jetton_id}/transfer/{account_id}/payload/get(getJettonTransferPayload)/responses/default`. + /// + /// HTTP response code: `default`. + case `default`(statusCode: Swift.Int, Components.Responses._Error) + /// The associated value of the enum case if `self` is `.`default``. + /// + /// - Throws: An error if `self` is not `.`default``. + /// - SeeAlso: `.`default``. + public var `default`: Components.Responses._Error { + get throws { + switch self { + case let .`default`(_, response): return response + default: try throwUnexpectedResponseStatus(expectedStatus: "default", response: self) + } + } + } + } + @frozen public enum AcceptableContentType: AcceptableProtocol { + case json + case other(Swift.String) + public init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/json": self = .json + default: self = .other(rawValue) + } + } + public var rawValue: Swift.String { + switch self { + case let .other(string): return string + case .json: return "application/json" + } + } + public static var allCases: [Self] { [.json] } + } + } /// Get only jetton transfers in the event /// /// - Remark: HTTP `GET /v2/events/{event_id}/jettons`. diff --git a/Packages/ton-api/openapi_generation/openapi.yml b/Packages/ton-api/openapi_generation/openapi.yml index 302ca08..2fa8f25 100644 --- a/Packages/ton-api/openapi_generation/openapi.yml +++ b/Packages/ton-api/openapi_generation/openapi.yml @@ -1380,6 +1380,24 @@ paths: $ref: '#/components/schemas/JettonHolders' 'default': $ref: '#/components/responses/Error' + /v2/jettons/{jetton_id}/transfer/{account_id}/payload: + get: + description: Get jetton's custom payload and state init required for transfer + operationId: getJettonTransferPayload + tags: + - Jettons + parameters: + - $ref: '#/components/parameters/accountIDParameter' + - $ref: '#/components/parameters/jettonIDParameter' + responses: + '200': + description: jetton's custom payload + content: + application/json: + schema: + $ref: '#/components/schemas/JettonTransferPayload' + 'default': + $ref: '#/components/responses/Error' /v2/events/{event_id}/jettons: get: description: "Get only jetton transfers in the event" @@ -4578,6 +4596,26 @@ components: $ref: '#/components/schemas/AccountAddress' jetton: $ref: '#/components/schemas/JettonPreview' + extensions: + type: array + items: + type: string + example: + - custom_payload + - non_transferable + lock: + type: object + required: + - amount + - till + properties: + amount: + type: string + example: 597968399 + till: + type: integer + format: int64 + example: 1678223064 JettonsBalances: type: object required: @@ -5845,6 +5883,19 @@ components: balance: type: string example: 1000000000 + JettonTransferPayload: + type: object + required: + - payload + properties: + custom_payload: + type: string + description: "hex-encoded BoC" + example: "b5ee9c72410212010001b40009460395b521c9251151ae7987e03c544bd275d6cd42c2d157f840beb14d5454b96718000d012205817002020328480101fd7f6a648d4f771d7f0abc1707e4e806b19de1801f65eb8c133a4cfb0c33d847000b22012004052848010147da975b922d89192f4c9b68a640daa6764ec398c93cec025e17f0c1852a711a0009220120061122012007082848010170d9fb0423cbef6c2cf1f3811a2f640daf8c9a326b6f8816c1b993e90d88e2100006220120090a28480101f6df1d75f6b9e45f224b2cb4fc2286d927d47b468b6dbf1fedc4316290ec2ae900042201200b102201200c0f2201200d" + state_init: + type: string + description: "hex-encoded BoC" + example: "b5ee9c72410212010001b40009460395b521c9251151ae7987e03c544bd275d6cd42c2d157f840beb14d5454b96718000d012205817002020328480101fd7f6a648d4f771d7f0abc1707e4e806b19de1801f65eb8c133a4cfb0c33d847000b22012004052848010147da975b922d89192f4c9b68a640daa6764ec398c93cec025e17f0c1852a711a0009220120061122012007082848010170d9fb0423cbef6c2cf1f3811a2f640daf8c9a326b6f8816c1b993e90d88e2100006220120090a28480101f6df1d75f6b9e45f224b2cb4fc2286d927d47b468b6dbf1fedc4316290ec2ae900042201200b102201200c0f2201200d" AccountStaking: type: object required: From 2b55880d0d6052325c6da5b35abca5a2fef9d8d2 Mon Sep 17 00:00:00 2001 From: Max Voloshinskii Date: Tue, 13 Aug 2024 16:55:34 +0300 Subject: [PATCH 2/3] Add v2/status --- .../ton-api/Sources/Generated/Client.swift | 51 +++++ .../ton-api/Sources/Generated/Types.swift | 198 ++++++++++++++++++ .../ton-api/openapi_generation/openapi.yml | 70 ++++++- 3 files changed, 318 insertions(+), 1 deletion(-) diff --git a/Packages/ton-api/Sources/Generated/Client.swift b/Packages/ton-api/Sources/Generated/Client.swift index c2cb021..dde237a 100644 --- a/Packages/ton-api/Sources/Generated/Client.swift +++ b/Packages/ton-api/Sources/Generated/Client.swift @@ -36,6 +36,57 @@ public struct Client: APIProtocol { ) } private var converter: Converter { client.converter } + /// Status + /// + /// - Remark: HTTP `GET /v2/status`. + /// - Remark: Generated from `#/paths//v2/status/get(status)`. + public func status(_ input: Operations.status.Input) async throws -> Operations.status.Output { + try await client.send( + input: input, + forOperation: Operations.status.id, + serializer: { input in + let path = try converter.renderedPath(template: "/v2/status", parameters: []) + var request: HTTPTypes.HTTPRequest = .init(soar_path: path, method: .get) + suppressMutabilityWarning(&request) + converter.setAcceptHeader(in: &request.headerFields, contentTypes: input.headers.accept) + return (request, nil) + }, + deserializer: { response, responseBody in + switch response.status.code { + case 200: + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Operations.status.Output.Ok.Body + if try contentType == nil + || converter.isMatchingContentType(received: contentType, expectedRaw: "application/json") + { + body = try await converter.getResponseBodyAsJSON( + Components.Schemas.ServiceStatus.self, + from: responseBody, + transforming: { value in .json(value) } + ) + } else { + throw converter.makeUnexpectedContentTypeError(contentType: contentType) + } + return .ok(.init(body: body)) + default: + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Components.Responses._Error.Body + if try contentType == nil + || converter.isMatchingContentType(received: contentType, expectedRaw: "application/json") + { + body = try await converter.getResponseBodyAsJSON( + Components.Responses._Error.Body.jsonPayload.self, + from: responseBody, + transforming: { value in .json(value) } + ) + } else { + throw converter.makeUnexpectedContentTypeError(contentType: contentType) + } + return .`default`(statusCode: response.status.code, .init(body: body)) + } + } + ) + } /// Get blockchain block data /// /// - Remark: HTTP `GET /v2/blockchain/blocks/{block_id}`. diff --git a/Packages/ton-api/Sources/Generated/Types.swift b/Packages/ton-api/Sources/Generated/Types.swift index 16f2947..a839de6 100644 --- a/Packages/ton-api/Sources/Generated/Types.swift +++ b/Packages/ton-api/Sources/Generated/Types.swift @@ -11,6 +11,11 @@ import struct Foundation.Date #endif /// A type that performs HTTP operations defined by the OpenAPI document. public protocol APIProtocol: Sendable { + /// Status + /// + /// - Remark: HTTP `GET /v2/status`. + /// - Remark: Generated from `#/paths//v2/status/get(status)`. + func status(_ input: Operations.status.Input) async throws -> Operations.status.Output /// Get blockchain block data /// /// - Remark: HTTP `GET /v2/blockchain/blocks/{block_id}`. @@ -515,6 +520,13 @@ public protocol APIProtocol: Sendable { } /// Convenience overloads for operation inputs. extension APIProtocol { + /// Status + /// + /// - Remark: HTTP `GET /v2/status`. + /// - Remark: Generated from `#/paths//v2/status/get(status)`. + public func status(headers: Operations.status.Input.Headers = .init()) async throws -> Operations.status.Output { + try await status(Operations.status.Input(headers: headers)) + } /// Get blockchain block data /// /// - Remark: HTTP `GET /v2/blockchain/blocks/{block_id}`. @@ -1622,6 +1634,85 @@ public enum Components { case minted } } + /// - Remark: Generated from `#/components/schemas/ServiceStatus`. + public struct ServiceStatus: Codable, Hashable, Sendable { + /// - Remark: Generated from `#/components/schemas/ServiceStatus/rest_online`. + public var rest_online: Swift.Bool + /// - Remark: Generated from `#/components/schemas/ServiceStatus/indexing_latency`. + public var indexing_latency: Swift.Int + /// Creates a new `ServiceStatus`. + /// + /// - Parameters: + /// - rest_online: + /// - indexing_latency: + public init(rest_online: Swift.Bool, indexing_latency: Swift.Int) { + self.rest_online = rest_online + self.indexing_latency = indexing_latency + } + public enum CodingKeys: String, CodingKey { + case rest_online + case indexing_latency + } + } + /// - Remark: Generated from `#/components/schemas/ReducedBlock`. + public struct ReducedBlock: Codable, Hashable, Sendable { + /// - Remark: Generated from `#/components/schemas/ReducedBlock/workchain_id`. + public var workchain_id: Swift.Int32 + /// - Remark: Generated from `#/components/schemas/ReducedBlock/shard`. + public var shard: Swift.String + /// - Remark: Generated from `#/components/schemas/ReducedBlock/seqno`. + public var seqno: Swift.Int32 + /// - Remark: Generated from `#/components/schemas/ReducedBlock/master_ref`. + public var master_ref: Swift.String? + /// - Remark: Generated from `#/components/schemas/ReducedBlock/tx_quantity`. + public var tx_quantity: Swift.Int + /// - Remark: Generated from `#/components/schemas/ReducedBlock/utime`. + public var utime: Swift.Int64 + /// - Remark: Generated from `#/components/schemas/ReducedBlock/shards_blocks`. + public var shards_blocks: [Swift.String] + /// - Remark: Generated from `#/components/schemas/ReducedBlock/parent`. + public var parent: [Swift.String] + /// Creates a new `ReducedBlock`. + /// + /// - Parameters: + /// - workchain_id: + /// - shard: + /// - seqno: + /// - master_ref: + /// - tx_quantity: + /// - utime: + /// - shards_blocks: + /// - parent: + public init( + workchain_id: Swift.Int32, + shard: Swift.String, + seqno: Swift.Int32, + master_ref: Swift.String? = nil, + tx_quantity: Swift.Int, + utime: Swift.Int64, + shards_blocks: [Swift.String], + parent: [Swift.String] + ) { + self.workchain_id = workchain_id + self.shard = shard + self.seqno = seqno + self.master_ref = master_ref + self.tx_quantity = tx_quantity + self.utime = utime + self.shards_blocks = shards_blocks + self.parent = parent + } + public enum CodingKeys: String, CodingKey { + case workchain_id + case shard + case seqno + case master_ref + case tx_quantity + case utime + case shards_blocks + case parent + } + } /// - Remark: Generated from `#/components/schemas/BlockchainBlock`. public struct BlockchainBlock: Codable, Hashable, Sendable { /// - Remark: Generated from `#/components/schemas/BlockchainBlock/tx_quantity`. @@ -8163,6 +8254,113 @@ public enum Components { } /// API operations, with input and output types, generated from `#/paths` in the OpenAPI document. public enum Operations { + /// Status + /// + /// - Remark: HTTP `GET /v2/status`. + /// - Remark: Generated from `#/paths//v2/status/get(status)`. + public enum status { + public static let id: Swift.String = "status" + public struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/v2/status/GET/header`. + public struct Headers: Sendable, Hashable { + public var accept: [OpenAPIRuntime.AcceptHeaderContentType] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + public init( + accept: [OpenAPIRuntime.AcceptHeaderContentType] = + .defaultValues() + ) { self.accept = accept } + } + public var headers: Operations.status.Input.Headers + /// Creates a new `Input`. + /// + /// - Parameters: + /// - headers: + public init(headers: Operations.status.Input.Headers = .init()) { self.headers = headers } + } + @frozen public enum Output: Sendable, Hashable { + public struct Ok: Sendable, Hashable { + /// - Remark: Generated from `#/paths/v2/status/GET/responses/200/content`. + @frozen public enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/v2/status/GET/responses/200/content/application\/json`. + case json(Components.Schemas.ServiceStatus) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + public var json: Components.Schemas.ServiceStatus { + get throws { + switch self { + case let .json(body): return body + } + } + } + } + /// Received HTTP response body + public var body: Operations.status.Output.Ok.Body + /// Creates a new `Ok`. + /// + /// - Parameters: + /// - body: Received HTTP response body + public init(body: Operations.status.Output.Ok.Body) { self.body = body } + } + /// status + /// + /// - Remark: Generated from `#/paths//v2/status/get(status)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Operations.status.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + public var ok: Operations.status.Output.Ok { + get throws { + switch self { + case let .ok(response): return response + default: try throwUnexpectedResponseStatus(expectedStatus: "ok", response: self) + } + } + } + /// Some error during request processing + /// + /// - Remark: Generated from `#/paths//v2/status/get(status)/responses/default`. + /// + /// HTTP response code: `default`. + case `default`(statusCode: Swift.Int, Components.Responses._Error) + /// The associated value of the enum case if `self` is `.`default``. + /// + /// - Throws: An error if `self` is not `.`default``. + /// - SeeAlso: `.`default``. + public var `default`: Components.Responses._Error { + get throws { + switch self { + case let .`default`(_, response): return response + default: try throwUnexpectedResponseStatus(expectedStatus: "default", response: self) + } + } + } + } + @frozen public enum AcceptableContentType: AcceptableProtocol { + case json + case other(Swift.String) + public init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/json": self = .json + default: self = .other(rawValue) + } + } + public var rawValue: Swift.String { + switch self { + case let .other(string): return string + case .json: return "application/json" + } + } + public static var allCases: [Self] { [.json] } + } + } /// Get blockchain block data /// /// - Remark: HTTP `GET /v2/blockchain/blocks/{block_id}`. diff --git a/Packages/ton-api/openapi_generation/openapi.yml b/Packages/ton-api/openapi_generation/openapi.yml index 2fa8f25..fca3191 100644 --- a/Packages/ton-api/openapi_generation/openapi.yml +++ b/Packages/ton-api/openapi_generation/openapi.yml @@ -11,6 +11,21 @@ servers: - url: "https://testnet.tonapi.io" - url: "http://localhost:8081" paths: + /v2/status: + get: + description: Status + operationId: status + tags: + - Blockchain + responses: + '200': + description: status + content: + application/json: + schema: + $ref: '#/components/schemas/ServiceStatus' + 'default': + $ref: '#/components/responses/Error' /v2/blockchain/blocks/{block_id}: get: description: Get blockchain block data @@ -2894,7 +2909,60 @@ components: $ref: '#/components/schemas/BlockCurrencyCollection' minted: $ref: '#/components/schemas/BlockCurrencyCollection' - + ServiceStatus: + type: object + required: + - indexing_latency + - rest_online + properties: + rest_online: + type: boolean + default: true + indexing_latency: + type: integer + example: 100 + ReducedBlock: + type: object + required: + - workchain_id + - shard + - seqno + - tx_quantity + - utime + - shards_blocks + - parent + properties: + workchain_id: + type: integer + example: 0 + format: int32 + shard: + type: string + example: 8000000000000000 + seqno: + type: integer + example: 21734019 + format: int32 + master_ref: + type: string + example: (-1,4234234,8000000000000000) + tx_quantity: + type: integer + example: 130 + utime: + type: integer + format: int64 + example: 23814011000000 + shards_blocks: + type: array + items: + type: string + example: [ (0,4234235,8000000000000000) ] + parent: + type: array + items: + type: string + example: [ (0,21734018,8000000000000000) ] BlockchainBlock: type: object required: From 6d091d3e7a4826eccb33e4f168f161514310da05 Mon Sep 17 00:00:00 2001 From: Grigory Serebryanyy Date: Tue, 13 Aug 2024 20:31:49 +0300 Subject: [PATCH 3/3] Remove _type in Action --- Packages/ton-api/Sources/Generated/Types.swift | 5 ----- 1 file changed, 5 deletions(-) diff --git a/Packages/ton-api/Sources/Generated/Types.swift b/Packages/ton-api/Sources/Generated/Types.swift index a839de6..b483028 100644 --- a/Packages/ton-api/Sources/Generated/Types.swift +++ b/Packages/ton-api/Sources/Generated/Types.swift @@ -5153,8 +5153,6 @@ public enum Components { case DomainRenew = "DomainRenew" case Unknown = "Unknown" } - /// - Remark: Generated from `#/components/schemas/Action/type`. - public var _type: Components.Schemas.Action._typePayload /// - Remark: Generated from `#/components/schemas/Action/status`. @frozen public enum statusPayload: String, Codable, Hashable, Sendable { case ok = "ok" @@ -5225,7 +5223,6 @@ public enum Components { /// - DomainRenew: /// - simple_preview: public init( - _type: Components.Schemas.Action._typePayload, status: Components.Schemas.Action.statusPayload, TonTransfer: Components.Schemas.TonTransferAction? = nil, ContractDeploy: Components.Schemas.ContractDeployAction? = nil, @@ -5247,7 +5244,6 @@ public enum Components { DomainRenew: Components.Schemas.DomainRenewAction? = nil, simple_preview: Components.Schemas.ActionSimplePreview ) { - self._type = _type self.status = status self.TonTransfer = TonTransfer self.ContractDeploy = ContractDeploy @@ -5270,7 +5266,6 @@ public enum Components { self.simple_preview = simple_preview } public enum CodingKeys: String, CodingKey { - case _type = "type" case status case TonTransfer case ContractDeploy