plutus-contract-0.1.0.0
Safe HaskellNone
LanguageHaskell2010

Wallet.Emulator.Wallet

Synopsis

Documentation

newtype SigningProcess Source #

Constructors

SigningProcess 

Fields

Instances

Instances details
Show SigningProcess Source # 
Instance details

Defined in Wallet.Emulator.Wallet

data Wallet Source #

A wallet identifier

Instances

Instances details
Eq Wallet Source # 
Instance details

Defined in Wallet.Emulator.Wallet

Data Wallet Source # 
Instance details

Defined in Wallet.Emulator.Wallet

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Wallet -> c Wallet Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Wallet Source #

toConstr :: Wallet -> Constr Source #

dataTypeOf :: Wallet -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Wallet) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Wallet) Source #

gmapT :: (forall b. Data b => b -> b) -> Wallet -> Wallet Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Wallet -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Wallet -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> Wallet -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Wallet -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Wallet -> m Wallet Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Wallet -> m Wallet Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Wallet -> m Wallet Source #

Ord Wallet Source # 
Instance details

Defined in Wallet.Emulator.Wallet

Show Wallet Source # 
Instance details

Defined in Wallet.Emulator.Wallet

Generic Wallet Source # 
Instance details

Defined in Wallet.Emulator.Wallet

Associated Types

type Rep Wallet :: Type -> Type Source #

ToJSON Wallet Source # 
Instance details

Defined in Wallet.Emulator.Wallet

ToJSONKey Wallet Source # 
Instance details

Defined in Wallet.Emulator.Wallet

FromJSON Wallet Source # 
Instance details

Defined in Wallet.Emulator.Wallet

ToHttpApiData Wallet Source # 
Instance details

Defined in Wallet.Emulator.Wallet

FromHttpApiData Wallet Source # 
Instance details

Defined in Wallet.Emulator.Wallet

ToSchema Wallet Source # 
Instance details

Defined in Wallet.Emulator.Wallet

Pretty Wallet Source # 
Instance details

Defined in Wallet.Emulator.Wallet

Methods

pretty :: Wallet -> Doc ann Source #

prettyList :: [Wallet] -> Doc ann Source #

type Rep Wallet Source # 
Instance details

Defined in Wallet.Emulator.Wallet

