cosmpy icon indicating copy to clipboard operation
cosmpy copied to clipboard

Use cosmpy with a different Cosmo chain

Open johnqh opened this issue 2 years ago • 7 comments

Prerequisites

Expected Behavior

We used protoc to generate the proto types and clients for a different Cosmo chain, and tried to use cosmpy to interact with it.

I expect to use cosmpy to sign message for the chain-specific functions to send transactions.

Current Behavior

It works until if the code import both cosmpy and proto types from the other chain.

cosmpy includes standard Cosmo types and clients, which conflict with the Cosmo types from the other chain. As far as I can tell, the only way to get around it is to have exactly the same Cosmo SDK version, Python version, and protoc/protobuf versions.

To Reproduce

No response

Context

Latest Cosmpy version

Failure Logs

No response

johnqh avatar Apr 24 '23 21:04 johnqh

I want to call osmosis/gamm/swap-exact-amount-in on cosmpy. Do I need to generate the proto file for osmosis myself? Is there a tutorial or method to generate it, similar to https://github.com/ctrl-Felix/cosmospy-protobuf, which can make cosmpy more versatile? @johnqh

thejoven avatar Jun 07 '23 07:06 thejoven

i try use

python -m grpc_tools.protoc --proto_path=$(OSMOSIS_SDK_DIR)/proto --proto_path=$(OSMOSIS_SDK_DIR)/third_party/proto  --python_out=$(OSMOSIS_PROTOS_DIR) --grpc_python_out=$(OSMOSIS_PROTOS_DIR) $(shell find $(OSMOSIS_SDK_DIR) \( -path */proto/* -or -path */third_party/proto/* \) -type f -name *.proto)

but get this error

osmosis/protorev/v1beta1/tx.proto:63:12: "TokenPairArbRoutes" is not defined.
osmosis/protorev/v1beta1/tx.proto:97:3: "PoolWeights" is not defined.
osmosis/protorev/v1beta1/tx.proto:150:12: "BaseDenom" is not defined.
make: *** [generate_proto_types] Error 1

thejoven avatar Jun 07 '23 07:06 thejoven

protoc --version libprotoc 23.2

The GeneratedProtocolMessageType is missing in the proto I generated. What version of protoc is being used in cosmpy?

@MissingNO57

thejoven avatar Jun 07 '23 11:06 thejoven

protoc --version libprotoc 3.20.3

Still unable to generate GeneratedProtocolMessageType image

thejoven avatar Jun 07 '23 12:06 thejoven

Check this repo. It has all the compiled protos for osmosis:

https://github.com/ctrl-Felix/cosmospy-protobuf/tree/chain/osmosis

freQniK avatar Jun 11 '23 05:06 freQniK

You can also use it to compile protos for any chain. Question is how would I use this with cosmpy?

freQniK avatar Jun 11 '23 05:06 freQniK

yep,I was also considering using ctrl-Felix before, but it's obvious that the protobuf generated by ctrl-Felix is different. I had to give up this option. I have now switched to TypeScript to meet my needs. Hopefully, there will be more iterations in Python, but obviously, the development ecosystem of Cosmos is too scattered and there are no good building tools available. It's a pity.

thejoven avatar Jun 12 '23 00:06 thejoven