Skip to content

Commit

Permalink
Tada, compiles 🎉
Browse files Browse the repository at this point in the history
  • Loading branch information
smelc committed May 3, 2024
1 parent 16e939d commit 4b53e8e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
7 changes: 4 additions & 3 deletions cardano-faucet/src/Cardano/Faucet.hs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ import Cardano.Api (TxInMode, AddressAny, QueryInMode(..), UTxO(unUTxO), QueryUT
import Cardano.Api.Byron ()
import qualified Cardano.Api.Ledger as L

import Cardano.Api.Shelley (makeStakeAddress, StakeCredential(StakeCredentialByKey), verificationKeyHash, castVerificationKey, SigningKey(StakeExtendedSigningKey), StakeAddress, PoolId, NetworkId, StakeExtendedKey, IsCardanoEra, LocalTxMonitorClient(..), SlotNo)
import Cardano.Api.Shelley (makeStakeAddress, StakeCredential(StakeCredentialByKey), verificationKeyHash, castVerificationKey, SigningKey(StakeExtendedSigningKey), StakeAddress, PoolId, NetworkId, StakeExtendedKey, LocalTxMonitorClient(..), SlotNo)
import Cardano.CLI.EraBased.Run.Address (buildShelleyAddress)
import Cardano.Faucet.Misc
import Cardano.Faucet.Types (FaucetState(..), FaucetConfigFile(..), FaucetValue, FaucetError(..), StakeKeyIntermediateState(..), StakeKeyState(..), accountKeyToStakeKey, parseConfig, mnemonicToRootKey, rootKeytoAcctKey, renderFaucetError, accountKeyToPaymentKey)
import Cardano.Faucet.Utils
Expand Down Expand Up @@ -218,7 +219,7 @@ submissionClient dryRun txQueue = Net.Tx.LocalTxSubmissionClient waitForTxAndLoo
queryManyStakeAddr :: ShelleyBasedEra era -> NetworkId -> [StakeCredential] -> QueryInMode (Either EraMismatch (Map StakeAddress L.Coin, Map StakeAddress PoolId))
queryManyStakeAddr sbe network creds = QueryInEra (QueryInShelleyBasedEra sbe (QueryStakeAddresses (Set.fromList creds) network))

newFaucetState :: IsCardanoEra era => FaucetConfigFile -> TQueue (TxInMode, ByteString) -> ExceptT FaucetError IO (FaucetState era)
newFaucetState :: FaucetConfigFile -> TQueue (TxInMode, ByteString) -> ExceptT FaucetError IO (FaucetState era)
newFaucetState fsConfig fsTxQueue = do
(fsUtxoTMVar,fsStakeTMVar,fsSendMoneyRateLimitState,fsDelegationRateLimitState) <- liftIO $ (,,,) <$> newEmptyTMVarIO <*> newEmptyTMVarIO <*> newTMVarIO mempty <*> newTMVarIO mempty
fsRootKey <- mnemonicToRootKey $ fcfMnemonic fsConfig
Expand All @@ -231,7 +232,7 @@ newFaucetState fsConfig fsTxQueue = do
fsPaymentVkey = pay_vkey
fsBucketSizes = findAllSizes fsConfig
fsNetwork = fcfNetwork fsConfig
fsOwnAddress <- withExceptT FaucetErrorShelleyAddr $ AddressShelley <$> buildShelleyAddress (castVerificationKey pay_vkey) Nothing fsNetwork
fsOwnAddress <- withExceptT FaucetErrorAddr $ AddressShelley <$> buildShelleyAddress (castVerificationKey pay_vkey) Nothing fsNetwork
pure $ FaucetState{..}

finish :: IO (Net.Query.ClientStAcquired block point query IO ())
Expand Down
7 changes: 4 additions & 3 deletions cardano-faucet/src/Cardano/Faucet/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ import Prelude (fail)

import Cardano.Address.Derivation (Depth(RootK, AccountK, PaymentK, PolicyK), XPrv, genMasterKeyFromMnemonic, indexFromWord32, deriveAccountPrivateKey, deriveAddressPrivateKey, Index, DerivationType(Hardened, Soft))
import Cardano.Address.Style.Shelley (Shelley, Role(UTxOExternal, Stake), derivePolicyPrivateKey)
import Cardano.Api (AnyCardanoEra, InputDecodeError, TxIn, TxOut, CtxUTxO, TxInMode, TxId, FileError, AddressAny, AssetId(AssetId, AdaAssetId), Quantity, SigningKey, PaymentExtendedKey, VerificationKey, HashableScriptData)
import Cardano.Api (AnyCardanoEra, InputDecodeError, TxIn, TxOut, CtxUTxO, TxInMode, TxId, FileError, AddressAny, AssetId(AssetId, AdaAssetId), Quantity, SigningKey, PaymentExtendedKey, VerificationKey, HashableScriptData, docToText)
import qualified Cardano.Api.Ledger as L
import Cardano.Api.Shelley (PoolId, StakeExtendedKey, StakeCredential, AssetName(..), NetworkId(Testnet, Mainnet), NetworkMagic(NetworkMagic), ShelleyWitnessSigningKey)
import Cardano.CLI.Types.Errors.AddressCmdError
import Cardano.Mnemonic (mkSomeMnemonic, getMkSomeMnemonicError)
import Cardano.Prelude
import Control.Concurrent.STM (TMVar, TQueue)
Expand Down Expand Up @@ -60,7 +61,7 @@ data FaucetError = FaucetErrorSocketNotFound
| FaucetErrorConfigFileNotSet
| FaucetErrorBadMnemonic Text
| FaucetErrorBadIdx
| FaucetErrorShelleyAddr -- ShelleyAddressCmdError
| FaucetErrorAddr AddressCmdError
| FaucetErrorTodo2 Text
deriving Generic

Expand All @@ -71,7 +72,7 @@ renderFaucetError (FaucetErrorParsingConfig err) = show err
renderFaucetError FaucetErrorConfigFileNotSet = "$CONFIG_FILE not set"
renderFaucetError (FaucetErrorBadMnemonic msg) = "bad mnemonic " <> msg
renderFaucetError FaucetErrorBadIdx = "bad index"
renderFaucetError (FaucetErrorShelleyAddr {-err-}) = undefined -- show err
renderFaucetError (FaucetErrorAddr err) = docToText $ renderAddressCmdError $ err
renderFaucetError (FaucetErrorTodo2 err) = show err

-- errors that can be sent to the user
Expand Down

0 comments on commit 4b53e8e

Please sign in to comment.