Skip to content

Commit

Permalink
UIA registration way
Browse files Browse the repository at this point in the history
  • Loading branch information
1aerostorm committed Oct 28, 2023
1 parent 1c0c23e commit 9877e3f
Show file tree
Hide file tree
Showing 15 changed files with 888 additions and 9 deletions.
3 changes: 2 additions & 1 deletion config/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
"add_to_fee": "1.000 GOLOS",
"signing_key": "5K67PNheLkmxkgJ5UjvR8Nyt3GVPoLEN1dMZjFuNETzrNyMecPG",
"delegation": "75000.000000 GESTS",
"free_regs_per_day": 10
"free_regs_per_day": 10,
"uias": ["YMUSDT", "YMPZM", "YMHIVE"]
},
"server_session_secret": "exiKdyF+IwRIXJDmtGIl4vWUz4i3eVSISpfZoeYc0s4=",
"session_cookie_key": "X-Reg-ISession",
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"passport-yandex": "^0.0.5",
"querystring": "^0.2.1",
"react": "^17.0.2",
"react-copy-to-clipboard": "^5.1.0",
"react-dom": "^17.0.2",
"react-foundation-components": "git+https://github.com/golos-blockchain/react-foundation-components.git#5dbfb800aff45988c57bb7d09c1c235a8b49b418",
"react-google-recaptcha": "^2.1.0",
Expand Down
1 change: 1 addition & 0 deletions src/App.scss
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
@import "./modules/LoginForm";
@import "./modules/PendingTx";
@import "./modules/PermissionsList";
@import "./modules/register/UIARegister";

@import "./pages/_common";
@import "./pages/index";
Expand Down
9 changes: 9 additions & 0 deletions src/elements/register/VerifyWayTabs.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,21 @@ class VerifyWayTabs extends React.Component {
transfer = <Link href={path + '?transfer'}>{transfer}</Link>
}

let uia = tt('verify_way_tabs_jsx.with_uia')
if (currentWay === 'uia') {
uia = <span>{uia}</span>
} else {
uia = <Link href={path + '?uia'}>{uia}</Link>
}

