I am currently on tag: v2022-04-06 of plutus-apps and was wondering how to create Lookup and Constraints for a typedValidator that checks whether the input was returned to the script with the correct staking credential. I was hoping to find someone here that could tell me if that is currently possible or not.
In processConstraint
it also looks like it just uses Address.scriptHashAddress
to generate the address for this constraint, which does not include any staking credentials. (on tag v2022-04-06)
I have seen a few commit messages in plutus-apps for a new constraint via
mustPayToOtherScriptAddress
for a later release, but maybe it is already possible and I am just looking in the wrong place.
This is what I currently have written: (it pays to the script but validation fails because it doesn't pay to an address with staking credentials)
l = Constraints.typedValidatorLookups factoryV <>
Constraints.otherScript (Scripts.validatorScript factoryV) <>
Constraints.mintingPolicy policy <>
Constraints.unspentOutputs utxos
tx = Constraints.mustPayToTheScript datum (nftValue) <>
-- ?? Constraints.mustPayWithDatumToPubKeyAddress (scriptAddress factoryV) (Nothing) datum (nftValue) <>
Constraints.mustMintValue chunkValue <>
mconcat [Constraints.mustPayToOtherScript chunkVHash (Datum $ PlutusTx.toBuiltinData (ChunkDatum x)) singleCVal | x <- [start..(start+n-1)]] <>
Constraints.mustSpendScriptOutput ((Map.keys utxos) !! 0) r
unbalanced <- adjustUnbalancedTx <$> mkTxConstraints l tx
In factoryV
I just check for the existance
checkStakingCredential :: Bool
checkStakingCredential = case addressStakingCredential . txOutAddress $ factoryOutput of
Just _ -> True
_ -> False