Copyright | © 2018-2020 IOHK |
---|---|
License | Apache-2.0 |
Safe Haskell | None |
Language | Haskell2010 |
An extra interface for operation on transactions (e.g. creating witnesses, estimating size...). This makes it possible to decouple those operations from our wallet layer, keeping the implementation flexible to various backends.
Synopsis
-
data
TransactionLayer
k tx =
TransactionLayer
{
- mkTransaction :: AnyCardanoEra -> ( XPrv , Passphrase "encryption") -> ( Address -> Maybe (k ' AddressK XPrv , Passphrase "encryption")) -> ProtocolParameters -> TransactionCtx -> SelectionOf TxOut -> Either ErrMkTransaction ( Tx , tx)
- addVkWitnesses :: AnyCardanoEra -> ( XPrv , Passphrase "encryption") -> ( KeyHash , XPrv , Passphrase "encryption") -> ( Address -> Maybe (k ' AddressK XPrv , Passphrase "encryption")) -> ( TxIn -> Maybe Address ) -> tx -> tx
- mkUnsignedTransaction :: AnyCardanoEra -> XPub -> ProtocolParameters -> TransactionCtx -> SelectionOf TxOut -> Either ErrMkTransaction tx
- calcMinimumCost :: AnyCardanoEra -> ProtocolParameters -> TransactionCtx -> SelectionSkeleton -> Coin
- maxScriptExecutionCost :: ProtocolParameters -> [ Redeemer ] -> Coin
- evaluateMinimumFee :: forall era. IsShelleyBasedEra era => ProtocolParameters -> Tx era -> Coin
- estimateSignedTxSize :: forall era. IsShelleyBasedEra era => ProtocolParameters -> Tx era -> TxSize
- evaluateTransactionBalance :: forall era. IsShelleyBasedEra era => Tx era -> ProtocolParameters -> UTxO -> [( TxIn , TxOut , Maybe ( Hash "Datum"))] -> Value
- distributeSurplus :: FeePolicy -> Coin -> TxFeeAndChange [ TxOut ] -> Either ErrMoreSurplusNeeded ( TxFeeAndChange [ TxOut ])
- computeSelectionLimit :: AnyCardanoEra -> ProtocolParameters -> TransactionCtx -> [ TxOut ] -> SelectionLimit
- tokenBundleSizeAssessor :: TokenBundleMaxSize -> TokenBundleSizeAssessor
- constraints :: AnyCardanoEra -> ProtocolParameters -> TxConstraints
- decodeTx :: AnyCardanoEra -> tx -> ( Tx , TokenMapWithScripts , TokenMapWithScripts , [ Certificate ], Maybe ValidityIntervalExplicit )
- updateTx :: forall era. IsShelleyBasedEra era => Tx era -> TxUpdate -> Either ErrUpdateSealedTx ( Tx era)
- assignScriptRedeemers :: forall era. IsShelleyBasedEra era => ProtocolParameters -> TimeInterpreter ( Either PastHorizonException ) -> ( TxIn -> Maybe ( TxOut , Maybe ( Hash "Datum"))) -> [ Redeemer ] -> Tx era -> Either ErrAssignRedeemers ( Tx era)
-
data
DelegationAction
- = RegisterKeyAndJoin PoolId
- | Join PoolId
- | Quit
-
data
TransactionCtx
=
TransactionCtx
{
- txWithdrawal :: Withdrawal
- txMetadata :: Maybe TxMetadata
- txValidityInterval :: ( Maybe SlotNo , SlotNo )
- txDelegationAction :: Maybe DelegationAction
- txPlutusScriptExecutionCost :: Coin
- txAssetsToMint :: ( TokenMap , Map AssetId ( Script KeyHash ))
- txAssetsToBurn :: ( TokenMap , Map AssetId ( Script KeyHash ))
- txCollateralRequirement :: SelectionCollateralRequirement
- txFeePadding :: ! Coin
- defaultTransactionCtx :: TransactionCtx
- data Withdrawal
- withdrawalToCoin :: Withdrawal -> Coin
-
data
TxUpdate
=
TxUpdate
{
- extraInputs :: [( TxIn , TxOut )]
- extraCollateral :: [ TxIn ]
- extraOutputs :: [ TxOut ]
- feeUpdate :: TxFeeUpdate
- data TxFeeUpdate
-
data
TokenMapWithScripts
=
TokenMapWithScripts
{
- txTokenMap :: ! TokenMap
- txScripts :: !( Map TokenPolicyId AnyScript )
- emptyTokenMapWithScripts :: TokenMapWithScripts
-
data
AnyScript
- = NativeScript !( Script KeyHash )
- | PlutusScript ! PlutusScriptInfo
- newtype PlutusScriptInfo = PlutusScriptInfo { }
- data PlutusVersion
- data TxFeeAndChange change = TxFeeAndChange { }
- mapTxFeeAndChange :: ( Coin -> Coin ) -> (change1 -> change2) -> TxFeeAndChange change1 -> TxFeeAndChange change2
-
data
ValidityIntervalExplicit
=
ValidityIntervalExplicit
{
- invalidBefore :: !( Quantity "slot" Word64 )
- invalidHereafter :: !( Quantity "slot" Word64 )
- data ErrSignTx
- data ErrMkTransaction
- data ErrCannotJoin
- data ErrCannotQuit
- newtype ErrUpdateSealedTx = ErrExistingKeyWitnesses Int
- data ErrAssignRedeemers
- newtype ErrMoreSurplusNeeded = ErrMoreSurplusNeeded Coin
Interface
data TransactionLayer k tx Source #
TransactionLayer | |
|
data DelegationAction Source #
Whether the user is attempting any particular delegation action.
Instances
data TransactionCtx Source #
Some additional context about a transaction. This typically contains details that are known upfront about the transaction and are used to construct it from inputs selected from the wallet's UTxO.
TransactionCtx | |
|
Instances
defaultTransactionCtx :: TransactionCtx Source #
A default context with sensible placeholder. Can be used to reduce repetition for changing only sub-part of the default context.
data Withdrawal Source #
WithdrawalSelf RewardAccount ( NonEmpty DerivationIndex ) Coin | |
WithdrawalExternal RewardAccount ( NonEmpty DerivationIndex ) Coin | |
NoWithdrawal |
Instances
Eq Withdrawal Source # | |
Defined in Cardano.Wallet.Transaction (==) :: Withdrawal -> Withdrawal -> Bool Source # (/=) :: Withdrawal -> Withdrawal -> Bool Source # |
|
Show Withdrawal Source # | |
Defined in Cardano.Wallet.Transaction |
withdrawalToCoin :: Withdrawal -> Coin Source #
Describes modifications that can be made to a
Tx
using
$sel:updateTx:TransactionLayer
.
TxUpdate | |
|
data TxFeeUpdate Source #
Method to use when updating the fee of a transaction.
UseOldTxFee |
Instead of updating the fee, just use the old fee of the Tx (no-op for fee update). |
UseNewTxFee Coin |
Specify a new fee to use instead. |
Instances
Eq TxFeeUpdate Source # | |
Defined in Cardano.Wallet.Transaction (==) :: TxFeeUpdate -> TxFeeUpdate -> Bool Source # (/=) :: TxFeeUpdate -> TxFeeUpdate -> Bool Source # |
|
Show TxFeeUpdate Source # | |
Defined in Cardano.Wallet.Transaction |
data TokenMapWithScripts Source #
TokenMapWithScripts | |
|
Instances
Instances
Eq AnyScript Source # | |
Show AnyScript Source # | |
Generic AnyScript Source # | |
NFData AnyScript Source # | |
Defined in Cardano.Wallet.Transaction |
|
ToJSON ( ApiT AnyScript ) Source # | |
FromJSON ( ApiT AnyScript ) Source # | |
type Rep AnyScript Source # | |
Defined in Cardano.Wallet.Transaction
type
Rep
AnyScript
=
D1
('
MetaData
"AnyScript" "Cardano.Wallet.Transaction" "cardano-wallet-core-2022.7.1-AGKhlyz9liLKN3QqZD1gj" '
False
) (
C1
('
MetaCons
"NativeScript" '
PrefixI
'
False
) (
S1
('
MetaSel
('
Nothing
::
Maybe
Symbol
) '
NoSourceUnpackedness
'
SourceStrict
'
DecidedStrict
) (
Rec0
(
Script
KeyHash
)))
:+:
C1
('
MetaCons
"PlutusScript" '
PrefixI
'
False
) (
S1
('
MetaSel
('
Nothing
::
Maybe
Symbol
) '
NoSourceUnpackedness
'
SourceStrict
'
DecidedStrict
) (
Rec0
PlutusScriptInfo
)))
|
newtype PlutusScriptInfo Source #
Instances
data PlutusVersion Source #
Instances
data TxFeeAndChange change Source #
Small helper record to disambiguate between a fee and change Coin values.
Used by
$sel:distributeSurplus:TransactionLayer
.
Instances
Eq change => Eq ( TxFeeAndChange change) Source # | |
Defined in Cardano.Wallet.Transaction (==) :: TxFeeAndChange change -> TxFeeAndChange change -> Bool Source # (/=) :: TxFeeAndChange change -> TxFeeAndChange change -> Bool Source # |
|
Show change => Show ( TxFeeAndChange change) Source # | |
Defined in Cardano.Wallet.Transaction |
:: ( Coin -> Coin ) |
A function to transform the fee |
-> (change1 -> change2) |
A function to transform the change |
-> TxFeeAndChange change1 |
The original fee and change |
-> TxFeeAndChange change2 |
The transformed fee and change |
Manipulates a
TxFeeAndChange
value.
data ValidityIntervalExplicit Source #
ValidityIntervalExplicit | |
|
Instances
Errors
Possible signing error
ErrSignTxAddressUnknown TxIn |
We tried to sign a transaction with inputs that are unknown to us? |
ErrSignTxUnimplemented |
TODO: [ADP-919] Remove ErrSignTxUnimplemented |
Instances
Eq ErrSignTx Source # | |
Show ErrSignTx Source # | |
Generic ErrSignTx Source # | |
IsServerError ErrSignTx Source # | |
Defined in Cardano.Wallet.Api.Server toServerError :: ErrSignTx -> ServerError Source # |
|
type Rep ErrSignTx Source # | |
Defined in Cardano.Wallet.Transaction
type
Rep
ErrSignTx
=
D1
('
MetaData
"ErrSignTx" "Cardano.Wallet.Transaction" "cardano-wallet-core-2022.7.1-AGKhlyz9liLKN3QqZD1gj" '
False
) (
C1
('
MetaCons
"ErrSignTxAddressUnknown" '
PrefixI
'
False
) (
S1
('
MetaSel
('
Nothing
::
Maybe
Symbol
) '
NoSourceUnpackedness
'
NoSourceStrictness
'
DecidedLazy
) (
Rec0
TxIn
))
:+:
C1
('
MetaCons
"ErrSignTxUnimplemented" '
PrefixI
'
False
) (
U1
::
Type
->
Type
))
|
data ErrMkTransaction Source #
ErrMkTransactionNoSuchWallet WalletId | |
ErrMkTransactionTxBodyError Text |
We failed to construct a transaction for some reasons. |
ErrMkTransactionInvalidEra AnyCardanoEra |
Should never happen, means that that we have programmatically provided an invalid era. |
ErrMkTransactionJoinStakePool ErrCannotJoin | |
ErrMkTransactionQuitStakePool ErrCannotQuit | |
ErrMkTransactionIncorrectTTL PastHorizonException |
Instances
data ErrCannotJoin Source #
Instances
data ErrCannotQuit Source #
Instances
Eq ErrCannotQuit Source # | |
Defined in Cardano.Wallet.Transaction (==) :: ErrCannotQuit -> ErrCannotQuit -> Bool Source # (/=) :: ErrCannotQuit -> ErrCannotQuit -> Bool Source # |
|
Show ErrCannotQuit Source # | |
Defined in Cardano.Wallet.Transaction |
|
IsServerError ErrCannotQuit Source # | |
Defined in Cardano.Wallet.Api.Server |
newtype ErrUpdateSealedTx Source #
ErrExistingKeyWitnesses Int |
The
|
Instances
Eq ErrUpdateSealedTx Source # | |
Defined in Cardano.Wallet.Transaction (==) :: ErrUpdateSealedTx -> ErrUpdateSealedTx -> Bool Source # (/=) :: ErrUpdateSealedTx -> ErrUpdateSealedTx -> Bool Source # |
|
Show ErrUpdateSealedTx Source # | |
Defined in Cardano.Wallet.Transaction |
|
Generic ErrUpdateSealedTx Source # | |
Defined in Cardano.Wallet.Transaction from :: ErrUpdateSealedTx -> Rep ErrUpdateSealedTx x Source # to :: Rep ErrUpdateSealedTx x -> ErrUpdateSealedTx Source # |
|
IsServerError ErrUpdateSealedTx Source # | |
Defined in Cardano.Wallet.Api.Server |
|
type Rep ErrUpdateSealedTx Source # | |
Defined in Cardano.Wallet.Transaction
type
Rep
ErrUpdateSealedTx
=
D1
('
MetaData
"ErrUpdateSealedTx" "Cardano.Wallet.Transaction" "cardano-wallet-core-2022.7.1-AGKhlyz9liLKN3QqZD1gj" '
True
) (
C1
('
MetaCons
"ErrExistingKeyWitnesses" '
PrefixI
'
False
) (
S1
('
MetaSel
('
Nothing
::
Maybe
Symbol
) '
NoSourceUnpackedness
'
NoSourceStrictness
'
DecidedLazy
) (
Rec0
Int
)))
|
data ErrAssignRedeemers Source #
ErrAssignRedeemersScriptFailure Redeemer String |
Failed to assign execution units for a particular redeemer. The
TODO: Refine this type to avoid the
|
ErrAssignRedeemersTargetNotFound Redeemer |
The given redeemer target couldn't be located in the transaction. |
ErrAssignRedeemersInvalidData Redeemer String |
Redeemer's data isn't a valid Plutus' data. |
ErrAssignRedeemersTranslationError ( TranslationError StandardCrypto ) |
Mistranslating of hashes, credentials, certificates etc. |
Instances
newtype ErrMoreSurplusNeeded Source #
Error for when its impossible for
$sel:distributeSurplus:TransactionLayer
to distribute the
surplus. As long as the surplus is larger than
costOfIncreasingCoin
, this
should never happen.
Instances
Eq ErrMoreSurplusNeeded Source # | |
Defined in Cardano.Wallet.Transaction (==) :: ErrMoreSurplusNeeded -> ErrMoreSurplusNeeded -> Bool Source # (/=) :: ErrMoreSurplusNeeded -> ErrMoreSurplusNeeded -> Bool Source # |
|
Show ErrMoreSurplusNeeded Source # | |
Defined in Cardano.Wallet.Transaction |
|
Generic ErrMoreSurplusNeeded Source # | |
Defined in Cardano.Wallet.Transaction from :: ErrMoreSurplusNeeded -> Rep ErrMoreSurplusNeeded x Source # to :: Rep ErrMoreSurplusNeeded x -> ErrMoreSurplusNeeded Source # |
|
type Rep ErrMoreSurplusNeeded Source # | |
Defined in Cardano.Wallet.Transaction
type
Rep
ErrMoreSurplusNeeded
=
D1
('
MetaData
"ErrMoreSurplusNeeded" "Cardano.Wallet.Transaction" "cardano-wallet-core-2022.7.1-AGKhlyz9liLKN3QqZD1gj" '
True
) (
C1
('
MetaCons
"ErrMoreSurplusNeeded" '
PrefixI
'
False
) (
S1
('
MetaSel
('
Nothing
::
Maybe
Symbol
) '
NoSourceUnpackedness
'
NoSourceStrictness
'
DecidedLazy
) (
Rec0
Coin
)))
|