update purescript bridge

This commit is contained in:
fanghr 2022-05-14 01:04:16 +08:00
parent 88c54a74c5
commit ea4f3c1ce0
2 changed files with 21 additions and 13 deletions

View file

@ -4,6 +4,7 @@ module Agora.Governor where
import Prelude import Prelude
import Agora.Proposal (ProposalId, ProposalThresholds) import Agora.Proposal (ProposalId, ProposalThresholds)
import Agora.SafeMoney (GTTag)
import Data.Bounded.Generic (genericBottom, genericTop) import Data.Bounded.Generic (genericBottom, genericTop)
import Data.Enum (class Enum) import Data.Enum (class Enum)
import Data.Enum.Generic (genericPred, genericSucc) import Data.Enum.Generic (genericPred, genericSucc)
@ -13,6 +14,10 @@ import Data.Lens.Iso.Newtype (_Newtype)
import Data.Lens.Record (prop) import Data.Lens.Record (prop)
import Data.Maybe (Maybe(..)) import Data.Maybe (Maybe(..))
import Data.Newtype (class Newtype) import Data.Newtype (class Newtype)
import Data.Tagged (Tagged)
import GHC.Num.Integer (Integer)
import Plutus.V1.Ledger.Tx (TxOutRef)
import Plutus.V1.Ledger.Value (AssetClass)
import Type.Proxy (Proxy(Proxy)) import Type.Proxy (Proxy(Proxy))
newtype GovernorDatum = GovernorDatum newtype GovernorDatum = GovernorDatum
@ -34,6 +39,7 @@ _GovernorDatum = _Newtype
data GovernorRedeemer data GovernorRedeemer
= CreateProposal = CreateProposal
| MintGATs | MintGATs
| MutateGovernor
derive instance Generic GovernorRedeemer _ derive instance Generic GovernorRedeemer _
@ -57,21 +63,24 @@ _MintGATs = prism' (const MintGATs) case _ of
MintGATs -> Just unit MintGATs -> Just unit
_ -> Nothing _ -> Nothing
_MutateGovernor :: Prism' GovernorRedeemer Unit
_MutateGovernor = prism' (const MutateGovernor) case _ of
MutateGovernor -> Just unit
_ -> Nothing
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
data Governor = Governor newtype Governor = Governor
{ gstOutRef :: TxOutRef
, gtClassRef :: Tagged GTTag AssetClass
, maximumCosigners :: Integer
}
derive instance Generic Governor _ derive instance Generic Governor _
instance Enum Governor where derive instance Newtype Governor _
succ = genericSucc
pred = genericPred
instance Bounded Governor where
bottom = genericBottom
top = genericTop
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
_Governor :: Iso' Governor Unit _Governor :: Iso' Governor {gstOutRef :: TxOutRef, gtClassRef :: Tagged GTTag AssetClass, maximumCosigners :: Integer}
_Governor = iso (const unit) (const Governor) _Governor = _Newtype

View file

@ -14,7 +14,6 @@ import Data.Lens.Record (prop)
import Data.Maybe (Maybe(..)) import Data.Maybe (Maybe(..))
import Data.Newtype (class Newtype) import Data.Newtype (class Newtype)
import Data.Tagged (Tagged) import Data.Tagged (Tagged)
import Data.Tuple (Tuple)
import GHC.Num.Integer (Integer) import GHC.Num.Integer (Integer)
import Plutus.V1.Ledger.Crypto (PubKeyHash) import Plutus.V1.Ledger.Crypto (PubKeyHash)
import Plutus.V1.Ledger.Scripts (DatumHash, ValidatorHash) import Plutus.V1.Ledger.Scripts (DatumHash, ValidatorHash)
@ -120,7 +119,7 @@ _ProposalVotes = _Newtype
newtype ProposalDatum = ProposalDatum newtype ProposalDatum = ProposalDatum
{ proposalId :: ProposalId { proposalId :: ProposalId
, effects :: Map ResultTag (Array (Tuple ValidatorHash DatumHash)) , effects :: Map ResultTag (Map ValidatorHash DatumHash)
, status :: ProposalStatus , status :: ProposalStatus
, cosigners :: Array PubKeyHash , cosigners :: Array PubKeyHash
, thresholds :: ProposalThresholds , thresholds :: ProposalThresholds
@ -133,7 +132,7 @@ derive instance Newtype ProposalDatum _
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
_ProposalDatum :: Iso' ProposalDatum {proposalId :: ProposalId, effects :: Map ResultTag (Array (Tuple ValidatorHash DatumHash)), status :: ProposalStatus, cosigners :: Array PubKeyHash, thresholds :: ProposalThresholds, votes :: ProposalVotes} _ProposalDatum :: Iso' ProposalDatum {proposalId :: ProposalId, effects :: Map ResultTag (Map ValidatorHash DatumHash), status :: ProposalStatus, cosigners :: Array PubKeyHash, thresholds :: ProposalThresholds, votes :: ProposalVotes}
_ProposalDatum = _Newtype _ProposalDatum = _Newtype
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------