-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
hard-nett
committed
Mar 29, 2024
1 parent
3b10918
commit 7f2b967
Showing
24 changed files
with
526 additions
and
752 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"swagger": "2.0", | ||
"info": { | ||
"title": "Terp Network - gRPC Gateway docs", | ||
"description": "A REST interface for state queries, legacy transactions", | ||
"version": "1.0.0" | ||
}, | ||
"apis": [] | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"name": "docs", | ||
"version": "1.0.0", | ||
"main": "index.js", | ||
"license": "MIT", | ||
"scripts": { | ||
"combine": "swagger-combine ./config.json -o static/swagger/swagger.yaml -f yaml --continueOnConflictingPaths --includeDefinitions", | ||
"convert": "swagger2openapi static/swagger/swagger.yaml --outfile static/openapi/openapi.yaml --yaml", | ||
"build": "redoc-cli bundle static/openapi/openapi.yaml --output ./static/openapi/index.html" | ||
}, | ||
"dependencies": { | ||
"redoc-cli": "^0.9.12", | ||
"swagger-combine": "^1.4.0", | ||
"swagger2openapi": "^7.0.3" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
swagger: '2.0' | ||
info: | ||
title: Terp Network - gRPC Gateway docs | ||
description: A REST interface for state queries, legacy transactions | ||
version: 1.0.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
version: v1 | ||
plugins: | ||
- name: gocosmos | ||
out: .. | ||
opt: plugins=grpc,Mgoogle/protobuf/any.proto=github.com/cosmos/cosmos-sdk/codec/types,Mcosmos/orm/v1/orm.proto=cosmossdk.io/orm | ||
- name: grpc-gateway | ||
out: .. | ||
opt: logtostderr=true,allow_colon_final_segments=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,50 @@ | ||
#!/usr/bin/env bash | ||
|
||
#== Legacy Requirements (<= SDK v45) == | ||
# | ||
## make sure your `go env GOPATH` is in the `$PATH` | ||
## Install: | ||
## + latest buf (v1.0.0-rc11 or later) | ||
## + protobuf v3 | ||
# | ||
## All protoc dependencies must be installed not in the module scope | ||
## currently we must use grpc-gateway v1 | ||
# cd ~ | ||
# go install google.golang.org/protobuf/cmd/protoc-gen-go@latest | ||
# go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest | ||
# go install github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway@v1.16.0 | ||
# go install github.com/cosmos/cosmos-proto/cmd/protoc-gen-go-pulsar@latest | ||
# go get github.com/regen-network/cosmos-proto@latest # doesn't work in install mode | ||
# go get github.com/regen-network/cosmos-proto/protoc-gen-gocosmos@v0.3.1 | ||
|
||
# Updated - How to run manually: | ||
# docker build --pull --rm -f "contrib/devtools/Dockerfile" -t cosmossdk-proto:latest "contrib/devtools" | ||
# docker run --rm -v $(pwd):/workspace --workdir /workspace cosmossdk-proto sh ./scripts/protocgen.sh | ||
|
||
set -eo pipefail | ||
set -e | ||
|
||
GO_MOD_PACKAGE="github.com/terpnetwork/terp-core" | ||
|
||
echo "Generating gogo proto code" | ||
cd proto | ||
buf mod update | ||
proto_dirs=$(find . -path -prune -o -name '*.proto' -print0 | xargs -0 -n1 dirname | sort | uniq) | ||
for dir in $proto_dirs; do | ||
for file in $(find "${dir}" -maxdepth 1 -name '*.proto'); do | ||
# this regex checks if a proto file has its go_package set to github.com/strangelove-ventures/poa/... | ||
# gogo proto files SHOULD ONLY be generated if this is false | ||
# we don't want gogo proto to run for proto files which are natively built for google.golang.org/protobuf | ||
if grep -q "option go_package" "$file" && grep -H -o -c "option go_package.*$GO_MOD_PACKAGE/api" "$file" | grep -q ':0$'; then | ||
buf generate --template buf.gen.gogo.yaml $file | ||
fi | ||
done | ||
done | ||
|
||
echo "Generating pulsar proto code" | ||
buf generate --template buf.gen.pulsar.yaml | ||
|
||
cd .. | ||
buf generate | ||
|
||
# move proto files to the right places | ||
cp -r ./github.com/terpnetwork/terp-core/x/* x/ | ||
cp -r ./github.com/cosmos/gaia/x/* x/ | ||
cp -r $GO_MOD_PACKAGE/* ./ | ||
rm -rf github.com | ||
|
||
# Copy files over for dep injection | ||
rm -rf api && mkdir api | ||
custom_modules=$(find . -name 'module' -type d -not -path "./proto/*") | ||
|
||
# get the 1 up directory (so ./cosmos/mint/module becomes ./cosmos/mint) | ||
# remove the relative path starter from base namespaces. so ./cosmos/mint becomes cosmos/mint | ||
base_namespace=$(echo $custom_modules | sed -e 's|/module||g' | sed -e 's|\./||g') | ||
|
||
# echo "Base namespace: $base_namespace" | ||
for module in $base_namespace; do | ||
echo " [+] Moving: ./$module to ./api/$module" | ||
|
||
mkdir -p api/$module | ||
|
||
mv $module/* ./api/$module/ | ||
|
||
# # incorrect reference to the module for coins | ||
find api/$module -type f -name '*.go' -exec sed -i -e 's|types "github.com/cosmos/cosmos-sdk/types"|types "cosmossdk.io/api/cosmos/base/v1beta1"|g' {} \; | ||
find api/$module -type f -name '*.go' -exec sed -i -e 's|types1 "github.com/cosmos/cosmos-sdk/x/bank/types"|types1 "cosmossdk.io/api/cosmos/bank/v1beta1"|g' {} \; | ||
|
||
rm -rf ./github.com | ||
rm -rf $module | ||
done |
This file was deleted.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.