return <div style={{ marginBottom: '1.0rem' }}>
{social}
&nbsp;|&nbsp;
{invite}
&nbsp;|&nbsp;
{transfer}
&nbsp;|&nbsp;
{uia}
</div>
}
}
Expand Down
18 changes: 15 additions & 3 deletions src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,18 @@
"cannot_reset": "Unfortunately, something went wrong. We cannot set your password. But everything is under control - it is your temporary key. Save it, and contact us: ",
"unload_warning": "Do you saved the key? Or you want to cancel registration? If transfer already sent, there are no refund possible."
},
"uia_register_jsx": {
"select_uia": "Choose cryptocurrencу",
"register_with": "Register with...",
"no_such_asset": " - no such UIA.",
"deposit_unavailable": " - deposit temporarily unavailable.",
"min_amount": "Min amount",
"fee": "Fee",
"memo_fixed": "Memo",
"to": "Send tokens to address/account",
"api_error": "Cannot get address. Try again later. If problem still occurs, contact the issuer of ",
"api_error_details": "and send the error details:"
},
"invites_jsx": {
"claim_wrong_secret": "Wrong secret",
"claim_wrong_secret_fatal": "No such invite check",
Expand Down Expand Up @@ -239,8 +251,7 @@
"worker_request_vote": "Voting for worker requests",
"proposal_create": "Creating transaction proposals",
"proposal_delete": "Removing transaction proposals",
"proposal_update": "Voting in transaction proposals",
"proposal_update_active": "Voting in transaction proposals with active authorities"
"proposal_update": "Voting in transaction proposals"
},
"recovery": {
"change_title": "Change recovery account",
Expand Down Expand Up @@ -311,7 +322,8 @@
"verify_way_tabs_jsx": {
"social": "Social",
"invite_code": "Invite-code",
"transfer": "Transfer"
"transfer": "Transfer",
"with_uia": "With cryptocurrencies"
},
"g": {
"APP_NAME": "Golos",
Expand Down
18 changes: 15 additions & 3 deletions src/locales/ru-RU.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,18 @@
"cannot_reset": "К сожалению, случилась какая-то ошибка и мы не смогли установить пароль. Но все под контролем - вот ваш временный ключ. Сохраните его и обратитесь к нам за помощью: ",
"unload_warning": "Вы точно сохранили ключ, или вы хотите отменить регистрацию? Если перевод уже сделан, то автоматического возврата средств не будет."
},
"uia_register_jsx": {
"select_uia": "Выберите криптовалюту",
"register_with": "Регистрация с помощью...",
"no_such_asset": " - такого UIA не существует.",
"deposit_unavailable": " - депозит временно недоступен.",
"min_amount": "Минимальная сумма",
"fee": "Комиссия",
"memo_fixed": "Заметка/memo",
"to": "Отправьте токены на адрес/аккаунт",
"api_error": "Не удается получить адрес. Попробуйте позднее. Если проблема сохраняется, свяжитесь с эмитентом ",
"api_error_details": "и сообщите подробности ошибки:"
},
"invites_jsx": {
"claim_wrong_secret": "Неверно указан ключ",
"claim_wrong_secret_fatal": "Такого чека нет",
Expand Down Expand Up @@ -239,8 +251,7 @@
"worker_request_vote": "Голосование за заявки на работу (воркеры)",
"proposal_create": "Создание пропозалов",
"proposal_delete": "Удаление пропозалов",
"proposal_update": "Голосование в пропозалах",
"proposal_update_active": "Голосование в пропозалах с активным ключом"
"proposal_update": "Голосование в пропозалах"
},
"recovery": {
"change_title": "Задать аккаунт для восстановления",
Expand Down Expand Up @@ -311,7 +322,8 @@
"verify_way_tabs_jsx": {
"social": "Соцсети",
"invite_code": "Инвайт-код",
"transfer": "Перевод с биржи"
"transfer": "Перевод с биржи",
"with_uia": "С помощью криптовалюты"
},
"g": {
"APP_NAME": "Голос",
Expand Down
100 changes: 100 additions & 0 deletions src/modules/register/TransferWaiter.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
import React from 'react'
import tt from 'counterpart'
import { Asset } from 'golos-lib-js/lib/utils';

import LoadingIndicator from '@/elements/LoadingIndicator'
import { callApi, } from '@/utils/RegApiClient'

class TransferWaiter extends React.Component {
state = {
}

constructor(props) {
super(props)
}

poll = async (sym) => {
const retry = async () => {
await new Promise(resolve => setTimeout(resolve, 1000))
if (!this.state.stopped)
this.poll(sym)
}
try {
let res = await callApi('/api/reg/wait_for_transfer/' + sym)
res = await res.json()
if (res.status === 'ok') {
const { onTransfer } = this.props
onTransfer(Asset(res.delta))
} else {
console.error(res)
await retry()
}
} catch (err) {
console.error('TransferWaiter', err)
await retry()
}
}

start = async () => {
this.setState({
seconds: 30*60,
stopped: false
})

this.countdown = setInterval(() => {
const { seconds } = this.state
if (seconds === 0) {
console.log('Countdown reached, stop.')
this.stop()
return
}
this.setState({
seconds: seconds - 1
})
}, 1000)

const { sym, } = this.props

this.poll(sym)
}

componentDidMount() {
this.start()
}

stop = () => {
if (this.countdown) clearInterval(this.countdown)
this.setState({
stopped: true
})
}

componentWillUnmount() {
this.stop()
}

componentDidUpdate(prevProps) {
if (this.props.sym !== prevProps.sym) {
this.stop()
this.start()
}
}

render() {
const { seconds } = this.state
if (!seconds) return null
const min = Math.floor(seconds / 60)
const sec = seconds % 60
const remaining = min.toString().padStart(2, '0') + ':' + sec.toString().padStart(2, '0')
const { sym, title } = this.props
return <div align="center" style={{ marginTop: '1rem', }}>
{title}
<div style={{ marginTop: '0.5rem', }}>
<LoadingIndicator type='dots' />
{remaining}
</div>
</div>
}
}

export default TransferWaiter
Loading

0 comments on commit 9877e3f

Please sign in to comment.