@@ -30,12 +30,85 @@ private variable
3030```
3131-->
3232
33+ ## Witnessing Functions {#sec: witnessing-functions }
34+
3335``` agda
34- languages : Tx ℓ → UTxO → ℙ Language
35- languages tx utxo = ∅ -- TODO
36+ module _ (tx : TopLevelTx) where
37+ open Tx tx
38+ open TxBody txBody
39+
40+ module _ (utxo : UTxO) where
41+ UsesBootstrapAddress : Type
42+ UsesBootstrapAddress = ∃[ o ∈ (range txOuts) ∪ range (utxo ∣ (txIns ∪ refInputs)) ] isBootstrapAddr (proj₁ o)
43+
44+ HasInlineDatum : TxOut → Type
45+ HasInlineDatum txout = Is-just (txOutToDatum txout)
46+
47+ UsesV2Features : Type
48+ UsesV2Features = ∃[ o ∈ (range txOuts) ∪ range (utxo ∣ (txIns ∪ refInputs)) ] HasInlineDatum o
49+
50+ data UsesV3Features : Set where
51+ hasVotes : ¬ (Is-[] txGovVotes) → UsesV3Features
52+ hasProposals : ¬ (Is-[] txGovProposals) → UsesV3Features
53+ hasDonation : NonZero txDonation → UsesV3Features
54+ hasTreasure : Is-just currentTreasury → UsesV3Features
55+
56+ data UsesV4Features : Set where
57+ hasSubtransactions : ¬ (Is-[] txSubTransactions) → UsesV4Features
58+ hasGuards : ¬ (Is-∅ txGuards) → UsesV4Features
59+ ```
3660
37- allowedLanguages : Tx ℓ → UTxO → ℙ Language
38- allowedLanguages tx utxo = ∅ -- TODO
61+ <!--
62+ ```agda
63+ module _ {tx : TopLevelTx} where
64+ open Tx tx
65+ open TxBody txBody
66+
67+ instance
68+ Dec-UsesV3Features : UsesV3Features tx ⁇
69+ Dec-UsesV3Features .dec
70+ with ¿ ¬ (Is-[] txGovVotes) ¿ | ¿ ¬ (Is-[] txGovProposals) ¿
71+ | ¿ NonZero txDonation ¿ | ¿ Is-just currentTreasury ¿
72+ ... | yes p | _ | _ | _ = yes (hasVotes p)
73+ ... | _ | yes p | _ | _ = yes (hasProposals p)
74+ ... | _ | _ | yes p | _ = yes (hasDonation p)
75+ ... | _ | _ | _ | yes p = yes (hasTreasure p)
76+ ... | no p₁ | no p₂ | no p₃ | no p₄
77+ = no λ { (hasVotes x) → p₁ x ; (hasProposals x) → p₂ x ; (hasDonation x) → p₃ x ; (hasTreasure x) → p₄ x}
78+
79+ module _ {tx : TopLevelTx} where
80+ open Tx tx
81+ open TxBody txBody
82+
83+ instance
84+ Dec-UsesV4Features : UsesV4Features tx ⁇
85+ Dec-UsesV4Features .dec
86+ with ¿ ¬ (Is-[] txSubTransactions) ¿ | ¿ ¬ (Is-∅ txGuards) ¿
87+ ... | yes p | _ = yes (hasSubtransactions p)
88+ ... | _ | yes p = yes (hasGuards p)
89+ ... | no p₁ | no p₂
90+ = no λ { (hasSubtransactions x) → p₁ x ; (hasGuards x) → p₂ x}
91+ ```
92+ -->
93+
94+ ``` agda
95+ languages : ℙ P2Script → ℙ Language
96+ languages p2Scripts = mapˢ language p2Scripts
97+
98+ allowedLanguages : TopLevelTx → UTxO → ℙ Language
99+ allowedLanguages tx utxo =
100+ if UsesBootstrapAddress tx utxo
101+ then ∅
102+ else
103+ if UsesV4Features tx
104+ then fromList (PlutusV4 ∷ [])
105+ else
106+ if UsesV3Features tx
107+ then fromList (PlutusV4 ∷ PlutusV3 ∷ [])
108+ else
109+ if UsesV2Features tx utxo
110+ then fromList (PlutusV4 ∷ PlutusV3 ∷ PlutusV2 ∷ [])
111+ else fromList (PlutusV4 ∷ PlutusV3 ∷ PlutusV2 ∷ PlutusV1 ∷ [])
39112```
40113
41114``` agda
@@ -78,7 +151,6 @@ data _⊢_⇀⦇_,SUBUTXOW⦈_ : UTxOEnv → UTxOState → SubLevelTx → UTxOSt
78151 ∙ neededVKeyHashes ⊆ witsKeyHashes
79152 ∙ neededScriptHashes ⊆ mapˢ hash p1Scripts ∪ mapˢ hash p2Scripts
80153 ∙ neededDataHashes ⊆ dom (Γ .globalData)
81- ∙ languages tx utxo ⊆ allowedLanguages tx utxo
82154 ∙ txADhash ≡ map hash txAuxData
83155 ∙ Γ ⊢ s ⇀⦇ stx ,SUBUTXO⦈ s'
84156 ────────────────────────────────
@@ -123,7 +195,7 @@ data _⊢_⇀⦇_,UTXOW⦈_ : UTxOEnv → UTxOState → TopLevelTx → UTxOState
123195 ∙ neededVKeyHashes ⊆ witsKeyHashes
124196 ∙ neededScriptHashes ⊆ mapˢ hash p1Scripts ∪ mapˢ hash p2Scripts
125197 ∙ neededDataHashes ⊆ dom (Γ .globalData)
126- ∙ languages tx utxo ⊆ allowedLanguages tx utxo
198+ ∙ languages p2Scripts ⊆ allowedLanguages tx utxo
127199 ∙ txADhash ≡ map hash txAuxData
128200 ∙ Γ ⊢ s ⇀⦇ tx ,UTXO⦈ s'
129201 ────────────────────────────────
0 commit comments