Skip to content

Commit

Permalink
Update mappings file
Browse files Browse the repository at this point in the history
  • Loading branch information
seandotau authored Sep 6, 2023
1 parent d57e26b commit 2b67af3
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions docs/quickstart/quickstart_chains/polygon-zkevm.md
Original file line number Diff line number Diff line change
Expand Up @@ -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<void> {
logger.info(`New transfer transaction log at block ${log.blockNumber}`);
assert(log.args, "No log.args");
Expand Down Expand Up @@ -172,6 +179,7 @@ export async function handleTransaction(tx: ApproveTransaction): Promise<void> {

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_).
Expand Down

0 comments on commit 2b67af3

Please sign in to comment.