//
// DO NOT EDIT.
//
// Generated by the protocol buffer compiler.
// Source: cosmwasm/wasm/v1beta1/tx.proto
//

//
// Copyright 2018, gRPC Authors All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
import GRPC
import NIO
import SwiftProtobuf


/// Msg defines the wasm Msg service.
///
/// Usage: instantiate `Starnamed_X_Wasm_V1beta1_MsgClient`, then call methods of this protocol to make API calls.
internal protocol Starnamed_X_Wasm_V1beta1_MsgClientProtocol: GRPCClient {
  var serviceName: String { get }
  var interceptors: Starnamed_X_Wasm_V1beta1_MsgClientInterceptorFactoryProtocol? { get }

  func storeCode(
    _ request: Starnamed_X_Wasm_V1beta1_MsgStoreCode,
    callOptions: CallOptions?
  ) -> UnaryCall<Starnamed_X_Wasm_V1beta1_MsgStoreCode, Starnamed_X_Wasm_V1beta1_MsgStoreCodeResponse>

  func instantiateContract(
    _ request: Starnamed_X_Wasm_V1beta1_MsgInstantiateContract,
    callOptions: CallOptions?
  ) -> UnaryCall<Starnamed_X_Wasm_V1beta1_MsgInstantiateContract, Starnamed_X_Wasm_V1beta1_MsgInstantiateContractResponse>

  func executeContract(
    _ request: Starnamed_X_Wasm_V1beta1_MsgExecuteContract,
    callOptions: CallOptions?
  ) -> UnaryCall<Starnamed_X_Wasm_V1beta1_MsgExecuteContract, Starnamed_X_Wasm_V1beta1_MsgExecuteContractResponse>

  func migrateContract(
    _ request: Starnamed_X_Wasm_V1beta1_MsgMigrateContract,
    callOptions: CallOptions?
  ) -> UnaryCall<Starnamed_X_Wasm_V1beta1_MsgMigrateContract, Starnamed_X_Wasm_V1beta1_MsgMigrateContractResponse>

  func updateAdmin(
    _ request: Starnamed_X_Wasm_V1beta1_MsgUpdateAdmin,
    callOptions: CallOptions?
  ) -> UnaryCall<Starnamed_X_Wasm_V1beta1_MsgUpdateAdmin, Starnamed_X_Wasm_V1beta1_MsgUpdateAdminResponse>

  func clearAdmin(
    _ request: Starnamed_X_Wasm_V1beta1_MsgClearAdmin,
    callOptions: CallOptions?
  ) -> UnaryCall<Starnamed_X_Wasm_V1beta1_MsgClearAdmin, Starnamed_X_Wasm_V1beta1_MsgClearAdminResponse>
}

extension Starnamed_X_Wasm_V1beta1_MsgClientProtocol {
  internal var serviceName: String {
    return "starnamed.x.wasm.v1beta1.Msg"
  }

  /// StoreCode to submit Wasm code to the system
  ///
  /// - Parameters:
  ///   - request: Request to send to StoreCode.
  ///   - callOptions: Call options.
  /// - Returns: A `UnaryCall` with futures for the metadata, status and response.
  internal func storeCode(
    _ request: Starnamed_X_Wasm_V1beta1_MsgStoreCode,
    callOptions: CallOptions? = nil
  ) -> UnaryCall<Starnamed_X_Wasm_V1beta1_MsgStoreCode, Starnamed_X_Wasm_V1beta1_MsgStoreCodeResponse> {
    return self.makeUnaryCall(
      path: "/starnamed.x.wasm.v1beta1.Msg/StoreCode",
      request: request,
      callOptions: callOptions ?? self.defaultCallOptions,
      interceptors: self.interceptors?.makeStoreCodeInterceptors() ?? []
    )
  }

  ///  Instantiate creates a new smart contract instance for the given code id.
  ///
  /// - Parameters:
  ///   - request: Request to send to InstantiateContract.
  ///   - callOptions: Call options.
  /// - Returns: A `UnaryCall` with futures for the metadata, status and response.
  internal func instantiateContract(
    _ request: Starnamed_X_Wasm_V1beta1_MsgInstantiateContract,
    callOptions: CallOptions? = nil
  ) -> UnaryCall<Starnamed_X_Wasm_V1beta1_MsgInstantiateContract, Starnamed_X_Wasm_V1beta1_MsgInstantiateContractResponse> {
    return self.makeUnaryCall(
      path: "/starnamed.x.wasm.v1beta1.Msg/InstantiateContract",
      request: request,
      callOptions: callOptions ?? self.defaultCallOptions,
      interceptors: self.interceptors?.makeInstantiateContractInterceptors() ?? []
    )
  }

