Skip to content

Commit

Permalink
fix: filter only spaces with at least 4 multisig members
Browse files Browse the repository at this point in the history
  • Loading branch information
pmespresso committed Apr 22, 2021
1 parent 65f47f0 commit 00c11e4
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions scripts/bulk_add.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ interface Space {
filters: any;
name: string;
network: string; // '1', '56', etc
members?: [];
symbol: string;
domain: string;
about: string;
Expand All @@ -19,7 +20,7 @@ function filterObject(obj: any, predicate: Function) {
let result: Record<string, any> = {};

for (let key in obj) {
if (obj.hasOwnProperty(key) && !predicate(obj[key])) {
if (obj.hasOwnProperty(key) && predicate(obj[key])) {
result[key] = obj[key];
}
}
Expand All @@ -38,13 +39,21 @@ async function fetchAllSpaces(): Promise<Record<string, Space>> {
async function fetchMainnetSpaces() {
const allSpaces = await fetchAllSpaces();

const filtered = filterObject(allSpaces, (space: Space) => space.network !== "1");
const filtered = filterObject(allSpaces, (space: Space) => space.network === "1");

return filtered;
}

fetchMainnetSpaces();
async function run() {
const allMainnetSpaces = await fetchMainnetSpaces();

// async function run() {
console.log(Object.keys(allMainnetSpaces).length);

// }
const withMembers = filterObject(allMainnetSpaces, (space: Space) => space.members && space.members.length > 4);

console.log(Object.keys(withMembers).length);

console.log(withMembers);
}

run();

0 comments on commit 00c11e4

Please sign in to comment.