From 01fcea702e32e1f97a0aa351b6623d94dc0fbcea Mon Sep 17 00:00:00 2001 From: Nico Flaig Date: Wed, 30 Oct 2024 10:36:41 +0000 Subject: [PATCH] Use ssz type to handle json serialization Default parsing can't handle BigInt --- packages/api/src/keymanager/routes.ts | 37 +++++++++++++++++---------- 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/packages/api/src/keymanager/routes.ts b/packages/api/src/keymanager/routes.ts index f91beccce80..4d04049f9bd 100644 --- a/packages/api/src/keymanager/routes.ts +++ b/packages/api/src/keymanager/routes.ts @@ -1,7 +1,8 @@ import {ContainerType, ValueOf} from "@chainsafe/ssz"; import {ChainForkConfig} from "@lodestar/config"; import {Epoch, phase0, ssz, stringType} from "@lodestar/types"; -import {Schema, Endpoint, RouteDefinitions} from "../utils/index.js"; +import {RecursivePartial} from "@lodestar/utils"; +import {Schema, Endpoint, RouteDefinitions, ResponseDataCodec} from "../utils/index.js"; import {WireFormat} from "../utils/wireFormat.js"; import { EmptyArgs, @@ -90,11 +91,28 @@ export const BuilderBoostFactorDataType = new ContainerType( }, {jsonCase: "eth2"} ); +export const ProposerConfigType = new ContainerType( + { + graffiti: stringType, + strictFeeRecipientCheck: ssz.Boolean, + feeRecipient: stringType, + builder: new ContainerType( + { + gasLimit: ssz.UintNum64, + selection: stringType, + boostFactor: ssz.UintBn64, + }, + {jsonCase: "eth2"} + ), + }, + {jsonCase: "eth2"} +); export type FeeRecipientData = ValueOf; export type GraffitiData = ValueOf; export type GasLimitData = ValueOf; export type BuilderBoostFactorData = ValueOf; +export type ProposerConfig = RecursivePartial>; export type SignerDefinition = { pubkey: PubkeyHex; @@ -109,17 +127,6 @@ export type SignerDefinition = { export type RemoteSignerDefinition = Pick; -export type ProposerConfig = { - graffiti?: string; - strictFeeRecipientCheck?: boolean; - feeRecipient?: string; - builder?: { - gasLimit?: number; - selection?: string; - boostFactor?: bigint; - }; -}; - /** * JSON serialized representation of a single keystore in EIP-2335: BLS12-381 Keystore format. * ``` @@ -665,7 +672,11 @@ export function getDefinitions(_config: ChainForkConfig): RouteDefinitions, + meta: EmptyMetaCodec, + }, }, signVoluntaryExit: {