Skip to content

Commit

Permalink
Merge pull request #343 from hypersign-protocol/client-spec-nil-fix
Browse files Browse the repository at this point in the history
fix: clientSpec RPC param is optional
  • Loading branch information
Vishwas1 committed Mar 17, 2023
2 parents f6fc693 + 1781ab2 commit 0677963
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 25 deletions.
6 changes: 0 additions & 6 deletions x/ssi/client/cli/tx_ssi.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,6 @@ func CmdCreateSchema() *cobra.Command {
SchemaDoc: &schemaDoc,
SchemaProof: &schemaProof,
Creator: clientCtx.GetFromAddress().String(),
ClientSpec: &types.ClientSpec{
Type: "",
},
}

if err := msg.ValidateBasic(); err != nil {
Expand Down Expand Up @@ -227,9 +224,6 @@ func CmdRegisterCredentialStatus() *cobra.Command {
CredentialStatus: &credentialStatus,
Proof: &proof,
Creator: clientCtx.GetFromAddress().String(),
ClientSpec: &types.ClientSpec{
Type: "",
},
}

if err := msg.ValidateBasic(); err != nil {
Expand Down
3 changes: 0 additions & 3 deletions x/ssi/client/cli/tx_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,6 @@ func getSignatures(cmd *cobra.Command, message []byte, cmdArgs []string) ([]*typ
// Get the VM Ids
signInfoList = append(signInfoList, &types.SignInfo{
VerificationMethodId: didSigningElementsList[i].VerificationMethodId,
ClientSpec: &types.ClientSpec{
Type: "",
},
})

// Sign based on the Signing Algorithm
Expand Down
29 changes: 13 additions & 16 deletions x/ssi/verification/client_spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,22 +52,19 @@ func getPersonalSignSpecDocBytes(ssiMsg types.SsiMsg) ([]byte, error) {

// Get the updated marshaled SSI document for the respective ClientSpec
func getDocBytesByClientSpec(ssiMsg types.SsiMsg, extendedVm *types.ExtendedVerificationMethod) ([]byte, error) {
if extendedVm.ClientSpec == nil {
return nil, fmt.Errorf("clientSpec cannot be nil for verificationMethod %v", extendedVm.Id)
}

switch extendedVm.ClientSpec.Type {
case types.ADR036ClientSpec:
return getCosmosADR036SignDocBytes(ssiMsg, extendedVm.ClientSpec)
case types.PersonalSignClientSpec:
return getPersonalSignSpecDocBytes(ssiMsg)
// Non-ClientSpec RPC Request. Return marshaled SSI document as-is
case "":
if extendedVm.ClientSpec != nil {
switch extendedVm.ClientSpec.Type {
case types.ADR036ClientSpec:
return getCosmosADR036SignDocBytes(ssiMsg, extendedVm.ClientSpec)
case types.PersonalSignClientSpec:
return getPersonalSignSpecDocBytes(ssiMsg)
default:
return nil, fmt.Errorf(
"supported clientSpecs: %v",
types.SupportedClientSpecs,
)
}
} else {
return ssiMsg.GetSignBytes(), nil
default:
return nil, fmt.Errorf(
"supported clientSpecs: %v",
types.SupportedClientSpecs,
)
}
}

0 comments on commit 0677963

Please sign in to comment.