Compare commits

..

1 Commits

Author SHA1 Message Date
b5e5aa838a
add support for operators 2025-02-13 22:44:20 +02:00
3 changed files with 10 additions and 5 deletions

@ -285,7 +285,7 @@ impl BrainData {
operator: &str, operator: &str,
uuid: &str, uuid: &str,
reason: &str, reason: &str,
) -> Result<(), Error> { ) -> Result<u64, Error> {
let contract = self.find_contract_by_uuid(uuid)?; let contract = self.find_contract_by_uuid(uuid)?;
let mut operator_data = self let mut operator_data = self
.operators .operators
@ -332,7 +332,7 @@ impl BrainData {
}) })
.await?; .await?;
Ok(()) Ok(refund_ammount)
} }
pub fn ban_user(&self, operator: &str, user: &str) { pub fn ban_user(&self, operator: &str, user: &str) {

@ -301,14 +301,14 @@ impl BrainCli for BrainCliMock {
} }
} }
async fn kick_contract(&self, req: Request<KickReq>) -> Result<Response<Empty>, Status> { async fn kick_contract(&self, req: Request<KickReq>) -> Result<Response<KickResp>, Status> {
let req = check_sig_from_req(req)?; let req = check_sig_from_req(req)?;
match self match self
.data .data
.kick_contract(&req.operator_wallet, &req.contract_uuid, &req.reason) .kick_contract(&req.operator_wallet, &req.contract_uuid, &req.reason)
.await .await
{ {
Ok(()) => Ok(Response::new(Empty {})), Ok(nano_lp) => Ok(Response::new(KickResp { nano_lp })),
Err(e) => Err(Status::permission_denied(e.to_string())), Err(e) => Err(Status::permission_denied(e.to_string())),
} }
} }

@ -244,6 +244,11 @@ message BanUserReq {
string user_wallet = 2; string user_wallet = 2;
} }
message KickResp {
uint64 nano_lp = 1;
}
service BrainCli { service BrainCli {
rpc GetBalance (Pubkey) returns (AccountBalance); rpc GetBalance (Pubkey) returns (AccountBalance);
rpc NewVm (NewVmReq) returns (NewVmResp); rpc NewVm (NewVmReq) returns (NewVmResp);
@ -257,7 +262,7 @@ service BrainCli {
rpc ListOperators (Empty) returns (stream ListOperatorsResp); rpc ListOperators (Empty) returns (stream ListOperatorsResp);
rpc InspectOperator (Pubkey) returns (InspectOperatorResp); rpc InspectOperator (Pubkey) returns (InspectOperatorResp);
rpc RegisterOperator (RegOperatorReq) returns (Empty); rpc RegisterOperator (RegOperatorReq) returns (Empty);
rpc KickContract (KickReq) returns (Empty); rpc KickContract (KickReq) returns (KickResp);
rpc BanUser (BanUserReq) returns (Empty); rpc BanUser (BanUserReq) returns (Empty);
// admin commands // admin commands
rpc Airdrop (AirdropReq) returns (Empty); rpc Airdrop (AirdropReq) returns (Empty);