Skip to content

Commit

Permalink
Merge branch 'master' of github.com:calimero-network/core into chore-…
Browse files Browse the repository at this point in the history
…-run-only-rust-tests-affected-with-changed-files
  • Loading branch information
MatejVukosav committed Nov 6, 2024
2 parents 2c54305 + cd3a318 commit 3a1392f
Show file tree
Hide file tree
Showing 12 changed files with 47 additions and 16 deletions.
4 changes: 2 additions & 2 deletions crates/context/config/src/client/env/proxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ use mutate::ContextProxyMutate;
use query::ContextProxyQuery;

#[derive(Copy, Clone, Debug)]
pub enum ContextConfig {}
pub enum ContextProxy {}

impl<'a, T: 'a> Environment<'a, T> for ContextConfig {
impl<'a, T: 'a> Environment<'a, T> for ContextProxy {
type Query = ContextProxyQuery<'a, T>;
type Mutate = ContextProxyMutate<'a, T>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ impl Method<Starknet> for ProposalRequest {
todo!()
}

fn decode(response: Vec<u8>) -> eyre::Result<Self::Returns> {
fn decode(_response: Vec<u8>) -> eyre::Result<Self::Returns> {
todo!()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ impl Method<Starknet> for ProposalRequest {
todo!()
}

fn decode(response: Vec<u8>) -> eyre::Result<Self::Returns> {
fn decode(_response: Vec<u8>) -> eyre::Result<Self::Returns> {
todo!()
}
}
26 changes: 23 additions & 3 deletions crates/context/config/src/client/relayer.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use std::borrow::Cow;

use serde::{Deserialize, Serialize};
use thiserror::Error;
use url::Url;

use super::transport::{Operation, Transport, TransportRequest};
Expand Down Expand Up @@ -39,8 +40,22 @@ pub struct RelayRequest<'a> {
pub payload: Vec<u8>,
}

#[derive(Debug, Error)]
pub enum RelayerError {
#[error(transparent)]
Raw(#[from] reqwest::Error),
#[error(
"relayer response ({status}): {}",
body.is_empty().then_some("<empty>").unwrap_or(body)
)]
Response {
status: reqwest::StatusCode,
body: String,
},
}

impl Transport for RelayerTransport {
type Error = reqwest::Error;
type Error = RelayerError;

async fn send(
&self,
Expand All @@ -60,8 +75,13 @@ impl Transport for RelayerTransport {
.send()
.await?;

// todo! check response.status code
if !response.status().is_success() {
return Err(RelayerError::Response {
status: response.status(),
body: response.text().await?,
});
}

response.bytes().await.map(Into::into)
response.bytes().await.map(Into::into).map_err(Into::into)
}
}
1 change: 0 additions & 1 deletion crates/meroctl/src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ where

// return Ok(result);
// }
//

pub fn load_config(home: &Utf8Path, node_name: &str) -> EyreResult<ConfigFile> {
let path = home.join(node_name);
Expand Down
2 changes: 1 addition & 1 deletion crates/node/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ impl Node {
}
}

todo!()
Ok(())
}

async fn handle_state_delta(
Expand Down
1 change: 0 additions & 1 deletion crates/server-primitives/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,4 @@ pub mod ws;
#[derive(Clone, Copy, Debug, Deserialize, Serialize, ThisError)]
#[error("Infallible")]
#[expect(clippy::exhaustive_enums, reason = "This will never have any variants")]
//tests
pub enum Infallible {}

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion node-ui/build/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
})(window.location);
</script>
<!-- End Single Page Apps for GitHub Pages -->
<script type="module" crossorigin src="/admin-dashboard/assets/main-CEAaf8Ev.js"></script>
<script type="module" crossorigin src="/admin-dashboard/assets/main-Bzv535nm.js"></script>
<link rel="stylesheet" crossorigin href="/admin-dashboard/assets/main-BesWMiQO.css">
</head>
<body>
Expand Down
3 changes: 3 additions & 0 deletions node-ui/src/api/httpClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ export class AxiosHttpClient implements HttpClient {
this.axios.interceptors.response.use(
(response: AxiosResponse) => response,
(error: AxiosError) => {
if (error.response?.status === 401) {
window.location.href = '/admin-dashboard/';
}
if (!error.response) {
this.showServerDownPopup();
}
Expand Down
8 changes: 6 additions & 2 deletions node-ui/src/pages/setup/index.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
import React from 'react';
import React, { useEffect } from 'react';
import { useNavigate } from 'react-router-dom';
import { setAppEndpointKey } from '../../utils/storage';
import { clearStorage, setAppEndpointKey } from '../../utils/storage';
import ContentWrapper from '../../components/login/ContentWrapper';
import { SetupModal } from '../../components/setup/SetupModal';
import { getNodeUrl } from '../../utils/node';

export default function SetupPage() {
const navigate = useNavigate();

useEffect(() => {
clearStorage();
}, []);

return (
<ContentWrapper>
<SetupModal
Expand Down
6 changes: 6 additions & 0 deletions node-ui/src/utils/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ export interface ClientKey {
publicKey: string;
}

export const clearStorage = () => {
localStorage.removeItem(APP_URL);
localStorage.removeItem(AUTHORIZED);
localStorage.removeItem(CLIENT_KEY);
};

export const getAppEndpointKey = (): string | null => {
try {
if (typeof window !== 'undefined' && window.localStorage) {
Expand Down

0 comments on commit 3a1392f

Please sign in to comment.