Skip to content

Commit

Permalink
cli: fix address handling
Browse files Browse the repository at this point in the history
  • Loading branch information
deepfire committed Nov 23, 2020
1 parent f9f4964 commit 218df55
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions cardano-cli/src/Cardano/CLI/Shelley/Run/Genesis.hs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ import Ouroboros.Consensus.BlockchainTime (SystemStart (..))
import Ouroboros.Consensus.Shelley.Protocol (StandardCrypto)
import Ouroboros.Consensus.Shelley.Node (ShelleyGenesisStaking(..))

import qualified Shelley.Spec.Ledger.Address as Ledger
import qualified Shelley.Spec.Ledger.API as Ledger
import qualified Shelley.Spec.Ledger.Keys as Ledger
import qualified Shelley.Spec.Ledger.BaseTypes as Ledger
Expand Down Expand Up @@ -465,13 +464,14 @@ runGenesisCreateStaked (GenesisDir rootdir)
stdeldir = rootdir </> "stake-delegator-keys"
utxodir = rootdir </> "utxo-keys"

genStuffedAddress :: IO (Address Shelley)
genStuffedAddress :: IO (AddressInEra ShelleyEra)
genStuffedAddress =
ShelleyAddress
shelleyAddressInEra <$>
(ShelleyAddress
<$> pure Ledger.Testnet
<*> (Ledger.KeyHashObj . mkKeyHash . read64BitInt
<$> Crypto.runSecureRandom (getRandomBytes 8))
<*> pure Ledger.StakeRefNull
<$> Crypto.runSecureRandom (getRandomBytes 8))
<*> pure Ledger.StakeRefNull)

read64BitInt :: ByteString -> Int
read64BitInt = (fromIntegral :: Word64 -> Int)
Expand Down Expand Up @@ -576,7 +576,7 @@ createDelegatorCredentials dir index = do

data Delegation
= Delegation
{ dInitialUtxoAddr :: Address Shelley
{ dInitialUtxoAddr :: AddressInEra ShelleyEra
, dDelegStaking :: Ledger.KeyHash Ledger.Staking StandardCrypto
, dPoolParams :: Ledger.PoolParams StandardShelley
}
Expand Down Expand Up @@ -655,7 +655,7 @@ computeDelegation nw delegDir pool delegIx = do
$ readFileTextEnvelope (AsVerificationKey AsStakeKey) stakeVKF

pure Delegation
{ dInitialUtxoAddr = initialUtxoAddr
{ dInitialUtxoAddr = shelleyAddressInEra initialUtxoAddr
, dDelegStaking = Ledger.hashKey stakeVK
, dPoolParams = pool
}
Expand Down Expand Up @@ -740,7 +740,7 @@ updateTemplate (SystemStart start)
nonDelegCoin = fromIntegral $ fromMaybe (sgMaxLovelaceSupply template) (unLovelace <$> mAmountNonDeleg)
delegCoin = fromIntegral amountDeleg

distribute :: Integer -> [Address Shelley] -> [(Address Shelley, Lovelace)]
distribute :: Integer -> [AddressInEra ShelleyEra] -> [(AddressInEra ShelleyEra, Lovelace)]
distribute funds addrs =
fst $ List.foldl' folder ([], fromIntegral funds) addrs
where
Expand Down

0 comments on commit 218df55

Please sign in to comment.