Skip to content

Add formatAddress utility for truncating Stellar addresses #608

Description

@Kingsman-99

Description

Stellar public keys are 56 characters long. Throughout the SDK, addresses are passed as raw strings with no helper to produce a display-friendly truncated form (e.g. GABCD...WXYZ). This issue adds a formatAddress utility to src/utils.ts.

Acceptance Criteria

  • formatAddress(address: string, opts?: { leading?: number, trailing?: number }): string exported from src/utils.ts
  • Default: first 5 characters + ... + last 4 characters → "GABCD...WXYZ"
  • leading and trailing options override the defaults
  • Throws SdkError with code INVALID_RECIPIENT if the address is shorter than leading + trailing + 3
  • formatAddress exported from src/index.ts
  • Unit tests: default format, custom leading/trailing, too-short address throws, full-length valid address formats correctly

Context

  • Target files: src/utils.ts, src/index.ts
  • Uses SdkError from src/errors.ts
  • No new dependencies

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions