-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use ledger keys' roles casting with explicit whitelist, instead of co…
…erceKeyRole
- Loading branch information
1 parent
5e8bd69
commit 2626cce
Showing
10 changed files
with
58 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
{-# LANGUAGE DataKinds #-} | ||
{-# LANGUAGE DefaultSignatures #-} | ||
{-# LANGUAGE FlexibleInstances #-} | ||
{-# LANGUAGE MultiParamTypeClasses #-} | ||
|
||
module Cardano.Api.Ledger.Keys where | ||
|
||
import qualified Cardano.Api.ReexposeLedger as L | ||
|
||
import Cardano.Ledger.Keys (HasKeyRole (..)) | ||
import qualified Cardano.Ledger.Keys as Shelley | ||
|
||
-- | Allows casting of the ledger keys between different roles. In comparison to the 'coerceKeyRole', this | ||
-- class requires explicit listing of the key types we allow casting of. This prevents from accidental | ||
-- casting of a new key role when ledger interface changes. | ||
class CastLedgerKey keyType keyRoleA keyRoleB where | ||
castLedgerKey :: keyType keyRoleA c -> keyType keyRoleB c | ||
default castLedgerKey :: HasKeyRole keyType => keyType keyRoleA c -> keyType keyRoleB c | ||
castLedgerKey = coerceKeyRole | ||
|
||
instance CastLedgerKey L.Credential L.StakePool L.Staking | ||
instance CastLedgerKey L.Credential L.Staking L.StakePool | ||
|
||
instance CastLedgerKey L.Credential L.DRepRole L.HotCommitteeRole | ||
instance CastLedgerKey L.Credential L.HotCommitteeRole L.DRepRole | ||
|
||
instance CastLedgerKey Shelley.VKey L.Payment L.Witness | ||
instance CastLedgerKey Shelley.VKey L.Witness L.Payment | ||
|
||
instance CastLedgerKey Shelley.KeyHash L.Payment L.Witness | ||
instance CastLedgerKey Shelley.KeyHash L.Witness L.Payment |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters