Skip to content

Commit

Permalink
release constraints on derivedFrom array attributes (seller.royaltyRe…
Browse files Browse the repository at this point in the history
…cipients and conditionEntity.offers)
  • Loading branch information
levalleux-ludo committed Feb 29, 2024
1 parent 1c440f7 commit 47c1226
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
4 changes: 2 additions & 2 deletions packages/subgraph/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,7 @@ type Seller implements Account @entity {
logs: [EventLog!]! @derivedFrom(field: "account")
contractURI: String!
"Percentage as integer, to get decimals divide by 10000. E.g. 1 = 0.01%, 10000 = 100%"
royaltyRecipients: [RoyaltyRecipientEntity!]! @derivedFrom(field: "seller")
royaltyRecipients: [RoyaltyRecipientEntity!] @derivedFrom(field: "seller")
pendingSeller: PendingSeller @derivedFrom(field: "seller")
metadataUri: String!
metadata: SellerMetadata
Expand Down Expand Up @@ -921,7 +921,7 @@ type ConditionEntity @entity {
maxTokenId: BigInt!
threshold: BigInt!
maxCommits: BigInt!
offers: [Offer!]! @derivedFrom(field: "condition")
offers: [Offer!] @derivedFrom(field: "condition")
}

"""
Expand Down
10 changes: 8 additions & 2 deletions packages/subgraph/src/mappings/group-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,10 @@ export function handleGroupUpdatedEvent(event: GroupUpdated): void {
condition.threshold = conditionFromEvent.threshold;
condition.maxCommits = conditionFromEvent.maxCommits;
condition.save();
clearPreviousOffersCondition(condition.offers);
const previousOffers = condition.offers;
if (previousOffers) {
clearPreviousOffersCondition(previousOffers);
}
} else {
log.warning("Not found ConditionEntity with ID '{}'", [groupId.toString()]);
}
Expand Down Expand Up @@ -111,7 +114,10 @@ export function handleGroupUpdatedEventLegacy(event: GroupUpdatedLegacy): void {
condition.threshold = conditionFromEvent.threshold;
condition.maxCommits = conditionFromEvent.maxCommits;
condition.save();
clearPreviousOffersCondition(condition.offers);
const previousOffers = condition.offers;
if (previousOffers) {
clearPreviousOffersCondition(previousOffers);
}
} else {
log.warning("Not found ConditionEntity with ID '{}'", [groupId.toString()]);
}
Expand Down

0 comments on commit 47c1226

Please sign in to comment.