Skip to content

fix: correct native XLM SAC defaults and add derivation-based test - #251

Open
Daveeee-tech wants to merge 1 commit into
Miracle656:mainfrom
Daveeee-tech:main
Open

Daveeee-tech wants to merge 1 commit into
Miracle656:mainfrom
Daveeee-tech:main

Conversation

@Daveeee-tech

Copy link
Copy Markdown

closes #222

Summary

Fixes the hard-coded native XLM Stellar Asset Contract (SAC) addresses, which were each shifted one network along. Adds a test that checks them against the SDK's own derivation so this can't regress silently.

Problem

DEFAULT_XLM_SAC_MAINNET and DEFAULT_XLM_SAC_TESTNET in src/indexer.ts, and KNOWN_SAC_IDS in src/indexer/sac-detect.ts, did not match Asset.native().contractId(...):

Network Previously held Correct value (SDK derivation)
Mainnet testnet SAC (CDLZFC3S…) CAS3J7GYLGXMF6TDJBBYYSE3HQ6BBSMLNUQ34T6TZMYMW2EVH34XOWMA
Testnet standalone SAC (CDMLFMKM…) CDLZFC3SYJYDZT7K67VZ75HPJVIEUVNIXF47ZG2FB2RMQQVU2HHGCYSC

All three are valid StrKey contract IDs, so nothing flagged the error. Only the derivation was wrong.

Impact

  • Mainnet: with SAC_CONTRACT_IDS unset, resolveSacContractIds() falls back to a contract that doesn't exist on mainnet. getEvents returns nothing forever, and the service looks healthy while the table stays empty.
  • Testnet: the fallback points at the standalone SAC, with the same silent-empty failure. Working deployments only avoided this by setting SAC_CONTRACT_IDS explicitly.
  • sac-detect.ts: real mainnet XLM transfers missed KNOWN_SAC_IDS and took the slow RPC path. Testnet XLM hit the set through the entry labelled "mainnet", so it was right for the wrong reason.

Changes

  • src/indexer.ts: corrected DEFAULT_XLM_SAC_MAINNET and DEFAULT_XLM_SAC_TESTNET.
  • src/indexer/sac-detect.ts: corrected the two values in KNOWN_SAC_IDS.
  • .env.example:
    • corrected both native SAC fallbacks and the testnet / mainnet fallback comment
    • corrected the "Known mainnet SAC addresses" block and the SAC_CONTRACT_IDS_TESTNET / SAC_CONTRACT_IDS_MAINNET examples
    • corrected the mainnet USDC example to CCW67TSZV3SSS2HXMBQ5JFGCKJNXKZM7UQUWUZPUTHXSTZLEO7SJMI75, which is what new Asset('USDC', 'GA5ZSEJYB37JRC5AVCIA5MOP4RHTM335X2KGX3IHOJAPP5RE34K4KZVN').contractId(Networks.PUBLIC) produces (the issuer key was already correct)
  • Tests: added a test asserting each constant against Asset.native().contractId(Networks.PUBLIC | Networks.TESTNET) instead of against a literal.
it("matches the SDK's own derivation", () => {
  expect(DEFAULT_XLM_SAC_MAINNET).toBe(Asset.native().contractId(Networks.PUBLIC));
  expect(DEFAULT_XLM_SAC_TESTNET).toBe(Asset.native().contractId(Networks.TESTNET));
});

Background

The wrong value originated in #166, which quoted CDLZFC3SY… as the mainnet SAC and carried into docs/DEPLOY_MAINNET.md via #211. The doc was corrected on merge, but the code was not.

Acceptance criteria

  • DEFAULT_XLM_SAC_MAINNET / DEFAULT_XLM_SAC_TESTNET equal the SDK derivation for Networks.PUBLIC / Networks.TESTNET
  • KNOWN_SAC_IDS holds the same two corrected values
  • .env.example corrected (both native fallbacks, known-mainnet-SAC block, USDC example)
  • Test asserts each constant against Asset.native().contractId(...)

Notes for reviewers

  • Deployments that already set SAC_CONTRACT_IDS explicitly are unaffected.
  • Deployments relying on the old defaults were indexing nothing, so after upgrading they will start picking up native XLM events from the network they actually target.

@drips-wave

drips-wave Bot commented Oct 16, 2026

Copy link
Copy Markdown

@Daveeee-tech 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

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.

The built-in native XLM SAC defaults are wrong: mainnet holds the testnet address, testnet holds the standalone one

1 participant