Skip to content

Commit

Permalink
feat(swagger): add make command proto-swagger-gen (#856)
Browse files Browse the repository at this point in the history
  • Loading branch information
VictorTrustyDev authored Apr 23, 2024
1 parent 6f6df1e commit d79ac7b
Show file tree
Hide file tree
Showing 6 changed files with 56,664 additions and 51,519 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ Ref: https://keepachangelog.com/en/1.0.0/

## Unreleased

### Features

- (swagger) [#856](https://github.com/dymensionxyz/dymension/issues/856) Add make command `proto-swagger-gen`

## [v3.1.0](https://github.com/dymensionxyz/dymension/releases/tag/v3.1.0)

### Features
Expand Down
101 changes: 101 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,15 @@ TM_VERSION := $(shell go list -m github.com/tendermint/tendermint | sed 's:.* ::
DOCKER := $(shell which docker)
BUILDDIR ?= $(CURDIR)/build

# Dependencies version
DEPS_COSMOS_SDK_VERSION := $(shell cat go.sum | grep 'github.com/cosmos/cosmos-sdk' | grep -v -e 'go.mod' | tail -n 1 | awk '{ print $$2; }')
DEPS_ETHERMINT_VERSION := $(shell cat go.sum | grep 'github.com/dymensionxyz/ethermint' | grep -v -e 'go.mod' | tail -n 1 | awk '{ print $$2; }')
DEPS_OSMOSIS_VERSION := $(shell cat go.sum | grep 'github.com/dymensionxyz/osmosis' | grep -v -e 'go.mod' | tail -n 1 | awk '{ print $$2; }')
DEPS_IBC_GO_VERSION := $(shell cat go.sum | grep 'github.com/cosmos/ibc-go' | grep -v -e 'go.mod' | tail -n 1 | awk '{ print $$2; }')
DEPS_COSMOS_PROTO_VERSION := $(shell cat go.sum | grep 'github.com/cosmos/cosmos-proto' | grep -v -e 'go.mod' | tail -n 1 | awk '{ print $$2; }')
DEPS_COSMOS_GOGOPROTO_VERSION := $(shell cat go.sum | grep 'github.com/cosmos/gogoproto' | grep -v -e 'go.mod' | tail -n 1 | awk '{ print $$2; }')
DEPS_CONFIO_ICS23_VERSION := go/$(shell cat go.sum | grep 'github.com/confio/ics23/go' | grep -v -e 'go.mod' | tail -n 1 | awk '{ print $$2; }')

export GO111MODULE = on

# process build tags
Expand Down Expand Up @@ -141,14 +150,106 @@ release:
### Proto ###
###############################################################################

# ------
# NOTE: Link to the tendermintdev/sdk-proto-gen docker images:
# https://hub.docker.com/r/tendermintdev/sdk-proto-gen/tags
#
protoVer=v0.7
protoImageName=tendermintdev/sdk-proto-gen:$(protoVer)
containerProtoGen=cosmos-sdk-proto-gen-$(protoVer)
containerProtoFmt=cosmos-sdk-proto-fmt-$(protoVer)
# ------
# NOTE: cosmos/proto-builder image is needed because clang-format is not installed
# on the tendermintdev/sdk-proto-gen docker image.
# Link to the cosmos/proto-builder docker images:
# https://github.com/cosmos/cosmos-sdk/pkgs/container/proto-builder
#
protoCosmosVer=0.11.2
protoCosmosName=ghcr.io/cosmos/proto-builder:$(protoCosmosVer)
protoCosmosImage=$(DOCKER) run --network host --rm -v $(CURDIR):/workspace --workdir /workspace $(protoCosmosName)

proto-gen:
@echo "Generating Protobuf files"
@if docker ps -a --format '{{.Names}}' | grep -Eq "^${containerProtoGen}$$"; then docker start -a $(containerProtoGen); else docker run --name $(containerProtoGen) -v $(CURDIR):/workspace --workdir /workspace $(protoImageName) \
sh ./scripts/protocgen.sh; fi
@go mod tidy

proto-swagger-gen:
@echo "Downloading Protobuf dependencies"
@make proto-download-deps
@echo "Generating Protobuf Swagger"
$(protoCosmosImage) sh ./scripts/protoc-swagger-gen.sh

SWAGGER_DIR=./swagger-proto
THIRD_PARTY_DIR=$(SWAGGER_DIR)/third_party

proto-download-deps:
mkdir -p "$(THIRD_PARTY_DIR)/cosmos_tmp" && \
cd "$(THIRD_PARTY_DIR)/cosmos_tmp" && \
git init && \
git remote add origin "https://github.com/cosmos/cosmos-sdk.git" && \
git config core.sparseCheckout true && \
printf "proto\nthird_party\n" > .git/info/sparse-checkout && \
git fetch --depth=1 origin "$(DEPS_COSMOS_SDK_VERSION)" && \
git checkout FETCH_HEAD && \
rm -f ./proto/buf.* && \
mv ./proto/* ..
rm -rf "$(THIRD_PARTY_DIR)/cosmos_tmp"

mkdir -p "$(THIRD_PARTY_DIR)/ethermint_tmp" && \
cd "$(THIRD_PARTY_DIR)/ethermint_tmp" && \
git init && \
git remote add origin "https://github.com/dymensionxyz/ethermint.git" && \
git config core.sparseCheckout true && \
printf "proto\nthird_party\n" > .git/info/sparse-checkout && \
git fetch --depth=1 origin "$(DEPS_ETHERMINT_VERSION)" && \
git checkout FETCH_HEAD && \
rm -f ./proto/buf.* && \
mv ./proto/* ..
rm -rf "$(THIRD_PARTY_DIR)/ethermint_tmp"

mkdir -p "$(THIRD_PARTY_DIR)/osmosis_tmp" && \
cd "$(THIRD_PARTY_DIR)/osmosis_tmp" && \
git init && \
git remote add origin "https://github.com/dymensionxyz/osmosis.git" && \
git config core.sparseCheckout true && \
printf "proto\nthird_party\n" > .git/info/sparse-checkout && \
git fetch --depth=1 origin "$(DEPS_OSMOSIS_VERSION)" && \
git checkout FETCH_HEAD && \
rm -f ./proto/buf.* && \
mv ./proto/* ..
rm -rf "$(THIRD_PARTY_DIR)/osmosis_tmp"

mkdir -p "$(THIRD_PARTY_DIR)/ibc_tmp" && \
cd "$(THIRD_PARTY_DIR)/ibc_tmp" && \
git init && \
git remote add origin "https://github.com/cosmos/ibc-go.git" && \
git config core.sparseCheckout true && \
printf "proto\n" > .git/info/sparse-checkout && \
git fetch --depth=1 origin "$(DEPS_IBC_GO_VERSION)" && \
git checkout FETCH_HEAD && \
rm -f ./proto/buf.* && \
mv ./proto/* ..
rm -rf "$(THIRD_PARTY_DIR)/ibc_tmp"

mkdir -p "$(THIRD_PARTY_DIR)/cosmos_proto_tmp" && \
cd "$(THIRD_PARTY_DIR)/cosmos_proto_tmp" && \
git init && \
git remote add origin "https://github.com/cosmos/cosmos-proto.git" && \
git config core.sparseCheckout true && \
printf "proto\n" > .git/info/sparse-checkout && \
git fetch --depth=1 origin "$(DEPS_COSMOS_PROTO_VERSION)" && \
git checkout FETCH_HEAD && \
rm -f ./proto/buf.* && \
mv ./proto/* ..
rm -rf "$(THIRD_PARTY_DIR)/cosmos_proto_tmp"

mkdir -p "$(THIRD_PARTY_DIR)/gogoproto" && \
curl -SSL https://raw.githubusercontent.com/cosmos/gogoproto/$(DEPS_COSMOS_GOGOPROTO_VERSION)/gogoproto/gogo.proto > "$(THIRD_PARTY_DIR)/gogoproto/gogo.proto"

mkdir -p "$(THIRD_PARTY_DIR)/google/api" && \
curl -sSL https://raw.githubusercontent.com/googleapis/googleapis/master/google/api/annotations.proto > "$(THIRD_PARTY_DIR)/google/api/annotations.proto"
curl -sSL https://raw.githubusercontent.com/googleapis/googleapis/master/google/api/http.proto > "$(THIRD_PARTY_DIR)/google/api/http.proto"

mkdir -p "$(THIRD_PARTY_DIR)/confio/ics23" && \
curl -sSL https://raw.githubusercontent.com/confio/ics23/$(DEPS_CONFIO_ICS23_VERSION)/proofs.proto > "$(THIRD_PARTY_DIR)/proofs.proto"
227 changes: 227 additions & 0 deletions docs/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,227 @@
{
"swagger": "2.0",
"info": {
"title": "HTTP API Console",
"description": "",
"version": "1.0.0"
},
"apis": [
{
"url": "./tmp-swagger-gen/dymension/delayedack/query.swagger.json",
"operationIds": {
"rename": {
"Params": "DelayedAckParams"
}
}
},
{
"url": "./tmp-swagger-gen/dymension/eibc/query.swagger.json",
"operationIds": {
"rename": {
"Params": "EIbcParams"
}
}
},
{
"url": "./tmp-swagger-gen/dymension/rollapp/query.swagger.json",
"operationIds": {
"rename": {
"Params": "RollAppParams"
}
}
},
{
"url": "./tmp-swagger-gen/dymension/sequencer/query.swagger.json",
"operationIds": {
"rename": {
"Params": "SequencerParams"
}
}
},
{
"url": "./tmp-swagger-gen/dymension/streamer/query.swagger.json",
"operationIds": {
"rename": {
"Params": "StreamerParams",
"ModuleToDistributeCoins": "StreamerModuleToDistributeCoins"
}
}
},
{
"url": "./tmp-swagger-gen/ethermint/evm/v1/query.swagger.json",
"operationIds": {
"rename": {
"Params": "EvmParams"
}
}
},
{
"url": "./tmp-swagger-gen/ethermint/feemarket/v1/query.swagger.json",
"operationIds": {
"rename": {
"Params": "FeeMarketParams",
"BaseFee": "FeeMarketBaseFee"
}
}
},
{
"url": "./tmp-swagger-gen/osmosis/gamm/v2/query.swagger.json",
"operationIds": {
"rename": {
"SpotPrice": "SpotPriceV2"
}
}
},
{
"url": "./tmp-swagger-gen/osmosis/gamm/v1beta1/query.swagger.json",
"operationIds": {
"rename": {
"Params": "GammParams",
"SpotPrice": "SpotPriceV1beta1",
"Pool": "GammPool"
}
}
},
{
"url": "./tmp-swagger-gen/osmosis/epochs/query.swagger.json"
},
{
"url": "./tmp-swagger-gen/osmosis/incentives/query.swagger.json",
"operationIds": {
"rename": {
"Params": "IncentivesParams",
"ModuleToDistributeCoins": "IncentivesModuleToDistributeCoins"
}
}
},
{
"url": "./tmp-swagger-gen/osmosis/lockup/query.swagger.json",
"operationIds": {
"rename": {
"Params": "LockupParams"
}
}
},
{
"url": "./tmp-swagger-gen/osmosis/txfees/v1beta1/query.swagger.json",
"operationIds": {
"rename": {
"Params": "TxFeesParams"
}
}
},
{
"url": "./tmp-swagger-gen/ibc/applications/transfer/v1/query.swagger.json",
"operationIds": {
"rename": {
"Params": "TransferParams"
}
}
},
{
"url": "./tmp-swagger-gen/ibc/core/client/v1/query.swagger.json",
"operationIds": {
"rename": {
"Params": "ClientParams"
}
}
},
{
"url": "./tmp-swagger-gen/ibc/core/connection/v1/query.swagger.json",
"operationIds": {
"rename": {
"Params": "ConnectionParams"
}
}
},
{
"url": "./tmp-swagger-gen/ibc/core/channel/v1/query.swagger.json"
},
{
"url": "./tmp-swagger-gen/cosmos/auth/v1beta1/query.swagger.json",
"operationIds": {
"rename": {
"Account": "AuthAccount",
"Params": "AuthParams"
}
}
},
{
"url": "./tmp-swagger-gen/cosmos/authz/v1beta1/query.swagger.json"
},
{
"url": "./tmp-swagger-gen/cosmos/bank/v1beta1/query.swagger.json",
"operationIds": {
"rename": {
"Balance": "BankBalance",
"Params": "BankParams"
}
}
},
{
"url": "./tmp-swagger-gen/cosmos/distribution/v1beta1/query.swagger.json",
"operationIds": {
"rename": {
"Params": "DistributionParams",
"DelegatorValidators": "DistDelegatorValidators"
}
}
},
{
"url": "./tmp-swagger-gen/cosmos/feegrant/v1beta1/query.swagger.json"
},
{
"url": "./tmp-swagger-gen/cosmos/gov/v1beta1/query.swagger.json",
"operationIds": {
"rename": {
"Params": "GovParams"
}
}
},
{
"url": "./tmp-swagger-gen/cosmos/gov/v1/query.swagger.json",
"operationIds": {
"rename": {
"Params": "GovV1Params",
"Proposal": "GovV1Proposal",
"Proposals": "GovV1Proposal",
"Vote": "GovV1Vote",
"Votes": "GovV1Votes",
"Deposit": "GovV1Deposit",
"Deposits": "GovV1Deposit",
"TallyResult": "GovV1TallyResult"
}
}
},
{
"url": "./tmp-swagger-gen/cosmos/slashing/v1beta1/query.swagger.json",
"operationIds": {
"rename": {
"Params": "SlashingParams"
}
}
},
{
"url": "./tmp-swagger-gen/cosmos/staking/v1beta1/query.swagger.json",
"operationIds": {
"rename": {
"Params": "StakingParams"
}
}
},
{
"url": "./tmp-swagger-gen/cosmos/tx/v1beta1/service.swagger.json",
"dereference": {
"circular": "ignore"
}
},
{
"url": "./tmp-swagger-gen/cosmos/base/tendermint/v1beta1/query.swagger.json",
"operationIds": {
"rename": {
"Params": "BaseParams"
}
}
}
]
}
Loading

0 comments on commit d79ac7b

Please sign in to comment.