| Safe Haskell | None |
|---|---|
| Language | GHC2021 |
Conformance.Observe.Payments
Description
The payments an accepted exit made, read off its transaction.
The chain settles a fold per payee. A fold that delivers a token pays the deposit with it: the output carrying the token holds at least the deposit. A fold that delivers nothing, and a reject, pay the request's owner: the owner is credited the summed lovelace of every output at the owner's payment key that carries no token the fold delivers. An absent insertion locks the deposit in the custody output it creates. A spent custody's refund address is credited the summed lovelace of every output at that address carrying no delivered token. A retraction returns what the request held through one output at the owner's key whose inline datum is the retracted request's own output reference: the largest such output is what the chain reads, never a sum of fragments. Every amount is read as the chain paid it, never selected by the amount the model expects, so a short or surplus payment reaches the comparison. This module reads those payments in the chain's own terms — addresses, keys and lovelace — and leaves their translation to model identities to the live runner, which allocated them.
Synopsis
- data FoldOutput = FoldOutput {
- outputAddress :: ByteString
- outputKey :: ByteString
- outputLovelace :: Integer
- outputCarrier :: Bool
- outputDatum :: Text
- outputApprovals :: [Text]
- outputCustody :: Bool
- outputReference :: Maybe Text
- data ExitFacts = ExitFacts {
- factsExit :: Exit
- factsEdge :: Edge
- factsOwner :: ByteString
- factsRefund :: Maybe ByteString
- factsReference :: Maybe Text
- data Payee
- = Custody
- | Destination ByteString
- | Owner ByteString
- | Refund ByteString
- data Payment = Payment {
- payee :: Payee
- paidLovelace :: Integer
- foldPayments :: ExitFacts -> [FoldOutput] -> Either String [Payment]
- creditsOwner :: ByteString -> FoldOutput -> Bool
- data OwnerReading = OwnerReading {
- readingLovelace :: Integer
- readingDatum :: Text
- readingApprovals :: [Text]
- readOwner :: ByteString -> [FoldOutput] -> Either String (Maybe OwnerReading)
- readBound :: ByteString -> Text -> [FoldOutput] -> Either String (Maybe OwnerReading)
- ownerOutputObservation :: Integer -> (Text -> Either String Integer) -> [Value] -> Integer -> Maybe Integer -> OwnerReading -> Either String Value
- data OwedPayee
- owedPayee :: ExitFacts -> OwedPayee
- owedOutputs :: ExitFacts -> [FoldOutput] -> [Int]
- data OutputEdit
- = Readdress Int
- | Relovelace Int Integer
- | Rebind Int
- | SpendState
- tamperEdits :: Tamper -> ExitFacts -> [FoldOutput] -> Either String [OutputEdit]
Documentation
data FoldOutput Source #
One output of the fold's transaction, reduced to what settlement reads.
Constructors
| FoldOutput | |
Fields
| |
Instances
| Show FoldOutput Source # | |
Defined in Conformance.Observe.Payments Methods showsPrec :: Int -> FoldOutput -> ShowS Source # show :: FoldOutput -> String Source # showList :: [FoldOutput] -> ShowS Source # | |
| Eq FoldOutput Source # | |
Defined in Conformance.Observe.Payments Methods (==) :: FoldOutput -> FoldOutput -> Bool Source # (/=) :: FoldOutput -> FoldOutput -> Bool Source # | |
What the chain records about the exit beside its outputs.
Constructors
| ExitFacts | |
Fields
| |
Instances
| Show ExitFacts Source # | |
Defined in Conformance.Observe.Payments | |
| Eq ExitFacts Source # | |
Defined in Conformance.Observe.Payments | |
Who a payment reached, in the chain's terms.
Constructors
| Custody | the cage's custody |
| Destination ByteString | the address holding the delivered token |
| Owner ByteString | the request owner's payment key |
| Refund ByteString | the refund address a spent custody recorded |
Instances
| Show Payee Source # | |
Defined in Conformance.Observe.Payments | |
| Eq Payee Source # | |
Defined in Conformance.Observe.Payments | |
A payment the fold made: its payee and the lovelace that reached it.
Constructors
| Payment | |
Fields
| |
Instances
| Show Payment Source # | |
Defined in Conformance.Observe.Payments | |
| Eq Payment Source # | |
Defined in Conformance.Observe.Payments | |
foldPayments :: ExitFacts -> [FoldOutput] -> Either String [Payment] Source #
The payments of one accepted fold, in the order the model states them: what the fold owes for its request, then the custody refund it pays.
What is owed is reported as the chain paid it, however much that is, so a short payment reaches the comparison as a value below the model's floor. What cannot be read as a payment at all — a delivered token no single output carries, a custody lock that is not there, a spent custody whose source was not observed — is refused rather than reported.
creditsOwner :: ByteString -> FoldOutput -> Bool Source #
Whether the chain credits an output to an owner's key: it sits at that payment key and carries no token the fold delivers.
data OwnerReading Source #
The owner output as the ledger outputs crediting the owner present it.
Constructors
| OwnerReading | |
Fields
| |
Instances
| Show OwnerReading Source # | |
Defined in Conformance.Observe.Payments Methods showsPrec :: Int -> OwnerReading -> ShowS Source # show :: OwnerReading -> String Source # showList :: [OwnerReading] -> ShowS Source # | |
| Eq OwnerReading Source # | |
Defined in Conformance.Observe.Payments Methods (==) :: OwnerReading -> OwnerReading -> Bool Source # (/=) :: OwnerReading -> OwnerReading -> Bool Source # | |
readOwner :: ByteString -> [FoldOutput] -> Either String (Maybe OwnerReading) Source #
Read the owner output off the outputs crediting the owner's key, or nothing when no output credits it. Outputs presenting different datum forms cannot be read as one owner output, and are refused.
readBound :: ByteString -> Text -> [FoldOutput] -> Either String (Maybe OwnerReading) Source #
Read a retraction's return off the outputs crediting the owner's key and bound to the output reference the request sat at, or nothing when no output is bound to it. The chain settles a retraction by one sufficient bound output, so the return is read as the largest of them, never a sum; whether it is enough is the judgement's, not the reader's.
ownerOutputObservation :: Integer -> (Text -> Either String Integer) -> [Value] -> Integer -> Maybe Integer -> OwnerReading -> Either String Value Source #
The observed owner output, in the model's vocabulary: the owner's
identity, the lovelace and datum form read, the registry tokens and state
tokens it holds, the approval it returns, named by approvalOf — the
run's own binding of each booked approval to its model name, which refuses a
name no booking established. Whichever approval the ledger returns is the one
reported, so another request's approval differs from the model's commitment. The
output reference its datum presents, if any, arrives as its identity.
Whom an exit owes its request's payment, and so which outputs pay it.
Constructors
| OwedCustody | |
| OwedCarrier | |
| OwedOwner | |
| OwedBound |
owedPayee :: ExitFacts -> OwedPayee Source #
Whom this exit owes its request's payment: the model's rule, by edge for a fold; a reject owes the owner, a retraction the owner through a bound output.
owedOutputs :: ExitFacts -> [FoldOutput] -> [Int] Source #
The positions of the outputs through which the chain settles what an exit owes for its request: the custody output an absent insertion locks, the outputs carrying a token the fold delivers, for a fold delivering nothing and a reject every output crediting the owner's key, and for a retraction every output crediting it bound to the retracted request.
data OutputEdit Source #
A change to one output of the fold's transaction, by position.
Constructors
| Readdress Int | send the output to another address, value unchanged |
| Relovelace Int Integer | give the output this lovelace |
| Rebind Int | bind the output to another output reference |
| SpendState | spend the registry's state beside the request |
Instances
| Show OutputEdit Source # | |
Defined in Conformance.Observe.Payments Methods showsPrec :: Int -> OutputEdit -> ShowS Source # show :: OutputEdit -> String Source # showList :: [OutputEdit] -> ShowS Source # | |
| Eq OutputEdit Source # | |
Defined in Conformance.Observe.Payments Methods (==) :: OutputEdit -> OutputEdit -> Bool Source # (/=) :: OutputEdit -> OutputEdit -> Bool Source # | |
tamperEdits :: Tamper -> ExitFacts -> [FoldOutput] -> Either String [OutputEdit] Source #
The edits a tamper makes to the payment an exit owes, read off the exit's
own outputs. OtherAddress sends every output paying it elsewhere.
ShortByOne leaves the payee credited one lovelace less than the first output
paying it holds: that output loses one lovelace, every other output paying it
goes elsewhere, and the lovelace taken goes to the transaction's last output,
its change. OtherReference binds every output returning a retracted request to
another output reference, and StateSpent spends the registry's state beside
the retraction; neither applies to another exit. ExtraSigner changes no
output.