Skip to content

Commit 590edcb

Browse files
committed
for clarity, rename _validateExceedsMaxInteger(validateCannotExceedMaxInteger) to _validateCannotExceedMaxInteger(values)
1 parent 77dc55a commit 590edcb

File tree

2 files changed

+6
-17
lines changed

2 files changed

+6
-17
lines changed

packages/tx/src/baseTransaction.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,12 @@ export abstract class BaseTransaction<TransactionObject> {
3737
this.r = r ? new BN(toBuffer(r)) : undefined
3838
this.s = s ? new BN(toBuffer(s)) : undefined
3939

40-
const validateCannotExceedMaxInteger = {
40+
this._validateCannotExceedMaxInteger({
4141
nonce: this.nonce,
4242
gasPrice: this.gasPrice,
4343
gasLimit: this.gasLimit,
4444
value: this.value,
45-
}
46-
47-
this._validateExceedsMaxInteger(validateCannotExceedMaxInteger)
45+
})
4846

4947
this.common = txOptions.common?.copy() ?? new Common({ chain: 'mainnet' })
5048
}
@@ -192,9 +190,9 @@ export abstract class BaseTransaction<TransactionObject> {
192190
// Accept the v,r,s values from the `sign` method, and convert this into a TransactionObject
193191
protected abstract _processSignature(v: number, r: Buffer, s: Buffer): TransactionObject
194192

195-
protected _validateExceedsMaxInteger(validateCannotExceedMaxInteger: { [key: string]: BN }) {
196-
for (const [key, value] of Object.entries(validateCannotExceedMaxInteger)) {
197-
if (value && value.gt(MAX_INTEGER)) {
193+
protected _validateCannotExceedMaxInteger(values: { [key: string]: BN | undefined }) {
194+
for (const [key, value] of Object.entries(values)) {
195+
if (value?.gt(MAX_INTEGER)) {
198196
throw new Error(`${key} cannot exceed MAX_INTEGER, given ${value}`)
199197
}
200198
}

packages/tx/src/legacyTransaction.ts

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -96,16 +96,7 @@ export default class Transaction extends BaseTransaction<Transaction> {
9696
public constructor(txData: TxData, opts: TxOptions = {}) {
9797
super(txData, opts)
9898

99-
const validateCannotExceedMaxInteger = {
100-
r: this.r ?? new BN(0),
101-
s: this.s ?? new BN(0),
102-
}
103-
104-
this._validateExceedsMaxInteger(validateCannotExceedMaxInteger)
105-
106-
if (this.v) {
107-
this._validateTxV(this.v)
108-
}
99+
this._validateCannotExceedMaxInteger({ r: this.r, s: this.s })
109100

110101
this._validateTxV(this.v)
111102

0 commit comments

Comments
 (0)