UNPKG

@graphprotocol/graph-cli

Version:

CLI for building for and deploying to The Graph

32 lines (31 loc) 1.01 kB
import { strings } from 'gluegun'; import { abiEvents } from '../../../scaffold/schema.js'; import ABI from '../abi.js'; export const source = ({ contract, contractName, startBlock, }) => startBlock ? ` address: '${contract}' abi: ${contractName} startBlock: ${startBlock}` : ` address: '${contract}' abi: ${contractName}`; export const mapping = ({ abi, contractName }) => ` kind: ethereum/events apiVersion: 0.0.9 language: wasm/assemblyscript entities: ${abiEvents(abi) .map(event => `- ${event.get('collision') ? `${contractName}${event.get('_alias')}` : event.get('_alias')}`) .join('\n ')} abis: - name: ${contractName} file: ./abis/${contractName}.json eventHandlers: ${abiEvents(abi) .map(event => ` - event: ${ABI.eventSignature(event)} handler: handle${event.get('_alias')}`) .join('')} file: ./src/${strings.kebabCase(contractName)}.ts`;