Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@initia/builder.js

Package Overview
Dependencies
Maintainers
5
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@initia/builder.js

The JavaScript Move Builder for Initia

  • 0.1.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
5
Weekly downloads
 
Created
Source

initia builder.js

This SDK is a Javascript wrapper for Initia Move Compiler using ffi-napi library.

How to install

$ npm install @initia/builder.js

How to use

Build Move Package

import { MoveBuilder } from '@initia/builder.js';

async function buildExample() {
    // recommend to use full package path, not relative path
    // ex) path.resolve(__dirname, "../relative_path")
    const builder = new MoveBuilder(/* path to move package */, {});

    // execute move compiler via ffi
    await builder.build();
    
    // load compiled module bytes as `Buffer`
    const compiledModuleBytes = await builder.get(/* module name */);
    console.info(compiledModuleBytes.toString('hex'));

    // change module name to what you want
    const nameConvertedModuleBytes = await MoveBuilder.convert_module_name(compiledModuleBytes, /* new module name */);
    console.info(nameConvertedModuleBytes.toString('hex'));
}

Create and Clean Move Package

import { MoveBuilder } from '@initia/builder.js';

async function createAndCleanExample() {
    // recommend to use full package path, not relative path
    // ex) path.resolve(__dirname, "../relative_path")
    const builder = new MoveBuilder(/* path to move package */, {});

    // create new move package
    await builder.new(/* package name */);
    
    await builder.build();
    
    // clean /build directory
    await builder.clean();
}

Read Move Package

import { MoveBuilder } from '@initia/builder.js';

async function readExample() {
    const builder = new MoveBuilder(/* path to move package */, {});

    const binary = await builder.get(/* module name */);

    // read module bytes
    const moduleInfo = await MoveBuilder.read_module_info(binary)
    console.log(moduleInfo)

    // decode module bytes
    const decodedModule = await MoveBuilder.decode_module_bytes(binary);
    console.log(decodedModule)
}

Keywords

FAQs

Package last updated on 11 Oct 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc