@@ -33,6 +33,9 @@ import {
3333 BALANCE_LIST_FETCH_SUCCESS ,
3434 BALANCE_LIST_FETCH_ERROR ,
3535 SHIELDED_BALANCE_PROGRESS_SET ,
36+ FETCH_SHIELDED_REWARDS_IN_PROGRESS ,
37+ FETCH_SHIELDED_REWARDS_SUCCESS ,
38+ FETCH_SHIELDED_REWARDS_ERROR ,
3639} from '../../constants/accounts' ;
3740import Axios from 'axios' ;
3841import { urlFetchRevealedPubkey , urlFetchRewards , urlFetchUnBondingDelegations , urlFetchVestingBalance , urlFetchBlockHeight , urlFetchTokensList , urlFetchBalanceList } from '../../constants/url' ;
@@ -45,6 +48,7 @@ import { config } from '../../config';
4548import { getSdk } from '@namada/sdk/web' ;
4649import init from '@namada/sdk/web-init' ;
4750import { workerShieldedSync } from 'workers/balanceServices' ;
51+ import { fetchShieldedRewards } from 'workers/services' ;
4852// import { Tokens } from '@namada/types';
4953
5054export const setAccountAddress = ( value , shieldedAddress , shieldedDetails ) => {
@@ -661,3 +665,44 @@ export const reSyncBalance = (viewingKey, timestamp, tnam, znam, chainId = confi
661665 }
662666 }
663667} ;
668+
669+
670+ const shieldedRewardsFetchInProgress = ( ) => ( {
671+ type : FETCH_SHIELDED_REWARDS_IN_PROGRESS ,
672+ } ) ;
673+
674+ const shieldedRewardsFetchSuccess = ( value ) => ( {
675+ type : FETCH_SHIELDED_REWARDS_SUCCESS ,
676+ value,
677+ } ) ;
678+
679+ const shieldedRewardsFetchError = ( error ) => ( {
680+ type : FETCH_SHIELDED_REWARDS_ERROR ,
681+ message : error || 'Failed to fetch shielded Rewards' ,
682+ } ) ;
683+
684+
685+ export const getShieldedRewards = ( viewingKey , chainId = config . CHAIN_ID , cb ) => async ( dispatch ) => {
686+ dispatch ( shieldedRewardsFetchInProgress ( ) ) ;
687+ try {
688+ const rewards = await fetchShieldedRewards (
689+ viewingKey ,
690+ chainId ,
691+ config . RPC_URL ,
692+ ) ;
693+ dispatch ( shieldedRewardsFetchSuccess ( rewards ) ) ;
694+ if ( cb ) {
695+ cb ( rewards ) ;
696+ }
697+ } catch ( error ) {
698+ console . error ( '❌ Shielded rewards error:' , {
699+ message : error . message || 'Unknown error' ,
700+ error,
701+ chainId,
702+ } ) ;
703+ dispatch ( shieldedRewardsFetchError ( error . message || 'Unknown error' ) ) ;
704+ if ( cb ) {
705+ cb ( null ) ;
706+ }
707+ }
708+ } ;
0 commit comments