Skip to content

Fix scValToString contract address encoding and add tests - #1267

Open
yahia008 wants to merge 1 commit into
Favourorg:mainfrom
yahia008:drips/1015
Open

yahia008 wants to merge 1 commit into
Favourorg:mainfrom
yahia008:drips/1015

Conversation

@yahia008

Copy link
Copy Markdown

Summary

Fix scValToString contract address encoding and add tests

What was solved

#1015 — 🟠 scValToString renders contract addresses as raw hex, not StrKey — per-token history and explorer links are broken

Fix scValToString in frontend/src/services/stellar-impl.ts so contract addresses are encoded as canonical C… StrKey via StrKey.encodeContract(addr.contractId()) instead of raw hex, and handle muxed-account addresses in the account branch. This restores per-token history filtering (getTokenEvents), explorer index search (loadTokenByAddress), and dashboard/explorer address displays and links. Add focused test coverage for the decoder.

Addressed:

  • Changed: README.md
  • Encode contract addresses with StrKey.encodeContract(addr.contractId()) in scValToString so event-derived tokenAddress fields (created, meta, mint, burn) are canonical StrKey.
  • Review and handle the account branch for muxed-account (scAddressTypeMuxedAccount) addresses so they don't throw or mis-encode.
  • Prefer scValToNative plus a thin formatting layer over the hand-rolled decoder where the SDK's canonical conversion suffices, to prevent field-by-field encoding bugs.

Changes

  • README.md (modify)

Approach

  1. In frontend/src/services/stellar-impl.ts, update scValToString to encode contract addresses via StrKey.encodeContract(addr.contractId()) instead of raw hex.
  2. Handle the scAddressTypeMuxedAccount branch in scValToString using StrKey.encodeMed25519PublicKey with the muxed id, avoiding throws.
  3. Keep non-address scv type handling intact (preserve existing return shapes) while relying on scValToNative where it suffices.
  4. Add frontend/src/services/stellar-impl.test.ts covering contract address, account address, muxed account, and other scv types for scValToString.

Issues

Closes #1015

This branch has not been deployed

No deployments
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.

🟠 scValToString renders contract addresses as raw hex, not StrKey — per-token history and explorer links are broken

1 participant