@@ -12,7 +12,6 @@ import useExtensionData from '~hooks/useExtensionData.ts';
1212import { type ClaimMotionRewardsPayload } from '~redux/sagas/motions/claimMotionRewards.ts' ;
1313import { type MotionFinalizePayload } from '~redux/types/actions/motion.ts' ;
1414import Numeral from '~shared/Numeral/index.ts' ;
15- import { type InstalledExtensionData } from '~types/extensions.ts' ;
1615import { type MotionAction } from '~types/motions.ts' ;
1716import { mapPayload } from '~utils/actions.ts' ;
1817import { getIsMotionOlderThanAWeek } from '~utils/dates.ts' ;
@@ -66,13 +65,17 @@ export const useFinalizeStep = (actionData: MotionAction) => {
6665 const isFinalizable =
6766 hasEnoughFundsToFinalize && ! motionStateHistory . hasFailedNotFinalizable ;
6867
69- const transform = mapPayload (
70- ( ) : MotionFinalizePayload => ( {
71- colonyAddress,
72- userAddress : user ?. walletAddress || '' ,
73- motionId,
74- canMotionFail : isMotionOlderThanWeek ,
75- } ) ,
68+ const transform = useMemo (
69+ ( ) =>
70+ mapPayload (
71+ ( ) : MotionFinalizePayload => ( {
72+ colonyAddress,
73+ userAddress : user ?. walletAddress || '' ,
74+ motionId,
75+ canMotionFail : isMotionOlderThanWeek ,
76+ } ) ,
77+ ) ,
78+ [ colonyAddress , isMotionOlderThanWeek , motionId , user ?. walletAddress ] ,
7679 ) ;
7780
7881 return {
@@ -102,13 +105,11 @@ export const useClaimConfig = (
102105 const {
103106 colony : { colonyAddress, nativeToken, motionsWithUnclaimedStakes } ,
104107 } = useColonyContext ( ) ;
105- const extension = useExtensionData ( Extension . VotingReputation ) ;
108+ const { extensionData } = useExtensionData ( Extension . VotingReputation ) ;
106109 const { pollLockedTokenBalance } = useUserTokenBalanceContext ( ) ;
107110
108111 const [ isClaimed , setIsClaimed ] = useState ( false ) ;
109112
110- const extensionData = extension ?. extensionData as InstalledExtensionData ;
111-
112113 const userAddress = user ?. walletAddress ;
113114 const nativeTokenDecimals = nativeToken . decimals ;
114115 const nativeTokenSymbol = ` ${ nativeToken . symbol } ` ;
@@ -202,15 +203,20 @@ export const useClaimConfig = (
202203 pollLockedTokenBalance ( ) ;
203204 } ;
204205
205- const claimPayload = mapPayload (
206- ( ) : ClaimMotionRewardsPayload => ( {
207- userAddress : userAddress || '' ,
208- colonyAddress : colonyAddress || '' ,
209- transactionHash : transactionHash || '' ,
210- extensionAddress : isInstalledExtensionData ( extensionData )
211- ? extensionData . address
212- : ADDRESS_ZERO ,
213- } ) ,
206+ const claimPayload = useMemo (
207+ ( ) =>
208+ mapPayload (
209+ ( ) : ClaimMotionRewardsPayload => ( {
210+ userAddress : userAddress || '' ,
211+ colonyAddress : colonyAddress || '' ,
212+ transactionHash : transactionHash || '' ,
213+ extensionAddress :
214+ extensionData && isInstalledExtensionData ( extensionData )
215+ ? extensionData . address
216+ : ADDRESS_ZERO ,
217+ } ) ,
218+ ) ,
219+ [ userAddress , colonyAddress , transactionHash , extensionData ] ,
214220 ) ;
215221
216222 const getDescriptionItems = ( ) : DescriptionListItem [ ] => {
0 commit comments