From 0ddf2804c68100459f69f9af00e65cc9d3a3ba20 Mon Sep 17 00:00:00 2001 From: yuetloo Date: Wed, 10 Jul 2024 16:37:39 -0400 Subject: [PATCH] get recipient data statically if subgraph is not available --- .../src/api/recipient-registry-optimistic.ts | 48 ++++++++++++++++++- ...F08B7DD31fE0267e8c70C4bF8C4BfbBddE760.json | 2 +- 2 files changed, 47 insertions(+), 3 deletions(-) diff --git a/vue-app/src/api/recipient-registry-optimistic.ts b/vue-app/src/api/recipient-registry-optimistic.ts index 478761432..d09f1dafb 100644 --- a/vue-app/src/api/recipient-registry-optimistic.ts +++ b/vue-app/src/api/recipient-registry-optimistic.ts @@ -1,7 +1,7 @@ import { Contract, toNumber, isHexString, ContractTransactionResponse } from 'ethers' import type { TransactionResponse, Signer } from 'ethers' import { DateTime } from 'luxon' -import { chain } from '@/api/core' +import { chain, clrFundContract } from '@/api/core' import { OptimisticRecipientRegistry } from './abi' import { provider, ipfsGatewayUrl } from './core' @@ -11,6 +11,8 @@ import type { GetProjectQuery, GetRecipientsQuery, Recipient } from '@/graphql/A import { hasDateElapsed } from '@/utils/dates' import type { RegistryInfo, RecipientApplicationData } from './types' import { formToRecipientData } from './recipient' +import { isSameAddress } from '@/utils/accounts' +import { getLeaderboardData } from './leaderboard' async function getRegistryInfo(registryAddress: string): Promise { const registry = new Contract(registryAddress, OptimisticRecipientRegistry, provider) @@ -129,6 +131,48 @@ function mapRequestStatus(request: RecipientRequestData): RequestStatus { return status } +/** + * Try to get the recipients from the static round data + * @param registryAddress The recipient registry address + * @returns The recipient application requests + */ +async function tryGetRecipientsStatically(registryAddress: string): Promise { + let requests: Request[] = [] + + try { + const fundingRoundAddress = await clrFundContract.getCurrentRound() + const fundingRoundInfo = await getLeaderboardData(fundingRoundAddress) + if (isSameAddress(fundingRoundInfo?.round?.recipientRegistryAddress, registryAddress)) { + if (fundingRoundInfo?.projects) { + requests = fundingRoundInfo.projects.map(project => { + let metadata = project.metadata + try { + if (typeof metadata === 'string') { + metadata = JSON.parse(project.metadata || '{}') + } + } catch (e) { + metadata = { name: project.name } + } + return { + transactionHash: '', // transaction hash not available in the static data + type: RequestType.Registration, + status: project.state as RequestStatus, + acceptanceDate: DateTime.fromISO(project.createdAt), + recipientId: project.id, + recipient: project.recipientAddress, + metadata, + requester: project.requester, + } + }) + } + } + } catch { + requests = [] + } + + return requests +} + export async function getRequests(registryInfo: RegistryInfo, registryAddress: string): Promise { let data: GetRecipientsQuery try { @@ -136,7 +180,7 @@ export async function getRequests(registryInfo: RegistryInfo, registryAddress: s registryAddress: registryAddress.toLowerCase(), }) } catch { - return [] + return tryGetRecipientsStatically(registryAddress) } if (!data.recipients.length) { diff --git a/vue-app/src/rounds/arbitrum/0x806F08B7DD31fE0267e8c70C4bF8C4BfbBddE760.json b/vue-app/src/rounds/arbitrum/0x806F08B7DD31fE0267e8c70C4bF8C4BfbBddE760.json index 662adbfd6..341a7a713 100644 --- a/vue-app/src/rounds/arbitrum/0x806F08B7DD31fE0267e8c70C4bF8C4BfbBddE760.json +++ b/vue-app/src/rounds/arbitrum/0x806F08B7DD31fE0267e8c70C4bF8C4BfbBddE760.json @@ -2372,7 +2372,7 @@ "state": "Removed", "recipientAddress": "0x361f732EbA09Fb99fd38B650E90a4AC6D9cc63c3", "requester": "0x7246E313daDAF4083dF2d8132801f1bFCad53aeB", - "name": "?", + "name": "Protobox.xyz", "metadata": "{\"name\":\"Protobox.xyz\" \"tagline\":\"Unlock the Power of Decentralized Storage: Seamlessly Connect. Be Unstoppable.\n\" \"description\":\"Protobox is a suite of tools that enables organizations utilizing centralized object storage such as Amazon S3 or its many variants to easily migrate to decentralized storage options such as Ethereum Swarm. Protobox enables users to connect via the S3 compatible storage connector that is standard in most applications. Protobox also provides simple management and payment of storage pools that is simple to use even for non Web3 natives. \" \"category\":\"Tooling\" \"problemSpace\":\"Current decentralized storage protocols are not user friendly to non Web3 natives and are not plug and play with existing storage connectors. \n\nObject storage alone is a $4.83 billion dollar market with a compound annual growth of 13.6%. All of which currently resides with a handful of companies in centralized locations. Additionally data stored by these providers can be removed at will if it no longer is expedient for the provider to carry it. Censorship can and is carried out as a common function not by the push of a button but by an algorithm that is often a black box. \n\n\nFinally the monopoly created by these three companies allows them to charge exorbitant prices for their services despite offering little to now innovation year over year. \n\nIf decentralized storage protocols can tap into this market it would not only provide a superior product to users at a fraction of the cost but also demonstrate a very clear use case for an industry that has taken more than a couple black eyes over the past two years. \n\nRecent talk at Ethereum Swarm Summit: https://summit.ethswarm.org/swarm-summit-2023/talk/DUAQZ7/\" \"plans\":\"1) Complete our S3 API implementation to enable all standard functionality specifically for private buckets. \n2) Launch additional infrastructure (Swarm bee nodes Gnosis mainnet validators edge caching nodes) to enable the network to handle the most complex work loads such as high definition video recording and playback on a global scale. \n\n3) Create a comprehensive web dashboard for users to manage purchase and manipulate their storage from a familiar GUI/UX. \n4) Enable fiat onramp and wallet-less payments to enable non-Web3 users to utilize all functionality without any interaction with new technology such as tokens or 0x wallets.\n5) Create a data migration tool to enable current centralized storage users to easily copy data to the desired decentralized option for migration or use in parallel.\n6) Public outreach - present the project at relevant conferences hold hackathons and workshops onboard large public good datasets free of charge - forever.\n7) Continue to work to ensure product meets requirements set forth by community projects building integrations such as Livepeer and others.\" \"teamName\":\"\" \"teamDescription\":\"Samuel Lauridsen\nThe firm’s founder draws upon over 15 years of prior experience designing deploying and managing mission-critical infrastructure for Silicon Valley’s leading tech companies including Apple Intel Facebook Equinix and Tesla. In addition to his work in Northern California he has 6+ years of experience working at one of the largest media conglomerates in the world including one of the “big five” motion picture studios. Currently based in Los Angeles this connection to the art world brings unique opportunities for collaboration to the project team.\n\n\nHannah Lauridsen\nHannah is a co-founder of Huntington Analytics. Her experience spans several industries and includes eight years as a small business owner; 10+ years of visual design/multimedia freelance; and three years in education. Core components of these roles have combined in Hannah’s current data visualization position. She is passionate about projects and tools that empower others to obtain equitable access to information and opportunities.\n\nIoseb Khutsishvili\nIoseb is a co-founder of MaxinAI. He has 20+ years of experience in developing core back-end applications and managing teams of 150+ software engineers. MaxinAI has piloted its transition to blockchain under Ioseb’s technical leadership. \n\nDavid Khosroshvili\nDavid is a serial entrepreneur Forbes Georgia 30/30 award winner and decentralization evangelist. He has built multiple technology companies during the last 10 years that currently employ over 120 talents in the blockchain and data science industries. David is a CEO and a founding member of MaxinAI.\n\" \"githubUrl\":\"https://github.com/Protobox-xyz\" \"radicleUrl\":\"\" \"websiteUrl\":\"https://www.protobox.xyz\" \"twitterUrl\":\"https://twitter.com/protobox_xyz\" \"discordUrl\":\"https://discord.gg/4wyqeypmm\" \"bannerImageHash\":\"QmXkEJ7WBmWk78qmj1nYqPSnNfXxCNbs7p3umwJwNEdJe6\" \"thumbnailImageHash\":\"QmPzuETqY9v9BQNTESqePYq15E7XYA676uMegYRrthEcSz\"}", "createdAt": "2023-07-12T03:52:00.000Z", "removedAt": "2023-07-12T15:29:08.000Z",