-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathservicesExtensions.py
More file actions
40 lines (35 loc) · 1.26 KB
/
servicesExtensions.py
File metadata and controls
40 lines (35 loc) · 1.26 KB
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
36
37
38
39
40
from typing import Any, Union
from artifacts import *
from servicesExtensions.requestSyncrhoneExtensionEscrow_service import \
RequestSynchroneExtensionEscrowService
def getServiceFromAddress(
address: str) -> Union[RequestSynchroneExtensionEscrowService, None]:
"""
Returns the service of a corresponding extension contract address
:param address:
The address of the currency contract
:return
The service object or None if not found
"""
if not address:
return None
if isThisArtifact(requestSynchroneExtensionEscrowArtifact, address):
return RequestSynchroneExtensionEscrowService()
def isThisArtifact(artifact: Any, 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