1- import { $web3 } from 'boot/api' ;
2- import { DappCombinedInfo } from 'src/v2/models/DappsStaking' ;
31import { ethers } from 'ethers' ;
42import { useAccount , useBalance , useNetworkInfo } from 'src/hooks' ;
53import { StakingData } from 'src/modules/dapp-staking/index' ;
64import { getTokenImage } from 'src/modules/token' ;
75import { useStore } from 'src/store' ;
8- import { computed , ref , watchEffect } from 'vue' ;
6+ import { DappCombinedInfo } from 'src/v2/models/DappsStaking' ;
7+ import { computed , ref , watch } from 'vue' ;
98
109export function useStakingList ( ) {
11- const { currentAccount } = useAccount ( ) ;
12- const { accountData } = useBalance ( currentAccount ) ;
10+ const { senderSs58Account } = useAccount ( ) ;
11+ const { accountData } = useBalance ( senderSs58Account ) ;
1312 const { nativeTokenSymbol } = useNetworkInfo ( ) ;
1413 const store = useStore ( ) ;
1514 const isLoading = computed ( ( ) => store . getters [ 'general/isLoading' ] ) ;
1615 const dapps = computed < DappCombinedInfo [ ] > ( ( ) => store . getters [ 'dapps/getAllDapps' ] ) ;
17- const isH160 = computed ( ( ) => store . getters [ 'general/isH160Formatted' ] ) ;
1816 const nativeTokenImg = computed < string > ( ( ) =>
1917 getTokenImage ( { isNativeToken : true , symbol : nativeTokenSymbol . value } )
2018 ) ;
@@ -31,8 +29,8 @@ export function useStakingList() {
3129 const setStakingList = async ( ) : Promise < void > => {
3230 const dappsRef = dapps . value ;
3331 const accountDataRef = accountData . value ;
34- const currentAccountRef = currentAccount . value ;
35- if ( ! accountDataRef || ! currentAccountRef ) return ;
32+ const senderSs58AccountRef = senderSs58Account . value ;
33+ if ( ! accountDataRef || ! senderSs58AccountRef ) return ;
3634 try {
3735 const data = dappsRef . map ( ( it ) => {
3836 const accountStakingAmount = it . stakerInfo . accountStakingAmount ;
@@ -48,12 +46,9 @@ export function useStakingList() {
4846 }
4947 } ) ;
5048
51- const balance = isH160 . value
52- ? await $web3 . value ! . eth . getBalance ( currentAccount . value )
53- : accountDataRef . getUsableFeeBalance ( ) . toString ( ) ;
54-
49+ const balance = accountDataRef . getUsableFeeBalance ( ) . toString ( ) ;
5550 data . unshift ( {
56- address : currentAccountRef ,
51+ address : senderSs58AccountRef ,
5752 name : 'Transferable Balance' ,
5853 balance,
5954 iconUrl : nativeTokenImg . value ,
@@ -65,8 +60,8 @@ export function useStakingList() {
6560 }
6661 } ;
6762
68- watchEffect ( async ( ) => {
69- if ( isLoading . value || ! dapps . value ) {
63+ watch ( [ isLoading , senderSs58Account , accountData ] , async ( ) => {
64+ if ( isLoading . value || ! dapps . value || ! senderSs58Account . value ) {
7065 return ;
7166 }
7267 await setStakingList ( ) ;
0 commit comments