diff --git a/root/schema.graphql b/root/schema.graphql index 6444629..0453674 100644 --- a/root/schema.graphql +++ b/root/schema.graphql @@ -158,6 +158,16 @@ type Validator @entity { isInAuction: Boolean! } +type StakeUpdate @entity { + id: ID! + validatorId: BigInt! + totalStaked: BigInt! + block: BigInt! + nonce: BigInt! + transactionHash: Bytes! + logIndex: 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 3be695f..39feb38 100644 --- a/root/src/mappings/staking-info.ts +++ b/root/src/mappings/staking-info.ts @@ -6,6 +6,7 @@ import { StakingParams, GlobalDelegatorCounter, DelegatorUnbond, + StakeUpdate as StakeUpdateEntity, } from '../../generated/schema' import { ClaimFee, @@ -163,7 +164,17 @@ export function handleStakeUpdate(event: StakeUpdate): void { // from totalStaked validator.selfStake = validator.totalStaked.minus(validator.delegatedStake) + //Stake update entity + let stakeUpdate = new StakeUpdateEntity(event.transaction.hash.toHex() + '-' + event.logIndex.toString()) + stakeUpdate.totalStaked = event.params.newAmount + stakeUpdate.nonce = event.params.nonce + stakeUpdate.block = event.block.number + stakeUpdate.transactionHash = event.transaction.hash + stakeUpdate.validatorId = event.params.validatorId + stakeUpdate.logIndex = event.logIndex + validator.save() + stakeUpdate.save() } export function handleClaimRewards(event: ClaimRewards): void {