laconic-sdk/scripts/proto-gen.sh
Nabarun 65001568c8
Some checks failed
Tests / sdk_tests (push) Failing after 8m38s
Remove hard-coded record types (#52)
Refactors the `Record.Attributes` from Any into a byte string.
Companion to cerc-io/laconicd#132.

Resolves https://github.com/cerc-io/laconicd/issues/107

Co-authored-by: Roy Crihfield <roy@manteia.ltd>
Co-authored-by: Prathamesh Musale <prathamesh.musale0@gmail.com>
Reviewed-on: #52
Reviewed-by: Thomas E Lackey <telackey@noreply.git.vdb.to>
Co-authored-by: Nabarun <nabarun@deepstacksoft.com>
Co-committed-by: Nabarun <nabarun@deepstacksoft.com>
2024-01-15 04:58:55 +00:00

41 lines
976 B
Bash
Executable File

#!/bin/bash
# NOTE: protoc is required
set -e
REPO_ROOT=$(pwd)
I=$REPO_ROOT/proto
DEST_TS=$REPO_ROOT/src/proto/
echo "Generating protobuf files"
mkdir -p $DEST_TS
protoc \
--plugin=protoc-gen-ts=$REPO_ROOT/node_modules/.bin/protoc-gen-ts \
--ts_out=$DEST_TS \
--proto_path=$I \
$(find $REPO_ROOT/proto/vulcanize -iname "*.proto")
SED='sed -i'
if [[ "$OSTYPE" == "darwin"* ]]; then
SED='sed -i ""'
fi
echo "Removing gRPC references..."
# https://github.com/tharsis/evmosjs/tree/main/packages/proto#note
for file in $(find $REPO_ROOT/src/proto -type f)
do
line=$(grep -n '@grpc/grpc-js' $file | cut -f1 -d':')
if [[ -n "$line" ]] && [[ "$line" -gt 0 ]]; then
echo "Processing file: $file"
$SED "${line}d" ${file}
functions=$(grep -n 'interface GrpcUnaryServiceInterface' $file | cut -f1 -d':')
$SED "${functions},\$d" ${file}
echo '}' >> $file
fi
$SED '1s#^#/* eslint-disable */\n#' $file
$SED '1s#^#// @ts-nocheck\n#' $file
done