Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 26 #39

Open
wants to merge 75 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
75 commits
Select commit Hold shift + click to select a range
08cbc64
receivingAddress is empty string in exchange reducer initial state
youfoundron Jun 27, 2017
df45dfb
listen to getCurrency in selectICOsWithRecentStats selector
youfoundron Jun 26, 2017
e7b3a63
make recentPrices reflect current currency
youfoundron Jun 26, 2017
a0d4cd5
make icoPrice currency specific in appendRecentStats
youfoundron Jun 26, 2017
09a5054
convert currPrice to correct currency when not USD
youfoundron Jun 27, 2017
267a7b3
:shirt: Fix lint errors
coopermaruyama Jun 27, 2017
9567507
Recover gracefully from a failed fetch
coopermaruyama Jun 27, 2017
45108a6
Update bancor ticker
coopermaruyama Jun 27, 2017
8344873
pull getAccount functionality out of identify
youfoundron Jun 28, 2017
3a7dbe5
refactor identify using getAccount
youfoundron Jun 28, 2017
0cf51d4
prefill receivingAddress in GetQuote#componentWillMount
youfoundron Jun 28, 2017
393d77b
getAccount -> getAccounts
youfoundron Jul 21, 2017
1603326
update lib/identity to use getAccounts
youfoundron Jul 21, 2017
e4439e5
add types pertaining to account fetching
youfoundron Jul 21, 2017
d539710
add actions pertaining to account fetching
youfoundron Jul 21, 2017
9d8351f
add constants pertaining to account fetching
youfoundron Jul 21, 2017
5fe06ee
add reducer logic pertaining to account fetching
youfoundron Jul 21, 2017
326ec8f
fetch addresses on GetQuote#componentWillMount
youfoundron Jul 21, 2017
73ed122
use <datalist> to list available addresses
youfoundron Jul 21, 2017
fb44b7b
Less logs
coopermaruyama Jun 28, 2017
d77bea6
Performance optimizations
coopermaruyama Jun 28, 2017
7199467
Add ecosystem config.
coopermaruyama Jun 28, 2017
0122292
Update pm2 scrippt.
coopermaruyama Jun 28, 2017
bbaa756
pm2
coopermaruyama Jun 28, 2017
a2e9d75
pm2
coopermaruyama Jun 28, 2017
6e3e158
Add SNT
coopermaruyama Jun 29, 2017
5fd63a6
Remove deleted server
coopermaruyama Jun 29, 2017
f150ff1
pm2
coopermaruyama Jun 29, 2017
9a17d93
Fix SNT stats
coopermaruyama Jun 29, 2017
bcf6759
Update staging IP
coopermaruyama Jun 29, 2017
5526a8f
PM2 Deploy
coopermaruyama Jun 29, 2017
47529c5
pm2
coopermaruyama Jun 29, 2017
4e99f80
pm2
coopermaruyama Jun 29, 2017
1c18b7f
pm2
coopermaruyama Jun 29, 2017
b4bbbc8
pm2
coopermaruyama Jun 29, 2017
f80bbc8
pm2
coopermaruyama Jun 29, 2017
cdadf08
pm2
coopermaruyama Jun 29, 2017
87c4800
pm2
coopermaruyama Jun 29, 2017
bc08120
pm2
coopermaruyama Jun 29, 2017
1a122ea
Add ICO Alerts link
coopermaruyama Jun 30, 2017
f960c87
add(ico data) : Added Aeternity, Darcrus, ETH, IOTA, MYST, QTUM, QRL …
paustria Jul 8, 2017
b07eddd
add(ico data) : Added adToken.
paustria Jul 9, 2017
845aeef
Prefer coinmarketcap.
coopermaruyama Jul 10, 2017
166b9d5
typo
coopermaruyama Jul 10, 2017
caba40f
public API
coopermaruyama Jul 10, 2017
65e6212
Revert "Less logs"
coopermaruyama Jul 10, 2017
9704efb
Logging
coopermaruyama Jul 12, 2017
c226d7f
pm2
coopermaruyama Jul 12, 2017
977a89c
Performance Optimization
coopermaruyama Jul 12, 2017
8d9e330
typo
coopermaruyama Jul 12, 2017
f8f9781
dont include huge price array
coopermaruyama Jul 12, 2017
13439ea
pm2
coopermaruyama Jul 12, 2017
c01e4c8
Fix adtoken ICO price
coopermaruyama Jul 12, 2017
58ee83b
Don't ignore console test.
coopermaruyama Jul 14, 2017
7c93417
Restore console utility test.
coopermaruyama Jul 14, 2017
4433a51
Typo in makefile
coopermaruyama Jul 14, 2017
50308fc
Compress logos
coopermaruyama Jul 14, 2017
27de0e6
fix(exchange): Dropdowns dont work
coopermaruyama Jul 14, 2017
fb19ee0
Fix(sorting): Current price sort doesn't work
coopermaruyama Jul 14, 2017
5515130
add(tokens): EOS, Voise
coopermaruyama Jul 14, 2017
a5aeb6a
Refactor ICO Data
coopermaruyama Jul 14, 2017
194f596
fix(data): ethereum should show 0% for ROI v.s. ETH
coopermaruyama Jul 14, 2017
56d15a8
feat(calc): Util to find compound interest rate
coopermaruyama Jul 14, 2017
4a53f8c
Add flow typings
coopermaruyama Jul 14, 2017
8f0bf61
Remove artifacts
coopermaruyama Jul 14, 2017
f4bf6aa
Docs: Instructions to add tokens
coopermaruyama Jul 14, 2017
4c96049
Typo
coopermaruyama Jul 14, 2017
bd2ba1a
:shirt:
coopermaruyama Jul 14, 2017
b68333f
eslint: allow template literals
coopermaruyama Jul 28, 2017
0733381
flow: Enable tpe suppression
coopermaruyama Jul 28, 2017
1226f79
Install GraphQL Optics
coopermaruyama Jul 28, 2017
82a0caf
:shirt:
coopermaruyama Jul 28, 2017
4b77a7e
Delay between graph fetches
coopermaruyama Jul 28, 2017
717c6e9
Coin traffic
coopermaruyama Jul 28, 2017
2bdc675
Merge branch 'master' into issue-26
coopermaruyama Jul 28, 2017
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 .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
"operator-assignment": [1, "never"],
"operator-linebreak": 0,
"quote-props": 0,
"quotes": [1, "single", "avoid-escape"],
"quotes": [1, "single", { "allowTemplateLiterals": true }],
"keyword-spacing": [1, {
"before": true,
"after": true,
Expand Down
4 changes: 4 additions & 0 deletions .flowconfig
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,7 @@ module.name_mapper='^~/\(.*\)' -> '<PROJECT_ROOT>/src/client/\1'
module.name_mapper='^~/\(.*\)' -> '<PROJECT_ROOT>/src/server/\1'
module.name_mapper='^shared/\(.*\)' -> '<PROJECT_ROOT>/src/shared/\1'
module.name_mapper='^settings$' -> '<PROJECT_ROOT>/settings.js'
suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe
suppress_type=$FlowTODO
suppress_type=$FlowTodo
suppress_type=$TODO
1 change: 1 addition & 0 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,6 @@
});
}
</script>
<script src="//apps.cointraffic.io/js/?wkey=3Tnr8t"></script>
</body>
</html>
1 change: 1 addition & 0 deletions public/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ div {

#app {
height: 100%;
padding-bottom: 48px;
}
/* Let's get this party started */
::-webkit-scrollbar {
Expand Down
16 changes: 15 additions & 1 deletion settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ require('dotenv').config();
module.exports = Object.assign({}, settingsPublic, {
APP_ROOT: __dirname,
APP_PORT: process.env.PORT || 3000,
DEBUG: isDebug(),
MONGO_URI: process.env.MONGO_URI || 'mongodb://mongo/app',
MONGO_TEST_URI: process.env.MONGO_TEST_URI || 'mongodb://mongo/app_test',
MONGO_USERNAME: process.env.MONGO_USERNAME,
Expand All @@ -14,5 +15,18 @@ module.exports = Object.assign({}, settingsPublic, {
SHAPESHIFT_SECRET: process.env.SHAPESHIFT_SECRET,
LOGGLY_SUBDOMAIN: 'icostats',
LOGGLY_TOKEN: '8b807190-29c8-4a5b-adfb-cfe5621fe18b',
LOGGLY_TAG: process.env.LOGGLY_TAG || 'development'
LOGGLY_TAG: process.env.LOGGLY_TAG || 'development',
OPTICS_API_KEY: process.env.OPTICS_API_KEY || 'service:icostats-dev:UZPcus12V1nCychIBLloUA'
});

function isDebug() {
if (process.env.NODE_ENV === 'production') {
return false;
}

if (typeof process.env.DEBUG !== 'undefined') {
return !!process.env.DEBUG;
}

return true;
}
21 changes: 21 additions & 0 deletions src/client/app/lib/getAccounts.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/**
* get the coinbase if user is on a web 3 browser.
*/
import Promise from 'bluebird';

export default async function getAccount() {
const web3Enabled = (
window.web3 &&
window.web3.eth &&
window.web3.eth.getAccounts
);

if (web3Enabled) {
const getAccounts = Promise.promisify(window.web3.eth.getAccounts);
const accounts = await getAccounts();

return accounts;
}

return [];
}
26 changes: 10 additions & 16 deletions src/client/app/lib/identify.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,14 @@
/**
* get the coinbase if user is on a web 3 browser.
* if user is on a web 3 browser
* identify them in analytics via their coinbase
*/
import Promise from 'bluebird';
import getAccounts from './getAccounts';

export default function identify() {
if (window.web3 && window.web3.eth && window.web3.eth.getAccounts) {
const getAccountsAsync = Promise.promisify(window.web3.eth.getAccounts);
export default async function identify() {
// take first account
const [account] = await getAccounts();

return getAccountsAsync().then((accounts) => {
const account = accounts[0];

if (account) {
window.analytics.identify(account);
}
});
}

return false;
}
if (account) {
window.analytics.identify(account);
}
}
16 changes: 16 additions & 0 deletions src/client/exchange/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import type {
RequestOrderStatusAction, ReceiveOrderStatusAction, ErrorValidateAddressAction
} from './types';
import * as types from './constants';
import getAddresses from '../app/lib/getAccounts';


export const initExchange = (toSymbol: string): InitExchangeAction => {
Expand Down Expand Up @@ -125,6 +126,21 @@ export const fetchLimit = (pair: string): ThunkAction => (dispatch) => {
.then(limit => dispatch(receiveLimit(limit)));
};

const requestAddresses = (): RequestAddressesAction => ({
type: types.REQUEST_ADDRESSES
});

const receiveAddresses = (addresses): ReceiveAddressesAction => ({
type: types.RECEIVE_ADDRESSES,
addresses
});

export const fetchAddresses = (): ThunkAction => (dispatch) => {
dispatch(requestAddresses());
return getAddresses()
.then(addresses => dispatch(receiveAddresses(addresses)));
};

export const setReceivingAddress = (
address: string
): SetReceivingAddressAction => ({
Expand Down
29 changes: 24 additions & 5 deletions src/client/exchange/components/GetQuote.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,14 @@ import type { Action, ReduxState } from '~/exchange/types';
import CheckIcon from '~/app/components/CheckIcon';
import GetQuoteColumn from './GetQuoteColumn';
import PoweredByShapeshift from './PoweredByShapeshift';
import { fetchValidateAddress, setReceivingAddress } from '../actions';
import { fetchAddresses, fetchValidateAddress, setReceivingAddress } from '../actions';

type Props = {
classes: Object,
coins: Object,
addresses: Array<string>,
isFetchingAddresses: boolean,
fetchAddresses: () => void,
receivingAddress: string,
isReceivingAddressValid: boolean,
setReceivingAddress: (address: string) => void,
Expand All @@ -24,7 +27,10 @@ type Props = {

class GetQuote extends React.Component {
props: Props;
state = {};

async componentWillMount() {
this.props.fetchAddresses();
}

handleChangeReceivingAddress = (event) => {
event.persist();
Expand All @@ -33,13 +39,18 @@ class GetQuote extends React.Component {

this.props.setReceivingAddress(address);

if (address && !this.props.isFetchingValidateAddress) {
if (
address &&
!this.props.isFetchingValidateAddress &&
!this.props.isFetchingAddresses
) {
debounce(this.props.fetchValidateAddress, 300)(address, to);
}
}

render() {
const {
addresses,
classes: c, coins, receivingAddress, isReceivingAddressValid
} = this.props;
const title = (
Expand Down Expand Up @@ -68,16 +79,21 @@ class GetQuote extends React.Component {
<div className={c.footer}>
<PoweredByShapeshift />
<input
type="text"
list={'receiving-address'}
value={receivingAddress}
spellCheck={false}
placeholder="Input receiving address"
value={receivingAddress}
onChange={this.handleChangeReceivingAddress}
className={classNames(c.inputReceiving, {
'is-valid': isReceivingAddressValid,
'is-invalid': isReceivingAddressValid === false
})}
/>
<datalist id={'receiving-address'}>{addresses.map(address => (
<option key={address}>
{address}
</option>
))}</datalist>
{isReceivingAddressValid && <CheckIcon />}
</div>
);
Expand Down Expand Up @@ -145,6 +161,7 @@ const styles = {
borderRadius: '3px',
padding: '4px 0',
width: '45%',
textOverflow: 'ellipsis',
borderBottom: '1px solid hsl(0, 0%, 84%)',
alignSelf: 'flex-end',
'&.is-valid': {
Expand All @@ -163,10 +180,12 @@ const styled = injectSheet(styles)(GetQuote);
============================================================================= */
const mapStateToProps = (state: {exchange: ReduxState}) => ({
to: state.exchange.to,
addresses: state.exchange.addresses,
receivingAddress: state.exchange.receivingAddress,
isReceivingAddressValid: state.exchange.isReceivingAddressValid
});
const mapDispatchToProps = (dispatch: Dispatch<Action>) => ({
fetchAddresses: () => dispatch(fetchAddresses()),
setReceivingAddress: address => dispatch(setReceivingAddress(address)),
fetchValidateAddress: (address, symbol) =>
dispatch(fetchValidateAddress(address, symbol)),
Expand Down
2 changes: 2 additions & 0 deletions src/client/exchange/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ export const REQUEST_LIMIT = 'exchange/REQUEST_LIMIT';
export const RECEIVE_LIMIT = 'exchange/RECEIVE_LIMIT';
export const REQUEST_SHIFT = 'exchange/REQUEST_SHIFT';
export const RECEIVE_SHIFT = 'exchange/RECEIVE_SHIFT';
export const REQUEST_ADDRESSES = 'exchange/REQUEST_ADDRESSES';
export const RECEIVE_ADDRESSES = 'exchange/RECEIVE_ADDRESSES';
export const SET_RECEIVING_ADDRESS = 'exchange/SET_RECEIVING_ADDRESS';
export const REQUEST_VALIDATE_ADDRESS = 'exchange/REQUEST_VALIDATE_ADDRESS';
export const RECEIVE_VALIDATE_ADDRESS = 'exchange/RECEIVE_VALIDATE_ADDRESS';
Expand Down
16 changes: 16 additions & 0 deletions src/client/exchange/reducers.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ const initialState: State = {
from: 'ETH',
to: 'WINGS',
amount: '',
addresses: [],
receivingAddress: '',
isFetchingAddresses: false,
isFetchingQuote: false,
didInvalidateQuote: false,
isFetchingLimit: false,
Expand Down Expand Up @@ -78,6 +81,19 @@ const exchangeReducer = (
limit: action.limit
};

case types.REQUEST_ADDRESSES:
return {
...state,
isFetchingAddresses: true
};

case types.RECEIVE_ADDRESSES:
return {
...state,
isFetchingAddresses: false,
addresses: action.addresses
};

case types.SET_RECEIVING_ADDRESS:
return {
...state,
Expand Down
11 changes: 11 additions & 0 deletions src/client/exchange/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@ export type ReceiveShiftAction = {
type: types.RECEIVE_SHIFT,
payload: { deposit: string, orderId: string }
};
export type RequestAddressesAction = {
type: types.REQUEST_ADDRESSES
};
export type ReceiveAddressesAction = {
type: types.RECEIVE_ADDRESSES,
addresses: Array<string>
};
export type SetReceivingAddressAction = {
type: types.SET_RECEIVING_ADDRESS,
address: string
Expand Down Expand Up @@ -63,6 +70,8 @@ export type Action =
| ReceiveLimitAction
| RequestShiftAction
| ReceiveShiftAction
| RequestAddressesAction
| ReceiveAddressesAction
| SetReceivingAddressAction
| RequestValidateAddressAction
| ReceiveValidateAddressAction
Expand All @@ -82,6 +91,8 @@ export type State = {
isFetchingLimit: boolean,
didInvalidateLimit: boolean,
limit?: $Limit,
addresses?: Array<string>,
isFetchingAddresses?: boolean,
depositAddress?: string,
receivingAddress?: string,
isFetchingValidateAddress: boolean,
Expand Down
23 changes: 19 additions & 4 deletions src/server/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import 'winston-loggly-bulk';
import mongoose from 'mongoose';
import Promise from 'bluebird';
import { graphqlExpress, graphiqlExpress } from 'graphql-server-express';
import OpticsAgent from 'optics-agent';
import settings from 'settings';
import schema from 'schema';
import NodeCache from 'node-cache';
Expand Down Expand Up @@ -61,14 +62,28 @@ winston.add(winston.transports.Loggly, {
exitOnError: false
});

app.use(expressWinston.logger({
winstonInstance: winston
}));
if (!settings.DEBUG) {
app.use(expressWinston.logger({
winstonInstance: winston
}));
}

/**
* Add optics to graphql
*/
OpticsAgent.configureAgent({ apiKey: settings.OPTICS_API_KEY });
OpticsAgent.instrumentSchema(schema);
app.use(OpticsAgent.middleware());

/**
* GraphQL
*/
app.use('/graphql', bodyParser.json(), graphqlExpress({ schema }));
app.use('/graphql', bodyParser.json(), graphqlExpress(req => ({
schema,
context: {
opticsContext: OpticsAgent.context(req)
}
})));

app.use('/graphiql', graphiqlExpress({
endpointURL: '/graphql'
Expand Down
2 changes: 1 addition & 1 deletion src/server/lib/graph-worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,6 @@ function recurseOrFinish(ticker, i, didSkip = false) {
} else {
// Keep recursing.
!didSkip && winston.info(`Fetched graph for ${ticker}`);
return recursiveFetch(tokens, i + 1);
return setTimeout(() => recursiveFetch(tokens, i + 1), 10000);
}
}
1 change: 0 additions & 1 deletion src/server/schema/resolvers/icos.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import winston from 'winston';
import has from 'lodash/has';
import { normalize as normalizeICO } from 'lib/icos';
import icoData from 'lib/ico-data';
import { fetchETHPrice, fetchBTCPrice } from 'shared/lib/exchanges/gdax';
import { cache } from 'app';
import Ticker from '~/models/ticker';
import PriceHistory from 'models/price-history';
Expand Down
1 change: 1 addition & 0 deletions tests/server/_setup.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/* eslint-disable */
import 'isomorphic-fetch';
import mongoose from 'mongoose';
import Promise from 'bluebird';
import settings from 'settings';
Expand Down