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

feat: Add cosmos message poller #325

Merged
merged 5 commits into from
Oct 17, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Default if fn is nil
  • Loading branch information
DavidNix committed Oct 17, 2022
commit 91d5053cb020aa5baf458c49ae6c6a19a736f46c
3 changes: 3 additions & 0 deletions chain/cosmos/poll.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ func PollForProposalStatus(ctx context.Context, chain *CosmosChain, startHeight,
// fn is optional. Return true from the fn to stop polling and return the found message. If fn is nil, returns the first message to match type T.
func PollForMessage[T any](ctx context.Context, chain *CosmosChain, registry codectypes.InterfaceRegistry, startHeight, maxHeight uint64, fn func(found T) bool) (T, error) {
var zero T
if fn == nil {
fn = func(T) bool { return true }
}
doPoll := func(ctx context.Context, height uint64) (T, error) {
h := int64(height)
block, err := chain.getFullNode().Client.Block(ctx, &h)
Expand Down