From 1781ab2999a8ef3b7fc6e39a3672524957538005 Mon Sep 17 00:00:00 2001 From: arnabghose997 Date: Fri, 17 Mar 2023 13:38:46 +0530 Subject: [PATCH] fix: clientSpec is optional for Tx not falling under any supported clientSpec category --- x/ssi/client/cli/tx_ssi.go | 6 ------ x/ssi/client/cli/tx_utils.go | 3 --- x/ssi/verification/client_spec.go | 29 +++++++++++++---------------- 3 files changed, 13 insertions(+), 25 deletions(-) diff --git a/x/ssi/client/cli/tx_ssi.go b/x/ssi/client/cli/tx_ssi.go index 9c105b9..9c4ef15 100644 --- a/x/ssi/client/cli/tx_ssi.go +++ b/x/ssi/client/cli/tx_ssi.go @@ -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 { @@ -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 { diff --git a/x/ssi/client/cli/tx_utils.go b/x/ssi/client/cli/tx_utils.go index a5fb183..311f4d1 100644 --- a/x/ssi/client/cli/tx_utils.go +++ b/x/ssi/client/cli/tx_utils.go @@ -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 diff --git a/x/ssi/verification/client_spec.go b/x/ssi/verification/client_spec.go index 260828a..49b126b 100644 --- a/x/ssi/verification/client_spec.go +++ b/x/ssi/verification/client_spec.go @@ -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, - ) } }