From 77d96dc6de49c1224f68caabc56698ba50bc4999 Mon Sep 17 00:00:00 2001 From: Pawel Jakubas Date: Mon, 3 Aug 2020 18:45:10 +0200 Subject: [PATCH] bump dependencies and add Shelley network constructors --- cardano-transactions.cabal | 6 +- src/Data/UTxO/Transaction/Cardano/Shelley.hs | 87 ++++++++++++++++++++ stack.yaml | 53 +++++++++++- 3 files changed, 142 insertions(+), 4 deletions(-) create mode 100644 src/Data/UTxO/Transaction/Cardano/Shelley.hs diff --git a/cardano-transactions.cabal b/cardano-transactions.cabal index 818aeb3..6ca7917 100644 --- a/cardano-transactions.cabal +++ b/cardano-transactions.cabal @@ -1,10 +1,10 @@ cabal-version: 1.12 --- This file has been generated from package.yaml by hpack version 0.31.2. +-- This file has been generated from package.yaml by hpack version 0.33.0. -- -- see: https://github.com/sol/hpack -- --- hash: bb07e37f882f89fbc02bca7bc78436aaa4ecca901ec7cd41b52577641ebd852d +-- hash: 6fa5d8537d9df3cbcb0caac4be815b9526e9c319137d49264e67a9a06ddaf2fa name: cardano-transactions version: 1.0.0 @@ -33,6 +33,7 @@ library exposed-modules: Data.UTxO.Transaction Data.UTxO.Transaction.Cardano.Byron + Data.UTxO.Transaction.Cardano.Shelley other-modules: Paths_cardano_transactions hs-source-dirs: @@ -50,6 +51,7 @@ library , cryptonite , extra , memory + , shelley-spec-ledger , text if flag(release) ghc-options: -Werror diff --git a/src/Data/UTxO/Transaction/Cardano/Shelley.hs b/src/Data/UTxO/Transaction/Cardano/Shelley.hs new file mode 100644 index 0000000..11b90e7 --- /dev/null +++ b/src/Data/UTxO/Transaction/Cardano/Shelley.hs @@ -0,0 +1,87 @@ +{-# LANGUAGE DataKinds #-} +{-# LANGUAGE InstanceSigs #-} +{-# LANGUAGE ScopedTypeVariables #-} +{-# LANGUAGE TypeFamilies #-} + +{-# OPTIONS_HADDOCK prune #-} +{-# OPTIONS_GHC -Wno-unrecognised-pragmas #-} -- needed for {#- HLINT ... #-} + +module Data.UTxO.Transaction.Cardano.Shelley + ( + -- * Initialization + mkInit + , mainnetMagic + , testnetMagic + + -- Internal + , Shelley + ) where + +import Cardano.Chain.UTxO + ( TxIn (..), TxInWitness (..), TxOut (..), TxSigData (..) ) +import Cardano.Crypto.Signing + ( SigningKey (..) ) +import Data.List.NonEmpty + ( NonEmpty ) +import Data.UTxO.Transaction + ( ErrMkPayment (..), MkPayment (..) ) +import Shelley.Spec.Ledger.BaseTypes + ( Network (..) ) + + +-- | Construct a payment 'Init' for /Shelley/ from primitive types. +-- +-- __examples__: +-- +-- >>> mkInit Mainnet == mainnetMagic +-- True +-- +-- >>> mkInit Testnet == testnetMagic +-- True +-- +-- @since 2.0.0 +mkInit + :: Network + -- ^ A network tag + -> Init Shelley +mkInit net = net + +-- | Pre-defined 'Init' magic for /Shelley/ MainNet. +-- +-- @since 2.0.0 +mainnetMagic :: Init Shelley +mainnetMagic = mkInit Mainnet + +-- | Pre-defined 'Init' magic for /Shelley/ TestNet. +-- +-- @since 2.0.0 +testnetMagic :: Init Shelley +testnetMagic = mkInit Testnet + +-- +-- MkPayment instance +-- + +-- Type-level constructor capturing types for 'Shelley'. +data Shelley + +instance MkPayment Shelley where + type Init Shelley = Network + + type Input Shelley = TxIn + type Output Shelley = TxOut + type SignKey Shelley = SigningKey + + type CoinSel Shelley = + (Network, [TxIn], [TxOut]) + + type Tx Shelley = Either + ErrMkPayment + (Network, NonEmpty TxIn, NonEmpty TxOut, TxSigData, [TxInWitness]) + + empty = undefined + addInput = undefined + addOutput = undefined + lock = undefined + signWith = undefined + serialize = undefined diff --git a/stack.yaml b/stack.yaml index 9f93799..4828f04 100644 --- a/stack.yaml +++ b/stack.yaml @@ -1,4 +1,4 @@ -resolver: https://raw.githubusercontent.com/input-output-hk/cardano-haskell/633f6141c3e7211dbb0c6ae6ad50d4976313e190/snapshots/cardano-1.14.2.yaml +resolver: lts-14.25 # Generate files required by Weeder. # See https://github.com/ndmitchell/weeder/issues/53 @@ -8,7 +8,56 @@ packages: - . extra-deps: - - hedgehog-quickcheck-0.1.1 +- hedgehog-quickcheck-0.1.1 +- base58-bytestring-0.1.0 +- canonical-json-0.6.0.0 +- quiet-0.2 +- streaming-binary-0.3.0.1 +- moo-1.2 +- gray-code-0.3.1 +- Unique-0.4.7.7 +- generic-monoid-0.1.0.1 + +- git: https://github.com/input-output-hk/cardano-prelude + commit: 316c854d1d3089f480708ad5cd5ecf8a74423ddd + subdirs: + - . + - test + +- git: https://github.com/input-output-hk/cardano-base + commit: 7d795c3040ea7785812efa1c97864bbb41b15d3e + subdirs: + - binary + - binary/test + - cardano-crypto-class + - slotting + - cardano-crypto-praos + +- git: https://github.com/input-output-hk/cardano-crypto + commit: 2547ad1e80aeabca2899951601079408becbc92c + +- git: https://github.com/input-output-hk/cardano-ledger-specs + commit: 183a70c001587d9b1977541deae28c3e44713907 + subdirs: + - byron/ledger/impl + - byron/crypto + - byron/ledger/impl/test + - byron/crypto/test + - byron/chain/executable-spec + - byron/ledger/executable-spec + - semantics/executable-spec + - semantics/small-steps-test + - shelley/chain-and-ledger/dependencies/non-integer + - shelley/chain-and-ledger/executable-spec + - shelley/chain-and-ledger/executable-spec/test + +- git: https://github.com/input-output-hk/iohk-monitoring-framework + commit: efa4b5ecd7f0a13124616b12679cd42517cd905a + subdirs: + - contra-tracer + +- git: https://github.com/input-output-hk/goblins + commit: 26d35ad52fe9ade3391532dbfeb2f416f07650bc flags: # Bundle VRF crypto in libsodium and do not rely on an external fork to have it.