Saving providerFee as an array of all previous provider fees

This commit is contained in:
Jamie Hewitt 2022-06-29 19:41:26 +03:00
parent f0552a63e9
commit 79aa847eff
4 changed files with 33 additions and 3 deletions

7
.vscode/extensions.json vendored Normal file
View File

@ -0,0 +1,7 @@
{
"recommendations": [
"dbaeumer.vscode-eslint",
"esbenp.prettier-vscode",
"wix.vscode-import-cost"
]
}

17
.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,17 @@
{
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
},
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true,
"eslint.validate": [
"javascript",
"javascriptreact",
"typescript",
"typescriptreact"
],
"search.exclude": {
"**/.next": true,
"**/out": true
}
}

View File

@ -265,7 +265,7 @@ type Order @entity {
publishingMarket: User publishingMarket: User
publishingMarketToken: Token # publishingMarketToken: Token #
publishingMarketAmmount: BigDecimal #call contract to get fee amount publishingMarketAmmount: BigDecimal #call contract to get fee amount
providerFee: String providerFee: [String!]
consumerMarket: User consumerMarket: User
consumerMarketToken: Token # consumerMarketToken: Token #

View File

@ -204,7 +204,8 @@ export function handleProviderFee(event: ProviderFee): void {
event.address.toHex(), event.address.toHex(),
event.transaction.from.toHex() event.transaction.from.toHex()
) )
const providerFee = `{providerFeeAddress: ${event.params.providerFeeAddress.toHex()}, providerFeeToken: ${event.params.providerFeeToken.toHex()}, providerFeeAmount: ${
const providerFee: string = `{providerFeeAddress: ${event.params.providerFeeAddress.toHex()}, providerFeeToken: ${event.params.providerFeeToken.toHex()}, providerFeeAmount: ${
event.params.providerFeeAmount event.params.providerFeeAmount
}, providerData: ${event.params.providerData.toHexString()}, v: ${ }, providerData: ${event.params.providerData.toHexString()}, v: ${
event.params.v event.params.v
@ -213,7 +214,12 @@ export function handleProviderFee(event: ProviderFee): void {
} }
}` }`
order.providerFee = providerFee let existingProviderFees: string[]
if (!order.providerFee) existingProviderFees = []
else existingProviderFees = order.providerFee as string[]
existingProviderFees.push(providerFee)
order.providerFee = existingProviderFees
order.save() order.save()
} }