2020-04-22 19:26:01 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
set -eo pipefail
|
|
|
|
|
2021-01-07 21:45:32 +00:00
|
|
|
protoc_gen_gocosmos() {
|
|
|
|
if ! grep "github.com/gogo/protobuf => github.com/regen-network/protobuf" go.mod &>/dev/null ; then
|
|
|
|
echo -e "\tPlease run this command from somewhere inside the ethermint folder."
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
go get github.com/regen-network/cosmos-proto/protoc-gen-gocosmos 2>/dev/null
|
|
|
|
}
|
|
|
|
|
|
|
|
protoc_gen_gocosmos
|
|
|
|
|
|
|
|
proto_dirs=$(find ./proto -path -prune -o -name '*.proto' -print0 | xargs -0 -n1 dirname | sort | uniq)
|
2020-04-22 19:26:01 +00:00
|
|
|
for dir in $proto_dirs; do
|
2021-01-07 21:45:32 +00:00
|
|
|
buf protoc \
|
|
|
|
-I "proto" \
|
|
|
|
-I "third_party/proto" \
|
|
|
|
--gocosmos_out=plugins=interfacetype+grpc,\
|
|
|
|
Mgoogle/protobuf/any.proto=github.com/cosmos/cosmos-sdk/codec/types:. \
|
|
|
|
$(find "${dir}" -maxdepth 1 -name '*.proto')
|
|
|
|
|
|
|
|
# command to generate gRPC gateway (*.pb.gw.go in respective modules) files
|
|
|
|
buf protoc \
|
|
|
|
-I "proto" \
|
|
|
|
-I "third_party/proto" \
|
|
|
|
--grpc-gateway_out=logtostderr=true:. \
|
|
|
|
$(find "${dir}" -maxdepth 1 -name '*.proto')
|
|
|
|
|
2020-04-22 19:26:01 +00:00
|
|
|
done
|
2021-01-07 21:45:32 +00:00
|
|
|
|
|
|
|
# generate codec/testdata proto code
|
|
|
|
buf protoc -I "proto" -I "third_party/proto" -I "testutil/testdata" --gocosmos_out=plugins=interfacetype+grpc,\
|
|
|
|
Mgoogle/protobuf/any.proto=github.com/cosmos/cosmos-sdk/codec/types:. ./testutil/testdata/*.proto
|
|
|
|
|
|
|
|
# move proto files to the right places
|
|
|
|
cp -r github.com/cosmos/ethermint/* ./
|
|
|
|
rm -rf github.com
|