| import hashlib | |
| import json | |
| from decimal import Decimal | |
| from typing import Any | |
| def _json_default(value: Any) -> str: | |
| if isinstance(value, Decimal): | |
| return str(value) | |
| return str(value) | |
| def stable_payload_hash(payload: dict[str, Any]) -> str: | |
| serialized = json.dumps(payload, sort_keys=True, default=_json_default, separators=(",", ":")) | |
| return hashlib.sha256(serialized.encode("utf-8")).hexdigest() | |