mirror of https://github.com/lightninglabs/loop
commit
e7ee29bd83
@ -0,0 +1,7 @@
|
||||
---
|
||||
Language: Proto
|
||||
BasedOnStyle: Google
|
||||
IndentWidth: 4
|
||||
AllowShortFunctionsOnASingleLine: None
|
||||
SpaceBeforeParens: Always
|
||||
CompactNamespaces: false
|
@ -0,0 +1,22 @@
|
||||
FROM golang:1.15.6-buster
|
||||
|
||||
RUN apt-get update && apt-get install -y \
|
||||
git \
|
||||
protobuf-compiler='3.6*' \
|
||||
clang-format='1:7.0*'
|
||||
|
||||
# We don't want any default values for these variables to make sure they're
|
||||
# explicitly provided by parsing the go.mod file. Otherwise we might forget to
|
||||
# update them here if we bump the versions.
|
||||
ARG PROTOC_GEN_VERSION
|
||||
ARG GRPC_GATEWAY_VERSION
|
||||
|
||||
RUN cd /tmp \
|
||||
&& export GO111MODULE=on \
|
||||
&& go get github.com/golang/protobuf/protoc-gen-go@${PROTOC_GEN_VERSION} \
|
||||
&& go get github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway@${GRPC_GATEWAY_VERSION} \
|
||||
&& go get github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger@${GRPC_GATEWAY_VERSION}
|
||||
|
||||
WORKDIR /build
|
||||
|
||||
CMD ["/bin/bash", "/build/looprpc/gen_protos.sh"]
|
File diff suppressed because it is too large
Load Diff
@ -1,24 +1,36 @@
|
||||
#!/bin/sh
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
# Generate the gRPC bindings for all proto files.
|
||||
for file in ./*.proto
|
||||
do
|
||||
protoc -I/usr/local/include -I. \
|
||||
-I$GOPATH/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis \
|
||||
--go_out=plugins=grpc,paths=source_relative:. \
|
||||
${file}
|
||||
# generate compiles the *.pb.go stubs from the *.proto files.
|
||||
function generate() {
|
||||
# Generate the gRPC bindings for all proto files.
|
||||
for file in ./*.proto
|
||||
do
|
||||
protoc -I/usr/local/include -I. \
|
||||
--go_out=plugins=grpc,paths=source_relative:. \
|
||||
"${file}"
|
||||
done
|
||||
|
||||
# Generate the REST reverse proxy for the client only.
|
||||
protoc -I/usr/local/include -I. \
|
||||
--grpc-gateway_out=logtostderr=true,paths=source_relative,grpc_api_configuration=rest-annotations.yaml:. \
|
||||
"client.proto"
|
||||
|
||||
done
|
||||
|
||||
# Only generate the REST proxy and definitions for the client component.
|
||||
protoc -I/usr/local/include -I. \
|
||||
-I$GOPATH/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis \
|
||||
--grpc-gateway_out=logtostderr=true:. \
|
||||
client.proto
|
||||
# Finally, generate the swagger file which describes the REST API in detail.
|
||||
protoc -I/usr/local/include -I. \
|
||||
--swagger_out=logtostderr=true,grpc_api_configuration=rest-annotations.yaml:. \
|
||||
"client.proto"
|
||||
}
|
||||
|
||||
protoc -I/usr/local/include -I. \
|
||||
-I$GOPATH/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis \
|
||||
--swagger_out=logtostderr=true:. \
|
||||
client.proto
|
||||
# format formats the *.proto files with the clang-format utility.
|
||||
function format() {
|
||||
find . -name "*.proto" -print0 | xargs -0 clang-format --style=file -i
|
||||
}
|
||||
|
||||
# Compile and format the looprpc package.
|
||||
pushd looprpc
|
||||
format
|
||||
generate
|
||||
popd
|
||||
|
@ -0,0 +1,23 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
# Directory of the script file, independent of where it's called from.
|
||||
DIR="$(cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd)"
|
||||
|
||||
PROTOC_GEN_VERSION=$(go list -f '{{.Version}}' -m github.com/golang/protobuf)
|
||||
GRPC_GATEWAY_VERSION=$(go list -f '{{.Version}}' -m github.com/grpc-ecosystem/grpc-gateway)
|
||||
|
||||
echo "Building protobuf compiler docker image..."
|
||||
docker build -q -t loop-protobuf-builder \
|
||||
--build-arg PROTOC_GEN_VERSION="$PROTOC_GEN_VERSION" \
|
||||
--build-arg GRPC_GATEWAY_VERSION="$GRPC_GATEWAY_VERSION" \
|
||||
.
|
||||
|
||||
echo "Compiling and formatting *.proto files..."
|
||||
docker run \
|
||||
--rm \
|
||||
--user $UID:$UID \
|
||||
-e UID=$UID \
|
||||
-v "$DIR/../:/build" \
|
||||
loop-protobuf-builder
|
@ -0,0 +1,33 @@
|
||||
type: google.api.Service
|
||||
config_version: 3
|
||||
|
||||
http:
|
||||
rules:
|
||||
# client.proto
|
||||
- selector: looprpc.SwapClient.LoopOut
|
||||
post: "/v1/loop/out"
|
||||
body: "*"
|
||||
- selector: looprpc.SwapClient.LoopIn
|
||||
post: "/v1/loop/in"
|
||||
body: "*"
|
||||
- selector: looprpc.SwapClient.ListSwaps
|
||||
get: "/v1/loop/swaps"
|
||||
- selector: looprpc.SwapClient.SwapInfo
|
||||
get: "/v1/loop/swap/{id}"
|
||||
- selector: looprpc.SwapClient.LoopOutTerms
|
||||
get: "/v1/loop/out/terms"
|
||||
- selector: looprpc.SwapClient.LoopOutQuote
|
||||
get: "/v1/loop/out/quote/{amt}"
|
||||
- selector: looprpc.SwapClient.GetLoopInTerms
|
||||
get: "/v1/loop/in/terms"
|
||||
- selector: looprpc.SwapClient.GetLoopInQuote
|
||||
get: "/v1/loop/in/quote/{amt}"
|
||||
- selector: looprpc.SwapClient.GetLsatTokens
|
||||
get: "/v1/lsat/tokens"
|
||||
- selector: looprpc.SwapClient.GetLiquidityParams
|
||||
get: "/v1/liquidity/params"
|
||||
- selector: looprpc.SwapClient.SetLiquidityParams
|
||||
post: "/v1/liquidity/params"
|
||||
body: "*"
|
||||
- selector: looprpc.SwapClient.SuggestSwaps
|
||||
get: "/v1/auto/suggest"
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue