Safe Haskell | None |
---|---|
Language | Haskell2010 |
Mock wallet implementation
Synopsis
- data WalletEffect r
- submitTxn :: forall effs. Member WalletEffect effs => CardanoTx -> Eff effs ()
- ownPaymentPubKeyHash :: (Member WalletEffect effs, Member (Error WalletAPIError) effs) => Eff effs PaymentPubKeyHash
- ownPaymentPubKeyHashes :: Member WalletEffect effs => Eff effs [PaymentPubKeyHash]
- ownFirstPaymentPubKeyHash :: (Member WalletEffect effs, Member (Error WalletAPIError) effs) => Eff effs PaymentPubKeyHash
- ownAddresses :: forall effs. Member WalletEffect effs => Eff effs (NonEmpty CardanoAddress)
- balanceTx :: forall effs. Member WalletEffect effs => UnbalancedTx -> Eff effs (Either WalletAPIError CardanoTx)
- yieldUnbalancedTx :: forall effs. Member WalletEffect effs => UnbalancedTx -> Eff effs ()
- data NodeClientEffect r
- publishTx :: forall effs. Member NodeClientEffect effs => CardanoTx -> Eff effs ()
- getClientSlot :: forall effs. Member NodeClientEffect effs => Eff effs Slot
- getClientParams :: forall effs. Member NodeClientEffect effs => Eff effs Params
- newtype PubKey = PubKey {
- getPubKey :: LedgerBytes
- newtype PubKeyHash = PubKeyHash {
- getPubKeyHash :: BuiltinByteString
- signTxAndSubmit :: Member WalletEffect effs => CardanoTx -> Eff effs CardanoTx
- signTxAndSubmit_ :: Member WalletEffect effs => CardanoTx -> Eff effs ()
- payToAddress :: (Member WalletEffect effs, Member (Error WalletAPIError) effs, Member (LogMsg Text) effs, Member (LogMsg RequestHandlerLogMsg) effs) => Params -> SlotRange -> Value -> Address -> Eff effs CardanoTx
- payToAddress_ :: (Member WalletEffect effs, Member (Error WalletAPIError) effs, Member (LogMsg Text) effs, Member (LogMsg RequestHandlerLogMsg) effs) => Params -> SlotRange -> Value -> Address -> Eff effs ()
- payToPaymentPublicKeyHash :: (Member WalletEffect effs, Member (Error WalletAPIError) effs, Member (LogMsg Text) effs, Member (LogMsg RequestHandlerLogMsg) effs) => Params -> SlotRange -> Value -> PaymentPubKeyHash -> Eff effs CardanoTx
- payToPaymentPublicKeyHash_ :: (Member WalletEffect effs, Member (Error WalletAPIError) effs, Member (LogMsg Text) effs, Member (LogMsg RequestHandlerLogMsg) effs) => Params -> SlotRange -> Value -> PaymentPubKeyHash -> Eff effs ()
- data Params = Params {
- pSlotConfig :: !SlotConfig
- emulatorPParams :: !PParams
- pNetworkId :: !NetworkId
- data Interval a = Interval {}
- data Slot
- type SlotRange = Interval Slot
- width :: SlotRange -> Maybe Integer
- defaultSlotRange :: SlotRange
- interval :: a -> a -> Interval a
- singleton :: a -> Interval a
- isEmpty :: (Enum a, Ord a) => Interval a -> Bool
- always :: Interval a
- member :: Ord a => a -> Interval a -> Bool
- before :: Ord a => a -> Interval a -> Bool
- after :: Ord a => a -> Interval a -> Bool
- contains :: Ord a => Interval a -> Interval a -> Bool
- data WalletAPIError
- = InsufficientFunds Text
- | ChangeHasLessThanNAda Value Ada
- | NoPaymentPubKeyHashError
- | PaymentPrivateKeyNotFound PaymentPubKeyHash
- | ValidationError ValidationError
- | ToCardanoError ToCardanoError
- | PaymentMkTxError MkTxError
- | RemoteClientFunctionNotYetSupported Text
- | OtherError Text
- throwInsufficientFundsError :: Member (Error WalletAPIError) effs => Text -> Eff effs a
- throwOtherError :: Member (Error WalletAPIError) effs => Text -> Eff effs a
Documentation
data WalletEffect r Source #
submitTxn :: forall effs. Member WalletEffect effs => CardanoTx -> Eff effs () Source #
ownPaymentPubKeyHash :: (Member WalletEffect effs, Member (Error WalletAPIError) effs) => Eff effs PaymentPubKeyHash Source #
Deprecated: Use ownFirstPaymentPubKeyHash, ownPaymentPubKeyHashes or ownAddresses instead
ownPaymentPubKeyHashes :: Member WalletEffect effs => Eff effs [PaymentPubKeyHash] Source #
ownFirstPaymentPubKeyHash :: (Member WalletEffect effs, Member (Error WalletAPIError) effs) => Eff effs PaymentPubKeyHash Source #
ownAddresses :: forall effs. Member WalletEffect effs => Eff effs (NonEmpty CardanoAddress) Source #
balanceTx :: forall effs. Member WalletEffect effs => UnbalancedTx -> Eff effs (Either WalletAPIError CardanoTx) Source #
yieldUnbalancedTx :: forall effs. Member WalletEffect effs => UnbalancedTx -> Eff effs () Source #
data NodeClientEffect r Source #
publishTx :: forall effs. Member NodeClientEffect effs => CardanoTx -> Eff effs () Source #
getClientSlot :: forall effs. Member NodeClientEffect effs => Eff effs Slot Source #
getClientParams :: forall effs. Member NodeClientEffect effs => Eff effs Params Source #
Instances
Eq PubKey | |
Ord PubKey | |
Defined in Ledger.Crypto | |
Show PubKey | |
IsString PubKey | |
Defined in Ledger.Crypto fromString :: String -> PubKey Source # | |
Generic PubKey | |
FromJSON PubKey | |
Defined in Ledger.Crypto parseJSON :: Value -> Parser PubKey parseJSONList :: Value -> Parser [PubKey] | |
FromJSONKey PubKey | |
Defined in Ledger.Crypto fromJSONKey :: FromJSONKeyFunction PubKey fromJSONKeyList :: FromJSONKeyFunction [PubKey] | |
ToJSON PubKey | |
Defined in Ledger.Crypto toEncoding :: PubKey -> Encoding toJSONList :: [PubKey] -> Value toEncodingList :: [PubKey] -> Encoding | |
ToJSONKey PubKey | |
Defined in Ledger.Crypto toJSONKey :: ToJSONKeyFunction PubKey toJSONKeyList :: ToJSONKeyFunction [PubKey] | |
Pretty PubKey | |
Defined in Ledger.Crypto prettyList :: [PubKey] -> Doc ann | |
Serialise PubKey | |
Defined in Ledger.Crypto encodeList :: [PubKey] -> Encoding decodeList :: Decoder s [PubKey] | |
Eq PubKey | |
Defined in Ledger.Crypto | |
FromData PubKey | |
Defined in Ledger.Crypto fromBuiltinData :: BuiltinData -> Maybe PubKey | |
Ord PubKey | |
ToData PubKey | |
Defined in Ledger.Crypto toBuiltinData :: PubKey -> BuiltinData | |
UnsafeFromData PubKey | |
Defined in Ledger.Crypto unsafeFromBuiltinData :: BuiltinData -> PubKey | |
Newtype PubKey | |
Lift DefaultUni PubKey | |
Defined in Ledger.Crypto | |
Typeable DefaultUni PubKey | |
Defined in Ledger.Crypto | |
type Rep PubKey | |
Defined in Ledger.Crypto | |
type O PubKey | |
Defined in Ledger.Crypto |
newtype PubKeyHash #
PubKeyHash | |
|
Instances
signTxAndSubmit :: Member WalletEffect effs => CardanoTx -> Eff effs CardanoTx Source #
Add the wallet's signature to the transaction and submit it. Returns the transaction with the wallet's signature.
signTxAndSubmit_ :: Member WalletEffect effs => CardanoTx -> Eff effs () Source #
A version of signTxAndSubmit
that discards the result.
payToAddress :: (Member WalletEffect effs, Member (Error WalletAPIError) effs, Member (LogMsg Text) effs, Member (LogMsg RequestHandlerLogMsg) effs) => Params -> SlotRange -> Value -> Address -> Eff effs CardanoTx Source #
Transfer some funds to an address, returning the transaction that was submitted.
Note: Due to a constraint in the Cardano ledger, each tx output must have a
minimum amount of Ada. Therefore, the funds to transfer will be adjusted
to satisfy that constraint. See adjustUnbalancedTx
.
payToAddress_ :: (Member WalletEffect effs, Member (Error WalletAPIError) effs, Member (LogMsg Text) effs, Member (LogMsg RequestHandlerLogMsg) effs) => Params -> SlotRange -> Value -> Address -> Eff effs () Source #
Transfer some funds to an address.
payToPaymentPublicKeyHash :: (Member WalletEffect effs, Member (Error WalletAPIError) effs, Member (LogMsg Text) effs, Member (LogMsg RequestHandlerLogMsg) effs) => Params -> SlotRange -> Value -> PaymentPubKeyHash -> Eff effs CardanoTx Source #
Transfer some funds to an address locked by a public key, returning the transaction that was submitted.
Note: Due to a constraint in the Cardano ledger, each tx output must have a
minimum amount of Ada. Therefore, the funds to transfer will be adjusted
to satisfy that constraint. See adjustUnbalancedTx
.
payToPaymentPublicKeyHash_ :: (Member WalletEffect effs, Member (Error WalletAPIError) effs, Member (LogMsg Text) effs, Member (LogMsg RequestHandlerLogMsg) effs) => Params -> SlotRange -> Value -> PaymentPubKeyHash -> Eff effs () Source #
Transfer some funds to an address locked by a public key.
Params | |
|
Instances
Slot ranges
Instances
Functor Interval | |
Defined in Plutus.V1.Ledger.Interval | |
(Typeable DefaultUni a, Lift DefaultUni (LowerBound a), Lift DefaultUni (UpperBound a)) => Lift DefaultUni (Interval a) | |
Defined in Plutus.V1.Ledger.Interval | |
Eq a => Eq (Interval a) | |
Ord a => Ord (Interval a) | |
Defined in Plutus.V1.Ledger.Interval compare :: Interval a -> Interval a -> Ordering Source # (<) :: Interval a -> Interval a -> Bool Source # (<=) :: Interval a -> Interval a -> Bool Source # (>) :: Interval a -> Interval a -> Bool Source # (>=) :: Interval a -> Interval a -> Bool Source # | |
Show a => Show (Interval a) | |
Generic (Interval a) | |
NFData a => NFData (Interval a) | |
Defined in Plutus.V1.Ledger.Interval | |
Pretty a => Pretty (Interval a) | |
Defined in Plutus.V1.Ledger.Interval pretty :: Interval a -> Doc ann prettyList :: [Interval a] -> Doc ann | |
Ord a => JoinSemiLattice (Interval a) | |
Defined in Plutus.V1.Ledger.Interval | |
Eq a => Eq (Interval a) | |
Defined in Plutus.V1.Ledger.Interval | |
FromData a => FromData (Interval a) | |
Defined in Plutus.V1.Ledger.Interval fromBuiltinData :: BuiltinData -> Maybe (Interval a) | |
ToData a => ToData (Interval a) | |
Defined in Plutus.V1.Ledger.Interval toBuiltinData :: Interval a -> BuiltinData | |
UnsafeFromData a => UnsafeFromData (Interval a) | |
Defined in Plutus.V1.Ledger.Interval unsafeFromBuiltinData :: BuiltinData -> Interval a | |
Ord a => BoundedJoinSemiLattice (Interval a) | |
Defined in Plutus.V1.Ledger.Interval | |
Ord a => BoundedMeetSemiLattice (Interval a) | |
Defined in Plutus.V1.Ledger.Interval | |
Ord a => MeetSemiLattice (Interval a) | |
Defined in Plutus.V1.Ledger.Interval | |
Typeable DefaultUni Interval | |
Defined in Plutus.V1.Ledger.Interval | |
type Rep (Interval a) | |
Defined in Plutus.V1.Ledger.Interval type Rep (Interval a) = D1 ('MetaData "Interval" "Plutus.V1.Ledger.Interval" "plutus-ledger-api-1.0.0.1-6EvbyJiK8IAAVEtnIJDu5Z" 'False) (C1 ('MetaCons "Interval" 'PrefixI 'True) (S1 ('MetaSel ('Just "ivFrom") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (LowerBound a)) :*: S1 ('MetaSel ('Just "ivTo") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (UpperBound a)))) |
Instances
Enum Slot | |
Eq Slot | |
Integral Slot | |
Defined in Ledger.Slot | |
Data Slot | |
Defined in Ledger.Slot gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Slot -> c Slot Source # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Slot Source # toConstr :: Slot -> Constr Source # dataTypeOf :: Slot -> DataType Source # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Slot) Source # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Slot) Source # gmapT :: (forall b. Data b => b -> b) -> Slot -> Slot Source # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Slot -> r Source # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Slot -> r Source # gmapQ :: (forall d. Data d => d -> u) -> Slot -> [u] Source # gmapQi :: Int -> (forall d. Data d => d -> u) -> Slot -> u Source # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Slot -> m Slot Source # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Slot -> m Slot Source # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Slot -> m Slot Source # | |
Num Slot | |
Ord Slot | |
Real Slot | |
Defined in Ledger.Slot toRational :: Slot -> Rational Source # | |
Show Slot | |
Generic Slot | |
FromJSON Slot | |
Defined in Ledger.Slot parseJSON :: Value -> Parser Slot parseJSONList :: Value -> Parser [Slot] | |
FromJSONKey Slot | |
Defined in Ledger.Slot fromJSONKey :: FromJSONKeyFunction Slot fromJSONKeyList :: FromJSONKeyFunction [Slot] | |
ToJSON Slot | |
Defined in Ledger.Slot | |
ToJSONKey Slot | |
Defined in Ledger.Slot toJSONKey :: ToJSONKeyFunction Slot toJSONKeyList :: ToJSONKeyFunction [Slot] | |
Hashable Slot | |
Defined in Ledger.Slot | |
Pretty Slot | |
Defined in Ledger.Slot prettyList :: [Slot] -> Doc ann | |
Serialise Slot | |
Defined in Ledger.Slot encodeList :: [Slot] -> Encoding decodeList :: Decoder s [Slot] | |
AdditiveGroup Slot | |
Defined in Ledger.Slot | |
AdditiveMonoid Slot | |
Defined in Ledger.Slot | |
AdditiveSemigroup Slot | |
Defined in Ledger.Slot | |
Enum Slot | |
Eq Slot | |
Defined in Ledger.Slot | |
FromData Slot | |
Defined in Ledger.Slot fromBuiltinData :: BuiltinData -> Maybe Slot | |
Ord Slot | |
ToData Slot | |
Defined in Ledger.Slot toBuiltinData :: Slot -> BuiltinData | |
UnsafeFromData Slot | |
Defined in Ledger.Slot unsafeFromBuiltinData :: BuiltinData -> Slot | |
HasDbType Slot | |
Defined in Plutus.ChainIndex.DbSchema type DbType Slot | |
Lift DefaultUni Slot | |
Defined in Ledger.Slot | |
Typeable DefaultUni Slot | |
Defined in Ledger.Slot | |
type Rep Slot | |
Defined in Ledger.Slot | |
type DbType Slot | |
Defined in Plutus.ChainIndex.DbSchema |
defaultSlotRange :: SlotRange Source #
The default slot validity range for transactions.
Error handling
data WalletAPIError Source #
An error thrown by wallet interactions.
InsufficientFunds Text | There were insufficient funds to perform the desired operation. |
ChangeHasLessThanNAda Value Ada | The change when selecting coins contains less than the minimum amount of Ada. |
NoPaymentPubKeyHashError | The wallet doesn't have any payment key hash, which should not be possible. |
PaymentPrivateKeyNotFound PaymentPubKeyHash | The private key of this public key hash is not known to the wallet. |
ValidationError ValidationError | There was an error during off-chain validation. |
ToCardanoError ToCardanoError | There was an error while converting to Cardano.API format. |
PaymentMkTxError MkTxError | There was an error while creating a payment transaction |
RemoteClientFunctionNotYetSupported Text | The called wallet effect is not yet supported in a remote wallet client scenario. |
OtherError Text | Some other error occurred. |
Instances
throwInsufficientFundsError :: Member (Error WalletAPIError) effs => Text -> Eff effs a Source #
throwOtherError :: Member (Error WalletAPIError) effs => Text -> Eff effs a Source #