threshold-network / staking-subgraphs

Threshold Network staking subgraphs
https://threshold.network
1 stars 1 forks source link

Add `applications` field to `stakeData` entity #23

Closed manumonti closed 9 months ago

manumonti commented 2 years ago

A new schema has been proposed in #11:

type StakeData @entity {
  ...
  applications: [Application!] @derivedFrom(field: "stake")
}

interface Application {
  id: ID!
  stake: StakeData!
  authorizedStakeAmount: BigInt!
}

type PREApplication implements Application @entity {
  id: ID! // id = "operatorAddress-preapplication"
  stake: StakeData!
  authorizedStakeAmount: BigInt!
  confirmationTimestamp: BigInt!
 ... // other fields related to the pre app
}

// other applications in the future eg. RandomBeaconApplication
type RandomBeaconApplication implement Application @entity {
...
}

As I understand, PREApplication ID should be <stakingProvider>-preapplication since if the ID is composed of the operator address, we can't easily find the PREOperator entity in order to modify or delete it when this type of event is received. But this will depend on the final PRE application contract.

In my opinion, this issue should be addressed when a definitive version of some Threshold application (PREApplication, TBTC, RandomBeacon) is deployed, since currently there are still in-progress discussions about, for example, authorizedStake events: https://github.com/threshold-network/solidity-contracts/issues/88#issuecomment-1111059312

manumonti commented 9 months ago

This work has been done in #43