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

Commit

Permalink
fix warnings, code refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
vbloher committed Oct 23, 2018
1 parent 5e91fb7 commit 581e768
Show file tree
Hide file tree
Showing 12 changed files with 118 additions and 115 deletions.
45 changes: 24 additions & 21 deletions src/Application.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, {Component} from 'react';
import {connect} from "react-redux";
import {navigate, goBack} from './redux/browser';
import {approve, reject} from './redux/wallet';
import { toggleMenu } from './redux/appMenu';
import {toggleMenu} from './redux/appMenu';

import AppMenu from './components/AppMenu/AppMenu';
import AddToAppMenuButton, {Container} from "./components/AddToAppMenuButton/AddToAppMenuButton";
Expand All @@ -11,7 +11,7 @@ import Navigation, {NavigationLeft, NavigationRight, NavigationCenter} from './c
import SearchInput from './components/SearchInput/SearchInput';
import Logo from './components/Logo/Logo';
import IdBar, {SettingsLink, WalletLink, CurrentUser} from './components/IdBar/IdBar';
import ConfirmationPopup, {ApproveButton, RejectButton} from './components/ConfirmationPopup/ConfirmationPopup';
import ConfirmationPopup, {ApproveButton} from './components/ConfirmationPopup/ConfirmationPopup';

import CybLink from './components/CybLink';

