Skip to content
New issue

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

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

Already on GitHub? # to your account

Rupato/BOT-2621/fix: added default values to currency block #216

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Original file line number Diff line number Diff line change
Expand Up @@ -242,12 +242,14 @@ window.Blockly.Blocks.trade_definition_tradeoptions = {
const { currency, landing_company_shortcode } = DBotStore.instance.client;
if (isAuthorizing$.getValue()) return;
account_limits.getStakePayoutLimits(currency, landing_company_shortcode, this.selected_market).then(limits => {
if (!this.getField('AMOUNT_LIMITS')) {
return;
}
const unsupported_trade_types = ['multiplier', 'accumulator'];
if (unsupported_trade_types.includes(this.selected_trade_type)) return;
const currency_block = this.getField('CURRENCY_LIST')?.getSourceBlock();
const currency_child_block = currency_block?.getChildren()?.[1]?.getField('NUM');
if (!this.getField('AMOUNT_LIMITS') && !currency_block && !currency_child_block) return;
this.amount_limits = limits;
const { max_payout, min_stake } = limits;
if (max_payout && min_stake && this.selected_trade_type !== 'multiplier') {
if (max_payout && min_stake) {
runIrreversibleEvents(() => {
this.setFieldValue(
localize('(min: {{min_stake}} - max: {{max_payout}})', {
Expand All @@ -257,6 +259,9 @@ window.Blockly.Blocks.trade_definition_tradeoptions = {
'AMOUNT_LIMITS'
);
});
if (currency_block && currency_child_block) {
currency_child_block.setValue(this.amount_limits?.min_stake);
}
}
});
},
Expand Down
Loading