我正在使用以下内容监听Node.js hyperledger composer客户端应用程序中的事件:
listen() {
LOG.info('Awaiting events');
this.bizNetworkConnection.on('event', (event) => {
// event: { "$class": "org.namespace.BasicEvent", "eventId": "0000-0000-0000-000000#0" }
LOG.info('New Event');
LOG.info(event);
let options = {
properties: { key:'value'}
};
});
}
I do get notified of an event from a transaction I submitted that emitted an event. However, I cannot make sense of the event output I received. How do I trim this down? Here is a small sample of the event output I receive.
info: [CommodityTrader-App] Hyperledger Composer: Commodity Trading console application
info: [CommodityTrader-App] CommodityRegistry:<init> businessNetworkDefinition obtained tutorial-network@0.0.2
info: [CommodityTrader-App] Awaiting events
info: [CommodityTrader-App] Command completed successfully.
info: [CommodityTrader-App] New Event
info: [CommodityTrader-App] $ref=$["$modelManager"], external=false, declarations=[type=AssetDeclaration, type=Identifier, name=Asset, classExtension=null, idField=null, type=ClassDeclarationBody, declarations=[], offset=774, line=21, column=25, offset=774, line=21, column=25, abstract=[abstract, undefined], decorators=[type=Decorator, name=docs, type=DecoratorArguments, list=[type=String, value=asset.md, offset=738, line=20, column=7, offset=748, line=20, column=17], offset=737, line=20, column=6, offset=749, line=20, column=18, offset=732, line=20, column=1, offset=749, line=20, column=18], offset=732, line=20, column=1, offset=775, line=21, column=26, $ref=$["$modelManager"]["modelFiles"]["org.hyperledger.composer.system"], decorators=[$ref=$["$modelManager"]["modelFiles"]["org.hyperledger.composer.system"]["declarations"][0]["ast"]["decorators"][0], $ref=$["$modelManager"]["modelFiles"]["org.hyperledger.composer.system"]["declarations"][0], arguments=[asset.md], name=docs], name=Asset, properties=[], superType=null, superTypeDeclaration=null, idField=null, abstract=true, fqn=org.hyperledger.composer.system.Asset, type=ParticipantDeclaration, type=Identifier, name=Participant, classExtension=null, idField=null, type=ClassDeclarationBody, declarations=[], offset=981, line=28, column=38, offset=981, line=28, column=38, abstract=[abstract, undefined], decorators=[type=Decorator, name=docs, type=DecoratorArguments, list=[type=String, value=participant.md, offset=926, line=27, column=7, offset=942, line=27, column=23], offset=925, line=27, column=6, offset=943, line=27, column=24, offset=920, line=27, column=1, offset=943, line=27, column=24], offset=920, line=27, column=1, offset=982, line=28, column=39, $ref=$["$modelManager"]["modelFiles"]["org.hyperledger.composer.system"], decorators=[$ref=$["$modelManager"]["modelFiles"]["org.hyperledger.composer.system"]["declarations"][1]["ast"]["decorators"][0], $ref=$["$modelManager"]["modelFiles"]["org.hyperledger.composer.system"]["declarations"][1], arguments=[participant.md], name=docs], name=Participant, properties=[], superType=null, superTypeDeclaration=null, idField=null, abstract=true, fqn=org.hyperledger.composer.system.Participant, type=TransactionDeclaration, type=Identifier, name=Transaction, classExtension=null, type=ClassDeclarationBody, declarations=[type=FieldDeclaration, type=Identifier, name=transactionId, name=String, array=null, regex=null, default=null, optional=null, decorators=[], offset=1377, line=41, column=3, offset=1402, line=42, column=3, type=FieldDeclaration, type=Identifier, name=timestamp, name=DateTime, array=null, default=null, optional=null, decorators=[], offset=1402, line=42, column=3, offset=1423, line=43, column=1], offset=1377, line=41, column=3, offset=1423, line=43, column=1, type=Identifier, name=transactionId, abstract=[abstract, undefined], decorators=[type=Decorator, name=docs, type=DecoratorArguments, list=[type=String, value=transaction.md, offset=1294, line=39, column=7, offset=1310, line=39, column=23], offset=1293, line=39, column=6, offset=1311, line=39, column=24, offset=1288, line=39, column=1, offset=1311, line=39, column=24], offset=1288, line=39, column=1, offset=1424, line=43, column=2, $ref=$["$modelManager"]["modelFiles"]["org.hyperledger.composer.system"], decorators=[$ref=$["$modelManager"]["modelFiles"]["org.hyperledger.composer.system"]["declarations"][2]["ast"]["decorators"][0], $ref=$["$modelManager"]["modelFiles"]["org.hyperledger.composer.system"]["declarations"][2], arguments=[transaction.md], name=docs], name=Transaction, properties=[$ref=$["$modelManager"]["modelFiles"]["org.hyperledger.composer.system"]["declarations"][2]["ast"]["body"]["declarations"][0], $ref=$["$modelManager"]["modelFiles"]["org.hyperledger.composer.system"]["declarations"][2], decorators=[], name=transactionId, decorator=null, type=String, array=false, optional=false, validator=null, defaultValue=null, $ref=$["$modelManager"]["modelFiles"]["org.hyperledger.composer.system"]["declarations"][2]["ast"]["body"]["declarations"][1], $ref=$["$modelManager"]["modelFiles"]["org.hyperledger.composer.system"]["declarations"][2], decorators=[], name=timestamp, decorator=null, type=DateTime, array=false, optional=false, validator=null, defaultValue=null], superType=null, superTypeDeclaration=null, idField=transactionId, abstract=true, fqn=org.hyperledger.composer.system.Transaction, type=EventDeclaration, type=Identifier, name=Event, classExtension=null, type=ClassDeclarationBody, declarations=[type=FieldDeclaration, type=Identifier, name=eventId, name=String, array=null, regex=null, default=null, optional=null, decorators=[], offset=1762, line=55, column=3, offset=1781, line=56, column=3, type=FieldDeclaration, type=Identifier, name=timestamp, name=DateTime, array=null, default=null, optional=null, decorators=[], offset=1781, line=56, column=3, offset=1802, line=57, column=1], offset=1762, line=55, column=3, offset=1802, line=57, column=1, type=Identifier, name=eventId, abstract=[abstract, undefined], decorators=[type=Decorator, name=docs, type=DecoratorArguments, list=[type=String, value=event.md, offset=1703, line=53, column=7, offset=1713, line=53, column=17], offset=1702, line=53, column=6, offset=1714, line=53, column=18, offset=1697, line=53, column=1, offset=1714, line=53, column=18], offset=1697, line=53, column=1, offset=1803, line=57, column=2, $ref=$["$modelManager"]["modelFiles"]["org.hyperledger.composer.system"], decorators=[$ref=$["$modelManager"]["modelFiles"]["org.hyperledger.composer.system"]["declarations"][3]["ast"]["decorators"][0], $ref=$["$modelManager"]["modelFiles"]["org.hyperledger.composer.system"]["declarations"][3], arguments=[event.md], name=docs], name=Event, properties=[$ref=$["$modelManager"]["modelFiles"]["org.hyperledger.composer.system"]["declarations"][3]["ast"]["body"]["declarations"][0], $ref=$["$modelManager"]["modelFiles"]["org.hyperledger.composer.system"]["declarations"][3], decorators=[], name=eventId, decorator=null, type=String, array=false, optional=false, validator=null, defaultValue=null, $ref=$["$modelManager"]["modelFiles"]["org.hyperledger.composer.system"]["declarations"][3]["ast"]["body"]["declarations"][1], $ref=$["$modelManager"]["modelFiles"]["org.hyperledger.composer.system"]["declarations"][3], decorators=[], name=timestamp, decorator=null, type=DateTime, array=false, optional=false, validator=null, defaultValue=null], superType=null, superTypeDeclaration=null, idField=eventId, abstract=true, fqn=org.hyperledger.composer.system.Event, type=AssetDeclaration, type=Identifier, name=Registry, classExtension=null, type=Identifier, name=registryId, type=ClassDeclarationBody, declarations=[type=FieldDeclaration, type=Identifier, name=registryId, name=String, array=null, regex=null, default=null, optional=null, decorators=[], offset=2156, line=69, column=3, offset=2178, line=70, column=3, type=FieldDeclaration, type=Identifier, name=name, name=String, array=null, regex=null, default=null, optional=null, decorators=[], offset=2178, line=70, column=3, offset=2194, line=71, column=3, type=FieldDeclaration, type=Identifier, name=type, name=String, array=null, regex=null, default=null, optional=null, decorators=[], offset=2194, line=71, column=3, offset=2210, line=72, column=3, type=FieldDeclaration, type=Identifier, name=system, name=Boolean, array=null, default=nul