0xMiden / 0xMiden/node

Unused error variant

Đang mở
#2,150 2 bình luận 0 reaction 0 người được giao Xem trên GitHub
rpc
Ngôn ngữ chính
Rust
Star
104
Fork
138
Merge trung bình
1 ngày 13 giờ
Pull request đã merge (30 ngày)
56

Mô tả

`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

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.