From 11d363bf5c5de45aa71bca329bbd0dc11f96dae9 Mon Sep 17 00:00:00 2001 From: yj Date: Thu, 22 Apr 2021 14:23:19 -0500 Subject: [PATCH] loosely fetch token address --- scripts/bulk_add.ts | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/scripts/bulk_add.ts b/scripts/bulk_add.ts index 3642b50..7b4f812 100644 --- a/scripts/bulk_add.ts +++ b/scripts/bulk_add.ts @@ -44,16 +44,32 @@ async function fetchMainnetSpaces() { return filtered; } +function extractTokenAddress(space: Space): string | null { + const strategyWithAddress = space.strategies.find((strategy) => strategy.name === "erc20-balance-of"); + + if (strategyWithAddress) { + return strategyWithAddress.params.address; + } else { + return null; + } +} + async function run() { const allMainnetSpaces = await fetchMainnetSpaces(); - console.log(Object.keys(allMainnetSpaces).length); + // 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(Object.keys(withMembers).length); - console.log(withMembers); + for (let i = 0; i < Object.keys(withMembers).length; i++) { + const key = Object.keys(withMembers)[i]; + + const tokenAddress = extractTokenAddress(withMembers[key]); + + console.log(tokenAddress); + } } run();