Skip to content

Commit f165903

Browse files
authored
Merge pull request #179 from InjectiveLabs/feat/chain_upgrade_v1_16
[feat] chain upgrade v1 16
2 parents d18403a + 5d5cac5 commit f165903

File tree

1,899 files changed

+49887
-10091
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,899 files changed

+49887
-10091
lines changed

.github/workflows/deploy.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ jobs:
1717

1818
steps:
1919
- uses: actions/checkout@v4
20+
21+
- name: Clone SDK repositories
22+
run: |
23+
make clone-sdk-repos
24+
2025
- name: Markdown autodocs
2126
uses: dineshsonachalam/[email protected]
2227
with:
@@ -25,7 +30,12 @@ jobs:
2530

2631
# Categories to automatically sync or transform its contents in the markdown files.
2732
# Defaults to '[code-block,json-to-html-table,workflow-artifact-table]'
28-
categories: '[code-block]'
33+
categories: '[code-block,json-to-html-table]'
34+
35+
- name: Clean SDK repositories
36+
run: |
37+
make clean-sdk-repos
38+
2939
- name: Set up Ruby
3040
uses: ruby/setup-ruby@v1
3141
with:

Makefile

Lines changed: 85 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,88 @@
1-
.PHONY: refresh-examples
1+
# Repository versions and URLs
2+
COSMOS_SDK_VERSION := v0.50.13-evm-comet1-inj.3
3+
COSMOS_SDK_REPO := https://github.com/InjectiveLabs/cosmos-sdk.git
24

