1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
/*use actix_web::{web, HttpRequest, HttpResponse};
use actix_web::web::Data;
use ant_core::data::Wallet;
use log::debug;
use crate::error::scratchpad_error::ScratchpadError;
use crate::controller::get_store_type;
use crate::service::scratchpad_service::{Scratchpad, ScratchpadService};
#[utoipa::path(
post,
path = "/anttp-0/private_scratchpad",
request_body(
content = Scratchpad
),
responses(
(status = CREATED, description = "Private scratchpad created successfully", body = Scratchpad)
),
params(
("x-store-type", Header, description = "Only persist to cache and do not publish (memory|disk|none)",
example = "memory"),
),
)]
pub async fn post_private_scratchpad(
scratchpad_service: Data<ScratchpadService>,
evm_wallet_data: Data<Wallet>,
scratchpad: web::Json<Scratchpad>,
request: HttpRequest,
) -> Result<HttpResponse, ScratchpadError> {
debug!("Creating new private scratchpad");
Ok(HttpResponse::Ok().json(
scratchpad_service.create_scratchpad(
scratchpad.into_inner(),
evm_wallet_data.get_ref().clone(),
true,
get_store_type(&request)
).await?
))
}
#[utoipa::path(
put,
path = "/anttp-0/private_scratchpad/{address}/{name}",
request_body(
content = Scratchpad
),
responses(
(status = OK, description = "Private scratchpad updated successfully", body = Scratchpad)
),
params(
("address" = String, Path, description = "Private scratchpad address"),
("name" = String, Path, description = "Private scratchpad name"),
("x-store-type", Header, description = "Only persist to cache and do not publish (memory|disk|none)",
example = "memory"),
),
)]
pub async fn put_private_scratchpad(
path: web::Path<(String, String)>,
scratchpad_service: Data<ScratchpadService>,
evm_wallet_data: Data<Wallet>,
scratchpad: web::Json<Scratchpad>,
request: HttpRequest,
) -> Result<HttpResponse, ScratchpadError> {
let (address, name) = path.into_inner();
debug!("Updating private scratchpad");
Ok(HttpResponse::Ok().json(
scratchpad_service.update_scratchpad(
address,
name,
scratchpad.into_inner(),
evm_wallet_data.get_ref().clone(),
true,
get_store_type(&request)
).await?
))
}
#[utoipa::path(
get,
path = "/anttp-0/private_scratchpad/{address}/{name}",
responses(
(status = OK, description = "Private scratchpad found successfully", body = Scratchpad),
(status = NOT_FOUND, description = "Private scratchpad was not found")
),
params(
("address" = String, Path, description = "Private scratchpad address"),
("name" = String, Path, description = "Private scratchpad name"),
)
)]
pub async fn get_private_scratchpad(
path: web::Path<(String, String)>,
scratchpad_service: Data<ScratchpadService>,
) -> Result<HttpResponse, ScratchpadError> {
let (address, name) = path.into_inner();
debug!("Getting private scratchpad at [{}] with name [{}]", address, name);
Ok(HttpResponse::Ok().json(scratchpad_service.get_scratchpad(address, Some(name), true).await?))
}*/