mlabs-haskell / cem-script

https://cardano.ideascale.com/c/idea/106740
MIT License
2 stars 2 forks source link

Generate Oura config for an instance of CEM-script #100

Open Renegatto opened 2 weeks ago

Renegatto commented 2 weeks ago

This PR introduces a function, that given a CEM-script instance will generate config for Oura, such that Oura will index all spendings from the CEM-script validator.

API

https://github.com/mlabs-haskell/cem-script/blob/ae302686587b5529de4ccbbe6d10f4afe18058df/src/Cardano/CEM/OuraConfig.hs#L51

ouraMonitoringScript ::
  forall (script :: Type).
  CEMScriptCompiled script =>
  Proxy script ->
  Ledger.Network ->
  SourcePath ->
  SinkPath ->
  Either String Toml.Table -- error or config

The only variable section of the config is filters, the rest can be safely overwritten by the user.

The generated filter have a shape:

{
  "type":"Select",
  "predicate": <cem script payment address bech32>,
  "skip_uncertain": false
}

Testing

The change is tested against the SimpleAuction example. It feeds Oura with two transactions one of which spends from the validator address, and expect Oura to catch exactly that transaction.

The tests use oura github.com/Renegatto/oura/commit/bfcac25065719f9e3405acbbdf5fe782846ddf32 that can use unix socket in a datagram mode as a source of Txs. This has been made to simplify the testing process and avoid the need of spinning cardano node for it.

Maintenance

If the need to extend this functionality will arise, it can be handy to revert this commit: 7494b2878ed1cc699daf02e9bca680f4ed6d3888 There was the WIP on making indexer to listen for a particular state transitions.