From aae20b82b067b179add649741dc1de2154f8940d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Migone?= Date: Mon, 27 Mar 2023 16:55:03 -0300 Subject: [PATCH] feat: add totalGRTMintedFromL2 to track L1 bridge minting MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tomás Migone --- schema.graphql | 2 ++ src/mappings/l1Gateway.ts | 8 ++++++++ subgraph.template.yaml | 2 ++ yarn.lock | 4 ++-- 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/schema.graphql b/schema.graphql index 23846b42..ca20fcef 100644 --- a/schema.graphql +++ b/schema.graphql @@ -203,6 +203,8 @@ type GraphNetwork @entity { totalGRTDeposited: BigInt! "Total amount of GRT withdrawn from the L2 gateway and claimed in L1." totalGRTWithdrawnConfirmed: BigInt! + "Total amount of GRT minted by L1 bridge" + totalGRTMintedFromL2: BigInt! # Bridge totals (Only available on L2 networks) "Total amount of GRT deposited to the L1 gateway and redeemed in L2." diff --git a/src/mappings/l1Gateway.ts b/src/mappings/l1Gateway.ts index 38ca9a35..579fb7b6 100644 --- a/src/mappings/l1Gateway.ts +++ b/src/mappings/l1Gateway.ts @@ -1,6 +1,7 @@ import { WithdrawalFinalized, DepositInitiated, + TokensMintedFromL2, } from '../types/L1GraphTokenGateway/L1GraphTokenGateway' import { BridgeWithdrawalTransaction, BridgeDepositTransaction } from '../types/schema' import { getRetryableTicketId, getTransactionIndex } from './helpers/bridge' @@ -63,3 +64,10 @@ export function handleDepositInitiated(event: DepositInitiated): void { entity.save() } + +export function handleTokensMintedFromL2 (event: TokensMintedFromL2): void { + // Update total GRT minted by bridge + let graphNetwork = createOrLoadGraphNetwork(event.block.number, event.address) + graphNetwork.totalGRTMintedFromL2 = graphNetwork.totalGRTMintedFromL2.plus(event.params.amount) + graphNetwork.save() +} \ No newline at end of file diff --git a/subgraph.template.yaml b/subgraph.template.yaml index 888aaf5b..5922ba4d 100644 --- a/subgraph.template.yaml +++ b/subgraph.template.yaml @@ -455,6 +455,8 @@ dataSources: - event: WithdrawalFinalized(address,indexed address,indexed address,indexed uint256,uint256) handler: handleWithdrawalFinalized receipt: true + - event: TokensMintedFromL2(uint256) + handler: handleTokensMintedFromL2 {{/isL1}} {{^isL1}} - kind: ethereum/contract diff --git a/yarn.lock b/yarn.lock index ec265650..a905307a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2205,9 +2205,9 @@ globby@^11.1.0: merge2 "^1.4.1" slash "^3.0.0" -"gluegun@git+https://github.com/edgeandnode/gluegun.git#v4.3.1-pin-colors-dep": +"gluegun@https://github.com/edgeandnode/gluegun#v4.3.1-pin-colors-dep": version "4.3.1" - resolved "git+https://github.com/edgeandnode/gluegun.git#b34b9003d7bf556836da41b57ef36eb21570620a" + resolved "https://github.com/edgeandnode/gluegun#b34b9003d7bf556836da41b57ef36eb21570620a" dependencies: apisauce "^1.0.1" app-module-path "^2.2.0"