Skip to content

Commit

Permalink
bugfix/speedup cancel transaction (#249)
Browse files Browse the repository at this point in the history
* ignoredecimals

* radix
  • Loading branch information
estebanmino authored and MajorLift committed Oct 11, 2023
1 parent a92dfa9 commit b417a84
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/transaction/TransactionController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@ export class TransactionController extends BaseController<TransactionConfig, Tra
const existingGasPrice = transactionMeta.transaction.gasPrice;
/* istanbul ignore next */
const existingGasPriceDecimal = parseInt(existingGasPrice === undefined ? '0x0' : existingGasPrice, 16);
const gasPrice = addHexPrefix(`${parseFloat(`${existingGasPriceDecimal * CANCEL_RATE}`).toString(16)}`);
const gasPrice = addHexPrefix(`${parseInt(`${existingGasPriceDecimal * CANCEL_RATE}`, 10).toString(16)}`);

const ethTransaction = new Transaction({
from: transactionMeta.transaction.from,
Expand Down Expand Up @@ -581,7 +581,7 @@ export class TransactionController extends BaseController<TransactionConfig, Tra
const existingGasPrice = transactionMeta.transaction.gasPrice;
/* istanbul ignore next */
const existingGasPriceDecimal = parseInt(existingGasPrice === undefined ? '0x0' : existingGasPrice, 16);
const gasPrice = addHexPrefix(`${parseFloat(`${existingGasPriceDecimal * SPEED_UP_RATE}`).toString(16)}`);
const gasPrice = addHexPrefix(`${parseInt(`${existingGasPriceDecimal * SPEED_UP_RATE}`, 10).toString(16)}`);
const ethTransaction = new Transaction({ ...transactionMeta.transaction, gasPrice });
await this.sign(ethTransaction, transactionMeta.transaction.from);
const rawTransaction = bufferToHex(ethTransaction.serialize());
Expand Down
4 changes: 2 additions & 2 deletions tests/TransactionController.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -775,14 +775,14 @@ describe('TransactionController', () => {
await controller.addTransaction({
from,
gas: '0x0',
gasPrice: '0x1',
gasPrice: '0x50fd51da',
to: from,
value: '0x0'
});
await controller.speedUpTransaction(controller.state.transactions[0].id);

expect(controller.state.transactions.length).toBe(2);
expect(controller.state.transactions[1].transaction.gasPrice).toBe('0x1.199999999999a');
expect(controller.state.transactions[1].transaction.gasPrice).toBe('0x5916a6d6');
resolve();
});
});
Expand Down

0 comments on commit b417a84

Please sign in to comment.