|
| 1 | +# mvr-static |
| 2 | + |
| 3 | +The mvr-static tool is a typescript CLI tool to generate a static file for Move Registry (mvr) |
| 4 | +resolution. This can be used to cache all MVR names for performance & security reasons, and used in |
| 5 | +the `NamedPackagesPlugin` (exported from `@mysten/sui`) in your project. |
| 6 | + |
| 7 | +## Usage |
| 8 | + |
| 9 | +### Generate a static file for MVR resolution |
| 10 | + |
| 11 | +You can generate your static file by running the following command: |
| 12 | + |
| 13 | +```bash |
| 14 | +pnpm dlx @mysten/mvr-static |
| 15 | +``` |
| 16 | + |
| 17 | +Available options: |
| 18 | + |
| 19 | +- `--directory <directory>`: The directory to run the command in (defaults to `.`) |
| 20 | +- `--output <file-name>`: The output's file name (defaults to `mvr.ts`) |
| 21 | +- `--depth <depth>`: The depth of recursive search for MVR names (defaults to `10`) |
| 22 | +- `--url-mainnet <url>`: The URL to the mainnet MVR (defaults to |
| 23 | + `https://mainnet.mvr.mystenlabs.com`) |
| 24 | +- `--url-testnet <url>`: The URL to the testnet MVR (defaults to |
| 25 | + `https://testnet.mvr.mystenlabs.com`) |
| 26 | +- `--include <dir_patterns>`: The directory patterns to include in the search (defaults to |
| 27 | + `**/*.{js,ts,jsx,tsx,mjs,cjs}`) |
| 28 | +- `--exclude <dir_patterns>`: The directory patterns to exclude in the search (defaults to |
| 29 | + `'node_modules/**', '**/.*'`) |
| 30 | +- `--force`: Force overwrite the existing MVR file (useful in CI) (defaults to `false`) |
| 31 | + |
| 32 | +### Use the static file in your project |
| 33 | + |
| 34 | +Once you have your static file, you can use it in your project by importing it and passing it to the |
| 35 | +`NamedPackagesPlugin` in your project. |
| 36 | + |
| 37 | +```ts |
| 38 | +import { NamedPackagesPlugin } from '@mysten/sui/src/transactions'; |
| 39 | + |
| 40 | +import { getMvrCache } from './mvr.ts'; |
| 41 | + |
| 42 | +// create a cache for your network. |
| 43 | +const cache = getMvrCache('mainnet'); |
| 44 | + |
| 45 | +const plugin = new NamedPackagesPlugin({ |
| 46 | + // ..., |
| 47 | + overrides: cache, |
| 48 | +}); |
| 49 | +``` |
0 commit comments