/* tslint:disable */
/* eslint-disable */
/**
 * Computes the Starknet contract address for a controller account without needing a full instance.
 *
 * # Arguments
 *
 * * `class_hash` - The class hash of the account contract (JsFelt).
 * * `owner` - The owner configuration for the account.
 * * `salt` - The salt used for address calculation (JsFelt).
 *
 * # Returns
 *
 * The computed Starknet contract address as a `JsFelt`.
 */
export function computeAccountAddress(class_hash: JsFelt, owner: Owner, salt: JsFelt): JsFelt;
/**
 * Subscribes to the creation of a session for a given controller, session_key_guid and cartridge api url.
 * The goal of this function is to know from any place when the register session flow has been completed, and to
 * get the authorization.
 */
export function subscribeCreateSession(session_key_guid: JsFelt, cartridge_api_url: string): Promise<JsSubscribeSessionResult>;
export function signerToGuid(signer: Signer): JsFelt;
export enum ErrorCode {
  StarknetFailedToReceiveTransaction = 1,
  StarknetContractNotFound = 20,
  StarknetBlockNotFound = 24,
  StarknetInvalidTransactionIndex = 27,
  StarknetClassHashNotFound = 28,
  StarknetTransactionHashNotFound = 29,
  StarknetPageSizeTooBig = 31,
  StarknetNoBlocks = 32,
  StarknetInvalidContinuationToken = 33,
  StarknetTooManyKeysInFilter = 34,
  StarknetContractError = 40,
  StarknetTransactionExecutionError = 41,
  StarknetClassAlreadyDeclared = 51,
  StarknetInvalidTransactionNonce = 52,
  StarknetInsufficientMaxFee = 53,
  StarknetInsufficientAccountBalance = 54,
  StarknetValidationFailure = 55,
  StarknetCompilationFailed = 56,
  StarknetContractClassSizeIsTooLarge = 57,
  StarknetNonAccount = 58,
  StarknetDuplicateTx = 59,
  StarknetCompiledClassHashMismatch = 60,
  StarknetUnsupportedTxVersion = 61,
  StarknetUnsupportedContractClassVersion = 62,
  StarknetUnexpectedError = 63,
  StarknetNoTraceAvailable = 10,
  StarknetReplacementTransactionUnderpriced = 64,
  StarknetFeeBelowMinimum = 65,
  SignError = 101,
  StorageError = 102,
  AccountFactoryError = 103,
  PaymasterExecutionTimeNotReached = 104,
  PaymasterExecutionTimePassed = 105,
  PaymasterInvalidCaller = 106,
  PaymasterRateLimitExceeded = 107,
  PaymasterNotSupported = 108,
  PaymasterHttp = 109,
  PaymasterExcecution = 110,
  PaymasterSerialization = 111,
  CartridgeControllerNotDeployed = 112,
  InsufficientBalance = 113,
  OriginError = 114,
  EncodingError = 115,
  SerdeWasmBindgenError = 116,
  CairoSerdeError = 117,
  CairoShortStringToFeltError = 118,
  DeviceCreateCredential = 119,
  DeviceGetAssertion = 120,
  DeviceBadAssertion = 121,
  DeviceChannel = 122,
  DeviceOrigin = 123,
  AccountSigning = 124,
  AccountProvider = 125,
  AccountClassHashCalculation = 126,
  AccountFeeOutOfRange = 128,
  ProviderRateLimited = 129,
  ProviderArrayLengthMismatch = 130,
  ProviderOther = 131,
  SessionAlreadyRegistered = 132,
  UrlParseError = 133,
  Base64DecodeError = 134,
  CoseError = 135,
  PolicyChainIdMismatch = 136,
  InvalidOwner = 137,
  GasPriceTooHigh = 138,
  TransactionTimeout = 139,
  ConversionError = 140,
  InvalidChainId = 141,
  SessionRefreshRequired = 142,
  ManualExecutionRequired = 143,
}
export interface JsCall {
    contractAddress: JsFelt;
    entrypoint: string;
    calldata: JsFelt[];
}

export type JsPriceUnit = "WEI" | "FRI";

export interface JsEstimateFeeDetails {
    nonce: JsFelt;
}

export interface JsFeeEstimate {
    l1_gas_consumed: number;
    l1_gas_price: number;
    l2_gas_consumed: number;
    l2_gas_price: number;
    l1_data_gas_consumed: number;
    l1_data_gas_price: number;
    overall_fee: number;
}

