diff --git a/src/erc7730/common/json.py b/src/erc7730/common/json.py index 24a893d..e359874 100644 --- a/src/erc7730/common/json.py +++ b/src/erc7730/common/json.py @@ -1,6 +1,8 @@ import json +from collections.abc import Iterator +from json import JSONEncoder from pathlib import Path -from typing import Any +from typing import Any, override def read_jsons_with_includes(paths: list[Path]) -> Any: @@ -64,3 +66,95 @@ def _merge_dicts(d1: dict[str, Any], d2: dict[str, Any]) -> dict[str, Any]: else: merged[key] = val1 return {**d2, **merged} + + +class CompactJSONEncoder(JSONEncoder): + """A JSON Encoder that puts small containers on single lines.""" + + CONTAINER_TYPES = (list, tuple, dict) + """Container datatypes include primitives or other containers.""" + + MAX_WIDTH = 120 + """Maximum width of a container that might be put on a single line.""" + + MAX_ITEMS = 10 + """Maximum number of items in container that might be put on single line.""" + + PRIMITIVES_ONLY = False + """Only put containers containing primitives only on a single line.""" + + def __init__(self, *args: Any, **kwargs: Any) -> None: + if kwargs.get("indent") is None: + kwargs["indent"] = 2 + super().__init__(*args, **kwargs) + self.indentation_level = 0 + + @override + def encode(self, o: Any) -> str: + if isinstance(o, list | tuple): + return self._encode_list(o) + if isinstance(o, dict): + return self._encode_object(o) + if isinstance(o, float): # Use scientific notation for floats + return format(o, "g") + return json.dumps( + obj=o, + skipkeys=self.skipkeys, + ensure_ascii=self.ensure_ascii, + check_circular=self.check_circular, + allow_nan=self.allow_nan, + sort_keys=self.sort_keys, + indent=self.indent, + separators=(self.item_separator, self.key_separator), + default=self.default if hasattr(self, "default") else None, + ) + + def _encode_list(self, o: list[Any] | tuple[Any]) -> str: + if self._put_on_single_line(o): + return "[" + ", ".join(self.encode(el) for el in o) + "]" + self.indentation_level += 1 + output = [self.indent_str + self.encode(el) for el in o] + self.indentation_level -= 1 + return "[\n" + ",\n".join(output) + "\n" + self.indent_str + "]" + + def _encode_object(self, o: Any) -> str: + if not o: + return "{}" + + o = {str(k) if k is not None else "null": v for k, v in o.items()} + + if self.sort_keys: + o = dict(sorted(o.items(), key=lambda x: x[0])) + + if self._put_on_single_line(o): + return "{ " + ", ".join(f"{json.dumps(k)}: {self.encode(el)}" for k, el in o.items()) + " }" + + self.indentation_level += 1 + output = [f"{self.indent_str}{json.dumps(k)}: {self.encode(v)}" for k, v in o.items()] + self.indentation_level -= 1 + + return "{\n" + ",\n".join(output) + "\n" + self.indent_str + "}" + + @override + def iterencode(self, o: Any, _one_shot: bool = False) -> Iterator[str]: + return self.encode(o) # type: ignore + + def _put_on_single_line(self, o: Any) -> bool: + return self._primitives_only(o) and len(o) <= self.MAX_ITEMS and len(str(o)) - 2 <= self.MAX_WIDTH + + def _primitives_only(self, o: list[Any] | tuple[Any] | dict[Any, Any]) -> bool: + if not self.PRIMITIVES_ONLY: + return True + if isinstance(o, list | tuple): + return not any(isinstance(el, self.CONTAINER_TYPES) for el in o) + elif isinstance(o, dict): + return not any(isinstance(el, self.CONTAINER_TYPES) for el in o.values()) + + @property + def indent_str(self) -> str: + if isinstance(self.indent, int): + return " " * (self.indentation_level * self.indent) + elif isinstance(self.indent, str): + return self.indentation_level * self.indent + else: + raise ValueError(f"indent must either be of type int or str (is: {type(self.indent)})") diff --git a/src/erc7730/common/pydantic.py b/src/erc7730/common/pydantic.py index e717691..17b4f07 100644 --- a/src/erc7730/common/pydantic.py +++ b/src/erc7730/common/pydantic.py @@ -1,10 +1,11 @@ +import json import os from pathlib import Path from typing import Any, TypeVar from pydantic import BaseModel -from erc7730.common.json import read_json_with_includes +from erc7730.common.json import CompactJSONEncoder, read_json_with_includes _BaseModel = TypeVar("_BaseModel", bound=BaseModel) @@ -31,12 +32,12 @@ def model_from_json_file_with_includes_or_none(path: Path, model: type[_BaseMode def model_to_json_dict(obj: _BaseModel) -> dict[str, Any]: """Serialize a pydantic model into a JSON dict.""" - return obj.model_dump(by_alias=True, exclude_none=True) + return obj.model_dump(mode="json", by_alias=True, exclude_none=True) def model_to_json_str(obj: _BaseModel) -> str: """Serialize a pydantic model into a JSON string.""" - return obj.model_dump_json(by_alias=True, exclude_none=True, indent=4) + return json.dumps(model_to_json_dict(obj), indent=2, cls=CompactJSONEncoder) def model_to_json_file(path: Path, model: _BaseModel) -> None: diff --git a/tests/convert/resolved/data/definition_format_address_name_resolved.json b/tests/convert/resolved/data/definition_format_address_name_resolved.json index e736e79..b256032 100644 --- a/tests/convert/resolved/data/definition_format_address_name_resolved.json +++ b/tests/convert/resolved/data/definition_format_address_name_resolved.json @@ -1,77 +1,35 @@ { - "context": { - "eip712": { - "deployments": [ - { - "chainId": 1, - "address": "0x0000000000000000000000000000000000000000" - } + "context": { + "eip712": { + "deployments": [{ "chainId": 1, "address": "0x0000000000000000000000000000000000000000" }], + "schemas": [ + { + "primaryType": "TestPrimaryType", + "types": { + "EIP712Domain": [ + { "name": "name", "type": "string" }, + { "name": "chainId", "type": "uint256" }, + { "name": "verifyingContract", "type": "address" } ], - "schemas": [ - { - "primaryType": "TestPrimaryType", - "types": { - "EIP712Domain": [ - { - "name": "name", - "type": "string" - }, - { - "name": "chainId", - "type": "uint256" - }, - { - "name": "verifyingContract", - "type": "address" - } - ], - "TestPrimaryType": [ - { - "name": "param1", - "type": "address" - } - ] - } - } - ] - } - }, - "metadata": { - "enums": {} - }, - "display": { - "formats": { - "TestPrimaryType": { - "fields": [ - { - "path": { - "type": "data", - "absolute": true, - "elements": [ - { - "type": "field", - "identifier": "param1" - } - ] - }, - "label": "Param 1", - "format": "addressName", - "params": { - "types": [ - "wallet", - "eoa", - "token", - "contract", - "collection" - ], - "sources": [ - "local", - "ens" - ] - } - } - ] - } + "TestPrimaryType": [{ "name": "param1", "type": "address" }] + } } + ] + } + }, + "metadata": { "enums": {} }, + "display": { + "formats": { + "TestPrimaryType": { + "fields": [ + { + "path": { "type": "data", "absolute": true, "elements": [{ "type": "field", "identifier": "param1" }] }, + "label": "Param 1", + "format": "addressName", + "params": { "types": ["wallet", "eoa", "token", "contract", "collection"], "sources": ["local", "ens"] } + } + ] + } } + } } diff --git a/tests/convert/resolved/data/definition_format_amount_resolved.json b/tests/convert/resolved/data/definition_format_amount_resolved.json index a93ac1f..375a399 100644 --- a/tests/convert/resolved/data/definition_format_amount_resolved.json +++ b/tests/convert/resolved/data/definition_format_amount_resolved.json @@ -1,64 +1,34 @@ { - "context": { - "eip712": { - "deployments": [ - { - "chainId": 1, - "address": "0x0000000000000000000000000000000000000000" - } + "context": { + "eip712": { + "deployments": [{ "chainId": 1, "address": "0x0000000000000000000000000000000000000000" }], + "schemas": [ + { + "primaryType": "TestPrimaryType", + "types": { + "EIP712Domain": [ + { "name": "name", "type": "string" }, + { "name": "chainId", "type": "uint256" }, + { "name": "verifyingContract", "type": "address" } ], - "schemas": [ - { - "primaryType": "TestPrimaryType", - "types": { - "EIP712Domain": [ - { - "name": "name", - "type": "string" - }, - { - "name": "chainId", - "type": "uint256" - }, - { - "name": "verifyingContract", - "type": "address" - } - ], - "TestPrimaryType": [ - { - "name": "param1", - "type": "uint256" - } - ] - } - } - ] - } - }, - "metadata": { - "enums": {} - }, - "display": { - "formats": { - "TestPrimaryType": { - "fields": [ - { - "path": { - "type": "data", - "absolute": true, - "elements": [ - { - "type": "field", - "identifier": "param1" - } - ] - }, - "label": "Param 1", - "format": "amount" - } - ] - } + "TestPrimaryType": [{ "name": "param1", "type": "uint256" }] + } } + ] + } + }, + "metadata": { "enums": {} }, + "display": { + "formats": { + "TestPrimaryType": { + "fields": [ + { + "path": { "type": "data", "absolute": true, "elements": [{ "type": "field", "identifier": "param1" }] }, + "label": "Param 1", + "format": "amount" + } + ] + } } + } } diff --git a/tests/convert/resolved/data/definition_format_calldata_resolved.json b/tests/convert/resolved/data/definition_format_calldata_resolved.json index 07f6332..5b36543 100644 --- a/tests/convert/resolved/data/definition_format_calldata_resolved.json +++ b/tests/convert/resolved/data/definition_format_calldata_resolved.json @@ -1,81 +1,38 @@ { - "context": { - "eip712": { - "deployments": [ - { - "chainId": 1, - "address": "0x0000000000000000000000000000000000000000" - } + "context": { + "eip712": { + "deployments": [{ "chainId": 1, "address": "0x0000000000000000000000000000000000000000" }], + "schemas": [ + { + "primaryType": "TestPrimaryType", + "types": { + "EIP712Domain": [ + { "name": "name", "type": "string" }, + { "name": "chainId", "type": "uint256" }, + { "name": "verifyingContract", "type": "address" } ], - "schemas": [ - { - "primaryType": "TestPrimaryType", - "types": { - "EIP712Domain": [ - { - "name": "name", - "type": "string" - }, - { - "name": "chainId", - "type": "uint256" - }, - { - "name": "verifyingContract", - "type": "address" - } - ], - "TestPrimaryType": [ - { - "name": "param1", - "type": "address" - }, - { - "name": "param2", - "type": "bytes" - } - ] - } - } - ] + "TestPrimaryType": [{ "name": "param1", "type": "address" }, { "name": "param2", "type": "bytes" }] + } } - }, - "metadata": { - "enums": {} - }, - "display": { - "formats": { - "TestPrimaryType": { - "fields": [ - { - "path": { - "type": "data", - "absolute": true, - "elements": [ - { - "type": "field", - "identifier": "param2" - } - ] - }, - "label": "Param 2", - "format": "calldata", - "params": { - "selector": "0x00000000", - "calleePath": { - "type": "data", - "absolute": true, - "elements": [ - { - "type": "field", - "identifier": "param1" - } - ] - } - } - } - ] + ] + } + }, + "metadata": { "enums": {} }, + "display": { + "formats": { + "TestPrimaryType": { + "fields": [ + { + "path": { "type": "data", "absolute": true, "elements": [{ "type": "field", "identifier": "param2" }] }, + "label": "Param 2", + "format": "calldata", + "params": { + "selector": "0x00000000", + "calleePath": { "type": "data", "absolute": true, "elements": [{ "type": "field", "identifier": "param1" }] } } - } + } + ] + } } + } } diff --git a/tests/convert/resolved/data/definition_format_date_resolved.json b/tests/convert/resolved/data/definition_format_date_resolved.json index 664032f..90c322b 100644 --- a/tests/convert/resolved/data/definition_format_date_resolved.json +++ b/tests/convert/resolved/data/definition_format_date_resolved.json @@ -1,67 +1,35 @@ { - "context": { - "eip712": { - "deployments": [ - { - "chainId": 1, - "address": "0x0000000000000000000000000000000000000000" - } + "context": { + "eip712": { + "deployments": [{ "chainId": 1, "address": "0x0000000000000000000000000000000000000000" }], + "schemas": [ + { + "primaryType": "TestPrimaryType", + "types": { + "EIP712Domain": [ + { "name": "name", "type": "string" }, + { "name": "chainId", "type": "uint256" }, + { "name": "verifyingContract", "type": "address" } ], - "schemas": [ - { - "primaryType": "TestPrimaryType", - "types": { - "EIP712Domain": [ - { - "name": "name", - "type": "string" - }, - { - "name": "chainId", - "type": "uint256" - }, - { - "name": "verifyingContract", - "type": "address" - } - ], - "TestPrimaryType": [ - { - "name": "param1", - "type": "uint256" - } - ] - } - } - ] - } - }, - "metadata": { - "enums": {} - }, - "display": { - "formats": { - "TestPrimaryType": { - "fields": [ - { - "path": { - "type": "data", - "absolute": true, - "elements": [ - { - "type": "field", - "identifier": "param1" - } - ] - }, - "label": "Param 1", - "format": "date", - "params": { - "encoding": "blockheight" - } - } - ] - } + "TestPrimaryType": [{ "name": "param1", "type": "uint256" }] + } } + ] + } + }, + "metadata": { "enums": {} }, + "display": { + "formats": { + "TestPrimaryType": { + "fields": [ + { + "path": { "type": "data", "absolute": true, "elements": [{ "type": "field", "identifier": "param1" }] }, + "label": "Param 1", + "format": "date", + "params": { "encoding": "blockheight" } + } + ] + } } + } } diff --git a/tests/convert/resolved/data/definition_format_duration_resolved.json b/tests/convert/resolved/data/definition_format_duration_resolved.json index 13640ba..684e7c3 100644 --- a/tests/convert/resolved/data/definition_format_duration_resolved.json +++ b/tests/convert/resolved/data/definition_format_duration_resolved.json @@ -1,64 +1,34 @@ { - "context": { - "eip712": { - "deployments": [ - { - "chainId": 1, - "address": "0x0000000000000000000000000000000000000000" - } + "context": { + "eip712": { + "deployments": [{ "chainId": 1, "address": "0x0000000000000000000000000000000000000000" }], + "schemas": [ + { + "primaryType": "TestPrimaryType", + "types": { + "EIP712Domain": [ + { "name": "name", "type": "string" }, + { "name": "chainId", "type": "uint256" }, + { "name": "verifyingContract", "type": "address" } ], - "schemas": [ - { - "primaryType": "TestPrimaryType", - "types": { - "EIP712Domain": [ - { - "name": "name", - "type": "string" - }, - { - "name": "chainId", - "type": "uint256" - }, - { - "name": "verifyingContract", - "type": "address" - } - ], - "TestPrimaryType": [ - { - "name": "param1", - "type": "uint256" - } - ] - } - } - ] - } - }, - "metadata": { - "enums": {} - }, - "display": { - "formats": { - "TestPrimaryType": { - "fields": [ - { - "path": { - "type": "data", - "absolute": true, - "elements": [ - { - "type": "field", - "identifier": "param1" - } - ] - }, - "label": "Param 1", - "format": "duration" - } - ] - } + "TestPrimaryType": [{ "name": "param1", "type": "uint256" }] + } } + ] + } + }, + "metadata": { "enums": {} }, + "display": { + "formats": { + "TestPrimaryType": { + "fields": [ + { + "path": { "type": "data", "absolute": true, "elements": [{ "type": "field", "identifier": "param1" }] }, + "label": "Param 1", + "format": "duration" + } + ] + } } + } } diff --git a/tests/convert/resolved/data/definition_format_enum_resolved.json b/tests/convert/resolved/data/definition_format_enum_resolved.json index e43e07c..fac346a 100644 --- a/tests/convert/resolved/data/definition_format_enum_resolved.json +++ b/tests/convert/resolved/data/definition_format_enum_resolved.json @@ -1,72 +1,35 @@ { - "context": { - "eip712": { - "deployments": [ - { - "chainId": 1, - "address": "0x0000000000000000000000000000000000000000" - } + "context": { + "eip712": { + "deployments": [{ "chainId": 1, "address": "0x0000000000000000000000000000000000000000" }], + "schemas": [ + { + "primaryType": "TestPrimaryType", + "types": { + "EIP712Domain": [ + { "name": "name", "type": "string" }, + { "name": "chainId", "type": "uint256" }, + { "name": "verifyingContract", "type": "address" } ], - "schemas": [ - { - "primaryType": "TestPrimaryType", - "types": { - "EIP712Domain": [ - { - "name": "name", - "type": "string" - }, - { - "name": "chainId", - "type": "uint256" - }, - { - "name": "verifyingContract", - "type": "address" - } - ], - "TestPrimaryType": [ - { - "name": "param1", - "type": "uint256" - } - ] - } - } - ] - } - }, - "metadata": { - "enums": { - "testEnum": { - "1": "stable", - "2": "variable" - } - } - }, - "display": { - "formats": { - "TestPrimaryType": { - "fields": [ - { - "path": { - "type": "data", - "absolute": true, - "elements": [ - { - "type": "field", - "identifier": "param1" - } - ] - }, - "label": "Param 1", - "format": "enum", - "params": { - "enumId": "testEnum" - } - } - ] - } + "TestPrimaryType": [{ "name": "param1", "type": "uint256" }] + } } + ] + } + }, + "metadata": { "enums": { "testEnum": { "1": "stable", "2": "variable" } } }, + "display": { + "formats": { + "TestPrimaryType": { + "fields": [ + { + "path": { "type": "data", "absolute": true, "elements": [{ "type": "field", "identifier": "param1" }] }, + "label": "Param 1", + "format": "enum", + "params": { "enumId": "testEnum" } + } + ] + } } + } } diff --git a/tests/convert/resolved/data/definition_format_nft_name_resolved.json b/tests/convert/resolved/data/definition_format_nft_name_resolved.json index a68d220..fa14532 100644 --- a/tests/convert/resolved/data/definition_format_nft_name_resolved.json +++ b/tests/convert/resolved/data/definition_format_nft_name_resolved.json @@ -1,76 +1,41 @@ { - "context": { - "eip712": { - "deployments": [ - { - "chainId": 1, - "address": "0x0000000000000000000000000000000000000000" - } + "context": { + "eip712": { + "deployments": [{ "chainId": 1, "address": "0x0000000000000000000000000000000000000000" }], + "schemas": [ + { + "primaryType": "TestPrimaryType", + "types": { + "EIP712Domain": [ + { "name": "name", "type": "string" }, + { "name": "chainId", "type": "uint256" }, + { "name": "verifyingContract", "type": "address" } ], - "schemas": [ - { - "primaryType": "TestPrimaryType", - "types": { - "EIP712Domain": [ - { - "name": "name", - "type": "string" - }, - { - "name": "chainId", - "type": "uint256" - }, - { - "name": "verifyingContract", - "type": "address" - } - ], - "TestPrimaryType": [ - { - "name": "param1", - "type": "string" - } - ] - } - } - ] + "TestPrimaryType": [{ "name": "param1", "type": "string" }] + } } - }, - "metadata": { - "enums": {} - }, - "display": { - "formats": { - "TestPrimaryType": { - "fields": [ - { - "path": { - "type": "data", - "absolute": true, - "elements": [ - { - "type": "field", - "identifier": "param1" - } - ] - }, - "label": "Param 1", - "format": "nftName", - "params": { - "collectionPath": { - "type": "data", - "absolute": true, - "elements": [ - { - "type": "field", - "identifier": "0x0000000000000000000000000000000000000001" - } - ] - } - } - } - ] + ] + } + }, + "metadata": { "enums": {} }, + "display": { + "formats": { + "TestPrimaryType": { + "fields": [ + { + "path": { "type": "data", "absolute": true, "elements": [{ "type": "field", "identifier": "param1" }] }, + "label": "Param 1", + "format": "nftName", + "params": { + "collectionPath": { + "type": "data", + "absolute": true, + "elements": [{ "type": "field", "identifier": "0x0000000000000000000000000000000000000001" }] + } } - } + } + ] + } } + } } diff --git a/tests/convert/resolved/data/definition_format_raw_resolved.json b/tests/convert/resolved/data/definition_format_raw_resolved.json index 57f32bf..0b1c8b7 100644 --- a/tests/convert/resolved/data/definition_format_raw_resolved.json +++ b/tests/convert/resolved/data/definition_format_raw_resolved.json @@ -1,64 +1,34 @@ { - "context": { - "eip712": { - "deployments": [ - { - "chainId": 1, - "address": "0x0000000000000000000000000000000000000000" - } + "context": { + "eip712": { + "deployments": [{ "chainId": 1, "address": "0x0000000000000000000000000000000000000000" }], + "schemas": [ + { + "primaryType": "TestPrimaryType", + "types": { + "EIP712Domain": [ + { "name": "name", "type": "string" }, + { "name": "chainId", "type": "uint256" }, + { "name": "verifyingContract", "type": "address" } ], - "schemas": [ - { - "primaryType": "TestPrimaryType", - "types": { - "EIP712Domain": [ - { - "name": "name", - "type": "string" - }, - { - "name": "chainId", - "type": "uint256" - }, - { - "name": "verifyingContract", - "type": "address" - } - ], - "TestPrimaryType": [ - { - "name": "param1", - "type": "string" - } - ] - } - } - ] - } - }, - "metadata": { - "enums": {} - }, - "display": { - "formats": { - "TestPrimaryType": { - "fields": [ - { - "path": { - "type": "data", - "absolute": true, - "elements": [ - { - "type": "field", - "identifier": "param1" - } - ] - }, - "label": "Param 1", - "format": "raw" - } - ] - } + "TestPrimaryType": [{ "name": "param1", "type": "string" }] + } } + ] + } + }, + "metadata": { "enums": {} }, + "display": { + "formats": { + "TestPrimaryType": { + "fields": [ + { + "path": { "type": "data", "absolute": true, "elements": [{ "type": "field", "identifier": "param1" }] }, + "label": "Param 1", + "format": "raw" + } + ] + } } + } } diff --git a/tests/convert/resolved/data/definition_format_token_amount_resolved.json b/tests/convert/resolved/data/definition_format_token_amount_resolved.json index cc0c560..3578863 100644 --- a/tests/convert/resolved/data/definition_format_token_amount_resolved.json +++ b/tests/convert/resolved/data/definition_format_token_amount_resolved.json @@ -1,80 +1,35 @@ { - "context": { - "eip712": { - "deployments": [ - { - "chainId": 1, - "address": "0x0000000000000000000000000000000000000000" - } + "context": { + "eip712": { + "deployments": [{ "chainId": 1, "address": "0x0000000000000000000000000000000000000000" }], + "schemas": [ + { + "primaryType": "TestPrimaryType", + "types": { + "EIP712Domain": [ + { "name": "name", "type": "string" }, + { "name": "chainId", "type": "uint256" }, + { "name": "verifyingContract", "type": "address" } ], - "schemas": [ - { - "primaryType": "TestPrimaryType", - "types": { - "EIP712Domain": [ - { - "name": "name", - "type": "string" - }, - { - "name": "chainId", - "type": "uint256" - }, - { - "name": "verifyingContract", - "type": "address" - } - ], - "TestPrimaryType": [ - { - "name": "token1", - "type": "address" - }, - { - "name": "token2", - "type": "address" - } - ] - } - } - ] - } - }, - "metadata": { - "enums": {} - }, - "display": { - "formats": { - "TestPrimaryType": { - "fields": [ - { - "path": { - "type": "data", - "absolute": true, - "elements": [ - { - "type": "field", - "identifier": "param1" - } - ] - }, - "label": "Param 1", - "format": "tokenAmount", - "params": { - "tokenPath": { - "type": "data", - "absolute": true, - "elements": [ - { - "type": "field", - "identifier": "token1" - } - ] - } - } - } - ] - } + "TestPrimaryType": [{ "name": "token1", "type": "address" }, { "name": "token2", "type": "address" }] + } } + ] + } + }, + "metadata": { "enums": {} }, + "display": { + "formats": { + "TestPrimaryType": { + "fields": [ + { + "path": { "type": "data", "absolute": true, "elements": [{ "type": "field", "identifier": "param1" }] }, + "label": "Param 1", + "format": "tokenAmount", + "params": { "tokenPath": { "type": "data", "absolute": true, "elements": [{ "type": "field", "identifier": "token1" }] } } + } + ] + } } + } } diff --git a/tests/convert/resolved/data/definition_format_unit_resolved.json b/tests/convert/resolved/data/definition_format_unit_resolved.json index dd3b624..ecd89d2 100644 --- a/tests/convert/resolved/data/definition_format_unit_resolved.json +++ b/tests/convert/resolved/data/definition_format_unit_resolved.json @@ -1,69 +1,35 @@ { - "context": { - "eip712": { - "deployments": [ - { - "chainId": 1, - "address": "0x0000000000000000000000000000000000000000" - } + "context": { + "eip712": { + "deployments": [{ "chainId": 1, "address": "0x0000000000000000000000000000000000000000" }], + "schemas": [ + { + "primaryType": "TestPrimaryType", + "types": { + "EIP712Domain": [ + { "name": "name", "type": "string" }, + { "name": "chainId", "type": "uint256" }, + { "name": "verifyingContract", "type": "address" } ], - "schemas": [ - { - "primaryType": "TestPrimaryType", - "types": { - "EIP712Domain": [ - { - "name": "name", - "type": "string" - }, - { - "name": "chainId", - "type": "uint256" - }, - { - "name": "verifyingContract", - "type": "address" - } - ], - "TestPrimaryType": [ - { - "name": "param1", - "type": "uint256" - } - ] - } - } - ] - } - }, - "metadata": { - "enums": {} - }, - "display": { - "formats": { - "TestPrimaryType": { - "fields": [ - { - "path": { - "type": "data", - "absolute": true, - "elements": [ - { - "type": "field", - "identifier": "param1" - } - ] - }, - "label": "Param 1", - "format": "unit", - "params": { - "base": "km/h", - "decimals": 2, - "prefix": true - } - } - ] - } + "TestPrimaryType": [{ "name": "param1", "type": "uint256" }] + } } + ] + } + }, + "metadata": { "enums": {} }, + "display": { + "formats": { + "TestPrimaryType": { + "fields": [ + { + "path": { "type": "data", "absolute": true, "elements": [{ "type": "field", "identifier": "param1" }] }, + "label": "Param 1", + "format": "unit", + "params": { "base": "km/h", "decimals": 2, "prefix": true } + } + ] + } } + } } diff --git a/tests/convert/resolved/data/definition_override_label_resolved.json b/tests/convert/resolved/data/definition_override_label_resolved.json index 7bc9732..5b617ef 100644 --- a/tests/convert/resolved/data/definition_override_label_resolved.json +++ b/tests/convert/resolved/data/definition_override_label_resolved.json @@ -1,64 +1,34 @@ { - "context": { - "eip712": { - "deployments": [ - { - "chainId": 1, - "address": "0x0000000000000000000000000000000000000000" - } + "context": { + "eip712": { + "deployments": [{ "chainId": 1, "address": "0x0000000000000000000000000000000000000000" }], + "schemas": [ + { + "primaryType": "TestPrimaryType", + "types": { + "EIP712Domain": [ + { "name": "name", "type": "string" }, + { "name": "chainId", "type": "uint256" }, + { "name": "verifyingContract", "type": "address" } ], - "schemas": [ - { - "primaryType": "TestPrimaryType", - "types": { - "EIP712Domain": [ - { - "name": "name", - "type": "string" - }, - { - "name": "chainId", - "type": "uint256" - }, - { - "name": "verifyingContract", - "type": "address" - } - ], - "TestPrimaryType": [ - { - "name": "param1", - "type": "string" - } - ] - } - } - ] - } - }, - "metadata": { - "enums": {} - }, - "display": { - "formats": { - "TestPrimaryType": { - "fields": [ - { - "path": { - "type": "data", - "absolute": true, - "elements": [ - { - "type": "field", - "identifier": "param1" - } - ] - }, - "label": "Param 1 custom", - "format": "raw" - } - ] - } + "TestPrimaryType": [{ "name": "param1", "type": "string" }] + } } + ] + } + }, + "metadata": { "enums": {} }, + "display": { + "formats": { + "TestPrimaryType": { + "fields": [ + { + "path": { "type": "data", "absolute": true, "elements": [{ "type": "field", "identifier": "param1" }] }, + "label": "Param 1 custom", + "format": "raw" + } + ] + } } + } } diff --git a/tests/convert/resolved/data/definition_override_params_resolved.json b/tests/convert/resolved/data/definition_override_params_resolved.json index c677628..20f868c 100644 --- a/tests/convert/resolved/data/definition_override_params_resolved.json +++ b/tests/convert/resolved/data/definition_override_params_resolved.json @@ -1,80 +1,35 @@ { - "context": { - "eip712": { - "deployments": [ - { - "chainId": 1, - "address": "0x0000000000000000000000000000000000000000" - } + "context": { + "eip712": { + "deployments": [{ "chainId": 1, "address": "0x0000000000000000000000000000000000000000" }], + "schemas": [ + { + "primaryType": "TestPrimaryType", + "types": { + "EIP712Domain": [ + { "name": "name", "type": "string" }, + { "name": "chainId", "type": "uint256" }, + { "name": "verifyingContract", "type": "address" } ], - "schemas": [ - { - "primaryType": "TestPrimaryType", - "types": { - "EIP712Domain": [ - { - "name": "name", - "type": "string" - }, - { - "name": "chainId", - "type": "uint256" - }, - { - "name": "verifyingContract", - "type": "address" - } - ], - "TestPrimaryType": [ - { - "name": "token1", - "type": "address" - }, - { - "name": "token2", - "type": "address" - } - ] - } - } - ] - } - }, - "metadata": { - "enums": {} - }, - "display": { - "formats": { - "TestPrimaryType": { - "fields": [ - { - "path": { - "type": "data", - "absolute": true, - "elements": [ - { - "type": "field", - "identifier": "param1" - } - ] - }, - "label": "Param 1", - "format": "tokenAmount", - "params": { - "tokenPath": { - "type": "data", - "absolute": true, - "elements": [ - { - "type": "field", - "identifier": "token2" - } - ] - } - } - } - ] - } + "TestPrimaryType": [{ "name": "token1", "type": "address" }, { "name": "token2", "type": "address" }] + } } + ] + } + }, + "metadata": { "enums": {} }, + "display": { + "formats": { + "TestPrimaryType": { + "fields": [ + { + "path": { "type": "data", "absolute": true, "elements": [{ "type": "field", "identifier": "param1" }] }, + "label": "Param 1", + "format": "tokenAmount", + "params": { "tokenPath": { "type": "data", "absolute": true, "elements": [{ "type": "field", "identifier": "token2" }] } } + } + ] + } } + } } diff --git a/tests/convert/resolved/data/definition_using_constants_resolved.json b/tests/convert/resolved/data/definition_using_constants_resolved.json index c451cbf..701f7fc 100644 --- a/tests/convert/resolved/data/definition_using_constants_resolved.json +++ b/tests/convert/resolved/data/definition_using_constants_resolved.json @@ -1,85 +1,40 @@ { - "context": { - "eip712": { - "deployments": [ - { - "chainId": 1, - "address": "0x0000000000000000000000000000000000000000" - } + "context": { + "eip712": { + "deployments": [{ "chainId": 1, "address": "0x0000000000000000000000000000000000000000" }], + "schemas": [ + { + "primaryType": "TestPrimaryType", + "types": { + "EIP712Domain": [ + { "name": "name", "type": "string" }, + { "name": "chainId", "type": "uint256" }, + { "name": "verifyingContract", "type": "address" } ], - "schemas": [ - { - "primaryType": "TestPrimaryType", - "types": { - "EIP712Domain": [ - { - "name": "name", - "type": "string" - }, - { - "name": "chainId", - "type": "uint256" - }, - { - "name": "verifyingContract", - "type": "address" - } - ], - "TestPrimaryType": [ - { - "name": "token1", - "type": "address" - }, - { - "name": "token2", - "type": "address" - } - ] - } - } - ] + "TestPrimaryType": [{ "name": "token1", "type": "address" }, { "name": "token2", "type": "address" }] + } } - }, - "metadata": { - "enums": {} - }, - "display": { - "formats": { - "TestPrimaryType": { - "fields": [ - { - "path": { - "type": "data", - "absolute": true, - "elements": [ - { - "type": "field", - "identifier": "param1" - } - ] - }, - "label": "Param 1", - "format": "tokenAmount", - "params": { - "tokenPath": { - "type": "data", - "absolute": true, - "elements": [ - { - "type": "field", - "identifier": "token1" - } - ] - }, - "nativeCurrencyAddress": [ - "0x0000000000000000000000000000000000000001" - ], - "threshold": "0xffffffff", - "message": "Max" - } - } - ] + ] + } + }, + "metadata": { "enums": {} }, + "display": { + "formats": { + "TestPrimaryType": { + "fields": [ + { + "path": { "type": "data", "absolute": true, "elements": [{ "type": "field", "identifier": "param1" }] }, + "label": "Param 1", + "format": "tokenAmount", + "params": { + "tokenPath": { "type": "data", "absolute": true, "elements": [{ "type": "field", "identifier": "token1" }] }, + "nativeCurrencyAddress": ["0x0000000000000000000000000000000000000001"], + "threshold": "0xffffffff", + "message": "Max" } - } + } + ] + } } + } } diff --git a/tests/convert/resolved/data/format_address_name_resolved.json b/tests/convert/resolved/data/format_address_name_resolved.json index 61776c0..44e1618 100644 --- a/tests/convert/resolved/data/format_address_name_resolved.json +++ b/tests/convert/resolved/data/format_address_name_resolved.json @@ -1,77 +1,35 @@ { - "context": { - "eip712": { - "deployments": [ - { - "chainId": 1, - "address": "0x0000000000000000000000000000000000000000" - } + "context": { + "eip712": { + "deployments": [{ "chainId": 1, "address": "0x0000000000000000000000000000000000000000" }], + "schemas": [ + { + "primaryType": "TestPrimaryType", + "types": { + "EIP712Domain": [ + { "name": "name", "type": "string" }, + { "name": "chainId", "type": "uint256" }, + { "name": "verifyingContract", "type": "address" } ], - "schemas": [ - { - "primaryType": "TestPrimaryType", - "types": { - "EIP712Domain": [ - { - "name": "name", - "type": "string" - }, - { - "name": "chainId", - "type": "uint256" - }, - { - "name": "verifyingContract", - "type": "address" - } - ], - "TestPrimaryType": [ - { - "name": "param1", - "type": "address" - } - ] - } - } - ] - } - }, - "metadata": { - "enums": {} - }, - "display": { - "formats": { - "TestPrimaryType": { - "fields": [ - { - "path": { - "type": "data", - "absolute": true, - "elements": [ - { - "type": "field", - "identifier": "param1" - } - ] - }, - "label": "All parameters specified", - "format": "addressName", - "params": { - "types": [ - "wallet", - "eoa", - "token", - "contract", - "collection" - ], - "sources": [ - "local", - "ens" - ] - } - } - ] - } + "TestPrimaryType": [{ "name": "param1", "type": "address" }] + } } + ] + } + }, + "metadata": { "enums": {} }, + "display": { + "formats": { + "TestPrimaryType": { + "fields": [ + { + "path": { "type": "data", "absolute": true, "elements": [{ "type": "field", "identifier": "param1" }] }, + "label": "All parameters specified", + "format": "addressName", + "params": { "types": ["wallet", "eoa", "token", "contract", "collection"], "sources": ["local", "ens"] } + } + ] + } } + } } diff --git a/tests/convert/resolved/data/format_address_name_using_constants_resolved.json b/tests/convert/resolved/data/format_address_name_using_constants_resolved.json index 61776c0..44e1618 100644 --- a/tests/convert/resolved/data/format_address_name_using_constants_resolved.json +++ b/tests/convert/resolved/data/format_address_name_using_constants_resolved.json @@ -1,77 +1,35 @@ { - "context": { - "eip712": { - "deployments": [ - { - "chainId": 1, - "address": "0x0000000000000000000000000000000000000000" - } + "context": { + "eip712": { + "deployments": [{ "chainId": 1, "address": "0x0000000000000000000000000000000000000000" }], + "schemas": [ + { + "primaryType": "TestPrimaryType", + "types": { + "EIP712Domain": [ + { "name": "name", "type": "string" }, + { "name": "chainId", "type": "uint256" }, + { "name": "verifyingContract", "type": "address" } ], - "schemas": [ - { - "primaryType": "TestPrimaryType", - "types": { - "EIP712Domain": [ - { - "name": "name", - "type": "string" - }, - { - "name": "chainId", - "type": "uint256" - }, - { - "name": "verifyingContract", - "type": "address" - } - ], - "TestPrimaryType": [ - { - "name": "param1", - "type": "address" - } - ] - } - } - ] - } - }, - "metadata": { - "enums": {} - }, - "display": { - "formats": { - "TestPrimaryType": { - "fields": [ - { - "path": { - "type": "data", - "absolute": true, - "elements": [ - { - "type": "field", - "identifier": "param1" - } - ] - }, - "label": "All parameters specified", - "format": "addressName", - "params": { - "types": [ - "wallet", - "eoa", - "token", - "contract", - "collection" - ], - "sources": [ - "local", - "ens" - ] - } - } - ] - } + "TestPrimaryType": [{ "name": "param1", "type": "address" }] + } } + ] + } + }, + "metadata": { "enums": {} }, + "display": { + "formats": { + "TestPrimaryType": { + "fields": [ + { + "path": { "type": "data", "absolute": true, "elements": [{ "type": "field", "identifier": "param1" }] }, + "label": "All parameters specified", + "format": "addressName", + "params": { "types": ["wallet", "eoa", "token", "contract", "collection"], "sources": ["local", "ens"] } + } + ] + } } + } } diff --git a/tests/convert/resolved/data/format_amount_resolved.json b/tests/convert/resolved/data/format_amount_resolved.json index a93ac1f..375a399 100644 --- a/tests/convert/resolved/data/format_amount_resolved.json +++ b/tests/convert/resolved/data/format_amount_resolved.json @@ -1,64 +1,34 @@ { - "context": { - "eip712": { - "deployments": [ - { - "chainId": 1, - "address": "0x0000000000000000000000000000000000000000" - } + "context": { + "eip712": { + "deployments": [{ "chainId": 1, "address": "0x0000000000000000000000000000000000000000" }], + "schemas": [ + { + "primaryType": "TestPrimaryType", + "types": { + "EIP712Domain": [ + { "name": "name", "type": "string" }, + { "name": "chainId", "type": "uint256" }, + { "name": "verifyingContract", "type": "address" } ], - "schemas": [ - { - "primaryType": "TestPrimaryType", - "types": { - "EIP712Domain": [ - { - "name": "name", - "type": "string" - }, - { - "name": "chainId", - "type": "uint256" - }, - { - "name": "verifyingContract", - "type": "address" - } - ], - "TestPrimaryType": [ - { - "name": "param1", - "type": "uint256" - } - ] - } - } - ] - } - }, - "metadata": { - "enums": {} - }, - "display": { - "formats": { - "TestPrimaryType": { - "fields": [ - { - "path": { - "type": "data", - "absolute": true, - "elements": [ - { - "type": "field", - "identifier": "param1" - } - ] - }, - "label": "Param 1", - "format": "amount" - } - ] - } + "TestPrimaryType": [{ "name": "param1", "type": "uint256" }] + } } + ] + } + }, + "metadata": { "enums": {} }, + "display": { + "formats": { + "TestPrimaryType": { + "fields": [ + { + "path": { "type": "data", "absolute": true, "elements": [{ "type": "field", "identifier": "param1" }] }, + "label": "Param 1", + "format": "amount" + } + ] + } } + } } diff --git a/tests/convert/resolved/data/format_amount_using_constants_resolved.json b/tests/convert/resolved/data/format_amount_using_constants_resolved.json index a93ac1f..375a399 100644 --- a/tests/convert/resolved/data/format_amount_using_constants_resolved.json +++ b/tests/convert/resolved/data/format_amount_using_constants_resolved.json @@ -1,64 +1,34 @@ { - "context": { - "eip712": { - "deployments": [ - { - "chainId": 1, - "address": "0x0000000000000000000000000000000000000000" - } + "context": { + "eip712": { + "deployments": [{ "chainId": 1, "address": "0x0000000000000000000000000000000000000000" }], + "schemas": [ + { + "primaryType": "TestPrimaryType", + "types": { + "EIP712Domain": [ + { "name": "name", "type": "string" }, + { "name": "chainId", "type": "uint256" }, + { "name": "verifyingContract", "type": "address" } ], - "schemas": [ - { - "primaryType": "TestPrimaryType", - "types": { - "EIP712Domain": [ - { - "name": "name", - "type": "string" - }, - { - "name": "chainId", - "type": "uint256" - }, - { - "name": "verifyingContract", - "type": "address" - } - ], - "TestPrimaryType": [ - { - "name": "param1", - "type": "uint256" - } - ] - } - } - ] - } - }, - "metadata": { - "enums": {} - }, - "display": { - "formats": { - "TestPrimaryType": { - "fields": [ - { - "path": { - "type": "data", - "absolute": true, - "elements": [ - { - "type": "field", - "identifier": "param1" - } - ] - }, - "label": "Param 1", - "format": "amount" - } - ] - } + "TestPrimaryType": [{ "name": "param1", "type": "uint256" }] + } } + ] + } + }, + "metadata": { "enums": {} }, + "display": { + "formats": { + "TestPrimaryType": { + "fields": [ + { + "path": { "type": "data", "absolute": true, "elements": [{ "type": "field", "identifier": "param1" }] }, + "label": "Param 1", + "format": "amount" + } + ] + } } + } } diff --git a/tests/convert/resolved/data/format_calldata_resolved.json b/tests/convert/resolved/data/format_calldata_resolved.json index f915a12..ecadac5 100644 --- a/tests/convert/resolved/data/format_calldata_resolved.json +++ b/tests/convert/resolved/data/format_calldata_resolved.json @@ -1,107 +1,44 @@ { - "context": { - "eip712": { - "deployments": [ - { - "chainId": 1, - "address": "0x0000000000000000000000000000000000000000" - } + "context": { + "eip712": { + "deployments": [{ "chainId": 1, "address": "0x0000000000000000000000000000000000000000" }], + "schemas": [ + { + "primaryType": "TestPrimaryType", + "types": { + "EIP712Domain": [ + { "name": "name", "type": "string" }, + { "name": "chainId", "type": "uint256" }, + { "name": "verifyingContract", "type": "address" } ], - "schemas": [ - { - "primaryType": "TestPrimaryType", - "types": { - "EIP712Domain": [ - { - "name": "name", - "type": "string" - }, - { - "name": "chainId", - "type": "uint256" - }, - { - "name": "verifyingContract", - "type": "address" - } - ], - "TestPrimaryType": [ - { - "name": "param1", - "type": "address" - }, - { - "name": "param2", - "type": "bytes" - } - ] - } - } - ] + "TestPrimaryType": [{ "name": "param1", "type": "address" }, { "name": "param2", "type": "bytes" }] + } } - }, - "metadata": { - "enums": {} - }, - "display": { - "formats": { - "TestPrimaryType": { - "fields": [ - { - "path": { - "type": "data", - "absolute": true, - "elements": [ - { - "type": "field", - "identifier": "param2" - } - ] - }, - "label": "With minimal set of parameters specified", - "format": "calldata", - "params": { - "calleePath": { - "type": "data", - "absolute": true, - "elements": [ - { - "type": "field", - "identifier": "param1" - } - ] - } - } - }, - { - "path": { - "type": "data", - "absolute": true, - "elements": [ - { - "type": "field", - "identifier": "param2" - } - ] - }, - "label": "With all parameters specified", - "format": "calldata", - "params": { - "selector": "0x00000000", - "calleePath": { - "type": "data", - "absolute": true, - "elements": [ - { - "type": "field", - "identifier": "param1" - } - ] - } - } - } - ] + ] + } + }, + "metadata": { "enums": {} }, + "display": { + "formats": { + "TestPrimaryType": { + "fields": [ + { + "path": { "type": "data", "absolute": true, "elements": [{ "type": "field", "identifier": "param2" }] }, + "label": "With minimal set of parameters specified", + "format": "calldata", + "params": { "calleePath": { "type": "data", "absolute": true, "elements": [{ "type": "field", "identifier": "param1" }] } } + }, + { + "path": { "type": "data", "absolute": true, "elements": [{ "type": "field", "identifier": "param2" }] }, + "label": "With all parameters specified", + "format": "calldata", + "params": { + "selector": "0x00000000", + "calleePath": { "type": "data", "absolute": true, "elements": [{ "type": "field", "identifier": "param1" }] } } - } + } + ] + } } + } } diff --git a/tests/convert/resolved/data/format_calldata_using_constants_resolved.json b/tests/convert/resolved/data/format_calldata_using_constants_resolved.json index f915a12..ecadac5 100644 --- a/tests/convert/resolved/data/format_calldata_using_constants_resolved.json +++ b/tests/convert/resolved/data/format_calldata_using_constants_resolved.json @@ -1,107 +1,44 @@ { - "context": { - "eip712": { - "deployments": [ - { - "chainId": 1, - "address": "0x0000000000000000000000000000000000000000" - } + "context": { + "eip712": { + "deployments": [{ "chainId": 1, "address": "0x0000000000000000000000000000000000000000" }], + "schemas": [ + { + "primaryType": "TestPrimaryType", + "types": { + "EIP712Domain": [ + { "name": "name", "type": "string" }, + { "name": "chainId", "type": "uint256" }, + { "name": "verifyingContract", "type": "address" } ], - "schemas": [ - { - "primaryType": "TestPrimaryType", - "types": { - "EIP712Domain": [ - { - "name": "name", - "type": "string" - }, - { - "name": "chainId", - "type": "uint256" - }, - { - "name": "verifyingContract", - "type": "address" - } - ], - "TestPrimaryType": [ - { - "name": "param1", - "type": "address" - }, - { - "name": "param2", - "type": "bytes" - } - ] - } - } - ] + "TestPrimaryType": [{ "name": "param1", "type": "address" }, { "name": "param2", "type": "bytes" }] + } } - }, - "metadata": { - "enums": {} - }, - "display": { - "formats": { - "TestPrimaryType": { - "fields": [ - { - "path": { - "type": "data", - "absolute": true, - "elements": [ - { - "type": "field", - "identifier": "param2" - } - ] - }, - "label": "With minimal set of parameters specified", - "format": "calldata", - "params": { - "calleePath": { - "type": "data", - "absolute": true, - "elements": [ - { - "type": "field", - "identifier": "param1" - } - ] - } - } - }, - { - "path": { - "type": "data", - "absolute": true, - "elements": [ - { - "type": "field", - "identifier": "param2" - } - ] - }, - "label": "With all parameters specified", - "format": "calldata", - "params": { - "selector": "0x00000000", - "calleePath": { - "type": "data", - "absolute": true, - "elements": [ - { - "type": "field", - "identifier": "param1" - } - ] - } - } - } - ] + ] + } + }, + "metadata": { "enums": {} }, + "display": { + "formats": { + "TestPrimaryType": { + "fields": [ + { + "path": { "type": "data", "absolute": true, "elements": [{ "type": "field", "identifier": "param2" }] }, + "label": "With minimal set of parameters specified", + "format": "calldata", + "params": { "calleePath": { "type": "data", "absolute": true, "elements": [{ "type": "field", "identifier": "param1" }] } } + }, + { + "path": { "type": "data", "absolute": true, "elements": [{ "type": "field", "identifier": "param2" }] }, + "label": "With all parameters specified", + "format": "calldata", + "params": { + "selector": "0x00000000", + "calleePath": { "type": "data", "absolute": true, "elements": [{ "type": "field", "identifier": "param1" }] } } - } + } + ] + } } + } } diff --git a/tests/convert/resolved/data/format_date_resolved.json b/tests/convert/resolved/data/format_date_resolved.json index f130b79..b44315f 100644 --- a/tests/convert/resolved/data/format_date_resolved.json +++ b/tests/convert/resolved/data/format_date_resolved.json @@ -1,84 +1,41 @@ { - "context": { - "eip712": { - "deployments": [ - { - "chainId": 1, - "address": "0x0000000000000000000000000000000000000000" - } + "context": { + "eip712": { + "deployments": [{ "chainId": 1, "address": "0x0000000000000000000000000000000000000000" }], + "schemas": [ + { + "primaryType": "TestPrimaryType", + "types": { + "EIP712Domain": [ + { "name": "name", "type": "string" }, + { "name": "chainId", "type": "uint256" }, + { "name": "verifyingContract", "type": "address" } ], - "schemas": [ - { - "primaryType": "TestPrimaryType", - "types": { - "EIP712Domain": [ - { - "name": "name", - "type": "string" - }, - { - "name": "chainId", - "type": "uint256" - }, - { - "name": "verifyingContract", - "type": "address" - } - ], - "TestPrimaryType": [ - { - "name": "param1", - "type": "string" - } - ] - } - } - ] - } - }, - "metadata": { - "enums": {} - }, - "display": { - "formats": { - "TestPrimaryType": { - "fields": [ - { - "path": { - "type": "data", - "absolute": true, - "elements": [ - { - "type": "field", - "identifier": "param1" - } - ] - }, - "label": "Param 1 - with blockheight encoding", - "format": "date", - "params": { - "encoding": "blockheight" - } - }, - { - "path": { - "type": "data", - "absolute": true, - "elements": [ - { - "type": "field", - "identifier": "param1" - } - ] - }, - "label": "Param 1 - with timestamp encoding", - "format": "date", - "params": { - "encoding": "timestamp" - } - } - ] - } + "TestPrimaryType": [{ "name": "param1", "type": "string" }] + } } + ] + } + }, + "metadata": { "enums": {} }, + "display": { + "formats": { + "TestPrimaryType": { + "fields": [ + { + "path": { "type": "data", "absolute": true, "elements": [{ "type": "field", "identifier": "param1" }] }, + "label": "Param 1 - with blockheight encoding", + "format": "date", + "params": { "encoding": "blockheight" } + }, + { + "path": { "type": "data", "absolute": true, "elements": [{ "type": "field", "identifier": "param1" }] }, + "label": "Param 1 - with timestamp encoding", + "format": "date", + "params": { "encoding": "timestamp" } + } + ] + } } + } } diff --git a/tests/convert/resolved/data/format_date_using_constants_resolved.json b/tests/convert/resolved/data/format_date_using_constants_resolved.json index f130b79..b44315f 100644 --- a/tests/convert/resolved/data/format_date_using_constants_resolved.json +++ b/tests/convert/resolved/data/format_date_using_constants_resolved.json @@ -1,84 +1,41 @@ { - "context": { - "eip712": { - "deployments": [ - { - "chainId": 1, - "address": "0x0000000000000000000000000000000000000000" - } + "context": { + "eip712": { + "deployments": [{ "chainId": 1, "address": "0x0000000000000000000000000000000000000000" }], + "schemas": [ + { + "primaryType": "TestPrimaryType", + "types": { + "EIP712Domain": [ + { "name": "name", "type": "string" }, + { "name": "chainId", "type": "uint256" }, + { "name": "verifyingContract", "type": "address" } ], - "schemas": [ - { - "primaryType": "TestPrimaryType", - "types": { - "EIP712Domain": [ - { - "name": "name", - "type": "string" - }, - { - "name": "chainId", - "type": "uint256" - }, - { - "name": "verifyingContract", - "type": "address" - } - ], - "TestPrimaryType": [ - { - "name": "param1", - "type": "string" - } - ] - } - } - ] - } - }, - "metadata": { - "enums": {} - }, - "display": { - "formats": { - "TestPrimaryType": { - "fields": [ - { - "path": { - "type": "data", - "absolute": true, - "elements": [ - { - "type": "field", - "identifier": "param1" - } - ] - }, - "label": "Param 1 - with blockheight encoding", - "format": "date", - "params": { - "encoding": "blockheight" - } - }, - { - "path": { - "type": "data", - "absolute": true, - "elements": [ - { - "type": "field", - "identifier": "param1" - } - ] - }, - "label": "Param 1 - with timestamp encoding", - "format": "date", - "params": { - "encoding": "timestamp" - } - } - ] - } + "TestPrimaryType": [{ "name": "param1", "type": "string" }] + } } + ] + } + }, + "metadata": { "enums": {} }, + "display": { + "formats": { + "TestPrimaryType": { + "fields": [ + { + "path": { "type": "data", "absolute": true, "elements": [{ "type": "field", "identifier": "param1" }] }, + "label": "Param 1 - with blockheight encoding", + "format": "date", + "params": { "encoding": "blockheight" } + }, + { + "path": { "type": "data", "absolute": true, "elements": [{ "type": "field", "identifier": "param1" }] }, + "label": "Param 1 - with timestamp encoding", + "format": "date", + "params": { "encoding": "timestamp" } + } + ] + } } + } } diff --git a/tests/convert/resolved/data/format_duration_resolved.json b/tests/convert/resolved/data/format_duration_resolved.json index 13640ba..684e7c3 100644 --- a/tests/convert/resolved/data/format_duration_resolved.json +++ b/tests/convert/resolved/data/format_duration_resolved.json @@ -1,64 +1,34 @@ { - "context": { - "eip712": { - "deployments": [ - { - "chainId": 1, - "address": "0x0000000000000000000000000000000000000000" - } + "context": { + "eip712": { + "deployments": [{ "chainId": 1, "address": "0x0000000000000000000000000000000000000000" }], + "schemas": [ + { + "primaryType": "TestPrimaryType", + "types": { + "EIP712Domain": [ + { "name": "name", "type": "string" }, + { "name": "chainId", "type": "uint256" }, + { "name": "verifyingContract", "type": "address" } ], - "schemas": [ - { - "primaryType": "TestPrimaryType", - "types": { - "EIP712Domain": [ - { - "name": "name", - "type": "string" - }, - { - "name": "chainId", - "type": "uint256" - }, - { - "name": "verifyingContract", - "type": "address" - } - ], - "TestPrimaryType": [ - { - "name": "param1", - "type": "uint256" - } - ] - } - } - ] - } - }, - "metadata": { - "enums": {} - }, - "display": { - "formats": { - "TestPrimaryType": { - "fields": [ - { - "path": { - "type": "data", - "absolute": true, - "elements": [ - { - "type": "field", - "identifier": "param1" - } - ] - }, - "label": "Param 1", - "format": "duration" - } - ] - } + "TestPrimaryType": [{ "name": "param1", "type": "uint256" }] + } } + ] + } + }, + "metadata": { "enums": {} }, + "display": { + "formats": { + "TestPrimaryType": { + "fields": [ + { + "path": { "type": "data", "absolute": true, "elements": [{ "type": "field", "identifier": "param1" }] }, + "label": "Param 1", + "format": "duration" + } + ] + } } + } } diff --git a/tests/convert/resolved/data/format_duration_using_constants_resolved.json b/tests/convert/resolved/data/format_duration_using_constants_resolved.json index 13640ba..684e7c3 100644 --- a/tests/convert/resolved/data/format_duration_using_constants_resolved.json +++ b/tests/convert/resolved/data/format_duration_using_constants_resolved.json @@ -1,64 +1,34 @@ { - "context": { - "eip712": { - "deployments": [ - { - "chainId": 1, - "address": "0x0000000000000000000000000000000000000000" - } + "context": { + "eip712": { + "deployments": [{ "chainId": 1, "address": "0x0000000000000000000000000000000000000000" }], + "schemas": [ + { + "primaryType": "TestPrimaryType", + "types": { + "EIP712Domain": [ + { "name": "name", "type": "string" }, + { "name": "chainId", "type": "uint256" }, + { "name": "verifyingContract", "type": "address" } ], - "schemas": [ - { - "primaryType": "TestPrimaryType", - "types": { - "EIP712Domain": [ - { - "name": "name", - "type": "string" - }, - { - "name": "chainId", - "type": "uint256" - }, - { - "name": "verifyingContract", - "type": "address" - } - ], - "TestPrimaryType": [ - { - "name": "param1", - "type": "uint256" - } - ] - } - } - ] - } - }, - "metadata": { - "enums": {} - }, - "display": { - "formats": { - "TestPrimaryType": { - "fields": [ - { - "path": { - "type": "data", - "absolute": true, - "elements": [ - { - "type": "field", - "identifier": "param1" - } - ] - }, - "label": "Param 1", - "format": "duration" - } - ] - } + "TestPrimaryType": [{ "name": "param1", "type": "uint256" }] + } } + ] + } + }, + "metadata": { "enums": {} }, + "display": { + "formats": { + "TestPrimaryType": { + "fields": [ + { + "path": { "type": "data", "absolute": true, "elements": [{ "type": "field", "identifier": "param1" }] }, + "label": "Param 1", + "format": "duration" + } + ] + } } + } } diff --git a/tests/convert/resolved/data/format_enum_resolved.json b/tests/convert/resolved/data/format_enum_resolved.json index 0a93a14..c19a9dc 100644 --- a/tests/convert/resolved/data/format_enum_resolved.json +++ b/tests/convert/resolved/data/format_enum_resolved.json @@ -1,93 +1,41 @@ { - "context": { - "eip712": { - "deployments": [ - { - "chainId": 1, - "address": "0x0000000000000000000000000000000000000000" - } + "context": { + "eip712": { + "deployments": [{ "chainId": 1, "address": "0x0000000000000000000000000000000000000000" }], + "schemas": [ + { + "primaryType": "TestPrimaryType", + "types": { + "EIP712Domain": [ + { "name": "name", "type": "string" }, + { "name": "chainId", "type": "uint256" }, + { "name": "verifyingContract", "type": "address" } ], - "schemas": [ - { - "primaryType": "TestPrimaryType", - "types": { - "EIP712Domain": [ - { - "name": "name", - "type": "string" - }, - { - "name": "chainId", - "type": "uint256" - }, - { - "name": "verifyingContract", - "type": "address" - } - ], - "TestPrimaryType": [ - { - "name": "param1", - "type": "uint256" - } - ] - } - } - ] - } - }, - "metadata": { - "enums": { - "local": { - "1": "stable", - "2": "variable" - }, - "remote": { - "1": "foo", - "2": "bar" - } - } - }, - "display": { - "formats": { - "TestPrimaryType": { - "fields": [ - { - "path": { - "type": "data", - "absolute": true, - "elements": [ - { - "type": "field", - "identifier": "param1" - } - ] - }, - "label": "Using a local enum", - "format": "enum", - "params": { - "enumId": "local" - } - }, - { - "path": { - "type": "data", - "absolute": true, - "elements": [ - { - "type": "field", - "identifier": "param1" - } - ] - }, - "label": "Using a remote enum", - "format": "enum", - "params": { - "enumId": "remote" - } - } - ] - } + "TestPrimaryType": [{ "name": "param1", "type": "uint256" }] + } } + ] + } + }, + "metadata": { "enums": { "local": { "1": "stable", "2": "variable" }, "remote": { "1": "foo", "2": "bar" } } }, + "display": { + "formats": { + "TestPrimaryType": { + "fields": [ + { + "path": { "type": "data", "absolute": true, "elements": [{ "type": "field", "identifier": "param1" }] }, + "label": "Using a local enum", + "format": "enum", + "params": { "enumId": "local" } + }, + { + "path": { "type": "data", "absolute": true, "elements": [{ "type": "field", "identifier": "param1" }] }, + "label": "Using a remote enum", + "format": "enum", + "params": { "enumId": "remote" } + } + ] + } } + } } diff --git a/tests/convert/resolved/data/format_enum_using_constants_resolved.json b/tests/convert/resolved/data/format_enum_using_constants_resolved.json index e43e07c..fac346a 100644 --- a/tests/convert/resolved/data/format_enum_using_constants_resolved.json +++ b/tests/convert/resolved/data/format_enum_using_constants_resolved.json @@ -1,72 +1,35 @@ { - "context": { - "eip712": { - "deployments": [ - { - "chainId": 1, - "address": "0x0000000000000000000000000000000000000000" - } + "context": { + "eip712": { + "deployments": [{ "chainId": 1, "address": "0x0000000000000000000000000000000000000000" }], + "schemas": [ + { + "primaryType": "TestPrimaryType", + "types": { + "EIP712Domain": [ + { "name": "name", "type": "string" }, + { "name": "chainId", "type": "uint256" }, + { "name": "verifyingContract", "type": "address" } ], - "schemas": [ - { - "primaryType": "TestPrimaryType", - "types": { - "EIP712Domain": [ - { - "name": "name", - "type": "string" - }, - { - "name": "chainId", - "type": "uint256" - }, - { - "name": "verifyingContract", - "type": "address" - } - ], - "TestPrimaryType": [ - { - "name": "param1", - "type": "uint256" - } - ] - } - } - ] - } - }, - "metadata": { - "enums": { - "testEnum": { - "1": "stable", - "2": "variable" - } - } - }, - "display": { - "formats": { - "TestPrimaryType": { - "fields": [ - { - "path": { - "type": "data", - "absolute": true, - "elements": [ - { - "type": "field", - "identifier": "param1" - } - ] - }, - "label": "Param 1", - "format": "enum", - "params": { - "enumId": "testEnum" - } - } - ] - } + "TestPrimaryType": [{ "name": "param1", "type": "uint256" }] + } } + ] + } + }, + "metadata": { "enums": { "testEnum": { "1": "stable", "2": "variable" } } }, + "display": { + "formats": { + "TestPrimaryType": { + "fields": [ + { + "path": { "type": "data", "absolute": true, "elements": [{ "type": "field", "identifier": "param1" }] }, + "label": "Param 1", + "format": "enum", + "params": { "enumId": "testEnum" } + } + ] + } } + } } diff --git a/tests/convert/resolved/data/format_nft_name_resolved.json b/tests/convert/resolved/data/format_nft_name_resolved.json index f58d475..f293c05 100644 --- a/tests/convert/resolved/data/format_nft_name_resolved.json +++ b/tests/convert/resolved/data/format_nft_name_resolved.json @@ -1,80 +1,35 @@ { - "context": { - "eip712": { - "deployments": [ - { - "chainId": 1, - "address": "0x0000000000000000000000000000000000000000" - } + "context": { + "eip712": { + "deployments": [{ "chainId": 1, "address": "0x0000000000000000000000000000000000000000" }], + "schemas": [ + { + "primaryType": "TestPrimaryType", + "types": { + "EIP712Domain": [ + { "name": "name", "type": "string" }, + { "name": "chainId", "type": "uint256" }, + { "name": "verifyingContract", "type": "address" } ], - "schemas": [ - { - "primaryType": "TestPrimaryType", - "types": { - "EIP712Domain": [ - { - "name": "name", - "type": "string" - }, - { - "name": "chainId", - "type": "uint256" - }, - { - "name": "verifyingContract", - "type": "address" - } - ], - "TestPrimaryType": [ - { - "name": "param1", - "type": "string" - }, - { - "name": "param2", - "type": "address" - } - ] - } - } - ] - } - }, - "metadata": { - "enums": {} - }, - "display": { - "formats": { - "TestPrimaryType": { - "fields": [ - { - "path": { - "type": "data", - "absolute": true, - "elements": [ - { - "type": "field", - "identifier": "param1" - } - ] - }, - "label": "Param 1", - "format": "nftName", - "params": { - "collectionPath": { - "type": "data", - "absolute": true, - "elements": [ - { - "type": "field", - "identifier": "param2" - } - ] - } - } - } - ] - } + "TestPrimaryType": [{ "name": "param1", "type": "string" }, { "name": "param2", "type": "address" }] + } } + ] + } + }, + "metadata": { "enums": {} }, + "display": { + "formats": { + "TestPrimaryType": { + "fields": [ + { + "path": { "type": "data", "absolute": true, "elements": [{ "type": "field", "identifier": "param1" }] }, + "label": "Param 1", + "format": "nftName", + "params": { "collectionPath": { "type": "data", "absolute": true, "elements": [{ "type": "field", "identifier": "param2" }] } } + } + ] + } } + } } diff --git a/tests/convert/resolved/data/format_nft_name_using_constants_resolved.json b/tests/convert/resolved/data/format_nft_name_using_constants_resolved.json index f58d475..f293c05 100644 --- a/tests/convert/resolved/data/format_nft_name_using_constants_resolved.json +++ b/tests/convert/resolved/data/format_nft_name_using_constants_resolved.json @@ -1,80 +1,35 @@ { - "context": { - "eip712": { - "deployments": [ - { - "chainId": 1, - "address": "0x0000000000000000000000000000000000000000" - } + "context": { + "eip712": { + "deployments": [{ "chainId": 1, "address": "0x0000000000000000000000000000000000000000" }], + "schemas": [ + { + "primaryType": "TestPrimaryType", + "types": { + "EIP712Domain": [ + { "name": "name", "type": "string" }, + { "name": "chainId", "type": "uint256" }, + { "name": "verifyingContract", "type": "address" } ], - "schemas": [ - { - "primaryType": "TestPrimaryType", - "types": { - "EIP712Domain": [ - { - "name": "name", - "type": "string" - }, - { - "name": "chainId", - "type": "uint256" - }, - { - "name": "verifyingContract", - "type": "address" - } - ], - "TestPrimaryType": [ - { - "name": "param1", - "type": "string" - }, - { - "name": "param2", - "type": "address" - } - ] - } - } - ] - } - }, - "metadata": { - "enums": {} - }, - "display": { - "formats": { - "TestPrimaryType": { - "fields": [ - { - "path": { - "type": "data", - "absolute": true, - "elements": [ - { - "type": "field", - "identifier": "param1" - } - ] - }, - "label": "Param 1", - "format": "nftName", - "params": { - "collectionPath": { - "type": "data", - "absolute": true, - "elements": [ - { - "type": "field", - "identifier": "param2" - } - ] - } - } - } - ] - } + "TestPrimaryType": [{ "name": "param1", "type": "string" }, { "name": "param2", "type": "address" }] + } } + ] + } + }, + "metadata": { "enums": {} }, + "display": { + "formats": { + "TestPrimaryType": { + "fields": [ + { + "path": { "type": "data", "absolute": true, "elements": [{ "type": "field", "identifier": "param1" }] }, + "label": "Param 1", + "format": "nftName", + "params": { "collectionPath": { "type": "data", "absolute": true, "elements": [{ "type": "field", "identifier": "param2" }] } } + } + ] + } } + } } diff --git a/tests/convert/resolved/data/format_raw_resolved.json b/tests/convert/resolved/data/format_raw_resolved.json index 57f32bf..0b1c8b7 100644 --- a/tests/convert/resolved/data/format_raw_resolved.json +++ b/tests/convert/resolved/data/format_raw_resolved.json @@ -1,64 +1,34 @@ { - "context": { - "eip712": { - "deployments": [ - { - "chainId": 1, - "address": "0x0000000000000000000000000000000000000000" - } + "context": { + "eip712": { + "deployments": [{ "chainId": 1, "address": "0x0000000000000000000000000000000000000000" }], + "schemas": [ + { + "primaryType": "TestPrimaryType", + "types": { + "EIP712Domain": [ + { "name": "name", "type": "string" }, + { "name": "chainId", "type": "uint256" }, + { "name": "verifyingContract", "type": "address" } ], - "schemas": [ - { - "primaryType": "TestPrimaryType", - "types": { - "EIP712Domain": [ - { - "name": "name", - "type": "string" - }, - { - "name": "chainId", - "type": "uint256" - }, - { - "name": "verifyingContract", - "type": "address" - } - ], - "TestPrimaryType": [ - { - "name": "param1", - "type": "string" - } - ] - } - } - ] - } - }, - "metadata": { - "enums": {} - }, - "display": { - "formats": { - "TestPrimaryType": { - "fields": [ - { - "path": { - "type": "data", - "absolute": true, - "elements": [ - { - "type": "field", - "identifier": "param1" - } - ] - }, - "label": "Param 1", - "format": "raw" - } - ] - } + "TestPrimaryType": [{ "name": "param1", "type": "string" }] + } } + ] + } + }, + "metadata": { "enums": {} }, + "display": { + "formats": { + "TestPrimaryType": { + "fields": [ + { + "path": { "type": "data", "absolute": true, "elements": [{ "type": "field", "identifier": "param1" }] }, + "label": "Param 1", + "format": "raw" + } + ] + } } + } } diff --git a/tests/convert/resolved/data/format_raw_using_constants_resolved.json b/tests/convert/resolved/data/format_raw_using_constants_resolved.json index 57f32bf..0b1c8b7 100644 --- a/tests/convert/resolved/data/format_raw_using_constants_resolved.json +++ b/tests/convert/resolved/data/format_raw_using_constants_resolved.json @@ -1,64 +1,34 @@ { - "context": { - "eip712": { - "deployments": [ - { - "chainId": 1, - "address": "0x0000000000000000000000000000000000000000" - } + "context": { + "eip712": { + "deployments": [{ "chainId": 1, "address": "0x0000000000000000000000000000000000000000" }], + "schemas": [ + { + "primaryType": "TestPrimaryType", + "types": { + "EIP712Domain": [ + { "name": "name", "type": "string" }, + { "name": "chainId", "type": "uint256" }, + { "name": "verifyingContract", "type": "address" } ], - "schemas": [ - { - "primaryType": "TestPrimaryType", - "types": { - "EIP712Domain": [ - { - "name": "name", - "type": "string" - }, - { - "name": "chainId", - "type": "uint256" - }, - { - "name": "verifyingContract", - "type": "address" - } - ], - "TestPrimaryType": [ - { - "name": "param1", - "type": "string" - } - ] - } - } - ] - } - }, - "metadata": { - "enums": {} - }, - "display": { - "formats": { - "TestPrimaryType": { - "fields": [ - { - "path": { - "type": "data", - "absolute": true, - "elements": [ - { - "type": "field", - "identifier": "param1" - } - ] - }, - "label": "Param 1", - "format": "raw" - } - ] - } + "TestPrimaryType": [{ "name": "param1", "type": "string" }] + } } + ] + } + }, + "metadata": { "enums": {} }, + "display": { + "formats": { + "TestPrimaryType": { + "fields": [ + { + "path": { "type": "data", "absolute": true, "elements": [{ "type": "field", "identifier": "param1" }] }, + "label": "Param 1", + "format": "raw" + } + ] + } } + } } diff --git a/tests/convert/resolved/data/format_token_amount_resolved.json b/tests/convert/resolved/data/format_token_amount_resolved.json index ac2a2e4..1ebfc2b 100644 --- a/tests/convert/resolved/data/format_token_amount_resolved.json +++ b/tests/convert/resolved/data/format_token_amount_resolved.json @@ -1,131 +1,56 @@ { - "context": { - "eip712": { - "deployments": [ - { - "chainId": 1, - "address": "0x0000000000000000000000000000000000000000" - } + "context": { + "eip712": { + "deployments": [{ "chainId": 1, "address": "0x0000000000000000000000000000000000000000" }], + "schemas": [ + { + "primaryType": "TestPrimaryType", + "types": { + "EIP712Domain": [ + { "name": "name", "type": "string" }, + { "name": "chainId", "type": "uint256" }, + { "name": "verifyingContract", "type": "address" } ], - "schemas": [ - { - "primaryType": "TestPrimaryType", - "types": { - "EIP712Domain": [ - { - "name": "name", - "type": "string" - }, - { - "name": "chainId", - "type": "uint256" - }, - { - "name": "verifyingContract", - "type": "address" - } - ], - "TestPrimaryType": [ - { - "name": "token1", - "type": "address" - }, - { - "name": "token2", - "type": "address" - } - ] - } - } - ] + "TestPrimaryType": [{ "name": "token1", "type": "address" }, { "name": "token2", "type": "address" }] + } } - }, - "metadata": { - "enums": {} - }, - "display": { - "formats": { - "TestPrimaryType": { - "fields": [ - { - "path": { - "type": "data", - "absolute": true, - "elements": [ - { - "type": "field", - "identifier": "param1" - } - ] - }, - "label": "With minimal set of parameters specified", - "format": "tokenAmount" - }, - { - "path": { - "type": "data", - "absolute": true, - "elements": [ - { - "type": "field", - "identifier": "param1" - } - ] - }, - "label": "With all parameters specified, string nativeCurrencyAddress", - "format": "tokenAmount", - "params": { - "tokenPath": { - "type": "data", - "absolute": true, - "elements": [ - { - "type": "field", - "identifier": "token1" - } - ] - }, - "nativeCurrencyAddress": [ - "0x0000000000000000000000000000000000000001" - ], - "threshold": "0xffffffff", - "message": "Max" - } - }, - { - "path": { - "type": "data", - "absolute": true, - "elements": [ - { - "type": "field", - "identifier": "param1" - } - ] - }, - "label": "With all parameters specified, array nativeCurrencyAddress", - "format": "tokenAmount", - "params": { - "tokenPath": { - "type": "data", - "absolute": true, - "elements": [ - { - "type": "field", - "identifier": "token1" - } - ] - }, - "nativeCurrencyAddress": [ - "0x0000000000000000000000000000000000000001", - "0x0000000000000000000000000000000000000002" - ], - "threshold": "0xffffffff", - "message": "Max" - } - } - ] + ] + } + }, + "metadata": { "enums": {} }, + "display": { + "formats": { + "TestPrimaryType": { + "fields": [ + { + "path": { "type": "data", "absolute": true, "elements": [{ "type": "field", "identifier": "param1" }] }, + "label": "With minimal set of parameters specified", + "format": "tokenAmount" + }, + { + "path": { "type": "data", "absolute": true, "elements": [{ "type": "field", "identifier": "param1" }] }, + "label": "With all parameters specified, string nativeCurrencyAddress", + "format": "tokenAmount", + "params": { + "tokenPath": { "type": "data", "absolute": true, "elements": [{ "type": "field", "identifier": "token1" }] }, + "nativeCurrencyAddress": ["0x0000000000000000000000000000000000000001"], + "threshold": "0xffffffff", + "message": "Max" } - } + }, + { + "path": { "type": "data", "absolute": true, "elements": [{ "type": "field", "identifier": "param1" }] }, + "label": "With all parameters specified, array nativeCurrencyAddress", + "format": "tokenAmount", + "params": { + "tokenPath": { "type": "data", "absolute": true, "elements": [{ "type": "field", "identifier": "token1" }] }, + "nativeCurrencyAddress": ["0x0000000000000000000000000000000000000001", "0x0000000000000000000000000000000000000002"], + "threshold": "0xffffffff", + "message": "Max" + } + } + ] + } } + } } diff --git a/tests/convert/resolved/data/format_token_amount_using_constants_resolved.json b/tests/convert/resolved/data/format_token_amount_using_constants_resolved.json index ac2a2e4..1ebfc2b 100644 --- a/tests/convert/resolved/data/format_token_amount_using_constants_resolved.json +++ b/tests/convert/resolved/data/format_token_amount_using_constants_resolved.json @@ -1,131 +1,56 @@ { - "context": { - "eip712": { - "deployments": [ - { - "chainId": 1, - "address": "0x0000000000000000000000000000000000000000" - } + "context": { + "eip712": { + "deployments": [{ "chainId": 1, "address": "0x0000000000000000000000000000000000000000" }], + "schemas": [ + { + "primaryType": "TestPrimaryType", + "types": { + "EIP712Domain": [ + { "name": "name", "type": "string" }, + { "name": "chainId", "type": "uint256" }, + { "name": "verifyingContract", "type": "address" } ], - "schemas": [ - { - "primaryType": "TestPrimaryType", - "types": { - "EIP712Domain": [ - { - "name": "name", - "type": "string" - }, - { - "name": "chainId", - "type": "uint256" - }, - { - "name": "verifyingContract", - "type": "address" - } - ], - "TestPrimaryType": [ - { - "name": "token1", - "type": "address" - }, - { - "name": "token2", - "type": "address" - } - ] - } - } - ] + "TestPrimaryType": [{ "name": "token1", "type": "address" }, { "name": "token2", "type": "address" }] + } } - }, - "metadata": { - "enums": {} - }, - "display": { - "formats": { - "TestPrimaryType": { - "fields": [ - { - "path": { - "type": "data", - "absolute": true, - "elements": [ - { - "type": "field", - "identifier": "param1" - } - ] - }, - "label": "With minimal set of parameters specified", - "format": "tokenAmount" - }, - { - "path": { - "type": "data", - "absolute": true, - "elements": [ - { - "type": "field", - "identifier": "param1" - } - ] - }, - "label": "With all parameters specified, string nativeCurrencyAddress", - "format": "tokenAmount", - "params": { - "tokenPath": { - "type": "data", - "absolute": true, - "elements": [ - { - "type": "field", - "identifier": "token1" - } - ] - }, - "nativeCurrencyAddress": [ - "0x0000000000000000000000000000000000000001" - ], - "threshold": "0xffffffff", - "message": "Max" - } - }, - { - "path": { - "type": "data", - "absolute": true, - "elements": [ - { - "type": "field", - "identifier": "param1" - } - ] - }, - "label": "With all parameters specified, array nativeCurrencyAddress", - "format": "tokenAmount", - "params": { - "tokenPath": { - "type": "data", - "absolute": true, - "elements": [ - { - "type": "field", - "identifier": "token1" - } - ] - }, - "nativeCurrencyAddress": [ - "0x0000000000000000000000000000000000000001", - "0x0000000000000000000000000000000000000002" - ], - "threshold": "0xffffffff", - "message": "Max" - } - } - ] + ] + } + }, + "metadata": { "enums": {} }, + "display": { + "formats": { + "TestPrimaryType": { + "fields": [ + { + "path": { "type": "data", "absolute": true, "elements": [{ "type": "field", "identifier": "param1" }] }, + "label": "With minimal set of parameters specified", + "format": "tokenAmount" + }, + { + "path": { "type": "data", "absolute": true, "elements": [{ "type": "field", "identifier": "param1" }] }, + "label": "With all parameters specified, string nativeCurrencyAddress", + "format": "tokenAmount", + "params": { + "tokenPath": { "type": "data", "absolute": true, "elements": [{ "type": "field", "identifier": "token1" }] }, + "nativeCurrencyAddress": ["0x0000000000000000000000000000000000000001"], + "threshold": "0xffffffff", + "message": "Max" } - } + }, + { + "path": { "type": "data", "absolute": true, "elements": [{ "type": "field", "identifier": "param1" }] }, + "label": "With all parameters specified, array nativeCurrencyAddress", + "format": "tokenAmount", + "params": { + "tokenPath": { "type": "data", "absolute": true, "elements": [{ "type": "field", "identifier": "token1" }] }, + "nativeCurrencyAddress": ["0x0000000000000000000000000000000000000001", "0x0000000000000000000000000000000000000002"], + "threshold": "0xffffffff", + "message": "Max" + } + } + ] + } } + } } diff --git a/tests/convert/resolved/data/format_unit_resolved.json b/tests/convert/resolved/data/format_unit_resolved.json index 86e3114..6a53b99 100644 --- a/tests/convert/resolved/data/format_unit_resolved.json +++ b/tests/convert/resolved/data/format_unit_resolved.json @@ -1,86 +1,41 @@ { - "context": { - "eip712": { - "deployments": [ - { - "chainId": 1, - "address": "0x0000000000000000000000000000000000000000" - } + "context": { + "eip712": { + "deployments": [{ "chainId": 1, "address": "0x0000000000000000000000000000000000000000" }], + "schemas": [ + { + "primaryType": "TestPrimaryType", + "types": { + "EIP712Domain": [ + { "name": "name", "type": "string" }, + { "name": "chainId", "type": "uint256" }, + { "name": "verifyingContract", "type": "address" } ], - "schemas": [ - { - "primaryType": "TestPrimaryType", - "types": { - "EIP712Domain": [ - { - "name": "name", - "type": "string" - }, - { - "name": "chainId", - "type": "uint256" - }, - { - "name": "verifyingContract", - "type": "address" - } - ], - "TestPrimaryType": [ - { - "name": "param1", - "type": "uint256" - } - ] - } - } - ] - } - }, - "metadata": { - "enums": {} - }, - "display": { - "formats": { - "TestPrimaryType": { - "fields": [ - { - "path": { - "type": "data", - "absolute": true, - "elements": [ - { - "type": "field", - "identifier": "param1" - } - ] - }, - "label": "With minimal set of parameters set", - "format": "unit", - "params": { - "base": "%" - } - }, - { - "path": { - "type": "data", - "absolute": true, - "elements": [ - { - "type": "field", - "identifier": "param1" - } - ] - }, - "label": "With all parameters set", - "format": "unit", - "params": { - "base": "km/h", - "decimals": 2, - "prefix": true - } - } - ] - } + "TestPrimaryType": [{ "name": "param1", "type": "uint256" }] + } } + ] + } + }, + "metadata": { "enums": {} }, + "display": { + "formats": { + "TestPrimaryType": { + "fields": [ + { + "path": { "type": "data", "absolute": true, "elements": [{ "type": "field", "identifier": "param1" }] }, + "label": "With minimal set of parameters set", + "format": "unit", + "params": { "base": "%" } + }, + { + "path": { "type": "data", "absolute": true, "elements": [{ "type": "field", "identifier": "param1" }] }, + "label": "With all parameters set", + "format": "unit", + "params": { "base": "km/h", "decimals": 2, "prefix": true } + } + ] + } } + } } diff --git a/tests/convert/resolved/data/format_unit_using_constants_resolved.json b/tests/convert/resolved/data/format_unit_using_constants_resolved.json index 91dbfa4..63f2f82 100644 --- a/tests/convert/resolved/data/format_unit_using_constants_resolved.json +++ b/tests/convert/resolved/data/format_unit_using_constants_resolved.json @@ -1,86 +1,41 @@ { - "context": { - "eip712": { - "deployments": [ - { - "chainId": 1, - "address": "0x0000000000000000000000000000000000000000" - } + "context": { + "eip712": { + "deployments": [{ "chainId": 1, "address": "0x0000000000000000000000000000000000000000" }], + "schemas": [ + { + "primaryType": "TestPrimaryType", + "types": { + "EIP712Domain": [ + { "name": "name", "type": "string" }, + { "name": "chainId", "type": "uint256" }, + { "name": "verifyingContract", "type": "address" } ], - "schemas": [ - { - "primaryType": "TestPrimaryType", - "types": { - "EIP712Domain": [ - { - "name": "name", - "type": "string" - }, - { - "name": "chainId", - "type": "uint256" - }, - { - "name": "verifyingContract", - "type": "address" - } - ], - "TestPrimaryType": [ - { - "name": "param1", - "type": "uint256" - } - ] - } - } - ] - } - }, - "metadata": { - "enums": {} - }, - "display": { - "formats": { - "TestPrimaryType": { - "fields": [ - { - "path": { - "type": "data", - "absolute": true, - "elements": [ - { - "type": "field", - "identifier": "param1" - } - ] - }, - "label": "With minimal set of parameters set", - "format": "unit", - "params": { - "base": "km/h" - } - }, - { - "path": { - "type": "data", - "absolute": true, - "elements": [ - { - "type": "field", - "identifier": "param1" - } - ] - }, - "label": "With all parameters set", - "format": "unit", - "params": { - "base": "km/h", - "decimals": 2, - "prefix": true - } - } - ] - } + "TestPrimaryType": [{ "name": "param1", "type": "uint256" }] + } } + ] + } + }, + "metadata": { "enums": {} }, + "display": { + "formats": { + "TestPrimaryType": { + "fields": [ + { + "path": { "type": "data", "absolute": true, "elements": [{ "type": "field", "identifier": "param1" }] }, + "label": "With minimal set of parameters set", + "format": "unit", + "params": { "base": "km/h" } + }, + { + "path": { "type": "data", "absolute": true, "elements": [{ "type": "field", "identifier": "param1" }] }, + "label": "With all parameters set", + "format": "unit", + "params": { "base": "km/h", "decimals": 2, "prefix": true } + } + ] + } } + } } diff --git a/tests/convert/resolved/data/minimal_contract_resolved.json b/tests/convert/resolved/data/minimal_contract_resolved.json index 487b179..cbd2371 100644 --- a/tests/convert/resolved/data/minimal_contract_resolved.json +++ b/tests/convert/resolved/data/minimal_contract_resolved.json @@ -1,55 +1,29 @@ { - "context": { - "contract": { - "deployments": [ - { - "chainId": 1, - "address": "0x0000000000000000000000000000000000000000" - } - ], - "abi": [ - { - "type": "function", - "name": "function1", - "inputs": [ - { - "name": "param1", - "type": "bytes4" - } - ], - "outputs": [ - { - "name": "", - "type": "address" - } - ] - } - ] - } - }, - "metadata": { - "enums": {} - }, - "display": { - "formats": { - "function1(bytes4)": { - "fields": [ - { - "path": { - "type": "data", - "absolute": true, - "elements": [ - { - "type": "field", - "identifier": "param1" - } - ] - }, - "label": "Param 1", - "format": "raw" - } - ] - } + "context": { + "contract": { + "deployments": [{ "chainId": 1, "address": "0x0000000000000000000000000000000000000000" }], + "abi": [ + { + "type": "function", + "name": "function1", + "inputs": [{ "name": "param1", "type": "bytes4" }], + "outputs": [{ "name": "", "type": "address" }] } + ] + } + }, + "metadata": { "enums": {} }, + "display": { + "formats": { + "function1(bytes4)": { + "fields": [ + { + "path": { "type": "data", "absolute": true, "elements": [{ "type": "field", "identifier": "param1" }] }, + "label": "Param 1", + "format": "raw" + } + ] + } } + } } diff --git a/tests/convert/resolved/data/minimal_eip712_resolved.json b/tests/convert/resolved/data/minimal_eip712_resolved.json index 57f32bf..0b1c8b7 100644 --- a/tests/convert/resolved/data/minimal_eip712_resolved.json +++ b/tests/convert/resolved/data/minimal_eip712_resolved.json @@ -1,64 +1,34 @@ { - "context": { - "eip712": { - "deployments": [ - { - "chainId": 1, - "address": "0x0000000000000000000000000000000000000000" - } + "context": { + "eip712": { + "deployments": [{ "chainId": 1, "address": "0x0000000000000000000000000000000000000000" }], + "schemas": [ + { + "primaryType": "TestPrimaryType", + "types": { + "EIP712Domain": [ + { "name": "name", "type": "string" }, + { "name": "chainId", "type": "uint256" }, + { "name": "verifyingContract", "type": "address" } ], - "schemas": [ - { - "primaryType": "TestPrimaryType", - "types": { - "EIP712Domain": [ - { - "name": "name", - "type": "string" - }, - { - "name": "chainId", - "type": "uint256" - }, - { - "name": "verifyingContract", - "type": "address" - } - ], - "TestPrimaryType": [ - { - "name": "param1", - "type": "string" - } - ] - } - } - ] - } - }, - "metadata": { - "enums": {} - }, - "display": { - "formats": { - "TestPrimaryType": { - "fields": [ - { - "path": { - "type": "data", - "absolute": true, - "elements": [ - { - "type": "field", - "identifier": "param1" - } - ] - }, - "label": "Param 1", - "format": "raw" - } - ] - } + "TestPrimaryType": [{ "name": "param1", "type": "string" }] + } } + ] + } + }, + "metadata": { "enums": {} }, + "display": { + "formats": { + "TestPrimaryType": { + "fields": [ + { + "path": { "type": "data", "absolute": true, "elements": [{ "type": "field", "identifier": "param1" }] }, + "label": "Param 1", + "format": "raw" + } + ] + } } + } }