input-output-hk / marlowe-playground

Apache License 2.0
6 stars 7 forks source link

Upload JSON From Local Drive To Marlowe Playground #72

Open johnshearing opened 2 years ago

johnshearing commented 2 years ago

Describe the feature you'd like

I noticed that if I cut and paste Marlowe code into the Marlowe Playground it will not load unless there is metadata from an example already loaded. Of course the metadata will not match the smart contract that I just pasted in. I understand that I would not be having this issue if I were loading and saving from gists on my github account. I am guessing that when saving to or loading from gists then the json data is what is saved and loaded which likely has the Marlowe code and the metadata for the smart contract. For those of us who can not or will not give write access to their github account, it would be nice if the json file that we can save to our downloads folder could later be uploaded again. Maybe it can and I am just not seeing how. Thanks

Describe alternatives you've considered

There could be a place to paste in the json as can be done with the Marlowe code.

Additional context / screenshots

image

hrajchert commented 2 years ago

Thanks for the feature request! We can definitely add a Load/Save to local disk, and it is a feature I wanted to do for some time. The current Download as JSON has a different purpose, so the implementation it's not trivial.

The idea behind this button is to obtain the Marlowe Core Json representation of a contract, ready to be used by the marlowe-cli to instantiate a contract in the blockchain. The feature you are requesting requires us to save the Extended Marlowe Json bundled with the source instead. Currently the only difference between the Marlowe Core JSON and Marlowe Extended JSON is the contract template parameters, but eventually this representation is the one that can include comments, metadata, functions, etc.

We already have a way to serialize the Extended Marlowe in its gist format, but we need to modify that so that it can be saved in a single tar file. I created the following ticket to capture that work. Also, if this means that we remove the current "Download as JSON", then we need to keep issue 157 in mind.

johnshearing commented 2 years ago

Hi Hernan, Thanks for considering the request.

Yes not trivial. I am working on a project similar to yours. It's an application generator for Cardano built from scratch (no libraries) in which not only builds the backend RESTful-API and JSON Database/DataDictionary but also the JavaScipt UI which runs in the browser. The application generator is even used to build itself. Now I want to automate coding of Plutus and Marlowe smart contracts and put that in the generator too. That is why I am studying Marlow, Plutus, and Haskell now. The repository is named after IOTA because I didn't know about Cardano when I started building but after finishing a few last thoughts in JavaScript I will start a brand new repository for Cardano and convert as much code as possible over to Haskell.

The generator script https://github.com/johnshearing/IOTA-Secure-Airgapped-Accounting-and-Banking-System/blob/master/lib/meta.js reads the JSON database https://github.com/johnshearing/IOTA-Secure-Airgapped-Accounting-and-Banking-System/blob/master/accounting/database/dbMetadata/metadata.json and uses the metadata found there to generate for each table a UI for adding https://github.com/johnshearing/IOTA-Secure-Airgapped-Accounting-and-Banking-System/blob/master/accounting/database/dbMetadata/metadataAdd.html records, a UI for editing https://github.com/johnshearing/IOTA-Secure-Airgapped-Accounting-and-Banking-System/blob/master/accounting/database/dbMetadata/metadataEdit.html records, a UI for searching https://github.com/johnshearing/IOTA-Secure-Airgapped-Accounting-and-Banking-System/blob/master/accounting/database/dbMetadata/metadataList.html records, and a backend RESTful-API with validation https://github.com/johnshearing/IOTA-Secure-Airgapped-Accounting-and-Banking-System/blob/master/accounting/database/dbMetadata/metadataLogic.js. I can't wait to start automating the construction of smart contracts too. Generic code for the finished applications is stored in the generator script. but if you need to deviate from generic behaviour then you can specify different code in the JSON database. The idea is to make a generator that one can use to code any kind of Cardano DAO that you would like to have.

Anyway, thank you for the work you are doing which makes all of this possible.

Best to you, John

On Tue, Jun 14, 2022 at 5:33 PM Hernan Rajchert @.***> wrote:

Thanks for the feature request! We can definitely add a Load/Save to local disk, and it is a feature I wanted to do for some time. The current Download as JSON has a different purpose, so the implementation it's not trivial.

The idea behind this button is to obtain the Marlowe Core Json representation of a contract, ready to be used by the marlowe-cli to instantiate a contract in the blockchain. The feature you are requesting requires us to save the Extended Marlowe Json bundled with the source instead. Currently the only difference between the Marlowe Core JSON and Marlowe Extended JSON is the contract template parameters, but eventually this representation is the one that can include comments, metadata, functions, etc.

We already have a way to serialize the Extended Marlowe in its gist format, but we need to modify that so that it can be saved in a single tar file. I created the following ticket https://github.com/input-output-hk/marlowe-playground/issues/73 to capture that work. Also, if this means that we remove the current "Download as JSON", then we need to keep issue 157 https://github.com/input-output-hk/marlowe-cardano/issues/157 in mind.

— Reply to this email directly, view it on GitHub https://github.com/input-output-hk/marlowe-playground/issues/72, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFKC3EO5IGYI4JYEAY44OLTVPD3D5ANCNFSM5YIIBRBQ . You are receiving this because you authored the thread.Message ID: @.***>