feat(frontend): let teams stream their own SIP-010 token - #31
Merged
Merged
Conversation
The create-stream selector was a hardcoded list of four curated tokens. `stream-manager.clar` is permissionless, so a team wanting to stream its own token had no way to select it without a code change — which blocks onboarding a protocol that already supports it. Discovery is now a separate concern from trust: - `lib/token-registry.ts` queries Hiro's token metadata API, which indexes every SIP-010 token (~5.6k). It is used ONLY to find and label tokens. - `verifySelection` is the single gate from a suggestion to a transaction. decimals and assetName are re-proven on-chain by the existing resolver and the registry's values are never used for a post-condition. I checked the registry's decimals against `get-decimals` on 25 indexed tokens and they agreed 25/25, but "has always agreed" is not a property a payment should depend on, and an indexer is one deploy behind the chain forever. - A resolver failure yields "unverifiable", never a fallback token. A flat list of the registry would not be shippable: `symbol=sBTC` returns 32 contracts including `buttcoin-stxcity`, so search flags any contract claiming a curated symbol as an impersonator, shows the full principal rather than a symbol, and requires an explicit confirm. Verified-but-new tokens stay frictionless — nothing legitimate is blocked. Three entry paths, in trust order: curated tokens pinned first, then search, then a contract id. The contract-id path exists because that is how users actually obtain one — a team puts `/dashboard/create?token=SP….x` in its own docs or Slack and nobody types 41 characters. It resolves from the chain, so it works for tokens the registry has not indexed yet and when the registry is down; the registry only supplies cosmetics there, since `/metadata/v1/search` does not return an asset identifier at all. Adds 43 network-free tests. Verified: 186 pass, tsc clean, build clean, lint unchanged at the pre-existing 14 errors / 4 warnings.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #30. The create-stream selector was a hardcoded list of four curated tokens, so a team could not stream its own token without a code change — even though
stream-manager.claris permissionless and #30 already made uncurated tokens safe to resolve.Why search, not a list
Hiro's token metadata API indexes every SIP-010 token (~5.6k), but a flat dropdown of that is not shippable.
symbol=sBTCreturns 32 contracts includingbuttcoin-stxcityandsBTC-mock-vpv-10. Sampling the default listing order showed 0% usable rows in the first few hundred — no symbol, no name, no supply.So the shape is three entry paths in trust order: curated tokens pinned first, then search over the registry, then a contract id.
Discovery is separate from trust
verifySelectioninlib/token-registry.tsis the single gate from a suggestion to a transaction:decimalsandassetNameare re-proven on-chain by the existing resolver. The registry's values are never used for a post-condition.get-decimalson 25 indexed tokens: 25/25 agreed. But "has always agreed" is not a property a payment should depend on, and an indexer is one deploy behind the chain forever.unverifiable— never a fallback token. Regression-tested against the exact bug fix: resolve token metadata from chain instead of assuming sBTC #30 fixed.Because the gate is one-directional, the registry can be wrong, stale, or fully down without any path to a misdirected payment.
How users get a contract id
Not by typing it. A team puts
/dashboard/create?token=SP….contract-namein its docs or Slack and the recipient clicks it. That resolves from the chain, so it also works for tokens deployed minutes ago that the registry has not indexed, and when the registry is down.Worth noting: the registry's
/searchendpoint returnscontract_idandtoken_numberwith no asset identifier at all, so the asset name for a post-condition cannot come from there even in principle. That path therefore takes only cosmetics from the registry and everything load-bearing from the chain.Friction: warn, never block
Verified against mainnet
Disagreement between listing and contract downgrades to
unverifiedand is refused: "Token listing reports 2 decimals but the contract reports 6."Verification
npx tsc --noEmitcleannpm run buildcleanNot addressed here
Multi-asset contracts (sBTC, ALEX) still have no disambiguating read-only function. They work via their curated entries, but a new multi-asset token would need a contract-side identifier. The registry cannot solve this — it indexes only one asset per such contract.