Skip to content
This repository was archived by the owner on Feb 22, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 .jest
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
jasmine.DEFAULT_TIMEOUT_INTERVAL = 120000
jasmine.DEFAULT_TIMEOUT_INTERVAL = 50000

process.on('unhandledRejection', e => console.log(e))
305 changes: 119 additions & 186 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
},
"scripts": {
"start": "gulp watch",
"test": "eslint src/ && jest -w 1 --coverage && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js && rm -rf ./coverage",
"test": "eslint src/ && jest -w 10 --coverage && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js && rm -rf ./coverage",
"release": "d() { test -z $1 && echo 'Please specify branch.' && exit 1; (git show-branch $1) || exit 1; git stash; git checkout $1; npm i; rm -rf branch/$1; mkdir -p branch/$1 ; gulp build-min; cp -r www/ branch/$1; gulp release-branch --branch $1;}; d",
"release-production": "d() { git stash; git checkout master; npm i;gulp build-min;gulp release-master;}; d",
"build": "webpack --config webpack.config.cli.js"
Expand Down Expand Up @@ -53,7 +53,7 @@
"coveralls": "^3.0.3",
"deep-diff": "^1.0.2",
"del": "^4.1.1",
"es6-plato": "^1.2.2",
"es6-plato": "^1.1.6",
"eslint": "^4.14.0",
"eslint-config-airbnb": "^16.1.0",
"eslint-config-binary": "^1.0.2",
Expand Down
4 changes: 1 addition & 3 deletions src/botPage/bot/Interface/ToolsInterface.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import CandleInterface from './CandleInterface';
import MiscInterface from './MiscInterface';
import IndicatorsInterface from './IndicatorsInterface';
import WebhookInterface from './WebhookInterface';
import { translate } from '../../../common/i18n';

// prettier-ignore
export default Interface => class extends IndicatorsInterface(
MiscInterface(CandleInterface(WebhookInterface(Interface)))) {
MiscInterface(CandleInterface(Interface))) {
getToolsInterface() {
return {
getTime : () => parseInt(new Date().getTime() / 1000),
Expand Down Expand Up @@ -77,7 +76,6 @@ export default Interface => class extends IndicatorsInterface(
...this.getCandleInterface(),
...this.getMiscInterface(),
...this.getIndicatorsInterface(),
...this.getWebhookInterface(),
};
}
};
33 changes: 0 additions & 33 deletions src/botPage/bot/Interface/WebhookInterface.js

This file was deleted.

19 changes: 8 additions & 11 deletions src/botPage/bot/TradeEngine/Balance.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { roundBalance } from '../../common/tools';
import { info } from '../broadcast';
import { observer as globalObserver } from '../../../common/utils/observer';

let balanceStr = '';

export default Engine =>
class Balance extends Engine {
Expand All @@ -10,30 +11,26 @@ export default Engine =>
balance: { balance: b, currency },
} = r;

const balance = roundBalance({ currency, balance: b });
const balanceStr = `${balance} ${currency}`;

globalObserver.setState({ balance, currency });
this.balance = roundBalance({ currency, balance: b });
balanceStr = `${this.balance} ${currency}`;

info({ accountID: this.accountInfo.loginid, balance: balanceStr });
});
}
// eslint-disable-next-line class-methods-use-this
getBalance(type) {
const { scope } = this.store.getState();
const currency = globalObserver.getState('currency');
let balance = globalObserver.getState('balance');
let { balance } = this;

// Deduct trade `amount` in this scope for correct value in `balance`-block
if (scope === 'BEFORE_PURCHASE') {
balance = roundBalance({
balance: Number(balance) - this.tradeOptions.amount,
currency,
currency: this.tradeOptions.currency,
balance : Number(balance) - this.tradeOptions.amount,
});
balanceStr = `${balance} ${this.tradeOptions.currency}`;
}

const balanceStr = `${balance}`;

return type === 'STR' ? balanceStr : Number(balance);
}
};
19 changes: 3 additions & 16 deletions src/botPage/bot/TradeEngine/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,23 +115,10 @@ export default class TradeEngine extends Balance(Purchase(Sell(OpenContract(Prop
this.listen('authorize', ({ authorize }) => {
this.accountInfo = authorize;
this.token = token;

// Only subscribe to balance in browser, not for tests.
if (document) {
this.api.subscribeToBalance().then(response => {
const {
balance: { balance, currency },
} = response;

globalObserver.setState({
balance: Number(balance),
currency,
});
resolve();
});
} else {
this.api.subscribeToBalance().then(r => {
this.balance = Number(r.balance.balance);
resolve();
}
});
})
);
}
Expand Down
1 change: 0 additions & 1 deletion src/botPage/bot/__tests__/BotApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ describe('Interface', () => {
currency : 'USD',
duration : 5,
duration_unit: 't',
basis : 'stake',
});

watch('before').then(c => {
Expand Down
1 change: 0 additions & 1 deletion src/botPage/bot/__tests__/UI.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ expectReturnTrue(
prediction: undefined,
barrierOffset: undefined,
secondBarrierOffset: undefined,
basis: 'stake',
});
}

Expand Down
3 changes: 1 addition & 2 deletions src/botPage/bot/__tests__/tools.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ export const start = options =>
`
Bot.start({
amount: 1,
currency: 'USD', ${options || ''},
basis: 'stake',
currency: 'USD', ${options || ''}
});
`;

Expand Down
2 changes: 1 addition & 1 deletion src/botPage/bot/tools.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const tradeOptionToProposal = tradeOption =>
tradeOption.contractTypes.map(type => {
const proposal = {
duration_unit: tradeOption.duration_unit,
basis : tradeOption.basis,
basis : 'stake',
currency : tradeOption.currency,
symbol : tradeOption.symbol,
duration : tradeOption.duration,
Expand Down
10 changes: 7 additions & 3 deletions src/botPage/common/const.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ const CRYPTO_CURRENCIES = ['BTC', 'ETH', 'LTC', 'BCH'];

const config = {
lists: {
PAYOUTTYPE: [
// [translate('Payout'), 'payout'],
[translate('Stake'), 'stake'],
],
CRYPTO_CURRENCIES,
DETAILS: [
[translate('statement'), '1'],
Expand Down Expand Up @@ -228,9 +232,9 @@ const config = {
bbResult : [[translate('upper'), '1'], [translate('middle'), '0'], [translate('lower'), '2']],
macdFields: [[translate('Histogram'), '0'], [translate('MACD'), '1'], [translate('Signal'), '2']],
gd : {
cid: '828416594271-qj2dnf4u2omg1iugangbtsrq6p0a55oc.apps.googleusercontent.com',
aid: 'derivbot-248506',
api: 'AIzaSyBDYQ7IIgGxM14IeAV5JrtaJNYjxB4A5jo',
cid: '646610722767-7ivdbunktgtnumj23en9gkecbgtf2ur7.apps.googleusercontent.com',
aid: 'binarybot-237009',
api: 'AIzaSyBieTeLip_lVQZUimIuJypU1kJyqOvQRgc',
},
};

Expand Down
15 changes: 10 additions & 5 deletions src/botPage/view/View.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ import {
} from '../../common/utils/storageManager';
import { isProduction } from '../../common/utils/tools';
import GTM from '../../common/gtm';
import { saveBeforeUnload } from './blockly/utils';

let realityCheckTimeout;

Expand Down Expand Up @@ -77,8 +76,6 @@ api.events.on('balance', response => {
const element = elTopMenuBalance;
element.textContent = `${balance} ${currency}`;
});

globalObserver.setState({ balance: b, currency });
});

const addBalanceForToken = token => {
Expand All @@ -93,6 +90,14 @@ const chart = new Chart(api);

const tradingView = new TradingView();

const setBeforeUnload = off => {
if (off) {
window.onbeforeunload = null;
} else {
window.onbeforeunload = () => 'You have some unsaved blocks, do you want to save them before you exit?';
}
};

const showRealityCheck = () => {
$('.blocker').show();
$('.reality-check').show();
Expand Down Expand Up @@ -467,7 +472,7 @@ export default class View {
$('#toggleHeaderButton').click(() => this.showHeader($('#header').is(':hidden')));

$('#logout, #toolbox-logout').click(() => {
saveBeforeUnload();
setBeforeUnload(true);
logout();
hideRealityCheck();
});
Expand Down Expand Up @@ -605,7 +610,7 @@ export default class View {

$('#login, #toolbox-login')
.bind('click.login', () => {
saveBeforeUnload();
setBeforeUnload(true);
document.location = getOAuthURL();
})
.text(translate('Log in'));
Expand Down
2 changes: 0 additions & 2 deletions src/botPage/view/blockly/blocks/tools/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,3 @@ import './block_holder';
import './loader';
import './candle';
import './time';
import './webhook';
import './key_value_pair';
34 changes: 0 additions & 34 deletions src/botPage/view/blockly/blocks/tools/key_value_pair.js

This file was deleted.

Loading