@@ -8,8 +8,8 @@ module Mantis.Command.Mint (
8
8
) where
9
9
10
10
11
- import Cardano.Api (ConsensusModeParams (CardanoModeParams ), CardanoEra ( MaryEra ), EpochSlots (.. ), NetworkId (.. ), NetworkMagic (.. ), PolicyId (.. ), anyAddressInEra , getTxId , makeTransactionBody )
12
- import Cardano.Api.Shelley (ShelleyWitnessSigningKey (.. ), TxOut (.. ), TxOutValue (.. ), UTxO (.. ), makeScriptWitness , makeSignedTransaction , makeShelleyKeyWitness )
11
+ import Cardano.Api (ConsensusModeParams (CardanoModeParams ), EpochSlots (.. ), IsShelleyBasedEra , NetworkId (.. ), NetworkMagic (.. ), PolicyId (.. ), ShelleyBasedEra , TxOutDatumHash ( .. ), anyAddressInEra , getTxId , makeTransactionBody , multiAssetSupportedInEra , shelleyBasedToCardanoEra )
12
+ import Cardano.Api.Shelley (ShelleyWitnessSigningKey (.. ), TxOut (.. ), TxOutValue (.. ), UTxO (.. ), makeSignedTransaction , makeShelleyKeyWitness )
13
13
import Control.Monad.IO.Class (MonadIO , liftIO )
14
14
import Control.Monad.Extra (whenJust )
15
15
import Data.Aeson (encode )
@@ -18,7 +18,7 @@ import Data.Maybe (fromMaybe)
18
18
import Mantis.Command.Types (Configuration (.. ), Mantis (.. ))
19
19
import Mantis.Query (adjustSlot , queryProtocol , queryTip , queryUTxO , submitTransaction )
20
20
import Mantis.Script (mintingScript )
21
- import Mantis.Transaction (includeFee , makeTransaction , printUTxO , printValue , readMinting , summarizeValues , supportedMultiAsset )
21
+ import Mantis.Transaction (includeFee , makeTransaction , printUTxO , printValue , readMinting , summarizeValues )
22
22
import Mantis.Types (MantisM , SlotRef , foistMantisEither , printMantis )
23
23
import Mantis.Wallet (makeVerificationKeyHash , readAddress , readSigningKey , readVerificationKey )
24
24
import Ouroboros.Network.Protocol.LocalTxSubmission.Type (SubmitResult (.. ))
@@ -45,21 +45,24 @@ options =
45
45
<*> O. optional (O. strOption $ O. long " metadata" <> O. metavar " METADATA_FILE" <> O. help " Path to output metadata JSON file." )
46
46
47
47
48
- main :: MonadFail m
48
+ main :: IsShelleyBasedEra era
49
+ => MonadFail m
49
50
=> MonadIO m
50
- => (String -> MantisM m () )
51
+ => ShelleyBasedEra era
52
+ -> (String -> MantisM m () )
51
53
-> FilePath
52
54
-> FilePath
53
55
-> Maybe SlotRef
54
56
-> Maybe String
55
57
-> Maybe FilePath
56
58
-> Maybe FilePath
57
59
-> MantisM m ()
58
- main debugMantis configFile mintingFile tokenSlot outputAddress scriptFile metadataFile =
60
+ main sbe debugMantis configFile mintingFile tokenSlot outputAddress scriptFile metadataFile =
59
61
do
60
62
Configuration {.. } <- liftIO $ read <$> readFile configFile
61
63
62
64
let
65
+ era = shelleyBasedToCardanoEra sbe
63
66
protocol = CardanoModeParams $ EpochSlots epochSlots
64
67
network = maybe Mainnet (Testnet . NetworkMagic ) magic
65
68
debugMantis " "
@@ -71,7 +74,7 @@ main debugMantis configFile mintingFile tokenSlot outputAddress scriptFile metad
71
74
let
72
75
before = (`adjustSlot` tip) <$> tokenSlot
73
76
74
- pparams <- queryProtocol socketPath protocol network
77
+ pparams <- queryProtocol sbe socketPath protocol network
75
78
debugMantis " "
76
79
debugMantis $ " Protocol parameters: " ++ LBS. unpack (encode pparams)
77
80
@@ -91,7 +94,7 @@ main debugMantis configFile mintingFile tokenSlot outputAddress scriptFile metad
91
94
92
95
debugMantis " "
93
96
debugMantis " Unspect UTxO:"
94
- utxo@ (UTxO utxo') <- queryUTxO socketPath protocol address network
97
+ utxo@ (UTxO utxo') <- queryUTxO sbe socketPath protocol address network
95
98
printUTxO " " utxo
96
99
97
100
let
@@ -121,25 +124,24 @@ main debugMantis configFile mintingFile tokenSlot outputAddress scriptFile metad
121
124
debugMantis $ " Minting: " ++ show minting
122
125
123
126
let
124
- Just address'' = anyAddressInEra MaryEra address'
127
+ Just address'' = anyAddressInEra era address'
128
+ Right supportedMultiAsset = multiAssetSupportedInEra era
125
129
txBody <- includeFee network pparams nIn 1 1 0
126
- $ makeTransaction
130
+ $ makeTransaction
127
131
(M. keys utxo')
128
- [TxOut address'' (TxOutValue supportedMultiAsset value')]
132
+ [TxOut address'' (TxOutValue supportedMultiAsset value') TxOutDatumHashNone ]
129
133
before
130
134
(Just metadata)
131
- Nothing
132
- (Just minting)
135
+ (Just (PolicyId scriptHash, script, minting))
133
136
txRaw <- foistMantisEither $ makeTransactionBody txBody
134
137
debugMantis " "
135
138
debugMantis $ " Transaction: " ++ show txRaw
136
139
137
140
let
138
141
witness = makeShelleyKeyWitness txRaw
139
- $ WitnessPaymentExtendedKey signingKey
140
- witness' = makeScriptWitness script
141
- txSigned = makeSignedTransaction [witness, witness'] txRaw
142
- result <- submitTransaction socketPath protocol network txSigned
142
+ $ either WitnessPaymentKey WitnessPaymentExtendedKey signingKey
143
+ txSigned = makeSignedTransaction [witness] txRaw
144
+ result <- submitTransaction sbe socketPath protocol network txSigned
143
145
printMantis " "
144
146
case result of
145
147
SubmitSuccess -> printMantis $ " Success: " ++ show (getTxId txRaw)
0 commit comments