@@ -3,27 +3,23 @@ module club::club {
3
3
use std::string::{utf8, String };
4
4
use std::type_name;
5
5
use std::vector;
6
- use sui::clock::{Clock , timestamp_ms};
7
6
use sui::coin::{Self , Coin };
8
7
use sui::event::emit;
9
8
use sui::object::{Self , UID , new, ID };
10
9
use sui::sui;
11
10
use sui::table::{Self , Table };
12
- use sui::table_vec::{Self , TableVec };
13
11
use sui::transfer::{share_object, public_transfer};
14
12
use sui::tx_context::{Self , TxContext , sender};
15
13
use sui::vec_set::{Self , VecSet , keys};
16
14
17
15
// errors
18
16
const ERR_NOT_AUTHORIZED : u64 = 1 ;
19
- const ERR_MESSAGE_NOT_FOUND : u64 = 2 ;
20
- const ERR_MESSAGE_DELETED : u64 = 3 ;
21
- const ERR_INVALID_CLUB_NAME : u64 = 4 ;
22
- const ERR_INVALID_CHANNEL_NAME : u64 = 5 ;
23
- const ERR_ADMIN_ALREADY_EXISTS : u64 = 6 ;
24
- const ERR_ADMIN_NOT_FOUND : u64 = 7 ;
25
- const ERR_CHANNEL_NOT_FOUND : u64 = 8 ;
26
- const ERR_INVALID_FEE : u64 = 9 ;
17
+ const ERR_INVALID_CLUB_NAME : u64 = 2 ;
18
+ const ERR_INVALID_CHANNEL_NAME : u64 = 3 ;
19
+ const ERR_ADMIN_ALREADY_EXISTS : u64 = 4 ;
20
+ const ERR_ADMIN_NOT_FOUND : u64 = 5 ;
21
+ const ERR_CHANNEL_NOT_FOUND : u64 = 6 ;
22
+ const ERR_INVALID_FEE : u64 = 7 ;
27
23
28
24
// constants
29
25
const VERSION : u64 = 0 ;
@@ -57,14 +53,6 @@ module club::club {
57
53
struct Channel has store {
58
54
name: String ,
59
55
deleted: bool ,
60
- messages: TableVec <Message >,
61
- }
62
-
63
- struct Message has copy , drop , store {
64
- sender: address ,
65
- content: vector <u8 >,
66
- timestamp: u64 ,
67
- deleted: bool ,
68
56
}
69
57
70
58
// ====== Events ======
@@ -139,7 +127,6 @@ module club::club {
139
127
let default_channel = Channel {
140
128
name: default_channel_name_str,
141
129
deleted: false ,
142
- messages: table_vec::empty (ctx),
143
130
};
144
131
let index = table::length (&club_global.clubs);
145
132
let type_name = type_name::into_string (type_name::get <T >());
@@ -274,7 +261,6 @@ module club::club {
274
261
let channel = Channel {
275
262
name: utf8 (name),
276
263
deleted: false ,
277
- messages: table_vec::empty (ctx),
278
264
};
279
265
vector ::push_back (&mut club.channels, channel);
280
266
}
@@ -303,42 +289,4 @@ module club::club {
303
289
let channel = vector ::borrow_mut (&mut club.channels, channel_index);
304
290
channel.name = utf8 (name);
305
291
}
306
-
307
- entry public fun new_message (
308
- clock: &Clock ,
309
- _club_global: &Global ,
310
- club: &mut Club ,
311
- channel_index: u64 ,
312
- content: vector <u8 >,
313
- ctx: &mut TxContext ,
314
- ) {
315
- assert !(channel_index < vector ::length (&club.channels), ERR_CHANNEL_NOT_FOUND );
316
- let channel = vector ::borrow_mut (&mut club.channels, channel_index);
317
- let sender = tx_context::sender (ctx);
318
- let message = Message {
319
- sender,
320
- content,
321
- timestamp: timestamp_ms (clock),
322
- deleted: false ,
323
- };
324
- table_vec::push_back (&mut channel.messages, message);
325
- }
326
-
327
- entry public fun delete_message (
328
- _club_global: &Global ,
329
- club: &mut Club ,
330
- channel_index: u64 ,
331
- message_index: u64 ,
332
- ctx: &mut TxContext ,
333
- ) {
334
- let sender = tx_context::sender (ctx);
335
- assert !(channel_index < vector ::length (&club.channels), ERR_CHANNEL_NOT_FOUND );
336
- let channel = vector ::borrow_mut (&mut club.channels, channel_index);
337
- assert !(message_index < table_vec::length (&channel.messages), ERR_MESSAGE_NOT_FOUND );
338
- let message = table_vec::borrow_mut (&mut channel.messages, message_index);
339
- assert !(message.sender == sender, ERR_NOT_AUTHORIZED );
340
- assert !(!message.deleted, ERR_MESSAGE_DELETED );
341
- message.content = vector ::empty ();
342
- message.deleted = true ;
343
- }
344
292
}
0 commit comments