You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have created a ponder app that has two contracts defined in the config with identical factory as an address but distinct non-overlapping block ranges. The config is given below:
Additionally, I have created the simple indexing functions as shown below.
ponder.on("uniV3Factory:PoolCreated",async({event, context})=>{awaitcontext.db.insert(factory).values({address: context.contracts.uniV3Factory.address,numPools: 1n}).onConflictDoUpdate((row)=>({numPools: row.numPools+1n,}));awaitcontext.db.insert(pool).values({address: event.args.pool,blockNumber: event.block.number,mintCount: 0n});})ponder.on("uniV3Pools:Mint",async({ event, context })=>{awaitcontext.db.update(pool,{address: event.log.address}).set((row)=>{if(row.blockNumber<19050001n){throwError("Pool created before the startBlock of the contract")}return{mintCount: row.mintCount+1n}})})ponder.on("uniV3PrevPools:Mint",async({ event, context })=>{awaitcontext.db.update(pool,{address: event.log.address}).set((row)=>({mintCount: row.mintCount+1n}))})
Currently, the pools captured via factory for uniV3PrevPools also get captured by factory in uniV3Pools even though they have different block ranges.
Expected behavior
I would expect that uniV3PrevPools would index Mint events only for pools created in 19000000 - 19050000 range and uniV3Pools would index Mint events only for pools created in 19050001 - 19100000 block range. I suspect that the issue in the way childAddresses are fetched from the syncStore, with no apparent filtering on blockRange:
constlogFactorySQL=(qb: SelectQueryBuilder<PonderSyncSchema,"logs",{}>,factory: LogFactory,)=>qb.select((()=>{if(factory.childAddressLocation.startsWith("offset")){constchildAddressOffset=Number(factory.childAddressLocation.substring(6),);conststart=2+12*2+childAddressOffset*2+1;constlength=20*2;returnksql<Hex>`'0x' || substring(data from ${start}::int for ${length}::int)`;}else{conststart=2+12*2+1;constlength=20*2;returnksql<Hex>`'0x' || substring(${ksql.ref(factory.childAddressLocation,)} from ${start}::integer for ${length}::integer)`;}})().as("childAddress"),).distinct().$call((qb)=>{if(Array.isArray(factory.address)){returnqb.where("address","in",factory.address);}returnqb.where("address","=",factory.address);}).where("topic0","=",factory.eventSelector).where("chainId","=",factory.chainId);
Steps to reproduce
No response
Link to repository
No response
Anything else?
No response
The text was updated successfully, but these errors were encountered:
Version
0.9.24
Current behavior
I have created a ponder app that has two contracts defined in the config with identical factory as an address but distinct non-overlapping block ranges. The config is given below:
Additionally, I have created the simple indexing functions as shown below.
The tables are:
Currently, the pools captured via factory for uniV3PrevPools also get captured by factory in uniV3Pools even though they have different block ranges.
Expected behavior
I would expect that uniV3PrevPools would index Mint events only for pools created in 19000000 - 19050000 range and uniV3Pools would index Mint events only for pools created in 19050001 - 19100000 block range. I suspect that the issue in the way childAddresses are fetched from the syncStore, with no apparent filtering on blockRange:
Steps to reproduce
No response
Link to repository
No response
Anything else?
No response
The text was updated successfully, but these errors were encountered: