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

How can the dapp disconnect from the wallet? #57

Open
hrajchert opened this issue Jan 17, 2024 · 6 comments
Open

How can the dapp disconnect from the wallet? #57

hrajchert opened this issue Jan 17, 2024 · 6 comments

Comments

@hrajchert
Copy link

I've seen that the class CardanoPeerConnect that wallets should implement have a disconnect method, but the dapp class DAppPeerConnect only has an onDisconnect handler. How can I terminate the connection from the dapp?

@fabianbormann
Copy link
Owner

Hi @hrajchert, I think it should be part of the demo implementation here: https://github.com/fabianbormann/cip-0045-demo-implementation/blob/main/demo-dapp/src/App.tsx#L78

Please let me know in case that it doesn't fit your needs.

@hrajchert
Copy link
Author

Hi @fabianbormann! Thanks for the reply, sadly I wasn't able to use the demo code as I'm not using the @cardano-foundation/cardano-connect-with-wallet-core library. I tried looking up the library's source code (to try to replicate the disconnect logic) but couldn't find the repo. Here is my current attempt, which is failing due to infinite recursion.

For more context, I'm trying to add mobile support to Marlowe contracts by adding some connector capabilities to the Marlowe TS-SDK. The PR that I mentioned allows any Marlowe user to interact with Marlowe contracts using a cip-45 wallet, but I had some problems trying to do a more realistic prototype.

The prototype I had in mind was a split-the-bill dapp, where a restaurant can charge a table splitting the bill among the different diners. Each diner could say how much tip they want to give, and the tips are distributed automatically to the staff.

The flow I had in mind:

  1. The restaurant has a dapp in a tablet carried by the waiter. They can configure a payment address and addresses for each staff member(to distribute tips).
  2. When it is time to charge, they put the full amount (or item per item) and ask the table how many shares is the bill going to be split and creates a contract that expects that many deposits
  3. Each diner can scan the QR code to connect to the dapp. With the current limitations, the waiter needs to ask for a tip percentage as the dapp needs to run in the browser. It would be ideal if the diner could access a mobile dapp and select the tip themselves.
  4. After all diners have made their deposits, the contract pays the restaurant and distributes the tips evenly to the staff.

@hrajchert
Copy link
Author

I found the code for wallet core 😅, but I'm not sure the code there applies to my example

@fabianbormann
Copy link
Owner

@hrajchert did it work for you? Otherwise I would invite you to join our CF Dev Discord server. https://discord.gg/HwTp2wyhjy

There is a channel for cip45 (which I should maybe rename to cardano-connect) and we could probably have a deeper discussion there or we could have a call 😊 ?

@hrajchert
Copy link
Author

hrajchert commented Feb 2, 2024

Hi @fabianbormann, as I mentioned in the message the disconnection method available in the demo app does not work for me as I'm not using the @cardano-foundation/cardano-connect-with-wallet-core library. I've read the code but it seems internal cleanup. I'm missing something that notifies the wallet that the Dapp wants to disconnect.

If you have some time I would love to have a call and discuss use cases :).

@fabianbormann
Copy link
Owner

My twitter handle is @YetAnotherAiGuy or my Discord user is abundzugamer ;) .. Would be nice if you could reach out to me on one channel so that we can find a good meeting slot.

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