Skip to content

Conversation

@bernard-wagner
Copy link
Contributor

@bernard-wagner bernard-wagner commented Aug 29, 2023

Follows on #5571

Motivation

It is useful to monitor for events emitted.

Solution

Introduces: cast subscribe

Building on the introduction of websockets, allow subscribing to events using the same syntax as cast logs.

Some additional changes to_json logic to support streaming.

Moved filter logic from logs.rs to filters.rs to enable reuse.

If --to-block is specified, subscribe to newHeads and exits loop when target block has been reached.

@Evalir Evalir requested review from Evalir and mattsse and removed request for mattsse September 4, 2023 15:55
@Evalir
Copy link
Member

Evalir commented Sep 4, 2023

hey @bernard-wagner just merged #5571 — should be good to continue

@bernard-wagner bernard-wagner marked this pull request as ready for review September 5, 2023 05:40
@bernard-wagner
Copy link
Contributor Author

@Evalir open question: Should this be a separate command or should it use a cast logs --subscribe switch?

@Evalir
Copy link
Member

Evalir commented Sep 11, 2023

hmm i think cast logs --subscribe is good enough @bernard-wagner

Copy link
Member

@Evalir Evalir left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will give a more thorough review later!

use foundry_common::abi::{get_event, parse_tokens};
use itertools::Itertools;

/// First tries to parse the `sig_or_topic` as an event signature. If successful, `topics_or_args`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do these docs go here? unsure if they correspond to build_filter

@bernard-wagner bernard-wagner force-pushed the subscribe branch 2 times, most recently from c3394ca to 1bb5bde Compare September 11, 2023 18:46
@bernard-wagner
Copy link
Contributor Author

bernard-wagner commented Sep 11, 2023

@Evalir apologies for all the force pushes. Moved to cast logs --subscribe removing the need to move the helper functions out of logs.rs. Improved the docs of the helper functions a bit. Tried passing ctrl-c as general future to Cast, but adds a lot of complexity which seems to be not needed (generic with DefaultType) if Optional.

Copy link
Member

@Evalir Evalir left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm bar failing tests—will rerun them as they seem like spurious network failures

@Evalir Evalir merged commit 2885b0d into foundry-rs:master Sep 12, 2023
mikelodder7 pushed a commit to LIT-Protocol/foundry that referenced this pull request Sep 12, 2023
* feat(cast): subscribe to logs

* undo generic signal

* fix tokio signal feature

---------

Co-authored-by: Enrique Ortiz <hi@enriqueortiz.dev>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants