103 lines
2.9 KiB
Text
103 lines
2.9 KiB
Text
-- File auto generated by purescript-bridge! --
|
|
module Agora.Stake where
|
|
|
|
import Prelude
|
|
|
|
import Agora.Proposal (ProposalId, ResultTag)
|
|
import Agora.SafeMoney (GTTag)
|
|
import Data.Generic.Rep (class Generic)
|
|
import Data.Lens (Iso', Lens', Prism', iso, prism')
|
|
import Data.Lens.Iso.Newtype (_Newtype)
|
|
import Data.Lens.Record (prop)
|
|
import Data.Maybe (Maybe(..))
|
|
import Data.Newtype (class Newtype)
|
|
import Data.Tagged (Tagged)
|
|
import GHC.Num.Integer (Integer)
|
|
import Plutus.V1.Ledger.Crypto (PubKeyHash)
|
|
import Plutus.V1.Ledger.Value (AssetClass)
|
|
import Type.Proxy (Proxy(Proxy))
|
|
|
|
newtype Stake = Stake
|
|
{ gtClassRef :: Tagged GTTag AssetClass
|
|
, proposalSTClass :: AssetClass
|
|
}
|
|
|
|
derive instance Generic Stake _
|
|
|
|
derive instance Newtype Stake _
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
_Stake :: Iso' Stake {gtClassRef :: Tagged GTTag AssetClass, proposalSTClass :: AssetClass}
|
|
_Stake = _Newtype
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
newtype ProposalLock = ProposalLock
|
|
{ vote :: ResultTag
|
|
, proposalId :: ProposalId
|
|
}
|
|
|
|
derive instance Generic ProposalLock _
|
|
|
|
derive instance Newtype ProposalLock _
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
_ProposalLock :: Iso' ProposalLock {vote :: ResultTag, proposalId :: ProposalId}
|
|
_ProposalLock = _Newtype
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
data StakeRedeemer
|
|
= DepositWithdraw (Tagged GTTag Integer)
|
|
| Destroy
|
|
| PermitVote ProposalLock
|
|
| RetractVotes (Array ProposalLock)
|
|
| WitnessStake
|
|
|
|
derive instance Generic StakeRedeemer _
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
_DepositWithdraw :: Prism' StakeRedeemer (Tagged GTTag Integer)
|
|
_DepositWithdraw = prism' DepositWithdraw case _ of
|
|
(DepositWithdraw a) -> Just a
|
|
_ -> Nothing
|
|
|
|
_Destroy :: Prism' StakeRedeemer Unit
|
|
_Destroy = prism' (const Destroy) case _ of
|
|
Destroy -> Just unit
|
|
_ -> Nothing
|
|
|
|
_PermitVote :: Prism' StakeRedeemer ProposalLock
|
|
_PermitVote = prism' PermitVote case _ of
|
|
(PermitVote a) -> Just a
|
|
_ -> Nothing
|
|
|
|
_RetractVotes :: Prism' StakeRedeemer (Array ProposalLock)
|
|
_RetractVotes = prism' RetractVotes case _ of
|
|
(RetractVotes a) -> Just a
|
|
_ -> Nothing
|
|
|
|
_WitnessStake :: Prism' StakeRedeemer Unit
|
|
_WitnessStake = prism' (const WitnessStake) case _ of
|
|
WitnessStake -> Just unit
|
|
_ -> Nothing
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
newtype StakeDatum = StakeDatum
|
|
{ stakedAmount :: Tagged GTTag Integer
|
|
, owner :: PubKeyHash
|
|
, lockedBy :: Array ProposalLock
|
|
}
|
|
|
|
derive instance Generic StakeDatum _
|
|
|
|
derive instance Newtype StakeDatum _
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
_StakeDatum :: Iso' StakeDatum {stakedAmount :: Tagged GTTag Integer, owner :: PubKeyHash, lockedBy :: Array ProposalLock}
|
|
_StakeDatum = _Newtype
|