Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@initia/builder.js",
"version": "0.2.9",
"version": "0.2.10",
"description": "The JavaScript Move Builder for Initia",
"license": "MIT",
"author": "Initia Foundation",
Expand Down
25 changes: 22 additions & 3 deletions src/builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ import {

type ModuleName = string

const DEFAULT_BYTECODE_VERSION = 6
const DEFAULT_LANGUAGE_VERSION = '2'
const DEFAULT_COMPILER_VERSION = '2'
export class MoveBuilder {
private readonly packagePath: string
private buildOptions: BuildOptions
Expand All @@ -32,6 +35,19 @@ export class MoveBuilder {
this.buildOptions = buildOptions
}

/**
* Get default value of a Movebuiler
* - version of bytecode
* - version of move compiler
* - version of move language version
*/
static getDefaultVersions() {
return {
bytecodeVersion: DEFAULT_BYTECODE_VERSION,
compilerVersion: DEFAULT_COMPILER_VERSION,
languageVersion: DEFAULT_LANGUAGE_VERSION,
}
}
/**
* Create raw build configuration.
* @returns Raw build configuration.
Expand Down Expand Up @@ -62,9 +78,12 @@ export class MoveBuilder {
fetch_deps_only: this.buildOptions.fetchDepsOnly || false,
skip_fetch_latest_git_deps:
this.buildOptions.skipFetchLatestGitDeps || false,
bytecode_version: this.buildOptions.bytecodeVersion || 0,
compiler_version: this.buildOptions.compilerVersion || '0',
language_version: this.buildOptions.languageVersion || '0',
bytecode_version:
this.buildOptions.bytecodeVersion || DEFAULT_BYTECODE_VERSION,
compiler_version:
this.buildOptions.compilerVersion || DEFAULT_COMPILER_VERSION,
language_version:
this.buildOptions.languageVersion || DEFAULT_LANGUAGE_VERSION,
additional_named_addresses: additionalNamedAddresses,
},
})
Expand Down
8 changes: 8 additions & 0 deletions test/build.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@ describe('build move package', () => {
)
jest.setTimeout(200000)

it('get default values of move builder', () => {
expect(MoveBuilder.getDefaultVersions()).toEqual({
bytecodeVersion: 6,
compilerVersion: '2',
languageVersion: '2',
})
})

it('builds the package correctly', async () => {
const buildResult = await builder.build()
const expectedBinary = await readFile(dummyModulePath)
Expand Down