Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export const open = async (
argumentObject: WalletArgumentsType = {},
): Promise => {
/*
* 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)
*/
export const open = async (
argumentObject: WalletArgumentsType = {},
): Promise => {
/*
* Validate the trasaction's object input
*/
userInputValidator({
firstArgument: argumentObject,
requiredEither: REQUIRED_PROPS_SOFTWARE.OPEN_WALLET,
});
const {
password,
privateKey,
mnemonic,
keystore,
chainId = CHAIN_IDS.HOMESTEAD,
} = argumentObject;
let extractedPrivateKey: string;
/*
* @TODO Re-add use ability to control derivation path
* When opening the wallet. But only if this proves to be a needed feature.
*/
const derivationPath: string = derivationPathSerializer({
change: PATH.CHANGE,
addressIndex: PATH.INDEX,
});
try {
/*
* @TODO Detect if existing but not valid keystore, and warn the user
*/
if (keystore && isSecretStorageWallet(keystore) && password) {
const keystoreWallet: Object =
export const open = async (
argumentObject: WalletArgumentsType = {},
): Promise => {
/*
* 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)
*/