Skip to content
This repository has been archived by the owner on Mar 27, 2024. It is now read-only.

Commit

Permalink
feat: factor walletlite.Command form vcwallet.Command.
Browse files Browse the repository at this point in the history
Signed-off-by: Volodymyr Kubiv <volodymyr.kubiv@euristiq.com>
  • Loading branch information
vkubiv committed Jul 27, 2022
1 parent c28f931 commit 55bfc82
Show file tree
Hide file tree
Showing 13 changed files with 1,823 additions and 1,550 deletions.
13 changes: 7 additions & 6 deletions cmd/aries-agent-mobile/pkg/wrappers/command/vcwallet.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (

"github.com/hyperledger/aries-framework-go/cmd/aries-agent-mobile/pkg/wrappers/models"
"github.com/hyperledger/aries-framework-go/pkg/controller/command"
cmddidcommwallet "github.com/hyperledger/aries-framework-go/pkg/controller/command/didcommwallet"
cmdvcwallet "github.com/hyperledger/aries-framework-go/pkg/controller/command/vcwallet"
)

Expand Down Expand Up @@ -261,13 +262,13 @@ func (v *VCWallet) CreateKeyPair(request *models.RequestEnvelope) *models.Respon

// Connect accepts out-of-band invitations and performs DID exchange.
func (v *VCWallet) Connect(request *models.RequestEnvelope) *models.ResponseEnvelope {
args := cmdvcwallet.ConnectRequest{}
args := cmddidcommwallet.ConnectRequest{}

if err := json.Unmarshal(request.Payload, &args); err != nil {
return &models.ResponseEnvelope{Error: &models.CommandError{Message: err.Error()}}
}

response, cmdErr := exec(v.handlers[cmdvcwallet.ConnectMethod], args)
response, cmdErr := exec(v.handlers[cmddidcommwallet.ConnectMethod], args)
if cmdErr != nil {
return &models.ResponseEnvelope{Error: cmdErr}
}
Expand All @@ -278,13 +279,13 @@ func (v *VCWallet) Connect(request *models.RequestEnvelope) *models.ResponseEnve
// ProposePresentation accepts out-of-band invitation and sends message proposing presentation
// from wallet to relying party.
func (v *VCWallet) ProposePresentation(request *models.RequestEnvelope) *models.ResponseEnvelope {
args := cmdvcwallet.ProposePresentationRequest{}
args := cmddidcommwallet.ProposePresentationRequest{}

if err := json.Unmarshal(request.Payload, &args); err != nil {
return &models.ResponseEnvelope{Error: &models.CommandError{Message: err.Error()}}
}

response, cmdErr := exec(v.handlers[cmdvcwallet.ProposePresentationMethod], args)
response, cmdErr := exec(v.handlers[cmddidcommwallet.ProposePresentationMethod], args)
if cmdErr != nil {
return &models.ResponseEnvelope{Error: cmdErr}
}
Expand All @@ -294,13 +295,13 @@ func (v *VCWallet) ProposePresentation(request *models.RequestEnvelope) *models.

// PresentProof sends present proof message from wallet to relying party.
func (v *VCWallet) PresentProof(request *models.RequestEnvelope) *models.ResponseEnvelope {
args := cmdvcwallet.PresentProofRequest{}
args := cmddidcommwallet.PresentProofRequest{}

if err := json.Unmarshal(request.Payload, &args); err != nil {
return &models.ResponseEnvelope{Error: &models.CommandError{Message: err.Error()}}
}

response, cmdErr := exec(v.handlers[cmdvcwallet.PresentProofMethod], args)
response, cmdErr := exec(v.handlers[cmddidcommwallet.PresentProofMethod], args)
if cmdErr != nil {
return &models.ResponseEnvelope{Error: cmdErr}
}
Expand Down
7 changes: 4 additions & 3 deletions cmd/aries-agent-mobile/pkg/wrappers/rest/endpoints.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ package rest
import (
"net/http"

cmddidcommwallet "github.com/hyperledger/aries-framework-go/pkg/controller/command/didcommwallet"
cmddidexch "github.com/hyperledger/aries-framework-go/pkg/controller/command/didexchange"
cmdintroduce "github.com/hyperledger/aries-framework-go/pkg/controller/command/introduce"
cmdisscred "github.com/hyperledger/aries-framework-go/pkg/controller/command/issuecredential"
Expand Down Expand Up @@ -518,13 +519,13 @@ func getVCWalletEndpoints() map[string]*endpoint {
cmdvcwallet.CreateKeyPairMethod: {
Path: opvcwallet.CreateKeyPairPath, Method: http.MethodPost,
},
cmdvcwallet.ConnectMethod: {
cmddidcommwallet.ConnectMethod: {
Path: opvcwallet.ConnectPath, Method: http.MethodPost,
},
cmdvcwallet.ProposePresentationMethod: {
cmddidcommwallet.ProposePresentationMethod: {
Path: opvcwallet.ProposePresentationPath, Method: http.MethodPost,
},
cmdvcwallet.PresentProofMethod: {
cmddidcommwallet.PresentProofMethod: {
Path: opvcwallet.PresentProofPath, Method: http.MethodPost,
},
}
Expand Down
7 changes: 4 additions & 3 deletions cmd/aries-agent-mobile/pkg/wrappers/rest/vcwallet.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ package rest

import (
"github.com/hyperledger/aries-framework-go/cmd/aries-agent-mobile/pkg/wrappers/models"
cmddidcommwallet "github.com/hyperledger/aries-framework-go/pkg/controller/command/didcommwallet"
cmdvcwallet "github.com/hyperledger/aries-framework-go/pkg/controller/command/vcwallet"
)

Expand Down Expand Up @@ -97,18 +98,18 @@ func (wallet *VCWallet) CreateKeyPair(request *models.RequestEnvelope) *models.R

// Connect accepts out-of-band invitations and performs DID exchange.
func (wallet *VCWallet) Connect(request *models.RequestEnvelope) *models.ResponseEnvelope {
return wallet.createRespEnvelope(request, cmdvcwallet.ConnectMethod)
return wallet.createRespEnvelope(request, cmddidcommwallet.ConnectMethod)
}

// ProposePresentation accepts out-of-band invitation and sends message proposing presentation
// from wallet to relying party.
func (wallet *VCWallet) ProposePresentation(request *models.RequestEnvelope) *models.ResponseEnvelope {
return wallet.createRespEnvelope(request, cmdvcwallet.ProposePresentationMethod)
return wallet.createRespEnvelope(request, cmddidcommwallet.ProposePresentationMethod)
}

// PresentProof sends message present proof message from wallet to relying party.
func (wallet *VCWallet) PresentProof(request *models.RequestEnvelope) *models.ResponseEnvelope {
return wallet.createRespEnvelope(request, cmdvcwallet.PresentProofMethod)
return wallet.createRespEnvelope(request, cmddidcommwallet.PresentProofMethod)
}

func (wallet *VCWallet) createRespEnvelope(request *models.RequestEnvelope, endpoint string) *models.ResponseEnvelope {
Expand Down
Loading

0 comments on commit 55bfc82

Please sign in to comment.