Typescript SDK Plugin

Typescript SDK plugin

The purpose of the MVR TypeScript SDK plugin is to offer developers a seamless experience when building PTBs with MVR names. This plugin resolves MVR names to their respective addresses before constructing the PTB, caching the results during each runtime.

This also applies to type names, which have traditionally been harder to refer to, especially across package upgrades.

How to use

The MVR plugin is exported directly from the @mysten/sui package. To enable the plugin, simply register it (either globally or per PTB) in your dApp.

[TODO: Add the public good endpoints]

import { namedPackagesPlugin, Transaction } from "@mysten/sui/transactions";
 
/** Register the MVR plugin globally (once) for our PTB construction */
Transaction.registerGlobalSerializationPlugin('namedPackagesPlugin', namedPackagesPlugin({
    suiGraphQLClient: new SuiGraphQLClient({
        url: `<a graphql endpoint with mvr enabled>`
    }),
    // You can also define overrides for packages and types optionally.
    // The following example shows how to override the sui@framework package to resolve 0x1.
    // Attention: Types need to be strictly defined in the overrides.
    overrides: {
        packages: { 'sui@framework': '0x2' },
        types: {}
    }
}));

Before / after example

ℹ️

The examples in the tabs are simplified for clarity. Actual addresses or names may differ.

Example of a PTB before MVR:

const transaction = new Transaction();
 
// testnet
// Notice how the suifren type has a V1 outer package id, and a V2 inner type package id,
// even if they are part of the same package upgrades.
transaction.moveCall({
    target: `0xe177697e191327901637f8d2c5ffbbde8b1aaac27ec1024c4b62d1ebd1cd7430::accessories::equip`,
    arguments: [..],
    typeArguments: [
        `0x80d7de9c4a56194087e0ba0bf59492aa8e6a5ee881606226930827085ddf2332::suifren::SuiFren<0x297d8afb6ede450529d347cf9254caeea2b685c8baef67b084122291ebaefb38::bullshark::Bullshark>`
    ]
});
 
// mainnet
transaction.moveCall({
    target: `0x54800ebb4606fd0c03b4554976264373b3374eeb3fd63e7ff69f31cac786ba8c::accessories::equip`,
    arguments: [..],
    typeArguments: [
        `0xee496a0cc04d06a345982ba6697c90c619020de9e274408c7819f787ff66e1a1::suifren::SuiFren<0x8894fa02fc6f36cbc485ae9145d05f247a78e220814fb8419ab261bd81f08f32::bullshark::Bullshark>`
    ]
});