From f0552a63e956853e0f0ff17acb9f3d8e104f0168 Mon Sep 17 00:00:00 2001 From: Jamie Hewitt Date: Wed, 29 Jun 2022 17:40:09 +0300 Subject: [PATCH] Saving providerFee as a string --- src/mappings/erc20Templates.ts | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/src/mappings/erc20Templates.ts b/src/mappings/erc20Templates.ts index a245dc4..56c8ef0 100644 --- a/src/mappings/erc20Templates.ts +++ b/src/mappings/erc20Templates.ts @@ -10,7 +10,8 @@ import { RemovedMinter, RemovedPaymentManager, CleanedPermissions, - OrderReused + OrderReused, + ProviderFee } from '../@types/templates/ERC20Template/ERC20Template' import { integer } from './utils/constants' @@ -18,14 +19,7 @@ import { weiToDecimal } from './utils/generic' import { addOrder } from './utils/globalUtils' import { getToken, getUSDValue } from './utils/tokenUtils' import { getUser } from './utils/userUtils' - -function getOrderId( - tx: string, - tokenAddress: string, - fromAddress: string -): string { - return `${tx}-${tokenAddress}-${fromAddress}` -} +import { getOrder, getOrderId } from './utils/orderUtils' export function handleOrderStarted(event: OrderStarted): void { const order = new Order( @@ -204,6 +198,25 @@ export function handleNewPaymentCollector(event: NewPaymentCollector): void { token.save() } +export function handleProviderFee(event: ProviderFee): void { + const order = getOrder( + event.transaction.hash.toHex(), + event.address.toHex(), + event.transaction.from.toHex() + ) + const providerFee = `{providerFeeAddress: ${event.params.providerFeeAddress.toHex()}, providerFeeToken: ${event.params.providerFeeToken.toHex()}, providerFeeAmount: ${ + event.params.providerFeeAmount + }, providerData: ${event.params.providerData.toHexString()}, v: ${ + event.params.v + }, r: ${event.params.r.toHexString()}, s: ${event.params.s.toHexString()}, validUntil: ${ + event.params.validUntil + } + }` + + order.providerFee = providerFee + order.save() +} + // export function handlePublishMarketFees(event: PublishMarketFees): void { // const order = Order.load( // getOrderId(