/**
 * Flowtype definitions for Ada
 * Generated by Flowgen from a Typescript Definition
 * Flowgen v1.21.0
 * @flow
 */

import Transport from "@ledgerhq/hw-transport";
import type { Interaction, SendFn } from "./interactions/common/types";
import type {
  ParsedAddressParams,
  ParsedCVote,
  ParsedMessageData,
  ParsedNativeScript,
  ParsedOperationalCertificate,
  ParsedSigningRequest,
  ValidBIP32Path,
} from "./types/internal";
import type {
  BIP32Path,
  CIP36Vote,
  DerivedAddress,
  DeviceCompatibility,
  DeviceOwnedAddress,
  ExtendedPublicKey,
  MessageData,
  SignedMessageData,
  NativeScript,
  NativeScriptHash,
  Network,
  OperationalCertificate,
  OperationalCertificateSignature,
  Serial,
  SignedCIP36VoteData,
  SignedTransactionData,
  SignTransactionRequest,
  Version,
} from "./types/public";
import typeof { NativeScriptHashDisplayFormat } from "./types/public";
import utils from "./utils";
declare export * from "./errors";
declare export * from "./types/public";
export type { SendFn };

/**
 * Main API endpoint
 * @category Main
 */
declare export class Ada {
  /**
   * $FlowIgnore[value-as-type]
   */
  transport: Transport;

  /**
   * @ignore
   */
  _send: SendFn;

  /**
   * $FlowIgnore[value-as-type]
   */
  constructor(transport: Transport, scrambleKey?: string): this;

  /**
   * Returns an object containing the app version.
   * @returns Result object containing the application version number.
   * @example const { major, minor, patch, flags } = await ada.getVersion();
   * console.log(`App version ${major}.${minor}.${patch}`);
   */
  getVersion(): Promise<GetVersionResponse>;

  /**
   * @ignore
   */
  _getVersion(): Interaction<Version>;

  /**
   * Returns an object containing the device serial number.
   * @returns Result object containing the device serial number.
   * @example const { serialHex } = await ada.getSerial();
   * console.log(`Serial number ${serial}`);
   */
  getSerial(): Promise<GetSerialResponse>;

  /**
   * @ignore
   */
  _getSerial(): Interaction<GetSerialResponse>;

  /**
   * Runs unit tests on the device (DEVEL app build only)
   */
  runTests(): Promise<void>;

  /**
   * @ignore
   */
  _runTests(): Interaction<void>;

  /**
   * Get several public keys; one for each of the specified BIP 32 path.
   * @param paths The paths. A path must begin with `44'/1815'/account'` or `1852'/1815'/account'`, and may be at most 5 indexes long.
   * @returns The extended public keys (i.e. with chaincode) for the given paths.
   * @example ```
   * const [{ publicKey, chainCode }] = await ada.getExtendedPublicKeys([[ HARDENED + 44, HARDENED + 1815, HARDENED + 1 ]]);
   * console.log(publicKey);
   * ```
   */
  getExtendedPublicKeys(
    x: GetExtendedPublicKeysRequest
  ): Promise<GetExtendedPublicKeysResponse>;

  /**
   * @ignore
   */
  _getExtendedPublicKeys(
    paths: ValidBIP32Path[]
  ): Interaction<Array<ExtendedPublicKey>>;

  /**
   * Get a public key from the specified BIP 32 path.
   */
  getExtendedPublicKey(
    x: GetExtendedPublicKeyRequest
  ): Promise<GetExtendedPublicKeyResponse>;

  /**
   * Derives an address for the specified BIP 32 path.
   * Note that the address is returned in raw *hex* format without any bech32/base58 encoding
   */
  deriveAddress(x: DeriveAddressRequest): Promise<DeriveAddressResponse>;

  /**
   * @ignore
   */
  _deriveAddress(
    addressParams: ParsedAddressParams
  ): Interaction<DerivedAddress>;

  /**
   * Show address corresponding to a given derivation path on the device.
   * This is useful for users to check whether the wallet does not try to scam the user.
   */
  showAddress(x: ShowAddressRequest): Promise<void>;

  /**
   * @ignore
   */
  _showAddress(addressParams: ParsedAddressParams): Interaction<void>;
  signTransaction(
    request: SignTransactionRequest
  ): Promise<SignTransactionResponse>;

  /**
   * @ignore
   */
  _signTx(request: ParsedSigningRequest): Interaction<SignedTransactionData>;
  signOperationalCertificate(
    request: SignOperationalCertificateRequest
  ): Promise<SignOperationalCertificateResponse>;

  /**
   * @ignore
   */
  _signOperationalCertificate(
    request: ParsedOperationalCertificate
  ): Interaction<OperationalCertificateSignature>;
  signMessage(request: SignMessageRequest): Promise<SignMessageResponse>;

  /**
   * @ignore
   */
  _signMessage(request: ParsedMessageData): Interaction<SignedMessageData>;
  signCIP36Vote(request: SignCIP36VoteRequest): Promise<SignCIP36VoteResponse>;

