Giter Site home page Giter Site logo

opendata-bondintelligence / uniswap-widgets-demo Goto Github PK

View Code? Open in Web Editor NEW

This project forked from chloewu21/uniswap-widgets-demo

0.0 0.0 0.0 7.63 MB

License: GNU General Public License v3.0

JavaScript 75.06% TypeScript 15.38% CSS 6.69% HTML 2.43% Dockerfile 0.44%

uniswap-widgets-demo's Introduction

This is a Create React App project bootstrapped with create-react-app to showcase how to integrate the @uniswap/widgets package in your own projects. It uses [email protected].

widgets-cra5

Uniswap Widgets


To start the demo:

yarn          # install dependencies
yarn start    # run the development server
# or
npm           # install dependencies
npm run start # run the development server

Navigate to http://localhost:3000 to see the widget.


The SwapWidget component is passed everything it needs to render:

In addition, it is passed these optional props to flesh out the demo:

  • locale: the locale in which to render, in this case "en-US"
  • onConnectWallet: a callback to invoke when a user clicks "Connect your wallet"
  • defaultInputTokenAddress: the default input token address, or "NATIVE" for Ether
  • defaultInputAmount: the default input token amount
  • defaultOutputTokenAddress: the default output token amount, in this case the address of the Uniswap (UNI) token

For all available props (including theming), refer to the documentation at https://docs.uniswap.org/sdk/widgets/swap-widget.

Passing a provider

This project uses @web3-react to connect to an Ethereum Provider. The demo uses both MetaMask and WalletConnect. See src/components/Web3Connectors.tsx.

The SwapWidget component will accept any EIP1193 Provider or @ethersproject JsonRpcProvider, so you are not limited to using @web3-react. If you do use a JsonRpcProvider, you can pass it in the same way, to the widget's provider prop.

Localization

The SwapWidget component will render in whichever supported locale is passed to the locale prop. The demo uses en-US, but includes a selector to demonstrate additional locales.

Known issues with Create React App

  • Many dependencies have not updated to support sourcemaps for CRA. To get around this, you can disable sourcemaps by setting GENERATE_SOURCEMAP=false, either when you run the script or in your .env file.

  • CRAv4 must use different import path for fonts. To import the widget using CRAv4:

    import { SwapWidget } from '@uniswap/widgets/index.js'
    import '@uniswap/widgets/dist/fonts.css'
    

Additional documentation

uniswap-widgets-demo's People

Contributors

zzmp avatar chloewu21 avatar eesha-jain avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.