glifio / wallet

Glif Wallet
https://wallet.glif.io
80 stars 32 forks source link

Browser extension #513

Open lidel opened 4 years ago

lidel commented 4 years ago

Hi, I am looking into the feasibility of bundling this wallet inside a browser extension (Manifest V2):

Initial idea is to have a browser action button that when clicked, loads the wallet inside a popup or in a new tab.

There are two ways of doing that:

  1. Loading everything from https://wallet.glif.io when user clicks on browser action icon.
  2. Bundling HTML+JS+CSS inside of extension, making UI load instantly even when remote server at https://wallet.glif.io is down.

The latter is preferable, because it also means we can harden supply chain and host it on IPFS, and trust CID instead of TLS cert fingerprint and DNS.

I tried to pre-build everything with next export, which outputs to ./out/, but when I try to load static version in a browser (npx http-server ./out -a 127.0.0.1 -p 3000 -c-1), there is just a blank white page without any errors in console.

Is static mode supported at all? Any suggestions/concerns?

Schwartz10 commented 4 years ago

Hey, cool idea! I actually just pushed some changes to dev branch (and very soon primary) that will make the debugging process a bit easier. It appears as though the dynamic import to load the WASM code isn't playing friendly with static mode (note - Next's page says dynamic imports are supported, so not sure why this isn't working). Here's where we dynamically import https://github.com/openworklabs/filecoin-web-wallet/blob/primary/lib/WasmLoader.jsx#L12

Anyways, I am able to at least load the page and see logs, which should unstuck you from seeing logs in the console. I did so following these steps.

  1. Create a new script in the wallet's package.json:
"export": "next build && next export"
  1. Run npm run export
  2. cd out
  3. npx http-server
  4. Navigate to http://127.0.0.1:8081

image

You'll see in the screenshot I hit an error when trying to load the wasm. I would definitely review / accept a PR to make this happen if you are able to get it to work//have the time. (Also note - there is some funny race condition or inconsistency when running this in static mode - an error loading the WASM should push the user to an "unsupported browser" page).

lidel commented 4 years ago

I've opened #530 to include scripts for running static version, but won't have bandwidth to debug the WASM issue. If someone else is able to resolve it, I can help with wrapping into a browser extension.

Schwartz10 commented 3 years ago

Hey @lidel ! Thank you for putting that together. Right now we're also at development capacity preparing for mainnet, but if we can dig up some free time, we'll look into this.