mirror of
https://github.com/oceanprotocol/ocean-subgraph.git
synced 2024-12-02 05:57:29 +01:00
Updating or Creating OrderResue provider fee
This commit is contained in:
parent
3dac319c0e
commit
0f124d01dd
@ -249,6 +249,7 @@ type OrderReuse @entity {
|
||||
createdTimestamp: BigInt!
|
||||
tx: String!
|
||||
block: BigInt!
|
||||
providerFee: String
|
||||
}
|
||||
type Order @entity {
|
||||
"transaction hash - token address - from address"
|
||||
|
@ -199,12 +199,6 @@ export function handleNewPaymentCollector(event: NewPaymentCollector): void {
|
||||
}
|
||||
|
||||
export function handleProviderFee(event: ProviderFee): void {
|
||||
const order = getOrder(
|
||||
event.transaction.hash.toHex(),
|
||||
event.address.toHex(),
|
||||
event.transaction.from.toHex()
|
||||
)
|
||||
|
||||
const providerFee: string = `{providerFeeAddress: ${event.params.providerFeeAddress.toHex()}, providerFeeToken: ${event.params.providerFeeToken.toHex()}, providerFeeAmount: ${
|
||||
event.params.providerFeeAmount
|
||||
}, providerData: ${event.params.providerData.toHexString()}, v: ${
|
||||
@ -214,8 +208,24 @@ export function handleProviderFee(event: ProviderFee): void {
|
||||
}
|
||||
}`
|
||||
|
||||
order.providerFee = providerFee
|
||||
order.save()
|
||||
const orderId = getOrderId(
|
||||
event.transaction.hash.toHex(),
|
||||
event.address.toHex(),
|
||||
event.transaction.from.toHex()
|
||||
)
|
||||
const order = Order.load(orderId)
|
||||
let orderReuse = OrderReuse.load(event.transaction.hash.toHex())
|
||||
if (order) {
|
||||
order.providerFee = providerFee
|
||||
order.save()
|
||||
} else if (orderReuse) {
|
||||
orderReuse.providerFee = providerFee
|
||||
orderReuse.save()
|
||||
} else {
|
||||
orderReuse = new OrderReuse(event.transaction.hash.toHex())
|
||||
orderReuse.providerFee = providerFee
|
||||
orderReuse.save()
|
||||
}
|
||||
}
|
||||
|
||||
// export function handlePublishMarketFees(event: PublishMarketFees): void {
|
||||
|
Loading…
Reference in New Issue
Block a user