Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
* Validate the trasaction's object input
*/
userInputValidator({
firstArgument: argumentObject,
});
const { addressCount, chainId = CHAIN_IDS.HOMESTEAD } = argumentObject;
/*
* @TODO Reduce code repetition
* By moving this inside a helper. This same patter will be used on the
* ledger wallet as well.
*
* If we're on a testnet set the coin type id to `1`
* This will be used in the derivation path
*/
const coinType: number =
chainId === CHAIN_IDS.HOMESTEAD ? PATH.COIN_MAINNET : PATH.COIN_TESTNET;
/*
* Get to root derivation path based on the coin type.
*
* Based on this, we will then derive all the needed address indexes
* (inside the class constructor)
*/
const rootDerivationPath: string = derivationPathSerializer({
change: PATH.CHANGE,
coinType,
});
/*
* Modify the default payload to overwrite the path with the new
* coin type id derivation
*/
const modifiedPayloadObject: Object = Object.assign({}, PAYLOAD_XPUB, {
path: fromString(rootDerivationPath, true).toPathArray(),
* Validate the trasaction's object input
*/
userInputValidator({
firstArgument: argumentObject,
});
const { addressCount, chainId = CHAIN_IDS.HOMESTEAD } = argumentObject;
/*
* @TODO Reduce code repetition
* By moving this inside a helper. This same patter will be used on the
* trezor wallet as well.
*
* If we're on a testnet set the coin type id to `1`
* This will be used in the derivation path
*/
const coinType: number =
chainId === CHAIN_IDS.HOMESTEAD ? PATH.COIN_MAINNET : PATH.COIN_TESTNET;
/*
* Get to root derivation path based on the coin type.
*
* Based on this, we will then derive all the needed address indexes
* (inside the class constructor)
*/
const rootDerivationPath: string = derivationPathSerializer({
coinType,
});
try {
const ledger: LedgerInstanceType = await ledgerConnection();
/*
* Get the harware wallet's root public key and chain code, to use
* for deriving the rest of the accounts
*/
const { publicKey, chainCode } = await ledger.getAddress(