forked from LedgerHQ/ledger-live-desktop
/
getAddress.js
35 lines (30 loc) · 875 Bytes
/
getAddress.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// @flow
import type { Observable } from "rxjs";
import { getCryptoCurrencyById } from "@ledgerhq/live-common/lib/currencies";
import { from } from "rxjs";
import type { DerivationMode } from "@ledgerhq/live-common/lib/types";
import { withDevice } from "@ledgerhq/live-common/lib/hw/deviceAccess";
import getAddress from "@ledgerhq/live-common/lib/hw/getAddress";
type Input = {
currencyId: string,
devicePath: string,
path: string,
verify?: boolean,
derivationMode: DerivationMode,
};
type Result = {
address: string,
path: string,
publicKey: string,
};
const cmd = ({ currencyId, devicePath, ...options }: Input): Observable<Result> =>
withDevice(devicePath)(transport =>
from(
getAddress(transport, {
currency: getCryptoCurrencyById(currencyId),
// $FlowFixMe
...options,
}),
),
);
export default cmd;