-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathservicesContracts.py
35 lines (30 loc) · 1008 Bytes
/
servicesContracts.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
from typing import Any
from artifacts import *
def getServiceFromAddress(address: str) -> Any:
"""
return the service of a corresponding currency contract address
:param address:
The address of the currency contract
"""
if not address:
return None
if isThisArtifact(requestEthereumArtifact, address):
return RequestEthereumService()
def isThisArtifact(artifact, address: str) -> bool:
"""
return True if any address in the network is sanitized address,
otherwise it returns False
:param artifact:
RequestNetwork Artifact to use in its interactions
with the Ethereum network
:param address:
The address of the currency contract
"""
if not address:
return False
sanitizedAddress = address.lower()
for network in artifact['networks'].values():
if ('address' in network and
network['address'].lower() == sanitizedAddress):
return True
return False