def __getattr__(self, function_name): if '_functions' not in self.__dict__: raise NoABIFunctionsFound( "The abi for this contract contains no function definitions. ", "Are you sure you provided the correct contract abi?") elif function_name not in self.__dict__['_functions']: raise MismatchedABI( "The function '{}' was not found in this contract's abi. ". format(function_name), "Are you sure you provided the correct contract abi?") else: return super().__getattribute__(function_name)
def __getattr__(self, function_name): if self.abi is None: raise NoABIFound("There is no ABI found for this contract.", ) elif not self._functions or len(self._functions) == 0: raise NoABIFunctionsFound( "The ABI for this contract contains no function definitions. ", "Are you sure you provided the correct contract ABI?") elif function_name not in self._functions: functions_available = ', '.join( [fn['name'] for fn in self._functions]) raise MismatchedABI( "The function '{}' was not found in this contract's ABI. ". format(function_name), "Here is a list of all of the function names found: ", "{}. ".format(functions_available), "Did you mean to call one of those functions?") else: return super().__getattribute__(function_name)