From 929bff555e775b8de7076f06848aac57cbc1cb06 Mon Sep 17 00:00:00 2001 From: phamphong9981 Date: Thu, 29 Aug 2024 11:35:16 +0700 Subject: [PATCH] feat: proxy beacon --- src/services/evm/crawl_contract_evm.service.ts | 8 ++++---- src/services/evm/helpers/contract_helper.ts | 6 +++++- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/services/evm/crawl_contract_evm.service.ts b/src/services/evm/crawl_contract_evm.service.ts index a0ad66578..c656f338a 100644 --- a/src/services/evm/crawl_contract_evm.service.ts +++ b/src/services/evm/crawl_contract_evm.service.ts @@ -301,22 +301,22 @@ export default class CrawlSmartContractEVMService extends BullableService { this.contractHelper.detectProxyContractByByteCode( addr, byteCode, - EIPProxyContractSupportByteCode.EIP_1967_IMPLEMENTATION.SLOT + EIPProxyContractSupportByteCode.EIP_1967_IMPLEMENTATION.TYPE ), this.contractHelper.detectProxyContractByByteCode( addr, byteCode, - EIPProxyContractSupportByteCode.EIP_1822_IMPLEMENTATION.SLOT + EIPProxyContractSupportByteCode.EIP_1822_IMPLEMENTATION.TYPE ), this.contractHelper.detectProxyContractByByteCode( addr, byteCode, - EIPProxyContractSupportByteCode.OPEN_ZEPPELIN_IMPLEMENTATION.SLOT + EIPProxyContractSupportByteCode.OPEN_ZEPPELIN_IMPLEMENTATION.TYPE ), this.contractHelper.detectProxyContractByByteCode( addr, byteCode, - EIPProxyContractSupportByteCode.EIP_1167_IMPLEMENTATION.SLOT + EIPProxyContractSupportByteCode.EIP_1167_IMPLEMENTATION.TYPE ), ]).catch(() => Promise.resolve(null)); }) diff --git a/src/services/evm/helpers/contract_helper.ts b/src/services/evm/helpers/contract_helper.ts index 991240802..718f852f2 100644 --- a/src/services/evm/helpers/contract_helper.ts +++ b/src/services/evm/helpers/contract_helper.ts @@ -20,13 +20,17 @@ export class ContractHelper { public async detectProxyContractByByteCode( contractAddress: string, byteCode: string, - byteCodeSlot: string, + type: string, blockHeight?: number | string ): Promise { const resultReturn: DetectEVMProxyContract = { logicContractAddress: '', EIP: '', }; + const byteCodeSlot = Object.values(EIPProxyContractSupportByteCode).find( + (e) => e.TYPE === type + )?.SLOT; + if (!byteCodeSlot) throw Error('Type proxy not supported'); const result = byteCode.includes(byteCodeSlot); if (!result) throw Error('Not proxy contract!');