cosmjs icon indicating copy to clipboard operation
cosmjs copied to clipboard

EVENT SUBSCRIBE

Open Abhishek-1857 opened this issue 3 years ago • 4 comments

How can i subscribe to events with the help of cosmjs.

Abhishek-1857 avatar Jun 07 '22 05:06 Abhishek-1857

i wish this question had an answer

KodamaHQ avatar Oct 10 '22 08:10 KodamaHQ

Hi @Abhishek-1857 , I managed to subscribe to the new block event using: ` const ws_client = new WebsocketClient(ws_tm_tendermint_rpc, (err)=>{console.log("Error Connecting:", err)}) const tm_client = Tendermint34Client.create(ws_client);

var new_block_subscribe = (await tm_client).subscribeNewBlock();
var latestUpdate = {};
var readLatestUpdate = true;
new_block_subscribe.addListener(
    {
    next: i => {console.log(i); latestUpdate = i; readLatestUpdate = false;},
    error: err => console.error(err),
    complete: () => console.log('completed'),
});`

Still trying to understand how to subscribe to other events similar to {"query":"tm.event = 'NewBlock'"}} using subscribeTx, but there is zero documentation on this topic

KodamaHQ avatar Oct 17 '22 10:10 KodamaHQ

Ok, they wont allow you to query anything else than tm.event = "Tx" AND etc.. idk why they would limit it this way,.

KodamaHQ avatar Oct 17 '22 13:10 KodamaHQ

@ranlavanet can you share with me a example for this ?

goni098 avatar Feb 16 '24 15:02 goni098