Skip to content

Commit

Permalink
Merge pull request #587 from chronologic/develop
Browse files Browse the repository at this point in the history
Merge develop to master
  • Loading branch information
e00dan authored Aug 27, 2018
2 parents 02a4a41 + 0ed37e1 commit 8521bee
Show file tree
Hide file tree
Showing 10 changed files with 4,610 additions and 4,547 deletions.
2 changes: 1 addition & 1 deletion __tests__/App.unit.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ describe('App', () => {
.find('.view-title')
.text()
.trim()
).toBe('TimeNode');
).toBe('Loading');
expect(
mockedRender
.find('.tab-pane.active h2')
Expand Down
28 changes: 2 additions & 26 deletions __tests__/__snapshots__/Header.unit.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,7 @@ exports[`Header displays current block number 1`] = `
</span>
<span
className="timenode-count"
>
<div>
<div
className="css-1ncsqv2"
/>
<div
className="css-o7y5po"
/>
<div
className="css-1ncsqv2"
/>
</div>
</span>
/>
</div>
<div
className="left-separator right-separator pull-left px-2 fs-14 font-heading d-lg-block d-none"
Expand Down Expand Up @@ -170,17 +158,5 @@ exports[`Header displays current block number 1`] = `
exports[`Header displays current block number 2`] = `
<span
className="timenode-count"
>
<div>
<div
className="css-1ncsqv2"
/>
<div
className="css-o7y5po"
/>
<div
className="css-1ncsqv2"
/>
</div>
</span>
/>
`;
17 changes: 10 additions & 7 deletions app/components/Header/Header.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,12 @@ class Header extends Component {
render() {
const { web3Service, keenStore } = this.props;

const activeTimenodes = keenStore.activeTimeNodes ? (
keenStore.activeTimeNodes
) : (
<BeatLoader color="#fff" size={4} />
);
const activeTimenodes =
keenStore.activeTimeNodes !== null ? (
keenStore.activeTimeNodes
) : (
<BeatLoader color="#fff" size={4} />
);

const infoBtn = (
<span
Expand Down Expand Up @@ -93,15 +94,17 @@ class Header extends Component {
</div>
<div className="left-separator right-separator pull-left px-2 fs-14 font-heading d-lg-block d-none">
<span className="active-timenodes">
<i className="fa fa-th-large" />&nbsp;Network:&nbsp;
<i className="fa fa-th-large" />
&nbsp;Network:&nbsp;
</span>
<span className="timenode-count">
<NetworkChooser history={this.props.history} />
</span>
</div>
<div className="pull-left p-l-10 fs-14 font-heading d-lg-block d-none">
<span className="active-timenodes" data-toggle="dropdown">
<i className="fa fa-file-alt ml-2 cursor-pointer" />&nbsp;
<i className="fa fa-file-alt ml-2 cursor-pointer" />
&nbsp;
</span>
<div
className="dropdown-menu notification-toggle"
Expand Down
5 changes: 3 additions & 2 deletions app/components/TimeNode/TimeNodeRoute.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class TimeNodeRoute extends Component {
}

render() {
const { walletKeystore, attachedDAYAccount } = this.props.timeNodeStore;
const { walletKeystore, attachedDAYAccount, nodeStatus } = this.props.timeNodeStore;

const { walletUnlocked } = this.state;

Expand All @@ -46,7 +46,8 @@ class TimeNodeRoute extends Component {
return (
<div id="timenodeRoute" className="container padding-25 sm-padding-10 subsection">
<h1 className="view-title">
{this.props.timeNodeStore.nodeStatus}&nbsp;
{nodeStatus}
&nbsp;
<span className="view-subtitle d-none d-md-inline">
{this.props.timeNodeStore.getMyAddress()}
</span>
Expand Down
62 changes: 28 additions & 34 deletions app/components/TimeNode/TimeNodeStatistics.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,13 @@ import { BeatLoader } from 'react-spinners';
class TimeNodeStatistics extends Component {
constructor(props) {
super(props);
this.state = {
timeNodeDisabled: null
};

this.startTimeNode = this.startTimeNode.bind(this);
this.stopTimeNode = this.stopTimeNode.bind(this);
this.refreshStats = this.refreshStats.bind(this);
this.shouldShowClaimedWarning = this.shouldShowClaimedWarning.bind(this);
}

async UNSAFE_componentWillMount() {
this.setState({
timeNodeDisabled: this.props.timeNodeStore.nodeStatus === TIMENODE_STATUS.DISABLED
});
}

componentDidMount() {
if (!window.indexedDB) {
throw Error(
Expand All @@ -45,25 +37,21 @@ class TimeNodeStatistics extends Component {
this.interval = setInterval(this.refreshStats, 5000);
}

getStopButton() {
getStopButton(disabled) {
return (
<button
className="btn btn-danger px-4"
onClick={this.shouldShowClaimedWarning}
disabled={this.state.timeNodeDisabled}
disabled={disabled}
>
Stop
</button>
);
}

getStartButton() {
getStartButton(disabled) {
return (
<button
className="btn btn-primary px-4"
onClick={this.startTimeNode}
disabled={this.state.timeNodeDisabled}
>
<button className="btn btn-primary px-4" onClick={this.startTimeNode} disabled={disabled}>
Start
</button>
);
Expand Down Expand Up @@ -104,6 +92,18 @@ class TimeNodeStatistics extends Component {
);
}

getDAYBalanceNotification(disabled) {
return !disabled ? null : (
<Alert
type="danger"
close={false}
msg={`Your DAY token balance is insufficient to start a TimeNode. Make sure you have at least ${
TIMENODE_STATUS.TIMENODE.minBalance
} DAY.`}
/>
);
}

componentWillUnmount() {
clearInterval(this.interval);
}
Expand All @@ -122,43 +122,37 @@ class TimeNodeStatistics extends Component {
}

render() {
let timeNodeStatus = null;
const {
bounties,
costs,
profit,
scanningStarted,
balanceETH,
balanceDAY,
executedTransactions
executedTransactions,
nodeStatus
} = this.props.timeNodeStore;

if (this.state.timeNodeDisabled) {
timeNodeStatus = TIMENODE_STATUS.DISABLED;
} else {
timeNodeStatus = scanningStarted ? 'running' : 'stopped';
}
const { DISABLED, LOADING } = TIMENODE_STATUS;
const timeNodeDisabled = nodeStatus === DISABLED || nodeStatus === LOADING;
const scanningStatus = scanningStarted ? 'running' : 'stopped';

const profitStatus = profit !== null ? profit + ' ETH' : <BeatLoader />;
const bountiesStatus =
bounties !== null && costs !== null ? `${bounties} (bounties) - ${costs} (costs)` : '';

const dayTokenError = (
<Alert msg="Your DAY token balance is too low. Please make sure you have at least 333 DAY tokens." />
);

return (
<div id="timeNodeStatistics">
{this.state.timeNodeDisabled ? dayTokenError : null}
{this.getBalanceNotification()}
{nodeStatus !== LOADING && this.getDAYBalanceNotification(timeNodeDisabled)}
{balanceETH !== null && this.getBalanceNotification()}
{this.getClaimingNotification()}

<h2 className="py-4">
Your TimeNode is currently {timeNodeStatus}.
Your TimeNode is {timeNodeDisabled ? DISABLED.toLowerCase() : scanningStatus}.
<span className="ml-2">
{this.props.timeNodeStore.scanningStarted
? this.getStopButton()
: this.getStartButton()}
{scanningStarted
? this.getStopButton(timeNodeDisabled)
: this.getStartButton(timeNodeDisabled)}
</span>
</h2>

Expand Down
3 changes: 2 additions & 1 deletion app/config/web3Config.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ const Networks = {
1: {
id: 1,
name: 'Mainnet',
endpoint: 'https://mainnet.infura.io/6M6ROam68gmdp9OeNmym',
endpoint:
'wss://neatly-tolerant-coral.quiknode.io/73b04107-89ee-4261-9a8f-3c1e946c17b2/CyYMMeeGTb-EeIBHGwORaw==/',
showInChooser: true,
dayTokenAddress: '0xe814aee960a85208c3db542c53e7d4a6c8d5f60f',
supported: true,
Expand Down
39 changes: 26 additions & 13 deletions app/stores/TimeNodeStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,20 @@ import { Config } from '@ethereum-alarm-clock/timenode-core';
* of DAY tokens held by the owner.
*/
export class TIMENODE_STATUS {
static MASTER_CHRONONODE = 'Master ChronoNode';
static CHRONONODE = 'ChronoNode';
static TIMENODE = 'TimeNode';
static MASTER_CHRONONODE = {
name: 'Master ChronoNode',
minBalance: 3333
};
static CHRONONODE = {
name: 'ChronoNode',
minBalance: 888
};
static TIMENODE = {
name: 'TimeNode',
minBalance: 333
};
static DISABLED = 'Disabled';
static LOADING = 'Loading';
}

// 2 minute as milliseconds
Expand Down Expand Up @@ -56,14 +66,20 @@ export default class TimeNodeStore {

@computed
get nodeStatus() {
if (this.balance >= 3333) {
return TIMENODE_STATUS.MASTER_CHRONONODE;
} else if (this.balance >= 888) {
return TIMENODE_STATUS.CHRONONODE;
} else if (this.balance >= 333 || this.isTimeMint) {
return TIMENODE_STATUS.TIMENODE;
const { MASTER_CHRONONODE, CHRONONODE, TIMENODE, DISABLED, LOADING } = TIMENODE_STATUS;

if (this.balanceDAY === null) {
return LOADING;
}

if (this.balanceDAY >= MASTER_CHRONONODE.minBalance) {
return MASTER_CHRONONODE.name;
} else if (this.balanceDAY >= CHRONONODE.minBalance) {
return CHRONONODE.name;
} else if (this.balanceDAY >= TIMENODE.minBalance || this.isTimeMint) {
return TIMENODE.name;
} else {
return TIMENODE_STATUS.DISABLED;
return DISABLED;
}
}

Expand All @@ -89,9 +105,6 @@ export default class TimeNodeStore {
};
}

@observable
nodeStatus = TIMENODE_STATUS.TIMENODE;

// If a TimeNode has selected a custom provider URL
// it will be stored in this variable
@observable
Expand Down
2 changes: 1 addition & 1 deletion app/stores/TransactionStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export class TransactionStore {

this._eacScheduler = this._eacScheduler || (await this._eac.scheduler());

this._fetcher.requestFactoryStartBlock = this.requestFactoryStartBlock;
this._fetcher.requestFactoryStartBlock = this.requestFactoryStartBlock || 1;
this._fetcher.startLazy();

this.initialized = true;
Expand Down
Loading

0 comments on commit 8521bee

Please sign in to comment.