From 3099727cdd9d29a89a4059b284e984e4416b3358 Mon Sep 17 00:00:00 2001 From: Pratap2018 Date: Thu, 29 Jan 2026 11:39:08 +0530 Subject: [PATCH] [fix]: id checking while register with namespace="" --- testutil/keeper/ssi.go | 1 + x/ssi/verification/common_document_checks.go | 20 +++++++++++++++++--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/testutil/keeper/ssi.go b/testutil/keeper/ssi.go index 0df763a..8c922e5 100644 --- a/testutil/keeper/ssi.go +++ b/testutil/keeper/ssi.go @@ -36,6 +36,7 @@ func SsiKeeper(t testing.TB) (*keeper.Keeper, sdk.Context) { memStoreKey, "SsiParams", ) + paramsSubspace = paramsSubspace.WithKeyTable(types.ParamKeyTable()) k := keeper.NewKeeper( cdc, storeKey, diff --git a/x/ssi/verification/common_document_checks.go b/x/ssi/verification/common_document_checks.go index 5fe173a..37243e1 100644 --- a/x/ssi/verification/common_document_checks.go +++ b/x/ssi/verification/common_document_checks.go @@ -20,7 +20,7 @@ func documentIdentifier(docType string) string { } func returnVersionNumIdx(namespace string) int { - if namespace == "mainnet" { + if namespace == "" { return 3 } else { return 4 @@ -71,18 +71,32 @@ func IsValidID(Id string, namespace string, docType string) error { // Mainnet Chain namespace check. If the document is registered on the mainnet chain, // the namespace should be empty + var expectedLength int if namespace == "" { - if len(docElements) != 3 { - return fmt.Errorf("expected number of did id elements for mainnet to be 3, got %s", fmt.Sprint(len(docElements))) + if docIdentifier == "sch" { + expectedLength = 4 + } else { + expectedLength = 3 } docMethodSpecificId = 2 } else { + if docIdentifier == "sch" { + expectedLength = 5 + } else { + expectedLength = 4 + } + docMethodSpecificId = 3 + docNamespace := docElements[docNamespaceIndex] if namespace != docNamespace { return fmt.Errorf("expected did namespace %s, got %s", namespace, docNamespace) } } + if len(docElements) != expectedLength { + return fmt.Errorf("expected %s id elements, got %s", fmt.Sprintf("%d", expectedLength), fmt.Sprintf("%d", len(docElements))) + } + // Check if method-specific-id string is alphanumeric and // has the minimum required character length of 32 isProperMethodSpecificId, err := regexp.MatchString(