Expand Down Expand Up @@ -58,24 +58,27 @@ class Application extends Component {

return (
<App openMenu={openMenu}>
<AppMenu openMenu={openMenu} />
{pendingRequest && <ConfirmationPopup
content={<div>
<div>
gas: <input ref='gas' placeholder='gas' defaultValue={72000}/>
</div>
<div>
from:{_from}
</div>
<div>
to:{_to}
</div>
</div>}
<AppMenu openMenu={openMenu}/>
{pendingRequest &&
<ConfirmationPopup
content={
<div>
<div>
gas: <input ref='gas' placeholder='gas' defaultValue={72000}/>
</div>
<div>
from:{_from}
</div>
<div>
to:{_to}
</div>
</div>
}
>

<ApproveButton onClick={this.approve}>approve</ApproveButton>
<ApproveButton onClick={this.reject}>reject</ApproveButton>
</ConfirmationPopup>}
<ApproveButton onClick={this.approve}>approve</ApproveButton>
<ApproveButton onClick={this.reject}>reject</ApproveButton>
</ConfirmationPopup>
}
<AppHeader isHome={homePage}>
<Navigation isHome={homePage}>
<NavigationLeft>
Expand All @@ -93,7 +96,7 @@ class Application extends Component {
/>
<button disabled={!canBack} onClick={goBack}>back</button>
<button disabled>forward</button>
{(!!dura && dura.indexOf('.dev') !== -1) && <div style={{ display: 'inline-block'}}>
{(!!dura && dura.indexOf('.dev') !== -1) && <div style={{display: 'inline-block'}}>
<button>deploy</button>
<CybLink dura='.help/#/deploy'>how to deploy app</CybLink>
</div>}
Expand All @@ -104,7 +107,7 @@ class Application extends Component {
<IdBar>
<SettingsLink/>
<WalletLink/>
<CurrentUser defaultAccount={defaultAccount} cyberDefaultAccount={cyberDefaultAccount} />
<CurrentUser defaultAccount={defaultAccount} cyberDefaultAccount={cyberDefaultAccount}/>
</IdBar>
</NavigationRight>
</Navigation>
Expand Down
79 changes: 39 additions & 40 deletions src/Home.js
Original file line number Diff line number Diff line change
@@ -1,51 +1,50 @@
import React, { Component } from 'react';

import CybLink from './components/CybLink';
import React, {Component} from 'react';

import Home, {
Items,
Item,
ItemTitle,
Image,
Arrow,
LinkList, LinkItem
Items,
Item,
ItemTitle,
Image,
Arrow,
LinkList, LinkItem
} from './components/Home/Home';

class HomePage extends Component {
render() {
return (
<Home>
<Items>
<Item dura='apps.cyb'>
<ItemTitle>App Store</ItemTitle>
<Image type='appStore'/>
<Arrow />
</Item>

<Item dura='.chaingear/#/new' >
<ItemTitle>Create Register</ItemTitle>
<Image type='createRegistry'/>
<Arrow />
</Item>
<Item dura='.help/#/create'>
<ItemTitle>Create App</ItemTitle>
<Image type='createApp'/>
<Arrow />
</Item>
</Items>
render() {
return (
<Home>
<Items>
<Item dura='apps.cyb'>
<ItemTitle>App Store</ItemTitle>
<Image type='appStore'/>
<Arrow/>
</Item>

<Item dura='.chaingear/#/new'>
<ItemTitle>Create Register</ItemTitle>
<Image type='createRegistry'/>
<Arrow/>
</Item>
<Item dura='.help/#/create'>
<ItemTitle>Create App</ItemTitle>
<Image type='createApp'/>
<Arrow/>
</Item>
</Items>

<LinkList>

<LinkItem target="_blank" to='https://github.com/cybercongress' icon='github'>GitHub</LinkItem>
<LinkItem target="_blank" to='https://github.com/orgs/cybercongress/projects/1' icon='roadmap'>Roadmap</LinkItem>
<LinkItem target="_blank" to='http://cybersearch.live' icon='cybernode'>Cybernode</LinkItem>
<LinkItem target="_blank" to='https://wiki.cybercongress.ai' icon='knowledge'>Knowledge</LinkItem>
<LinkItem target="_blank" to='https://medium.com/@cybercongress' icon='blog'>Blog</LinkItem>

</LinkList>
</Home>
);
}
<LinkItem target="_blank" to='https://github.com/cybercongress' icon='github'>GitHub</LinkItem>
<LinkItem target="_blank" to='https://github.com/orgs/cybercongress/projects/1'
icon='roadmap'>Roadmap</LinkItem>
<LinkItem target="_blank" to='http://cybersearch.live' icon='cybernode'>Cybernode</LinkItem>
<LinkItem target="_blank" to='https://wiki.cybercongress.ai' icon='knowledge'>Knowledge</LinkItem>
<LinkItem target="_blank" to='https://medium.com/@cybercongress' icon='blog'>Blog</LinkItem>

</LinkList>
</Home>
);
}
}

export default HomePage
6 changes: 2 additions & 4 deletions src/components/AddToAppMenuButton/AddToAppMenuButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export const Container = ({children}) => (
<div className='favoritesContainer'>
{children}
</div>
)
);

class AddToAppMenuButton extends Component {

Expand All @@ -27,7 +27,7 @@ class AddToAppMenuButton extends Component {
return menuItems.find(item => {
return item.rootDura === currentDura
})
}
};

render() {
const className = this.isFavoritedPage() ? 'favoritedPage' : 'addAppButton';
Expand All @@ -40,8 +40,6 @@ class AddToAppMenuButton extends Component {
}
}



export default connect(
state => ({
menuItems: state.appMenu.items,
Expand Down
6 changes: 3 additions & 3 deletions src/components/AppMenu/AppMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ class AppMenu extends Component {
rejectFavorite = () => {
this.refs.input.value = 'New App';
this.hideInput();
}
};

render() {
const { openMenu } = this.props;
const {openMenu} = this.props;

const deleteAppFromMenu = (rootDura) => {
this.props.deleteMenuItem(rootDura);
Expand All @@ -48,7 +48,7 @@ class AppMenu extends Component {
{appMenuItems}
</div>
{pendingAddToFavorites &&
<span className='addMenuItem'>
<span className='addMenuItem'>
<input
ref='input'
defaultValue='New App'
Expand Down
73 changes: 35 additions & 38 deletions src/components/Home/Home.js
Original file line number Diff line number Diff line change
@@ -1,68 +1,65 @@
import React from 'react';
import CybLink from '../CybLink';
import { Link as LinkRouter} from 'react-router';
import {Link as LinkRouter} from 'react-router';
import './Home.css';

const Home = (props) => (
<div {...props} className='home' />
<div {...props} className='home'/>
);





export const Items = ({ children }) => (
<div className='items'>
{children}
</div>
export const Items = ({children}) => (
<div className='items'>
{children}
</div>
);

export const Item = ({ children, dura, ...props }) => (
props.disabled ? (
<span className='item' {...props}>{children}</span>
export const Item = ({children, dura, ...props}) => (
props.disabled ? (
<span className='item' {...props}>{children}</span>
) : (
<CybLink dura={dura} className='item' {...props}>
{children}
</CybLink>
)
<CybLink dura={dura} className='item' {...props}>
{children}
</CybLink>
)
);

export const Arrow = () => (
<span className='arrow' />
<span className='arrow'/>
);

export const ItemTitle = ({ children, gray }) => (
<span className={'itemTitle' + ' ' + (gray ? 'itemTitleGray' : '')}>
export const ItemTitle = ({children, gray}) => {
const className = 'itemTitle ' + (gray ? 'itemTitleGray' : '');
return <span className={className}>
{children}
</span>
);
};

export const Image = ({ type }) => (
<div className={`image image${type}`}>
</div>
export const Image = ({type}) => (
<div className={`image image${type}`}>
</div>
);



const Link = (props) => {
if (/^https?:\/\//.test(props.to)) return <a href={props.to} {...props}/>

return <LinkRouter {...props} />
if (/^https?:\/\//.test(props.to)) {
return <a href={props.to} {...props}> </a>
} else {
return <LinkRouter {...props} />
}
};


export const LinkList = ({ children }) => (
<nav className='linkList'>
{children}
</nav>
export const LinkList = ({children}) => (
<nav className='linkList'>
{children}
</nav>
);

export const LinkItem = ({ children, to, icon, ...props }) => (
<Link to={to} className={`linkItem linkItem${icon}`} {...props}>
{children}
</Link>
export const LinkItem = ({children, to, icon, ...props}) => (
<Link to={to} className={`linkItem linkItem${icon}`} {...props}>
{children}
</Link>
);



export default Home;
export default Home;
1 change: 0 additions & 1 deletion src/containers/AppStore.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React, {Component} from 'react';
import CybLink from "../components/CybLink";
import Container from '../components/Container/Container';


Expand Down
4 changes: 2 additions & 2 deletions src/containers/Wallet/CyberWallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class CyberWallet extends Component {
const accounts = this.props.accounts;

return (
<div>
<Container>
<h3>Current account</h3>
{defaultAccount}

Expand All @@ -56,7 +56,7 @@ class CyberWallet extends Component {
placeholder='private key'
addCallback={this.importAccount}
/>
</div>
</Container>
);
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/cyber/codec.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const bech32 = {
},

isBech32(prefix, str) {
if (!prefix || prefix.length == 0) {
if (!prefix || prefix.length === 0) {
return false
}

Expand All @@ -73,4 +73,4 @@ const bech32 = {
module.exports = {
hex: hex,
bech32: bech32
};
};
6 changes: 5 additions & 1 deletion src/cyber/crypto.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const constants = require('./constants').CyberdNetConfig;

function encode(acc) {
if (!utils.isEmpty(acc)) {
let defaultCoding = constants.DEFAULT_ENCODING
let defaultCoding = constants.DEFAULT_ENCODING;
switch (defaultCoding) {
case constants.ENCODING_BECH32: {
if (codec.hex.isHex(acc.address)) {
Expand All @@ -16,6 +16,10 @@ function encode(acc) {
if (codec.hex.isHex(acc.publicKey)) {
acc.publicKey = codec.bech32.toBech32(constants.PREFIX_BECH32_ACCPUB, acc.publicKey)
}
break;
}
default: {

}
}
return acc
Expand Down
2 changes: 1 addition & 1 deletion src/cyber/keypair.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ const hd = {
} else {
const pubKey = Secp256k1.publicKeyCreate(privKeyBytes);
// TODO
if (index == 0) {
if (index === 0) {
indexBuffer = Buffer.from([0, 0, 0, 0]);
}
data = pubKey
Expand Down
Loading

0 comments on commit 581e768

Please sign in to comment.