ProvableHQ / sdk

A Software Development Kit (SDK) for Zero-Knowledge Transactions
https://provable.tools
GNU General Public License v3.0
584 stars 468 forks source link

fix: removed panic from Signature::from_str #878

Open sabsubsib opened 4 months ago

sabsubsib commented 4 months ago

Motivation

The change from .unwrap() to ? in the from_str function improves the error handling mechanism of our code. By using ?, we ensure that any errors that occur during the string parsing are properly propagated up the call stack, allowing for more graceful error handling and better debugging. This avoids potential panics at runtime due to unwrap() and adheres to best practices in Rust for error handling.

Test Plan

To ensure the changes work correctly, the following simple test plan was implemented:

  1. Manually tested the from_str method by providing both valid and invalid strings to verify that it returns the correct Result type.
  2. Checked that valid strings are parsed successfully and return Ok(Self) as expected.
  3. Verified that invalid strings now result in an error being returned instead of causing a panic, confirming that the ? operator is correctly propagating errors.
  4. Ensured that the overall application compiles without any errors after the modification.

Related PRs

This change does not depend on any other PRs and does not have any related PRs as of now.