@@ -54,6 +54,12 @@ record UTxOState : Type where
5454<!--
5555```agda
5656instance
57+ HasUTxO-UTxOEnv : HasUTxO UTxOEnv
58+ HasUTxO-UTxOEnv .UTxOOf = UTxOEnv.utxo₀
59+
60+ HasUTxO-UTxOState : HasUTxO UTxOState
61+ HasUTxO-UTxOState .UTxOOf = UTxOState.utxo
62+
5763 unquoteDecl HasCast-UTxOEnv HasCast-UTxOState = derive-HasCast
5864 ( (quote UTxOEnv , HasCast-UTxOEnv ) ∷
5965 [ (quote UTxOState , HasCast-UTxOState) ])
@@ -96,37 +102,28 @@ transaction (or partially applying any part of it). TODO: Add link to CIP once i
96102data _⊢_⇀⦇_,SUBUTXO⦈_ : UTxOEnv → UTxOState → SubLevelTx → UTxOState → Type where
97103
98104 SUBUTXO :
99- let txb = Tx.txBody tx
100- subTxs = TxBody.txSubTransactions txb
101- in
105+
102106 ────────────────────────────────
103107 Γ ⊢ s ⇀⦇ stx ,SUBUTXO⦈ s'
104108
105109data _⊢_⇀⦇_,UTXO⦈_ : UTxOEnv → UTxOState → TopLevelTx → UTxOState → Type where
106110
107111 UTXO :
108- let txb = Tx.txBody tx
109- subTxs = TxBody.txSubTransactions txb
110- utxo₀ = Γ .utxo₀
111- utxo = s .utxo
112- in
113- ∙ txIns ≢ ∅
114- ∙ txIns ⊆ dom utxo₀ -- (1)
115- ∙ refInputs ⊆ dom utxo
116-
117- ∙ requiredTopLevelGuardsSatisfied tx subTxs
118112
113+ ∙ SpendInputsOf tx ≢ ∅
114+ ∙ SpendInputsOf tx ⊆ dom (UTxOOf Γ) -- (1)
115+ ∙ ReferenceInputsOf tx ⊆ dom (UTxOOf s)
116+ ∙ requiredTopLevelGuardsSatisfied tx (SubTransactionsOf tx) -- (2)
119117 ∙ Γ ⊢ s ⇀⦇ tx ,UTXOS⦈ s'
120118 ────────────────────────────────
121119 Γ ⊢ s ⇀⦇ tx ,UTXO⦈ s'
122120```
123121
124- ** Note.** The premise ` requiredTopLevelGuardsSatisfied tx subTxs `
125- is explicitly a ** phase-1** condition (CIP-0118): every guard credential requested by
126- subTx bodies must appear in the top-level ` txGuards ` set.
122+ ** Notes** .
127123
128- A couple of details to notice:
124+ 1 . The set of spending inputs must exist in the UTxO * before* applying the
125+ transaction (or partially applying any part of it).
129126
130- - ` txb ` is computed via ` Tx.txBody tx` (no reliance on ` TxBodyOf ` instances).
131- - ` UTXOS-stub ` returns the ** same ** state (so we can typecheck
132- everything without inventing semantics prematurely) .
127+ 2 . The premise ` requiredTopLevelGuardsSatisfied tx subTxs ` is explicitly a
128+ phase-1 condition (CIP-0118): every guard credential requested by subtransaction
129+ bodies must appear in the top-level ` txGuards ` set .
0 commit comments