diff --git a/assets/dataType.go b/assets/dataType.go index 2ddcae3..a5c8241 100644 --- a/assets/dataType.go +++ b/assets/dataType.go @@ -181,6 +181,8 @@ var dataTypeMap = map[string]*DataType{ } } + dataVal["@assetType"] = "@object" + retVal, err := json.Marshal(dataVal) if err != nil { return "", nil, errors.WrapErrorWithStatus(err, "failed to marshal return value", http.StatusInternalServerError) diff --git a/assets/get.go b/assets/get.go index a82f8f6..afad09d 100644 --- a/assets/get.go +++ b/assets/get.go @@ -164,6 +164,11 @@ func getRecursive(stub *sw.StubWrapper, pvtCollection, key string, keysChecked [ for k, v := range response { switch prop := v.(type) { case map[string]interface{}: + + if prop["@assetType"].(string) == "@object" { + continue + } + propKey, err := NewKey(prop) if err != nil { return nil, errors.WrapErrorWithStatus(err, "failed to resolve asset references", 500) @@ -205,6 +210,11 @@ func getRecursive(stub *sw.StubWrapper, pvtCollection, key string, keysChecked [ case []interface{}: for idx, elem := range prop { if elemMap, ok := elem.(map[string]interface{}); ok { + + if elemMap["@assetType"].(string) == "@object" { + continue + } + elemKey, err := NewKey(elemMap) if err != nil { return nil, errors.WrapErrorWithStatus(err, "failed to resolve asset references", 500) diff --git a/stubwrapper/stubWrapper.go b/stubwrapper/stubWrapper.go index 26d17da..f3730ea 100644 --- a/stubwrapper/stubWrapper.go +++ b/stubwrapper/stubWrapper.go @@ -201,3 +201,12 @@ func (sw *StubWrapper) GetMSPID() (string, errors.ICCError) { } return mspid, nil } + +// SplitCompositeKey returns composite keys +func (sw *StubWrapper) SplitCompositeKey(compositeKey string) (string, []string, errors.ICCError) { + key, keys, err := sw.Stub.SplitCompositeKey(compositeKey) + if err != nil { + return "", nil, errors.WrapError(err, "stub.SplitCompositeKey call error") + } + return key, keys, nil +} diff --git a/test/tx_createAsset_test.go b/test/tx_createAsset_test.go index ec7d016..00b0d6a 100644 --- a/test/tx_createAsset_test.go +++ b/test/tx_createAsset_test.go @@ -43,7 +43,8 @@ func TestCreateAsset(t *testing.T) { "id": "31820792048", "height": 0.0, "info": map[string]interface{}{ - "passport": "1234", + "@assetType": "@object", + "passport": "1234", }, }