mirror of
https://github.com/oceanprotocol/ocean-subgraph.git
synced 2024-12-02 05:57:29 +01:00
Add gasUsed and gasPrice to order (#540)
* Add gasused to order Co-authored-by: alexcos20 <alex.coseru@gmail.com>
This commit is contained in:
parent
d2ddf2d156
commit
f61cce9722
@ -134,6 +134,8 @@ type OrderReuse @entity {
|
||||
block: Int!
|
||||
providerFee: String
|
||||
providerFeeValidUntil: BigInt
|
||||
gasPrice: BigInt
|
||||
gasUsed: BigInt
|
||||
}
|
||||
|
||||
type Order @entity {
|
||||
@ -167,6 +169,8 @@ type Order @entity {
|
||||
lastPriceToken: String!
|
||||
lastPriceValue: BigDecimal!
|
||||
estimatedUSDValue: BigDecimal!
|
||||
gasUsed: BigInt
|
||||
gasPrice: BigInt
|
||||
}
|
||||
|
||||
type User @entity {
|
||||
|
@ -1,5 +1,6 @@
|
||||
import { Order, Nft, OrderReuse } from '../@types/schema'
|
||||
import { BigInt } from '@graphprotocol/graph-ts'
|
||||
|
||||
import {
|
||||
NewPaymentCollector,
|
||||
OrderStarted,
|
||||
@ -65,6 +66,16 @@ export function handleOrderStarted(event: OrderStarted): void {
|
||||
order.lastPriceValue,
|
||||
order.createdTimestamp
|
||||
)
|
||||
if (event.receipt !== null) {
|
||||
order.gasUsed = event.receipt!.gasUsed
|
||||
} else {
|
||||
order.gasUsed = BigInt.zero()
|
||||
}
|
||||
if (event.transaction.gasPrice) {
|
||||
order.gasPrice = event.transaction.gasPrice
|
||||
} else {
|
||||
order.gasPrice = BigInt.zero()
|
||||
}
|
||||
order.save()
|
||||
token.save()
|
||||
addOrder()
|
||||
@ -91,6 +102,11 @@ export function handlerOrderReused(event: OrderReused): void {
|
||||
if (!order) return
|
||||
|
||||
const reuseOrder = new OrderReuse(event.transaction.hash.toHex())
|
||||
if (event.transaction.gasPrice)
|
||||
reuseOrder.gasPrice = event.transaction.gasPrice
|
||||
else reuseOrder.gasPrice = BigInt.zero()
|
||||
if (event.receipt !== null) reuseOrder.gasUsed = event.receipt!.gasUsed
|
||||
else reuseOrder.gasUsed = BigInt.zero()
|
||||
reuseOrder.order = orderId
|
||||
reuseOrder.caller = event.params.caller.toHexString()
|
||||
reuseOrder.createdTimestamp = event.params.timestamp.toI32()
|
||||
@ -235,6 +251,11 @@ export function handleProviderFee(event: ProviderFee): void {
|
||||
orderReuse.tx = event.transaction.hash.toHex()
|
||||
orderReuse.block = event.block.number.toI32()
|
||||
orderReuse.caller = event.transaction.from.toHex()
|
||||
if (event.transaction.gasPrice)
|
||||
orderReuse.gasPrice = event.transaction.gasPrice
|
||||
else orderReuse.gasPrice = BigInt.zero()
|
||||
if (event.receipt !== null) orderReuse.gasUsed = event.receipt!.gasUsed
|
||||
else orderReuse.gasUsed = BigInt.zero()
|
||||
orderReuse.save()
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user