From 4b44718c69758b2b2c76df832a39a3857f3df7cf Mon Sep 17 00:00:00 2001 From: Krishna Upadhyaya Date: Wed, 23 Aug 2023 20:47:51 +0530 Subject: [PATCH] Added UnstakeInit in schema --- root/schema.graphql | 12 ++++++++++++ root/src/mappings/staking-info.ts | 14 ++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/root/schema.graphql b/root/schema.graphql index 1989fef..a72ab7a 100644 --- a/root/schema.graphql +++ b/root/schema.graphql @@ -170,6 +170,18 @@ type StakeUpdate @entity { logIndex: BigInt! } +type UnstakeInit @entity { + id: ID! + validatorId: BigInt! + user: Bytes! + amount: BigInt! + block: BigInt! + nonce: BigInt! + transactionHash: Bytes! + logIndex: BigInt! + deactivationEpoch: BigInt! +} + # Keeps track of current delegator counter i.e. how many # delegators are present as of now type GlobalDelegatorCounter @entity { diff --git a/root/src/mappings/staking-info.ts b/root/src/mappings/staking-info.ts index b2a2f4e..e74b2a8 100644 --- a/root/src/mappings/staking-info.ts +++ b/root/src/mappings/staking-info.ts @@ -9,6 +9,7 @@ import { GlobalDelegationCounter, DelegatorUnbond, StakeUpdate as StakeUpdateEntity, + UnstakeInit as UnstakeInitEntity, } from '../../generated/schema' import { ClaimFee, @@ -114,7 +115,20 @@ export function handleUnstakeInit(event: UnstakeInit): void { // set deactivation epoch validator.deactivationEpoch = event.params.deactivationEpoch validator.nonce = event.params.nonce + + // UnstakeInit entity + let unstakeInit = new UnstakeInitEntity(event.transaction.hash.toHex() + '-' + event.logIndex.toString()) + unstakeInit.validatorId = event.params.validatorId + unstakeInit.user = event.params.user + unstakeInit.amount = event.params.amount + unstakeInit.block = event.block.number + unstakeInit.nonce = event.params.nonce + unstakeInit.transactionHash = event.transaction.hash + unstakeInit.logIndex = event.logIndex + unstakeInit.deactivationEpoch = event.params.deactivationEpoch + validator.save() + unstakeInit.save() } export function handleSignerChange(event: SignerChange): void {