Centralize asset/token resolution behind a single resolver - #2654
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Centralizes token and Stellar Asset Contract resolution in config::token and migrates token and contract commands to use the shared resolver.
Changes:
- Adds unresolved/resolved token types with SAC classification.
- Migrates balance, transfer, asset ID, deployment, and native alias resolution.
- Preserves token-aware missing-contract errors.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
config/token.rs |
Implements centralized token resolution. |
config/mod.rs |
Exports the token module. |
config/locator.rs |
Passes locator context to reserved aliases. |
config/alias.rs |
Resolves native through the shared resolver. |
commands/token/transfer.rs |
Uses resolved token metadata. |
commands/token/balance.rs |
Shares resolved tokens across reads. |
commands/token/args.rs |
Classifies missing contracts from resolved tokens. |
commands/contract/id/asset.rs |
Derives SAC IDs through the resolver. |
commands/contract/deploy/asset.rs |
Resolves SAC identity and asset before RPC. |
commands/contract/alias/ls.rs |
Supplies locator context for native aliases. |
leighmcculloch
approved these changes
Jul 22, 2026
fnando
force-pushed
the
centralize-token-resolution
branch
from
July 23, 2026 17:55
c94d536 to
68d851b
Compare
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.
What
Introduces a single token resolver in a new
config::tokenmodule and migrates the scattered asset/token → contract-id derivations onto it, resolving #2652.UnresolvedToken— a token reference parsed from a user string (native/CODE:ISSUER→ asset;C…strkey or alias → contract).ResolvedToken { contract_id, kind }whereTokenKindisSac(xdr::Asset)orContract— the single answer to both "what contract id?" and "is this a SAC, and for which asset?". Helpers:is_sac()/asset().Migrated call sites:
commands::token::args— dropped the oldTokenTarget;not_deployed_erroris now keyed offResolvedToken::kind, keeping thesac_not_deployedvscontract_not_foundsplit.args::Errornow carries only the two token-aware variants it actually produces.commands::token::{balance,transfer}—--idis nowUnresolvedToken; both resolve once and thread theResolvedTokenthrough.commands::contract::{id,deploy}::asset— derive the id (and, for deploy, the wrap-tx asset) via the resolver. Deploy resolves up front, before any RPC, so an invalid asset fails fast.config::alias::resolve_reserved— the reservednativealias now resolves through the shared resolver.utils::contract_id_hash_from_assetremains the low-level primitive the resolver builds on.Why
Resolving a token/asset reference to a contract id — and knowing whether it's a Stellar Asset Contract and for which asset — was spread across several overlapping places, with no single type answering both questions. This surfaced in #2651, where
nativehad to be special-cased as a SAC. The resolver makes SAC-awareness consistent everywhere (errors, deploy, id).Known limitations
snapshot::createis intentionally left unmigrated: that site parses the asset to extract the issuer for account search, not to derive a contract id, soResolvedToken's shape doesn't fit.