Skip to content

Commit e0cc58c

Browse files
committed
Updates to scripts and reverted protos
1 parent 2b64e59 commit e0cc58c

File tree

6 files changed

+124
-21012
lines changed

6 files changed

+124
-21012
lines changed

packages/xchain-mayachain/genMsgs.sh

Lines changed: 69 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,94 @@
11
#!/bin/bash
22

33
# This script updates MAYAChain Protobuf bindings for MsgDeposit and MsgSend
4+
set -e # Exit on any error
45

56
MSG_COMPILED_OUTPUTFILE=src/types/proto/MsgCompiled.js
67
MSG_COMPILED_TYPES_OUTPUTFILE=src/types/proto/MsgCompiled.d.ts
78

8-
TMP_DIR=$(mktemp -d)
9+
# Using local minimal proto files - no need to clone mayanode repository
910

10-
tput setaf 2
11-
echo "Checking out https://gitlab.com/mayachain/mayanode to $TMP_DIR"
12-
tput sgr0
13-
(cd "$TMP_DIR" && git clone https://gitlab.com/mayachain/mayanode)
11+
# Download cosmos/base/v1beta1/coin.proto from cosmossdk
12+
COSMOS_COIN_PROTO="proto/cosmos/base/v1beta1/coin.proto"
13+
if [ ! -f "$COSMOS_COIN_PROTO" ]; then
14+
tput setaf 2
15+
echo "Downloading cosmos/base/v1beta1/coin.proto from cosmossdk"
16+
tput sgr0
17+
mkdir -p "proto/cosmos/base/v1beta1"
18+
if ! curl -f -o "$COSMOS_COIN_PROTO" \
19+
"https://raw.githubusercontent.com/cosmos/cosmos-sdk/main/proto/cosmos/base/v1beta1/coin.proto"; then
20+
echo "Error: Failed to download cosmos coin.proto"
21+
exit 1
22+
fi
23+
echo "✓ Downloaded cosmos coin.proto"
24+
else
25+
echo "✓ cosmos coin.proto already exists"
26+
fi
1427

15-
# Verify proto files exist
28+
# Verify our minimal proto files exist
1629
tput setaf 2
17-
echo "Checking proto files"
30+
echo "Checking minimal proto files"
1831
tput sgr0
19-
ls "$TMP_DIR/mayanode/proto/mayachain/v1/common/common.proto" || echo "common.proto missing"
20-
ls "$TMP_DIR/mayanode/proto/mayachain/v1/x/mayachain/types/msg_deposit.proto" || echo "msg_deposit.proto missing"
21-
ls "$TMP_DIR/mayanode/proto/mayachain/v1/x/mayachain/types/msg_send.proto" || echo "msg_send.proto missing"
32+
MISSING_FILES=0
33+
for proto_file in \
34+
"proto/common/minimal_common.proto" \
35+
"proto/types/minimal_msg_deposit.proto" \
36+
"proto/types/minimal_msg_send.proto" \
37+
"$COSMOS_COIN_PROTO"; do
38+
if [ ! -f "$proto_file" ]; then
39+
echo "Error: $(basename "$proto_file") missing"
40+
MISSING_FILES=1
41+
else
42+
echo "$(basename "$proto_file") found"
43+
fi
44+
done
2245

23-
# Download cosmos/base/v1beta1/coin.proto from cosmossdk if needed
24-
if [ ! -f "$TMP_DIR/mayanode/third_party/proto/cosmos/base/v1beta1/coin.proto" ]; then
25-
tput setaf 2
26-
echo "Downloading cosmos/base/v1beta1/coin.proto from cosmossdk"
27-
tput sgr0
28-
mkdir -p "$TMP_DIR/mayanode/third_party/proto/cosmos/base/v1beta1"
29-
curl -o "$TMP_DIR/mayanode/third_party/proto/cosmos/base/v1beta1/coin.proto" \
30-
"https://raw.githubusercontent.com/cosmos/cosmos-sdk/main/proto/cosmos/base/v1beta1/coin.proto"
46+
if [ $MISSING_FILES -eq 1 ]; then
47+
echo "Error: Required proto files are missing"
48+
exit 1
3149
fi
3250

33-
# Generate Protobuf JS bindings with include path
51+
# Generate Protobuf JS bindings using minimal proto files to prevent over-inclusion
3452
tput setaf 2
3553
echo "Generating $MSG_COMPILED_OUTPUTFILE"
3654
tput sgr0
37-
yarn pbjs -w commonjs -t static-module \
38-
-p "$TMP_DIR/mayanode/proto" \
39-
-p "$TMP_DIR/mayanode/third_party/proto" \
40-
"$TMP_DIR/mayanode/proto/mayachain/v1/common/common.proto" \
41-
"$TMP_DIR/mayanode/proto/mayachain/v1/x/mayachain/types/msg_deposit.proto" \
42-
"$TMP_DIR/mayanode/proto/mayachain/v1/x/mayachain/types/msg_send.proto" \
43-
"$TMP_DIR/mayanode/third_party/proto/cosmos/base/v1beta1/coin.proto" \
44-
-o "$MSG_COMPILED_OUTPUTFILE" 2>pbjs_errors.txt
55+
if ! yarn pbjs -w commonjs -t static-module \
56+
-p proto \
57+
"proto/common/minimal_common.proto" \
58+
"proto/types/minimal_msg_deposit.proto" \
59+
"proto/types/minimal_msg_send.proto" \
60+
"$COSMOS_COIN_PROTO" \
61+
-o "$MSG_COMPILED_OUTPUTFILE" 2>pbjs_errors.txt; then
62+
echo "Error: Failed to generate JavaScript bindings"
63+
cat pbjs_errors.txt
64+
exit 1
65+
fi
4566

4667
# Generate TypeScript definitions
4768
tput setaf 2
4869
echo "Generating $MSG_COMPILED_TYPES_OUTPUTFILE"
4970
tput sgr0
50-
yarn pbts "$MSG_COMPILED_OUTPUTFILE" -o "$MSG_COMPILED_TYPES_OUTPUTFILE" 2>pbts_errors.txt
71+
if ! yarn pbts "$MSG_COMPILED_OUTPUTFILE" -o "$MSG_COMPILED_TYPES_OUTPUTFILE" 2>pbts_errors.txt; then
72+
echo "Error: Failed to generate TypeScript definitions"
73+
cat pbts_errors.txt
74+
exit 1
75+
fi
76+
77+
# Verify generated files
78+
if [ ! -f "$MSG_COMPILED_OUTPUTFILE" ] || [ ! -s "$MSG_COMPILED_OUTPUTFILE" ]; then
79+
echo "Error: Generated JavaScript file is missing or empty"
80+
exit 1
81+
fi
82+
83+
if [ ! -f "$MSG_COMPILED_TYPES_OUTPUTFILE" ] || [ ! -s "$MSG_COMPILED_TYPES_OUTPUTFILE" ]; then
84+
echo "Error: Generated TypeScript definitions file is missing or empty"
85+
exit 1
86+
fi
87+
88+
# Clean up error files if they're empty
89+
[ ! -s pbjs_errors.txt ] && rm -f pbjs_errors.txt
90+
[ ! -s pbts_errors.txt ] && rm -f pbts_errors.txt
5191

5292
tput setaf 2
53-
echo "Removing $TMP_DIR/mayanode"
93+
echo "✓ Successfully generated protobuf bindings"
5494
tput sgr0
55-
rm -rf "$TMP_DIR"

0 commit comments

Comments
 (0)