Skip to content

Commit

Permalink
chore: simplify adding and removing addresses to highPrioritySendersList
Browse files Browse the repository at this point in the history
  • Loading branch information
rabi-siddique committed Sep 27, 2024
1 parent bedea83 commit d94c352
Showing 1 changed file with 15 additions and 26 deletions.
41 changes: 15 additions & 26 deletions packages/inter-protocol/src/proposals/replaceElectorate.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
// @ts-check
import { E } from '@endo/eventual-send';
import { reserveThenDeposit } from './utils.js';

Check failure on line 3 in packages/inter-protocol/src/proposals/replaceElectorate.js

View workflow job for this annotation

GitHub Actions / lint-primary

Expected 1 empty line after import statement not followed by another import
import { makeStorageNodeChild } from '@agoric/internal/src/lib-chainStorage.js';
const { Fail } = assert;

const runConfig = {
committeeName: 'Economic Committee',
economicCommitteeAddresses: {
voterAddresses: {
gov1: 'agoric1ee9hr0jyrxhy999y755mp862ljgycmwyp4pl7q',
},
economicCommitteeAddressesToRemove: {
gov1: 'agoric1wrfh296eu2z34p6pah7q04jjuyj3mxu9v98277',
highPrioritySendersConfig: {
addressesToAdd: [],
addressesToRemove: ['agoric1wrfh296eu2z34p6pah7q04jjuyj3mxu9v98277'],
},
};

Expand Down Expand Up @@ -46,28 +46,18 @@ const handlehighPrioritySendersList = async ({
throw Error('highPrioritySendersManager is not defined');
}

const { economicCommitteeAddresses, economicCommitteeAddressesToRemove } =
runConfig;
const { addressesToAdd, addressesToRemove } =
runConfig.highPrioritySendersConfig;

const addSet = new Set(Object.values(economicCommitteeAddresses));
const removeSet = new Set(Object.values(economicCommitteeAddressesToRemove));

const uniqueAddAddresses = Array.from(addSet).filter(
address => !removeSet.has(address),
);
const uniqueRemoveAddresses = Array.from(removeSet).filter(
address => !addSet.has(address),
);

for (let addr of uniqueAddAddresses) {
for (let addr of addressesToAdd) {

Check failure on line 52 in packages/inter-protocol/src/proposals/replaceElectorate.js

View workflow job for this annotation

GitHub Actions / lint-primary

'addr' is never reassigned. Use 'const' instead
trace(`Adding ${addr} to High Priority Senders list`);
await E(highPrioritySendersManager).add(
HIGH_PRIORITY_SENDERS_NAMESPACE,
addr,
);
}

for (let addr of uniqueRemoveAddresses) {
for (let addr of addressesToRemove) {

Check failure on line 60 in packages/inter-protocol/src/proposals/replaceElectorate.js

View workflow job for this annotation

GitHub Actions / lint-primary

'addr' is never reassigned. Use 'const' instead
trace(`Removing ${addr} from High Priority Senders list`);
await E(highPrioritySendersManager).remove(
HIGH_PRIORITY_SENDERS_NAMESPACE,
Expand Down Expand Up @@ -122,14 +112,13 @@ const startNewEconomicCommittee = async ({
trace('startNewEconomicCommittee');

const { committeeName } = runConfig;
const committeeSize = Object.values(
runConfig.economicCommitteeAddresses,
).length;
trace(`committeeName ${committeeName}`);

const committeeSize = values(runConfig.voterAddresses).length;
trace(`committeeSize ${committeeSize}`);

const committeesNode = await E(chainStorage).makeChildNode(COMMITTEES_ROOT);

const committeesNode = await makeStorageNodeChild(
chainStorage,
COMMITTEES_ROOT,
);
const storageNode = await E(committeesNode).makeChildNode(
sanitizePathSegment(committeeName),
);
Expand Down Expand Up @@ -184,7 +173,7 @@ export const replaceElectorate = async permittedPowers => {

await inviteECMembers(permittedPowers, {
options: {
voterAddresses: runConfig.economicCommitteeAddresses,
voterAddresses: runConfig.voterAddresses,
},
});

Expand Down

0 comments on commit d94c352

Please sign in to comment.