Skip to content

Commit

Permalink
Cleanup logs.
Browse files Browse the repository at this point in the history
  • Loading branch information
mariacarmina committed Dec 7, 2024
1 parent b0768f0 commit 1be249e
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 106 deletions.
8 changes: 1 addition & 7 deletions src/components/Indexer/processor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -375,9 +375,6 @@ export class MetadataEventProcessor extends BaseEventProcessor {
)
return
}
INDEXER_LOGGER.logMessage(
`decrypted document from contract: ${JSON.stringify(ddo)}`
)
// for unencrypted DDOs
if (parseInt(flag) !== 2 && !this.checkDdoHash(updatedDdo, metadataHash)) {
return
Expand Down Expand Up @@ -457,9 +454,6 @@ export class MetadataEventProcessor extends BaseEventProcessor {
// we need to store the event data (either metadata created or update and is updatable)
if ([EVENTS.METADATA_CREATED, EVENTS.METADATA_UPDATED].includes(eventName)) {
const ddoWithPricing = await getPricingStatsForDddo(ddo, signer)
INDEXER_LOGGER.logMessage(
`ddo with indexedMetadata: ${JSON.stringify(ddoWithPricing)}`
)
if (
eventName === EVENTS.METADATA_UPDATED &&
ddoWithPricing.indexedMetadata.stats.length !== 0
Expand Down Expand Up @@ -768,7 +762,7 @@ export class OrderStartedEventProcessor extends BaseEventProcessor {
name: await datatokenContract.name(),
serviceId: ddo.services[serviceIndex].id,
orders: 1,
prices: [] // needs fixing, to retrieve pricing
prices: [] // needs fixing, to retrieve pricing -> add util function for fres and dispensers
})
}
await orderDatabase.create(
Expand Down
100 changes: 1 addition & 99 deletions src/components/Indexer/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -344,91 +344,7 @@ export function findServiceIdByDatatoken(ddo: any, datatokenAddress: string): st
return serviceIdToFind
}

// export async function getPricingSchemas(datatoken: ethers.Contract, signer: Signer) {
// let dispensers = []
// let fixedRates = []
// const prices = []
// try {
// dispensers = await datatoken.getDispensers()
// INDEXER_LOGGER.logMessage(`dt ctr call for disp: ${await datatoken.getDispensers()}`)
// INDEXER_LOGGER.logMessage(`dispensers: ${dispensers}`)
// } catch (e) {
// INDEXER_LOGGER.error(`Contract call fails when retrieving dispensers: ${e}`)
// }
// try {
// fixedRates = await datatoken.getFixedRates()
// INDEXER_LOGGER.logMessage(`dt ctr call for fre: ${await datatoken.getFixedRates()}`)
// } catch (e) {
// INDEXER_LOGGER.error(`Contract call fails when retrieving fixed rate exchanges: ${e}`)
// }
// if (dispensers.length === 0 && fixedRates.length === 0) {
// INDEXER_LOGGER.logMessage(`a intrat pe aici`)
// ddo.indexedMetadata.stats.push({
// datatokenAddress: service.datatokenAddress,
// name: await datatoken.name(),
// serviceId: service.id,
// orders: 0,
// prices: []
// })
// INDEXER_LOGGER.logMessage(
// `ddo with indexedMetadata w/o disp and fre: ${JSON.stringify(ddo)}`
// )
// } else {
// if (dispensers) {
// INDEXER_LOGGER.logMessage(`a intrat pe disp: ${dispensers}`)
// for (const dispenser of dispensers) {
// const dispenserContract = new ethers.Contract(dispenser, Dispenser.abi, signer)
// INDEXER_LOGGER.logMessage(`disp ctr: ${dispenserContract}`)
// if ((await dispenserContract.status())[0] === true) {
// INDEXER_LOGGER.logMessage(`disp ctr call: ${await dispenserContract.status()}`)
// ddo.indexedMetadata.stats.push({
// datatokenAddress: service.datatokenAddress,
// name: await datatoken.name(),
// serviceId: service.id,
// orders: 0,
// prices: prices.push({
// type: 'dispenser',
// price: '0',
// contract: dispenser
// })
// })
// }
// }
// }

// if (fixedRates) {
// for (const fixedRate of fixedRates) {
// const fixedRateContract = new ethers.Contract(
// fixedRate.address,
// FixedRateExchange.abi,
// signer
// )
// const exchange = await fixedRateContract.getExchange(fixedRate.id)
// if (exchange[6] === true) {
// ddo.indexedMetadata.stats.push({
// datatokenAddress: service.datatokenAddress,
// name: await datatoken.name(),
// serviceId: service.id,
// orders: 0, // just created
// prices: prices.push({
// type: 'fixedrate',
// price: exchange[5],
// token: exchange[3],
// contract: fixedRate,
// exchangeId: fixedRate.id
// })
// })
// }
// }
// }
// }
// }

export async function getPricingStatsForDddo(
ddo: any,
signer: Signer,
datatokenAddress?: string
): Promise<any> {
export async function getPricingStatsForDddo(ddo: any, signer: Signer): Promise<any> {
if (!ddo.indexedMetadata) {
ddo.indexedMetadata = {}
}
Expand All @@ -448,43 +364,29 @@ export async function getPricingStatsForDddo(
const prices = []
try {
dispensers = await datatoken.getDispensers()
INDEXER_LOGGER.logMessage(
`dt ctr call for disp: ${await datatoken.getDispensers()}`
)
INDEXER_LOGGER.logMessage(`dispensers: ${dispensers}`)
} catch (e) {
INDEXER_LOGGER.error(`Contract call fails when retrieving dispensers: ${e}`)
}
try {
fixedRates = await datatoken.getFixedRates()
INDEXER_LOGGER.logMessage(`dt ctr call for fre: ${await datatoken.getFixedRates()}`)
} catch (e) {
INDEXER_LOGGER.error(
`Contract call fails when retrieving fixed rate exchanges: ${e}`
)
}
if (dispensers.length === 0 && fixedRates.length === 0) {
INDEXER_LOGGER.logMessage(`a intrat pe aici`)
ddo.indexedMetadata.stats.push({
datatokenAddress: service.datatokenAddress,
name: await datatoken.name(),
serviceId: service.id,
orders: 0,
prices: []
})
INDEXER_LOGGER.logMessage(
`ddo with indexedMetadata w/o disp and fre: ${JSON.stringify(ddo)}`
)
} else {
if (dispensers) {
INDEXER_LOGGER.logMessage(`a intrat pe disp: ${dispensers}`)
for (const dispenser of dispensers) {
const dispenserContract = new ethers.Contract(dispenser, Dispenser.abi, signer)
INDEXER_LOGGER.logMessage(`disp ctr: ${dispenserContract}`)
if ((await dispenserContract.status())[0] === true) {
INDEXER_LOGGER.logMessage(
`disp ctr call: ${await dispenserContract.status()}`
)
ddo.indexedMetadata.stats.push({
datatokenAddress: service.datatokenAddress,
name: await datatoken.name(),
Expand Down

0 comments on commit 1be249e

Please sign in to comment.