vegaprotocol / vegawallet-browser

A wallet for the Vega protocol implemented as a browser extension for Firefox and Chromium-based browsers.
https://vegaprotocol.github.io/vegawallet-browser/
MIT License
4 stars 1 forks source link

Experimental browser extension

Contributing

Instructions for build and running the app can be found here.

Securely connect to Vega dapps and sign transactions from your browser.

This is an experimental release for test purposes only and is in active development. You should only transfer funds you are willing to lose to keys that are managed by the extension.

Installing the extension injects a Vega API for dapps and websites to interact with keys and send transactions to the Vega network. Connecting to the wallet and sending any transaction require explicit user approval.

Understand the risks before you start

By using the Vega Wallet, you acknowledge that you have read and understood the Vega Wallet User Data Policy ↗

Installation

Only one extension should be active (installed and enabled) at a time to avoid version conflict. Future updates may wipe all data, and keys are not recoverable. If you are communicating with multiple networks, consider using multiple browser profiles.

  1. Download a release from Github Releases for the network you are testing
  2. Follow the installation guide below based on the browser you are using:

Browser support

We support Firefox, Chrome. You can find specific version in the manifest files.

It might work on these:

Brave

But we've not tested against it. Last updated 28 Jul 2023.

Chrome users

  1. Unzip the file
  2. Add the extension by following this guide: Load unpacked extension

Firefox users

  1. Install the Firefox Browser Developer Edition
  2. Open Firefox developer edition
  3. Enter "about:config" in the URL bar. You'll be asked to accept the risk and continue
  4. Search for "xpinstall.signatures.required" and set to false
  5. Now enter "about:addons" in the URL bar
  6. From the settings cog drop down, select to install add-on from file and select your downloaded zip file
  7. You will need to accept a warning message to add an unverified extension
  8. Finally, you'll accept a "Vega wallet was added" message. Installation is then complete and you can pin to toolbar from your extension menu for easy access

Usage

The end-user API is available after window.onload and has the following methods exposed on window/globalThis:

Events include:

A sample react dApp is provided in examples/sample-react-dapp/index.html, and is also published to Github Pages - see the live demo.

A sample vanilla dApp is provided in examples/sample-dapp/index.html.

Alternatively, end-users can also communicate with the content script directly using JSON-RPC:

window.addEventListener('message', (event) => {
  // somehow avoid catching own message

  const response = event.data

  if (response.error) return console.error(response.error)

  console.log(response.result)
})

window.postMessage(
  {
    jsonrpc: '2.0',
    id: '1',
    method: 'vega.sendTransaction',
    params: { type, tx }
  },
  '*'
)

Reporting Bugs

Spot an issue? Provide feedback here

Please provide which browser you used and its version, and the output of both the DevTools console from the dApp used, the error page from the about:addons (FF) / chrome://extensions/ (Chromium) page and relevant logs from the background script and popup. See this guide for Chromium or this guide for Firefox

Examples of Chromium based browsers:

Examples of Firefox based browsers:

Structure

The project is built with rollup:

Development + building

Testing

The web extension source code lives in web-extension/common with platform specific artifacts in respectively web-extension/firefox and web-extension/chrome. All UI components exist in the frontend directory.

The web extension has 4 components:

Running the extension

To run the extension, first build it using NODE_ENV=production yarn build:beta or NODE_ENV=production yarn build:mainstream and then load it into chrome or firefox. The beta build is to generate "Vega Wallet - Beta" and the mainstream build is to generate the "Vega Wallet" extension.

For chrome follow the instructions here, the directory you need to select after pressing load unpacked should be ./build/chrome.

For firefox follow the instructions here, the directory you need to select after pressing the "load temporary addon" button should be ./build/firefox.