/**
* 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 { InstantiateMsg, ExecuteMsg, Uint128, DepositData, SpendCredentialData, Coin, QueryMsg, MigrateMsg, Addr, SpendCredentialStatus, PagedSpendCredentialResponse, SpendCredential, SpendCredentialResponse } from "./CoconutBandwidth.types";

export interface CoconutBandwidthReadOnlyInterface {
  contractAddress: string;
  getSpentCredential: ({
    blindedSerialNumber
  }: {
    blindedSerialNumber: string;
  }) => Promise<SpendCredentialResponse>;
  getAllSpentCredentials: ({
    limit,
    startAfter
  }: {
    limit?: number;
    startAfter?: string;
  }) => Promise<PagedSpendCredentialResponse>;
}
export class CoconutBandwidthQueryClient implements CoconutBandwidthReadOnlyInterface {
  client: CosmWasmClient;
  contractAddress: string;

  constructor(client: CosmWasmClient, contractAddress: string) {
    this.client = client;
    this.contractAddress = contractAddress;
    this.getSpentCredential = this.getSpentCredential.bind(this);
    this.getAllSpentCredentials = this.getAllSpentCredentials.bind(this);
  }

  getSpentCredential = async ({
    blindedSerialNumber
  }: {
    blindedSerialNumber: string;
  }): Promise<SpendCredentialResponse> => {
    return this.client.queryContractSmart(this.contractAddress, {
      get_spent_credential: {
        blinded_serial_number: blindedSerialNumber
      }
    });
  };
  getAllSpentCredentials = async ({
    limit,
    startAfter
  }: {
    limit?: number;
    startAfter?: string;
  }): Promise<PagedSpendCredentialResponse> => {
    return this.client.queryContractSmart(this.contractAddress, {
      get_all_spent_credentials: {
        limit,
        start_after: startAfter
      }
    });
  };
}
export interface CoconutBandwidthInterface extends CoconutBandwidthReadOnlyInterface {
  contractAddress: string;
  sender: string;
  depositFunds: ({
    data
  }: {
    data: DepositData;
  }, fee?: number | StdFee | "auto", memo?: string, _funds?: Coin[]) => Promise<ExecuteResult>;
  spendCredential: ({
    data
  }: {
    data: SpendCredentialData;
  }, fee?: number | StdFee | "auto", memo?: string, _funds?: Coin[]) => Promise<ExecuteResult>;
  releaseFunds: ({
    funds
  }: {
    funds: Coin;
  }, fee?: number | StdFee | "auto", memo?: string, _funds?: Coin[]) => Promise<ExecuteResult>;
}
export class CoconutBandwidthClient extends CoconutBandwidthQueryClient implements CoconutBandwidthInterface {
  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.depositFunds = this.depositFunds.bind(this);
    this.spendCredential = this.spendCredential.bind(this);
    this.releaseFunds = this.releaseFunds.bind(this);
  }

  depositFunds = async ({
    data
  }: {
    data: DepositData;
  }, fee: number | StdFee | "auto" = "auto", memo?: string, _funds?: Coin[]): Promise<ExecuteResult> => {
    return await this.client.execute(this.sender, this.contractAddress, {
      deposit_funds: {
        data
      }
    }, fee, memo, _funds);
  };
  spendCredential = async ({
    data
  }: {
    data: SpendCredentialData;
  }, fee: number | StdFee | "auto" = "auto", memo?: string, _funds?: Coin[]): Promise<ExecuteResult> => {
    return await this.client.execute(this.sender, this.contractAddress, {
      spend_credential: {
        data
      }
    }, fee, memo, _funds);
  };
  releaseFunds = async ({
    funds
  }: {
    funds: Coin;
  }, fee: number | StdFee | "auto" = "auto", memo?: string, _funds?: Coin[]): Promise<ExecuteResult> => {
    return await this.client.execute(this.sender, this.contractAddress, {
      release_funds: {
        funds
      }
    }, fee, memo, _funds);
  };
}
