@ -8,12 +8,12 @@ import { createAsyncLoadStore, refreshPage } from '../lib/async_listing_load'
import Web3 from 'web3'
import Web3 from 'web3'
import { openPoolInfoModal } from './stakes/validator_info'
import { openPoolInfoModal } from './stakes/validator_info'
import { openDelegatorsListModal } from './stakes/delegators_list'
import { openDelegatorsListModal } from './stakes/delegators_list'
import { openBecomeCandidateModal } from './stakes/become_candidate'
import { openBecomeCandidateModal , becomeCandidateConnectionLost } from './stakes/become_candidate'
import { openRemovePoolModal } from './stakes/remove_pool'
import { openRemovePoolModal } from './stakes/remove_pool'
import { openMakeStakeModal } from './stakes/make_stake'
import { openMakeStakeModal } from './stakes/make_stake'
import { openMoveStakeModal } from './stakes/move_stake'
import { openMoveStakeModal } from './stakes/move_stake'
import { openWithdrawStakeModal } from './stakes/withdraw_stake'
import { openWithdrawStakeModal } from './stakes/withdraw_stake'
import { openClaimRewardModal , connectionLost } from './stakes/claim_reward'
import { openClaimRewardModal , claimRewardC onnectionLost } from './stakes/claim_reward'
import { openClaimWithdrawalModal } from './stakes/claim_withdrawal'
import { openClaimWithdrawalModal } from './stakes/claim_withdrawal'
import { checkForTokenDefinition } from './stakes/utils'
import { checkForTokenDefinition } from './stakes/utils'
import { currentModal , openWarningModal , openErrorModal } from '../lib/modals'
import { currentModal , openWarningModal , openErrorModal } from '../lib/modals'
@ -35,6 +35,7 @@ export const initialState = {
tokenDecimals : 0 ,
tokenDecimals : 0 ,
tokenSymbol : '' ,
tokenSymbol : '' ,
validatorSetApplyBlock : 0 ,
validatorSetApplyBlock : 0 ,
validatorSetContract : null ,
web3 : null
web3 : null
}
}
@ -99,6 +100,7 @@ export function reducer (state = initialState, action) {
return Object . assign ( { } , state , {
return Object . assign ( { } , state , {
stakingContract : action . stakingContract ,
stakingContract : action . stakingContract ,
blockRewardContract : action . blockRewardContract ,
blockRewardContract : action . blockRewardContract ,
validatorSetContract : action . validatorSetContract ,
tokenDecimals : action . tokenDecimals ,
tokenDecimals : action . tokenDecimals ,
tokenSymbol : action . tokenSymbol
tokenSymbol : action . tokenSymbol
} )
} )
@ -191,23 +193,27 @@ if ($stakesPage.length) {
} )
} )
} )
} )
channel . on ( 'contracts' , msg => {
channel . on ( 'contracts' , async ( msg ) => {
const web3 = store . getState ( ) . web3
const web3 = store . getState ( ) . web3
const stakingContract =
const stakingContract =
new web3 . eth . Contract ( msg . staking _contract . abi , msg . staking _contract . address )
new web3 . eth . Contract ( msg . staking _contract . abi , msg . staking _contract . address )
const blockRewardContract =
const blockRewardContract =
new web3 . eth . Contract ( msg . block _reward _contract . abi , msg . block _reward _contract . address )
new web3 . eth . Contract ( msg . block _reward _contract . abi , msg . block _reward _contract . address )
const validatorSetContract =
new web3 . eth . Contract ( msg . validator _set _contract . abi , msg . validator _set _contract . address )
store . dispatch ( {
store . dispatch ( {
type : 'RECEIVED_CONTRACTS' ,
type : 'RECEIVED_CONTRACTS' ,
stakingContract ,
stakingContract ,
blockRewardContract ,
blockRewardContract ,
validatorSetContract ,
tokenDecimals : parseInt ( msg . token _decimals , 10 ) ,
tokenDecimals : parseInt ( msg . token _decimals , 10 ) ,
tokenSymbol : msg . token _symbol
tokenSymbol : msg . token _symbol
} )
} )
} )
} )
channel . onError ( connectionLost )
channel . onError ( becomeCandidateConnectionLost )
channel . onError ( claimRewardConnectionLost )
$ ( document . body )
$ ( document . body )
. on ( 'click' , '.js-pool-info' , event => {
. on ( 'click' , '.js-pool-info' , event => {
@ -218,9 +224,9 @@ if ($stakesPage.length) {
. on ( 'click' , '.js-delegators-list' , event => {
. on ( 'click' , '.js-delegators-list' , event => {
openDelegatorsListModal ( event , store )
openDelegatorsListModal ( event , store )
} )
} )
. on ( 'click' , '.js-become-candidate' , ( ) => {
. on ( 'click' , '.js-become-candidate' , event => {
if ( checkForTokenDefinition ( store ) ) {
if ( checkForTokenDefinition ( store ) ) {
openBecomeCandidateModal ( store )
openBecomeCandidateModal ( event , store )
}
}
} )
} )
. on ( 'click' , '.js-remove-pool' , ( ) => {
. on ( 'click' , '.js-remove-pool' , ( ) => {