Skip to content

Commit

Permalink
chore: clean code and change endpoint to unpack with a different message
Browse files Browse the repository at this point in the history
  • Loading branch information
martinsaporiti committed May 28, 2024
1 parent 4b3737d commit 06866af
Show file tree
Hide file tree
Showing 8 changed files with 8 additions and 1,300 deletions.
17 changes: 1 addition & 16 deletions cmd/platform/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import (
"github.com/polygonid/sh-id-platform/internal/providers/blockchain"
"github.com/polygonid/sh-id-platform/internal/redis"
"github.com/polygonid/sh-id-platform/internal/repositories"
"github.com/polygonid/sh-id-platform/pkg/blockchain/eth"
"github.com/polygonid/sh-id-platform/pkg/cache"
"github.com/polygonid/sh-id-platform/pkg/credentials/revocation_status"
circuitLoaders "github.com/polygonid/sh-id-platform/pkg/loaders"
Expand Down Expand Up @@ -147,20 +146,6 @@ func main() {
claimsService := services.NewClaim(claimsRepository, identityService, qrService, mtService, identityStateRepository, schemaLoader, storage, cfg.ServerUrl, ps, cfg.IPFS.GatewayURL, revocationStatusResolver)
proofService := gateways.NewProver(ctx, cfg, circuitsLoaderService)

stateService, err := eth.NewStateService(eth.StateServiceConfig{
EthClient: ethConn,
StateAddress: common.HexToAddress(cfg.Ethereum.ContractAddress),
ResponseTimeout: cfg.Ethereum.RPCResponseTimeout,
})
if err != nil {
log.Error(ctx, "failed init state service", "err", err)
return
}

onChainCredentialStatusResolverService := gateways.NewOnChainCredStatusResolverService(ethConn, cfg.Ethereum.RPCResponseTimeout)
revocationService := services.NewRevocationService(common.HexToAddress(cfg.Ethereum.ContractAddress), stateService, onChainCredentialStatusResolverService)

zkProofService := services.NewProofService(claimsService, revocationService, identityService, mtService, claimsRepository, keyStore, storage, stateService, schemaLoader)
transactionService, err := gateways.NewTransaction(ethereumClient, cfg.Ethereum.ConfirmationBlockCount)
if err != nil {
log.Error(ctx, "error creating transaction service", "err", err)
Expand All @@ -175,7 +160,7 @@ func main() {

publisher := gateways.NewPublisher(storage, identityService, claimsService, mtService, keyStore, transactionService, proofService, publisherGateway, cfg.Ethereum.ConfirmationTimeout, ps)

packageManager, err := protocol.InitPackageManager(ctx, stateContract, zkProofService, cfg.Circuit.Path)
packageManager, err := protocol.InitPackageManager(stateContract, cfg.Circuit.Path)
if err != nil {
log.Error(ctx, "failed init package protocol", "err", err)
return
Expand Down
16 changes: 1 addition & 15 deletions cmd/platform_ui/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ import (
"github.com/polygonid/sh-id-platform/internal/providers/blockchain"
"github.com/polygonid/sh-id-platform/internal/redis"
"github.com/polygonid/sh-id-platform/internal/repositories"
"github.com/polygonid/sh-id-platform/pkg/blockchain/eth"
"github.com/polygonid/sh-id-platform/pkg/cache"
"github.com/polygonid/sh-id-platform/pkg/credentials/revocation_status"
circuitLoaders "github.com/polygonid/sh-id-platform/pkg/loaders"
Expand Down Expand Up @@ -181,19 +180,6 @@ func main() {
connectionsService := services.NewConnection(connectionsRepository, claimsRepository, storage)
linkService := services.NewLinkService(storage, claimsService, qrService, claimsRepository, linkRepository, schemaRepository, schemaLoader, sessionRepository, ps, cfg.IPFS.GatewayURL)

stateService, err := eth.NewStateService(eth.StateServiceConfig{
EthClient: ethConn,
StateAddress: common.HexToAddress(cfg.Ethereum.ContractAddress),
ResponseTimeout: cfg.Ethereum.RPCResponseTimeout,
})
if err != nil {
log.Error(ctx, "failed init state service", "err", err)
return
}

onChainCredentialStatusResolverService := gateways.NewOnChainCredStatusResolverService(ethConn, cfg.Ethereum.RPCResponseTimeout)
revocationService := services.NewRevocationService(common.HexToAddress(cfg.Ethereum.ContractAddress), stateService, onChainCredentialStatusResolverService)
zkProofService := services.NewProofService(claimsService, revocationService, identityService, mtService, claimsRepository, keyStore, storage, stateService, schemaLoader)
transactionService, err := gateways.NewTransaction(ethereumClient, cfg.Ethereum.ConfirmationBlockCount)
if err != nil {
log.Error(ctx, "error creating transaction service", "err", err)
Expand All @@ -208,7 +194,7 @@ func main() {

publisher := gateways.NewPublisher(storage, identityService, claimsService, mtService, keyStore, transactionService, proofService, publisherGateway, cfg.Ethereum.ConfirmationTimeout, ps)

packageManager, err := protocol.InitPackageManager(ctx, stateContract, zkProofService, cfg.Circuit.Path)
packageManager, err := protocol.InitPackageManager(stateContract, cfg.Circuit.Path)
if err != nil {
log.Error(ctx, "failed init package protocol", "err", err)
return
Expand Down
3 changes: 2 additions & 1 deletion internal/api/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,8 @@ func (s *Server) Agent(ctx context.Context, request AgentRequestObject) (AgentRe
log.Debug(ctx, "agent empty request")
return Agent400JSONResponse{N400JSONResponse{"cannot proceed with an empty request"}}, nil
}
basicMessage, err := s.packageManager.UnpackWithType(packers.MediaTypeZKPMessage, []byte(*request.Body))

basicMessage, _, err := s.packageManager.Unpack([]byte(*request.Body))
if err != nil {
log.Debug(ctx, "agent bad request", "err", err, "body", *request.Body)
return Agent400JSONResponse{N400JSONResponse{"cannot proceed with the given request"}}, nil
Expand Down
13 changes: 0 additions & 13 deletions internal/core/ports/revocation_service.go

This file was deleted.

1 change: 1 addition & 0 deletions internal/core/services/claims.go
Original file line number Diff line number Diff line change
Expand Up @@ -630,6 +630,7 @@ func (c *claim) getRevocationStatus(ctx context.Context, basicMessage *ports.Age
Body: protocol.RevocationStatusResponseMessageBody{RevocationStatus: *revStatus},
From: basicMessage.IssuerDID.String(),
To: basicMessage.UserDID.String(),
Typ: packers.MediaTypePlainMessage,
}, nil
}

Expand Down
Loading

0 comments on commit 06866af

Please sign in to comment.