Skip to content

Commit b8a4306

Browse files
authored
Merge pull request #141 from poanetwork/support-rsk
Added support of work through public RPC nodes that do not support `eth_getLogs` call: e.g. Rootstock public RPC.
2 parents b82c2a8 + 671f054 commit b8a4306

File tree

18 files changed

+223
-68
lines changed

18 files changed

+223
-68
lines changed

.env.example

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ REACT_APP_HOME_NATIVE_NAME=POA
77
REACT_APP_HOME_NETWORK_NAME="POA Sokol"
88
REACT_APP_FOREIGN_NETWORK_NAME=Kovan
99

10+
# Set to true if network doesn't support events
11+
REACT_APP_HOME_WITHOUT_EVENTS=false
12+
REACT_APP_FOREIGN_WITHOUT_EVENTS=false
13+
1014
REACT_APP_HOME_EXPLORER_TX_TEMPLATE=https://blockscout.com/poa/sokol/tx/%s
1115
REACT_APP_FOREIGN_EXPLORER_TX_TEMPLATE=https://blockscout.com/eth/kovan/tx/%s
1216
REACT_APP_HOME_EXPLORER_ADDRESS_TEMPLATE=https://blockscout.com/poa/sokol/address/%s
@@ -21,3 +25,9 @@ REACT_APP_FOREIGN_GAS_PRICE_ORACLE_URL=https://gasprice.poa.network/
2125
REACT_APP_FOREIGN_GAS_PRICE_SPEED_TYPE=standard
2226
REACT_APP_FOREIGN_GAS_PRICE_FALLBACK=5000000000
2327
REACT_APP_FOREIGN_GAS_PRICE_UPDATE_INTERVAL=15000
28+
29+
# Default
30+
REACT_APP_DESCRIPTION="The POA cross-chain bridge serves as a method of transferring POA native tokens from the POA Network to the Ethereum network in a quick and cost-efficient manner."
31+
32+
# RSK
33+
#REACT_APP_DESCRIPTION="The TokenBridge serves as a method of transferring Bancor Network tokens between the Ethereum network to Rootstock network in a quick and cost-efficient manner."

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# POA Bridge - User Interface (UI) Application
22

