diff --git a/antd-swift/Package.swift b/antd-swift/Package.swift index 9be2ec8..a326362 100644 --- a/antd-swift/Package.swift +++ b/antd-swift/Package.swift @@ -22,6 +22,7 @@ let package = Package( .target( name: "AntdSdk", dependencies: [ + .product(name: "GRPCCore", package: "grpc-swift"), .product(name: "GRPCNIOTransportHTTP2", package: "grpc-swift-nio-transport"), .product(name: "GRPCProtobuf", package: "grpc-swift-protobuf"), .product(name: "SwiftProtobuf", package: "swift-protobuf"), diff --git a/antd-swift/Sources/AntdSdk/AntdClient.swift b/antd-swift/Sources/AntdSdk/AntdClient.swift index b5d0a10..9113256 100644 --- a/antd-swift/Sources/AntdSdk/AntdClient.swift +++ b/antd-swift/Sources/AntdSdk/AntdClient.swift @@ -20,12 +20,20 @@ public enum AntdClient { } /// Create a gRPC client connecting to the antd daemon. + /// + /// > Requires macOS 15+ / iOS 18+ / tvOS 18+ / watchOS 11+ (grpc-swift 2.x). + /// > Use ``createRest(baseURL:timeout:)`` on older platforms. + /// /// - Parameter target: gRPC target address (default: localhost:50051) + @available(macOS 15.0, iOS 18.0, tvOS 18.0, watchOS 11.0, *) public static func createGrpc(target: String = "localhost:50051") -> AntdClientProtocol { AntdGrpcClient(target: target) } /// Create a client using the specified transport. + /// + /// > `transport: "grpc"` requires macOS 15+ / iOS 18+ / tvOS 18+ / watchOS 11+. + /// /// - Parameters: /// - transport: "rest" or "grpc" /// - endpoint: Optional custom endpoint override @@ -34,7 +42,11 @@ public enum AntdClient { case "rest": return createRest(baseURL: endpoint ?? "http://localhost:8082") case "grpc": - return createGrpc(target: endpoint ?? "localhost:50051") + if #available(macOS 15.0, iOS 18.0, tvOS 18.0, watchOS 11.0, *) { + return createGrpc(target: endpoint ?? "localhost:50051") + } else { + fatalError("gRPC transport requires macOS 15+ / iOS 18+. Use 'rest' on older platforms.") + } default: fatalError("Unknown transport: \(transport). Use 'rest' or 'grpc'.") } diff --git a/antd-swift/Sources/AntdSdk/AntdGrpcClient.swift b/antd-swift/Sources/AntdSdk/AntdGrpcClient.swift index 218e58b..06a625e 100644 --- a/antd-swift/Sources/AntdSdk/AntdGrpcClient.swift +++ b/antd-swift/Sources/AntdSdk/AntdGrpcClient.swift @@ -1,27 +1,62 @@ import Foundation +import GRPCCore import GRPCNIOTransportHTTP2 import GRPCProtobuf -/// gRPC client for the antd daemon. +/// gRPC client for the antd daemon (grpc-swift 2.x). /// -/// > Note: The gRPC client requires the generated protobuf stubs from `antd/proto/antd/v1/`. -/// > Run `scripts/generate-protos.sh` to generate them into `Sources/AntdSdk/Proto/`. -/// > Until proto generation is set up, use ``AntdRestClient`` instead. +/// > Note: grpc-swift 2.x requires macOS 15+ / iOS 18+ / tvOS 18+ / watchOS 11+. +/// > Use ``AntdRestClient`` via ``AntdClient/createRest(baseURL:timeout:)`` on +/// > older platforms. +/// +/// V2-286 implements the wallet surface (`walletAddress`, `walletBalance`, +/// `walletApprove`); other RPCs throw `notImplemented()` until subsequent +/// gRPC fan-out work lands. +@available(macOS 15.0, iOS 18.0, tvOS 18.0, watchOS 11.0, *) public final class AntdGrpcClient: AntdClientProtocol, @unchecked Sendable { - private let target: String + private let host: String + private let port: Int public init(target: String = "localhost:50051") { - self.target = target + let (h, p) = Self.parseTarget(target) + self.host = h + self.port = p + } + + /// Accepts `"host:port"` or `"host"` (default port 50051). + private static func parseTarget(_ target: String) -> (String, Int) { + if let colon = target.lastIndex(of: ":"), + let p = Int(target[target.index(after: colon)...]) { + return (String(target[..( + _ body: @Sendable (GRPCClient) async throws -> T + ) async throws -> T { + do { + let transport = try HTTP2ClientTransport.Posix( + target: .dns(host: host, port: port), + transportSecurity: .plaintext + ) + return try await withGRPCClient(transport: transport, handleClient: body) + } catch let rpcError as RPCError { + throw ErrorMapping.fromGRPCStatus(code: rpcError.code.rawValue, detail: rpcError.message) + } + } + + // MARK: - Out-of-scope (later gRPC tickets) private func notImplemented() -> AntdError { - InternalError("gRPC client requires generated proto stubs. Use AntdClient.createRest() or run scripts/generate-protos.sh first.") + InternalError("not yet implemented on the gRPC client; use AntdClient.createRest()") } public func health() async throws -> HealthStatus { throw notImplemented() } @@ -39,12 +74,39 @@ public final class AntdGrpcClient: AntdClientProtocol, @unchecked Sendable { public func filePutPublic(path: String, paymentMode: PaymentMode = .auto) async throws -> FilePutPublicResult { throw notImplemented() } public func fileGetPublic(address: String, destPath: String) async throws { throw notImplemented() } public func fileCost(path: String, isPublic: Bool = true, paymentMode: PaymentMode = .auto) async throws -> UploadCostEstimate { throw notImplemented() } - public func walletAddress() async throws -> WalletAddress { throw notImplemented() } - public func walletBalance() async throws -> WalletBalance { throw notImplemented() } - public func walletApprove() async throws -> Bool { throw notImplemented() } public func prepareUpload(path: String, visibility: String? = nil) async throws -> PrepareUploadResult { throw notImplemented() } public func prepareUploadPublic(path: String) async throws -> PrepareUploadResult { throw notImplemented() } public func prepareDataUpload(_ data: Data) async throws -> PrepareUploadResult { throw notImplemented() } public func finalizeUpload(uploadId: String, txHashes: [String: String]) async throws -> FinalizeUploadResult { throw notImplemented() } public func finalizeMerkleUpload(uploadId: String, winnerPoolHash: String) async throws -> FinalizeMerkleUploadResult { throw notImplemented() } + + // MARK: - Wallet (V2-286) + // + // A missing daemon wallet emits gRPC `failedPrecondition`, which + // `ErrorMapping.fromGRPCStatus` maps to `PaymentError`. (Semantic a bit + // off vs REST's 503 but matches every other SDK's gRPC->SDK mapping.) + + public func walletAddress() async throws -> WalletAddress { + try await withGRPC { client in + let req = Antd_V1_GetWalletAddressRequest() + let resp = try await Antd_V1_WalletService.Client(wrapping: client).getAddress(req) + return WalletAddress(address: resp.address) + } + } + + public func walletBalance() async throws -> WalletBalance { + try await withGRPC { client in + let req = Antd_V1_GetWalletBalanceRequest() + let resp = try await Antd_V1_WalletService.Client(wrapping: client).getBalance(req) + return WalletBalance(balance: resp.balance, gasBalance: resp.gasBalance) + } + } + + public func walletApprove() async throws -> Bool { + try await withGRPC { client in + let req = Antd_V1_WalletApproveRequest() + let resp = try await Antd_V1_WalletService.Client(wrapping: client).approve(req) + return resp.approved + } + } } diff --git a/antd-swift/Sources/AntdSdk/Proto/antd/v1/chunks.grpc.swift b/antd-swift/Sources/AntdSdk/Proto/antd/v1/chunks.grpc.swift new file mode 100644 index 0000000..d3554f9 --- /dev/null +++ b/antd-swift/Sources/AntdSdk/Proto/antd/v1/chunks.grpc.swift @@ -0,0 +1,503 @@ +// DO NOT EDIT. +// swift-format-ignore-file +// swiftlint:disable all +// +// Generated by the gRPC Swift generator plugin for the protocol buffer compiler. +// Source: antd/v1/chunks.proto +// +// For information on using the generated types, please see the documentation: +// https://github.com/grpc/grpc-swift + +import GRPCCore +import GRPCProtobuf + +// MARK: - antd.v1.ChunkService + +/// Namespace containing generated types for the "antd.v1.ChunkService" service. +@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) +public enum Antd_V1_ChunkService { + /// Service descriptor for the "antd.v1.ChunkService" service. + public static let descriptor = GRPCCore.ServiceDescriptor(fullyQualifiedService: "antd.v1.ChunkService") + /// Namespace for method metadata. + public enum Method { + /// Namespace for "Get" metadata. + public enum Get { + /// Request type for "Get". + public typealias Input = Antd_V1_GetChunkRequest + /// Response type for "Get". + public typealias Output = Antd_V1_GetChunkResponse + /// Descriptor for "Get". + public static let descriptor = GRPCCore.MethodDescriptor( + service: GRPCCore.ServiceDescriptor(fullyQualifiedService: "antd.v1.ChunkService"), + method: "Get" + ) + } + /// Namespace for "Put" metadata. + public enum Put { + /// Request type for "Put". + public typealias Input = Antd_V1_PutChunkRequest + /// Response type for "Put". + public typealias Output = Antd_V1_PutChunkResponse + /// Descriptor for "Put". + public static let descriptor = GRPCCore.MethodDescriptor( + service: GRPCCore.ServiceDescriptor(fullyQualifiedService: "antd.v1.ChunkService"), + method: "Put" + ) + } + /// Descriptors for all methods in the "antd.v1.ChunkService" service. + public static let descriptors: [GRPCCore.MethodDescriptor] = [ + Get.descriptor, + Put.descriptor + ] + } +} + +@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) +extension GRPCCore.ServiceDescriptor { + /// Service descriptor for the "antd.v1.ChunkService" service. + public static let antd_v1_ChunkService = GRPCCore.ServiceDescriptor(fullyQualifiedService: "antd.v1.ChunkService") +} + +// MARK: antd.v1.ChunkService (server) + +@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) +extension Antd_V1_ChunkService { + /// Streaming variant of the service protocol for the "antd.v1.ChunkService" service. + /// + /// This protocol is the lowest-level of the service protocols generated for this service + /// giving you the most flexibility over the implementation of your service. This comes at + /// the cost of more verbose and less strict APIs. Each RPC requires you to implement it in + /// terms of a request stream and response stream. Where only a single request or response + /// message is expected, you are responsible for enforcing this invariant is maintained. + /// + /// Where possible, prefer using the stricter, less-verbose ``ServiceProtocol`` + /// or ``SimpleServiceProtocol`` instead. + public protocol StreamingServiceProtocol: GRPCCore.RegistrableRPCService { + /// Handle the "Get" method. + /// + /// - Parameters: + /// - request: A streaming request of `Antd_V1_GetChunkRequest` messages. + /// - context: Context providing information about the RPC. + /// - Throws: Any error which occurred during the processing of the request. Thrown errors + /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted + /// to an internal error. + /// - Returns: A streaming response of `Antd_V1_GetChunkResponse` messages. + func get( + request: GRPCCore.StreamingServerRequest, + context: GRPCCore.ServerContext + ) async throws -> GRPCCore.StreamingServerResponse + + /// Handle the "Put" method. + /// + /// - Parameters: + /// - request: A streaming request of `Antd_V1_PutChunkRequest` messages. + /// - context: Context providing information about the RPC. + /// - Throws: Any error which occurred during the processing of the request. Thrown errors + /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted + /// to an internal error. + /// - Returns: A streaming response of `Antd_V1_PutChunkResponse` messages. + func put( + request: GRPCCore.StreamingServerRequest, + context: GRPCCore.ServerContext + ) async throws -> GRPCCore.StreamingServerResponse + } + + /// Service protocol for the "antd.v1.ChunkService" service. + /// + /// This protocol is higher level than ``StreamingServiceProtocol`` but lower level than + /// the ``SimpleServiceProtocol``, it provides access to request and response metadata and + /// trailing response metadata. If you don't need these then consider using + /// the ``SimpleServiceProtocol``. If you need fine grained control over your RPCs then + /// use ``StreamingServiceProtocol``. + public protocol ServiceProtocol: Antd_V1_ChunkService.StreamingServiceProtocol { + /// Handle the "Get" method. + /// + /// - Parameters: + /// - request: A request containing a single `Antd_V1_GetChunkRequest` message. + /// - context: Context providing information about the RPC. + /// - Throws: Any error which occurred during the processing of the request. Thrown errors + /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted + /// to an internal error. + /// - Returns: A response containing a single `Antd_V1_GetChunkResponse` message. + func get( + request: GRPCCore.ServerRequest, + context: GRPCCore.ServerContext + ) async throws -> GRPCCore.ServerResponse + + /// Handle the "Put" method. + /// + /// - Parameters: + /// - request: A request containing a single `Antd_V1_PutChunkRequest` message. + /// - context: Context providing information about the RPC. + /// - Throws: Any error which occurred during the processing of the request. Thrown errors + /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted + /// to an internal error. + /// - Returns: A response containing a single `Antd_V1_PutChunkResponse` message. + func put( + request: GRPCCore.ServerRequest, + context: GRPCCore.ServerContext + ) async throws -> GRPCCore.ServerResponse + } + + /// Simple service protocol for the "antd.v1.ChunkService" service. + /// + /// This is the highest level protocol for the service. The API is the easiest to use but + /// doesn't provide access to request or response metadata. If you need access to these + /// then use ``ServiceProtocol`` instead. + public protocol SimpleServiceProtocol: Antd_V1_ChunkService.ServiceProtocol { + /// Handle the "Get" method. + /// + /// - Parameters: + /// - request: A `Antd_V1_GetChunkRequest` message. + /// - context: Context providing information about the RPC. + /// - Throws: Any error which occurred during the processing of the request. Thrown errors + /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted + /// to an internal error. + /// - Returns: A `Antd_V1_GetChunkResponse` to respond with. + func get( + request: Antd_V1_GetChunkRequest, + context: GRPCCore.ServerContext + ) async throws -> Antd_V1_GetChunkResponse + + /// Handle the "Put" method. + /// + /// - Parameters: + /// - request: A `Antd_V1_PutChunkRequest` message. + /// - context: Context providing information about the RPC. + /// - Throws: Any error which occurred during the processing of the request. Thrown errors + /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted + /// to an internal error. + /// - Returns: A `Antd_V1_PutChunkResponse` to respond with. + func put( + request: Antd_V1_PutChunkRequest, + context: GRPCCore.ServerContext + ) async throws -> Antd_V1_PutChunkResponse + } +} + +// Default implementation of 'registerMethods(with:)'. +@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) +extension Antd_V1_ChunkService.StreamingServiceProtocol { + public func registerMethods(with router: inout GRPCCore.RPCRouter) where Transport: GRPCCore.ServerTransport { + router.registerHandler( + forMethod: Antd_V1_ChunkService.Method.Get.descriptor, + deserializer: GRPCProtobuf.ProtobufDeserializer(), + serializer: GRPCProtobuf.ProtobufSerializer(), + handler: { request, context in + try await self.get( + request: request, + context: context + ) + } + ) + router.registerHandler( + forMethod: Antd_V1_ChunkService.Method.Put.descriptor, + deserializer: GRPCProtobuf.ProtobufDeserializer(), + serializer: GRPCProtobuf.ProtobufSerializer(), + handler: { request, context in + try await self.put( + request: request, + context: context + ) + } + ) + } +} + +// Default implementation of streaming methods from 'StreamingServiceProtocol'. +@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) +extension Antd_V1_ChunkService.ServiceProtocol { + public func get( + request: GRPCCore.StreamingServerRequest, + context: GRPCCore.ServerContext + ) async throws -> GRPCCore.StreamingServerResponse { + let response = try await self.get( + request: GRPCCore.ServerRequest(stream: request), + context: context + ) + return GRPCCore.StreamingServerResponse(single: response) + } + + public func put( + request: GRPCCore.StreamingServerRequest, + context: GRPCCore.ServerContext + ) async throws -> GRPCCore.StreamingServerResponse { + let response = try await self.put( + request: GRPCCore.ServerRequest(stream: request), + context: context + ) + return GRPCCore.StreamingServerResponse(single: response) + } +} + +// Default implementation of methods from 'ServiceProtocol'. +@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) +extension Antd_V1_ChunkService.SimpleServiceProtocol { + public func get( + request: GRPCCore.ServerRequest, + context: GRPCCore.ServerContext + ) async throws -> GRPCCore.ServerResponse { + return GRPCCore.ServerResponse( + message: try await self.get( + request: request.message, + context: context + ), + metadata: [:] + ) + } + + public func put( + request: GRPCCore.ServerRequest, + context: GRPCCore.ServerContext + ) async throws -> GRPCCore.ServerResponse { + return GRPCCore.ServerResponse( + message: try await self.put( + request: request.message, + context: context + ), + metadata: [:] + ) + } +} + +// MARK: antd.v1.ChunkService (client) + +@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) +extension Antd_V1_ChunkService { + /// Generated client protocol for the "antd.v1.ChunkService" service. + /// + /// You don't need to implement this protocol directly, use the generated + /// implementation, ``Client``. + public protocol ClientProtocol: Sendable { + /// Call the "Get" method. + /// + /// - Parameters: + /// - request: A request containing a single `Antd_V1_GetChunkRequest` message. + /// - serializer: A serializer for `Antd_V1_GetChunkRequest` messages. + /// - deserializer: A deserializer for `Antd_V1_GetChunkResponse` messages. + /// - options: Options to apply to this RPC. + /// - handleResponse: A closure which handles the response, the result of which is + /// returned to the caller. Returning from the closure will cancel the RPC if it + /// hasn't already finished. + /// - Returns: The result of `handleResponse`. + func get( + request: GRPCCore.ClientRequest, + serializer: some GRPCCore.MessageSerializer, + deserializer: some GRPCCore.MessageDeserializer, + options: GRPCCore.CallOptions, + onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> Result + ) async throws -> Result where Result: Sendable + + /// Call the "Put" method. + /// + /// - Parameters: + /// - request: A request containing a single `Antd_V1_PutChunkRequest` message. + /// - serializer: A serializer for `Antd_V1_PutChunkRequest` messages. + /// - deserializer: A deserializer for `Antd_V1_PutChunkResponse` messages. + /// - options: Options to apply to this RPC. + /// - handleResponse: A closure which handles the response, the result of which is + /// returned to the caller. Returning from the closure will cancel the RPC if it + /// hasn't already finished. + /// - Returns: The result of `handleResponse`. + func put( + request: GRPCCore.ClientRequest, + serializer: some GRPCCore.MessageSerializer, + deserializer: some GRPCCore.MessageDeserializer, + options: GRPCCore.CallOptions, + onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> Result + ) async throws -> Result where Result: Sendable + } + + /// Generated client for the "antd.v1.ChunkService" service. + /// + /// The ``Client`` provides an implementation of ``ClientProtocol`` which wraps + /// a `GRPCCore.GRPCCClient`. The underlying `GRPCClient` provides the long-lived + /// means of communication with the remote peer. + public struct Client: ClientProtocol where Transport: GRPCCore.ClientTransport { + private let client: GRPCCore.GRPCClient + + /// Creates a new client wrapping the provided `GRPCCore.GRPCClient`. + /// + /// - Parameters: + /// - client: A `GRPCCore.GRPCClient` providing a communication channel to the service. + public init(wrapping client: GRPCCore.GRPCClient) { + self.client = client + } + + /// Call the "Get" method. + /// + /// - Parameters: + /// - request: A request containing a single `Antd_V1_GetChunkRequest` message. + /// - serializer: A serializer for `Antd_V1_GetChunkRequest` messages. + /// - deserializer: A deserializer for `Antd_V1_GetChunkResponse` messages. + /// - options: Options to apply to this RPC. + /// - handleResponse: A closure which handles the response, the result of which is + /// returned to the caller. Returning from the closure will cancel the RPC if it + /// hasn't already finished. + /// - Returns: The result of `handleResponse`. + public func get( + request: GRPCCore.ClientRequest, + serializer: some GRPCCore.MessageSerializer, + deserializer: some GRPCCore.MessageDeserializer, + options: GRPCCore.CallOptions = .defaults, + onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> Result = { response in + try response.message + } + ) async throws -> Result where Result: Sendable { + try await self.client.unary( + request: request, + descriptor: Antd_V1_ChunkService.Method.Get.descriptor, + serializer: serializer, + deserializer: deserializer, + options: options, + onResponse: handleResponse + ) + } + + /// Call the "Put" method. + /// + /// - Parameters: + /// - request: A request containing a single `Antd_V1_PutChunkRequest` message. + /// - serializer: A serializer for `Antd_V1_PutChunkRequest` messages. + /// - deserializer: A deserializer for `Antd_V1_PutChunkResponse` messages. + /// - options: Options to apply to this RPC. + /// - handleResponse: A closure which handles the response, the result of which is + /// returned to the caller. Returning from the closure will cancel the RPC if it + /// hasn't already finished. + /// - Returns: The result of `handleResponse`. + public func put( + request: GRPCCore.ClientRequest, + serializer: some GRPCCore.MessageSerializer, + deserializer: some GRPCCore.MessageDeserializer, + options: GRPCCore.CallOptions = .defaults, + onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> Result = { response in + try response.message + } + ) async throws -> Result where Result: Sendable { + try await self.client.unary( + request: request, + descriptor: Antd_V1_ChunkService.Method.Put.descriptor, + serializer: serializer, + deserializer: deserializer, + options: options, + onResponse: handleResponse + ) + } + } +} + +// Helpers providing default arguments to 'ClientProtocol' methods. +@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) +extension Antd_V1_ChunkService.ClientProtocol { + /// Call the "Get" method. + /// + /// - Parameters: + /// - request: A request containing a single `Antd_V1_GetChunkRequest` message. + /// - options: Options to apply to this RPC. + /// - handleResponse: A closure which handles the response, the result of which is + /// returned to the caller. Returning from the closure will cancel the RPC if it + /// hasn't already finished. + /// - Returns: The result of `handleResponse`. + public func get( + request: GRPCCore.ClientRequest, + options: GRPCCore.CallOptions = .defaults, + onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> Result = { response in + try response.message + } + ) async throws -> Result where Result: Sendable { + try await self.get( + request: request, + serializer: GRPCProtobuf.ProtobufSerializer(), + deserializer: GRPCProtobuf.ProtobufDeserializer(), + options: options, + onResponse: handleResponse + ) + } + + /// Call the "Put" method. + /// + /// - Parameters: + /// - request: A request containing a single `Antd_V1_PutChunkRequest` message. + /// - options: Options to apply to this RPC. + /// - handleResponse: A closure which handles the response, the result of which is + /// returned to the caller. Returning from the closure will cancel the RPC if it + /// hasn't already finished. + /// - Returns: The result of `handleResponse`. + public func put( + request: GRPCCore.ClientRequest, + options: GRPCCore.CallOptions = .defaults, + onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> Result = { response in + try response.message + } + ) async throws -> Result where Result: Sendable { + try await self.put( + request: request, + serializer: GRPCProtobuf.ProtobufSerializer(), + deserializer: GRPCProtobuf.ProtobufDeserializer(), + options: options, + onResponse: handleResponse + ) + } +} + +// Helpers providing sugared APIs for 'ClientProtocol' methods. +@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) +extension Antd_V1_ChunkService.ClientProtocol { + /// Call the "Get" method. + /// + /// - Parameters: + /// - message: request message to send. + /// - metadata: Additional metadata to send, defaults to empty. + /// - options: Options to apply to this RPC, defaults to `.defaults`. + /// - handleResponse: A closure which handles the response, the result of which is + /// returned to the caller. Returning from the closure will cancel the RPC if it + /// hasn't already finished. + /// - Returns: The result of `handleResponse`. + public func get( + _ message: Antd_V1_GetChunkRequest, + metadata: GRPCCore.Metadata = [:], + options: GRPCCore.CallOptions = .defaults, + onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> Result = { response in + try response.message + } + ) async throws -> Result where Result: Sendable { + let request = GRPCCore.ClientRequest( + message: message, + metadata: metadata + ) + return try await self.get( + request: request, + options: options, + onResponse: handleResponse + ) + } + + /// Call the "Put" method. + /// + /// - Parameters: + /// - message: request message to send. + /// - metadata: Additional metadata to send, defaults to empty. + /// - options: Options to apply to this RPC, defaults to `.defaults`. + /// - handleResponse: A closure which handles the response, the result of which is + /// returned to the caller. Returning from the closure will cancel the RPC if it + /// hasn't already finished. + /// - Returns: The result of `handleResponse`. + public func put( + _ message: Antd_V1_PutChunkRequest, + metadata: GRPCCore.Metadata = [:], + options: GRPCCore.CallOptions = .defaults, + onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> Result = { response in + try response.message + } + ) async throws -> Result where Result: Sendable { + let request = GRPCCore.ClientRequest( + message: message, + metadata: metadata + ) + return try await self.put( + request: request, + options: options, + onResponse: handleResponse + ) + } +} \ No newline at end of file diff --git a/antd-swift/Sources/AntdSdk/Proto/antd/v1/chunks.pb.swift b/antd-swift/Sources/AntdSdk/Proto/antd/v1/chunks.pb.swift new file mode 100644 index 0000000..57b833e --- /dev/null +++ b/antd-swift/Sources/AntdSdk/Proto/antd/v1/chunks.pb.swift @@ -0,0 +1,220 @@ +// DO NOT EDIT. +// swift-format-ignore-file +// swiftlint:disable all +// +// Generated by the Swift generator plugin for the protocol buffer compiler. +// Source: antd/v1/chunks.proto +// +// For information on using the generated types, please see the documentation: +// https://github.com/apple/swift-protobuf/ + +#if canImport(FoundationEssentials) +import FoundationEssentials +#else +import Foundation +#endif +import SwiftProtobuf + +// If the compiler emits an error on this type, it is because this file +// was generated by a version of the `protoc` Swift plug-in that is +// incompatible with the version of SwiftProtobuf to which you are linking. +// Please ensure that you are building against the same version of the API +// that was used to generate this file. +fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck { + struct _2: SwiftProtobuf.ProtobufAPIVersion_2 {} + typealias Version = _2 +} + +public struct Antd_V1_GetChunkRequest: Sendable { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + /// hex + public var address: String = String() + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +public struct Antd_V1_GetChunkResponse: Sendable { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var data: Data = Data() + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +public struct Antd_V1_PutChunkRequest: Sendable { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var data: Data = Data() + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +public struct Antd_V1_PutChunkResponse: Sendable { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var cost: Antd_V1_Cost { + get {_cost ?? Antd_V1_Cost()} + set {_cost = newValue} + } + /// Returns true if `cost` has been explicitly set. + public var hasCost: Bool {self._cost != nil} + /// Clears the value of `cost`. Subsequent reads from it will return its default value. + public mutating func clearCost() {self._cost = nil} + + /// hex + public var address: String = String() + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} + + fileprivate var _cost: Antd_V1_Cost? = nil +} + +// MARK: - Code below here is support for the SwiftProtobuf runtime. + +fileprivate let _protobuf_package = "antd.v1" + +extension Antd_V1_GetChunkRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".GetChunkRequest" + public static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{1}address\0") + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularStringField(value: &self.address) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !self.address.isEmpty { + try visitor.visitSingularStringField(value: self.address, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Antd_V1_GetChunkRequest, rhs: Antd_V1_GetChunkRequest) -> Bool { + if lhs.address != rhs.address {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Antd_V1_GetChunkResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".GetChunkResponse" + public static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{1}data\0") + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularBytesField(value: &self.data) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !self.data.isEmpty { + try visitor.visitSingularBytesField(value: self.data, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Antd_V1_GetChunkResponse, rhs: Antd_V1_GetChunkResponse) -> Bool { + if lhs.data != rhs.data {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Antd_V1_PutChunkRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".PutChunkRequest" + public static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{1}data\0") + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularBytesField(value: &self.data) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !self.data.isEmpty { + try visitor.visitSingularBytesField(value: self.data, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Antd_V1_PutChunkRequest, rhs: Antd_V1_PutChunkRequest) -> Bool { + if lhs.data != rhs.data {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Antd_V1_PutChunkResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".PutChunkResponse" + public static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{1}cost\0\u{1}address\0") + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularMessageField(value: &self._cost) }() + case 2: try { try decoder.decodeSingularStringField(value: &self.address) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every if/case branch local when no optimizations + // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and + // https://github.com/apple/swift-protobuf/issues/1182 + try { if let v = self._cost { + try visitor.visitSingularMessageField(value: v, fieldNumber: 1) + } }() + if !self.address.isEmpty { + try visitor.visitSingularStringField(value: self.address, fieldNumber: 2) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Antd_V1_PutChunkResponse, rhs: Antd_V1_PutChunkResponse) -> Bool { + if lhs._cost != rhs._cost {return false} + if lhs.address != rhs.address {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} diff --git a/antd-swift/Sources/AntdSdk/Proto/antd/v1/common.grpc.swift b/antd-swift/Sources/AntdSdk/Proto/antd/v1/common.grpc.swift new file mode 100644 index 0000000..45a90d3 --- /dev/null +++ b/antd-swift/Sources/AntdSdk/Proto/antd/v1/common.grpc.swift @@ -0,0 +1,11 @@ +// DO NOT EDIT. +// swift-format-ignore-file +// swiftlint:disable all +// +// Generated by the gRPC Swift generator plugin for the protocol buffer compiler. +// Source: antd/v1/common.proto +// +// For information on using the generated types, please see the documentation: +// https://github.com/grpc/grpc-swift + +// This file contained no services. \ No newline at end of file diff --git a/antd-swift/Sources/AntdSdk/Proto/antd/v1/common.pb.swift b/antd-swift/Sources/AntdSdk/Proto/antd/v1/common.pb.swift new file mode 100644 index 0000000..d89b43a --- /dev/null +++ b/antd-swift/Sources/AntdSdk/Proto/antd/v1/common.pb.swift @@ -0,0 +1,226 @@ +// DO NOT EDIT. +// swift-format-ignore-file +// swiftlint:disable all +// +// Generated by the Swift generator plugin for the protocol buffer compiler. +// Source: antd/v1/common.proto +// +// For information on using the generated types, please see the documentation: +// https://github.com/apple/swift-protobuf/ + +import SwiftProtobuf + +// If the compiler emits an error on this type, it is because this file +// was generated by a version of the `protoc` Swift plug-in that is +// incompatible with the version of SwiftProtobuf to which you are linking. +// Please ensure that you are building against the same version of the API +// that was used to generate this file. +fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck { + struct _2: SwiftProtobuf.ProtobufAPIVersion_2 {} + typealias Version = _2 +} + +public struct Antd_V1_Cost: Sendable { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + /// storage cost in atto tokens as string + public var attoTokens: String = String() + + /// original file size in bytes + public var fileSize: UInt64 = 0 + + /// number of data chunks the file splits into + public var chunkCount: UInt32 = 0 + + /// gas heuristic as string (can exceed JS safe int) + public var estimatedGasCostWei: String = String() + + /// "auto" | "merkle" | "single" + public var paymentMode: String = String() + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +public struct Antd_V1_Address: Sendable { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var hex: String = String() + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +public struct Antd_V1_PublicKeyProto: Sendable { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var hex: String = String() + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +public struct Antd_V1_SecretKeyProto: Sendable { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var hex: String = String() + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +// MARK: - Code below here is support for the SwiftProtobuf runtime. + +fileprivate let _protobuf_package = "antd.v1" + +extension Antd_V1_Cost: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".Cost" + public static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{3}atto_tokens\0\u{3}file_size\0\u{3}chunk_count\0\u{3}estimated_gas_cost_wei\0\u{3}payment_mode\0") + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularStringField(value: &self.attoTokens) }() + case 2: try { try decoder.decodeSingularUInt64Field(value: &self.fileSize) }() + case 3: try { try decoder.decodeSingularUInt32Field(value: &self.chunkCount) }() + case 4: try { try decoder.decodeSingularStringField(value: &self.estimatedGasCostWei) }() + case 5: try { try decoder.decodeSingularStringField(value: &self.paymentMode) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !self.attoTokens.isEmpty { + try visitor.visitSingularStringField(value: self.attoTokens, fieldNumber: 1) + } + if self.fileSize != 0 { + try visitor.visitSingularUInt64Field(value: self.fileSize, fieldNumber: 2) + } + if self.chunkCount != 0 { + try visitor.visitSingularUInt32Field(value: self.chunkCount, fieldNumber: 3) + } + if !self.estimatedGasCostWei.isEmpty { + try visitor.visitSingularStringField(value: self.estimatedGasCostWei, fieldNumber: 4) + } + if !self.paymentMode.isEmpty { + try visitor.visitSingularStringField(value: self.paymentMode, fieldNumber: 5) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Antd_V1_Cost, rhs: Antd_V1_Cost) -> Bool { + if lhs.attoTokens != rhs.attoTokens {return false} + if lhs.fileSize != rhs.fileSize {return false} + if lhs.chunkCount != rhs.chunkCount {return false} + if lhs.estimatedGasCostWei != rhs.estimatedGasCostWei {return false} + if lhs.paymentMode != rhs.paymentMode {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Antd_V1_Address: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".Address" + public static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{1}hex\0") + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularStringField(value: &self.hex) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !self.hex.isEmpty { + try visitor.visitSingularStringField(value: self.hex, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Antd_V1_Address, rhs: Antd_V1_Address) -> Bool { + if lhs.hex != rhs.hex {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Antd_V1_PublicKeyProto: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".PublicKeyProto" + public static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{1}hex\0") + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularStringField(value: &self.hex) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !self.hex.isEmpty { + try visitor.visitSingularStringField(value: self.hex, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Antd_V1_PublicKeyProto, rhs: Antd_V1_PublicKeyProto) -> Bool { + if lhs.hex != rhs.hex {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Antd_V1_SecretKeyProto: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".SecretKeyProto" + public static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{1}hex\0") + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularStringField(value: &self.hex) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !self.hex.isEmpty { + try visitor.visitSingularStringField(value: self.hex, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Antd_V1_SecretKeyProto, rhs: Antd_V1_SecretKeyProto) -> Bool { + if lhs.hex != rhs.hex {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} diff --git a/antd-swift/Sources/AntdSdk/Proto/antd/v1/data.grpc.swift b/antd-swift/Sources/AntdSdk/Proto/antd/v1/data.grpc.swift new file mode 100644 index 0000000..d03a82a --- /dev/null +++ b/antd-swift/Sources/AntdSdk/Proto/antd/v1/data.grpc.swift @@ -0,0 +1,1316 @@ +// DO NOT EDIT. +// swift-format-ignore-file +// swiftlint:disable all +// +// Generated by the gRPC Swift generator plugin for the protocol buffer compiler. +// Source: antd/v1/data.proto +// +// For information on using the generated types, please see the documentation: +// https://github.com/grpc/grpc-swift + +import GRPCCore +import GRPCProtobuf + +// MARK: - antd.v1.DataService + +/// Namespace containing generated types for the "antd.v1.DataService" service. +@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) +public enum Antd_V1_DataService { + /// Service descriptor for the "antd.v1.DataService" service. + public static let descriptor = GRPCCore.ServiceDescriptor(fullyQualifiedService: "antd.v1.DataService") + /// Namespace for method metadata. + public enum Method { + /// Namespace for "Put" metadata. + public enum Put { + /// Request type for "Put". + public typealias Input = Antd_V1_PutDataRequest + /// Response type for "Put". + public typealias Output = Antd_V1_PutDataResponse + /// Descriptor for "Put". + public static let descriptor = GRPCCore.MethodDescriptor( + service: GRPCCore.ServiceDescriptor(fullyQualifiedService: "antd.v1.DataService"), + method: "Put" + ) + } + /// Namespace for "PutPublic" metadata. + public enum PutPublic { + /// Request type for "PutPublic". + public typealias Input = Antd_V1_PutPublicDataRequest + /// Response type for "PutPublic". + public typealias Output = Antd_V1_PutPublicDataResponse + /// Descriptor for "PutPublic". + public static let descriptor = GRPCCore.MethodDescriptor( + service: GRPCCore.ServiceDescriptor(fullyQualifiedService: "antd.v1.DataService"), + method: "PutPublic" + ) + } + /// Namespace for "Get" metadata. + public enum Get { + /// Request type for "Get". + public typealias Input = Antd_V1_GetDataRequest + /// Response type for "Get". + public typealias Output = Antd_V1_GetDataResponse + /// Descriptor for "Get". + public static let descriptor = GRPCCore.MethodDescriptor( + service: GRPCCore.ServiceDescriptor(fullyQualifiedService: "antd.v1.DataService"), + method: "Get" + ) + } + /// Namespace for "GetPublic" metadata. + public enum GetPublic { + /// Request type for "GetPublic". + public typealias Input = Antd_V1_GetPublicDataRequest + /// Response type for "GetPublic". + public typealias Output = Antd_V1_GetPublicDataResponse + /// Descriptor for "GetPublic". + public static let descriptor = GRPCCore.MethodDescriptor( + service: GRPCCore.ServiceDescriptor(fullyQualifiedService: "antd.v1.DataService"), + method: "GetPublic" + ) + } + /// Namespace for "StreamPublic" metadata. + public enum StreamPublic { + /// Request type for "StreamPublic". + public typealias Input = Antd_V1_StreamPublicDataRequest + /// Response type for "StreamPublic". + public typealias Output = Antd_V1_DataChunk + /// Descriptor for "StreamPublic". + public static let descriptor = GRPCCore.MethodDescriptor( + service: GRPCCore.ServiceDescriptor(fullyQualifiedService: "antd.v1.DataService"), + method: "StreamPublic" + ) + } + /// Namespace for "Cost" metadata. + public enum Cost { + /// Request type for "Cost". + public typealias Input = Antd_V1_DataCostRequest + /// Response type for "Cost". + public typealias Output = Antd_V1_Cost + /// Descriptor for "Cost". + public static let descriptor = GRPCCore.MethodDescriptor( + service: GRPCCore.ServiceDescriptor(fullyQualifiedService: "antd.v1.DataService"), + method: "Cost" + ) + } + /// Descriptors for all methods in the "antd.v1.DataService" service. + public static let descriptors: [GRPCCore.MethodDescriptor] = [ + Put.descriptor, + PutPublic.descriptor, + Get.descriptor, + GetPublic.descriptor, + StreamPublic.descriptor, + Cost.descriptor + ] + } +} + +@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) +extension GRPCCore.ServiceDescriptor { + /// Service descriptor for the "antd.v1.DataService" service. + public static let antd_v1_DataService = GRPCCore.ServiceDescriptor(fullyQualifiedService: "antd.v1.DataService") +} + +// MARK: antd.v1.DataService (server) + +@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) +extension Antd_V1_DataService { + /// Streaming variant of the service protocol for the "antd.v1.DataService" service. + /// + /// This protocol is the lowest-level of the service protocols generated for this service + /// giving you the most flexibility over the implementation of your service. This comes at + /// the cost of more verbose and less strict APIs. Each RPC requires you to implement it in + /// terms of a request stream and response stream. Where only a single request or response + /// message is expected, you are responsible for enforcing this invariant is maintained. + /// + /// Where possible, prefer using the stricter, less-verbose ``ServiceProtocol`` + /// or ``SimpleServiceProtocol`` instead. + public protocol StreamingServiceProtocol: GRPCCore.RegistrableRPCService { + /// Handle the "Put" method. + /// + /// > Source IDL Documentation: + /// > + /// > Private = unqualified verb (the DataMap is returned to the caller; it is + /// > NOT stored on the network). Public = `_public` suffix (the DataMap is + /// > additionally stored on-network and the call returns the resulting address). + /// + /// - Parameters: + /// - request: A streaming request of `Antd_V1_PutDataRequest` messages. + /// - context: Context providing information about the RPC. + /// - Throws: Any error which occurred during the processing of the request. Thrown errors + /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted + /// to an internal error. + /// - Returns: A streaming response of `Antd_V1_PutDataResponse` messages. + func put( + request: GRPCCore.StreamingServerRequest, + context: GRPCCore.ServerContext + ) async throws -> GRPCCore.StreamingServerResponse + + /// Handle the "PutPublic" method. + /// + /// - Parameters: + /// - request: A streaming request of `Antd_V1_PutPublicDataRequest` messages. + /// - context: Context providing information about the RPC. + /// - Throws: Any error which occurred during the processing of the request. Thrown errors + /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted + /// to an internal error. + /// - Returns: A streaming response of `Antd_V1_PutPublicDataResponse` messages. + func putPublic( + request: GRPCCore.StreamingServerRequest, + context: GRPCCore.ServerContext + ) async throws -> GRPCCore.StreamingServerResponse + + /// Handle the "Get" method. + /// + /// - Parameters: + /// - request: A streaming request of `Antd_V1_GetDataRequest` messages. + /// - context: Context providing information about the RPC. + /// - Throws: Any error which occurred during the processing of the request. Thrown errors + /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted + /// to an internal error. + /// - Returns: A streaming response of `Antd_V1_GetDataResponse` messages. + func get( + request: GRPCCore.StreamingServerRequest, + context: GRPCCore.ServerContext + ) async throws -> GRPCCore.StreamingServerResponse + + /// Handle the "GetPublic" method. + /// + /// - Parameters: + /// - request: A streaming request of `Antd_V1_GetPublicDataRequest` messages. + /// - context: Context providing information about the RPC. + /// - Throws: Any error which occurred during the processing of the request. Thrown errors + /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted + /// to an internal error. + /// - Returns: A streaming response of `Antd_V1_GetPublicDataResponse` messages. + func getPublic( + request: GRPCCore.StreamingServerRequest, + context: GRPCCore.ServerContext + ) async throws -> GRPCCore.StreamingServerResponse + + /// Handle the "StreamPublic" method. + /// + /// - Parameters: + /// - request: A streaming request of `Antd_V1_StreamPublicDataRequest` messages. + /// - context: Context providing information about the RPC. + /// - Throws: Any error which occurred during the processing of the request. Thrown errors + /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted + /// to an internal error. + /// - Returns: A streaming response of `Antd_V1_DataChunk` messages. + func streamPublic( + request: GRPCCore.StreamingServerRequest, + context: GRPCCore.ServerContext + ) async throws -> GRPCCore.StreamingServerResponse + + /// Handle the "Cost" method. + /// + /// - Parameters: + /// - request: A streaming request of `Antd_V1_DataCostRequest` messages. + /// - context: Context providing information about the RPC. + /// - Throws: Any error which occurred during the processing of the request. Thrown errors + /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted + /// to an internal error. + /// - Returns: A streaming response of `Antd_V1_Cost` messages. + func cost( + request: GRPCCore.StreamingServerRequest, + context: GRPCCore.ServerContext + ) async throws -> GRPCCore.StreamingServerResponse + } + + /// Service protocol for the "antd.v1.DataService" service. + /// + /// This protocol is higher level than ``StreamingServiceProtocol`` but lower level than + /// the ``SimpleServiceProtocol``, it provides access to request and response metadata and + /// trailing response metadata. If you don't need these then consider using + /// the ``SimpleServiceProtocol``. If you need fine grained control over your RPCs then + /// use ``StreamingServiceProtocol``. + public protocol ServiceProtocol: Antd_V1_DataService.StreamingServiceProtocol { + /// Handle the "Put" method. + /// + /// > Source IDL Documentation: + /// > + /// > Private = unqualified verb (the DataMap is returned to the caller; it is + /// > NOT stored on the network). Public = `_public` suffix (the DataMap is + /// > additionally stored on-network and the call returns the resulting address). + /// + /// - Parameters: + /// - request: A request containing a single `Antd_V1_PutDataRequest` message. + /// - context: Context providing information about the RPC. + /// - Throws: Any error which occurred during the processing of the request. Thrown errors + /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted + /// to an internal error. + /// - Returns: A response containing a single `Antd_V1_PutDataResponse` message. + func put( + request: GRPCCore.ServerRequest, + context: GRPCCore.ServerContext + ) async throws -> GRPCCore.ServerResponse + + /// Handle the "PutPublic" method. + /// + /// - Parameters: + /// - request: A request containing a single `Antd_V1_PutPublicDataRequest` message. + /// - context: Context providing information about the RPC. + /// - Throws: Any error which occurred during the processing of the request. Thrown errors + /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted + /// to an internal error. + /// - Returns: A response containing a single `Antd_V1_PutPublicDataResponse` message. + func putPublic( + request: GRPCCore.ServerRequest, + context: GRPCCore.ServerContext + ) async throws -> GRPCCore.ServerResponse + + /// Handle the "Get" method. + /// + /// - Parameters: + /// - request: A request containing a single `Antd_V1_GetDataRequest` message. + /// - context: Context providing information about the RPC. + /// - Throws: Any error which occurred during the processing of the request. Thrown errors + /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted + /// to an internal error. + /// - Returns: A response containing a single `Antd_V1_GetDataResponse` message. + func get( + request: GRPCCore.ServerRequest, + context: GRPCCore.ServerContext + ) async throws -> GRPCCore.ServerResponse + + /// Handle the "GetPublic" method. + /// + /// - Parameters: + /// - request: A request containing a single `Antd_V1_GetPublicDataRequest` message. + /// - context: Context providing information about the RPC. + /// - Throws: Any error which occurred during the processing of the request. Thrown errors + /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted + /// to an internal error. + /// - Returns: A response containing a single `Antd_V1_GetPublicDataResponse` message. + func getPublic( + request: GRPCCore.ServerRequest, + context: GRPCCore.ServerContext + ) async throws -> GRPCCore.ServerResponse + + /// Handle the "StreamPublic" method. + /// + /// - Parameters: + /// - request: A request containing a single `Antd_V1_StreamPublicDataRequest` message. + /// - context: Context providing information about the RPC. + /// - Throws: Any error which occurred during the processing of the request. Thrown errors + /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted + /// to an internal error. + /// - Returns: A streaming response of `Antd_V1_DataChunk` messages. + func streamPublic( + request: GRPCCore.ServerRequest, + context: GRPCCore.ServerContext + ) async throws -> GRPCCore.StreamingServerResponse + + /// Handle the "Cost" method. + /// + /// - Parameters: + /// - request: A request containing a single `Antd_V1_DataCostRequest` message. + /// - context: Context providing information about the RPC. + /// - Throws: Any error which occurred during the processing of the request. Thrown errors + /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted + /// to an internal error. + /// - Returns: A response containing a single `Antd_V1_Cost` message. + func cost( + request: GRPCCore.ServerRequest, + context: GRPCCore.ServerContext + ) async throws -> GRPCCore.ServerResponse + } + + /// Simple service protocol for the "antd.v1.DataService" service. + /// + /// This is the highest level protocol for the service. The API is the easiest to use but + /// doesn't provide access to request or response metadata. If you need access to these + /// then use ``ServiceProtocol`` instead. + public protocol SimpleServiceProtocol: Antd_V1_DataService.ServiceProtocol { + /// Handle the "Put" method. + /// + /// > Source IDL Documentation: + /// > + /// > Private = unqualified verb (the DataMap is returned to the caller; it is + /// > NOT stored on the network). Public = `_public` suffix (the DataMap is + /// > additionally stored on-network and the call returns the resulting address). + /// + /// - Parameters: + /// - request: A `Antd_V1_PutDataRequest` message. + /// - context: Context providing information about the RPC. + /// - Throws: Any error which occurred during the processing of the request. Thrown errors + /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted + /// to an internal error. + /// - Returns: A `Antd_V1_PutDataResponse` to respond with. + func put( + request: Antd_V1_PutDataRequest, + context: GRPCCore.ServerContext + ) async throws -> Antd_V1_PutDataResponse + + /// Handle the "PutPublic" method. + /// + /// - Parameters: + /// - request: A `Antd_V1_PutPublicDataRequest` message. + /// - context: Context providing information about the RPC. + /// - Throws: Any error which occurred during the processing of the request. Thrown errors + /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted + /// to an internal error. + /// - Returns: A `Antd_V1_PutPublicDataResponse` to respond with. + func putPublic( + request: Antd_V1_PutPublicDataRequest, + context: GRPCCore.ServerContext + ) async throws -> Antd_V1_PutPublicDataResponse + + /// Handle the "Get" method. + /// + /// - Parameters: + /// - request: A `Antd_V1_GetDataRequest` message. + /// - context: Context providing information about the RPC. + /// - Throws: Any error which occurred during the processing of the request. Thrown errors + /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted + /// to an internal error. + /// - Returns: A `Antd_V1_GetDataResponse` to respond with. + func get( + request: Antd_V1_GetDataRequest, + context: GRPCCore.ServerContext + ) async throws -> Antd_V1_GetDataResponse + + /// Handle the "GetPublic" method. + /// + /// - Parameters: + /// - request: A `Antd_V1_GetPublicDataRequest` message. + /// - context: Context providing information about the RPC. + /// - Throws: Any error which occurred during the processing of the request. Thrown errors + /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted + /// to an internal error. + /// - Returns: A `Antd_V1_GetPublicDataResponse` to respond with. + func getPublic( + request: Antd_V1_GetPublicDataRequest, + context: GRPCCore.ServerContext + ) async throws -> Antd_V1_GetPublicDataResponse + + /// Handle the "StreamPublic" method. + /// + /// - Parameters: + /// - request: A `Antd_V1_StreamPublicDataRequest` message. + /// - response: A response stream of `Antd_V1_DataChunk` messages. + /// - context: Context providing information about the RPC. + /// - Throws: Any error which occurred during the processing of the request. Thrown errors + /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted + /// to an internal error. + func streamPublic( + request: Antd_V1_StreamPublicDataRequest, + response: GRPCCore.RPCWriter, + context: GRPCCore.ServerContext + ) async throws + + /// Handle the "Cost" method. + /// + /// - Parameters: + /// - request: A `Antd_V1_DataCostRequest` message. + /// - context: Context providing information about the RPC. + /// - Throws: Any error which occurred during the processing of the request. Thrown errors + /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted + /// to an internal error. + /// - Returns: A `Antd_V1_Cost` to respond with. + func cost( + request: Antd_V1_DataCostRequest, + context: GRPCCore.ServerContext + ) async throws -> Antd_V1_Cost + } +} + +// Default implementation of 'registerMethods(with:)'. +@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) +extension Antd_V1_DataService.StreamingServiceProtocol { + public func registerMethods(with router: inout GRPCCore.RPCRouter) where Transport: GRPCCore.ServerTransport { + router.registerHandler( + forMethod: Antd_V1_DataService.Method.Put.descriptor, + deserializer: GRPCProtobuf.ProtobufDeserializer(), + serializer: GRPCProtobuf.ProtobufSerializer(), + handler: { request, context in + try await self.put( + request: request, + context: context + ) + } + ) + router.registerHandler( + forMethod: Antd_V1_DataService.Method.PutPublic.descriptor, + deserializer: GRPCProtobuf.ProtobufDeserializer(), + serializer: GRPCProtobuf.ProtobufSerializer(), + handler: { request, context in + try await self.putPublic( + request: request, + context: context + ) + } + ) + router.registerHandler( + forMethod: Antd_V1_DataService.Method.Get.descriptor, + deserializer: GRPCProtobuf.ProtobufDeserializer(), + serializer: GRPCProtobuf.ProtobufSerializer(), + handler: { request, context in + try await self.get( + request: request, + context: context + ) + } + ) + router.registerHandler( + forMethod: Antd_V1_DataService.Method.GetPublic.descriptor, + deserializer: GRPCProtobuf.ProtobufDeserializer(), + serializer: GRPCProtobuf.ProtobufSerializer(), + handler: { request, context in + try await self.getPublic( + request: request, + context: context + ) + } + ) + router.registerHandler( + forMethod: Antd_V1_DataService.Method.StreamPublic.descriptor, + deserializer: GRPCProtobuf.ProtobufDeserializer(), + serializer: GRPCProtobuf.ProtobufSerializer(), + handler: { request, context in + try await self.streamPublic( + request: request, + context: context + ) + } + ) + router.registerHandler( + forMethod: Antd_V1_DataService.Method.Cost.descriptor, + deserializer: GRPCProtobuf.ProtobufDeserializer(), + serializer: GRPCProtobuf.ProtobufSerializer(), + handler: { request, context in + try await self.cost( + request: request, + context: context + ) + } + ) + } +} + +// Default implementation of streaming methods from 'StreamingServiceProtocol'. +@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) +extension Antd_V1_DataService.ServiceProtocol { + public func put( + request: GRPCCore.StreamingServerRequest, + context: GRPCCore.ServerContext + ) async throws -> GRPCCore.StreamingServerResponse { + let response = try await self.put( + request: GRPCCore.ServerRequest(stream: request), + context: context + ) + return GRPCCore.StreamingServerResponse(single: response) + } + + public func putPublic( + request: GRPCCore.StreamingServerRequest, + context: GRPCCore.ServerContext + ) async throws -> GRPCCore.StreamingServerResponse { + let response = try await self.putPublic( + request: GRPCCore.ServerRequest(stream: request), + context: context + ) + return GRPCCore.StreamingServerResponse(single: response) + } + + public func get( + request: GRPCCore.StreamingServerRequest, + context: GRPCCore.ServerContext + ) async throws -> GRPCCore.StreamingServerResponse { + let response = try await self.get( + request: GRPCCore.ServerRequest(stream: request), + context: context + ) + return GRPCCore.StreamingServerResponse(single: response) + } + + public func getPublic( + request: GRPCCore.StreamingServerRequest, + context: GRPCCore.ServerContext + ) async throws -> GRPCCore.StreamingServerResponse { + let response = try await self.getPublic( + request: GRPCCore.ServerRequest(stream: request), + context: context + ) + return GRPCCore.StreamingServerResponse(single: response) + } + + public func streamPublic( + request: GRPCCore.StreamingServerRequest, + context: GRPCCore.ServerContext + ) async throws -> GRPCCore.StreamingServerResponse { + let response = try await self.streamPublic( + request: GRPCCore.ServerRequest(stream: request), + context: context + ) + return response + } + + public func cost( + request: GRPCCore.StreamingServerRequest, + context: GRPCCore.ServerContext + ) async throws -> GRPCCore.StreamingServerResponse { + let response = try await self.cost( + request: GRPCCore.ServerRequest(stream: request), + context: context + ) + return GRPCCore.StreamingServerResponse(single: response) + } +} + +// Default implementation of methods from 'ServiceProtocol'. +@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) +extension Antd_V1_DataService.SimpleServiceProtocol { + public func put( + request: GRPCCore.ServerRequest, + context: GRPCCore.ServerContext + ) async throws -> GRPCCore.ServerResponse { + return GRPCCore.ServerResponse( + message: try await self.put( + request: request.message, + context: context + ), + metadata: [:] + ) + } + + public func putPublic( + request: GRPCCore.ServerRequest, + context: GRPCCore.ServerContext + ) async throws -> GRPCCore.ServerResponse { + return GRPCCore.ServerResponse( + message: try await self.putPublic( + request: request.message, + context: context + ), + metadata: [:] + ) + } + + public func get( + request: GRPCCore.ServerRequest, + context: GRPCCore.ServerContext + ) async throws -> GRPCCore.ServerResponse { + return GRPCCore.ServerResponse( + message: try await self.get( + request: request.message, + context: context + ), + metadata: [:] + ) + } + + public func getPublic( + request: GRPCCore.ServerRequest, + context: GRPCCore.ServerContext + ) async throws -> GRPCCore.ServerResponse { + return GRPCCore.ServerResponse( + message: try await self.getPublic( + request: request.message, + context: context + ), + metadata: [:] + ) + } + + public func streamPublic( + request: GRPCCore.ServerRequest, + context: GRPCCore.ServerContext + ) async throws -> GRPCCore.StreamingServerResponse { + return GRPCCore.StreamingServerResponse( + metadata: [:], + producer: { writer in + try await self.streamPublic( + request: request.message, + response: writer, + context: context + ) + return [:] + } + ) + } + + public func cost( + request: GRPCCore.ServerRequest, + context: GRPCCore.ServerContext + ) async throws -> GRPCCore.ServerResponse { + return GRPCCore.ServerResponse( + message: try await self.cost( + request: request.message, + context: context + ), + metadata: [:] + ) + } +} + +// MARK: antd.v1.DataService (client) + +@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) +extension Antd_V1_DataService { + /// Generated client protocol for the "antd.v1.DataService" service. + /// + /// You don't need to implement this protocol directly, use the generated + /// implementation, ``Client``. + public protocol ClientProtocol: Sendable { + /// Call the "Put" method. + /// + /// > Source IDL Documentation: + /// > + /// > Private = unqualified verb (the DataMap is returned to the caller; it is + /// > NOT stored on the network). Public = `_public` suffix (the DataMap is + /// > additionally stored on-network and the call returns the resulting address). + /// + /// - Parameters: + /// - request: A request containing a single `Antd_V1_PutDataRequest` message. + /// - serializer: A serializer for `Antd_V1_PutDataRequest` messages. + /// - deserializer: A deserializer for `Antd_V1_PutDataResponse` messages. + /// - options: Options to apply to this RPC. + /// - handleResponse: A closure which handles the response, the result of which is + /// returned to the caller. Returning from the closure will cancel the RPC if it + /// hasn't already finished. + /// - Returns: The result of `handleResponse`. + func put( + request: GRPCCore.ClientRequest, + serializer: some GRPCCore.MessageSerializer, + deserializer: some GRPCCore.MessageDeserializer, + options: GRPCCore.CallOptions, + onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> Result + ) async throws -> Result where Result: Sendable + + /// Call the "PutPublic" method. + /// + /// - Parameters: + /// - request: A request containing a single `Antd_V1_PutPublicDataRequest` message. + /// - serializer: A serializer for `Antd_V1_PutPublicDataRequest` messages. + /// - deserializer: A deserializer for `Antd_V1_PutPublicDataResponse` messages. + /// - options: Options to apply to this RPC. + /// - handleResponse: A closure which handles the response, the result of which is + /// returned to the caller. Returning from the closure will cancel the RPC if it + /// hasn't already finished. + /// - Returns: The result of `handleResponse`. + func putPublic( + request: GRPCCore.ClientRequest, + serializer: some GRPCCore.MessageSerializer, + deserializer: some GRPCCore.MessageDeserializer, + options: GRPCCore.CallOptions, + onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> Result + ) async throws -> Result where Result: Sendable + + /// Call the "Get" method. + /// + /// - Parameters: + /// - request: A request containing a single `Antd_V1_GetDataRequest` message. + /// - serializer: A serializer for `Antd_V1_GetDataRequest` messages. + /// - deserializer: A deserializer for `Antd_V1_GetDataResponse` messages. + /// - options: Options to apply to this RPC. + /// - handleResponse: A closure which handles the response, the result of which is + /// returned to the caller. Returning from the closure will cancel the RPC if it + /// hasn't already finished. + /// - Returns: The result of `handleResponse`. + func get( + request: GRPCCore.ClientRequest, + serializer: some GRPCCore.MessageSerializer, + deserializer: some GRPCCore.MessageDeserializer, + options: GRPCCore.CallOptions, + onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> Result + ) async throws -> Result where Result: Sendable + + /// Call the "GetPublic" method. + /// + /// - Parameters: + /// - request: A request containing a single `Antd_V1_GetPublicDataRequest` message. + /// - serializer: A serializer for `Antd_V1_GetPublicDataRequest` messages. + /// - deserializer: A deserializer for `Antd_V1_GetPublicDataResponse` messages. + /// - options: Options to apply to this RPC. + /// - handleResponse: A closure which handles the response, the result of which is + /// returned to the caller. Returning from the closure will cancel the RPC if it + /// hasn't already finished. + /// - Returns: The result of `handleResponse`. + func getPublic( + request: GRPCCore.ClientRequest, + serializer: some GRPCCore.MessageSerializer, + deserializer: some GRPCCore.MessageDeserializer, + options: GRPCCore.CallOptions, + onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> Result + ) async throws -> Result where Result: Sendable + + /// Call the "StreamPublic" method. + /// + /// - Parameters: + /// - request: A request containing a single `Antd_V1_StreamPublicDataRequest` message. + /// - serializer: A serializer for `Antd_V1_StreamPublicDataRequest` messages. + /// - deserializer: A deserializer for `Antd_V1_DataChunk` messages. + /// - options: Options to apply to this RPC. + /// - handleResponse: A closure which handles the response, the result of which is + /// returned to the caller. Returning from the closure will cancel the RPC if it + /// hasn't already finished. + /// - Returns: The result of `handleResponse`. + func streamPublic( + request: GRPCCore.ClientRequest, + serializer: some GRPCCore.MessageSerializer, + deserializer: some GRPCCore.MessageDeserializer, + options: GRPCCore.CallOptions, + onResponse handleResponse: @Sendable @escaping (GRPCCore.StreamingClientResponse) async throws -> Result + ) async throws -> Result where Result: Sendable + + /// Call the "Cost" method. + /// + /// - Parameters: + /// - request: A request containing a single `Antd_V1_DataCostRequest` message. + /// - serializer: A serializer for `Antd_V1_DataCostRequest` messages. + /// - deserializer: A deserializer for `Antd_V1_Cost` messages. + /// - options: Options to apply to this RPC. + /// - handleResponse: A closure which handles the response, the result of which is + /// returned to the caller. Returning from the closure will cancel the RPC if it + /// hasn't already finished. + /// - Returns: The result of `handleResponse`. + func cost( + request: GRPCCore.ClientRequest, + serializer: some GRPCCore.MessageSerializer, + deserializer: some GRPCCore.MessageDeserializer, + options: GRPCCore.CallOptions, + onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> Result + ) async throws -> Result where Result: Sendable + } + + /// Generated client for the "antd.v1.DataService" service. + /// + /// The ``Client`` provides an implementation of ``ClientProtocol`` which wraps + /// a `GRPCCore.GRPCCClient`. The underlying `GRPCClient` provides the long-lived + /// means of communication with the remote peer. + public struct Client: ClientProtocol where Transport: GRPCCore.ClientTransport { + private let client: GRPCCore.GRPCClient + + /// Creates a new client wrapping the provided `GRPCCore.GRPCClient`. + /// + /// - Parameters: + /// - client: A `GRPCCore.GRPCClient` providing a communication channel to the service. + public init(wrapping client: GRPCCore.GRPCClient) { + self.client = client + } + + /// Call the "Put" method. + /// + /// > Source IDL Documentation: + /// > + /// > Private = unqualified verb (the DataMap is returned to the caller; it is + /// > NOT stored on the network). Public = `_public` suffix (the DataMap is + /// > additionally stored on-network and the call returns the resulting address). + /// + /// - Parameters: + /// - request: A request containing a single `Antd_V1_PutDataRequest` message. + /// - serializer: A serializer for `Antd_V1_PutDataRequest` messages. + /// - deserializer: A deserializer for `Antd_V1_PutDataResponse` messages. + /// - options: Options to apply to this RPC. + /// - handleResponse: A closure which handles the response, the result of which is + /// returned to the caller. Returning from the closure will cancel the RPC if it + /// hasn't already finished. + /// - Returns: The result of `handleResponse`. + public func put( + request: GRPCCore.ClientRequest, + serializer: some GRPCCore.MessageSerializer, + deserializer: some GRPCCore.MessageDeserializer, + options: GRPCCore.CallOptions = .defaults, + onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> Result = { response in + try response.message + } + ) async throws -> Result where Result: Sendable { + try await self.client.unary( + request: request, + descriptor: Antd_V1_DataService.Method.Put.descriptor, + serializer: serializer, + deserializer: deserializer, + options: options, + onResponse: handleResponse + ) + } + + /// Call the "PutPublic" method. + /// + /// - Parameters: + /// - request: A request containing a single `Antd_V1_PutPublicDataRequest` message. + /// - serializer: A serializer for `Antd_V1_PutPublicDataRequest` messages. + /// - deserializer: A deserializer for `Antd_V1_PutPublicDataResponse` messages. + /// - options: Options to apply to this RPC. + /// - handleResponse: A closure which handles the response, the result of which is + /// returned to the caller. Returning from the closure will cancel the RPC if it + /// hasn't already finished. + /// - Returns: The result of `handleResponse`. + public func putPublic( + request: GRPCCore.ClientRequest, + serializer: some GRPCCore.MessageSerializer, + deserializer: some GRPCCore.MessageDeserializer, + options: GRPCCore.CallOptions = .defaults, + onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> Result = { response in + try response.message + } + ) async throws -> Result where Result: Sendable { + try await self.client.unary( + request: request, + descriptor: Antd_V1_DataService.Method.PutPublic.descriptor, + serializer: serializer, + deserializer: deserializer, + options: options, + onResponse: handleResponse + ) + } + + /// Call the "Get" method. + /// + /// - Parameters: + /// - request: A request containing a single `Antd_V1_GetDataRequest` message. + /// - serializer: A serializer for `Antd_V1_GetDataRequest` messages. + /// - deserializer: A deserializer for `Antd_V1_GetDataResponse` messages. + /// - options: Options to apply to this RPC. + /// - handleResponse: A closure which handles the response, the result of which is + /// returned to the caller. Returning from the closure will cancel the RPC if it + /// hasn't already finished. + /// - Returns: The result of `handleResponse`. + public func get( + request: GRPCCore.ClientRequest, + serializer: some GRPCCore.MessageSerializer, + deserializer: some GRPCCore.MessageDeserializer, + options: GRPCCore.CallOptions = .defaults, + onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> Result = { response in + try response.message + } + ) async throws -> Result where Result: Sendable { + try await self.client.unary( + request: request, + descriptor: Antd_V1_DataService.Method.Get.descriptor, + serializer: serializer, + deserializer: deserializer, + options: options, + onResponse: handleResponse + ) + } + + /// Call the "GetPublic" method. + /// + /// - Parameters: + /// - request: A request containing a single `Antd_V1_GetPublicDataRequest` message. + /// - serializer: A serializer for `Antd_V1_GetPublicDataRequest` messages. + /// - deserializer: A deserializer for `Antd_V1_GetPublicDataResponse` messages. + /// - options: Options to apply to this RPC. + /// - handleResponse: A closure which handles the response, the result of which is + /// returned to the caller. Returning from the closure will cancel the RPC if it + /// hasn't already finished. + /// - Returns: The result of `handleResponse`. + public func getPublic( + request: GRPCCore.ClientRequest, + serializer: some GRPCCore.MessageSerializer, + deserializer: some GRPCCore.MessageDeserializer, + options: GRPCCore.CallOptions = .defaults, + onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> Result = { response in + try response.message + } + ) async throws -> Result where Result: Sendable { + try await self.client.unary( + request: request, + descriptor: Antd_V1_DataService.Method.GetPublic.descriptor, + serializer: serializer, + deserializer: deserializer, + options: options, + onResponse: handleResponse + ) + } + + /// Call the "StreamPublic" method. + /// + /// - Parameters: + /// - request: A request containing a single `Antd_V1_StreamPublicDataRequest` message. + /// - serializer: A serializer for `Antd_V1_StreamPublicDataRequest` messages. + /// - deserializer: A deserializer for `Antd_V1_DataChunk` messages. + /// - options: Options to apply to this RPC. + /// - handleResponse: A closure which handles the response, the result of which is + /// returned to the caller. Returning from the closure will cancel the RPC if it + /// hasn't already finished. + /// - Returns: The result of `handleResponse`. + public func streamPublic( + request: GRPCCore.ClientRequest, + serializer: some GRPCCore.MessageSerializer, + deserializer: some GRPCCore.MessageDeserializer, + options: GRPCCore.CallOptions = .defaults, + onResponse handleResponse: @Sendable @escaping (GRPCCore.StreamingClientResponse) async throws -> Result + ) async throws -> Result where Result: Sendable { + try await self.client.serverStreaming( + request: request, + descriptor: Antd_V1_DataService.Method.StreamPublic.descriptor, + serializer: serializer, + deserializer: deserializer, + options: options, + onResponse: handleResponse + ) + } + + /// Call the "Cost" method. + /// + /// - Parameters: + /// - request: A request containing a single `Antd_V1_DataCostRequest` message. + /// - serializer: A serializer for `Antd_V1_DataCostRequest` messages. + /// - deserializer: A deserializer for `Antd_V1_Cost` messages. + /// - options: Options to apply to this RPC. + /// - handleResponse: A closure which handles the response, the result of which is + /// returned to the caller. Returning from the closure will cancel the RPC if it + /// hasn't already finished. + /// - Returns: The result of `handleResponse`. + public func cost( + request: GRPCCore.ClientRequest, + serializer: some GRPCCore.MessageSerializer, + deserializer: some GRPCCore.MessageDeserializer, + options: GRPCCore.CallOptions = .defaults, + onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> Result = { response in + try response.message + } + ) async throws -> Result where Result: Sendable { + try await self.client.unary( + request: request, + descriptor: Antd_V1_DataService.Method.Cost.descriptor, + serializer: serializer, + deserializer: deserializer, + options: options, + onResponse: handleResponse + ) + } + } +} + +// Helpers providing default arguments to 'ClientProtocol' methods. +@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) +extension Antd_V1_DataService.ClientProtocol { + /// Call the "Put" method. + /// + /// > Source IDL Documentation: + /// > + /// > Private = unqualified verb (the DataMap is returned to the caller; it is + /// > NOT stored on the network). Public = `_public` suffix (the DataMap is + /// > additionally stored on-network and the call returns the resulting address). + /// + /// - Parameters: + /// - request: A request containing a single `Antd_V1_PutDataRequest` message. + /// - options: Options to apply to this RPC. + /// - handleResponse: A closure which handles the response, the result of which is + /// returned to the caller. Returning from the closure will cancel the RPC if it + /// hasn't already finished. + /// - Returns: The result of `handleResponse`. + public func put( + request: GRPCCore.ClientRequest, + options: GRPCCore.CallOptions = .defaults, + onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> Result = { response in + try response.message + } + ) async throws -> Result where Result: Sendable { + try await self.put( + request: request, + serializer: GRPCProtobuf.ProtobufSerializer(), + deserializer: GRPCProtobuf.ProtobufDeserializer(), + options: options, + onResponse: handleResponse + ) + } + + /// Call the "PutPublic" method. + /// + /// - Parameters: + /// - request: A request containing a single `Antd_V1_PutPublicDataRequest` message. + /// - options: Options to apply to this RPC. + /// - handleResponse: A closure which handles the response, the result of which is + /// returned to the caller. Returning from the closure will cancel the RPC if it + /// hasn't already finished. + /// - Returns: The result of `handleResponse`. + public func putPublic( + request: GRPCCore.ClientRequest, + options: GRPCCore.CallOptions = .defaults, + onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> Result = { response in + try response.message + } + ) async throws -> Result where Result: Sendable { + try await self.putPublic( + request: request, + serializer: GRPCProtobuf.ProtobufSerializer(), + deserializer: GRPCProtobuf.ProtobufDeserializer(), + options: options, + onResponse: handleResponse + ) + } + + /// Call the "Get" method. + /// + /// - Parameters: + /// - request: A request containing a single `Antd_V1_GetDataRequest` message. + /// - options: Options to apply to this RPC. + /// - handleResponse: A closure which handles the response, the result of which is + /// returned to the caller. Returning from the closure will cancel the RPC if it + /// hasn't already finished. + /// - Returns: The result of `handleResponse`. + public func get( + request: GRPCCore.ClientRequest, + options: GRPCCore.CallOptions = .defaults, + onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> Result = { response in + try response.message + } + ) async throws -> Result where Result: Sendable { + try await self.get( + request: request, + serializer: GRPCProtobuf.ProtobufSerializer(), + deserializer: GRPCProtobuf.ProtobufDeserializer(), + options: options, + onResponse: handleResponse + ) + } + + /// Call the "GetPublic" method. + /// + /// - Parameters: + /// - request: A request containing a single `Antd_V1_GetPublicDataRequest` message. + /// - options: Options to apply to this RPC. + /// - handleResponse: A closure which handles the response, the result of which is + /// returned to the caller. Returning from the closure will cancel the RPC if it + /// hasn't already finished. + /// - Returns: The result of `handleResponse`. + public func getPublic( + request: GRPCCore.ClientRequest, + options: GRPCCore.CallOptions = .defaults, + onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> Result = { response in + try response.message + } + ) async throws -> Result where Result: Sendable { + try await self.getPublic( + request: request, + serializer: GRPCProtobuf.ProtobufSerializer(), + deserializer: GRPCProtobuf.ProtobufDeserializer(), + options: options, + onResponse: handleResponse + ) + } + + /// Call the "StreamPublic" method. + /// + /// - Parameters: + /// - request: A request containing a single `Antd_V1_StreamPublicDataRequest` message. + /// - options: Options to apply to this RPC. + /// - handleResponse: A closure which handles the response, the result of which is + /// returned to the caller. Returning from the closure will cancel the RPC if it + /// hasn't already finished. + /// - Returns: The result of `handleResponse`. + public func streamPublic( + request: GRPCCore.ClientRequest, + options: GRPCCore.CallOptions = .defaults, + onResponse handleResponse: @Sendable @escaping (GRPCCore.StreamingClientResponse) async throws -> Result + ) async throws -> Result where Result: Sendable { + try await self.streamPublic( + request: request, + serializer: GRPCProtobuf.ProtobufSerializer(), + deserializer: GRPCProtobuf.ProtobufDeserializer(), + options: options, + onResponse: handleResponse + ) + } + + /// Call the "Cost" method. + /// + /// - Parameters: + /// - request: A request containing a single `Antd_V1_DataCostRequest` message. + /// - options: Options to apply to this RPC. + /// - handleResponse: A closure which handles the response, the result of which is + /// returned to the caller. Returning from the closure will cancel the RPC if it + /// hasn't already finished. + /// - Returns: The result of `handleResponse`. + public func cost( + request: GRPCCore.ClientRequest, + options: GRPCCore.CallOptions = .defaults, + onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> Result = { response in + try response.message + } + ) async throws -> Result where Result: Sendable { + try await self.cost( + request: request, + serializer: GRPCProtobuf.ProtobufSerializer(), + deserializer: GRPCProtobuf.ProtobufDeserializer(), + options: options, + onResponse: handleResponse + ) + } +} + +// Helpers providing sugared APIs for 'ClientProtocol' methods. +@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) +extension Antd_V1_DataService.ClientProtocol { + /// Call the "Put" method. + /// + /// > Source IDL Documentation: + /// > + /// > Private = unqualified verb (the DataMap is returned to the caller; it is + /// > NOT stored on the network). Public = `_public` suffix (the DataMap is + /// > additionally stored on-network and the call returns the resulting address). + /// + /// - Parameters: + /// - message: request message to send. + /// - metadata: Additional metadata to send, defaults to empty. + /// - options: Options to apply to this RPC, defaults to `.defaults`. + /// - handleResponse: A closure which handles the response, the result of which is + /// returned to the caller. Returning from the closure will cancel the RPC if it + /// hasn't already finished. + /// - Returns: The result of `handleResponse`. + public func put( + _ message: Antd_V1_PutDataRequest, + metadata: GRPCCore.Metadata = [:], + options: GRPCCore.CallOptions = .defaults, + onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> Result = { response in + try response.message + } + ) async throws -> Result where Result: Sendable { + let request = GRPCCore.ClientRequest( + message: message, + metadata: metadata + ) + return try await self.put( + request: request, + options: options, + onResponse: handleResponse + ) + } + + /// Call the "PutPublic" method. + /// + /// - Parameters: + /// - message: request message to send. + /// - metadata: Additional metadata to send, defaults to empty. + /// - options: Options to apply to this RPC, defaults to `.defaults`. + /// - handleResponse: A closure which handles the response, the result of which is + /// returned to the caller. Returning from the closure will cancel the RPC if it + /// hasn't already finished. + /// - Returns: The result of `handleResponse`. + public func putPublic( + _ message: Antd_V1_PutPublicDataRequest, + metadata: GRPCCore.Metadata = [:], + options: GRPCCore.CallOptions = .defaults, + onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> Result = { response in + try response.message + } + ) async throws -> Result where Result: Sendable { + let request = GRPCCore.ClientRequest( + message: message, + metadata: metadata + ) + return try await self.putPublic( + request: request, + options: options, + onResponse: handleResponse + ) + } + + /// Call the "Get" method. + /// + /// - Parameters: + /// - message: request message to send. + /// - metadata: Additional metadata to send, defaults to empty. + /// - options: Options to apply to this RPC, defaults to `.defaults`. + /// - handleResponse: A closure which handles the response, the result of which is + /// returned to the caller. Returning from the closure will cancel the RPC if it + /// hasn't already finished. + /// - Returns: The result of `handleResponse`. + public func get( + _ message: Antd_V1_GetDataRequest, + metadata: GRPCCore.Metadata = [:], + options: GRPCCore.CallOptions = .defaults, + onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> Result = { response in + try response.message + } + ) async throws -> Result where Result: Sendable { + let request = GRPCCore.ClientRequest( + message: message, + metadata: metadata + ) + return try await self.get( + request: request, + options: options, + onResponse: handleResponse + ) + } + + /// Call the "GetPublic" method. + /// + /// - Parameters: + /// - message: request message to send. + /// - metadata: Additional metadata to send, defaults to empty. + /// - options: Options to apply to this RPC, defaults to `.defaults`. + /// - handleResponse: A closure which handles the response, the result of which is + /// returned to the caller. Returning from the closure will cancel the RPC if it + /// hasn't already finished. + /// - Returns: The result of `handleResponse`. + public func getPublic( + _ message: Antd_V1_GetPublicDataRequest, + metadata: GRPCCore.Metadata = [:], + options: GRPCCore.CallOptions = .defaults, + onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> Result = { response in + try response.message + } + ) async throws -> Result where Result: Sendable { + let request = GRPCCore.ClientRequest( + message: message, + metadata: metadata + ) + return try await self.getPublic( + request: request, + options: options, + onResponse: handleResponse + ) + } + + /// Call the "StreamPublic" method. + /// + /// - Parameters: + /// - message: request message to send. + /// - metadata: Additional metadata to send, defaults to empty. + /// - options: Options to apply to this RPC, defaults to `.defaults`. + /// - handleResponse: A closure which handles the response, the result of which is + /// returned to the caller. Returning from the closure will cancel the RPC if it + /// hasn't already finished. + /// - Returns: The result of `handleResponse`. + public func streamPublic( + _ message: Antd_V1_StreamPublicDataRequest, + metadata: GRPCCore.Metadata = [:], + options: GRPCCore.CallOptions = .defaults, + onResponse handleResponse: @Sendable @escaping (GRPCCore.StreamingClientResponse) async throws -> Result + ) async throws -> Result where Result: Sendable { + let request = GRPCCore.ClientRequest( + message: message, + metadata: metadata + ) + return try await self.streamPublic( + request: request, + options: options, + onResponse: handleResponse + ) + } + + /// Call the "Cost" method. + /// + /// - Parameters: + /// - message: request message to send. + /// - metadata: Additional metadata to send, defaults to empty. + /// - options: Options to apply to this RPC, defaults to `.defaults`. + /// - handleResponse: A closure which handles the response, the result of which is + /// returned to the caller. Returning from the closure will cancel the RPC if it + /// hasn't already finished. + /// - Returns: The result of `handleResponse`. + public func cost( + _ message: Antd_V1_DataCostRequest, + metadata: GRPCCore.Metadata = [:], + options: GRPCCore.CallOptions = .defaults, + onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> Result = { response in + try response.message + } + ) async throws -> Result where Result: Sendable { + let request = GRPCCore.ClientRequest( + message: message, + metadata: metadata + ) + return try await self.cost( + request: request, + options: options, + onResponse: handleResponse + ) + } +} \ No newline at end of file diff --git a/antd-swift/Sources/AntdSdk/Proto/antd/v1/data.pb.swift b/antd-swift/Sources/AntdSdk/Proto/antd/v1/data.pb.swift new file mode 100644 index 0000000..04bc593 --- /dev/null +++ b/antd-swift/Sources/AntdSdk/Proto/antd/v1/data.pb.swift @@ -0,0 +1,566 @@ +// DO NOT EDIT. +// swift-format-ignore-file +// swiftlint:disable all +// +// Generated by the Swift generator plugin for the protocol buffer compiler. +// Source: antd/v1/data.proto +// +// For information on using the generated types, please see the documentation: +// https://github.com/apple/swift-protobuf/ + +#if canImport(FoundationEssentials) +import FoundationEssentials +#else +import Foundation +#endif +import SwiftProtobuf + +// If the compiler emits an error on this type, it is because this file +// was generated by a version of the `protoc` Swift plug-in that is +// incompatible with the version of SwiftProtobuf to which you are linking. +// Please ensure that you are building against the same version of the API +// that was used to generate this file. +fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck { + struct _2: SwiftProtobuf.ProtobufAPIVersion_2 {} + typealias Version = _2 +} + +public struct Antd_V1_GetPublicDataRequest: Sendable { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + /// hex + public var address: String = String() + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +public struct Antd_V1_GetPublicDataResponse: Sendable { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var data: Data = Data() + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +public struct Antd_V1_PutPublicDataRequest: Sendable { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var data: Data = Data() + + /// Optional payment mode: "auto" (default), "merkle", or "single". Empty + /// string is treated as "auto" so old clients omitting the field stay + /// wire-compatible. + public var paymentMode: String = String() + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +public struct Antd_V1_PutPublicDataResponse: Sendable { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var cost: Antd_V1_Cost { + get {_cost ?? Antd_V1_Cost()} + set {_cost = newValue} + } + /// Returns true if `cost` has been explicitly set. + public var hasCost: Bool {self._cost != nil} + /// Clears the value of `cost`. Subsequent reads from it will return its default value. + public mutating func clearCost() {self._cost = nil} + + /// hex + public var address: String = String() + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} + + fileprivate var _cost: Antd_V1_Cost? = nil +} + +public struct Antd_V1_StreamPublicDataRequest: Sendable { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + /// hex + public var address: String = String() + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +public struct Antd_V1_DataChunk: Sendable { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var data: Data = Data() + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +public struct Antd_V1_GetDataRequest: Sendable { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + /// hex + public var dataMap: String = String() + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +public struct Antd_V1_GetDataResponse: Sendable { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var data: Data = Data() + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +public struct Antd_V1_PutDataRequest: Sendable { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var data: Data = Data() + + /// Optional payment mode: "auto" (default), "merkle", or "single". Empty + /// string is treated as "auto" so old clients omitting the field stay + /// wire-compatible. + public var paymentMode: String = String() + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +public struct Antd_V1_PutDataResponse: Sendable { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var cost: Antd_V1_Cost { + get {_cost ?? Antd_V1_Cost()} + set {_cost = newValue} + } + /// Returns true if `cost` has been explicitly set. + public var hasCost: Bool {self._cost != nil} + /// Clears the value of `cost`. Subsequent reads from it will return its default value. + public mutating func clearCost() {self._cost = nil} + + /// hex + public var dataMap: String = String() + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} + + fileprivate var _cost: Antd_V1_Cost? = nil +} + +public struct Antd_V1_DataCostRequest: Sendable { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var data: Data = Data() + + /// Optional payment mode the estimate should reflect: "auto" (default), + /// "merkle", or "single". Empty string is treated as "auto". + public var paymentMode: String = String() + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +// MARK: - Code below here is support for the SwiftProtobuf runtime. + +fileprivate let _protobuf_package = "antd.v1" + +extension Antd_V1_GetPublicDataRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".GetPublicDataRequest" + public static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{1}address\0") + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularStringField(value: &self.address) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !self.address.isEmpty { + try visitor.visitSingularStringField(value: self.address, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Antd_V1_GetPublicDataRequest, rhs: Antd_V1_GetPublicDataRequest) -> Bool { + if lhs.address != rhs.address {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Antd_V1_GetPublicDataResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".GetPublicDataResponse" + public static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{1}data\0") + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularBytesField(value: &self.data) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !self.data.isEmpty { + try visitor.visitSingularBytesField(value: self.data, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Antd_V1_GetPublicDataResponse, rhs: Antd_V1_GetPublicDataResponse) -> Bool { + if lhs.data != rhs.data {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Antd_V1_PutPublicDataRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".PutPublicDataRequest" + public static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{1}data\0\u{3}payment_mode\0") + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularBytesField(value: &self.data) }() + case 2: try { try decoder.decodeSingularStringField(value: &self.paymentMode) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !self.data.isEmpty { + try visitor.visitSingularBytesField(value: self.data, fieldNumber: 1) + } + if !self.paymentMode.isEmpty { + try visitor.visitSingularStringField(value: self.paymentMode, fieldNumber: 2) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Antd_V1_PutPublicDataRequest, rhs: Antd_V1_PutPublicDataRequest) -> Bool { + if lhs.data != rhs.data {return false} + if lhs.paymentMode != rhs.paymentMode {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Antd_V1_PutPublicDataResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".PutPublicDataResponse" + public static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{1}cost\0\u{1}address\0") + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularMessageField(value: &self._cost) }() + case 2: try { try decoder.decodeSingularStringField(value: &self.address) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every if/case branch local when no optimizations + // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and + // https://github.com/apple/swift-protobuf/issues/1182 + try { if let v = self._cost { + try visitor.visitSingularMessageField(value: v, fieldNumber: 1) + } }() + if !self.address.isEmpty { + try visitor.visitSingularStringField(value: self.address, fieldNumber: 2) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Antd_V1_PutPublicDataResponse, rhs: Antd_V1_PutPublicDataResponse) -> Bool { + if lhs._cost != rhs._cost {return false} + if lhs.address != rhs.address {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Antd_V1_StreamPublicDataRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".StreamPublicDataRequest" + public static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{1}address\0") + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularStringField(value: &self.address) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !self.address.isEmpty { + try visitor.visitSingularStringField(value: self.address, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Antd_V1_StreamPublicDataRequest, rhs: Antd_V1_StreamPublicDataRequest) -> Bool { + if lhs.address != rhs.address {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Antd_V1_DataChunk: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".DataChunk" + public static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{1}data\0") + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularBytesField(value: &self.data) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !self.data.isEmpty { + try visitor.visitSingularBytesField(value: self.data, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Antd_V1_DataChunk, rhs: Antd_V1_DataChunk) -> Bool { + if lhs.data != rhs.data {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Antd_V1_GetDataRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".GetDataRequest" + public static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{3}data_map\0") + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularStringField(value: &self.dataMap) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !self.dataMap.isEmpty { + try visitor.visitSingularStringField(value: self.dataMap, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Antd_V1_GetDataRequest, rhs: Antd_V1_GetDataRequest) -> Bool { + if lhs.dataMap != rhs.dataMap {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Antd_V1_GetDataResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".GetDataResponse" + public static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{1}data\0") + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularBytesField(value: &self.data) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !self.data.isEmpty { + try visitor.visitSingularBytesField(value: self.data, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Antd_V1_GetDataResponse, rhs: Antd_V1_GetDataResponse) -> Bool { + if lhs.data != rhs.data {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Antd_V1_PutDataRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".PutDataRequest" + public static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{1}data\0\u{3}payment_mode\0") + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularBytesField(value: &self.data) }() + case 2: try { try decoder.decodeSingularStringField(value: &self.paymentMode) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !self.data.isEmpty { + try visitor.visitSingularBytesField(value: self.data, fieldNumber: 1) + } + if !self.paymentMode.isEmpty { + try visitor.visitSingularStringField(value: self.paymentMode, fieldNumber: 2) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Antd_V1_PutDataRequest, rhs: Antd_V1_PutDataRequest) -> Bool { + if lhs.data != rhs.data {return false} + if lhs.paymentMode != rhs.paymentMode {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Antd_V1_PutDataResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".PutDataResponse" + public static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{1}cost\0\u{3}data_map\0") + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularMessageField(value: &self._cost) }() + case 2: try { try decoder.decodeSingularStringField(value: &self.dataMap) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every if/case branch local when no optimizations + // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and + // https://github.com/apple/swift-protobuf/issues/1182 + try { if let v = self._cost { + try visitor.visitSingularMessageField(value: v, fieldNumber: 1) + } }() + if !self.dataMap.isEmpty { + try visitor.visitSingularStringField(value: self.dataMap, fieldNumber: 2) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Antd_V1_PutDataResponse, rhs: Antd_V1_PutDataResponse) -> Bool { + if lhs._cost != rhs._cost {return false} + if lhs.dataMap != rhs.dataMap {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Antd_V1_DataCostRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".DataCostRequest" + public static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{1}data\0\u{3}payment_mode\0") + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularBytesField(value: &self.data) }() + case 2: try { try decoder.decodeSingularStringField(value: &self.paymentMode) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !self.data.isEmpty { + try visitor.visitSingularBytesField(value: self.data, fieldNumber: 1) + } + if !self.paymentMode.isEmpty { + try visitor.visitSingularStringField(value: self.paymentMode, fieldNumber: 2) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Antd_V1_DataCostRequest, rhs: Antd_V1_DataCostRequest) -> Bool { + if lhs.data != rhs.data {return false} + if lhs.paymentMode != rhs.paymentMode {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} diff --git a/antd-swift/Sources/AntdSdk/Proto/antd/v1/events.grpc.swift b/antd-swift/Sources/AntdSdk/Proto/antd/v1/events.grpc.swift new file mode 100644 index 0000000..a2c4d5f --- /dev/null +++ b/antd-swift/Sources/AntdSdk/Proto/antd/v1/events.grpc.swift @@ -0,0 +1,309 @@ +// DO NOT EDIT. +// swift-format-ignore-file +// swiftlint:disable all +// +// Generated by the gRPC Swift generator plugin for the protocol buffer compiler. +// Source: antd/v1/events.proto +// +// For information on using the generated types, please see the documentation: +// https://github.com/grpc/grpc-swift + +import GRPCCore +import GRPCProtobuf + +// MARK: - antd.v1.EventService + +/// Namespace containing generated types for the "antd.v1.EventService" service. +@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) +public enum Antd_V1_EventService { + /// Service descriptor for the "antd.v1.EventService" service. + public static let descriptor = GRPCCore.ServiceDescriptor(fullyQualifiedService: "antd.v1.EventService") + /// Namespace for method metadata. + public enum Method { + /// Namespace for "Subscribe" metadata. + public enum Subscribe { + /// Request type for "Subscribe". + public typealias Input = Antd_V1_SubscribeRequest + /// Response type for "Subscribe". + public typealias Output = Antd_V1_ClientEventProto + /// Descriptor for "Subscribe". + public static let descriptor = GRPCCore.MethodDescriptor( + service: GRPCCore.ServiceDescriptor(fullyQualifiedService: "antd.v1.EventService"), + method: "Subscribe" + ) + } + /// Descriptors for all methods in the "antd.v1.EventService" service. + public static let descriptors: [GRPCCore.MethodDescriptor] = [ + Subscribe.descriptor + ] + } +} + +@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) +extension GRPCCore.ServiceDescriptor { + /// Service descriptor for the "antd.v1.EventService" service. + public static let antd_v1_EventService = GRPCCore.ServiceDescriptor(fullyQualifiedService: "antd.v1.EventService") +} + +// MARK: antd.v1.EventService (server) + +@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) +extension Antd_V1_EventService { + /// Streaming variant of the service protocol for the "antd.v1.EventService" service. + /// + /// This protocol is the lowest-level of the service protocols generated for this service + /// giving you the most flexibility over the implementation of your service. This comes at + /// the cost of more verbose and less strict APIs. Each RPC requires you to implement it in + /// terms of a request stream and response stream. Where only a single request or response + /// message is expected, you are responsible for enforcing this invariant is maintained. + /// + /// Where possible, prefer using the stricter, less-verbose ``ServiceProtocol`` + /// or ``SimpleServiceProtocol`` instead. + public protocol StreamingServiceProtocol: GRPCCore.RegistrableRPCService { + /// Handle the "Subscribe" method. + /// + /// - Parameters: + /// - request: A streaming request of `Antd_V1_SubscribeRequest` messages. + /// - context: Context providing information about the RPC. + /// - Throws: Any error which occurred during the processing of the request. Thrown errors + /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted + /// to an internal error. + /// - Returns: A streaming response of `Antd_V1_ClientEventProto` messages. + func subscribe( + request: GRPCCore.StreamingServerRequest, + context: GRPCCore.ServerContext + ) async throws -> GRPCCore.StreamingServerResponse + } + + /// Service protocol for the "antd.v1.EventService" service. + /// + /// This protocol is higher level than ``StreamingServiceProtocol`` but lower level than + /// the ``SimpleServiceProtocol``, it provides access to request and response metadata and + /// trailing response metadata. If you don't need these then consider using + /// the ``SimpleServiceProtocol``. If you need fine grained control over your RPCs then + /// use ``StreamingServiceProtocol``. + public protocol ServiceProtocol: Antd_V1_EventService.StreamingServiceProtocol { + /// Handle the "Subscribe" method. + /// + /// - Parameters: + /// - request: A request containing a single `Antd_V1_SubscribeRequest` message. + /// - context: Context providing information about the RPC. + /// - Throws: Any error which occurred during the processing of the request. Thrown errors + /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted + /// to an internal error. + /// - Returns: A streaming response of `Antd_V1_ClientEventProto` messages. + func subscribe( + request: GRPCCore.ServerRequest, + context: GRPCCore.ServerContext + ) async throws -> GRPCCore.StreamingServerResponse + } + + /// Simple service protocol for the "antd.v1.EventService" service. + /// + /// This is the highest level protocol for the service. The API is the easiest to use but + /// doesn't provide access to request or response metadata. If you need access to these + /// then use ``ServiceProtocol`` instead. + public protocol SimpleServiceProtocol: Antd_V1_EventService.ServiceProtocol { + /// Handle the "Subscribe" method. + /// + /// - Parameters: + /// - request: A `Antd_V1_SubscribeRequest` message. + /// - response: A response stream of `Antd_V1_ClientEventProto` messages. + /// - context: Context providing information about the RPC. + /// - Throws: Any error which occurred during the processing of the request. Thrown errors + /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted + /// to an internal error. + func subscribe( + request: Antd_V1_SubscribeRequest, + response: GRPCCore.RPCWriter, + context: GRPCCore.ServerContext + ) async throws + } +} + +// Default implementation of 'registerMethods(with:)'. +@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) +extension Antd_V1_EventService.StreamingServiceProtocol { + public func registerMethods(with router: inout GRPCCore.RPCRouter) where Transport: GRPCCore.ServerTransport { + router.registerHandler( + forMethod: Antd_V1_EventService.Method.Subscribe.descriptor, + deserializer: GRPCProtobuf.ProtobufDeserializer(), + serializer: GRPCProtobuf.ProtobufSerializer(), + handler: { request, context in + try await self.subscribe( + request: request, + context: context + ) + } + ) + } +} + +// Default implementation of streaming methods from 'StreamingServiceProtocol'. +@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) +extension Antd_V1_EventService.ServiceProtocol { + public func subscribe( + request: GRPCCore.StreamingServerRequest, + context: GRPCCore.ServerContext + ) async throws -> GRPCCore.StreamingServerResponse { + let response = try await self.subscribe( + request: GRPCCore.ServerRequest(stream: request), + context: context + ) + return response + } +} + +// Default implementation of methods from 'ServiceProtocol'. +@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) +extension Antd_V1_EventService.SimpleServiceProtocol { + public func subscribe( + request: GRPCCore.ServerRequest, + context: GRPCCore.ServerContext + ) async throws -> GRPCCore.StreamingServerResponse { + return GRPCCore.StreamingServerResponse( + metadata: [:], + producer: { writer in + try await self.subscribe( + request: request.message, + response: writer, + context: context + ) + return [:] + } + ) + } +} + +// MARK: antd.v1.EventService (client) + +@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) +extension Antd_V1_EventService { + /// Generated client protocol for the "antd.v1.EventService" service. + /// + /// You don't need to implement this protocol directly, use the generated + /// implementation, ``Client``. + public protocol ClientProtocol: Sendable { + /// Call the "Subscribe" method. + /// + /// - Parameters: + /// - request: A request containing a single `Antd_V1_SubscribeRequest` message. + /// - serializer: A serializer for `Antd_V1_SubscribeRequest` messages. + /// - deserializer: A deserializer for `Antd_V1_ClientEventProto` messages. + /// - options: Options to apply to this RPC. + /// - handleResponse: A closure which handles the response, the result of which is + /// returned to the caller. Returning from the closure will cancel the RPC if it + /// hasn't already finished. + /// - Returns: The result of `handleResponse`. + func subscribe( + request: GRPCCore.ClientRequest, + serializer: some GRPCCore.MessageSerializer, + deserializer: some GRPCCore.MessageDeserializer, + options: GRPCCore.CallOptions, + onResponse handleResponse: @Sendable @escaping (GRPCCore.StreamingClientResponse) async throws -> Result + ) async throws -> Result where Result: Sendable + } + + /// Generated client for the "antd.v1.EventService" service. + /// + /// The ``Client`` provides an implementation of ``ClientProtocol`` which wraps + /// a `GRPCCore.GRPCCClient`. The underlying `GRPCClient` provides the long-lived + /// means of communication with the remote peer. + public struct Client: ClientProtocol where Transport: GRPCCore.ClientTransport { + private let client: GRPCCore.GRPCClient + + /// Creates a new client wrapping the provided `GRPCCore.GRPCClient`. + /// + /// - Parameters: + /// - client: A `GRPCCore.GRPCClient` providing a communication channel to the service. + public init(wrapping client: GRPCCore.GRPCClient) { + self.client = client + } + + /// Call the "Subscribe" method. + /// + /// - Parameters: + /// - request: A request containing a single `Antd_V1_SubscribeRequest` message. + /// - serializer: A serializer for `Antd_V1_SubscribeRequest` messages. + /// - deserializer: A deserializer for `Antd_V1_ClientEventProto` messages. + /// - options: Options to apply to this RPC. + /// - handleResponse: A closure which handles the response, the result of which is + /// returned to the caller. Returning from the closure will cancel the RPC if it + /// hasn't already finished. + /// - Returns: The result of `handleResponse`. + public func subscribe( + request: GRPCCore.ClientRequest, + serializer: some GRPCCore.MessageSerializer, + deserializer: some GRPCCore.MessageDeserializer, + options: GRPCCore.CallOptions = .defaults, + onResponse handleResponse: @Sendable @escaping (GRPCCore.StreamingClientResponse) async throws -> Result + ) async throws -> Result where Result: Sendable { + try await self.client.serverStreaming( + request: request, + descriptor: Antd_V1_EventService.Method.Subscribe.descriptor, + serializer: serializer, + deserializer: deserializer, + options: options, + onResponse: handleResponse + ) + } + } +} + +// Helpers providing default arguments to 'ClientProtocol' methods. +@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) +extension Antd_V1_EventService.ClientProtocol { + /// Call the "Subscribe" method. + /// + /// - Parameters: + /// - request: A request containing a single `Antd_V1_SubscribeRequest` message. + /// - options: Options to apply to this RPC. + /// - handleResponse: A closure which handles the response, the result of which is + /// returned to the caller. Returning from the closure will cancel the RPC if it + /// hasn't already finished. + /// - Returns: The result of `handleResponse`. + public func subscribe( + request: GRPCCore.ClientRequest, + options: GRPCCore.CallOptions = .defaults, + onResponse handleResponse: @Sendable @escaping (GRPCCore.StreamingClientResponse) async throws -> Result + ) async throws -> Result where Result: Sendable { + try await self.subscribe( + request: request, + serializer: GRPCProtobuf.ProtobufSerializer(), + deserializer: GRPCProtobuf.ProtobufDeserializer(), + options: options, + onResponse: handleResponse + ) + } +} + +// Helpers providing sugared APIs for 'ClientProtocol' methods. +@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) +extension Antd_V1_EventService.ClientProtocol { + /// Call the "Subscribe" method. + /// + /// - Parameters: + /// - message: request message to send. + /// - metadata: Additional metadata to send, defaults to empty. + /// - options: Options to apply to this RPC, defaults to `.defaults`. + /// - handleResponse: A closure which handles the response, the result of which is + /// returned to the caller. Returning from the closure will cancel the RPC if it + /// hasn't already finished. + /// - Returns: The result of `handleResponse`. + public func subscribe( + _ message: Antd_V1_SubscribeRequest, + metadata: GRPCCore.Metadata = [:], + options: GRPCCore.CallOptions = .defaults, + onResponse handleResponse: @Sendable @escaping (GRPCCore.StreamingClientResponse) async throws -> Result + ) async throws -> Result where Result: Sendable { + let request = GRPCCore.ClientRequest( + message: message, + metadata: metadata + ) + return try await self.subscribe( + request: request, + options: options, + onResponse: handleResponse + ) + } +} \ No newline at end of file diff --git a/antd-swift/Sources/AntdSdk/Proto/antd/v1/events.pb.swift b/antd-swift/Sources/AntdSdk/Proto/antd/v1/events.pb.swift new file mode 100644 index 0000000..c010ac8 --- /dev/null +++ b/antd-swift/Sources/AntdSdk/Proto/antd/v1/events.pb.swift @@ -0,0 +1,117 @@ +// DO NOT EDIT. +// swift-format-ignore-file +// swiftlint:disable all +// +// Generated by the Swift generator plugin for the protocol buffer compiler. +// Source: antd/v1/events.proto +// +// For information on using the generated types, please see the documentation: +// https://github.com/apple/swift-protobuf/ + +import SwiftProtobuf + +// If the compiler emits an error on this type, it is because this file +// was generated by a version of the `protoc` Swift plug-in that is +// incompatible with the version of SwiftProtobuf to which you are linking. +// Please ensure that you are building against the same version of the API +// that was used to generate this file. +fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck { + struct _2: SwiftProtobuf.ProtobufAPIVersion_2 {} + typealias Version = _2 +} + +public struct Antd_V1_SubscribeRequest: Sendable { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +public struct Antd_V1_ClientEventProto: Sendable { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var kind: String = String() + + public var recordsPaid: UInt64 = 0 + + public var recordsAlreadyPaid: UInt64 = 0 + + public var tokensSpent: String = String() + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +// MARK: - Code below here is support for the SwiftProtobuf runtime. + +fileprivate let _protobuf_package = "antd.v1" + +extension Antd_V1_SubscribeRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".SubscribeRequest" + public static let _protobuf_nameMap = SwiftProtobuf._NameMap() + + public mutating func decodeMessage(decoder: inout D) throws { + // Load everything into unknown fields + while try decoder.nextFieldNumber() != nil {} + } + + public func traverse(visitor: inout V) throws { + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Antd_V1_SubscribeRequest, rhs: Antd_V1_SubscribeRequest) -> Bool { + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Antd_V1_ClientEventProto: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".ClientEventProto" + public static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{1}kind\0\u{3}records_paid\0\u{3}records_already_paid\0\u{3}tokens_spent\0") + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularStringField(value: &self.kind) }() + case 2: try { try decoder.decodeSingularUInt64Field(value: &self.recordsPaid) }() + case 3: try { try decoder.decodeSingularUInt64Field(value: &self.recordsAlreadyPaid) }() + case 4: try { try decoder.decodeSingularStringField(value: &self.tokensSpent) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !self.kind.isEmpty { + try visitor.visitSingularStringField(value: self.kind, fieldNumber: 1) + } + if self.recordsPaid != 0 { + try visitor.visitSingularUInt64Field(value: self.recordsPaid, fieldNumber: 2) + } + if self.recordsAlreadyPaid != 0 { + try visitor.visitSingularUInt64Field(value: self.recordsAlreadyPaid, fieldNumber: 3) + } + if !self.tokensSpent.isEmpty { + try visitor.visitSingularStringField(value: self.tokensSpent, fieldNumber: 4) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Antd_V1_ClientEventProto, rhs: Antd_V1_ClientEventProto) -> Bool { + if lhs.kind != rhs.kind {return false} + if lhs.recordsPaid != rhs.recordsPaid {return false} + if lhs.recordsAlreadyPaid != rhs.recordsAlreadyPaid {return false} + if lhs.tokensSpent != rhs.tokensSpent {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} diff --git a/antd-swift/Sources/AntdSdk/Proto/antd/v1/files.grpc.swift b/antd-swift/Sources/AntdSdk/Proto/antd/v1/files.grpc.swift new file mode 100644 index 0000000..ebaed09 --- /dev/null +++ b/antd-swift/Sources/AntdSdk/Proto/antd/v1/files.grpc.swift @@ -0,0 +1,1124 @@ +// DO NOT EDIT. +// swift-format-ignore-file +// swiftlint:disable all +// +// Generated by the gRPC Swift generator plugin for the protocol buffer compiler. +// Source: antd/v1/files.proto +// +// For information on using the generated types, please see the documentation: +// https://github.com/grpc/grpc-swift + +import GRPCCore +import GRPCProtobuf + +// MARK: - antd.v1.FileService + +/// Namespace containing generated types for the "antd.v1.FileService" service. +@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) +public enum Antd_V1_FileService { + /// Service descriptor for the "antd.v1.FileService" service. + public static let descriptor = GRPCCore.ServiceDescriptor(fullyQualifiedService: "antd.v1.FileService") + /// Namespace for method metadata. + public enum Method { + /// Namespace for "Put" metadata. + public enum Put { + /// Request type for "Put". + public typealias Input = Antd_V1_PutFileRequest + /// Response type for "Put". + public typealias Output = Antd_V1_PutFileResponse + /// Descriptor for "Put". + public static let descriptor = GRPCCore.MethodDescriptor( + service: GRPCCore.ServiceDescriptor(fullyQualifiedService: "antd.v1.FileService"), + method: "Put" + ) + } + /// Namespace for "PutPublic" metadata. + public enum PutPublic { + /// Request type for "PutPublic". + public typealias Input = Antd_V1_PutFileRequest + /// Response type for "PutPublic". + public typealias Output = Antd_V1_PutFilePublicResponse + /// Descriptor for "PutPublic". + public static let descriptor = GRPCCore.MethodDescriptor( + service: GRPCCore.ServiceDescriptor(fullyQualifiedService: "antd.v1.FileService"), + method: "PutPublic" + ) + } + /// Namespace for "Get" metadata. + public enum Get { + /// Request type for "Get". + public typealias Input = Antd_V1_GetFileRequest + /// Response type for "Get". + public typealias Output = Antd_V1_GetFileResponse + /// Descriptor for "Get". + public static let descriptor = GRPCCore.MethodDescriptor( + service: GRPCCore.ServiceDescriptor(fullyQualifiedService: "antd.v1.FileService"), + method: "Get" + ) + } + /// Namespace for "GetPublic" metadata. + public enum GetPublic { + /// Request type for "GetPublic". + public typealias Input = Antd_V1_GetFilePublicRequest + /// Response type for "GetPublic". + public typealias Output = Antd_V1_GetFileResponse + /// Descriptor for "GetPublic". + public static let descriptor = GRPCCore.MethodDescriptor( + service: GRPCCore.ServiceDescriptor(fullyQualifiedService: "antd.v1.FileService"), + method: "GetPublic" + ) + } + /// Namespace for "Cost" metadata. + public enum Cost { + /// Request type for "Cost". + public typealias Input = Antd_V1_FileCostRequest + /// Response type for "Cost". + public typealias Output = Antd_V1_Cost + /// Descriptor for "Cost". + public static let descriptor = GRPCCore.MethodDescriptor( + service: GRPCCore.ServiceDescriptor(fullyQualifiedService: "antd.v1.FileService"), + method: "Cost" + ) + } + /// Descriptors for all methods in the "antd.v1.FileService" service. + public static let descriptors: [GRPCCore.MethodDescriptor] = [ + Put.descriptor, + PutPublic.descriptor, + Get.descriptor, + GetPublic.descriptor, + Cost.descriptor + ] + } +} + +@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) +extension GRPCCore.ServiceDescriptor { + /// Service descriptor for the "antd.v1.FileService" service. + public static let antd_v1_FileService = GRPCCore.ServiceDescriptor(fullyQualifiedService: "antd.v1.FileService") +} + +// MARK: antd.v1.FileService (server) + +@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) +extension Antd_V1_FileService { + /// Streaming variant of the service protocol for the "antd.v1.FileService" service. + /// + /// This protocol is the lowest-level of the service protocols generated for this service + /// giving you the most flexibility over the implementation of your service. This comes at + /// the cost of more verbose and less strict APIs. Each RPC requires you to implement it in + /// terms of a request stream and response stream. Where only a single request or response + /// message is expected, you are responsible for enforcing this invariant is maintained. + /// + /// Where possible, prefer using the stricter, less-verbose ``ServiceProtocol`` + /// or ``SimpleServiceProtocol`` instead. + public protocol StreamingServiceProtocol: GRPCCore.RegistrableRPCService { + /// Handle the "Put" method. + /// + /// > Source IDL Documentation: + /// > + /// > Private = unqualified verb (the DataMap is returned to the caller; it is + /// > NOT stored on the network). Public = `_public` suffix (the DataMap is + /// > additionally stored on-network and the call returns the resulting address). + /// + /// - Parameters: + /// - request: A streaming request of `Antd_V1_PutFileRequest` messages. + /// - context: Context providing information about the RPC. + /// - Throws: Any error which occurred during the processing of the request. Thrown errors + /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted + /// to an internal error. + /// - Returns: A streaming response of `Antd_V1_PutFileResponse` messages. + func put( + request: GRPCCore.StreamingServerRequest, + context: GRPCCore.ServerContext + ) async throws -> GRPCCore.StreamingServerResponse + + /// Handle the "PutPublic" method. + /// + /// - Parameters: + /// - request: A streaming request of `Antd_V1_PutFileRequest` messages. + /// - context: Context providing information about the RPC. + /// - Throws: Any error which occurred during the processing of the request. Thrown errors + /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted + /// to an internal error. + /// - Returns: A streaming response of `Antd_V1_PutFilePublicResponse` messages. + func putPublic( + request: GRPCCore.StreamingServerRequest, + context: GRPCCore.ServerContext + ) async throws -> GRPCCore.StreamingServerResponse + + /// Handle the "Get" method. + /// + /// - Parameters: + /// - request: A streaming request of `Antd_V1_GetFileRequest` messages. + /// - context: Context providing information about the RPC. + /// - Throws: Any error which occurred during the processing of the request. Thrown errors + /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted + /// to an internal error. + /// - Returns: A streaming response of `Antd_V1_GetFileResponse` messages. + func get( + request: GRPCCore.StreamingServerRequest, + context: GRPCCore.ServerContext + ) async throws -> GRPCCore.StreamingServerResponse + + /// Handle the "GetPublic" method. + /// + /// - Parameters: + /// - request: A streaming request of `Antd_V1_GetFilePublicRequest` messages. + /// - context: Context providing information about the RPC. + /// - Throws: Any error which occurred during the processing of the request. Thrown errors + /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted + /// to an internal error. + /// - Returns: A streaming response of `Antd_V1_GetFileResponse` messages. + func getPublic( + request: GRPCCore.StreamingServerRequest, + context: GRPCCore.ServerContext + ) async throws -> GRPCCore.StreamingServerResponse + + /// Handle the "Cost" method. + /// + /// - Parameters: + /// - request: A streaming request of `Antd_V1_FileCostRequest` messages. + /// - context: Context providing information about the RPC. + /// - Throws: Any error which occurred during the processing of the request. Thrown errors + /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted + /// to an internal error. + /// - Returns: A streaming response of `Antd_V1_Cost` messages. + func cost( + request: GRPCCore.StreamingServerRequest, + context: GRPCCore.ServerContext + ) async throws -> GRPCCore.StreamingServerResponse + } + + /// Service protocol for the "antd.v1.FileService" service. + /// + /// This protocol is higher level than ``StreamingServiceProtocol`` but lower level than + /// the ``SimpleServiceProtocol``, it provides access to request and response metadata and + /// trailing response metadata. If you don't need these then consider using + /// the ``SimpleServiceProtocol``. If you need fine grained control over your RPCs then + /// use ``StreamingServiceProtocol``. + public protocol ServiceProtocol: Antd_V1_FileService.StreamingServiceProtocol { + /// Handle the "Put" method. + /// + /// > Source IDL Documentation: + /// > + /// > Private = unqualified verb (the DataMap is returned to the caller; it is + /// > NOT stored on the network). Public = `_public` suffix (the DataMap is + /// > additionally stored on-network and the call returns the resulting address). + /// + /// - Parameters: + /// - request: A request containing a single `Antd_V1_PutFileRequest` message. + /// - context: Context providing information about the RPC. + /// - Throws: Any error which occurred during the processing of the request. Thrown errors + /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted + /// to an internal error. + /// - Returns: A response containing a single `Antd_V1_PutFileResponse` message. + func put( + request: GRPCCore.ServerRequest, + context: GRPCCore.ServerContext + ) async throws -> GRPCCore.ServerResponse + + /// Handle the "PutPublic" method. + /// + /// - Parameters: + /// - request: A request containing a single `Antd_V1_PutFileRequest` message. + /// - context: Context providing information about the RPC. + /// - Throws: Any error which occurred during the processing of the request. Thrown errors + /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted + /// to an internal error. + /// - Returns: A response containing a single `Antd_V1_PutFilePublicResponse` message. + func putPublic( + request: GRPCCore.ServerRequest, + context: GRPCCore.ServerContext + ) async throws -> GRPCCore.ServerResponse + + /// Handle the "Get" method. + /// + /// - Parameters: + /// - request: A request containing a single `Antd_V1_GetFileRequest` message. + /// - context: Context providing information about the RPC. + /// - Throws: Any error which occurred during the processing of the request. Thrown errors + /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted + /// to an internal error. + /// - Returns: A response containing a single `Antd_V1_GetFileResponse` message. + func get( + request: GRPCCore.ServerRequest, + context: GRPCCore.ServerContext + ) async throws -> GRPCCore.ServerResponse + + /// Handle the "GetPublic" method. + /// + /// - Parameters: + /// - request: A request containing a single `Antd_V1_GetFilePublicRequest` message. + /// - context: Context providing information about the RPC. + /// - Throws: Any error which occurred during the processing of the request. Thrown errors + /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted + /// to an internal error. + /// - Returns: A response containing a single `Antd_V1_GetFileResponse` message. + func getPublic( + request: GRPCCore.ServerRequest, + context: GRPCCore.ServerContext + ) async throws -> GRPCCore.ServerResponse + + /// Handle the "Cost" method. + /// + /// - Parameters: + /// - request: A request containing a single `Antd_V1_FileCostRequest` message. + /// - context: Context providing information about the RPC. + /// - Throws: Any error which occurred during the processing of the request. Thrown errors + /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted + /// to an internal error. + /// - Returns: A response containing a single `Antd_V1_Cost` message. + func cost( + request: GRPCCore.ServerRequest, + context: GRPCCore.ServerContext + ) async throws -> GRPCCore.ServerResponse + } + + /// Simple service protocol for the "antd.v1.FileService" service. + /// + /// This is the highest level protocol for the service. The API is the easiest to use but + /// doesn't provide access to request or response metadata. If you need access to these + /// then use ``ServiceProtocol`` instead. + public protocol SimpleServiceProtocol: Antd_V1_FileService.ServiceProtocol { + /// Handle the "Put" method. + /// + /// > Source IDL Documentation: + /// > + /// > Private = unqualified verb (the DataMap is returned to the caller; it is + /// > NOT stored on the network). Public = `_public` suffix (the DataMap is + /// > additionally stored on-network and the call returns the resulting address). + /// + /// - Parameters: + /// - request: A `Antd_V1_PutFileRequest` message. + /// - context: Context providing information about the RPC. + /// - Throws: Any error which occurred during the processing of the request. Thrown errors + /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted + /// to an internal error. + /// - Returns: A `Antd_V1_PutFileResponse` to respond with. + func put( + request: Antd_V1_PutFileRequest, + context: GRPCCore.ServerContext + ) async throws -> Antd_V1_PutFileResponse + + /// Handle the "PutPublic" method. + /// + /// - Parameters: + /// - request: A `Antd_V1_PutFileRequest` message. + /// - context: Context providing information about the RPC. + /// - Throws: Any error which occurred during the processing of the request. Thrown errors + /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted + /// to an internal error. + /// - Returns: A `Antd_V1_PutFilePublicResponse` to respond with. + func putPublic( + request: Antd_V1_PutFileRequest, + context: GRPCCore.ServerContext + ) async throws -> Antd_V1_PutFilePublicResponse + + /// Handle the "Get" method. + /// + /// - Parameters: + /// - request: A `Antd_V1_GetFileRequest` message. + /// - context: Context providing information about the RPC. + /// - Throws: Any error which occurred during the processing of the request. Thrown errors + /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted + /// to an internal error. + /// - Returns: A `Antd_V1_GetFileResponse` to respond with. + func get( + request: Antd_V1_GetFileRequest, + context: GRPCCore.ServerContext + ) async throws -> Antd_V1_GetFileResponse + + /// Handle the "GetPublic" method. + /// + /// - Parameters: + /// - request: A `Antd_V1_GetFilePublicRequest` message. + /// - context: Context providing information about the RPC. + /// - Throws: Any error which occurred during the processing of the request. Thrown errors + /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted + /// to an internal error. + /// - Returns: A `Antd_V1_GetFileResponse` to respond with. + func getPublic( + request: Antd_V1_GetFilePublicRequest, + context: GRPCCore.ServerContext + ) async throws -> Antd_V1_GetFileResponse + + /// Handle the "Cost" method. + /// + /// - Parameters: + /// - request: A `Antd_V1_FileCostRequest` message. + /// - context: Context providing information about the RPC. + /// - Throws: Any error which occurred during the processing of the request. Thrown errors + /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted + /// to an internal error. + /// - Returns: A `Antd_V1_Cost` to respond with. + func cost( + request: Antd_V1_FileCostRequest, + context: GRPCCore.ServerContext + ) async throws -> Antd_V1_Cost + } +} + +// Default implementation of 'registerMethods(with:)'. +@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) +extension Antd_V1_FileService.StreamingServiceProtocol { + public func registerMethods(with router: inout GRPCCore.RPCRouter) where Transport: GRPCCore.ServerTransport { + router.registerHandler( + forMethod: Antd_V1_FileService.Method.Put.descriptor, + deserializer: GRPCProtobuf.ProtobufDeserializer(), + serializer: GRPCProtobuf.ProtobufSerializer(), + handler: { request, context in + try await self.put( + request: request, + context: context + ) + } + ) + router.registerHandler( + forMethod: Antd_V1_FileService.Method.PutPublic.descriptor, + deserializer: GRPCProtobuf.ProtobufDeserializer(), + serializer: GRPCProtobuf.ProtobufSerializer(), + handler: { request, context in + try await self.putPublic( + request: request, + context: context + ) + } + ) + router.registerHandler( + forMethod: Antd_V1_FileService.Method.Get.descriptor, + deserializer: GRPCProtobuf.ProtobufDeserializer(), + serializer: GRPCProtobuf.ProtobufSerializer(), + handler: { request, context in + try await self.get( + request: request, + context: context + ) + } + ) + router.registerHandler( + forMethod: Antd_V1_FileService.Method.GetPublic.descriptor, + deserializer: GRPCProtobuf.ProtobufDeserializer(), + serializer: GRPCProtobuf.ProtobufSerializer(), + handler: { request, context in + try await self.getPublic( + request: request, + context: context + ) + } + ) + router.registerHandler( + forMethod: Antd_V1_FileService.Method.Cost.descriptor, + deserializer: GRPCProtobuf.ProtobufDeserializer(), + serializer: GRPCProtobuf.ProtobufSerializer(), + handler: { request, context in + try await self.cost( + request: request, + context: context + ) + } + ) + } +} + +// Default implementation of streaming methods from 'StreamingServiceProtocol'. +@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) +extension Antd_V1_FileService.ServiceProtocol { + public func put( + request: GRPCCore.StreamingServerRequest, + context: GRPCCore.ServerContext + ) async throws -> GRPCCore.StreamingServerResponse { + let response = try await self.put( + request: GRPCCore.ServerRequest(stream: request), + context: context + ) + return GRPCCore.StreamingServerResponse(single: response) + } + + public func putPublic( + request: GRPCCore.StreamingServerRequest, + context: GRPCCore.ServerContext + ) async throws -> GRPCCore.StreamingServerResponse { + let response = try await self.putPublic( + request: GRPCCore.ServerRequest(stream: request), + context: context + ) + return GRPCCore.StreamingServerResponse(single: response) + } + + public func get( + request: GRPCCore.StreamingServerRequest, + context: GRPCCore.ServerContext + ) async throws -> GRPCCore.StreamingServerResponse { + let response = try await self.get( + request: GRPCCore.ServerRequest(stream: request), + context: context + ) + return GRPCCore.StreamingServerResponse(single: response) + } + + public func getPublic( + request: GRPCCore.StreamingServerRequest, + context: GRPCCore.ServerContext + ) async throws -> GRPCCore.StreamingServerResponse { + let response = try await self.getPublic( + request: GRPCCore.ServerRequest(stream: request), + context: context + ) + return GRPCCore.StreamingServerResponse(single: response) + } + + public func cost( + request: GRPCCore.StreamingServerRequest, + context: GRPCCore.ServerContext + ) async throws -> GRPCCore.StreamingServerResponse { + let response = try await self.cost( + request: GRPCCore.ServerRequest(stream: request), + context: context + ) + return GRPCCore.StreamingServerResponse(single: response) + } +} + +// Default implementation of methods from 'ServiceProtocol'. +@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) +extension Antd_V1_FileService.SimpleServiceProtocol { + public func put( + request: GRPCCore.ServerRequest, + context: GRPCCore.ServerContext + ) async throws -> GRPCCore.ServerResponse { + return GRPCCore.ServerResponse( + message: try await self.put( + request: request.message, + context: context + ), + metadata: [:] + ) + } + + public func putPublic( + request: GRPCCore.ServerRequest, + context: GRPCCore.ServerContext + ) async throws -> GRPCCore.ServerResponse { + return GRPCCore.ServerResponse( + message: try await self.putPublic( + request: request.message, + context: context + ), + metadata: [:] + ) + } + + public func get( + request: GRPCCore.ServerRequest, + context: GRPCCore.ServerContext + ) async throws -> GRPCCore.ServerResponse { + return GRPCCore.ServerResponse( + message: try await self.get( + request: request.message, + context: context + ), + metadata: [:] + ) + } + + public func getPublic( + request: GRPCCore.ServerRequest, + context: GRPCCore.ServerContext + ) async throws -> GRPCCore.ServerResponse { + return GRPCCore.ServerResponse( + message: try await self.getPublic( + request: request.message, + context: context + ), + metadata: [:] + ) + } + + public func cost( + request: GRPCCore.ServerRequest, + context: GRPCCore.ServerContext + ) async throws -> GRPCCore.ServerResponse { + return GRPCCore.ServerResponse( + message: try await self.cost( + request: request.message, + context: context + ), + metadata: [:] + ) + } +} + +// MARK: antd.v1.FileService (client) + +@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) +extension Antd_V1_FileService { + /// Generated client protocol for the "antd.v1.FileService" service. + /// + /// You don't need to implement this protocol directly, use the generated + /// implementation, ``Client``. + public protocol ClientProtocol: Sendable { + /// Call the "Put" method. + /// + /// > Source IDL Documentation: + /// > + /// > Private = unqualified verb (the DataMap is returned to the caller; it is + /// > NOT stored on the network). Public = `_public` suffix (the DataMap is + /// > additionally stored on-network and the call returns the resulting address). + /// + /// - Parameters: + /// - request: A request containing a single `Antd_V1_PutFileRequest` message. + /// - serializer: A serializer for `Antd_V1_PutFileRequest` messages. + /// - deserializer: A deserializer for `Antd_V1_PutFileResponse` messages. + /// - options: Options to apply to this RPC. + /// - handleResponse: A closure which handles the response, the result of which is + /// returned to the caller. Returning from the closure will cancel the RPC if it + /// hasn't already finished. + /// - Returns: The result of `handleResponse`. + func put( + request: GRPCCore.ClientRequest, + serializer: some GRPCCore.MessageSerializer, + deserializer: some GRPCCore.MessageDeserializer, + options: GRPCCore.CallOptions, + onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> Result + ) async throws -> Result where Result: Sendable + + /// Call the "PutPublic" method. + /// + /// - Parameters: + /// - request: A request containing a single `Antd_V1_PutFileRequest` message. + /// - serializer: A serializer for `Antd_V1_PutFileRequest` messages. + /// - deserializer: A deserializer for `Antd_V1_PutFilePublicResponse` messages. + /// - options: Options to apply to this RPC. + /// - handleResponse: A closure which handles the response, the result of which is + /// returned to the caller. Returning from the closure will cancel the RPC if it + /// hasn't already finished. + /// - Returns: The result of `handleResponse`. + func putPublic( + request: GRPCCore.ClientRequest, + serializer: some GRPCCore.MessageSerializer, + deserializer: some GRPCCore.MessageDeserializer, + options: GRPCCore.CallOptions, + onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> Result + ) async throws -> Result where Result: Sendable + + /// Call the "Get" method. + /// + /// - Parameters: + /// - request: A request containing a single `Antd_V1_GetFileRequest` message. + /// - serializer: A serializer for `Antd_V1_GetFileRequest` messages. + /// - deserializer: A deserializer for `Antd_V1_GetFileResponse` messages. + /// - options: Options to apply to this RPC. + /// - handleResponse: A closure which handles the response, the result of which is + /// returned to the caller. Returning from the closure will cancel the RPC if it + /// hasn't already finished. + /// - Returns: The result of `handleResponse`. + func get( + request: GRPCCore.ClientRequest, + serializer: some GRPCCore.MessageSerializer, + deserializer: some GRPCCore.MessageDeserializer, + options: GRPCCore.CallOptions, + onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> Result + ) async throws -> Result where Result: Sendable + + /// Call the "GetPublic" method. + /// + /// - Parameters: + /// - request: A request containing a single `Antd_V1_GetFilePublicRequest` message. + /// - serializer: A serializer for `Antd_V1_GetFilePublicRequest` messages. + /// - deserializer: A deserializer for `Antd_V1_GetFileResponse` messages. + /// - options: Options to apply to this RPC. + /// - handleResponse: A closure which handles the response, the result of which is + /// returned to the caller. Returning from the closure will cancel the RPC if it + /// hasn't already finished. + /// - Returns: The result of `handleResponse`. + func getPublic( + request: GRPCCore.ClientRequest, + serializer: some GRPCCore.MessageSerializer, + deserializer: some GRPCCore.MessageDeserializer, + options: GRPCCore.CallOptions, + onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> Result + ) async throws -> Result where Result: Sendable + + /// Call the "Cost" method. + /// + /// - Parameters: + /// - request: A request containing a single `Antd_V1_FileCostRequest` message. + /// - serializer: A serializer for `Antd_V1_FileCostRequest` messages. + /// - deserializer: A deserializer for `Antd_V1_Cost` messages. + /// - options: Options to apply to this RPC. + /// - handleResponse: A closure which handles the response, the result of which is + /// returned to the caller. Returning from the closure will cancel the RPC if it + /// hasn't already finished. + /// - Returns: The result of `handleResponse`. + func cost( + request: GRPCCore.ClientRequest, + serializer: some GRPCCore.MessageSerializer, + deserializer: some GRPCCore.MessageDeserializer, + options: GRPCCore.CallOptions, + onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> Result + ) async throws -> Result where Result: Sendable + } + + /// Generated client for the "antd.v1.FileService" service. + /// + /// The ``Client`` provides an implementation of ``ClientProtocol`` which wraps + /// a `GRPCCore.GRPCCClient`. The underlying `GRPCClient` provides the long-lived + /// means of communication with the remote peer. + public struct Client: ClientProtocol where Transport: GRPCCore.ClientTransport { + private let client: GRPCCore.GRPCClient + + /// Creates a new client wrapping the provided `GRPCCore.GRPCClient`. + /// + /// - Parameters: + /// - client: A `GRPCCore.GRPCClient` providing a communication channel to the service. + public init(wrapping client: GRPCCore.GRPCClient) { + self.client = client + } + + /// Call the "Put" method. + /// + /// > Source IDL Documentation: + /// > + /// > Private = unqualified verb (the DataMap is returned to the caller; it is + /// > NOT stored on the network). Public = `_public` suffix (the DataMap is + /// > additionally stored on-network and the call returns the resulting address). + /// + /// - Parameters: + /// - request: A request containing a single `Antd_V1_PutFileRequest` message. + /// - serializer: A serializer for `Antd_V1_PutFileRequest` messages. + /// - deserializer: A deserializer for `Antd_V1_PutFileResponse` messages. + /// - options: Options to apply to this RPC. + /// - handleResponse: A closure which handles the response, the result of which is + /// returned to the caller. Returning from the closure will cancel the RPC if it + /// hasn't already finished. + /// - Returns: The result of `handleResponse`. + public func put( + request: GRPCCore.ClientRequest, + serializer: some GRPCCore.MessageSerializer, + deserializer: some GRPCCore.MessageDeserializer, + options: GRPCCore.CallOptions = .defaults, + onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> Result = { response in + try response.message + } + ) async throws -> Result where Result: Sendable { + try await self.client.unary( + request: request, + descriptor: Antd_V1_FileService.Method.Put.descriptor, + serializer: serializer, + deserializer: deserializer, + options: options, + onResponse: handleResponse + ) + } + + /// Call the "PutPublic" method. + /// + /// - Parameters: + /// - request: A request containing a single `Antd_V1_PutFileRequest` message. + /// - serializer: A serializer for `Antd_V1_PutFileRequest` messages. + /// - deserializer: A deserializer for `Antd_V1_PutFilePublicResponse` messages. + /// - options: Options to apply to this RPC. + /// - handleResponse: A closure which handles the response, the result of which is + /// returned to the caller. Returning from the closure will cancel the RPC if it + /// hasn't already finished. + /// - Returns: The result of `handleResponse`. + public func putPublic( + request: GRPCCore.ClientRequest, + serializer: some GRPCCore.MessageSerializer, + deserializer: some GRPCCore.MessageDeserializer, + options: GRPCCore.CallOptions = .defaults, + onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> Result = { response in + try response.message + } + ) async throws -> Result where Result: Sendable { + try await self.client.unary( + request: request, + descriptor: Antd_V1_FileService.Method.PutPublic.descriptor, + serializer: serializer, + deserializer: deserializer, + options: options, + onResponse: handleResponse + ) + } + + /// Call the "Get" method. + /// + /// - Parameters: + /// - request: A request containing a single `Antd_V1_GetFileRequest` message. + /// - serializer: A serializer for `Antd_V1_GetFileRequest` messages. + /// - deserializer: A deserializer for `Antd_V1_GetFileResponse` messages. + /// - options: Options to apply to this RPC. + /// - handleResponse: A closure which handles the response, the result of which is + /// returned to the caller. Returning from the closure will cancel the RPC if it + /// hasn't already finished. + /// - Returns: The result of `handleResponse`. + public func get( + request: GRPCCore.ClientRequest, + serializer: some GRPCCore.MessageSerializer, + deserializer: some GRPCCore.MessageDeserializer, + options: GRPCCore.CallOptions = .defaults, + onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> Result = { response in + try response.message + } + ) async throws -> Result where Result: Sendable { + try await self.client.unary( + request: request, + descriptor: Antd_V1_FileService.Method.Get.descriptor, + serializer: serializer, + deserializer: deserializer, + options: options, + onResponse: handleResponse + ) + } + + /// Call the "GetPublic" method. + /// + /// - Parameters: + /// - request: A request containing a single `Antd_V1_GetFilePublicRequest` message. + /// - serializer: A serializer for `Antd_V1_GetFilePublicRequest` messages. + /// - deserializer: A deserializer for `Antd_V1_GetFileResponse` messages. + /// - options: Options to apply to this RPC. + /// - handleResponse: A closure which handles the response, the result of which is + /// returned to the caller. Returning from the closure will cancel the RPC if it + /// hasn't already finished. + /// - Returns: The result of `handleResponse`. + public func getPublic( + request: GRPCCore.ClientRequest, + serializer: some GRPCCore.MessageSerializer, + deserializer: some GRPCCore.MessageDeserializer, + options: GRPCCore.CallOptions = .defaults, + onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> Result = { response in + try response.message + } + ) async throws -> Result where Result: Sendable { + try await self.client.unary( + request: request, + descriptor: Antd_V1_FileService.Method.GetPublic.descriptor, + serializer: serializer, + deserializer: deserializer, + options: options, + onResponse: handleResponse + ) + } + + /// Call the "Cost" method. + /// + /// - Parameters: + /// - request: A request containing a single `Antd_V1_FileCostRequest` message. + /// - serializer: A serializer for `Antd_V1_FileCostRequest` messages. + /// - deserializer: A deserializer for `Antd_V1_Cost` messages. + /// - options: Options to apply to this RPC. + /// - handleResponse: A closure which handles the response, the result of which is + /// returned to the caller. Returning from the closure will cancel the RPC if it + /// hasn't already finished. + /// - Returns: The result of `handleResponse`. + public func cost( + request: GRPCCore.ClientRequest, + serializer: some GRPCCore.MessageSerializer, + deserializer: some GRPCCore.MessageDeserializer, + options: GRPCCore.CallOptions = .defaults, + onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> Result = { response in + try response.message + } + ) async throws -> Result where Result: Sendable { + try await self.client.unary( + request: request, + descriptor: Antd_V1_FileService.Method.Cost.descriptor, + serializer: serializer, + deserializer: deserializer, + options: options, + onResponse: handleResponse + ) + } + } +} + +// Helpers providing default arguments to 'ClientProtocol' methods. +@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) +extension Antd_V1_FileService.ClientProtocol { + /// Call the "Put" method. + /// + /// > Source IDL Documentation: + /// > + /// > Private = unqualified verb (the DataMap is returned to the caller; it is + /// > NOT stored on the network). Public = `_public` suffix (the DataMap is + /// > additionally stored on-network and the call returns the resulting address). + /// + /// - Parameters: + /// - request: A request containing a single `Antd_V1_PutFileRequest` message. + /// - options: Options to apply to this RPC. + /// - handleResponse: A closure which handles the response, the result of which is + /// returned to the caller. Returning from the closure will cancel the RPC if it + /// hasn't already finished. + /// - Returns: The result of `handleResponse`. + public func put( + request: GRPCCore.ClientRequest, + options: GRPCCore.CallOptions = .defaults, + onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> Result = { response in + try response.message + } + ) async throws -> Result where Result: Sendable { + try await self.put( + request: request, + serializer: GRPCProtobuf.ProtobufSerializer(), + deserializer: GRPCProtobuf.ProtobufDeserializer(), + options: options, + onResponse: handleResponse + ) + } + + /// Call the "PutPublic" method. + /// + /// - Parameters: + /// - request: A request containing a single `Antd_V1_PutFileRequest` message. + /// - options: Options to apply to this RPC. + /// - handleResponse: A closure which handles the response, the result of which is + /// returned to the caller. Returning from the closure will cancel the RPC if it + /// hasn't already finished. + /// - Returns: The result of `handleResponse`. + public func putPublic( + request: GRPCCore.ClientRequest, + options: GRPCCore.CallOptions = .defaults, + onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> Result = { response in + try response.message + } + ) async throws -> Result where Result: Sendable { + try await self.putPublic( + request: request, + serializer: GRPCProtobuf.ProtobufSerializer(), + deserializer: GRPCProtobuf.ProtobufDeserializer(), + options: options, + onResponse: handleResponse + ) + } + + /// Call the "Get" method. + /// + /// - Parameters: + /// - request: A request containing a single `Antd_V1_GetFileRequest` message. + /// - options: Options to apply to this RPC. + /// - handleResponse: A closure which handles the response, the result of which is + /// returned to the caller. Returning from the closure will cancel the RPC if it + /// hasn't already finished. + /// - Returns: The result of `handleResponse`. + public func get( + request: GRPCCore.ClientRequest, + options: GRPCCore.CallOptions = .defaults, + onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> Result = { response in + try response.message + } + ) async throws -> Result where Result: Sendable { + try await self.get( + request: request, + serializer: GRPCProtobuf.ProtobufSerializer(), + deserializer: GRPCProtobuf.ProtobufDeserializer(), + options: options, + onResponse: handleResponse + ) + } + + /// Call the "GetPublic" method. + /// + /// - Parameters: + /// - request: A request containing a single `Antd_V1_GetFilePublicRequest` message. + /// - options: Options to apply to this RPC. + /// - handleResponse: A closure which handles the response, the result of which is + /// returned to the caller. Returning from the closure will cancel the RPC if it + /// hasn't already finished. + /// - Returns: The result of `handleResponse`. + public func getPublic( + request: GRPCCore.ClientRequest, + options: GRPCCore.CallOptions = .defaults, + onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> Result = { response in + try response.message + } + ) async throws -> Result where Result: Sendable { + try await self.getPublic( + request: request, + serializer: GRPCProtobuf.ProtobufSerializer(), + deserializer: GRPCProtobuf.ProtobufDeserializer(), + options: options, + onResponse: handleResponse + ) + } + + /// Call the "Cost" method. + /// + /// - Parameters: + /// - request: A request containing a single `Antd_V1_FileCostRequest` message. + /// - options: Options to apply to this RPC. + /// - handleResponse: A closure which handles the response, the result of which is + /// returned to the caller. Returning from the closure will cancel the RPC if it + /// hasn't already finished. + /// - Returns: The result of `handleResponse`. + public func cost( + request: GRPCCore.ClientRequest, + options: GRPCCore.CallOptions = .defaults, + onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> Result = { response in + try response.message + } + ) async throws -> Result where Result: Sendable { + try await self.cost( + request: request, + serializer: GRPCProtobuf.ProtobufSerializer(), + deserializer: GRPCProtobuf.ProtobufDeserializer(), + options: options, + onResponse: handleResponse + ) + } +} + +// Helpers providing sugared APIs for 'ClientProtocol' methods. +@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) +extension Antd_V1_FileService.ClientProtocol { + /// Call the "Put" method. + /// + /// > Source IDL Documentation: + /// > + /// > Private = unqualified verb (the DataMap is returned to the caller; it is + /// > NOT stored on the network). Public = `_public` suffix (the DataMap is + /// > additionally stored on-network and the call returns the resulting address). + /// + /// - Parameters: + /// - message: request message to send. + /// - metadata: Additional metadata to send, defaults to empty. + /// - options: Options to apply to this RPC, defaults to `.defaults`. + /// - handleResponse: A closure which handles the response, the result of which is + /// returned to the caller. Returning from the closure will cancel the RPC if it + /// hasn't already finished. + /// - Returns: The result of `handleResponse`. + public func put( + _ message: Antd_V1_PutFileRequest, + metadata: GRPCCore.Metadata = [:], + options: GRPCCore.CallOptions = .defaults, + onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> Result = { response in + try response.message + } + ) async throws -> Result where Result: Sendable { + let request = GRPCCore.ClientRequest( + message: message, + metadata: metadata + ) + return try await self.put( + request: request, + options: options, + onResponse: handleResponse + ) + } + + /// Call the "PutPublic" method. + /// + /// - Parameters: + /// - message: request message to send. + /// - metadata: Additional metadata to send, defaults to empty. + /// - options: Options to apply to this RPC, defaults to `.defaults`. + /// - handleResponse: A closure which handles the response, the result of which is + /// returned to the caller. Returning from the closure will cancel the RPC if it + /// hasn't already finished. + /// - Returns: The result of `handleResponse`. + public func putPublic( + _ message: Antd_V1_PutFileRequest, + metadata: GRPCCore.Metadata = [:], + options: GRPCCore.CallOptions = .defaults, + onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> Result = { response in + try response.message + } + ) async throws -> Result where Result: Sendable { + let request = GRPCCore.ClientRequest( + message: message, + metadata: metadata + ) + return try await self.putPublic( + request: request, + options: options, + onResponse: handleResponse + ) + } + + /// Call the "Get" method. + /// + /// - Parameters: + /// - message: request message to send. + /// - metadata: Additional metadata to send, defaults to empty. + /// - options: Options to apply to this RPC, defaults to `.defaults`. + /// - handleResponse: A closure which handles the response, the result of which is + /// returned to the caller. Returning from the closure will cancel the RPC if it + /// hasn't already finished. + /// - Returns: The result of `handleResponse`. + public func get( + _ message: Antd_V1_GetFileRequest, + metadata: GRPCCore.Metadata = [:], + options: GRPCCore.CallOptions = .defaults, + onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> Result = { response in + try response.message + } + ) async throws -> Result where Result: Sendable { + let request = GRPCCore.ClientRequest( + message: message, + metadata: metadata + ) + return try await self.get( + request: request, + options: options, + onResponse: handleResponse + ) + } + + /// Call the "GetPublic" method. + /// + /// - Parameters: + /// - message: request message to send. + /// - metadata: Additional metadata to send, defaults to empty. + /// - options: Options to apply to this RPC, defaults to `.defaults`. + /// - handleResponse: A closure which handles the response, the result of which is + /// returned to the caller. Returning from the closure will cancel the RPC if it + /// hasn't already finished. + /// - Returns: The result of `handleResponse`. + public func getPublic( + _ message: Antd_V1_GetFilePublicRequest, + metadata: GRPCCore.Metadata = [:], + options: GRPCCore.CallOptions = .defaults, + onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> Result = { response in + try response.message + } + ) async throws -> Result where Result: Sendable { + let request = GRPCCore.ClientRequest( + message: message, + metadata: metadata + ) + return try await self.getPublic( + request: request, + options: options, + onResponse: handleResponse + ) + } + + /// Call the "Cost" method. + /// + /// - Parameters: + /// - message: request message to send. + /// - metadata: Additional metadata to send, defaults to empty. + /// - options: Options to apply to this RPC, defaults to `.defaults`. + /// - handleResponse: A closure which handles the response, the result of which is + /// returned to the caller. Returning from the closure will cancel the RPC if it + /// hasn't already finished. + /// - Returns: The result of `handleResponse`. + public func cost( + _ message: Antd_V1_FileCostRequest, + metadata: GRPCCore.Metadata = [:], + options: GRPCCore.CallOptions = .defaults, + onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> Result = { response in + try response.message + } + ) async throws -> Result where Result: Sendable { + let request = GRPCCore.ClientRequest( + message: message, + metadata: metadata + ) + return try await self.cost( + request: request, + options: options, + onResponse: handleResponse + ) + } +} \ No newline at end of file diff --git a/antd-swift/Sources/AntdSdk/Proto/antd/v1/files.pb.swift b/antd-swift/Sources/AntdSdk/Proto/antd/v1/files.pb.swift new file mode 100644 index 0000000..2983115 --- /dev/null +++ b/antd-swift/Sources/AntdSdk/Proto/antd/v1/files.pb.swift @@ -0,0 +1,420 @@ +// DO NOT EDIT. +// swift-format-ignore-file +// swiftlint:disable all +// +// Generated by the Swift generator plugin for the protocol buffer compiler. +// Source: antd/v1/files.proto +// +// For information on using the generated types, please see the documentation: +// https://github.com/apple/swift-protobuf/ + +import SwiftProtobuf + +// If the compiler emits an error on this type, it is because this file +// was generated by a version of the `protoc` Swift plug-in that is +// incompatible with the version of SwiftProtobuf to which you are linking. +// Please ensure that you are building against the same version of the API +// that was used to generate this file. +fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck { + struct _2: SwiftProtobuf.ProtobufAPIVersion_2 {} + typealias Version = _2 +} + +public struct Antd_V1_PutFileRequest: Sendable { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + /// local filesystem path + public var path: String = String() + + /// Optional payment mode: "auto" (default), "merkle", or "single". Empty + /// string is treated as "auto" so old clients omitting the field stay + /// wire-compatible. + public var paymentMode: String = String() + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +public struct Antd_V1_PutFilePublicResponse: Sendable { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + /// hex — the DataMap's chunk address on the network + public var address: String = String() + + /// Total storage cost paid in token units (atto). "0" if all chunks already existed. + public var storageCostAtto: String = String() + + /// Total gas cost paid in wei, as a decimal string (u128 exceeds JSON safe-integer range). + public var gasCostWei: String = String() + + /// Number of chunks stored on the network. + public var chunksStored: UInt64 = 0 + + /// Which payment mode was actually used ("auto", "merkle", or "single"). + public var paymentModeUsed: String = String() + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +public struct Antd_V1_PutFileResponse: Sendable { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + /// Hex-encoded rmp_serde-serialized DataMap. The caller keeps this; it is + /// NOT stored on the network. Same shape as `PutDataResponse.data_map`. + public var dataMap: String = String() + + /// Total storage cost paid in token units (atto). "0" if all chunks already existed. + public var storageCostAtto: String = String() + + /// Total gas cost paid in wei, as a decimal string (u128 exceeds JSON safe-integer range). + public var gasCostWei: String = String() + + /// Number of chunks stored on the network. + public var chunksStored: UInt64 = 0 + + /// Which payment mode was actually used ("auto", "merkle", or "single"). + public var paymentModeUsed: String = String() + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +public struct Antd_V1_GetFilePublicRequest: Sendable { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + /// hex — DataMap chunk address + public var address: String = String() + + /// local filesystem path + public var destPath: String = String() + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +public struct Antd_V1_GetFileRequest: Sendable { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + /// hex — rmp_serde-serialized DataMap + public var dataMap: String = String() + + /// local filesystem path + public var destPath: String = String() + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +/// Shared by GetPublic and Get — the file is written to dest_path, the response +/// itself is empty (success = file written, failure = RPC error). +public struct Antd_V1_GetFileResponse: Sendable { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +public struct Antd_V1_FileCostRequest: Sendable { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var path: String = String() + + public var isPublic: Bool = false + + /// Optional payment mode the estimate should reflect: "auto" (default), + /// "merkle", or "single". Empty string is treated as "auto". + public var paymentMode: String = String() + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +// MARK: - Code below here is support for the SwiftProtobuf runtime. + +fileprivate let _protobuf_package = "antd.v1" + +extension Antd_V1_PutFileRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".PutFileRequest" + public static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{1}path\0\u{3}payment_mode\0") + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularStringField(value: &self.path) }() + case 2: try { try decoder.decodeSingularStringField(value: &self.paymentMode) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !self.path.isEmpty { + try visitor.visitSingularStringField(value: self.path, fieldNumber: 1) + } + if !self.paymentMode.isEmpty { + try visitor.visitSingularStringField(value: self.paymentMode, fieldNumber: 2) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Antd_V1_PutFileRequest, rhs: Antd_V1_PutFileRequest) -> Bool { + if lhs.path != rhs.path {return false} + if lhs.paymentMode != rhs.paymentMode {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Antd_V1_PutFilePublicResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".PutFilePublicResponse" + public static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{2}\u{2}address\0\u{3}storage_cost_atto\0\u{3}gas_cost_wei\0\u{3}chunks_stored\0\u{3}payment_mode_used\0\u{b}cost\0\u{c}\u{1}\u{1}") + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 2: try { try decoder.decodeSingularStringField(value: &self.address) }() + case 3: try { try decoder.decodeSingularStringField(value: &self.storageCostAtto) }() + case 4: try { try decoder.decodeSingularStringField(value: &self.gasCostWei) }() + case 5: try { try decoder.decodeSingularUInt64Field(value: &self.chunksStored) }() + case 6: try { try decoder.decodeSingularStringField(value: &self.paymentModeUsed) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !self.address.isEmpty { + try visitor.visitSingularStringField(value: self.address, fieldNumber: 2) + } + if !self.storageCostAtto.isEmpty { + try visitor.visitSingularStringField(value: self.storageCostAtto, fieldNumber: 3) + } + if !self.gasCostWei.isEmpty { + try visitor.visitSingularStringField(value: self.gasCostWei, fieldNumber: 4) + } + if self.chunksStored != 0 { + try visitor.visitSingularUInt64Field(value: self.chunksStored, fieldNumber: 5) + } + if !self.paymentModeUsed.isEmpty { + try visitor.visitSingularStringField(value: self.paymentModeUsed, fieldNumber: 6) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Antd_V1_PutFilePublicResponse, rhs: Antd_V1_PutFilePublicResponse) -> Bool { + if lhs.address != rhs.address {return false} + if lhs.storageCostAtto != rhs.storageCostAtto {return false} + if lhs.gasCostWei != rhs.gasCostWei {return false} + if lhs.chunksStored != rhs.chunksStored {return false} + if lhs.paymentModeUsed != rhs.paymentModeUsed {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Antd_V1_PutFileResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".PutFileResponse" + public static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{3}data_map\0\u{3}storage_cost_atto\0\u{3}gas_cost_wei\0\u{3}chunks_stored\0\u{3}payment_mode_used\0") + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularStringField(value: &self.dataMap) }() + case 2: try { try decoder.decodeSingularStringField(value: &self.storageCostAtto) }() + case 3: try { try decoder.decodeSingularStringField(value: &self.gasCostWei) }() + case 4: try { try decoder.decodeSingularUInt64Field(value: &self.chunksStored) }() + case 5: try { try decoder.decodeSingularStringField(value: &self.paymentModeUsed) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !self.dataMap.isEmpty { + try visitor.visitSingularStringField(value: self.dataMap, fieldNumber: 1) + } + if !self.storageCostAtto.isEmpty { + try visitor.visitSingularStringField(value: self.storageCostAtto, fieldNumber: 2) + } + if !self.gasCostWei.isEmpty { + try visitor.visitSingularStringField(value: self.gasCostWei, fieldNumber: 3) + } + if self.chunksStored != 0 { + try visitor.visitSingularUInt64Field(value: self.chunksStored, fieldNumber: 4) + } + if !self.paymentModeUsed.isEmpty { + try visitor.visitSingularStringField(value: self.paymentModeUsed, fieldNumber: 5) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Antd_V1_PutFileResponse, rhs: Antd_V1_PutFileResponse) -> Bool { + if lhs.dataMap != rhs.dataMap {return false} + if lhs.storageCostAtto != rhs.storageCostAtto {return false} + if lhs.gasCostWei != rhs.gasCostWei {return false} + if lhs.chunksStored != rhs.chunksStored {return false} + if lhs.paymentModeUsed != rhs.paymentModeUsed {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Antd_V1_GetFilePublicRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".GetFilePublicRequest" + public static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{1}address\0\u{3}dest_path\0") + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularStringField(value: &self.address) }() + case 2: try { try decoder.decodeSingularStringField(value: &self.destPath) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !self.address.isEmpty { + try visitor.visitSingularStringField(value: self.address, fieldNumber: 1) + } + if !self.destPath.isEmpty { + try visitor.visitSingularStringField(value: self.destPath, fieldNumber: 2) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Antd_V1_GetFilePublicRequest, rhs: Antd_V1_GetFilePublicRequest) -> Bool { + if lhs.address != rhs.address {return false} + if lhs.destPath != rhs.destPath {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Antd_V1_GetFileRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".GetFileRequest" + public static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{3}data_map\0\u{3}dest_path\0") + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularStringField(value: &self.dataMap) }() + case 2: try { try decoder.decodeSingularStringField(value: &self.destPath) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !self.dataMap.isEmpty { + try visitor.visitSingularStringField(value: self.dataMap, fieldNumber: 1) + } + if !self.destPath.isEmpty { + try visitor.visitSingularStringField(value: self.destPath, fieldNumber: 2) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Antd_V1_GetFileRequest, rhs: Antd_V1_GetFileRequest) -> Bool { + if lhs.dataMap != rhs.dataMap {return false} + if lhs.destPath != rhs.destPath {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Antd_V1_GetFileResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".GetFileResponse" + public static let _protobuf_nameMap = SwiftProtobuf._NameMap() + + public mutating func decodeMessage(decoder: inout D) throws { + // Load everything into unknown fields + while try decoder.nextFieldNumber() != nil {} + } + + public func traverse(visitor: inout V) throws { + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Antd_V1_GetFileResponse, rhs: Antd_V1_GetFileResponse) -> Bool { + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Antd_V1_FileCostRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".FileCostRequest" + public static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{1}path\0\u{3}is_public\0\u{3}payment_mode\0") + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularStringField(value: &self.path) }() + case 2: try { try decoder.decodeSingularBoolField(value: &self.isPublic) }() + case 3: try { try decoder.decodeSingularStringField(value: &self.paymentMode) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !self.path.isEmpty { + try visitor.visitSingularStringField(value: self.path, fieldNumber: 1) + } + if self.isPublic != false { + try visitor.visitSingularBoolField(value: self.isPublic, fieldNumber: 2) + } + if !self.paymentMode.isEmpty { + try visitor.visitSingularStringField(value: self.paymentMode, fieldNumber: 3) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Antd_V1_FileCostRequest, rhs: Antd_V1_FileCostRequest) -> Bool { + if lhs.path != rhs.path {return false} + if lhs.isPublic != rhs.isPublic {return false} + if lhs.paymentMode != rhs.paymentMode {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} diff --git a/antd-swift/Sources/AntdSdk/Proto/antd/v1/health.grpc.swift b/antd-swift/Sources/AntdSdk/Proto/antd/v1/health.grpc.swift new file mode 100644 index 0000000..7514bfb --- /dev/null +++ b/antd-swift/Sources/AntdSdk/Proto/antd/v1/health.grpc.swift @@ -0,0 +1,310 @@ +// DO NOT EDIT. +// swift-format-ignore-file +// swiftlint:disable all +// +// Generated by the gRPC Swift generator plugin for the protocol buffer compiler. +// Source: antd/v1/health.proto +// +// For information on using the generated types, please see the documentation: +// https://github.com/grpc/grpc-swift + +import GRPCCore +import GRPCProtobuf + +// MARK: - antd.v1.HealthService + +/// Namespace containing generated types for the "antd.v1.HealthService" service. +@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) +public enum Antd_V1_HealthService { + /// Service descriptor for the "antd.v1.HealthService" service. + public static let descriptor = GRPCCore.ServiceDescriptor(fullyQualifiedService: "antd.v1.HealthService") + /// Namespace for method metadata. + public enum Method { + /// Namespace for "Check" metadata. + public enum Check { + /// Request type for "Check". + public typealias Input = Antd_V1_HealthCheckRequest + /// Response type for "Check". + public typealias Output = Antd_V1_HealthCheckResponse + /// Descriptor for "Check". + public static let descriptor = GRPCCore.MethodDescriptor( + service: GRPCCore.ServiceDescriptor(fullyQualifiedService: "antd.v1.HealthService"), + method: "Check" + ) + } + /// Descriptors for all methods in the "antd.v1.HealthService" service. + public static let descriptors: [GRPCCore.MethodDescriptor] = [ + Check.descriptor + ] + } +} + +@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) +extension GRPCCore.ServiceDescriptor { + /// Service descriptor for the "antd.v1.HealthService" service. + public static let antd_v1_HealthService = GRPCCore.ServiceDescriptor(fullyQualifiedService: "antd.v1.HealthService") +} + +// MARK: antd.v1.HealthService (server) + +@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) +extension Antd_V1_HealthService { + /// Streaming variant of the service protocol for the "antd.v1.HealthService" service. + /// + /// This protocol is the lowest-level of the service protocols generated for this service + /// giving you the most flexibility over the implementation of your service. This comes at + /// the cost of more verbose and less strict APIs. Each RPC requires you to implement it in + /// terms of a request stream and response stream. Where only a single request or response + /// message is expected, you are responsible for enforcing this invariant is maintained. + /// + /// Where possible, prefer using the stricter, less-verbose ``ServiceProtocol`` + /// or ``SimpleServiceProtocol`` instead. + public protocol StreamingServiceProtocol: GRPCCore.RegistrableRPCService { + /// Handle the "Check" method. + /// + /// - Parameters: + /// - request: A streaming request of `Antd_V1_HealthCheckRequest` messages. + /// - context: Context providing information about the RPC. + /// - Throws: Any error which occurred during the processing of the request. Thrown errors + /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted + /// to an internal error. + /// - Returns: A streaming response of `Antd_V1_HealthCheckResponse` messages. + func check( + request: GRPCCore.StreamingServerRequest, + context: GRPCCore.ServerContext + ) async throws -> GRPCCore.StreamingServerResponse + } + + /// Service protocol for the "antd.v1.HealthService" service. + /// + /// This protocol is higher level than ``StreamingServiceProtocol`` but lower level than + /// the ``SimpleServiceProtocol``, it provides access to request and response metadata and + /// trailing response metadata. If you don't need these then consider using + /// the ``SimpleServiceProtocol``. If you need fine grained control over your RPCs then + /// use ``StreamingServiceProtocol``. + public protocol ServiceProtocol: Antd_V1_HealthService.StreamingServiceProtocol { + /// Handle the "Check" method. + /// + /// - Parameters: + /// - request: A request containing a single `Antd_V1_HealthCheckRequest` message. + /// - context: Context providing information about the RPC. + /// - Throws: Any error which occurred during the processing of the request. Thrown errors + /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted + /// to an internal error. + /// - Returns: A response containing a single `Antd_V1_HealthCheckResponse` message. + func check( + request: GRPCCore.ServerRequest, + context: GRPCCore.ServerContext + ) async throws -> GRPCCore.ServerResponse + } + + /// Simple service protocol for the "antd.v1.HealthService" service. + /// + /// This is the highest level protocol for the service. The API is the easiest to use but + /// doesn't provide access to request or response metadata. If you need access to these + /// then use ``ServiceProtocol`` instead. + public protocol SimpleServiceProtocol: Antd_V1_HealthService.ServiceProtocol { + /// Handle the "Check" method. + /// + /// - Parameters: + /// - request: A `Antd_V1_HealthCheckRequest` message. + /// - context: Context providing information about the RPC. + /// - Throws: Any error which occurred during the processing of the request. Thrown errors + /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted + /// to an internal error. + /// - Returns: A `Antd_V1_HealthCheckResponse` to respond with. + func check( + request: Antd_V1_HealthCheckRequest, + context: GRPCCore.ServerContext + ) async throws -> Antd_V1_HealthCheckResponse + } +} + +// Default implementation of 'registerMethods(with:)'. +@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) +extension Antd_V1_HealthService.StreamingServiceProtocol { + public func registerMethods(with router: inout GRPCCore.RPCRouter) where Transport: GRPCCore.ServerTransport { + router.registerHandler( + forMethod: Antd_V1_HealthService.Method.Check.descriptor, + deserializer: GRPCProtobuf.ProtobufDeserializer(), + serializer: GRPCProtobuf.ProtobufSerializer(), + handler: { request, context in + try await self.check( + request: request, + context: context + ) + } + ) + } +} + +// Default implementation of streaming methods from 'StreamingServiceProtocol'. +@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) +extension Antd_V1_HealthService.ServiceProtocol { + public func check( + request: GRPCCore.StreamingServerRequest, + context: GRPCCore.ServerContext + ) async throws -> GRPCCore.StreamingServerResponse { + let response = try await self.check( + request: GRPCCore.ServerRequest(stream: request), + context: context + ) + return GRPCCore.StreamingServerResponse(single: response) + } +} + +// Default implementation of methods from 'ServiceProtocol'. +@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) +extension Antd_V1_HealthService.SimpleServiceProtocol { + public func check( + request: GRPCCore.ServerRequest, + context: GRPCCore.ServerContext + ) async throws -> GRPCCore.ServerResponse { + return GRPCCore.ServerResponse( + message: try await self.check( + request: request.message, + context: context + ), + metadata: [:] + ) + } +} + +// MARK: antd.v1.HealthService (client) + +@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) +extension Antd_V1_HealthService { + /// Generated client protocol for the "antd.v1.HealthService" service. + /// + /// You don't need to implement this protocol directly, use the generated + /// implementation, ``Client``. + public protocol ClientProtocol: Sendable { + /// Call the "Check" method. + /// + /// - Parameters: + /// - request: A request containing a single `Antd_V1_HealthCheckRequest` message. + /// - serializer: A serializer for `Antd_V1_HealthCheckRequest` messages. + /// - deserializer: A deserializer for `Antd_V1_HealthCheckResponse` messages. + /// - options: Options to apply to this RPC. + /// - handleResponse: A closure which handles the response, the result of which is + /// returned to the caller. Returning from the closure will cancel the RPC if it + /// hasn't already finished. + /// - Returns: The result of `handleResponse`. + func check( + request: GRPCCore.ClientRequest, + serializer: some GRPCCore.MessageSerializer, + deserializer: some GRPCCore.MessageDeserializer, + options: GRPCCore.CallOptions, + onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> Result + ) async throws -> Result where Result: Sendable + } + + /// Generated client for the "antd.v1.HealthService" service. + /// + /// The ``Client`` provides an implementation of ``ClientProtocol`` which wraps + /// a `GRPCCore.GRPCCClient`. The underlying `GRPCClient` provides the long-lived + /// means of communication with the remote peer. + public struct Client: ClientProtocol where Transport: GRPCCore.ClientTransport { + private let client: GRPCCore.GRPCClient + + /// Creates a new client wrapping the provided `GRPCCore.GRPCClient`. + /// + /// - Parameters: + /// - client: A `GRPCCore.GRPCClient` providing a communication channel to the service. + public init(wrapping client: GRPCCore.GRPCClient) { + self.client = client + } + + /// Call the "Check" method. + /// + /// - Parameters: + /// - request: A request containing a single `Antd_V1_HealthCheckRequest` message. + /// - serializer: A serializer for `Antd_V1_HealthCheckRequest` messages. + /// - deserializer: A deserializer for `Antd_V1_HealthCheckResponse` messages. + /// - options: Options to apply to this RPC. + /// - handleResponse: A closure which handles the response, the result of which is + /// returned to the caller. Returning from the closure will cancel the RPC if it + /// hasn't already finished. + /// - Returns: The result of `handleResponse`. + public func check( + request: GRPCCore.ClientRequest, + serializer: some GRPCCore.MessageSerializer, + deserializer: some GRPCCore.MessageDeserializer, + options: GRPCCore.CallOptions = .defaults, + onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> Result = { response in + try response.message + } + ) async throws -> Result where Result: Sendable { + try await self.client.unary( + request: request, + descriptor: Antd_V1_HealthService.Method.Check.descriptor, + serializer: serializer, + deserializer: deserializer, + options: options, + onResponse: handleResponse + ) + } + } +} + +// Helpers providing default arguments to 'ClientProtocol' methods. +@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) +extension Antd_V1_HealthService.ClientProtocol { + /// Call the "Check" method. + /// + /// - Parameters: + /// - request: A request containing a single `Antd_V1_HealthCheckRequest` message. + /// - options: Options to apply to this RPC. + /// - handleResponse: A closure which handles the response, the result of which is + /// returned to the caller. Returning from the closure will cancel the RPC if it + /// hasn't already finished. + /// - Returns: The result of `handleResponse`. + public func check( + request: GRPCCore.ClientRequest, + options: GRPCCore.CallOptions = .defaults, + onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> Result = { response in + try response.message + } + ) async throws -> Result where Result: Sendable { + try await self.check( + request: request, + serializer: GRPCProtobuf.ProtobufSerializer(), + deserializer: GRPCProtobuf.ProtobufDeserializer(), + options: options, + onResponse: handleResponse + ) + } +} + +// Helpers providing sugared APIs for 'ClientProtocol' methods. +@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) +extension Antd_V1_HealthService.ClientProtocol { + /// Call the "Check" method. + /// + /// - Parameters: + /// - message: request message to send. + /// - metadata: Additional metadata to send, defaults to empty. + /// - options: Options to apply to this RPC, defaults to `.defaults`. + /// - handleResponse: A closure which handles the response, the result of which is + /// returned to the caller. Returning from the closure will cancel the RPC if it + /// hasn't already finished. + /// - Returns: The result of `handleResponse`. + public func check( + _ message: Antd_V1_HealthCheckRequest, + metadata: GRPCCore.Metadata = [:], + options: GRPCCore.CallOptions = .defaults, + onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> Result = { response in + try response.message + } + ) async throws -> Result where Result: Sendable { + let request = GRPCCore.ClientRequest( + message: message, + metadata: metadata + ) + return try await self.check( + request: request, + options: options, + onResponse: handleResponse + ) + } +} \ No newline at end of file diff --git a/antd-swift/Sources/AntdSdk/Proto/antd/v1/health.pb.swift b/antd-swift/Sources/AntdSdk/Proto/antd/v1/health.pb.swift new file mode 100644 index 0000000..1640039 --- /dev/null +++ b/antd-swift/Sources/AntdSdk/Proto/antd/v1/health.pb.swift @@ -0,0 +1,153 @@ +// DO NOT EDIT. +// swift-format-ignore-file +// swiftlint:disable all +// +// Generated by the Swift generator plugin for the protocol buffer compiler. +// Source: antd/v1/health.proto +// +// For information on using the generated types, please see the documentation: +// https://github.com/apple/swift-protobuf/ + +import SwiftProtobuf + +// If the compiler emits an error on this type, it is because this file +// was generated by a version of the `protoc` Swift plug-in that is +// incompatible with the version of SwiftProtobuf to which you are linking. +// Please ensure that you are building against the same version of the API +// that was used to generate this file. +fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck { + struct _2: SwiftProtobuf.ProtobufAPIVersion_2 {} + typealias Version = _2 +} + +public struct Antd_V1_HealthCheckRequest: Sendable { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +public struct Antd_V1_HealthCheckResponse: Sendable { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + /// "ok" + public var status: String = String() + + /// "default", "local", "alpha" + public var network: String = String() + + /// antd crate version (e.g. "0.4.0") + public var version: String = String() + + /// EVM preset: "arbitrum-one", "arbitrum-sepolia", "local", "custom" + public var evmNetwork: String = String() + + /// seconds since process start + public var uptimeSeconds: UInt64 = 0 + + /// short git SHA, or "" if built outside a git checkout + public var buildCommit: String = String() + + /// token contract, or "" if unconfigured + public var paymentTokenAddress: String = String() + + /// payment vault contract, or "" if unconfigured + public var paymentVaultAddress: String = String() + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +// MARK: - Code below here is support for the SwiftProtobuf runtime. + +fileprivate let _protobuf_package = "antd.v1" + +extension Antd_V1_HealthCheckRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".HealthCheckRequest" + public static let _protobuf_nameMap = SwiftProtobuf._NameMap() + + public mutating func decodeMessage(decoder: inout D) throws { + // Load everything into unknown fields + while try decoder.nextFieldNumber() != nil {} + } + + public func traverse(visitor: inout V) throws { + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Antd_V1_HealthCheckRequest, rhs: Antd_V1_HealthCheckRequest) -> Bool { + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Antd_V1_HealthCheckResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".HealthCheckResponse" + public static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{1}status\0\u{1}network\0\u{1}version\0\u{3}evm_network\0\u{3}uptime_seconds\0\u{3}build_commit\0\u{3}payment_token_address\0\u{3}payment_vault_address\0") + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularStringField(value: &self.status) }() + case 2: try { try decoder.decodeSingularStringField(value: &self.network) }() + case 3: try { try decoder.decodeSingularStringField(value: &self.version) }() + case 4: try { try decoder.decodeSingularStringField(value: &self.evmNetwork) }() + case 5: try { try decoder.decodeSingularUInt64Field(value: &self.uptimeSeconds) }() + case 6: try { try decoder.decodeSingularStringField(value: &self.buildCommit) }() + case 7: try { try decoder.decodeSingularStringField(value: &self.paymentTokenAddress) }() + case 8: try { try decoder.decodeSingularStringField(value: &self.paymentVaultAddress) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !self.status.isEmpty { + try visitor.visitSingularStringField(value: self.status, fieldNumber: 1) + } + if !self.network.isEmpty { + try visitor.visitSingularStringField(value: self.network, fieldNumber: 2) + } + if !self.version.isEmpty { + try visitor.visitSingularStringField(value: self.version, fieldNumber: 3) + } + if !self.evmNetwork.isEmpty { + try visitor.visitSingularStringField(value: self.evmNetwork, fieldNumber: 4) + } + if self.uptimeSeconds != 0 { + try visitor.visitSingularUInt64Field(value: self.uptimeSeconds, fieldNumber: 5) + } + if !self.buildCommit.isEmpty { + try visitor.visitSingularStringField(value: self.buildCommit, fieldNumber: 6) + } + if !self.paymentTokenAddress.isEmpty { + try visitor.visitSingularStringField(value: self.paymentTokenAddress, fieldNumber: 7) + } + if !self.paymentVaultAddress.isEmpty { + try visitor.visitSingularStringField(value: self.paymentVaultAddress, fieldNumber: 8) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Antd_V1_HealthCheckResponse, rhs: Antd_V1_HealthCheckResponse) -> Bool { + if lhs.status != rhs.status {return false} + if lhs.network != rhs.network {return false} + if lhs.version != rhs.version {return false} + if lhs.evmNetwork != rhs.evmNetwork {return false} + if lhs.uptimeSeconds != rhs.uptimeSeconds {return false} + if lhs.buildCommit != rhs.buildCommit {return false} + if lhs.paymentTokenAddress != rhs.paymentTokenAddress {return false} + if lhs.paymentVaultAddress != rhs.paymentVaultAddress {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} diff --git a/antd-swift/Sources/AntdSdk/Proto/antd/v1/wallet.grpc.swift b/antd-swift/Sources/AntdSdk/Proto/antd/v1/wallet.grpc.swift new file mode 100644 index 0000000..2e8ccd0 --- /dev/null +++ b/antd-swift/Sources/AntdSdk/Proto/antd/v1/wallet.grpc.swift @@ -0,0 +1,864 @@ +// DO NOT EDIT. +// swift-format-ignore-file +// swiftlint:disable all +// +// Generated by the gRPC Swift generator plugin for the protocol buffer compiler. +// Source: antd/v1/wallet.proto +// +// For information on using the generated types, please see the documentation: +// https://github.com/grpc/grpc-swift + +import GRPCCore +import GRPCProtobuf + +// MARK: - antd.v1.WalletService + +/// Namespace containing generated types for the "antd.v1.WalletService" service. +@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) +public enum Antd_V1_WalletService { + /// Service descriptor for the "antd.v1.WalletService" service. + public static let descriptor = GRPCCore.ServiceDescriptor(fullyQualifiedService: "antd.v1.WalletService") + /// Namespace for method metadata. + public enum Method { + /// Namespace for "GetAddress" metadata. + public enum GetAddress { + /// Request type for "GetAddress". + public typealias Input = Antd_V1_GetWalletAddressRequest + /// Response type for "GetAddress". + public typealias Output = Antd_V1_GetWalletAddressResponse + /// Descriptor for "GetAddress". + public static let descriptor = GRPCCore.MethodDescriptor( + service: GRPCCore.ServiceDescriptor(fullyQualifiedService: "antd.v1.WalletService"), + method: "GetAddress" + ) + } + /// Namespace for "GetBalance" metadata. + public enum GetBalance { + /// Request type for "GetBalance". + public typealias Input = Antd_V1_GetWalletBalanceRequest + /// Response type for "GetBalance". + public typealias Output = Antd_V1_GetWalletBalanceResponse + /// Descriptor for "GetBalance". + public static let descriptor = GRPCCore.MethodDescriptor( + service: GRPCCore.ServiceDescriptor(fullyQualifiedService: "antd.v1.WalletService"), + method: "GetBalance" + ) + } + /// Namespace for "Approve" metadata. + public enum Approve { + /// Request type for "Approve". + public typealias Input = Antd_V1_WalletApproveRequest + /// Response type for "Approve". + public typealias Output = Antd_V1_WalletApproveResponse + /// Descriptor for "Approve". + public static let descriptor = GRPCCore.MethodDescriptor( + service: GRPCCore.ServiceDescriptor(fullyQualifiedService: "antd.v1.WalletService"), + method: "Approve" + ) + } + /// Descriptors for all methods in the "antd.v1.WalletService" service. + public static let descriptors: [GRPCCore.MethodDescriptor] = [ + GetAddress.descriptor, + GetBalance.descriptor, + Approve.descriptor + ] + } +} + +@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) +extension GRPCCore.ServiceDescriptor { + /// Service descriptor for the "antd.v1.WalletService" service. + public static let antd_v1_WalletService = GRPCCore.ServiceDescriptor(fullyQualifiedService: "antd.v1.WalletService") +} + +// MARK: antd.v1.WalletService (server) + +@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) +extension Antd_V1_WalletService { + /// Streaming variant of the service protocol for the "antd.v1.WalletService" service. + /// + /// This protocol is the lowest-level of the service protocols generated for this service + /// giving you the most flexibility over the implementation of your service. This comes at + /// the cost of more verbose and less strict APIs. Each RPC requires you to implement it in + /// terms of a request stream and response stream. Where only a single request or response + /// message is expected, you are responsible for enforcing this invariant is maintained. + /// + /// Where possible, prefer using the stricter, less-verbose ``ServiceProtocol`` + /// or ``SimpleServiceProtocol`` instead. + /// + /// > Source IDL Documentation: + /// > + /// > Wallet operations. Mirrors the REST `/v1/wallet/*` surface 1:1. + /// > + /// > All three RPCs require the daemon to have been started with a configured + /// > wallet (the `AUTONOMI_WALLET_KEY` env var). When the wallet is absent the + /// > daemon returns `Status::failed_precondition` with the same "wallet not + /// > configured" message the REST handlers return as 503. + /// > + /// > External-signer flows do NOT use this service — they pay via off-daemon + /// > EVM transactions, see `UploadService` and `ChunkService.PrepareChunk` / + /// > `FinalizeChunk` for the prepare/finalize surface. `WalletService` is only + /// > for callers that have entrusted a key to the daemon. + public protocol StreamingServiceProtocol: GRPCCore.RegistrableRPCService { + /// Handle the "GetAddress" method. + /// + /// > Source IDL Documentation: + /// > + /// > Returns the wallet's on-chain address (hex with 0x prefix). + /// + /// - Parameters: + /// - request: A streaming request of `Antd_V1_GetWalletAddressRequest` messages. + /// - context: Context providing information about the RPC. + /// - Throws: Any error which occurred during the processing of the request. Thrown errors + /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted + /// to an internal error. + /// - Returns: A streaming response of `Antd_V1_GetWalletAddressResponse` messages. + func getAddress( + request: GRPCCore.StreamingServerRequest, + context: GRPCCore.ServerContext + ) async throws -> GRPCCore.StreamingServerResponse + + /// Handle the "GetBalance" method. + /// + /// > Source IDL Documentation: + /// > + /// > Returns the wallet's token + gas balances. + /// + /// - Parameters: + /// - request: A streaming request of `Antd_V1_GetWalletBalanceRequest` messages. + /// - context: Context providing information about the RPC. + /// - Throws: Any error which occurred during the processing of the request. Thrown errors + /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted + /// to an internal error. + /// - Returns: A streaming response of `Antd_V1_GetWalletBalanceResponse` messages. + func getBalance( + request: GRPCCore.StreamingServerRequest, + context: GRPCCore.ServerContext + ) async throws -> GRPCCore.StreamingServerResponse + + /// Handle the "Approve" method. + /// + /// > Source IDL Documentation: + /// > + /// > Approves the wallet to spend tokens on the payment vault contract. + /// > One-time operation; safe to call repeatedly (idempotent at the contract + /// > level — a no-op once approval is in place). + /// + /// - Parameters: + /// - request: A streaming request of `Antd_V1_WalletApproveRequest` messages. + /// - context: Context providing information about the RPC. + /// - Throws: Any error which occurred during the processing of the request. Thrown errors + /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted + /// to an internal error. + /// - Returns: A streaming response of `Antd_V1_WalletApproveResponse` messages. + func approve( + request: GRPCCore.StreamingServerRequest, + context: GRPCCore.ServerContext + ) async throws -> GRPCCore.StreamingServerResponse + } + + /// Service protocol for the "antd.v1.WalletService" service. + /// + /// This protocol is higher level than ``StreamingServiceProtocol`` but lower level than + /// the ``SimpleServiceProtocol``, it provides access to request and response metadata and + /// trailing response metadata. If you don't need these then consider using + /// the ``SimpleServiceProtocol``. If you need fine grained control over your RPCs then + /// use ``StreamingServiceProtocol``. + /// + /// > Source IDL Documentation: + /// > + /// > Wallet operations. Mirrors the REST `/v1/wallet/*` surface 1:1. + /// > + /// > All three RPCs require the daemon to have been started with a configured + /// > wallet (the `AUTONOMI_WALLET_KEY` env var). When the wallet is absent the + /// > daemon returns `Status::failed_precondition` with the same "wallet not + /// > configured" message the REST handlers return as 503. + /// > + /// > External-signer flows do NOT use this service — they pay via off-daemon + /// > EVM transactions, see `UploadService` and `ChunkService.PrepareChunk` / + /// > `FinalizeChunk` for the prepare/finalize surface. `WalletService` is only + /// > for callers that have entrusted a key to the daemon. + public protocol ServiceProtocol: Antd_V1_WalletService.StreamingServiceProtocol { + /// Handle the "GetAddress" method. + /// + /// > Source IDL Documentation: + /// > + /// > Returns the wallet's on-chain address (hex with 0x prefix). + /// + /// - Parameters: + /// - request: A request containing a single `Antd_V1_GetWalletAddressRequest` message. + /// - context: Context providing information about the RPC. + /// - Throws: Any error which occurred during the processing of the request. Thrown errors + /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted + /// to an internal error. + /// - Returns: A response containing a single `Antd_V1_GetWalletAddressResponse` message. + func getAddress( + request: GRPCCore.ServerRequest, + context: GRPCCore.ServerContext + ) async throws -> GRPCCore.ServerResponse + + /// Handle the "GetBalance" method. + /// + /// > Source IDL Documentation: + /// > + /// > Returns the wallet's token + gas balances. + /// + /// - Parameters: + /// - request: A request containing a single `Antd_V1_GetWalletBalanceRequest` message. + /// - context: Context providing information about the RPC. + /// - Throws: Any error which occurred during the processing of the request. Thrown errors + /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted + /// to an internal error. + /// - Returns: A response containing a single `Antd_V1_GetWalletBalanceResponse` message. + func getBalance( + request: GRPCCore.ServerRequest, + context: GRPCCore.ServerContext + ) async throws -> GRPCCore.ServerResponse + + /// Handle the "Approve" method. + /// + /// > Source IDL Documentation: + /// > + /// > Approves the wallet to spend tokens on the payment vault contract. + /// > One-time operation; safe to call repeatedly (idempotent at the contract + /// > level — a no-op once approval is in place). + /// + /// - Parameters: + /// - request: A request containing a single `Antd_V1_WalletApproveRequest` message. + /// - context: Context providing information about the RPC. + /// - Throws: Any error which occurred during the processing of the request. Thrown errors + /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted + /// to an internal error. + /// - Returns: A response containing a single `Antd_V1_WalletApproveResponse` message. + func approve( + request: GRPCCore.ServerRequest, + context: GRPCCore.ServerContext + ) async throws -> GRPCCore.ServerResponse + } + + /// Simple service protocol for the "antd.v1.WalletService" service. + /// + /// This is the highest level protocol for the service. The API is the easiest to use but + /// doesn't provide access to request or response metadata. If you need access to these + /// then use ``ServiceProtocol`` instead. + /// + /// > Source IDL Documentation: + /// > + /// > Wallet operations. Mirrors the REST `/v1/wallet/*` surface 1:1. + /// > + /// > All three RPCs require the daemon to have been started with a configured + /// > wallet (the `AUTONOMI_WALLET_KEY` env var). When the wallet is absent the + /// > daemon returns `Status::failed_precondition` with the same "wallet not + /// > configured" message the REST handlers return as 503. + /// > + /// > External-signer flows do NOT use this service — they pay via off-daemon + /// > EVM transactions, see `UploadService` and `ChunkService.PrepareChunk` / + /// > `FinalizeChunk` for the prepare/finalize surface. `WalletService` is only + /// > for callers that have entrusted a key to the daemon. + public protocol SimpleServiceProtocol: Antd_V1_WalletService.ServiceProtocol { + /// Handle the "GetAddress" method. + /// + /// > Source IDL Documentation: + /// > + /// > Returns the wallet's on-chain address (hex with 0x prefix). + /// + /// - Parameters: + /// - request: A `Antd_V1_GetWalletAddressRequest` message. + /// - context: Context providing information about the RPC. + /// - Throws: Any error which occurred during the processing of the request. Thrown errors + /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted + /// to an internal error. + /// - Returns: A `Antd_V1_GetWalletAddressResponse` to respond with. + func getAddress( + request: Antd_V1_GetWalletAddressRequest, + context: GRPCCore.ServerContext + ) async throws -> Antd_V1_GetWalletAddressResponse + + /// Handle the "GetBalance" method. + /// + /// > Source IDL Documentation: + /// > + /// > Returns the wallet's token + gas balances. + /// + /// - Parameters: + /// - request: A `Antd_V1_GetWalletBalanceRequest` message. + /// - context: Context providing information about the RPC. + /// - Throws: Any error which occurred during the processing of the request. Thrown errors + /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted + /// to an internal error. + /// - Returns: A `Antd_V1_GetWalletBalanceResponse` to respond with. + func getBalance( + request: Antd_V1_GetWalletBalanceRequest, + context: GRPCCore.ServerContext + ) async throws -> Antd_V1_GetWalletBalanceResponse + + /// Handle the "Approve" method. + /// + /// > Source IDL Documentation: + /// > + /// > Approves the wallet to spend tokens on the payment vault contract. + /// > One-time operation; safe to call repeatedly (idempotent at the contract + /// > level — a no-op once approval is in place). + /// + /// - Parameters: + /// - request: A `Antd_V1_WalletApproveRequest` message. + /// - context: Context providing information about the RPC. + /// - Throws: Any error which occurred during the processing of the request. Thrown errors + /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted + /// to an internal error. + /// - Returns: A `Antd_V1_WalletApproveResponse` to respond with. + func approve( + request: Antd_V1_WalletApproveRequest, + context: GRPCCore.ServerContext + ) async throws -> Antd_V1_WalletApproveResponse + } +} + +// Default implementation of 'registerMethods(with:)'. +@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) +extension Antd_V1_WalletService.StreamingServiceProtocol { + public func registerMethods(with router: inout GRPCCore.RPCRouter) where Transport: GRPCCore.ServerTransport { + router.registerHandler( + forMethod: Antd_V1_WalletService.Method.GetAddress.descriptor, + deserializer: GRPCProtobuf.ProtobufDeserializer(), + serializer: GRPCProtobuf.ProtobufSerializer(), + handler: { request, context in + try await self.getAddress( + request: request, + context: context + ) + } + ) + router.registerHandler( + forMethod: Antd_V1_WalletService.Method.GetBalance.descriptor, + deserializer: GRPCProtobuf.ProtobufDeserializer(), + serializer: GRPCProtobuf.ProtobufSerializer(), + handler: { request, context in + try await self.getBalance( + request: request, + context: context + ) + } + ) + router.registerHandler( + forMethod: Antd_V1_WalletService.Method.Approve.descriptor, + deserializer: GRPCProtobuf.ProtobufDeserializer(), + serializer: GRPCProtobuf.ProtobufSerializer(), + handler: { request, context in + try await self.approve( + request: request, + context: context + ) + } + ) + } +} + +// Default implementation of streaming methods from 'StreamingServiceProtocol'. +@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) +extension Antd_V1_WalletService.ServiceProtocol { + public func getAddress( + request: GRPCCore.StreamingServerRequest, + context: GRPCCore.ServerContext + ) async throws -> GRPCCore.StreamingServerResponse { + let response = try await self.getAddress( + request: GRPCCore.ServerRequest(stream: request), + context: context + ) + return GRPCCore.StreamingServerResponse(single: response) + } + + public func getBalance( + request: GRPCCore.StreamingServerRequest, + context: GRPCCore.ServerContext + ) async throws -> GRPCCore.StreamingServerResponse { + let response = try await self.getBalance( + request: GRPCCore.ServerRequest(stream: request), + context: context + ) + return GRPCCore.StreamingServerResponse(single: response) + } + + public func approve( + request: GRPCCore.StreamingServerRequest, + context: GRPCCore.ServerContext + ) async throws -> GRPCCore.StreamingServerResponse { + let response = try await self.approve( + request: GRPCCore.ServerRequest(stream: request), + context: context + ) + return GRPCCore.StreamingServerResponse(single: response) + } +} + +// Default implementation of methods from 'ServiceProtocol'. +@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) +extension Antd_V1_WalletService.SimpleServiceProtocol { + public func getAddress( + request: GRPCCore.ServerRequest, + context: GRPCCore.ServerContext + ) async throws -> GRPCCore.ServerResponse { + return GRPCCore.ServerResponse( + message: try await self.getAddress( + request: request.message, + context: context + ), + metadata: [:] + ) + } + + public func getBalance( + request: GRPCCore.ServerRequest, + context: GRPCCore.ServerContext + ) async throws -> GRPCCore.ServerResponse { + return GRPCCore.ServerResponse( + message: try await self.getBalance( + request: request.message, + context: context + ), + metadata: [:] + ) + } + + public func approve( + request: GRPCCore.ServerRequest, + context: GRPCCore.ServerContext + ) async throws -> GRPCCore.ServerResponse { + return GRPCCore.ServerResponse( + message: try await self.approve( + request: request.message, + context: context + ), + metadata: [:] + ) + } +} + +// MARK: antd.v1.WalletService (client) + +@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) +extension Antd_V1_WalletService { + /// Generated client protocol for the "antd.v1.WalletService" service. + /// + /// You don't need to implement this protocol directly, use the generated + /// implementation, ``Client``. + /// + /// > Source IDL Documentation: + /// > + /// > Wallet operations. Mirrors the REST `/v1/wallet/*` surface 1:1. + /// > + /// > All three RPCs require the daemon to have been started with a configured + /// > wallet (the `AUTONOMI_WALLET_KEY` env var). When the wallet is absent the + /// > daemon returns `Status::failed_precondition` with the same "wallet not + /// > configured" message the REST handlers return as 503. + /// > + /// > External-signer flows do NOT use this service — they pay via off-daemon + /// > EVM transactions, see `UploadService` and `ChunkService.PrepareChunk` / + /// > `FinalizeChunk` for the prepare/finalize surface. `WalletService` is only + /// > for callers that have entrusted a key to the daemon. + public protocol ClientProtocol: Sendable { + /// Call the "GetAddress" method. + /// + /// > Source IDL Documentation: + /// > + /// > Returns the wallet's on-chain address (hex with 0x prefix). + /// + /// - Parameters: + /// - request: A request containing a single `Antd_V1_GetWalletAddressRequest` message. + /// - serializer: A serializer for `Antd_V1_GetWalletAddressRequest` messages. + /// - deserializer: A deserializer for `Antd_V1_GetWalletAddressResponse` messages. + /// - options: Options to apply to this RPC. + /// - handleResponse: A closure which handles the response, the result of which is + /// returned to the caller. Returning from the closure will cancel the RPC if it + /// hasn't already finished. + /// - Returns: The result of `handleResponse`. + func getAddress( + request: GRPCCore.ClientRequest, + serializer: some GRPCCore.MessageSerializer, + deserializer: some GRPCCore.MessageDeserializer, + options: GRPCCore.CallOptions, + onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> Result + ) async throws -> Result where Result: Sendable + + /// Call the "GetBalance" method. + /// + /// > Source IDL Documentation: + /// > + /// > Returns the wallet's token + gas balances. + /// + /// - Parameters: + /// - request: A request containing a single `Antd_V1_GetWalletBalanceRequest` message. + /// - serializer: A serializer for `Antd_V1_GetWalletBalanceRequest` messages. + /// - deserializer: A deserializer for `Antd_V1_GetWalletBalanceResponse` messages. + /// - options: Options to apply to this RPC. + /// - handleResponse: A closure which handles the response, the result of which is + /// returned to the caller. Returning from the closure will cancel the RPC if it + /// hasn't already finished. + /// - Returns: The result of `handleResponse`. + func getBalance( + request: GRPCCore.ClientRequest, + serializer: some GRPCCore.MessageSerializer, + deserializer: some GRPCCore.MessageDeserializer, + options: GRPCCore.CallOptions, + onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> Result + ) async throws -> Result where Result: Sendable + + /// Call the "Approve" method. + /// + /// > Source IDL Documentation: + /// > + /// > Approves the wallet to spend tokens on the payment vault contract. + /// > One-time operation; safe to call repeatedly (idempotent at the contract + /// > level — a no-op once approval is in place). + /// + /// - Parameters: + /// - request: A request containing a single `Antd_V1_WalletApproveRequest` message. + /// - serializer: A serializer for `Antd_V1_WalletApproveRequest` messages. + /// - deserializer: A deserializer for `Antd_V1_WalletApproveResponse` messages. + /// - options: Options to apply to this RPC. + /// - handleResponse: A closure which handles the response, the result of which is + /// returned to the caller. Returning from the closure will cancel the RPC if it + /// hasn't already finished. + /// - Returns: The result of `handleResponse`. + func approve( + request: GRPCCore.ClientRequest, + serializer: some GRPCCore.MessageSerializer, + deserializer: some GRPCCore.MessageDeserializer, + options: GRPCCore.CallOptions, + onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> Result + ) async throws -> Result where Result: Sendable + } + + /// Generated client for the "antd.v1.WalletService" service. + /// + /// The ``Client`` provides an implementation of ``ClientProtocol`` which wraps + /// a `GRPCCore.GRPCCClient`. The underlying `GRPCClient` provides the long-lived + /// means of communication with the remote peer. + /// + /// > Source IDL Documentation: + /// > + /// > Wallet operations. Mirrors the REST `/v1/wallet/*` surface 1:1. + /// > + /// > All three RPCs require the daemon to have been started with a configured + /// > wallet (the `AUTONOMI_WALLET_KEY` env var). When the wallet is absent the + /// > daemon returns `Status::failed_precondition` with the same "wallet not + /// > configured" message the REST handlers return as 503. + /// > + /// > External-signer flows do NOT use this service — they pay via off-daemon + /// > EVM transactions, see `UploadService` and `ChunkService.PrepareChunk` / + /// > `FinalizeChunk` for the prepare/finalize surface. `WalletService` is only + /// > for callers that have entrusted a key to the daemon. + public struct Client: ClientProtocol where Transport: GRPCCore.ClientTransport { + private let client: GRPCCore.GRPCClient + + /// Creates a new client wrapping the provided `GRPCCore.GRPCClient`. + /// + /// - Parameters: + /// - client: A `GRPCCore.GRPCClient` providing a communication channel to the service. + public init(wrapping client: GRPCCore.GRPCClient) { + self.client = client + } + + /// Call the "GetAddress" method. + /// + /// > Source IDL Documentation: + /// > + /// > Returns the wallet's on-chain address (hex with 0x prefix). + /// + /// - Parameters: + /// - request: A request containing a single `Antd_V1_GetWalletAddressRequest` message. + /// - serializer: A serializer for `Antd_V1_GetWalletAddressRequest` messages. + /// - deserializer: A deserializer for `Antd_V1_GetWalletAddressResponse` messages. + /// - options: Options to apply to this RPC. + /// - handleResponse: A closure which handles the response, the result of which is + /// returned to the caller. Returning from the closure will cancel the RPC if it + /// hasn't already finished. + /// - Returns: The result of `handleResponse`. + public func getAddress( + request: GRPCCore.ClientRequest, + serializer: some GRPCCore.MessageSerializer, + deserializer: some GRPCCore.MessageDeserializer, + options: GRPCCore.CallOptions = .defaults, + onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> Result = { response in + try response.message + } + ) async throws -> Result where Result: Sendable { + try await self.client.unary( + request: request, + descriptor: Antd_V1_WalletService.Method.GetAddress.descriptor, + serializer: serializer, + deserializer: deserializer, + options: options, + onResponse: handleResponse + ) + } + + /// Call the "GetBalance" method. + /// + /// > Source IDL Documentation: + /// > + /// > Returns the wallet's token + gas balances. + /// + /// - Parameters: + /// - request: A request containing a single `Antd_V1_GetWalletBalanceRequest` message. + /// - serializer: A serializer for `Antd_V1_GetWalletBalanceRequest` messages. + /// - deserializer: A deserializer for `Antd_V1_GetWalletBalanceResponse` messages. + /// - options: Options to apply to this RPC. + /// - handleResponse: A closure which handles the response, the result of which is + /// returned to the caller. Returning from the closure will cancel the RPC if it + /// hasn't already finished. + /// - Returns: The result of `handleResponse`. + public func getBalance( + request: GRPCCore.ClientRequest, + serializer: some GRPCCore.MessageSerializer, + deserializer: some GRPCCore.MessageDeserializer, + options: GRPCCore.CallOptions = .defaults, + onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> Result = { response in + try response.message + } + ) async throws -> Result where Result: Sendable { + try await self.client.unary( + request: request, + descriptor: Antd_V1_WalletService.Method.GetBalance.descriptor, + serializer: serializer, + deserializer: deserializer, + options: options, + onResponse: handleResponse + ) + } + + /// Call the "Approve" method. + /// + /// > Source IDL Documentation: + /// > + /// > Approves the wallet to spend tokens on the payment vault contract. + /// > One-time operation; safe to call repeatedly (idempotent at the contract + /// > level — a no-op once approval is in place). + /// + /// - Parameters: + /// - request: A request containing a single `Antd_V1_WalletApproveRequest` message. + /// - serializer: A serializer for `Antd_V1_WalletApproveRequest` messages. + /// - deserializer: A deserializer for `Antd_V1_WalletApproveResponse` messages. + /// - options: Options to apply to this RPC. + /// - handleResponse: A closure which handles the response, the result of which is + /// returned to the caller. Returning from the closure will cancel the RPC if it + /// hasn't already finished. + /// - Returns: The result of `handleResponse`. + public func approve( + request: GRPCCore.ClientRequest, + serializer: some GRPCCore.MessageSerializer, + deserializer: some GRPCCore.MessageDeserializer, + options: GRPCCore.CallOptions = .defaults, + onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> Result = { response in + try response.message + } + ) async throws -> Result where Result: Sendable { + try await self.client.unary( + request: request, + descriptor: Antd_V1_WalletService.Method.Approve.descriptor, + serializer: serializer, + deserializer: deserializer, + options: options, + onResponse: handleResponse + ) + } + } +} + +// Helpers providing default arguments to 'ClientProtocol' methods. +@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) +extension Antd_V1_WalletService.ClientProtocol { + /// Call the "GetAddress" method. + /// + /// > Source IDL Documentation: + /// > + /// > Returns the wallet's on-chain address (hex with 0x prefix). + /// + /// - Parameters: + /// - request: A request containing a single `Antd_V1_GetWalletAddressRequest` message. + /// - options: Options to apply to this RPC. + /// - handleResponse: A closure which handles the response, the result of which is + /// returned to the caller. Returning from the closure will cancel the RPC if it + /// hasn't already finished. + /// - Returns: The result of `handleResponse`. + public func getAddress( + request: GRPCCore.ClientRequest, + options: GRPCCore.CallOptions = .defaults, + onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> Result = { response in + try response.message + } + ) async throws -> Result where Result: Sendable { + try await self.getAddress( + request: request, + serializer: GRPCProtobuf.ProtobufSerializer(), + deserializer: GRPCProtobuf.ProtobufDeserializer(), + options: options, + onResponse: handleResponse + ) + } + + /// Call the "GetBalance" method. + /// + /// > Source IDL Documentation: + /// > + /// > Returns the wallet's token + gas balances. + /// + /// - Parameters: + /// - request: A request containing a single `Antd_V1_GetWalletBalanceRequest` message. + /// - options: Options to apply to this RPC. + /// - handleResponse: A closure which handles the response, the result of which is + /// returned to the caller. Returning from the closure will cancel the RPC if it + /// hasn't already finished. + /// - Returns: The result of `handleResponse`. + public func getBalance( + request: GRPCCore.ClientRequest, + options: GRPCCore.CallOptions = .defaults, + onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> Result = { response in + try response.message + } + ) async throws -> Result where Result: Sendable { + try await self.getBalance( + request: request, + serializer: GRPCProtobuf.ProtobufSerializer(), + deserializer: GRPCProtobuf.ProtobufDeserializer(), + options: options, + onResponse: handleResponse + ) + } + + /// Call the "Approve" method. + /// + /// > Source IDL Documentation: + /// > + /// > Approves the wallet to spend tokens on the payment vault contract. + /// > One-time operation; safe to call repeatedly (idempotent at the contract + /// > level — a no-op once approval is in place). + /// + /// - Parameters: + /// - request: A request containing a single `Antd_V1_WalletApproveRequest` message. + /// - options: Options to apply to this RPC. + /// - handleResponse: A closure which handles the response, the result of which is + /// returned to the caller. Returning from the closure will cancel the RPC if it + /// hasn't already finished. + /// - Returns: The result of `handleResponse`. + public func approve( + request: GRPCCore.ClientRequest, + options: GRPCCore.CallOptions = .defaults, + onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> Result = { response in + try response.message + } + ) async throws -> Result where Result: Sendable { + try await self.approve( + request: request, + serializer: GRPCProtobuf.ProtobufSerializer(), + deserializer: GRPCProtobuf.ProtobufDeserializer(), + options: options, + onResponse: handleResponse + ) + } +} + +// Helpers providing sugared APIs for 'ClientProtocol' methods. +@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) +extension Antd_V1_WalletService.ClientProtocol { + /// Call the "GetAddress" method. + /// + /// > Source IDL Documentation: + /// > + /// > Returns the wallet's on-chain address (hex with 0x prefix). + /// + /// - Parameters: + /// - message: request message to send. + /// - metadata: Additional metadata to send, defaults to empty. + /// - options: Options to apply to this RPC, defaults to `.defaults`. + /// - handleResponse: A closure which handles the response, the result of which is + /// returned to the caller. Returning from the closure will cancel the RPC if it + /// hasn't already finished. + /// - Returns: The result of `handleResponse`. + public func getAddress( + _ message: Antd_V1_GetWalletAddressRequest, + metadata: GRPCCore.Metadata = [:], + options: GRPCCore.CallOptions = .defaults, + onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> Result = { response in + try response.message + } + ) async throws -> Result where Result: Sendable { + let request = GRPCCore.ClientRequest( + message: message, + metadata: metadata + ) + return try await self.getAddress( + request: request, + options: options, + onResponse: handleResponse + ) + } + + /// Call the "GetBalance" method. + /// + /// > Source IDL Documentation: + /// > + /// > Returns the wallet's token + gas balances. + /// + /// - Parameters: + /// - message: request message to send. + /// - metadata: Additional metadata to send, defaults to empty. + /// - options: Options to apply to this RPC, defaults to `.defaults`. + /// - handleResponse: A closure which handles the response, the result of which is + /// returned to the caller. Returning from the closure will cancel the RPC if it + /// hasn't already finished. + /// - Returns: The result of `handleResponse`. + public func getBalance( + _ message: Antd_V1_GetWalletBalanceRequest, + metadata: GRPCCore.Metadata = [:], + options: GRPCCore.CallOptions = .defaults, + onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> Result = { response in + try response.message + } + ) async throws -> Result where Result: Sendable { + let request = GRPCCore.ClientRequest( + message: message, + metadata: metadata + ) + return try await self.getBalance( + request: request, + options: options, + onResponse: handleResponse + ) + } + + /// Call the "Approve" method. + /// + /// > Source IDL Documentation: + /// > + /// > Approves the wallet to spend tokens on the payment vault contract. + /// > One-time operation; safe to call repeatedly (idempotent at the contract + /// > level — a no-op once approval is in place). + /// + /// - Parameters: + /// - message: request message to send. + /// - metadata: Additional metadata to send, defaults to empty. + /// - options: Options to apply to this RPC, defaults to `.defaults`. + /// - handleResponse: A closure which handles the response, the result of which is + /// returned to the caller. Returning from the closure will cancel the RPC if it + /// hasn't already finished. + /// - Returns: The result of `handleResponse`. + public func approve( + _ message: Antd_V1_WalletApproveRequest, + metadata: GRPCCore.Metadata = [:], + options: GRPCCore.CallOptions = .defaults, + onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> Result = { response in + try response.message + } + ) async throws -> Result where Result: Sendable { + let request = GRPCCore.ClientRequest( + message: message, + metadata: metadata + ) + return try await self.approve( + request: request, + options: options, + onResponse: handleResponse + ) + } +} \ No newline at end of file diff --git a/antd-swift/Sources/AntdSdk/Proto/antd/v1/wallet.pb.swift b/antd-swift/Sources/AntdSdk/Proto/antd/v1/wallet.pb.swift new file mode 100644 index 0000000..0aecc29 --- /dev/null +++ b/antd-swift/Sources/AntdSdk/Proto/antd/v1/wallet.pb.swift @@ -0,0 +1,249 @@ +// DO NOT EDIT. +// swift-format-ignore-file +// swiftlint:disable all +// +// Generated by the Swift generator plugin for the protocol buffer compiler. +// Source: antd/v1/wallet.proto +// +// For information on using the generated types, please see the documentation: +// https://github.com/apple/swift-protobuf/ + +import SwiftProtobuf + +// If the compiler emits an error on this type, it is because this file +// was generated by a version of the `protoc` Swift plug-in that is +// incompatible with the version of SwiftProtobuf to which you are linking. +// Please ensure that you are building against the same version of the API +// that was used to generate this file. +fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck { + struct _2: SwiftProtobuf.ProtobufAPIVersion_2 {} + typealias Version = _2 +} + +public struct Antd_V1_GetWalletAddressRequest: Sendable { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +public struct Antd_V1_GetWalletAddressResponse: Sendable { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + /// Wallet address, hex with 0x prefix (20 bytes / 42 chars). + public var address: String = String() + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +public struct Antd_V1_GetWalletBalanceRequest: Sendable { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +public struct Antd_V1_GetWalletBalanceResponse: Sendable { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + /// Token balance, atto tokens as decimal string. + public var balance: String = String() + + /// Gas (native EVM token) balance, atto tokens as decimal string. + public var gasBalance: String = String() + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +public struct Antd_V1_WalletApproveRequest: Sendable { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +public struct Antd_V1_WalletApproveResponse: Sendable { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + /// True if the approve transaction succeeded. + public var approved: Bool = false + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +// MARK: - Code below here is support for the SwiftProtobuf runtime. + +fileprivate let _protobuf_package = "antd.v1" + +extension Antd_V1_GetWalletAddressRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".GetWalletAddressRequest" + public static let _protobuf_nameMap = SwiftProtobuf._NameMap() + + public mutating func decodeMessage(decoder: inout D) throws { + // Load everything into unknown fields + while try decoder.nextFieldNumber() != nil {} + } + + public func traverse(visitor: inout V) throws { + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Antd_V1_GetWalletAddressRequest, rhs: Antd_V1_GetWalletAddressRequest) -> Bool { + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Antd_V1_GetWalletAddressResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".GetWalletAddressResponse" + public static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{1}address\0") + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularStringField(value: &self.address) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !self.address.isEmpty { + try visitor.visitSingularStringField(value: self.address, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Antd_V1_GetWalletAddressResponse, rhs: Antd_V1_GetWalletAddressResponse) -> Bool { + if lhs.address != rhs.address {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Antd_V1_GetWalletBalanceRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".GetWalletBalanceRequest" + public static let _protobuf_nameMap = SwiftProtobuf._NameMap() + + public mutating func decodeMessage(decoder: inout D) throws { + // Load everything into unknown fields + while try decoder.nextFieldNumber() != nil {} + } + + public func traverse(visitor: inout V) throws { + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Antd_V1_GetWalletBalanceRequest, rhs: Antd_V1_GetWalletBalanceRequest) -> Bool { + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Antd_V1_GetWalletBalanceResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".GetWalletBalanceResponse" + public static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{1}balance\0\u{3}gas_balance\0") + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularStringField(value: &self.balance) }() + case 2: try { try decoder.decodeSingularStringField(value: &self.gasBalance) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !self.balance.isEmpty { + try visitor.visitSingularStringField(value: self.balance, fieldNumber: 1) + } + if !self.gasBalance.isEmpty { + try visitor.visitSingularStringField(value: self.gasBalance, fieldNumber: 2) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Antd_V1_GetWalletBalanceResponse, rhs: Antd_V1_GetWalletBalanceResponse) -> Bool { + if lhs.balance != rhs.balance {return false} + if lhs.gasBalance != rhs.gasBalance {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Antd_V1_WalletApproveRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".WalletApproveRequest" + public static let _protobuf_nameMap = SwiftProtobuf._NameMap() + + public mutating func decodeMessage(decoder: inout D) throws { + // Load everything into unknown fields + while try decoder.nextFieldNumber() != nil {} + } + + public func traverse(visitor: inout V) throws { + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Antd_V1_WalletApproveRequest, rhs: Antd_V1_WalletApproveRequest) -> Bool { + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Antd_V1_WalletApproveResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".WalletApproveResponse" + public static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{1}approved\0") + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularBoolField(value: &self.approved) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if self.approved != false { + try visitor.visitSingularBoolField(value: self.approved, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Antd_V1_WalletApproveResponse, rhs: Antd_V1_WalletApproveResponse) -> Bool { + if lhs.approved != rhs.approved {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} diff --git a/antd-swift/Tests/AntdSdkTests/GrpcWalletTests.swift b/antd-swift/Tests/AntdSdkTests/GrpcWalletTests.swift new file mode 100644 index 0000000..fd17e3a --- /dev/null +++ b/antd-swift/Tests/AntdSdkTests/GrpcWalletTests.swift @@ -0,0 +1,120 @@ +import XCTest +import GRPCCore +import GRPCNIOTransportHTTP2 +@testable import AntdSdk + +/// V2-286 in-process mock-server tests for `AntdGrpcClient.wallet*`. +/// Mirrors the antd-rust / antd-go / antd-py / antd-java / antd-kotlin / +/// antd-csharp / antd-ruby / antd-dart suites. +@available(macOS 15.0, iOS 18.0, tvOS 18.0, watchOS 11.0, *) +final class GrpcWalletTests: XCTestCase { + + private func withMockServer( + service: MockWalletService, + _ body: @Sendable (AntdGrpcClient) async throws -> T + ) async throws -> T { + let transport = HTTP2ServerTransport.Posix( + address: .ipv4(host: "127.0.0.1", port: 0), + transportSecurity: .plaintext + ) + return try await withGRPCServer( + transport: transport, + services: [service] + ) { _ in + let listening = try await transport.listeningAddress + guard let port = listening.ipv4?.port else { + XCTFail("expected an ipv4 listening address; got \(listening)") + throw RPCError(code: .internalError, message: "no ipv4 listening address") + } + let client = AntdGrpcClient(target: "127.0.0.1:\(port)") + return try await body(client) + } + } + + func testWalletAddressReturnsAddress() async throws { + try await withMockServer(service: MockWalletService()) { client in + let r = try await client.walletAddress() + XCTAssertEqual(r.address, "0xabc1234567890abcdef1234567890abcdef123456") + } + } + + func testWalletBalanceReturnsBalances() async throws { + try await withMockServer(service: MockWalletService()) { client in + let r = try await client.walletBalance() + XCTAssertEqual(r.balance, "1000000000000000000") + XCTAssertEqual(r.gasBalance, "500000000000000000") + } + } + + func testWalletApproveReturnsTrue() async throws { + try await withMockServer(service: MockWalletService()) { client in + let approved = try await client.walletApprove() + XCTAssertTrue(approved) + } + } + + /// Daemon emits gRPC `failedPrecondition` for "wallet not configured"; + /// the established mapping `ErrorMapping.fromGRPCStatus` surfaces this + /// as `PaymentError`. (Semantic a bit off vs REST's 503 but matches + /// every SDK.) + func testWalletAddressUnconfiguredThrowsPaymentError() async throws { + try await withMockServer(service: MockWalletService(unconfigured: true)) { client in + do { + _ = try await client.walletAddress() + XCTFail("expected PaymentError") + } catch let err as PaymentError { + XCTAssertTrue(err.message.contains("wallet not configured")) + } catch { + XCTFail("expected PaymentError, got \(error)") + } + } + } +} + +/// Mock implementation of `WalletService` returning canned responses, or +/// `failedPrecondition` errors when `unconfigured == true`. +@available(macOS 15.0, iOS 18.0, tvOS 18.0, watchOS 11.0, *) +final class MockWalletService: Antd_V1_WalletService.SimpleServiceProtocol, @unchecked Sendable { + private let unconfigured: Bool + + init(unconfigured: Bool = false) { + self.unconfigured = unconfigured + } + + func getAddress( + request: Antd_V1_GetWalletAddressRequest, + context: ServerContext + ) async throws -> Antd_V1_GetWalletAddressResponse { + if unconfigured { + throw RPCError(code: .failedPrecondition, message: "wallet not configured — set AUTONOMI_WALLET_KEY") + } + var resp = Antd_V1_GetWalletAddressResponse() + resp.address = "0xabc1234567890abcdef1234567890abcdef123456" + return resp + } + + func getBalance( + request: Antd_V1_GetWalletBalanceRequest, + context: ServerContext + ) async throws -> Antd_V1_GetWalletBalanceResponse { + if unconfigured { + throw RPCError(code: .failedPrecondition, message: "wallet not configured — set AUTONOMI_WALLET_KEY") + } + var resp = Antd_V1_GetWalletBalanceResponse() + resp.balance = "1000000000000000000" + resp.gasBalance = "500000000000000000" + return resp + } + + func approve( + request: Antd_V1_WalletApproveRequest, + context: ServerContext + ) async throws -> Antd_V1_WalletApproveResponse { + if unconfigured { + throw RPCError(code: .failedPrecondition, message: "wallet not configured — set AUTONOMI_WALLET_KEY") + } + var resp = Antd_V1_WalletApproveResponse() + resp.approved = true + return resp + } +} diff --git a/antd-swift/scripts/generate-protos.sh b/antd-swift/scripts/generate-protos.sh new file mode 100755 index 0000000..29fd969 --- /dev/null +++ b/antd-swift/scripts/generate-protos.sh @@ -0,0 +1,42 @@ +#!/usr/bin/env bash +# Generate Swift gRPC + protobuf stubs from antd/proto/antd/v1/*.proto. +# +# Uses the protoc-gen-swift + protoc-gen-grpc-swift plugins shipped via SwiftPM +# in this package (swift-protobuf + grpc-swift-protobuf). On first run, builds +# the plugins from source via `swift build`; subsequent runs reuse them. +# +# Output: Sources/AntdSdk/Proto/*.pb.swift (protobuf stubs) + +# *.grpc.swift (gRPC client/server stubs, grpc-swift 2.x V2 codegen). +set -euo pipefail + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +PKG_DIR="$(cd "$SCRIPT_DIR/.." && pwd)" +PROTO_DIR="$(cd "$PKG_DIR/../antd/proto" && pwd)" +OUT_DIR="$PKG_DIR/Sources/AntdSdk/Proto" + +PLUGIN_DIR="$PKG_DIR/.build/$(uname -m)-unknown-linux-gnu/debug" +if [[ ! -x "$PLUGIN_DIR/protoc-gen-swift" || ! -x "$PLUGIN_DIR/protoc-gen-grpc-swift" ]]; then + echo "Building codegen plugins..." + (cd "$PKG_DIR" && swift build --product protoc-gen-swift --product protoc-gen-grpc-swift) +fi + +export PATH="$PLUGIN_DIR:$PATH" + +mkdir -p "$OUT_DIR" + +protoc \ + --proto_path="$PROTO_DIR" \ + --swift_out="$OUT_DIR" \ + --swift_opt=Visibility=Public \ + --grpc-swift_out="$OUT_DIR" \ + --grpc-swift_opt=Client=true,Server=true,Visibility=Public \ + "$PROTO_DIR"/antd/v1/common.proto \ + "$PROTO_DIR"/antd/v1/health.proto \ + "$PROTO_DIR"/antd/v1/data.proto \ + "$PROTO_DIR"/antd/v1/chunks.proto \ + "$PROTO_DIR"/antd/v1/files.proto \ + "$PROTO_DIR"/antd/v1/events.proto \ + "$PROTO_DIR"/antd/v1/wallet.proto + +echo "Generated:" +ls -la "$OUT_DIR" diff --git a/antd/build.rs b/antd/build.rs index 4a12b27..a8ad9c2 100644 --- a/antd/build.rs +++ b/antd/build.rs @@ -25,6 +25,7 @@ fn main() -> Result<(), Box> { "proto/antd/v1/chunks.proto", "proto/antd/v1/files.proto", "proto/antd/v1/events.proto", + "proto/antd/v1/wallet.proto", ], &["proto"], )?; diff --git a/antd/proto/antd/v1/wallet.proto b/antd/proto/antd/v1/wallet.proto new file mode 100644 index 0000000..5b36017 --- /dev/null +++ b/antd/proto/antd/v1/wallet.proto @@ -0,0 +1,53 @@ +syntax = "proto3"; + +package antd.v1; + +option csharp_namespace = "Antd.V1"; +option go_package = "github.com/WithAutonomi/ant-sdk/antd-go/proto/antd/v1;v1"; + +// Wallet operations. Mirrors the REST `/v1/wallet/*` surface 1:1. +// +// All three RPCs require the daemon to have been started with a configured +// wallet (the `AUTONOMI_WALLET_KEY` env var). When the wallet is absent the +// daemon returns `Status::failed_precondition` with the same "wallet not +// configured" message the REST handlers return as 503. +// +// External-signer flows do NOT use this service — they pay via off-daemon +// EVM transactions, see `UploadService` and `ChunkService.PrepareChunk` / +// `FinalizeChunk` for the prepare/finalize surface. `WalletService` is only +// for callers that have entrusted a key to the daemon. +service WalletService { + // Returns the wallet's on-chain address (hex with 0x prefix). + rpc GetAddress(GetWalletAddressRequest) returns (GetWalletAddressResponse); + + // Returns the wallet's token + gas balances. + rpc GetBalance(GetWalletBalanceRequest) returns (GetWalletBalanceResponse); + + // Approves the wallet to spend tokens on the payment vault contract. + // One-time operation; safe to call repeatedly (idempotent at the contract + // level — a no-op once approval is in place). + rpc Approve(WalletApproveRequest) returns (WalletApproveResponse); +} + +message GetWalletAddressRequest {} + +message GetWalletAddressResponse { + // Wallet address, hex with 0x prefix (20 bytes / 42 chars). + string address = 1; +} + +message GetWalletBalanceRequest {} + +message GetWalletBalanceResponse { + // Token balance, atto tokens as decimal string. + string balance = 1; + // Gas (native EVM token) balance, atto tokens as decimal string. + string gas_balance = 2; +} + +message WalletApproveRequest {} + +message WalletApproveResponse { + // True if the approve transaction succeeded. + bool approved = 1; +} diff --git a/antd/src/grpc/mod.rs b/antd/src/grpc/mod.rs index a2a772c..0541906 100644 --- a/antd/src/grpc/mod.rs +++ b/antd/src/grpc/mod.rs @@ -11,7 +11,7 @@ pub mod service; use service::pb::{ chunk_service_server::ChunkServiceServer, data_service_server::DataServiceServer, event_service_server::EventServiceServer, file_service_server::FileServiceServer, - health_service_server::HealthServiceServer, + health_service_server::HealthServiceServer, wallet_service_server::WalletServiceServer, }; pub async fn serve( @@ -30,6 +30,9 @@ pub async fn serve( let event_svc = EventServiceServer::new(service::EventServiceImpl { state: state.clone(), }); + let wallet_svc = WalletServiceServer::new(service::WalletServiceImpl { + state: state.clone(), + }); let health_svc = HealthServiceServer::new(service::HealthServiceImpl { state: state.clone(), }); @@ -43,6 +46,7 @@ pub async fn serve( .add_service(chunk_svc) .add_service(file_svc) .add_service(event_svc) + .add_service(wallet_svc) .serve_with_incoming(TcpListenerStream::new(listener)) .await?; diff --git a/antd/src/grpc/service.rs b/antd/src/grpc/service.rs index 7c99312..7384db3 100644 --- a/antd/src/grpc/service.rs +++ b/antd/src/grpc/service.rs @@ -592,3 +592,78 @@ impl pb::event_service_server::EventService for EventServiceImpl { ))) } } + +// ── WalletService ── +// +// Mirrors `antd/src/rest/wallet.rs` 1:1; the underlying `Client::wallet()` +// access is transport-agnostic. Same error mapping: a missing wallet returns +// `Status::failed_precondition` (the gRPC analog of REST's 503 service- +// unavailable for this case). + +pub struct WalletServiceImpl { + pub state: Arc, +} + +#[tonic::async_trait] +impl pb::wallet_service_server::WalletService for WalletServiceImpl { + async fn get_address( + &self, + _request: Request, + ) -> Result, Status> { + let wallet = self.state.client.wallet().ok_or_else(|| { + Status::failed_precondition("wallet not configured — set AUTONOMI_WALLET_KEY") + })?; + Ok(Response::new(pb::GetWalletAddressResponse { + address: format!("{:#x}", wallet.address()), + })) + } + + async fn get_balance( + &self, + _request: Request, + ) -> Result, Status> { + let wallet = self.state.client.wallet().ok_or_else(|| { + Status::failed_precondition("wallet not configured — set AUTONOMI_WALLET_KEY") + })?; + + let balance = wallet + .balance_of_tokens() + .await + .map_err(|e| Status::internal(format!("failed to get token balance: {e}")))?; + let gas_balance = wallet + .balance_of_gas_tokens() + .await + .map_err(|e| Status::internal(format!("failed to get gas balance: {e}")))?; + + Ok(Response::new(pb::GetWalletBalanceResponse { + balance: balance.to_string(), + gas_balance: gas_balance.to_string(), + })) + } + + async fn approve( + &self, + _request: Request, + ) -> Result, Status> { + if self.state.client.wallet().is_none() { + return Err(Status::failed_precondition( + "wallet not configured — set AUTONOMI_WALLET_KEY", + )); + } + + let client = self.state.client.clone(); + // Spawn so the approve tx can run on its own task (matches REST handler + // shape; ant-core's approve_token_spend is async and may be long). + tokio::spawn(async move { + client + .approve_token_spend() + .await + .map_err(AntdError::from_core) + }) + .await + .map_err(|e| Status::internal(format!("task failed: {e}")))? + .map_err(|e| Status::internal(format!("approve failed: {e}")))?; + + Ok(Response::new(pb::WalletApproveResponse { approved: true })) + } +}