Skip to content

Commit

Permalink
NDEV-3424 rpc: allow 'data' and 'input' properties in eth_estimateGas
Browse files Browse the repository at this point in the history
  • Loading branch information
afalaleev committed Nov 26, 2024
1 parent f9c2865 commit 2650b23
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions proxy/base/rpc_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from common.neon.transaction_meta_model import NeonTxMetaModel
from common.neon.transaction_model import NeonTxModel, NeonTxType
from common.neon_rpc.api import CoreApiTxModel
from common.utils.cached import cached_property
from common.utils.pydantic import HexUIntField


Expand All @@ -36,10 +37,9 @@ class RpcEthTxRequest(BaseJsonRpcModel):
default=EthAddress.default(),
validation_alias=AliasChoices("to", "toAddress"),
)
data: EthBinStrField = Field(
default=EthBinStr.default(),
validation_alias=AliasChoices("data", "input"),
)
data_v1: EthBinStrField = Field(default=EthBinStr.default(), validation_alias="data")
data_v2: EthBinStrField = Field(default=EthBinStr.default(), validation_alias="input")

value: HexUIntField = Field(default=0)
nonce: HexUIntField | None = Field(default=None)

Expand All @@ -58,13 +58,16 @@ def model_post_init(self, _ctx: Any) -> None:
if self.maxPriorityFeePerGas > self.maxFeePerGas:
raise ValueError("maxPriorityFeePerGas should be not greater than maxFeePerGas")

@cached_property
def data(self) -> EthBinStr:
return self.data_v2 if not self.data_v2.is_empty else self.data_v1

@classmethod
def default(cls) -> Self:
if not cls._default:
cls._default = cls(
fromAddress=EthAddress.default(),
toAddress=EthAddress.default(),
data=EthBinStr.default(),
)
return cls._default

Expand Down

0 comments on commit 2650b23

Please sign in to comment.