sui-ts-transpiler-advanced

raw JSON →
1.0.0 verified Fri May 01 auth: no javascript

A CLI tool and SDK (v1.0.0) that converts TypeScript smart contracts to Sui Move language with full logic preservation, not just structural mapping. Released as an initial stable version, it offers commands for project init, transpilation, and build. Key differentiators include support for classes, type mappings (string→vector<u8>, number→u64, bigint→u256), and programmatic usage via import. Suitable for developers working with Sui blockchain who prefer TypeScript over Move.

error Error [ERR_REQUIRE_ESM]: require() of ES Module /path/to/node_modules/sui-ts-transpiler-advanced/index.js from /path/to/file.js not supported.
cause Package is ESM-only; CommonJS require() is not supported.
fix
Convert your file to ES module (use 'type': 'module' in package.json) or use dynamic import() instead.
error SyntaxError: Cannot use import statement outside a module
cause The import statement is used in a CommonJS file.
fix
Add 'type': 'module' to your package.json or rename file to .mjs.
error TypeError: Class constructor SuiMoveTranspiler cannot be invoked without 'new'
cause SuiMoveTranspiler must be instantiated with the new keyword; it is not a factory function.
fix
Use 'new SuiMoveTranspiler(options)' instead of calling it as a function.
breaking Requires Node >=16.0.0; lower versions will fail to load the package.
fix Upgrade Node.js to version 16+.
breaking ESM-only package; attempting require() will throw ERR_REQUIRE_ESM.
fix Use import syntax or dynamic import() instead of require().
deprecated The --verbose flag is deprecated in favor of environment variable DEBUG=sui-ts-transpiler.
fix Use DEBUG=sui-ts-transpiler sui-ts transpile instead of -v/--verbose.
gotcha TypeScript private fields are not transpiled to Move private fields; Move uses module-level visibility.
fix All class fields become public struct fields in Move; adjust security assumptions.
npm install sui-ts-transpiler-advanced
yarn add sui-ts-transpiler-advanced
pnpm add sui-ts-transpiler-advanced

Programmatic usage of sui-ts-transpiler-advanced to transpile a TypeScript class to Sui Move

import { SuiMoveTranspiler } from 'sui-ts-transpiler-advanced';

const transpiler = new SuiMoveTranspiler({
  outputDir: 'build',
  moduleName: 'my_contract',
  packageName: 'my_package'
});

const tsCode = `
class Token {
  private name: string;
  private supply: number;
  
  constructor(name: string, supply: number) {
    this.name = name;
    this.supply = supply;
  }
}
`;

const result = transpiler.transpile(tsCode);

if (result.success) {
  console.log('Generated Move code:', result.moveCode);
} else {
  console.error('Errors:', result.errors);
}