Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const CardanoLedgerCryptoProvider = async (ADALITE_CONFIG, walletState) => {
let transport
try {
transport = await LedgerTransportU2F.create()
} catch (u2fError) {
try {
transport = await LedgerTransportWebusb.create()
} catch (webUsbError) {
debugLog(webUsbError)
throw u2fError
}
}
transport.setExchangeTimeout(ADALITE_CONFIG.ADALITE_LOGOUT_AFTER * 1000)
const ledger = new Ledger(transport)
const state = Object.assign(walletState, {
derivationScheme: derivationSchemes.v2,
rootHdPassphrase: null,
derivedAddresses: {},
})
const isHwWallet = () => true
const getHwWalletName = () => 'Ledger'
const deriveXpub = CachedDeriveXpubFactory(state.derivationScheme, async (absDerivationPath) => {
const response = await ledger.getExtendedPublicKey(absDerivationPath)
const xpubHex = response.publicKeyHex + response.chainCodeHex
return Buffer.from(xpubHex, 'hex')
})
function deriveHdNode(childIndex) {