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

@automata-network/wallet-react

v1.4.0

Published

A monorepo consists of Web3 wallet SDK and React UI component to connect dApp web app to popular web3 wallet like MetaMask and WalletConnect.

Downloads

6

Readme

Automata Network Wallet SDK

A monorepo consists of Web3 wallet SDK and React UI component to connect dApp web app to popular web3 wallet like MetaMask and WalletConnect.

Install

npm install @automata-network/wallet-react /
@solana/wallet-adapter-react /
@solana/wallet-adapter-wallets /
@polkadot/api /
@polkadot/extension-inject /
@web3-onboard/coinbase /
@web3-onboard/core /
@web3-onboard/enkrypt /
@web3-onboard/fortmatic /
@web3-onboard/gnosis /
@web3-onboard/injected-wallets /
@web3-onboard/ledger /
@web3-onboard/mew-wallet /
@web3-onboard/portis /
@web3-onboard/torus /
@web3-onboard/trezor /
@web3-onboard/walletconnect /
ethers /
react /
react-dom -S

How To

Here's the example.

import '@automata-network/wallet-react/style.css'

createRoot(document.getElementById('root') as HTMLElement).render(
  <StrictMode>
    <WalletProvider
      appName="Automata Wallet Demo"
      chains={[
        {
          type: ChainType.EVM,
          chainId: "5",
          chainName: "Ethereum Goerli",
          nativeCurrency: {
            decimals: 18,
            name: "GoerliETH",
            symbol: "GoerliETH",
          },
          rpcUrls: [
            "https://goerli.infura.io/v3/9aa3d95b3bc440fa88ea12eaa4456161",
          ],
          blockExplorerUrls: ["https://goerli.etherscan.io/"],
          iconUrl:
            "https://raw.githubusercontent.com/ethereum/ethereum-org-website/dev/src/assets/assets/eth-glyph-colored.svg",
        },
        {
          type: ChainType.EVM,
          chainId: "80001",
          chainName: "Polygon",
          nativeCurrency: {
            decimals: 18,
            name: "MATIC",
            symbol: "MATIC",
          },
          rpcUrls: ["https://rpc.ankr.com/polygon_mumbai"],
          blockExplorerUrls: ["https://mumbai.polygonscan.com/"],
          iconUrl:
            "https://raw.githubusercontent.com/maticnetwork/matic-docs/master/static/img/polygon-logo.svg",
        },
        {
          type: ChainType.Polkadot,
          chainId: "Westend",
          chainName: "Westend",
          rpcUrls: ["wss://westend-rpc.polkadot.io"],
          blockExplorerUrls: ["https://westend.subscan.io/"],
          iconUrl:
            "https://polkadot.js.org/apps/static/westend_colour.eb7969da..svg",
        },
        {
          type: ChainType.Solana,
          chainId: "Solana Testnet",
          chainName: "Solana Testnet",
          rpcUrls: ["https://api.testnet.solana.com"],
          blockExplorerUrls: ["https://explorer.solana.com/?cluster=testnet"],
          iconUrl: "https://solana.com/src/img/branding/solanaLogoMark.svg",
        },
      ]}
      providerConfigs={{
        evm: {
          fortmatic: process.env.VITE_FORTMATIC_API_KEY
            ? {
                apiKey: process.env.VITE_FORTMATIC_API_KEY,
              }
            : undefined,
          walletconnect: {},
          // coinbase: {},
          portis: process.env.VITE_PORTIS_API_KEY
            ? {
                apiKey: process.env.VITE_PORTIS_API_KEY,
              }
            : undefined,
          gnosis: {},
          torus: process.env.VITE_TORUS_API_KEY
            ? { apiKey: process.env.VITE_TORUS_API_KEY, showTorusButton: false }
            : undefined,
          trezor:
            process.env.VITE_TREZOR_EMAIL && process.env.VITE_TREZOR_APP_URL
              ? {
                  email: process.env.VITE_TREZOR_EMAIL,
                  appUrl: process.env.VITE_TREZOR_APP_URL,
                }
              : undefined,
          mew: true,
          enkrypt: true,
          subwallet: true,
          talisman: true,
          ledger: {},
        },
        polkadot: {
          enkrypt: true,
          subwallet: true,
          talisman: true,
          polkadotJsExtension: true,
        },
        solana: {
          math: {},
          solflare: {},
          phantom: {},
        },
      }}
    >
      <Navbar>
        <Wallet />
      </Navbar>
      <App />
    </WalletProvider>
  </StrictMode>
)

If you want to use the json rpc provider or get the account address, chain ID, etc.. you can use the useWallet hook.

const { account, chainId, rpcRequest } = useWallet()

Customize styles and class name prefix

If you want to customize your style you can copy the content from @automata-network/wallet-react/src/style.less and use your own variables or component style file. then compile your less to css on your build phase and import it to your website.

If our class name prefix conflict with your code, you can modify the @selector-prefix variable on the @automata-network/wallet-react/src/style.less and compile your customized css.

Then you need to set up the customized class name prefix on the wallet provider.

<WalletProvider
  prefixCls="your-class-name-prefix"
>

Integeration with ViteJS

[TBD]

Integeration with Create React App

[TBD]

Integeration with NextJS

[TBD]

Trouble shooting

Uncaught ReferenceError: process is not defined

That caused by the @walletconnect/web3-provider, it required the process object from Node.js, but there is no process on the browser.

so we need to set up an alias to point @walletconnect/web3-provider to its prebuilt bundle.

{
  alias: {
    '@walletconnect/web3-provider': '@walletconnect/web3-provider/dist/umd/index.min.js'
  }
}

Contribute on Development

Clone this repo and run the script below to install all required dependencies.

# First we install the dependencies and link
cd wallet_sdk_dir && npm install

Then build the SDK and link the dist directory so you can use the SDK in the example site.

npm run build
npm link

When you've made some changes on the SDK part, just rebuild it and the example site will be reloaded automatically.

Don't forget to unlink the SDK when you've finished with the development, using npm unlink @automata-network/wallet-sdk.