feat: add clipboard paste button to destination address inputs - #40
feat: add clipboard paste button to destination address inputs#40MJ-RWA wants to merge 1 commit into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Note
|
| Layer / File(s) | Summary |
|---|---|
Address input behavior apps/src/components/AddressInput.tsx |
Adds controlled input updates, clipboard reading, Stellar address validation, paste-button UI, success and error toasts, and optional error rendering. |
Destination form integration apps/src/pages/SchedulePage.tsx, apps/src/pages/SendPage.tsx |
Replaces destination text inputs with AddressInput. SendPage preserves validation and uses the shorter Invalid Stellar address message. |
Estimated code review effort: 3 (Moderate) | ~20 minutes
Sequence Diagram(s)
sequenceDiagram
participant User
participant AddressInput
participant ClipboardAPI
participant Toast
User->>AddressInput: Click paste button
AddressInput->>ClipboardAPI: Read clipboard text
ClipboardAPI-->>AddressInput: Return clipboard text
AddressInput->>AddressInput: Trim and validate address
AddressInput->>Toast: Show success or error notification
Possibly related issues
- Issue #1 — Add clipboard paste button on address input fields #3 — Requests the reusable
AddressInput, clipboard paste support, and integration intoSendPageandSchedulePage.
Possibly related PRs
- MJ-RWA/Stellarflow#39 — Both PRs update
SendPagedestination address validation and send-button behavior.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
| Check name | Status | Explanation |
|---|---|---|
| Description Check | ✅ Passed | Check skipped - CodeRabbit’s high-level summary is enabled. |
| Title check | ✅ Passed | The title clearly summarizes the addition of a clipboard paste button to destination address inputs. |
| Docstring Coverage | ✅ Passed | No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. |
| 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/clipboard-paste
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.
Comment @coderabbitai help to get the list of available commands.
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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 `@apps/src/components/AddressInput.tsx`:
- Around line 16-20: Replace the structural G-prefix and length checks with one
shared Stellar SDK address validator across AddressInput.tsx:16-20,
SchedulePage.tsx:108, and SendPage.tsx:121-123. Apply it to clipboard input,
manual input, scheduled destination saves, and pre-send validation so malformed
addresses are rejected before onChange, storage, or buildSendTx; preserve the
existing success and error behaviors.
🪄 Autofix
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: CHILL
Plan: Pro Plus
Run ID: a71030bf-1efe-4268-a15b-c188db335410
📒 Files selected for processing (3)
apps/src/components/AddressInput.tsxapps/src/pages/SchedulePage.tsxapps/src/pages/SendPage.tsx
| if (trimmed.startsWith('G') && trimmed.length === 56) { | ||
| onChange(trimmed); | ||
| toast.success('Address pasted'); | ||
| } else { | ||
| toast.error('Clipboard does not contain a valid Stellar address'); |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Inspect the declared Stellar SDK and existing validation helpers.
fd -H -t f '^package\.json$' . -x sh -c 'echo "--- $1"; jq -r ".dependencies, .devDependencies" "$1" | grep -i stellar || true' _ {}
fd -t f '^stellar\.(ts|tsx)$' apps/src/lib \
-x ast-grep outline {} --items all
rg -n -C3 'StrKey|isValidEd25519PublicKey|decodeAddress|buildSendTx|startsWith\(.G.\)|length !== 56' apps/srcRepository: MJ-RWA/Stellarflow
Length of output: 5570
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "--- AddressInput.tsx"
cat -n apps/src/components/AddressInput.tsx
echo "--- SendPage.tsx relevant section"
sed -n '1,150p' apps/src/pages/SendPage.tsx | cat -n
echo "--- SchedulePage.tsx relevant section"
sed -n '1,150p' apps/src/pages/SchedulePage.tsx | cat -n
echo "--- scheduler/stellar relevant sections"
sed -n '1,80p' apps/src/hooks/useScheduler.ts | cat -n
sed -n '1,90p' apps/src/lib/stellar.ts | cat -n
echo "--- read-only behavioral probe: clipboard structural validator accepts invalid base32 StrKeys"
python3 - <<'PY'
import string
prefix = "G"
choices = [c.upper() for c in string.ascii_uppercase[:4]] + list(string.digits)
bad_prefix = "A" + "".join(choices[:40]) + ("G" * (55 - len(choices[:40])))
bad_len = prefix + "".join(choices[:30]) * 2
print("prefix+length-only matches 'G'+ 55 base32 chars:", prefix + "".join(choices[:40]) + ("G" * (55 - len(choices[:40]))) in [prefix + c for c in choices] * 55)
print("any G-prefix 56-character string made only of base32 chars is accepted:", True)
print("bad_prefix", bad_prefix, "starts G, len", len(bad_prefix), "matches false positives")
print("bad_len", bad_len, "len", len(bad_len), "matches false positives")
PYRepository: MJ-RWA/Stellarflow
Length of output: 22419
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "--- AddressInput.tsx"
cat -n apps/src/components/AddressInput.tsx
echo "--- SendPage.tsx relevant section"
sed -n '1,150p' apps/src/pages/SendPage.tsx | cat -n
echo "--- SchedulePage.tsx relevant section"
sed -n '1,150p' apps/src/pages/SchedulePage.tsx | cat -n
echo "--- scheduler/stellar relevant sections"
sed -n '1,80p' apps/src/hooks/useScheduler.ts | cat -n
sed -n '1,90p' apps/src/lib/stellar.ts | cat -n
echo "--- read-only behavioral probe: clipboard structural validator accepts invalid base32 StrKeys"
python3 - <<'PY'
import string
prefix = "G"
choices = [c.upper() for c in string.ascii_uppercase[:4]] + list(string.digits)
bad_prefix = "A" + "".join(choice for choice in choices[:40]) + ("G" * (55 - len(choices[:40])))
bad_len = prefix + "".join(choice for choice in choices[:30]) * 2
print("prefix+length-only matches 'G'+ 55 base32 chars:", prefix + "".join(choice for choice in choices[:40]) + ("G" * (55 - len(choices[:40]))) in [prefix + c for c in choices] * 55)
print("any G-prefix 56-character string made only of base32 chars is accepted:", True)
print("bad_prefix", bad_prefix, "len", len(bad_prefix), "starts G false positive")
print("bad_len", bad_len, "len", len(bad_len), "false positive")
PYRepository: MJ-RWA/Stellarflow
Length of output: 22400
Use one protocol-level Stellar address validator.
AddressInput only checks G... and length before calling onChange, so malformed base32 StrKeys can be accepted. SendPage uses the same structural check and can reach buildSendTx with an invalid destination. SchedulePage stores any nonempty destination before execution. Use a shared Stellar SDK validator for clipboard input, manual input, scheduled saves, and pre-send validation.
📍 Affects 3 files
apps/src/components/AddressInput.tsx#L16-L20(this comment)apps/src/pages/SchedulePage.tsx#L108-L108apps/src/pages/SendPage.tsx#L121-L123
🤖 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 `@apps/src/components/AddressInput.tsx` around lines 16 - 20, Replace the
structural G-prefix and length checks with one shared Stellar SDK address
validator across AddressInput.tsx:16-20, SchedulePage.tsx:108, and
SendPage.tsx:121-123. Apply it to clipboard input, manual input, scheduled
destination saves, and pre-send validation so malformed addresses are rejected
before onChange, storage, or buildSendTx; preserve the existing success and
error behaviors.
Summary by CodeRabbit