|
|
@ -16,6 +16,8 @@ import { openWithdrawStakeModal } from './stakes/withdraw_stake' |
|
|
|
import { openClaimWithdrawalModal } from './stakes/claim_withdrawal' |
|
|
|
import { openClaimWithdrawalModal } from './stakes/claim_withdrawal' |
|
|
|
import { openWarningModal } from '../lib/modals' |
|
|
|
import { openWarningModal } from '../lib/modals' |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const stakesPageSelector = '[data-page="stakes"]' |
|
|
|
|
|
|
|
|
|
|
|
export const initialState = { |
|
|
|
export const initialState = { |
|
|
|
account: null, |
|
|
|
account: null, |
|
|
|
blockRewardContract: null, |
|
|
|
blockRewardContract: null, |
|
|
@ -87,11 +89,26 @@ export function reducer (state = initialState, action) { |
|
|
|
tokenSymbol: action.tokenSymbol |
|
|
|
tokenSymbol: action.tokenSymbol |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
case 'FINISH_REQUEST': { |
|
|
|
|
|
|
|
$(stakesPageSelector).fadeTo(0, 1) |
|
|
|
|
|
|
|
return state |
|
|
|
|
|
|
|
} |
|
|
|
default: |
|
|
|
default: |
|
|
|
return state |
|
|
|
return state |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function reloadPoolList(msg, store) { |
|
|
|
|
|
|
|
store.dispatch({ |
|
|
|
|
|
|
|
type: 'RECEIVED_UPDATE', |
|
|
|
|
|
|
|
lastBlockNumber: msg.block_number, |
|
|
|
|
|
|
|
lastEpochNumber: msg.epoch_number, |
|
|
|
|
|
|
|
stakingAllowed: msg.staking_allowed, |
|
|
|
|
|
|
|
validatorSetApplyBlock: msg.validator_set_apply_block |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
refreshPage(store) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const elements = { |
|
|
|
const elements = { |
|
|
|
'[data-page="stakes"]': { |
|
|
|
'[data-page="stakes"]': { |
|
|
|
load ($el) { |
|
|
|
load ($el) { |
|
|
@ -106,7 +123,7 @@ const elements = { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const $stakesPage = $('[data-page="stakes"]') |
|
|
|
const $stakesPage = $(stakesPageSelector) |
|
|
|
const $stakesTop = $('[data-selector="stakes-top"]') |
|
|
|
const $stakesTop = $('[data-selector="stakes-top"]') |
|
|
|
if ($stakesPage.length) { |
|
|
|
if ($stakesPage.length) { |
|
|
|
const store = createAsyncLoadStore(reducer, initialState, 'dataset.identifierPool') |
|
|
|
const store = createAsyncLoadStore(reducer, initialState, 'dataset.identifierPool') |
|
|
@ -115,6 +132,8 @@ if ($stakesPage.length) { |
|
|
|
const channel = subscribeChannel('stakes:staking_update') |
|
|
|
const channel = subscribeChannel('stakes:staking_update') |
|
|
|
store.dispatch({ type: 'CHANNEL_CONNECTED', channel }) |
|
|
|
store.dispatch({ type: 'CHANNEL_CONNECTED', channel }) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const $refreshInformer = $('.refresh-informer', $stakesPage) |
|
|
|
|
|
|
|
|
|
|
|
channel.on('staking_update', msg => { |
|
|
|
channel.on('staking_update', msg => { |
|
|
|
// hide tooltip on tooltip triggering element reloading
|
|
|
|
// hide tooltip on tooltip triggering element reloading
|
|
|
|
// due to issues with bootstrap tooltips https://github.com/twbs/bootstrap/issues/13133
|
|
|
|
// due to issues with bootstrap tooltips https://github.com/twbs/bootstrap/issues/13133
|
|
|
@ -129,21 +148,34 @@ if ($stakesPage.length) { |
|
|
|
$stakesPage.find('[pool-filter-my]').prop('checked', false); |
|
|
|
$stakesPage.find('[pool-filter-my]').prop('checked', false); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let lastBlockNumber = state.lastBlockNumber |
|
|
|
|
|
|
|
|
|
|
|
if ( |
|
|
|
if ( |
|
|
|
msg.staking_allowed !== state.stakingAllowed || |
|
|
|
msg.staking_allowed !== state.stakingAllowed || |
|
|
|
msg.epoch_number > state.lastEpochNumber || |
|
|
|
msg.epoch_number > state.lastEpochNumber || |
|
|
|
msg.validator_set_apply_block != state.validatorSetApplyBlock || |
|
|
|
msg.validator_set_apply_block != state.validatorSetApplyBlock || |
|
|
|
(state.refreshInterval && msg.block_number >= state.lastBlockNumber + state.refreshInterval) |
|
|
|
(state.refreshInterval && msg.block_number >= state.lastBlockNumber + state.refreshInterval) |
|
|
|
) { |
|
|
|
) { |
|
|
|
store.dispatch({ |
|
|
|
reloadPoolList(msg, store) |
|
|
|
type: 'RECEIVED_UPDATE', |
|
|
|
lastBlockNumber = msg.block_number |
|
|
|
lastBlockNumber: msg.block_number, |
|
|
|
|
|
|
|
lastEpochNumber: msg.epoch_number, |
|
|
|
|
|
|
|
stakingAllowed: msg.staking_allowed, |
|
|
|
|
|
|
|
validatorSetApplyBlock: msg.validator_set_apply_block |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
refreshPage(store) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const refreshGap = msg.block_number - lastBlockNumber |
|
|
|
|
|
|
|
$refreshInformer.find('span').html(refreshGap) |
|
|
|
|
|
|
|
if (refreshGap > 0) { |
|
|
|
|
|
|
|
$refreshInformer.show() |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
$refreshInformer.hide() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const $refreshInformerLink = $refreshInformer.find('a') |
|
|
|
|
|
|
|
$refreshInformerLink.off('click') |
|
|
|
|
|
|
|
$refreshInformerLink.on('click', (event) => { |
|
|
|
|
|
|
|
event.preventDefault() |
|
|
|
|
|
|
|
$refreshInformer.hide() |
|
|
|
|
|
|
|
$stakesPage.fadeTo(0, 0.5) |
|
|
|
|
|
|
|
reloadPoolList(msg, store) |
|
|
|
|
|
|
|
}) |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
channel.on('contracts', msg => { |
|
|
|
channel.on('contracts', msg => { |
|
|
|