Skip to content

grhbit/solana-wallet-adapter-browser-test

Repository files navigation

BrowserTest Wallet (solana-wallet-adapter-browser-test)

A solana wallet adapter for testing on browser.

Demo

Install

$ npm install solana-wallet-adapter-browser-test
# or yarn
$ yarn add solana-wallet-adapter-browser-test
# or pnpm
$ pnpm add solana-wallet-adapter-browser-test

Usage

import { useMemo } from "react";
import { WalletProvider } from "@solana/wallet-adapter-react";
import { Keypair } from "@solana/web3.js";
import {
  BrowserTestWalletAdapter,
  StaticBrowserTestWallet,
} from "solana-wallet-adapter-browser-test";

const App = (props) => {
  const { children } = props;
  const wallets = useMemo(
    () => [
      // Do not use this wallet adapter on production.
      ...(process.env.NODE_ENV === "production"
        ? []
        : [
            new BrowserTestWalletAdapter({
              keypair: Keypair.generate(),
            }),
            new BrowserTestWalletAdapter({
              name: "Another BrowserTest Wallet",
              wallet: new StaticBrowserTestWallet(Keypair.genrate()),
            }),
          ]),
    ],
    []
  );
  return <WalletProvider wallets={wallets}>{children}</WalletProvider>;
};

License

MIT © Gwon Seonggwang