statebox / purescript-studio

Statebox studio + core + API + REST client
https://studio.statebox.cloud
4 stars 0 forks source link

Create GET /tx/ Transactions API endpoint #204

Open marcosh opened 5 years ago

marcosh commented 5 years ago

create a GET endpoint to retrieve all the transactions of a given protocol/process (which is the correct one of the two?)

epost commented 5 years ago
  1. Payload: nothing. Just request /tx/<hash>, like in Client.purs. Example invocation: Studio.purs. URL to use: ExampleData.purs
epost commented 5 years ago
  1. where should the API retrieve the data?

    As a starting point, maybe you could return some hardcoded transactions. Some example transaction chains are here:

    Should I use the transitions function

    Eventually, yes, as well as other functions.

epost commented 5 years ago
  1. which format should I use to return the data?

    Example: https://testapi.statebox.io/tx/zFsGM27eBJwszedPLyzbErav4PMkj8WgrnukEfpnXFqe5.

    Should I use data types from Transactions.purs?

    Si. :)

marcosh commented 5 years ago

I just pushed an update on this with more or less all the scaffolding.

Now I'd like to proceed with the most relevant part, which is retrieving the transaction data from the hash and output its data in the response. I have some doubts regarding these:

  1. where should I retrieve the transaction data? I saw that the code which does that at the moment is in https://github.com/statebox/cloud/blob/master/services/tx/process-tx.js and interacts directly with Firebase. Is this code something we want to keep or something we want to rewrite in Purescript? Do we want to abstract the fact that we are using Firebase? In other words, should I just proxy the hash call to this service or do I need to replace that service?

  2. looking at the types in https://github.com/statebox/purescript-studio/blob/development/stbx-core/src/Statebox/Core/Transaction.purs, should the return type of the API be something like Tx TxSum?

epost commented 5 years ago
  1. Yes, it needs to be redone in PS; this is https://github.com/statebox/js-protocol-implementation/issues/1.
marcosh commented 5 years ago

check https://hackmd.io/bC26TmAGRTe9mQt9D9ritw?view#purescript-studio-api-inbox for more notes on this