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
1 change: 1 addition & 0 deletions src/botPage/bot/__tests__/BotApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ describe('Interface', () => {
currency : 'USD',
duration : 5,
duration_unit: 't',
basis : 'stake',
});

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

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

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 : 'stake',
basis : tradeOption.basis,
currency : tradeOption.currency,
symbol : tradeOption.symbol,
duration : tradeOption.duration,
Expand Down
4 changes: 0 additions & 4 deletions src/botPage/common/const.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@ 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
16 changes: 11 additions & 5 deletions src/botPage/view/blockly/blocks/trade/components.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,17 @@ export const duration = block => {

export const payout = block => {
if (!block.getInput('AMOUNT')) {
block
.appendValueInput('AMOUNT')
.setCheck('Number')
.appendField(`${translate('Stake')}:`)
.appendField(new Blockly.FieldDropdown(config.lists.CURRENCY), 'CURRENCY_LIST');
const amountInput = block.appendValueInput('AMOUNT');

amountInput.setCheck('Number');

if (block.type === 'tradeOptions_payout') {
amountInput.appendField(`${translate('Payout')}:`);
} else {
amountInput.appendField(`${translate('Stake')}:`);
}

amountInput.appendField(new Blockly.FieldDropdown(config.lists.CURRENCY), 'CURRENCY_LIST');
}
};

Expand Down
14 changes: 9 additions & 5 deletions src/botPage/view/blockly/blocks/trade/tradeOptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export default () => {
if (!symbol) return;

const getNestedTradeOptions = block => {
if (block.type === 'tradeOptions') {
if (/^tradeOptions/.test(block.type)) {
this.pollForContracts(symbol).then(contracts => {
this.updateBarrierOffsetBlocks(contracts, false, false, [block.id]);
this.applyBarrierHandlebars('BARRIEROFFSETTYPE_LIST', [ev.blockId], true);
Expand Down Expand Up @@ -141,7 +141,7 @@ export default () => {
});
},
updatePredictionBlocks(contracts, updateOnly = []) {
getBlocksByType('tradeOptions').forEach(tradeOptionsBlock => {
getBlocksByType(this.type).forEach(tradeOptionsBlock => {
if (tradeOptionsBlock.disabled) return;
if (updateOnly.length && !updateOnly.includes(tradeOptionsBlock.id)) return;

Expand All @@ -166,7 +166,7 @@ export default () => {
});
},
updateBarrierOffsetBlocks(contracts, useDefaultType = false, setDefaultValue = false, updateOnly = []) {
getBlocksByType('tradeOptions').forEach(tradeOptionsBlock => {
getBlocksByType(this.type).forEach(tradeOptionsBlock => {
if (tradeOptionsBlock.disabled) return;
if (updateOnly.length && !updateOnly.includes(tradeOptionsBlock.id)) return;

Expand Down Expand Up @@ -241,7 +241,7 @@ export default () => {
});
},
updateDurationLists(contracts, useDefaultUnit = false, setMinDuration = false, updateOnly = []) {
getBlocksByType('tradeOptions').forEach(tradeOptionsBlock => {
getBlocksByType(this.type).forEach(tradeOptionsBlock => {
if (tradeOptionsBlock.disabled) return;
if (updateOnly.length && !updateOnly.includes(tradeOptionsBlock.id)) return;

Expand Down Expand Up @@ -290,7 +290,7 @@ export default () => {
});
},
applyBarrierHandlebars(barrierFieldName, forceDistinct = false, updateOnly = []) {
getBlocksByType('tradeOptions').forEach(tradeOptionsBlock => {
getBlocksByType(this.type).forEach(tradeOptionsBlock => {
if (tradeOptionsBlock.disabled) return;
if (updateOnly.length && !updateOnly.includes(tradeOptionsBlock.id)) return;

Expand Down Expand Up @@ -318,6 +318,8 @@ export default () => {
});
},
};
Blockly.Blocks.tradeOptions_payout = Blockly.Blocks.tradeOptions;

Blockly.JavaScript.tradeOptions = block => {
const durationValue = Blockly.JavaScript.valueToCode(block, 'DURATION', Blockly.JavaScript.ORDER_ATOMIC) || '0';
const durationType = block.getFieldValue('DURATIONTYPE_LIST');
Expand Down Expand Up @@ -366,8 +368,10 @@ export default () => {
prediction: ${predictionValue},
barrierOffset: ${barrierOffsetValue},
secondBarrierOffset: ${secondBarrierOffsetValue},
basis: '${block.type === 'tradeOptions_payout' ? 'payout' : 'stake'}',
});
`;
return code;
};
Blockly.JavaScript.tradeOptions_payout = Blockly.JavaScript.tradeOptions;
};
12 changes: 12 additions & 0 deletions static/xml/toolbox.xml
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,18 @@
</shadow>
</value>
</block>
<block type="tradeOptions_payout">
<value name="DURATION">
<shadow type="math_number">
<field name="NUM">5</field>
</shadow>
</value>
<value name="AMOUNT">
<shadow type="math_number">
<field name="NUM">1</field>
</shadow>
</value>
</block>
</category>
<category name="Before Purchase" i18n-text="Before Purchase">
<block type="before_purchase"></block>
Expand Down