Skip to content

Commit

Permalink
onchain dev4
Browse files Browse the repository at this point in the history
  • Loading branch information
michele-nuzzi committed Jul 16, 2024
1 parent a7ad8ea commit 68cdf9c
Show file tree
Hide file tree
Showing 10 changed files with 46 additions and 24 deletions.
4 changes: 2 additions & 2 deletions packages/onchain/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/onchain/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@harmoniclabs/plu-ts-onchain",
"version": "0.3.0-dev3",
"version": "0.3.0-dev4",
"description": "An embedded DSL for Cardano smart contracts creation coupled with a library for Cardano transactions, all in Typescript",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion packages/onchain/src/pluts/API/V1/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,4 @@ export const V1 = Object.freeze({
PValue,
PValueEntry,
PAssetsEntry
});
} as const);
2 changes: 1 addition & 1 deletion packages/onchain/src/pluts/API/V2/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ export const V2 = Object.freeze({
POutputDatum,
PTxInInfo,
PTxOut
});
} as const);
2 changes: 1 addition & 1 deletion packages/onchain/src/pluts/API/V3/Governance/PDRep.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { pstruct } from "../../../PTypes";
import { pstruct } from "../../../PTypes/PStruct/pstruct";
import { PCredential } from "../../V1/Address/PCredential";

export const PDrep = pstruct({
Expand Down
25 changes: 12 additions & 13 deletions packages/onchain/src/pluts/API/V3/index.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
import { V2 } from "../V2";
// import { V2 } from "../V2";

export * from "./Governance";
export * from "./ScriptContext";
export * from "./Tx";

import { PChangedParams, PDrep, PGovernanceAction, PProposalProcedure, PProtocolVersion, PVote, PVoter, PConstitution, PRational } from "./Governance";
import { PCertificate, PDelegatee, PScriptContext, PScriptInfo, PScriptPurpose, PTxInfo } from "./ScriptContext";
import { PTxId, PTxInInfo, PTxOutRef } from "./Tx";

export const V3 = Object.freeze({
...V2,

PChangedParams, PDrep, PGovernanceAction, PProposalProcedure, PProtocolVersion, PVote, PVoter, PConstitution, PRational,
PCertificate, PDelegatee, PScriptContext, PScriptInfo, PScriptPurpose, PTxInfo,
PTxId, PTxInInfo, PTxOutRef
});

// import { PChangedParams, PDrep, PGovernanceAction, PProposalProcedure, PProtocolVersion, PVote, PVoter, PConstitution, PRational } from "./Governance";
// import { PCertificate, PDelegatee, PScriptContext, PScriptInfo, PScriptPurpose, PTxInfo } from "./ScriptContext";
// import { PTxId, PTxInInfo, PTxOutRef } from "./Tx";

// @ts-ignore The inferred type of this node exceeds the maximum length the compiler will serialize. An explicit type annotation is needed.ts(7056)
// export const V3 = Object.freeze({
// ...V2,
//
// PChangedParams, PDrep, PGovernanceAction, PProposalProcedure, PProtocolVersion, PVote, PVoter, PConstitution, PRational,
// PCertificate, PDelegatee, PScriptContext, PScriptInfo, PScriptPurpose, PTxInfo,
// PTxId, PTxInInfo, PTxOutRef
// } as const);
27 changes: 24 additions & 3 deletions packages/onchain/src/pluts/Script/makeScript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,25 @@ import type { PDataRepresentable } from "../PType/PDataRepresentable";
import { TermFn } from "../PTypes/PFn/PFn";
import { perror } from "../lib/perror";
import { pmakeUnit } from "../lib/std/unit/pmakeUnit";
import { pif, ptraceError } from "../lib/builtins";
import { pif } from "../lib/builtins";
import { papp } from "../lib/papp";
import { pfn } from "../lib/pfn";
import { PrimType, bool, data, unit } from "../type_system/types";
import { isWellFormedType, typeExtends } from "../type_system";
import { fromData } from "../lib/std/data/conversion/fromData";


import { ptraceError } from "../lib/std/traces";


/**
* @deprecated
*
* since plutus v3, all plutus scripts take only the script context as argument
* and redeemer and datum can be extracted from there
*
* it is suggested to use plutus v3 (or higher) to get the best performance out of your contract
*
* also make sure your contract returns a `unit` and no longer a `bool`
*/
export function makeValidator(
typedValidator: Term<
PLam<
Expand Down Expand Up @@ -89,6 +100,16 @@ export function makeValidator(
}


/**
* @deprecated
*
* since plutus v3, all plutus scripts take only the script context as argument
* and redeemer and datum can be extracted from there
*
* it is suggested to use plutus v3 (or higher) to get the best performance out of your contract
*
* also make sure your contract returns a `unit` and no longer a `bool`
*/
export function makeRedeemerValidator(
typedValidator: Term<
PLam<
Expand Down
3 changes: 2 additions & 1 deletion packages/onchain/src/pluts/lib/std/PMaybe/PMaybe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { StructT, TermType, FromPType, ToPType } from "../../../type_system";
import { _fromData } from "../data/conversion/fromData_minimal";
import { TermFn } from "../../../PTypes/PFn/PFn";
import { pmatch } from "../../pmatch/pmatch";
import type { Term } from "../../../Term";

export type MaybeT<T extends TermType> = StructT<{
Just: { val: T },
Expand Down Expand Up @@ -41,7 +42,7 @@ export function PMaybe<T extends TermType>(tyArg: T)
(( self, defaultValue ) =>
pmatch( self )
.onJust(({ val }) => val)
.onNothing(_ => defaultValue )
.onNothing(_ => defaultValue ) as Term<ToPType<T>>
)
};
});
Expand Down
2 changes: 1 addition & 1 deletion packages/onchain/src/pluts/lib/std/passert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@ export const passertAndContinue = <T extends TermType>(
.$( pdelay( perror( resultType ) ) )
)
) as any
)
);
1 change: 1 addition & 0 deletions packages/onchain/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"compilerOptions": {
"disableSizeLimit": true,
"skipLibCheck": true,
/* Basic Options */
// "incremental": true, /* Enable incremental compilation */
Expand Down

0 comments on commit 68cdf9c

Please sign in to comment.