-
Notifications
You must be signed in to change notification settings - Fork 57
Conversation
add cosmos v0.44 support
for more information, see https://pre-commit.ci
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.
This fixed pushing txs to the new endpoint, tysm for this
But also to note, I had to change one line under get_pushable command
|
Wasn't it working like it was there? Because I submitted transactions like this |
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.
Thanks a lot!
I'm not yet able to have a good look unfortunately but here's my first drive-by review.
A couple questions:
- where did you get the
.proto
files? - are all the
.proto
files strictly needed? Is this the smallest set that works? - what command did you run to generate
.py
files from the.proto
files?
rpc_url = "https://rpc.cosmos.network/" | ||
|
||
# Method 1 | ||
r = tx.broadcast(url=rpc_url) |
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 don't really want this API or the requests
dependency. Cosmospy is not a networking library.
import requests | ||
|
||
pushable_tx = tx.get_pushable() | ||
r = requests.post(rpc_url, data=pushable_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.
Let's stick to httpx
here.
@@ -27,6 +27,10 @@ dependencies = [ | |||
"mnemonic >=0.19", | |||
"hdwallets >=0.1.0", | |||
"typing-extensions >=3.7.4; python_version < '3.8'", | |||
"requests==2.26.0", | |||
"protobuf >= 3.19.1", | |||
"google >= 3.0.0", |
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.
where is google
dependency used? Do we really need it?
|
||
from cosmospy._typing import SyncMode |
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.
typing
module should remain public API. (no underscore prefix)
|
||
def _get_pubkey(self): | ||
pubkey_bytes = privkey_to_pubkey(self._privkey) | ||
_pubkey = pubkey.PubKey() |
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.
There shouldn't be a reason to use private variables inside the function scope (applies to other methods too)
@@ -1,14 +1,15 @@ | |||
import sys | |||
|
|||
print(sys.version_info) |
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.
This should be removed
if sys.version_info < (3, 8): | ||
from typing_extensions import Literal, TypedDict | ||
else: | ||
from typing import Literal, TypedDict | ||
|
||
|
||
# Valid transaction broadcast modes for the `POST /txs` endpoint of the | ||
# Valid transaction broadcast modes for the TX endpoint of the |
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.
POST /cosmos/tx/v1beta1/txs
endpoint
I'm fairly sure @czarcas7ic is correct here. Based on swagger docs of the |
Also see https://docs.cosmos.network/master/core/proto-docs.html#cosmos-tx-v1beta1-service-proto |
I think it just depends if you use the API or RPC. If you want to use it with the RPC endpoint it works. That's why I changed the endpoint to https://rpc.cosmos.network and not the api endpoint. If you want to submit it to the API you need the change @czarcas7ic made. It would be interesting to know if there is a performance difference |
I took the proto files from cyberpy but I think those are the sames they also used in their js library. I will check if they are all needed. This version is just a really fast adaption because I wanted to provide a fix for everyone using cosmospy (also for me I wasn't able to vroadcast transactions in python anymore) I took the generated python files also from cybai but you can generate those files with tools like https://github.com/dropbox/mypy-protobuf, I will setup a proper way to generate them also in case of changements. Regarding the google dep it is needed as everything relies on google.protobuf and if google or protobuf aren't installed you get the error Also the current tests will need to be recreated to work with the new update. |
Thanks. Would be good to know what is
The |
Okay, I have some news regarding the proto files The proto files are coming from cosmos (ex: https://github.com/cosmos/cosmos-sdk/blob/master/proto/cosmos/base/v1beta1/coin.proto => https://github.com/ctrl-Felix/cosmospy/blob/sdkv0.44/src/cosmospy/proto/coin.proto) There are then cli utilities to migrate those protos to python code. I saw some proto files have been updated on cosmos or have more content. I will update them on my repo too. |
I am confused too but it needs both. Check out this thread: https://stackoverflow.com/questions/38680593/importerror-no-module-named-google-protobuf There is no explanation to this |
Did you try removing the |
I think this may be the best source for the proto files https://buf.build/cosmos/cosmos-sdk/tree What we need is
I cannot accept a PR with autogenerated files that I can not verify/reproduce myself. |
I will close the pr anyways and redo it with a new version where the protos are generated from the official ones. This PR is probbaly more a dirty quick fix. |
ah yeah, you're right. Google is the one which isn't needed. |
BTW, here's the docs for compiling Python from Here's a link to download the (currently) latest |
I have some problems with converting the proto files to python files. AS Example: |
add cosmos v0.44 support