  /// Execute submits the given message data to a smart contract
  ///
  /// - Parameters:
  ///   - request: Request to send to ExecuteContract.
  ///   - callOptions: Call options.
  /// - Returns: A `UnaryCall` with futures for the metadata, status and response.
  internal func executeContract(
    _ request: Starnamed_X_Wasm_V1beta1_MsgExecuteContract,
    callOptions: CallOptions? = nil
  ) -> UnaryCall<Starnamed_X_Wasm_V1beta1_MsgExecuteContract, Starnamed_X_Wasm_V1beta1_MsgExecuteContractResponse> {
    return self.makeUnaryCall(
      path: "/starnamed.x.wasm.v1beta1.Msg/ExecuteContract",
      request: request,
      callOptions: callOptions ?? self.defaultCallOptions,
      interceptors: self.interceptors?.makeExecuteContractInterceptors() ?? []
    )
  }

  /// Migrate runs a code upgrade/ downgrade for a smart contract
  ///
  /// - Parameters:
  ///   - request: Request to send to MigrateContract.
  ///   - callOptions: Call options.
  /// - Returns: A `UnaryCall` with futures for the metadata, status and response.
  internal func migrateContract(
    _ request: Starnamed_X_Wasm_V1beta1_MsgMigrateContract,
    callOptions: CallOptions? = nil
  ) -> UnaryCall<Starnamed_X_Wasm_V1beta1_MsgMigrateContract, Starnamed_X_Wasm_V1beta1_MsgMigrateContractResponse> {
    return self.makeUnaryCall(
      path: "/starnamed.x.wasm.v1beta1.Msg/MigrateContract",
      request: request,
      callOptions: callOptions ?? self.defaultCallOptions,
      interceptors: self.interceptors?.makeMigrateContractInterceptors() ?? []
    )
  }

  /// UpdateAdmin sets a new   admin for a smart contract
  ///
  /// - Parameters:
  ///   - request: Request to send to UpdateAdmin.
  ///   - callOptions: Call options.
  /// - Returns: A `UnaryCall` with futures for the metadata, status and response.
  internal func updateAdmin(
    _ request: Starnamed_X_Wasm_V1beta1_MsgUpdateAdmin,
    callOptions: CallOptions? = nil
  ) -> UnaryCall<Starnamed_X_Wasm_V1beta1_MsgUpdateAdmin, Starnamed_X_Wasm_V1beta1_MsgUpdateAdminResponse> {
    return self.makeUnaryCall(
      path: "/starnamed.x.wasm.v1beta1.Msg/UpdateAdmin",
      request: request,
      callOptions: callOptions ?? self.defaultCallOptions,
      interceptors: self.interceptors?.makeUpdateAdminInterceptors() ?? []
    )
  }

  /// ClearAdmin removes any admin stored for a smart contract
  ///
  /// - Parameters:
  ///   - request: Request to send to ClearAdmin.
  ///   - callOptions: Call options.
  /// - Returns: A `UnaryCall` with futures for the metadata, status and response.
  internal func clearAdmin(
    _ request: Starnamed_X_Wasm_V1beta1_MsgClearAdmin,
    callOptions: CallOptions? = nil
  ) -> UnaryCall<Starnamed_X_Wasm_V1beta1_MsgClearAdmin, Starnamed_X_Wasm_V1beta1_MsgClearAdminResponse> {
    return self.makeUnaryCall(
      path: "/starnamed.x.wasm.v1beta1.Msg/ClearAdmin",
      request: request,
      callOptions: callOptions ?? self.defaultCallOptions,
      interceptors: self.interceptors?.makeClearAdminInterceptors() ?? []
    )
  }
}

internal protocol Starnamed_X_Wasm_V1beta1_MsgClientInterceptorFactoryProtocol {

  /// - Returns: Interceptors to use when invoking 'storeCode'.
  func makeStoreCodeInterceptors() -> [ClientInterceptor<Starnamed_X_Wasm_V1beta1_MsgStoreCode, Starnamed_X_Wasm_V1beta1_MsgStoreCodeResponse>]

  /// - Returns: Interceptors to use when invoking 'instantiateContract'.
  func makeInstantiateContractInterceptors() -> [ClientInterceptor<Starnamed_X_Wasm_V1beta1_MsgInstantiateContract, Starnamed_X_Wasm_V1beta1_MsgInstantiateContractResponse>]

  /// - Returns: Interceptors to use when invoking 'executeContract'.
  func makeExecuteContractInterceptors() -> [ClientInterceptor<Starnamed_X_Wasm_V1beta1_MsgExecuteContract, Starnamed_X_Wasm_V1beta1_MsgExecuteContractResponse>]

  /// - Returns: Interceptors to use when invoking 'migrateContract'.
  func makeMigrateContractInterceptors() -> [ClientInterceptor<Starnamed_X_Wasm_V1beta1_MsgMigrateContract, Starnamed_X_Wasm_V1beta1_MsgMigrateContractResponse>]

