refactor(starknet): replace BlockStatus string with typed enum#3779
refactor(starknet): replace BlockStatus string with typed enum#37790xsamalt wants to merge 1 commit into
Conversation
0xsamalt
commented
Jul 1, 2026
- Introduces BlockStatus as a typed uint8 enum in starknet/block.go with constants BlockPending, BlockAcceptedOnL1, BlockAcceptedOnL2, BlockRejected, and BlockPreConfirmed
- Adds UnmarshalText so the feeder JSON response deserialises directly into the enum and invalid status strings now return an error
- Updates all comparison sites and test assertions to use the typed constants
c2f22d1 to
f3415d0
Compare
|
Nice one, typed status is much better than a bare string 👍 One thing I'd double-check first though: So if the feeder ever sends something not in the list (pretty sure Wdyt about mapping unknown values to a |
|
Checked this against both the spec and Juno's own fixtures. Grepped our own feeder testdata to be sure this isn't just spec theory: So I don't think there's a real path that hits the default error case. Given that, I'd rather keep it strict if the feeder ever does send something unexpected here, that's a signal of an actual protocol change we want to know about loudly, not something we want to silently coerce into a |
|
Fair enough — the fixture check convinced me, let's keep it strict. Only nit: could the UnmarshalText error include the offending value (e.g. |
|
Already included... the default case returns |
f3415d0 to
6ce228b
Compare
|
Rebased onto main to resolve conflicts. A few refactors landed on main since this opened (subscription-cache→deduper, feeder client value-return change, pending-endpoint removal) that touched the same code paths. No change to the BlockStatus type or its logic; the rebase also required updating a handful of test call sites ( Verified with go build/go vet/go test across the affected packages. |