diff --git a/.github/workflows/node.js.yaml b/.github/workflows/node.js.yaml index 9266e3c..259c3e5 100644 --- a/.github/workflows/node.js.yaml +++ b/.github/workflows/node.js.yaml @@ -2,20 +2,20 @@ name: Node.js CI on: push: - branches: [ master ] + branches: [master] pull_request: - branches: [ master ] + branches: [master] jobs: build: - runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 + - name: Use Node.js 20.x + uses: actions/setup-node@v3 with: - node-version: 16.x + node-version: 20.x # Cache dependencies as `npm ci` takes like 6 minutes to run. # https://github.com/actions/cache/blob/main/examples.md#node---npm - id: npm-cache-dir diff --git a/src/handlers/collection.ts b/src/handlers/collection.ts index 6e485a4..851a3de 100644 --- a/src/handlers/collection.ts +++ b/src/handlers/collection.ts @@ -30,7 +30,7 @@ import { RaritiesWithOracle } from '../entities/RaritiesWithOracle/RaritiesWithO import { getURNForWearableV2, getURNForCollectionV2 } from '../modules/metadata/wearable' import { getStoreAddress } from '../modules/store' import { getOrCreateAnalyticsDayData } from '../modules/analytics' -import { getCurationId, getBlockWhereRescueItemsStarted } from '../modules/curation' +import { getCurationId, getBlockWhereRescueItemsStarted, isAllowedCommitteeTxInput } from '../modules/curation' import { toLowerCase } from '../utils' import { getRaritiesWithOracleAddress } from '../modules/rarity' @@ -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 = '' diff --git a/src/modules/curation/index.ts b/src/modules/curation/index.ts index feeb128..f481f10 100644 --- a/src/modules/curation/index.ts +++ b/src/modules/curation/index.ts @@ -22,3 +22,23 @@ export function getBlockWhereRescueItemsStarted(): BigInt { return BigInt.fromI32(I32.MAX_VALUE) } + +// 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 +export const ALLOWED_SELECTORS: string[] = ['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. + */ +export function isAllowedCommitteeTxInput(txInput: string): boolean { + for (let i = 0; i < ALLOWED_SELECTORS.length; i++) { + if (txInput.startsWith(ALLOWED_SELECTORS[i])) { + return true + } + } + return false +} diff --git a/src/utils/index.ts b/src/utils/index.ts index 5400ace..113d252 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -12,4 +12,4 @@ export function toLowerCase(str: string): string { } return result -} \ No newline at end of file +}