Skip to content

Commit 239d5c7

Browse files
committed
feat: get default versions
1 parent 3577bc7 commit 239d5c7

File tree

4 files changed

+32
-5
lines changed

4 files changed

+32
-5
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@initia/builder.js",
3-
"version": "0.2.9",
3+
"version": "0.2.10",
44
"description": "The JavaScript Move Builder for Initia",
55
"license": "MIT",
66
"author": "Initia Foundation",

src/builder.ts

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ import {
1818

1919
type ModuleName = string
2020

21+
const DEFAULT_BYTECODE_VERSION = 6
22+
const DEFAULT_LANGUAGE_VERSION = '1'
23+
const DEFAULT_COMPILER_VERSION = '1'
2124
export class MoveBuilder {
2225
private readonly packagePath: string
2326
private buildOptions: BuildOptions
@@ -32,6 +35,19 @@ export class MoveBuilder {
3235
this.buildOptions = buildOptions
3336
}
3437

38+
/**
39+
* Get default value of a Movebuiler
40+
* - version of bytecode
41+
* - version of move compiler
42+
* - version of move language version
43+
*/
44+
static getDefaultValues() {
45+
return {
46+
bytecodeVersion: DEFAULT_BYTECODE_VERSION,
47+
compilerVersion: DEFAULT_COMPILER_VERSION,
48+
languageVersion: DEFAULT_LANGUAGE_VERSION,
49+
}
50+
}
3551
/**
3652
* Create raw build configuration.
3753
* @returns Raw build configuration.
@@ -62,9 +78,12 @@ export class MoveBuilder {
6278
fetch_deps_only: this.buildOptions.fetchDepsOnly || false,
6379
skip_fetch_latest_git_deps:
6480
this.buildOptions.skipFetchLatestGitDeps || false,
65-
bytecode_version: this.buildOptions.bytecodeVersion || 0,
66-
compiler_version: this.buildOptions.compilerVersion || '0',
67-
language_version: this.buildOptions.languageVersion || '0',
81+
bytecode_version:
82+
this.buildOptions.bytecodeVersion || DEFAULT_BYTECODE_VERSION,
83+
compiler_version:
84+
this.buildOptions.compilerVersion || DEFAULT_COMPILER_VERSION,
85+
language_version:
86+
this.buildOptions.languageVersion || DEFAULT_LANGUAGE_VERSION,
6887
additional_named_addresses: additionalNamedAddresses,
6988
},
7089
})

test/build.spec.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,14 @@ describe('build move package', () => {
2323
)
2424
jest.setTimeout(200000)
2525

26+
it('get default values of move builder', () => {
27+
expect(MoveBuilder.getDefaultValues()).toEqual({
28+
bytecodeVersion: 6,
29+
compilerVersion: '1',
30+
languageVersion: '1',
31+
})
32+
})
33+
2634
it('builds the package correctly', async () => {
2735
const buildResult = await builder.build()
2836
const expectedBinary = await readFile(dummyModulePath)

test/script.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ describe('build script and decode', () => {
1313
it('decodes script bytes', async () => {
1414
const bytePath = path.resolve(
1515
__dirname,
16-
'contract/script/build/script/bytecode_scripts/even_0.mv'
16+
'contract/script/build/script/bytecode_scripts/even.mv'
1717
)
1818
const binary = await readFile(bytePath)
1919
const decodedScript = await MoveBuilder.decodeScriptBytes(binary)

0 commit comments

Comments
 (0)