33-Labs / flowview

https://flowview.app
23 stars 7 forks source link

Add hybrid custody support for emulator #14

Open bartolomej opened 11 months ago

bartolomej commented 11 months ago

I can see that the Hybrid custody feature is disabled for the emulator network:

https://github.com/33-Labs/flowview/blob/1c739751c3637011872100867b74b697679b052a/components/common/Siderbar.js#L64-L69

I believe that's because hybrid custody contracts aren't available (deployed) on the emulator network by default, so the scripts won't work.

I wonder if we could enable emulator support, but just make sure to handle errors appropriately (I saw that errors are currently just ignored), to let the users know why the hybrid custody doesn't work (in case they don't have that contract deployed).

Context:

We are thinking of integrating flow-view to Flowser app (likely by embedding a deployed or locally hosted version in an iframe window) to reuse existing hybrid custody features already supported in flow-view. I think the basic support would already work if we enabled hybrid custody for the emulator.

There is still a question of how to make it easy for users to setup hybrid custody contracts locally (I just spend quite some time doing that myself, so I don't think it's easy to do that now), but that can be solved separately.

bartolomej commented 11 months ago

Thought I'd paste some extra notes around exposing HybridCustody on the emulator:

But I think the easiest and the most preferred way to do that now is to just use a hybrid custody scaffold: https://github.com/onflow/hybrid-custody-scaffold. Of course, this is mostly a valid solution when starting a new project.

LanfordCai commented 11 months ago

@bartolomej How about adding some buttons to the Flowview page that allow users to 'click to deploy'? For instance, there could be a 'HybridCustody' button. When a user clicks it, HybridCustody would be deployed to the emulator service account. In terms of dependencies, any that are omitted would also be deployed to the service account.

bartolomej commented 11 months ago

@LanfordCai That would also work but seems like it could require a bit more work to get implemented.

I think most importantly we should probably handle the errors gracefully first (e.g. display them to the user) and then follow-up with an improvement that offers a fix for the received errors, as the one you mentioned.

The one slight issue with "deploy HybridCustody" action is that it won't update the flow.json config in the user's project folder, which is not ideal for local development (e.g. transactions with new import syntax won't work).

I wonder if we should either:

LanfordCai commented 11 months ago

@bartolomej I have updated https://emulator.flowview.app. Could you please check the hc pages?

bartolomej commented 11 months ago

@LanfordCai I can see the pages are now visible for the emulator mode and you can configure the hybrid custody contract address. That's great, thanks for that!

Follow-up things that could be nice to have:

LanfordCai commented 10 months ago

@bartolomej Thank you for your feedback! Now you can edit the contract address by clicking the cog button at the top-right of the page! As for the API, now there is no API for flowview and it would be great to know you are going to implement it! Thank you!