This commit is contained in:
Etan Kissling 2023-10-24 23:08:39 +02:00
parent 6948dc5673
commit efadecfb10
No known key found for this signature in database
GPG Key ID: B21DA824C5A3D03D
1 changed files with 13 additions and 13 deletions

View File

@ -1557,6 +1557,9 @@ proc ETHTransactionsCreateFromJson(
value: UInt256 value: UInt256
input: List[byte, Limit MAX_CALLDATA_SIZE] input: List[byte, Limit MAX_CALLDATA_SIZE]
# EIP-2718
`type`: Opt[uint8]
# EIP-2930 # EIP-2930
access_list: Opt[List[Eip6493AccessTuple, Limit MAX_ACCESS_LIST_SIZE]] access_list: Opt[List[Eip6493AccessTuple, Limit MAX_ACCESS_LIST_SIZE]]
@ -1572,9 +1575,6 @@ proc ETHTransactionsCreateFromJson(
`from`: ExecutionAddress `from`: ExecutionAddress
ecdsa_signature: array[65, byte] ecdsa_signature: array[65, byte]
# EIP-2718
`type`: Opt[uint8]
Eip6493Transaction = object Eip6493Transaction = object
payload: PartialContainer[Eip6493TransactionPayload, 32] payload: PartialContainer[Eip6493TransactionPayload, 32]
signature: PartialContainer[Eip6493TransactionSignature, 16] signature: PartialContainer[Eip6493TransactionSignature, 16]
@ -1591,6 +1591,16 @@ proc ETHTransactionsCreateFromJson(
return nil return nil
eip6493Tx.payload.input = eip6493Tx.payload.input =
List[byte, Limit MAX_CALLDATA_SIZE].init(tx.payload) List[byte, Limit MAX_CALLDATA_SIZE].init(tx.payload)
case tx.txType
of TxLegacy:
if tx.V notin [27'i64, 28'i64]: # With replay protection
`.`(eip6493Tx.payload, `type`).ok(0x00)
of TxEip2930:
`.`(eip6493Tx.payload, `type`).ok(0x01)
of TxEip1559:
`.`(eip6493Tx.payload, `type`).ok(0x02)
of TxEip4844:
`.`(eip6493Tx.payload, `type`).ok(0x03)
if tx.txType >= TxEip2930: if tx.txType >= TxEip2930:
if tx.accessList.len > MAX_ACCESS_LIST_SIZE: if tx.accessList.len > MAX_ACCESS_LIST_SIZE:
return nil return nil
@ -1608,16 +1618,6 @@ proc ETHTransactionsCreateFromJson(
eip6493Tx.signature.`from` = ExecutionAddress(data: fromAddress) eip6493Tx.signature.`from` = ExecutionAddress(data: fromAddress)
eip6493Tx.signature.ecdsa_signature = rawSig eip6493Tx.signature.ecdsa_signature = rawSig
case tx.txType
of TxLegacy:
if tx.V notin [27'i64, 28'i64]: # With replay protection
`.`(eip6493Tx.signature, `type`).ok(0x00)
of TxEip2930:
`.`(eip6493Tx.signature, `type`).ok(0x01)
of TxEip1559:
`.`(eip6493Tx.signature, `type`).ok(0x02)
of TxEip4844:
`.`(eip6493Tx.signature, `type`).ok(0x03)
# Nim 1.6.14: Inlining `SSZ.encode` into constructor may corrupt memory. # Nim 1.6.14: Inlining `SSZ.encode` into constructor may corrupt memory.
let eip6493Bytes = SSZ.encode(eip6493Tx) let eip6493Bytes = SSZ.encode(eip6493Tx)