Skip to content
This repository has been archived by the owner on Jul 6, 2022. It is now read-only.

Latest commit

 

History

History
22 lines (16 loc) · 1.18 KB

README.md

File metadata and controls

22 lines (16 loc) · 1.18 KB

polymath-react

Reusable React.js components and hooks

This repo contains two reusable pieces that are common amongst all Polymath standalone apps:

  • const {error, sdk, networkId, walletAddress} = usePolymathSdk(): call this hook inside your functional components. It will attempt to:
    • instantiate an SDK instance.
    • Connect to Polymath network
    • Get the current browser wallet address (eg from Metamask)
    • return an error, if any.
  • const {error, tokenSelector, tokens, tokenIndex} = useTokenSelector(sdk, walletAddress): call this hook to fetch all the seurity tokens that are either owned by walletAddress or are delegated to be managed by walletAddress. The hook returns:
    • tokens an array of security token objects.
    • tokenSelector a React select list that enables selecting a token to manage.
    • tokenIndex is the index of currently selected token if any.

Installation

  • yarn add PolymathNetwork/react. Yes, we will release this repo as an npm pacakge soon!

Example

To see those hooks actions please checkout our role management app.