From 2b67af37c3cd689445acec8c8b2f28d7756b33ae Mon Sep 17 00:00:00 2001 From: seandotau Date: Wed, 6 Sep 2023 12:21:31 +1000 Subject: [PATCH] Update mappings file --- docs/quickstart/quickstart_chains/polygon-zkevm.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/docs/quickstart/quickstart_chains/polygon-zkevm.md b/docs/quickstart/quickstart_chains/polygon-zkevm.md index 600bb1e80a9..74bef80019a 100644 --- a/docs/quickstart/quickstart_chains/polygon-zkevm.md +++ b/docs/quickstart/quickstart_chains/polygon-zkevm.md @@ -142,6 +142,13 @@ Mapping functions define how chain data is transformed into the optimised GraphQ Navigate to the default mapping function in the `src/mappings` directory. You will be able to see two exported functions `handleLog` and `handleTransaction`: ```ts +import { Approval, Transfer } from "../types"; +import { + ApproveTransaction, + TransferLog, +} from "../types/abi-interfaces/Erc20Abi"; +import assert from "assert"; + export async function handleLog(log: TransferLog): Promise { logger.info(`New transfer transaction log at block ${log.blockNumber}`); assert(log.args, "No log.args"); @@ -172,6 +179,7 @@ export async function handleTransaction(tx: ApproveTransaction): Promise { await approval.save(); } + ``` The `handleLog` function receives a `log` parameter of type `TransferLog` which includes log data in the payload. We extract this data and then save this to the store using the `.save()` function (_Note that SubQuery will automatically save this to the database_).