3-
[![Build Status](https://travis-ci.org/patitonar/bridge-ui.svg?branch=master)](https://travis-ci.org/patitonar/bridge-ui)
3+
[![Build Status](https://travis-ci.org/poanetwork/bridge-ui.svg?branch=master)](https://travis-ci.org/poanetwork/bridge-ui)
44
[![Gitter](https://badges.gitter.im/poanetwork/poa-bridge.svg)](https://gitter.im/poanetwork/poa-bridge?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
5-
[![Coverage Status](https://coveralls.io/repos/github/patitonar/bridge-ui/badge.svg?branch=master)](https://coveralls.io/github/patitonar/bridge-ui?branch=master)
5+
[![Coverage Status](https://coveralls.io/repos/github/poanetwork/bridge-ui/badge.svg?branch=master)](https://coveralls.io/github/poanetwork/bridge-ui?branch=master)
66
[![dependencies Status](https://david-dm.org/poanetwork/bridge-ui/status.svg)](https://david-dm.org/poanetwork/bridge-ui)
77

88
Welcome to the POA Bridge! Following is an overview of the POA Bridge and Bridge UI Application, as well as [basic instructions for getting started](#getting-started).
@@ -165,6 +165,8 @@ REACT_APP_HOME_HTTP_PARITY_URL | http public rpc node for Foreign Network
165165
REACT_APP_HOME_NATIVE_NAME | name of the home native coin
166166
REACT_APP_HOME_NETWORK_NAME | name to be displayed for home network
167167
REACT_APP_FOREIGN_NETWORK_NAME | name to be displayed for foreign network
168+
REACT_APP_HOME_WITHOUT_EVENTS | `true` if home network doesn't support events
169+
REACT_APP_FOREIGN_WITHOUT_EVENTS | `true` if foreign network doesn't support events
168170
REACT_APP_HOME_EXPLORER_TX_TEMPLATE | template link to transaction on home explorer. `%s` will be replaced by transaction hash
169171
REACT_APP_FOREIGN_EXPLORER_TX_TEMPLATE | template link to transaction on foreign explorer. `%s` will be replaced by transaction hash
170172
REACT_APP_HOME_EXPLORER_ADDRESS_TEMPLATE | template link to address on home explorer. `%s` will be replaced by address
@@ -177,6 +179,7 @@ REACT_APP_FOREIGN_GAS_PRICE_ORACLE_URL | The URL used to get a JSON response fro
177179
REACT_APP_FOREIGN_GAS_PRICE_SPEED_TYPE | Gas Price speed (slow, standard, fast, instant)
178180
REACT_APP_FOREIGN_GAS_PRICE_FALLBACK | The gas price (in Wei) that is used if both the oracle and the fall back gas price specified in the Foreign Bridge contract are not available.
179181
REACT_APP_FOREIGN_GAS_PRICE_UPDATE_INTERVAL | An interval in milliseconds used to get the updated gas price value either from the oracle or from the Foreign Bridge contract.
182+
REACT_APP_DESCRIPTION | The meta description for the deployed bridge page
180183

181184
* Run `npm run start`
182185
* Make sure your web3 wallet (Nifty Wallet or MetaMask) is funded and connected to the POA Sokol Network (see step 2)

package-lock.json

Lines changed: 24 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"react-app-rewired": "^1.5.0",
2222
"react-copy-to-clipboard": "^5.0.1",
2323
"react-dom": "^16.2.0",
24+
"react-router": "^4.3.1",
2425
"react-router-dom": "^4.2.2",
2526
"react-scripts": "1.1.1",
2627
"react-transition-group": "^2.2.1",

public/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
77
<meta name="theme-color" content="#000000">
88
<meta property="og:title" content="POA Bridge UI" />
9-
<meta property="og:description" content="The POA cross-chain bridge serves as a method of transferring POA native tokens from the POA Network to the Ethereum network in a quick and cost-efficient manner. " />
9+
<meta property="og:description" content="%REACT_APP_DESCRIPTION%" />
1010
<meta property="og:url" content="https://poanetwork.github.io/bridge-ui" />
1111
<meta property="og:type" content="website" />
1212
<meta property="og:image" content="/images/bridgeogimage.jpg">

src/assets/stylesheets/application.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/assets/stylesheets/application/header.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
display: flex;
3333
justify-content: space-between;
3434
align-items: center;
35-
width: 600px;
35+
max-width: 700px;
3636

3737
@media screen and (max-width: $mobile-width) {
3838
display: none;
@@ -57,7 +57,7 @@
5757
}
5858

5959
.link {
60-
margin-left: 30px;
60+
margin: 0 15px;
6161
line-height: 16px;
6262
text-decoration: none;
6363
font-weight: bold;

src/components/Bridge.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,13 @@ export class Bridge extends React.Component {
9494
tokenAddress: homeStore.tokenAddress
9595
})
9696
} else {
97+
const value = Web3Utils.toHex(Web3Utils.toWei(amount))
9798
return txStore.doSend({
9899
to: homeStore.HOME_BRIDGE_ADDRESS,
99100
from: web3Store.defaultAccount.address,
100-
value: Web3Utils.toHex(Web3Utils.toWei(amount)),
101-
data: '0x'
101+
value,
102+
data: '0x',
103+
sentValue: value
102104
})
103105
}
104106
} catch (e) {

src/components/Header.js

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,42 +6,53 @@ import menuOpenIcon from '../assets/images/icons/icon-close.svg'
66
import { Wallet } from './Wallet'
77
import { DailyQuotaModal } from './DailyQuotaModal'
88
import { inject, observer } from 'mobx-react/index'
9+
import yn from './utils/yn'
910

10-
const getMobileMenuLinks = (onMenuToggle) =>
11+
const getMobileMenuLinks = (onMenuToggle, withoutEvents) =>
1112
(<div className="links_container_mobile">
12-
<Link to='/events' className="link" onClick={onMenuToggle}>
13-
<i className="icon_events" /><span className='link_text'>Events</span>
14-
</Link>
13+
{withoutEvents ? null :
14+
<Link to='/events' className="link" onClick={onMenuToggle}>
15+
<i className="icon_events" /><span className='link_text'>Events</span>
16+
</Link>
17+
}
1518
<Link to='/status' className="link" onClick={onMenuToggle}>
1619
<i className="icon_status" /><span className='link_text'>Status</span>
1720
</Link>
18-
<Link to='/statistics' className="link" onClick={onMenuToggle}>
19-
<i className="icon_statistics" /><span className='link_text'>Statistics</span>
20-
</Link>
21+
{withoutEvents ? null :
22+
<Link to='/statistics' className="link" onClick={onMenuToggle}>
23+
<i className="icon_statistics" /><span className='link_text'>Statistics</span>
24+
</Link>
25+
}
2126
</div>)
2227

2328

2429
@inject("RootStore")
2530
@observer
2631
export class Header extends React.Component {
2732
render () {
28-
const {showMobileMenu, onMenuToggle, RootStore: {alertStore}} = this.props
33+
const { showMobileMenu, onMenuToggle, RootStore: { alertStore, web3Store } } = this.props
34+
const { REACT_APP_HOME_WITHOUT_EVENTS: HOME, REACT_APP_FOREIGN_WITHOUT_EVENTS: FOREIGN } = process.env
35+
const withoutEvents = web3Store.metamaskNet.id === web3Store.homeNet.id.toString() ? yn(HOME) : yn(FOREIGN)
2936
return (
3037
<header className="header">
31-
{showMobileMenu && (<div className="header-mobile-menu-container">{getMobileMenuLinks(onMenuToggle)}</div>)}
38+
{showMobileMenu && (<div className="header-mobile-menu-container">{getMobileMenuLinks(onMenuToggle, withoutEvents)}</div>)}
3239
<div className="container">
3340
<Link to="/" onClick={showMobileMenu ? onMenuToggle : null}><img className="header-logo" src={logo}
3441
alt=""/></Link>
3542
<div className="links_container">
36-
<Link to='/events' className="link">
37-
<i className="icon_events"/><span className='link_text'>Events</span>
38-
</Link>
43+
{withoutEvents ? null :
44+
<Link to='/events' className="link">
45+
<i className="icon_events"/><span className='link_text'>Events</span>
46+
</Link>
47+
}
3948
<Link to='/status' className="link">
4049
<i className="icon_status"/><span className='link_text'>Status</span>
4150
</Link>
42-
<Link to='/statistics' className="link">
43-
<i className="icon_statistics"/><span className='link_text'>Statistics</span>
44-
</Link>
51+
{withoutEvents ? null :
52+
<Link to='/statistics' className="link">
53+
<i className="icon_statistics"/><span className='link_text'>Statistics</span>
54+
</Link>
55+
}
4556
<Wallet/>
4657
</div>
4758
<div className="mobile-menu">

src/components/RelayEvents.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import React from 'react';
22
import { inject, observer } from "mobx-react";
33
import { EventsListHeader } from './index'
44
import { Event } from './index'
5+
import yn from './utils/yn'
6+
import { Redirect } from 'react-router'
57

68

79
const WAIT_INTERVAL = 700;
@@ -132,12 +134,14 @@ export class RelayEvents extends React.Component {
132134
}
133135

134136
render(){
135-
const { homeStore, foreignStore } = this.props.RootStore
137+
const { homeStore, foreignStore, web3Store } = this.props.RootStore
136138
const { selectedList } = this.state
137139
const home = this.getHomeEvents(homeStore, foreignStore)
138140
const foreign = this.getForeignEvents(foreignStore, homeStore)
141+
const { REACT_APP_HOME_WITHOUT_EVENTS: HOME, REACT_APP_FOREIGN_WITHOUT_EVENTS: FOREIGN } = process.env
142+
const withoutEvents = web3Store.metamaskNet.id === web3Store.homeNet.id.toString() ? yn(HOME) : yn(FOREIGN)
139143

140-
return(
144+
return withoutEvents ? (<Redirect to="/" />) : (
141145
<div className="events-page">
142146
<div className="events-container">
143147
<EventsListHeader

0 commit comments

Comments
 (0)