council.graphql 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280
  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. type Candidate @entity {
  37. "Account used for staking currency needed for the candidacy."
  38. stakingAccountId: String!
  39. "Account that will receive rewards if candidate's elected to the council."
  40. rewardAccountId: String!
  41. "Candidate's membership."
  42. member: Membership!
  43. "Election cycle"
  44. electionRound: ElectionRound!
  45. "Stake locked for the candidacy."
  46. stake: BigInt!
  47. "Reflects if the stake is still locked for candidacy or has been already released by the member."
  48. stakeLocked: Boolean!
  49. "Reflects if the candidacy was withdrawn before voting started."
  50. candidacyWithdrawn: Boolean!
  51. "Sum of power of all votes received."
  52. votePower: BigInt!
  53. "The metadata contained in note."
  54. noteMetadata: CandidacyNoteMetadata!
  55. "Votes recieved in referendums by this member."
  56. votesRecieved: [CastVote!]! @derivedFrom(field: "voteFor")
  57. }
  58. type CouncilMember @entity {
  59. "Runtime council member id"
  60. id: ID!
  61. "Account used for staking currency for council membership."
  62. stakingAccountId: String!
  63. "Account that will receive used for reward currency for council membership."
  64. rewardAccountId: String!
  65. "Council member's membership."
  66. member: Membership!
  67. "Stake used for the council membership."
  68. stake: BigInt!
  69. "Block number in which council member recieved the last reward payment."
  70. lastPaymentBlock: BigInt!
  71. "Reward amount that should have been paid but couldn't be paid off due to insufficient budget."
  72. unpaidReward: BigInt!
  73. "Amount of reward collected by this council member so far."
  74. accumulatedReward: BigInt!
  75. electedInCouncil: ElectedCouncil!
  76. }
  77. type CandidacyNoteMetadata @entity {
  78. "Candidacy header text."
  79. header: String
  80. "Candidate program in form of bullet points."
  81. bulletPoints: [String!]!
  82. "Image uri of candidate's banner."
  83. bannerImageUri: String
  84. "Candidacy description (Markdown-formatted)."
  85. description: String
  86. }
  87. ################### Referendum #################################################
  88. # This section (ReferendumStage*) is not useful before referencing variant is solved.
  89. # See commented reference in ElectionRound, for example.
  90. # Uncomment after solving the issue or delete if it can't be solved or is not needed
  91. # in the future.
  92. #
  93. #type ReferendumStageInactive @variant {
  94. # # no properties
  95. #
  96. # # TODO: remove me - variant needs to have at least 1 property now
  97. # dummy: Int
  98. #}
  99. #
  100. #type ReferendumStageVoting @variant {
  101. # "Block in which referendum started."
  102. # started: BigInt!
  103. #
  104. # "Target number of winners."
  105. # winningTargetCount: BigInt!
  106. #
  107. # "Index of current election"
  108. # electionRound: ElectionRound!
  109. #}
  110. #
  111. #type ReferendumStageRevealing @variant {
  112. # "Block in which referendum started"
  113. # started: BigInt!
  114. #
  115. # "Target number of winners"
  116. # winningTargetCount: BigInt!
  117. #
  118. # "Intermediate winning options"
  119. # intermediateWinners: [ReferendumStageRevealingOptionResult!]!
  120. #
  121. # "Index of current election"
  122. # electionRound: ElectionRound!
  123. #}
  124. type ReferendumStageRevealingOptionResult @entity {
  125. "Member that received votes."
  126. option: Membership!
  127. "Sum of votes' power received."
  128. votePower: BigInt!
  129. # TODO: reference variant (how?)
  130. #referendumRevealingStages: [ReferendumStageRevealing!]! @derivedFrom(field: "intermediateWinners")
  131. "Election round."
  132. electionRound: ElectionRound!
  133. "Event that concluded the referendum."
  134. referendumFinishedEvent: ReferendumFinishedEvent!
  135. }
  136. # TODO: this maybe needs to be @entity - so it's saved in db
  137. #union ReferendumStage = ReferendumStageInactive | ReferendumStageVoting | ReferendumStageRevealing | VariantNone
  138. type CastVote @entity {
  139. "Hashed vote that was casted before being revealed. Hex format."
  140. commitment: String!
  141. "Election round."
  142. electionRound: ElectionRound!
  143. "Stake used to back up the vote."
  144. stake: BigInt!
  145. "Reflects if the stake is still locked for candidacy or has been already released by the member."
  146. stakeLocked: Boolean!
  147. "Account that cast the vote."
  148. castBy: String!
  149. "Member receiving the vote."
  150. voteFor: Candidate
  151. "Vote's power."
  152. votePower: BigInt!
  153. }
  154. ################### Derived ####################################################
  155. type ElectedCouncil @entity {
  156. "Members that were elected to the council."
  157. councilMembers: [CouncilMember!]! @derivedFrom(field: "electedInCouncil")
  158. "Changes to council status that were made during it's reign."
  159. updates: [CouncilStageUpdate!]! @derivedFrom(field: "electedCouncil")
  160. "Block number at which the council was elected."
  161. electedAtBlock: Int!
  162. "Block number at which the council reign ended and a new council was elected."
  163. endedAtBlock: Int
  164. # it might seem that derived field is wrongly set to `nextElectedCouncil`, but that's how it should be
  165. "Elections held before the council was rightfully elected."
  166. #councilElections: [ElectionRound!]! @derivedFrom(field: "electedCouncil")
  167. councilElections: [ElectionRound!]! @derivedFrom(field: "nextElectedCouncil")
  168. # it might seem that derived field is wrongly set to `electedCouncil`, but that's how it should be
  169. "Elections held before the next council was or will be rightfully elected."
  170. #nextCouncilElections: [ElectionRound!]! @derivedFrom(field: "nextElectedCouncil")
  171. nextCouncilElections: [ElectionRound!]! @derivedFrom(field: "electedCouncil")
  172. "Sign if council is already resigned."
  173. isResigned: Boolean!
  174. }
  175. type ElectionRound @entity {
  176. "Election cycle ID."
  177. cycleId: Int!
  178. "Sign if election has already finished."
  179. isFinished: Boolean!
  180. "Vote cast in the election round."
  181. castVotes: [CastVote!]! @derivedFrom(field: "electionRound")
  182. # TODO: reference variant (how?)
  183. #referendumStageVoting: ReferendumStage @derivedFrom(field: "cycleId")
  184. #referendumStageRevealing: ReferendumStage @derivedFrom(field: "cycleId")
  185. "Council that is ruling during the election."
  186. electedCouncil: ElectedCouncil!
  187. "Council that was elected in this election round."
  188. nextElectedCouncil: ElectedCouncil
  189. "Candidates in this election round."
  190. candidates: [Candidate!]! @derivedFrom(field: "electionRound")
  191. }
  192. # Not yet sure if this will be needed by apps using query node.
  193. #
  194. #type Budget @entity {
  195. # "Block number at which the next rewards will be paid."
  196. # nextRewardPaymentsAt: BigInt!
  197. #}
  198. #
  199. #type BudgetPayment @entity {
  200. # "Block number at which the payment was done."
  201. # paidAtBlock: Int!
  202. #
  203. # "Member that was paid."
  204. # member: Membership!
  205. #
  206. # "Account that received the payment"
  207. # account: String!
  208. #
  209. # "Amount that was paid."
  210. # amount: BigInt!
  211. #
  212. # "Amount that couldn't be paid due to insufficient council budget's balance."
  213. # unpaidAmount: BigInt!
  214. #}