Skip to content

Commit

Permalink
Parse remote key's pubkeys into format expected by validator store. (#…
Browse files Browse the repository at this point in the history
…4405)

Properly parse remote key pubkeys into the format expecting by validator store
  • Loading branch information
dadepo authored Aug 13, 2022
1 parent 551ad74 commit d39e2f9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
8 changes: 6 additions & 2 deletions packages/cli/src/cmds/validator/options.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {defaultOptions} from "@lodestar/validator";
import {ICliCommandOptions, ILogArgs} from "../../util/index.js";
import {ensure0xPrefix, ICliCommandOptions, ILogArgs} from "../../util/index.js";
import {logOptions, beaconPathsOptions} from "../beacon/options.js";
import {IBeaconPaths} from "../beacon/paths.js";
import {keymanagerRestApiServerOptsDefault} from "./keymanager/server.js";
Expand Down Expand Up @@ -210,9 +210,13 @@ export const validatorOptions: ICliCommandOptions<IValidatorCliArgs> = {
description:
"List of validator public keys used by an external signer. May also provide a single string a comma separated public keys",
type: "array",
string: true, // Ensures the pubkey string is not automatically converted to numbers
coerce: (pubkeys: string[]): string[] =>
// Parse ["0x11,0x22"] to ["0x11", "0x22"]
pubkeys.map((item) => item.split(",")).flat(1),
pubkeys
.map((item) => item.split(","))
.flat(1)
.map(ensure0xPrefix),
group: "externalSignerUrl",
},

Expand Down
8 changes: 0 additions & 8 deletions packages/cli/src/util/format.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,6 @@ import {fromHexString} from "@chainsafe/ssz";
/**
* 0x prefix a string if not prefixed already
*/
export function add0xPrefix(hex: string): string {
if (!hex.startsWith("0x")) {
return `0x${hex}`;
} else {
return hex;
}
}

export function ensure0xPrefix(hex: string): string {
if (!hex.startsWith("0x")) hex = `0x${hex}`;
return hex;
Expand Down

0 comments on commit d39e2f9

Please sign in to comment.