Remove either error id pattern in Samples

This commit is contained in:
Seungheon Oh 2022-06-17 14:29:00 -05:00
parent 071a6ca7cc
commit a8699bf992
6 changed files with 31 additions and 30 deletions

View file

@ -67,8 +67,9 @@ genMultiSigProp prop = do
MeetsMinSigs -> chooseInt (minSig, length pkhs) MeetsMinSigs -> chooseInt (minSig, length pkhs)
DoesNotMeetMinSigs -> chooseInt (0, minSig - 1) DoesNotMeetMinSigs -> chooseInt (0, minSig - 1)
let builder = mconcat $ signedWith <$> take n pkhs <> othersigners let builder :: BaseBuilder
txinfo = either error id $ buildTxInfo builder builder = mconcat $ signedWith <$> take n pkhs <> othersigners
txinfo = buildTxInfoUnsafe builder
pure (ms, ScriptContext txinfo (Spending (TxOutRef "" 0))) pure (ms, ScriptContext txinfo (Spending (TxOutRef "" 0)))
-- | Classify model into propositions. -- | Classify model into propositions.

View file

@ -34,8 +34,8 @@ import Plutarch.Api.V1 (mkValidator, validatorHash)
import Plutarch.Context ( import Plutarch.Context (
MintingBuilder, MintingBuilder,
SpendingBuilder, SpendingBuilder,
buildMinting, buildMintingUnsafe,
buildSpending, buildSpendingUnsafe,
fee, fee,
input, input,
mint, mint,
@ -139,7 +139,7 @@ mintGST =
. withValue (gst <> minAda) . withValue (gst <> minAda)
. withDatum governorOutputDatum . withDatum governorOutputDatum
] ]
in either error id $ buildMinting builder in buildMintingUnsafe builder
{- | A valid script context to create a proposal. {- | A valid script context to create a proposal.
@ -259,7 +259,7 @@ createProposal =
. withValue gst . withValue gst
. withDatum governorInputDatum . withDatum governorInputDatum
] ]
in either error id $ buildSpending builder in buildSpendingUnsafe builder
{- This script context should be a valid transaction for minting authority for the effect scrips. {- This script context should be a valid transaction for minting authority for the effect scrips.
@ -378,7 +378,7 @@ mintGATs =
. withValue gst . withValue gst
. withDatum governorInputDatum . withDatum governorInputDatum
] ]
in either error id $ buildSpending builder in buildSpendingUnsafe builder
{- | A valid script context for changing the state datum of the governor. {- | A valid script context for changing the state datum of the governor.
@ -458,4 +458,4 @@ mutateState =
. withValue gst . withValue gst
. withDatum governorInputDatum . withDatum governorInputDatum
] ]
in either error id $ buildSpending builder in buildSpendingUnsafe builder

View file

@ -46,8 +46,8 @@ import Data.Tagged (Tagged (..), untag)
import Plutarch.Context ( import Plutarch.Context (
BaseBuilder, BaseBuilder,
MintingBuilder, MintingBuilder,
buildMinting, buildMintingUnsafe,
buildTxInfo, buildTxInfoUnsafe,
input, input,
mint, mint,
output, output,
@ -162,7 +162,7 @@ proposalCreation =
) )
. withDatum govAfter . withDatum govAfter
] ]
in either error id $ buildMinting builder in buildMintingUnsafe builder
proposalRef :: TxOutRef proposalRef :: TxOutRef
proposalRef = TxOutRef "0b2086cbf8b6900f8cb65e012de4516cb66b5cb08a9aaba12a8b88be" 1 proposalRef = TxOutRef "0b2086cbf8b6900f8cb65e012de4516cb66b5cb08a9aaba12a8b88be" 1
@ -236,7 +236,7 @@ cosignProposal newSigners =
) )
. withDatum stakeDatum . withDatum stakeDatum
] ]
in either error id $ buildTxInfo builder in buildTxInfoUnsafe builder
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
@ -377,7 +377,7 @@ voteOnProposal params =
) )
. withDatum stakeOutputDatum . withDatum stakeOutputDatum
] ]
in either error id $ buildTxInfo builder in buildTxInfoUnsafe builder
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
@ -442,7 +442,7 @@ mkTransitionTxInfo from to effects votes startingTime validTime =
. withValue (pst <> minAda) . withValue (pst <> minAda)
. withDatum proposalOutputDatum . withDatum proposalOutputDatum
] ]
in either error id $ buildTxInfo builder in buildTxInfoUnsafe builder
{- | Create a valid 'TxInfo' that advances a proposal, given the parameters. {- | Create a valid 'TxInfo' that advances a proposal, given the parameters.
Note that 'TransitionParameters.initialProposalStatus' should not be 'Finished'. Note that 'TransitionParameters.initialProposalStatus' should not be 'Finished'.

View file

@ -31,8 +31,8 @@ import Plutarch.Api.V1 (mkValidator, validatorHash)
import Plutarch.Context ( import Plutarch.Context (
MintingBuilder, MintingBuilder,
SpendingBuilder, SpendingBuilder,
buildMinting, buildMintingUnsafe,
buildSpending, buildSpendingUnsafe,
input, input,
mint, mint,
output, output,
@ -87,7 +87,7 @@ stakeCreation =
. withValue (st <> Value.singleton "da8c30857834c6ae7203935b89278c532b3995245295456f993e1d24" "LQ" 424242424242) . withValue (st <> Value.singleton "da8c30857834c6ae7203935b89278c532b3995245295456f993e1d24" "LQ" 424242424242)
. withDatum datum . withDatum datum
] ]
in either error id $ buildMinting builder in buildMintingUnsafe builder
-- | This ScriptContext should fail because the datum has too much GT. -- | This ScriptContext should fail because the datum has too much GT.
stakeCreationWrongDatum :: ScriptContext stakeCreationWrongDatum :: ScriptContext
@ -150,4 +150,4 @@ stakeDepositWithdraw config =
. withValue (st <> Value.assetClassValue (untag stake.gtClassRef) (untag stakeBefore.stakedAmount)) . withValue (st <> Value.assetClassValue (untag stake.gtClassRef) (untag stakeBefore.stakedAmount))
. withDatum stakeAfter . withDatum stakeAfter
] ]
in either error id $ buildSpending builder in buildSpendingUnsafe builder

