From eb3c82eda43618b95cdd2fe9ff7165cf99f130ca Mon Sep 17 00:00:00 2001 From: Gabriel Diaz Date: Mon, 6 Jan 2025 15:40:59 -0300 Subject: [PATCH] fix: Add a new allowed selector (sponserdCallV2) for committee txn inputs --- src/handlers/collection.ts | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/handlers/collection.ts b/src/handlers/collection.ts index 6e485a4..4fc6094 100644 --- a/src/handlers/collection.ts +++ b/src/handlers/collection.ts @@ -212,8 +212,7 @@ export function handleRescueItem(event: RescueItem): void { if ((isNewContent && event.block.number.gt(block)) || event.block.number.equals(block)) { // Create curation let txInput = event.transaction.input.toHexString() - // forwardMetaTx(address _target, bytes calldata _data) or manageCollection(address,address,address,bytes[]) selector - if (txInput.startsWith('0x07bd3522') || txInput.startsWith('0x81c9308e')) { + if (isAllowedCommitteeTxInput(txInput)) { let curationId = getCurationId(collectionAddress, event.transaction.hash.toHexString(), event.logIndex.toString()) let curation = new Curation(curationId) let curator = '' @@ -517,8 +516,7 @@ export function handleSetApproved(event: SetApproved): void { if (event.block.number.lt(block)) { // Create curation let txInput = event.transaction.input.toHexString() - // forwardMetaTx(address _target, bytes calldata _data) or manageCollection(address,address,address,bytes[]) selector - if (txInput.startsWith('0x07bd3522') || txInput.startsWith('0x81c9308e')) { + if (isAllowedCommitteeTxInput(txInput)) { let curationId = getCurationId(collectionAddress, event.transaction.hash.toHexString(), event.logIndex.toString()) let curation = new Curation(curationId) let curator = '' @@ -592,3 +590,18 @@ export function handleTransferOwnership(event: OwnershipTransferred): void { collection.save() } } + +// List of allowed committee function selectors +// 0x07bd3522: forwardMetaTx(address _target, bytes calldata _data) +// 0xad718d2a: sponsoredCallV2(address _target,bytes _data,bytes32 _correlationId,bytes32 _r,bytes32 _vs) +// 0x81c9308e: manageCollection(address,address,address,bytes[]) selector +const ALLOWED_SELECTORS = ['0x07bd3522', '0xad718d2a', '0x81c9308e'] + +/** + * Verify if it's an allowed committee transaction input. + * @param txInput - The transaction input data as a hexadecimal string. + * @returns True if the input starts with an allowed selector, false otherwise. + */ +function isAllowedCommitteeTxInput(txInput: string): boolean { + return ALLOWED_SELECTORS.some(selector => txInput.startsWith(selector)) +}