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