# bridge-ui-sdk

> Horizon Bridge UI SDK

Latest version **1.0.13** (published 2020-11-16) · MIT license · 0 weekly downloads

## Install

```sh
npm install bridge-ui-sdk
pnpm add bridge-ui-sdk
yarn add bridge-ui-sdk
bun add bridge-ui-sdk
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.13 |
| Published | 2020-11-16 |
| First published | 2020-11-11 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Node | >=10 |
| Dependencies | 13 |
| Unpacked size | 1.9 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | harmony |
| Maintainers | potvik |

## Links

- npm: https://www.npmjs.com/package/bridge-ui-sdk
- Repository: https://github.com/harmony-one/ethhmy-bridge.ui-sdk
- Homepage: https://github.com/harmony-one/ethhmy-bridge.ui-sdk#readme
- Issues: https://github.com/harmony-one/ethhmy-bridge.ui-sdk/issues
- npm.io page: https://npm.io/package/bridge-ui-sdk

## Dependencies (13)

- [mobx](https://npm.io/package/mobx.md) 5.15.0
- [bn.js](https://npm.io/package/bn.js.md) ^5.1.3
- [lodash](https://npm.io/package/lodash.md) ^4.17.20
- [grommet](https://npm.io/package/grommet.md) ^2.15.2
- [bridge-sdk](https://npm.io/package/bridge-sdk.md) ^1.0.17
- [classnames](https://npm.io/package/classnames.md) ^2.2.6
- [mobx-react](https://npm.io/package/mobx-react.md) 6.1.4
- [superagent](https://npm.io/package/superagent.md) ^6.0.0
- [bignumber.js](https://npm.io/package/bignumber.js.md) ^9.0.1
- [react-select](https://npm.io/package/react-select.md) ^3.1.0
- [async-validator](https://npm.io/package/async-validator.md) ^3.4.0
- [core-decorators](https://npm.io/package/core-decorators.md) ^0.20.0
- [@metamask/detect-provider](https://npm.io/package/@metamask/detect-provider.md) ^1.2.0

## Recent versions

- 1.0.13 (latest) — 2020-11-16
- 1.0.12 — 2020-11-12
- 1.0.11 — 2020-11-12
- 1.0.10 — 2020-11-11
- 1.0.10-s — 2020-11-11
- 1.0.9 — 2020-11-11
- 1.0.8 — 2020-11-11
- 1.0.7 — 2020-11-11
- 1.0.6 — 2020-11-11
- 1.0.5 — 2020-11-11
- 1.0.4 — 2020-11-11
- 1.0.3 — 2020-11-11
- 1.0.2 — 2020-11-11
- 1.0.1 — 2020-11-11
- 1.0.0 — 2020-11-11

## README

# bridge-ui-sdk

> Horizon Bridge UI SDK

[![NPM](https://img.shields.io/npm/v/bridge-ui-sdk.svg)](https://www.npmjs.com/package/bridge-ui-sdk) [![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)

<img height="460" src="https://github.com/harmony-one/ethhmy-bridge.ui-sdk/blob/main/bridge_widget.jpeg?raw=true">

## Install
For npm users:

```shell
  $ npm install bridge-ui-sdk styled-components --save
```

For Yarn users:

```shell
  $ yarn add bridge-ui-sdk styled-components
```

## Usage
```tsx
import React from 'react'
import { ExchangeBlock } from 'bridge-ui-sdk'
import 'bridge-ui-sdk/dist/index.css'

({ addressMetamask, addressOneWallet }) => <ExchangeBlock network='testnet' addressMetamask={addressMetamask} addressOneWallet={addressOneWallet} />
```

#### You need to do sign nn with your wallets in other blocks. ExchangeBlock will use your wallets through window object.
#### After wallet sign in (Metamask or OneWallet), your need to set next props to ExchangeBlock

### Params
| Name | Type | Default | Description |
| --- | --- | --- | --- |
| network | `'mainnet'` or `'testnet'` | `'testnet'` | Network type - instead of this type Exchange block will use different configs (smart contract address, validator address etc)
| addressMetamask | String |  | Your Ethereum address with wich you signed in
| addressOneWallet | String |  | Your Harmony address with wich you signed in

## Full Example (with wallets sign in)

https://github.com/harmony-one/ethhmy-bridge.ui-sdk/blob/main/example/src/App.tsx

```tsx
import React, { useEffect, useState } from 'react'
import detectEthereumProvider from '@metamask/detect-provider'

import { ExchangeBlock } from 'bridge-ui-sdk'
import 'bridge-ui-sdk/dist/index.css'

const App = () => {
  const [metamask, setMetamask] = useState<string>()
  const [oneWallet, setOneWallet] = useState<string>()

  useEffect(() => {
    detectEthereumProvider().then((provider: any) => {
      try {
        // @ts-ignore
        if (provider !== window.ethereum) {
          console.error('Do you have multiple wallets installed?')
        }

        if (!provider) {
          alert('Metamask not found')
        }

        provider.on('accountsChanged', (accounts: string[]) =>
          setMetamask(accounts[0])
        )

        provider.on('disconnect', () => {
          setMetamask('')
        })

        provider
          .request({ method: 'eth_requestAccounts' })
          .then(async (accounts: string[]) => {
            setMetamask(accounts[0])
          })
      } catch (e) {
        console.error(e)
      }
    })
  }, [])

  useEffect(() => {
    try {
      // @ts-ignore
      setTimeout(() => {
        // @ts-ignore
        window.onewallet
          .getAccount()
          .then(({ address }: any) => setOneWallet(address))
      }, 3000)
    } catch (e) {
      console.error(e)
    }
  }, [])

  return (
    <ExchangeBlock
      network='testnet'
      addressMetamask={metamask}
      addressOneWallet={oneWallet}
    />
  )
}

export default App
```

## License

MIT © [harmony](https://github.com/harmony)

---
_Source: https://npm.io/package/bridge-ui-sdk · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
