Skip to content

Commit

Permalink
Merge pull request #109 from decentraland/fix/transak-buyer
Browse files Browse the repository at this point in the history
fix: patch buyer in sales done by third party providers
  • Loading branch information
cazala authored Sep 17, 2024
2 parents 376ccdf + de8eac1 commit abe5bc3
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 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,14 @@ 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 {
if (buyer == '0xed038688ecf1193f8d9717eb3930f0bf0d745cb4' || buyer == '0xea749fd6ba492dbc14c24fe8a3d08769229b896c') {
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 +60,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 abe5bc3

Please sign in to comment.