Skip to content

Commit

Permalink
Merge pull request #22 from GoLedgerDev/develop
Browse files Browse the repository at this point in the history
Fix getRecursive when accessing an object custom datatype
  • Loading branch information
andremacedopv authored Jul 6, 2023
2 parents 91eefe1 + 5e4204e commit 09b1abc
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 6 deletions.
6 changes: 4 additions & 2 deletions assets/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,8 @@ func getRecursive(stub *sw.StubWrapper, pvtCollection, key string, keysChecked [
switch prop := v.(type) {
case map[string]interface{}:

if prop["@assetType"].(string) == "@object" {
assetType, ok := prop["@assetType"].(string)
if !ok || assetType == "@object" {
continue
}

Expand Down Expand Up @@ -211,7 +212,8 @@ func getRecursive(stub *sw.StubWrapper, pvtCollection, key string, keysChecked [
for idx, elem := range prop {
if elemMap, ok := elem.(map[string]interface{}); ok {

if elemMap["@assetType"].(string) == "@object" {
assetType, ok := elemMap["@assetType"].(string)
if !ok || assetType == "@object" {
continue
}

Expand Down
2 changes: 1 addition & 1 deletion test/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ func TestMain(m *testing.M) {

tx.InitHeader(tx.Header{
Name: "CC Tools Test",
Version: "v0.7.1",
Version: "v0.8.1",
Colors: map[string][]string{
"@default": {"#4267B2", "#34495E", "#ECF0F1"},
},
Expand Down
4 changes: 2 additions & 2 deletions test/tx_getHeader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ func TestGetHeader(t *testing.T) {
stub := mock.NewMockStub("org1MSP", new(testCC))

expectedResponse := map[string]interface{}{
"ccToolsVersion": "v0.7.1",
"ccToolsVersion": "v0.8.1",
"colors": []interface{}{
"#4267B2",
"#34495E",
Expand All @@ -20,7 +20,7 @@ func TestGetHeader(t *testing.T) {
"name": "CC Tools Test",
"orgMSP": "org1MSP",
"orgTitle": "CC Tools Demo",
"version": "v0.7.1",
"version": "v0.8.1",
}
err := invokeAndVerify(stub, "getHeader", nil, expectedResponse, 200)
if err != nil {
Expand Down
5 changes: 5 additions & 0 deletions test/tx_getSchema_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,21 @@ func TestGetSchema(t *testing.T) {
"label": "Person",
"tag": "person",
"writers": nil,
"dynamic": false,
},
map[string]interface{}{
"description": "Library as a collection of books",
"label": "Library",
"tag": "library",
"writers": nil,
"dynamic": false,
},
map[string]interface{}{
"description": "Book",
"label": "Book",
"tag": "book",
"writers": nil,
"dynamic": false,
},
map[string]interface{}{
"description": "Secret between Org2 and Org3",
Expand All @@ -38,12 +41,14 @@ func TestGetSchema(t *testing.T) {
},
"tag": "secret",
"writers": nil,
"dynamic": false,
},
map[string]interface{}{
"description": "AssetTypeListData",
"label": "AssetTypeListData",
"tag": "assetTypeListData",
"writers": nil,
"dynamic": false,
},
}
err := invokeAndVerify(stub, "getSchema", nil, expectedResponse, 200)
Expand Down
2 changes: 1 addition & 1 deletion transactions/getHeader.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ var header Header

func InitHeader(h Header) {
header = h
header.CCToolsVersion = "v0.7.1"
header.CCToolsVersion = "v0.8.1"
}

// GetHeader returns data in CCHeader
Expand Down
2 changes: 2 additions & 0 deletions transactions/getSchema.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ var GetSchema = Transaction{
Description string `json:"description"`
Readers []string `json:"readers,omitempty"`
Writers []string `json:"writers"`
Dynamic bool `json:"dynamic"`
}
var assetList []assetListElem
for _, assetTypeDef := range assetTypeList {
Expand All @@ -66,6 +67,7 @@ var GetSchema = Transaction{
Label: assetTypeDef.Label,
Description: assetTypeDef.Description,
Readers: assetTypeDef.Readers,
Dynamic: assetTypeDef.Dynamic,
})
}

Expand Down

0 comments on commit 09b1abc

Please sign in to comment.