diff --git a/root/src/mappings/staking-info.ts b/root/src/mappings/staking-info.ts index fb31d07..1e952a6 100644 --- a/root/src/mappings/staking-info.ts +++ b/root/src/mappings/staking-info.ts @@ -98,7 +98,8 @@ export function handleUnstaked(event: Unstaked): void { // update unstaked status validator.status = 1 - validator.selfStake = BigInt.fromI32(0) + validator.totalStaked = event.params.total + validator.selfStake = validator.selfStake.minus(event.params.amount) validator.save() } @@ -289,6 +290,7 @@ export function handleShareBurned(event: ShareBurned): void { let validator = loadValidator(event.params.validatorId) validator.delegatedStake = validator.delegatedStake.minus(event.params.amount) + validator.totalStaked = validator.totalStaked.minus(event.params.amount) validator.save() // -- Saving updation @@ -312,6 +314,7 @@ export function handleShareBurnedWithId(event: ShareBurnedWithId): void { let validator = loadValidator(event.params.validatorId) validator.delegatedStake = validator.delegatedStake.minus(event.params.amount) + validator.totalStaked = validator.totalStaked.minus(event.params.amount) validator.save() // -- Saving updation diff --git a/root/src/mappings/staking-nft.ts b/root/src/mappings/staking-nft.ts index 010e734..26b0e54 100644 --- a/root/src/mappings/staking-nft.ts +++ b/root/src/mappings/staking-nft.ts @@ -1,5 +1,5 @@ import { Transfer } from '../../generated/StakingNft/StakingNft' -import { StakingNFTTransfer } from '../../generated/schema' +import { StakingNFTTransfer, Validator } from '../../generated/schema' // To be invoked when staking NFT contracts Transfer event to be emitted // @@ -26,7 +26,11 @@ export function handleTransfer(event: Transfer): void { let transactionHashes = entity.transactionHashes transactionHashes.push(event.transaction.hash) entity.transactionHashes = transactionHashes + let validatorId = 'validator:' + event.params.tokenId.toString() + let validator = Validator.load(validatorId) + validator.owner = event.params.to // save entity entity.save() + validator.save() } diff --git a/root/subgraph.template.yaml b/root/subgraph.template.yaml index 4a52674..694f7de 100644 --- a/root/subgraph.template.yaml +++ b/root/subgraph.template.yaml @@ -210,6 +210,7 @@ dataSources: language: wasm/assemblyscript entities: - StakingNFTTransfer + - Validator abis: - name: StakingNft file: ./abis/StakingNft.json