import { RefObject } from "react";
import { Account, AccountLike, AnyMessage, Operation, SignedOperation } from "@ledgerhq/types-live";
import { WalletHandlers, ServerConfig, WalletAPIServer } from "@ledgerhq/wallet-api-server";
import { Permission } from "@ledgerhq/wallet-api-core";
import { WalletState } from "@ledgerhq/live-wallet/store";
import { StateDB } from "../hooks/useDBRaw";
import { AppManifest, WalletAPICustomHandlers, DiscoverDB } from "./types";
import { TrackingAPI } from "./tracking";
import { CompleteExchangeUiRequest } from "./logic";
import { AppResult } from "../hw/actions/app";
import { Transaction } from "../generated/types";
import { LiveAppManifest } from "../platform/types";
import { ModularDrawerConfiguration } from "./ModularDrawer/types";
export declare function safeGetRefValue<T>(ref: RefObject<T>): NonNullable<T>;
export declare function useSetWalletAPIAccounts(accounts: AccountLike[]): void;
export declare function useDAppManifestCurrencyIds(manifest: AppManifest): string[];
export interface UiHook {
    "account.request": (params: {
        currencyIds?: string[];
        areCurrenciesFiltered?: boolean;
        useCase?: string;
        uiUseCase?: string;
        drawerConfiguration?: ModularDrawerConfiguration;
        onSuccess: (account: AccountLike, parentAccount: Account | undefined) => void;
        onCancel: () => void;
    }) => void;
    "account.receive": (params: {
        account: AccountLike;
        parentAccount: Account | undefined;
        accountAddress: string;
        onSuccess: (address: string) => void;
        onCancel: () => void;
        onError: (error: Error) => void;
    }) => void;
    "message.sign": (params: {
        account: AccountLike;
        message: AnyMessage;
        options: Parameters<WalletHandlers["message.sign"]>[0]["options"];
        onSuccess: (signature: string) => void;
        onError: (error: Error) => void;
        onCancel: () => void;
    }) => void;
    "storage.get": WalletHandlers["storage.get"];
    "storage.set": WalletHandlers["storage.set"];
    "transaction.signRaw": (params: {
        account: AccountLike;
        parentAccount: Account | undefined;
        transaction: string;
        broadcast?: boolean;
        options: Parameters<WalletHandlers["transaction.sign"]>[0]["options"];
        onSuccess: (signedOperation: SignedOperation) => void;
        onError: (error: Error) => void;
    }) => void;
    "transaction.sign": (params: {
        account: AccountLike;
        parentAccount: Account | undefined;
        signFlowInfos: {
            canEditFees: boolean;
            hasFeesProvided: boolean;
            liveTx: Partial<Transaction>;
        };
        options: Parameters<WalletHandlers["transaction.sign"]>[0]["options"];
        onSuccess: (signedOperation: SignedOperation) => void;
        onError: (error: Error) => void;
    }) => void;
    "transaction.broadcast": (account: AccountLike, parentAccount: Account | undefined, mainAccount: Account, optimisticOperation: Operation) => void;
    "device.transport": (params: {
        appName: string | undefined;
        onSuccess: (result: AppResult) => void;
        onCancel: () => void;
    }) => void;
    "device.select": (params: {
        appName: string | undefined;
        onSuccess: (result: AppResult) => void;
        onCancel: () => void;
    }) => void;
    "exchange.start": (params: {
        exchangeType: "SWAP" | "FUND" | "SELL" | "SWAP_NG" | "SELL_NG" | "FUND_NG";
        onSuccess: (nonce: string) => void;
        onCancel: (error: Error) => void;
    }) => void;
    "exchange.complete": (params: {
        exchangeParams: CompleteExchangeUiRequest;
        onSuccess: (hash: string) => void;
        onCancel: (error: Error) => void;
    }) => void;
}
export declare function usePermission(manifest: AppManifest): Omit<Permission, "currencyIds">;
export declare function useConfig({ appId, userId, tracking, wallet, mevProtected, }: ServerConfig): ServerConfig;
export type useWalletAPIServerOptions = {
    walletState: WalletState;
    manifest: AppManifest;
    accounts: AccountLike[];
    tracking: TrackingAPI;
    config: ServerConfig;
    webviewHook: {
        reload: () => void;
        postMessage: (message: string) => void;
    };
    uiHook: Partial<UiHook>;
    customHandlers?: WalletAPICustomHandlers;
};
export declare function useWalletAPIServer({ walletState, manifest, accounts, tracking, config, webviewHook, uiHook: { "account.request": uiAccountRequest, "account.receive": uiAccountReceive, "message.sign": uiMessageSign, "storage.get": uiStorageGet, "storage.set": uiStorageSet, "transaction.sign": uiTxSign, "transaction.signRaw": uiTxSignRaw, "transaction.broadcast": uiTxBroadcast, "device.transport": uiDeviceTransport, "device.select": uiDeviceSelect, "exchange.start": uiExchangeStart, "exchange.complete": uiExchangeComplete, }, customHandlers, }: useWalletAPIServerOptions): {
    onMessage: (event: string) => void;
    server: WalletAPIServer;
    onLoad: () => void;
    onReload: () => void;
    onLoadError: () => void;
    widgetLoaded: boolean;
};
export declare enum ExchangeType {
    SWAP = 0,
    SELL = 1,
    FUND = 2,
    SWAP_NG = 3,
    SELL_NG = 4,
    FUND_NG = 5
}
export interface Categories {
    categories: string[];
    manifestsByCategories: Map<string, AppManifest[]>;
    selected: string;
    setSelected: (val: string) => void;
    reset: () => void;
}
/** e.g. "all", "restaking", "services", etc */
export type CategoryId = Categories["selected"];
export declare function useCategories(manifests: any, initialCategory?: CategoryId | null): Categories;
export type RecentlyUsedDB = StateDB<DiscoverDB, DiscoverDB["recentlyUsed"]>;
export type CacheBustedLiveAppsdDB = StateDB<DiscoverDB, DiscoverDB["cacheBustedLiveApps"]>;
export type LocalLiveAppDB = StateDB<DiscoverDB, DiscoverDB["localLiveApp"]>;
export type CurrentAccountHistDB = StateDB<DiscoverDB, DiscoverDB["currentAccountHist"]>;
export interface LocalLiveApp {
    state: LiveAppManifest[];
    addLocalManifest: (LiveAppManifest: any) => void;
    removeLocalManifestById: (string: any) => void;
    getLocalLiveAppManifestById: (string: any) => LiveAppManifest | undefined;
}
export declare function useLocalLiveApp([LocalLiveAppDb, setState]: LocalLiveAppDB): LocalLiveApp;
export interface RecentlyUsed {
    data: RecentlyUsedManifest[];
    append: (manifest: AppManifest) => void;
    clear: () => void;
}
export type RecentlyUsedManifest = AppManifest & {
    usedAt: UsedAt;
};
export type UsedAt = {
    unit?: Intl.RelativeTimeFormatUnit;
    diff: number;
};
export declare function useCacheBustedLiveApps([cacheBustedLiveAppsDb, setState]: CacheBustedLiveAppsdDB): {
    getLatest: (manifestId: string) => number;
    edit: (manifestId: string, cacheBustingId: number) => void;
};
export declare function useRecentlyUsed(manifests: AppManifest[], [recentlyUsedManifestsDb, setState]: RecentlyUsedDB): RecentlyUsed;
export interface DisclaimerRaw {
    onConfirm: (manifest: AppManifest, isChecked: boolean) => void;
    onSelect: (manifest: AppManifest) => void;
}
interface DisclaimerUiHook {
    prompt: (manifest: AppManifest, onContinue: (manifest: AppManifest, isChecked: boolean) => void) => void;
    dismiss: () => void;
    openApp: (manifest: AppManifest) => void;
    close: () => void;
}
export declare function useDisclaimerRaw({ isReadOnly, isDismissed, uiHook, appendRecentlyUsed, }: {
    isReadOnly?: boolean;
    isDismissed: boolean;
    appendRecentlyUsed: (manifest: AppManifest) => void;
    uiHook: DisclaimerUiHook;
}): DisclaimerRaw;
export {};
//# sourceMappingURL=react.d.ts.map