Replace todo!() panics with structured errors for unsupported ScAddress types in signer #2547
Open
Rachit2323 wants to merge 2 commits intostellar:mainfrom
Open
Conversation
…ss types in signer Three ScAddress variants (MuxedAccount, ClaimableBalance, LiquidityPool) were hitting todo!() macros which panic and crash the CLI process when encountered in Soroban authorization entries. Replace with proper Error variants so the CLI exits cleanly with a descriptive message instead of crashing. Also adds a unit test to prove the behavior is intentional.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves Soroban authorization signing in soroban-cli by replacing todo!() panics for unsupported ScAddress variants with structured Error returns, preventing CLI crashes and providing clearer user-facing failures.
Changes:
- Added explicit
Errorvariants for unsupportedScAddresstypes (MuxedAccount, ClaimableBalance, LiquidityPool). - Updated
sign_soroban_authorizationsto return those errors instead of panicking. - Added a unit test covering the MuxedAccount unsupported-path behavior.
Comments suppressed due to low confidence (1)
cmd/soroban-cli/src/signer/mod.rs:111
- The
ScAddress::Contract(...)branch returnsError::MissingSignerForAddresseven though the comment states contract addresses aren't supported, and there is already anError::ContractAddressAreNotSupported { .. }variant. This yields a misleading error message ("Missing signing key for account...") for contract addresses. Consider returningContractAddressAreNotSupportedhere (or removing that unused variant if it's not intended to be used).
ScAddress::Contract(stellar_xdr::curr::ContractId(Hash(c))) => {
// This address is for a contract. This means we're using a custom
// smart-contract account. Currently the CLI doesn't support that yet.
return Err(Error::MissingSignerForAddress {
address: stellar_strkey::Strkey::Contract(stellar_strkey::Contract(*c))
.to_string(),
});
}
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What:
Three ScAddress variants (MuxedAccount, ClaimableBalance, LiquidityPool) in
signer/mod.rs were hitting todo!() macros instead of returning proper errors.
Replaced them with structured Error variants and added a unit test.
Why:
If a Soroban auth entry contains one of these address types, the CLI crashes
with a panic instead of showing a useful message. This is a bad experience —
users see a raw thread panic with no guidance. Now they get a clear error and
the process exits cleanly.
Known limitations:
MuxedAccount signing is not implemented yet — this just makes the failure
graceful. Full support can be added in a follow-up.