Fix simulator RPC object: add fields from latest spec (#2859)
This commit is contained in:
parent
a57a887269
commit
c525590a51
|
@ -269,12 +269,17 @@ proc toBlockHeader*(bc: BlockObject): Header =
|
|||
blobGasUsed : maybeU64(bc.blobGasUsed),
|
||||
excessBlobGas : maybeU64(bc.excessBlobGas),
|
||||
parentBeaconBlockRoot: bc.parentBeaconBlockRoot,
|
||||
requestsHash : bc.requestsHash,
|
||||
)
|
||||
|
||||
func vHashes(x: Opt[seq[Hash32]]): seq[VersionedHash] =
|
||||
if x.isNone: return
|
||||
else: x.get
|
||||
|
||||
func authList(x: Opt[seq[AuthorizationObject]]): seq[Authorization] =
|
||||
if x.isNone: return
|
||||
else: ethAuthList x.get
|
||||
|
||||
proc toTransaction(tx: TransactionObject): Transaction =
|
||||
Transaction(
|
||||
txType : tx.`type`.get(0.Web3Quantity).TxType,
|
||||
|
@ -293,6 +298,7 @@ proc toTransaction(tx: TransactionObject): Transaction =
|
|||
V : tx.v.uint64,
|
||||
R : tx.r,
|
||||
S : tx.s,
|
||||
authorizationList: authList(tx.authorizationList),
|
||||
)
|
||||
|
||||
proc toTransactions*(txs: openArray[TxOrHash]): seq[Transaction] =
|
||||
|
@ -360,6 +366,7 @@ type
|
|||
accessList*: Opt[seq[AccessPair]]
|
||||
maxFeePerBlobGas*: Opt[UInt256]
|
||||
versionedHashes*: Opt[seq[VersionedHash]]
|
||||
authorizationList*: Opt[seq[Authorization]]
|
||||
|
||||
proc toRPCReceipt(rec: ReceiptObject): RPCReceipt =
|
||||
RPCReceipt(
|
||||
|
@ -408,6 +415,7 @@ proc toRPCTx(tx: eth_api.TransactionObject): RPCTx =
|
|||
Opt.some(vHashes tx.blobVersionedHashes)
|
||||
else:
|
||||
Opt.none(seq[VersionedHash]),
|
||||
authorizationList: ethAuthList(tx.authorizationList),
|
||||
)
|
||||
|
||||
proc waitForTTD*(client: RpcClient,
|
||||
|
|
|
@ -63,17 +63,16 @@ func u256*(x: FixedBytes[32]): UInt256 =
|
|||
func ethTime*(x: Web3Quantity): EthTime =
|
||||
EthTime(x)
|
||||
|
||||
func ethGasInt*(x: Web3Quantity): GasInt =
|
||||
GasInt x
|
||||
|
||||
func ethBlob*(x: Web3ExtraData): seq[byte] =
|
||||
distinctBase x
|
||||
|
||||
func ethWithdrawal*(x: WithdrawalV1): common.Withdrawal =
|
||||
result.index = x.index.uint64
|
||||
result.validatorIndex = x.validatorIndex.uint64
|
||||
result.address = x.address
|
||||
result.amount = x.amount.uint64
|
||||
func ethWithdrawal*(x: WithdrawalV1): Withdrawal =
|
||||
Withdrawal(
|
||||
index: x.index.uint64,
|
||||
validatorIndex: x.validatorIndex.uint64,
|
||||
address: x.address,
|
||||
amount: x.amount.uint64,
|
||||
)
|
||||
|
||||
func ethWithdrawals*(list: openArray[WithdrawalV1]):
|
||||
seq[Withdrawal] =
|
||||
|
@ -95,6 +94,27 @@ func ethTxs*(list: openArray[Web3Tx]):
|
|||
for x in list:
|
||||
result.add ethTx(x)
|
||||
|
||||
func ethAuth*(x: AuthorizationObject): Authorization =
|
||||
Authorization(
|
||||
chainId: ChainId x.chainId,
|
||||
address: x.address,
|
||||
nonce: distinctBase x.nonce,
|
||||
v: distinctBase x.v,
|
||||
r: x.r,
|
||||
s: x.s,
|
||||
)
|
||||
|
||||
func ethAuthList*(list: openArray[AuthorizationObject]):
|
||||
seq[Authorization] =
|
||||
result = newSeqOfCap[Authorization](list.len)
|
||||
for x in list:
|
||||
result.add ethAuth(x)
|
||||
|
||||
func ethAuthList*(x: Opt[seq[AuthorizationObject]]):
|
||||
Opt[seq[Authorization]] =
|
||||
if x.isNone: Opt.none(seq[Authorization])
|
||||
else: Opt.some(ethAuthList x.get)
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# Eth types to Web3 types
|
||||
# ------------------------------------------------------------------------------
|
||||
|
|
|
@ -12,7 +12,6 @@ import
|
|||
std/[
|
||||
options,
|
||||
strutils,
|
||||
times,
|
||||
os,
|
||||
uri,
|
||||
net
|
||||
|
|
Loading…
Reference in New Issue