From 44c51a1d5306df43035287e46b5278d504474938 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 | 8 ++++---- 2 files changed, 4 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..a0e3bab 100644 --- a/src/mapping.ts +++ b/src/mapping.ts @@ -57,16 +57,16 @@ 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.totalStaked = stakeData.tStake - .plus(stakeData.keepInTStake) - .plus(stakeData.nuInTStake) + stakeData.nuInTStake = + type === "NU" + ? amount + : BigInt.zero().plus(stakeData.keepInTStake).plus(stakeData.nuInTStake) stakeData.save() const lastEpoch = getOrCreateLastEpoch()