fix(hdnode):remake signTransaction

staking
neeboo 5 years ago
parent 3ef409379c
commit 7f8b1ba48e
  1. 29
      packages/harmony-account/src/hdnode.ts
  2. 3
      packages/harmony-core/src/truffleProvider.ts

@ -164,21 +164,30 @@ export class HDNode {
let gasLimit = new Unit('0').asWei().toWei();
if (txParams.gas !== undefined && isHex(txParams.gas)) {
gasLimit = new BN(hexToNumber(txParams.gas)).lt(new BN(this.gasLimit))
? txParams.gas
: this.gasLimit;
gasLimit = new Unit(txParams.gas)
.asWei()
.toWei()
.lt(new Unit(this.gasLimit).asWei().toWei())
? new Unit(txParams.gas).asWei().toWei()
: new Unit(this.gasLimit).asWei().toWei();
}
if (txParams.gasLimit !== undefined && isHex(txParams.gasLimit)) {
gasLimit = new BN(hexToNumber(txParams.gasLimit)).lt(new BN(this.gasLimit))
? txParams.gasLimit
: this.gasLimit;
gasLimit = new Unit(txParams.gasLimit)
.asWei()
.toWei()
.lt(new Unit(this.gasLimit).asWei().toWei())
? new Unit(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))
? txParams.gasPrice
: this.gasPrice;
gasPrice = new Unit(txParams.gasPrice)
.asWei()
.toWei()
.lt(new Unit(this.gasPrice).asWei().toWei())
? new Unit(txParams.gasPrice).asWei().toWei()
: new Unit(this.gasPrice).asWei().toWei();
}
const value = txParams.value !== undefined && isHex(txParams.value) ? txParams.value : '0';
@ -198,7 +207,7 @@ export class HDNode {
);
const signed = await signerAccount.signTransaction(tx);
// console.log({ signed: signed.txParams });
return signed.getRawTransaction();
}
getAddress(idx?: number) {

@ -4,6 +4,7 @@ import {
RPCRequestPayload,
ResponseMiddleware,
} from '@harmony-js/network';
import { ChainID, ChainType } from '@harmony-js/utils';
import { HDNode } from '@harmony-js/account';
@ -43,7 +44,7 @@ export class TruffleProvider extends HDNode {
chainType: ChainType.Harmony,
chainId: ChainID.Default,
},
transactionOptions = {
transactionOptions: TransactionOptions = {
gasLimit: '10000000',
gasPrice: '20000000000',
},

Loading…
Cancel
Save