@helios-lang/contract-utils 0.1.41 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/examples/multi-validator/contract.js +11 -7
- package/examples/multi-validator/index.d.ts +19 -9
- package/examples/multi-validator/index.js +38 -14
- package/examples/multi-validator/package-lock.json +79 -5
- package/examples/multi-validator/package.json +1 -0
- package/package.json +2 -2
- package/src/cast/Cast.js +57 -13
- package/src/cast/PermissiveType.js +15 -3
- package/src/cast/StrictType.js +15 -3
- package/src/cast/index.js +19 -2
- package/src/codegen/LoadedModule.js +9 -1
- package/src/codegen/LoadedScriptsWriter.js +90 -31
- package/src/codegen/LoadedValidator.js +28 -4
- package/src/context/ContractContext.js +54 -23
- package/src/context/ContractContextBuilder.js +109 -21
- package/src/context/DagCompiler.js +18 -7
- package/src/index.js +1 -11
- package/types/cast/Cast.d.ts +42 -4
- package/types/cast/Cast.d.ts.map +1 -1
- package/types/cast/PermissiveType.d.ts +3 -2
- package/types/cast/PermissiveType.d.ts.map +1 -1
- package/types/cast/StrictType.d.ts +3 -2
- package/types/cast/StrictType.d.ts.map +1 -1
- package/types/cast/index.d.ts +6 -2
- package/types/cast/index.d.ts.map +1 -1
- package/types/codegen/LoadedModule.d.ts +6 -1
- package/types/codegen/LoadedModule.d.ts.map +1 -1
- package/types/codegen/LoadedScriptsWriter.d.ts +13 -0
- package/types/codegen/LoadedScriptsWriter.d.ts.map +1 -1
- package/types/codegen/LoadedValidator.d.ts +19 -5
- package/types/codegen/LoadedValidator.d.ts.map +1 -1
- package/types/context/ContractContext.d.ts +28 -11
- package/types/context/ContractContext.d.ts.map +1 -1
- package/types/context/ContractContextBuilder.d.ts +58 -19
- package/types/context/ContractContextBuilder.d.ts.map +1 -1
- package/types/context/DagCompiler.d.ts +17 -7
- package/types/context/DagCompiler.d.ts.map +1 -1
- package/types/index.d.ts +1 -3
- package/types/index.d.ts.map +1 -1
package/types/cast/Cast.d.ts
CHANGED
|
@@ -1,21 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @template TStrict
|
|
3
|
+
* @template TPermissive
|
|
4
|
+
* @param {CastLike<TStrict, TPermissive>} cast
|
|
5
|
+
* @param {CastConfig} config
|
|
6
|
+
* @returns {Cast<TStrict, TPermissive>}
|
|
7
|
+
*/
|
|
8
|
+
export function configureCast<TStrict, TPermissive>(cast: CastLike<TStrict, TPermissive>, config: CastConfig): Cast<TStrict, TPermissive>;
|
|
1
9
|
/**
|
|
2
10
|
* @typedef {import("@helios-lang/uplc").UplcData} UplcData
|
|
3
11
|
* @typedef {import("../codegen/index.js").TypeSchema} TypeSchema
|
|
4
12
|
*/
|
|
5
13
|
/**
|
|
6
|
-
* @
|
|
7
|
-
*
|
|
14
|
+
* @typedef {{
|
|
15
|
+
* isMainnet: boolean
|
|
16
|
+
* }} CastConfig
|
|
17
|
+
*/
|
|
18
|
+
/**
|
|
19
|
+
* @template TStrict
|
|
20
|
+
* @template TPermissive
|
|
21
|
+
* @typedef {(config: CastConfig) => Cast<TStrict, TPermissive>} ConfigurableCast
|
|
8
22
|
*/
|
|
9
|
-
|
|
23
|
+
/**
|
|
24
|
+
* StrictType and PermissiveType work for both Cast and ConfigurableCast
|
|
25
|
+
* @template TStrict
|
|
26
|
+
* @template TPermissive
|
|
27
|
+
* @typedef {Cast<TStrict, TPermissive> | ConfigurableCast<TStrict, TPermissive>} CastLike
|
|
28
|
+
*/
|
|
29
|
+
/**
|
|
30
|
+
* @template TStrict
|
|
31
|
+
* @template TPermissive
|
|
32
|
+
*/
|
|
33
|
+
export class Cast<TStrict, TPermissive> {
|
|
10
34
|
/**
|
|
11
35
|
* @param {TypeSchema} schema
|
|
36
|
+
* @param {CastConfig} config
|
|
12
37
|
*/
|
|
13
|
-
constructor(schema: TypeSchema);
|
|
38
|
+
constructor(schema: TypeSchema, config: CastConfig);
|
|
14
39
|
/**
|
|
15
40
|
* @readonly
|
|
16
41
|
* @type {TypeSchema}
|
|
17
42
|
*/
|
|
18
43
|
readonly schema: TypeSchema;
|
|
44
|
+
/**
|
|
45
|
+
* @readonly
|
|
46
|
+
* @type {CastConfig}
|
|
47
|
+
*/
|
|
48
|
+
readonly config: CastConfig;
|
|
19
49
|
/**
|
|
20
50
|
* @param {UplcData} data
|
|
21
51
|
* @returns {TStrict}
|
|
@@ -29,4 +59,12 @@ export class Cast<TStrict = any, TPermissive = any> {
|
|
|
29
59
|
}
|
|
30
60
|
export type UplcData = import("@helios-lang/uplc").UplcData;
|
|
31
61
|
export type TypeSchema = import("../codegen/index.js").TypeSchema;
|
|
62
|
+
export type CastConfig = {
|
|
63
|
+
isMainnet: boolean;
|
|
64
|
+
};
|
|
65
|
+
export type ConfigurableCast<TStrict, TPermissive> = (config: CastConfig) => Cast<TStrict, TPermissive>;
|
|
66
|
+
/**
|
|
67
|
+
* StrictType and PermissiveType work for both Cast and ConfigurableCast
|
|
68
|
+
*/
|
|
69
|
+
export type CastLike<TStrict, TPermissive> = Cast<TStrict, TPermissive> | ConfigurableCast<TStrict, TPermissive>;
|
|
32
70
|
//# sourceMappingURL=Cast.d.ts.map
|
package/types/cast/Cast.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Cast.d.ts","sourceRoot":"","sources":["../../src/cast/Cast.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Cast.d.ts","sourceRoot":"","sources":["../../src/cast/Cast.js"],"names":[],"mappings":"AAwWA;;;;;;GAMG;AACH,kGAHW,UAAU,8BASpB;AAnVD;;;GAGG;AAEH;;;;GAIG;AAEH;;;;GAIG;AAEH;;;;;GAKG;AAEH;;;GAGG;AACH;IAaI;;;OAGG;IACH,oBAHW,UAAU,UACV,UAAU,EAKpB;IAnBD;;;OAGG;IACH,iBAFU,UAAU,CAEd;IAEN;;;OAGG;IACH,iBAFU,UAAU,CAEd;IAWN;;;OAGG;IACH,mBAHW,QAAQ,GACN,OAAO,CAInB;IAED;;;OAGG;IACH,cAHW,WAAW,GACT,QAAQ,CAIpB;CACJ;uBAhEY,OAAO,mBAAmB,EAAE,QAAQ;yBACpC,OAAO,qBAAqB,EAAE,UAAU;yBAIxC;IACZ,SAAa,EAAE,OAAO,CAAA;CACnB;8DAMkB,UAAU,KAAK,KAAK,OAAO,EAAE,WAAW,CAAC;;;;6CAOlD,KAAK,OAAO,EAAE,WAAW,CAAC,GAAG,iBAAiB,OAAO,EAAE,WAAW,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
export type
|
|
2
|
-
|
|
1
|
+
export type ConfigurableCast<TStrict, TPermissive> = import("./Cast.js").ConfigurableCast<TStrict, TPermissive>;
|
|
2
|
+
export type CastLike<TStrict, TPermissive> = import("./Cast.js").CastLike<TStrict, TPermissive>;
|
|
3
|
+
export type PermissiveType<C extends CastLike<any, any>> = C extends CastLike<any, infer TPermissive> ? TPermissive : never;
|
|
3
4
|
//# sourceMappingURL=PermissiveType.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PermissiveType.d.ts","sourceRoot":"","sources":["../../src/cast/PermissiveType.js"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"PermissiveType.d.ts","sourceRoot":"","sources":["../../src/cast/PermissiveType.js"],"names":[],"mappings":"qDAKa,OAAO,WAAW,EAAE,gBAAgB,CAAC,OAAO,EAAE,WAAW,CAAC;6CAM1D,OAAO,WAAW,EAAE,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
export type
|
|
2
|
-
|
|
1
|
+
export type ConfigurableCast<TStrict, TPermissive> = import("./Cast.js").ConfigurableCast<TStrict, TPermissive>;
|
|
2
|
+
export type CastLike<TStrict, TPermissive> = import("./Cast.js").CastLike<TStrict, TPermissive>;
|
|
3
|
+
export type StrictType<C extends CastLike<any, any>> = C extends CastLike<infer TStrict, any> ? TStrict : never;
|
|
3
4
|
//# sourceMappingURL=StrictType.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StrictType.d.ts","sourceRoot":"","sources":["../../src/cast/StrictType.js"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"StrictType.d.ts","sourceRoot":"","sources":["../../src/cast/StrictType.js"],"names":[],"mappings":"qDAKa,OAAO,WAAW,EAAE,gBAAgB,CAAC,OAAO,EAAE,WAAW,CAAC;6CAM1D,OAAO,WAAW,EAAE,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC"}
|
package/types/cast/index.d.ts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
export { Cast };
|
|
2
|
-
export
|
|
3
|
-
export type
|
|
2
|
+
export { configureCast } from "./Cast.js";
|
|
3
|
+
export type CastConfig = import("./Cast.js").CastConfig;
|
|
4
|
+
export type ConfigurableCast<TStrict, TPermissive> = import("./Cast.js").ConfigurableCast<TStrict, TPermissive>;
|
|
5
|
+
export type CastLike<TStrict, TPermissive> = import("./Cast.js").CastLike<TStrict, TPermissive>;
|
|
6
|
+
export type PermissiveType<C extends CastLike<any, any>> = import("./PermissiveType.js").PermissiveType<C>;
|
|
7
|
+
export type StrictType<C extends CastLike<any, any>> = import("./StrictType.js").StrictType<C>;
|
|
4
8
|
import { Cast } from "./Cast.js";
|
|
5
9
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cast/index.js"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cast/index.js"],"names":[],"mappings":";;yBAKa,OAAO,WAAW,EAAE,UAAU;qDAM9B,OAAO,WAAW,EAAE,gBAAgB,CAAC,OAAO,EAAE,WAAW,CAAC;6CAM1D,OAAO,WAAW,EAAE,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC;2DAKlD,OAAO,qBAAqB,EAAE,cAAc,CAAC,CAAC,CAAC;uDAK/C,OAAO,iBAAiB,EAAE,UAAU,CAAC,CAAC,CAAC;qBA3B/B,WAAW"}
|
|
@@ -1,6 +1,11 @@
|
|
|
1
|
+
export type CastLike<TStrict, TPermissive> = import("../cast/Cast.js").CastLike<TStrict, TPermissive>;
|
|
1
2
|
export type LoadedModule = {
|
|
2
3
|
$name: string;
|
|
4
|
+
$purpose: "module";
|
|
3
5
|
$sourceCode: string;
|
|
4
|
-
$dependencies: LoadedModule
|
|
6
|
+
$dependencies: ReadonlyArray<LoadedModule>;
|
|
7
|
+
$types: {
|
|
8
|
+
[name: string]: CastLike<any, any>;
|
|
9
|
+
};
|
|
5
10
|
};
|
|
6
11
|
//# sourceMappingURL=LoadedModule.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LoadedModule.d.ts","sourceRoot":"","sources":["../../src/codegen/LoadedModule.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"LoadedModule.d.ts","sourceRoot":"","sources":["../../src/codegen/LoadedModule.js"],"names":[],"mappings":"6CAKa,OAAO,iBAAiB,EAAE,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC;;WAKzD,MAAM;cACH,QAAQ;iBACL,MAAM;mBACJ,cAAc,YAAY,CAAC"}
|
|
@@ -37,6 +37,19 @@ export class LoadedScriptsWriter {
|
|
|
37
37
|
* @returns {LoadedScriptsWriter}
|
|
38
38
|
*/
|
|
39
39
|
private write;
|
|
40
|
+
/**
|
|
41
|
+
* @param {string} path
|
|
42
|
+
* @param {string} typeName
|
|
43
|
+
* @param {string[]} typeParams
|
|
44
|
+
* @returns {LoadedScriptsWriter}
|
|
45
|
+
*/
|
|
46
|
+
writeImportType(path: string, typeName: string, typeParams?: string[]): LoadedScriptsWriter;
|
|
47
|
+
/**
|
|
48
|
+
* @param {string} path
|
|
49
|
+
* @param {string[]} objectNames
|
|
50
|
+
* @returns {LoadedScriptsWriter}
|
|
51
|
+
*/
|
|
52
|
+
writeImport(path: string, ...objectNames: string[]): LoadedScriptsWriter;
|
|
40
53
|
/**
|
|
41
54
|
* @private
|
|
42
55
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LoadedScriptsWriter.d.ts","sourceRoot":"","sources":["../../src/codegen/LoadedScriptsWriter.js"],"names":[],"mappings":"AAGA;;;;GAIG;AAEH;IAUI;;;OAGG;IACH,gBAFa,mBAAmB,CAQ/B;IAfG,yBAAoC;IACpC,0BAAqC;IACrC,uBAAkC;IAetC;;;OAGG;IACH;;QAFa,mBAAmB,CAgC/B;IAED;;;OAGG;IACH;;QAFa,mBAAmB,CAkC/B;IAED;;OAEG;IACH,YAFa,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAQpC;IAED;;;;;OAKG;IACH,cAKC;IAED;;OAEG;IACH,
|
|
1
|
+
{"version":3,"file":"LoadedScriptsWriter.d.ts","sourceRoot":"","sources":["../../src/codegen/LoadedScriptsWriter.js"],"names":[],"mappings":"AAGA;;;;GAIG;AAEH;IAUI;;;OAGG;IACH,gBAFa,mBAAmB,CAQ/B;IAfG,yBAAoC;IACpC,0BAAqC;IACrC,uBAAkC;IAetC;;;OAGG;IACH;;QAFa,mBAAmB,CAgC/B;IAED;;;OAGG;IACH;;QAFa,mBAAmB,CAkC/B;IAED;;OAEG;IACH,YAFa,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAQpC;IAED;;;;;OAKG;IACH,cAKC;IAED;;;;;OAKG;IACH,sBALW,MAAM,YACN,MAAM,eACN,MAAM,EAAE,GACN,mBAAmB,CAmB/B;IAED;;;;OAIG;IACH,kBAJW,MAAM,kBACN,MAAM,EAAE,GACN,mBAAmB,CAQ/B;IAED;;OAEG;IACH,qBA6BC;IAED;;;OAGG;IACH,kBAFW,OAAO,MAAM,EAAE,UAAU,CAAC,QAyBpC;IAED;;;OAGG;IACH,oBA4BC;IAED;;;OAGG;IACH,uBAgDC;CACJ;gCAzTY,OAAO,wBAAwB,EAAE,iBAAiB;mCAClD,OAAO,2BAA2B,EAAE,oBAAoB;yBACxD,OAAO,iBAAiB,EAAE,UAAU;6BANpB,0BAA0B"}
|
|
@@ -1,16 +1,30 @@
|
|
|
1
|
+
export type CastLike<TStrict, TPermissive> = import("../cast/Cast.js").CastLike<TStrict, TPermissive>;
|
|
1
2
|
export type LoadedModule = import("./LoadedModule.js").LoadedModule;
|
|
2
3
|
export type LoadedValidator = {
|
|
3
4
|
$name: string;
|
|
4
5
|
$sourceCode: string;
|
|
5
|
-
$dependencies: LoadedModule
|
|
6
|
-
$hashDependencies: LoadedValidator
|
|
6
|
+
$dependencies: ReadonlyArray<LoadedModule>;
|
|
7
|
+
$hashDependencies: ReadonlyArray<LoadedValidator>;
|
|
7
8
|
$dependsOnOwnHash: boolean;
|
|
8
|
-
$
|
|
9
|
+
$types: {
|
|
10
|
+
[name: string]: CastLike<any, any>;
|
|
11
|
+
};
|
|
12
|
+
$Redeemer: CastLike<any, any>;
|
|
9
13
|
} & ({
|
|
10
14
|
$purpose: "spending";
|
|
11
|
-
$Datum:
|
|
15
|
+
$Datum: CastLike<any, any>;
|
|
12
16
|
} | {
|
|
13
17
|
$purpose: "minting" | "certifying" | "rewarding" | "staking";
|
|
14
18
|
});
|
|
15
|
-
|
|
19
|
+
export type NamedDependencyToObject<N extends {
|
|
20
|
+
$name: string;
|
|
21
|
+
}> = { [name in N["$name"]]: Extract<N, {
|
|
22
|
+
$name: name;
|
|
23
|
+
}>; };
|
|
24
|
+
export type NamedDependenciesToObject<N extends readonly {
|
|
25
|
+
$name: string;
|
|
26
|
+
}[]> = { [name in (N extends readonly (infer M)[] ? M : never)["$name"]]: Extract<N extends readonly (infer M)[] ? M : never, {
|
|
27
|
+
$name: name;
|
|
28
|
+
}>; };
|
|
29
|
+
export type ExtractDependencies<V extends LoadedValidator> = NamedDependenciesToObject<V["$dependencies"]>;
|
|
16
30
|
//# sourceMappingURL=LoadedValidator.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LoadedValidator.d.ts","sourceRoot":"","sources":["../../src/codegen/LoadedValidator.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"LoadedValidator.d.ts","sourceRoot":"","sources":["../../src/codegen/LoadedValidator.js"],"names":[],"mappings":"6CAKa,OAAO,iBAAiB,EAAE,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC;2BAIxD,OAAO,mBAAmB,EAAE,YAAY;;WAKzC,MAAM;iBACA,MAAM;mBACJ,cAAc,YAAY,CAAC;uBACvB,cAAc,eAAe,CAAC;uBAC9B,OAAO;;;;eAEf,SAAS,GAAG,EAAE,GAAG,CAAC;;cAGjB,UAAU;YACZ,SAAS,GAAG,EAAE,GAAG,CAAC;;cAEhB,SAAS,GAAG,YAAY,GAAG,WAAW,GAAG,SAAS;;;WAM7C,MAAM;;;;;WAOQ,MAAM;;;;6DAM7B,0BAA0B,CAAC,CAAC,eAAe,CAAC,CAAC"}
|
|
@@ -1,23 +1,40 @@
|
|
|
1
|
+
export type LoadedModule = import("../codegen/index.js").LoadedModule;
|
|
1
2
|
export type LoadedValidator = import("../codegen/index.js").LoadedValidator;
|
|
2
3
|
export type MintingContext<TRedeemerStrict, TRedeemerPermissive> = import("@helios-lang/ledger").MintingContext<TRedeemerStrict, TRedeemerPermissive>;
|
|
3
4
|
export type SpendingContext<TDatumStrict, TDatumPermissive, TRedeemerStrict, TRedeemerPermissive> = import("@helios-lang/ledger").SpendingContext<TDatumStrict, TDatumPermissive, TRedeemerStrict, TRedeemerPermissive>;
|
|
4
5
|
export type StakingContext<TRedeemerStrict, TRedeemerPermissive> = import("@helios-lang/ledger").StakingContext<TRedeemerStrict, TRedeemerPermissive>;
|
|
5
|
-
export type
|
|
6
|
-
export type
|
|
7
|
-
export type
|
|
8
|
-
export type
|
|
6
|
+
export type CastLike<TStrict, TPermissive> = import("../cast/index.js").CastLike<TStrict, TPermissive>;
|
|
7
|
+
export type PermissiveType<C extends CastLike<any, any>> = import("../cast/index.js").PermissiveType<C>;
|
|
8
|
+
export type StrictType<C extends CastLike<any, any>> = import("../cast/index.js").StrictType<C>;
|
|
9
|
+
export type AnyContractValidatorContext = (ValidatorHash<SpendingContext<any, any, any, any>> | MintingPolicyHash<MintingContext<any, any>> | StakingValidatorHash<StakingContext<any, any>>);
|
|
10
|
+
export type ContractValidatorContexts<V extends import("../codegen/LoadedValidator.js").LoadedValidator> = V extends {
|
|
9
11
|
"$purpose": "spending";
|
|
10
|
-
"$Datum":
|
|
11
|
-
|
|
12
|
+
"$Datum": CastLike<any, any>;
|
|
13
|
+
"$Redeemer": CastLike<any, any>;
|
|
14
|
+
} ? {
|
|
15
|
+
$hash: ValidatorHash<SpendingContext<V["$Datum"], PermissiveType<V["$Datum"]>, StrictType<V["$Redeemer"]>, PermissiveType<V["$Redeemer"]>>>;
|
|
16
|
+
} & ContractTypesContext<V["$types"]> : V extends {
|
|
12
17
|
"$purpose": "minting";
|
|
13
|
-
|
|
18
|
+
"$Redeemer": CastLike<any, any>;
|
|
19
|
+
} ? {
|
|
20
|
+
$hash: MintingPolicyHash<MintingContext<StrictType<V["$Redeemer"]>, PermissiveType<V["$Redeemer"]>>>;
|
|
21
|
+
} & ContractTypesContext<V["$types"]> : V extends {
|
|
14
22
|
"$purpose": ("certifying" | "rewarding" | "staking");
|
|
15
|
-
|
|
16
|
-
|
|
23
|
+
"$Redeemer": CastLike<any, any>;
|
|
24
|
+
} ? {
|
|
25
|
+
$hash: StakingValidatorHash<StakingContext<StrictType<V["$Redeemer"]>, PermissiveType<V["$Redeemer"]>>>;
|
|
26
|
+
} & ContractTypesContext<V["$types"]> : never;
|
|
27
|
+
export type ContractModuleContexts<V extends import("../codegen/LoadedModule.js").LoadedModule> = ContractTypesContext<V["$types"]>;
|
|
28
|
+
export type ContractTypesContext<T extends {
|
|
29
|
+
[typeName: string]: CastLike<any, any>;
|
|
30
|
+
}> = { [K in keyof T]: Cast<import("../cast/StrictType.js").StrictType<T[K]>, import("../cast/PermissiveType.js").PermissiveType<T[K]>>; };
|
|
31
|
+
export type ContractContext<Vs extends {
|
|
17
32
|
[name: string]: import("../codegen/LoadedValidator.js").LoadedValidator;
|
|
18
|
-
}
|
|
19
|
-
|
|
33
|
+
}, Ms extends {
|
|
34
|
+
[name: string]: import("../codegen/LoadedModule.js").LoadedModule;
|
|
35
|
+
}> = { [K in keyof Vs]: ContractValidatorContexts<Vs[K]>; } & { [K_1 in keyof Ms]: ContractTypesContext<Ms[K_1]["$types"]>; };
|
|
20
36
|
import { ValidatorHash } from "@helios-lang/ledger";
|
|
21
37
|
import { MintingPolicyHash } from "@helios-lang/ledger";
|
|
22
38
|
import { StakingValidatorHash } from "@helios-lang/ledger";
|
|
39
|
+
import { Cast } from "../cast/index.js";
|
|
23
40
|
//# sourceMappingURL=ContractContext.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContractContext.d.ts","sourceRoot":"","sources":["../../src/context/ContractContext.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ContractContext.d.ts","sourceRoot":"","sources":["../../src/context/ContractContext.js"],"names":[],"mappings":"2BAQa,OAAO,qBAAqB,EAAE,YAAY;8BAC1C,OAAO,qBAAqB,EAAE,eAAe;mEAM7C,OAAO,qBAAqB,EAAE,cAAc,CAAC,eAAe,EAAE,mBAAmB,CAAC;oGAQlF,OAAO,qBAAqB,EAAE,eAAe,CAAC,YAAY,EAAE,gBAAgB,EAAE,eAAe,EAAE,mBAAmB,CAAC;mEAMnH,OAAO,qBAAqB,EAAE,cAAc,CAAC,eAAe,EAAE,mBAAmB,CAAC;6CAMlF,OAAO,kBAAkB,EAAE,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC;2DAKzD,OAAO,kBAAkB,EAAE,cAAc,CAAC,CAAC,CAAC;uDAK5C,OAAO,kBAAkB,EAAE,UAAU,CAAC,CAAC,CAAC;0CAIxC,CACZ,cAAkB,gBAAgB,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,GACtD,kBAAsB,eAAe,GAAG,EAAE,GAAG,CAAC,CAAC,GAC/C,qBAAyB,eAAe,GAAG,EAAE,GAAG,CAAC,CAAC,CAC/C;2GAKS,CAAC,SAAS;IAAC,UAAU,EAAE,UAAU,CAAC;IAAC,QAAQ,EAAE,SAAS,GAAG,EAAE,GAAG,CAAC,CAAC;IAAC,WAAW,EAAE,SAAS,GAAG,EAAE,GAAG,CAAC,CAAA;CAAC,GAAG;IAChH,KAAa,EAAE,cACf,gBACA,CAAa,CAAC,QAAQ,CAAC,EACvB,eAA2B,CAAC,CAAC,QAAQ,CAAC,CAAC,EACvC,WAAuB,CAAC,CAAC,WAAW,CAAC,CAAC,EACtC,eAA2B,CAAC,CAAC,WAAW,CAAC,CAAC,CAC/B,CACF,CAAA;CACF,GAAG,qBAAqB,CAAC,CAAC,QAAQ,CAAC,CAAC,GAC3C,CAAO,SAAS;IAAC,UAAU,EAAE,SAAS,CAAC;IAAC,WAAW,EAAE,SAAS,GAAG,EAAE,GAAG,CAAC,CAAA;CAAC,GAAG;IAC3E,KAAa,EAAE,kBACf,eACA,WAAuB,CAAC,CAAC,WAAW,CAAC,CAAC,EACtC,eAA2B,CAAC,CAAC,WAAW,CAAC,CAAC,CAC/B,CACF,CAAA;CACF,GAAG,qBAAqB,CAAC,CAAC,QAAQ,CAAC,CAAC,GAC3C,CAAO,SAAS;IAAC,UAAU,EAAE,CAAC,YAAY,GAAG,WAAW,GAAG,SAAS,CAAC,CAAC;IAAC,WAAW,EAAE,SAAS,GAAG,EAAE,GAAG,CAAC,CAAA;CAAC,GAAG;IAC1G,KAAa,EAAE,qBACf,eACA,WAAuB,CAAC,CAAC,WAAW,CAAC,CAAC,EACtC,eAA2B,CAAC,CAAC,WAAW,CAAC,CAAC,CAC/B,CACF,CAAA;CACF,GAAG,qBAAqB,CAAC,CAAC,QAAQ,CAAC,CAAC,GAC3C,KAAW;kGAMC,qBAAqB,CAAC,CAAC,QAAQ,CAAC,CAAC;;;;;;;;;8BAtFvC,qBAAqB;kCAArB,qBAAqB;qCAArB,qBAAqB;qBACP,kBAAkB"}
|
|
@@ -1,53 +1,92 @@
|
|
|
1
1
|
/**
|
|
2
|
+
* @typedef {import("../cast/index.js").CastConfig} CastConfig
|
|
2
3
|
* @typedef {import("../codegen/LoadedModule.js").LoadedModule} LoadedModule
|
|
3
4
|
* @typedef {import("../codegen/LoadedValidator.js").LoadedValidator} LoadedValidator
|
|
4
5
|
* @typedef {import("../compiler/index.js").CompilerLib} CompilerLib
|
|
5
6
|
*/
|
|
6
7
|
/**
|
|
7
|
-
* @template {
|
|
8
|
-
* @typedef {import("
|
|
8
|
+
* @template {LoadedValidator} V
|
|
9
|
+
* @typedef {import("../codegen/LoadedValidator.js").ExtractDependencies<V>} ExtractDependencies
|
|
9
10
|
*/
|
|
10
11
|
/**
|
|
11
|
-
* @template {{[name: string]: LoadedValidator}}
|
|
12
|
+
* @template {{[name: string]: LoadedValidator}} Vs
|
|
13
|
+
* @template {{[name: string]: LoadedModule}} Ms
|
|
14
|
+
* @typedef {import("./ContractContext.js").ContractContext<Vs, Ms>} ContractContext
|
|
12
15
|
*/
|
|
13
|
-
|
|
16
|
+
/**
|
|
17
|
+
* @typedef {{
|
|
18
|
+
* isMainnet: boolean
|
|
19
|
+
* expectedHashes?: {[name: string]: string}
|
|
20
|
+
* }} ContractContextBuildProps
|
|
21
|
+
*/
|
|
22
|
+
/**
|
|
23
|
+
* @template {{[name: string]: LoadedValidator}} Vs
|
|
24
|
+
* @template {{[name: string]: LoadedModule}} Ms
|
|
25
|
+
*/
|
|
26
|
+
export class ContractContextBuilder<Vs extends {
|
|
14
27
|
[name: string]: import("./DagCompiler.js").LoadedValidator;
|
|
28
|
+
}, Ms extends {
|
|
29
|
+
[name: string]: import("./ContractContext.js").LoadedModule;
|
|
15
30
|
}> {
|
|
16
31
|
/**
|
|
17
|
-
* @returns {ContractContextBuilder<{}>}
|
|
32
|
+
* @returns {ContractContextBuilder<{}, {}>}
|
|
18
33
|
*/
|
|
19
|
-
static "new"(): ContractContextBuilder<{}>;
|
|
34
|
+
static "new"(): ContractContextBuilder<{}, {}>;
|
|
20
35
|
/**
|
|
21
36
|
* @private
|
|
22
|
-
* @param {
|
|
37
|
+
* @param {Vs} validators
|
|
38
|
+
* @param {Ms} modules
|
|
23
39
|
*/
|
|
24
40
|
private constructor();
|
|
25
41
|
/**
|
|
26
42
|
* @private
|
|
27
43
|
* @readonly
|
|
28
|
-
* @type {
|
|
44
|
+
* @type {Vs}
|
|
29
45
|
*/
|
|
30
46
|
private readonly validators;
|
|
47
|
+
/**
|
|
48
|
+
* @readonly
|
|
49
|
+
* @type {Ms}
|
|
50
|
+
*/
|
|
51
|
+
readonly modules: Ms;
|
|
31
52
|
/**
|
|
32
53
|
* @template {LoadedValidator} V
|
|
33
54
|
* @param {V} validator
|
|
34
|
-
* @returns {ContractContextBuilder<
|
|
35
|
-
* [K in V["$name"]]: V
|
|
36
|
-
*
|
|
55
|
+
* @returns {ContractContextBuilder<
|
|
56
|
+
* Vs & {[K in V["$name"]]: V},
|
|
57
|
+
* Ms & ExtractDependencies<V>
|
|
58
|
+
* >}
|
|
37
59
|
*/
|
|
38
|
-
with<V extends import("./DagCompiler.js").LoadedValidator>(validator: V): ContractContextBuilder<
|
|
60
|
+
with<V extends import("./DagCompiler.js").LoadedValidator>(validator: V): ContractContextBuilder<Vs & { [K in V["$name"]]: V; }, Ms & ExtractDependencies<V>>;
|
|
39
61
|
/**
|
|
40
|
-
* @
|
|
41
|
-
* @
|
|
62
|
+
* @template {LoadedModule} M
|
|
63
|
+
* @param {M} m
|
|
64
|
+
* @returns {ContractContextBuilder<
|
|
65
|
+
* Vs,
|
|
66
|
+
* Ms & {[K in M["$name"]]: M}
|
|
67
|
+
* >}
|
|
42
68
|
*/
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
69
|
+
withModule<M extends import("./ContractContext.js").LoadedModule>(m: M): ContractContextBuilder<Vs, Ms & { [K_1 in M["$name"]]: M; }>;
|
|
70
|
+
/**
|
|
71
|
+
* @param {ContractContextBuildProps} props
|
|
72
|
+
* @returns {ContractContext<Vs, Ms>}
|
|
73
|
+
*/
|
|
74
|
+
build(props: ContractContextBuildProps): ContractContext<Vs, Ms>;
|
|
46
75
|
}
|
|
76
|
+
export type CastConfig = import("../cast/index.js").CastConfig;
|
|
47
77
|
export type LoadedModule = import("../codegen/LoadedModule.js").LoadedModule;
|
|
48
78
|
export type LoadedValidator = import("../codegen/LoadedValidator.js").LoadedValidator;
|
|
49
79
|
export type CompilerLib = import("../compiler/index.js").CompilerLib;
|
|
50
|
-
export type
|
|
80
|
+
export type ExtractDependencies<V extends import("./DagCompiler.js").LoadedValidator> = import("../codegen/LoadedValidator.js").ExtractDependencies<V>;
|
|
81
|
+
export type ContractContext<Vs extends {
|
|
51
82
|
[name: string]: import("./DagCompiler.js").LoadedValidator;
|
|
52
|
-
}
|
|
83
|
+
}, Ms extends {
|
|
84
|
+
[name: string]: import("./ContractContext.js").LoadedModule;
|
|
85
|
+
}> = import("./ContractContext.js").ContractContext<Vs, Ms>;
|
|
86
|
+
export type ContractContextBuildProps = {
|
|
87
|
+
isMainnet: boolean;
|
|
88
|
+
expectedHashes?: {
|
|
89
|
+
[name: string]: string;
|
|
90
|
+
} | undefined;
|
|
91
|
+
};
|
|
53
92
|
//# sourceMappingURL=ContractContextBuilder.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContractContextBuilder.d.ts","sourceRoot":"","sources":["../../src/context/ContractContextBuilder.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ContractContextBuilder.d.ts","sourceRoot":"","sources":["../../src/context/ContractContextBuilder.js"],"names":[],"mappings":"AAKA;;;;;GAKG;AAEH;;;GAGG;AAEH;;;;GAIG;AAEH;;;;;GAKG;AAEH;;;GAGG;AACH;;;;;IAwBI;;OAEG;IACH,gBAFa,uBAAuB,EAAE,EAAE,EAAE,CAAC,CAI1C;IAfD;;;;OAIG;IACH,sBAGC;IArBD;;;;OAIG;IACH,4BAAU;IAEV;;;OAGG;IACH,kBAFU,EAAE,CAEL;IAmBP;;;;;;;OAOG;IACH,8JAaC;IAED;;;;;;;OAOG;IACH,sIAQC;IAED;;;OAGG;IACH,aAHW,yBAAyB,GACvB,gBAAgB,EAAE,EAAE,EAAE,CAAC,CA+CnC;CACJ;yBAtJY,OAAO,kBAAkB,EAAE,UAAU;2BACrC,OAAO,4BAA4B,EAAE,YAAY;8BACjD,OAAO,+BAA+B,EAAE,eAAe;0BACvD,OAAO,sBAAsB,EAAE,WAAW;wFAK1C,OAAO,+BAA+B,EAAE,mBAAmB,CAAC,CAAC,CAAC;;;;;KAM9D,OAAO,sBAAsB,EAAE,eAAe,CAAC,EAAE,EAAE,EAAE,CAAC;;eAKnD,OAAO"}
|
|
@@ -4,9 +4,10 @@
|
|
|
4
4
|
*/
|
|
5
5
|
export function getModuleDependencies(validator: LoadedValidator): string[];
|
|
6
6
|
/**
|
|
7
|
+
* @typedef {import("../cast/index.js").CastConfig} CastConfig
|
|
7
8
|
* @typedef {import("../codegen/LoadedValidator.js").LoadedValidator} LoadedValidator
|
|
8
9
|
* @typedef {import("../compiler/index.js").CompilerLib} CompilerLib
|
|
9
|
-
* @typedef {import("./ContractContext.js").
|
|
10
|
+
* @typedef {import("./ContractContext.js").AnyContractValidatorContext} AnyContractValidatorContext
|
|
10
11
|
*/
|
|
11
12
|
/**
|
|
12
13
|
* Compiles a set of validators that depend on eachothers hashes (forming a Directed Acyclical Graph)
|
|
@@ -14,8 +15,9 @@ export function getModuleDependencies(validator: LoadedValidator): string[];
|
|
|
14
15
|
export class DagCompiler {
|
|
15
16
|
/**
|
|
16
17
|
* @param {CompilerLib} lib
|
|
18
|
+
* @param {CastConfig} castConfig
|
|
17
19
|
*/
|
|
18
|
-
constructor(lib: CompilerLib);
|
|
20
|
+
constructor(lib: CompilerLib, castConfig: CastConfig);
|
|
19
21
|
/**
|
|
20
22
|
* @private
|
|
21
23
|
* @readonly
|
|
@@ -25,18 +27,25 @@ export class DagCompiler {
|
|
|
25
27
|
/**
|
|
26
28
|
* @private
|
|
27
29
|
* @readonly
|
|
28
|
-
* @type {
|
|
30
|
+
* @type {CastConfig}
|
|
31
|
+
*/
|
|
32
|
+
private readonly config;
|
|
33
|
+
/**
|
|
34
|
+
* @private
|
|
35
|
+
* @readonly
|
|
36
|
+
* @type {{[name: string]: AnyContractValidatorContext}}
|
|
29
37
|
*/
|
|
30
38
|
private readonly cache;
|
|
39
|
+
castConfig: import("../cast/Cast.js").CastConfig;
|
|
31
40
|
/**
|
|
32
41
|
* @param {LoadedValidator[]} validators
|
|
33
42
|
* @param {Option<{[name: string]: string}>} expectedHashes
|
|
34
|
-
* @returns {{[name: string]:
|
|
43
|
+
* @returns {{[name: string]: AnyContractValidatorContext}}
|
|
35
44
|
*/
|
|
36
|
-
build(validators: LoadedValidator[], expectedHashes?: Option<{
|
|
45
|
+
build(validators: LoadedValidator[], castConfig: any, expectedHashes?: Option<{
|
|
37
46
|
[name: string]: string;
|
|
38
47
|
}>): {
|
|
39
|
-
[name: string]: import("./ContractContext.js").
|
|
48
|
+
[name: string]: import("./ContractContext.js").AnyContractValidatorContext;
|
|
40
49
|
};
|
|
41
50
|
/**
|
|
42
51
|
* @private
|
|
@@ -58,7 +67,8 @@ export class DagCompiler {
|
|
|
58
67
|
*/
|
|
59
68
|
private getHashTypes;
|
|
60
69
|
}
|
|
70
|
+
export type CastConfig = import("../cast/index.js").CastConfig;
|
|
61
71
|
export type LoadedValidator = import("../codegen/LoadedValidator.js").LoadedValidator;
|
|
62
72
|
export type CompilerLib = import("../compiler/index.js").CompilerLib;
|
|
63
|
-
export type
|
|
73
|
+
export type AnyContractValidatorContext = import("./ContractContext.js").AnyContractValidatorContext;
|
|
64
74
|
//# sourceMappingURL=DagCompiler.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DagCompiler.d.ts","sourceRoot":"","sources":["../../src/context/DagCompiler.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"DagCompiler.d.ts","sourceRoot":"","sources":["../../src/context/DagCompiler.js"],"names":[],"mappings":"AAuNA;;;GAGG;AACH,iDAHW,eAAe,GACb,MAAM,EAAE,CAsBpB;AArOD;;;;;GAKG;AAEH;;GAEG;AACH;IAsBI;;;OAGG;IACH,iBAHW,WAAW,cACX,UAAU,EAMpB;IA7BD;;;;OAIG;IACH,qBAAG;IAEH;;;;OAIG;IACH,wBAAM;IAEN;;;;OAIG;IACH,uBAAK;IAQD,iDAA4B;IAIhC;;;;OAIG;IACH,kBAJW,eAAe,EAAE;;;;MAkF3B;IAED;;;;;OAKG;IACH,mBA6BC;IAED;;;;OAIG;IACH,4BAoBC;IAED;;;;OAIG;IACH,qBAMC;CACJ;yBA1MY,OAAO,kBAAkB,EAAE,UAAU;8BACrC,OAAO,+BAA+B,EAAE,eAAe;0BACvD,OAAO,sBAAsB,EAAE,WAAW;0CAC1C,OAAO,sBAAsB,EAAE,2BAA2B"}
|
package/types/index.d.ts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
export
|
|
1
|
+
export * from "./cast/index.js";
|
|
2
2
|
export { ContractContextBuilder } from "./context/index.js";
|
|
3
3
|
export { LoadedScriptsWriter } from "./codegen/LoadedScriptsWriter.js";
|
|
4
|
-
export type StrictType<C extends import("./cast/Cast.js").Cast<any, any>> = import("./cast/index.js").StrictType<C>;
|
|
5
|
-
export type PermissiveType<C extends import("./cast/Cast.js").Cast<any, any>> = import("./cast/index.js").PermissiveType<C>;
|
|
6
4
|
export { typeCheckFiles, typeCheckScripts, loadCompilerLib } from "./compiler/ops.js";
|
|
7
5
|
//# sourceMappingURL=index.d.ts.map
|
package/types/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.js"],"names":[],"mappings":""}
|