Skip to content
This repository was archived by the owner on Mar 5, 2025. It is now read-only.

Commit d4f1363

Browse files
committed
Replace hardfork strings with enum
1 parent 7324eec commit d4f1363

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

packages/web3-eth-accounts/src/index.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ var utils = require('web3-utils');
3333
var helpers = require('web3-core-helpers');
3434
var {TransactionFactory} = require('@ethereumjs/tx');
3535
var Common = require('@ethereumjs/common').default;
36-
36+
var HardForks = require('@ethereumjs/common').Hardfork;
3737

3838
var isNot = function(value) {
3939
return (typeof value === 'undefined') || value === null;
@@ -178,7 +178,7 @@ Accounts.prototype.signTransaction = function signTransaction(tx, privateKey, ca
178178
networkId: transaction.networkId,
179179
chainId: transaction.chainId
180180
},
181-
transaction.hardfork || "london"
181+
transaction.hardfork || HardForks.London
182182
);
183183

184184
delete transaction.networkId;
@@ -191,7 +191,7 @@ Accounts.prototype.signTransaction = function signTransaction(tx, privateKey, ca
191191
networkId: transaction.common.customChain.networkId,
192192
chainId: transaction.common.customChain.chainId
193193
},
194-
transaction.common.hardfork || "london",
194+
transaction.common.hardfork || HardForks.London,
195195
);
196196

197197
delete transaction.common;
@@ -333,16 +333,16 @@ function _handleTxType(tx) {
333333
if (
334334
hasEip1559 ||
335335
(
336-
(tx.common && tx.common.hardfork && tx.common.hardfork.toLowerCase() === 'london') ||
337-
(tx.hardfork && tx.hardfork.toLowerCase() === 'london')
336+
(tx.common && tx.common.hardfork && tx.common.hardfork.toLowerCase() === HardForks.London) ||
337+
(tx.hardfork && tx.hardfork.toLowerCase() === HardForks.London)
338338
)
339339
) {
340340
txType = '0x2';
341341
} else if (
342342
tx.accessList ||
343343
(
344-
(tx.common && tx.common.hardfork && tx.common.hardfork.toLowerCase() === 'berlin') ||
345-
(tx.hardfork && tx.hardfork.toLowerCase() === 'berlin')
344+
(tx.common && tx.common.hardfork && tx.common.hardfork.toLowerCase() === HardForks.Berlin) ||
345+
(tx.hardfork && tx.hardfork.toLowerCase() === HardForks.Berlin)
346346
)
347347
) {
348348
txType = '0x1';

0 commit comments

Comments
 (0)