Skip to content

Centralize asset/token resolution behind a single resolver #2652

Description

@fnando

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status
    Backlog (Not Ready)

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions