Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

disable metadata in the generated binary #86

Merged
merged 1 commit into from
Jun 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions solc_json_parser/standard_json_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import os
from typing import Tuple, Callable, List, Union, Optional, Dict
from functools import cached_property, cache

from semantic_version import Version
from .version_cfg import v_keys
from . import ast_shared as s
from .ast_shared import SolidityAstError, solc_bin
Expand Down Expand Up @@ -187,9 +189,13 @@ def override_settings(input_json):
Override settings:
- Disable optimization which could confuse source mapping
- Mark all fields to be generated in the outputs for analysis

https://docs.soliditylang.org/en/latest/using-the-compiler.html#input-description
"""
s.assoc_in(input_json, ['settings', 'optimizer', 'enabled'], False)
s.assoc_in(input_json, ['settings', 'outputSelection'], {'*': {'*': [ '*' ], '': ['ast']}})
s.assoc_in(input_json, ['settings', 'metadata'], {'bytecodeHash': 'none'}) # equiv. of solc --metadata=none

input_json['language']= input_json.get('language', 'Solidity')
return input_json

Expand Down Expand Up @@ -218,7 +224,11 @@ def __init__(self, input_json: Union[dict, str], version: str, solc_bin_resolver
# try use input as a plain source file
self.input_json = StandardJsonParser.__prepare_standard_input(input_json)


self.input_json = override_settings(self.input_json)
support_cbor = Version(version) >= Version('0.8.8')
if support_cbor:
s.assoc_in(self.input_json, ['settings', 'metadata', 'appendCBOR'], False)

self.solc_json_ast: Dict[int, dict] = {}
self.is_standard_json = True
Expand Down
Loading