mirror of
https://github.com/FiloSpaTeam/plutus-pioneer-program.git
synced 2024-11-14 02:42:35 +01:00
reformatting
This commit is contained in:
parent
64d795fbb2
commit
7d03111171
1 changed files with 17 additions and 4 deletions
|
@ -66,16 +66,29 @@ lovelaces = Ada.getLovelace . Ada.fromValue
|
|||
transition :: TokenSale -> State Integer -> TSRedeemer -> Maybe (TxConstraints Void Void, State Integer)
|
||||
transition ts s r = case (stateValue s, stateData s, r) of
|
||||
(v, _, SetPrice p) | p >= 0 -> Just ( Constraints.mustBeSignedBy (tsSeller ts)
|
||||
, State p (v <> nft (negate 1))
|
||||
, State p $
|
||||
v <>
|
||||
nft (negate 1)
|
||||
)
|
||||
(v, p, AddTokens n) | n > 0 -> Just ( mempty
|
||||
, State p $ v <> nft (negate 1) <> assetClassValue (tsToken ts) n
|
||||
, State p $
|
||||
v <>
|
||||
nft (negate 1) <>
|
||||
assetClassValue (tsToken ts) n
|
||||
)
|
||||
(v, p, BuyTokens n) | n > 0 -> Just ( mempty
|
||||
, State p $ v <> nft (negate 1) <> assetClassValue (tsToken ts) (negate n) <> lovelaceValueOf (n * p)
|
||||
, State p $
|
||||
v <>
|
||||
nft (negate 1) <>
|
||||
assetClassValue (tsToken ts) (negate n) <>
|
||||
lovelaceValueOf (n * p)
|
||||
)
|
||||
(v, p, Withdraw n l) | n >= 0 && l >= 0 -> Just ( Constraints.mustBeSignedBy (tsSeller ts)
|
||||
, State p $ v <> nft (negate 1) <> assetClassValue (tsToken ts) (negate n) <> lovelaceValueOf (negate l)
|
||||
, State p $
|
||||
v <>
|
||||
nft (negate 1) <>
|
||||
assetClassValue (tsToken ts) (negate n) <>
|
||||
lovelaceValueOf (negate l)
|
||||
)
|
||||
_ -> Nothing
|
||||
where
|
||||
|
|
Loading…
Reference in a new issue