Add comprehensive event emission for auth-related failures #57
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.
Add comprehensive event emission for auth-related failures
Summary
This PR adds comprehensive event emission for authentication-related failures throughout the stellar smart account contract, as requested by @alberto-crossmint. When auth functions fail for any reason, the contract now emits detailed events before returning errors, making it easier to parse and understand failure reasons.
Key Changes:
AuthCheckFailedEvent,SignerOperationFailedEvent,PolicyValidationFailedEvent,SignatureVerificationFailedEvent__check_auth, signer management functions (add_signer,update_signer,revoke_signer), policy validation, signature verification, and constructor validationErrorenums to numeric codes and string messages for Soroban compatibilityTechnical Notes:
#[contracttype]for Soroban serialization compatibilityu32codes (1-11) with string messages for easy parsingformat!macroReview & Testing Checklist for Human
error_to_code_and_message()function are accurate and complete for all Error enum variantsRecommended Test Plan:
Diagram
%%{ init : { "theme" : "default" }}%% graph TD A["contracts/smart-account/src/account.rs"]:::major-edit B["contracts/smart-account/src/lib.rs"]:::minor-edit C["contracts/smart-account/src/auth/policy/time_based.rs"]:::minor-edit D["contracts/smart-account/src/auth/policy/allow_list.rs"]:::minor-edit E["contracts/smart-account/src/auth/signers/ed25519.rs"]:::minor-edit F["contracts/smart-account/src/auth/signers/secp256r1.rs"]:::minor-edit A --> |"exports events"| B A --> |"calls policy validation"| C A --> |"calls policy validation"| D A --> |"calls signature verification"| E A --> |"calls signature verification"| F A --> |"emits events on failure"| G["Event Emission Points:<br/>- __check_auth<br/>- add_signer<br/>- update_signer<br/>- revoke_signer<br/>- __constructor"]:::context subgraph Legend L1["Major Edit"]:::major-edit L2["Minor Edit"]:::minor-edit L3["Context/No Edit"]:::context end classDef major-edit fill:#90EE90 classDef minor-edit fill:#87CEEB classDef context fill:#FFFFFFNotes
format!macro for hex encoding("auth", "failed"),("signer", "failed"),("policy", "failed")for easy filtering