models.ts


Overview

The [models.ts](/projects/291/69105) file defines TypeScript interfaces related to gas estimations and fee recommendations for blockchain transactions involving both Layer 1 (L1) and Layer 2 (L2) networks. Specifically, it extends base types imported from an external EVM (Ethereum Virtual Machine) API module to include additional properties pertinent to Layer 1 gas metrics. This enables the application to handle and represent combined gas data spanning both layers, which is crucial for accurate transaction cost calculations and fee recommendations in multi-layer blockchain environments.


Interfaces

BaseGasEstimate

export interface BaseGasEstimate extends GasEstimate {
  l1GasLimit: string
}

Description

`BaseGasEstimate` extends the `GasEstimate` interface imported from an external EVM API module. It adds the `l1GasLimit` property to provide information about the estimated gas limit specifically for Layer 1 transactions, complementing the existing gas estimation data.

Properties

Property

Type

Description

*Inherited*

All properties from `GasEstimate` (e.g., `gasLimit`, `gasUsed`, etc.)

`l1GasLimit`

`string`

The estimated gas limit for the Layer 1 transaction. Represents the maximum amount of gas the L1 transaction is expected to consume.

Usage Example

const estimate: BaseGasEstimate = {
  gasLimit: "21000",       // from GasEstimate
  gasUsed: "20000",
  l1GasLimit: "15000"      // additional L1 gas limit
};

BaseGasFees

export interface BaseGasFees extends GasFees {
  l1GasPrice: string
}

Description

`BaseGasFees` extends the `GasFees` interface imported from the EVM API module. It adds an `l1GasPrice` property to indicate the current recommended gas price for Layer 1 transactions. This allows fee calculations to consider both L2 and L1 gas prices, which is important in contexts where the cost of executing on L1 must be factored into overall transaction fees.

Properties

Property

Type

Description

*Inherited*

All properties from `GasFees` (e.g., `maxFeePerGas`, `maxPriorityFeePerGas`, etc.)

`l1GasPrice`

`string`

The recommended gas price for Layer 1 transactions, typically expressed in wei or gwei.

Usage Example

const fees: BaseGasFees = {
  maxFeePerGas: "1000000000",     // from GasFees
  maxPriorityFeePerGas: "200000000",
  l1GasPrice: "500000000"          // additional L1 gas price
};

Implementation Details


Interaction with Other System Components


Mermaid Class Diagram

classDiagram
    class GasEstimate {
        <<interface>>
        +gasLimit: string
        +gasUsed: string
        +... (other EVM gas properties)
    }
    class BaseGasEstimate {
        +l1GasLimit: string
    }
    BaseGasEstimate --|> GasEstimate

    class GasFees {
        <<interface>>
        +maxFeePerGas: string
        +maxPriorityFeePerGas: string
        +... (other EVM fee properties)
    }
    class BaseGasFees {
        +l1GasPrice: string
    }
    BaseGasFees --|> GasFees

Summary

The [models.ts](/projects/291/69105) file provides enhanced gas estimation and fee interfaces tailored for multi-layer blockchain environments by extending base EVM types with Layer 1-specific gas data. This modular approach simplifies handling cross-layer transaction cost details and integrates smoothly with broader transaction processing and fee recommendation services in the system.