members.ts 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. import { Option, Null, bool, u32, u64, u128, Text } from '@polkadot/types'
  2. import { BlockNumber, Moment } from '@polkadot/types/interfaces'
  3. import { GenericAccountId as AccountId } from '@polkadot/types/generic/AccountId'
  4. import { RegistryTypes } from '@polkadot/types/types'
  5. import { JoyEnum, JoyStructDecorated } from './common'
  6. export class MemberId extends u64 {}
  7. export class PaidTermId extends u64 {}
  8. export class SubscriptionId extends u64 {}
  9. export class ActorId extends u64 {}
  10. export class Paid extends PaidTermId {}
  11. export class Screening extends AccountId {}
  12. export class Genesis extends Null {}
  13. export class EntryMethod extends JoyEnum({
  14. Paid,
  15. Screening,
  16. Genesis,
  17. }) {}
  18. export type IMembership = {
  19. handle: Text
  20. avatar_uri: Text
  21. about: Text
  22. registered_at_block: BlockNumber
  23. registered_at_time: Moment
  24. entry: EntryMethod
  25. suspended: bool
  26. subscription: Option<SubscriptionId>
  27. root_account: AccountId
  28. controller_account: AccountId
  29. }
  30. export class Membership
  31. extends JoyStructDecorated({
  32. handle: Text,
  33. avatar_uri: Text,
  34. about: Text,
  35. registered_at_block: u32,
  36. registered_at_time: u64,
  37. entry: EntryMethod,
  38. suspended: bool,
  39. subscription: Option.with(SubscriptionId),
  40. root_account: AccountId,
  41. controller_account: AccountId,
  42. })
  43. implements IMembership {}
  44. export class PaidMembershipTerms extends JoyStructDecorated({
  45. fee: u128, // BalanceOf
  46. text: Text,
  47. }) {}
  48. export const membersTypes: RegistryTypes = {
  49. EntryMethod,
  50. MemberId,
  51. PaidTermId,
  52. SubscriptionId,
  53. Membership,
  54. PaidMembershipTerms,
  55. ActorId,
  56. }
  57. export default membersTypes