Skip to content

Commit dfa15dd

Browse files
committed
feat: added basic service registry for Horizon
1 parent 83303d3 commit dfa15dd

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

schema.graphql

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -898,6 +898,13 @@ type Provision @entity {
898898
delegatorShares: BigInt!
899899
"Exchange rate of of tokens received for each share"
900900
delegationExchangeRate: BigDecimal!
901+
902+
"Service registry URL for the indexer"
903+
url: String
904+
"Geohash of the indexer. Shows where their indexer is located in the world"
905+
geoHash: String
906+
"Address set as rewards destination for payments to the service provider"
907+
rewardsDestination: Bytes
901908
}
902909

903910
enum PaymentTypes {

src/mappings/subgraphService.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,17 @@
1-
// ToDo
1+
import { ethereum } from "@graphprotocol/graph-ts"
2+
import { RewardsDestinationSet, ServiceProviderRegistered } from "../types/SubgraphService/SubgraphService"
3+
import { createOrLoadProvision } from "./helpers/helpers"
4+
5+
export function handleServiceProviderRegistered(event: ServiceProviderRegistered): void {
6+
let decodedCalldata = ethereum.decode('(string,string,address)', event.params.data).toTuple()
7+
let provision = createOrLoadProvision(event.params.serviceProvider, event.address, event.block.timestamp)
8+
provision.url = decodedCalldata[0].toString()
9+
provision.geoHash = decodedCalldata[1].toString()
10+
provision.save()
11+
}
12+
13+
export function handleRewardsDestinationSet(event: RewardsDestinationSet): void {
14+
let provision = createOrLoadProvision(event.params.indexer, event.address, event.block.timestamp)
15+
provision.rewardsDestination = event.params.rewardsDestination
16+
provision.save()
17+
}

0 commit comments

Comments
 (0)