mirror of https://github.com/nucypher/nucypher.git
Handle UnknownContract at Agent init-time
parent
61ebd5aa5c
commit
1372323bf0
|
@ -6,6 +6,7 @@ from constant_sorrow import constants
|
||||||
|
|
||||||
from nucypher.blockchain.eth import constants
|
from nucypher.blockchain.eth import constants
|
||||||
from nucypher.blockchain.eth.chains import Blockchain
|
from nucypher.blockchain.eth.chains import Blockchain
|
||||||
|
from nucypher.blockchain.eth.interfaces import EthereumContractRegistry
|
||||||
|
|
||||||
|
|
||||||
class EthereumContractAgent(ABC):
|
class EthereumContractAgent(ABC):
|
||||||
|
@ -33,9 +34,13 @@ class EthereumContractAgent(ABC):
|
||||||
blockchain = Blockchain.connect()
|
blockchain = Blockchain.connect()
|
||||||
self.blockchain = blockchain
|
self.blockchain = blockchain
|
||||||
|
|
||||||
|
try:
|
||||||
# Fetch the contract by reading address and abi from the registry and blockchain
|
# Fetch the contract by reading address and abi from the registry and blockchain
|
||||||
contract = self.blockchain.interface.get_contract_by_name(name=self.principal_contract_name,
|
contract = self.blockchain.interface.get_contract_by_name(name=self.principal_contract_name,
|
||||||
upgradeable=self._upgradeable)
|
upgradeable=self._upgradeable)
|
||||||
|
except EthereumContractRegistry.UnknownContract:
|
||||||
|
raise self.ContractNotDeployed("There is no registry entry for {}".format(self.principal_contract_name))
|
||||||
|
|
||||||
self.__contract = contract
|
self.__contract = contract
|
||||||
super().__init__()
|
super().__init__()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue