Skip to content
This repository has been archived by the owner on Dec 19, 2020. It is now read-only.

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
vbloher committed Nov 30, 2018
2 parents 792765f + 8274a7b commit 16204f8
Show file tree
Hide file tree
Showing 8 changed files with 112 additions and 4 deletions.
1 change: 1 addition & 0 deletions CNAME
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
cyb.ai
6 changes: 4 additions & 2 deletions src/components/ConfirmationPopup/ConfirmationPopup.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ import { Title, Message } from '@cybercongress/ui';
import './ConfirmationPopup.css';
import Block, { BlockRow, Row } from '../Settings/Block';
import Button from '../Button/Button';
import CybLink from '../CybLink';


const ConfirmationPopup = ({
from, to, approveCallback, rejectCallback, children,
content, txHash, totalAmount, accountBalance, insufficientFunds,
hidePending, txError,
hidePending, txError, viewHash
}) => (
<div className='confirmation-popup'>
<span>
Expand Down Expand Up @@ -51,7 +53,7 @@ const ConfirmationPopup = ({
<div>
<Message type='info'>
<span>Tx hash:</span>
{txHash}
<CybLink dura={`${txHash}.eth`} onClick={viewHash}>{txHash}</CybLink>
</Message>
</div>
<div className='confirmation-popup__buttons'>
Expand Down
6 changes: 6 additions & 0 deletions src/containers/Application/ConfirmationPopup.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,11 @@ class ConfirmationPopupContainer extends Component {
}
};


viewHash = (txHash) => {
this.props.hidePending();
}

render() {

if (!this.props.password) {
Expand Down Expand Up @@ -145,6 +150,7 @@ class ConfirmationPopupContainer extends Component {
rejectCallback={ this.reject }
hidePending={() => this.props.hidePending()}
txHash={ lastTransactionId }
viewHash={this.viewHash}
txError={ txError }
content={ (
<TxDetailsContainer>
Expand Down
56 changes: 56 additions & 0 deletions src/containers/TransactionView/TransactionView.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import React, { Component } from 'react';
import { connect } from 'react-redux';
import { getTransaction } from '../../redux/wallet';

import './transaction.css';

function syntaxHighlight(json) {
if (typeof json != 'string') {
json = JSON.stringify(json, undefined, 2);
}
json = json.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
return json.replace(/("(\\u[a-zA-Z0-9]{4}|\\[^u]|[^\\"])*"(\s*:)?|\b(true|false|null)\b|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?)/g, function (match) {
var cls = 'number';
if (/^"/.test(match)) {
if (/:$/.test(match)) {
cls = 'key';
} else {
cls = 'string';
}
} else if (/true|false/.test(match)) {
cls = 'boolean';
} else if (/null/.test(match)) {
cls = 'null';
}
return '<span class="' + cls + '">' + match + '</span>';
});
}

class TransactionView extends Component {
componentDidMount() {
this.props.getTransaction(this.props.params.txHash)
}
render() {
const { data } = this.props;
return (
<div>
<h2>transaction</h2>
{data ? (
<pre dangerouslySetInnerHTML={{ __html: syntaxHighlight(data) }}>
</pre>
): (
<div>not found</div>
)}
</div>
);
}
}

export default connect(
state => ({
data: state.wallet.transaction
}),
{
getTransaction
}
)(TransactionView);
6 changes: 6 additions & 0 deletions src/containers/TransactionView/transaction.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
pre {outline: 1px solid #ccc; padding: 5px; margin: 5px; }
.string { color: green; }
.number { color: darkorange; }
.boolean { color: blue; }
.null { color: magenta; }
.key { color: red; }
6 changes: 6 additions & 0 deletions src/redux/browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,12 @@ export const navigate = (_dura, init = false) => (dispatch, getState) => {
return;
}

if (!!_dura && _dura.split('.')[1] === 'eth') {
hashHistory.push(`/eth/${_dura.split('.')[0]}`);
dispatch(updateDURA(_dura));
return;
}

if (_dura === 'apps.cyb') {
// if (!init)
hashHistory.push('/appstore');
Expand Down
33 changes: 31 additions & 2 deletions src/redux/wallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ const initState = {

password: null,
incorrectPassword: false,

transaction: null,
};

export const reducer = (state = initState, action) => {
Expand Down Expand Up @@ -85,6 +87,13 @@ export const reducer = (state = initState, action) => {
};
}

case 'SET_ETH_TX': {
return {
...state,
transaction: action.payload
}
}

default:
return state;
}
Expand Down Expand Up @@ -310,13 +319,13 @@ export const approve = (gasLimit, gasPrice) => (dispatch, getState) => {
wv.send('web3_eth_call', result);

if (e) {
dispatch(hidePending());
// dispatch(hidePending());
} else {
dispatch({
type: 'SHOW_TRANSACTION',
payload: result.result,
});
dispatch(hidePending());
// dispatch(hidePending());
}
// dispatch(hidePending());
});
Expand Down Expand Up @@ -520,3 +529,23 @@ export const isLoginExist = () => {

return !!cryptoWallet;
};


export const getTransaction = (hash) => (dispatch, getState) => {
web3.eth.getTransaction(hash)
.then(data => {
dispatch({
type: 'SET_ETH_TX',
payload: data,
});
});

// const subscription = web3.eth.subscribe('pendingTransactions')

// subscription.subscribe((error, result) => {
// // debugger
// // if (error) console.log(error)

// console.log(result)
// })
};
2 changes: 2 additions & 0 deletions src/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@ import NotFound from './NotFound';
import Browser from './Browser';
import Home from './containers/Home';
import AppStore from './containers/AppStore/AppStore';
import TransactionView from './containers/TransactionView/TransactionView';

const AppRouter = () => (
<Router history={ hashHistory }>
<Route path='/' component={ Application }>
<Route path='/rootregistry' component={ RootRegistry } />
<Route path='/settings' component={ Settings } />
<Route path='/wallet' component={ Wallet } />
<Route path='/eth/:txHash' component={ TransactionView } />
<Route path='/appstore' component={ AppStore } />
<Route path='/notfound' component={ NotFound } />
<Route path='/browser' component={ Browser } />
Expand Down

0 comments on commit 16204f8

Please sign in to comment.