Skip to content

feat: add shortenAddress helper for wallet address display — Close #423#447

Merged
Chucks1093 merged 1 commit into
accesslayerorg:devfrom
pixels26:formatting-wallet-address
Jun 25, 2026
Merged

feat: add shortenAddress helper for wallet address display — Close #423#447
Chucks1093 merged 1 commit into
accesslayerorg:devfrom
pixels26:formatting-wallet-address

Conversation

@pixels26

Copy link
Copy Markdown
Contributor

Summary

Adds a shortenAddress utility to format long Stellar wallet addresses for UI display. Full addresses are shortened to first 4 + ... + last 4 characters (e.g. GABC...XY12).

Closes #423

Changes

  • src/lib/web3/format.ts — Simplified shortenAddress(address) to:
    • Return the full address unchanged when shorter than 10 characters
    • Otherwise return first 4 + ... + last 4
    • Return empty string for falsy input
  • src/lib/web3/__tests__/format.test.ts — New test file with 5 unit tests covering:
    • Standard Stellar address → correctly shortened (GABC...1234)
    • Address shorter than 10 characters → returned as-is
    • Exactly 9-character address → returned as-is
    • Exactly 10-character address → correctly shortened
    • Empty string → returns empty string

Acceptance Criteria

  • Standard Stellar address returns correctly shortened form
  • Addresses shorter than 10 characters are returned as-is
  • Unit tests cover all cases

Testing

pnpm vitest run src/lib/web3/__tests__/format.test.ts

# Output:
#  ✓ src/lib/web3/__tests__/format.test.ts (5 tests)
# Test Files  1 passed (1)
#      Tests  5 passed (5)

@drips-wave

drips-wave Bot commented Jun 25, 2026

Copy link
Copy Markdown

@pixels26 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@Chucks1093 Chucks1093 merged commit 499444b into accesslayerorg:dev Jun 25, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add helper for formatting wallet address as shortened display string

2 participants