diff --git a/web3/builder_api.nim b/web3/builder_api.nim new file mode 100644 index 0000000..91b563a --- /dev/null +++ b/web3/builder_api.nim @@ -0,0 +1,14 @@ +import + strutils, + json_serialization/std/[sets, net], serialization/errors, + json_rpc/[client, jsonmarshal], + conversions, builder_api_types, engine_api_types + +export + builder_api_types, conversions + +from os import DirSep, AltSep +template sourceDir: string = currentSourcePath.rsplit({DirSep, AltSep}, 1)[0] + +createRpcSigs(RpcClient, sourceDir & "/builder_api_callsigs.nim") + diff --git a/web3/builder_api_callsigs.nim b/web3/builder_api_callsigs.nim new file mode 100644 index 0000000..c05167f --- /dev/null +++ b/web3/builder_api_callsigs.nim @@ -0,0 +1,6 @@ +# https://github.com/flashbots/mev-boost/blob/thegostep/docs/docs/milestone-1.md#api-docs + +import ethtypes, builder_api_types, engine_api_types + +proc builder_getPayloadHeaderV1(payloadId: PayloadID): ExecutionPayloadHeaderV1 +proc builder_proposeBlindedBlockV1(blck: SignedBlindedBeaconBlock): ExecutionPayloadV1 diff --git a/web3/builder_api_types.nim b/web3/builder_api_types.nim new file mode 100644 index 0000000..1be133f --- /dev/null +++ b/web3/builder_api_types.nim @@ -0,0 +1,47 @@ +import + ethtypes + +export + ethtypes + +type + # https://github.com/ethereum/consensus-specs/blob/v1.1.9/specs/bellatrix/beacon-chain.md#executionpayloadheader + ExecutionPayloadHeaderV1* = object + parent_hash*: FixedBytes[32] + fee_recipient*: Address + state_root*: FixedBytes[32] + receipts_root*: FixedBytes[32] + logs_bloom*: FixedBytes[256] + random*: FixedBytes[32] + block_number*: Quantity + gas_limit*: Quantity + gas_used*: Quantity + timestamp*: Quantity + extra_data*: string # List[byte, MAX_EXTRA_DATA_BYTES] + base_fee_per_gas*: FixedBytes[32] # base fee introduced in EIP-1559, little-endian serialized + + # https://github.com/flashbots/mev-boost/blob/thegostep/docs/docs/milestone-1.md#blindedbeaconblockbody + BlindedBeaconBlockBody* = object + randao_reveal*: FixedBytes[96] + eth1_data*: string # Eth1Data + graffiti*: FixedBytes[32] + proposer_slashings*: string # List[ProposerSlashing, MAX_PROPOSER_SLASHINGS] + attester_slashings*: string # List[AttesterSlashing, MAX_ATTESTER_SLASHINGS] + attestations*: string # List[Attestation, MAX_ATTESTATIONS] + voluntary_exits*: string # List[SignedVoluntaryExit, MAX_VOLUNTARY_EXITS] + sync_aggregate*: string # SyncAggregate + execution_payload_header*: ExecutionPayloadHeaderV1 + + # https://github.com/flashbots/mev-boost/blob/thegostep/docs/docs/milestone-1.md#blindedbeaconblock + BlindedBeaconBlock* = object + slot*: Quantity + proposer_index*: Quantity + parent_root*: FixedBytes[32] + state_root*: FixedBytes[32] + body*: BlindedBeaconBlockBody + + # https://github.com/flashbots/mev-boost/blob/thegostep/docs/docs/milestone-1.md#signedblindedbeaconblock + SignedBlindedBeaconBlock* = object + message*: BlindedBeaconBlock + signature*: FixedBytes[96] +