/**
 * JavaScript-friendly OutsideExecution V3 structure
 */
export interface JsOutsideExecutionV3 {
    caller: JsFelt;
    execute_after: number;
    execute_before: number;
    calls: JsCall[];
    nonce: [JsFelt, JsFelt];
}

/**
 * Result type for signExecuteFromOutside containing both the OutsideExecution and signature
 */
export interface JsSignedOutsideExecution {
    outside_execution: JsOutsideExecutionV3;
    signature: JsFelt[];
}

export interface Owner {
    signer?: Signer;
    account?: JsFelt;
}

export interface CallPolicy {
    target: JsFelt;
    method: JsFelt;
    authorized?: boolean;
}

export interface TypedDataPolicy {
    scope_hash: JsFelt;
    authorized?: boolean;
}

export type Policy = CallPolicy | TypedDataPolicy;

export type JsRegister = RegisterInput;

export type JsRegisterResponse = ResponseData;

export interface WebauthnSigner {
    rpId: string;
    credentialId: string;
    publicKey: string;
}

export interface StarknetSigner {
    privateKey: JsFelt;
}

export interface Eip191Signer {
    address: string;
}

export interface Signer {
    webauthns?: WebauthnSigner[];
    webauthn?: WebauthnSigner;
    starknet?: StarknetSigner;
    eip191?: Eip191Signer;
}

export type JsAddSignerInput = SignerInput;

export type JsRemoveSignerInput = SignerInput;

export type JsFelt = Felt;

export type Felts = JsFelt[];

export type JsFeeSource = "PAYMASTER" | "CREDITS";

export type JsSubscribeSessionResult = SubscribeCreateSessionSubscribeCreateSession;

export type JsRevokableSession = RevokableSession;

export interface AuthorizedSession {
    session: Session;
    authorization: JsFelt[] | null;
    isRegistered: boolean;
    expiresAt: number;
    allowedPoliciesRoot: JsFelt;
    metadataHash: JsFelt;
    sessionKeyGuid: JsFelt;
    guardianKeyGuid: JsFelt;
}

export interface Session {
    policies: Policy[];
    expiresAt: number;
    metadataHash: JsFelt;
    sessionKeyGuid: JsFelt;
    guardianKeyGuid: JsFelt;
}

export interface Credentials {
    authorization: JsFelt[];
    privateKey: JsFelt;
}

