juliankoh / etherscan_py

Powerful wrapper over Etherscan API
MIT License
7 stars 5 forks source link

get_all_transactions() raises an Exception when no transactions are found #3

Closed wirelessfuture closed 3 years ago

wirelessfuture commented 3 years ago

Description

Trying to check an address for successful transactions. However it seems to raise an "Invalid Etherscan Request" Exception when there are no results, which I don't understand why. It should just return an empty result as this forces unnecessary error handling in a project using this package.

What I Did

from etherscan_py import etherscan_py
client = etherscan_py.Client("API_KEY")
address_to_get_tx = <some address that isn't very active>
from_block = <arbitrary block number here>
to_block = 'latest'
transactions = client.get_all_transactions(
            from_address=address_to_get_tx,
            status=1, 
            from_block=from_block, 
            to_block=to_block, 
            thread_count=1
 )

Changing line 84 from this: raise Exception("Invalid Etherscan request")

To this: return res['result']

Fixes the issues as down in line 238 you seem to already have a loop that handles situations when no new transactions are found. I can make a pull request if needed.

wirelessfuture commented 3 years ago

Closing this as issue is fixed in: https://github.com/juliankoh/etherscan_py/pull/4