  /// - Returns: Interceptors to use when invoking 'updateAdmin'.
  func makeUpdateAdminInterceptors() -> [ClientInterceptor<Starnamed_X_Wasm_V1beta1_MsgUpdateAdmin, Starnamed_X_Wasm_V1beta1_MsgUpdateAdminResponse>]

  /// - Returns: Interceptors to use when invoking 'clearAdmin'.
  func makeClearAdminInterceptors() -> [ClientInterceptor<Starnamed_X_Wasm_V1beta1_MsgClearAdmin, Starnamed_X_Wasm_V1beta1_MsgClearAdminResponse>]
}

internal final class Starnamed_X_Wasm_V1beta1_MsgClient: Starnamed_X_Wasm_V1beta1_MsgClientProtocol {
  internal let channel: GRPCChannel
  internal var defaultCallOptions: CallOptions
  internal var interceptors: Starnamed_X_Wasm_V1beta1_MsgClientInterceptorFactoryProtocol?

  /// Creates a client for the starnamed.x.wasm.v1beta1.Msg service.
  ///
  /// - Parameters:
  ///   - channel: `GRPCChannel` to the service host.
  ///   - defaultCallOptions: Options to use for each service call if the user doesn't provide them.
  ///   - interceptors: A factory providing interceptors for each RPC.
  internal init(
    channel: GRPCChannel,
    defaultCallOptions: CallOptions = CallOptions(),
    interceptors: Starnamed_X_Wasm_V1beta1_MsgClientInterceptorFactoryProtocol? = nil
  ) {
    self.channel = channel
    self.defaultCallOptions = defaultCallOptions
    self.interceptors = interceptors
  }
}

/// Msg defines the wasm Msg service.
///
/// To build a server, implement a class that conforms to this protocol.
internal protocol Starnamed_X_Wasm_V1beta1_MsgProvider: CallHandlerProvider {
  var interceptors: Starnamed_X_Wasm_V1beta1_MsgServerInterceptorFactoryProtocol? { get }

  /// StoreCode to submit Wasm code to the system
  func storeCode(request: Starnamed_X_Wasm_V1beta1_MsgStoreCode, context: StatusOnlyCallContext) -> EventLoopFuture<Starnamed_X_Wasm_V1beta1_MsgStoreCodeResponse>

  ///  Instantiate creates a new smart contract instance for the given code id.
  func instantiateContract(request: Starnamed_X_Wasm_V1beta1_MsgInstantiateContract, context: StatusOnlyCallContext) -> EventLoopFuture<Starnamed_X_Wasm_V1beta1_MsgInstantiateContractResponse>

  /// Execute submits the given message data to a smart contract
  func executeContract(request: Starnamed_X_Wasm_V1beta1_MsgExecuteContract, context: StatusOnlyCallContext) -> EventLoopFuture<Starnamed_X_Wasm_V1beta1_MsgExecuteContractResponse>

  /// Migrate runs a code upgrade/ downgrade for a smart contract
  func migrateContract(request: Starnamed_X_Wasm_V1beta1_MsgMigrateContract, context: StatusOnlyCallContext) -> EventLoopFuture<Starnamed_X_Wasm_V1beta1_MsgMigrateContractResponse>

  /// UpdateAdmin sets a new   admin for a smart contract
  func updateAdmin(request: Starnamed_X_Wasm_V1beta1_MsgUpdateAdmin, context: StatusOnlyCallContext) -> EventLoopFuture<Starnamed_X_Wasm_V1beta1_MsgUpdateAdminResponse>

  /// ClearAdmin removes any admin stored for a smart contract
  func clearAdmin(request: Starnamed_X_Wasm_V1beta1_MsgClearAdmin, context: StatusOnlyCallContext) -> EventLoopFuture<Starnamed_X_Wasm_V1beta1_MsgClearAdminResponse>
}

extension Starnamed_X_Wasm_V1beta1_MsgProvider {
  internal var serviceName: Substring { return "starnamed.x.wasm.v1beta1.Msg" }

