diff --git a/services/diddoc_service.go b/services/diddoc_service.go index e349f622..15b4619c 100644 --- a/services/diddoc_service.go +++ b/services/diddoc_service.go @@ -5,6 +5,7 @@ import ( // jsonpb Marshaller is deprecated, but is needed because there's only one way to proto // marshal in combination with our proto generator version "encoding/json" + "fmt" "strings" cheqd "github.com/cheqd/cheqd-node/x/cheqd/types" @@ -88,7 +89,7 @@ func (ds DIDDocService) MarshallContentStream(contentStream protoiface.MessageV1 ResourceType: contentStream.Header.ResourceType, MediaType: contentStream.Header.MediaType, Created: contentStream.Header.Created, - Checksum: contentStream.Header.Checksum, + Checksum: fmt.Sprintf("%x", contentStream.Header.Checksum), PreviousVersionId: contentStream.Header.PreviousVersionId, NextVersionId: contentStream.Header.NextVersionId, Data: contentStream.Data, diff --git a/services/request_service_test.go b/services/request_service_test.go index 1fad69a1..c1dead4b 100644 --- a/services/request_service_test.go +++ b/services/request_service_test.go @@ -221,7 +221,7 @@ func TestDereferencing(t *testing.T) { validVerificationMethod := validVerificationMethod() validService := validService() validResource := validResource() - validChecksum, _ := json.Marshal(validResource.Header.Checksum) + validChecksum := fmt.Sprintf("%x", validResource.Header.Checksum) validData, _ := json.Marshal(validResource.Data) validMetadata := validMetadata() validFragmentMetadata := types.NewResolutionDidDocMetadata(validDid, validMetadata, []*resource.ResourceHeader{}) @@ -269,7 +269,7 @@ func TestDereferencing(t *testing.T) { ledgerService: NewMockLedgerService(validDIDDoc, validMetadata, validResource), dereferencingType: types.DIDJSONLD, didUrl: validDid + types.RESOURCE_PATH + validResourceId, - expectedContentStream: fmt.Sprintf("{\"@context\":[\"%s\"],\"collectionId\":\"%s\",\"id\":\"%s\",\"name\":\"%s\",\"resourceType\":\"%s\",\"mediaType\":\"%s\",\"checksum\":%s,\"data\":%s}", + expectedContentStream: fmt.Sprintf("{\"@context\":[\"%s\"],\"collectionId\":\"%s\",\"id\":\"%s\",\"name\":\"%s\",\"resourceType\":\"%s\",\"mediaType\":\"%s\",\"checksum\":\"%s\",\"data\":%s}", types.DIDSchemaJSONLD, validResource.Header.CollectionId, validResource.Header.Id, validResource.Header.Name, validResource.Header.ResourceType, validResource.Header.MediaType, validChecksum, validData), expectedMetadata: types.ResolutionDidDocMetadata{}, expectedError: "", diff --git a/types/dereferencing_content_stream.go b/types/dereferencing_content_stream.go index c71ba40a..70c6a55b 100644 --- a/types/dereferencing_content_stream.go +++ b/types/dereferencing_content_stream.go @@ -8,7 +8,7 @@ type DereferencedResource struct { ResourceType string `json:"resourceType,omitempty"` MediaType string `json:"mediaType,omitempty"` Created string `json:"created,omitempty"` - Checksum []byte `json:"checksum,omitempty"` + Checksum string `json:"checksum,omitempty"` PreviousVersionId string `json:"previousVersionId,omitempty"` NextVersionId string `json:"nextVersionId,omitempty"` Data []byte `json:"data,omitempty"` diff --git a/types/did_doc_metadata.go b/types/did_doc_metadata.go index 618ac70f..35ded6a0 100644 --- a/types/did_doc_metadata.go +++ b/types/did_doc_metadata.go @@ -1,6 +1,8 @@ package types import ( + "fmt" + cheqd "github.com/cheqd/cheqd-node/x/cheqd/types" resource "github.com/cheqd/cheqd-node/x/resource/types" ) @@ -19,7 +21,7 @@ type ResourcePreview struct { ResourceType string `json:"resourceType,omitempty"` MediaType string `json:"mediaType,omitempty"` Created string `json:"created,omitempty"` - Checksum []byte `json:"checksum,omitempty"` + Checksum string `json:"checksum,omitempty"` PreviousVersionId string `json:"previousVersionId,omitempty"` NextVersionId string `json:"nextVersionId,omitempty"` } @@ -42,7 +44,7 @@ func NewResolutionDidDocMetadata(did string, metadata cheqd.Metadata, resources r.ResourceType, r.MediaType, r.Created, - r.Checksum, + fmt.Sprintf("%x", r.Checksum), r.PreviousVersionId, r.NextVersionId, } diff --git a/types/did_doc_metadata_test.go b/types/did_doc_metadata_test.go index 5b79bbf2..bfdb6bba 100644 --- a/types/did_doc_metadata_test.go +++ b/types/did_doc_metadata_test.go @@ -1,6 +1,7 @@ package types import ( + "fmt" "testing" cheqd "github.com/cheqd/cheqd-node/x/cheqd/types" @@ -27,7 +28,7 @@ func TestNewResolutionDidDocMetadata(t *testing.T) { ResourceType: resourceHeader.ResourceType, MediaType: resourceHeader.MediaType, Created: resourceHeader.Created, - Checksum: resourceHeader.Checksum, + Checksum: fmt.Sprintf("%x", resourceHeader.Checksum), PreviousVersionId: resourceHeader.PreviousVersionId, NextVersionId: resourceHeader.NextVersionId, }