Skip to content

Commit 866fadd

Browse files
committed
Use CTL's currentSlot and currentTime
1 parent c679fd1 commit 866fadd

File tree

1 file changed

+6
-17
lines changed

1 file changed

+6
-17
lines changed

src/Seabug/Contract/Mint.purs

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,17 @@ module Seabug.Contract.Mint where
33
import Contract.Prelude
44

55
import Contract.Address
6-
( Slot
7-
, getNetworkId
6+
( getNetworkId
87
, ownPaymentPubKeyHash
98
, ownStakePubKeyHash
109
, payPubKeyHashBaseAddress
1110
)
12-
import Contract.Chain (ChainTip(..), Tip(..), getTip)
11+
import Contract.Chain (currentSlot, currentTime)
1312
import Contract.Monad (Contract, liftContractE, liftContractM, liftedE, liftedM)
1413
import Contract.PlutusData (toData)
1514
import Contract.ScriptLookups as Lookups
1615
import Contract.Scripts (validatorHash)
17-
import Contract.Time (from, getEraSummaries, getSystemStart, slotToPosixTime)
16+
import Contract.Time (from)
1817
import Contract.Transaction (TransactionHash, balanceAndSignTxE, submit)
1918
import Contract.TxConstraints as Constraints
2019
import Contract.Utxos (utxosAt)
@@ -37,13 +36,6 @@ import Seabug.Types
3736
, NftData(..)
3837
, NftId(..)
3938
)
40-
import Types.BigNum as BigNum
41-
42-
-- | TODO: Use `currentSlot` instead, see
43-
-- | https://github.com/mlabs-haskell/seabug-contracts/issues/27
44-
slotFromTip :: Tip -> Slot
45-
slotFromTip TipAtGenesis = wrap $ BigNum.zero
46-
slotFromTip (Tip (ChainTip { slot })) = slot
4739

4840
-- | Mint the self-governed NFT for the given collection.
4941
mintWithCollection
@@ -62,7 +54,6 @@ mintWithCollection
6254
addr <- liftContractM "Cannot get user address" $
6355
payPubKeyHashBaseAddress networkId owner ownerStake
6456
utxos <- liftedM "Cannot get user utxos" $ utxosAt addr
65-
currentSlot <- slotFromTip <$> getTip
6657
marketplaceValidator' <- unwrap <$> liftContractE marketplaceValidator
6758
lockingScript <- liftedE $ mkLockScript collectionNftCs lockLockup
6859
lockLockupEnd
@@ -84,10 +75,8 @@ mintWithCollection
8475
curr <- liftedM "Could not get currency symbol" $ liftAff $
8576
scriptCurrencySymbol policy
8677
tn <- liftedM "Could not get token name" $ MintingPolicy.mkTokenName nft
87-
eraSummaries <- getEraSummaries
88-
systemStart <- getSystemStart
89-
now <- liftedE $ liftAff $ liftEffect $
90-
slotToPosixTime eraSummaries systemStart currentSlot
78+
entered <- currentSlot
79+
now <- currentTime
9180
let
9281
nftValue = singleton curr tn one
9382
lookups = mconcat
@@ -105,7 +94,7 @@ mintWithCollection
10594
, Constraints.mustPayToScript lockingScriptHash
10695
( wrap $ toData $ LockDatum
10796
{ sgNft: curr
108-
, entered: currentSlot
97+
, entered
10998
, underlyingTn: collectionNftTn
11099
}
111100
) $ singleton collectionNftCs collectionNftTn one

0 commit comments

Comments
 (0)