EXPERIMENTS

#044 Persist Me
    Dupdate
by Anupam, 03/01/23

If you already have Dub, you can simply Check for Updates (or, you’ll get an auto-update soon)!

Or, get the download here.

https://downloads.dubdubdub.xyz/dub.dmg

Overview

This week’s big jump: persistent connections on dApps with a much more robust history manager.

Last week, I pushed forward on powering up browser history - allowing users to track their search and tab journeys across profiles (search sessions), wallet events (connect, disconnect, signing, etc..), and search history sorted by website.

My major accomplishment this week was enabling another major feature: magic connections.

Whenever you land on a dApp, we automatically check if you’ve been there before & if you were last connected with the selected wallet. If so, we drop you right back in by connecting you automatically - no extra steps!

Lots of things went into enabling this, but the coolest of which is that we know also support disconnecting!

Other new features this week include View Only Wallets (i.e., wallets that were added without a private key - you can still connect these wallets), enabling canceling notifications / transaction requests and properly rejecting them for the dApp (see video), fixed bit.ly links, enabled more robust URL validation (to handle errors for mistyped URLs and take you to a search engine when appropriate), and started down WalletConnect implementation by bringing in Cam’s code.

In short:

Automatic reconnection after visiting / connecting to a site once and automatic disconnection when a wallet is disconnected from a dApp

Rejecting a connection request reflects on the webpage

Process

I had a lot of fun - and a lot of pain - building and re-implementing history manager to work more seamlessly with connecting.

While I had made a lot of the progress on this on the last sprint, I only started flushing out the bugs (of which there were honestly, many) on this run around. Much of the problems I ran into were logic puzzles - figuring out what data to pull out from where when; these aren’t difficult, but did take some time! And, of course, there was a lot of refactoring in the Tab and in the wallet instance / wallets to keep make sure we’re tracking history everywhere.

Finishing this up also meant implementing disconnection / connection rejections (so I could actually test the persistent connections) which was just some fun JavaScript work. Unfortunately, there’s 0 documentation on how these kinds of web3 providers work, so it’s a lot of learning from poking around. After some learning time, I was able to implement the two functions that make this possible-

I also learned that the “Disconnect” button on a dApp doesn’t actually disconnect the wallet - it simply reloads the dApp to stop checking if a wallet is connected. In other words, clicking the disconnect button on a dApp doesn’t actually communicate with the wallet - so it’s impossible to track if this button is clicked. Down the line, I hope to experiment more with making the connection between wallet <-> dApp <-> blockchain much more seamless.

I also spent a LOT of time parsing through trying to read if something was valid URL. Unfortunately, there isn’t really a good standard for validating URLs - there are many different TLDs and a lot of custom rules which are basically impossible to track. While there are a few built-in APIs to WebKit that can watch, none of them are absolutely inclusive of all URL rules (I tried them!).

Instead, I now make a small (tiny) & fast API request to validate that a URL can be navigated to - and, if a successful “pre-flight” response comes through, we save the URL and take you to the site.

Next Steps

The big push for this coming week will be wrapping up WalletConnect, exploring data persistence, & cleaning up any issues with persistent dApp connections.

We’re also pushing forward on our public facing website & storytelling so there’s more to be done there.

As always, more to be done. Back next week with more ✌️