Wallet Connection Prefab
Summary We currently have multiple wallet connection providers [Wallet Connect, MetaMask, Web3Auth, HyperPlay] and use single scenes for each, we can unify these providers into one prefab
Suggested features or ways to address the summary
We can have ILoginProviders added to this prefab to load providers during runtime.
Motivation Easier for User to simply drag prefab into their scene for usage We can have handle different wallet connections via an abstraction
Acceptance Criteria We can use multiple wallet connection providers from a single scene using a single prefab.
Blockers (OPTIONAL) [Do you see any blocker that needs to be done before implementing this feature?]
Dependencies (OPTIONAL) [Do you know about dependencies that directly affect this issue?]
Additional Context (OPTIONAL) [Add any other context, files, images (screenshots/videos), diagrams, or documents about the feature request here.]
Final Steps
- Give it one of these labels
Type: FeatureType: Enhancement - Add your estimation
Estimations
| 5 | Moderate efort | A few days | Mediium complexity | Moderate |
UI Flow
Work Breakdown
PR 1
Refactor Web3Auth to use WalletProvider
- Refactor
InProcessSignerandInProcessTransactionExecutorto be injected instead of initialized inWeb3AuthWalllet - Refactor
Web3AuthWallet -> Web3AuthProvider : WalletProvider -
IWeb3wrapper that can injected to pass web3 initialized with a private key - cleanup more of Web3Auth GUI (multiple input handling) and move
Web3AuthTransactionHandlertoWeb3AuthTransactionExecutorandWeb3AuthProvider
PR 2
Create prefab Visuals
- Connection Overlay, Loading Overlay, Error modal and a way to list out providers as Prefabs
PR 3
- Refactor
LoginProviderto beConnectionProviderthat can support connection providers asIWeb3BuilderServiceAdapter - Connect Providers/Login provider to Prefab, Have a custom editor for Login Provider that can add/remove providers as
IWeb3BuilderServiceAdapter - Handle
WalletConnectionto work with the loading overlay and other parts of the Wallet prefab
PR 4
-
- Create
WalletConnectionwhich can be restored for restorable providers, AddWalletConnection IWalletProvider.Restore()and haveIWalletProvider.Connect()returnWalletConnection
- Create
- Have
IWalletProviderConfighandle restoring sessions for providers - Remove previous
LoginProvidersto replace withConnectionProviders - Make sure all providers work
- Create a disconnect/logout prefab with an optional display for account (with a copy option) that's instantiated on Login [optional]
Restorable providers -> The ones that can remember the session? I am not sure if any of the providers we currently have can't save the session? But good to think in advance :D
I like everything you have wrote Rob! LGTM 👍
Good work, Rob. Yet there are points I want to discuss.
- We create Web3 before "Provider prompts connection". This operation is a consequence of creating (Launching) a web3 instance.
- What is the purpose of Logout prefab? Why not let users call a public method to logout?
-
IWeb3 wrapper that can injected to pass web3 initialized with a private key
- What do you mean here? What is the function of IWeb3 wrapper and what is its relationship with other parts of the system?
- Please describe the entity (service, class) the developer is going to interact with to show the overlay, how it will be configured, and how it would relate to the existing Web3Builder/Web3 systems.
- The current LoginProvider implementation is cumbersome. If we're going to refactor this part of the project heavily, then it would be nice to see the whole inheritance hierarchy removed in favor of composition-based code.
Good work, Rob. Yet there are points I want to discuss.
- We create Web3 before "Provider prompts connection". This operation is a consequence of creating (Launching) a web3 instance.
- What is the purpose of Logout prefab? Why not let users call a public method to logout?
IWeb3 wrapper that can injected to pass web3 initialized with a private key
- What do you mean here? What is the function of IWeb3 wrapper and what is its relationship with other parts of the system?
- Please describe the entity (service, class) the developer is going to interact with to show the overlay, how it will be configured, and how it would relate to the existing Web3Builder/Web3 systems.
- The current LoginProvider implementation is cumbersome. If we're going to refactor this part of the project heavily, then it would be nice to see the whole inheritance hierarchy removed in favor of composition-based code.
- I don't follow
- We will have that but this would be a good feature to have it as an option
- It's for process signer and txn executor, a way to abstract the private key, it's NEthereum's web3 not ours
- It's going to be a refactor of the already existing LoginProvider and it'll work the same with a few modifications I mentioned above
- That's probably how's it's going to end up since current concrete implementations are gonna end up being IWeb3BuilderServiceAdapter
- Sorry. I was referring to your diagram. There is a step "Provider prompts connection" and it comes before we build Web3. Prompting connection is currently a part of Web3 initialization flow. It is invoked when you build Web3 instance.
- Yeah, but what is that prefab for? What functionality does it provide?
- Can you elaborate more?
4-5. I see. Then we need to have a dependency diagram describing new/refactored components, before proceeding. It's hard to see what you're proposing without it.
- Sorry. I was referring to your diagram. There is a step "Provider prompts connection" and it comes before we build Web3. Prompting connection is currently a part of Web3 initialization flow. It is invoked when you build Web3 instance.
- Yeah, but what is that prefab for? What functionality does it provide?
- Can you elaborate more?
4-5. I see. Then we need to have a dependency diagram describing new/refactored components, before proceeding. It's hard to see what you're proposing without it.
- Yep, that's what I mean
- Just Logging out/disconnect and displaying public address
- Currently we use private key for In Process signer and txn executor, and we initialize a web3 object for both using the private key, 2 issues here are 1, easy access to private key (public property) 2, NEthereum's web3 object is being created more than once, we can create one instance and reference/inject it where we need it
- Sure I'll get to that when I reach PR 3
@oleksandrchainsafe here's the class diagram for PR3, I've also updated PR4 by moving session restoration form PR3 to PR4
Looks good, yet hard to envision the final result IMO.
Please make sure users can manage: a) time of initialization of web3, b) where web3 is stored (not force them into using Web3Accessor), c) which modules are used for the particular web3 instance from code (do not restrict them into using inspector only).
Looks good, yet hard to envision the final result IMO.
Please make sure users can manage: a) time of initialization of web3, b) where web3 is stored (not force them into using Web3Accessor), c) which modules are used for the particular web3 instance from code (do not restrict them into using inspector only).
I've already implemented this since last week here
a) could you elaborate more
b) we actually have further plans for Web3Accessor and we're going to expand on it here so we're keeping it in core pkg but I can have ConnectionHandler.TryConnect return Web3 object
c) Inspector window?? we have a custom editor for adding/removing providers but devs can also implement their own providers