Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge Katana dev branch #1470

Merged
merged 3 commits into from
Jan 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
145 changes: 142 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ members = [
"crates/katana/core",
"crates/katana/executor",
"crates/katana/primitives",
"crates/katana/rpc",
"crates/katana/rpc/rpc",
"crates/katana/rpc/rpc-api",
"crates/katana/rpc/rpc-types",
"crates/katana/rpc/rpc-types-builder",
"crates/katana/runner",
Expand Down Expand Up @@ -89,6 +90,7 @@ futures = "0.3.28"
hex = "0.4.3"
indoc = "1.0.7"
itertools = "0.10.3"
jsonrpsee = { version = "0.16.2", default-features = false }
lazy_static = "1.4.0"
metrics-process = "1.0.9"
num-bigint = "0.4"
Expand Down
3 changes: 2 additions & 1 deletion crates/dojo-test-utils/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ dojo-world = { path = "../dojo-world", features = [ "manifest", "migration" ] }
jsonrpsee = { version = "0.16.2", features = [ "server" ] }
katana-core = { path = "../katana/core" }
katana-primitives = { path = "../katana/primitives" }
katana-rpc = { path = "../katana/rpc" }
katana-rpc = { path = "../katana/rpc/rpc" }
katana-rpc-api = { path = "../katana/rpc/rpc-api" }
scarb-ui.workspace = true
scarb.workspace = true
serde.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion crates/dojo-test-utils/src/sequencer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ pub use katana_core::backend::config::{Environment, StarknetConfig};
use katana_core::sequencer::KatanaSequencer;
pub use katana_core::sequencer::SequencerConfig;
use katana_primitives::chain::ChainId;
use katana_rpc::api::ApiKind;
use katana_rpc::config::ServerConfig;
use katana_rpc::{spawn, NodeHandle};
use katana_rpc_api::ApiKind;
use starknet::accounts::{ExecutionEncoding, SingleOwnerAccount};
use starknet::core::chain_id;
use starknet::core::types::FieldElement;
Expand Down
3 changes: 2 additions & 1 deletion crates/katana/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ clap_complete.workspace = true
console.workspace = true
katana-core = { path = "core" }
katana-primitives = { path = "primitives" }
katana-rpc = { path = "rpc" }
katana-rpc = { path = "rpc/rpc" }
katana-rpc-api = { path = "rpc/rpc-api" }
metrics = { path = "../metrics" }
metrics-process.workspace = true
serde_json.workspace = true
Expand Down
4 changes: 2 additions & 2 deletions crates/katana/core/src/accounts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use katana_primitives::FieldElement;
use katana_provider::traits::state::StateWriter;
use rand::rngs::SmallRng;
use rand::{RngCore, SeedableRng};
use serde::Serialize;
use serde::{Deserialize, Serialize};
use serde_with::serde_as;
use starknet::core::serde::unsigned_field_element::UfeHex;
use starknet::core::utils::{get_contract_address, get_storage_var_address};
Expand All @@ -15,7 +15,7 @@ use starknet::signers::SigningKey;
use crate::constants::{FEE_TOKEN_ADDRESS, OZ_V1_ACCOUNT_CONTRACT_CLASS_HASH};

#[serde_as]
#[derive(Debug, Clone, Serialize)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Account {
#[serde_as(as = "UfeHex")]
pub balance: FieldElement,
Expand Down
9 changes: 5 additions & 4 deletions crates/katana/core/src/sequencer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -267,8 +267,9 @@ impl KatanaSequencer {
self.backend.chain_id
}

pub fn block_number(&self) -> BlockNumber {
BlockNumberProvider::latest_number(&self.backend.blockchain.provider()).unwrap()
pub fn block_number(&self) -> SequencerResult<BlockNumber> {
let num = BlockNumberProvider::latest_number(&self.backend.blockchain.provider())?;
Ok(num)
}

pub fn block_tx_count(&self, block_id: BlockIdOrTag) -> SequencerResult<Option<u64>> {
Expand Down Expand Up @@ -300,7 +301,7 @@ impl KatanaSequencer {
Ok(count)
}

pub async fn nonce_at(
pub fn nonce_at(
&self,
block_id: BlockIdOrTag,
contract_address: ContractAddress,
Expand Down Expand Up @@ -352,7 +353,7 @@ impl KatanaSequencer {
Ok(tx)
}

pub async fn events(
pub fn events(
&self,
from_block: BlockIdOrTag,
to_block: BlockIdOrTag,
Expand Down
18 changes: 18 additions & 0 deletions crates/katana/rpc/rpc-api/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[package]
description = "Katana RPC APIs"
edition.workspace = true
name = "katana-rpc-api"
version.workspace = true

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
katana-core = { path = "../../core" }
katana-primitives = { path = "../../primitives" }
katana-rpc-types = { path = "../rpc-types" }

jsonrpsee = { workspace = true, features = [ "macros", "server" ] }
starknet.workspace = true

[features]
client = [ "jsonrpsee/client" ]
Loading
Loading