Skip to content

Commit

Permalink
fix: Add a new allowed selector (sponserdCallV2) for committee txn in…
Browse files Browse the repository at this point in the history
…puts
  • Loading branch information
cyaiox committed Jan 6, 2025
1 parent 77120cc commit eb3c82e
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions src/handlers/collection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ''
Expand Down Expand Up @@ -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 = ''
Expand Down Expand Up @@ -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))
}

0 comments on commit eb3c82e

Please sign in to comment.