Skip to content

Commit

Permalink
fix: proxy contract not found (#885)
Browse files Browse the repository at this point in the history
* fix: remove foreign key proxy_contract in proxy_history

* fix: check proxy contract exists or not

* fix: search proxy_contract only
  • Loading branch information
fibonacci998 authored Aug 16, 2024
1 parent 50c810e commit 462bd1e
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions src/services/evm/crawl_evm_proxy_history.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,27 @@ export default class CrawlProxyContractEVMService extends BullableService {
newProxyHistories.push(EvmProxyHistory.fromJson(newJSONProxy));
}

const newProxyContractsToSave = _.filter(
newProxyHistories,
(proxyContract) => proxyContract.implementation_contract !== null
// check evm_smart_contract if proxy_contract is existed
const foundContractsInDB = _.keyBy(
await EVMSmartContract.query().whereIn(
'address',
newProxyHistories.map((e) => e.proxy_contract)
),
'address'
);
const newProxyContractsToSave: EvmProxyHistory[] = [];
newProxyHistories.forEach((proxyHistory) => {
if (
proxyHistory.implementation_contract !== null &&
foundContractsInDB[proxyHistory.proxy_contract] !== null
) {
newProxyContractsToSave.push(proxyHistory);
} else {
this.logger.warn(
`This contract address ${proxyHistory.proxy_contract} is not proxy, at tx hash ${proxyHistory.tx_hash}`
);
}
});
const newProxyContracts: EvmProxyHistory[] = [];
await knex.transaction(async (trx) => {
if (newProxyContractsToSave.length > 0) {
Expand Down

0 comments on commit 462bd1e

Please sign in to comment.