Skip to content

Commit

Permalink
UIA register - fix get_free_poller
Browse files Browse the repository at this point in the history
  • Loading branch information
1aerostorm committed Apr 15, 2024
1 parent 32a90f1 commit 92acbb1
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 3 deletions.
4 changes: 3 additions & 1 deletion db/reg_pollers.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
fiber = require 'fiber'
decimal = require 'decimal'

function reg_pollers_migration_v1()
if box.space.reg_pollers ~= nil then
Expand Down Expand Up @@ -43,6 +44,7 @@ local function wrap_rp(rp)
end

function get_free_reg_poller(amount, sym, step, now)
amount = decimal.new(amount) -- fix "1.1 + 0.1 ~= 1.2" problem
local rps = nil
repeat
if rps ~= nil then
Expand All @@ -55,7 +57,7 @@ function get_free_reg_poller(amount, sym, step, now)
end
rps = box.space.reg_pollers.index.by_amount:select{sym, amount}
until #rps == 0
return amount
return tostring(amount)
end

local function clean_reg_pollers(now)
Expand Down
1 change: 1 addition & 0 deletions src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@
"min_amount": "Minimal amount is ",
"enter_amount": "Exact amount, which will be transferred by gate: ",
"slot_is_used": "Try another amount.",
"eg": " E.g.: ",
"fee": "Fee",
"memo_fixed": "Memo",
"to": "Send tokens to address/account",
Expand Down
1 change: 1 addition & 0 deletions src/locales/ru-RU.json
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@
"min_amount": "Минимальная сумма - ",
"enter_amount": "Точная сумма, которую вы отправите шлюзу: ",
"slot_is_used": "Введите другую сумму.",
"eg": " Например: ",
"fee": "Комиссия",
"memo_fixed": "Заметка/memo",
"to": "Отправьте токены на адрес/аккаунт",
Expand Down
6 changes: 5 additions & 1 deletion src/modules/register/UIARegister.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -494,18 +494,22 @@ class UIARegister extends React.Component {

_onAmountSubmit = async (values) => {
const waitAmount = values.amount.asset
let freeAmount
try {
let fp = await callApi('/api/reg/get_free_poller/' + waitAmount.toString())
fp = await fp.json()
if (fp.status !== 'ok') {
throw new Error(fp.error || 'Unknown error')
}
if (fp.amount !== waitAmount.toString()) {
freeAmount = parseFloat(fp.amount)
throw new Error('Slot is used')
}
} catch (err) {
this.setState({
amountSubmitError: err.message === 'Slot is used' ? tt('uia_register_jsx.slot_is_used') : err.message
amountSubmitError: err.message === 'Slot is used' ?
tt('uia_register_jsx.slot_is_used') + (freeAmount ? (tt('uia_register_jsx.eg') + freeAmount + '.') : '' )
: err.message
})
return
}
Expand Down
1 change: 0 additions & 1 deletion src/pages/api/reg/[...all].js
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,6 @@ let handler = nextConnect({ attachParams: true, })
error = tt('uia_register_jsx.cannot_check_orders') + exAmount.symbol + '/' + sym2
}
if (error) break
console.log(exAmount.toString(), sym2, JSON.stringify(resEx))
if (resEx.remain) {
error = tt('uia_register_jsx.too_low_orders') + exAmount.symbol + '/' + sym2 + tt('uia_register_jsx.cannot_register_with_it')
break
Expand Down

0 comments on commit 92acbb1

Please sign in to comment.