use Credential instead of PubKeyHash everywhere
This commit is contained in:
parent
367a630cef
commit
f730998326
15 changed files with 948 additions and 865 deletions
|
|
@ -41,6 +41,7 @@ import Plutarch.Context (
|
|||
)
|
||||
import PlutusLedgerApi.V1.Value qualified as Value
|
||||
import PlutusLedgerApi.V2 (
|
||||
Credential (PubKeyCredential),
|
||||
PubKeyHash,
|
||||
ScriptContext,
|
||||
TxOutRef (TxOutRef),
|
||||
|
|
@ -73,7 +74,7 @@ data Parameters = Parameters
|
|||
|
||||
-- | Select the correct stake redeemer based on the existence of the new delegate.
|
||||
mkStakeRedeemer :: Parameters -> StakeRedeemer
|
||||
mkStakeRedeemer (newDelegate -> d) = maybe ClearDelegate DelegateTo d
|
||||
mkStakeRedeemer = maybe ClearDelegate (DelegateTo . PubKeyCredential) . newDelegate
|
||||
|
||||
-- | The owner of the input stake.
|
||||
stakeOwner :: PubKeyHash
|
||||
|
|
@ -84,8 +85,8 @@ mkStakeInputDatum :: Parameters -> StakeDatum
|
|||
mkStakeInputDatum ps =
|
||||
StakeDatum
|
||||
{ stakedAmount = 5
|
||||
, owner = stakeOwner
|
||||
, delegatedTo = ps.existingDelegate
|
||||
, owner = PubKeyCredential stakeOwner
|
||||
, delegatedTo = PubKeyCredential <$> ps.existingDelegate
|
||||
, lockedBy = []
|
||||
}
|
||||
|
||||
|
|
@ -105,12 +106,14 @@ setDelegate ps = buildSpending' builder
|
|||
else stakeInput.stakedAmount
|
||||
in stakeInput
|
||||
{ stakedAmount = stakedAmount
|
||||
, delegatedTo = ps.newDelegate
|
||||
, delegatedTo = PubKeyCredential <$> ps.newDelegate
|
||||
}
|
||||
|
||||
signer =
|
||||
if ps.signedByOwner
|
||||
then stakeInput.owner
|
||||
then case stakeInput.owner of
|
||||
PubKeyCredential c -> c
|
||||
_ -> signer2
|
||||
else signer2
|
||||
|
||||
st = Value.assetClassValue stakeAssetClass 1 -- Stake ST
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue