Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tx capabilities dirty #3803

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/tx/src/1559/tx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import * as EIP1559 from '../capabilities/eip1559.js'
import * as EIP2718 from '../capabilities/eip2718.js'
import * as EIP2930 from '../capabilities/eip2930.js'
import * as Legacy from '../capabilities/legacy.js'
import { getBaseJSON, sharedConstructor, valueBoundaryCheck } from '../features/util.js'
import { getBaseJSON, sharedConstructor, valueBoundaryCheck } from '../capabilities/generic.js'
import { TransactionType } from '../types.js'
import { AccessLists } from '../util.js'

Expand Down
24 changes: 2 additions & 22 deletions packages/tx/src/2930/tx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import {

import * as EIP2718 from '../capabilities/eip2718.js'
import * as EIP2930 from '../capabilities/eip2930.js'
import { getBaseJSON, sharedConstructor, valueBoundaryCheck } from '../capabilities/generic.js'
import * as Legacy from '../capabilities/legacy.js'
import { getBaseJSON, sharedConstructor, valueBoundaryCheck } from '../features/util.js'
import { TransactionType } from '../types.js'
import { AccessLists } from '../util.js'

Expand Down Expand Up @@ -72,7 +72,7 @@ export class AccessList2930Tx implements TransactionInterface<TransactionType.Ac
* e.g. 1559 (fee market) and 2930 (access lists)
* for FeeMarket1559Tx objects
*/
protected activeCapabilities: number[] = []
public activeCapabilities: number[] = []

/**
* This constructor takes the values, validates them, assigns them and freezes the object.
Expand Down Expand Up @@ -123,26 +123,6 @@ export class AccessList2930Tx implements TransactionInterface<TransactionType.Ac
}
}

/**
* Checks if a tx type defining capability is active
* on a tx, for example the EIP-1559 fee market mechanism
* or the EIP-2930 access list feature.
*
* Note that this is different from the tx type itself,
* so EIP-2930 access lists can very well be active
* on an EIP-1559 tx for example.
*
* This method can be useful for feature checks if the
* tx type is unknown (e.g. when instantiated with
* the tx factory).
*
* See `Capabilities` in the `types` module for a reference
* on all supported capabilities.
*/
supports(capability: Capability) {
return this.activeCapabilities.includes(capability)
}

getEffectivePriorityFee(baseFee?: bigint): bigint {
return Legacy.getEffectivePriorityFee(this.gasPrice, baseFee)
}
Expand Down
4 changes: 2 additions & 2 deletions packages/tx/src/4844/tx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ import {
import * as EIP1559 from '../capabilities/eip1559.js'
import * as EIP2718 from '../capabilities/eip2718.js'
import * as EIP2930 from '../capabilities/eip2930.js'
import { getBaseJSON, sharedConstructor, valueBoundaryCheck } from '../capabilities/generic.js'
import * as Legacy from '../capabilities/legacy.js'
import { LIMIT_BLOBS_PER_TX } from '../constants.js'
import { getBaseJSON, sharedConstructor, valueBoundaryCheck } from '../features/util.js'
import { TransactionType } from '../types.js'
import { AccessLists, validateNotArray } from '../util.js'

Expand Down Expand Up @@ -85,7 +85,7 @@ export class Blob4844Tx implements TransactionInterface<TransactionType.BlobEIP4
* e.g. 1559 (fee market) and 2930 (access lists)
* for FeeMarket1559Tx objects
*/
protected activeCapabilities: number[] = []
public activeCapabilities: number[] = []

/**
* This constructor takes the values, validates them, assigns them and freezes the object.
Expand Down
4 changes: 2 additions & 2 deletions packages/tx/src/7702/tx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import {
import * as EIP1559 from '../capabilities/eip1559.js'
import * as EIP2718 from '../capabilities/eip2718.js'
import * as EIP7702 from '../capabilities/eip7702.js'
import { getBaseJSON, sharedConstructor, valueBoundaryCheck } from '../capabilities/generic.js'
import * as Legacy from '../capabilities/legacy.js'
import { getBaseJSON, sharedConstructor, valueBoundaryCheck } from '../features/util.js'
import { TransactionType } from '../types.js'
import { AccessLists, AuthorizationLists, validateNotArray } from '../util.js'

Expand Down Expand Up @@ -79,7 +79,7 @@ export class EOACode7702Tx implements TransactionInterface<TransactionType.EOACo
* e.g. 1559 (fee market) and 2930 (access lists)
* for FeeMarket1559Tx objects
*/
protected activeCapabilities: number[] = []
public activeCapabilities: number[] = []

/**
* This constructor takes the values, validates them, assigns them and freezes the object.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
import { paramsTx } from '../params.js'
import { checkMaxInitCodeSize, validateNotArray } from '../util.js'

import type { TransactionInterface, TransactionType, TxData, TxOptions } from '../types.js'
import type { L1TxInterface, TransactionType, TxData, TxOptions } from '../types.js'

export function getCommon(common?: Common): Common {
return common?.copy() ?? new Common({ chain: Mainnet })
Expand Down Expand Up @@ -70,7 +70,7 @@ type Mutable<T> = {
// represents the constructor of baseTransaction
// Note: have to use `Mutable` to write to readonly props. Only call this in constructor of txs.
export function sharedConstructor(
tx: Mutable<TransactionInterface>,
tx: Mutable<L1TxInterface>,
txData: TxData[TransactionType],
opts: TxOptions = {},
) {
Expand Down Expand Up @@ -122,7 +122,7 @@ export function sharedConstructor(
}
}

export function getBaseJSON(tx: TransactionInterface) {
export function getBaseJSON(tx: L1TxInterface) {
return {
type: bigIntToHex(BigInt(tx.type)),
nonce: bigIntToHex(tx.nonce),
Expand Down
Loading
Loading