-
Notifications
You must be signed in to change notification settings - Fork 178
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add classes to interact with Safe APIs #292
Conversation
- Support Tx Service - Support Relay Service (deprecated) - Closes #284
Pull Request Test Coverage Report for Build 2670131465
💛 - Coveralls |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks pretty great!
if not response.ok: | ||
raise SafeAPIException(f"Cannot remove delegate: {response.content}") | ||
|
||
def post_transaction(self, safe_tx: SafeTx): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Love it!
self.transaction_service = TransactionServiceApi( | ||
self.ethereum_client, EthereumNetwork.RINKEBY | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So I guess then I would create an instance like this and then call transaction_service.post_transaction(safe_tx)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's right
gnosis/safe/api/base_api.py
Outdated
|
||
import requests | ||
|
||
from gnosis.eth.ethereum_client import EthereumClient, EthereumNetwork |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought you didn't like this kind of import?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What kind of import?
Other day I was talking about absolute import: from something import *
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You were saying that we should be able to
from gnosis.eth import EthereumClient, EthereumNetwork
(as it is stated in the docs here https://gnosis-py.readthedocs.io/en/latest/quickstart.html#safe)
I was pointing out that this kind of import doesn't satisfy mypy, but here I see you doing it the way I was suggesting.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right, missed that 👍🏻
gnosis/safe/api/base_api.py
Outdated
ethereum_network = ethereum_client.get_network() | ||
if ethereum_network in cls.URL_BY_NETWORK: | ||
return cls(ethereum_network, ethereum_client=ethereum_client) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking about moving this to the __init__
. Do we consider SafeBaseAPI
to be in a valid state if the result from from_ethereum_client
is None
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, it's not, we should raise an error. Problem is that if we move that to __init__
we need to make EthereumNetwork
optional. WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I personally like the idea of having these network parameters optional since they are not needed to encode transactions. And there are some use cases which only want to make use of transaction encoding.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added an exception if network is not found and the possibility of setting a custom base URL
- Raise exception if Network is not found
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀
SafeTx.api_post_data
#284