From 7c74e5d45278945f81c0dcfaadb3d8dbd40ea3f2 Mon Sep 17 00:00:00 2001 From: Ngalim Siregar Date: Sun, 31 Mar 2024 21:10:26 +0700 Subject: [PATCH] Update ChainId inner representation to Felt --- src/core.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/core.rs b/src/core.rs index f914d7eb..6fe1a457 100644 --- a/src/core.rs +++ b/src/core.rs @@ -9,6 +9,7 @@ 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}; @@ -18,11 +19,11 @@ use crate::{impl_from_through_intermediate, 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)) + format!("0x{}", hex::encode(&self.0.to_string())) } }