From 0fb25742b0ac4a933043c2981004fe76f7edb324 Mon Sep 17 00:00:00 2001 From: Arun Jangra Date: Wed, 19 Jun 2024 19:29:43 +0530 Subject: [PATCH] refactor : changed program_vec to program_bytes --- crates/client/rpc-core/src/lib.rs | 6 +++--- crates/client/rpc/src/lib.rs | 2 +- crates/client/rpc/src/types.rs | 22 ---------------------- 3 files changed, 4 insertions(+), 26 deletions(-) diff --git a/crates/client/rpc-core/src/lib.rs b/crates/client/rpc-core/src/lib.rs index 9b6c65d1d8..68126b3925 100644 --- a/crates/client/rpc-core/src/lib.rs +++ b/crates/client/rpc-core/src/lib.rs @@ -52,15 +52,15 @@ pub struct DeclareV0Result { /// /// **declare_transaction** : DeclareTransactionV0V1 struct constructed before calling. /// -/// **program_vec** : Program vector is program from `ClassInfo` struct converted into Vector. +/// **program_bytes** : Program bytes is program from `ClassInfo` struct converted into Vector. /// /// **entrypoints** : Entrypoints are taken from `ClassInfo` struct. /// /// **abi_length** : ABI length calculated from abi in `LegacyContractClass`. -#[derive(Serialize, Deserialize, Debug, Eq, PartialEq)] +#[derive(Serialize, Deserialize, Debug)] pub struct CustomDeclareV0Transaction { pub declare_transaction: DeclareTransactionV0V1, - pub program_vec: Vec, + pub program_bytes: Vec, pub entrypoints: IndexMap>, pub abi_length: usize, } diff --git a/crates/client/rpc/src/lib.rs b/crates/client/rpc/src/lib.rs index 159fc0d2e9..25ced03180 100644 --- a/crates/client/rpc/src/lib.rs +++ b/crates/client/rpc/src/lib.rs @@ -316,7 +316,7 @@ where async fn declare_v0_contract(&self, params: mc_rpc_core::CustomDeclareV0Transaction) -> RpcResult { let txn_hash: TransactionHash = self.get_txn_hash(params.declare_transaction.clone()); - let program_decoded = Program::decode_all(&mut params.program_vec.as_slice()).map_err(|e| { + let program_decoded = Program::decode_all(&mut params.program_bytes.as_slice()).map_err(|e| { log::debug!("error: {:?}", e); StarknetRpcApiError::InternalServerError })?; diff --git a/crates/client/rpc/src/types.rs b/crates/client/rpc/src/types.rs index c2fdde9162..c098eb4360 100644 --- a/crates/client/rpc/src/types.rs +++ b/crates/client/rpc/src/types.rs @@ -1,11 +1,7 @@ use std::num::ParseIntError; use std::{fmt, u64}; -use indexmap::IndexMap; use mp_felt::Felt252Wrapper; -use serde::{Deserialize, Serialize}; -use starknet_api::deprecated_contract_class::{EntryPoint, EntryPointType}; -use starknet_api::transaction::DeclareTransactionV0V1; use starknet_ff::FieldElement; pub struct RpcEventFilter { @@ -29,24 +25,6 @@ pub enum ParseTokenError { ParseFailed(ParseIntError), } -/// CustomDeclareV0Transaction -/// This will be given as an input to the rpc body -/// -/// **declare_transaction** : DeclareTransactionV0V1 struct constructed before calling. -/// -/// **program_vec** : Program vector is program from `ClassInfo` struct converted into Vector. -/// -/// **entrypoints** : Entrypoints are taken from `ClassInfo` struct. -/// -/// **abi_length** : ABI length calculated from abi in `LegacyContractClass`. -#[derive(Serialize, Deserialize, Debug, Eq, PartialEq)] -pub struct CustomDeclareV0Transaction { - pub declare_transaction: DeclareTransactionV0V1, - pub program_vec: Vec, - pub entrypoints: IndexMap>, - pub abi_length: usize, -} - impl fmt::Display for ContinuationToken { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "{:x},{:x}", self.block_n, self.event_n)