style(proto): ignore tmp-swagger-gen/**/*.swagger.json

This commit is contained in:
Prad Nukala
2025-10-21 12:04:29 -04:00
parent e3b492f3b9
commit 53a34171e8
45 changed files with 300 additions and 181 deletions
+5 -1
View File
@@ -95,6 +95,7 @@ logs/
configs/logs.json
tmp/
tmp*
tmp-swagger-gen/
# ===== Environment & Secrets =====
.env
@@ -121,5 +122,8 @@ COMPLETION_SUMMARY.md
data/
compose/
heighliner*
**/*.swagger.yaml
# Ignore individual module swagger files (generated in tmp directory)
tmp-swagger-gen/**/*.swagger.json
# Allow the final combined swagger.yaml
!client/docs/swagger-ui/swagger.yaml
.mcp.json
+4 -5
View File
@@ -2,16 +2,15 @@
package modulev1
import (
fmt "fmt"
io "io"
reflect "reflect"
sync "sync"
_ "cosmossdk.io/api/cosmos/app/v1alpha1"
fmt "fmt"
runtime "github.com/cosmos/cosmos-proto/runtime"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoiface "google.golang.org/protobuf/runtime/protoiface"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
io "io"
reflect "reflect"
sync "sync"
)
var (
+4 -5
View File
@@ -2,17 +2,16 @@
package dexv1
import (
fmt "fmt"
io "io"
reflect "reflect"
sync "sync"
v1beta1 "cosmossdk.io/api/cosmos/base/v1beta1"
fmt "fmt"
runtime "github.com/cosmos/cosmos-proto/runtime"
_ "github.com/cosmos/gogoproto/gogoproto"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoiface "google.golang.org/protobuf/runtime/protoiface"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
io "io"
reflect "reflect"
sync "sync"
)
var (
+3 -4
View File
@@ -3,15 +3,14 @@ package dexv1
import (
fmt "fmt"
io "io"
reflect "reflect"
sync "sync"
runtime "github.com/cosmos/cosmos-proto/runtime"
_ "github.com/cosmos/gogoproto/gogoproto"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoiface "google.golang.org/protobuf/runtime/protoiface"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
io "io"
reflect "reflect"
sync "sync"
)
var _ protoreflect.List = (*_GenesisState_3_list)(nil)
+4 -5
View File
@@ -2,12 +2,8 @@
package dexv1
import (
fmt "fmt"
io "io"
reflect "reflect"
sync "sync"
v1beta1 "cosmossdk.io/api/cosmos/base/v1beta1"
fmt "fmt"
_ "github.com/cosmos/cosmos-proto"
runtime "github.com/cosmos/cosmos-proto/runtime"
_ "github.com/cosmos/gogoproto/gogoproto"
@@ -15,6 +11,9 @@ import (
protoiface "google.golang.org/protobuf/runtime/protoiface"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
timestamppb "google.golang.org/protobuf/types/known/timestamppb"
io "io"
reflect "reflect"
sync "sync"
)
var _ protoreflect.List = (*_InterchainDEXAccount_7_list)(nil)
+4 -5
View File
@@ -2,19 +2,18 @@
package dexv1
import (
fmt "fmt"
io "io"
reflect "reflect"
sync "sync"
v1beta1 "cosmossdk.io/api/cosmos/base/query/v1beta1"
v1beta11 "cosmossdk.io/api/cosmos/base/v1beta1"
fmt "fmt"
runtime "github.com/cosmos/cosmos-proto/runtime"
_ "github.com/cosmos/gogoproto/gogoproto"
_ "google.golang.org/genproto/googleapis/api/annotations"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoiface "google.golang.org/protobuf/runtime/protoiface"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
io "io"
reflect "reflect"
sync "sync"
)
var (
-1
View File
@@ -8,7 +8,6 @@ package dexv1
import (
context "context"
grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status"
+4 -5
View File
@@ -2,13 +2,9 @@
package dexv1
import (
fmt "fmt"
io "io"
reflect "reflect"
sync "sync"
v1beta1 "cosmossdk.io/api/cosmos/base/v1beta1"
_ "cosmossdk.io/api/cosmos/msg/v1"
fmt "fmt"
_ "github.com/cosmos/cosmos-proto"
runtime "github.com/cosmos/cosmos-proto/runtime"
_ "github.com/cosmos/gogoproto/gogoproto"
@@ -16,6 +12,9 @@ import (
protoiface "google.golang.org/protobuf/runtime/protoiface"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
timestamppb "google.golang.org/protobuf/types/known/timestamppb"
io "io"
reflect "reflect"
sync "sync"
)
var _ protoreflect.List = (*_MsgRegisterDEXAccount_3_list)(nil)
-1
View File
@@ -8,7 +8,6 @@ package dexv1
import (
context "context"
grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status"
+4 -5
View File
@@ -2,16 +2,15 @@
package modulev1
import (
fmt "fmt"
io "io"
reflect "reflect"
sync "sync"
_ "cosmossdk.io/api/cosmos/app/v1alpha1"
fmt "fmt"
runtime "github.com/cosmos/cosmos-proto/runtime"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoiface "google.golang.org/protobuf/runtime/protoiface"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
io "io"
reflect "reflect"
sync "sync"
)
var (
+3 -4
View File
@@ -3,16 +3,15 @@ package didv1
import (
fmt "fmt"
io "io"
reflect "reflect"
sync "sync"
runtime "github.com/cosmos/cosmos-proto/runtime"
_ "github.com/cosmos/gogoproto/gogoproto"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoiface "google.golang.org/protobuf/runtime/protoiface"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
timestamppb "google.golang.org/protobuf/types/known/timestamppb"
io "io"
reflect "reflect"
sync "sync"
)
var _ protoreflect.List = (*_EventDIDCreated_3_list)(nil)
+4 -5
View File
@@ -2,17 +2,16 @@
package didv1
import (
fmt "fmt"
io "io"
reflect "reflect"
sync "sync"
_ "cosmossdk.io/api/amino"
fmt "fmt"
runtime "github.com/cosmos/cosmos-proto/runtime"
_ "github.com/cosmos/gogoproto/gogoproto"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoiface "google.golang.org/protobuf/runtime/protoiface"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
io "io"
reflect "reflect"
sync "sync"
)
var (
+5 -6
View File
@@ -2,19 +2,18 @@
package didv1
import (
fmt "fmt"
io "io"
reflect "reflect"
sort "sort"
sync "sync"
v1beta1 "cosmossdk.io/api/cosmos/base/query/v1beta1"
fmt "fmt"
runtime "github.com/cosmos/cosmos-proto/runtime"
_ "github.com/cosmos/gogoproto/gogoproto"
_ "google.golang.org/genproto/googleapis/api/annotations"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoiface "google.golang.org/protobuf/runtime/protoiface"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
io "io"
reflect "reflect"
sort "sort"
sync "sync"
)
var (
-1
View File
@@ -8,7 +8,6 @@ package didv1
import (
context "context"
grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status"
-1
View File
@@ -4,7 +4,6 @@ package didv1
import (
context "context"
ormlist "cosmossdk.io/orm/model/ormlist"
ormtable "cosmossdk.io/orm/model/ormtable"
ormerrors "cosmossdk.io/orm/types/ormerrors"
+4 -5
View File
@@ -2,16 +2,15 @@
package didv1
import (
fmt "fmt"
io "io"
reflect "reflect"
sync "sync"
_ "cosmossdk.io/api/cosmos/orm/v1"
fmt "fmt"
runtime "github.com/cosmos/cosmos-proto/runtime"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoiface "google.golang.org/protobuf/runtime/protoiface"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
io "io"
reflect "reflect"
sync "sync"
)
var (
+4 -5
View File
@@ -2,18 +2,17 @@
package didv1
import (
fmt "fmt"
io "io"
reflect "reflect"
sync "sync"
_ "cosmossdk.io/api/cosmos/msg/v1"
fmt "fmt"
_ "github.com/cosmos/cosmos-proto"
runtime "github.com/cosmos/cosmos-proto/runtime"
_ "github.com/cosmos/gogoproto/gogoproto"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoiface "google.golang.org/protobuf/runtime/protoiface"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
io "io"
reflect "reflect"
sync "sync"
)
var (
-1
View File
@@ -8,7 +8,6 @@ package didv1
import (
context "context"
grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status"
+5 -6
View File
@@ -2,18 +2,17 @@
package didv1
import (
fmt "fmt"
io "io"
reflect "reflect"
sort "sort"
sync "sync"
_ "cosmossdk.io/api/amino"
fmt "fmt"
runtime "github.com/cosmos/cosmos-proto/runtime"
_ "github.com/cosmos/gogoproto/gogoproto"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoiface "google.golang.org/protobuf/runtime/protoiface"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
io "io"
reflect "reflect"
sort "sort"
sync "sync"
)
var (
+4 -5
View File
@@ -2,16 +2,15 @@
package modulev1
import (
fmt "fmt"
io "io"
reflect "reflect"
sync "sync"
_ "cosmossdk.io/api/cosmos/app/v1alpha1"
fmt "fmt"
runtime "github.com/cosmos/cosmos-proto/runtime"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoiface "google.golang.org/protobuf/runtime/protoiface"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
io "io"
reflect "reflect"
sync "sync"
)
var (
+3 -4
View File
@@ -3,16 +3,15 @@ package dwnv1
import (
fmt "fmt"
io "io"
reflect "reflect"
sync "sync"
runtime "github.com/cosmos/cosmos-proto/runtime"
_ "github.com/cosmos/gogoproto/gogoproto"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoiface "google.golang.org/protobuf/runtime/protoiface"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
timestamppb "google.golang.org/protobuf/types/known/timestamppb"
io "io"
reflect "reflect"
sync "sync"
)
var (
+4 -5
View File
@@ -2,17 +2,16 @@
package dwnv1
import (
fmt "fmt"
io "io"
reflect "reflect"
sync "sync"
_ "cosmossdk.io/api/amino"
fmt "fmt"
runtime "github.com/cosmos/cosmos-proto/runtime"
_ "github.com/cosmos/gogoproto/gogoproto"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoiface "google.golang.org/protobuf/runtime/protoiface"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
io "io"
reflect "reflect"
sync "sync"
)
var _ protoreflect.List = (*_GenesisState_2_list)(nil)
+4 -5
View File
@@ -2,18 +2,17 @@
package dwnv1
import (
fmt "fmt"
io "io"
reflect "reflect"
sync "sync"
v1beta1 "cosmossdk.io/api/cosmos/base/query/v1beta1"
fmt "fmt"
runtime "github.com/cosmos/cosmos-proto/runtime"
_ "github.com/cosmos/gogoproto/gogoproto"
_ "google.golang.org/genproto/googleapis/api/annotations"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoiface "google.golang.org/protobuf/runtime/protoiface"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
io "io"
reflect "reflect"
sync "sync"
)
var (
-1
View File
@@ -8,7 +8,6 @@ package dwnv1
import (
context "context"
grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status"
-1
View File
@@ -4,7 +4,6 @@ package dwnv1
import (
context "context"
ormlist "cosmossdk.io/orm/model/ormlist"
ormtable "cosmossdk.io/orm/model/ormtable"
ormerrors "cosmossdk.io/orm/types/ormerrors"
+4 -5
View File
@@ -2,16 +2,15 @@
package dwnv1
import (
fmt "fmt"
io "io"
reflect "reflect"
sync "sync"
_ "cosmossdk.io/api/cosmos/orm/v1"
fmt "fmt"
runtime "github.com/cosmos/cosmos-proto/runtime"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoiface "google.golang.org/protobuf/runtime/protoiface"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
io "io"
reflect "reflect"
sync "sync"
)
var _ protoreflect.List = (*_EncryptionMetadata_6_list)(nil)
+4 -5
View File
@@ -2,18 +2,17 @@
package dwnv1
import (
fmt "fmt"
io "io"
reflect "reflect"
sync "sync"
_ "cosmossdk.io/api/cosmos/msg/v1"
fmt "fmt"
_ "github.com/cosmos/cosmos-proto"
runtime "github.com/cosmos/cosmos-proto/runtime"
_ "github.com/cosmos/gogoproto/gogoproto"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoiface "google.golang.org/protobuf/runtime/protoiface"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
io "io"
reflect "reflect"
sync "sync"
)
var (
-1
View File
@@ -8,7 +8,6 @@ package dwnv1
import (
context "context"
grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status"
+4 -5
View File
@@ -2,16 +2,15 @@
package modulev1
import (
fmt "fmt"
io "io"
reflect "reflect"
sync "sync"
_ "cosmossdk.io/api/cosmos/app/v1alpha1"
fmt "fmt"
runtime "github.com/cosmos/cosmos-proto/runtime"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoiface "google.golang.org/protobuf/runtime/protoiface"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
io "io"
reflect "reflect"
sync "sync"
)
var (
+3 -4
View File
@@ -3,16 +3,15 @@ package svcv1
import (
fmt "fmt"
io "io"
reflect "reflect"
sync "sync"
runtime "github.com/cosmos/cosmos-proto/runtime"
_ "github.com/cosmos/gogoproto/gogoproto"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoiface "google.golang.org/protobuf/runtime/protoiface"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
timestamppb "google.golang.org/protobuf/types/known/timestamppb"
io "io"
reflect "reflect"
sync "sync"
)
var (
+4 -5
View File
@@ -2,19 +2,18 @@
package svcv1
import (
fmt "fmt"
io "io"
reflect "reflect"
sync "sync"
_ "cosmossdk.io/api/amino"
v1beta1 "cosmossdk.io/api/cosmos/base/v1beta1"
fmt "fmt"
_ "github.com/cosmos/cosmos-proto"
runtime "github.com/cosmos/cosmos-proto/runtime"
_ "github.com/cosmos/gogoproto/gogoproto"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoiface "google.golang.org/protobuf/runtime/protoiface"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
io "io"
reflect "reflect"
sync "sync"
)
var _ protoreflect.List = (*_GenesisState_2_list)(nil)
+4 -5
View File
@@ -3,16 +3,15 @@ package svcv1
import (
fmt "fmt"
io "io"
reflect "reflect"
sort "sort"
sync "sync"
runtime "github.com/cosmos/cosmos-proto/runtime"
_ "google.golang.org/genproto/googleapis/api/annotations"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoiface "google.golang.org/protobuf/runtime/protoiface"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
io "io"
reflect "reflect"
sort "sort"
sync "sync"
)
var (
-1
View File
@@ -8,7 +8,6 @@ package svcv1
import (
context "context"
grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status"
-1
View File
@@ -4,7 +4,6 @@ package svcv1
import (
context "context"
ormlist "cosmossdk.io/orm/model/ormlist"
ormtable "cosmossdk.io/orm/model/ormtable"
ormerrors "cosmossdk.io/orm/types/ormerrors"
+5 -6
View File
@@ -2,17 +2,16 @@
package svcv1
import (
fmt "fmt"
io "io"
reflect "reflect"
sort "sort"
sync "sync"
_ "cosmossdk.io/api/cosmos/orm/v1"
fmt "fmt"
runtime "github.com/cosmos/cosmos-proto/runtime"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoiface "google.golang.org/protobuf/runtime/protoiface"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
io "io"
reflect "reflect"
sort "sort"
sync "sync"
)
var _ protoreflect.List = (*_Service_5_list)(nil)
+4 -5
View File
@@ -2,18 +2,17 @@
package svcv1
import (
fmt "fmt"
io "io"
reflect "reflect"
sync "sync"
_ "cosmossdk.io/api/cosmos/msg/v1"
fmt "fmt"
_ "github.com/cosmos/cosmos-proto"
runtime "github.com/cosmos/cosmos-proto/runtime"
_ "github.com/cosmos/gogoproto/gogoproto"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoiface "google.golang.org/protobuf/runtime/protoiface"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
io "io"
reflect "reflect"
sync "sync"
)
var (
-1
View File
@@ -8,7 +8,6 @@ package svcv1
import (
context "context"
grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status"
+12 -3
View File
@@ -55,9 +55,18 @@ test:
###############################################################################
swagger-gen:
@gum log --level info "Generating OpenAPI documentation..."
@buf generate --template buf.gen.openapi.yaml
@gum log --level info "✅ OpenAPI documentation generated in docs/static/openapi/"
@gum log --level info "✅ Merged API specification: docs/static/openapi/sonr.swagger.yaml"
@$(protoImage) buf generate --template proto/buf.gen.openapi.yaml
@gum log --level info "Combining swagger files into unified specification..."
@mkdir -p $(GIT_ROOT)/client/docs/swagger-ui
@npx swagger-combine $(GIT_ROOT)/client/docs/config.json \
-o $(GIT_ROOT)/client/docs/swagger-ui/swagger.yaml \
-f yaml \
--continueOnConflictingPaths true \
--includeDefinitions true
@gum log --level info "Cleaning up temporary files..."
@rm -rf $(GIT_ROOT)/tmp-swagger-gen
@gum log --level info "✅ OpenAPI documentation generated successfully"
@gum log --level info "✅ Unified API specification: client/docs/swagger-ui/swagger.yaml"
push:
@npx buf push
+4 -3
View File
@@ -1,15 +1,16 @@
version: v1
plugins:
# Generate OpenAPI v2 (Swagger) documentation
# Follows Cosmos SDK standard approach: generate to tmp directory, then combine
- name: openapiv2
out: ../docs/static/openapi
out: ../tmp-swagger-gen
opt:
- logtostderr=true
- fqn_for_swagger_name=true
- simple_operation_ids=true
- openapi_naming_strategy=simple
- json_names_for_fields=true
- allow_merge=false
- output_format=yaml
- output_format=json
# Generate methods without HTTP bindings
- generate_unbound_methods=true
# Include service tags
+39 -1
View File
@@ -25,6 +25,36 @@ set_toml_value() {
ensure_file "$file"
# Check if we're using Docker and the file is owned by root
if [[ "${USE_DOCKER:-false}" == "true" ]] && [[ "$(stat -c %u "$file" 2>/dev/null || echo 0)" == "0" ]]; then
# Use Docker to modify the file to avoid permission issues
# Escape special characters for sed
local escaped_value
escaped_value=$(printf '%s\n' "$value" | sed 's/[[\.*^$()+?{|]/\\&/g')
# Check if value is a JSON array/object (starts with [ or {) - don't quote it
local sed_replacement
if [[ "$value" =~ ^\[.*\]$ ]] || [[ "$value" =~ ^\{.*\}$ ]]; then
sed_replacement="$key = $escaped_value"
else
sed_replacement="$key = \"$escaped_value\""
fi
docker run --rm -i \
-v "$(dirname "$file"):$(dirname "$file")" \
--entrypoint sh \
onsonr/snrd:latest \
-c "sed -i 's|^\s*$key\s*=.*|$sed_replacement|g' '$file'"
if [ $? -eq 0 ]; then
log_success "Set $key = $value in $file (Docker sed)"
return 0
else
log_error "Failed to set $section.$key in $file"
return 1
fi
fi
if [[ "$CRUDINI_AVAILABLE" == "true" ]]; then
if crudini --set "$file" "$section" "$key" "$value" 2>/dev/null; then
log_success "Set $section.$key = $value in $file"
@@ -39,8 +69,16 @@ set_toml_value() {
local escaped_value
escaped_value=$(printf '%s\n' "$value" | sed 's/[[\.*^$()+?{|]/\\&/g')
# Check if value is a JSON array/object (starts with [ or {) - don't quote it
local sed_replacement
if [[ "$value" =~ ^\[.*\]$ ]] || [[ "$value" =~ ^\{.*\}$ ]]; then
sed_replacement="$key = $escaped_value"
else
sed_replacement="$key = \"$escaped_value\""
fi
# Try to find and replace the line
if sed -i "s|^\s*$key\s*=.*|$key = \"$escaped_value\"|g" "$file"; then
if sed -i "s|^\s*$key\s*=.*|$sed_replacement|g" "$file"; then
log_success "Set $key = $value in $file (using sed)"
return 0
fi
+6
View File
@@ -120,8 +120,14 @@ retry() {
# Initialize environment
init_env() {
local skip_binary_check="${1:-false}"
require_cmd jq
# Only check for binary if not skipping (allows Docker mode to be decided later)
if [[ "$skip_binary_check" != "true" ]]; then
ensure_binary
fi
# Set up cleanup trap
trap cleanup EXIT
+38 -5
View File
@@ -51,21 +51,53 @@ generate_vrf_key() {
local vrf_key_path="$chain_dir/vrf_secret.key"
# Ensure directory exists
mkdir -p "$chain_dir"
mkdir -p "$chain_dir" 2>/dev/null || true
# Check if we're using Docker and the directory is owned by root
if [[ "${USE_DOCKER:-false}" == "true" ]] && [[ "$(stat -c %u "$chain_dir" 2>/dev/null || echo 0)" == "0" ]]; then
# Use Docker to create the VRF key file
docker run --rm -i \
-v "$chain_dir:$chain_dir" \
--entrypoint sh \
onsonr/snrd:latest \
-c "echo -n '$vrf_key_hex' | xxd -r -p > '$vrf_key_path' && chmod 0600 '$vrf_key_path'"
if [ $? -ne 0 ]; then
log_error "Failed to create VRF key using Docker"
return 1
fi
else
# Convert hex to binary and write to file
echo -n "$vrf_key_hex" | xxd -r -p > "$vrf_key_path"
# Set restrictive permissions (owner read/write only)
chmod 0600 "$vrf_key_path"
fi
# Validate file was created with correct size (64 bytes)
local file_size
file_size=$(wc -c < "$vrf_key_path")
if [[ "${USE_DOCKER:-false}" == "true" ]]; then
# Use Docker to check file size for root-owned files
file_size=$(docker run --rm -i \
-v "$chain_dir:$chain_dir" \
--entrypoint sh \
onsonr/snrd:latest \
-c "wc -c < '$vrf_key_path' 2>/dev/null || echo 0")
else
file_size=$(wc -c < "$vrf_key_path" 2>/dev/null || echo 0)
fi
if [[ $file_size -ne 64 ]]; then
log_error "VRF key file has incorrect size: ${file_size} bytes"
if [[ "${USE_DOCKER:-false}" == "true" ]]; then
docker run --rm -i \
-v "$chain_dir:$chain_dir" \
--entrypoint sh \
onsonr/snrd:latest \
-c "rm -f '$vrf_key_path'"
else
rm -f "$vrf_key_path"
fi
return 1
fi
@@ -110,9 +142,10 @@ update_genesis_params() {
set_json_string "$genesis_file" 'app_state.gov.params.max_deposit_period' "30s"
set_json_string "$genesis_file" 'app_state.gov.params.min_deposit[0].amount' "10"
set_json_string "$genesis_file" 'app_state.gov.params.voting_period' "30s"
set_json_string "$genesis_file" 'app_state.gov.params.quorum' "0.000000000000000000"
set_json_string "$genesis_file" 'app_state.gov.params.threshold' "0.000000000000000000"
set_json_string "$genesis_file" 'app_state.gov.params.veto_threshold' "0.000000000000000000"
set_json_string "$genesis_file" 'app_state.gov.params.expedited_voting_period' "15s"
set_json_string "$genesis_file" 'app_state.gov.params.quorum' "0.334000000000000000"
set_json_string "$genesis_file" 'app_state.gov.params.threshold' "0.500000000000000000"
set_json_string "$genesis_file" 'app_state.gov.params.veto_threshold' "0.334000000000000000"
fi
# Update EVM parameters if present
+18
View File
@@ -18,6 +18,24 @@ patch_json() {
log_info "Patching $file with: $jq_expr"
# Check if we're using Docker and the file is owned by root
if [[ "${USE_DOCKER:-false}" == "true" ]] && [[ "$(stat -c %u "$file" 2>/dev/null || echo 0)" == "0" ]]; then
# Use Docker to patch the file to avoid permission issues
docker run --rm -i \
-v "$(dirname "$file"):$(dirname "$file")" \
--entrypoint sh \
onsonr/snrd:latest \
-c "jq -r '$jq_expr' '$file' > '${file}.tmp' && mv '${file}.tmp' '$file'"
if [ $? -eq 0 ]; then
log_success "Successfully patched $file"
return 0
else
log_error "Failed to patch JSON file: $file"
return 1
fi
fi
# Create temp file in same directory to avoid cross-filesystem issues
local temp_file
temp_file="$(dirname "$file")/.tmp.$(basename "$file").$$"
+10 -2
View File
@@ -22,13 +22,21 @@ import_mnemonic() {
return 1
fi
# Use Docker wrapper if needed
if is_docker; then
# Use run_binary wrapper if available (for Docker mode), otherwise use CHAIN_BIN directly
if [ "$(type -t run_binary)" = "function" ]; then
# run_binary is available, use it (handles Docker automatically, including --home)
echo "$mnemonic" | run_binary keys add "$key_name" \
--keyring-backend "$KEYRING_BACKEND" \
--algo "$algo" \
--recover
elif is_docker; then
# We're inside Docker container
echo "$mnemonic" | $CHAIN_BIN keys add "$key_name" \
--keyring-backend "$KEYRING_BACKEND" \
--algo "$algo" \
--recover
else
# Local execution
echo "$mnemonic" | $CHAIN_BIN keys add "$key_name" \
--keyring-backend "$KEYRING_BACKEND" \
--algo "$algo" \
+63 -25
View File
@@ -9,20 +9,28 @@ set -euo pipefail
# Source helper libraries
# Get the directory of this script reliably
SCRIPT_DIR="/usr/local/lib/sonr-scripts"
# Check if we're running in Docker (where scripts are installed to /usr/local/lib/sonr-scripts)
# or locally (where scripts are in the repo's scripts/lib directory)
if [ -d "/usr/local/lib/sonr-scripts" ]; then
SCRIPT_DIR="/usr/local/lib/sonr-scripts"
else
# Get the directory where this script is located
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/lib" && pwd)"
fi
source "${SCRIPT_DIR}/env.sh"
source "${SCRIPT_DIR}/config.sh"
source "${SCRIPT_DIR}/keys.sh"
source "${SCRIPT_DIR}/genesis.sh"
# Initialize environment
init_env
# Initialize environment (skip binary check as we'll handle Docker/binary detection later)
init_env true
# Set defaults for test node
export KEY="${KEY:-acc0}"
export KEY2="${KEY2:-acc1}"
export MONIKER="${MONIKER:-localvalidator}"
export KEYALGO="${KEYALGO:-eth_secp256k1}"
export KEYRING="${KEYRING:-test}"
# Configurable ports
export RPC="${RPC:-26657}"
@@ -47,7 +55,7 @@ export CLEAN="${CLEAN:-false}"
export DOCKER_DETACHED="${DOCKER_DETACHED:-false}"
# Check if binary exists, if not use Docker (or force Docker if requested)
USE_DOCKER=false
export USE_DOCKER=false
if [[ "${FORCE_DOCKER}" == "true" ]] || ! command -v "$CHAIN_BIN" >/dev/null 2>&1; then
# Check if Docker is available and use it
if command -v docker >/dev/null 2>&1; then
@@ -58,14 +66,14 @@ if [[ "${FORCE_DOCKER}" == "true" ]] || ! command -v "$CHAIN_BIN" >/dev/null 2>&
fi
if docker image inspect onsonr/snrd:latest >/dev/null 2>&1; then
log_info "Using Docker image onsonr/snrd:latest"
USE_DOCKER=true
export USE_DOCKER=true
else
log_info "Docker image onsonr/snrd:latest not found. Pulling image..."
docker pull onsonr/snrd:latest || {
log_error "Failed to pull onsonr/snrd:latest. Please ensure Docker is running and you have internet access."
exit 1
}
USE_DOCKER=true
export USE_DOCKER=true
fi
else
log_error "Binary $CHAIN_BIN not found. Please either:"
@@ -80,28 +88,32 @@ run_binary() {
if [[ "${USE_DOCKER}" == "true" ]]; then
# Ensure the directory exists on the host
mkdir -p "${HOME_DIR}"
# Determine if we're in a TTY
DOCKER_TTY_FLAG=""
if [ -t 0 ]; then
DOCKER_TTY_FLAG="-it"
fi
# Mount home directory to container's /root/.sonr
docker run --rm ${DOCKER_TTY_FLAG} \
# Use -i for interactive (stdin) only, not -t (tty)
# This allows piping to work properly
# Run as root in Docker, fix permissions after
docker run --rm -i \
-v "${HOME_DIR}:/root/.sonr" \
--network host \
onsonr/snrd:latest \
snrd --home /root/.sonr "$@"
# Fix permissions on files created by Docker
chmod -R u+rwX "${HOME_DIR}" 2>/dev/null || true
else
${CHAIN_BIN} "$@"
fi
}
export -f run_binary
# Set client configuration
set_config() {
# Skip if config directory doesn't exist yet (will be set later during initialization)
if [[ ! -d "${HOME_DIR}/config" ]]; then
return 0
fi
run_binary config set client chain-id "${CHAIN_ID}"
run_binary config set client keyring-backend "${KEYRING}"
}
set_config
# Don't call set_config here - it will be called after chain init in from_scratch()
from_scratch() {
# Fresh install on current branch (skip if using Docker or SKIP_INSTALL is true)
@@ -115,18 +127,34 @@ from_scratch() {
log_error "HOME_DIR must be more than 2 characters long"
return 1
fi
rm -rf "${HOME_DIR}"
# Handle permission issues from Docker-created files
if [ -d "${HOME_DIR}" ]; then
# Try to fix permissions first
chmod -R u+rwX "${HOME_DIR}" 2>/dev/null || true
# Now try to remove
if ! rm -rf "${HOME_DIR}" 2>/dev/null; then
log_warn "Could not remove ${HOME_DIR} due to permission issues"
log_info "Attempting cleanup with Docker..."
if command -v docker >/dev/null 2>&1; then
# Use a simple busybox container to clean up with proper permissions
docker run --rm -v "${HOME_DIR}:/data" --user root busybox sh -c "rm -rf /data/* /data/.[!.]* 2>/dev/null || true" 2>/dev/null || true
# Try to remove the directory again
rm -rf "${HOME_DIR}" 2>/dev/null || {
log_error "Failed to clean ${HOME_DIR}. Please run: sudo rm -rf ${HOME_DIR}"
log_error "Then run 'make localnet' again"
return 1
}
else
log_error "Failed to clean ${HOME_DIR}. Please run: sudo rm -rf ${HOME_DIR}"
return 1
fi
fi
fi
log_info "Removed existing chain directory: ${HOME_DIR}"
# Reset configuration
set_config
# Add test keys
log_info "Adding test keys..."
import_mnemonic "${KEY}" "${SONR_MNEMONIC_1}" "$KEYALGO"
import_mnemonic "${KEY2}" "${SONR_MNEMONIC_2}" "$KEYALGO"
# Initialize chain
# Initialize chain (must be done before adding keys)
log_info "Initializing chain with moniker: $MONIKER"
if [[ "${USE_DOCKER}" == "true" ]]; then
docker run --rm \
@@ -134,10 +162,20 @@ from_scratch() {
--network host \
onsonr/snrd:latest \
snrd --home /root/.sonr init "${MONIKER}" --chain-id "${CHAIN_ID}" --default-denom "${DENOM}"
# Fix permissions on files created by Docker
chmod -R u+rwX "${HOME_DIR}" 2>/dev/null || true
else
${CHAIN_BIN} init "${MONIKER}" --chain-id "${CHAIN_ID}" --default-denom "${DENOM}" --home "${HOME_DIR}"
fi
# Now that chain is initialized, set client configuration
set_config
# Add test keys (must be done after chain init)
log_info "Adding test keys..."
import_mnemonic "${KEY}" "${SONR_MNEMONIC_1}" "$KEYALGO"
import_mnemonic "${KEY2}" "${SONR_MNEMONIC_2}" "$KEYALGO"
# Update genesis parameters
log_info "Updating genesis parameters..."
update_genesis_params
@@ -209,7 +247,7 @@ configure_node "$HOME_DIR" \
--rest-port "$REST" \
--grpc-port "$GRPC" \
--grpc-web-port "$GRPC_WEB" \
--json-rpc-port "$JSON_RPC" \
--json-rpc-port "$JSON_RPC" "$JSON_RPC_WS" \
--rosetta-port "$ROSETTA" \
--min-gas-prices "0${DENOM}" \
--pruning nothing