ensure GTs are in the stake being checked
This commit is contained in:
parent
dd2bc5c0d6
commit
e5ab13d874
1 changed files with 15 additions and 15 deletions
|
|
@ -271,8 +271,6 @@ governorValidator gov =
|
||||||
txInfo' <- plet $ pfromData $ ctx.txInfo
|
txInfo' <- plet $ pfromData $ ctx.txInfo
|
||||||
txInfo <- pletFields @'["mint", "inputs", "outputs", "datums", "signatories"] txInfo'
|
txInfo <- pletFields @'["mint", "inputs", "outputs", "datums", "signatories"] txInfo'
|
||||||
|
|
||||||
valueSpent <- plet $ pvalueSpent # txInfo.inputs
|
|
||||||
|
|
||||||
PSpending ((pfield @"_0" #) -> txOutRef') <- pmatch $ pfromData ctx.purpose
|
PSpending ((pfield @"_0" #) -> txOutRef') <- pmatch $ pfromData ctx.purpose
|
||||||
let txOutRef = pfromData txOutRef'
|
let txOutRef = pfromData txOutRef'
|
||||||
|
|
||||||
|
|
@ -340,22 +338,21 @@ governorValidator gov =
|
||||||
passert "Exactly one input from the stake validator" $
|
passert "Exactly one input from the stake validator" $
|
||||||
plength # inputsFromStakeValidatorWithStateToken #== 1
|
plength # inputsFromStakeValidatorWithStateToken #== 1
|
||||||
|
|
||||||
stakeInputDatumHash <-
|
stakeInput <-
|
||||||
plet $
|
pletFields @'["datumHash", "value"] $
|
||||||
pfield @"datumHash"
|
pfield @"resolved"
|
||||||
#$ pfield @"resolved"
|
|
||||||
#$ phead # inputsFromStakeValidatorWithStateToken
|
#$ phead # inputsFromStakeValidatorWithStateToken
|
||||||
|
|
||||||
passert "Stake input must have datum" $
|
passert "Stake input must have datum" $
|
||||||
pisDJust # stakeInputDatumHash
|
pisDJust # stakeInput.datumHash
|
||||||
|
|
||||||
let stakeInputDatum' = mustFindDatum' @PStakeDatum # stakeInputDatumHash # txInfo.datums
|
let stakeInputDatum' = mustFindDatum' @PStakeDatum # stakeInput.datumHash # txInfo.datums
|
||||||
|
|
||||||
stakeInputDatum <-
|
stakeInputDatum <-
|
||||||
pletFields @["stakedAmount", "owner", "lockedBy"] stakeInputDatum'
|
pletFields @["stakedAmount", "owner", "lockedBy"] stakeInputDatum'
|
||||||
|
|
||||||
passert "Required amount of stake GT should be spent" $
|
passert "Required amount of stake GT should be presented" $
|
||||||
stakeInputDatum.stakedAmount #< (pgtValueOf # valueSpent)
|
stakeInputDatum.stakedAmount #== (pgtValueOf # stakeInput.value)
|
||||||
|
|
||||||
passert "Tx should be signed by the stake owner" $
|
passert "Tx should be signed by the stake owner" $
|
||||||
ptxSignedBy # txInfo.signatories # stakeInputDatum.owner
|
ptxSignedBy # txInfo.signatories # stakeInputDatum.owner
|
||||||
|
|
@ -435,12 +432,15 @@ governorValidator gov =
|
||||||
passert "Exactly one UTXO with stake state token should be sent to the stake validator" $
|
passert "Exactly one UTXO with stake state token should be sent to the stake validator" $
|
||||||
plength # outputToStakeValidatorWithStateToken #== 1
|
plength # outputToStakeValidatorWithStateToken #== 1
|
||||||
|
|
||||||
let stakeOutputDatumHash' =
|
stakeOutput <-
|
||||||
pfield @"datumHash"
|
pletFields @'["datumHash", "value"] $
|
||||||
#$ pfromData
|
pfromData $
|
||||||
$ phead # outputToStakeValidatorWithStateToken
|
phead # outputToStakeValidatorWithStateToken
|
||||||
|
|
||||||
stakeOutputDatumHash = mustBePDJust # "Stake output should have datum" # stakeOutputDatumHash'
|
passert "Staked GTs should be sent back to stake validator" $
|
||||||
|
stakeInputDatum.stakedAmount #== (pgtValueOf # stakeOutput.value)
|
||||||
|
|
||||||
|
let stakeOutputDatumHash = mustBePDJust # "Stake output should have datum" # stakeOutput.datumHash
|
||||||
|
|
||||||
stakeOutputDatum =
|
stakeOutputDatum =
|
||||||
pforgetData $
|
pforgetData $
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue