Skip to content

Commit 6d732c5

Browse files
committed
feat: add role validation and logging in consolidation write logic
1 parent 1ef16c2 commit 6d732c5

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

features/vault-operations/vault-roles.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,8 @@ export const checkVaultRole = async (
107107

108108
if (!hasRole) {
109109
throw new Error(`Address ${address} does not have the ${roleName} role`);
110+
} else {
111+
logInfo(`✅ Address ${address} has the ${roleName} role`);
110112
}
111113

112114
return hasRole;

programs/use-cases/consolidation/write.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ import {
1414
consolidateAndIncreaseFeeExemptionWithoutBatching,
1515
consolidationRequestsAndIncreaseFeeExemption,
1616
} from 'features/consolidation.js';
17+
import { checkVaultRole } from 'features';
18+
import { getAccount } from 'providers';
1719
import {
1820
checkPubkeysArgs,
1921
validateConsolidationInput,
@@ -26,6 +28,7 @@ import {
2628
removeInactiveValidators,
2729
} from 'utils';
2830
import { PubkeyMap } from 'utils/consolidation/types.js';
31+
import { getDashboardContract } from 'contracts';
2932

3033
export const consolidationWrite = consolidation
3134
.command('write')
@@ -82,6 +85,16 @@ consolidationWrite
8285
);
8386
validateConsolidationInput(sourcePubkeys, targetPubkeys, dashboard);
8487

88+
const [account, dashboardContract] = await Promise.all([
89+
getAccount(),
90+
getDashboardContract(dashboard),
91+
]);
92+
await checkVaultRole(
93+
dashboardContract,
94+
'NODE_OPERATOR_FEE_EXEMPT_ROLE',
95+
account.address,
96+
);
97+
8598
const { sourceValidatorsInfo, targetValidatorsInfo } =
8699
await getValidatorsInfo(sourcePubkeys, targetPubkeys);
87100
const targetAndSourceValidators = getTargetAndSourceValidatorsInfo(

0 commit comments

Comments
 (0)