Chainscore / Chainscore/tessera
bug: Dictionary.from_json cannot deserialize when key_type is a complex dataclass (e.g. LookupTable)
- Dominant language
- Python
- Stars
- 1
- Forks
- 0
- PR merge metrics
- No merged PRs in 30d
Description
## Bug Description
When calling Dictionary.from_json(...) on a dictionary whose key type is itself a non‑primitive dataclass (for example, LookupTimestamps whose keys are LookupTable instances), the JSON-based deserializer rejects the input. It expects the JSON representation of the dictionary to use only primitive string keys, but our keys are JSON objects (or tuples), so it raises:
## Steps to Reproduce
```
state.delta = Delta.from_json({
1: {
"balance": 0,
"storage": { "": "" },
"lookup": { "": "" },
"timestamps": {
{ "hash": "", "length": 0 }: []
},
"code_hash": "",
"gas_limit": 0,
"min_gas": 0
}
})
```
## Expected Behavior
Dictionary.from_json should support non‑primitive keys whose key_type implements its own from_json (e.g. a dataclass with "hash" and "length" fields). The JSON loader should accept JSON objects as keys (by serializing them to strings, or by iterating the mapping as arrays of [key, value] pairs), then hand each object to the key type’s from_json.
## Actual Behavior
The loader refuses to accept any non‑string key. It attempts to treat the literal map’s keys directly as Python primitives (tuples, ByteArray32, etc.), then fails when it tries to feed them to LookupTable.from_json, which expects a dict.
## Screenshots

## Possible Solution
Might be-> Support the “array of pairs” format ([[keyJson, valueJson], …]) for complex keys.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.