mirror of
https://github.com/creating2morrow/neveko.git
synced 2025-01-03 17:39:55 +00:00
remove unused enum variant
This commit is contained in:
parent
43cc2ee744
commit
06cab5460e
11 changed files with 88 additions and 81 deletions
|
@ -374,12 +374,33 @@ impl Order {
|
||||||
pub fn to_db(o: &Order) -> String {
|
pub fn to_db(o: &Order) -> String {
|
||||||
format!(
|
format!(
|
||||||
"{}:{}:{}:{}:{}:{}:{}:{}:{}:{}:{}:{}:{}:{}:{}:{}:{}:{}:{}:{}:{}:{}:{}:{}:{}:{}:{}",
|
"{}:{}:{}:{}:{}:{}:{}:{}:{}:{}:{}:{}:{}:{}:{}:{}:{}:{}:{}:{}:{}:{}:{}:{}:{}:{}:{}",
|
||||||
o.cid, o.pid, o.cust_kex_1, o.cust_kex_2, o.cust_kex_3, o.cust_msig_make,
|
o.cid,
|
||||||
o.cust_msig_prepare, o.cust_msig_txset, o.date, o.deliver_date,
|
o.pid,
|
||||||
o.hash, o.mediator_msig_make, o.mediator_msig_prepare, o.mediator_kex_1,
|
o.cust_kex_1,
|
||||||
o.mediator_kex_2, o.mediator_kex_3, o.ship_date, o.subaddress, o.status,
|
o.cust_kex_2,
|
||||||
o.quantity, o.vend_kex_1, o.vend_kex_2, o.vend_kex_3, o.vend_msig_make,
|
o.cust_kex_3,
|
||||||
o.vend_msig_prepare, o.vend_msig_txset, o.xmr_address,
|
o.cust_msig_make,
|
||||||
|
o.cust_msig_prepare,
|
||||||
|
o.cust_msig_txset,
|
||||||
|
o.date,
|
||||||
|
o.deliver_date,
|
||||||
|
o.hash,
|
||||||
|
o.mediator_msig_make,
|
||||||
|
o.mediator_msig_prepare,
|
||||||
|
o.mediator_kex_1,
|
||||||
|
o.mediator_kex_2,
|
||||||
|
o.mediator_kex_3,
|
||||||
|
o.ship_date,
|
||||||
|
o.subaddress,
|
||||||
|
o.status,
|
||||||
|
o.quantity,
|
||||||
|
o.vend_kex_1,
|
||||||
|
o.vend_kex_2,
|
||||||
|
o.vend_kex_3,
|
||||||
|
o.vend_msig_make,
|
||||||
|
o.vend_msig_prepare,
|
||||||
|
o.vend_msig_txset,
|
||||||
|
o.xmr_address,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
pub fn from_db(k: String, v: String) -> Order {
|
pub fn from_db(k: String, v: String) -> Order {
|
||||||
|
@ -456,10 +477,7 @@ impl Order {
|
||||||
xmr_address,
|
xmr_address,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn update(
|
pub fn update(orid: String, o: Order) -> Order {
|
||||||
orid: String,
|
|
||||||
o: Order,
|
|
||||||
) -> Order {
|
|
||||||
Order {
|
Order {
|
||||||
orid,
|
orid,
|
||||||
cid: String::from(&o.cid),
|
cid: String::from(&o.cid),
|
||||||
|
|
|
@ -30,7 +30,6 @@ enum RpcFields {
|
||||||
CreateWallet,
|
CreateWallet,
|
||||||
ExchangeMultisigKeys,
|
ExchangeMultisigKeys,
|
||||||
Export,
|
Export,
|
||||||
Finalize,
|
|
||||||
GetTxProof,
|
GetTxProof,
|
||||||
GetTxById,
|
GetTxById,
|
||||||
GetVersion,
|
GetVersion,
|
||||||
|
@ -58,7 +57,6 @@ impl RpcFields {
|
||||||
RpcFields::CreateWallet => String::from("create_wallet"),
|
RpcFields::CreateWallet => String::from("create_wallet"),
|
||||||
RpcFields::ExchangeMultisigKeys => String::from("exchange_multisig_keys"),
|
RpcFields::ExchangeMultisigKeys => String::from("exchange_multisig_keys"),
|
||||||
RpcFields::Export => String::from("export_multisig_info"),
|
RpcFields::Export => String::from("export_multisig_info"),
|
||||||
RpcFields::Finalize => String::from("finalize_multisig"),
|
|
||||||
RpcFields::GetTxProof => String::from("get_tx_proof"),
|
RpcFields::GetTxProof => String::from("get_tx_proof"),
|
||||||
RpcFields::GetTxById => String::from("get_transfer_by_txid"),
|
RpcFields::GetTxById => String::from("get_transfer_by_txid"),
|
||||||
RpcFields::GetVersion => String::from("get_version"),
|
RpcFields::GetVersion => String::from("get_version"),
|
||||||
|
@ -400,10 +398,7 @@ pub async fn close_wallet(filename: String, password: String) -> bool {
|
||||||
info!("executing {}", RpcFields::Close.value());
|
info!("executing {}", RpcFields::Close.value());
|
||||||
let client = reqwest::Client::new();
|
let client = reqwest::Client::new();
|
||||||
let host = get_rpc_host();
|
let host = get_rpc_host();
|
||||||
let params = reqres::XmrRpcOpenWalletParams {
|
let params = reqres::XmrRpcOpenWalletParams { filename, password };
|
||||||
filename,
|
|
||||||
password,
|
|
||||||
};
|
|
||||||
let req = reqres::XmrRpcOpenRequest {
|
let req = reqres::XmrRpcOpenRequest {
|
||||||
jsonrpc: RpcFields::JsonRpcVersion.value(),
|
jsonrpc: RpcFields::JsonRpcVersion.value(),
|
||||||
id: RpcFields::Id.value(),
|
id: RpcFields::Id.value(),
|
||||||
|
|
|
@ -419,8 +419,8 @@ pub async fn start_up() {
|
||||||
// wait for rpc server for a bit
|
// wait for rpc server for a bit
|
||||||
tokio::time::sleep(std::time::Duration::new(5, 0)).await;
|
tokio::time::sleep(std::time::Duration::new(5, 0)).await;
|
||||||
monero::check_rpc_connection().await;
|
monero::check_rpc_connection().await;
|
||||||
let wallet_password = std::env::var(crate::MONERO_WALLET_PASSWORD)
|
let wallet_password =
|
||||||
.unwrap_or(String::from("password"));
|
std::env::var(crate::MONERO_WALLET_PASSWORD).unwrap_or(String::from("password"));
|
||||||
gen_app_wallet(&wallet_password).await;
|
gen_app_wallet(&wallet_password).await;
|
||||||
i2p::start().await;
|
i2p::start().await;
|
||||||
gen_app_gpg().await;
|
gen_app_gpg().await;
|
||||||
|
|
|
@ -1,11 +1,18 @@
|
||||||
use rocket::http::Status;
|
use rocket::{
|
||||||
use rocket::response::status::Custom;
|
get,
|
||||||
use rocket::serde::json::Json;
|
http::Status,
|
||||||
use rocket::{get, patch, post};
|
patch,
|
||||||
|
post,
|
||||||
|
response::status::Custom,
|
||||||
|
serde::json::Json,
|
||||||
|
};
|
||||||
|
|
||||||
use nevmes_core::*;
|
use nevmes_core::*;
|
||||||
|
|
||||||
use crate::{dispute, product};
|
use crate::{
|
||||||
|
dispute,
|
||||||
|
product,
|
||||||
|
};
|
||||||
|
|
||||||
// JSON APIs
|
// JSON APIs
|
||||||
|
|
||||||
|
@ -16,10 +23,7 @@ pub async fn create_product(
|
||||||
_token: auth::BearerToken,
|
_token: auth::BearerToken,
|
||||||
) -> Custom<Json<models::Product>> {
|
) -> Custom<Json<models::Product>> {
|
||||||
let m_product: models::Product = product::create(req_product);
|
let m_product: models::Product = product::create(req_product);
|
||||||
Custom(
|
Custom(Status::Ok, Json(m_product))
|
||||||
Status::Ok,
|
|
||||||
Json(m_product),
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Update product information
|
/// Update product information
|
||||||
|
@ -30,10 +34,7 @@ pub async fn update_product(
|
||||||
_token: auth::BearerToken,
|
_token: auth::BearerToken,
|
||||||
) -> Custom<Json<models::Product>> {
|
) -> Custom<Json<models::Product>> {
|
||||||
let m_product: models::Product = product::modify(product);
|
let m_product: models::Product = product::modify(product);
|
||||||
Custom(
|
Custom(Status::Ok, Json(m_product))
|
||||||
Status::Ok,
|
|
||||||
Json(m_product),
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// /// Initialize order
|
// /// Initialize order
|
||||||
|
@ -89,22 +90,13 @@ pub async fn create_dispute(
|
||||||
_token: auth::BearerToken,
|
_token: auth::BearerToken,
|
||||||
) -> Custom<Json<models::Dispute>> {
|
) -> Custom<Json<models::Dispute>> {
|
||||||
let m_dispute: models::Dispute = dispute::create(dispute);
|
let m_dispute: models::Dispute = dispute::create(dispute);
|
||||||
Custom(
|
Custom(Status::Ok, Json(m_dispute))
|
||||||
Status::Ok,
|
|
||||||
Json(m_dispute),
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Create a dispute
|
/// Create a dispute
|
||||||
#[get("/<did>")]
|
#[get("/<did>")]
|
||||||
pub async fn get_dispute(
|
pub async fn get_dispute(_token: auth::BearerToken, did: String) -> Custom<Json<models::Dispute>> {
|
||||||
_token: auth::BearerToken,
|
|
||||||
did: String,
|
|
||||||
) -> Custom<Json<models::Dispute>> {
|
|
||||||
let m_dispute: models::Dispute = dispute::find(&did);
|
let m_dispute: models::Dispute = dispute::find(&did);
|
||||||
Custom(
|
Custom(Status::Ok, Json(m_dispute))
|
||||||
Status::Ok,
|
|
||||||
Json(m_dispute),
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
// END JSON APIs
|
// END JSON APIs
|
||||||
|
|
|
@ -1,6 +1,14 @@
|
||||||
use nevmes_core::{db, models::*, utils};
|
use log::{
|
||||||
|
debug,
|
||||||
|
error,
|
||||||
|
info,
|
||||||
|
};
|
||||||
|
use nevmes_core::{
|
||||||
|
db,
|
||||||
|
models::*,
|
||||||
|
utils,
|
||||||
|
};
|
||||||
use rocket::serde::json::Json;
|
use rocket::serde::json::Json;
|
||||||
use log::{debug, error, info};
|
|
||||||
|
|
||||||
/// Create a new dispute
|
/// Create a new dispute
|
||||||
pub fn create(d: Json<Dispute>) -> Dispute {
|
pub fn create(d: Json<Dispute>) -> Dispute {
|
||||||
|
@ -25,7 +33,7 @@ pub fn find(did: &String) -> Dispute {
|
||||||
let r = db::Interface::read(&s.env, &s.handle, &String::from(did));
|
let r = db::Interface::read(&s.env, &s.handle, &String::from(did));
|
||||||
if r == utils::empty_string() {
|
if r == utils::empty_string() {
|
||||||
error!("dispute not found");
|
error!("dispute not found");
|
||||||
return Default::default()
|
return Default::default();
|
||||||
}
|
}
|
||||||
Dispute::from_db(String::from(did), r)
|
Dispute::from_db(String::from(did), r)
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,8 +15,14 @@ async fn rocket() -> _ {
|
||||||
env_logger::init();
|
env_logger::init();
|
||||||
log::info!("nevmes-auth is online");
|
log::info!("nevmes-auth is online");
|
||||||
rocket::custom(&config)
|
rocket::custom(&config)
|
||||||
.mount("/dispute", routes![controller::create_dispute, controller::get_dispute])
|
.mount(
|
||||||
|
"/dispute",
|
||||||
|
routes![controller::create_dispute, controller::get_dispute],
|
||||||
|
)
|
||||||
// .mount("/order", routes![controller::initialize_order, controller::update_order])
|
// .mount("/order", routes![controller::initialize_order, controller::update_order])
|
||||||
// .mount("/orders", routes![controller::get_orders])
|
// .mount("/orders", routes![controller::get_orders])
|
||||||
.mount("/product", routes![controller::create_product, controller::update_product])
|
.mount(
|
||||||
|
"/product",
|
||||||
|
routes![controller::create_product, controller::update_product],
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,6 @@
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
|
||||||
// /// Create a skeleton for order
|
// /// Create a skeleton for order
|
||||||
// pub fn create(cid: String, pid: String) -> models::Order {
|
// pub fn create(cid: String, pid: String) -> models::Order {
|
||||||
// let ts = chrono::offset::Utc::now().timestamp();
|
// let ts = chrono::offset::Utc::now().timestamp();
|
||||||
|
@ -78,7 +77,6 @@
|
||||||
// new_order
|
// new_order
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
|
||||||
// /// Lookup order
|
// /// Lookup order
|
||||||
// pub fn find(oid: String) -> models::Order {
|
// pub fn find(oid: String) -> models::Order {
|
||||||
// let s = db::Interface::open();
|
// let s = db::Interface::open();
|
||||||
|
|
|
@ -1,6 +1,14 @@
|
||||||
// Product repo/service layer
|
// Product repo/service layer
|
||||||
use nevmes_core::{db, models::*, utils};
|
use log::{
|
||||||
use log::{debug, error, info};
|
debug,
|
||||||
|
error,
|
||||||
|
info,
|
||||||
|
};
|
||||||
|
use nevmes_core::{
|
||||||
|
db,
|
||||||
|
models::*,
|
||||||
|
utils,
|
||||||
|
};
|
||||||
use rocket::serde::json::Json;
|
use rocket::serde::json::Json;
|
||||||
|
|
||||||
/// Create a new product
|
/// Create a new product
|
||||||
|
@ -26,7 +34,10 @@ pub fn create(d: Json<Product>) -> Product {
|
||||||
debug!("creating product index");
|
debug!("creating product index");
|
||||||
}
|
}
|
||||||
let product_list = [r, String::from(&pid)].join(",");
|
let product_list = [r, String::from(&pid)].join(",");
|
||||||
debug!("writing product index {} for id: {}", product_list, list_key);
|
debug!(
|
||||||
|
"writing product index {} for id: {}",
|
||||||
|
product_list, list_key
|
||||||
|
);
|
||||||
db::Interface::write(&s.env, &s.handle, &String::from(list_key), &product_list);
|
db::Interface::write(&s.env, &s.handle, &String::from(list_key), &product_list);
|
||||||
new_product
|
new_product
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,21 +21,6 @@ pub async fn get_version(_jwp: proof::PaymentProof) -> Custom<Json<reqres::XmrRp
|
||||||
Custom(Status::Ok, Json(monero::get_version().await))
|
Custom(Status::Ok, Json(monero::get_version().await))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[get("/test")]
|
|
||||||
pub async fn test() -> Custom<Json<models::User>> {
|
|
||||||
let mut v: Vec<String> = Vec::new();
|
|
||||||
v.push("t1".to_string());
|
|
||||||
v.push("t2".to_string());
|
|
||||||
v.push("t3".to_string());
|
|
||||||
let u: models::User = models::User {
|
|
||||||
uid: v.remove(0),
|
|
||||||
xmr_address: v.remove(0),
|
|
||||||
name: v.remove(0),
|
|
||||||
};
|
|
||||||
Custom(Status::Ok, Json(u))
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/// If i2p not in the state of rejecting tunnels this will return `open: true`
|
/// If i2p not in the state of rejecting tunnels this will return `open: true`
|
||||||
///
|
///
|
||||||
/// Protected: false
|
/// Protected: false
|
||||||
|
@ -97,12 +82,7 @@ pub async fn gen_jwp(proof: Json<proof::TxProof>) -> Custom<Json<reqres::Jwp>> {
|
||||||
///
|
///
|
||||||
/// Protected: true
|
/// Protected: true
|
||||||
#[get("/products")]
|
#[get("/products")]
|
||||||
pub async fn get_products(
|
pub async fn get_products(_jwp: proof::PaymentProof) -> Custom<Json<Vec<models::Product>>> {
|
||||||
_jwp: proof::PaymentProof,
|
|
||||||
) -> Custom<Json<Vec<models::Product>>> {
|
|
||||||
let m_products: Vec<models::Product> = product::find_all();
|
let m_products: Vec<models::Product> = product::find_all();
|
||||||
Custom(
|
Custom(Status::Ok, Json(m_products))
|
||||||
Status::Ok,
|
|
||||||
Json(m_products),
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,5 +59,4 @@ async fn rocket() -> _ {
|
||||||
.mount("/i2p", routes![controller::get_i2p_status])
|
.mount("/i2p", routes![controller::get_i2p_status])
|
||||||
.mount("/xmr/rpc", routes![controller::get_version])
|
.mount("/xmr/rpc", routes![controller::get_version])
|
||||||
.mount("/market", routes![controller::get_products])
|
.mount("/market", routes![controller::get_products])
|
||||||
.mount("/test", routes![controller::test])
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue