diff --git a/schema.graphql b/schema.graphql index 8980797..e9e1825 100644 --- a/schema.graphql +++ b/schema.graphql @@ -847,28 +847,45 @@ type Provision @entity { tokensProvisioned: BigInt! + "Timestamp when the provision was created" + createdAt: BigInt! + "Service provider tokens that are being thawed (and will stop being slashable soon)" tokensThawing: BigInt! - "Shares representing the thawing tokens" - sharesThawing: BigInt! - "Max amount that can be taken by the verifier when slashing, expressed in parts-per-million of the amount slashed" maxVerifierCut: Int! - "Time, in seconds, tokens must thaw before being withdrawn" - thawingPeriod: BigInt! - - "Timestamp when the provision was created" - createdAt: BigInt! - "Pending value for maxVerifierCut. Verifier needs to accept it before it becomes active" maxVerifierCutPending: Int! + "Time, in seconds, tokens must thaw before being withdrawn" + thawingPeriod: BigInt! + "Pending value for thawingPeriod. Verifier needs to accept it before it becomes active" thawingPeriodPending: BigInt! } +type ThawRequest @entity { + id: ID! + + indexer: Indexer! + + service: DataService! + + owner: GraphAccount! + + "Shares representing the thawing tokens" + shares: BigInt! + + "Tokens thawed" + tokens: BigInt! + + thawingUntil: BigInt! + + valid: Boolean +} + """ A state channel Allocation representing a single Indexer-SubgraphDeployment stake """ diff --git a/src/mappings/horizonStaking.ts b/src/mappings/horizonStaking.ts index 1312e74..8557099 100644 --- a/src/mappings/horizonStaking.ts +++ b/src/mappings/horizonStaking.ts @@ -1,8 +1,8 @@ import { BigInt, log } from '@graphprotocol/graph-ts' import { addresses } from '../../config/addresses' import { HorizonStakeDeposited, HorizonStakeLocked, HorizonStakeWithdrawn, TokensDeprovisioned } from '../types/HorizonStaking/HorizonStaking' -import { Indexer, GraphNetwork } from '../types/schema' -import { calculateCapacities, createOrLoadDataService, createOrLoadEpoch, createOrLoadGraphNetwork, createOrLoadIndexer, createOrLoadProvision, updateAdvancedIndexerMetrics } from './helpers/helpers' +import { Indexer, GraphNetwork, ThawRequest } from '../types/schema' +import { calculateCapacities, createOrLoadDataService, createOrLoadEpoch, createOrLoadGraphAccount, createOrLoadGraphNetwork, createOrLoadIndexer, createOrLoadProvision, updateAdvancedIndexerMetrics } from './helpers/helpers' import { ProvisionCreated, ProvisionIncreased, @@ -177,17 +177,23 @@ export function handleProvisionSlashed(event: ProvisionSlashed): void { } export function handleThawRequestCreated(event: ThawRequestCreated): void { - // To Do + let dataService = createOrLoadDataService(event.params.verifier) + let indexer = Indexer.load(event.params.serviceProvider.toHexString())! + let owner = createOrLoadGraphAccount(event.params.owner, event.block.timestamp) + + let request = new ThawRequest(event.params.thawRequestId.toHexString()) + request.indexer = indexer.id + request.service = dataService.id + request.owner = owner.id + request.shares = event.params.shares + request.tokens = BigInt.fromI32(0) + request.thawingUntil = event.params.thawingUntil + request.save() } export function handleThawRequestFulfilled(event: ThawRequestFulfilled): void { - // To Do -} - -export function handleThawRequestsFulfilled(event: ThawRequestsFulfilled): void { - // To Do -} - -export function handleThawingPeriodCleared(event: ThawingPeriodCleared): void { - // To Do -} + let request = ThawRequest.load(event.params.thawRequestId.toHexString()) + request.tokens = event.params.tokens + request.valid = event.params.valid + request.save() +} \ No newline at end of file diff --git a/subgraph.template.yaml b/subgraph.template.yaml index c916346..4036bfe 100644 --- a/subgraph.template.yaml +++ b/subgraph.template.yaml @@ -423,10 +423,6 @@ dataSources: handler: handleThawRequestCreated - event: ThawRequestFulfilled(indexed bytes32,uint256,uint256,uint64,bool) handler: handleThawRequestFulfilled - - event: ThawRequestsFulfilled(indexed address,indexed address,indexed address,uint256,uint256,uint8) - handler: handleThawRequestsFulfilled - - event: ThawingPeriodCleared() - handler: handleThawingPeriodCleared - kind: ethereum/contract name: Curation network: {{network}}