From 1ea19ff870c243c4da24b08ea6c4567225330856 Mon Sep 17 00:00:00 2001 From: mixplore <9848598+mixplore@users.noreply.github.com> Date: Tue, 12 Nov 2024 18:32:04 +0200 Subject: [PATCH] chore: fix stack too deep compile error --- contracts/modules/viewer/NexusViewer.sol | 30 ++++++++++++------- .../assessment-and-nexus-viewer-deploy.js | 1 + 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/contracts/modules/viewer/NexusViewer.sol b/contracts/modules/viewer/NexusViewer.sol index 1c874134d0..536d941812 100644 --- a/contracts/modules/viewer/NexusViewer.sol +++ b/contracts/modules/viewer/NexusViewer.sol @@ -40,22 +40,30 @@ contract NexusViewer is INexusViewer, Multicall { // Assessment IAssessmentViewer.AssessmentRewards memory assessmentRewards = assessmentViewer.getRewards(member); - (uint assessmentStake, IAssessmentViewer.AssessmentStakeLockedState memory stakeLockedState) = _getAssessmentStake(member); + uint assessmentStakeValue = 0; + // Workaround for stack too deep error + { + (uint assessmentStake, IAssessmentViewer.AssessmentStakeLockedState memory stakeLockedState) = _getAssessmentStake(member); + assessmentStakeValue = stakeLockedState.isStakeLocked ? 0 : assessmentStake; + } // Staking Pool IStakingViewer.AggregatedTokens memory aggregatedTokens = stakingViewer.getAggregatedTokens(tokenIds); uint managerTotalRewards = stakingViewer.getManagerTotalRewards(member); - IStakingViewer.TokenPoolMap[] memory tokenPools = stakingViewer.getStakingPoolsOf(tokenIds); uint poolManagerNXMLockedForMV = 0; - // for each token, get the pool and manager - for (uint i = 0; i < tokenPools.length; i++) { - IStakingViewer.Pool memory pool = stakingViewer.getPool(tokenPools[i].poolId); - // check if pool manager is locked for MV - uint lockedForMV = nxm.isLockedForMV(pool.manager); - // get the latest date locked for MV - if (lockedForMV > 0 && lockedForMV > poolManagerNXMLockedForMV) { - poolManagerNXMLockedForMV = lockedForMV; + // Workaround for stack too deep error + { + IStakingViewer.TokenPoolMap[] memory tokenPools = stakingViewer.getStakingPoolsOf(tokenIds); + // for each token, get the pool and manager + for (uint i = 0; i < tokenPools.length; i++) { + IStakingViewer.Pool memory pool = stakingViewer.getPool(tokenPools[i].poolId); + // check if pool manager is locked for MV + uint lockedForMV = nxm.isLockedForMV(pool.manager); + // get the latest date locked for MV + if (lockedForMV > 0 && lockedForMV > poolManagerNXMLockedForMV) { + poolManagerNXMLockedForMV = lockedForMV; + } } } @@ -68,7 +76,7 @@ contract NexusViewer is INexusViewer, Multicall { return ClaimableNXM({ governanceRewards: governanceRewards, assessmentRewards: assessmentRewards.withdrawableAmountInNXM, - assessmentStake: stakeLockedState.isStakeLocked ? 0 : assessmentStake, + assessmentStake: assessmentStakeValue, stakingPoolTotalRewards: aggregatedTokens.totalRewards, stakingPoolTotalExpiredStake: aggregatedTokens.totalExpiredStake, stakingPoolManagerIsNXMLockedForMV: poolManagerNXMLockedForMV, diff --git a/scripts/deploy/assessment-and-nexus-viewer-deploy.js b/scripts/deploy/assessment-and-nexus-viewer-deploy.js index 28dc2916ee..a43cd471a5 100644 --- a/scripts/deploy/assessment-and-nexus-viewer-deploy.js +++ b/scripts/deploy/assessment-and-nexus-viewer-deploy.js @@ -19,6 +19,7 @@ const main = async () => { console.log('AssessmentViewer implementation address:', assessmentViewerImplementation.address); console.log('NexusViewer implementation address:', nexusViewerImplementation.address); + console.log('NexusViewer ABI', nexusViewerImplementation.interface.format(ethers.utils.FormatTypes.json)); }; main() .then(() => process.exit(0))