@@ -7,14 +7,12 @@ module Seabug.Contract.Mint
77import Contract.Prelude
88
99import Contract.Address
10- ( getNetworkId
11- , ownPaymentPubKeyHash
12- , ownStakePubKeyHash
13- , payPubKeyHashBaseAddress
10+ ( ownPaymentPubKeyHash
11+ , getWalletAddress
1412 )
1513import Contract.AuxiliaryData (setTxMetadata )
1614import Contract.Chain (currentSlot , currentTime )
17- import Contract.Monad (Contract , liftContractE , liftContractM , liftedE , liftedM )
15+ import Contract.Monad (Contract , liftContractE , liftedE , liftedM )
1816import Contract.PlutusData (toData )
1917import Contract.ScriptLookups as Lookups
2018import Contract.Scripts (validatorHash )
@@ -28,13 +26,16 @@ import Contract.Value
2826 , scriptCurrencySymbol
2927 , singleton
3028 )
31- import Seabug.Contract.Util (getSeabugMetadata )
29+ import Seabug.Contract.Util
30+ ( ReturnBehaviour (ToMarketPlace)
31+ , getSeabugMetadata
32+ , payBehaviour
33+ )
3234import Seabug.Lock (mkLockScript )
3335import Seabug.MarketPlace (marketplaceValidator )
3436import Seabug.MintingPolicy as MintingPolicy
3537import Seabug.Types
3638 ( LockDatum (..)
37- , MarketplaceDatum (..)
3839 , MintAct (..)
3940 , MintParams (..)
4041 , NftCollection (..)
@@ -44,23 +45,22 @@ import Seabug.Types
4445
4546mintWithCollectionTest
4647 :: forall (r :: Row Type )
47- . CurrencySymbol /\ TokenName
48+ . ReturnBehaviour
49+ -> CurrencySymbol /\ TokenName
4850 -> MintParams
4951 -> ( Constraints.TxConstraints Void Void
5052 -> Contract r (Constraints.TxConstraints Void Void )
5153 )
5254 -> Contract r (TransactionHash /\ (CurrencySymbol /\ TokenName ) /\ NftData )
5355mintWithCollectionTest
56+ retBehaviour
5457 (collectionNftCs /\ collectionNftTn)
5558 ( MintParams
5659 { price, lockLockup, lockLockupEnd, authorShare, daoShare }
5760 )
5861 modConstraints = do
5962 owner <- liftedM " Cannot get PaymentPubKeyHash" ownPaymentPubKeyHash
60- ownerStake <- liftedM " Cannot get StakePubKeyHash" ownStakePubKeyHash
61- networkId <- getNetworkId
62- addr <- liftContractM " Cannot get user address" $
63- payPubKeyHashBaseAddress networkId owner ownerStake
63+ addr <- liftedM " Cannot get address" getWalletAddress
6464 utxos <- liftedM " Cannot get user utxos" $ utxosAt addr
6565 marketplaceValidator' <- unwrap <$> marketplaceValidator
6666 lockingScript <- mkLockScript collectionNftCs lockLockup lockLockupEnd
@@ -95,11 +95,8 @@ mintWithCollectionTest
9595 constraints = mconcat
9696 [ Constraints .mustMintValueWithRedeemer (wrap $ toData $ MintToken nft)
9797 nftValue
98- , Constraints .mustPayToScript marketplaceValidator'.validatorHash
99- ( wrap $ toData $ MarketplaceDatum
100- { getMarketplaceDatum: curr /\ tn }
101- )
102- nftValue
98+ , payBehaviour retBehaviour marketplaceValidator'.validatorHash
99+ (curr /\ tn)
103100 , Constraints .mustPayToScript lockingScriptHash
104101 ( wrap $ toData $ LockDatum
105102 { sgNft: curr
@@ -127,7 +124,7 @@ mintWithCollection'
127124 . CurrencySymbol /\ TokenName
128125 -> MintParams
129126 -> Contract r (TransactionHash /\ (CurrencySymbol /\ TokenName ) /\ NftData )
130- mintWithCollection' c p = mintWithCollectionTest c p pure
127+ mintWithCollection' c p = mintWithCollectionTest ToMarketPlace c p pure
131128
132129-- | Mint the self-governed NFT for the given collection.
133130mintWithCollection
0 commit comments