yoroi-extension-ledger-connect-handler
v2.0.4
Published
Interface for communication with Cardano Ledger app
Downloads
3
Maintainers
Readme
yoroi-extension-ledger-connect-handler
This library enables Yoroi extension to communicate with Ledger device, in process this library needs one web page that directly communicates with Ledger device. This library is responsible for opening, sendind resquest, passing back response to Yoroi and closing the target web page.
Message Passing
Flow:
Yoroi
requestsyoroi-extension-ledger-connect-handler
(Using function call).yoroi-extension-ledger-connect-handler
opens target Website.yoroi-extension-ledger-connect-handler
sends request message tocontent-script
(Using extension port).content-script
passes request to the target Website app(UsingpostMessage()
).- Target Website app processes the request and send response to
content-script
(UsingpostMessage()
). content-script
passes response toyoroi-extension-ledger-connect-handler
(Using extension port).- Finally,
yoroi-extension-ledger-connect-handler
passes response toYoroi
(Using function return).
Supported Functions
getExtendedPublicKey = (hdPath: BIP32Path): Promise<ExtendedPublicKeyResp>
params:
- hdPath: BIP32Path HARDENED = 0x80000000; PURPOSE = 44; COIN_TYPE = 1815; // Cardano BIP32Path = [ HARDENED + PURPOSE, HARDENED + COIN_TYPE, HARDENED + account, chain, address ]
returns:
- Promise<ExtendedPublicKeyResp> type ExtendedPublicKeyResp = { ePublicKey: GetExtendedPublicKeyResponse, deviceVersion: GetVersionResponse, }
signTransaction = (inputs: Array<InputTypeUTxO>, outputs: Array<OutputTypeAddress | OutputTypeChange>): Promise<SignTransactionResponse>
params:
- inputs: Array<InputTypeUTxO>
- outputs: Array<OutputTypeAddress | OutputTypeChange>
returns:
showAddress = (hdPath: BIP32Path, address: string): Promise<void>
params:
- hdPath: BIP32Path
- address: string
returns:
- Promise<void>
deriveAddress = (hdPath: BIP32Path): Promise<DeriveAddressResponse>
params:
- hdPath: BIP32Path
returns:
getVersion = (): Promise<GetVersionResponse>
params:
void
returns:
Example
Import
import LedgerConnect from 'yoroi-extension-ledger-connect-handler';
Create new instance
const ledgerConnect = new LedgerConnect(config);
config
is type of: Config
Calling function
const deviceVersionResp = await ledgerConnect.getVersion();
Supported Ledger Transport
- @ledgerhq/hw-transport-webauthn [Default]
- @ledgerhq/hw-transport-u2f
- Has issues on
Windows 10 Version: >= 1903
. Refer.
- Has issues on
- @ledgerhq/hw-transport-webusb [Incomplete]
Building up
nvm i
yarn
yarn run build
Publishing
Make sure you have followed Building up steps before publishing.
npm publish