Skip to content

Commit

Permalink
fix(katana-node-bindings): use new Felt (#2146)
Browse files Browse the repository at this point in the history
  • Loading branch information
glihm authored Jul 6, 2024
1 parent 4d33374 commit 0ff19cc
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 16 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

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

1 change: 0 additions & 1 deletion crates/katana/node-bindings/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
description = "Utilities for working with the Katana binary"
edition.workspace = true
license-file.workspace = true
license.workspace = true
name = "katana-node-bindings"
repository.workspace = true
version.workspace = true
Expand Down
20 changes: 10 additions & 10 deletions crates/katana/node-bindings/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use std::process::{Child, Command};
use std::str::FromStr;
use std::time::{Duration, Instant};

use starknet::core::types::{FieldElement, FromStrError};
use starknet::core::types::{Felt, FromStrError};
use starknet::macros::short_string;
use starknet::signers::SigningKey;
use thiserror::Error;
Expand All @@ -29,7 +29,7 @@ const KATANA_STARTUP_TIMEOUT_MILLIS: u64 = 10_000;
#[derive(Debug, Clone)]
pub struct Account {
/// The account contract address
pub address: FieldElement,
pub address: Felt,
/// The private key, if any
pub private_key: Option<SigningKey>,
}
Expand All @@ -42,7 +42,7 @@ pub struct KatanaInstance {
port: u16,
child: Child,
accounts: Vec<Account>,
chain_id: FieldElement,
chain_id: Felt,
}

impl KatanaInstance {
Expand All @@ -62,7 +62,7 @@ impl KatanaInstance {
}

/// Returns the chain of the katana instance
pub fn chain_id(&self) -> FieldElement {
pub fn chain_id(&self) -> Felt {
self.chain_id
}

Expand Down Expand Up @@ -179,7 +179,7 @@ pub struct Katana {
disable_validate: bool,

// Environment options
chain_id: Option<FieldElement>,
chain_id: Option<Felt>,
validate_max_steps: Option<u64>,
invoke_max_steps: Option<u64>,
eth_gas_price: Option<u64>,
Expand Down Expand Up @@ -335,7 +335,7 @@ impl Katana {
}

/// Sets the chain ID.
pub const fn chain_id(mut self, id: FieldElement) -> Self {
pub const fn chain_id(mut self, id: Felt) -> Self {
self.chain_id = Some(id);
self
}
Expand Down Expand Up @@ -508,8 +508,8 @@ impl Katana {
port = addr.port();

for (address, info) in account_infos {
let address = FieldElement::from_str(&address)?;
let private_key = FieldElement::from_str(&info.private_key)?;
let address = Felt::from_str(&address)?;
let private_key = Felt::from_str(&info.private_key)?;
let key = SigningKey::from_secret_scalar(private_key);
accounts.push(Account { address, private_key: Some(key) });
}
Expand Down Expand Up @@ -547,7 +547,7 @@ impl Katana {
.ok_or(Error::MissingAccountAddress)?
.trim();

let address = FieldElement::from_str(hex)?;
let address = Felt::from_str(hex)?;
let account = Account { address, private_key: None };
current_account = Some(account);
}
Expand All @@ -566,7 +566,7 @@ impl Katana {
.ok_or(Error::MissingAccountPrivateKey)?
.trim();

let private_key = FieldElement::from_str(hex)?;
let private_key = Felt::from_str(hex)?;
let signing_key = SigningKey::from_secret_scalar(private_key);
accounts.push(Account { private_key: Some(signing_key), ..acc });
}
Expand Down
8 changes: 4 additions & 4 deletions crates/katana/runner/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use anyhow::{Context, Result};
use assert_fs::TempDir;
use katana_node_bindings::{Katana, KatanaInstance};
pub use runner_macro::{katana_test, runner};
use starknet::core::types::FieldElement;
use starknet::core::types::Felt;
use starknet::providers::jsonrpc::HttpTransport;
use starknet::providers::JsonRpcClient;
use tokio::sync::Mutex;
Expand All @@ -23,7 +23,7 @@ pub struct KatanaRunner {
instance: KatanaInstance,
provider: JsonRpcClient<HttpTransport>,
log_file_path: PathBuf,
contract: Mutex<Option<FieldElement>>,
contract: Mutex<Option<Felt>>,
}

/// Configuration for the KatanaRunner.
Expand Down Expand Up @@ -150,12 +150,12 @@ impl KatanaRunner {
// A contract needs to be deployed only once for each instance
// In proptest runner is static but deployment would happen for each test, unless it is
// persisted here.
pub async fn set_contract(&self, contract_address: FieldElement) {
pub async fn set_contract(&self, contract_address: Felt) {
let mut lock = self.contract.lock().await;
*lock = Some(contract_address);
}

pub async fn contract(&self) -> Option<FieldElement> {
pub async fn contract(&self) -> Option<Felt> {
*self.contract.lock().await
}
}
Expand Down

0 comments on commit 0ff19cc

Please sign in to comment.