-
Notifications
You must be signed in to change notification settings - Fork 211
/
ExtraSigs.hs
66 lines (58 loc) · 1.93 KB
/
ExtraSigs.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE UndecidableInstances #-}
-- |
-- Copyright: © 2020-2022 IOHK
-- License: Apache-2.0
--
-- Raw extra signers required data extraction from 'Tx'
--
module Cardano.Wallet.Read.Tx.ExtraSigs where
import Prelude
import Cardano.Api
( AllegraEra, AlonzoEra, BabbageEra, ByronEra, ConwayEra, MaryEra, ShelleyEra )
import Cardano.Ledger.Alonzo.TxBody
( reqSignerHashesTxBodyL )
import Cardano.Ledger.Core
( bodyTxL )
import Cardano.Ledger.Crypto
( StandardCrypto )
import Cardano.Ledger.Keys
( KeyHash, KeyRole (..) )
import Cardano.Wallet.Read.Eras
( EraFun (..) )
import Cardano.Wallet.Read.Tx
( Tx (..) )
import Cardano.Wallet.Read.Tx.Eras
( onTx )
import Control.Lens
( (^.) )
import Data.Set
( Set )
type family ExtraSigsType era where
ExtraSigsType ByronEra = ()
ExtraSigsType ShelleyEra = ()
ExtraSigsType AllegraEra = ()
ExtraSigsType MaryEra = ()
ExtraSigsType AlonzoEra = Set (KeyHash 'Witness StandardCrypto)
ExtraSigsType BabbageEra = Set (KeyHash 'Witness StandardCrypto)
ExtraSigsType ConwayEra = Set (KeyHash 'Witness StandardCrypto)
newtype ExtraSigs era = ExtraSigs (ExtraSigsType era)
deriving instance Show (ExtraSigsType era) => Show (ExtraSigs era)
deriving instance Eq (ExtraSigsType era) => Eq (ExtraSigs era)
getEraExtraSigs :: EraFun Tx ExtraSigs
getEraExtraSigs
= EraFun
{ byronFun = \_ -> ExtraSigs ()
, shelleyFun = \_ -> ExtraSigs ()
, allegraFun = \_ -> ExtraSigs ()
, maryFun = \_ -> ExtraSigs ()
, alonzoFun = onTx $ \tx -> ExtraSigs
$ tx ^. bodyTxL . reqSignerHashesTxBodyL
, babbageFun = onTx $ \tx -> ExtraSigs
$ tx ^. bodyTxL . reqSignerHashesTxBodyL
, conwayFun = onTx $ \tx -> ExtraSigs
$ tx ^. bodyTxL . reqSignerHashesTxBodyL
}