Problem
Resolving a user-supplied token/asset reference to a contract id — and knowing whether it's a Stellar Asset Contract (and for which asset) — is spread across several overlapping places:
utils::contract_id_hash_from_asset — the primitive (xdr::Asset → id)
config::alias::resolve_reserved — the reserved native alias → native SAC id
commands::token::args::TokenTarget — --id string → id, with an asset-vs-contract split
commands::contract::deploy::asset / commands::contract::id::asset — deploy/id from builder::Asset
config::locator and commands::snapshot::create — more ad-hoc builder::Asset → id
No single type answers both "what contract id?" and "is this a SAC, and which asset?" — the exact knowledge needed to produce a good sac_not_deployed vs contract_not_found error. This surfaced in #2651, where native had to be special-cased to be classified as a SAC.
Proposal
Introduce a centralized resolver producing something like ResolvedToken { contract_id, kind: Sac(Asset) | Contract }, then migrate the call sites above onto it. This removes the duplicated asset→id derivations and makes SAC-awareness consistent everywhere (errors, deploy, id, snapshot).
Context
Follow-up from PR #2651 review discussion.
Problem
Resolving a user-supplied token/asset reference to a contract id — and knowing whether it's a Stellar Asset Contract (and for which asset) — is spread across several overlapping places:
utils::contract_id_hash_from_asset— the primitive (xdr::Asset→ id)config::alias::resolve_reserved— the reservednativealias → native SAC idcommands::token::args::TokenTarget—--idstring → id, with an asset-vs-contract splitcommands::contract::deploy::asset/commands::contract::id::asset— deploy/id frombuilder::Assetconfig::locatorandcommands::snapshot::create— more ad-hocbuilder::Asset→ idNo single type answers both "what contract id?" and "is this a SAC, and which asset?" — the exact knowledge needed to produce a good
sac_not_deployedvscontract_not_founderror. This surfaced in #2651, wherenativehad to be special-cased to be classified as a SAC.Proposal
Introduce a centralized resolver producing something like
ResolvedToken { contract_id, kind: Sac(Asset) | Contract }, then migrate the call sites above onto it. This removes the duplicated asset→id derivations and makes SAC-awareness consistent everywhere (errors, deploy, id, snapshot).Context
Follow-up from PR #2651 review discussion.