Skip to content

Commit 83f01b7

Browse files
committed
remove .js stubs
1 parent deb8722 commit 83f01b7

5 files changed

Lines changed: 399 additions & 24 deletions

File tree

lang/js/src/main/scala/com/wavesplatform/lang/impl/Global.scala

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ import scala.scalajs.js.{Promise, UndefOr}
1111
@js.native
1212
@JSImport("@waves/ts-lib-crypto", JSImport.Namespace)
1313
private object TsLibCrypto extends js.Object {
14-
def verifySignature(publicKey: Uint8Array, message: Uint8Array, signature: Uint8Array): Boolean = js.native
15-
def rsaVerify(publicKey: Uint8Array, message: Uint8Array, signature: Uint8Array, digest: UndefOr[String]): Boolean = js.native
16-
def keccak(bytes: Uint8Array): Uint8Array = js.native
17-
def blake2b(bytes: Uint8Array): Uint8Array = js.native
18-
def sha256(bytes: Uint8Array): String = js.native
19-
def merkleVerify(rootHash: Uint8Array, merkleProof: Uint8Array, leafData: Uint8Array): Boolean = js.native
14+
def verifySignature(publicKey: Uint8Array, message: Uint8Array, signature: Uint8Array): Boolean = js.native
15+
def rsaVerify(publicKey: Uint8Array, message: Uint8Array, signature: Uint8Array, digest: UndefOr[String]): Boolean = js.native
16+
def keccak(bytes: Uint8Array): Uint8Array = js.native
17+
def blake2b(bytes: Uint8Array): Uint8Array = js.native
18+
def sha256(bytes: Uint8Array): String = js.native
19+
def merkleVerify(rootHash: Uint8Array, merkleProof: Uint8Array, leafData: Uint8Array): Boolean = js.native
2020
}
2121

