From f414b426fbb5073e12e87ff6cf3c88db40bd61a2 Mon Sep 17 00:00:00 2001 From: daveroga Date: Mon, 2 Sep 2024 07:26:22 +0200 Subject: [PATCH] defined typedDataTypes --- pkg/services/did.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/pkg/services/did.go b/pkg/services/did.go index 95873e3..669a57b 100644 --- a/pkg/services/did.go +++ b/pkg/services/did.go @@ -184,7 +184,7 @@ func (d *DidDocumentServices) GetDidDocument(ctx context.Context, did string, op return didResolution, nil } -func getTypedData(typeDataType TypedDataType, did w3c.DID, identityState IdentityState) (apitypes.TypedData, error) { +func getTypedData(typedDataType TypedDataType, did w3c.DID, identityState IdentityState) (apitypes.TypedData, error) { id, err := core.IDFromDID(did) if err != nil { return apitypes.TypedData{}, @@ -195,9 +195,10 @@ func getTypedData(typeDataType TypedDataType, did w3c.DID, identityState Identit var apiTypes apitypes.Types var message apitypes.TypedDataMessage - primaryType := "" + var primaryType string - if typeDataType == IdentityStateType { + switch typedDataType { + case IdentityStateType: primaryType = "IdentityState" apiTypes = apitypes.Types{ "IdentityState": []apitypes.Type{ @@ -223,7 +224,7 @@ func getTypedData(typeDataType TypedDataType, did w3c.DID, identityState Identit "replacedAtTimestamp": replacedAtTimestamp, } - } else { + case GlobalStateType: primaryType = "GlobalState" apiTypes = apitypes.Types{ "GlobalState": []apitypes.Type{ @@ -248,6 +249,8 @@ func getTypedData(typeDataType TypedDataType, did w3c.DID, identityState Identit "root": root, "replacedAtTimestamp": replacedAtTimestamp, } + default: + return apitypes.TypedData{}, fmt.Errorf("typedDataType %d not defined", typedDataType) } typedData := apitypes.TypedData{