5+
INJECTIVE_CORE_VERSION := v1.16.0
6+
INJECTIVE_CORE_REPO := https://github.com/InjectiveLabs/injective-core.git
7+
8+
INDEXER_VERSION := v1.16.54
9+
INDEXER_REPO := https://github.com/InjectiveLabs/injective-indexer.git
10+
11+
PYTHON_SDK_VERSION := v1.11.0
12+
PYTHON_SDK_REPO := https://github.com/InjectiveLabs/sdk-python.git
13+
14+
GO_SDK_VERSION := v1.58.0
15+
GO_SDK_REPO := https://github.com/InjectiveLabs/sdk-go.git
16+
17+
# Temporary directories
18+
TEMP_DIR := /tmp/injective-docs-repos
19+
COSMOS_SDK_DIR := $(TEMP_DIR)/cosmos-sdk
20+
INJECTIVE_CORE_DIR := $(TEMP_DIR)/injective-core
21+
INDEXER_DIR := $(TEMP_DIR)/injective-indexer
22+
PYTHON_SDK_DIR := tmp-python-sdk
23+
GO_SDK_DIR := tmp-go-sdk
24+
25+
clone-sdk-repos:
26+
@echo "Cloning SDK repositories..."
27+
@git clone -q --depth 1 --branch $(PYTHON_SDK_VERSION) $(PYTHON_SDK_REPO) $(PYTHON_SDK_DIR)
28+
@git clone -q --depth 1 --branch $(GO_SDK_VERSION) $(GO_SDK_REPO) $(GO_SDK_DIR)
29+
@echo "SDK repositories cloned successfully!"
30+
31+
clean-sdk-repos:
32+
@echo "Cleaning up SDK repositories..."
33+
@rm -rf $(PYTHON_SDK_DIR)
34+
@rm -rf $(GO_SDK_DIR)
35+
@echo "SDK repositories cleaned successfully!"
36+
37+
# Documentation targets
338
refresh-examples:
39+
@$(MAKE) clone-sdk-repos
440
markdown-autodocs -c code-block -c json-to-html-table -o source/includes/*.md
41+
@$(MAKE) clean-sdk-repos
42+
43+
# Internal targets without repository management
44+
_update-errors:
45+
@echo "Updating error documentation from repositories..."
46+
@./scripts/extract_errors.sh $(COSMOS_SDK_DIR) $(INJECTIVE_CORE_DIR)
47+
@echo "Generating markdown documentation..."
48+
@./scripts/generate_errors_md.sh
49+
50+
_update-proto:
51+
@echo "Generating proto JSON files..."
52+
@./scripts/generate_proto_json_files.sh $(COSMOS_SDK_DIR) $(INJECTIVE_CORE_DIR) $(INDEXER_DIR)
53+
54+
# Public targets with repository management
55+
update-errors-documentation:
56+
@$(MAKE) clone-repos
57+
@$(MAKE) _update-errors
58+
@$(MAKE) clean-repos
59+
60+
update-proto-json:
61+
@$(MAKE) clone-repos
62+
@$(MAKE) _update-proto
63+
@$(MAKE) clean-repos
64+
65+
# Repository management targets
66+
clone-repos:
67+
@echo "Cloning repositories..."
68+
@rm -rf $(TEMP_DIR)
69+
@mkdir -p $(TEMP_DIR)
70+
@git clone -q --depth 1 --branch $(COSMOS_SDK_VERSION) $(COSMOS_SDK_REPO) $(COSMOS_SDK_DIR)
71+
@git clone -q --depth 1 --branch $(INJECTIVE_CORE_VERSION) $(INJECTIVE_CORE_REPO) $(INJECTIVE_CORE_DIR)
72+
@git clone -q --depth 1 --branch $(INDEXER_VERSION) $(INDEXER_REPO) $(INDEXER_DIR)
73+
74+
clean-repos:
75+
@echo "Cleaning up repositories..."
76+
@rm -rf $(TEMP_DIR)
77+
78+
# Combined documentation update target
79+
update-all-proto-related-files:
80+
@$(MAKE) clone-repos
81+
@echo "Updating all documentation..."
82+
@$(MAKE) -s _update-proto
83+
@$(MAKE) -s _update-errors
84+
@$(MAKE) clean-repos
85+
@echo "All documentation has been updated successfully!"
86+
87+
# Declare all phony targets at once
88+
.PHONY: refresh-examples update-errors-documentation update-proto-json clone-repos clean-repos clone-sdk-repos clean-sdk-repos update-all-docs _update-errors _update-proto update-all-proto-related-files

scripts/extract_errors.sh

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
#!/bin/bash
2+
3+
# Exit on any error
4+
set -e
5+
6+
# Script usage
7+
usage() {
8+
echo "Usage: $0 <cosmos-sdk-path> <injective-core-path>"
9+
echo
10+
echo "Extract error definitions from Cosmos SDK and Injective Core repositories"
11+
echo
12+
echo "Arguments:"
13+
echo " cosmos-sdk-path Path to the Cosmos SDK repository"
14+
echo " injective-core-path Path to the Injective Core repository"
15+
echo
16+
echo "Example:"
17+
echo " $0 /tmp/cosmos-sdk /tmp/injective-core"
18+
exit 1
19+
}
20+
21+
# Check arguments
22+
if [ $# -ne 2 ]; then
23+
usage
24+
fi
25+
26+
# Configuration
27+
COSMOS_SDK_DIR="$1"
28+
INJECTIVE_CORE_DIR="$2"
29+
BASE_OUTPUT_DIR="source/json_tables"
30+
31+
# Store the original directory
32+
ORIGINAL_DIR=$(pwd)
33+
34+
# Check dependencies
35+
if ! command -v jq &> /dev/null; then
36+
echo "Error: jq is required but not installed. Please install jq first."
37+
exit 1
38+
fi
39+
40+
# Function to extract errors from a file and append to JSON array
41+
extract_errors() {
42+
local file=$1
43+
local json_objects=""
44+
local error_pattern='errors\.Register\([[:space:]]*([^,]+)[[:space:]]*,[[:space:]]*([^,]+)[[:space:]]*,[[:space:]]*\"([^\"]+)\"'
45+
46+
while IFS= read -r line; do
47+
if [[ $line =~ $error_pattern ]]; then
48+
error_code=$(echo "${BASH_REMATCH[2]}" | tr -d ' ')
49+
description="${BASH_REMATCH[3]}"
50+
51+
if [ -z "$json_objects" ]; then
52+
json_objects="{\"Error Code\": $error_code, \"Description\": \"$description\"}"
53+
else
54+
json_objects="$json_objects,{\"Error Code\": $error_code, \"Description\": \"$description\"}"
55+
fi
56+
fi
57+
done < "$file"
58+
59+
if [ -n "$json_objects" ]; then
60+
echo "[$json_objects]" | jq '.'
61+
return 0
62+
fi
63+
return 1
64+
}
65+
66+
# Function to process modules in a directory
67+
process_modules() {
68+
local base_dir=$1
69+
local output_dir=$2
70+
local modules_path=$3
71+
72+
echo "Processing modules in $modules_path..."
73+
74+
cd "$base_dir"
75+
for module in "$modules_path"/*; do
76+
# Skip if not a directory
77+
[ ! -d "$module" ] && continue
78+
79+
module_name=$(basename "$module")
80+
echo "Processing module: $module_name"
81+
82+
json_content=""
83+
84+
# Check for errors.go in main folder
85+
if [ -f "$module/errors.go" ] && content=$(extract_errors "$module/errors.go"); then
86+
json_content="$content"
87+
fi
88+
89+
# Check for errors.go in types subfolder
90+
if [ -f "$module/types/errors.go" ] && types_content=$(extract_errors "$module/types/errors.go"); then
91+
if [ -n "$json_content" ]; then
92+
json_content=$(echo "$json_content" "$types_content" | jq -s 'add')
93+
else
94+
json_content="$types_content"
95+
fi
96+
fi
97+
98+
# Save if we found any errors
99+
if [ -n "$json_content" ]; then
100+
echo "$json_content" > "$ORIGINAL_DIR/$output_dir/$module_name.json"
101+
echo " Found errors in module $module_name"
102+
else
103+
echo " No errors found in module $module_name"
104+
fi
105+
done
106+
cd "$ORIGINAL_DIR"
107+
}
108+
109+
# Clean up any existing files and create directory structure
110+
echo "Setting up directories..."
111+
rm -rf "$BASE_OUTPUT_DIR/errors" "$BASE_OUTPUT_DIR/chain/errors"
112+
mkdir -p "$BASE_OUTPUT_DIR/errors" "$BASE_OUTPUT_DIR/chain/errors"
113+
114+
# Process Cosmos SDK repository
115+
echo "Processing Cosmos SDK repository..."
116+
process_modules "$COSMOS_SDK_DIR" "$BASE_OUTPUT_DIR/errors" "x"
117+
118+
# Process Injective Core repository
119+
echo "Processing Injective Core repository..."
120+
process_modules "$INJECTIVE_CORE_DIR" "$BASE_OUTPUT_DIR/chain/errors" "injective-chain/modules"
121+
122+
echo "Error extraction complete. JSON files have been created in:"
123+
echo "- $BASE_OUTPUT_DIR/errors (Cosmos SDK modules)"
124+
echo "- $BASE_OUTPUT_DIR/chain/errors (Injective Core modules)"

scripts/generate_errors_md.sh

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#!/bin/bash
2+
3+
# Exit on any error
4+
set -e
5+
6+
OUTPUT_FILE="source/includes/_errors.md"
7+
COSMOS_ERRORS_DIR="source/json_tables/errors"
8+
INJECTIVE_ERRORS_DIR="source/json_tables/chain/errors"
9+
10+
# Function to add a module's errors to the markdown file
11+
add_module_errors() {
12+
local file=$1
13+
local prefix=$2
14+
local module_name=$(basename "$file" .json)
15+
16+
# Just capitalize the first letter
17+
local capitalized_name=$(echo "$module_name" | perl -pe 's/^(.)/\u$1/')
18+
19+
echo "## ${capitalized_name} module" >> "$OUTPUT_FILE"
20+
echo >> "$OUTPUT_FILE"
21+
echo "<!-- MARKDOWN-AUTO-DOCS:START (JSON_TO_HTML_TABLE:src=./$file) -->" >> "$OUTPUT_FILE"
22+
echo "<!-- MARKDOWN-AUTO-DOCS:END -->" >> "$OUTPUT_FILE"
23+
echo >> "$OUTPUT_FILE"
24+
}
25+
26+
# Remove existing file if it exists
27+
rm -f "$OUTPUT_FILE"
28+
29+
# Add Cosmos SDK section
30+
if [ -d "$COSMOS_ERRORS_DIR" ]; then
31+
echo "# Cosmos SDK errors" >> "$OUTPUT_FILE"
32+
echo >> "$OUTPUT_FILE"
33+
for file in "$COSMOS_ERRORS_DIR"/*.json; do
34+
[ -f "$file" ] || continue
35+
add_module_errors "$file" "Cosmos SDK"
36+
done
37+
fi
38+
39+
# Add Injective section
40+
if [ -d "$INJECTIVE_ERRORS_DIR" ]; then
41+
echo "# Injective errors" >> "$OUTPUT_FILE"
42+
echo >> "$OUTPUT_FILE"
43+
for file in "$INJECTIVE_ERRORS_DIR"/*.json; do
44+
[ -f "$file" ] || continue
45+
add_module_errors "$file" "Injective"
46+
done
47+
fi
48+
49+
echo "Generated errors documentation in $OUTPUT_FILE"

0 commit comments

Comments
 (0)