diff --git a/src/modules/analytics/index.ts b/src/modules/analytics/index.ts index b217b69..e3fca20 100644 --- a/src/modules/analytics/index.ts +++ b/src/modules/analytics/index.ts @@ -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, @@ -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' @@ -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)