council.graphql 7.1 KB

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