Skip to content

feat: support Stellar Asset Contracts in register_import! - #82

Draft
pselle wants to merge 1 commit into
feat/register-importfrom
feat/register-import-sac
Draft

pselle wants to merge 1 commit into
feat/register-importfrom
feat/register-import-sac

Conversation

@pselle

@pselle pselle commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Part of #65

Stacked on #77. Makes register_import! work for Stellar Asset Contracts (xlm/native, "CODE:ISSUER", or a registered name that resolves to a SAC), replacing the "SAC support is coming" compile error.

A test Env only creates a SAC at the address derived from its asset, so register_import! registers a test asset and copies its contract instance to the address import_contract! baked in. import_contract! itself is unchanged. The asset is a mintable stand-in with a generated admin, even for xlm:

env.mock_all_auths();
let xlm = register_import!(&env, xlm);
token::StellarAssetClient::new(&env, &xlm).mint(&alice, &1_000);

The copy uses Env::host().get_ledger_entry / add_ledger_entry, which are #[doc(hidden)] testutils APIs and could change across soroban-sdk majors. contract = Mock works on SAC names; args without contract is a compile error since a SAC has no constructor. The xlm_tip_jar fixture now imports xlm directly instead of through a #[cfg(test)] twin module, and just test-register-import runs it in CI.

For `xlm`/`native`, `"CODE:ISSUER"`, or a registered name that resolves
to a SAC, register_import! now puts a mintable test asset at the address
import_contract! baked in, replacing the compile error. A test Env only
creates a SAC at the address derived from its asset, so the expansion
registers a throwaway one and copies its contract instance to the baked
address. import_contract! itself is unchanged.

Rewrite the xlm_tip_jar fixture to use it, dropping its hand-written
`#[cfg(test)]` twin module, and run its test from
`just test-register-import`.

Part of #65

Co-Authored-By: Claude <noreply@anthropic.com>
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.

1 participant