-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathindex.ts
45 lines (40 loc) · 1.74 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// IMPORTS
// ================================================================================================
import { StarkOptions, Logger } from '@guildofweavers/genstark';
import { AirSchema, compile as compileAirAssembly } from '@guildofweavers/air-assembly';
import { compile as compileScript } from '@guildofweavers/air-script';
import { Stark } from './lib/Stark';
import { Logger as ConsoleLogger, noopLogger } from './lib/utils';
// RE-EXPORTS
// ================================================================================================
export { Stark } from './lib/Stark';
export { inline } from './lib/utils';
export { MerkleTree, createHash } from '@guildofweavers/merkle';
export { createPrimeField } from '@guildofweavers/galois';
// PUBLIC FUNCTIONS
// ================================================================================================
export function instantiate(source: AirSchema | Buffer | string, component: string, options?: Partial<StarkOptions>, logger?: Logger): Stark {
if (logger === null) {
logger = noopLogger;
}
else if (logger === undefined) {
logger = new ConsoleLogger();
}
if (source instanceof AirSchema) {
return new Stark(source, component, options, logger);
}
else {
const schema = compileAirAssembly(source as any);
return new Stark(schema, component, options, logger);
}
}
export function instantiateScript(source: Buffer | string, options?: Partial<StarkOptions>, logger?: Logger): Stark {
if (logger === null) {
logger = noopLogger;
}
else if (logger === undefined) {
logger = new ConsoleLogger();
}
const schema = compileScript(source as any);
return instantiate(schema, 'default', options, logger);
}