Skip to content

Commit

Permalink
fix: patch buyer in sales done by third party providers
Browse files Browse the repository at this point in the history
  • Loading branch information
cazala committed Sep 16, 2024
1 parent 376ccdf commit 2539f74
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/modules/analytics/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Address, BigInt, Bytes, log } from '@graphprotocol/graph-ts'
import { Item, NFT, Sale, AnalyticsDayData, ItemsDayData } from '../../entities/schema'
import { ERC721 } from '../../entities/templates/ERC721/ERC721'
import { createOrLoadAccount, ZERO_ADDRESS } from '../account'
import {
buildCountFromEarnings,
Expand All @@ -17,6 +18,15 @@ import {
updateUniqueCollectorsSet
} from './accountsDayData'

// check if the buyer in a sale was a third party provider (to pay with credit card, cross chain, etc)
export function isThirdPartySale(buyer: string): boolean {
switch (buyer) {
case '0xed038688ecf1193f8d9717eb3930f0bf0d745cb4': // TRANSAK POLYGON
return true
}
return false
}

export let BID_SALE_TYPE = 'bid'
export let ORDER_SALE_TYPE = 'order'
export let MINT_SALE_TYPE = 'mint'
Expand Down Expand Up @@ -51,6 +61,12 @@ export function trackSale(
return
}

// check if the buyer is a third party and update it if so
if (isThirdPartySale(buyer.toHexString())) {
let erc721 = ERC721.bind(Address.fromString(nft.contractAddress))
buyer = erc721.ownerOf(nft.tokenId)
}

// save sale
let saleId = BigInt.fromI32(count.salesTotal).toString()
let sale = new Sale(saleId)
Expand Down

0 comments on commit 2539f74

Please sign in to comment.