Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/add keys from range #37

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions programs/common/curated-module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,31 @@ export const addCuratedModuleSubCommands = (command: Command, contract: Contract
await authorizedCall(contract, 'addSigningKeys', [operatorId, count, publicKeys, signatures]);
});

command
.command('add-keys-from-range')
.description('Adds signing keys from a deposit data file for a specified range')
.argument('<operator-id>', 'Node operator ID')
.argument('<file-path>', 'Path to the file containing deposit data')
.argument('<start-index>', 'Start index of the key range (inclusive)')
.argument('<end-index>', 'End index of the key range (exclusive)')
.action(async (operatorId, filePath, startIndex, endIndex) => {
// eslint-disable-next-line @typescript-eslint/no-var-requires
const depositData: DepositData[] = require(filePath);
// Validate and slice the array to get only the specified range
if (startIndex < 0 || endIndex > depositData.length || startIndex >= endIndex) {
throw new Error('Invalid start or end index');
}
const selectedDepositData = depositData.slice(startIndex, endIndex);

await supplementAndVerifyDepositDataArray(selectedDepositData);

const count = selectedDepositData.length;
const publicKeys = joinHex(selectedDepositData.map(({ pubkey }) => pubkey));
const signatures = joinHex(selectedDepositData.map(({ signature }) => signature));

await authorizedCall(contract, 'addSigningKeys', [operatorId, count, publicKeys, signatures]);
});

command
.command('remove-keys')
.description('removes signing keys')
Expand Down