|
@@ -1,39 +1,12 @@
|
|
|
import { getTypeRegistry, bool, u16, u32, u64, Text, Option, Vec as Vector} from '@polkadot/types';
|
|
|
-import { AccountId, Moment, BlockNumber } from '@polkadot/types/interfaces';
|
|
|
+import { AccountId } from '@polkadot/types/interfaces';
|
|
|
import { GenericAccountId } from '@polkadot/types';
|
|
|
+import { BlockAndTime } from './media';
|
|
|
|
|
|
import { JoyStruct } from './JoyStruct';
|
|
|
|
|
|
-// Based on copypasta from joy-media/BlockAndTimeType
|
|
|
-export type BlockchainTimestampType = {
|
|
|
- block: BlockNumber,
|
|
|
- time: Moment
|
|
|
-};
|
|
|
-
|
|
|
-// Based on copypasta from joy-media/BlockAndTime
|
|
|
-export class BlockchainTimestamp extends JoyStruct<BlockchainTimestampType> {
|
|
|
- constructor (value?: BlockchainTimestampType) {
|
|
|
- super({
|
|
|
- block: u32, // BlockNumber
|
|
|
- time: u64, // Moment
|
|
|
- }, value);
|
|
|
- }
|
|
|
-
|
|
|
- get block (): BlockNumber {
|
|
|
- return this.getField('block');
|
|
|
- }
|
|
|
-
|
|
|
- get time (): Moment {
|
|
|
- return this.getField('time');
|
|
|
- }
|
|
|
-
|
|
|
- static newEmpty (): BlockchainTimestamp {
|
|
|
- return new BlockchainTimestamp({} as BlockchainTimestampType);
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
export type ModerationActionType = {
|
|
|
- moderated_at: BlockchainTimestamp,
|
|
|
+ moderated_at: BlockAndTime,
|
|
|
moderator_id: AccountId,
|
|
|
rationale: Text
|
|
|
};
|
|
@@ -41,13 +14,13 @@ export type ModerationActionType = {
|
|
|
export class ModerationAction extends JoyStruct<ModerationActionType> {
|
|
|
constructor (value: ModerationActionType) {
|
|
|
super({
|
|
|
- moderated_at: BlockchainTimestamp,
|
|
|
+ moderated_at: BlockAndTime,
|
|
|
moderator_id: GenericAccountId,
|
|
|
rationale: Text
|
|
|
}, value);
|
|
|
}
|
|
|
|
|
|
- get moderated_at (): BlockchainTimestamp {
|
|
|
+ get moderated_at (): BlockAndTime {
|
|
|
return this.getField('moderated_at');
|
|
|
}
|
|
|
|
|
@@ -61,19 +34,19 @@ export class ModerationAction extends JoyStruct<ModerationActionType> {
|
|
|
}
|
|
|
|
|
|
export type PostTextChangeType = {
|
|
|
- expired_at: BlockchainTimestamp,
|
|
|
+ expired_at: BlockAndTime,
|
|
|
text: Text
|
|
|
};
|
|
|
|
|
|
export class PostTextChange extends JoyStruct<PostTextChangeType> {
|
|
|
constructor (value: PostTextChangeType) {
|
|
|
super({
|
|
|
- expired_at: BlockchainTimestamp,
|
|
|
+ expired_at: BlockAndTime,
|
|
|
text: Text
|
|
|
}, value);
|
|
|
}
|
|
|
|
|
|
- get expired_at (): BlockchainTimestamp {
|
|
|
+ get expired_at (): BlockAndTime {
|
|
|
return this.getField('expired_at');
|
|
|
}
|
|
|
|
|
@@ -154,7 +127,7 @@ export type CategoryType = {
|
|
|
id: CategoryId,
|
|
|
title: Text,
|
|
|
description: Text,
|
|
|
- created_at: BlockchainTimestamp,
|
|
|
+ created_at: BlockAndTime,
|
|
|
deleted: bool,
|
|
|
archived: bool,
|
|
|
num_direct_subcategories: u32,
|
|
@@ -170,7 +143,7 @@ export class Category extends JoyStruct<CategoryType> {
|
|
|
id: CategoryId,
|
|
|
title: Text,
|
|
|
description: Text,
|
|
|
- created_at: BlockchainTimestamp,
|
|
|
+ created_at: BlockAndTime,
|
|
|
deleted: bool,
|
|
|
archived: bool,
|
|
|
num_direct_subcategories: u32,
|
|
@@ -197,7 +170,7 @@ export class Category extends JoyStruct<CategoryType> {
|
|
|
return this.getString('description');
|
|
|
}
|
|
|
|
|
|
- get created_at (): BlockchainTimestamp {
|
|
|
+ get created_at (): BlockAndTime {
|
|
|
return this.getField('created_at');
|
|
|
}
|
|
|
|
|
@@ -264,7 +237,7 @@ export type ThreadType = {
|
|
|
moderation: OptionModerationAction,
|
|
|
num_unmoderated_posts: u32,
|
|
|
num_moderated_posts: u32,
|
|
|
- created_at: BlockchainTimestamp,
|
|
|
+ created_at: BlockAndTime,
|
|
|
author_id: AccountId
|
|
|
};
|
|
|
|
|
@@ -278,7 +251,7 @@ export class Thread extends JoyStruct<ThreadType> {
|
|
|
moderation: OptionModerationAction,
|
|
|
num_unmoderated_posts: u32,
|
|
|
num_moderated_posts: u32,
|
|
|
- created_at: BlockchainTimestamp,
|
|
|
+ created_at: BlockAndTime,
|
|
|
author_id: GenericAccountId
|
|
|
}, value);
|
|
|
}
|
|
@@ -323,7 +296,7 @@ export class Thread extends JoyStruct<ThreadType> {
|
|
|
return new u32(this.num_unmoderated_posts.add(this.num_moderated_posts));
|
|
|
}
|
|
|
|
|
|
- get created_at (): BlockchainTimestamp {
|
|
|
+ get created_at (): BlockAndTime {
|
|
|
return this.getField('created_at');
|
|
|
}
|
|
|
|
|
@@ -339,7 +312,7 @@ export type PostType = {
|
|
|
current_text: Text,
|
|
|
moderation: OptionModerationAction,
|
|
|
text_change_history: VecPostTextChange,
|
|
|
- created_at: BlockchainTimestamp,
|
|
|
+ created_at: BlockAndTime,
|
|
|
author_id: AccountId
|
|
|
};
|
|
|
|
|
@@ -353,7 +326,7 @@ export class Post extends JoyStruct<PostType> {
|
|
|
current_text: Text,
|
|
|
moderation: OptionModerationAction,
|
|
|
text_change_history: VecPostTextChange,
|
|
|
- created_at: BlockchainTimestamp,
|
|
|
+ created_at: BlockAndTime,
|
|
|
author_id: GenericAccountId
|
|
|
}, value);
|
|
|
}
|
|
@@ -390,7 +363,7 @@ export class Post extends JoyStruct<PostType> {
|
|
|
return this.getField('text_change_history');
|
|
|
}
|
|
|
|
|
|
- get created_at (): BlockchainTimestamp {
|
|
|
+ get created_at (): BlockAndTime {
|
|
|
return this.getField('created_at');
|
|
|
}
|
|
|
|
|
@@ -441,7 +414,6 @@ export class Reply extends JoyStruct<ReplyType> {
|
|
|
export function registerForumTypes () {
|
|
|
try {
|
|
|
getTypeRegistry().register({
|
|
|
- BlockchainTimestamp,
|
|
|
PostTextChange,
|
|
|
ModerationAction,
|
|
|
InputValidationLengthConstraint,
|