3
3
4
4
import { _ChainAsset , _ChainInfo } from '@subwallet/chain-list/types' ;
5
5
import { ApiMap , ServiceInfo } from '@subwallet/extension-base/background/KoniTypes' ;
6
- import { CRON_REFRESH_NFT_INTERVAL , CRON_SYNC_MANTA_PAY } from '@subwallet/extension-base/constants' ;
6
+ import { CRON_REFRESH_CHAIN_STAKING_METADATA , CRON_REFRESH_NFT_INTERVAL , CRON_SYNC_MANTA_PAY } from '@subwallet/extension-base/constants' ;
7
7
import { KoniSubscription } from '@subwallet/extension-base/koni/background/subscription' ;
8
8
import { _isChainSupportEvmNft , _isChainSupportNativeNft , _isChainSupportWasmNft } from '@subwallet/extension-base/services/chain-service/utils' ;
9
9
import { EventItem , EventType } from '@subwallet/extension-base/services/event-service/types' ;
@@ -129,6 +129,12 @@ export class KoniCron {
129
129
( commonReload || needUpdateNft ) && this . removeCron ( 'refreshNft' ) ;
130
130
commonReload && this . removeCron ( 'refreshPoolingStakingReward' ) ;
131
131
132
+ if ( chainUpdated ) {
133
+ this . stopPoolInfo ( ) ;
134
+ this . removeCron ( 'fetchPoolInfo' ) ;
135
+ this . addCron ( 'fetchPoolInfo' , this . fetchPoolInfo , CRON_REFRESH_CHAIN_STAKING_METADATA ) ;
136
+ }
137
+
132
138
// Chains
133
139
if ( this . checkNetworkAvailable ( serviceInfo ) ) { // only add cron jobs if there's at least 1 active network
134
140
( commonReload || needUpdateNft ) && this . addCron ( 'refreshNft' , this . refreshNft ( address , serviceInfo . chainApiMap , this . state . getSmartContractNfts ( ) , this . state . getActiveChainInfoMap ( ) ) , CRON_REFRESH_NFT_INTERVAL ) ;
@@ -138,6 +144,8 @@ export class KoniCron {
138
144
139
145
this . state . eventService . onLazy ( this . eventHandler ) ;
140
146
147
+ this . addCron ( 'fetchPoolInfo' , this . fetchPoolInfo , CRON_REFRESH_CHAIN_STAKING_METADATA ) ;
148
+
141
149
if ( ! currentAccountInfo ?. address ) {
142
150
return ;
143
151
}
@@ -169,6 +177,7 @@ export class KoniCron {
169
177
}
170
178
171
179
this . removeAllCrons ( ) ;
180
+ this . stopPoolInfo ( ) ;
172
181
173
182
this . status = 'stopped' ;
174
183
@@ -181,6 +190,14 @@ export class KoniCron {
181
190
}
182
191
} ;
183
192
193
+ fetchPoolInfo = ( ) => {
194
+ this . state . earningService . runSubscribePoolsInfo ( ) . catch ( console . error ) ;
195
+ } ;
196
+
197
+ stopPoolInfo = ( ) => {
198
+ this . state . earningService . runUnsubscribePoolsInfo ( ) ;
199
+ } ;
200
+
184
201
refreshNft = ( address : string , apiMap : ApiMap , smartContractNfts : _ChainAsset [ ] , chainInfoMap : Record < string , _ChainInfo > ) => {
185
202
return ( ) => {
186
203
this . subscriptions . subscribeNft ( address , apiMap . substrate , apiMap . evm , smartContractNfts , chainInfoMap ) ;
0 commit comments