refactor(protocol): Address routing decode memory optimization and missing symbol traits
- Lingua principale
- Rust
- Stelle
- 132
- Fork
- 167
- Merge medio
- 1g 23h
- PR unite (30g)
- 110
Descrizione
### Problem Description
1. **RoutingParameters Decode Overhead & Invariant Documentation:**
- `RoutingParameters::decode(mut bech32_string: String)` currently requires an owned `String`, causing callers in `Address::from_str` to perform an unnecessary `.to_owned()` allocation on substring slices. Inside `decode`, two `insert_str(0, ...)` calls cause additional heap reallocations.
- `RoutingParameters::encode_to_string` contains an unfinished `expect("TODO")` on line 160.
2. **Missing Symbol Traits for `TokenSymbol` and `RoleSymbol`:**
- Neither `TokenSymbol` nor `RoleSymbol` implements `core::str::FromStr`, preventing standard `s.parse::()` usage.
- Neither implements `core::hash::Hash`, preventing usage in hashed collections (`HashSet`/`HashMap`).
- `TokenSymbol` is missing ordering traits (`Ord`, `PartialOrd`).
3. **Doctest Panics in `miden-standards`:**
- Doc examples in `authority.rs` and `access/mod.rs` contain `unimplemented!()` placeholders that panic when doctests are run.
### Proposed Solution
- Update `RoutingParameters::decode` to take `&str` and construct the full bech32 string in a single allocation.
- Implement `FromStr`, `Hash`, and `AsRef` for `TokenSymbol` and `RoleSymbol`.
- Replace doctest `unimplemented!()` with valid `AccountId` test fixtures.
I have a branch ready with all fixes and signed commits.
Guida per i contributori
Apri la guida per i contributori
Valutazione
Questa issue non è ancora stata valutata.