Skip to content

Commit

Permalink
Merge pull request #22 from lidofinance/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
avsetsin committed Feb 8, 2024
2 parents a0899e6 + d1fdcf0 commit e347e65
Show file tree
Hide file tree
Showing 12 changed files with 108 additions and 11 deletions.
1 change: 1 addition & 0 deletions programs/accounting-consensus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { addAccessControlSubCommands, addConsensusCommands, addLogsCommands, add

const oracle = program
.command('accounting-consensus')
.aliases(['ao-consensus'])
.description('interact with hash consensus contract for accounting oracle');
addAccessControlSubCommands(oracle, consensusForAccountingContract);
addParsingCommands(oracle, consensusForAccountingContract);
Expand Down
5 changes: 4 additions & 1 deletion programs/accounting-oracle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ import {
} from './common';
import { logger } from '@utils';

const oracle = program.command('accounting-oracle').description('interact with accounting oracle contract');
const oracle = program
.command('accounting-oracle')
.aliases(['ao'])
.description('interact with accounting oracle contract');
addAccessControlSubCommands(oracle, accountingOracleContract);
addBaseOracleCommands(oracle, accountingOracleContract);
addOssifiableProxyCommands(oracle, accountingOracleContract);
Expand Down
30 changes: 30 additions & 0 deletions programs/common/consensus.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { authorizedCall, getLatestBlock, getProvider, logger } from '@utils';
import chalk from 'chalk';
import { Command } from 'commander';
import { Contract, EventLog, formatEther } from 'ethers';
import prompts from 'prompts';

export const addConsensusCommands = (command: Command, contract: Contract) => {
command
Expand Down Expand Up @@ -60,6 +62,20 @@ export const addConsensusCommands = (command: Command, contract: Contract) => {
.option('-q, --quorum <string>', 'quorum')
.action(async (options) => {
const { address, quorum } = options;
const { confirm } = await prompts({
type: 'confirm',
name: 'confirm',
message: chalk.red(
'This change will affect the operation of Ejector. Are all operators ready for this change?',
),
initial: false,
});

if (!confirm) {
logger.error('Aborted');
return;
}

await authorizedCall(contract, 'addMember', [address, quorum]);
});

Expand All @@ -70,6 +86,20 @@ export const addConsensusCommands = (command: Command, contract: Contract) => {
.option('-q, --quorum <string>', 'quorum')
.action(async (options) => {
const { address, quorum } = options;
const { confirm } = await prompts({
type: 'confirm',
name: 'confirm',
message: chalk.red(
'This change will affect the operation of Ejector. Are all operators ready for this change?',
),
initial: false,
});

if (!confirm) {
logger.error('Aborted');
return;
}

await authorizedCall(contract, 'removeMember', [address, quorum]);
});

Expand Down
34 changes: 31 additions & 3 deletions programs/common/curated-module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,34 @@ export const addCuratedModuleSubCommands = (command: Command, contract: Contract
.description('returns operators count')
.action(async () => {
const total = await contract.getNodeOperatorsCount();
logger.log('Total', total);
logger.log('Total', Number(total));
});

command
.command('operator-list')
.description('returns list of operators')
.action(async () => {
const total = await contract.getNodeOperatorsCount();
const operatorIds = new Array(Number(total)).fill(0).map((_, index) => index);

const result = await Promise.all(
operatorIds.map(async (operatorId) => {
const operator = await contract.getNodeOperator(operatorId, true);
const parsed = operator.toObject();

return {
active: parsed.active,
name: parsed.name,
rewardAddress: parsed.rewardAddress,
vetted: parsed.totalVettedValidators,
exited: parsed.totalExitedValidators,
deposited: parsed.totalDepositedValidators,
total: parsed.totalAddedValidators,
};
}),
);

logger.table(result);
});

command
Expand Down Expand Up @@ -211,9 +238,10 @@ export const addCuratedModuleSubCommands = (command: Command, contract: Contract
);

const filteredResult = result.filter((v) => v);
const sortedResult = filteredResult.sort((a, b) => Number(a?.operatorId) - Number(b?.operatorId));

if (filteredResult.length) {
logger.table(filteredResult);
if (sortedResult.length) {
logger.table(sortedResult);
} else {
logger.log('No manager addresses');
}
Expand Down
1 change: 1 addition & 0 deletions programs/exit-bus-consensus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { addAccessControlSubCommands, addConsensusCommands, addLogsCommands, add

const oracle = program
.command('exit-bus-consensus')
.aliases(['vebo-consensus'])
.description('interact with hash consensus contract for validator exit bus oracle');
addAccessControlSubCommands(oracle, consensusForExitBusContract);
addParsingCommands(oracle, consensusForExitBusContract);
Expand Down
5 changes: 4 additions & 1 deletion programs/exit-bus-oracle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@ export type LidoValidator = {
signingKey: KAPIKey;
};

const oracle = program.command('exit-bus-oracle').description('interact with validator exit bus oracle contract');
const oracle = program
.command('exit-bus-oracle')
.aliases(['vebo'])
.description('interact with validator exit bus oracle contract');
addAccessControlSubCommands(oracle, exitBusOracleContract);
addBaseOracleCommands(oracle, exitBusOracleContract);
addOssifiableProxyCommands(oracle, exitBusOracleContract);
Expand Down
2 changes: 1 addition & 1 deletion programs/lido.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { resumeLidoAndSetStakingLimit, votingForward } from '@scripts';
import { addAragonAppSubCommands, addLogsCommands, addParsingCommands } from './common';
import { addERC20Commands } from './common/erc20';

const lido = program.command('lido').description('interact with lido contract');
const lido = program.command('lido').aliases(['steth']).description('interact with lido contract');
addAragonAppSubCommands(lido, lidoContract);
addParsingCommands(lido, lidoContract);
addLogsCommands(lido, lidoContract);
Expand Down
5 changes: 4 additions & 1 deletion programs/nor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ import { program } from '@command';
import { norContract } from '@contracts';
import { addAragonAppSubCommands, addCuratedModuleSubCommands, addLogsCommands, addParsingCommands } from './common';

const nor = program.command('nor').description('interact with node operator registry contract');
const nor = program
.command('nor')
.aliases(['curated', 'curated-module'])
.description('interact with node operator registry contract');
addAragonAppSubCommands(nor, norContract);
addParsingCommands(nor, norContract);
addLogsCommands(nor, norContract);
Expand Down
5 changes: 4 additions & 1 deletion programs/sandbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ import { program } from '@command';
import { sandboxContract } from '@contracts';
import { addAragonAppSubCommands, addCuratedModuleSubCommands, addLogsCommands, addParsingCommands } from './common';

const sandbox = program.command('sandbox').description('interact with simple dvt module contract');
const sandbox = program
.command('sandbox')
.aliases(['sandbox-module'])
.description('interact with simple dvt module contract');
addAragonAppSubCommands(sandbox, sandboxContract);
addParsingCommands(sandbox, sandboxContract);
addLogsCommands(sandbox, sandboxContract);
Expand Down
5 changes: 4 additions & 1 deletion programs/simple-dvt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ import { provider } from '@providers';
import { Contract } from 'ethers';
import { logger } from '@utils';

const simpleDVT = program.command('simple-dvt').description('interact with simple dvt module contract');
const simpleDVT = program
.command('simple-dvt')
.aliases(['sdvt', 'sdvt-module'])
.description('interact with simple dvt module contract');
addAragonAppSubCommands(simpleDVT, simpleDVTContract);
addParsingCommands(simpleDVT, simpleDVTContract);
addLogsCommands(simpleDVT, simpleDVTContract);
Expand Down
21 changes: 20 additions & 1 deletion programs/staking-router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ import { Result, parseEther } from 'ethers';
import { addAccessControlSubCommands, addLogsCommands, addOssifiableProxyCommands, addParsingCommands } from './common';
import { getNodeOperators, getStakingModules } from './staking-module';

const router = program.command('staking-router').description('interact with staking router contract');
const router = program
.command('staking-router')
.aliases(['sr', 'router'])
.description('interact with staking router contract');
addAccessControlSubCommands(router, stakingRouterContract);
addOssifiableProxyCommands(router, stakingRouterContract);
addParsingCommands(router, stakingRouterContract);
Expand Down Expand Up @@ -91,6 +94,22 @@ router
logger.log('Module paused', isPaused);
});

router
.command('pause-module')
.description('pause deposits for staking module')
.argument('<module-id>', 'module id')
.action(async (moduleId) => {
await authorizedCall(stakingRouterContract, 'pauseStakingModule', [moduleId]);
});

router
.command('resume-module')
.description('resume deposits for staking module')
.argument('<module-id>', 'module id')
.action(async (moduleId) => {
await authorizedCall(stakingRouterContract, 'resumeStakingModule', [moduleId]);
});

router
.command('last-deposit-block')
.description('returns last deposit block for module')
Expand Down
5 changes: 4 additions & 1 deletion programs/withdrawal-request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ import {
} from './common';
import { contractCallTxWithConfirm, logger } from '@utils';

const withdrawal = program.command('withdrawal-request').description('interact with withdrawal request contract');
const withdrawal = program
.command('withdrawal-request')
.aliases(['wq', 'withdrawal-queue'])
.description('interact with withdrawal request contract');
addAccessControlSubCommands(withdrawal, withdrawalRequestContract);
addOssifiableProxyCommands(withdrawal, withdrawalRequestContract);
addParsingCommands(withdrawal, withdrawalRequestContract);
Expand Down

0 comments on commit e347e65

Please sign in to comment.