CardanoSolutions / ogmios

❇️ A WebSocket JSON/RPC bridge for Cardano
https://ogmios.dev
Mozilla Public License 2.0
304 stars 90 forks source link

Ogmios REPL #14

Closed KtorZ closed 3 years ago

KtorZ commented 3 years ago

Describe your idea, in simple words.

Ogmios is quite good for rapid testing. With only a few lines of JavaScript, it's easy to send request to a node. However, one has to always write some boilerplate to setup the websocket connection, serialize WSP requests, parse JSON results etc ... It'd be quite amazing if one could simply starts a REPL and interact with Ogmios by sending request directly. Behind the scene, the REPL would handle passing messages around. The REPL could even define a few useful helpers to send messages in batches.

ogmios> ledgerTip()
{
    "slot": 23424555,
    "hash": "30a80a93cb9a2e48e44d05da62a9402170a1a7c9e7a1c466fabfa5317276888b"
}

ogmios> let ledgerTip = await ledgerTip()

ogmios> findIntersection([ledgerTip])
{
    "IntersectionFound": {
      "point": {
        "slot": 23451312,
        "hash": "8a1364d853e4bf3a8aeb4f50e328b728bbd2b476f9c5ce01635f9607612525b8"
      },
      "tip": {
        "slot": 23451312,
        "hash": "8a1364d853e4bf3a8aeb4f50e328b728bbd2b476f9c5ce01635f9607612525b8",
        "blockNo": 5425625
      }
    }
}

ogmios> requestNext()
...

Why is it a good idea?

This would reduce even further the entry barrier to Ogmios and Cardano. Interact with the Cardano blockchain would be as easy as starting the REPL and typing commands.

Are you willing to work on it yourself?

Yes.

rhyslbw commented 3 years ago

I'd be happy to work on this as a way to test out the interfaces of my WIP TypeScript library.

rhyslbw commented 3 years ago

Ok @KtorZ, it's not quite ready for a PR yet but is functional and has some docs and examples https://github.com/rhyslbw/cardano-ogmios/tree/feature/client-typescript/clients/TypeScript

The tests serve as the best documentation currently:

Todo:

rhyslbw commented 3 years ago

Static binaries are built and uploaded as artifacts within the CI workflow as a new job: https://github.com/rhyslbw/cardano-ogmios/actions/runs/718453796 (To trigger this test I specified the branch, but have since pushed over that commit to restore the original triggers)

I suggest we rename the build job for clarity. Maybe haskell ? https://github.com/KtorZ/cardano-ogmios/blob/b3eb7596661be2a5d013a321f0dc8fbec781d492/.github/workflows/continuous-integration.yaml#L11

KtorZ commented 3 years ago

Nice! What do you think about:

So that it reflects the repository folder organization.

rhyslbw commented 3 years ago

I like that idea. Will implement