@@ -49,6 +49,7 @@ import { Transaction } from './transaction';
4949import { TransferBuilder } from './transferBuilder' ;
5050
5151const DEFAULT_M = 3 ;
52+ const RAW_TX_HEX_REGEX = / ^ ( 0 x ) ? [ 0 - 9 a - f ] { 1 , } $ / ;
5253
5354/**
5455 * EthereumLike transaction builder.
@@ -165,7 +166,7 @@ export abstract class TransactionBuilder extends BaseTransactionBuilder {
165166 /** @inheritdoc */
166167 protected fromImplementation ( rawTransaction : string , isFirstSigner ?: boolean ) : Transaction {
167168 let tx : Transaction ;
168- if ( / ^ 0 x ? [ 0 - 9 a - f ] { 1 , } $ / . test ( rawTransaction . toLowerCase ( ) ) ) {
169+ if ( RAW_TX_HEX_REGEX . test ( rawTransaction . toLowerCase ( ) ) ) {
169170 tx = Transaction . fromSerialized ( this . _coinConfig , this . _common , rawTransaction , isFirstSigner ) ;
170171 this . loadBuilderInput ( tx . toJson ( ) , isFirstSigner ) ;
171172 } else {
@@ -343,7 +344,7 @@ export abstract class TransactionBuilder extends BaseTransactionBuilder {
343344 throw new InvalidTransactionError ( 'Raw transaction is empty' ) ;
344345 }
345346 if ( typeof rawTransaction === 'string' ) {
346- if ( / ^ 0 x ? [ 0 - 9 a - f ] { 1 , } $ / . test ( rawTransaction . toLowerCase ( ) ) ) {
347+ if ( RAW_TX_HEX_REGEX . test ( rawTransaction . toLowerCase ( ) ) ) {
347348 const txBytes = ethUtil . toBuffer ( ethUtil . addHexPrefix ( rawTransaction . toLowerCase ( ) ) ) ;
348349 if ( ! this . isEip1559Txn ( txBytes ) && ! this . isRLPDecodable ( txBytes ) ) {
349350 throw new ParseTransactionError ( 'There was error in decoding the hex string' ) ;
0 commit comments