Implement data source templates (#106)

* Implement data source templates

* Remove optional param from wasm instantiate

* Add all types for solidity to typescript mapping

* Set contract address in context for data source templates

* Implement block handlers for data source templates
This commit is contained in:
2022-01-06 18:32:08 +05:30
committed by GitHub
parent 4867530da7
commit aabf9f8e15
35 changed files with 2906 additions and 688 deletions
@@ -0,0 +1,10 @@
import { PoolCreated } from '../../generated/Factory/Factory';
import { Pool as PoolTemplate } from '../../generated/templates';
import { log } from '@graphprotocol/graph-ts';
export function handlePoolCreated (event: PoolCreated): void {
log.debug('PoolCreated event', []);
// create the tracked contract based on the template
PoolTemplate.create(event.params.pool);
}
@@ -0,0 +1,14 @@
import { dataSource, ethereum, log } from '@graphprotocol/graph-ts';
import { Initialize } from '../../generated/templates/Pool/Pool';
export function handleInitialize (event: Initialize): void {
log.debug('event.address: {}', [event.address.toHexString()]);
log.debug('event.params.sqrtPriceX96: {}', [event.params.sqrtPriceX96.toString()]);
log.debug('event.params.tick: {}', [event.params.tick.toString()]);
}
export function handleBlock (block: ethereum.Block): void {
log.debug('block info: {}', [block.number.toString()]);
log.debug('dataSource address: {}', [dataSource.address().toHex()]);
}