@ledgerhq/live-common
Version:
Common ground for the Ledger Live apps
32 lines • 1.53 kB
TypeScript
import { Observable } from "rxjs";
import Transport from "@ledgerhq/hw-transport";
export { Transport };
export declare const cancelDeviceAction: (transport: Transport) => void;
export type TransportRef = {
current: Transport;
refreshTransport: () => Promise<void>;
_refreshedCounter: number;
};
export type JobArgs = {
transportRef: TransportRef;
};
/**
* Wrapper providing a transport that can be refreshed to a job that can be executed
*
* This is useful for any job that may need to refresh the transport because of a device disconnected-like error
*
* The transportRef.current will be updated with the new transport when transportRef.refreshTransport is called
*
* @param deviceId the id of the device to open the transport channel with
* @param options contains optional configuration
* - openTimeoutMs: optional timeout that limits in time the open attempt of the matching registered transport.
* @returns a function that takes a job and returns an observable on the result of the job
* job: the job to execute with the transport. It takes:
* - transportRef: a reference to the transport that can be updated by calling a transportRef.refreshTransport()
*/
export declare const withTransport: (deviceId: string, options?: {
openTimeoutMs?: number;
matchDeviceByName?: string;
}) => <T>(job: ({ transportRef }: JobArgs) => Observable<T>) => Observable<T>;
export declare const setErrorRemapping: (f: (arg0: Error) => Observable<never>) => void;
//# sourceMappingURL=core.d.ts.map