Skip to content

Commit

Permalink
feat: add totalGRTMintedFromL2 to track L1 bridge minting
Browse files Browse the repository at this point in the history
Signed-off-by: Tomás Migone <tomas@edgeandnode.com>
  • Loading branch information
tmigone authored and juanmardefago committed Apr 11, 2023
1 parent ba97977 commit aae20b8
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 2 deletions.
2 changes: 2 additions & 0 deletions schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand Down
8 changes: 8 additions & 0 deletions src/mappings/l1Gateway.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {
WithdrawalFinalized,
DepositInitiated,
TokensMintedFromL2,
} from '../types/L1GraphTokenGateway/L1GraphTokenGateway'
import { BridgeWithdrawalTransaction, BridgeDepositTransaction } from '../types/schema'
import { getRetryableTicketId, getTransactionIndex } from './helpers/bridge'
Expand Down Expand Up @@ -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()
}
2 changes: 2 additions & 0 deletions subgraph.template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit aae20b8

Please # to comment.