kopia lustrzana https://github.com/bugout-dev/moonstream
rodzic
e76a779400
commit
0e1a54fda7
|
@ -94,7 +94,7 @@ class EntityCollectionNotFoundException(Exception):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
class AddressNotAreSmartContractException(Exception):
|
class AddressNotSmartContractException(Exception):
|
||||||
"""
|
"""
|
||||||
Raised when address not are smart contract
|
Raised when address not are smart contract
|
||||||
"""
|
"""
|
||||||
|
@ -801,10 +801,12 @@ def get_list_of_support_interfaces(
|
||||||
Returns list of interfaces supported by given address
|
Returns list of interfaces supported by given address
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if not check_if_smartcontract(
|
_, _, is_contract = check_if_smart_contract(
|
||||||
blockchain_type=blockchain_type, address=address, user_token=user_token
|
blockchain_type=blockchain_type, address=address, user_token=user_token
|
||||||
)[2]:
|
)
|
||||||
raise AddressNotAreSmartContractException(f"Address not are smart contract")
|
|
||||||
|
if not is_contract:
|
||||||
|
raise AddressNotSmartContractException(f"Address not are smart contract")
|
||||||
|
|
||||||
web3_client = connect(blockchain_type, user_token=user_token)
|
web3_client = connect(blockchain_type, user_token=user_token)
|
||||||
|
|
||||||
|
@ -894,7 +896,7 @@ def get_list_of_support_interfaces(
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
def check_if_smartcontract(
|
def check_if_smart_contract(
|
||||||
blockchain_type: AvailableBlockchainType,
|
blockchain_type: AvailableBlockchainType,
|
||||||
address: str,
|
address: str,
|
||||||
user_token: uuid.UUID,
|
user_token: uuid.UUID,
|
||||||
|
|
|
@ -14,12 +14,12 @@ from moonstreamdb.blockchain import AvailableBlockchainType
|
||||||
from web3 import Web3
|
from web3 import Web3
|
||||||
|
|
||||||
from ..actions import (
|
from ..actions import (
|
||||||
AddressNotAreSmartContractException,
|
AddressNotSmartContractException,
|
||||||
validate_abi_json,
|
validate_abi_json,
|
||||||
apply_moonworm_tasks,
|
apply_moonworm_tasks,
|
||||||
get_entity_subscription_collection_id,
|
get_entity_subscription_collection_id,
|
||||||
EntityCollectionNotFoundException,
|
EntityCollectionNotFoundException,
|
||||||
check_if_smartcontract,
|
check_if_smart_contract,
|
||||||
get_list_of_support_interfaces,
|
get_list_of_support_interfaces,
|
||||||
)
|
)
|
||||||
from ..admin import subscription_types
|
from ..admin import subscription_types
|
||||||
|
@ -636,7 +636,7 @@ async def address_info(request: Request, address: str):
|
||||||
with ThreadPoolExecutor(max_workers=5) as executor:
|
with ThreadPoolExecutor(max_workers=5) as executor:
|
||||||
futures.append(
|
futures.append(
|
||||||
executor.submit(
|
executor.submit(
|
||||||
check_if_smartcontract,
|
check_if_smart_contract,
|
||||||
address=address,
|
address=address,
|
||||||
blockchain_type=blockchain_type,
|
blockchain_type=blockchain_type,
|
||||||
user_token=user_token,
|
user_token=user_token,
|
||||||
|
@ -705,7 +705,7 @@ def get_contract_interfaces(
|
||||||
address=address,
|
address=address,
|
||||||
user_token=user_token,
|
user_token=user_token,
|
||||||
)
|
)
|
||||||
except AddressNotAreSmartContractException as e:
|
except AddressNotSmartContractException as e:
|
||||||
raise MoonstreamHTTPException(
|
raise MoonstreamHTTPException(
|
||||||
status_code=409,
|
status_code=409,
|
||||||
detail=str(e),
|
detail=str(e),
|
||||||
|
|
Ładowanie…
Reference in New Issue