Remove either error id pattern in Samples

This commit is contained in:
Seungheon Oh 2022-06-17 14:29:00 -05:00
parent 0bc5706770
commit e386cc5e75
No known key found for this signature in database
GPG key ID: 9B0E12D357369B66
6 changed files with 31 additions and 30 deletions

View file

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

View file

@ -34,8 +34,8 @@ import Plutarch.Api.V1 (mkValidator, validatorHash)
import Plutarch.Context (
MintingBuilder,
SpendingBuilder,
buildMinting,
buildSpending,
buildMintingUnsafe,
buildSpendingUnsafe,
fee,
input,
mint,
@ -139,7 +139,7 @@ mintGST =
. withValue (gst <> minAda)
. withDatum governorOutputDatum
]
in either error id $ buildMinting builder
in buildMintingUnsafe builder
{- | A valid script context to create a proposal.
@ -259,7 +259,7 @@ createProposal =
. withValue gst
. 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.
@ -378,7 +378,7 @@ mintGATs =
. withValue gst
. withDatum governorInputDatum
]
in either error id $ buildSpending builder
in buildSpendingUnsafe builder
{- | A valid script context for changing the state datum of the governor.
@ -458,4 +458,4 @@ mutateState =
. withValue gst
. 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 (
BaseBuilder,
MintingBuilder,
buildMinting,
buildTxInfo,
buildMintingUnsafe,
buildTxInfoUnsafe,
input,
mint,
output,
@ -162,7 +162,7 @@ proposalCreation =
)
. withDatum govAfter
]
in either error id $ buildMinting builder
in buildMintingUnsafe builder
proposalRef :: TxOutRef
proposalRef = TxOutRef "0b2086cbf8b6900f8cb65e012de4516cb66b5cb08a9aaba12a8b88be" 1
@ -236,7 +236,7 @@ cosignProposal newSigners =
)
. withDatum stakeDatum
]
in either error id $ buildTxInfo builder
in buildTxInfoUnsafe builder
--------------------------------------------------------------------------------
@ -377,7 +377,7 @@ voteOnProposal params =
)
. 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)
. withDatum proposalOutputDatum
]
in either error id $ buildTxInfo builder
in buildTxInfoUnsafe builder
{- | Create a valid 'TxInfo' that advances a proposal, given the parameters.
Note that 'TransitionParameters.initialProposalStatus' should not be 'Finished'.

View file

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

View file

@ -20,7 +20,7 @@ module Sample.Treasury (
import Plutarch.Context (
MintingBuilder,
UTXO,
buildMinting,
buildMintingUnsafe,
credential,
input,
mint,
@ -83,7 +83,7 @@ validCtx =
. withValue (Value.singleton gatCs gatTn 1 <> minAda)
. withTxId "52b67b60260da3937510ad545c7f46f8d9915bd27e1082e76947fb309f913bd3"
]
in either error id $ buildMinting builder
in buildMintingUnsafe builder
treasuryRef :: TxOutRef
treasuryRef =
@ -124,4 +124,4 @@ trCtxGATNameNotAddress =
. withValue (Value.singleton gatCs gatTn 1 <> minAda)
. 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"
},
"locked": {
"lastModified": 1655470312,
"narHash": "sha256-O4Dy803SFOS+S1OFEecfCRkjWc8y0iHbO+EVKtBqsGk=",
"lastModified": 1655492974,
"narHash": "sha256-FNshUKtfs8tbxAUlqhP3AgmkjKMiKyw+kEBULmg6bVM=",
"owner": "Liqwid-Labs",
"repo": "liqwid-plutarch-extra",
"rev": "fd9b2e6e713c36efef30bcef8d97a069fda7d71a",
"rev": "4a9cdc642b85e16e487b789012bb8417c3e197d8",
"type": "github"
},
"original": {
@ -7459,11 +7459,11 @@
},
"nixpkgs-2111_5": {
"locked": {
"lastModified": 1655355951,
"narHash": "sha256-uroxR5FTZWEqpakNtwiZBABj6SpX+TOuUZ4G0PtSy94=",
"lastModified": 1655415671,
"narHash": "sha256-WD7HxxW1m8D/fkV1QlCYlZvnE5gQdg7ckq3myI4gPtE=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "b882c61856522467f866f3d6321e1aa5b0b393b5",
"rev": "f96729212602f15a6a226d2f27f5de70492ad095",
"type": "github"
},
"original": {
@ -9286,11 +9286,11 @@
"plutarch": "plutarch_4"
},
"locked": {
"lastModified": 1654627196,
"narHash": "sha256-OohlZsi0/j55Sq6U/hA7gl6SQyTHIGT9Pg+R61veCJw=",
"lastModified": 1655492019,
"narHash": "sha256-ZwU9wjSaC1BCukLqx3swqD30mwppVr7Fg2Y8jEkQ2c8=",
"owner": "Liqwid-Labs",
"repo": "plutarch-context-builder",
"rev": "b6c6e50c60c87f2b63d8027ff66728fabbb569fe",
"rev": "fa0e90bf0cdb258c5be500d066d5698fb360cfc3",
"type": "github"
},
"original": {