type Rep Wallet = D1 ('MetaData "Wallet" "Wallet.Emulator.Wallet" "plutus-contract-0.1.0.0-2DbvKQdtEvHK4UkDq1ndDW" 'False) (C1 ('MetaCons "Wallet" 'PrefixI 'True) (S1 ('MetaSel ('Just "prettyWalletName") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe String)) :*: S1 ('MetaSel ('Just "getWalletId") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 WalletId)))

newtype WalletId Source #

Constructors

WalletId 

Fields

Instances

Instances details
Eq WalletId Source # 
Instance details

Defined in Wallet.Emulator.Wallet

Data WalletId Source # 
Instance details

Defined in Wallet.Emulator.Wallet

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> WalletId -> c WalletId Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c WalletId Source #

toConstr :: WalletId -> Constr Source #

dataTypeOf :: WalletId -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c WalletId) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c WalletId) Source #

gmapT :: (forall b. Data b => b -> b) -> WalletId -> WalletId Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> WalletId -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> WalletId -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> WalletId -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> WalletId -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> WalletId -> m WalletId Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> WalletId -> m WalletId Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> WalletId -> m WalletId Source #

Ord WalletId Source # 
Instance details

Defined in Wallet.Emulator.Wallet

Show WalletId Source # 
Instance details

Defined in Wallet.Emulator.Wallet

Generic WalletId Source # 
Instance details

Defined in Wallet.Emulator.Wallet

Associated Types

type Rep WalletId :: Type -> Type Source #

ToJSON WalletId Source # 
Instance details

Defined in Wallet.Emulator.Wallet

ToJSONKey WalletId Source # 
Instance details

Defined in Wallet.Emulator.Wallet

FromJSON WalletId Source # 
Instance details

Defined in Wallet.Emulator.Wallet

ToHttpApiData WalletId Source # 
Instance details

Defined in Wallet.Emulator.Wallet

FromHttpApiData WalletId Source # 
Instance details

Defined in Wallet.Emulator.Wallet

ToSchema WalletId Source # 
Instance details

Defined in Wallet.Emulator.Wallet

type Rep WalletId Source # 
Instance details

Defined in Wallet.Emulator.Wallet

type Rep WalletId = D1 ('MetaData "WalletId" "Wallet.Emulator.Wallet" "plutus-contract-0.1.0.0-2DbvKQdtEvHK4UkDq1ndDW" 'True) (C1 ('MetaCons "WalletId" 'PrefixI 'True) (S1 ('MetaSel ('Just "unWalletId") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 WalletId)))

walletToMockWallet :: Wallet -> Maybe MockWallet Source #

The MockWallet whose ID is the given wallet ID (if it exists)

mockWalletPaymentPubKey :: Wallet -> PaymentPubKey Source #

The public key of a mock wallet. (Fails if the wallet is not a mock wallet).

mockWalletPaymentPubKeyHash :: Wallet -> PaymentPubKeyHash Source #

The payment public key hash of a mock wallet. (Fails if the wallet is not a mock wallet).

mockWalletAddress :: Wallet -> Address Source #

Get the address of a mock wallet. (Fails if the wallet is not a mock wallet).

data WalletEvent Source #

Instances

Instances details
Eq WalletEvent Source # 
Instance details

Defined in Wallet.Emulator.Wallet

Show WalletEvent Source # 
Instance details

Defined in Wallet.Emulator.Wallet

Generic WalletEvent Source # 
Instance details

Defined in Wallet.Emulator.Wallet

Associated Types

type Rep WalletEvent :: Type -> Type Source #

ToJSON WalletEvent Source # 
Instance details

Defined in Wallet.Emulator.Wallet

FromJSON WalletEvent Source # 
Instance details

Defined in Wallet.Emulator.Wallet

Pretty WalletEvent Source # 
Instance details

Defined in Wallet.Emulator.Wallet

type Rep WalletEvent Source # 
Instance details

Defined in Wallet.Emulator.Wallet

data WalletState Source #

The state used by the mock wallet environment.

Constructors

WalletState 

Fields

Instances

Instances details
Show WalletState Source # 
Instance details

Defined in Wallet.Emulator.Wallet

ownAddress :: WalletState -> Address Source #

Get the user's own payment public-key address.

fromMockWallet :: MockWallet -> WalletState Source #

An empty wallet using the given private key. for that wallet as the sole watched address.

emptyWalletState :: Wallet -> Maybe WalletState Source #

Empty wallet state for an emulator Wallet. Returns Nothing if the wallet is not known in the emulator.

handleBalanceTx Source #

Arguments

:: forall effs. (Member (State WalletState) effs, Member ChainIndexQueryEffect effs, Member (Error WalletAPIError) effs, Member (LogMsg TxBalanceMsg) effs) 
=> Map TxOutRef ChainIndexTxOut

The current wallet's unspent transaction outputs.

-> UnbalancedTx 
-> Eff effs Tx 

Balance an unbalanced transaction by adding missing inputs and outputs

adjustBalanceWithMissingLovelace Source #

Arguments

:: (Value, Value)

The unbalanced tx's left and right balance.

-> (Value, Value)

New left and right balance.

Adjust the left and right balance of an unbalanced Tx with the missing lovelace considering the minimum lovelace per transaction output constraint from the Cardano blockchain.

splitOffAdaOnlyValue :: Value -> [Value] Source #

Split value into an ada-only and an non-ada-only value, making sure each has at least minAdaTxOut.

addCollateral Source #

Arguments

:: Member (Error WalletAPIError) effs 
=> Map TxOutRef ChainIndexTxOut

The current wallet's unspent transaction outputs.

-> Value 
-> Tx 
-> Eff effs Tx 

addInputs Source #

Arguments

:: Member (Error WalletAPIError) effs 
=> Map TxOutRef ChainIndexTxOut

The current wallet's unspent transaction outputs.

-> PaymentPubKey 
-> Maybe StakePubKey 
-> Value 
-> Tx 
-> Eff effs Tx 

addInputs mp pk vl tx selects transaction outputs worth at least vl from the UTXO map mp and adds them as inputs to tx. A public key output for pk is added containing any leftover change.

selectCoin :: Member (Error WalletAPIError) effs => [(a, Value)] -> Value -> Eff effs ([(a, Value)], Value) Source #

Given a set of as with coin values, and a target value, select a number of a such that their total value is greater than or equal to the target.

valueIsZeroOrHasMinAda :: Value -> Bool Source #

Check that a value is a proper TxOut value or is zero (i.e. the absence of a TxOut)

removeEmptyOutputs :: Tx -> Tx Source #

Removes transaction outputs with empty datum and empty value.

takeUntil :: (a -> Bool) -> [a] -> [a] Source #

Take elements from a list until the predicate is satisfied. takeUntil p includes the first element for wich p is true (unlike takeWhile (not . p)).

signWallet :: MockWallet -> SigningProcess Source #

Sign the transaction by calling signTxnWithKey (throwing a PrivateKeyNotFound error if called with a key other than the wallet's private key)

signTxnWithKey :: Member (Error WalletAPIError) r => MockWallet -> CardanoTx -> PaymentPubKeyHash -> Eff r CardanoTx Source #

Sign the transaction with the private key of the mock wallet.

signTxWithPrivateKey :: Member (Error WalletAPIError) r => PaymentPrivateKey -> CardanoTx -> PaymentPubKeyHash -> Eff r CardanoTx Source #

Sign the transaction with the private key, if the hash is that of the private key.

signPrivateKeys :: [PaymentPrivateKey] -> SigningProcess Source #

Sign the transaction with the given private keys, ignoring the list of public keys that the SigningProcess is passed.

data Entity Source #

An Entity is a thing that can hold Value. Used in the balances function to compute who holds for a given chain state and set of wallets.

Instances

Instances details
Eq Entity Source # 
Instance details

Defined in Wallet.Emulator.Wallet

Ord Entity Source # 
Instance details

Defined in Wallet.Emulator.Wallet

Show Entity Source # 
Instance details

Defined in Wallet.Emulator.Wallet

walletPaymentPubKeyHashes :: WalletSet -> Map PaymentPubKeyHash Wallet Source #

Pick out all the public keys from the set of wallets and map them back to their corresponding wallets.

balances :: ChainState -> WalletSet -> Map Entity Value Source #

For a set of wallets, convert them into a map of value: entity, where entity is one of Entity.

Orphan instances

Data WalletId Source # 
Instance details

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> WalletId -> c WalletId Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c WalletId Source #

toConstr :: WalletId -> Constr Source #

dataTypeOf :: WalletId -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c WalletId) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c WalletId) Source #

gmapT :: (forall b. Data b => b -> b) -> WalletId -> WalletId Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> WalletId -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> WalletId -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> WalletId -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> WalletId -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> WalletId -> m WalletId Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> WalletId -> m WalletId Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> WalletId -> m WalletId Source #

ToSchema WalletId Source # 
Instance details