Skip to content

feat(sbt): make metadata base URI admin-configurable - #129

Open
moon-code12 wants to merge 2 commits into
Kalebtron1:mainfrom
moon-code12:feat/configurable-sbt-metadata-uri
Open

moon-code12 wants to merge 2 commits into
Kalebtron1:mainfrom
moon-code12:feat/configurable-sbt-metadata-uri

Conversation

@moon-code12

Copy link
Copy Markdown

Summary

Makes SBT metadata project-owned and admin-configurable.

  • Added DataKey::MetadataBaseUri (instance storage, appended at the end of the enum).
  • init writes the project-owned default base URI.
  • token_uri now builds <base><tier>.json from the stored base URI.
  • Added set_metadata_base_uri(admin, base_uri) with the same admin auth/check pattern as mint and revoke.
  • Added get_metadata_base_uri() for clients and operators.
  • Legacy instances without the key fall back to the default, so the upgrade needs no migration call.
  • Added the missing metadata/bronce.json and updated all tier metadata image URLs to this project's public/images assets.
  • Documented the upgrade/setter flow in docs/contracts/migration.md.

Closes #103

Before / after

Before

token_uri matched the tier against hardcoded URLs under
https://raw.githubusercontent.com/YORCH12/Stellar-Hack-vinculo-credito/main/metadata/.
The project's own metadata/ and public/images/ assets were unused.

After

  • Fresh deployments store https://raw.githubusercontent.com/Kalebtron1/Project-Vyn/main/metadata/ as the default.
  • token_uri returns:
    • tier 0/other -> <base>bronce.json
    • tier 1 -> <base>plata.json
    • tier 2 -> <base>oro.json
    • tier 3 -> <base>diamante.json
    • tier 4 -> <base>platino.json
  • The admin can change the base at any time:
    stellar contract invoke \
      --id $SBT_CONTRACT_ID \
      --source $ADMIN_SECRET \
      --network $NETWORK \
      -- set_metadata_base_uri \
      --admin $ADMIN_PUBLIC \
      --base_uri "https://cdn.example.com/vyn/metadata/"
  • Base URI validation: non-empty, at most 512 bytes, and must end with /.
  • Only the saved admin can call the setter; the auth/check pattern mirrors mint and revoke.

Metadata files

  • Added metadata/bronce.json (the contract already returned a bronce URL but the file was missing).
  • Updated image in metadata/{plata,oro,diamante,platino}.json to
    https://raw.githubusercontent.com/Kalebtron1/Project-Vyn/main/public/images/<tier>.png.
  • src/stellar/nft-metadata.json now records metadata_base_uri and each level's metadata_file.

Validation

cargo test
running 5 tests
test tests::defaults_to_project_metadata_for_every_tier ... ok
test tests::admin_can_update_metadata_base_uri ... ok
test tests::non_admin_cannot_update_metadata_base_uri ... ok
test tests::invalid_base_uris_are_rejected ... ok
test tests::token_uri_falls_back_to_default_before_init ... ok

test result: ok. 5 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
cargo build --release --target wasm32-unknown-unknown

Build succeeds; vinculo_sbt.wasm is 18,409 bytes.

URI checks (HTTP 200):

https://raw.githubusercontent.com/Kalebtron1/Project-Vyn/main/metadata/plata.json
https://raw.githubusercontent.com/Kalebtron1/Project-Vyn/main/metadata/oro.json
https://raw.githubusercontent.com/Kalebtron1/Project-Vyn/main/metadata/diamante.json
https://raw.githubusercontent.com/Kalebtron1/Project-Vyn/main/metadata/platino.json
https://raw.githubusercontent.com/Kalebtron1/Project-Vyn/main/public/images/{bronce,plata,oro,diamante,platino}.png

metadata/bronce.json is newly added by this PR, so its URL will resolve after merge.

Migration / upgrade

docs/contracts/migration.md now documents that the new key is additive and that
upgraded instances fall back to the default until the admin calls the setter. No
storage migration is required.

@drips-wave

drips-wave Bot commented Oct 20, 2026

Copy link
Copy Markdown

@moon-code12 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@vercel

vercel Bot commented Oct 20, 2026

Copy link
Copy Markdown

@moon-code12 is attempting to deploy a commit to the alankcr1-6443's projects Team on Vercel.

A member of the Team first needs to authorize it.

Sync with main (docs overhaul, supabase keep-alive). Reword the metadata
base URI migration note to match main's warning that the deployed contracts
cannot be upgraded in place: init sets the default URI, and instances
without the key still fall back to it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@moon-code12

Copy link
Copy Markdown
Author

I merged the latest main into this branch (no conflicts) and reworded the migration note so it matches main's warning that the contracts can't be upgraded in place. The checks that are still red come from repo settings, not from this change:

Locally, cargo fmt --check and cargo clippy --all-targets -- -D warnings pass, and cargo build --release --target wasm32-unknown-unknown passes for all three contracts.

Could a maintainer approve the workflow run and authorize the Vercel deployment?

This branch has not been deployed

No deployments
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.

Make SBT metadata URIs configurable by the admin

1 participant