council.graphql 7.9 KB

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