Use the Zone SDK to inscribe data on blockchain#351
Conversation
…-docs into zone-sdk-inscribe
|
|
||
| // Watch for events | ||
| event = sequencer.next_event() => { | ||
| if let Some(event) = event { |
There was a problem hiding this comment.
next_event returns event not Option. Proposed fix: drop if let Some(event)
There was a problem hiding this comment.
I want to keep it consistent with the implementation in the master branch of logos-blockchain, and that's how it is there: https://github.com/logos-blockchain/logos-blockchain/blob/5069049472419e6c92cae3e1393f5d99f20b359e/deployment/tui-zone/src/lib.rs#L69
If we want to modify it, we should change it there as well, no? @pradovic
There was a problem hiding this comment.
Sorry, It was on my PR that I just merged to master (I thought I already did)
weboko
left a comment
There was a problem hiding this comment.
Dogfooded on x86_64 Linux. Found a compile error that will block users from completing the tutorial.
The tui-zone-tutorial branch carries an older zone-sdk where ZoneSequencer::next_event() returns Option<Event> — the signature was changed to return Event directly on master after the tutorial branch was cut.
This means the tutorial code in Step 3 will not compile as written on the tutorial branch.
| tokio::select! { | ||
|
|
||
| // Watch for events | ||
| event = sequencer.next_event() => { |
There was a problem hiding this comment.
Compile error — on the tui-zone-tutorial branch, ZoneSequencer::next_event() returns Option<Event>, not Event. Binding event here therefore has type Option<Event>, but handle_event on line 386 expects Event. This causes:
error[E0308]: mismatched types
--> src/lib.rs:112:30
|
| handle_event(event, ...)
| ^^^^^ expected `Event`, found `Option<Event>`
Verified with cargo check on the tutorial branch — the error is reproducible. On master the signature was changed to -> Event directly, which is why master compiles.
Suggested fix — use the Some(event) pattern in tokio::select! to unwrap and disable the arm on None:
| event = sequencer.next_event() => { | |
| Some(event) = sequencer.next_event() => { |
| fn handle_event( | ||
| event: Event, | ||
| state: &mut InMemoryZoneState, | ||
| sequencer: &mut ZoneSequencer<NodeHttpClient>, | ||
| ready_tx: &mut Option<tokio::sync::oneshot::Sender<()>>,) { |
There was a problem hiding this comment.
Non-standard formatting: the function parameters use 1-space indentation and the closing ) is on the same line as the last argument with a leading ,. This will pass rustfmt with a warning and looks inconsistent with the rest of the codebase (4-space indentation, closing ) on its own line).
Suggested fix:
| fn handle_event( | |
| event: Event, | |
| state: &mut InMemoryZoneState, | |
| sequencer: &mut ZoneSequencer<NodeHttpClient>, | |
| ready_tx: &mut Option<tokio::sync::oneshot::Sender<()>>,) { | |
| fn handle_event( | |
| event: Event, | |
| state: &mut InMemoryZoneState, | |
| sequencer: &mut ZoneSequencer<NodeHttpClient>, | |
| ready_tx: &mut Option<tokio::sync::oneshot::Sender<()>>, | |
| ) { |
No description provided.