@helios-lang/contract-utils
Advanced tools
Comparing version 0.1.11 to 0.1.12
{ | ||
"name": "@helios-lang/contract-utils", | ||
"version": "0.1.11", | ||
"version": "0.1.12", | ||
"description": "Convenience and type-safety utilities for using Helios validators from within Typescript", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
export { loadLibrary } from "./load.js" | ||
/** | ||
* @typedef {import("./Lib.js").Lib} Lib | ||
*/ |
/** | ||
* @typedef {{ | ||
* allValidatorTypes: {[name: string]: any}, | ||
* otherValidators: {[name: string]: {purpose: string, hash: string}}, | ||
@@ -18,2 +19,3 @@ * dependsOnOwnHash?: boolean, | ||
* version: string | ||
* getValidatorType: (purpose: string) => any | ||
* typeCheck: (validators: {[name: string]: SourceDetails}, modules: {[name: string]: SourceDetails}) => ({ | ||
@@ -20,0 +22,0 @@ * modules: {[name: string]: ModuleDetails}, validators: {[name: string]: ValidatorDetails}}) |
@@ -132,3 +132,2 @@ /** | ||
/** | ||
* @private | ||
* @param {string} purpose | ||
@@ -356,12 +355,4 @@ * @returns {HashType} | ||
const otherValidators = options.otherValidators ?? {} | ||
const otherValidatorTypes = Object.fromEntries( | ||
Object.keys(otherValidators).map((k) => { | ||
return [k, this.getValidatorType(otherValidators[k].purpose)] | ||
}) | ||
) | ||
const otherValidatorTypes = options.allValidatorTypes | ||
if (options.dependsOnOwnHash) { | ||
otherValidatorTypes[name] = this.getValidatorType(purpose) | ||
} | ||
const program = this.lib.Program.newInternal( | ||
@@ -368,0 +359,0 @@ main, |
@@ -15,2 +15,3 @@ import { bytesToHex } from "@helios-lang/codec-utils" | ||
/** | ||
* @typedef {import("../lib/index.js").Lib} Lib | ||
* @typedef {import("./ContractContext.js").Validator} CompiledValidator | ||
@@ -111,2 +112,15 @@ */ | ||
/** | ||
* @private | ||
* @param {Lib} lib | ||
* @returns {{[name: string]: any}} | ||
*/ | ||
getValidatorTypes(lib) { | ||
return Object.fromEntries( | ||
Object.entries(this.validators).map(([name, v]) => { | ||
return [name, lib.getValidatorType(v.$purpose)] | ||
}) | ||
) | ||
} | ||
/** | ||
* | ||
@@ -141,2 +155,4 @@ * @param {Option<{[name: string]: string}>} expectedHashes | ||
const allValidatorTypes = this.getValidatorTypes(lib) | ||
/** | ||
@@ -229,4 +245,2 @@ * @type {{[name: string]: ( | ||
const otherValidators = getOtherValidators() | ||
const { cborHex: optimizedCborHex } = lib.compile( | ||
@@ -238,2 +252,3 @@ validator.$sourceCode, | ||
otherValidators: getOtherValidators(), | ||
allValidatorTypes: allValidatorTypes, | ||
dependsOnOwnHash: validator.$dependsOnOwnHash | ||
@@ -284,2 +299,3 @@ } | ||
otherValidators: getOtherValidators(), | ||
allValidatorTypes: allValidatorTypes, | ||
ownHash: validator.$dependsOnOwnHash ? ownHash : undefined | ||
@@ -286,0 +302,0 @@ } |
export { loadLibrary } from "./load.js"; | ||
export type Lib = import("./Lib.js").Lib; | ||
//# sourceMappingURL=index.d.ts.map |
/** | ||
* @typedef {{ | ||
* allValidatorTypes: {[name: string]: any}, | ||
* otherValidators: {[name: string]: {purpose: string, hash: string}}, | ||
@@ -17,2 +18,3 @@ * dependsOnOwnHash?: boolean, | ||
* version: string | ||
* getValidatorType: (purpose: string) => any | ||
* typeCheck: (validators: {[name: string]: SourceDetails}, modules: {[name: string]: SourceDetails}) => ({ | ||
@@ -43,2 +45,5 @@ * modules: {[name: string]: ModuleDetails}, validators: {[name: string]: ValidatorDetails}}) | ||
export type CompileOptions = { | ||
allValidatorTypes: { | ||
[name: string]: any; | ||
}; | ||
otherValidators: { | ||
@@ -59,2 +64,3 @@ [name: string]: { | ||
version: string; | ||
getValidatorType: (purpose: string) => any; | ||
typeCheck: (validators: { | ||
@@ -61,0 +67,0 @@ [name: string]: SourceDetails; |
@@ -101,7 +101,6 @@ /** | ||
/** | ||
* @private | ||
* @param {string} purpose | ||
* @returns {HashType} | ||
*/ | ||
private getValidatorType; | ||
getValidatorType(purpose: string): HashType; | ||
/** | ||
@@ -108,0 +107,0 @@ * @private |
/** | ||
* @typedef {import("../lib/index.js").Lib} Lib | ||
* @typedef {import("./ContractContext.js").Validator} CompiledValidator | ||
@@ -78,2 +79,8 @@ */ | ||
/** | ||
* @private | ||
* @param {Lib} lib | ||
* @returns {{[name: string]: any}} | ||
*/ | ||
private getValidatorTypes; | ||
/** | ||
* | ||
@@ -109,2 +116,3 @@ * @param {Option<{[name: string]: string}>} expectedHashes | ||
} | ||
export type Lib = import("../lib/index.js").Lib; | ||
export type CompiledValidator = import("./ContractContext.js").Validator; | ||
@@ -111,0 +119,0 @@ export type MintingContext<TRedeemerStrict, TRedeemerPermissive> = import("@helios-lang/ledger").MintingContext<TRedeemerStrict, TRedeemerPermissive>; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
89042
2493