Skip to content

Commit

Permalink
plutus v3 context default export
Browse files Browse the repository at this point in the history
  • Loading branch information
michele-nuzzi committed Jul 12, 2024
1 parent f6ef0a0 commit f0f6a69
Show file tree
Hide file tree
Showing 35 changed files with 372 additions and 76 deletions.
6 changes: 1 addition & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,14 @@ npm install https://github.com/HarmonicLabs/plu-ts

## Get started

Have a look at the [`plu-ts` documentation](https://pluts.harmoniclabs.tech/docs/intro) where you can find some [example projects](https://pluts.harmoniclabs.tech/docs/examples/Hello%20World) to help you get started.
Have a look at the [`plu-ts` documentation](https://pluts.harmoniclabs.tech) where you can find some [example projects](https://pluts.harmoniclabs.tech/docs/examples/Hello%20World) to help you get started.

## Sponsors ❤️

the [sponsors.md](./sponsors.md) file contains a list of supportes of this project.

Everyone of them is special and is contribuitng in making this software aviable for everyone.

### Special thanks for their support goes to:

[VledicFranco](https://github.com/VledicFranco) by [Drunken Dragon Entertainment](https://twitter.com/DrunkenDragnEnt)

Consider having a look at the [documentation](https://www.harmoniclabs.tech/plu-ts-docs/index.html) even if it is currently being written; feel free to contribute to the [`plu-ts-docs` repository](https://github.com/HarmonicLabs/plu-ts-docs)

## Project Catalyst
Expand Down
22 changes: 11 additions & 11 deletions catalyst-proposals.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# plu-ts related Catalyst proposals

## Current found ( Found 10 )

date to be announced

## old proposals:

- Found 9:
- [(passed, not founded) Typescript smart-contracts](https://cardano.ideascale.com/c/idea/414103)
- [(passed, not founded) 100% Typescript offchain code](https://cardano.ideascale.com/c/idea/414144)
- Found 8:
- [(passed, not founded) Offchain Typescript library](https://cardano.ideascale.com/c/idea/396949)
- Fund 12: none
- Fund 11:
- [HLabs: plu-ts - ts framework for Cardano smart contracts](https://cardano.ideascale.com/c/idea/111482) FUNDED
- Fund 10:
- [plu-ts Typescript smart-contracts - road to production](https://cardano.ideascale.com/c/idea/100658) NOT FUNDED
- [plu-ts - 0 to full Cardano dApp tutorial/documentation](https://cardano.ideascale.com/c/idea/101023) FUNDED
- Fund 9:
- [(passed, not founded) Typescript smart-contracts](https://cardano.ideascale.com/c/idea/414103) NOT FUNDED
- [(passed, not founded) 100% Typescript offchain code](https://cardano.ideascale.com/c/idea/414144) NOT FUNDED
- Fund 8:
- [(passed, not founded) Offchain Typescript library](https://cardano.ideascale.com/c/idea/396949) NOT FUNDED
4 changes: 2 additions & 2 deletions packages/offchain/src/toOnChain/getTxIntervalData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export function getTxIntervalData(
0, // PPosixTimeRange (PInterval) only constructor
[
// from
new DataConstr( // PLowerBound
new DataConstr( // PBound
0, // only constructor
[
// bound
Expand All @@ -104,7 +104,7 @@ export function getTxIntervalData(
]
),
// to
new DataConstr( // PUpperBound
new DataConstr( // PBound
0, // only constructor
[
// bound
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { pstruct } from "../../../PTypes/PStruct/pstruct";
import { bool } from "../../../type_system/types";
import { PExtended } from "./PExtended";

export const PLowerBound = pstruct({
PLowerBound: {
export const PBound = pstruct({
PBound: {
bound: PExtended.type,
inclusive: bool
}
Expand Down
2 changes: 1 addition & 1 deletion packages/onchain/src/pluts/API/V1/Interval/PExtended.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { int } from "../../../type_system";

export const PExtended = pstruct({
PNegInf: {},
PFinite: { _0: int },
PFinite: { n: int },
PPosInf: {}
});

Expand Down
7 changes: 3 additions & 4 deletions packages/onchain/src/pluts/API/V1/Interval/PInterval.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { pstruct } from "../../../PTypes/PStruct/pstruct";
import { PLowerBound } from "./PLowerBound";
import { PUpperBound } from "./PUpperBound";
import { PBound } from "./PBound";

export const PInterval = pstruct({
PInterval: {
from: PLowerBound.type,
to: PUpperBound.type
from: PBound.type,
to: PBound.type
}
});
10 changes: 0 additions & 10 deletions packages/onchain/src/pluts/API/V1/Interval/PUpperBound.ts

This file was deleted.

15 changes: 6 additions & 9 deletions packages/onchain/src/pluts/API/V1/index.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
// export * from "./ScriptContext/PScriptContext";
// export * from "./ScriptContext/PTxInfo/PTxInfo";
export * from "./ScriptContext/PScriptPurpose";
// export * from "./ScriptContext/PScriptPurpose";
export * from "./Address/PAddress";
export * from "./Address/PCredential";
export * from "./Address/PStakingCredential";
export * from "./Interval/PExtended";
export * from "./Interval/PBound";
export * from "./Interval/PInterval";
export * from "./Interval/PLowerBound";
export * from "./Interval/PUpperBound";
export * from "./PDCert";
export * from "./PubKey/PPubKey";
export * from "./PubKey/PPubKeyHash";
export * from "./ScriptsHashes/PDatumHash";
export * from "./ScriptsHashes/PScriptHash";
export * from "./ScriptsHashes/PValidatorHash";
export * from "./Time";
export * from "./Tx/PTxId";
// export * from "./Tx/PTxId";
// export * from "./Tx/PTxInInfo";
// export * from "./Tx/PTxOut";
export * from "./Tx/PTxOutRef";
// export * from "./Tx/PTxOutRef";
export * from "./Value/PCurrencySymbol";
export * from "./Value/PTokenName";
export * from "./Value/PValue";
Expand All @@ -31,8 +30,6 @@ import { PCredential } from "./Address/PCredential";
import { PStakingCredential } from "./Address/PStakingCredential";
import { PExtended } from "./Interval/PExtended";
import { PInterval } from "./Interval/PInterval";
import { PLowerBound } from "./Interval/PLowerBound";
import { PUpperBound } from "./Interval/PUpperBound";
import { PDCert } from "./PDCert";
import { PPubKey } from "./PubKey/PPubKey";
import { PPubKeyHash } from "./PubKey/PPubKeyHash";
Expand All @@ -47,6 +44,7 @@ import { PTxOutRef } from "./Tx/PTxOutRef";
import { PCurrencySymbol } from "./Value/PCurrencySymbol";
import { PTokenName } from "./Value/PTokenName";
import { PValue } from "./Value/PValue";
import { PBound } from "./Interval/PBound";

export const V1 = Object.freeze({
PScriptContext,
Expand All @@ -61,8 +59,7 @@ export const V1 = Object.freeze({
// ./Interval
PExtended,
PInterval,
PLowerBound,
PUpperBound,
PBound,

// ./PDCert
PDCert,
Expand Down
6 changes: 3 additions & 3 deletions packages/onchain/src/pluts/API/V2/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
export * from "./ScriptContext/PScriptContext";
export * from "./ScriptContext/PTxInfo/PTxInfo";
// export * from "./ScriptContext/PScriptContext";
// export * from "./ScriptContext/PTxInfo/PTxInfo";
export * from "./Tx/POutputDatum";
export * from "./Tx/PTxOut";
export * from "./Tx/PTxInInfo";
// export * from "./Tx/PTxInInfo";

import { V1 } from "../V1";
import { PScriptContext } from "./ScriptContext/PScriptContext";
Expand Down
53 changes: 53 additions & 0 deletions packages/onchain/src/pluts/API/V3/Governance/PChangedParams.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import { palias } from "../../../PTypes/PAlias/palias";
import { data, map } from "../../../type_system";

/**
{- | A Plutus Data object containing proposed parameter changes. The Data object contains
a @Map@ with one entry per changed parameter, from the parameter ID to the new value.
Unchanged parameters are not included.
The mapping from parameter IDs to parameters can be found in
[conway.cddl](https://github.com/IntersectMBO/cardano-ledger/blob/master/eras/conway/impl/cddl-files/conway.cddl).
/Invariant:/ This map is non-empty, and the keys are stored in ascending order.
-}
important note:
we can't really type this map because the values of each parameters are different
protocol_param_update =
{ ? 0: coin ; minfee A
, ? 1: coin ; minfee B
, ? 2: uint .size 4 ; max block body size
, ? 3: uint .size 4 ; max transaction size
, ? 4: uint .size 2 ; max block header size
, ? 5: coin ; key deposit
, ? 6: coin ; pool deposit
, ? 7: epoch_interval ; maximum epoch
, ? 8: uint .size 2 ; n_opt: desired number of stake pools
, ? 9: nonnegative_interval ; pool pledge influence
, ? 10: unit_interval ; expansion rate
, ? 11: unit_interval ; treasury growth rate
, ? 16: coin ; min pool cost
, ? 17: coin ; ada per utxo byte
, ? 18: costmdls ; cost models for script languages
, ? 19: ex_unit_prices ; execution costs
, ? 20: ex_units ; max tx ex units
, ? 21: ex_units ; max block ex units
, ? 22: uint .size 4 ; max value size
, ? 23: uint .size 2 ; collateral percentage
, ? 24: uint .size 2 ; max collateral inputs
, ? 25: pool_voting_thresholds ; pool voting thresholds
, ? 26: drep_voting_thresholds ; DRep voting thresholds
, ? 27: uint .size 2 ; min committee size
, ? 28: epoch_interval ; committee term limit
, ? 29: epoch_interval ; governance action validity period
, ? 30: coin ; governance action deposit
, ? 31: coin ; DRep deposit
, ? 32: epoch_interval ; DRep inactivity period
, ? 33: nonnegative_interval ; MinFee RefScriptCostPerByte
}
*/
export const PChangedParams = palias( map( data, data ) );
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { pstruct } from "../../PTypes";
import { PCredential } from "../V1";
import { pstruct } from "../../../PTypes";
import { PCredential } from "../../V1/Address/PCredential";

export const PDrep = pstruct({
DRep: { credentials: PCredential.type },
Expand Down
51 changes: 51 additions & 0 deletions packages/onchain/src/pluts/API/V3/Governance/PGovernanceAction.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import { PMaybe } from "../../../lib";
import { pstruct } from "../../../PTypes/PStruct/pstruct";
import { int, list, map } from "../../../type_system/types";
import { PCredential } from "../../V1/Address/PCredential";
import { PValidatorHash } from "../../V1/ScriptsHashes/PValidatorHash";
import { PTxOutRef } from "../Tx/PTxOutRef";
import { PChangedParams } from "./PChangedParams";
import { PProtocolVersion } from "./PProtocolVersion";

export const PRational = pstruct({
PRational: {
numerator: int,
denominator: int
}
});

export const PConstitution = pstruct({
PConstitution: {
constitutionScriptHash: PMaybe( PValidatorHash.type ).type
}
});

export const PGovernanceAction = pstruct({
ParameterChange: {
govActionId: PMaybe( PTxOutRef.type ).type,
changedParameters: PChangedParams.type,
constitutionScriptHash: PMaybe( PValidatorHash.type ).type
},
HardForkInitiation: {
govActionId: PMaybe( PTxOutRef.type ).type,
nextProtocolVersion: PProtocolVersion.type
},
TreasuryWithdrawals: {
withdrawals: map( PCredential.type, int ),
constitutionScriptHash: PMaybe( PValidatorHash.type ).type
},
NoConfidence: {
govActionId: PMaybe( PTxOutRef.type ).type
},
UpdateCommittee: {
govActionId: PMaybe( PTxOutRef.type ).type,
removedMembers: list( PCredential.type ),
newMembers: map( PCredential.type, int ),
newQuorum: PRational.type
},
NewConstitution: {
govActionId: PMaybe( PTxOutRef.type ).type,
consitution: PConstitution.type
},
InfoAction: {}
});
13 changes: 13 additions & 0 deletions packages/onchain/src/pluts/API/V3/Governance/PProposalProcedure.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { pstruct } from "../../../PTypes/PStruct/pstruct";
import { int } from "../../../type_system";
import { PCredential } from "../../V1/Address/PCredential";
import { PGovernanceAction } from "./PGovernanceAction";

export const PProposalProcedure = pstruct({
PProposalProcedure: {
/** lovelaces */
deposit: int,
returnCredentials: PCredential.type,
governanceAction: PGovernanceAction.type
}
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { pstruct } from "../../../PTypes/PStruct/pstruct";
import { int } from "../../../type_system/types";

export const PProtocolVersion = pstruct({
PProtocolVersion: {
major: int,
minor: int
}
});
7 changes: 7 additions & 0 deletions packages/onchain/src/pluts/API/V3/Governance/PVote.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { pstruct } from "../../../PTypes/PStruct/pstruct";

export const PVote = pstruct({
No: {},
Yes: {},
Abstain: {}
});
9 changes: 9 additions & 0 deletions packages/onchain/src/pluts/API/V3/Governance/PVoter.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { pstruct } from "../../../PTypes/PStruct/pstruct";
import { PCredential } from "../../V1/Address/PCredential";
import { PPubKeyHash } from "../../V1/PubKey/PPubKeyHash";

export const PVoter = pstruct({
Committee: { hotCredentials: PCredential.type },
DRep: { credentials: PCredential.type },
StakePool: { poolHash: PPubKeyHash.type }
});
7 changes: 7 additions & 0 deletions packages/onchain/src/pluts/API/V3/Governance/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export * from "./PChangedParams";
export * from "./PGovernanceAction";
export * from "./PProposalProcedure";
export * from "./PProtocolVersion";
export * from "./PVote";
export * from "./PVoter";
export * from "./PDRep";
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { pstruct } from "../../../../PTypes/PStruct/pstruct";
import { PMaybe } from "../../../../lib/std/PMaybe/PMaybe";
import { int } from "../../../../type_system/types";
import { PCredential } from "../../../V1/Address/PCredential";
import { PPubKeyHash } from "../../../V1/PubKey/PPubKeyHash";
import { PDelegatee } from "../../PDelegatee";
import { pstruct } from "../../../PTypes/PStruct/pstruct";
import { PMaybe } from "../../../lib/std/PMaybe/PMaybe";
import { int } from "../../../type_system/types";
import { PCredential } from "../../V1/Address/PCredential";
import { PPubKeyHash } from "../../V1/PubKey/PPubKeyHash";
import { PDelegatee } from "./PDelegatee";

const PMaybeInt = PMaybe( int );

Expand Down Expand Up @@ -42,7 +42,7 @@ export const PCertificate = pstruct({
},
PoolRetire: {
poolId: PPubKeyHash.type,
epoch: int, // epoch
epoch: int,
},
CommitteeHotAuthorization: {
cold: PCredential.type,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { pstruct } from "../../PTypes/PStruct/pstruct";
import { PPubKeyHash } from "../V1/PubKey/PPubKeyHash";
import { PDrep } from "./PDRep";
import { pstruct } from "../../../PTypes/PStruct/pstruct";
import { PPubKeyHash } from "../../V1/PubKey/PPubKeyHash";
import { PDrep } from "../Governance/PDRep";

export const PDelegatee = pstruct({
DelegStake: { poolId: PPubKeyHash.type },
Expand Down
12 changes: 12 additions & 0 deletions packages/onchain/src/pluts/API/V3/ScriptContext/PScriptContext.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { pstruct } from "../../../PTypes/PStruct/pstruct";
import { data } from "../../../type_system";
import { PScriptInfo } from "./PScriptInfo";
import { PTxInfo } from "./PTxInfo";

export const PScriptContext = pstruct({
PScriptContext: {
tx: PTxInfo.type,
redeemer: data,
purpose: PScriptInfo.type
}
});
Loading

0 comments on commit f0f6a69

Please sign in to comment.