Skip to content

Commit

Permalink
(fix) Changed the proto compilation code in Makefile to point to Inje…
Browse files Browse the repository at this point in the history
…ctiveLabs forks for cosmos-sdk, ibc-go, cometbft and wasmd. Also changed the logic to download locally specific injective-core and injective-indexer versions
  • Loading branch information
abel committed Nov 15, 2023
1 parent e4beb6e commit 01e5c3d
Show file tree
Hide file tree
Showing 113 changed files with 3,575 additions and 2,809 deletions.
58 changes: 43 additions & 15 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
all:

EXCHANGE_PROTO_FILES=$(shell find ../injective-indexer/api/gen/grpc -type f -name '*.proto')
PROTO_DIRS=$(shell find ./proto -path -prune -o -name '*.proto' -print0 | xargs -0 -n1 dirname | sort | uniq)
gen: gen-client

gen-client: copy-proto
@for dir in $(PROTO_DIRS); do \
gen-client: clone-all copy-proto
@for dir in $(shell find ./proto -path -prune -o -name '*.proto' -print0 | xargs -0 -n1 dirname | sort | uniq); do \
mkdir -p ./pyinjective/$${dir}; \
python3 -m grpc_tools.protoc \
-I proto \
Expand All @@ -14,25 +12,55 @@ gen-client: copy-proto
$$(find ./$${dir} -type f -name '*.proto'); \
done; \
rm -rf proto
$(call clean_repos)
echo "import os\nimport sys\n\nsys.path.insert(0, os.path.abspath(os.path.dirname(__file__)))" > pyinjective/proto/__init__.py

define clean_repos
rm -Rf cosmos-sdk
rm -Rf ibc-go
rm -Rf cometbft
rm -Rf wasmd
rm -Rf injective-core
rm -Rf injective-indexer
endef

clean-all:
$(call clean_repos)

clone-injective-core:
git clone https://github.com/InjectiveLabs/injective-core.git -b v1.12.5-testnet --depth 1 --single-branch

clone-injective-indexer:
git clone https://github.com/InjectiveLabs/injective-indexer.git -b v1.12.45-rc5 --depth 1 --single-branch

clone-cometbft:
git clone https://github.com/cometbft/cometbft.git -b v0.37.2 --depth 1 --single-branch

clone-wasmd:
git clone https://github.com/InjectiveLabs/wasmd.git -b v0.40.2-inj --depth 1 --single-branch

clone-cosmos-sdk:
git clone https://github.com/InjectiveLabs/cosmos-sdk.git -b v0.47.3-inj-6 --depth 1 --single-branch

clone-ibc-go:
git clone https://github.com/InjectiveLabs/ibc-go.git -b v7.2.0-inj --depth 1 --single-branch

clone-all: clone-cosmos-sdk clone-cometbft clone-ibc-go clone-wasmd clone-injective-core clone-injective-indexer

copy-proto:
rm -rf pyinjective/proto
mkdir -p proto/exchange
buf export buf.build/cosmos/cosmos-sdk:v0.47.0 --output=third_party
buf export https://github.com/cosmos/ibc-go.git --exclude-imports --output=third_party
buf export https://github.com/cometbft/cometbft.git --exclude-imports --output=third_party
buf export https://github.com/CosmWasm/wasmd.git --exclude-imports --output=./third_party
buf export https://github.com/cosmos/ics23.git --exclude-imports --output=./third_party

cp -r ../injective-core/proto/injective proto/
cp -r ./third_party/* proto/
buf export ./cosmos-sdk --output=third_party
buf export ./ibc-go --exclude-imports --output=third_party
buf export ./cometbft --exclude-imports --output=third_party
buf export ./wasmd --exclude-imports --output=third_party
buf export https://github.com/cosmos/ics23.git --exclude-imports --output=third_party
cp -r injective-core/proto/injective proto/
cp -r third_party/* proto/

rm -rf ./third_party

@for file in $(EXCHANGE_PROTO_FILES); do \
cp "$${file}" proto/exchange/; \
done
find ./injective-indexer/api/gen/grpc -type f -name "*.proto" -exec cp {} ./proto/exchange/ \;

tests:
poetry run pytest -v
Expand Down
39 changes: 0 additions & 39 deletions pyinjective/proto/capability/v1/capability_pb2.py

This file was deleted.

36 changes: 0 additions & 36 deletions pyinjective/proto/capability/v1/genesis_pb2.py

This file was deleted.

14 changes: 11 additions & 3 deletions pyinjective/proto/cosmos/authz/v1beta1/tx_pb2.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 34 additions & 0 deletions pyinjective/proto/cosmos/authz/v1beta1/tx_pb2_grpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ def __init__(self, channel):
request_serializer=cosmos_dot_authz_dot_v1beta1_dot_tx__pb2.MsgRevoke.SerializeToString,
response_deserializer=cosmos_dot_authz_dot_v1beta1_dot_tx__pb2.MsgRevokeResponse.FromString,
)
self.ExecCompat = channel.unary_unary(
'/cosmos.authz.v1beta1.Msg/ExecCompat',
request_serializer=cosmos_dot_authz_dot_v1beta1_dot_tx__pb2.MsgExecCompat.SerializeToString,
response_deserializer=cosmos_dot_authz_dot_v1beta1_dot_tx__pb2.MsgExecCompatResponse.FromString,
)


class MsgServicer(object):
Expand Down Expand Up @@ -63,6 +68,13 @@ def Revoke(self, request, context):
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!')

def ExecCompat(self, request, context):
"""ExecCompat has same functionality as Exec but accepts array of json-encoded message string instead of []*Any
"""
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!')


def add_MsgServicer_to_server(servicer, server):
rpc_method_handlers = {
Expand All @@ -81,6 +93,11 @@ def add_MsgServicer_to_server(servicer, server):
request_deserializer=cosmos_dot_authz_dot_v1beta1_dot_tx__pb2.MsgRevoke.FromString,
response_serializer=cosmos_dot_authz_dot_v1beta1_dot_tx__pb2.MsgRevokeResponse.SerializeToString,
),
'ExecCompat': grpc.unary_unary_rpc_method_handler(
servicer.ExecCompat,
request_deserializer=cosmos_dot_authz_dot_v1beta1_dot_tx__pb2.MsgExecCompat.FromString,
response_serializer=cosmos_dot_authz_dot_v1beta1_dot_tx__pb2.MsgExecCompatResponse.SerializeToString,
),
}
generic_handler = grpc.method_handlers_generic_handler(
'cosmos.authz.v1beta1.Msg', rpc_method_handlers)
Expand Down Expand Up @@ -142,3 +159,20 @@ def Revoke(request,
cosmos_dot_authz_dot_v1beta1_dot_tx__pb2.MsgRevokeResponse.FromString,
options, channel_credentials,
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)

@staticmethod
def ExecCompat(request,
target,
options=(),
channel_credentials=None,
call_credentials=None,
insecure=False,
compression=None,
wait_for_ready=None,
timeout=None,
metadata=None):
return grpc.experimental.unary_unary(request, target, '/cosmos.authz.v1beta1.Msg/ExecCompat',
cosmos_dot_authz_dot_v1beta1_dot_tx__pb2.MsgExecCompat.SerializeToString,
cosmos_dot_authz_dot_v1beta1_dot_tx__pb2.MsgExecCompatResponse.FromString,
options, channel_credentials,
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)
34 changes: 34 additions & 0 deletions pyinjective/proto/cosmos/bank/v1beta1/events_pb2.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 01e5c3d

Please sign in to comment.