compute_variant_inputs_hash

Function compute_variant_inputs_hash 

Source
pub fn compute_variant_inputs_hash(variant_inputs: &Value) -> Result<String>
Expand description

Compute SHA-256 hash of variant_inputs JSON value.

This is the single source of truth for computing variant_inputs_hash values. It ensures consistent hashing by serializing the JSON value and hashing the result.

This function MUST be used everywhere variant_inputs_hash is computed to ensure that identity comparisons work correctly across the codebase.

§Arguments

  • variant_inputs - The variant_inputs JSON value to hash

§Returns

A string in the format “sha256:hexdigest”

§Errors

Returns an error if the JSON value cannot be serialized.

§Example

use agpm_cli::utils::{compute_variant_inputs_hash, EMPTY_VARIANT_INPUTS_HASH};
use serde_json::json;

let hash = compute_variant_inputs_hash(&json!({})).unwrap();
assert_eq!(hash, *EMPTY_VARIANT_INPUTS_HASH);