0.1.4 • Published 4 years ago

@nevenhsu/uni-wallet-connect v0.1.4

Weekly downloads
-
License
GPL-3.0-or-later
Repository
github
Last release
4 years ago

Uni-wallet-connect

A library extracted from the Uniswap v3 codebase and rewritten for reusability. It uses @web-react and ethers.js. NextJS is supported by default.

Demo

How to use

See next example for complete details.

npm install uni-wallet-connect
# or
yarn add uni-wallet-connect

pages/_app.tsx

import '@reach/dialog/styles.css'
import 'inter-ui/inter.css'
import '../styles/globals.css'
import type { AppProps } from 'next/app'
import dynamic from 'next/dynamic'
import React, { StrictMode } from 'react'

const Wrapper = dynamic(() => import('../components/Wrapper'), {
  ssr: false,
})

function MyApp({ Component, pageProps }: AppProps) {
  return (
    <StrictMode>
      <Wrapper>
        <Component {...pageProps} />
      </Wrapper>
    </StrictMode>
  )
}

export default MyApp

components/Wrapper.tsx

import React from 'react'
import { BrowserRouter } from 'react-router-dom'
import { Provider } from 'react-redux'
import Uniswap, { ThemeProvider, makeStore } from '@nevenhsu/uni-wallet-connect'

const store = makeStore()

export default function Wrapper({ children }: React.PropsWithChildren<{}>) {
  return (
    <Provider store={store}>
      <ThemeProvider>
        <BrowserRouter>
          <Uniswap>{children}</Uniswap>
        </BrowserRouter>
      </ThemeProvider>
    </Provider>
  )
}

.env

NEXT_PUBLIC_INFURA_KEY=xxxxxyyyyyzzzzz
NEXT_PUBLIC_APP_NAME=uni-wallet
NEXT_PUBLIC_LOGO_URL=http://localhost:3000/icon.png