View file

@ -20,7 +20,7 @@ module Sample.Treasury (
import Plutarch.Context ( import Plutarch.Context (
MintingBuilder, MintingBuilder,
UTXO, UTXO,
buildMinting, buildMintingUnsafe,
credential, credential,
input, input,
mint, mint,
@ -83,7 +83,7 @@ validCtx =
. withValue (Value.singleton gatCs gatTn 1 <> minAda) . withValue (Value.singleton gatCs gatTn 1 <> minAda)
. withTxId "52b67b60260da3937510ad545c7f46f8d9915bd27e1082e76947fb309f913bd3" . withTxId "52b67b60260da3937510ad545c7f46f8d9915bd27e1082e76947fb309f913bd3"
] ]
in either error id $ buildMinting builder in buildMintingUnsafe builder
treasuryRef :: TxOutRef treasuryRef :: TxOutRef
treasuryRef = treasuryRef =
@ -124,4 +124,4 @@ trCtxGATNameNotAddress =
. withValue (Value.singleton gatCs gatTn 1 <> minAda) . withValue (Value.singleton gatCs gatTn 1 <> minAda)
. withTxId "52b67b60260da3937510ad545c7f46f8d9915bd27e1082e76947fb309f913bd3" . withTxId "52b67b60260da3937510ad545c7f46f8d9915bd27e1082e76947fb309f913bd3"
] ]
in either error id $ buildMinting builder in buildMintingUnsafe builder

18
flake.lock generated
View file

@ -6339,11 +6339,11 @@
"plutarch-quickcheck": "plutarch-quickcheck" "plutarch-quickcheck": "plutarch-quickcheck"
}, },
"locked": { "locked": {
"lastModified": 1655470312, "lastModified": 1655492974,
"narHash": "sha256-O4Dy803SFOS+S1OFEecfCRkjWc8y0iHbO+EVKtBqsGk=", "narHash": "sha256-FNshUKtfs8tbxAUlqhP3AgmkjKMiKyw+kEBULmg6bVM=",
"owner": "Liqwid-Labs", "owner": "Liqwid-Labs",
"repo": "liqwid-plutarch-extra", "repo": "liqwid-plutarch-extra",
"rev": "fd9b2e6e713c36efef30bcef8d97a069fda7d71a", "rev": "4a9cdc642b85e16e487b789012bb8417c3e197d8",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -7459,11 +7459,11 @@
}, },
"nixpkgs-2111_5": { "nixpkgs-2111_5": {
"locked": { "locked": {
"lastModified": 1655355951, "lastModified": 1655415671,
"narHash": "sha256-uroxR5FTZWEqpakNtwiZBABj6SpX+TOuUZ4G0PtSy94=", "narHash": "sha256-WD7HxxW1m8D/fkV1QlCYlZvnE5gQdg7ckq3myI4gPtE=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "b882c61856522467f866f3d6321e1aa5b0b393b5", "rev": "f96729212602f15a6a226d2f27f5de70492ad095",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -9286,11 +9286,11 @@
"plutarch": "plutarch_4" "plutarch": "plutarch_4"
}, },
"locked": { "locked": {
"lastModified": 1654627196, "lastModified": 1655492019,
"narHash": "sha256-OohlZsi0/j55Sq6U/hA7gl6SQyTHIGT9Pg+R61veCJw=", "narHash": "sha256-ZwU9wjSaC1BCukLqx3swqD30mwppVr7Fg2Y8jEkQ2c8=",
"owner": "Liqwid-Labs", "owner": "Liqwid-Labs",
"repo": "plutarch-context-builder", "repo": "plutarch-context-builder",
"rev": "b6c6e50c60c87f2b63d8027ff66728fabbb569fe", "rev": "fa0e90bf0cdb258c5be500d066d5698fb360cfc3",
"type": "github" "type": "github"
}, },
"original": { "original": {