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

Delete null semantics check #113

Merged
merged 2 commits into from
Feb 3, 2022
Merged
Show file tree
Hide file tree
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
3 changes: 1 addition & 2 deletions ethtx/decoders/semantic/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,7 @@ def _get_parameters_str(parameters):
event.event_name = event_transformations.get("name") or event.event_name
else:
if calculated_event_signature in anonymous_events and (
not event_transformations
or event.event_signature not in event_transformations
event.event_signature not in event_transformations
):
event_transformations = anonymous_events[calculated_event_signature]
else:
Expand Down
52 changes: 22 additions & 30 deletions ethtx/providers/semantic_providers/repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
)
from ethtx.providers import EtherscanProvider, Web3Provider, ENSProvider
from ethtx.providers.semantic_providers.database import ISemanticsDatabase
from ethtx.providers.web3_provider import NodeDataProvider
from ethtx.semantics.protocols_router import amend_contract_semantics
from ethtx.semantics.solidity.precompiles import precompiles
from ethtx.semantics.standards.erc20 import ERC20_FUNCTIONS, ERC20_EVENTS
Expand All @@ -38,7 +39,7 @@ def __init__(
self,
database_connection: ISemanticsDatabase,
etherscan_provider: EtherscanProvider,
web3provider: Web3Provider,
web3provider: NodeDataProvider,
ens_provider: ENSProvider,
refresh_ens: bool = True
):
Expand Down Expand Up @@ -231,9 +232,8 @@ def get_event_abi(self, chain_id, address, signature) -> Optional[EventSemantics
return None

semantics = self.get_semantics(chain_id, address)
event_semantics = (
semantics.contract.events.get(signature) if semantics else None
)
event_semantics = semantics.contract.events.get(signature)


return event_semantics

Expand All @@ -246,10 +246,7 @@ def get_transformations(
return None

semantics = self.get_semantics(chain_id, address)
if semantics:
transformations = semantics.contract.transformations.get(signature)
else:
transformations = None
transformations = semantics.contract.transformations.get(signature)

return transformations

Expand All @@ -261,15 +258,15 @@ def get_anonymous_event_abi(self, chain_id, address) -> Optional[EventSemantics]

semantics = self.get_semantics(chain_id, address)
event_semantics = None
if semantics:
anonymous_events = {
signature
for signature, event in semantics.contract.events.items()
if event.anonymous
}
if len(anonymous_events) == 1:
event_signature = anonymous_events.pop()
event_semantics = semantics.contract.events[event_signature]

anonymous_events = {
signature
for signature, event in semantics.contract.events.items()
if event.anonymous
}
if len(anonymous_events) == 1:
event_signature = anonymous_events.pop()
event_semantics = semantics.contract.events[event_signature]

return event_semantics

Expand All @@ -282,9 +279,7 @@ def get_function_abi(
return None

semantics = self.get_semantics(chain_id, address)
function_semantics = (
semantics.contract.functions.get(signature) if semantics else None
)
function_semantics = semantics.contract.functions.get(signature)

return function_semantics

Expand All @@ -295,9 +290,8 @@ def get_constructor_abi(self, chain_id, address) -> Optional[FunctionSemantics]:
return None

semantics = self.get_semantics(chain_id, address)
constructor_semantics = (
semantics.contract.functions.get("constructor") if semantics else None
)
constructor_semantics = semantics.contract.functions.get("constructor")

if constructor_semantics:
constructor_semantics.outputs.append(
ParameterSemantics(
Expand Down Expand Up @@ -348,9 +342,7 @@ def get_standard(self, chain_id, address) -> Optional[str]:
return None

semantics = self.get_semantics(chain_id, address)
standard = semantics.standard if semantics is not None else None

return standard
return semantics.standard

def get_token_data(
self, chain_id, address, proxies=None
Expand All @@ -360,15 +352,15 @@ def get_token_data(
return None, None, None, None

semantics = self.get_semantics(chain_id, address)
if semantics and semantics.erc20:
if semantics.erc20:
token_name = (
semantics.erc20.name if semantics and semantics.erc20 else address
semantics.erc20.name if semantics.erc20 else address
)
token_symbol = (
semantics.erc20.symbol if semantics and semantics.erc20 else "Unknown"
semantics.erc20.symbol if semantics.erc20 else "Unknown"
)
token_decimals = (
semantics.erc20.decimals if semantics and semantics.erc20 else 18
semantics.erc20.decimals if semantics.erc20 else 18
)
elif proxies and address in proxies and proxies[address].token:
token_name = proxies[address].token.name
Expand Down