Skip to content

Commit

Permalink
Update gh-pages
Browse files Browse the repository at this point in the history
Store path: /nix/store/yylsa702yxawvvwv0x84w76862ki5dxf-tx-village-github-pages
  • Loading branch information
hercules-ci[bot] committed Oct 1, 2024
1 parent 8e3b076 commit e423113
Show file tree
Hide file tree
Showing 76 changed files with 336 additions and 183 deletions.
2 changes: 1 addition & 1 deletion artifacts/tx-indexer/search-index.js

Large diffs are not rendered by default.

30 changes: 30 additions & 0 deletions artifacts/tx-indexer/src/tx_indexer/from_oura.rs.html
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,21 @@ <h2>Files</h2></div></nav><div class="sidebar-resizer"></div>
<a href="#135" id="135">135</a>
<a href="#136" id="136">136</a>
<a href="#137" id="137">137</a>
<a href="#138" id="138">138</a>
<a href="#139" id="139">139</a>
<a href="#140" id="140">140</a>
<a href="#141" id="141">141</a>
<a href="#142" id="142">142</a>
<a href="#143" id="143">143</a>
<a href="#144" id="144">144</a>
<a href="#145" id="145">145</a>
<a href="#146" id="146">146</a>
<a href="#147" id="147">147</a>
<a href="#148" id="148">148</a>
<a href="#149" id="149">149</a>
<a href="#150" id="150">150</a>
<a href="#151" id="151">151</a>
<a href="#152" id="152">152</a>
</pre></div><pre class="rust"><code><span class="kw">use </span>::oura::model::{MintRecord, OutputAssetRecord};
<span class="kw">use </span>anyhow::Context;
<span class="kw">use </span>data_encoding::HEXLOWER;
Expand All @@ -145,6 +160,7 @@ <h2>Files</h2></div></nav><div class="sidebar-resizer"></div>
address::Address,
crypto::LedgerBytes,
datum::{Datum, DatumHash},
redeemer::Redeemer,
script::{MintingPolicyHash, ScriptHash},
transaction::TransactionHash,
value::{CurrencySymbol, TokenName, Value},
Expand Down Expand Up @@ -235,6 +251,20 @@ <h2>Files</h2></div></nav><div class="sidebar-resizer"></div>
}
}

<span class="kw">impl </span>FromOura&lt;serde_json::Value&gt; <span class="kw">for </span>Redeemer {
<span class="kw">fn </span>from_oura(value: serde_json::Value) -&gt; <span class="prelude-ty">Result</span>&lt;<span class="self">Self</span>, OuraParseError&gt; {
<span class="kw">let </span>csl_plutus_data =
csl::encode_json_value_to_plutus_datum(value, csl::PlutusDatumSchema::DetailedSchema)
.with_context(|| <span class="string">"Parsing Redeemer from Oura"</span>)<span class="question-mark">?</span>;

<span class="prelude-val">Ok</span>(Redeemer(
csl_plutus_data
.try_to_pla()
.with_context(|| <span class="string">"Parsing Redeemer from Oura"</span>)<span class="question-mark">?</span>,
))
}
}

