Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Script Api Redesign #586

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions cardano-api/cardano-api.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ library internal
Cardano.Api.Orphans
Cardano.Api.Pretty
Cardano.Api.Protocol
Cardano.Api.Protocol.Version
Cardano.Api.Protocol.AvailableEras
Cardano.Api.ProtocolParameters
Cardano.Api.Query
Cardano.Api.Query.Expr
Expand All @@ -132,6 +132,8 @@ library internal
Cardano.Api.ReexposeNetwork
Cardano.Api.Rewards
Cardano.Api.Script
Cardano.Api.Experimental.Eras
Cardano.Api.Experimental.Tx
Cardano.Api.ScriptData
Cardano.Api.SerialiseBech32
Cardano.Api.SerialiseCBOR
Expand Down Expand Up @@ -237,7 +239,6 @@ library
Cardano.Api.ChainSync.Client
Cardano.Api.ChainSync.ClientPipelined
Cardano.Api.Crypto.Ed25519Bip32
Cardano.Api.Experimental
Cardano.Api.Ledger
Cardano.Api.Network
Cardano.Api.Shelley
Expand Down
17 changes: 14 additions & 3 deletions cardano-api/internal/Cardano/Api/Convenience/Construction.hs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ where
import Cardano.Api.Address
import Cardano.Api.Certificate
import Cardano.Api.Eon.ShelleyBasedEra
import Cardano.Api.Eras
import Cardano.Api.Experimental.Eras (sbeToEra)
import Cardano.Api.Experimental.Tx
import Cardano.Api.Fees
import Cardano.Api.ProtocolParameters
import Cardano.Api.Query
Expand All @@ -31,6 +34,7 @@ import qualified Cardano.Ledger.Keys as L

import qualified Data.List as List
import qualified Data.Map.Strict as Map
import Data.Maybe
import Data.Set (Set)
import qualified Data.Set as Set
import Data.Text (Text)
Expand Down Expand Up @@ -72,7 +76,9 @@ constructBalancedTx
stakeDelegDeposits
drepDelegDeposits
shelleyWitSigningKeys = do
BalancedTxBody _ txbody _txBalanceOutput _fee <-
let availableEra = fromMaybe (error "TODO") $ sbeToEra sbe

BalancedTxBody _ unsignedTx _txBalanceOutput _fee <-
makeTransactionBodyAutoBalance
sbe
systemStart
Expand All @@ -86,8 +92,13 @@ constructBalancedTx
changeAddr
mOverrideWits

let keyWits = map (makeShelleyKeyWitness sbe txbody) shelleyWitSigningKeys
return $ makeSignedTransaction keyWits txbody
let alternateKeyWits = map (makeKeyWitness availableEra unsignedTx) shelleyWitSigningKeys
signedTx = signTx availableEra [] alternateKeyWits unsignedTx

caseShelleyToAlonzoOrBabbageEraOnwards
(const $ error "constructBalancedTx: TODO Fail")
(\w -> return $ ShelleyTx sbe $ obtainShimConstraints w signedTx)
sbe

data TxInsExistError
= TxInsDoNotExist [TxIn]
Expand Down
16 changes: 16 additions & 0 deletions cardano-api/internal/Cardano/Api/Experimental/Eras.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
module Cardano.Api.Experimental.Eras
( -- * New Era interface
BabbageEra
, ConwayEra
, Era (..)
, UseEra
, AvailableErasToSbe
, SbeToAvailableEras
, ToConstrainedEra
, useEra
, protocolVersionToSbe
, sbeToEra
)
where

import Cardano.Api.Protocol.AvailableEras
Loading