council.graphql 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282
  1. # TODO:
  2. # - do we need some fulltext search for council/election?
  3. # workaround for https://github.com/Joystream/hydra/issues/434
  4. type VariantNone @variant {
  5. _phantom: Int
  6. }
  7. ################### Council ####################################################
  8. type CouncilStageUpdate @entity {
  9. "The new stage council got into."
  10. stage: CouncilStage!
  11. "Block number at which change happened."
  12. changedAt: BigInt!
  13. "Council term during which the update happened (if any)."
  14. electedCouncil: ElectedCouncil
  15. "Election not completed due to insufficient candidates or winners."
  16. electionProblem: ElectionProblem
  17. }
  18. type CouncilStageAnnouncing @variant {
  19. "Number of candidates aspiring to be elected as council members."
  20. candidatesCount: BigInt!
  21. }
  22. type CouncilStageElection @variant {
  23. "Number of candidates aspiring to be elected as council members."
  24. candidatesCount: BigInt!
  25. }
  26. type CouncilStageIdle @variant {
  27. # no properties
  28. # TODO: remove me - variant needs to have at least 1 property now
  29. dummy: Int
  30. }
  31. union CouncilStage = CouncilStageAnnouncing | CouncilStageElection | CouncilStageIdle | VariantNone
  32. enum ElectionProblem {
  33. NOT_ENOUGH_CANDIDATES
  34. NEW_COUNCIL_NOT_ELECTED
  35. }
  36. enum CandidacyStatus {
  37. ACTIVE
  38. WITHDRAWN
  39. ELECTED
  40. FAILED
  41. }
  42. type Candidate @entity {
  43. "Account used for staking currency needed for the candidacy."
  44. stakingAccountId: String!
  45. "Account that will receive rewards if candidate's elected to the council."
  46. rewardAccountId: String!
  47. "Candidate's membership."
  48. member: Membership!
  49. "Election cycle"
  50. electionRound: ElectionRound!
  51. "Stake locked for the candidacy."
  52. stake: BigInt!
  53. "Reflects if the stake is still locked for candidacy or has been already released by the member."
  54. stakeLocked: Boolean!
  55. "Current candidate status"
  56. status: CandidacyStatus!
  57. "Sum of power of all votes received."
  58. votePower: BigInt!
  59. "Block in which the last vote was received."
  60. lastVoteReceivedAtBlock: BigInt
  61. "Event number in block in which the last vote was received."
  62. lastVoteReceivedAtEventNumber: Int
  63. "The metadata contained in note."
  64. noteMetadata: CandidacyNoteMetadata!
  65. "Votes received in referendums by this member."
  66. votesReceived: [CastVote!]! @derivedFrom(field: "voteFor")
  67. }
  68. type CouncilMember @entity {
  69. "Runtime council member id"
  70. id: ID!
  71. "Account used for staking currency for council membership."
  72. stakingAccountId: String!
  73. "Account that will receive used for reward currency for council membership."
  74. rewardAccountId: String!
  75. "Council member's membership."
  76. member: Membership!
  77. "Stake used for the council membership."
  78. stake: BigInt!
  79. "Block number in which council member received the last reward payment."
  80. lastPaymentBlock: BigInt!
  81. "Reward amount that should have been paid but couldn't be paid off due to insufficient budget."
  82. unpaidReward: BigInt!
  83. "Amount of reward collected by this council member so far."
  84. accumulatedReward: BigInt!
  85. electedInCouncil: ElectedCouncil!
  86. }
  87. type CandidacyNoteMetadata @entity {
  88. "Candidacy header text."
  89. header: String
  90. "Candidate program in form of bullet points. Takes array with one empty string [''] as deletion request."
  91. bulletPoints: [String!]
  92. "Image uri of candidate's banner."
  93. bannerImageUri: String
  94. "Candidacy description (Markdown-formatted)."
  95. description: String
  96. }
  97. ################### Referendum #################################################
  98. # NOTE: Due to the bug https://github.com/Joystream/hydra/issues/467 `ReferendumStage*` variants were transformed to entities.
  99. # It shouldn't have any negative impact on current usage, but it might need remodeling in the future depending on usage.
  100. type ReferendumStageVoting @entity {
  101. "Block in which referendum started."
  102. startedAtBlock: BigInt!
  103. "Target number of winners."
  104. winningTargetCount: BigInt!
  105. "Election round"
  106. electionRound: ElectionRound!
  107. }
  108. type ReferendumStageRevealing @entity {
  109. "Block in which referendum started"
  110. startedAtBlock: BigInt!
  111. "Target number of winners"
  112. winningTargetCount: BigInt!
  113. "Election round."
  114. electionRound: ElectionRound!
  115. }
  116. type CastVote @entity {
  117. "Hashed vote that was casted before being revealed. Hex format."
  118. commitment: String!
  119. "Election round."
  120. electionRound: ElectionRound!
  121. "Stake used to back up the vote."
  122. stake: BigInt!
  123. "Reflects if the stake is still locked for candidacy or has been already released by the member."
  124. stakeLocked: Boolean!
  125. "Account that cast the vote."
  126. castBy: String!
  127. "Member receiving the vote."
  128. voteFor: Candidate
  129. "Vote's power."
  130. votePower: BigInt!
  131. }
  132. ################### Derived ####################################################
  133. type ElectedCouncil @entity {
  134. "Members that were elected to the council."
  135. councilMembers: [CouncilMember!]! @derivedFrom(field: "electedInCouncil")
  136. "Changes to council status that were made during it's reign."
  137. updates: [CouncilStageUpdate!]! @derivedFrom(field: "electedCouncil")
  138. "Block number at which the council was elected."
  139. electedAtBlock: Int!
  140. "Block number at which the council reign ended and a new council was elected."
  141. endedAtBlock: Int
  142. "Time at which the council was elected."
  143. electedAtTime: DateTime!
  144. "Time at which the council reign ended and a new council was elected."
  145. endedAtTime: DateTime
  146. "Network running at the time of election."
  147. electedAtNetwork: Network!
  148. "Network running at the time of resignation."
  149. endedAtNetwork: Network
  150. # it might seems that derived field is wrongly set to `nextElectedCouncil`, but that's how it should be
  151. "Elections held before the council was rightfully elected."
  152. councilElections: [ElectionRound!]! @derivedFrom(field: "nextElectedCouncil")
  153. # it might seems that derived field is wrongly set to `electedCouncil`, but that's how it should be
  154. "Elections held before the next council was or will be rightfully elected."
  155. nextCouncilElections: [ElectionRound!]! @derivedFrom(field: "electedCouncil")
  156. "Sign if council is already resigned."
  157. isResigned: Boolean!
  158. }
  159. type ElectionRound @entity {
  160. "Election cycle ID."
  161. cycleId: Int!
  162. "Sign if election has already finished."
  163. isFinished: Boolean!
  164. "Block number at which the election ended."
  165. endedAtBlock: Int
  166. "Time at which the election ended."
  167. endedAtTime: DateTime
  168. "Network running at the time the election ended."
  169. endedAtNetwork: Network
  170. "Vote cast in the election round."
  171. castVotes: [CastVote!]! @derivedFrom(field: "electionRound")
  172. "Referendum voting stage that happened during this election round."
  173. referendumStageVoting: ReferendumStageVoting @derivedFrom(field: "electionRound")
  174. "Referendum revealing stage that happened during this election round."
  175. referendumStageRevealing: ReferendumStageRevealing @derivedFrom(field: "electionRound")
  176. "Council that is ruling during the election."
  177. electedCouncil: ElectedCouncil!
  178. "Council that was elected in this election round."
  179. nextElectedCouncil: ElectedCouncil
  180. "Candidates in this election round."
  181. candidates: [Candidate!]! @derivedFrom(field: "electionRound")
  182. }
  183. # Not yet sure if this will be needed by apps using query node.
  184. #
  185. #type Budget @entity {
  186. # "Block number at which the next rewards will be paid."
  187. # nextRewardPaymentsAt: BigInt!
  188. #}
  189. #
  190. #type BudgetPayment @entity {
  191. # "Block number at which the payment was done."
  192. # paidAtBlock: Int!
  193. #
  194. # "Member that was paid."
  195. # member: Membership!
  196. #
  197. # "Account that received the payment"
  198. # account: String!
  199. #
  200. # "Amount that was paid."
  201. # amount: BigInt!
  202. #
  203. # "Amount that couldn't be paid due to insufficient council budget's balance."
  204. # unpaidAmount: BigInt!
  205. #}