Hyperledger编写器生成的角度应用程序在调用事务时无法实例化概念

时间:2018-08-10 16:19:42

标签: hyperledger hyperledger-composer

我使用generator-hyperledger-composer为我的企业网络生成了一个Angular应用。该模型在其中使用concept,如下所示:

asset Box identified by boxId {
    o String boxId
    o Item[] items
}

concept Item {
    o String name
    o String description
}

我还有一项交易,允许参与者将Item添加到Box

transaction AddItem {
    --> Box box
    o Item item
}

通过Angular应用调用交易时,我尝试了以下2个版本来尝试使交易发生(我也提供了有效的boxId):

item: {
    "$class": "org.example.mynetwork.Item",
    "name": "Lorem",
    "description": "Ipsum"
}

我也尝试过

item {
    "name": "Lorem",
    "description": "Ipsum"
}

相关的Javascript代码如下:

tx.box.addArrayValue("items", tx.item);

这两种情况都会导致500: Internal Server Error和来自我的REST服务器的以下日志

Unhandled error for request POST /api/AddSpray: ValidationException: Unexpected properties for type org.ukkoagro.croptracker.Spray: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74
at validateProperties (/home/haardik/.nvm/versions/node/v8.11.3/lib/node_modules/composer-rest-server/node_modules/composer-common/lib/serializer/jsonpopulator.js:60:15)
at JSONPopulator.visitClassDeclaration (/home/haardik/.nvm/versions/node/v8.11.3/lib/node_modules/composer-rest-server/node_modules/composer-common/lib/serializer/jsonpopulator.js:118:9)
at JSONPopulator.visit (/home/haardik/.nvm/versions/node/v8.11.3/lib/node_modules/composer-rest-server/node_modules/composer-common/lib/serializer/jsonpopulator.js:96:25)
at ConceptDeclaration.accept (/home/haardik/.nvm/versions/node/v8.11.3/lib/node_modules/composer-rest-server/node_modules/composer-common/lib/introspect/decorated.js:65:24)
at JSONPopulator.convertItem (/home/haardik/.nvm/versions/node/v8.11.3/lib/node_modules/composer-rest-server/node_modules/composer-common/lib/serializer/jsonpopulator.js:194:30)
at JSONPopulator.visitField (/home/haardik/.nvm/versions/node/v8.11.3/lib/node_modules/composer-rest-server/node_modules/composer-common/lib/serializer/jsonpopulator.js:149:27)
at JSONPopulator.visit (/home/haardik/.nvm/versions/node/v8.11.3/lib/node_modules/composer-rest-server/node_modules/composer-common/lib/serializer/jsonpopulator.js:100:25)
at Field.accept (/home/haardik/.nvm/versions/node/v8.11.3/lib/node_modules/composer-rest-server/node_modules/composer-common/lib/introspect/decorated.js:65:24)
at properties.forEach (/home/haardik/.nvm/versions/node/v8.11.3/lib/node_modules/composer-rest-server/node_modules/composer-common/lib/serializer/jsonpopulator.js:124:51)
at Array.forEach (<anonymous>)
at JSONPopulator.visitClassDeclaration (/home/haardik/.nvm/versions/node/v8.11.3/lib/node_modules/composer-rest-server/node_modules/composer-common/lib/serializer/jsonpopulator.js:120:20)
at JSONPopulator.visit (/home/haardik/.nvm/versions/node/v8.11.3/lib/node_modules/composer-rest-server/node_modules/composer-common/lib/serializer/jsonpopulator.js:96:25)
at TransactionDeclaration.accept (/home/haardik/.nvm/versions/node/v8.11.3/lib/node_modules/composer-rest-server/node_modules/composer-common/lib/introspect/decorated.js:65:24)
at Serializer.fromJSON (/home/haardik/.nvm/versions/node/v8.11.3/lib/node_modules/composer-rest-server/node_modules/composer-common/lib/serializer.js:180:26)
at ensureConnected.then (/home/haardik/.nvm/versions/node/v8.11.3/lib/node_modules/composer-rest-server/node_modules/loopback-connector-composer/lib/businessnetworkconnector.js:634:43)
at <anonymous>

0 个答案:

没有答案