Skip to content

Commit

Permalink
Add newPayload4 and getPayload4 convenience API (#142)
Browse files Browse the repository at this point in the history
  • Loading branch information
jangko authored Mar 28, 2024
1 parent e049d14 commit 9e37047
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions web3/engine_api.nim
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ createRpcSigsFromNim(RpcClient):
proc engine_newPayloadV3(payload: ExecutionPayload,
expectedBlobVersionedHashes: Option[seq[VersionedHash]],
parentBeaconBlockRoot: Option[FixedBytes[32]]): PayloadStatusV1
proc engine_newPayloadV4(payload: ExecutionPayload,
expectedBlobVersionedHashes: Option[seq[VersionedHash]],
parentBeaconBlockRoot: Option[FixedBytes[32]]): PayloadStatusV1
proc engine_forkchoiceUpdatedV2(forkchoiceState: ForkchoiceStateV1, payloadAttributes: Option[PayloadAttributes]): ForkchoiceUpdatedResponse
proc engine_forkchoiceUpdatedV3(forkchoiceState: ForkchoiceStateV1, payloadAttributes: Option[PayloadAttributes]): ForkchoiceUpdatedResponse

Expand Down Expand Up @@ -96,6 +99,12 @@ template getPayload*(
payloadId: PayloadID): Future[GetPayloadV3Response] =
engine_getPayloadV3(rpcClient, payloadId)

template getPayload*(
rpcClient: RpcClient,
T: type GetPayloadV4Response,
payloadId: PayloadID): Future[GetPayloadV4Response] =
engine_getPayloadV4(rpcClient, payloadId)

template newPayload*(
rpcClient: RpcClient,
payload: ExecutionPayloadV1): Future[PayloadStatusV1] =
Expand All @@ -114,6 +123,14 @@ template newPayload*(
engine_newPayloadV3(
rpcClient, payload, versionedHashes, parentBeaconBlockRoot)

template newPayload*(
rpcClient: RpcClient,
payload: ExecutionPayloadV4,
versionedHashes: seq[VersionedHash],
parentBeaconBlockRoot: FixedBytes[32]): Future[PayloadStatusV1] =
engine_newPayloadV4(
rpcClient, payload, versionedHashes, parentBeaconBlockRoot)

template exchangeCapabilities*(
rpcClient: RpcClient,
methods: seq[string]): Future[seq[string]] =
Expand Down

0 comments on commit 9e37047

Please sign in to comment.