diff --git a/subgraph/src/OptimisticRecipientRegistryMapping.ts b/subgraph/src/OptimisticRecipientRegistryMapping.ts index f02ba444b..506cc9c83 100644 --- a/subgraph/src/OptimisticRecipientRegistryMapping.ts +++ b/subgraph/src/OptimisticRecipientRegistryMapping.ts @@ -57,17 +57,36 @@ export function handleRequestSubmitted(event: RequestSubmitted): void { //TODO: create RecipientRegistry entity here if it does not exist. let recipientId = event.params._recipientId.toHexString() - let recipient = new Recipient(recipientId) - recipient.recipientRegistry = recipientRegistryId - recipient.recipientAddress = event.params._recipient - recipient.requestType = BigInt.fromI32(event.params._type).toString() - recipient.requester = event.transaction.from.toHexString() - recipient.submissionTime = event.params._timestamp.toString() - recipient.deposit = event.transaction.value - recipient.recipientMetadata = event.params._metadata - recipient.verified = false - recipient.requestSubmittedHash = event.transaction.hash + if (event.params._type == 0) { + // add recipient request + let recipient = new Recipient(recipientId) + recipient.recipientRegistry = recipientRegistryId + recipient.recipientAddress = event.params._recipient + recipient.requester = event.transaction.from.toHexString() + recipient.deposit = event.transaction.value + recipient.recipientMetadata = event.params._metadata - recipient.save() + // requestSubmittedHash stores the transaction hash for add recipient request + // the UI uses it to look up the newly added recipient record + recipient.requestSubmittedHash = event.transaction.hash + recipient.requestType = BigInt.fromI32(event.params._type).toString() + recipient.submissionTime = event.params._timestamp.toString() + recipient.verified = false + recipient.save() + } else { + // deleteRecipient request + // no need to update metadata and recipient address as they are not available for delete requests + let recipient = Recipient.load(recipientId) + if (recipient == null) { + // this should not happen, record the transaction hash for troubleshooting + recipient = new Recipient(recipientId) + recipient.requestSubmittedHash = event.transaction.hash + } + recipient.recipientRegistry = recipientRegistryId + recipient.requestType = BigInt.fromI32(event.params._type).toString() + recipient.submissionTime = event.params._timestamp.toString() + recipient.verified = false + recipient.save() + } } diff --git a/vue-app/src/api/recipient-registry-optimistic.ts b/vue-app/src/api/recipient-registry-optimistic.ts index a2493568b..6550092cf 100644 --- a/vue-app/src/api/recipient-registry-optimistic.ts +++ b/vue-app/src/api/recipient-registry-optimistic.ts @@ -52,6 +52,7 @@ export enum RequestStatus { Accepted = 'Accepted', Rejected = 'Rejected', Executed = 'Live', + PendingRemoval = 'Pending removal', Removed = 'Removed', } @@ -131,6 +132,10 @@ export async function getRequests(registryInfo: RegistryInfo, registryAddress: s if (recipient.verified) { request.status = requestType === RequestTypeCode.Removal ? RequestStatus.Removed : RequestStatus.Executed + } else { + if (requestType === RequestTypeCode.Removal) { + request.status = RequestStatus.PendingRemoval + } } // In case there are two requests submissions events, we always prioritize @@ -255,6 +260,9 @@ export async function getProjects(registryAddress: string, startTime?: number, e // Disallow contributions to removed recipient, but don't hide it project.isLocked = true } + } else { + // project is not removed yet, keep the index so that it can still receive contributions + project.index = recipient.recipientIndex } } @@ -309,9 +317,14 @@ export async function getProject(recipientId: string, filter = true): Promise -
+