Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docs work #194

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions documentation/pages/_meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"developer": "Developer",
"user": "User",
"node-operator": "Node Operator",
"move-registry": "Move Registry (beta)",
"dashboard": {
"title": "SuiNS Dashboard ↗",
"type": "page",
Expand Down
19 changes: 19 additions & 0 deletions documentation/pages/move-registry.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Move Registry

Move Registry is built to provide a name service for interacting / building with packages from the ecosystem. You could consider it the name service for packages.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Move Registry is built to provide a name service for interacting / building with packages from the ecosystem. You could consider it the name service for packages.
Move Registry provides a name service for interacting and building with packages from the ecosystem.


Move Registry is currently used for the following scenarios:

1. To reference packages and types in PTBs using their names.
2. To depend on other packages when developing with Move.

## Why use the Move Registry?

Move Registry provides a uniform (single source of truth) naming service for packages in the Move ecosystem.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably this should be in introduction as well.

This means that you can reference packages by their names, and the Move Registry will resolve the package address for you, despite the network*.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
This means that you can reference packages by their names, and the Move Registry will resolve the package address for you, despite the network*.
It allows to reference packages by their names, and the Move Registry will resolve the package address, despite the network.


Additionally, Move Registry helps with working with versioning of packages. You can call a specific version of a package easily, without having to
resolve the addresses yourself, or worry about the package being updated (name without a specified version defaults to the latest).
Comment on lines +15 to +16
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Additionally, Move Registry helps with working with versioning of packages. You can call a specific version of a package easily, without having to
resolve the addresses yourself, or worry about the package being updated (name without a specified version defaults to the latest).
Additionally, Move Registry helps with working with versioning of packages. Call a specific version of a package easily, without having to
resolve the addresses or worry about the package being updated. For example, name without a specified version defaults to the latest.



*Move Registry default service currently supports Mainnet and testnet.*
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
*Move Registry default service currently supports Mainnet and testnet.*
*Move Registry default service currently supports mainnet and testnet neworks.*

7 changes: 7 additions & 0 deletions documentation/pages/move-registry/_meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"design": "Design of the Move Registry",
"managing-package-info": "Managing Package Metadata",
"mvr-names": "Managing MVR Names",
"maintainer-practises": "Package Maintainer Best-Practices",
"tooling": "Tooling"
}
36 changes: 36 additions & 0 deletions documentation/pages/move-registry/design.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Design of the Move Registry

Before diving into specifics, we first need to analyze the design. The Move Registry consists of two independent components:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Before diving into specifics, we first need to analyze the design. The Move Registry consists of two independent components:
Before diving into specifics, let's understand its design. The Move Registry consists of two independent components:


1. Package Info registration: Exists independently on each network.
2. Move Registry: A single source of truth located on mainnet.

![High level design](/images/mvr/mvr-overall.svg)


## Package Info objects

The first step when publishing a package is to register its metadata object. This metadata object serves as a key source of information for:

1. Locating the source code across different versions of the package.
2. (Future) Providing text-based metadata (title, description, tags) for the package, which can be used in the MVR search engine.

This metadata object can be reused when authorizing any package upgrades to supply source information for the new version.
It is designed to be indexable by Sui Indexers, as it cannot be stored within another object.

![Package Info Objects](/images/mvr/mvr-package-info.svg)


## Move Registry

Move Registry registration is separate from the PackageInfo registration process. This separation is necessary because the PackageInfo object acts as both the source of truth for package metadata and a proof of package ownership, whereas the Move Registry is used to register applications that can be resolved using MVR tooling.

The steps to register a package are as follows:

1. Using your SuiNS name, register an application.
2. Based on the network, associate the application name with a `PackageInfo` object:
- **Mainnet**: Associate the application name with a complete PackageInfo object, which provides the full metadata and ownership proof.
- **Other Networks**: Associate the application name with only the PackageInfo object ID, acting as a pointer without ensuring a full mapping.


![Move Registry](/images/mvr/mvr-registry.svg)
10 changes: 10 additions & 0 deletions documentation/pages/move-registry/maintainer-practises.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Best Practises
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# Best Practises
# Best Practices

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this would really benefit from an example.


For package authors/maintainers, the following best practises are recommended when saving your source code to make sure
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
For package authors/maintainers, the following best practises are recommended when saving your source code to make sure
For package authors/maintainers, the following best practices are recommended when saving your source code to make sure

What do we mean by saving. your source code?

that your package is easily usable by other developers.

