Skip to content
This repository has been archived by the owner on Mar 28, 2023. It is now read-only.

Commit

Permalink
Merge branch 'master' into heath-ledger
Browse files Browse the repository at this point in the history
  • Loading branch information
ironng committed Jul 24, 2020
2 parents 4cc34fb + d9b8aee commit 00042dd
Show file tree
Hide file tree
Showing 27 changed files with 429 additions and 342 deletions.
219 changes: 152 additions & 67 deletions package-lock.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions package.json
Expand Up @@ -11,6 +11,7 @@
"@web3-react/injected-connector": "^6.0.7",
"bignumber.js": "^9.0.0",
"classnames": "^2.2.6",
"console.history": "^1.5.1",
"ethereumjs-common": "^1.5.0",
"ethereumjs-tx": "^2.1.2",
"history": "^4.9.0",
Expand Down
Binary file removed src/.DS_Store
Binary file not shown.
8 changes: 3 additions & 5 deletions src/components/deposit/Confirming.js
@@ -1,6 +1,7 @@
import React from 'react'
import { connect } from 'react-redux'

import Description from "../lib/Description"
import StatusIndicator from '../svgs/StatusIndicator'
import { formatSatsToBtc } from '../../utils'

Expand All @@ -18,7 +19,7 @@ const Confirming = ({ signerFee, error }) => {
{ error ? 'Error confirming transaction' : 'Confirming...' }
</div>
<hr />
<div className="description">
<Description error={error}>
<div>
Waiting for transaction confirmations. We’ll send you a browser
notification when your TBTC is ready to be minted.
Expand All @@ -28,10 +29,7 @@ const Confirming = ({ signerFee, error }) => {
<span className="signer-fee-label">Signer Fee: </span>
{signerFee} BTC*
</div>
</div>
<div className="error">
{ error }
</div>
</Description>
</div>
</div>
)
Expand Down
12 changes: 5 additions & 7 deletions src/components/deposit/GetAddress.js
@@ -1,9 +1,10 @@
import React, { useState, useEffect } from 'react'
import { connect } from 'react-redux'

import Description from "../lib/Description"
import StatusIndicator from '../svgs/StatusIndicator'

const GetAddress = ({ status, btcAddressError }) => {
const GetAddress = ({ status, error }) => {
const [statusText, setStatusText] = useState('Generating BTC address...')
useEffect(() => {
if (status === 3) {
Expand All @@ -24,12 +25,9 @@ const GetAddress = ({ status, btcAddressError }) => {
Initiating deposit
</div>
<hr />
<div className="description">
<Description error={error}>
{statusText}
</div>
<div className="error">
{ btcAddressError }
</div>
</Description>
</div>
</div >
)
Expand All @@ -38,7 +36,7 @@ const GetAddress = ({ status, btcAddressError }) => {
const mapStateToProps = (state, ownProps) => {
return {
status: state.deposit.invoiceStatus,
btcAddressError: state.deposit.btcAddressError,
error: state.deposit.btcAddressError,
}
}

Expand Down
8 changes: 3 additions & 5 deletions src/components/deposit/Invoice.js
Expand Up @@ -3,6 +3,7 @@ import { bindActionCreators } from 'redux'
import { connect } from 'react-redux'

import { requestADeposit } from '../../actions'
import Description from "../lib/Description"
import StatusIndicator from '../svgs/StatusIndicator'

const Invoice = ({ requestADeposit, error }) => {
Expand All @@ -23,12 +24,9 @@ const Invoice = ({ requestADeposit, error }) => {
{ error ? 'Error initiating deposit' : 'Initiating deposit' }
</div>
<hr />
<div className="description">
<Description error={error}>
Initiating...
</div>
<div className="error">
{ error }
</div>
</Description>
</div>
</div >
)
Expand Down
2 changes: 1 addition & 1 deletion src/components/deposit/LotSizeSelector.js
Expand Up @@ -10,7 +10,7 @@ const LotSizeOption = ({ lotSize, onClick, selected }) => {
onClick={handleClick}>
<input type="radio" id={lotSize} name="lot-size" value={lotSize}
checked={selected} readOnly />
<label className="lot-size-option-label">
<label className="lot-size-option-label" htmlFor={lotSize}>
{lotSize}&nbsp;&nbsp;฿
</label>
</li>
Expand Down
10 changes: 4 additions & 6 deletions src/components/deposit/Pay.js
Expand Up @@ -5,6 +5,7 @@ import { useParams } from "react-router-dom"

import StatusIndicator from '../svgs/StatusIndicator'
import CopyAddressField from '../lib/CopyAddressField'
import Description from "../lib/Description"

import { formatSatsToBtc } from '../../utils'

Expand All @@ -30,19 +31,16 @@ const PayComponent = ({ btcAddress, btcAmount, signerFee, error }) => {
Pay: {btcAmount} BTC
</div>
<hr />
<div className="description">
<Description error={error}>
<div>
Scan the QR code or click to copy the address below into your wallet.
</div>
<div className="signer-fee">
<span className="signer-fee-label">Signer Fee: </span>
{signerFee} BTC*
</div>
</div>
<CopyAddressField address={btcAddress} qrCodeUrl={btcURL} />
<div className="error">
{ error }
</div>
<CopyAddressField address={btcAddress} qrCodeUrl={btcURL} />
</Description>
</div>
</div>
)
Expand Down
14 changes: 6 additions & 8 deletions src/components/deposit/Prove.js
Expand Up @@ -2,6 +2,7 @@ import React, { Component } from 'react'
import { connect } from 'react-redux'
import { useParams, withRouter } from 'react-router-dom'

import Description from "../lib/Description"
import StatusIndicator from '../svgs/StatusIndicator'

function Prove(props) {
Expand All @@ -16,7 +17,7 @@ class ProveComponent extends Component {
}

render() {
const { provingDeposit, proveDepositError } = this.props
const { provingDeposit, error } = this.props

return (
<div className="prove">
Expand All @@ -31,22 +32,19 @@ class ProveComponent extends Component {
{
provingDeposit
? 'Submitting Proof...'
: proveDepositError
: error
? 'Error submitting proof'
: 'Received!'
}
</div>
<hr />
<div className="description">
<Description error={error}>
{
provingDeposit
? 'Generating SPV and submitting to the sidechain...'
: 'Finally, let’s submit proof to the sidechain and get you your TBTC.'
}
</div>
<div className="error">
{ proveDepositError }
</div>
</Description>
</div>
</div>
)
Expand All @@ -57,7 +55,7 @@ class ProveComponent extends Component {
const mapStateToProps = (state, ownProps) => {
return {
provingDeposit: state.deposit.provingDeposit,
proveDepositError: state.deposit.proveDepositError
error: state.deposit.proveDepositError
}
}

Expand Down
13 changes: 6 additions & 7 deletions src/components/deposit/Start.js
Expand Up @@ -5,6 +5,7 @@ import { connect } from 'react-redux'
import history from '../../history'
import { requestPermission } from '../../lib/notifications'
import { selectLotSize, requestAvailableLotSizes } from '../../actions'
import Description from "../lib/Description"
import StatusIndicator from '../svgs/StatusIndicator'
import BTCLogo from '../svgs/btclogo'
import { useWeb3React } from '@web3-react/core'
Expand Down Expand Up @@ -51,13 +52,11 @@ const Start = ({
{ error ? 'Error getting available lot sizes' : 'Select Lot Size' }
</div>
<hr />
<div className={error ? "error" : "description"}>
{ error ? error : (
<LotSizeSelector
lotSizes={availableLotSizes}
onSelect={selectLotSize} />
)}
</div>
<Description error={error}>
<LotSizeSelector
lotSizes={availableLotSizes}
onSelect={selectLotSize} />
</Description>
<div className='cta'>
<button
onClick={handleClickPay}
Expand Down
38 changes: 18 additions & 20 deletions src/components/lib/CopyAddressField.js
Expand Up @@ -15,30 +15,28 @@ const CopyAddressField = ({ address, qrCodeUrl }) => {
}

return (
<div className="copy-address-field">
<div className="copy-address">
{ qrCodeUrl ? (
<div className="qr-code-wrapper">
<QRCodeIcon />
<div className="qr-code">
<QRCode
value={qrCodeUrl}
renderAs="svg"
size={225} />
</div>
<div className="copy-address-field" onClick={handleCopyClick}>
{ qrCodeUrl ? (
<div className="qr-code-wrapper">
<QRCodeIcon />
<div className="qr-code">
<QRCode
value={qrCodeUrl}
renderAs="svg"
size={225} />
</div>
) : ''}
<div className="address" onClick={handleCopyClick}>
{address}
</div>
<div className="copy-text">
{ isCopied ? 'copied!' : 'copy' }
</div>
) : ''}
<div className="address">
{address}
</div>
<div className="copy-text">
{ isCopied ? 'copied!' : 'copy' }
</div>
<textarea
className="hidden-copy-field"
ref={hiddenCopyFieldRef}
defaultValue={address || ''} />
className="hidden-copy-field"
ref={hiddenCopyFieldRef}
defaultValue={address || ''} />
</div>
)
}
Expand Down
9 changes: 9 additions & 0 deletions src/components/lib/Description.js
@@ -0,0 +1,9 @@
import React from "react"

const Description = ({ children, error }) => (
<div className={error ? "error" : "description"}>
{ error ? error : children }
</div>
)

export default Description
18 changes: 17 additions & 1 deletion src/components/lib/Footer.js
Expand Up @@ -9,7 +9,8 @@ class Footer extends Component {
email: '',
success: false,
error: '',
loading: false
loading: false,
errorLogUrl: ''
}

handleInput = (evt) => {
Expand Down Expand Up @@ -51,6 +52,15 @@ class Footer extends Component {
}
}

handleDownloadError = (e) => {
const blob = new Blob(
[JSON.stringify(console.history, null, 2)], { type: 'application/json' }
)
this.setState({
errorLogUrl: window.URL.createObjectURL(blob)
})
}

render() {
const { includeSubscription } = this.props
const { email, error, success, loading } = this.state
Expand All @@ -68,6 +78,12 @@ class Footer extends Component {
</a>
</div>
</div>
<a
className="download-error-button" onClick={this.handleDownloadError}
href={this.state.errorLogUrl}
download={`tbtc-dapp-console-log-${new Date().getTime()}.json`}>
Download Error Log ↓
</a>
</div>
{
includeSubscription && (
Expand Down
2 changes: 2 additions & 0 deletions src/components/lib/index.js
@@ -1,9 +1,11 @@
import Description from './Description'
import Footer from './Footer'
import Header from './Header'
import Modal from './Modal'
import Web3Status from './Web3Status'

export {
Description,
Footer,
Header,
Modal,
Expand Down
14 changes: 4 additions & 10 deletions src/components/redemption/Confirming.js
@@ -1,6 +1,7 @@
import React from 'react'
import { connect } from 'react-redux'

import Description from "../lib/Description"
import StatusIndicator from '../svgs/StatusIndicator'

const Confirming = ({ txHash, btcNetwork, error }) => {
Expand All @@ -20,24 +21,17 @@ const Confirming = ({ txHash, btcNetwork, error }) => {
{ error ? 'Error confirming transaction' : 'Confirming...' }
</div>
<hr />
<div className="description">
<Description error={error}>
<p>We're waiting to confirm your transaction.</p>
{
txHash
? <a className=""href={blockExplorerUrl}
? <a href={blockExplorerUrl}
target="_blank" rel="noopener noreferrer">
Follow along in block explorer
</a>
: ''
}
{
error
? <div className="error">
{ error }
</div>
: ''
}
</div>
</Description>
</div>
</div>
)
Expand Down

0 comments on commit 00042dd

Please sign in to comment.