Skip to content
This repository was archived by the owner on Mar 16, 2022. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
"ethjs": "^0.3.3",
"ethjs-account": "^0.1.4",
"history": "^4.7.2",
"lessdux": "^0.7.0",
"lessdux": "^0.7.3",
"normalize.css": "^7.0.0",
"qrcode": "^1.2.0",
"react": "^16.2.0",
Expand Down
Binary file added src/assets/images/etherscan-logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 19 additions & 0 deletions src/bootstrap/dapp-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,24 @@ else if (window.web3 && window.web3.currentProvider)
eth = new Eth(window.web3.currentProvider)
else eth = new Eth(new Eth.HttpProvider(ETHEREUM_PROVIDER))

const network = eth
.net_version()
.then(networkID => {
switch (networkID) {
case '1':
return 'main'
case '3':
return 'ropsten'
case '4':
return 'rinkeby'
case '42':
return 'kovan'
default:
return null
}
})
.catch(() => null)

const IICOContractFactory = eth.contract && eth.contract(IICO.abi) // TODO: Put this on NPM or load dynamically?

const ETHAddressRegExpCaptureGroup = '(0x[a-fA-F0-9]{40})'
Expand All @@ -20,6 +38,7 @@ const strictETHAddressRegExp = /^0x[a-fA-F0-9]{40}$/

export {
eth,
network,
IICOContractFactory,
ETHAddressRegExpCaptureGroup,
ETHAddressRegExp,
Expand Down
1 change: 1 addition & 0 deletions src/bootstrap/global-components.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export default () => (
<div id="global-components">
<ReduxToastr
timeOut={0}
preventDuplicates
position="top-center"
transitionIn="bounceInDown"
transitionOut="bounceOutUp"
Expand Down
14 changes: 5 additions & 9 deletions src/bootstrap/initializer.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,7 @@ class Initializer extends PureComponent {
]).isRequired
}

state = {
isWeb3Loaded: eth.accounts !== undefined,
pathAddress: undefined
}
state = { pathAddress: undefined }

