You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Surfaced by CodeRabbit during review of #711. The panic paths are pre-existing (inherited from the original `ManagedCoreAccount::from_*_account` constructors that #711 split). Both `ManagedCoreFundsAccount` and `ManagedCoreKeysAccount` carry the same `expect(...)` fallback today.
Repo coding guideline: "Avoid `unwrap()` and `expect()` in library code; use proper error types (e.g. `thiserror`) and never panic in library code."
If `from_account_type` errors even with `NoKeySource` (e.g. an account variant we forgot to handle), the constructor aborts the caller's process instead of returning a structured error.
Suggested fix
Convert all three constructors (`from_account`, `from_bls_account`, `from_eddsa_account`) on both `ManagedCoreFundsAccount` and `ManagedCoreKeysAccount` to return `Result<Self, Error>` and propagate the underlying `crate::error::Error` from `ManagedAccountType::from_account_type`.
Touches every callsite, including the FFI surface in `key-wallet-ffi`. Worth doing in one focused PR.
The NoKeySource fallback cannot fail today: with NoKeySource, AddressPool::new generates nothing and returns Ok, and a failing derivation path already falls back to master(). The only ? left on that path are the from_normal_idx(0) / from_normal_idx(1) calls in dual_pools.
#1328 replaces those with ChildIndex constants, which makes the NoKeySource path infallible by construction. Removing the three expects still needs an infallible way to build the type without a key source, since from_account_type keeps returning Result for real key sources. That can follow once #1328 lands.
Activity
ZocoLini commentedon Nov 6, 2026
The
NoKeySourcefallback cannot fail today: withNoKeySource,AddressPool::newgenerates nothing and returnsOk, and a failing derivation path already falls back tomaster(). The only?left on that path are thefrom_normal_idx(0)/from_normal_idx(1)calls indual_pools.#1328 replaces those with
ChildIndexconstants, which makes theNoKeySourcepath infallible by construction. Removing the threeexpects still needs an infallible way to build the type without a key source, sincefrom_account_typekeeps returningResultfor real key sources. That can follow once #1328 lands.