Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add hybrid custody support for emulator #14

Open
bartolomej opened this issue Nov 9, 2023 · 6 comments
Open

Add hybrid custody support for emulator #14

bartolomej opened this issue Nov 9, 2023 · 6 comments

Comments

@bartolomej
Copy link

bartolomej commented Nov 9, 2023

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

// {
// id: "6", label: `Acct Linking`, subItems: [
// { id: "6-0", isSubItem: true, label: "Owned Acct", smLabel: "Owned Acct", link: { pathname: "/account/[account]/hc/owned_account", query: { account: account } } },
// { id: "6-1", isSubItem: true, label: "Accts Manager", smLabel: "Accts Mgr", link: { pathname: "/account/[account]/hc/manager", query: { account: account } } },
// ]
// },

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
Copy link
Author

bartolomej commented Nov 9, 2023

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
Copy link
Member

@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
Copy link
Author

@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:

  • let the user resolve the error on their own when seeing the error message (or implement that in another local development tool such as Flow CLI or Flowser)
  • try to fix the error within flowview (e.g. with a deploy HybridCustody action button) and assume users will update the flow.json on their own or display a help message

@LanfordCai
Copy link
Member

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

@bartolomej
Copy link
Author

@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:

  • the ability to edit existing hybrid custody address (afaik once you set it, you can't edit it from the UI now)
  • API for updating the hybrid custody address
    • this will be useful if we integrate flowview in Flowser. Then we can automatically detect where the HybridCustody is deployed and update flowview settings accordingly
    • This could be achieved by allowing an optional URL parameter to specify this setting or using iFrame postMessage to execute configuration logic from the parent window (if flowview is embedded in iframe)
    • This is probably only relevant for our use case, for now, so I'll handle the implementation for this on our end (e.g. in a forked version) and make a PR if our solution could be useful in general

@LanfordCai
Copy link
Member

@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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants