npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@subter/react-tezos-wallet-guard

v1.0.0

Published

A reactjs component that manages wallet connection for the tezos blockchain

Downloads

5

Readme

Reactjs Tezos Wallet Guard

A reactjs component that is meant to wrap around your routes to manage connection and disconnect of the wallet (through Beacon SDK)

Installation & Usage

To install, run:

npm install @subter/react-tezos-wallet-guard

You can then use it in your code as follows:

// index.js
import { ProvideAuth } from "@subter/react-tezos-wallet-guard";
import { BeaconEvent } from "@airgap/beacon-sdk";

// Your component code
// ...
// ...
ReactDOM.render(
  <React.StrictMode>
    <ProvideAuth
      network="hangzhounet"
      contractAddress={process.env.REACT_APP_BACKEND_CONTRACT_ADDRESS}
      beaconWalletOptions={{
        name: "Subter Development",
        disableDefaultEvents: true,
        eventHandlers={{
          [BeaconEvent.LOCAL_RATE_LIMIT_REACHED]: {
            handler: data => console.log("Local rate limit reached")
          }
        }}
      }}
    >
      {/** React Router */}
      <BrowserRouter>
        <Routes>
          <Route path="/" element={<App />} />
          <Route path="/dashboard" element={<Dashboard />} />
        </Routes>
      </BrowserRouter>
    </ProvideAuth>
  </React.StrictMode>,
  document.getElementById("root")
);

and then in any of your defined components:

import { useAuth } from "@subter/react-tezos-wallet-guard";

// Your component code
// ...
// ...
const { contract, storage, onTransaction, userAddress } = useAuth();

Props

network (string)(required)

The network in which to lookup the domain. Supported values:

  • mainnet
  • hangzhounet

contractAddress (string)(required)

Your backend contract address

beaconWalletOptions (object)(optional)

The config object passed to BeaconWallet from the @taquito/beacon-wallet package.

  • The preferredNetwork is set to the value passed for the network prop
  • For the eventHandlers, the BeaconEvent.PAIR_INIT and the BeaconEvent.PAIR_SUCCESS are being used by the library (and it will override any event handlers defined by you)

Exports

<ProvideAuth /> component

A reactjs context provider.

useAuth() hook

A reactjs hook that provides the following details:

  • Tezos => The TezosToolkit()
  • contract => The backend contract
  • publicToken => Once the wallet is paired, the public key of the user's wallet address
  • wallet => The BeaconWallet()
  • userAddress => The Wallet's address
  • userBalance => The tezos balance in the user's wallet
  • storage => The storage on the backend contract
  • onTransaction => Function to be called after each blockchain transaction, to update the contract's storage and user's balance details
  • beaconConnection => Read this value to know if the wallet is connected or not
  • connectWallet => Function to initiate connection with the user's wallet
  • disconnectWallet => Function to initiate disconnection with the user's wallet