From 30635ba397f8552c52fe1315732c63691282fa49 Mon Sep 17 00:00:00 2001 From: Prad Nukala Date: Sat, 25 Oct 2025 14:43:44 -0400 Subject: [PATCH 1/3] chore(ci): migrate scopes to toml format --- .github/Repo.toml | 18 ++++++ .github/scopes.json | 150 -------------------------------------------- 2 files changed, 18 insertions(+), 150 deletions(-) create mode 100644 .github/Repo.toml delete mode 100644 .github/scopes.json diff --git a/.github/Repo.toml b/.github/Repo.toml new file mode 100644 index 000000000..1e5969a9b --- /dev/null +++ b/.github/Repo.toml @@ -0,0 +1,18 @@ +[scopes] +ante = ["app/ante"] +api = ["api/dex", "api/did", "api/dwn", "api/svc", "api"] +app = ["app/context", "app/decorators", "app/params", "app/upgrades", "app"] +chains = ["chains"] +ci = ["Makefile", ".github"] +cli = ["app/commands"] +cmd = ["cmd/snrd", "cmd"] +config = ["networks/localnet", "networks/testnet", "networks"] +deps = ["go.sum", "go.mod"] +dex = ["proto/dex", "x/dex"] +did = ["proto/did", "x/did"] +docs = ["docs"] +dwn = ["proto/dwn", "x/dwn"] +proto = ["proto"] +scripts = ["scripts"] +svc = ["proto/svc", "x/svc"] +test = ["test/e2e", "test/integration", "test/oauth", "test"] diff --git a/.github/scopes.json b/.github/scopes.json deleted file mode 100644 index d0824f49b..000000000 --- a/.github/scopes.json +++ /dev/null @@ -1,150 +0,0 @@ -[ - { - "scope": "deps", - "path": "go.sum" - }, - { - "scope": "deps", - "path": "go.mod" - }, - { - "scope": "api", - "path": "api/dex" - }, - { - "scope": "api", - "path": "api/did" - }, - { - "scope": "api", - "path": "api/dwn" - }, - { - "scope": "api", - "path": "api/svc" - }, - { - "scope": "api", - "path": "api" - }, - { - "scope": "ante", - "path": "app/ante" - }, - { - "scope": "cli", - "path": "app/commands" - }, - { - "scope": "app", - "path": "app/context" - }, - { - "scope": "app", - "path": "app/decorators" - }, - { - "scope": "app", - "path": "app/params" - }, - { - "scope": "app", - "path": "app/upgrades" - }, - { - "scope": "app", - "path": "app" - }, - { - "scope": "chains", - "path": "chains" - }, - { - "scope": "cmd", - "path": "cmd/snrd" - }, - { - "scope": "cmd", - "path": "cmd" - }, - { - "scope": "docs", - "path": "docs" - }, - { - "scope": "config", - "path": "networks/localnet" - }, - { - "scope": "config", - "path": "networks/testnet" - }, - { - "scope": "config", - "path": "networks" - }, - { - "scope": "dex", - "path": "proto/dex" - }, - { - "scope": "did", - "path": "proto/did" - }, - { - "scope": "dwn", - "path": "proto/dwn" - }, - { - "scope": "svc", - "path": "proto/svc" - }, - { - "scope": "proto", - "path": "proto" - }, - { - "scope": "scripts", - "path": "scripts" - }, - { - "scope": "test", - "path": "test/e2e" - }, - { - "scope": "test", - "path": "test/integration" - }, - { - "scope": "test", - "path": "test/oauth" - }, - { - "scope": "test", - "path": "test" - }, - { - "scope": "dex", - "path": "x/dex" - }, - { - "scope": "did", - "path": "x/did" - }, - { - "scope": "dwn", - "path": "x/dwn" - }, - { - "scope": "svc", - "path": "x/svc" - }, - { - "scope": "ci", - "path": "Makefile" - }, - { - "scope": "ci", - "path": ".github" - } -] From 88ca486108f755f130f85af2cf9131a9ee6b9566 Mon Sep 17 00:00:00 2001 From: Prad Nukala Date: Sat, 25 Oct 2025 14:43:46 -0400 Subject: [PATCH 2/3] chore(devbox): add dasel package and update devbox config --- .gitignore | 1 + devbox.json | 9 +++++---- devbox.lock | 48 ++++++++++++++++++++++++++++++++++++++++++++++ docker-compose.yml | 20 ------------------- 4 files changed, 54 insertions(+), 24 deletions(-) diff --git a/.gitignore b/.gitignore index d8619caa5..cb33c8319 100755 --- a/.gitignore +++ b/.gitignore @@ -121,3 +121,4 @@ tmp-openapi-gen/**/*.json # Allow the final combined openapi.yml !docs/static/openapi.yml .mcp.json +node_modules diff --git a/devbox.json b/devbox.json index 5a7e3b496..93f7d75c5 100644 --- a/devbox.json +++ b/devbox.json @@ -8,7 +8,8 @@ "jq@latest", "trunk@latest", "mods@latest", - "yq@latest" + "yq@latest", + "dasel@latest" ], "env": {}, "shell": { @@ -16,10 +17,10 @@ "go mod download" ], "scripts": { - "build": "make build-all", - "test": "make test-all", + "build": "make build-all", + "test": "make test-all", "snapshot": "make snapshot", - "release": "make release" + "release": "make release" } } } diff --git a/devbox.lock b/devbox.lock index 42b36d593..b845db086 100644 --- a/devbox.lock +++ b/devbox.lock @@ -1,6 +1,54 @@ { "lockfile_version": "1", "packages": { + "dasel@latest": { + "last_modified": "2025-10-07T08:41:47Z", + "resolved": "github:NixOS/nixpkgs/bce5fe2bb998488d8e7e7856315f90496723793c#dasel", + "source": "devbox-search", + "version": "2.8.1", + "systems": { + "aarch64-darwin": { + "outputs": [ + { + "name": "out", + "path": "/nix/store/kahwgfqz0x48aj3ikrd963pinkjsgi1p-dasel-2.8.1", + "default": true + } + ], + "store_path": "/nix/store/kahwgfqz0x48aj3ikrd963pinkjsgi1p-dasel-2.8.1" + }, + "aarch64-linux": { + "outputs": [ + { + "name": "out", + "path": "/nix/store/gcnpff6qc8r8rz6paphc3j2q20hhys5r-dasel-2.8.1", + "default": true + } + ], + "store_path": "/nix/store/gcnpff6qc8r8rz6paphc3j2q20hhys5r-dasel-2.8.1" + }, + "x86_64-darwin": { + "outputs": [ + { + "name": "out", + "path": "/nix/store/c97l94fqsic4nqrgrzrn5fjbw18lggjw-dasel-2.8.1", + "default": true + } + ], + "store_path": "/nix/store/c97l94fqsic4nqrgrzrn5fjbw18lggjw-dasel-2.8.1" + }, + "x86_64-linux": { + "outputs": [ + { + "name": "out", + "path": "/nix/store/5494996bmd4nqv17l4ji9r3r2n5b1aqj-dasel-2.8.1", + "default": true + } + ], + "store_path": "/nix/store/5494996bmd4nqv17l4ji9r3r2n5b1aqj-dasel-2.8.1" + } + } + }, "docker@latest": { "last_modified": "2025-08-05T11:35:34Z", "resolved": "github:NixOS/nixpkgs/a683adc19ff5228af548c6539dbc3440509bfed3#docker", diff --git a/docker-compose.yml b/docker-compose.yml index 6a85cdedb..548fb92cb 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -32,26 +32,6 @@ services: networks: - sonr-network - caddy: - container_name: caddy - image: caddy:2-alpine - restart: unless-stopped - depends_on: - snrd: - condition: service_healthy - ports: - - "80:80" - - "443:443" - - "443:443/udp" - volumes: - - ./caddy/Caddyfile:/etc/caddy/Caddyfile:ro - - caddy-data:/data - - caddy-config:/config - environment: - CADDY_DOMAIN: ${CADDY_DOMAIN:-localhost} - networks: - - sonr-network - snrd: container_name: snrd image: onsonr/snrd:latest From be4e4b8367bf0cedb662edae7a33af8441442fa1 Mon Sep 17 00:00:00 2001 From: Prad Nukala Date: Sat, 25 Oct 2025 14:43:47 -0400 Subject: [PATCH 3/3] docs(src): add README file for sonrctl cli --- src/README.md | 396 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 396 insertions(+) create mode 100644 src/README.md diff --git a/src/README.md b/src/README.md new file mode 100644 index 000000000..626449301 --- /dev/null +++ b/src/README.md @@ -0,0 +1,396 @@ +# sonrctl 🚀 + +**Blazingly fast CLI for managing Sonr blockchain nodes, validators, and networks** + +Built with [Bun](https://bun.sh) - the all-in-one JavaScript runtime. + +## Features + +- ⚡ **Blazingly Fast** - Built on Bun for instant startup and execution +- 🎯 **Simple API** - Clean, intuitive commands for node management +- 🐳 **Docker Integration** - Seamless container orchestration for testnets +- 💾 **SQLite Config** - Lightweight, fast configuration management +- 🎨 **Beautiful Output** - Colored, formatted CLI output +- 🔧 **Node Management** - Initialize, start, stop, and monitor nodes +- 🌐 **Network Operations** - Full testnet deployment and management + +## Installation + +### Install Bun (if not already installed) + +```bash +curl -fsSL https://bun.sh/install | bash +``` + +### Install sonrctl + +```bash +# Clone the repository +git clone https://github.com/sonr-io/sonr.git +cd sonr + +# Install dependencies +bun install + +# Link the CLI globally +bun link +``` + +### Install snrd binary + +```bash +sonrctl install latest +``` + +## Quick Start + +```bash +# Show help +sonrctl help + +# Initialize a validator node +sonrctl init validator val-naruto --chain-id sonrtest_1-1 + +# Start the entire testnet network +sonrctl start network --detach + +# Check network status +sonrctl status network + +# Stop the network +sonrctl stop network +``` + +## Commands + +### `sonrctl install [version]` + +Install or update the snrd binary. + +```bash +# Install latest version +sonrctl install latest + +# Install specific version (coming soon) +sonrctl install v1.0.0 +``` + +### `sonrctl init [options]` + +Initialize a new node configuration. + +**Types:** `validator`, `sentry`, `full` + +**Options:** +- `--chain-id ` - Chain ID (default: sonrtest_1-1) +- `--home ` - Home directory (default: ~/.sonr/) +- `--rpc-port ` - RPC port (default: 26657) +- `--rest-port ` - REST API port (default: 1317) +- `--grpc-port ` - gRPC port (default: 9090) +- `--grpc-web-port ` - gRPC-Web port (default: 9091) +- `--json-rpc-port ` - JSON-RPC port (default: 8545) +- `--json-rpc-ws-port ` - JSON-RPC WebSocket port (default: 8546) + +**Examples:** + +```bash +# Initialize a validator +sonrctl init validator val-naruto + +# Initialize a sentry with custom home +sonrctl init sentry sentry-naruto --home ~/.sonr/custom-sentry + +# Initialize with custom ports +sonrctl init validator my-val --rpc-port 26658 --rest-port 1318 +``` + +### `sonrctl start [options]` + +Start a node or the entire network. + +**Targets:** +- `` - Start a specific registered node +- `network` - Start the entire testnet using docker-compose + +**Options:** +- `--detach`, `-d` - Run in background (network only) + +**Examples:** + +```bash +# Start a specific node +sonrctl start val-naruto + +# Start network in foreground +sonrctl start network + +# Start network in background +sonrctl start network --detach +``` + +### `sonrctl stop ` + +Stop a node, network, or all containers. + +**Targets:** +- `` - Stop a specific container +- `network` - Stop the entire testnet +- `all` - Stop all running containers + +**Examples:** + +```bash +# Stop a specific node +sonrctl stop val-naruto + +# Stop the network +sonrctl stop network + +# Stop all containers +sonrctl stop all +``` + +### `sonrctl status [target]` + +Check status of nodes and network. + +**Targets:** +- (none) - Show overall status +- `` - Show specific node status +- `network` - Show network status + +**Examples:** + +```bash +# Show overall status +sonrctl status + +# Show specific node status +sonrctl status val-naruto + +# Show network status +sonrctl status network +``` + +### `sonrctl config [args]` + +Manage sonrctl configuration. + +**Commands:** +- `list` - List all configuration +- `get ` - Get a specific value +- `set ` - Set a configuration value + +**Examples:** + +```bash +# List all configuration +sonrctl config list + +# Get chain ID +sonrctl config get chain_id + +# Set home directory +sonrctl config set home ~/.sonr-custom +``` + +## Configuration + +sonrctl stores its configuration in: +- **Config Database:** `~/.config/sonr/config.db` +- **Node Home:** `~/.sonr/` (default) + +The SQLite database stores: +- Global configuration (chain ID, binary path, etc.) +- Registered nodes +- Node metadata + +## Project Structure + +``` +src/ +├── index.ts # Main CLI entry point +├── types.ts # TypeScript type definitions +├── commands/ # Command implementations +│ ├── install.ts # Install snrd binary +│ ├── init.ts # Initialize nodes +│ ├── start.ts # Start nodes/network +│ ├── stop.ts # Stop nodes/network +│ ├── status.ts # Check status +│ └── config.ts # Configuration management +└── lib/ # Utility libraries + ├── constants.ts # Constants and defaults + ├── logger.ts # Beautiful logging + ├── config.ts # SQLite configuration manager + ├── toml.ts # TOML file utilities + ├── docker.ts # Docker operations + └── node.ts # Node operations +``` + +## Architecture + +sonrctl is built with a clean, modular architecture: + +1. **Command Layer** - Handles user input and command routing +2. **Library Layer** - Provides utilities for common operations +3. **Storage Layer** - SQLite database for configuration persistence + +### Key Design Decisions + +- **Bun Runtime** - For blazingly fast execution and built-in tools +- **SQLite Storage** - Lightweight, fast, and portable +- **No External Dependencies** - Minimal deps, maximum performance +- **Clean Separation** - Commands, libraries, and utilities are separate +- **Type Safety** - Full TypeScript support + +## Docker Integration + +sonrctl integrates seamlessly with Docker for testnet deployment: + +- Start/stop docker-compose networks +- Manage individual containers +- Monitor container status +- Execute commands in containers +- View container logs + +The CLI can work as a drop-in replacement for manual docker-compose operations. + +## Development + +### Prerequisites + +- [Bun](https://bun.sh) v1.0+ +- Docker (for network operations) +- Git + +### Running Locally + +```bash +# Run directly with Bun +bun run src/index.ts help + +# Run a specific command +bun run src/index.ts status +``` + +### Adding New Commands + +1. Create a new file in `src/commands/` +2. Export an async function that takes `args: string[]` +3. Import and add to the switch statement in `src/index.ts` +4. Update the help text + +Example: + +```typescript +// src/commands/mycommand.ts +export async function mycommand(args: string[]) { + Logger.header('My Command'); + // Implementation +} + +// src/index.ts +import { mycommand } from './commands/mycommand'; + +// Add to switch statement +case 'mycommand': + await mycommand(commandArgs); + break; +``` + +## Examples + +### Setting Up a Testnet + +```bash +# 1. Install the binary +sonrctl install + +# 2. Start the testnet network +sonrctl start network --detach + +# 3. Check status +sonrctl status network + +# 4. View logs +docker logs -f val-naruto + +# 5. Stop when done +sonrctl stop network +``` + +### Creating a Custom Node + +```bash +# 1. Initialize a custom validator +sonrctl init validator my-validator \ + --chain-id mychain-1 \ + --home ~/.sonr/my-validator \ + --rpc-port 26667 + +# 2. Configure genesis (manual step) +# Edit ~/.sonr/my-validator/config/genesis.json + +# 3. Start the node +sonrctl start my-validator + +# 4. Check status +sonrctl status my-validator +``` + +## Troubleshooting + +### Command not found + +```bash +# Make sure Bun's bin directory is in your PATH +export PATH="$HOME/.bun/bin:$PATH" + +# Re-link the CLI +bun link +``` + +### Docker permission denied + +```bash +# Add your user to the docker group +sudo usermod -aG docker $USER + +# Log out and back in, or run: +newgrp docker +``` + +### Binary not found after install + +```bash +# Check if ~/.local/bin is in your PATH +export PATH="$HOME/.local/bin:$PATH" + +# Add to your shell profile +echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.bashrc +``` + +## Contributing + +Contributions are welcome! Please: + +1. Fork the repository +2. Create a feature branch +3. Make your changes +4. Add tests if applicable +5. Submit a pull request + +## License + +Apache 2.0 - See LICENSE file for details + +## Links + +- [Sonr Network](https://sonr.io) +- [Documentation](https://docs.sonr.io) +- [GitHub](https://github.com/sonr-io/sonr) +- [Bun](https://bun.sh) + +--- + +**Built with ❤️ using Bun**