Skip to content

Commit

Permalink
Type check refactors for _handleTxPricing
Browse files Browse the repository at this point in the history
  • Loading branch information
spacesailor24 committed Jul 21, 2021
1 parent d4f1363 commit f2ca0d8
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions packages/web3-eth-accounts/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -354,24 +354,17 @@ function _handleTxType(tx) {
function _handleTxPricing(_this, tx) {
return new Promise((resolve, reject) => {
try {
if (
(
tx.type === undefined ||
tx.type === '0x0' ||
tx.type === '0x1'
) && tx.gasPrice !== undefined)
{
// Legacy transaction, return provided gasPrice
resolve({ gasPrice: tx.gasPrice })
if (tx.type < '0x2' && tx.gasPrice !== undefined) {
// gasPrice already set, return
resolve()
} else {
Promise.all([
_this._ethereumCall.getBlockByNumber(),
_this._ethereumCall.getGasPrice()
]).then(responses => {
const [block, gasPrice] = responses;
if (
(tx.type !== '0x0' &&
tx.type !== '0x1') &&
(tx.type === '0x2') &&
block && block.baseFeePerGas
) {
// The network supports EIP-1559
Expand Down

0 comments on commit f2ca0d8

Please sign in to comment.