UNPKG

@harmoniclabs/plu-ts-onchain

Version:

An embedded DSL for Cardano smart contracts creation coupled with a library for Cardano transactions, all in Typescript

23 lines (22 loc) 1.51 kB
import { Term } from "../../../Term/index.js"; import type { PStruct, StructInstance } from "../../../PTypes/PStruct/pstruct.js"; import type { TermFn } from "../../../PTypes/PFn/PFn.js"; import { StructDefinition, Methods } from "../../../type_system/index.js"; import { PBool } from "../../../PTypes/PBool.js"; import { TermBool } from "./TermBool.js"; import { TermInt } from "./TermInt.js"; import { TermList } from "./TermList.js"; import type { IsSingleKey } from "../../../../utils/IsSingleKey.js"; import type { PData } from "../../../PTypes/PData/index.js"; import { FilterMethodsByInput, LiftMethods, MethodsAsTerms } from "./userMethods/methodsTypes.js"; import { BaseUtilityTermExtension } from "./BaseUtilityTerm.js"; export type RawStruct = { readonly index: TermInt; readonly fields: TermList<PData>; }; export type TermStruct<SDef extends StructDefinition, SMethods extends Methods> = Term<PStruct<SDef, SMethods>> & BaseUtilityTermExtension & { readonly peq: TermFn<[PStruct<SDef, {}>], PBool>; readonly eq: (other: Term<PStruct<SDef, {}>> | Term<PData>) => TermBool; readonly raw: RawStruct; } & (IsSingleKey<SDef> extends true ? StructInstance<SDef[keyof SDef]> : {}) & LiftMethods<FilterMethodsByInput<SMethods, PStruct<SDef, {}>>> & MethodsAsTerms<FilterMethodsByInput<SMethods, PStruct<SDef, {}>>>; export declare function addPStructMethods<SDef extends StructDefinition, SMethods extends Methods>(struct: Term<PStruct<SDef, SMethods>>): TermStruct<SDef, SMethods>;