From 0ef1044ba62209ac951bc0ba42691427f9cce792 Mon Sep 17 00:00:00 2001 From: Manuel Montenegro Date: Fri, 20 May 2022 15:40:25 +0200 Subject: [PATCH] Delete schema's stakeType field from StakeData A stake can have different stake types at the same time (T, NuInTStake and KeepInTStake), so the StakeType's field can be misleading. --- schema.graphql | 7 ------- src/mapping.ts | 7 +++---- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/schema.graphql b/schema.graphql index 183f247..7a6e0a5 100644 --- a/schema.graphql +++ b/schema.graphql @@ -1,9 +1,3 @@ -enum StakeType { - NU - KEEP - T -} - type Account @entity { # Id is the ethereum address of the account. id: ID! @@ -16,7 +10,6 @@ type StakeData @entity { # ID is the staking provider address id: ID! owner: Account! - stakeType: StakeType! beneficiary: Bytes! authorizer: Bytes! tStake: BigInt! diff --git a/src/mapping.ts b/src/mapping.ts index 0212042..f897706 100644 --- a/src/mapping.ts +++ b/src/mapping.ts @@ -57,14 +57,13 @@ export function handleStaked(event: Staked): void { account.save() } - stakeData.stakeType = type stakeData.owner = account.id stakeData.beneficiary = event.params.beneficiary stakeData.authorizer = event.params.authorizer - stakeData.tStake = type === "T" ? amount : BigInt.zero() - stakeData.nuInTStake = type === "NU" ? amount : BigInt.zero() - stakeData.keepInTStake = type === "KEEP" ? amount : BigInt.zero() + stakeData.tStake = type === "T" ? stakeAmount : BigInt.zero() + stakeData.keepInTStake = type === "KEEP" ? stakeAmount : BigInt.zero() stakeData.totalStaked = stakeData.tStake + stakeData.nuInTStake = type === "NU" ? stakeAmount : BigInt.zero() .plus(stakeData.keepInTStake) .plus(stakeData.nuInTStake) stakeData.save()