/**
* 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 { Coin, StdFee } from "@cosmjs/amino";
import { InstantiateMsg, TimeConfiguration, ExecuteMsg, ContractSafeBytes, Addr, QueryMsg, MigrateMsg, PagedDealerResponse, DealerDetails, Timestamp, Uint64, EpochState, Epoch, DealerType, DealerDetailsResponse, PagedDealingsResponse, ContractDealing, NullableInitialReplacementData, InitialReplacementData, PagedVKSharesResponse, ContractVKShare } from "./CoconutDkg.types";

export interface CoconutDkgReadOnlyInterface {
  contractAddress: string;
  getCurrentEpochState: () => Promise<Epoch>;
  getCurrentEpochThreshold: () => Promise<Uint64>;
  getInitialDealers: () => Promise<NullableInitialReplacementData>;
  getDealerDetails: ({
    dealerAddress
  }: {
    dealerAddress: string;
  }) => Promise<DealerDetailsResponse>;
  getCurrentDealers: ({
    limit,
    startAfter
  }: {
    limit?: number;
    startAfter?: string;
  }) => Promise<PagedDealerResponse>;
  getPastDealers: ({
    limit,
    startAfter
  }: {
    limit?: number;
    startAfter?: string;
  }) => Promise<PagedDealerResponse>;
  getDealing: ({
    idx,
    limit,
    startAfter
  }: {
    idx: number;
    limit?: number;
    startAfter?: string;
  }) => Promise<PagedDealingsResponse>;
  getVerificationKeys: ({
    epochId,
    limit,
    startAfter
  }: {
    epochId: number;
    limit?: number;
    startAfter?: string;
  }) => Promise<PagedVKSharesResponse>;
}
export class CoconutDkgQueryClient implements CoconutDkgReadOnlyInterface {
  client: CosmWasmClient;
  contractAddress: string;

  constructor(client: CosmWasmClient, contractAddress: string) {
    this.client = client;
    this.contractAddress = contractAddress;
    this.getCurrentEpochState = this.getCurrentEpochState.bind(this);
    this.getCurrentEpochThreshold = this.getCurrentEpochThreshold.bind(this);
    this.getInitialDealers = this.getInitialDealers.bind(this);
    this.getDealerDetails = this.getDealerDetails.bind(this);
    this.getCurrentDealers = this.getCurrentDealers.bind(this);
    this.getPastDealers = this.getPastDealers.bind(this);
    this.getDealing = this.getDealing.bind(this);
    this.getVerificationKeys = this.getVerificationKeys.bind(this);
  }

  getCurrentEpochState = async (): Promise<Epoch> => {
    return this.client.queryContractSmart(this.contractAddress, {
      get_current_epoch_state: {}
    });
  };
  getCurrentEpochThreshold = async (): Promise<Uint64> => {
    return this.client.queryContractSmart(this.contractAddress, {
      get_current_epoch_threshold: {}
    });
  };
  getInitialDealers = async (): Promise<NullableInitialReplacementData> => {
    return this.client.queryContractSmart(this.contractAddress, {
      get_initial_dealers: {}
    });
  };
  getDealerDetails = async ({
    dealerAddress
  }: {
    dealerAddress: string;
  }): Promise<DealerDetailsResponse> => {
    return this.client.queryContractSmart(this.contractAddress, {
      get_dealer_details: {
        dealer_address: dealerAddress
      }
    });
  };
  getCurrentDealers = async ({
    limit,
    startAfter
  }: {
    limit?: number;
    startAfter?: string;
  }): Promise<PagedDealerResponse> => {
    return this.client.queryContractSmart(this.contractAddress, {
      get_current_dealers: {
        limit,
        start_after: startAfter
      }
    });
  };
  getPastDealers = async ({
    limit,
    startAfter
  }: {
    limit?: number;
    startAfter?: string;
  }): Promise<PagedDealerResponse> => {
    return this.client.queryContractSmart(this.contractAddress, {
      get_past_dealers: {
        limit,
        start_after: startAfter
      }
    });
  };
  getDealing = async ({
    idx,
    limit,
    startAfter
  }: {
    idx: number;
    limit?: number;
    startAfter?: string;
  }): Promise<PagedDealingsResponse> => {
    return this.client.queryContractSmart(this.contractAddress, {
      get_dealing: {
        idx,
        limit,
        start_after: startAfter
      }
    });
  };
  getVerificationKeys = async ({
    epochId,
    limit,
    startAfter
  }: {
    epochId: number;
    limit?: number;
    startAfter?: string;
  }): Promise<PagedVKSharesResponse> => {
    return this.client.queryContractSmart(this.contractAddress, {
      get_verification_keys: {
        epoch_id: epochId,
        limit,
        start_after: startAfter
      }
    });
  };
}
export interface CoconutDkgInterface extends CoconutDkgReadOnlyInterface {
  contractAddress: string;
  sender: string;
  registerDealer: ({
    announceAddress,
    bteKeyWithProof,
    resharing
  }: {
    announceAddress: string;
    bteKeyWithProof: string;
    resharing: boolean;
  }, fee?: number | StdFee | "auto", memo?: string, _funds?: Coin[]) => Promise<ExecuteResult>;
  commitDealing: ({
    dealingBytes,
    resharing
  }: {
    dealingBytes: ContractSafeBytes;
    resharing: boolean;
  }, fee?: number | StdFee | "auto", memo?: string, _funds?: Coin[]) => Promise<ExecuteResult>;
  commitVerificationKeyShare: ({
    resharing,
    share
  }: {
    resharing: boolean;
    share: string;
  }, fee?: number | StdFee | "auto", memo?: string, _funds?: Coin[]) => Promise<ExecuteResult>;
  verifyVerificationKeyShare: ({
    owner,
    resharing
  }: {
    owner: Addr;
    resharing: boolean;
  }, fee?: number | StdFee | "auto", memo?: string, _funds?: Coin[]) => Promise<ExecuteResult>;
  surpassedThreshold: (fee?: number | StdFee | "auto", memo?: string, _funds?: Coin[]) => Promise<ExecuteResult>;
  advanceEpochState: (fee?: number | StdFee | "auto", memo?: string, _funds?: Coin[]) => Promise<ExecuteResult>;
}
export class CoconutDkgClient extends CoconutDkgQueryClient implements CoconutDkgInterface {
  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.registerDealer = this.registerDealer.bind(this);
    this.commitDealing = this.commitDealing.bind(this);
    this.commitVerificationKeyShare = this.commitVerificationKeyShare.bind(this);
    this.verifyVerificationKeyShare = this.verifyVerificationKeyShare.bind(this);
    this.surpassedThreshold = this.surpassedThreshold.bind(this);
    this.advanceEpochState = this.advanceEpochState.bind(this);
  }

  registerDealer = async ({
    announceAddress,
    bteKeyWithProof,
    resharing
  }: {
    announceAddress: string;
    bteKeyWithProof: string;
    resharing: boolean;
  }, fee: number | StdFee | "auto" = "auto", memo?: string, _funds?: Coin[]): Promise<ExecuteResult> => {
    return await this.client.execute(this.sender, this.contractAddress, {
      register_dealer: {
        announce_address: announceAddress,
        bte_key_with_proof: bteKeyWithProof,
        resharing
      }
    }, fee, memo, _funds);
  };
  commitDealing = async ({
    dealingBytes,
    resharing
  }: {
    dealingBytes: ContractSafeBytes;
    resharing: boolean;
  }, fee: number | StdFee | "auto" = "auto", memo?: string, _funds?: Coin[]): Promise<ExecuteResult> => {
    return await this.client.execute(this.sender, this.contractAddress, {
      commit_dealing: {
        dealing_bytes: dealingBytes,
        resharing
      }
    }, fee, memo, _funds);
  };
  commitVerificationKeyShare = async ({
    resharing,
    share
  }: {
    resharing: boolean;
    share: string;
  }, fee: number | StdFee | "auto" = "auto", memo?: string, _funds?: Coin[]): Promise<ExecuteResult> => {
    return await this.client.execute(this.sender, this.contractAddress, {
      commit_verification_key_share: {
        resharing,
        share
      }
    }, fee, memo, _funds);
  };
  verifyVerificationKeyShare = async ({
    owner,
    resharing
  }: {
    owner: Addr;
    resharing: boolean;
  }, fee: number | StdFee | "auto" = "auto", memo?: string, _funds?: Coin[]): Promise<ExecuteResult> => {
    return await this.client.execute(this.sender, this.contractAddress, {
      verify_verification_key_share: {
        owner,
        resharing
      }
    }, fee, memo, _funds);
  };
  surpassedThreshold = async (fee: number | StdFee | "auto" = "auto", memo?: string, _funds?: Coin[]): Promise<ExecuteResult> => {
    return await this.client.execute(this.sender, this.contractAddress, {
      surpassed_threshold: {}
    }, fee, memo, _funds);
  };
  advanceEpochState = async (fee: number | StdFee | "auto" = "auto", memo?: string, _funds?: Coin[]): Promise<ExecuteResult> => {
    return await this.client.execute(this.sender, this.contractAddress, {
      advance_epoch_state: {}
    }, fee, memo, _funds);
  };
}