componentDidMount() {
const { fetchAccounts } = this.props
Expand Down Expand Up @@ -87,8 +84,8 @@ class Initializer extends PureComponent {
}

render() {
const { isWeb3Loaded, pathAddress } = this.state
const { accounts, children } = this.props
const { pathAddress } = this.state

const loading = (
<div id="initializer-loader">
Expand All @@ -97,20 +94,19 @@ class Initializer extends PureComponent {
)

if (pathAddress === undefined) return loading

return (
<RenderIf
resource={accounts}
loading={loading}
done={children}
failedLoading={
<div>
<RequiresMetaMask needsUnlock={isWeb3Loaded} />
<RequiresMetaMask needsUnlock={Boolean(window.web3)} />
<SimpleBid match={{ params: { address: pathAddress } }} noWeb3 />
</div>
}
extraValues={[accounts.data && accounts.data[0]]}
extraFailedValues={[!isWeb3Loaded]}
extraValues={[(accounts.data && accounts.data[0]) || null]}
extraFailedValues={[!window.web3]}
/>
)
}
Expand Down
19 changes: 13 additions & 6 deletions src/components/__snapshots__/storyshots.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -1003,14 +1003,21 @@ exports[`Storyshots Chain Hash default 1`] = `
}
>
<span
className="ChainHash"
data-tip="0x5b5d09477f730baafb1e2e0fb78f5d95fd94a6f4"
>
0x5b5d...a6f4
<a
href="https://etherscan.io/address/0x5b5d09477f730baafb1e2e0fb78f5d95fd94a6f4"
className="ChainHash-link"
href="https://undefined.etherscan.io/address/0x5b5d09477f730baafb1e2e0fb78f5d95fd94a6f4"
rel="noopener noreferrer"
target="_blank"
>
0x5b5d...a6f4
<img
alt="Etherscan Logo"
className="ChainHash-link-image"
src="etherscan-logo.png"
/>
</a>
</span>
<div
Expand Down Expand Up @@ -6582,7 +6589,7 @@ exports[`Storyshots Text Input default 1`] = `
>
<input
className="TextInput-input"
onBlur={undefined}
onBlur={null}
onChange={[Function]}
step={undefined}
type="text"
Expand Down Expand Up @@ -6895,7 +6902,7 @@ exports[`Storyshots Text Input error 1`] = `
>
<input
className="TextInput-input"
onBlur={undefined}
onBlur={null}
onChange={[Function]}
step={undefined}
type="text"
Expand Down Expand Up @@ -7208,7 +7215,7 @@ exports[`Storyshots Text Input touched 1`] = `
>
<input
className="TextInput-input"
onBlur={undefined}
onBlur={null}
onChange={[Function]}
step={undefined}
type="text"
Expand Down Expand Up @@ -7521,7 +7528,7 @@ exports[`Storyshots Text Input valid 1`] = `
>
<input
className="TextInput-input"
onBlur={undefined}
onBlur={null}
onChange={[Function]}
step={undefined}
type="text"
Expand Down
14 changes: 14 additions & 0 deletions src/components/chain-hash/chain-hash.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/* @define ChainHash */
.ChainHash {
overflow-wrap: break-word;

&-link {
margin-left: 4px;
position: relative;

&-image {
height: 100%;
position: absolute;
}
}
}
69 changes: 51 additions & 18 deletions src/components/chain-hash/index.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,54 @@
import React from 'react'
import React, { PureComponent } from 'react'
import PropTypes from 'prop-types'

const ChainHash = ({ children }) => (
<span data-tip={children}>
<a
href={`https://etherscan.io/address/${children}`}
target="_blank"
rel="noopener noreferrer"
>
{children.slice(0, 6) + '...' + children.slice(children.length - 4)}
</a>
</span>
)

ChainHash.propTypes = {
// State
children: PropTypes.string.isRequired
}
import { network } from '../../bootstrap/dapp-api'
import etherscanLogo from '../../assets/images/etherscan-logo.png'

import './chain-hash.css'

export default class ChainHash extends PureComponent {
static propTypes = {
// State
children: PropTypes.string.isRequired,

// Modifiers
full: PropTypes.bool
}

export default ChainHash
static defaultProps = {
// Modifiers
full: false
}

state = { network: undefined }

async componentDidMount() {
this.setState({ network: await network })
}

render() {
const { children, full } = this.props
const { network } = this.state
return (
<span data-tip={children} className="ChainHash">
{full
? children
: children.slice(0, 6) + '...' + children.slice(children.length - 4)}
<a
href={`https://${
network !== 'main' ? `${network}.` : ''
}etherscan.io/address/${children}`}
target="_blank"
rel="noopener noreferrer"
className="ChainHash-link"
>
<img
src={etherscanLogo}
alt="Etherscan Logo"
className="ChainHash-link-image"
/>
</a>
</span>
)
}
}
3 changes: 1 addition & 2 deletions src/components/slider/slider.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ it('Renders and handles mouse events.', () => {
{
label: 'label 2',
percent: 0.6,
color: 'color',
point: false
color: 'color'
}
]}
calcValue={calcValue}
Expand Down
2 changes: 0 additions & 2 deletions src/constants/error.js

This file was deleted.

21 changes: 13 additions & 8 deletions src/containers/simple-bid/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { RenderIf } from 'lessdux'

import * as IICOSelectors from '../../reducers/iico'
import * as IICOActions from '../../actions/iico'
import ChainHash from '../../components/chain-hash'
import Identicon from '../../components/identicon'
import ETHQR from '../../components/eth-qr'

Expand Down Expand Up @@ -70,13 +71,17 @@ class SimpleBid extends PureComponent {
</p>
<p>
The address you send from has to be whitelisted in the{' '}
<a
href={`https://kleros.io/kyc`}
target="_blank"
rel="noopener noreferrer"
>
KYC
</a>{' '}
{process.env.REACT_APP_BRANCH === 'master' ? (
<a
href={`https://kleros.io/kyc`}
target="_blank"
rel="noopener noreferrer"
>
KYC
</a>
) : (
'KYC'
)}{' '}
and you need to <b>send at least 300,000 gas with the transaction.</b>
<RenderIf
resource={IICOData}
Expand Down Expand Up @@ -107,7 +112,7 @@ class SimpleBid extends PureComponent {
</p>
{address && (
<div className="SimpleBid-addressInfo">
<b>Contract Address:</b> {address}
<b>Contract Address:</b> <ChainHash full>{address}</ChainHash>
<div className="SimpleBid-addressInfo-blocks">
<div>
<b>Identicon:</b>
Expand Down
1 change: 0 additions & 1 deletion src/containers/simple-bid/simple-bid.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
text-align: justify;

&-addressInfo {
overflow-wrap: break-word;
text-align: left;

&-blocks {
Expand Down
2 changes: 1 addition & 1 deletion src/reducers/iico.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export const _IICODataShape = PropTypes.shape({
address: PropTypes.string.isRequired,

// Centralized
ethPrice: PropTypes.number.isRequired,
ethPrice: PropTypes.number,

// Token
tokenContractAddress: PropTypes.string.isRequired,
Expand Down
5 changes: 4 additions & 1 deletion src/sagas/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ export function makeRestartable(saga) {
err
)

err.message && toastr.error('', err.message.slice(0, 100))
err.message &&
toastr.info(
'Your connection is unstable, please check your network and refresh the page.'
)
yield call(delay, 3000)
}
}
Expand Down
6 changes: 1 addition & 5 deletions src/sagas/wallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,13 @@ import * as walletSelectors from '../reducers/wallet'
import * as walletActions from '../actions/wallet'
import { eth } from '../bootstrap/dapp-api'
import { lessduxSaga } from '../utils/saga'
import * as errorConstants from '../constants/error'

/**
* Fetches the current wallet's accounts.
* @returns {object[]} - The accounts.
*/
export function* fetchAccounts() {
const accounts = yield call(eth.accounts)
if (!accounts[0]) throw new Error(errorConstants.ETH_NO_ACCOUNTS)

return accounts
return yield call(eth.accounts)
}

/**
Expand Down
7 changes: 4 additions & 3 deletions src/setupTests.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@ import 'jest-enzyme'
// Configure
configure({ adapter: new Adapter() })

// Mock globals
window.fetch = jest.fn(() => new Promise(resolve => resolve(undefined)))
window.web3 = {}

// Mock modules
jest.mock('./components/identicon', () => () => <div>[Identicon]</div>)

// Mock fetch
window.fetch = jest.fn(() => new Promise(resolve => resolve(undefined)))

// Mock time
timezoneMock.register('UTC')
Date.now = jest.fn(() => 1516916214006)
5 changes: 4 additions & 1 deletion src/utils/saga.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,10 @@ export function* lessduxSaga(flow, resourceActions, saga, action) {
})
)
} catch (err) {
err.message && toastr.error('', err.message.slice(0, 100))
err.message &&
toastr.info(
'Your connection is unstable, please check your network and refresh the page.'
)
yield put(errorAction(resourceActions['FAIL' + failWord], err))
}
}
Expand Down
7 changes: 6 additions & 1 deletion stories/slider.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,10 @@ import Slider from '../src/components/slider'
const calcValue = percent => `${(percent * 100).toFixed(0)}%`

storiesOf('Slider', module).add('default', () => (
<Slider startLabel="Jan 1st, 2018" endLabel="Today" calcValue={calcValue} />
<Slider
startLabel="Jan 1st, 2018"
endLabel="Today"
initialPercent={0.5}
calcValue={calcValue}
/>
))
Loading