types.ts 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521
  1. import {GenericEventData} from "@polkadot/types/generic/Event";
  2. import { ApiPromise } from '@polkadot/api'
  3. import { MemberId } from '@joystream/types/members'
  4. import {
  5. ProposalParameters,
  6. ProposalStatus,
  7. VotingResults,
  8. } from '@joystream/types/proposals'
  9. import { AccountId, Nominations } from '@polkadot/types/interfaces'
  10. import { Option } from '@polkadot/types/codec'
  11. import { StorageKey } from '@polkadot/types/primitive'
  12. export class Statistics {
  13. councilRound: number = 0;
  14. councilMembers: number = 0;
  15. electionApplicants: number = 0;
  16. electionAvgApplicants: number = 0;
  17. perElectionApplicants: number = 0;
  18. electionApplicantsStakes: number = 0;
  19. electionVotes: number = 0;
  20. avgVotePerApplicant: number = 0;
  21. dateStart: string = "";
  22. dateEnd: string = "";
  23. startBlock: number = 0;
  24. endBlock: number = 0;
  25. percNewBlocks: number = 0;
  26. startMembers: number = 0;
  27. endMembers: number = 0;
  28. newMembers: number = 0;
  29. percNewMembers: number = 0;
  30. newBlocks: number = 0;
  31. avgBlockProduction: number = 0;
  32. startThreads: number = 0;
  33. endThreads: number = 0;
  34. newThreads: number = 0;
  35. totalThreads: number = 0;
  36. percNewThreads: number = 0;
  37. startPosts: number = 0;
  38. // endPosts: number = 0;
  39. newPosts: number = 0;
  40. endPosts: number = 0;
  41. percNewPosts: number = 0;
  42. startCategories: number = 0;
  43. endCategories: number = 0;
  44. newCategories: number = 0;
  45. perNewCategories: number = 0;
  46. newProposals: number = 0;
  47. newApprovedProposals: number = 0;
  48. startChannels: number = 0;
  49. newChannels: number = 0;
  50. endChannels: number = 0;
  51. percNewChannels: number = 0;
  52. startMedia: number = 0;
  53. newMedia: number = 0;
  54. endMedia: number = 0;
  55. percNewMedia: number = 0;
  56. deletedMedia: number = 0;
  57. newMints: number = 0;
  58. startMinted: number = 0;
  59. totalMinted: number = 0;
  60. percMinted: number = 0;
  61. endMinted: number = 0;
  62. totalMintCapacityIncrease: number = 0;
  63. startCouncilMinted: number = 0;
  64. endCouncilMinted: number = 0;
  65. newCouncilMinted: number = 0;
  66. percNewCouncilMinted: number = 0;
  67. startCuratorMinted: number = 0;
  68. endCuratorMinted: number = 0;
  69. newCuratorMinted: number = 0;
  70. percCuratorMinted: number = 0;
  71. startStorageMinted: number = 0;
  72. endStorageMinted: number = 0;
  73. newStorageMinted: number = 0;
  74. percStorageMinted: number = 0;
  75. startIssuance: number = 0;
  76. endIssuance: number = 0;
  77. newIssuance: number = 0;
  78. percNewIssuance: number = 0;
  79. newTokensBurn: number = 0;
  80. newValidatorRewards: number = 0;
  81. avgValidators: number = 0;
  82. startValidators: string = "";
  83. endValidators: string = "";
  84. percValidators: number = 0;
  85. startValidatorsStake: number = 0;
  86. endValidatorsStake: number = 0;
  87. percNewValidatorsStake: number = 0;
  88. startStorageProviders: number = 0;
  89. endStorageProviders: number = 0;
  90. percNewStorageProviders: number = 0;
  91. newStorageProviderReward: number = 0;
  92. startStorageProvidersStake: number = 0;
  93. endStorageProvidersStake: number = 0;
  94. percNewStorageProviderStake: number = 0;
  95. newCouncilRewards: number = 0;
  96. startCurators: number = 0;
  97. endCurators: number = 0;
  98. percNewCurators: number = 0;
  99. newCuratorRewards: number = 0;
  100. startUsedSpace: number = 0;
  101. newUsedSpace: number = 0;
  102. endUsedSpace: number = 0;
  103. percNewUsedSpace: number = 0;
  104. avgNewSizePerContent: number = 0;
  105. totalAvgSizePerContent: number = 0;
  106. percAvgSizePerContent: number = 0;
  107. newStakes: number = 0;
  108. totalNewStakeValue: number = 0;
  109. newTextProposals: number = 0;
  110. newRuntimeUpgradeProposal: number = 0;
  111. newSetElectionParametersProposal: number = 0;
  112. spendingProposalsTotal: number = 0;
  113. bountiesTotalPaid: number = 0;
  114. newSetLeadProposal: number = 0;
  115. newSetContentWorkingGroupMintCapacityProposal: number = 0;
  116. newEvictStorageProviderProposal: number = 0;
  117. newSetValidatorCountProposal: number = 0;
  118. newSetStorageRoleParametersProposal: number = 0;
  119. storageProviders: string;
  120. curators: string;
  121. constructor() {
  122. }
  123. }
  124. export class ValidatorReward {
  125. sharedReward: number = 0;
  126. remainingReward: number = 0;
  127. validators: number = 0;
  128. slotStake: number = 0;
  129. blockNumber: number = 0;
  130. }
  131. export class WorkersInfo {
  132. rewards: number = 0;
  133. startStake: number = 0;
  134. endStake: number = 0;
  135. startNrOfWorkers: number = 0;
  136. endNrOfWorkers: number = 0;
  137. }
  138. export class Exchange {
  139. sender: string = "";
  140. amount: number = 0;
  141. fees: number = 0;
  142. blockNumber: number = 0;
  143. }
  144. export enum ProposalTypes {
  145. Text = "Text",
  146. RuntimeUpgrade = "RuntimeUpgrade",
  147. SetElectionParameters = "SetElectionParameters",
  148. Spending = "Spending",
  149. SetLead = "SetLead",
  150. SetContentWorkingGroupMintCapacity = "SetContentWorkingGroupMintCapacity",
  151. EvictStorageProvider = "EvictStorageProvider",
  152. SetValidatorCount = "SetValidatorCount",
  153. SetStorageRoleParameters = "SetStorageRoleParameters",
  154. }
  155. export class SpendingProposals {
  156. constructor(public id: number, public spentAmount: number) {
  157. }
  158. }
  159. export class MintStatistics {
  160. startMinted: number;
  161. endMinted: number;
  162. diffMinted: number;
  163. percMinted: number;
  164. constructor(startMinted: number = 0, endMinted: number = 0, diffMinted: number = 0, percMinted: number = 0) {
  165. this.startMinted = startMinted;
  166. this.endMinted = endMinted;
  167. this.diffMinted = diffMinted;
  168. this.percMinted = percMinted;
  169. }
  170. }
  171. export class Media {
  172. constructor(public id: number, public title: string) {
  173. }
  174. }
  175. export class Channel {
  176. constructor(public id: number, public title: string) {
  177. }
  178. }
  179. export class Bounty {
  180. constructor(public proposalId: number, public title: string, public status: string, public amountAsked: number, public amountMinted: number) {
  181. }
  182. }
  183. export class CacheEvent {
  184. constructor(public section: string, public method: string, public data: GenericEventData) {
  185. }
  186. }
  187. export interface Api {
  188. query: any
  189. rpc: any
  190. derive: any
  191. }
  192. export interface Block {
  193. height: number
  194. blockHash: string
  195. }
  196. export interface Category {
  197. }
  198. export interface Member {
  199. }
  200. export interface Thread {
  201. }
  202. export interface Post {
  203. }
  204. export interface IState {
  205. //gethandle: (account: AccountId | string) => string;
  206. connecting: boolean
  207. now: number
  208. block: number
  209. blocks: Block[]
  210. nominators: string[]
  211. validators: string[]
  212. stashes: string[]
  213. loading: boolean
  214. councils: Seat[][]
  215. councilElection?: { stage: any; round: number; termEndsAt: number }
  216. channels: Channel[]
  217. categories: Category[]
  218. proposals: ProposalDetail[]
  219. posts: Post[]
  220. threads: Thread[]
  221. domain: string
  222. proposalCount: number
  223. proposalPosts: any[]
  224. handles: Handles
  225. members: Member[]
  226. tokenomics?: Tokenomics
  227. reports: { [key: string]: string }
  228. [key: string]: any
  229. stars: { [key: string]: boolean }
  230. stakes?: { [key: string]: Stakes }
  231. rewardPoints?: RewardPoints
  232. lastReward: number
  233. }
  234. export interface RewardPoints {
  235. total: number
  236. individual: { [account: string]: number }
  237. }
  238. export interface Stake {
  239. who: string
  240. value: number
  241. }
  242. export interface Stakes {
  243. total: number
  244. own: number
  245. others: Stake[]
  246. commission: number
  247. }
  248. export interface Seat {
  249. member: string
  250. handle?: string
  251. id?: number
  252. stake: number
  253. backers: Backer[]
  254. }
  255. export interface Backer {
  256. member: string
  257. stake: number
  258. }
  259. export interface CouncilType {
  260. round: number
  261. last: string
  262. }
  263. export interface CouncilModel {}
  264. export interface Options {
  265. verbose: number
  266. channel: boolean
  267. council: boolean
  268. forum: boolean
  269. proposals: boolean
  270. }
  271. export interface ProposalDetail {
  272. createdAt: number
  273. finalizedAt: number
  274. message: string
  275. parameters: string
  276. stage: any
  277. result: string
  278. exec: any
  279. id: number
  280. title: string
  281. description: any
  282. votes: VotingResults
  283. type: string
  284. votesByAccount?: Vote[]
  285. author?: string
  286. authorId: number
  287. }
  288. export interface Vote {
  289. vote: string
  290. handle: string
  291. }
  292. export type ProposalArray = number[]
  293. export interface ProposalPost {
  294. threadId: number
  295. text: string
  296. id: number
  297. }
  298. export interface Proposals {
  299. current: number
  300. last: number
  301. active: ProposalArray
  302. executing: ProposalArray
  303. }
  304. export interface ChannelType {
  305. id: number
  306. handle: string
  307. title: string
  308. description: string
  309. avatar: string
  310. banner: string
  311. content: string
  312. ownerId: number
  313. accountId: string
  314. publicationStatus: boolean
  315. curation: string
  316. createdAt: string
  317. principal: number
  318. }
  319. export interface CategoryType {
  320. id: number
  321. threadId: number
  322. title: string
  323. description: string
  324. createdAt: number
  325. deleted: boolean
  326. archived: boolean
  327. subcategories: number
  328. unmoderatedThreads: number
  329. moderatedThreads: number
  330. position: number
  331. moderatorId: string
  332. }
  333. export interface PostType {
  334. id: number
  335. text: string
  336. threadId: number
  337. authorId: string
  338. createdAt: { block: number; time: number }
  339. }
  340. export interface ThreadType {
  341. id: number
  342. title: string
  343. categoryId: number
  344. nrInCategory: number
  345. moderation: string
  346. createdAt: string
  347. authorId: string
  348. }
  349. export interface MemberType {
  350. account: string
  351. handle: string
  352. id: number
  353. registeredAt: number
  354. about: string
  355. addPost: any
  356. }
  357. export interface Header {
  358. number: number
  359. timestamp: number
  360. author: string
  361. }
  362. export interface Summary {
  363. blocks: Block[]
  364. validators: number[]
  365. nominators: number[]
  366. }
  367. export type NominatorsEntries = [StorageKey, Option<Nominations>][]
  368. export interface ProviderStatus {
  369. [propName: string]: boolean
  370. }
  371. export interface Handles {
  372. [key: string]: string
  373. }
  374. export interface Tokenomics {
  375. price: string
  376. totalIssuance: string
  377. validators: { total_stake: string }
  378. burns: Burn[]
  379. exchanges: Exchange[]
  380. extecutedBurnsAmount: number
  381. }
  382. export interface Burn {
  383. amount: number
  384. blockHeight: number
  385. date: string // "2020-09-21T11:07:54.000Z"
  386. logTime: string //"2020-09-21T11:08:54.091Z"
  387. }
  388. export interface Exchange {
  389. amount: number
  390. amountUSD: number
  391. blockHeight: number
  392. date: string // "2020-09-21T11:07:48.000Z"
  393. logTime: string // "2020-09-21T11:08:48.552Z"
  394. price: number // 0.000053676219442924057
  395. recipient: string //"5D5PhZQNJzcJXVBxwJxZcsutjKPqUPydrvpu6HeiBfMaeKQu"
  396. sender: string // "5DACzSg65taZ2NRktUtzBjhLZr8H5T8rwNoZUng9gQV6ayqT"
  397. senderMemo: string //"4Testing1337SendToBurnerAddressHopingItWorksOfc5D5PhZQNJzcJXVBxwJxZcsutjKPqUPydrvpu6HeiBfMaeKQu"
  398. status: string // FINALIZED | PENDING
  399. xmrAddress: string //"No address found"
  400. }
  401. export interface Event {
  402. text: string
  403. date: number
  404. category: {
  405. tag: string
  406. color: string
  407. }
  408. link: {
  409. url: string
  410. text: string
  411. }
  412. }
  413. export interface CalendarItem {
  414. id: number
  415. group: number
  416. title: string
  417. start_time: number
  418. end_time: number
  419. }
  420. export interface CalendarGroup {
  421. id: number
  422. title: string
  423. }
  424. export interface Status {
  425. block: number
  426. era: number
  427. round: number
  428. members: number
  429. channels: number
  430. categories: number
  431. threads: number
  432. posts: number
  433. proposals: number
  434. proposalPosts: number
  435. }