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 (#112)

* fix: Add a new allowed selector (sponserdCallV2) for committee txn inputs

* chore: Updates node-version

* fix: AssemblyScript method

* refactor: Move isAllowedCommitteeTxInput to utils

* fix: Move method to a properly module

* fix: Update satsuma deployment ids

* fix: Update graph studio deployment id
  • Loading branch information
cyaiox authored Jan 15, 2025
1 parent 77120cc commit cfa5fa0
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 18 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/node.js.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 5 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,14 @@

| Network | Provider | URL | Current | Previous |
| ---------- | --------------- | --------------------------------------------------------------------------------------- | ---------------------------------------------- | ---------------------------------------------- |
| Mainnet | Satsuma | https://subgraph.satsuma-prod.com/decentraland/collections-ethereum-mainnet/playground | QmQVuFfc5quYrG7t4jVPRTNXjBWhPrqVtwwKkGrWoqnSHw | Qmf4SMTepdDoFh1ozcaAUMieGF83tnNa2G2Jr4KkH5jPRA |
| Mainnet | Satsuma | https://subgraph.satsuma-prod.com/decentraland/collections-ethereum-mainnet/playground | QmUB93QwfnCHoivBT46XVKUN58hCwioVmJTtwYbekQTjAg | QmXd2SSKpMa9Z4igqbGwr6vSvA7rgxRUFmYipgNFBbnMHN |
| Mainnet | Hosted Services | https://thegraph.com/explorer/subgraph/decentraland/collections-ethereum-mainnet | QmQVuFfc5quYrG7t4jVPRTNXjBWhPrqVtwwKkGrWoqnSHw | Qmf4SMTepdDoFh1ozcaAUMieGF83tnNa2G2Jr4KkH5jPRA |
| Sepolia | Satsuma | https://subgraph.satsuma-prod.com/decentraland/collections-ethereum-sepolia/playground | QmSYyRTthY69mSHxkAY6ym3beCWQr97NwecWdpxjiHypKh | QmWQZiMSV5AnUPN34NFmAYtxGntxewMUUwuS9r5vBpc5Ys |
| Sepolia | Satsuma | https://subgraph.satsuma-prod.com/decentraland/collections-ethereum-sepolia/playground | Qme5ou2ivyxTsosbmK5W5RWzpNmtDZFSqpGzDxpJUrdbhj | QmSYyRTthY69mSHxkAY6ym3beCWQr97NwecWdpxjiHypKh |
| Sepolia | Graph Studio | https://api.studio.thegraph.com/query/49472/collections-ethereum-sepolia/version/latest | QmSYyRTthY69mSHxkAY6ym3beCWQr97NwecWdpxjiHypKh | QmWQZiMSV5AnUPN34NFmAYtxGntxewMUUwuS9r5vBpc5Ys |
| Matic | Satsuma | https://subgraph.satsuma-prod.com/decentraland/collections-matic-mainnet/playground | QmVtyq4MTv7ajHhBg3WHszkCQDnD1DM57AEcxMFb1PkHkk | QmPAV5PzFgu7iaiSYYmRTPGFR4ADGfeKSTPqTPt5eKVAVv |
| Matic | Hosted Services | https://thegraph.com/explorer/subgraph/decentraland/collections-matic-mainnet | QmVtyq4MTv7ajHhBg3WHszkCQDnD1DM57AEcxMFb1PkHkk | QmPAV5PzFgu7iaiSYYmRTPGFR4ADGfeKSTPqTPt5eKVAVv |
| Matic | Satsuma | https://subgraph.satsuma-prod.com/decentraland/collections-matic-mainnet/playground | QmTmqmgdZ58JRp5N7nKj2XiE4b6R2HjsPNeMmbtU92Uc2x | QmTNHaULmSpzSsaMnFvUDqSpHUw7o5hGS7oGxj5hQo8pwX |
| Matic | Graph Studio | https://thegraph.com/explorer/subgraph/decentraland/collections-matic-mainnet | Qmddr5gN7TY67SVZQzqGKSgwz3boofKdcnDD7QxSopraHV | QmTNHaULmSpzSsaMnFvUDqSpHUw7o5hGS7oGxj5hQo8pwX |
| Matic Temp | Hosted Services | https://thegraph.com/explorer/subgraph/decentraland/collections-matic-mainnet-temp | QmTKztw187jUHZ33S2pndtyo68K462XwewcvMVAVH7mwZR | Qmf3igvJs24gozdwCwnDyPNz9DEBQMPQRFmEhUzEvgxZSq |
| Mumbai | Satsuma | https://subgraph.satsuma-prod.com/decentraland/collections-matic-mumbai/playground | QmdqoM3jpJWWbK1EMTZcSE5WJgiUaoSpKcSLeQRHhqQSea | QmYVGaMGvqkcBMrJ4F5XrkzwCzhB3FfJvHRBERbtgovCai |
| Mumbai | Hosted Service | https://thegraph.com/explorer/subgraph/decentraland/collections-matic-mumbai | QmdqoM3jpJWWbK1EMTZcSE5WJgiUaoSpKcSLeQRHhqQSea | QmYVGaMGvqkcBMrJ4F5XrkzwCzhB3FfJvHRBERbtgovCai |
| Amoy | Satsuma | https://subgraph.satsuma-prod.com/decentraland/collections-matic-amoy/playground | QmeJBtfn5mgPH2CbRJpWbwUBmjg64vxTA5KTERaHUtG15u | QmZKxA9VfjFTDNbNDASec194y3rZxiamtEMakWaoFaD8ov |
| Amoy | Satsuma | https://subgraph.satsuma-prod.com/decentraland/collections-matic-amoy/playground | Qmd3Fxkiv9gWH87sWiNDaagU61mns77MizCMoKNDmhqbhK | QmeJBtfn5mgPH2CbRJpWbwUBmjg64vxTA5KTERaHUtG15u |

Using [The Graph](https://thegraph.com) and [Alchemy](https://www.alchemy.com/)

Expand Down
8 changes: 3 additions & 5 deletions src/handlers/collection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down 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
20 changes: 20 additions & 0 deletions src/modules/curation/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
2 changes: 1 addition & 1 deletion src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ export function toLowerCase(str: string): string {
}

return result
}
}

0 comments on commit cfa5fa0

Please sign in to comment.