optionally generateMnemonic during HDNode creation; Fix a bug with setSigner

pull/84/head
Aaron Li 4 years ago
parent 99a827782f
commit f29f2586dd
  1. 7
      packages/harmony-account/src/hdnode.ts

@ -85,6 +85,7 @@ export class HDNode {
chainId: ChainID = ChainID.Default,
gasLimit = '1000000',
gasPrice = '2000000000',
generateMnemonic?: boolean,
) {
this.provider = this.setProvider(provider);
this.shardID = shardID;
@ -96,7 +97,9 @@ export class HDNode {
this.path = chainType === ChainType.Harmony ? HDPath : `m/44'/60'/0'/0/`;
this.index = index;
this.addressCount = addressCount;
this.getHdWallet(menmonic || HDNode.generateMnemonic());
if (generateMnemonic) {
this.getHdWallet(menmonic || HDNode.generateMnemonic());
}
this.gasLimit = gasLimit;
this.gasPrice = gasPrice;
}
@ -258,7 +261,7 @@ export class HDNode {
setSigner(address: string) {
const foundIndex = this.addresses.findIndex((value) => value === address);
this.addresses.slice(foundIndex, foundIndex + 1);
this.addresses.splice(foundIndex, 1);
this.addresses.unshift(address);
}
}

Loading…
Cancel
Save