use serde::{Deserialize, Serialize};
pub type RoomKey = [u8; 32];
pub type RequestId = u64;
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum ChatDelegateRequestMsg {
StoreRequest {
key: ChatDelegateKey,
value: Vec<u8>,
},
GetRequest {
key: ChatDelegateKey,
},
DeleteRequest {
key: ChatDelegateKey,
},
ListRequest,
StoreSigningKey {
room_key: RoomKey,
signing_key_bytes: [u8; 32],
},
GetPublicKey {
room_key: RoomKey,
},
SignMessage {
room_key: RoomKey,
request_id: RequestId,
message_bytes: Vec<u8>,
},
SignMember {
room_key: RoomKey,
request_id: RequestId,
member_bytes: Vec<u8>,
},
SignBan {
room_key: RoomKey,
request_id: RequestId,
ban_bytes: Vec<u8>,
},
SignConfig {
room_key: RoomKey,
request_id: RequestId,
config_bytes: Vec<u8>,
},
SignMemberInfo {
room_key: RoomKey,
request_id: RequestId,
member_info_bytes: Vec<u8>,
},
SignSecretVersion {
room_key: RoomKey,
request_id: RequestId,
record_bytes: Vec<u8>,
},
SignEncryptedSecret {
room_key: RoomKey,
request_id: RequestId,
secret_bytes: Vec<u8>,
},
SignUpgrade {
room_key: RoomKey,
request_id: RequestId,
upgrade_bytes: Vec<u8>,
},
EnsureRoomSubscription {
room_owner_vk: RoomKey,
contract_id: [u8; 32],
},
}
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Hash)]
pub struct ChatDelegateKey(pub Vec<u8>);
impl ChatDelegateKey {
pub fn new(key: Vec<u8>) -> Self {
Self(key)
}
pub fn as_bytes(&self) -> &[u8] {
&self.0
}
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum ChatDelegateResponseMsg {
GetResponse {
key: ChatDelegateKey,
value: Option<Vec<u8>>,
},
ListResponse {
keys: Vec<ChatDelegateKey>,
},
StoreResponse {
key: ChatDelegateKey,
value_size: usize,
result: Result<(), String>,
},
DeleteResponse {
key: ChatDelegateKey,
result: Result<(), String>,
},
StoreSigningKeyResponse {
room_key: RoomKey,
result: Result<(), String>,
},
GetPublicKeyResponse {
room_key: RoomKey,
public_key: Option<[u8; 32]>,
},
SignResponse {
room_key: RoomKey,
request_id: RequestId,
signature: Result<Vec<u8>, String>,
},
EnsureRoomSubscriptionResponse {
room_owner_vk: RoomKey,
result: Result<(), String>,
},
}