Skip to content

Commit 54fa1f9

Browse files
committed
tx: moved isSigned() method to BaseTransaction
1 parent d3d1a17 commit 54fa1f9

File tree

5 files changed

+23
-25
lines changed

5 files changed

+23
-25
lines changed

packages/tx/src/baseTransaction.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,10 @@ export abstract class BaseTransaction<TransactionObject> {
148148

149149
abstract getMessageToVerifySignature(): Buffer
150150

151-
abstract isSigned(): boolean
151+
public isSigned(): boolean {
152+
const { v, r, s } = this
153+
return !!v && !!r && !!s
154+
}
152155

153156
/**
154157
* Determines if the signature is valid

packages/tx/src/eip2930Transaction.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -285,11 +285,6 @@ export default class AccessListEIP2930Transaction extends BaseTransaction<Access
285285
return this.getMessageToSign()
286286
}
287287

288-
public isSigned(): boolean {
289-
const { yParity, r, s } = this
290-
return yParity !== undefined && !!r && !!s
291-
}
292-
293288
public getSenderPublicKey(): Buffer {
294289
if (!this.isSigned()) {
295290
throw new Error('Cannot call this method if transaction is not signed')

packages/tx/src/legacyTransaction.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ const N_DIV_2 = new BN('7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46
2222
* An Ethereum transaction.
2323
*/
2424
export default class Transaction extends BaseTransaction<Transaction> {
25-
2625
get transactionType(): number {
2726
return 0
2827
}
@@ -171,11 +170,6 @@ export default class Transaction extends BaseTransaction<Transaction> {
171170
return this._getMessageToSign(withEIP155)
172171
}
173172

174-
public isSigned(): boolean {
175-
const { v, r, s } = this
176-
return !!v && !!r && !!s
177-
}
178-
179173
/**
180174
* Returns the public key of the sender
181175
*/

packages/tx/src/transactionFactory.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,20 @@ export default class TransactionFactory {
1515
* @param txData - The transaction data. The `type` field will determine which transaction type is returned (if undefined, create a Transaction)
1616
* @param txOptions - Options to pass on to the constructor of the transaction
1717
*/
18-
public static fromTxData(txData: TxData | AccessListEIP2930TxData, txOptions: TxOptions = {}): TypedTransaction {
18+
public static fromTxData(
19+
txData: TxData | AccessListEIP2930TxData,
20+
txOptions: TxOptions = {}
21+
): TypedTransaction {
1922
const common = txOptions.common ?? DEFAULT_COMMON
2023
if (!('type' in txData) || txData.type === undefined) {
2124
// Assume Transaction
2225
return Transaction.fromTxData(<TxData>txData, txOptions)
2326
} else {
2427
const txType = new BN(txData.type).toNumber()
25-
return TransactionFactory.getTransactionClass(txType, common).fromTxData(<AccessListEIP2930TxData>txData, txOptions)
28+
return TransactionFactory.getTransactionClass(txType, common).fromTxData(
29+
<AccessListEIP2930TxData>txData,
30+
txOptions
31+
)
2632
}
2733
}
2834

packages/tx/src/types.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -94,17 +94,17 @@ export type TxData = {
9494
/**
9595
* EC recovery ID.
9696
*/
97-
v?: BNLike
98-
99-
/**
100-
* EC signature parameter.
101-
*/
102-
r?: BNLike
103-
104-
/**
105-
* EC signature parameter.
106-
*/
107-
s?: BNLike
97+
v?: BNLike
98+
99+
/**
100+
* EC signature parameter.
101+
*/
102+
r?: BNLike
103+
104+
/**
105+
* EC signature parameter.
106+
*/
107+
s?: BNLike
108108
}
109109

110110
/**

0 commit comments

Comments
 (0)