use v2 types

This commit is contained in:
Hongrui Fang 2022-08-15 21:27:57 +08:00
parent b453f2b216
commit fec449ceb5
36 changed files with 504 additions and 360 deletions

View file

@ -80,11 +80,13 @@ import Plutarch.Context (
signedWith,
timeRange,
withDatum,
withOutRef,
withRef,
withValue,
)
import Plutarch.Lift (PLifted, PUnsafeLiftDecl)
import PlutusLedgerApi.V1 (
import PlutusLedgerApi.V1.Value (AssetClass (..))
import PlutusLedgerApi.V1.Value qualified as Value
import PlutusLedgerApi.V2 (
DatumHash,
POSIXTime,
POSIXTimeRange,
@ -92,8 +94,6 @@ import PlutusLedgerApi.V1 (
TxOutRef (TxOutRef),
ValidatorHash,
)
import PlutusLedgerApi.V1.Value (AssetClass (..))
import PlutusLedgerApi.V1.Value qualified as Value
import PlutusTx.AssocMap qualified as AssocMap
import Sample.Proposal.Shared (
governorTxRef,
@ -317,7 +317,7 @@ mkProposalBuilder ps =
[ input $
mconcat
[ script proposalValidatorHash
, withOutRef proposalRef
, withRef proposalRef
, withDatum (mkProposalInputDatum ps)
, withValue value
]
@ -400,7 +400,7 @@ mkStakeBuilder ps =
, input $
mconcat
[ script stakeValidatorHash
, withOutRef (mkStakeRef idx)
, withRef (mkStakeRef idx)
, withValue perStakeValue
, withDatum i
]
@ -462,14 +462,14 @@ mkGovernorBuilder ps =
mconcat
[ script govValidatorHash
, withValue value
, withOutRef governorRef
, withRef governorRef
, withDatum governorInputDatum
]
, output $
mconcat
[ script govValidatorHash
, withValue value
, withOutRef governorRef
, withRef governorRef
, withDatum (mkGovernorOutputDatum ps)
]
]

View file

@ -46,17 +46,16 @@ import Plutarch.Context (
timeRange,
txId,
withDatum,
withOutRef,
withTxId,
withRef,
withValue,
)
import PlutusLedgerApi.V1 (
import PlutusLedgerApi.V1.Value qualified as Value
import PlutusLedgerApi.V2 (
POSIXTimeRange,
PubKeyHash,
TxOutRef (..),
Value,
)
import PlutusLedgerApi.V1.Value qualified as Value
import PlutusTx.AssocMap qualified as AssocMap
import Sample.Proposal.Shared (proposalTxRef, stakeTxRef)
import Sample.Shared (
@ -165,8 +164,7 @@ cosign ps = builder
[ script stakeValidatorHash
, withValue stakeValue
, withDatum stakeDatum
, withTxId stakeTxRef
, withOutRef (mkStakeRef refIdx)
, withRef (mkStakeRef refIdx)
]
, output $
mconcat
@ -196,8 +194,7 @@ cosign ps = builder
[ script proposalValidatorHash
, withValue pst
, withDatum proposalInputDatum
, withTxId proposalTxRef
, withOutRef proposalRef
, withRef proposalRef
]
, output $
mconcat

View file

@ -31,7 +31,12 @@ import Agora.Proposal (
ResultTag (ResultTag),
emptyVotesFor,
)
import Agora.Proposal.Time (MaxTimeRangeWidth (MaxTimeRangeWidth), ProposalStartingTime (..))
import Agora.Proposal.Time (
MaxTimeRangeWidth (
MaxTimeRangeWidth
),
ProposalStartingTime (..),
)
import Agora.Scripts (AgoraScripts (..))
import Agora.Stake (
ProposalLock (..),
@ -50,10 +55,11 @@ import Plutarch.Context (
timeRange,
txId,
withDatum,
withOutRef,
withRef,
withValue,
)
import PlutusLedgerApi.V1 (
import PlutusLedgerApi.V1.Value qualified as Value
import PlutusLedgerApi.V2 (
DatumHash,
POSIXTime (POSIXTime),
POSIXTimeRange,
@ -62,7 +68,6 @@ import PlutusLedgerApi.V1 (
ValidatorHash,
always,
)
import PlutusLedgerApi.V1.Value qualified as Value
import PlutusTx.AssocMap qualified as AssocMap
import Sample.Proposal.Shared (stakeTxRef)
import Sample.Shared (
@ -303,7 +308,7 @@ createProposal ps = builder
[ script govValidatorHash
, withValue governorValue
, withDatum governorInputDatum
, withOutRef governorRef
, withRef governorRef
]
, output $
mconcat
@ -317,7 +322,7 @@ createProposal ps = builder
[ script stakeValidatorHash
, withValue stakeValue
, withDatum (mkStakeInputDatum ps)
, withOutRef stakeRef
, withRef stakeRef
]
, output $
mconcat

View file

@ -7,7 +7,7 @@ Shared constants for proposal samples.
-}
module Sample.Proposal.Shared (proposalTxRef, stakeTxRef, governorTxRef) where
import PlutusLedgerApi.V1 (TxId)
import PlutusLedgerApi.V2 (TxId)
-- | 'TxId' of all the proposal inputs in the samples.
proposalTxRef :: TxId

View file

@ -46,16 +46,16 @@ import Plutarch.Context (
signedWith,
txId,
withDatum,
withOutRef,
withRef,
withValue,
)
import PlutusLedgerApi.V1 (
import PlutusLedgerApi.V1.Value qualified as Value
import PlutusLedgerApi.V2 (
DatumHash,
PubKeyHash,
TxOutRef (..),
ValidatorHash,
)
import PlutusLedgerApi.V1.Value qualified as Value
import PlutusTx.AssocMap qualified as AssocMap
import Sample.Proposal.Shared (stakeTxRef)
import Sample.Shared (
@ -261,7 +261,7 @@ unlockStake ps =
[ script proposalValidatorHash
, withValue pst
, withDatum i
, withOutRef (mkProposalRef idx)
, withRef (mkProposalRef idx)
]
, output $
mconcat
@ -293,7 +293,7 @@ unlockStake ps =
[ script stakeValidatorHash
, withValue stakeValue
, withDatum sInDatum
, withOutRef stakeRef
, withRef stakeRef
]
, output $
mconcat

View file

@ -40,14 +40,14 @@ import Plutarch.Context (
timeRange,
txId,
withDatum,
withOutRef,
withRef,
withValue,
)
import PlutusLedgerApi.V1 (
import PlutusLedgerApi.V1.Value qualified as Value
import PlutusLedgerApi.V2 (
PubKeyHash,
TxOutRef (TxOutRef),
)
import PlutusLedgerApi.V1.Value qualified as Value
import PlutusTx.AssocMap qualified as AssocMap
import Sample.Proposal.Shared (proposalTxRef, stakeTxRef)
import Sample.Shared (
@ -222,14 +222,14 @@ vote params =
[ script proposalValidatorHash
, withValue pst
, withDatum proposalInputDatum
, withOutRef proposalRef
, withRef proposalRef
]
, input $
mconcat
[ script stakeValidatorHash
, withValue stakeValue
, withDatum stakeInputDatum
, withOutRef stakeRef
, withRef stakeRef
]
, output $
mconcat