export class CartridgeAccount {
  private constructor();
  free(): void;
  [Symbol.dispose](): void;
  /**
   * Creates a new `CartridgeAccount` instance.
   *
   * # Parameters
   * - `app_id`: Application identifier.
   * - `rpc_url`: The URL of the JSON-RPC endpoint.
   * - `address`: The blockchain address associated with the account.
   * - `username`: Username associated with the account.
   * - `owner`: A Owner struct containing the owner signer and associated data.
   */
  static new(app_id: string, class_hash: JsFelt, rpc_url: string, address: JsFelt, username: string, owner: Owner, cartridge_api_url: string): Promise<CartridgeAccountWithMeta>;
  /**
   * Creates a new `CartridgeAccount` instance with a randomly generated Starknet signer.
   * The controller address is computed internally based on the generated signer.
   *
   * # Parameters
   * - `app_id`: Application identifier.
   * - `rpc_url`: The URL of the JSON-RPC endpoint.
   * - `username`: Username associated with the account.
   */
  static newHeadless(app_id: string, class_hash: JsFelt, rpc_url: string, username: string, cartridge_api_url: string): Promise<CartridgeAccountWithMeta>;
  static fromStorage(app_id: string, cartridge_api_url: string): Promise<CartridgeAccountWithMeta | undefined>;
  disconnect(): Promise<void>;
  registerSession(policies: Policy[], expires_at: bigint, public_key: JsFelt, max_fee?: JsFeeEstimate | null): Promise<any>;
  registerSessionCalldata(policies: Policy[], expires_at: bigint, public_key: JsFelt): Promise<any>;
  upgrade(new_class_hash: JsFelt): Promise<JsCall>;
  register(register: JsRegister): Promise<JsRegisterResponse>;
  createSession(policies: Policy[], expires_at: bigint): Promise<AuthorizedSession | undefined>;
  skipSession(policies: Policy[]): Promise<void>;
  addOwner(owner?: Signer | null, signer_input?: JsAddSignerInput | null, rp_id?: string | null): Promise<void>;
  removeOwner(signer: JsRemoveSignerInput): Promise<void>;
  createPasskeySigner(rp_id: string): Promise<JsAddSignerInput>;
  estimateInvokeFee(calls: JsCall[]): Promise<JsFeeEstimate>;
  execute(calls: JsCall[], max_fee?: JsFeeEstimate | null, fee_source?: JsFeeSource | null): Promise<any>;
  executeFromOutsideV2(calls: JsCall[], fee_source?: JsFeeSource | null): Promise<any>;
  executeFromOutsideV3(calls: JsCall[], fee_source?: JsFeeSource | null): Promise<any>;
  trySessionExecute(calls: JsCall[], fee_source?: JsFeeSource | null): Promise<any>;
  isRegisteredSessionAuthorized(policies: Policy[], public_key?: JsFelt | null): Promise<AuthorizedSession | undefined>;
  hasRequestedSession(policies: Policy[]): Promise<boolean>;
  revokeSession(session: JsRevokableSession): Promise<void>;
  revokeSessions(sessions: JsRevokableSession[]): Promise<void>;
  signMessage(typed_data: string): Promise<Felts>;
  getNonce(): Promise<any>;
  deploySelf(max_fee?: JsFeeEstimate | null): Promise<any>;
  delegateAccount(): Promise<JsFelt>;
  hasAuthorizedPoliciesForCalls(calls: JsCall[]): Promise<boolean>;
  hasAuthorizedPoliciesForMessage(typed_data: string): Promise<boolean>;
  /**
   * Signs an OutsideExecution V3 transaction and returns both the OutsideExecution object and its signature.
   *
   * # Parameters
   * - `calls`: Array of calls to execute from outside
   *
   * # Returns
   * A `JsSignedOutsideExecution` containing the OutsideExecution V3 object and its signature
   */
  signExecuteFromOutside(calls: JsCall[]): Promise<JsSignedOutsideExecution>;
}
/**
 * A type for accessing fixed attributes of `CartridgeAccount`.
 *
 * This type exists as concurrent mutable and immutable calls to `CartridgeAccount` are guarded
 * with `WasmMutex`, which only operates under an `async` context. If these getters were directly
 * implemented under `CartridgeAccount`:
 *
 * - calls to them would unnecessarily have to be `async` as well;
 * - there would be excessive locking.
 *
 * This type is supposed to only ever be borrowed immutably. So no concurrent access control would
 * be needed.
 */
export class CartridgeAccountMeta {
  private constructor();
  free(): void;
  [Symbol.dispose](): void;
  appId(): string;
  username(): string;
  address(): string;
  classHash(): string;
  rpcUrl(): string;
  chainId(): string;
  owner(): Owner;
  ownerGuid(): JsFelt;
}
/**
 * A type used as the return type for constructing `CartridgeAccount` to provide an extra,
 * separately borrowable `meta` field for synchronously accessing fixed fields.
 *
 * This type exists instead of simply having `CartridgeAccount::new()` return a tuple as tuples
 * don't implement `IntoWasmAbi` which is needed for crossing JS-WASM boundary.
 */
export class CartridgeAccountWithMeta {
  private constructor();
  free(): void;
  [Symbol.dispose](): void;
  meta(): CartridgeAccountMeta;
  intoAccount(): CartridgeAccount;
}
export class ControllerFactory {
  private constructor();
  free(): void;
  [Symbol.dispose](): void;
  static fromStorage(app_id: string, cartridge_api_url: string): Promise<CartridgeAccountWithMeta | undefined>;
  static login(app_id: string, username: string, class_hash: JsFelt, rpc_url: string, address: JsFelt, owner: Owner, cartridge_api_url: string, session_expires_at_s: bigint, is_controller_registered?: boolean | null): Promise<LoginResult>;
  /**
   * This should only be used with webauthn signers
   */
  static apiLogin(app_id: string, username: string, class_hash: JsFelt, rpc_url: string, address: JsFelt, owner: Owner, cartridge_api_url: string): Promise<CartridgeAccountWithMeta>;
}
export class JsControllerError {
  private constructor();
  free(): void;
  [Symbol.dispose](): void;
  code: ErrorCode;
  message: string;
  get data(): string | undefined;
  set data(value: string | null | undefined);
}
export class LoginResult {
  private constructor();
  free(): void;
  [Symbol.dispose](): void;
  intoValues(): Array<any>;
}
