updated contract addrs and /current-chain endpoint for register FE

This commit is contained in:
dr-frmr 2024-01-10 18:39:59 -03:00
parent 497774161a
commit cf26769ba8
No known key found for this signature in database
7 changed files with 21 additions and 10 deletions

View File

@ -49,6 +49,7 @@ async fn serve_register_fe(
our_ip: String,
http_server_port: u16,
rpc_url: String,
testnet: bool,
) -> (Identity, Vec<u8>, Keyfile) {
// check if we have keys saved on disk, encrypted
// if so, prompt user for "password" to decrypt with
@ -69,7 +70,7 @@ async fn serve_register_fe(
let (tx, mut rx) = mpsc::channel::<(Identity, Keyfile, Vec<u8>)>(1);
let (our, decoded_keyfile, encoded_keyfile) = tokio::select! {
_ = register::register(tx, kill_rx, our_ip, http_server_port, rpc_url, disk_keyfile) => {
_ = register::register(tx, kill_rx, our_ip, http_server_port, rpc_url, disk_keyfile, testnet) => {
panic!("registration failed")
}
Some((our, decoded_keyfile, encoded_keyfile)) = rx.recv() => {
@ -224,6 +225,7 @@ async fn main() {
our_ip.to_string(),
http_server_port,
rpc_url.clone(),
*matches.get_one::<bool>("testnet").unwrap(), // true if testnet mode
)
.await;
#[cfg(feature = "simulation-mode")]
@ -238,6 +240,7 @@ async fn main() {
our_ip.to_string(),
http_server_port.clone(),
rpc_url.clone(),
*matches.get_one::<bool>("testnet").unwrap(), // true if testnet mode
)
.await
}

View File

@ -1,12 +1,12 @@
{
"files": {
"main.css": "/static/css/main.005a7f66.css",
"main.js": "/static/js/main.40ea1170.js",
"main.js": "/static/js/main.85e3d839.js",
"static/media/unknown.png": "/static/media/unknown.880d04d4611a45ab1001.png",
"index.html": "/index.html"
},
"entrypoints": [
"static/css/main.005a7f66.css",
"static/js/main.40ea1170.js"
"static/js/main.85e3d839.js"
]
}

File diff suppressed because one or more lines are too long

View File

@ -31,8 +31,8 @@ abigen!(
type RegistrationSender = mpsc::Sender<(Identity, Keyfile, Vec<u8>)>;
pub const NDNS_SEPOLIA_ADDRESS: &str = "0x6e22E7b9f5a99D5921c14A88Aaf954502aC17B90";
pub const NDNS_OPTIMISM_ADDRESS: &str = "0x4C8D8d4A71cE21B4A16dAbf4593cDF30d79728F1"; // TODO
pub const NDNS_SEPOLIA_ADDRESS: &str = "0xa11e3794e701565aD37f84DD364d581f5e9518c9";
pub const NDNS_OPTIMISM_ADDRESS: &str = "0x942A69Cc3dd5d9a87c35f13ebA444adc00934B0F";
pub fn _ip_to_number(ip: &str) -> Result<u32, &'static str> {
let octets: Vec<&str> = ip.split('.').collect();
@ -102,6 +102,7 @@ pub async fn register(
port: u16,
rpc_url: String,
keyfile: Option<Vec<u8>>,
testnet: bool,
) {
// Networking info is generated and passed to the UI, but not used until confirmed
let (public_key, serialized_networking_keypair) = keygen::generate_networking_key();
@ -153,7 +154,14 @@ pub async fn register(
.map(move || warp::reply::html(include_str!("register-ui/build/index.html"))))
.or(warp::path("set-password")
.and(warp::get())
.map(move || warp::reply::html(include_str!("register-ui/build/index.html"))));
.map(move || warp::reply::html(include_str!("register-ui/build/index.html"))))
.or(warp::path("current-chain").and(warp::get()).map(move || {
if testnet {
warp::reply::json(&"0xAA36A7")
} else {
warp::reply::json(&"0xA")
}
}));
let api = warp::path("info")
.and(

View File

@ -48,7 +48,7 @@ pub async fn terminal(
888
888
88888bo od88bo od8888b 8888888 8888bo 888d888
88888bo od88bo od8888b 88888888 8888bo 888d888
888 "88b d8P Y8b d88P" 888 "88b 888P"
888 888 88888888 888 888 .d888888 888
888 888 Y8b. Y88b. Y88b. 888 888 888