0.3.2 • Published 3 days ago

@massalabs/as-transformer v0.3.2

Weekly downloads
-
License
ISC
Repository
-
Last release
3 days ago

as-transformer

An AssemblyScript transformer helper module.

Installation

This module can be installed using GitPkg that makes subfolders of repos directly usable with npm or yarn.

To install this module, run the following command at your project root directory :

npm install -D 'https://gitpkg.now.sh/massalabs/as/transformer?main'

Usage

Transform ts files

file2base64

Transformations

This transformer loads the given file, encodes it in base64 and then replace the call to file2base64 by the encoded content.

Example:

export function main(_args: string): i32 {
    const bytes = fileToBase64('./build/sc.wasm'); // will read `build/sc.wasm`, will encode it in base64 and then put the result in a string used to initialize `bytes`.
    const sc_addr = create_sc(bytes);
    call(sc_addr, "advance", "", 0);
    generate_event("gol SC deployed at addr: " + sc_addr);
    return 0;
}
Usage

You can use this transformer by adding --transform transformer/file2base64.js to your asc command.

For instance, to compile assembly/my_sc.ts with this transformer you will execute:

yarn asc --transform transformer/file2base64.js assembly/my_sc.ts --target release --exportRuntime -o build/my_sc.wasm

Transformer extenders

Replacer

This extender simplify how you can write a code replacer. Have a look at as-tester/check_replacer.js to see usage.

0.3.0

9 months ago

0.3.2

6 months ago

0.3.1

6 months ago

0.2.1

11 months ago

0.2.0

12 months ago

0.1.0

1 year ago

0.1.2

1 year ago

0.1.1

1 year ago

0.0.2-dev.0

2 years ago