0xMiden / 0xMiden/node

Unused error variant

Aperta
#2,150 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub
rpc
Lingua principale
Rust
Stelle
104
Fork
138
Merge medio
1g 13h
PR unite (30g)
56

Descrizione

`GetNoteScriptByRoot` currently reports a missing script by returning `Ok(MaybeNoteScript { script: None })` ([link](https://github.com/0xMiden/node/blob/143cf7fe8511b55f28b32038b72dbf903f975663/crates/store/src/server/rpc_api.rs#L358-L376)). However, `GetNoteScriptByRootError::ScriptNotFound` is still declared with error code `2`:

https://github.com/0xMiden/node/blob/143cf7fe8511b55f28b32038b72dbf903f975663/crates/store/src/errors.rs#L460

As far as I can tell, that variant is never constructed anywhere in the codebase. This is a bit inconsistent with other lookup endpoints in the same crate. For example, `get_account` reports missing accounts via a typed `GetAccountError::AccountNotFound` error; though here it might make sense since not finding a script is not necessarily an error state.

We hit this in the client because we were parsing the error but instead we always got a response. That broke a flow that probes the registry before deciding whether to register a script.
Not sure there's much to do, but we probably want one of the following:

- keep the current `Ok(None)` / `MaybeNoteScript` behavior, and remove the unused `ScriptNotFound` variant;
- return `ScriptNotFound` when the script is missing, matching endpoints like `get_account` and removing the `Option<>` out of the response type

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.