From b063b30bc2a9b4cbe1f237d95327bc1d305923c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ph=E1=BA=A1m=20Th=C3=A0nh=20Phong?= <49814372+phamphong9981@users.noreply.github.com> Date: Mon, 9 Sep 2024 10:58:43 +0700 Subject: [PATCH] fix: evm proxy history object string (#898) * fix: evm proxy history object string * fix: evm proxy history object string * fix: evm proxy history object string --- .../evm/crawl_evm_proxy_history.service.ts | 31 ++++++++++++------- 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/src/services/evm/crawl_evm_proxy_history.service.ts b/src/services/evm/crawl_evm_proxy_history.service.ts index bdee65458..6db552fa7 100644 --- a/src/services/evm/crawl_evm_proxy_history.service.ts +++ b/src/services/evm/crawl_evm_proxy_history.service.ts @@ -114,7 +114,7 @@ export default class CrawlProxyContractEVMService extends BullableService { }) as EVMSmartContract; const firstTimeCatchProxyEvent = proxyContractDb.find((proxy) => proxy.address === evmEvent.address) && - anyProxyHistoryByAddress[evmEvent.address]; + !anyProxyHistoryByAddress[evmEvent.address]; const newJSONProxy: Dictionary = {}; switch (evmEvent.topic0) { @@ -139,22 +139,29 @@ export default class CrawlProxyContractEVMService extends BullableService { // break; default: if (firstTimeCatchProxyEvent) { - implementationAddress = await this.contractHelper.isContractProxy( - evmEvent.address, - _.find( - EIPProxyContractSupportByteCode, - (value, __) => value.TYPE === evmEventProxy.type - )?.SLOT, - undefined, - bytecodes[evmEvent.address] - ); + implementationAddress = ( + await this.contractHelper.isContractProxy( + evmEvent.address, + _.find( + EIPProxyContractSupportByteCode, + (value, __) => value.TYPE === evmEventProxy.type + )?.SLOT, + undefined, + bytecodes[evmEvent.address] + ) + )?.logicContractAddress; } break; } newJSONProxy.proxy_contract = _.toLower(evmEvent.address); - newJSONProxy.implementation_contract = - _.toLower(implementationAddress as string) || null; + if (implementationAddress) { + newJSONProxy.implementation_contract = _.toLower( + implementationAddress as string + ); + } else { + newJSONProxy.implementation_contract = null; + } newJSONProxy.block_height = evmEvent.block_height; newJSONProxy.tx_hash = evmEvent.tx_hash; newJSONProxy.last_updated_height = lastUpdatedHeight;