Skip to content

Commit

Permalink
common: remove stakingABI workaround for exponential rebates
Browse files Browse the repository at this point in the history
  • Loading branch information
tilacog committed Sep 19, 2023
1 parent b12f4ec commit 0576c9c
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 29 deletions.
1 change: 0 additions & 1 deletion packages/indexer-common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
"graphql-tag": "2.12.6",
"jayson": "3.6.6",
"lodash.groupby": "^4.6.0",
"lodash.intersection": "^4.4.0",
"lodash.isequal": "4.5.0",
"lodash.xor": "^4.5.0",
"morgan": "1.10.0",
Expand Down
1 change: 0 additions & 1 deletion packages/indexer-common/src/abi/stakingUpdatedABI.json

This file was deleted.

35 changes: 9 additions & 26 deletions packages/indexer-common/src/transactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ import { IndexerError, indexerError, IndexerErrorCode } from './errors'
import { TransactionConfig, TransactionType } from './types'
import { NetworkSubgraph } from './network-subgraph'
import gql from 'graphql-tag'
import intersection from 'lodash.intersection'
import updatedStakingAbi from './abi/stakingUpdatedABI.json'

export class TransactionManager {
ethereum: providers.BaseProvider
Expand Down Expand Up @@ -413,42 +411,27 @@ export class TransactionManager {
): utils.Result | undefined {
const events: Event[] | providers.Log[] = receipt.events || receipt.logs
const decodedEvents: utils.Result[] = []
const updatedStakingIface = new utils.Interface(updatedStakingAbi)

// With exponential rebates, the AllocationClosed event changed signature
// so it has a different topic. Until these changes are deployed in both mainnet and
// testnet, we need to search for both.
// TODO: Update to a new common-ts and remove this hack once exponential rebates is on mainnet
const newAbiTopic = updatedStakingIface.getEventTopic('AllocationClosed')
const expectedTopics = [contractInterface.getEventTopic(eventType)]
if (eventType == 'AllocationClosed') {
expectedTopics.push(newAbiTopic)
}
const expectedTopic = contractInterface.getEventTopic(eventType)

const result = events
.filter((event) => intersection(event.topics, expectedTopics).length > 0)
.filter((event) => event.topics.includes(expectedTopic))
.map((event) => {
let decoded: utils.Result
if (eventType == 'AllocationClosed' && event.topics.includes(newAbiTopic)) {
decoded = updatedStakingIface.decodeEventLog(
eventType,
event.data,
event.topics,
)
} else {
decoded = contractInterface.decodeEventLog(eventType, event.data, event.topics)
}
const decoded = contractInterface.decodeEventLog(
eventType,
event.data,
event.topics,
)
decodedEvents.push(decoded)
return decoded
})
.find(
(eventLogs: utils.Result) =>
(eventLogs) =>
eventLogs[logKey].toLocaleLowerCase() === logValue.toLocaleLowerCase(),
)

logger.trace('Searched for event logs', {
function: 'findEvent',
expectedTopics,
expectedTopic,
events,
decodedEvents,
eventType,
Expand Down
2 changes: 1 addition & 1 deletion packages/indexer-common/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
],
"resolveJsonModule": true
},
"include": ["src/**/*.ts", "src/abi/stakingUpdatedABI.json"],
"include": ["src/**/*.ts"],
"exclude": [],
"references": []
}

0 comments on commit 0576c9c

Please sign in to comment.