user2385: Can somebody explain these lines and why (both) Constraints.typedValidatorLookups... and
Constraints.otherScript... are used? Still struggling to get my head around lookups, so maybe that is why I'm somehow failing to grasp what exactly the purpose of these lines is and why for example, just the second is not enough by itself?
let lookups = Constraints.unspentOutputs (Map.singleton oref o)     <>
Constraints.typedValidatorLookups (typedValidator oracle) <>
Constraints.otherScript (oracleValidator oracle)```

(Core.hs : lines 169, 170)


user907: This one is a bit technical it has to do with looking up and updating the constraints of an already existing transaction (that belongs to the script address). See Case ii) to skip my synopsis.
Just a little synopsis for future readers: The Core.hs script is an Oracle, that has to update its datum regarding Ada price. The lines in which lookups occur are in the function updateOracle that has the purpose of building a transaction and then submitting it. To accomplish this the constraints need to refer to typed script inputs and outputs. In updateOracle we dealt with two cases
.
.
    case m of
        Nothing -> do
            ledgerTx <- submitTxConstraints (typedOracleValidator oracle) c
            .
            .
        Just (oref, o,  _) -> do
            let lookups = Constraints.unspentOutputs (Map.singleton oref o)     <>
                          Constraints.typedValidatorLookups (typedOracleValidator oracle) <>
                          Constraints.otherScript (oracleValidator oracle)
                tx      = c <> Constraints.mustSpendScriptOutput oref (Redeemer $ PlutusTx.toBuiltinData Update)
            ledgerTx <- submitTxConstraintsWith @Oracling lookups tx
            .
            .


i) Create the Oracle (if it doesn't exists) at the same time of submission and add datum.

ii) Just update the datum of an existing Oracle


Case i) uses submitTxConstraints which takes the constraints as inputs in the form of a script instance (with typed validator hash & the compiled program) and the locked value with the script.
Case ii) on the other hand, uses submitTxConstraintsWith which takes the updated constraints as ScriptLookup type rather than a script instance. To your question, we need to semigroup:

Constraints.typedValidatorLookups (this gets the previous
parameters of the ScriptLookup)
Constraints.unspentOutputs (updates slTxOutputs from
ScriptLookup, which are the unspent outputs that the script wants to
spend)
Constraints.otherScript (updates slOtherScripts from
ScriptLookup, which are validators of the script other than our
script)

The reason why Constraints.typedValidatorLookups alone is not enough is because we would not be updating anything without semigrouping ScriptLookup element by element as defined in OffChain.hs)

2385: <p>Can somebody explain these lines and why (both) Constraints.typedValidatorLookups... and
Constraints.otherScript... are used? Still struggling to get my head around lookups, so maybe that is why I'm somehow failing to grasp what exactly the purpose of these lines is and why for example, just the second is not enough by itself?</p>
<pre><code>let lookups = Constraints.unspentOutputs (Map.singleton oref o)     &lt;&gt;
Constraints.typedValidatorLookups (typedValidator oracle) &lt;&gt;
Constraints.otherScript (oracleValidator oracle)```

(Core.hs : lines 169, 170)
</code></pre>
 907: <p>This one is a bit technical it has to do with looking up and updating the constraints of an already existing transaction (that belongs to the script address). See Case ii) to skip my synopsis.</p>
<p>Just a little synopsis for future readers: The <a href="https://github.com/input-output-hk/plutus-pioneer-program/blob/main/code/week06/src/Week06/Oracle/Core.hs" rel="nofollow noreferrer"><code>Core.hs</code></a> script is an Oracle, that has to update its datum regarding Ada price. The lines in which lookups occur are in the function <code>updateOracle</code> that has the purpose of building a transaction and then submitting it. To accomplish this the constraints need to refer to typed script inputs and outputs. In <code>updateOracle</code> we dealt with two cases</p>
<pre><code>.
.
    case m of
        Nothing -&gt; do
            ledgerTx &lt;- submitTxConstraints (typedOracleValidator oracle) c
            .
            .
        Just (oref, o,  _) -&gt; do
            let lookups = Constraints.unspentOutputs (Map.singleton oref o)     &lt;&gt;
                          Constraints.typedValidatorLookups (typedOracleValidator oracle) &lt;&gt;
                          Constraints.otherScript (oracleValidator oracle)
                tx      = c &lt;&gt; Constraints.mustSpendScriptOutput oref (Redeemer $ PlutusTx.toBuiltinData Update)
            ledgerTx &lt;- submitTxConstraintsWith @Oracling lookups tx
            .
            .
</code></pre>
<ul>
<li><p>i) Create the Oracle (if it doesn't exists) at the same time of submission and add datum.</p>
</li>
<li><p>ii) Just update the datum of an existing Oracle</p>
</li>
</ul>
<p>Case i) uses <code>submitTxConstraints</code> which takes the constraints as inputs in the form of a script instance (with typed validator hash &amp; the compiled program) and the locked value with the script.</p>
<p>Case ii) on the other hand, uses <code>submitTxConstraintsWith</code> which takes the updated constraints as <code>ScriptLookup</code> type rather than a script instance. To your question, we need to semigroup:</p>
<ul>
<li><code>Constraints.typedValidatorLookups</code> (this gets the previous
parameters of the <code>ScriptLookup</code>)</li>
<li><code>Constraints.unspentOutputs</code> (updates <code>slTxOutputs</code> from
<code>ScriptLookup</code>, which are the unspent outputs that the script wants to
spend)</li>
<li><code>Constraints.otherScript</code> (updates <code>slOtherScripts</code> from
<code>ScriptLookup</code>, which are validators of the script other than our
script)</li>
</ul>
<p>The reason why <code>Constraints.typedValidatorLookups</code> alone is not enough is because we would not be updating anything without semigrouping <code>ScriptLookup</code> element by element as defined in <a href="https://github.com/input-output-hk/plutus/blob/master/plutus-ledger/src/Ledger/Constraints/OffChain.hs" rel="nofollow noreferrer"><code>OffChain.hs</code></a>)</p>
