-
Notifications
You must be signed in to change notification settings - Fork 109
Fix: Resolve protobuf generation bloat with sparse mode filtering #1525
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 4 commits
13c02d5
2b64e59
e0cc58c
8e0eead
a079d62
cb614fe
1ca3399
4f9cad6
4d2ddf2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,31 +1,97 @@ | ||||||||||||
| #!/bin/bash | ||||||||||||
|
|
||||||||||||
| # this script checks out mayanode master and generates the proto3 typescript buindings for MsgDeposit and MsgSend | ||||||||||||
| # This script updates MAYAChain Protobuf bindings for MsgDeposit and MsgSend | ||||||||||||
| set -e # Exit on any error | ||||||||||||
|
|
||||||||||||
| MSG_COMPILED_OUTPUTFILE=src/types/proto/MsgCompiled.js | ||||||||||||
| MSG_COMPILED_TYPES_OUTPUTFILE=src/types/proto/MsgCompiled.d.ts | ||||||||||||
|
|
||||||||||||
| TMP_DIR=$(mktemp -d) | ||||||||||||
| # Using local minimal proto files - no need to clone mayanode repository | ||||||||||||
|
|
||||||||||||
| # Download cosmos/base/v1beta1/coin.proto from cosmossdk | ||||||||||||
| COSMOS_COIN_PROTO="proto/cosmos/base/v1beta1/coin.proto" | ||||||||||||
| if [ ! -f "$COSMOS_COIN_PROTO" ]; then | ||||||||||||
| tput setaf 2 | ||||||||||||
| echo "Downloading cosmos/base/v1beta1/coin.proto from cosmossdk" | ||||||||||||
| tput sgr0 | ||||||||||||
| mkdir -p "proto/cosmos/base/v1beta1" | ||||||||||||
| if ! curl -f -o "$COSMOS_COIN_PROTO" \ | ||||||||||||
| "https://raw.githubusercontent.com/cosmos/cosmos-sdk/main/proto/cosmos/base/v1beta1/coin.proto"; then | ||||||||||||
| echo "Error: Failed to download cosmos coin.proto" | ||||||||||||
| exit 1 | ||||||||||||
| fi | ||||||||||||
| echo "✓ Downloaded cosmos coin.proto" | ||||||||||||
| else | ||||||||||||
| echo "✓ cosmos coin.proto already exists" | ||||||||||||
| fi | ||||||||||||
|
|
||||||||||||
| # Verify our minimal proto files exist | ||||||||||||
| tput setaf 2 | ||||||||||||
| echo "Checking out https://gitlab.com/mayachain/mayanode to $TMP_DIR" | ||||||||||||
| echo "Checking minimal proto files" | ||||||||||||
| tput sgr0 | ||||||||||||
| (cd $TMP_DIR && git clone https://gitlab.com/mayachain/mayanode) | ||||||||||||
| MISSING_FILES=0 | ||||||||||||
| for proto_file in \ | ||||||||||||
| "proto/common/minimal_common.proto" \ | ||||||||||||
| "proto/types/minimal_msg_deposit.proto" \ | ||||||||||||
| "proto/types/minimal_msg_send.proto" \ | ||||||||||||
| "$COSMOS_COIN_PROTO"; do | ||||||||||||
| if [ ! -f "$proto_file" ]; then | ||||||||||||
| echo "Error: $(basename "$proto_file") missing" | ||||||||||||
| MISSING_FILES=1 | ||||||||||||
| else | ||||||||||||
| echo "✓ $(basename "$proto_file") found" | ||||||||||||
| fi | ||||||||||||
| done | ||||||||||||
|
|
||||||||||||
|
coderabbitai[bot] marked this conversation as resolved.
|
||||||||||||
| if [ $MISSING_FILES -eq 1 ]; then | ||||||||||||
| echo "Error: Required proto files are missing" | ||||||||||||
| exit 1 | ||||||||||||
| fi | ||||||||||||
|
|
||||||||||||
| # Generate msgs | ||||||||||||
| # Generate Protobuf JS bindings using minimal proto files to prevent over-inclusion | ||||||||||||
| tput setaf 2 | ||||||||||||
| echo "Generating $MSG_COMPILED_OUTPUTFILE" | ||||||||||||
| tput sgr0 | ||||||||||||
| yarn run pbjs -w commonjs -t static-module $TMP_DIR/mayanode/proto/mayachain/v1/common/common.proto $TMP_DIR/mayanode/proto/mayachain/v1/x/mayachain/types/msg_deposit.proto $TMP_DIR/mayanode/proto/mayachain/v1/x/mayachain/types/msg_send.proto $TMP_DIR/mayanode/third_party/proto/cosmos/base/v1beta1/coin.proto -o $MSG_COMPILED_OUTPUTFILE | ||||||||||||
| if ! yarn pbjs -w commonjs -t static-module \ | ||||||||||||
| -p proto \ | ||||||||||||
| "proto/common/minimal_common.proto" \ | ||||||||||||
| "proto/types/minimal_msg_deposit.proto" \ | ||||||||||||
| "proto/types/minimal_msg_send.proto" \ | ||||||||||||
| "$COSMOS_COIN_PROTO" \ | ||||||||||||
| -o "$MSG_COMPILED_OUTPUTFILE" 2>pbjs_errors.txt; then | ||||||||||||
| echo "Error: Failed to generate JavaScript bindings" | ||||||||||||
| cat pbjs_errors.txt | ||||||||||||
| exit 1 | ||||||||||||
| fi | ||||||||||||
|
coderabbitai[bot] marked this conversation as resolved.
Outdated
|
||||||||||||
|
|
||||||||||||
| # Fix import to be ESM-compatible (no omitted file extension) | ||||||||||||
| sed -i -E 's|"(protobufjs/minimal)"|"\1.js"|' "$MSG_COMPILED_OUTPUTFILE" | ||||||||||||
|
|
||||||||||||
|
Comment on lines
96
to
98
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion BSD/GNU sed portability: use -i.bak to support macOS. -sed -i -E 's|"(protobufjs/minimal)"|"\1.js"|' "$MSG_COMPILED_OUTPUTFILE"
+sed -i.bak -E 's|"(protobufjs/minimal)"|"\1.js"|' "$MSG_COMPILED_OUTPUTFILE" && rm -f "$MSG_COMPILED_OUTPUTFILE.bak"📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||
| # Generate TypeScript definitions | ||||||||||||
| tput setaf 2 | ||||||||||||
| echo "Generating $MSG_COMPILED_TYPES_OUTPUTFILE" | ||||||||||||
| tput sgr0 | ||||||||||||
| yarn run pbts $MSG_COMPILED_OUTPUTFILE -o $MSG_COMPILED_TYPES_OUTPUTFILE | ||||||||||||
| if ! yarn pbts "$MSG_COMPILED_OUTPUTFILE" -o "$MSG_COMPILED_TYPES_OUTPUTFILE" 2>pbts_errors.txt; then | ||||||||||||
| echo "Error: Failed to generate TypeScript definitions" | ||||||||||||
| cat pbts_errors.txt | ||||||||||||
| exit 1 | ||||||||||||
| fi | ||||||||||||
|
|
||||||||||||
| # Verify generated files | ||||||||||||
| if [ ! -f "$MSG_COMPILED_OUTPUTFILE" ] || [ ! -s "$MSG_COMPILED_OUTPUTFILE" ]; then | ||||||||||||
| echo "Error: Generated JavaScript file is missing or empty" | ||||||||||||
| exit 1 | ||||||||||||
| fi | ||||||||||||
|
|
||||||||||||
| if [ ! -f "$MSG_COMPILED_TYPES_OUTPUTFILE" ] || [ ! -s "$MSG_COMPILED_TYPES_OUTPUTFILE" ]; then | ||||||||||||
| echo "Error: Generated TypeScript definitions file is missing or empty" | ||||||||||||
| exit 1 | ||||||||||||
| fi | ||||||||||||
|
|
||||||||||||
| # Clean up error files if they're empty | ||||||||||||
| [ ! -s pbjs_errors.txt ] && rm -f pbjs_errors.txt | ||||||||||||
| [ ! -s pbts_errors.txt ] && rm -f pbts_errors.txt | ||||||||||||
|
|
||||||||||||
| tput setaf 2 | ||||||||||||
| echo "Removing $TMP_DIR/mayanode" | ||||||||||||
| echo "✓ Successfully generated protobuf bindings" | ||||||||||||
| tput sgr0 | ||||||||||||
| rm -rf $TMP_DIR | ||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,45 +1,68 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| #!/bin/bash | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # This script updates THORChain Protobuf bindings for MsgDeposit and MsgSend | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| set -e # Exit on any error | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| MSG_COMPILED_OUTPUTFILE=src/types/proto/MsgCompiled.js | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| MSG_COMPILED_TYPES_OUTPUTFILE=src/types/proto/MsgCompiled.d.ts | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| TMP_DIR=$(mktemp -d) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Using local minimal proto files - no need to clone thornode repository | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| tput setaf 2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "Checking out https://gitlab.com/thorchain/thornode to $TMP_DIR" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| tput sgr0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| (cd "$TMP_DIR" && git clone --branch develop https://gitlab.com/thorchain/thornode) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Download cosmos/base/v1beta1/coin.proto from cosmossdk | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| COSMOS_COIN_PROTO="proto/cosmos/base/v1beta1/coin.proto" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if [ ! -f "$COSMOS_COIN_PROTO" ]; then | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| tput setaf 2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "Downloading cosmos/base/v1beta1/coin.proto from cosmossdk" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| tput sgr0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| mkdir -p "proto/cosmos/base/v1beta1" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if ! curl -f -o "$COSMOS_COIN_PROTO" \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "https://raw.githubusercontent.com/cosmos/cosmos-sdk/main/proto/cosmos/base/v1beta1/coin.proto"; then | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "Error: Failed to download cosmos coin.proto" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| exit 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "✓ Downloaded cosmos coin.proto" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "✓ cosmos coin.proto already exists" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Verify proto files exist | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Verify our minimal proto files exist | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| tput setaf 2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "Checking proto files" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "Checking minimal proto files" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| tput sgr0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ls "$TMP_DIR/thornode/proto/thorchain/v1/common/common.proto" || echo "common.proto missing" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ls "$TMP_DIR/thornode/proto/thorchain/v1/types/msg_deposit.proto" || echo "msg_deposit.proto missing" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ls "$TMP_DIR/thornode/proto/thorchain/v1/types/msg_send.proto" || echo "msg_send.proto missing" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| MISSING_FILES=0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| for proto_file in \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "proto/common/minimal_common.proto" \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "proto/types/minimal_msg_deposit.proto" \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "proto/types/minimal_msg_send.proto" \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "$COSMOS_COIN_PROTO"; do | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if [ ! -f "$proto_file" ]; then | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "Error: $(basename "$proto_file") missing" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| MISSING_FILES=1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "✓ $(basename "$proto_file") found" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| done | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Download cosmos/base/v1beta1/coin.proto from cosmossdk | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| tput setaf 2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "Downloading cosmos/base/v1beta1/coin.proto from cosmossdk" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| tput sgr0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| mkdir -p "$TMP_DIR/thornode/third_party/proto/cosmos/base/v1beta1" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| curl -o "$TMP_DIR/thornode/third_party/proto/cosmos/base/v1beta1/coin.proto" \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "https://raw.githubusercontent.com/cosmos/cosmos-sdk/main/proto/cosmos/base/v1beta1/coin.proto" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if [ $MISSING_FILES -eq 1 ]; then | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "Error: Required proto files are missing" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| exit 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Generate Protobuf JS bindings with include path | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Generate Protobuf JS bindings using minimal proto files to prevent over-inclusion | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| tput setaf 2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "Generating $MSG_COMPILED_OUTPUTFILE" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| tput sgr0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| yarn pbjs -w commonjs -t static-module \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| -p "$TMP_DIR/thornode/proto" \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| -p "$TMP_DIR/thornode/third_party/proto" \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "$TMP_DIR/thornode/proto/thorchain/v1/common/common.proto" \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "$TMP_DIR/thornode/proto/thorchain/v1/types/msg_deposit.proto" \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "$TMP_DIR/thornode/proto/thorchain/v1/types/msg_send.proto" \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "$TMP_DIR/thornode/third_party/proto/cosmos/base/v1beta1/coin.proto" \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| -o "$MSG_COMPILED_OUTPUTFILE" 2>pbjs_errors.txt | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if ! yarn pbjs -w commonjs -t static-module \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| -p proto \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "proto/common/minimal_common.proto" \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "proto/types/minimal_msg_deposit.proto" \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "proto/types/minimal_msg_send.proto" \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "$COSMOS_COIN_PROTO" \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| -o "$MSG_COMPILED_OUTPUTFILE" 2>pbjs_errors.txt; then | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+91
to
+101
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Verify pbjs supports --sparse before use Older pbjs lacks --sparse; fail fast with a clear message. +tput setaf 2 || true
+echo "Checking pbjs supports --sparse"
+tput sgr0 || true
+if ! yarn pbjs --help | grep -q -- '--sparse'; then
+ echo "Error: pbjs does not support --sparse. Update protobufjs-cli."
+ exit 1
+fi
if ! yarn pbjs -w commonjs -t static-module --sparse \📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "Error: Failed to generate JavaScript bindings" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| cat pbjs_errors.txt | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| exit 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Ensure output directory exists before pbjs; fail clearly if tools are missing Avoids failures on clean checkouts; surfaces missing binaries early. +mkdir -p "$(dirname "$MSG_COMPILED_OUTPUTFILE")"
+command -v yarn >/dev/null || { echo "Error: yarn not found"; exit 1; }
if ! yarn pbjs -w commonjs -t static-module \
-p proto \
"proto/common/minimal_common.proto" \
"proto/types/minimal_msg_deposit.proto" \
"proto/types/minimal_msg_send.proto" \
"$COSMOS_COIN_PROTO" \
-o "$MSG_COMPILED_OUTPUTFILE" 2>pbjs_errors.txt; then📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Fix import to be ESM-compatible (no omitted file extension) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| sed -i -E 's|"(protobufjs/minimal)"|"\1.js"|' "$MSG_COMPILED_OUTPUTFILE" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -48,9 +71,27 @@ sed -i -E 's|"(protobufjs/minimal)"|"\1.js"|' "$MSG_COMPILED_OUTPUTFILE" | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| tput setaf 2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "Generating $MSG_COMPILED_TYPES_OUTPUTFILE" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| tput sgr0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| yarn pbts --name types "$MSG_COMPILED_OUTPUTFILE" -o "$MSG_COMPILED_TYPES_OUTPUTFILE" 2>pbts_errors.txt | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if ! yarn pbts --name types "$MSG_COMPILED_OUTPUTFILE" -o "$MSG_COMPILED_TYPES_OUTPUTFILE" 2>pbts_errors.txt; then | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "Error: Failed to generate TypeScript definitions" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| cat pbts_errors.txt | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| exit 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
coderabbitai[bot] marked this conversation as resolved.
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Verify generated files | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if [ ! -f "$MSG_COMPILED_OUTPUTFILE" ] || [ ! -s "$MSG_COMPILED_OUTPUTFILE" ]; then | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "Error: Generated JavaScript file is missing or empty" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| exit 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if [ ! -f "$MSG_COMPILED_TYPES_OUTPUTFILE" ] || [ ! -s "$MSG_COMPILED_TYPES_OUTPUTFILE" ]; then | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "Error: Generated TypeScript definitions file is missing or empty" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| exit 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Clean up error files if they're empty | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| [ ! -s pbjs_errors.txt ] && rm -f pbjs_errors.txt | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| [ ! -s pbts_errors.txt ] && rm -f pbts_errors.txt | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| tput setaf 2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "Removing $TMP_DIR/thornode" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "✓ Successfully generated protobuf bindings" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| tput sgr0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| rm -rf "$TMP_DIR" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.