mirror of
https://github.com/cerc-io/watcher-ts
synced 2026-09-11 18:24:05 +00:00
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:
@@ -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()]);
|
||||
}
|
||||
Reference in New Issue
Block a user