/** * @module LedgerLivePlatformSDK */ /// import Logger from "../logger"; import { RawSignedTransaction } from "../rawTypes"; import { ExchangeType } from "../types"; import type { Account, ApplicationDetails, Currency, DeviceInfo, EcdsaSignature, ExchangeDeviceTxId, ExchangePayload, FeesLevel, Transaction, Transport } from "../types"; import LedgerPlatformApduTransport from "./LedgerPlatformApduTransport"; export default class LedgerLivePlatformSDK { /** * @ignore * @internal */ private transport; /** * @ignore * @internal */ private logger; /** * @ignore * @internal */ private serverAndClient?; constructor(transport: Transport, logger?: Logger); /** * @ignore * @internal * Wrapper to api request for logging */ private _request; /** * Connect the SDK to the Ledger Live instance * * @remarks * Establish the connection with Ledger Live through the [[transport]] instance provided at initialization */ connect(): void; /** * Disconnect the SDK. */ disconnect(): void; /** * @ignore Not yet implemented * Open a bridge to an application to exchange APDUs with a device application * @param _appName - The name of the application to bridge * * @returns The result of the handler function */ bridgeApp(_appName: string): Promise; /** * @ignore Not yet implemented * Open a bridge to a the device dashboard to exchange APDUs * * @returns A APDU transport which can be used either to send raw APDU * or used with ledgerjs libraries. */ bridgeDashboard(): Promise; /** * @alpha * Start the exchange process by generating a nonce on Ledger device * @param exchangeType - used by the exchange transport to discern between swap/sell/fund * * @returns - A transaction ID used to complete the exchange process */ startExchange({ exchangeType, }: { exchangeType: ExchangeType; }): Promise; /** * @alpha * Complete an exchange process by passing by the exchange content and its signature. * User will be prompted on its device to approve the exchange. * If the exchange is validated, the transaction is then signed and broadcasted to the network. * @param provider - Used to verify the signature * @param fromAccountId - Live identifier of the account used as a source for the tx * @param toAccountId - (Swap) Live identifier of the account used as a destination * @param transaction - Transaction containing the recipient and amount * @param binaryPayload - Blueprint of the data that we'll allow signing * @param signature - Ensures the source of the payload * @param feesStrategy - Slow / Medium / Fast * @param exchangeType - used by the exchange transport to discern between swap/sell/fund * * @returns - The broadcasted transaction details. */ completeExchange({ provider, fromAccountId, toAccountId, transaction, binaryPayload, signature, feesStrategy, exchangeType, }: { provider: string; fromAccountId: string; toAccountId?: string; transaction: Transaction; binaryPayload: ExchangePayload; signature: EcdsaSignature; feesStrategy: FeesLevel; exchangeType: ExchangeType; }): Promise; /** * Let the user sign a transaction through Ledger Live * @param accountId - Ledger Live id of the account * @param transaction - The transaction object in the currency family-specific format * @param params - Parameters for the sign modal * * @returns The raw signed transaction to broadcast */ signTransaction(accountId: string, transaction: Transaction, params?: { /** * The name of the Ledger Nano app to use for the signing process */ useApp: string; }): Promise; /** * Let the user sign the provided message through Ledger Live. * In Ethereum context, this is an [EIP-191 message](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-191.md) or an [EIP-712 message](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-712.md) * @param accountId - Ledger Live id of the account * @param message - Message the user should sign * * @returns Message signed */ signMessage(accountId: string, message: Buffer): Promise; /** * Broadcast a previously signed transaction through Ledger Live * @param accountId - Ledger Live id of the account * @param signedTransaction - A [[RawSignedTransaction]] returned by Ledger Live when signing with [[signTransaction]] * * @returns The hash of the transaction */ broadcastSignedTransaction(accountId: string, signedTransaction: RawSignedTransaction): Promise; /** * List accounts added by user on Ledger Live * * @returns The list of accounts added by the current user on Ledger Live */ listAccounts(params?: { includeTokens?: boolean; }): Promise; /** * Let user choose an account in a Ledger Live, providing filters for choosing currency or allowing add account. * * @param params - Parameters for the request modal, currencies is an array of currencies (not families). * * @returns The account selected by the user */ requestAccount(params?: { /** * Select a set of currencies by id. Globing is enabled */ currencies?: string[]; /** * Allow the user to create a new account during the flow */ allowAddAccount?: boolean; /** * Allow the user to pick token accounts */ includeTokens?: boolean; }): Promise; /** * Let user verify it's account address on his device through Ledger Live * * @param accountId - LL id of the account * * @returns The verified address or an error message if the verification doesn't succeed */ receive(accountId: string): Promise; /** * @ignore Not yet implemented * Synchronize an account with its network and return an updated view of the account * @param accountId - The id of the account to synchronize * * @returns - An updated view of the account */ synchronizeAccount(_accountId: string): Promise; /** * List cryptocurrencies supported by Ledger Live, providing filters by name or ticker * * @param params - Filters for currencies * * @returns The list of corresponding cryptocurrencies * * @beta Filtering not yet implemented */ listCurrencies(params?: { /** * Include tokens in the results */ includeTokens?: boolean; /** * Select a set of currencies by id. Globing is enabled */ currencies?: string[]; }): Promise; /** * @ignore Not yet implemented * Get information about a currently connected device (firmware version...) * * @returns {Promise} - Informations about the last connected device */ getLastConnectedDeviceInfo(): Promise; /** * @ignore Not yet implemented * List applications opened on a currently connected device * * @returns {Promise} - The list of applications */ listApps(): Promise; }