Skip to content

Commit

Permalink
add UpdateExpiration activity
Browse files Browse the repository at this point in the history
  • Loading branch information
psparacino committed Feb 7, 2024
1 parent 3ec7ca2 commit 146bcee
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
1 change: 1 addition & 0 deletions carbonmark/schema.graphql
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
enum ActivityType {
UpdatedQuantity
UpdatedPrice
UpdatedExpiration
Purchase
Sold
CreatedListing
Expand Down
24 changes: 23 additions & 1 deletion carbonmark/src/Carbonmark.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,32 @@ export function handleListingUpdated(event: ListingUpdated): void {
activity.previousPrice = event.params.oldUnitPrice
activity.timeStamp = event.block.timestamp
activity.seller = listing.seller
activity.save()
}
if (
event.params.oldAmount == event.params.newAmount &&
event.params.oldUnitPrice == event.params.newUnitPrice &&
event.params.oldDeadline != event.params.newDeadline
) {
if (activity.seller != ZERO_ADDRESS) {
activity = loadOrCreateActivity(event.transaction.hash.toHexString().concat('ListingUpdated2'))
}

listing.singleUnitPrice = event.params.newUnitPrice
listing.updatedAt = event.block.timestamp
listing.expiration = event.params.newDeadline

activity.activityType = 'UpdatedExpiration'
activity.project = listing.project
activity.user = event.transaction.from
activity.price = event.params.newUnitPrice
activity.previousPrice = event.params.oldUnitPrice
activity.timeStamp = event.block.timestamp
activity.seller = listing.seller
activity.save()
}

listing.save()
activity.save()
}

export function handleListingFilled(event: ListingFilled): void {
Expand Down

0 comments on commit 146bcee

Please sign in to comment.