-
Notifications
You must be signed in to change notification settings - Fork 4
[feat] chain upgrade v1 16 #179
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
Changes from all commits
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 |
|---|---|---|
|
|
@@ -17,6 +17,11 @@ jobs: | |
|
|
||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - name: Clone SDK repositories | ||
| run: | | ||
| make clone-sdk-repos | ||
|
|
||
| - name: Markdown autodocs | ||
| uses: dineshsonachalam/[email protected] | ||
| with: | ||
|
|
@@ -25,7 +30,12 @@ jobs: | |
|
|
||
| # Categories to automatically sync or transform its contents in the markdown files. | ||
| # Defaults to '[code-block,json-to-html-table,workflow-artifact-table]' | ||
| categories: '[code-block]' | ||
| categories: '[code-block,json-to-html-table]' | ||
|
|
||
| - name: Clean SDK repositories | ||
| run: | | ||
| make clean-sdk-repos | ||
|
|
||
| - name: Set up Ruby | ||
| uses: ruby/setup-ruby@v1 | ||
| with: | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,88 @@ | ||
| .PHONY: refresh-examples | ||
| # Repository versions and URLs | ||
| COSMOS_SDK_VERSION := v0.50.13-evm-comet1-inj.3 | ||
| COSMOS_SDK_REPO := https://github.com/InjectiveLabs/cosmos-sdk.git | ||
|
|
||
| INJECTIVE_CORE_VERSION := v1.16.0 | ||
| INJECTIVE_CORE_REPO := https://github.com/InjectiveLabs/injective-core.git | ||
|
|
||
| INDEXER_VERSION := v1.16.54 | ||
| INDEXER_REPO := https://github.com/InjectiveLabs/injective-indexer.git | ||
|
|
||
| PYTHON_SDK_VERSION := v1.11.0 | ||
| PYTHON_SDK_REPO := https://github.com/InjectiveLabs/sdk-python.git | ||
|
|
||
| GO_SDK_VERSION := v1.58.0 | ||
| GO_SDK_REPO := https://github.com/InjectiveLabs/sdk-go.git | ||
|
|
||
| # Temporary directories | ||
| TEMP_DIR := /tmp/injective-docs-repos | ||
| COSMOS_SDK_DIR := $(TEMP_DIR)/cosmos-sdk | ||
| INJECTIVE_CORE_DIR := $(TEMP_DIR)/injective-core | ||
| INDEXER_DIR := $(TEMP_DIR)/injective-indexer | ||
| PYTHON_SDK_DIR := tmp-python-sdk | ||
| GO_SDK_DIR := tmp-go-sdk | ||
|
|
||
| clone-sdk-repos: | ||
| @echo "Cloning SDK repositories..." | ||
| @git clone -q --depth 1 --branch $(PYTHON_SDK_VERSION) $(PYTHON_SDK_REPO) $(PYTHON_SDK_DIR) | ||
| @git clone -q --depth 1 --branch $(GO_SDK_VERSION) $(GO_SDK_REPO) $(GO_SDK_DIR) | ||
| @echo "SDK repositories cloned successfully!" | ||
|
|
||
| clean-sdk-repos: | ||
| @echo "Cleaning up SDK repositories..." | ||
| @rm -rf $(PYTHON_SDK_DIR) | ||
| @rm -rf $(GO_SDK_DIR) | ||
| @echo "SDK repositories cleaned successfully!" | ||
|
|
||
| # Documentation targets | ||
| refresh-examples: | ||
| @$(MAKE) clone-sdk-repos | ||
| markdown-autodocs -c code-block -c json-to-html-table -o source/includes/*.md | ||
| @$(MAKE) clean-sdk-repos | ||
|
|
||
| # Internal targets without repository management | ||
| _update-errors: | ||
| @echo "Updating error documentation from repositories..." | ||
| @./scripts/extract_errors.sh $(COSMOS_SDK_DIR) $(INJECTIVE_CORE_DIR) | ||
| @echo "Generating markdown documentation..." | ||
| @./scripts/generate_errors_md.sh | ||
|
|
||
| _update-proto: | ||
| @echo "Generating proto JSON files..." | ||
| @./scripts/generate_proto_json_files.sh $(COSMOS_SDK_DIR) $(INJECTIVE_CORE_DIR) $(INDEXER_DIR) | ||
|
|
||
| # Public targets with repository management | ||
| update-errors-documentation: | ||
| @$(MAKE) clone-repos | ||
| @$(MAKE) _update-errors | ||
| @$(MAKE) clean-repos | ||
|
|
||
| update-proto-json: | ||
| @$(MAKE) clone-repos | ||
| @$(MAKE) _update-proto | ||
| @$(MAKE) clean-repos | ||
|
|
||
| # Repository management targets | ||
| clone-repos: | ||
| @echo "Cloning repositories..." | ||
| @rm -rf $(TEMP_DIR) | ||
| @mkdir -p $(TEMP_DIR) | ||
| @git clone -q --depth 1 --branch $(COSMOS_SDK_VERSION) $(COSMOS_SDK_REPO) $(COSMOS_SDK_DIR) | ||
| @git clone -q --depth 1 --branch $(INJECTIVE_CORE_VERSION) $(INJECTIVE_CORE_REPO) $(INJECTIVE_CORE_DIR) | ||
| @git clone -q --depth 1 --branch $(INDEXER_VERSION) $(INDEXER_REPO) $(INDEXER_DIR) | ||
|
|
||
| clean-repos: | ||
| @echo "Cleaning up repositories..." | ||
| @rm -rf $(TEMP_DIR) | ||
|
|
||
| # Combined documentation update target | ||
| update-all-proto-related-files: | ||
| @$(MAKE) clone-repos | ||
| @echo "Updating all documentation..." | ||
| @$(MAKE) -s _update-proto | ||
| @$(MAKE) -s _update-errors | ||
| @$(MAKE) clean-repos | ||
| @echo "All documentation has been updated successfully!" | ||
|
|
||
| # Declare all phony targets at once | ||
| .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 | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,124 @@ | ||
| #!/bin/bash | ||
|
|
||
| # Exit on any error | ||
| set -e | ||
|
|
||
| # Script usage | ||
| usage() { | ||
| echo "Usage: $0 <cosmos-sdk-path> <injective-core-path>" | ||
| echo | ||
| echo "Extract error definitions from Cosmos SDK and Injective Core repositories" | ||
| echo | ||
| echo "Arguments:" | ||
| echo " cosmos-sdk-path Path to the Cosmos SDK repository" | ||
| echo " injective-core-path Path to the Injective Core repository" | ||
| echo | ||
| echo "Example:" | ||
| echo " $0 /tmp/cosmos-sdk /tmp/injective-core" | ||
| exit 1 | ||
| } | ||
|
|
||
| # Check arguments | ||
| if [ $# -ne 2 ]; then | ||
| usage | ||
| fi | ||
|
|
||
| # Configuration | ||
| COSMOS_SDK_DIR="$1" | ||
| INJECTIVE_CORE_DIR="$2" | ||
| BASE_OUTPUT_DIR="source/json_tables" | ||
|
|
||
| # Store the original directory | ||
| ORIGINAL_DIR=$(pwd) | ||
|
|
||
| # Check dependencies | ||
| if ! command -v jq &> /dev/null; then | ||
| echo "Error: jq is required but not installed. Please install jq first." | ||
| exit 1 | ||
| fi | ||
|
|
||
| # Function to extract errors from a file and append to JSON array | ||
| extract_errors() { | ||
| local file=$1 | ||
| local json_objects="" | ||
| local error_pattern='errors\.Register\([[:space:]]*([^,]+)[[:space:]]*,[[:space:]]*([^,]+)[[:space:]]*,[[:space:]]*\"([^\"]+)\"' | ||
|
|
||
| while IFS= read -r line; do | ||
| if [[ $line =~ $error_pattern ]]; then | ||
| error_code=$(echo "${BASH_REMATCH[2]}" | tr -d ' ') | ||
| description="${BASH_REMATCH[3]}" | ||
|
|
||
| if [ -z "$json_objects" ]; then | ||
| json_objects="{\"Error Code\": $error_code, \"Description\": \"$description\"}" | ||
| else | ||
| json_objects="$json_objects,{\"Error Code\": $error_code, \"Description\": \"$description\"}" | ||
| fi | ||
| fi | ||
| done < "$file" | ||
|
|
||
| if [ -n "$json_objects" ]; then | ||
| echo "[$json_objects]" | jq '.' | ||
| return 0 | ||
| fi | ||
| return 1 | ||
| } | ||
|
|
||
| # Function to process modules in a directory | ||
| process_modules() { | ||
| local base_dir=$1 | ||
| local output_dir=$2 | ||
| local modules_path=$3 | ||
|
|
||
| echo "Processing modules in $modules_path..." | ||
|
|
||
| cd "$base_dir" | ||
| for module in "$modules_path"/*; do | ||
| # Skip if not a directory | ||
| [ ! -d "$module" ] && continue | ||
|
|
||
| module_name=$(basename "$module") | ||
| echo "Processing module: $module_name" | ||
|
|
||
| json_content="" | ||
|
|
||
| # Check for errors.go in main folder | ||
| if [ -f "$module/errors.go" ] && content=$(extract_errors "$module/errors.go"); then | ||
| json_content="$content" | ||
| fi | ||
|
|
||
| # Check for errors.go in types subfolder | ||
| if [ -f "$module/types/errors.go" ] && types_content=$(extract_errors "$module/types/errors.go"); then | ||
| if [ -n "$json_content" ]; then | ||
| json_content=$(echo "$json_content" "$types_content" | jq -s 'add') | ||
| else | ||
| json_content="$types_content" | ||
| fi | ||
| fi | ||
|
|
||
| # Save if we found any errors | ||
| if [ -n "$json_content" ]; then | ||
| echo "$json_content" > "$ORIGINAL_DIR/$output_dir/$module_name.json" | ||
| echo " Found errors in module $module_name" | ||
| else | ||
| echo " No errors found in module $module_name" | ||
| fi | ||
| done | ||
| cd "$ORIGINAL_DIR" | ||
| } | ||
|
|
||
| # Clean up any existing files and create directory structure | ||
| echo "Setting up directories..." | ||
| rm -rf "$BASE_OUTPUT_DIR/errors" "$BASE_OUTPUT_DIR/chain/errors" | ||
| mkdir -p "$BASE_OUTPUT_DIR/errors" "$BASE_OUTPUT_DIR/chain/errors" | ||
|
|
||
| # Process Cosmos SDK repository | ||
| echo "Processing Cosmos SDK repository..." | ||
| process_modules "$COSMOS_SDK_DIR" "$BASE_OUTPUT_DIR/errors" "x" | ||
|
|
||
| # Process Injective Core repository | ||
| echo "Processing Injective Core repository..." | ||
| process_modules "$INJECTIVE_CORE_DIR" "$BASE_OUTPUT_DIR/chain/errors" "injective-chain/modules" | ||
|
|
||
| echo "Error extraction complete. JSON files have been created in:" | ||
| echo "- $BASE_OUTPUT_DIR/errors (Cosmos SDK modules)" | ||
| echo "- $BASE_OUTPUT_DIR/chain/errors (Injective Core modules)" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| #!/bin/bash | ||
|
|
||
| # Exit on any error | ||
| set -e | ||
|
|
||
| OUTPUT_FILE="source/includes/_errors.md" | ||
| COSMOS_ERRORS_DIR="source/json_tables/errors" | ||
| INJECTIVE_ERRORS_DIR="source/json_tables/chain/errors" | ||
|
|
||
| # Function to add a module's errors to the markdown file | ||
| add_module_errors() { | ||
| local file=$1 | ||
| local prefix=$2 | ||
| local module_name=$(basename "$file" .json) | ||
|
|
||
|
Comment on lines
+11
to
+15
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. Remove unused The 🧰 Tools🪛 Shellcheck (0.10.0)[warning] 13-13: prefix appears unused. Verify use (or export if used externally). (SC2034) [warning] 14-14: Declare and assign separately to avoid masking return values. (SC2155) 🤖 Prompt for AI Agents |
||
| # Just capitalize the first letter | ||
| local capitalized_name=$(echo "$module_name" | perl -pe 's/^(.)/\u$1/') | ||
|
|
||
| echo "## ${capitalized_name} module" >> "$OUTPUT_FILE" | ||
| echo >> "$OUTPUT_FILE" | ||
| echo "<!-- MARKDOWN-AUTO-DOCS:START (JSON_TO_HTML_TABLE:src=./$file) -->" >> "$OUTPUT_FILE" | ||
| echo "<!-- MARKDOWN-AUTO-DOCS:END -->" >> "$OUTPUT_FILE" | ||
| echo >> "$OUTPUT_FILE" | ||
| } | ||
|
|
||
| # Remove existing file if it exists | ||
| rm -f "$OUTPUT_FILE" | ||
|
|
||
| # Add Cosmos SDK section | ||
| if [ -d "$COSMOS_ERRORS_DIR" ]; then | ||
| echo "# Cosmos SDK errors" >> "$OUTPUT_FILE" | ||
| echo >> "$OUTPUT_FILE" | ||
| for file in "$COSMOS_ERRORS_DIR"/*.json; do | ||
| [ -f "$file" ] || continue | ||
| add_module_errors "$file" "Cosmos SDK" | ||
| done | ||
| fi | ||
|
|
||
| # Add Injective section | ||
| if [ -d "$INJECTIVE_ERRORS_DIR" ]; then | ||
| echo "# Injective errors" >> "$OUTPUT_FILE" | ||
| echo >> "$OUTPUT_FILE" | ||
| for file in "$INJECTIVE_ERRORS_DIR"/*.json; do | ||
| [ -f "$file" ] || continue | ||
| add_module_errors "$file" "Injective" | ||
| done | ||
| fi | ||
|
|
||
| echo "Generated errors documentation in $OUTPUT_FILE" | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
refresh-examplesleaves temp SDK repos behind on failureIf
markdown-autodocsexits non-zero, the subsequentclean-sdk-reposline is never reached, polluting the working tree. Wrap the call or use a trap to guarantee cleanup.🤖 Prompt for AI Agents