Skip to content
This repository was archived by the owner on Aug 11, 2022. It is now read-only.
9 changes: 9 additions & 0 deletions plutus-context-builder/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@ This format is based on [Keep A Changelog](https://keepachangelog.com/en/1.0.0).

## Unreleased

## 2.0.1 -- 2022-05-17

### Added

* module `Test.Plutus.ContextBuilder.Internal`, not recommended for end users,
* the `foldBuilt` utility function, and
* `transactionSpending` and `transactionMinting` for testing of whole
transactions.

## 2.0 -- 2022-03-09

### Added
Expand Down
7 changes: 4 additions & 3 deletions plutus-context-builder/plutus-context-builder.cabal
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cabal-version: 3.0
name: plutus-context-builder
version: 2.0
version: 2.0.1
extra-source-files: CHANGELOG.md

common lang
Expand Down Expand Up @@ -44,9 +44,10 @@ common lang

library
import: lang
exposed-modules: Test.Plutus.ContextBuilder
exposed-modules:
Test.Plutus.ContextBuilder
, Test.Plutus.ContextBuilder.Internal
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd say 'minor version bump'. Also worth mentioning that everything in that module will need docs and @sinces if they weren't docced or exposed before.

Copy link
Copy Markdown
Author

@blamario blamario May 19, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I incremented the versions to 2.0.1 for plutus-context-builder and 9.1.1 for tasty-plutus. That's what minor means with PVP, right?

other-modules:
Test.Plutus.ContextBuilder.Internal
Test.Plutus.ContextBuilder.Minting

build-depends:
Expand Down
62 changes: 58 additions & 4 deletions plutus-context-builder/src/Test/Plutus/ContextBuilder.hs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ module Test.Plutus.ContextBuilder (
ValueType (..),
SideUTXO (..),
ValidatorUTXO (..),
SomeValidatedUTXO (..),
TestUTXO (..),
ValidatorUTXOs (..),
Minting (..),
Expand All @@ -42,8 +43,10 @@ module Test.Plutus.ContextBuilder (
-- ** Basic construction
input,
validatorInput,
validatedInput,
output,
validatorOutput,
validatedOutput,
signedWith,
datum,
addDatum,
Expand Down Expand Up @@ -85,12 +88,15 @@ module Test.Plutus.ContextBuilder (
-- ** Direct
liftContextFragment,
liftNamedContextFragment,
foldBuilt,

-- ** Build finished context
spendingScriptContext,
mintingScriptContext,
spendingScriptContextDef,
mintingScriptContextDef,
transactionSpending,
transactionMinting,

-- ** Utilities
defTransactionConfig,
Expand Down Expand Up @@ -123,8 +129,9 @@ import Test.Plutus.ContextBuilder.Internal (
InputPosition (Head, Tail),
Minting (Mint),
Naming (Anonymous, Named),
Purpose (ForMinting, ForSpending),
Purpose (ForMinting, ForSpending, ForTransaction),
SideUTXO (SideUTXO, sUtxoType, sUtxoValue),
SomeValidatedUTXO (SomeValidatedUTXO, someRedeemer, someSpendingScript, someUTxO),
TestUTXO (TestUTXO, tUtxoDatum, tUtxoValue),
TransactionConfig (
TransactionConfig,
Expand All @@ -137,14 +144,17 @@ import Test.Plutus.ContextBuilder.Internal (
),
UTXOType (PubKeyUTXO, ScriptUTXO),
ValidatorUTXO (ValidatorUTXO, vUtxoDatum, vUtxoValue),
ValidatorUTXOs (NoValidatorUTXOs, ValidatorUTXOs),
ValidatorUTXOs (MultiValidatorUTXOs, NoValidatorUTXOs, ValidatorUTXOs),
ValueType (GeneralValue, TokensValue),
defTransactionConfig,
foldBuilt,
makeIncompleteContexts,
mintingScriptContext,
mintingScriptContextDef,
spendingScriptContext,
spendingScriptContextDef,
transactionMinting,
transactionSpending,
)
import Test.Plutus.ContextBuilder.Minting (
MintingPolicyAction (BurnAction, MintAction),
Expand Down Expand Up @@ -182,7 +192,32 @@ validatorInput ::
ValidatorUTXO d ->
ContextBuilder ( 'ForSpending d r) 'Anonymous
validatorInput name x =
NoNames $ mempty {cfValidatorInputs = ValidatorUTXOs $ Map.singleton name x}
NoNames $
mempty
{ cfValidatorInputs =
ValidatorUTXOs $ Map.singleton name x
}

{- | Anonymous context from a single 'SomeValidatedUTXO' input.

= Note

This input won't be used for spending in any 'ScriptPurpose' of any
'ScriptContext' built from this.

@since 2.0.1
-}
validatedInput ::
-- | Name of the input
Text ->
SomeValidatedUTXO ->
ContextBuilder 'ForTransaction 'Anonymous
validatedInput name x =
NoNames $
mempty
{ cfValidatorInputs =
MultiValidatorUTXOs $ Map.singleton name x
}

{- | Anonymous context from a single 'SideUTXO' output.

Expand All @@ -205,7 +240,26 @@ validatorOutput ::
ValidatorUTXO d ->
ContextBuilder ( 'ForSpending d r) 'Anonymous
validatorOutput name x =
NoNames $ mempty {cfValidatorOutputs = ValidatorUTXOs $ Map.singleton name x}
NoNames $
mempty
{ cfValidatorOutputs =
ValidatorUTXOs $ Map.singleton name x
}

{- | Anonymous context from a single 'SomeValidatedUTXO' output.

@since 2.0.1
-}
validatedOutput ::
Text ->
SomeValidatedUTXO ->
ContextBuilder 'ForTransaction 'Anonymous
validatedOutput name x =
NoNames $
mempty
{ cfValidatorOutputs =
MultiValidatorUTXOs $ Map.singleton name x
}

{- | Anonymous context signed with one signature.

Expand Down
Loading