1. Whenever you publish/upgrade a package, you need to use the [Automated Address Management](https://docs.sui.io/concepts/sui-move-concepts/packages/automated-address-management)
2. It's recommended to switch your `Sui` dependency to the correct network you're publishing/upgrading against (e.g. `framework/testnet` for testnet, `framework/mainnet` for mainnet).
3. After properly configuring your Automated Address Management, you should commit your changes to your git repository.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this in Move.toml?

4. Make sure this commit is also tagged OR is part of your main branch. A good practise is tagging your releases with network/verson (e.g. `mainnet/v1`).
5. You can then use the commit SHA or the tag to update the source code origin in the `PackageInfo` object.
9 changes: 9 additions & 0 deletions documentation/pages/move-registry/managing-package-info.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Creating/Maintaining `PackageInfo` object

[
TODO!!!: Add sui client ptb commands to:
1. Create a `PackageInfo` object for your package.
2. Add the source code information to the `PackageInfo` object.


]
7 changes: 7 additions & 0 deletions documentation/pages/move-registry/mvr-names.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Managing MVR names

[TODO!!!: Add sui client ptb commands to:

1. Create a new MVR app by presenting a SuiNS name and a package name.
2. Linking a MVR app with a `PackageInfo` object.
]
6 changes: 6 additions & 0 deletions documentation/pages/move-registry/tooling.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Tooling

Two main tools have been developed using the Move Registry:

- A TypeScript SDK plugin for building PTBs with MVR names.
- An MVR CLI tool for Move development.
4 changes: 4 additions & 0 deletions documentation/pages/move-registry/tooling/_meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"typescript-sdk": "Typescript SDK Plugin",
"mvr-cli": "MVR CLI"
}
45 changes: 45 additions & 0 deletions documentation/pages/move-registry/tooling/mvr-cli.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import { Tabs } from 'nextra/components'
import { Callout } from 'nextra/components'

# MVR CLI

MVR CLI is used to manage your package dependencies and to interact with the Move Registry. It is a command-line tool that allows you to:

1. Add dependencies to your Move project.
2. Build your Move project with MVR dependencies.


## Installation

To install the MVR CLI, you can use the following command:

```bash
TODO: add installation command
```
stefan-mysten marked this conversation as resolved.
Show resolved Hide resolved
Comment on lines +16 to +18
Copy link
Contributor

@stefan-mysten stefan-mysten Nov 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Download the correct binary file according to your OS and architecture from GitHub release page:
https://github.com/MystenLabs/mvr/releases/latest

After downloading the file, rename the binary to mvr and put it on your PATH. Below are examples on how to do it on three popular shells:

For Zsh

  1. Open the zshrc file
nano ~/.zshrc
  1. Add this line at the end, replacing /path/to/your/folder with the actual folder path to the binary:
 export PATH="/path/to/your/folder:$PATH"
  1. Save the file and source it to apply changes:
source ~/.zshrc

For bash

  1. Open your .bashrc file (or .bash_profile on macOS):
nano ~/.bashrc
  1. Add this line at the end, replacing /path/to/your/folder with the actual folder path to the binary:
 export PATH="/path/to/your/folder:$PATH"
  1. Save the file and source it to apply changes:
source ~/.bashrc

For fish

  1. Open your Fish configuration file:
nano ~/.config/fish/config.fish
  1. Add this line, replacing /path/to/your/folder with your desired path:
set -Ux fish_user_paths /path/to/your/folder $fish_user_paths
  1. Fish automatically loads this file, so you don’t need to manually source it.

Now you can call mvr --help.


## Adding dependencies

To add a dependency to your move code, you can use the `mvr add` command. This command will add the dependency to your `Move.toml` file.

```bash
mvr add <package_name> --network <mainnet|testnet>
```

Using this, a new entry will be added to your `Move.toml` file.

```toml
[dependencies]
...
app = { r.mvr = "@mvr/app" }

[r.mvr]
network = "mainnet"
```

## Building against MVR dependencies

You can use `sui move build` as usual, and the MVR CLI will be automatically invoked to resolve dependencies and build your project.

```bash
sui move build
```
86 changes: 86 additions & 0 deletions documentation/pages/move-registry/tooling/typescript-sdk.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
import { Tabs } from 'nextra/components'
import { Callout } from 'nextra/components'

# Typescript SDK plugin

The purpose of the MVR TypeScript SDK plugin is to offer developers a seamless experience when building PTBs with MVR names.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry about my noob question but what is an SDK plugin?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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


## How to use

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

[TODO: Add the public good endpoints]

```typescript
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
<Callout type="warning" emoji="ℹ️">
The examples in the tabs are simplified for clarity. Actual addresses or names may differ.
</Callout>


<Tabs items={['Before MVR', 'After MVR']}>
<Tabs.Tab>
Example of a PTB before MVR:
```typescript
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>`
]
});
```
</Tabs.Tab>
<Tabs.Tab>
Example of a PTB after MVR, consistent across networks:

```typescript
const transaction = new Transaction();

// Now we can use `@suifrens/core` across all package upgrades for type reference.
// And we also have the guarantee to call the latest version of the accessories package.
transaction.moveCall({
target: `@suifrens/accessories::accessories::equip`,
arguments: [..],
typeArguments: [
`@suifrens/core::suifren::SuiFren<@suifrens/core::bullshark::Bullshark>`
]
})
```
</Tabs.Tab>
</Tabs>
10 changes: 10 additions & 0 deletions documentation/public/images/mvr/mvr-overall.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions documentation/public/images/mvr/mvr-package-info.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions documentation/public/images/mvr/mvr-registry.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.