Skip to content
This repository has been archived by the owner on Sep 3, 2019. It is now read-only.

Commit

Permalink
878 insight path (#889)
Browse files Browse the repository at this point in the history
* Use node env to determine env

* Remove cross env module

* Add is prod func check in config

* Fix order

* Fix getting escrow result
  • Loading branch information
dwalintukan committed Aug 22, 2018
1 parent 09a263f commit 7cc9b95
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 46 deletions.
29 changes: 0 additions & 29 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@
"case-sensitive-paths-webpack-plugin": "^2.1.2",
"chalk": "^2.4.1",
"copy-webpack-plugin": "^4.5.1",
"cross-env": "^5.2.0",
"css-loader": "^0.28.11",
"dotenv": "4.0.0",
"enzyme": "^3.4.1",
Expand Down Expand Up @@ -122,8 +121,8 @@
"whatwg-fetch": "2.0.3"
},
"scripts": {
"start": "cross-env REACT_APP_ENV=dev node scripts/start.js",
"start:prod": "cross-env REACT_APP_ENV=prod node scripts/start.js",
"start": "node scripts/start.js",
"start:prod": "node scripts/start.js",
"build": "node scripts/build.js",
"test": "jest",
"lint": "eslint .",
Expand Down
1 change: 1 addition & 0 deletions src/config/app.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
module.exports = {
isProduction: () => process.env.NODE_ENV === 'production',
intervals: { // in MS
syncInfo: 5000,
tooltipDelay: 300,
Expand Down
7 changes: 5 additions & 2 deletions src/network/graphql/mutations.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ import _ from 'lodash';

import client from './';
import { TYPE, getMutation, isValidEnum } from './schema';
import { isProduction } from '../../config/app';

if (process.env.REACT_APP_ENV === 'dev') {
if (!isProduction()) {
window.mutations = '';
}

Expand Down Expand Up @@ -46,7 +47,9 @@ class GraphMutation {

async execute() {
const mutation = this.build();
if (process.env.REACT_APP_ENV === 'dev') {

// Post mutation to window
if (!isProduction()) {
window.mutations += `\n${mutation}`;
}

Expand Down
8 changes: 5 additions & 3 deletions src/network/graphql/queries.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import gql from 'graphql-tag';
import client from './';
import GraphParser from './parser';
import { TYPE, isValidEnum, getTypeDef } from './schema';
import { isProduction } from '../../config/app';

if (process.env.REACT_APP_ENV === 'dev') {
if (!isProduction()) {
window.queries = '';
}


class GraphQuery {
constructor(queryName, type) {
this.queryName = queryName;
Expand Down Expand Up @@ -117,7 +117,9 @@ class GraphQuery {

async execute() {
const query = this.build();
if (process.env.REACT_APP_ENV === 'dev') {

// Post query to window
if (!isProduction()) {
window.queries += `\n${query}`;
}

Expand Down
7 changes: 3 additions & 4 deletions src/network/routes.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { isProduction } from '../config/app';

const AUTHORITY = 'puti.io:8989';
const HTTP_ROUTE = `https://${AUTHORITY}`;
const WS_ROUTE = `wss://${AUTHORITY}`;

const QTUM_EXPLORER = {
dev: 'https://testnet.qtum.org',
prod: 'https://explorer.qtum.org',
}[process.env.REACT_APP_ENV];
const QTUM_EXPLORER = isProduction() ? 'https://explorer.qtum.org' : 'https://testnet.qtum.org';
const BASE_INSIGHT = `${QTUM_EXPLORER}/insight-api`;

export default {
Expand Down
6 changes: 3 additions & 3 deletions src/scenes/CreateEvent/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { defineMessages } from 'react-intl';
import { decimalToSatoshi, satoshiToDecimal } from '../../helpers/utility';
import Tracking from '../../helpers/mixpanelUtil';
import Routes from '../../network/routes';
import { maxTransactionFee, defaults } from '../../config/app';
import { isProduction, maxTransactionFee, defaults } from '../../config/app';
import { createTopic } from '../../network/graphql/mutations';

const messages = defineMessages({
Expand Down Expand Up @@ -65,7 +65,7 @@ const MAX_LEN_EVENTNAME_HEX = 640;
const MAX_LEN_RESULT_HEX = 64;
const TIME_DELAY_FROM_NOW_SEC = 15 * 60;
let TIME_GAP_MIN_SEC = 30 * 60;
if (process.env.REACT_APP_ENV === 'dev') {
if (!isProduction()) {
TIME_GAP_MIN_SEC = 2 * 60;
}

Expand Down Expand Up @@ -262,7 +262,7 @@ export default class CreateEventStore {
this.prediction.endTime = nowPlus(TIME_DELAY_FROM_NOW_SEC + TIME_GAP_MIN_SEC);
this.resultSetting.startTime = nowPlus(TIME_DELAY_FROM_NOW_SEC + TIME_GAP_MIN_SEC);
this.resultSetting.endTime = nowPlus(TIME_DELAY_FROM_NOW_SEC + (TIME_GAP_MIN_SEC * 2));
this.escrowAmount = satoshiToDecimal(escrowRes.data.result[0]); // eslint-disable-line
this.escrowAmount = satoshiToDecimal(escrowRes.data[0]); // eslint-disable-line
this.creator = this.app.wallet.lastUsedAddress;
this.isOpen = true;
});
Expand Down
6 changes: 4 additions & 2 deletions src/stores/AppStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import PendingTxsSnackbarStore from '../components/PendingTxsSnackbar/store';
import CreateEventStore from '../scenes/CreateEvent/store';
import EventPageStore from '../scenes/Event/store';
import WalletHistoryStore from '../scenes/Wallet/History/store';
import { isProduction } from '../config/app';

class AppStore {
@observable loading = true;
Expand Down Expand Up @@ -73,8 +74,9 @@ class AppStore {
}

const store = new AppStore();
if (process.env.REACT_APP_ENV === 'dev') {
window.xstore = store;
// Add store to window
if (!isProduction()) {
window.store = store;
}

export default store;

0 comments on commit 7cc9b95

Please sign in to comment.