From d4f1363c180234f07cddccd02c860026f6c4d47b Mon Sep 17 00:00:00 2001 From: Wyatt Barnes Date: Tue, 20 Jul 2021 14:40:17 -1000 Subject: [PATCH] Replace hardfork strings with enum --- packages/web3-eth-accounts/src/index.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/web3-eth-accounts/src/index.js b/packages/web3-eth-accounts/src/index.js index 285d31c7cce..59645aa2517 100644 --- a/packages/web3-eth-accounts/src/index.js +++ b/packages/web3-eth-accounts/src/index.js @@ -33,7 +33,7 @@ var utils = require('web3-utils'); var helpers = require('web3-core-helpers'); var {TransactionFactory} = require('@ethereumjs/tx'); var Common = require('@ethereumjs/common').default; - +var HardForks = require('@ethereumjs/common').Hardfork; var isNot = function(value) { return (typeof value === 'undefined') || value === null; @@ -178,7 +178,7 @@ Accounts.prototype.signTransaction = function signTransaction(tx, privateKey, ca networkId: transaction.networkId, chainId: transaction.chainId }, - transaction.hardfork || "london" + transaction.hardfork || HardForks.London ); delete transaction.networkId; @@ -191,7 +191,7 @@ Accounts.prototype.signTransaction = function signTransaction(tx, privateKey, ca networkId: transaction.common.customChain.networkId, chainId: transaction.common.customChain.chainId }, - transaction.common.hardfork || "london", + transaction.common.hardfork || HardForks.London, ); delete transaction.common; @@ -333,16 +333,16 @@ function _handleTxType(tx) { if ( hasEip1559 || ( - (tx.common && tx.common.hardfork && tx.common.hardfork.toLowerCase() === 'london') || - (tx.hardfork && tx.hardfork.toLowerCase() === 'london') + (tx.common && tx.common.hardfork && tx.common.hardfork.toLowerCase() === HardForks.London) || + (tx.hardfork && tx.hardfork.toLowerCase() === HardForks.London) ) ) { txType = '0x2'; } else if ( tx.accessList || ( - (tx.common && tx.common.hardfork && tx.common.hardfork.toLowerCase() === 'berlin') || - (tx.hardfork && tx.hardfork.toLowerCase() === 'berlin') + (tx.common && tx.common.hardfork && tx.common.hardfork.toLowerCase() === HardForks.Berlin) || + (tx.hardfork && tx.hardfork.toLowerCase() === HardForks.Berlin) ) ) { txType = '0x1';