Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

unable to find newEventHub function

I am new to hyperledger fabric. I have downloaded the fabric v1.2.0 and I tried to run fabcar example from the fabric-sample folder. My querying on the chaincode went well, but when I tried to invoke the chaincode I got the below error from the cmd.

This is my request to the chaincode

var request = {
    //targets: let default to the peer assigned to the client
    chaincodeId: 'fabcar',
    fcn: 'changeCarOwner',
    args: ['CAR4', 'Dave'],
    chainId: 'mychannel',
    txId: tx_id
};

Error:

Failed to invoke successfully :: TypeError: fabric_client.newEventHub is not a function

When I tried to find newEventHub in index.t.ds, I could not find the function. Can anyone help me with this.Thanks in advance.

like image 863
Pragadeesh Dharsha V Avatar asked Jul 20 '18 06:07

Pragadeesh Dharsha V


2 Answers

I think they've replaced the EventHub class with ChannelEventHub.

You can update the invoke.js file with following:

on line 105:

let event_hub = channel.newChannelEventHub('localhost:7051');
// event_hub.setPeerAddr('grpc://localhost:7053');

on line 130:

console.log('The transaction has been committed on peer ' + event_hub.getPeerAddr());

That should fix it.

like image 186
Krishna Moniz Avatar answered Nov 03 '22 13:11

Krishna Moniz


Change the fabric-client npm version from "unstable" to ^1.2.1 in package.json and run npm install

like image 4
vignesh679 Avatar answered Nov 03 '22 13:11

vignesh679