empty args

This commit is contained in:
trizin 2024-07-22 16:55:35 +03:00 committed by GitHub
parent 37882645c4
commit 55480cf7a3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -30,7 +30,7 @@ import {
const ADDRESS_ZERO = "0x0000000000000000000000000000000000000000" const ADDRESS_ZERO = "0x0000000000000000000000000000000000000000"
export function handleOrderStarted(event: OrderStarted): void { export function handleOrderStarted(event: OrderStarted): void {
log.info("handleOrderStarted") log.info("handleOrderStarted", [])
const order = new Order( const order = new Order(
getOrderId( getOrderId(
event.transaction.hash.toHex(), event.transaction.hash.toHex(),
@ -39,59 +39,59 @@ export function handleOrderStarted(event: OrderStarted): void {
event.logIndex.toI32() event.logIndex.toI32()
) )
) )
log.info("Created order object") log.info("Created order object", [])
const token = getToken(event.address, true) const token = getToken(event.address, true)
log.info("Got the token") log.info("Got the token", [])
order.datatoken = token.id order.datatoken = token.id
token.orderCount = token.orderCount.plus(integer.ONE) token.orderCount = token.orderCount.plus(integer.ONE)
log.info("set data token and order count") log.info("set data token and order count", [])
const consumer = getUser(event.params.consumer.toHex()) const consumer = getUser(event.params.consumer.toHex())
order.consumer = consumer.id order.consumer = consumer.id
log.info("got consumer id") log.info("got consumer id", [])
if (token.nft) { if (token.nft) {
const nft = Nft.load(token.nft as string) as Nft const nft = Nft.load(token.nft as string) as Nft
if (nft) { if (nft) {
log.info("nft loaded and set") log.info("nft loaded and set", [])
const nftOwner = getUser(nft.owner) const nftOwner = getUser(nft.owner)
order.nftOwner = nftOwner.id order.nftOwner = nftOwner.id
} else { } else {
log.info("nft couldnt load") log.info("nft couldnt load", [])
order.nftOwner = ADDRESS_ZERO order.nftOwner = ADDRESS_ZERO
} }
} else { } else {
log.info("nft not found") log.info("nft not found", [])
} }
const payer = getUser(event.params.payer.toHex()) const payer = getUser(event.params.payer.toHex())
payer.totalOrders = payer.totalOrders.plus(integer.ONE) payer.totalOrders = payer.totalOrders.plus(integer.ONE)
payer.save() payer.save()
log.info("payer saved") log.info("payer saved", [])
order.payer = payer.id order.payer = payer.id
order.amount = weiToDecimal( order.amount = weiToDecimal(
event.params.amount.toBigDecimal(), event.params.amount.toBigDecimal(),
token.decimals token.decimals
) )
log.info("set order amount") log.info("set order amount", [])
order.serviceIndex = event.params.serviceIndex.toI32() order.serviceIndex = event.params.serviceIndex.toI32()
log.info("set order service index") log.info("set order service index", [])
const publishMarket = getUser(event.params.publishMarketAddress.toHex()) const publishMarket = getUser(event.params.publishMarketAddress.toHex())
order.publishingMarket = publishMarket.id order.publishingMarket = publishMarket.id
log.info("set order publish market") log.info("set order publish market", [])
order.createdTimestamp = event.block.timestamp.toI32() order.createdTimestamp = event.block.timestamp.toI32()
order.tx = event.transaction.hash.toHex() order.tx = event.transaction.hash.toHex()
order.eventIndex = event.logIndex.toI32() order.eventIndex = event.logIndex.toI32()
order.block = event.block.number.toI32() order.block = event.block.number.toI32()
log.info("set created ts tx eventindex and block") log.info("set created ts tx eventindex and block", [])
const tokenId = token.lastPriceToken const tokenId = token.lastPriceToken
log.info("got token id") log.info("got token id", [])
if (tokenId) { if (tokenId) {
log.info("token id setting") log.info("token id setting", [])
const priceToken = getToken(Address.fromString(tokenId), false) const priceToken = getToken(Address.fromString(tokenId), false)
order.lastPriceToken = priceToken.id order.lastPriceToken = priceToken.id
order.lastPriceValue = token.lastPriceValue order.lastPriceValue = token.lastPriceValue
@ -100,28 +100,28 @@ export function handleOrderStarted(event: OrderStarted): void {
order.lastPriceValue, order.lastPriceValue,
order.createdTimestamp order.createdTimestamp
) )
log.info("token id is set") log.info("token id is set", [])
} }
if (event.receipt !== null && event.receipt!.gasUsed) { if (event.receipt !== null && event.receipt!.gasUsed) {
order.gasUsed = event.receipt!.gasUsed.toBigDecimal() order.gasUsed = event.receipt!.gasUsed.toBigDecimal()
log.info("LOG1") log.info("LOG1", [])
} else { } else {
order.gasUsed = BigDecimal.zero() order.gasUsed = BigDecimal.zero()
log.info("LOG2") log.info("LOG2", [])
} }
if (event.transaction.gasPrice) { if (event.transaction.gasPrice) {
order.gasPrice = event.transaction.gasPrice order.gasPrice = event.transaction.gasPrice
log.info("LOG3") log.info("LOG3", [])
} else { } else {
order.gasPrice = BigInt.zero() order.gasPrice = BigInt.zero()
log.info("LOG4") log.info("LOG4", [])
} }
log.info("order save start") log.info("order save start", [])
order.save() order.save()
token.save() token.save()
addOrder() addOrder()
log.info("order save done") log.info("order save done", [])
if (token.nft) { if (token.nft) {
const nft = Nft.load(token.nft as string) as Nft const nft = Nft.load(token.nft as string) as Nft
if (nft) { if (nft) {
@ -131,7 +131,7 @@ export function handleOrderStarted(event: OrderStarted): void {
const owner = getUser(nft.owner) const owner = getUser(nft.owner)
owner.totalSales = owner.totalSales.plus(integer.ONE) owner.totalSales = owner.totalSales.plus(integer.ONE)
owner.save() owner.save()
log.info("owner data updated") log.info("owner data updated", [])
} }
} }
@ -340,7 +340,7 @@ export function handleProviderFee(event: ProviderFee): void {
event.logIndex.toI32() event.logIndex.toI32()
) )
if (orderReuse) { if (orderReuse) {
log.info('order reuse id in provider fee handler: {}', [orderReuse.id]) log.info('order reuse id in provider fee handler: {}', [orderReuse.id], [])
orderReuse.providerFee = providerFee orderReuse.providerFee = providerFee
orderReuse.providerFeeValidUntil = event.params.validUntil orderReuse.providerFeeValidUntil = event.params.validUntil
orderReuse.save() orderReuse.save()