Skip to content

Commit

Permalink
Update ChainId inner representation to Felt
Browse files Browse the repository at this point in the history
  • Loading branch information
nsiregar committed Mar 31, 2024
1 parent b85bf99 commit 9bd6ea8
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,21 @@ use once_cell::sync::Lazy;
use primitive_types::H160;
use serde::{Deserialize, Serialize};
use starknet_crypto::FieldElement;
use starknet_types_core::felt::Felt;

use crate::crypto::PublicKey;
use crate::hash::{pedersen_hash_array, PoseidonHash, StarkFelt, StarkHash};
use crate::serde_utils::{BytesAsHex, PrefixedBytesAsHex};
use crate::transaction::{Calldata, ContractAddressSalt};
use crate::{impl_from_through_intermediate, StarknetApiError};
use crate::{impl_from_through_intermediate, stark_felt, StarknetApiError};

/// A chain id.
#[derive(Clone, Debug, Display, Eq, PartialEq, Hash, Deserialize, Serialize, PartialOrd, Ord)]
pub struct ChainId(pub String);
pub struct ChainId(pub Felt);

impl ChainId {
pub fn as_hex(&self) -> String {
format!("0x{}", hex::encode(&self.0))
pub fn as_hex(&self) -> Felt {
stark_felt!(format!("0x{}", hex::encode(&self.0)))
}
}

Expand Down

0 comments on commit 9bd6ea8

Please sign in to comment.