Managing Package Metadata
👀
This is a developer preview of the Move Registry. It is experimental and therefore provides no guarantees of uptime or correctness. Use at your own risk.

Creating/Maintaining PackageInfo object

⚠️

These examples assume that you use the MVR plugin for the Sui Typescript SDK, as described in the Typescript SDK section.

Creating a new PackageInfo object

You should create a PackageInfo object for your package when you first deploy it, once for each network. You can then treat the object as the source of truth for metadata of your package.

The following example works for both Mainnet and Testnet.

const transaction = new Transaction();
// ... (other code, could also include a `transaction.publish()` 
// call to publish & register in one step.)
 
/// We pass in our UpgradeCap 
const packageInfo = transaction.moveCall({
    target: `@mvr/metadata::package_info::new`,
    arguments: [transaction.object('<Your UpgradeCap (by value or object id)>')],
});
 
// We also need to create the visual representation of our "info" object.
// You can also call `@mvr/metadata::display::new` instead, 
// that allows customizing the colors of your metadata object!
const display = transaction.moveCall({
    target: `@mvr/metadata::display::default`,
    arguments: [
        transaction.pure.string('<Add a name to easily identify your package. This is not your MVR name.>')
    ],
});
 
// Set that display object to our info object.
transaction.moveCall({
    target: `@mvr/metadata::package_info::set_display`,
    arguments: [transaction.object(packageInfo), display],
});
 
 
// transfer the `PackageInfo` object to a safe address. 
transaction.moveCall({
    target: `@mvr/metadata::package_info::transfer`,
    arguments: [transaction.object(packageInfo), transaction.pure.address('<Your safe address>')],
});
 
// .. you can do any other actions, like setting the source code info, in the same PTB.

Adding source code information

You can add source code information on your PackageInfo object using the following setup.

To update the source for a version, first call @mvr/metadata::package_info::unset_git_versioning to remove the existing information.

const transaction = new Transaction();
// adding source code info:
 
// 1. Create our `GitInfo` object.
const git = transaction.moveCall({
    target: `@mvr/metadata::git::new`,
    arguments: [
        transaction.pure.string('<Your git repository, e.g. `https://github.com/mystenlabs/mvr`>'),
        transaction.pure.string('<Your git subdirectory, e.g. `packages/mvr`>'),
        transaction.pure.string('<Your git commit hash or tag, e.g. `636d22d6bc4195afec9a1c0a8563b61fc813acfc`>'),
    ],
});
 
transaction.moveCall({
    target: `@mvr/metadata::package_info::set_git_versioning`,
    arguments: [
        transaction.object(`<Your PackageInfo object>`),
        transaction.pure.u64(`<The version number for the given source code (e.g. 1)>`),
        git,
    ],
});

Removing or updating source code information

const transaction = new Transaction();
 
transaction.moveCall({
    target: `@mvr/metadata::package_info::unset_git_versioning`,
    arguments: [
        transaction.object(`<Your PackageInfo object>`),
        transaction.pure.u64(`<The version number for the given source code (e.g. 1)>`),
    ],
});
// .. you could then follow the previous steps to add the new source code info for that version.

Tranferring the PackageInfo object

You can transfer the PackageInfo object to another address (or object) by the following setup. If you want to build custom access control for your object, you can utilize a transfer to object workflow (see Transfer to Object (opens in a new tab) on the Sui documentation site for more information).

PackageInfo does not allow public transfers, to ensure that the object is always indexable (wrapping could hurt the discoverability of the object).

const transaction = new Transaction();
 
// transfer the `PackageInfo` object to a safe address. 
transaction.moveCall({
    target: `@mvr/metadata::package_info::transfer`,
    arguments: [transaction.object(packageInfo), transaction.pure.address('<Your safe address>')],
});