Skip to content

Commit

Permalink
Added UnstakeInit in schema
Browse files Browse the repository at this point in the history
  • Loading branch information
0xKrishna committed Aug 23, 2023
1 parent c16b5c9 commit 4b44718
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
12 changes: 12 additions & 0 deletions root/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
14 changes: 14 additions & 0 deletions root/src/mappings/staking-info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
GlobalDelegationCounter,
DelegatorUnbond,
StakeUpdate as StakeUpdateEntity,
UnstakeInit as UnstakeInitEntity,
} from '../../generated/schema'
import {
ClaimFee,
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 4b44718

Please sign in to comment.