|
|
@ -58,6 +58,8 @@ export class HDNode { |
|
|
|
private addressCount: number; |
|
|
|
private addressCount: number; |
|
|
|
private addresses: string[]; |
|
|
|
private addresses: string[]; |
|
|
|
private wallets: WalletsInterfaces; |
|
|
|
private wallets: WalletsInterfaces; |
|
|
|
|
|
|
|
private gasLimit: string; |
|
|
|
|
|
|
|
private gasPrice: string; |
|
|
|
|
|
|
|
|
|
|
|
constructor( |
|
|
|
constructor( |
|
|
|
provider: string | HttpProvider | WSProvider = 'http://localhost:9500', |
|
|
|
provider: string | HttpProvider | WSProvider = 'http://localhost:9500', |
|
|
@ -66,6 +68,8 @@ export class HDNode { |
|
|
|
addressCount: number = 1, |
|
|
|
addressCount: number = 1, |
|
|
|
chainType: ChainType = ChainType.Harmony, |
|
|
|
chainType: ChainType = ChainType.Harmony, |
|
|
|
chainId: ChainID = ChainID.Default, |
|
|
|
chainId: ChainID = ChainID.Default, |
|
|
|
|
|
|
|
gasLimit = '1000000', |
|
|
|
|
|
|
|
gasPrice = '2000000000', |
|
|
|
) { |
|
|
|
) { |
|
|
|
this.provider = this.setProvider(provider); |
|
|
|
this.provider = this.setProvider(provider); |
|
|
|
this.messenger = new Messenger(this.provider, chainType, chainId); |
|
|
|
this.messenger = new Messenger(this.provider, chainType, chainId); |
|
|
@ -76,6 +80,8 @@ export class HDNode { |
|
|
|
this.index = index; |
|
|
|
this.index = index; |
|
|
|
this.addressCount = addressCount; |
|
|
|
this.addressCount = addressCount; |
|
|
|
this.getHdWallet(menmonic || HDNode.generateMnemonic()); |
|
|
|
this.getHdWallet(menmonic || HDNode.generateMnemonic()); |
|
|
|
|
|
|
|
this.gasLimit = gasLimit; |
|
|
|
|
|
|
|
this.gasPrice = gasPrice; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
normalizePrivateKeys(mnemonic: string | string[]) { |
|
|
|
normalizePrivateKeys(mnemonic: string | string[]) { |
|
|
@ -155,16 +161,31 @@ export class HDNode { |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
const to: string = txParams.to ? getAddress(txParams.to).checksum : '0x'; |
|
|
|
const to: string = txParams.to ? getAddress(txParams.to).checksum : '0x'; |
|
|
|
const gasLimit = |
|
|
|
|
|
|
|
txParams.gas !== undefined && isHex(txParams.gas) |
|
|
|
let gasLimit = new Unit('0').asWei().toWei(); |
|
|
|
? // ? new Unit(hexToNumber(txParams.gas)).asWei().toWei()
|
|
|
|
|
|
|
|
new Unit('1000000').asWei().toWei() |
|
|
|
if (txParams.gas !== undefined && isHex(txParams.gas)) { |
|
|
|
: new Unit('0').asWei().toWei(); |
|
|
|
gasLimit = new BN(hexToNumber(txParams.gas)).lt(new BN(this.gasLimit)) |
|
|
|
const gasPrice = |
|
|
|
? new Unit(hexToNumber(txParams.gas)).asWei().toWei() |
|
|
|
txParams.gasPrice !== undefined && isHex(txParams.gasPrice) |
|
|
|
: new Unit(this.gasLimit).asWei().toWei(); |
|
|
|
? // ? new Unit(txParams.gasPrice).asWei().toWei()
|
|
|
|
} |
|
|
|
new Unit('2').asGwei().toWei() |
|
|
|
if (txParams.gasLimit !== undefined && isHex(txParams.gasLimit)) { |
|
|
|
: new Unit('0').asWei().toWei(); |
|
|
|
gasLimit = new BN(hexToNumber(txParams.gasLimit)).lt( |
|
|
|
|
|
|
|
new BN(this.gasLimit), |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
? new Unit(hexToNumber(txParams.gasLimit)).asWei().toWei() |
|
|
|
|
|
|
|
: new Unit(this.gasLimit).asWei().toWei(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let gasPrice = new Unit('0').asWei().toWei(); |
|
|
|
|
|
|
|
if (txParams.gasPrice !== undefined && isHex(txParams.gasPrice)) { |
|
|
|
|
|
|
|
gasPrice = new BN(hexToNumber(txParams.gasPrice)).lt( |
|
|
|
|
|
|
|
new BN(this.gasPrice), |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
? new Unit(hexToNumber(txParams.gasPrice)).asWei().toWei() |
|
|
|
|
|
|
|
: new Unit(this.gasPrice).asWei().toWei(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const value = |
|
|
|
const value = |
|
|
|
txParams.value !== undefined && isHex(txParams.value) |
|
|
|
txParams.value !== undefined && isHex(txParams.value) |
|
|
|
? txParams.value |
|
|
|
? txParams.value |
|
|
|