<span class="kw">impl </span>FromOura&lt;String&gt; <span class="kw">for </span>Address {
<span class="kw">fn </span>from_oura(value: String) -&gt; <span class="prelude-ty">Result</span>&lt;<span class="self">Self</span>, OuraParseError&gt; {
<span class="kw">let </span>csl_addr = csl::Address::from_bech32(<span class="kw-2">&amp;</span>value)
Expand Down
126 changes: 124 additions & 2 deletions artifacts/tx-indexer/src/tx_indexer/handler/chain_event.rs.html
Original file line number Diff line number Diff line change
Expand Up @@ -222,18 +222,82 @@ <h2>Files</h2></div></nav><div class="sidebar-resizer"></div>
<a href="#220" id="220">220</a>
<a href="#221" id="221">221</a>
<a href="#222" id="222">222</a>
<a href="#223" id="223">223</a>
<a href="#224" id="224">224</a>
<a href="#225" id="225">225</a>
<a href="#226" id="226">226</a>
<a href="#227" id="227">227</a>
<a href="#228" id="228">228</a>
<a href="#229" id="229">229</a>
<a href="#230" id="230">230</a>
<a href="#231" id="231">231</a>
<a href="#232" id="232">232</a>
<a href="#233" id="233">233</a>
<a href="#234" id="234">234</a>
<a href="#235" id="235">235</a>
<a href="#236" id="236">236</a>
<a href="#237" id="237">237</a>
<a href="#238" id="238">238</a>
<a href="#239" id="239">239</a>
<a href="#240" id="240">240</a>
<a href="#241" id="241">241</a>
<a href="#242" id="242">242</a>
<a href="#243" id="243">243</a>
<a href="#244" id="244">244</a>
<a href="#245" id="245">245</a>
<a href="#246" id="246">246</a>
<a href="#247" id="247">247</a>
<a href="#248" id="248">248</a>
<a href="#249" id="249">249</a>
<a href="#250" id="250">250</a>
<a href="#251" id="251">251</a>
<a href="#252" id="252">252</a>
<a href="#253" id="253">253</a>
<a href="#254" id="254">254</a>
<a href="#255" id="255">255</a>
<a href="#256" id="256">256</a>
<a href="#257" id="257">257</a>
<a href="#258" id="258">258</a>
<a href="#259" id="259">259</a>
<a href="#260" id="260">260</a>
<a href="#261" id="261">261</a>
<a href="#262" id="262">262</a>
<a href="#263" id="263">263</a>
<a href="#264" id="264">264</a>
<a href="#265" id="265">265</a>
<a href="#266" id="266">266</a>
<a href="#267" id="267">267</a>
<a href="#268" id="268">268</a>
<a href="#269" id="269">269</a>
<a href="#270" id="270">270</a>
<a href="#271" id="271">271</a>
<a href="#272" id="272">272</a>
<a href="#273" id="273">273</a>
<a href="#274" id="274">274</a>
<a href="#275" id="275">275</a>
<a href="#276" id="276">276</a>
<a href="#277" id="277">277</a>
<a href="#278" id="278">278</a>
<a href="#279" id="279">279</a>
<a href="#280" id="280">280</a>
<a href="#281" id="281">281</a>
<a href="#282" id="282">282</a>
<a href="#283" id="283">283</a>
</pre></div><pre class="rust"><code><span class="kw">use crate</span>::{
from_oura::{FromOura, OuraParseError},
progress_tracker::ProgressTracker,
};
<span class="kw">use </span>anyhow::anyhow;
<span class="kw">use </span>itertools::Itertools;
<span class="kw">use </span>num_bigint::BigInt;
<span class="kw">use </span>oura::model <span class="kw">as </span>oura;
<span class="kw">use </span>plutus_ledger_api::v2::{
address::Address,
datum::{Datum, DatumHash, OutputDatum},
redeemer::Redeemer,
script::ScriptHash,
transaction::{TransactionHash, TransactionInput, TransactionOutput, TxInInfo},
value::Value,
transaction::{ScriptPurpose, TransactionHash, TransactionInput, TransactionOutput, TxInInfo},
value::{CurrencySymbol, Value},
};
<span class="kw">use </span>std::fmt::Debug;
<span class="kw">use </span>std::{collections::HashMap, sync::atomic::Ordering};
Expand Down Expand Up @@ -277,6 +341,7 @@ <h2>Files</h2></div></nav><div class="sidebar-resizer"></div>
<span class="kw">pub </span>inputs: Vec&lt;TransactionInput&gt;,
<span class="kw">pub </span>outputs: Vec&lt;TxInInfo&gt;,
<span class="kw">pub </span>mint: Value,
<span class="kw">pub </span>redeemers: HashMap&lt;ScriptPurpose, Redeemer&gt;,

<span class="kw">pub </span>plutus_data: HashMap&lt;DatumHash, Datum&gt;,
<span class="comment">// TODO(chase): Which of these would be realistically be interested in?
Expand Down Expand Up @@ -368,6 +433,63 @@ <h2>Files</h2></div></nav><div class="sidebar-resizer"></div>
<span class="prelude-val">Ok</span>(TransactionEventRecord {
hash: TransactionHash::from_oura(tx.hash.clone())<span class="question-mark">?</span>,
fee: tx.fee,
redeemers: tx
.plutus_redeemers
.unwrap()
.into_iter()
.map(|redeemer_record| {
<span class="comment">// TODO(szg251): parse other redeemer tags
</span><span class="kw">let </span>script_purpose = <span class="kw">match </span><span class="kw-2">&amp;</span>redeemer_record.purpose[..] {
<span class="string">"spend" </span>=&gt; {
<span class="kw">let </span>inputs = tx.inputs.as_ref().unwrap();
<span class="kw">let </span>input = inputs
.get(redeemer_record.input_idx <span class="kw">as </span>usize)
.ok_or(OuraParseError::ParseError(<span class="macro">anyhow!</span>(
<span class="string">"No input found at redeemer index {}"</span>,
redeemer_record.input_idx
)))<span class="question-mark">?
</span>.clone();

<span class="kw">let </span>transaction_input = TransactionInput {
transaction_id: TransactionHash::from_oura(input.tx_id)<span class="question-mark">?</span>,
index: BigInt::from(input.index),
};
ScriptPurpose::Spending(transaction_input)
}
<span class="string">"mint" </span>=&gt; {
<span class="kw">let </span>policies = tx
.mint
.as_ref()
.unwrap()
.iter()
.map(|mint| mint.policy.clone())
.sorted()
.dedup()
.collect::&lt;Vec&lt;<span class="kw">_</span>&gt;&gt;();
<span class="kw">let </span>policy = policies
.get(redeemer_record.input_idx <span class="kw">as </span>usize)
.ok_or(OuraParseError::ParseError(<span class="macro">anyhow!</span>(
<span class="string">"No mint found at redeemer index {}"</span>,
redeemer_record.input_idx
)))<span class="question-mark">?
</span>.clone();

ScriptPurpose::Minting(CurrencySymbol::from_oura(policy)<span class="question-mark">?</span>)
}
<span class="comment">// "cert" =&gt; ScriptPurpose::Certifying (),
// "reward" =&gt; ScriptPurpose::Rewarding(0)
</span><span class="kw">_ </span>=&gt; <span class="prelude-val">Err</span>(OuraParseError::ParseError(<span class="macro">anyhow!</span>(
<span class="string">"Cannot parse redeemer tag variant: {}"</span>,
redeemer_record.purpose
)))<span class="question-mark">?</span>,
};

<span class="prelude-val">Ok</span>((
script_purpose,
Redeemer::from_oura(redeemer_record.plutus_data)<span class="question-mark">?</span>,
))
})
.collect::&lt;<span class="prelude-ty">Result</span>&lt;<span class="kw">_</span>, OuraParseError&gt;&gt;()<span class="question-mark">?</span>,
size: tx.size,
<span class="comment">// All these unwraps should succeed since we enable `include_transaction_details`
// in the mapper config.
Expand Down
24 changes: 12 additions & 12 deletions artifacts/tx-indexer/src/tx_indexer/handler/retry.rs.html
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ <h2>Files</h2></div></nav><div class="sidebar-resizer"></div>
<span class="kw">use </span>oura::model <span class="kw">as </span>oura;
<span class="kw">use </span>std::{fmt::Debug, ops::Mul, time::Duration};
<span class="kw">use </span>strum_macros::Display;
<span class="kw">use </span>tracing::{event, span, Instrument, Level};
<span class="kw">use </span>tracing::{debug, debug_span, error, warn, warn_span, Instrument};

<span class="doccomment">/// Influence retrying behavior.
/// i.e How many times and how often a failed operation should be retried.
Expand Down Expand Up @@ -184,7 +184,7 @@ <h2>Files</h2></div></nav><div class="sidebar-resizer"></div>
policy: <span class="kw-2">&amp;</span>RetryPolicy,
progress_tracker: <span class="kw-2">&amp;mut </span><span class="prelude-ty">Option</span>&lt;ProgressTracker&gt;,
) -&gt; <span class="prelude-ty">Result</span>&lt;(), H::Error&gt; {
<span class="kw">let </span>span = <span class="macro">span!</span>(Level::DEBUG, <span class="string">"perform_with_retry"</span>);
<span class="kw">let </span>span = <span class="macro">debug_span!</span>(<span class="string">"perform_with_retry"</span>);
<span class="kw">let </span>_enter = span.enter();

<span class="kw">match </span>parse_oura_event(oura_event, progress_tracker) {
Expand All @@ -195,44 +195,44 @@ <h2>Files</h2></div></nav><div class="sidebar-resizer"></div>

<span class="kw">loop </span>{
<span class="comment">// TODO(szg251): Handle errors properly
</span><span class="kw">let </span>span = <span class="macro">span!</span>(Level::DEBUG, <span class="string">"TryingOperation"</span>, retry_count = retry);
</span><span class="kw">let </span>span = <span class="macro">debug_span!</span>(<span class="string">"TryingOperation"</span>, retry_count = retry);
<span class="kw">let </span>res = <span class="kw">async </span>{
<span class="kw">let </span>result = handler.handle(event.clone())
.instrument(<span class="macro">span!</span>(Level::DEBUG, <span class="string">"UserDefinedHandler"</span>)).<span class="kw">await</span>;
.instrument(<span class="macro">debug_span!</span>(<span class="string">"UserDefinedHandler"</span>)).<span class="kw">await</span>;

<span class="kw">match </span>result {
<span class="prelude-val">Ok</span>(<span class="kw">_</span>) =&gt; {
<span class="macro">event!</span>(Level::DEBUG, label=%EventOutcome::Success);
<span class="macro">debug!</span>(label=%EventOutcome::Success);
<span class="prelude-val">Some</span>(<span class="prelude-val">Ok</span>(()))
}
<span class="prelude-val">Err</span>(err) =&gt; <span class="kw">match </span>err.get_error_policy() {
ErrorPolicy::Exit =&gt; {
<span class="macro">event!</span>(Level::ERROR, label=%EventOutcome::FailureExit);
<span class="macro">error!</span>(label=%EventOutcome::FailureExit);
<span class="prelude-val">Some</span>(<span class="prelude-val">Err</span>(err))
}
ErrorPolicy::Skip =&gt; {
<span class="macro">event!</span>(Level::WARN, label=%EventOutcome::FailureSkip, err=<span class="question-mark">?</span>err);
<span class="macro">warn!</span>(label=%EventOutcome::FailureSkip, err=<span class="question-mark">?</span>err);
<span class="prelude-val">Some</span>(<span class="prelude-val">Ok</span>(()))
}
ErrorPolicy::Call(err_f) =&gt; <span class="macro">span!</span>(Level::WARN, <span class="string">"OperationFailureCall"</span>).in_scope(|| {
ErrorPolicy::Call(err_f) =&gt; <span class="macro">warn_span!</span>(<span class="string">"OperationFailureCall"</span>).in_scope(|| {
err_f(err);
<span class="prelude-val">Some</span>(<span class="prelude-val">Ok</span>(()))
}),
ErrorPolicy::Retry <span class="kw">if </span>retry &lt; policy.max_retries =&gt; {
<span class="macro">event!</span>(Level::WARN, label=%EventOutcome::FailureRetry, err=<span class="question-mark">?</span>err);
<span class="macro">warn!</span>(label=%EventOutcome::FailureRetry, err=<span class="question-mark">?</span>err);

retry += <span class="number">1</span>;

<span class="kw">let </span>backoff = compute_backoff_delay(policy, retry);

<span class="macro">event!</span>(Level::DEBUG, label=%EventOutcome::RetryBackoff, backoff_secs=backoff.as_secs());
<span class="macro">debug!</span>(label=%EventOutcome::RetryBackoff, backoff_secs=backoff.as_secs());

std::thread::sleep(backoff);

<span class="prelude-val">None
</span>}
<span class="kw">_ </span>=&gt; {
<span class="macro">event!</span>(Level::DEBUG, label=%EventOutcome::RetriesExhausted);
<span class="macro">debug!</span>(label=%EventOutcome::RetriesExhausted);
<span class="prelude-val">Some</span>(<span class="prelude-val">Err</span>(err))
}
},
Expand All @@ -248,7 +248,7 @@ <h2>Files</h2></div></nav><div class="sidebar-resizer"></div>
}
<span class="prelude-val">Ok</span>(<span class="prelude-val">None</span>) =&gt; <span class="prelude-val">Ok</span>(()),
<span class="prelude-val">Err</span>(err) =&gt; {
<span class="macro">event!</span>(Level::ERROR, err = <span class="question-mark">?</span>err);
<span class="macro">error!</span>(err = <span class="question-mark">?</span>err);

<span class="prelude-val">Ok</span>(())
}
Expand Down
Loading

0 comments on commit e423113

Please sign in to comment.