{-# LANGUAGE OverloadedStrings #-}
{-# OPTIONS_GHC -Wno-incomplete-uni-patterns #-}

module Test.Cardano.Chain.Common.Example (
  exampleAddress,
  exampleAddress1,
  exampleAddress2,
  exampleAddress3,
  exampleAddress4,
  exampleAttributes,
  exampleAddrSpendingData_VerKey,
  exampleChainDifficulty,
  exampleKeyHash,
)
where

import Cardano.Chain.Common (
  AddrAttributes (..),
  AddrSpendingData (..),
  Address,
  Attributes,
  ChainDifficulty (..),
  HDAddressPayload (..),
  KeyHash,
  NetworkMagic (..),
  hashKey,
  makeAddress,
  mkAttributes,
 )
import Cardano.Prelude
import Test.Cardano.Crypto.CBOR (getBytes)
import Test.Cardano.Crypto.Example (
  exampleRedeemVerificationKey,
  exampleVerificationKey,
  exampleVerificationKeys,
 )

exampleAttributes :: Attributes ()
exampleAttributes :: Attributes ()
exampleAttributes = forall h. h -> Attributes h
mkAttributes ()

exampleAddrSpendingData_VerKey :: AddrSpendingData
exampleAddrSpendingData_VerKey :: AddrSpendingData
exampleAddrSpendingData_VerKey = VerificationKey -> AddrSpendingData
VerKeyASD VerificationKey
exampleVerificationKey

exampleAddress :: Address
exampleAddress :: Address
exampleAddress = AddrSpendingData -> AddrAttributes -> Address
makeAddress AddrSpendingData
exampleAddrSpendingData_VerKey AddrAttributes
attrs
  where
    attrs :: AddrAttributes
attrs = Maybe HDAddressPayload -> NetworkMagic -> AddrAttributes
AddrAttributes Maybe HDAddressPayload
hap NetworkMagic
nm
    hap :: Maybe HDAddressPayload
hap = forall a. a -> Maybe a
Just (ByteString -> HDAddressPayload
HDAddressPayload (Int -> Int -> ByteString
getBytes Int
32 Int
32))
    nm :: NetworkMagic
nm = NetworkMagic
NetworkMainOrStage

exampleAddress1 :: Address
exampleAddress1 :: Address
exampleAddress1 = AddrSpendingData -> AddrAttributes -> Address
makeAddress AddrSpendingData
easd AddrAttributes
attrs
  where
    easd :: AddrSpendingData
easd = VerificationKey -> AddrSpendingData
VerKeyASD VerificationKey
vk
    [VerificationKey
vk] = Int -> Int -> [VerificationKey]
exampleVerificationKeys Int
24 Int
1
    attrs :: AddrAttributes
attrs = Maybe HDAddressPayload -> NetworkMagic -> AddrAttributes
AddrAttributes Maybe HDAddressPayload
hap NetworkMagic
nm
    hap :: Maybe HDAddressPayload
hap = forall a. Maybe a
Nothing :: Maybe HDAddressPayload
    nm :: NetworkMagic
nm = NetworkMagic
NetworkMainOrStage

exampleAddress2 :: Address
exampleAddress2 :: Address
exampleAddress2 = AddrSpendingData -> AddrAttributes -> Address
makeAddress AddrSpendingData
easd AddrAttributes
attrs
  where
    easd :: AddrSpendingData
easd = RedeemVerificationKey -> AddrSpendingData
RedeemASD RedeemVerificationKey
exampleRedeemVerificationKey
    attrs :: AddrAttributes
attrs = Maybe HDAddressPayload -> NetworkMagic -> AddrAttributes
AddrAttributes Maybe HDAddressPayload
hap NetworkMagic
nm
    hap :: Maybe HDAddressPayload
hap = forall a. a -> Maybe a
Just (ByteString -> HDAddressPayload
HDAddressPayload (Int -> Int -> ByteString
getBytes Int
15 Int
32))
    nm :: NetworkMagic
nm = NetworkMagic
NetworkMainOrStage

exampleAddress3 :: Address
exampleAddress3 :: Address
exampleAddress3 = AddrSpendingData -> AddrAttributes -> Address
makeAddress AddrSpendingData
easd AddrAttributes
attrs
  where
    easd :: AddrSpendingData
easd = VerificationKey -> AddrSpendingData
VerKeyASD VerificationKey
vk
    [VerificationKey
vk] = Int -> Int -> [VerificationKey]
exampleVerificationKeys Int
20 Int
1
    attrs :: AddrAttributes
attrs = Maybe HDAddressPayload -> NetworkMagic -> AddrAttributes
AddrAttributes Maybe HDAddressPayload
hap NetworkMagic
nm
    hap :: Maybe HDAddressPayload
hap = forall a. a -> Maybe a
Just (ByteString -> HDAddressPayload
HDAddressPayload (Int -> Int -> ByteString
getBytes Int
17 Int
32))
    nm :: NetworkMagic
nm = Word32 -> NetworkMagic
NetworkTestnet Word32
9973261

exampleAddress4 :: Address
exampleAddress4 :: Address
exampleAddress4 = AddrSpendingData -> AddrAttributes -> Address
makeAddress AddrSpendingData
easd AddrAttributes
attrs
  where
    easd :: AddrSpendingData
easd = AddrSpendingData
exampleAddrSpendingData_VerKey
    attrs :: AddrAttributes
attrs = Maybe HDAddressPayload -> NetworkMagic -> AddrAttributes
AddrAttributes forall a. Maybe a
Nothing NetworkMagic
nm
    nm :: NetworkMagic
nm = Word32 -> NetworkMagic
NetworkTestnet Word32
11111911

exampleChainDifficulty :: ChainDifficulty
exampleChainDifficulty :: ChainDifficulty
exampleChainDifficulty = Word64 -> ChainDifficulty
ChainDifficulty Word64
9999

exampleKeyHash :: KeyHash
exampleKeyHash :: KeyHash
exampleKeyHash = VerificationKey -> KeyHash
hashKey VerificationKey
exampleVerificationKey