/**
* This file was automatically generated by @cosmwasm/ts-codegen@0.35.3.
* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
* and run the @cosmwasm/ts-codegen generate command to regenerate this file.
*/

import { CosmWasmClient, SigningCosmWasmClient, ExecuteResult } from "@cosmjs/cosmwasm-stargate";
import { StdFee } from "@cosmjs/amino";
import { Uint128, InstantiateMsg, Coin, ExecuteMsg, Address, NymName, MessageSignature, NameDetails, QueryMsg, MigrateMsg, Addr, PagedNamesListResponse, RegisteredName, NamesListResponse, ConfigResponse, ContractVersion, ContractBuildInformation, Uint32 } from "./NameService.types";
import { GetCw2ContractVersionResponse } from './types';
export interface NameServiceReadOnlyInterface {
  contractAddress: string;
  nameId: ({
    nameId
  }: {
    nameId: number;
  }) => Promise<RegisteredName>;
  byOwner: ({
    owner
  }: {
    owner: string;
  }) => Promise<NamesListResponse>;
  byName: ({
    name
  }: {
    name: NymName;
  }) => Promise<RegisteredName>;
  byAddress: ({
    address
  }: {
    address: Address;
  }) => Promise<NamesListResponse>;
  all: ({
    limit,
    startAfter
  }: {
    limit?: number;
    startAfter?: number;
  }) => Promise<PagedNamesListResponse>;
  signingNonce: ({
    address
  }: {
    address: string;
  }) => Promise<Uint32>;
  config: () => Promise<ConfigResponse>;
  getContractVersion: () => Promise<ContractBuildInformation>;
  getCw2ContractVersion: () => Promise<GetCw2ContractVersionResponse>;
}
export class NameServiceQueryClient implements NameServiceReadOnlyInterface {
  client: CosmWasmClient;
  contractAddress: string;

  constructor(client: CosmWasmClient, contractAddress: string) {
    this.client = client;
    this.contractAddress = contractAddress;
    this.nameId = this.nameId.bind(this);
    this.byOwner = this.byOwner.bind(this);
    this.byName = this.byName.bind(this);
    this.byAddress = this.byAddress.bind(this);
    this.all = this.all.bind(this);
    this.signingNonce = this.signingNonce.bind(this);
    this.config = this.config.bind(this);
    this.getContractVersion = this.getContractVersion.bind(this);
    this.getCw2ContractVersion = this.getCw2ContractVersion.bind(this);
  }

  nameId = async ({
    nameId
  }: {
    nameId: number;
  }): Promise<RegisteredName> => {
    return this.client.queryContractSmart(this.contractAddress, {
      name_id: {
        name_id: nameId
      }
    });
  };
  byOwner = async ({
    owner
  }: {
    owner: string;
  }): Promise<NamesListResponse> => {
    return this.client.queryContractSmart(this.contractAddress, {
      by_owner: {
        owner
      }
    });
  };
  byName = async ({
    name
  }: {
    name: NymName;
  }): Promise<RegisteredName> => {
    return this.client.queryContractSmart(this.contractAddress, {
      by_name: {
        name
      }
    });
  };
  byAddress = async ({
    address
  }: {
    address: Address;
  }): Promise<NamesListResponse> => {
    return this.client.queryContractSmart(this.contractAddress, {
      by_address: {
        address
      }
    });
  };
  all = async ({
    limit,
    startAfter
  }: {
    limit?: number;
    startAfter?: number;
  }): Promise<PagedNamesListResponse> => {
    return this.client.queryContractSmart(this.contractAddress, {
      all: {
        limit,
        start_after: startAfter
      }
    });
  };
  signingNonce = async ({
    address
  }: {
    address: string;
  }): Promise<Uint32> => {
    return this.client.queryContractSmart(this.contractAddress, {
      signing_nonce: {
        address
      }
    });
  };
  config = async (): Promise<ConfigResponse> => {
    return this.client.queryContractSmart(this.contractAddress, {
      config: {}
    });
  };
  getContractVersion = async (): Promise<ContractBuildInformation> => {
    return this.client.queryContractSmart(this.contractAddress, {
      get_contract_version: {}
    });
  };
  getCw2ContractVersion = async (): Promise<GetCw2ContractVersionResponse> => {
    return this.client.queryContractSmart(this.contractAddress, {
      get_cw2_contract_version: {}
    });
  };
}
export interface NameServiceInterface extends NameServiceReadOnlyInterface {
  contractAddress: string;
  sender: string;
  register: ({
    name,
    ownerSignature
  }: {
    name: NameDetails;
    ownerSignature: MessageSignature;
  }, fee?: number | StdFee | "auto", memo?: string, _funds?: Coin[]) => Promise<ExecuteResult>;
  deleteId: ({
    nameId
  }: {
    nameId: number;
  }, fee?: number | StdFee | "auto", memo?: string, _funds?: Coin[]) => Promise<ExecuteResult>;
  deleteName: ({
    name
  }: {
    name: NymName;
  }, fee?: number | StdFee | "auto", memo?: string, _funds?: Coin[]) => Promise<ExecuteResult>;
  updateDepositRequired: ({
    depositRequired
  }: {
    depositRequired: Coin;
  }, fee?: number | StdFee | "auto", memo?: string, _funds?: Coin[]) => Promise<ExecuteResult>;
}
export class NameServiceClient extends NameServiceQueryClient implements NameServiceInterface {
  client: SigningCosmWasmClient;
  sender: string;
  contractAddress: string;

  constructor(client: SigningCosmWasmClient, sender: string, contractAddress: string) {
    super(client, contractAddress);
    this.client = client;
    this.sender = sender;
    this.contractAddress = contractAddress;
    this.register = this.register.bind(this);
    this.deleteId = this.deleteId.bind(this);
    this.deleteName = this.deleteName.bind(this);
    this.updateDepositRequired = this.updateDepositRequired.bind(this);
  }

  register = async ({
    name,
    ownerSignature
  }: {
    name: NameDetails;
    ownerSignature: MessageSignature;
  }, fee: number | StdFee | "auto" = "auto", memo?: string, _funds?: Coin[]): Promise<ExecuteResult> => {
    return await this.client.execute(this.sender, this.contractAddress, {
      register: {
        name,
        owner_signature: ownerSignature
      }
    }, fee, memo, _funds);
  };
  deleteId = async ({
    nameId
  }: {
    nameId: number;
  }, fee: number | StdFee | "auto" = "auto", memo?: string, _funds?: Coin[]): Promise<ExecuteResult> => {
    return await this.client.execute(this.sender, this.contractAddress, {
      delete_id: {
        name_id: nameId
      }
    }, fee, memo, _funds);
  };
  deleteName = async ({
    name
  }: {
    name: NymName;
  }, fee: number | StdFee | "auto" = "auto", memo?: string, _funds?: Coin[]): Promise<ExecuteResult> => {
    return await this.client.execute(this.sender, this.contractAddress, {
      delete_name: {
        name
      }
    }, fee, memo, _funds);
  };
  updateDepositRequired = async ({
    depositRequired
  }: {
    depositRequired: Coin;
  }, fee: number | StdFee | "auto" = "auto", memo?: string, _funds?: Coin[]): Promise<ExecuteResult> => {
    return await this.client.execute(this.sender, this.contractAddress, {
      update_deposit_required: {
        deposit_required: depositRequired
      }
    }, fee, memo, _funds);
  };
}
