diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index b5c43ed0f82..d0e0dc6ea01 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -21,6 +21,7 @@ jobs: uses: dtolnay/rust-toolchain@stable with: toolchain: stable + components: rustfmt, clippy - name: Set up cargo cache uses: Swatinem/rust-cache@v2 @@ -31,7 +32,19 @@ jobs: - name: Run cargo build run: | cargo build - + + - name: Run cargo clippy + run: | + cargo clippy --all-targets --all-features --workspace -- -D warnings + + - name: Run cargo fmt + run: | + cargo fmt --all -- --check + + - name: Run cargo test + run: | + cargo test + docker-build: name: Build Docker image runs-on: ubuntu-latest diff --git a/crates/rpc/src/lib.rs b/crates/rpc/src/lib.rs index 07580dbe223..1935a1c0f52 100644 --- a/crates/rpc/src/lib.rs +++ b/crates/rpc/src/lib.rs @@ -79,15 +79,15 @@ where { match res { Ok(result) => Json( - serde_json::to_value(&RpcSuccessResponse { + serde_json::to_value(RpcSuccessResponse { id: req.id, jsonrpc: "2.0".to_string(), - result: result, + result, }) .unwrap(), ), Err(error) => Json( - serde_json::to_value(&RpcErrorResponse { + serde_json::to_value(RpcErrorResponse { id: req.id, jsonrpc: "2.0".to_string(), error: error.into(), diff --git a/crates/rpc/src/utils.rs b/crates/rpc/src/utils.rs index be9b56aed0e..8da4bfe4847 100644 --- a/crates/rpc/src/utils.rs +++ b/crates/rpc/src/utils.rs @@ -5,9 +5,9 @@ pub enum RpcErr { MethodNotFound, } -impl Into for RpcErr { - fn into(self) -> RpcErrorMetadata { - match self { +impl From for RpcErrorMetadata { + fn from(value: RpcErr) -> Self { + match value { RpcErr::MethodNotFound => RpcErrorMetadata { code: -32601, message: "Method not found".to_string(),