44 conetDepinProvider ,
55 conetProvider ,
66 ethProvider ,
7- solanaRpc ,
87} from "../utils/constants" ;
98import {
109 CoNET_Data ,
@@ -14,21 +13,19 @@ import {
1413} from "../utils/globals" ;
1514import contracts from "../utils/contracts" ;
1615import { initProfileTokens } from "../utils/utils" ;
17- import { checkCurrentRate } from ' ../services/passportPurchase'
16+ import { checkCurrentRate } from " ../services/passportPurchase" ;
1817import {
1918 getPassportsInfoForProfile ,
2019 getVpnTimeUsed ,
2120 storeSystemData ,
2221} from "./wallets" ;
23- import { Connection , PublicKey } from "@solana/web3.js" ;
24- import { TOKEN_PROGRAM_ID } from "@solana/spl-token" ;
22+ import { PublicKey } from "@solana/web3.js" ;
2523
2624let epoch = 0 ;
2725
2826const listenProfileVer = async (
2927 _setProfiles : ( profiles : profile [ ] ) => void ,
3028 _setActivePassport : ( profiles : freePassport ) => void ,
31- _updateCurrentPassport : ( ) => Promise < void > ,
3229 setMiningData : ( response : nodeResponse ) => void
3330) => {
3431 epoch = await conetProvider . getBlockNumber ( ) ;
@@ -39,39 +36,34 @@ const listenProfileVer = async (
3936
4037 if ( processingBlock === true ) return ;
4138
42- if ( block % 10 === 0 ) {
43- setProcessingBlock ( true ) ;
39+ const profiles = CoNET_Data ?. profiles ;
4440
45- const profiles = CoNET_Data ?. profiles ;
46- if ( ! profiles ) {
47- return ;
48- }
49- const runningList : any [ ] = [ ] ;
41+ if ( ! profiles ) {
42+ return ;
43+ }
5044
51- runningList . push ( getProfileAssets ( profiles [ 0 ] , profiles [ 1 ] ) ) ;
45+ setProcessingBlock ( true ) ;
5246
53- await Promise . all ( runningList ) ;
54- // get rate update
55- checkCurrentRate ( setMiningData ) ;
47+ if ( block % 10 === 0 ) {
48+ await getProfileAssets ( profiles [ 0 ] , profiles [ 1 ] ) ;
49+ checkCurrentRate ( setMiningData ) ;
5650 await getVpnTimeUsed ( ) ;
51+ }
5752
53+ if ( block % 2 === 0 ) {
5854 await getPassportsInfoForProfile ( profiles [ 0 ] ) ;
55+ }
5956
60- if ( CoNET_Data ?. profiles && CoNET_Data ?. profiles . length > 0 ) {
61- _setProfiles ( CoNET_Data ?. profiles ) ;
62-
63- if ( CoNET_Data . profiles [ 0 ] . activePassport )
64- _setActivePassport ( CoNET_Data . profiles [ 0 ] . activePassport ) ;
65- }
66-
67- storeSystemData ( ) ;
57+ if ( CoNET_Data ?. profiles && CoNET_Data ?. profiles . length > 0 ) {
58+ _setProfiles ( CoNET_Data ?. profiles ) ;
6859
69- setProcessingBlock ( false ) ;
60+ if ( CoNET_Data . profiles [ 0 ] . activePassport )
61+ _setActivePassport ( CoNET_Data . profiles [ 0 ] . activePassport ) ;
7062 }
7163
72- if ( block % 2 === 0 ) {
73- await _updateCurrentPassport ( ) ;
74- }
64+ storeSystemData ( ) ;
65+
66+ setProcessingBlock ( false ) ;
7567 }
7668 } ) ;
7769
@@ -87,14 +79,13 @@ const getProfileAssets = async (profile: profile, solanaProfile: profile) => {
8779 profile . tokens = initProfileTokens ( ) ;
8880 }
8981
90- const [ cCNTP , conet , conetDepin , conet_eth , eth ] =
91- await Promise . all ( [
92- scanCCNTP ( key ) ,
93- scanCONETHolesky ( key ) ,
94- scanCONETDepin ( key ) ,
95- scanConetETH ( key ) ,
96- scanETH ( key )
97- ] ) ;
82+ const [ cCNTP , conet , conetDepin , conet_eth , eth ] = await Promise . all ( [
83+ scanCCNTP ( key ) ,
84+ scanCONETHolesky ( key ) ,
85+ scanCONETDepin ( key ) ,
86+ scanConetETH ( key ) ,
87+ scanETH ( key ) ,
88+ ] ) ;
9889
9990 if ( profile . tokens ?. cCNTP ) {
10091 profile . tokens . cCNTP . balance =
@@ -262,7 +253,11 @@ const scanSolanaSol = async (walletAddr: string, randomSolanaRPC: string) => {
262253} ;
263254
264255const scanSolanaSp = async ( walletAddr : string , solanaRPC_url : string ) => {
265- return await scan_spl_balance ( walletAddr , contracts . PassportSolana . address , solanaRPC_url ) ;
256+ return await scan_spl_balance (
257+ walletAddr ,
258+ contracts . PassportSolana . address ,
259+ solanaRPC_url
260+ ) ;
266261} ;
267262
268263const scan_erc20_balance : (
@@ -297,7 +292,11 @@ const scan_natural_balance = async (walletAddr: string, provider: any) => {
297292 }
298293} ;
299294
300- const scan_spl_balance = async ( walletAddr : string , tokenAddress : string , solanaRPC_url : string ) => {
295+ const scan_spl_balance = async (
296+ walletAddr : string ,
297+ tokenAddress : string ,
298+ solanaRPC_url : string
299+ ) => {
301300 try {
302301 const TOKEN_PROGRAM_ID = "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" ; // Solana SPL Token Program ID
303302
0 commit comments