Skip to content

Returning Error from main #4

@ghost

Description

instead of using unwrap you should prefer to use the anyhow crate and have something like (notice the ?):

fn main() -> Result<(), anyhow::Error> {
    // ...
     let input_deposit: DepositInput =
        serde_json::from_str(input_json_data)?;

let cfg = CircomConfig::<Bn254>::new(
        "./circuits/withdraw_js/withdraw.wasm",
        "./circuits/withdraw.r1cs",
    )?;

    // Insert our public inputs as key value pairs
    let mut builder = CircomBuilder::new(cfg);

    builder.push_input(
        "root",
        BigInt::parse_bytes(input_deposit.root.as_bytes(), 10)?,
    );
    builder.push_input(
        "nullifierHash",
        BigInt::parse_bytes(input_deposit.nullifier_hash.as_bytes(), 10)?,
    );
  // ...
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions