council.graphql 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  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. "Block in which the last vote was received."
  54. lastVoteReceivedAtBlock: BigInt
  55. "Event number in block in which the last vote was received."
  56. lastVoteReceivedAtEventNumber: Int
  57. "The metadata contained in note."
  58. noteMetadata: CandidacyNoteMetadata!
  59. "Votes recieved in referendums by this member."
  60. votesRecieved: [CastVote!]! @derivedFrom(field: "voteFor")
  61. }
  62. type CouncilMember @entity {
  63. "Runtime council member id"
  64. id: ID!
  65. "Account used for staking currency for council membership."
  66. stakingAccountId: String!
  67. "Account that will receive used for reward currency for council membership."
  68. rewardAccountId: String!
  69. "Council member's membership."
  70. member: Membership!
  71. "Stake used for the council membership."
  72. stake: BigInt!
  73. "Block number in which council member recieved the last reward payment."
  74. lastPaymentBlock: BigInt!
  75. "Reward amount that should have been paid but couldn't be paid off due to insufficient budget."
  76. unpaidReward: BigInt!
  77. "Amount of reward collected by this council member so far."
  78. accumulatedReward: BigInt!
  79. electedInCouncil: ElectedCouncil!
  80. }
  81. type CandidacyNoteMetadata @entity {
  82. "Candidacy header text."
  83. header: String
  84. "Candidate program in form of bullet points. Takes array with one empty string [''] as deletion request."
  85. bulletPoints: [String!]
  86. "Image uri of candidate's banner."
  87. bannerImageUri: String
  88. "Candidacy description (Markdown-formatted)."
  89. description: String
  90. }
  91. ################### Referendum #################################################
  92. # NOTE: Due to the bug https://github.com/Joystream/hydra/issues/467 `ReferendumStage*` variants were transformed to entities.
  93. # It shouldn't have any negative impact on current usage, but it might need remodeling in the future depending on usage.
  94. type ReferendumStageVoting @entity {
  95. "Block in which referendum started."
  96. startedAtBlock: BigInt!
  97. "Target number of winners."
  98. winningTargetCount: BigInt!
  99. "Election round"
  100. electionRound: ElectionRound!
  101. }
  102. type ReferendumStageRevealing @entity {
  103. "Block in which referendum started"
  104. startedAtBlock: BigInt!
  105. "Target number of winners"
  106. winningTargetCount: BigInt!
  107. "Election round."
  108. electionRound: ElectionRound!
  109. }
  110. type CastVote @entity {
  111. "Hashed vote that was casted before being revealed. Hex format."
  112. commitment: String!
  113. "Election round."
  114. electionRound: ElectionRound!
  115. "Stake used to back up the vote."
  116. stake: BigInt!
  117. "Reflects if the stake is still locked for candidacy or has been already released by the member."
  118. stakeLocked: Boolean!
  119. "Account that cast the vote."
  120. castBy: String!
  121. "Member receiving the vote."
  122. voteFor: Candidate
  123. "Vote's power."
  124. votePower: BigInt!
  125. }
  126. ################### Derived ####################################################
  127. type ElectedCouncil @entity {
  128. "Members that were elected to the council."
  129. councilMembers: [CouncilMember!]! @derivedFrom(field: "electedInCouncil")
  130. "Changes to council status that were made during it's reign."
  131. updates: [CouncilStageUpdate!]! @derivedFrom(field: "electedCouncil")
  132. "Block number at which the council was elected."
  133. electedAtBlock: Int!
  134. "Block number at which the council reign ended and a new council was elected."
  135. endedAtBlock: Int
  136. "Time at which the council was elected."
  137. electedAtTime: DateTime!
  138. "Time at which the council reign ended and a new council was elected."
  139. endedAtTime: DateTime
  140. "Network running at the time of election."
  141. electedAtNetwork: Network!
  142. "Network running at the time of resignation."
  143. endedAtNetwork: Network
  144. # it might seems that derived field is wrongly set to `nextElectedCouncil`, but that's how it should be
  145. "Elections held before the council was rightfully elected."
  146. councilElections: [ElectionRound!]! @derivedFrom(field: "nextElectedCouncil")
  147. # it might seems that derived field is wrongly set to `electedCouncil`, but that's how it should be
  148. "Elections held before the next council was or will be rightfully elected."
  149. nextCouncilElections: [ElectionRound!]! @derivedFrom(field: "electedCouncil")
  150. "Sign if council is already resigned."
  151. isResigned: Boolean!
  152. }
  153. type ElectionRound @entity {
  154. "Election cycle ID."
  155. cycleId: Int!
  156. "Sign if election has already finished."
  157. isFinished: Boolean!
  158. "Vote cast in the election round."
  159. castVotes: [CastVote!]! @derivedFrom(field: "electionRound")
  160. "Referendum voting stage that happened during this election round."
  161. referendumStageVoting: ReferendumStageVoting @derivedFrom(field: "electionRound")
  162. "Referendum revealing stage that happened during this election round."
  163. referendumStageRevealing: ReferendumStageRevealing @derivedFrom(field: "electionRound")
  164. "Council that is ruling during the election."
  165. electedCouncil: ElectedCouncil!
  166. "Council that was elected in this election round."
  167. nextElectedCouncil: ElectedCouncil
  168. "Candidates in this election round."
  169. candidates: [Candidate!]! @derivedFrom(field: "electionRound")
  170. }
  171. # Not yet sure if this will be needed by apps using query node.
  172. #
  173. #type Budget @entity {
  174. # "Block number at which the next rewards will be paid."
  175. # nextRewardPaymentsAt: BigInt!
  176. #}
  177. #
  178. #type BudgetPayment @entity {
  179. # "Block number at which the payment was done."
  180. # paidAtBlock: Int!
  181. #
  182. # "Member that was paid."
  183. # member: Membership!
  184. #
  185. # "Account that received the payment"
  186. # account: String!
  187. #
  188. # "Amount that was paid."
  189. # amount: BigInt!
  190. #
  191. # "Amount that couldn't be paid due to insufficient council budget's balance."
  192. # unpaidAmount: BigInt!
  193. #}