  /**
   * @ignore
   */
  _signCIP36Vote(request: ParsedCVote): Interaction<SignedCIP36VoteData>;

  /**
   * Derive a native script hash for the specified native script and display
   * it on Ledger in the specified format. The hash is returned in raw hex
   * format without any encoding.
   */
  deriveNativeScriptHash(
    x: DeriveNativeScriptHashRequest
  ): Promise<DeriveNativeScriptHashResponse>;

  /**
   * @ignore
   */
  _deriveNativeScriptHash(
    script: ParsedNativeScript,
    displayFormat: $Values<NativeScriptHashDisplayFormat>
  ): Interaction<NativeScriptHash>;
}
/**
 * Response to [[Ada.getVersion]] call
 * @category Main
 */
export type GetVersionResponse = {|
  version: Version,
  compatibility: DeviceCompatibility,
|};
/**
 * Get multiple public keys ([[Ada.getExtendedPublicKeys]]) request data
 * @category Main
 * @see  [[GetExtendedPublicKeysResponse]]
 */
export type GetExtendedPublicKeysRequest = {|
  /**
   * Paths to public keys which should be derived by the device
   */
  paths: BIP32Path[],
|};
/**
 * [[Ada.getExtendedPublicKeys]] response data
 * @category Main
 * @see  [[GetExtendedPublicKeysRequest]]
 */
export type GetExtendedPublicKeysResponse = Array<ExtendedPublicKey>;
/**
 * Get single public keys ([[Ada.getExtendedPublicKey]]) request data
 * @category Main
 * @see  [[GetExtendedPublicKeysResponse]]
 */
export type GetExtendedPublicKeyRequest = {|
  /**
   * Path to public key which should be derived
   */
  path: BIP32Path,
|};
/**
 * Get single public key ([[Ada.getExtendedPublicKey]]) response data
 * @category Main
 * @see  [[GetExtendedPublicKeysResponse]]
 */
export type GetExtendedPublicKeyResponse = ExtendedPublicKey;
/**
 * Derive address ([[Ada.deriveAddress]]) request data
 * @category Main
 * @see  [[DeriveAddressResponse]]
 */
export type DeriveAddressRequest = {|
  network: Network,
  address: DeviceOwnedAddress,
|};
/**
 * Derive address ([[Ada.deriveAddress]]) response data
 * @category Main
 * @see  [[DeriveAddressRequest]]
 */
export type DeriveAddressResponse = DerivedAddress;
/**
 * Show address on device ([[Ada.showAddress]]) request data
 * @category Main
 */
export type ShowAddressRequest = DeriveAddressRequest;
/**
 * Get device serial number ([[Ada.getSerial]]) response data
 * @category Main
 */
export type GetSerialResponse = Serial;
/**
 * Sign transaction ([[Ada.signTransaction]]) response data
 * @category Main
 * @see  [[SignTransactionRequest]]
 */
export type SignTransactionResponse = SignedTransactionData;
/**
 * Sign operational certificate ([[Ada.signOperationalCertificate]]) request data
 * @category Main
 * @see  [[SignOperationalCertificateResponse]]
 */
export type SignOperationalCertificateRequest = OperationalCertificate;
/**
 * Sign operational certificate ([[Ada.signOperationalCertificate]]) response data
 * @category Main
 * @see  [[SignOperationalCertificateRequest]]
 */
export type SignOperationalCertificateResponse =
  OperationalCertificateSignature;
/**
 * Sign CIP-8 message ([[Ada.signMessage]]) request data
 * @category Main
 * @see  [[SignMessageResponse]]
 */
export type SignMessageRequest = MessageData;
/**
 * Sign CIP-8 message ([[Ada.signMessage]]) response data
 * @category Main
 * @see  [[SignMessageRequest]]
 */
export type SignMessageResponse = SignedMessageData;
/**
 * Sign CIP36 vote ([[Ada.signCIP36Vote]]) request data
 * @category Main
 * @see  [[SignCIP36VoteResponse]]
 */
export type SignCIP36VoteRequest = CIP36Vote;
/**
 * Sign CIP36 vote ([[Ada.signCIP36Vote]]) response data
 * @category Main
 * @see  [[SignCIP36VoteRequest]]
 */
export type SignCIP36VoteResponse = SignedCIP36VoteData;
/**
 * Derive native script hash ([[Ada.deriveNativeScriptHash]]) request data
 * @category Main
 * @see  [[DeriveNativeScriptHashResponse]]
 */
export type DeriveNativeScriptHashRequest = {|
  script: NativeScript,
  displayFormat: $Values<NativeScriptHashDisplayFormat>,
|};
/**
 * Derive native script hash ([[Ada.deriveNativeScriptHash]]) response data
 * @category Main
 * @see  [[DeriveNativeScriptHashRequest]]
 */
export type DeriveNativeScriptHashResponse = NativeScriptHash;
declare export { utils };
declare export default typeof Ada;

/**
 * Default Cardano networks
 * @see  [[Network]]
 */
declare export var Networks: {|
  Mainnet: Network,
  Testnet: Network,
|};
