Skip to content
Hieu Dao edited this page Jan 18, 2022 · 14 revisions

SubWallet Extensions

SubWallet is forked from polkadot-js/extension. We aim add many features but can rebase polkadot origin anytime.

Main Concept

Main Concept Extension is compiled from folder packages/extension-koni

  • Background environment: Background environment is compiled from packages/extension-koni/src/background.ts.
    • Background is use to handle message from Extensions pages and Chrome tabs via Chrome API Message Passing.
    • Save all state to store and persist to chrome storage.
    • Run cronjob.
  • Extensions: Is frontend and page of extension:
    • popup.html: Frontend page open when click to extension icon in browser.
    • portfolio.html: Frontend to display more complicated view.
  • Inject Scripts: Inject script into chrome tabs.

All data request must be call and handle by in background. Extension Pages and Inject Scripts use data from background environment and not call API directly.

Project structure

  • extension-base - Contain main features run in background, call api, persist data into chrome store and inject script.
  • extension-dapp - A convenience wrapper to work with the injected objects, simplifying data extraction for any dapp that wishes to integrate the extension (or any extension that supports the interface)
  • extension-inject - A convenience wrapper that allows extension developers to inject their extension for use by any dapp
  • extension-chains - Definitions for chains that are supported by this extension. It contains the bare definitions as well as a stripped-down (call-only) metadata format.
  • extension-dapp - The actual in-depth technical breakdown is given in the next section for any dapp developer wishing to work with the raw objects injected into the window. However, convenience wrappers are provided that allows for any dapp to use this extension (or any other extension that conforms to the interface) without having to manage any additional info.
  • extension-mocks - Mock data for testing.
  • extension-compat-metamask: Compitable with metamask
  • extension-koni-base: Custom package, extension extension base
  • extension-koni-ui (replace extension-ui): The UI components for the extension, to build up the popup
  • extension-koni (replace extension): All the injection and background processing logic (the main entry)
Clone this wiki locally