mirror of
https://github.com/FiloSpaTeam/plutus-pioneer-program.git
synced 2024-12-22 05:21:59 +01:00
fixed Homework1 & Solution1
This commit is contained in:
parent
c74fb6fefa
commit
528928c8fb
2 changed files with 8 additions and 4 deletions
|
@ -15,6 +15,7 @@ module Week05.Homework1 where
|
|||
import Control.Monad hiding (fmap)
|
||||
import Control.Monad.Freer.Extras as Extras
|
||||
import Data.Aeson (ToJSON, FromJSON)
|
||||
import Data.Default (Default (..))
|
||||
import Data.Text (Text)
|
||||
import Data.Void (Void)
|
||||
import GHC.Generics (Generic)
|
||||
|
@ -24,6 +25,7 @@ import qualified PlutusTx
|
|||
import PlutusTx.Prelude hiding (Semigroup(..), unless)
|
||||
import Ledger hiding (mint, singleton)
|
||||
import Ledger.Constraints as Constraints
|
||||
import Ledger.TimeSlot
|
||||
import qualified Ledger.Typed.Scripts as Scripts
|
||||
import Ledger.Value as Value
|
||||
import Playground.Contract (printJson, printSchemas, ensureKnownCurrencies, stage, ToSchema)
|
||||
|
@ -63,7 +65,7 @@ mint mp = do
|
|||
else do
|
||||
let val = Value.singleton (curSymbol pkh deadline) (mpTokenName mp) (mpAmount mp)
|
||||
lookups = Constraints.mintingPolicy $ policy pkh deadline
|
||||
tx = Constraints.mustMintValue val <> Constraints.mustValidateIn (to deadline)
|
||||
tx = Constraints.mustMintValue val <> Constraints.mustValidatlIn (to $ now + 5000)
|
||||
ledgerTx <- submitTxConstraintsWith @Void lookups tx
|
||||
void $ awaitTxConfirmed $ txId ledgerTx
|
||||
Contract.logInfo @String $ printf "forged %s" (show val)
|
||||
|
@ -80,7 +82,7 @@ mkKnownCurrencies []
|
|||
test :: IO ()
|
||||
test = runEmulatorTraceIO $ do
|
||||
let tn = "ABC"
|
||||
deadline = 10
|
||||
deadline = slotToBeginPOSIXTime def 10
|
||||
h <- activateContractWallet (Wallet 1) endpoints
|
||||
callEndpoint @"mint" h $ MintParams
|
||||
{ mpTokenName = tn
|
||||
|
|
|
@ -14,6 +14,7 @@ module Week05.Solution1 where
|
|||
|
||||
import Control.Monad hiding (fmap)
|
||||
import Data.Aeson (ToJSON, FromJSON)
|
||||
import Data.Default (Default (..))
|
||||
import Data.Text (Text)
|
||||
import Data.Void (Void)
|
||||
import GHC.Generics (Generic)
|
||||
|
@ -23,6 +24,7 @@ import qualified PlutusTx
|
|||
import PlutusTx.Prelude hiding (Semigroup(..), unless)
|
||||
import Ledger hiding (mint, singleton)
|
||||
import Ledger.Constraints as Constraints
|
||||
import Ledger.TimeSlot
|
||||
import qualified Ledger.Typed.Scripts as Scripts
|
||||
import Ledger.Value as Value
|
||||
import Playground.Contract (printJson, printSchemas, ensureKnownCurrencies, stage, ToSchema)
|
||||
|
@ -69,7 +71,7 @@ mint mp = do
|
|||
else do
|
||||
let val = Value.singleton (curSymbol pkh deadline) (mpTokenName mp) (mpAmount mp)
|
||||
lookups = Constraints.mintingPolicy $ policy pkh deadline
|
||||
tx = Constraints.mustMintValue val <> Constraints.mustValidateIn (to deadline)
|
||||
tx = Constraints.mustMintValue val <> Constraints.mustValidateIn (to $ now + 5000)
|
||||
ledgerTx <- submitTxConstraintsWith @Void lookups tx
|
||||
void $ awaitTxConfirmed $ txId ledgerTx
|
||||
Contract.logInfo @String $ printf "forged %s" (show val)
|
||||
|
@ -86,7 +88,7 @@ mkKnownCurrencies []
|
|||
test :: IO ()
|
||||
test = runEmulatorTraceIO $ do
|
||||
let tn = "ABC"
|
||||
deadline = 10
|
||||
deadline = slotToBeginPOSIXTime def 10
|
||||
h <- activateContractWallet (Wallet 1) endpoints
|
||||
callEndpoint @"mint" h $ MintParams
|
||||
{ mpTokenName = tn
|
||||
|
|
Loading…
Reference in a new issue