0.1.6 • Published 2 days ago

@initia/builder.js v0.1.6

Weekly downloads
-
License
MIT
Repository
github
Last release
2 days ago

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)
}
0.1.6

2 days ago

0.1.3

5 months ago

0.1.0

7 months ago

0.1.1

7 months ago

0.0.9

8 months ago

0.0.8

9 months ago

0.0.7

12 months ago

0.0.6

12 months ago

0.0.5

12 months ago

0.0.4

12 months ago

0.0.3

12 months ago

0.0.2

12 months ago

0.0.1

12 months ago