Skip to content

Commit 0e8dad6

Browse files
committed
Use new NoABIFound error
1 parent 4f63b2f commit 0e8dad6

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

Diff for: tests/core/contracts/test_contract_call_interface.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
BlockNumberOutofRange,
2525
InvalidAddress,
2626
MismatchedABI,
27+
NoABIFound,
2728
NoABIFunctionsFound,
2829
ValidationError,
2930
)
@@ -527,7 +528,7 @@ def test_function_multiple_possible_encodings(web3):
527528

528529
def test_function_no_abi(web3):
529530
contract = web3.eth.contract()
530-
with pytest.raises(NoABIFunctionsFound):
531+
with pytest.raises(NoABIFound):
531532
contract.functions.thisFunctionDoesNotExist().call()
532533

533534

Diff for: web3/contract.py

+12-5
Original file line numberDiff line numberDiff line change
@@ -106,18 +106,21 @@ class ContractFunctions:
106106
"""
107107

108108
def __init__(self, abi, web3, address=None):
109-
if abi:
110-
self.abi = abi
109+
self.abi = abi
110+
self.web3 = web3
111+
self.address = address
112+
113+
if self.abi:
111114
self._functions = filter_by_type('function', self.abi)
112115
for func in self._functions:
113116
setattr(
114117
self,
115118
func['name'],
116119
ContractFunction.factory(
117120
func['name'],
118-
web3=web3,
121+
web3=self.web3,
119122
contract_abi=self.abi,
120-
address=address,
123+
address=self.address,
121124
function_identifier=func['name']))
122125

123126
def __iter__(self):
@@ -128,6 +131,10 @@ def __iter__(self):
128131
yield func['name']
129132

130133
def __getattr__(self, function_name):
134+
if self.abi is None:
135+
raise NoABIFound(
136+
"There is no ABI found for this contract.",
137+
)
131138
if '_functions' not in self.__dict__:
132139
raise NoABIFunctionsFound(
133140
"The abi for this contract contains no function definitions. ",
@@ -1180,7 +1187,7 @@ def __init__(self,
11801187
self.abi = abi
11811188
self._functions = None
11821189

1183-
if abi:
1190+
if self.abi:
11841191
if transaction is None:
11851192
transaction = {}
11861193

0 commit comments

Comments
 (0)