mirror of
https://github.com/Instadapp/boardroom-inc-protocol-Info.git
synced 2024-07-29 22:37:02 +00:00
fix: filter only spaces with at least 4 multisig members
This commit is contained in:
parent
65f47f0317
commit
00c11e4365
|
@ -8,6 +8,7 @@ interface Space {
|
||||||
filters: any;
|
filters: any;
|
||||||
name: string;
|
name: string;
|
||||||
network: string; // '1', '56', etc
|
network: string; // '1', '56', etc
|
||||||
|
members?: [];
|
||||||
symbol: string;
|
symbol: string;
|
||||||
domain: string;
|
domain: string;
|
||||||
about: string;
|
about: string;
|
||||||
|
@ -19,7 +20,7 @@ function filterObject(obj: any, predicate: Function) {
|
||||||
let result: Record<string, any> = {};
|
let result: Record<string, any> = {};
|
||||||
|
|
||||||
for (let key in obj) {
|
for (let key in obj) {
|
||||||
if (obj.hasOwnProperty(key) && !predicate(obj[key])) {
|
if (obj.hasOwnProperty(key) && predicate(obj[key])) {
|
||||||
result[key] = obj[key];
|
result[key] = obj[key];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -38,13 +39,21 @@ async function fetchAllSpaces(): Promise<Record<string, Space>> {
|
||||||
async function fetchMainnetSpaces() {
|
async function fetchMainnetSpaces() {
|
||||||
const allSpaces = await fetchAllSpaces();
|
const allSpaces = await fetchAllSpaces();
|
||||||
|
|
||||||
const filtered = filterObject(allSpaces, (space: Space) => space.network !== "1");
|
const filtered = filterObject(allSpaces, (space: Space) => space.network === "1");
|
||||||
|
|
||||||
return filtered;
|
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();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user