@ledgerhq/live-common
Version:
Common ground for the Ledger Live apps
32 lines • 1.97 kB
TypeScript
import type { Device } from "../../hw/actions/types";
import type { OnboardingStatePollingResult, GetOnboardingStatePollingArgs, GetOnboardingStatePollingResult } from "../../hw/getOnboardingStatePolling";
export type UseOnboardingStatePollingResult = OnboardingStatePollingResult & {
fatalError: Error | null;
resetStates: () => void;
};
export type UseOnboardingStatePollingDependencies = {
getOnboardingStatePolling?: (args: GetOnboardingStatePollingArgs) => GetOnboardingStatePollingResult;
};
export type UseOnboardingStatePollingArgs = UseOnboardingStatePollingDependencies & {
device: Device | null;
pollingPeriodMs: number;
stopPolling?: boolean;
allowedErrorChecks?: ((error: unknown) => boolean)[];
};
/**
* Polls the current device onboarding state, and notify the hook consumer of
* any allowed errors and fatal errors
* @param getOnboardingStatePolling A polling function, by default set to live-common/hw/getOnboardingStatePolling.
* This dependency injection is needed for LLD to have the polling working on the internal thread
* @param device A Device object
* @param pollingPeriodMs The period in ms after which the device onboarding state is fetched again
* @param stopPolling Flag to stop or continue the polling
* @returns An object containing:
* - onboardingState: the device state during the onboarding
* - allowedError: any error that is allowed and does not stop the polling
* - fatalError: any error that is fatal and stops the polling
* - lockedDevice: a boolean set to true if the device is currently locked, false otherwise
* - resetStates: a function to reset the values of: onboardingState, allowedError, fatalError and lockedDevice
*/
export declare const useOnboardingStatePolling: ({ getOnboardingStatePolling, device, pollingPeriodMs, stopPolling, allowedErrorChecks, }: UseOnboardingStatePollingArgs) => UseOnboardingStatePollingResult;
//# sourceMappingURL=useOnboardingStatePolling.d.ts.map