Skip to content

Commit

Permalink
Fix PublicKeysListRoute to only list public keys as identifiers
Browse files Browse the repository at this point in the history
  • Loading branch information
usmansaleem committed Oct 17, 2024
1 parent 9c7a565 commit ad8cadd
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import tech.pegasys.web3signer.signing.ArtifactSigner;
import tech.pegasys.web3signer.signing.ArtifactSignerProvider;
import tech.pegasys.web3signer.signing.EthSecpArtifactSigner;
import tech.pegasys.web3signer.signing.SecpArtifactSignature;
import tech.pegasys.web3signer.signing.bulkloading.SecpAwsBulkLoader;
import tech.pegasys.web3signer.signing.bulkloading.SecpAzureBulkLoader;
import tech.pegasys.web3signer.signing.bulkloading.SecpV3KeystoresBulkLoader;
Expand Down Expand Up @@ -239,10 +238,6 @@ private MappedResults<ArtifactSigner> bulkloadV3Keystores() {
return walletResults;
}

private String formatSecpSignature(final SecpArtifactSignature signature) {
return SecpArtifactSignature.toBytes(signature).toHexString();
}

private void registerSignerLoadingHealthCheck(
final String name, final MappedResults<ArtifactSigner> result) {
super.registerHealthCheckProcedure(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,21 @@

public class PublicKeysListRoute implements Web3SignerRoute {

private static final String PATH_FORMAT = "/api/v1/%s/publicKeys";
private static final String ETH1_PATH = "/api/v1/eth1/publicKeys";
private static final String ETH2_PATH = "/api/v1/eth2/publicKeys";

private final Context context;
private final String path;

public PublicKeysListRoute(final Context context, final String mode) {
this.context = context;
this.path = String.format(PATH_FORMAT, mode);
this.path =
switch (mode) {
case "eth1" -> ETH1_PATH;
case "eth2" -> ETH2_PATH;
default ->
throw new IllegalArgumentException("Unsupported mode for Public Key Route: " + mode);
};
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import static tech.pegasys.web3signer.core.service.http.handlers.ContentTypes.JSON_UTF_8;

import tech.pegasys.web3signer.signing.ArtifactSignerProvider;
import tech.pegasys.web3signer.signing.config.DefaultArtifactSignerProvider;

import java.util.List;
import java.util.stream.Collectors;
Expand All @@ -33,8 +34,11 @@ public PublicKeysListHandler(final List<ArtifactSignerProvider> artifactSignerPr

@Override
public void handle(final RoutingContext context) {
// at the moment, we only support DefaultArtifactSignerProvider subclass that contains primary
// key as identifiers
final List<String> availableIdentifiers =
artifactSignerProviders.stream()
.filter(provider -> provider instanceof DefaultArtifactSignerProvider)
.flatMap(provider -> provider.availableIdentifiers().stream())
.collect(Collectors.toList());

Expand Down

0 comments on commit ad8cadd

Please sign in to comment.