@waves/ride-js
Advanced tools
Comparing version 2.2.0-beta.2 to 2.2.0-beta.3
{ | ||
"name": "@waves/ride-js", | ||
"version": "2.2.0-beta.2", | ||
"version": "2.2.0-beta.3", | ||
"description": "Js compiler for Ride - Waves smart contract language.", | ||
@@ -9,3 +9,3 @@ "main": "src/index.js", | ||
"build": "./node_modules/.bin/webpack --config webpack.config.js", | ||
"test": "echo \"Error: no test specified\" && exit 1", | ||
"test": "mocha", | ||
"prepublishOnly": "npm run build", | ||
@@ -12,0 +12,0 @@ "getNewCompiler": "sh scripts/getNewCompiler.sh" |
@@ -11,6 +11,14 @@ # Ride-js | ||
sbt langJS/fullOptJS | ||
sbt replJS/fullOptJS | ||
``` | ||
* From `waves` project copy ```./lang/js/target/lang-opt.js``` to ```./src``` of `ride-js` | ||
* From `waves` project copy ```./repl/js/target/repl-opt.js``` to ```./src``` of `ride-js` | ||
# Workaround | ||
If there is error with compiling try | ||
```sbt | ||
sbt clean && sbt lang/clean | ||
``` | ||
### Tasks | ||
* `npm run build` builds minified version that can be included as script tag. Add RideJS variable to global scope | ||
* `npm run build` builds minified version that can be included as script tag. Add RideJS variable to global scope |
@@ -1,2 +0,2 @@ | ||
export interface ICompilationResult { | ||
export interface ICompilationResult { | ||
result: { | ||
@@ -11,2 +11,3 @@ ast: object | ||
userFunctionsComplexity?: Record<string, number> | ||
stateCallsComplexities?: Record<string, number> | ||
} | ||
@@ -67,3 +68,3 @@ } | ||
contentType: number, | ||
scriptType: number | ||
scriptType: number, | ||
imports: string[] | ||
@@ -84,8 +85,20 @@ } | ||
export function compile(code: string, estimatorVersion?: number, libraries?: Record<string, string>): ICompilationResult | ICompilationError; | ||
export function compile( | ||
code: string, | ||
estimatorVersion?: number, | ||
needCompaction?: boolean, | ||
removeUnusedCode?: boolean, | ||
libraries?: Record<string, string> | ||
): ICompilationResult | ICompilationError; | ||
export function parseAndCompile( | ||
code: string, | ||
estimatorVersion?: number, | ||
needCompaction?: boolean, | ||
removeUnusedCode?: boolean, | ||
libraries?: Record<string, string> | ||
): IParseAndCompileResult | ICompilationError; | ||
export function flattenCompilationResult(compiled: ICompilationResult | ICompilationError): IFlattenedCompilationResult | ||
export function parseAndCompile(code: string, estimatorVersion?: number): IParseAndCompileResult | ICompilationError; | ||
export function scriptInfo(code: string): IScriptInfo | ICompilationError; | ||
@@ -214,3 +227,3 @@ | ||
decList: (ILet | IFunc)[] | ||
annFuncList: IAnnotatedFunc[] | ||
annFuncList: IAnnotatedFunc//todo fix | ||
} | ||
@@ -226,2 +239,4 @@ | ||
type: 'ANNOTATION', | ||
posStart: 80, | ||
posEnd: 143, | ||
name: IName, | ||
@@ -235,13 +250,8 @@ argList: IName[] | ||
expr: TExpr | ||
argList: TArgument[] | ||
body: IBlock | IFunctionCall | ||
argList: TArgument[], | ||
} | ||
export type TArgument = { argName: IName, type: TArgumentType } | ||
export type TArgumentType = { typeName: IName, typeParam?: ITypeParam } | ||
export type TArgument = { argName: IName, typeList: TArgumentType[] } | ||
export type TArgumentType = { typeName: IName, typeParam?: any } | ||
export interface ITypeParam extends IPos { | ||
value: {isUnion: boolean, typeList: TArgumentType[]} | ||
} | ||
export interface IFunctionCall extends IExprNode { | ||
@@ -248,0 +258,0 @@ type: 'FUNCTION_CALL' |
require('./interop'); | ||
const crypto = require('@waves/ts-lib-crypto'); | ||
const scalaJsCompiler = require('./lang-opt.js'); | ||
const replJs = require('./repl-opt.js'); | ||
function wrappedCompile(code, estimatorVersion = 2) { | ||
function wrappedCompile(code, estimatorVersion = 3, needCompaction = false, removeUnusedCode = false, libraries = {}) { | ||
if (typeof code !== 'string') { | ||
@@ -12,3 +13,3 @@ return { | ||
try { | ||
const result = scalaJsCompiler.compile(code, estimatorVersion); | ||
const result = scalaJsCompiler.compile(code, estimatorVersion, needCompaction, removeUnusedCode, libraries); | ||
if (result.error) { | ||
@@ -22,3 +23,3 @@ try { | ||
const bytes = new Uint8Array(result.result); | ||
const {ast, complexity, verifierComplexity, callableComplexities, userFunctionComplexities, globalVariableComplexities} = result; | ||
const {ast, complexity, verifierComplexity, callableComplexities, userFunctionComplexities, globalVariableComplexities, stateCallsComplexities} = result; | ||
return { | ||
@@ -34,3 +35,4 @@ result: { | ||
userFunctionComplexities, | ||
globalVariableComplexities | ||
globalVariableComplexities, | ||
stateCallsComplexities | ||
} | ||
@@ -49,4 +51,4 @@ } | ||
const repl = (opts != null) | ||
? scalaJsCompiler.repl(new scalaJsCompiler.NodeConnectionSettings(opts.nodeUrl, opts.chainId.charCodeAt(0), opts.address)) | ||
: scalaJsCompiler.repl(); | ||
? replJs.repl(new replJs.NodeConnectionSettings(opts.nodeUrl, opts.chainId.charCodeAt(0), opts.address)) | ||
: replJs.repl(); | ||
@@ -56,3 +58,3 @@ const wrapReconfigure = (repl) => { | ||
return (opts) => { | ||
const settings = new scalaJsCompiler.NodeConnectionSettings(opts.nodeUrl, opts.chainId.charCodeAt(0), opts.address); | ||
const settings = new replJs.NodeConnectionSettings(opts.nodeUrl, opts.chainId.charCodeAt(0), opts.address); | ||
const newRepl = reconfigureFn(settings); | ||
@@ -59,0 +61,0 @@ newRepl.reconfigure = wrapReconfigure(newRepl); |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No tests
QualityPackage does not have any tests. This is a strong signal of a poorly maintained or low quality package.
Found 1 instance in 1 package
6592937
9
27112
1
24