Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Listening to all contract events seems ineffective #3447

Open
BoboTiG opened this issue Jan 29, 2025 · 0 comments
Open

Listening to all contract events seems ineffective #3447

BoboTiG opened this issue Jan 29, 2025 · 0 comments
Labels
fix:bug Something isn't working

Comments

@BoboTiG
Copy link

BoboTiG commented Jan 29, 2025

Describe the bug

I am using RUES to listen to contract calls, any function. From the documentation:

Endpoint: /on/contracts:[contract-id]/[event-name], where [event-name] is optional. If the event name is not provided, the connection will listen to all events on the given contract.

So, passing an empty event-name should work.

To Reproduce

Here is some Python code (you will first need to install niquests, and websockets, modules):

# File: listen-all.py
import json

import niquests
import websockets


async def listen_to_stake_contract_calls() -> None:
    url = "wss://nodes.dusk.network/on"
    url_contract = "https://nodes.dusk.network/on/contracts:0200000000000000000000000000000000000000000000000000000000000000/"

    async with websockets.connect(url) as wss:
        # Get a session ID
        session_id = await wss.recv()
        print(f"{session_id = }")

        # Subscribe
        with niquests.get(url_contract, headers={"Rusk-Session-Id": session_id}) as req:
            req.raise_for_status()

        while "listening":
            print("Now listening ...")
            raw = await wss.recv()
            print(raw)


if __name__ == "__main__":
    import asyncio

    asyncio.run(listen_to_stake_contract_calls())

Now, a second script with one change (I added the specific withdraw topic/event at the end of the URL):

# File: listen-withdraw.py
# Same content as above with a modified `url_contract`
url_contract = "https://nodes.dusk.network/on/contracts:0200000000000000000000000000000000000000000000000000000000000000/withdraw"

Execute both scripts in different terminals, and wait for any event to happen.

Expected behaviour

listen-all.py will never get events, it will wait indefinitely.

While on the other hand, listen-withdraw.py will effectively print withdraw events.

Platform

  • Architecture: 8086
  • OS: Debian GNU/Linux (even if I think this is not related to the OS, nor the tooling).
@BoboTiG BoboTiG added the fix:bug Something isn't working label Jan 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fix:bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant