-
Notifications
You must be signed in to change notification settings - Fork 647
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
Fix rewarded_addresses
event payload serialization
#4492
Comments
@zone117x your JS code is right but your TS interface says "reward_set" instead of "stacker_set". Just commenting because it took me a second to see if the Rust code I was looking at was right or not |
Ah thanks, I think the payload is morphing a bit between when this ingestion code was written and current next / draft PRs :) |
Also note that I'm currently working off of PR #4430 for this event data |
I think this works in // Convert to a list of b58-encoded strings
let reward_set_json = json!({
"rewarded_addresses": reward_set
.rewarded_addresses
.iter()
.cloned()
.map(|a| a.to_b58())
.collect::<Vec<String>>(),
"reward_cycle": reward_set.start_cycle_state,
"signers": reward_set.signers,
});
let payload = json!({
"stacker_set": reward_set_json,
"block_id": block_id,
"cycle_number": cycle_number
}); |
That |
Agreed. If we were to write an alias and "deprecate" that fn, what would a better name be? |
|
Epoch3 introduces the
reward_set
payload for event observers. It looks like there is some default rust->json serialization going on, which creates a very convoluted JSON payload.Here's the typescript schema/definition for what we're receiving:
If it isn't obvious, this schema is obtuse. For reference, here's a snippet of code required to deal with that format (convert one of those entries into a bitcoin address string):
IIUC in the pox clarity contract, these
rewarded_addresses
are represented as a(version: byte, hashbytes: buffer)
. In JSON, that would simply be:The encoded bitcoin address strings would also work, e.g.
The text was updated successfully, but these errors were encountered: