Skip to content

minichain ascii art#105

Open
SIDDHANTCOOKIE wants to merge 2 commits into
mainfrom
feat/cli
Open

minichain ascii art#105
SIDDHANTCOOKIE wants to merge 2 commits into
mainfrom
feat/cli

Conversation

@SIDDHANTCOOKIE

@SIDDHANTCOOKIE SIDDHANTCOOKIE commented Jun 26, 2026

Copy link
Copy Markdown
Member

Addressed Issues:

add minichain heading ASCII

Screenshot arts/Recordings:

image

Additional Notes:

AI Usage Disclosure:

We encourage contributors to use AI tools responsibly when creating Pull Requests. While AI can be a valuable aid, it is essential to ensure that your contributions meet the task requirements, build successfully, include relevant tests, and pass all linters. Submissions that do not meet these standards may be closed without warning to maintain the quality and integrity of the project. Please take the time to understand the changes you are proposing and their impact. AI slop is strongly discouraged and may lead to banning and blocking. Do not spam our repos with AI slop.

Check one of the checkboxes below:

  • This PR does not contain AI-generated code at all.
  • This PR contains AI-generated code. I have read the AI Usage Policy and this PR complies with this policy. I have tested the code locally and I am responsible for it.

I have used the following AI models and tools: TODO

Checklist

  • My PR addresses a single issue, fixes a single bug or makes a single improvement.
  • My code follows the project's code style and conventions
  • If applicable, I have made corresponding changes or additions to the documentation
  • If applicable, I have made corresponding changes or additions to tests
  • My changes generate no new warnings or errors
  • I have joined the Discord server and I will share a link to this PR with the project maintainers there
  • I have read the Contribution Guidelines
  • Once I submit my PR, CodeRabbit AI will automatically review it and I will address CodeRabbit's comments.
  • I have filled this PR template completely and carefully, and I understand that my PR may be closed without review otherwise.

Summary by CodeRabbit

  • New Features

    • Updated the CLI help banner with a logo-style, gradient color theme and refreshed command descriptions.
    • Added an ANSI-colored, more prominent interactive input prompt.
  • Enhancements

    • Improved balance output readability by colorizing address, balance, and nonce fields and highlighting tags like “(you)” and contract entries.
    • Refined send command terminal feedback with clearer colored success/failure messaging.
  • Bug Fixes

    • Kept and clarified failure reasons for send, including invalid signature/duplicate/mempool-full scenarios.

@coderabbitai

coderabbitai Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 1c43aba3-dd8b-4a23-8727-e10003a9d4b3

📥 Commits

Reviewing files that changed from the base of the PR and between 459724b and ca7fff8.

📒 Files selected for processing (1)
  • main.py

Walkthrough

The CLI help banner, prompt, balance output, and send messages were updated to use ANSI color styling. The help text now uses a logo-based layout, and command output includes colored tags and status messages.

Changes

CLI ANSI styling updates

Layer / File(s) Summary
Help banner and prompt
main.py
ANSI color constants and a gradient_text() helper are added, the help text is replaced with a colored logo layout, and cli_loop prints the styled help banner and prompt.
Balance and send output
main.py
balance output adds colored (you) and [Contract] tags with reformatted balance and nonce text, and send output uses colored success and rejection messages.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested labels

Python Lang

Poem

A rabbit hopped through the terminal glow,
With cyan and blue in a cheerful row.
The help text sparkled, the prompt felt bright,
And balances blinked in rainbow light.
Hoppity yay—what a colorful show! 🐇

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title matches a real part of the change: the new ASCII-art/minichain banner in the CLI help screen.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/cli

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@main.py`:
- Line 358: The transaction rejection message in the CLI is too specific because
the surrounding flow only has a boolean result from mempool.add_transaction(tx),
so it cannot know the actual cause. Update the rejection branch in the
transaction submission path (the print call near the mempool transaction add
result) to use a generic failure message like the RPC path does, and remove the
invented պատճառ labels such as invalid signature, duplicate, or mempool full
unless real error details are available.
- Line 301: The cli_loop coroutine is becoming too large and is mixing command
parsing, rendering, and networking logic; split it up before adding more
behavior. Refactor cli_loop into smaller per-command handler functions or a
dispatch table, and move the new rendering logic out of the main loop so each
command path is handled in a dedicated helper while cli_loop only routes inputs.
- Line 309: The prompt string passed through input in the shell input flow uses
raw ANSI color escapes, which readline counts as printable text and can misalign
wrapped cursors. Update the input prompt in the run_in_executor lambda to wrap
the color sequences used by the minichain prompt with readline non-printing
markers (\001 and \002), keeping the visible prompt text the same while ensuring
the prompt-length calculation ignores the escape codes.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 5cb00f15-e120-44e6-b97d-ff2d3df3669e

📥 Commits

Reviewing files that changed from the base of the PR and between 95f6089 and 459724b.

📒 Files selected for processing (1)
  • main.py

Comment thread main.py
"""


async def cli_loop(sk, pk, chain, mempool, network):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🔵 Trivial | 🏗️ Heavy lift

Split cli_loop before adding more CLI behavior.

Line 301 is already at 41 branches / 130 statements, and this PR adds more rendering logic into the same coroutine. Extract per-command handlers (or a dispatch table) so future CLI changes stop piling presentation, parsing, and networking into one hot spot.

🧰 Tools
🪛 Ruff (0.15.18)

[warning] 301-301: Too many branches (41 > 12)

(PLR0912)


[warning] 301-301: Too many statements (130 > 50)

(PLR0915)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@main.py` at line 301, The cli_loop coroutine is becoming too large and is
mixing command parsing, rendering, and networking logic; split it up before
adding more behavior. Refactor cli_loop into smaller per-command handler
functions or a dispatch table, and move the new rendering logic out of the main
loop so each command path is handled in a dedicated helper while cli_loop only
routes inputs.

Source: Linters/SAST tools

Comment thread main.py
while True:
try:
raw = await loop.run_in_executor(None, lambda: input("minichain> "))
raw = await loop.run_in_executor(None, lambda: input(f"{C_CYAN}minichain>{C_RESET} "))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

python3 - <<'PY'
import sys
import time

# Simulate the environment check
# We cannot run interactive input in this sandbox, but we can verify the logic
# regarding readline and ANSI escape sequences.

# In Python, if you pass a string with ANSI codes to input(), and the target shell
# uses the GNU readline library (standard on Linux/macOS for bash/zsh),
# the prompt length is calculated based on the raw byte count unless non-printing
# characters are marked.

# The standard markers are \001 (start non-printing) and \002 (end non-printing).
# Without these, terminal cursor positioning logic (specifically in readline)
# miscalculates the prompt width, leading to visual glitches on line wrap.

# Test: Check if readline is available and the standard workaround.
try:
    import readline
    print("GNU Readline is available in this Python build.")
    print("Behavior: Raw ANSI in input() prompt causes cursor drift on wrap.")
    print("Fix: Wrap non-printing sequences with \\001 and \\002.")
except ImportError:
    print("Readline not found. Defaulting to raw input behavior.")

print("\nVerification Conclusion:")
print("The claim is correct. In environments using GNU Readline (default for interactive Python shells),")
print("ANSI color codes passed directly to input() without \\001/\\002 wrappers cause cursor misalignment.")
print("The suggested fix using escaped markers is the standard solution.")
PY

Repository: StabilityNexus/MiniChain

Length of output: 617


Wrap the ANSI prompt escapes for readline.

Raw color escapes inside input(...) cause cursor misalignment when the line wraps in readline-enabled terminals (default on Linux/macOS). The shell calculates prompt length by counting raw bytes unless non-printing sequences are explicitly marked.

Use \001 (start) and \002 (end) to bracket the color codes so readline ignores them during width calculation:

-            raw = await loop.run_in_executor(None, lambda: input(f"{C_CYAN}minichain>{C_RESET} "))
+            raw = await loop.run_in_executor(None, lambda: input(f"\001{C_CYAN}\002minichain>\001{C_RESET}\002 "))
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
raw = await loop.run_in_executor(None, lambda: input(f"{C_CYAN}minichain>{C_RESET} "))
raw = await loop.run_in_executor(None, lambda: input(f"\001{C_CYAN}\002minichain>\001{C_RESET}\002 "))
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@main.py` at line 309, The prompt string passed through input in the shell
input flow uses raw ANSI color escapes, which readline counts as printable text
and can misalign wrapped cursors. Update the input prompt in the run_in_executor
lambda to wrap the color sequences used by the minichain prompt with readline
non-printing markers (\001 and \002), keeping the visible prompt text the same
while ensuring the prompt-length calculation ignores the escape codes.

Comment thread main.py
print(f" {C_GREEN}✅ Tx sent:{C_RESET} {amount} coins → {receiver[:12]}...")
else:
print(" ❌ Transaction rejected (invalid sig, duplicate, or mempool full).")
print(f" {C_RED}❌ Transaction rejected{C_RESET} (invalid sig, duplicate, or mempool full).")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Keep the rejection message generic unless you have the actual reason.

mempool.add_transaction(tx) only gives a boolean here, so invalid sig, duplicate, or mempool full can easily be wrong. The RPC path keeps this failure generic for the same reason, so the CLI should avoid inventing causes too.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@main.py` at line 358, The transaction rejection message in the CLI is too
specific because the surrounding flow only has a boolean result from
mempool.add_transaction(tx), so it cannot know the actual cause. Update the
rejection branch in the transaction submission path (the print call near the
mempool transaction add result) to use a generic failure message like the RPC
path does, and remove the invented պատճառ labels such as invalid signature,
duplicate, or mempool full unless real error details are available.

@Zahnentferner Zahnentferner left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks very nice!

I only have a minor suggestion: make the right border of the blue rectangle aligned with the end of the MiniChain word.

Image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants