Open vikiival opened 1 year ago
I don't have examples related to handling ink factory contracts... but i believe it can be achived by code like this:
const FACTORY_ADDRESS = '0x5207202c27b646ceeb294ce516d4334edafbd771f869215cb070ba51dd7e2c72'
const processor = new SubstrateBatchProcessor()
.setDataSource({
archive: "https://shibuya.archive.subsquid.io/graphql"
})
.addContractsContractEmitted('*')
processor.run(new TypeormDatabase(), async (ctx) => {
for (const block of ctx.blocks) {
for (const item of block.items) {
if (item.kind === 'event' && item.name === 'Contracts.ContractEmitted') {
const contractAddress = item.event.args.contract
if (contractAddress === FACTORY_ADDRESS) {
// update the list of contracts to watch
} else if (await isPairContract(ctx.store, contractAddress)) {
// the contract has been created by the factory,
// index the event
}
}
}
}
})
ink! smart contracts have topics but they are encoded in data (item.event.args.data) so only contractAddress can be filtered
The question for the @subsquid team.
Is it possible to add some sort of filtering?
@tmcgroul can we implement something like this?
unfortunately it's impossible to add additional filtering. contracts-pallet just doesn't expose enough open data for filtering (only contract address)
EVM processor has ability to check for factory contracts
SQUID EVM FACTORY
It would be possible to use this approach and would be much simplier than #3.
Blocked by SubSquid currently