Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor
MultiSig
/ Tx
defs to Tx
module
- move transaction definitions from `UTxO` to own module - add hashScript to `MultiSignatureScript` typeclass - define first tag for native multi-signature - move address defintions to `Address module`
- Loading branch information
Showing
23 changed files
with
415 additions
and
339 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
{-# LANGUAGE LambdaCase #-} | ||
|
||
module Address | ||
( Addr(..) | ||
, Ix | ||
, Ptr(..) | ||
, mkRwdAcnt | ||
) | ||
where | ||
|
||
import Data.Typeable (Typeable) | ||
import Data.Word (Word8) | ||
import Numeric.Natural (Natural) | ||
|
||
import Cardano.Binary (ToCBOR(toCBOR), encodeListLen) | ||
import Cardano.Crypto.Hash (HashAlgorithm) | ||
|
||
import Delegation.PoolParams (RewardAcnt(..)) | ||
import Keys | ||
import Slot (Slot(..)) | ||
|
||
-- |An address for UTxO. | ||
data Addr hashAlgo dsignAlgo | ||
= AddrTxin | ||
{ _payHK :: KeyHash hashAlgo dsignAlgo | ||
, _stakeHK :: KeyHash hashAlgo dsignAlgo | ||
} | ||
| AddrPtr | ||
{ _stakePtr :: Ptr | ||
} | ||
deriving (Show, Eq, Ord) | ||
|
||
instance | ||
(Typeable dsignAlgo, HashAlgorithm hashAlgo) | ||
=> ToCBOR (Addr hashAlgo dsignAlgo) | ||
where | ||
toCBOR = \case | ||
AddrTxin payHK stakeHK -> | ||
encodeListLen 3 | ||
<> toCBOR (0 :: Word8) | ||
<> toCBOR payHK | ||
<> toCBOR stakeHK | ||
AddrPtr stakePtr -> | ||
encodeListLen 2 | ||
<> toCBOR (1 :: Word8) | ||
<> toCBOR stakePtr | ||
|
||
type Ix = Natural | ||
|
||
-- | Pointer to a slot, transaction index and index in certificate list. | ||
data Ptr | ||
= Ptr Slot Ix Ix | ||
deriving (Show, Eq, Ord) | ||
|
||
instance ToCBOR Ptr where | ||
toCBOR (Ptr slot txIx certIx) = | ||
encodeListLen 3 | ||
<> toCBOR slot | ||
<> toCBOR txIx | ||
<> toCBOR certIx | ||
|
||
mkRwdAcnt | ||
:: ( HashAlgorithm hashAlgo | ||
, DSIGNAlgorithm dsignAlgo | ||
) | ||
=> KeyPair dsignAlgo | ||
-> RewardAcnt hashAlgo dsignAlgo | ||
mkRwdAcnt keys = RewardAcnt $ hashKey $ vKey keys |
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 was deleted.
Oops, something went wrong.
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
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
Oops, something went wrong.