Skip to content

Commit

Permalink
Delete schema's stakeType field from StakeData
Browse files Browse the repository at this point in the history
A stake can have different stake types at the same time (T, NuInTStake
and KeepInTStake), so the StakeType's field can be misleading.
  • Loading branch information
manumonti committed Jun 10, 2022
1 parent 3a193c3 commit 0ef1044
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 11 deletions.
7 changes: 0 additions & 7 deletions schema.graphql
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
enum StakeType {
NU
KEEP
T
}

type Account @entity {
# Id is the ethereum address of the account.
id: ID!
Expand All @@ -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!
Expand Down
7 changes: 3 additions & 4 deletions src/mapping.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 0ef1044

Please sign in to comment.