Skip to content

Commit

Permalink
feat: proxy beacon
Browse files Browse the repository at this point in the history
  • Loading branch information
phamphong9981 committed Aug 29, 2024
1 parent e4b7773 commit 929bff5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
8 changes: 4 additions & 4 deletions src/services/evm/crawl_contract_evm.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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));
})
Expand Down
6 changes: 5 additions & 1 deletion src/services/evm/helpers/contract_helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,17 @@ export class ContractHelper {
public async detectProxyContractByByteCode(
contractAddress: string,
byteCode: string,
byteCodeSlot: string,
type: string,
blockHeight?: number | string
): Promise<DetectEVMProxyContract> {
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!');
Expand Down

0 comments on commit 929bff5

Please sign in to comment.