-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathAddressRemovedEventProcessor.ts
More file actions
46 lines (41 loc) · 1.44 KB
/
AddressRemovedEventProcessor.ts
File metadata and controls
46 lines (41 loc) · 1.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import { ethers, Signer, FallbackProvider, Interface } from 'ethers'
import { INDEXER_LOGGER } from '../../../utils/logging/common.js'
import { LOG_LEVELS_STR } from '../../../utils/logging/Logger.js'
import { BaseEventProcessor } from './BaseProcessor.js'
import AccessList from '@oceanprotocol/contracts/artifacts/contracts/accesslists/AccessList.sol/AccessList.json' with { type: 'json' }
const accessListInterface = new Interface(AccessList.abi)
export class AddressRemovedEventProcessor extends BaseEventProcessor {
async processEvent(
event: ethers.Log,
chainId: number,
signer: Signer,
provider: FallbackProvider
): Promise<any> {
try {
const decoded = accessListInterface.parseLog({
topics: Array.from(event.topics),
data: event.data
})
if (!decoded) return null
const tokenId = Number(decoded.args[0])
const contractAddress = event.address.toLowerCase()
const { accessList } = await this.getDatabase()
const result = await accessList.removeUserByTokenId(
chainId,
contractAddress,
tokenId
)
INDEXER_LOGGER.logMessage(
`[AddressRemoved] tokenId=${tokenId} removed from ${contractAddress} on chain ${chainId}`
)
return result
} catch (err) {
INDEXER_LOGGER.log(
LOG_LEVELS_STR.LEVEL_ERROR,
`Error processing AddressRemoved event: ${err.message}`,
true
)
return null
}
}
}