2222
@js.native
@@ -34,7 +34,7 @@ object Global {
3434
val result = new Uint8Array(len)
3535
var i = 0
3636
while (i < len) {
37-
result(i) = (Integer.parseInt(hex.substring(i * 2, i * 2 + 2), 16) & 0xFF).toByte
37+
result(i) = (Integer.parseInt(hex.substring(i * 2, i * 2 + 2), 16) & 0xff).toByte
3838
i += 1
3939
}
4040
result.buffer

ride-js-bundle/index.d.ts

Lines changed: 340 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,340 @@
1+
export interface ICompilationResult {
2+
result: {
3+
ast: object
4+
base64: string
5+
bytes: Uint8Array
6+
size: number
7+
complexity: number
8+
verifierComplexity?: number
9+
callableComplexity?: Record<string, number>
10+
userFunctionsComplexity?: Record<string, number>
11+
}
12+
}
13+
14+
export interface ICompilationError {
15+
error: string
16+
}
17+
18+
export interface IDecompilationResult {
19+
result: string
20+
}
21+
22+
export interface IDecompilationError {
23+
error: any
24+
}
25+
26+
export type TType = TList | TStruct | TUnion | TPrimitive
27+
28+
export type TPrimitive = string;
29+
30+
export type TStructField = { name: string, type: TType };
31+
32+
export type TStruct = {
33+
typeName: string
34+
fields: TStructField[]
35+
};
36+
37+
export type TList = {
38+
'listOf': TType
39+
};
40+
41+
export type TUnionItem = TStruct | TPrimitive | TList
42+
export type TUnion = TUnionItem[]
43+
44+
export type TFunction = {
45+
name: string
46+
doc: string
47+
resultType: TType
48+
args: TFunctionArgument[]
49+
};
50+
51+
export type TFunctionArgument = {
52+
name: string
53+
type: TType
54+
doc: string
55+
};
56+
57+
export interface IVarDoc {
58+
name: string
59+
type: TType
60+
doc: string
61+
}
62+
63+
export interface IScriptInfo {
64+
stdLibVersion: number,
65+
contentType: number,
66+
scriptType: number
67+
imports: string[]
68+
}
69+
70+
export interface IFlattenedCompilationResult {
71+
ast?: object
72+
base64?: string
73+
bytes?: Uint8Array
74+
size?: number
75+
complexity?: number
76+
verifierComplexity?: number
77+
callableComplexities?: Record<string, number>
78+
userFunctionComplexities?: Record<string, number>
79+
error?: string
80+
}
81+
82+
export function compile(
83+
code: string,
84+
estimatorVersion?: number,
85+
needCompaction?: boolean,
86+
removeUnusedCode?: boolean,
87+
libraries?: Record<string, string>
88+
): ICompilationResult | ICompilationError;
89+
90+
export function flattenCompilationResult(compiled: ICompilationResult | ICompilationError): IFlattenedCompilationResult
91+
92+
export function parseAndCompile(
93+
code: string,
94+
estimatorVersion?: number,
95+
needCompaction?: boolean,
96+
removeUnusedCode?: boolean,
97+
libs?: Record<string, string>
98+
): IParseAndCompileResult | ICompilationError;
99+
100+
export function scriptInfo(code: string): IScriptInfo | ICompilationError;
101+
102+
export function getTypes(stdlibVersion?: number, isTokenContext?: boolean, isContract?: boolean): TStructField[];
103+
104+
export function getVarsDoc(stdlibVersion?: number, isTokenContext?: boolean, isContract?: boolean): IVarDoc[];
105+
106+
export function getFunctionsDoc(stdlibVersion?: number, isTokenContext?: boolean, isContract?: boolean): TFunction[];
107+
108+
export function decompile(compiledCode: string): IDecompilationResult | IDecompilationError;
109+
110+
export interface IReplOptions {
111+
nodeUrl: string
112+
chainId: string
113+
address: string
114+
}
115+
116+
export function repl(opts?: IReplOptions): {
117+
reconfigure: (opts: IReplOptions) => ReturnType<typeof repl>
118+
evaluate: (expr: string) => Promise<IDecompilationResult | IDecompilationError>,
119+
clear: () => void,
120+
test: (str: string) => Promise<string>,
121+
info: (s: string) => string,
122+
totalInfo: () => string,
123+
};
124+
125+
export const version: string;
126+
export const contractLimits: {
127+
MaxComplexityByVersion: (v: number) => number,
128+
MaxExprSizeInBytes: number,
129+
MaxContractSizeInBytes: number,
130+
MaxInvokeScriptArgs: number,
131+
MaxInvokeScriptSizeInBytes: number,
132+
MaxWriteSetSizeInBytes: number,
133+
MaxPaymentAmount: number,
134+
MaxAttachedPaymentAmount: number,
135+
MaxAssetVerifierComplexityByVersion: (v: number) => number,
136+
MaxAccountVerifierComplexityByVersion: (v: number) => number,
137+
MaxCallableComplexityByVersion: (v: number) => number,
138+
};
139+
140+
export interface IPos {
141+
posStart: number,
142+
posEnd: number
143+
}
144+
145+
export interface IName extends IPos {
146+
value: string,
147+
}
148+
149+
export interface IContext extends IPos {
150+
name: string
151+
}
152+
153+
154+
export interface IConstByteStr extends IExprNode {
155+
type: 'CONST_BYTESTR'
156+
}
157+
158+
export interface IConstLong extends IExprNode {
159+
type: 'CONST_LONG'
160+
}
161+
162+
export interface IConstStr extends IExprNode {
163+
type: 'CONST_STRING'
164+
}
165+
166+
export interface ITrue extends IExprNode {
167+
type: 'TRUE'
168+
}
169+
170+
export interface IFalse extends IExprNode {
171+
type: 'FALSE'
172+
}
173+
174+
export interface IRef extends IExprNode {
175+
type: 'REF'
176+
name: string
177+
}
178+
179+
export interface IBlock extends IExprNode {
180+
type: 'BLOCK'
181+
dec: TDecl
182+
body: TExpr
183+
}
184+
185+
186+
export interface IIf extends IExprNode {
187+
type: 'IF'
188+
cond: TExpr
189+
ifTrue: TExpr
190+
ifFalse: TExpr
191+
}
192+
193+
194+
export interface IGetter extends IExprNode {
195+
type: 'GETTER'
196+
ref: TExpr
197+
field: IName
198+
name: string
199+
}
200+
201+
export interface IMatch extends IExprNode {
202+
type: 'MATCH'
203+
expr: TExpr
204+
cases: IMatchCase[]
205+
}
206+
207+
//------------------------
208+
export interface IMatchCase extends INode {
209+
type: 'MATCH_CASE'
210+
expr: TExpr
211+
}
212+
213+
export interface ILet extends INode {
214+
type: 'LET'
215+
name: IName
216+
expr: TExpr
217+
dec?: TDecl
218+
}
219+
220+
export interface IScript extends Exclude<INode, 'resultType'> {
221+
type: 'SCRIPT'
222+
expr: TExpr
223+
}
224+
225+
export interface IDApp extends Exclude<INode, 'resultType'> {
226+
type: 'DAPP'
227+
decList: (ILet | IFunc)[]
228+
annFuncList: IAnnotatedFunc[]
229+
}
230+
231+
export interface IAnnotatedFunc extends Exclude<INode, 'resultType'> {
232+
type: 'ANNOTATEDFUNC',
233+
annList: IAnnotation[],
234+
func: IFunc
235+
}
236+
237+
export interface IAnnotation extends Exclude<INode, 'resultType'> {
238+
type: 'ANNOTATION',
239+
name: IName,
240+
argList: IName[]
241+
}
242+
243+
export interface IFunc extends INode {
244+
type: 'FUNC'
245+
name: IName
246+
expr: TExpr
247+
argList: TArgument[]
248+
body: IBlock | IFunctionCall
249+
}
250+
251+
export type TArgument = { argName: IName, type: TArgumentType }
252+
export type TArgumentType = { typeName: IName, typeParam?: ITypeParam }
253+
254+
export interface ITypeParam extends IPos {
255+
value: { isUnion: boolean, typeList: TArgumentType[] }
256+
}
257+
258+
export interface IFunctionCall extends IExprNode {
259+
type: 'FUNCTION_CALL'
260+
name: IName
261+
args: TExpr[]
262+
}
263+
264+
export interface INode extends IPos {
265+
type: TNodeType
266+
resultType: string
267+
ctx: IContext[]
268+
}
269+
270+
export type TExprResultType = { type: string } | { unionTypes: TExprResultType[] } | { listOf: TExprResultType }
271+
272+
export interface IExprNode extends Omit<INode, 'resultType'> {
273+
resultType: TExprResultType
274+
}
275+
276+
export interface IError extends IPos {
277+
msg: string
278+
}
279+
280+
export interface IParseAndCompileResult {
281+
result: ArrayBuffer
282+
complexity: number
283+
errorList: IError[]
284+
exprAst?: IScript
285+
dAppAst?: IDApp
286+
}
287+
288+
export type TPrimitiveNode = IConstStr | IConstLong | IConstByteStr | ITrue | IFalse
289+
290+
export type TNode =
291+
| IBlock
292+
| IConstByteStr
293+
| IIf
294+
| IFunctionCall
295+
| IConstLong
296+
| IRef
297+
| IConstStr
298+
| ITrue
299+
| IFalse
300+
| IGetter
301+
| IMatch
302+
| ILet
303+
| IMatchCase
304+
| IFunc
305+
| IScript
306+
| IDApp
307+
| IAnnotatedFunc
308+
| IAnnotation
309+
export type TNodeType =
310+
| 'BLOCK'
311+
| 'LET'
312+
| 'CONST_BYTESTR'
313+
| 'IF'
314+
| 'FUNCTION_CALL'
315+
| 'CONST_LONG'
316+
| 'REF'
317+
| 'CONST_STRING'
318+
| 'TRUE'
319+
| 'FALSE'
320+
| 'GETTER'
321+
| 'MATCH'
322+
| 'MATCH_CASE'
323+
| 'FUNC'
324+
| 'SCRIPT'
325+
| 'DAPP'
326+
| 'ANNOTATEDFUNC'
327+
| 'ANNOTATION'
328+
export type TDecl = ILet | IFunc
329+
export type TExpr =
330+
| IBlock
331+
| IConstByteStr
332+
| IIf
333+
| IFunctionCall
334+
| IConstLong
335+
| IConstStr
336+
| ITrue
337+
| IFalse
338+
| IGetter
339+
| IMatch
340+
| IRef

ride-js-bundle/package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@
33
"version": "0.1.0",
44
"description": "RIDE Compiler and REPL",
55
"type": "module",
6+
"main": "./dist/ride.js",
7+
"types": "./index.d.ts",
68
"exports": {
7-
"./lang": "./dist/lang.js",
8-
"./repl": "./dist/repl.js"
9+
".": "./dist/ride.js"
910
},
10-
"files": ["dist/"],
11+
"files": ["dist/", "index.d.ts"],
1112
"license": "MIT",
1213
"repository": {
1314
"type": "git",

0 commit comments

Comments
 (0)