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
/*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/public_scratchpad",
request_body(
content = Scratchpad
),
responses(
(status = CREATED, description = "Public 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_public_scratchpad(
scratchpad_service: Data<ScratchpadService>,
evm_wallet_data: Data<Wallet>,
scratchpad: web::Json<Scratchpad>,
request: HttpRequest,
) -> Result<HttpResponse, ScratchpadError> {
debug!("Creating new public scratchpad");
Ok(HttpResponse::Ok().json(
scratchpad_service.create_scratchpad(
scratchpad.into_inner(),
evm_wallet_data.get_ref().clone(),
false,
get_store_type(&request)
).await?
))
}
#[utoipa::path(
put,
path = "/anttp-0/public_scratchpad/{address}/{name}",
request_body(
content = Scratchpad
),
responses(
(status = OK, description = "Public scratchpad updated successfully", body = Scratchpad)
),
params(
("address" = String, Path, description = "Public scratchpad address"),
("name" = String, Path, description = "Public scratchpad name"),
("x-store-type", Header, description = "Only persist to cache and do not publish (memory|disk|none)",
example = "memory"),
),
)]
pub async fn put_public_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 public scratchpad");
Ok(HttpResponse::Ok().json(
scratchpad_service.update_scratchpad(
address,
name,
scratchpad.into_inner(),
evm_wallet_data.get_ref().clone(),
false,
get_store_type(&request)
).await?
))
}
#[utoipa::path(
get,
path = "/anttp-0/public_scratchpad/{address}",
responses(
(status = OK, description = "Public scratchpad found successfully", body = Scratchpad),
(status = NOT_FOUND, description = "Public scratchpad was not found")
),
params(
("address" = String, Path, description = "Public scratchpad address"),
)
)]
pub async fn get_public_scratchpad(
path: web::Path<String>,
scratchpad_service: Data<ScratchpadService>,
) -> Result<HttpResponse, ScratchpadError> {
let address = path.into_inner();
debug!("Getting public scratchpad at [{}]", address);
Ok(HttpResponse::Ok().json(scratchpad_service.get_scratchpad(address, None, false).await?))
}*/