  /// Determines, calls and returns the appropriate request handler, depending on the request's method.
  /// Returns nil for methods not handled by this service.
  internal func handle(
    method name: Substring,
    context: CallHandlerContext
  ) -> GRPCServerHandlerProtocol? {
    switch name {
    case "StoreCode":
      return UnaryServerHandler(
        context: context,
        requestDeserializer: ProtobufDeserializer<Starnamed_X_Wasm_V1beta1_MsgStoreCode>(),
        responseSerializer: ProtobufSerializer<Starnamed_X_Wasm_V1beta1_MsgStoreCodeResponse>(),
        interceptors: self.interceptors?.makeStoreCodeInterceptors() ?? [],
        userFunction: self.storeCode(request:context:)
      )

    case "InstantiateContract":
      return UnaryServerHandler(
        context: context,
        requestDeserializer: ProtobufDeserializer<Starnamed_X_Wasm_V1beta1_MsgInstantiateContract>(),
        responseSerializer: ProtobufSerializer<Starnamed_X_Wasm_V1beta1_MsgInstantiateContractResponse>(),
        interceptors: self.interceptors?.makeInstantiateContractInterceptors() ?? [],
        userFunction: self.instantiateContract(request:context:)
      )

    case "ExecuteContract":
      return UnaryServerHandler(
        context: context,
        requestDeserializer: ProtobufDeserializer<Starnamed_X_Wasm_V1beta1_MsgExecuteContract>(),
        responseSerializer: ProtobufSerializer<Starnamed_X_Wasm_V1beta1_MsgExecuteContractResponse>(),
        interceptors: self.interceptors?.makeExecuteContractInterceptors() ?? [],
        userFunction: self.executeContract(request:context:)
      )

    case "MigrateContract":
      return UnaryServerHandler(
        context: context,
        requestDeserializer: ProtobufDeserializer<Starnamed_X_Wasm_V1beta1_MsgMigrateContract>(),
        responseSerializer: ProtobufSerializer<Starnamed_X_Wasm_V1beta1_MsgMigrateContractResponse>(),
        interceptors: self.interceptors?.makeMigrateContractInterceptors() ?? [],
        userFunction: self.migrateContract(request:context:)
      )

    case "UpdateAdmin":
      return UnaryServerHandler(
        context: context,
        requestDeserializer: ProtobufDeserializer<Starnamed_X_Wasm_V1beta1_MsgUpdateAdmin>(),
        responseSerializer: ProtobufSerializer<Starnamed_X_Wasm_V1beta1_MsgUpdateAdminResponse>(),
        interceptors: self.interceptors?.makeUpdateAdminInterceptors() ?? [],
        userFunction: self.updateAdmin(request:context:)
      )

    case "ClearAdmin":
      return UnaryServerHandler(
        context: context,
        requestDeserializer: ProtobufDeserializer<Starnamed_X_Wasm_V1beta1_MsgClearAdmin>(),
        responseSerializer: ProtobufSerializer<Starnamed_X_Wasm_V1beta1_MsgClearAdminResponse>(),
        interceptors: self.interceptors?.makeClearAdminInterceptors() ?? [],
        userFunction: self.clearAdmin(request:context:)
      )

    default:
      return nil
    }
  }
}

internal protocol Starnamed_X_Wasm_V1beta1_MsgServerInterceptorFactoryProtocol {

  /// - Returns: Interceptors to use when handling 'storeCode'.
  ///   Defaults to calling `self.makeInterceptors()`.
  func makeStoreCodeInterceptors() -> [ServerInterceptor<Starnamed_X_Wasm_V1beta1_MsgStoreCode, Starnamed_X_Wasm_V1beta1_MsgStoreCodeResponse>]

  /// - Returns: Interceptors to use when handling 'instantiateContract'.
  ///   Defaults to calling `self.makeInterceptors()`.
  func makeInstantiateContractInterceptors() -> [ServerInterceptor<Starnamed_X_Wasm_V1beta1_MsgInstantiateContract, Starnamed_X_Wasm_V1beta1_MsgInstantiateContractResponse>]

  /// - Returns: Interceptors to use when handling 'executeContract'.
  ///   Defaults to calling `self.makeInterceptors()`.
  func makeExecuteContractInterceptors() -> [ServerInterceptor<Starnamed_X_Wasm_V1beta1_MsgExecuteContract, Starnamed_X_Wasm_V1beta1_MsgExecuteContractResponse>]

  /// - Returns: Interceptors to use when handling 'migrateContract'.
  ///   Defaults to calling `self.makeInterceptors()`.
  func makeMigrateContractInterceptors() -> [ServerInterceptor<Starnamed_X_Wasm_V1beta1_MsgMigrateContract, Starnamed_X_Wasm_V1beta1_MsgMigrateContractResponse>]

  /// - Returns: Interceptors to use when handling 'updateAdmin'.
  ///   Defaults to calling `self.makeInterceptors()`.
  func makeUpdateAdminInterceptors() -> [ServerInterceptor<Starnamed_X_Wasm_V1beta1_MsgUpdateAdmin, Starnamed_X_Wasm_V1beta1_MsgUpdateAdminResponse>]

  /// - Returns: Interceptors to use when handling 'clearAdmin'.
  ///   Defaults to calling `self.makeInterceptors()`.
  func makeClearAdminInterceptors() -> [ServerInterceptor<Starnamed_X_Wasm_V1beta1_MsgClearAdmin, Starnamed_X_Wasm_V1beta1_MsgClearAdminResponse>]
}
